summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authoramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-07 18:00:13 +0000
committeramber <amber@54d463be-8e91-2dee-dedb-b68131a5f0ec>2005-04-07 18:00:13 +0000
commit1a348ede4934a1ba78f337ee1dffe11a699f4bef (patch)
tree883d4c1ae282fb67e1720f81c20f564499298ff4 /src/char
parent7cb0d361f1b4260b47ab1da99224332947320553 (diff)
parenta6cd6538e4271ea08dc86803e8b7e8c8f235960b (diff)
downloadhercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.tar.gz
hercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.tar.bz2
hercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.tar.xz
hercules-1a348ede4934a1ba78f337ee1dffe11a699f4bef.zip
branch for major stability breakage
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@1440 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/char')
-rw-r--r--src/char/GNUmakefile17
-rw-r--r--src/char/Makefile6
-rw-r--r--src/char/char.c529
-rw-r--r--src/char/char.h3
-rw-r--r--src/char/int_guild.c118
-rw-r--r--src/char/int_guild.h1
-rw-r--r--src/char/int_party.c148
-rw-r--r--src/char/int_party.h1
-rw-r--r--src/char/int_pet.c47
-rw-r--r--src/char/int_pet.h1
-rw-r--r--src/char/int_storage.c168
-rw-r--r--src/char/int_storage.h1
-rw-r--r--src/char/inter.c65
-rw-r--r--src/char/inter.h1
14 files changed, 677 insertions, 429 deletions
diff --git a/src/char/GNUmakefile b/src/char/GNUmakefile
deleted file mode 100644
index f3164e0ec..000000000
--- a/src/char/GNUmakefile
+++ /dev/null
@@ -1,17 +0,0 @@
-all: char-server
-txt: char-server
-
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h
-char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ)
- $(CC) -o ../../$@ $^
-
-char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h
-inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H)
-int_party.o: int_party.c int_party.h inter.h char.h $(COMMON_H)
-int_guild.o: int_guild.c int_guild.h int_storage.h inter.h char.h $(COMMON_H)
-int_storage.o: int_storage.c int_storage.h int_guild.h inter.h char.h $(COMMON_H)
-int_pet.o: int_pet.c int_pet.h inter.h char.h $(COMMON_H)
-
-clean:
- rm -f *.o ../../char-server
diff --git a/src/char/Makefile b/src/char/Makefile
index 0a2009333..aee0e69e2 100644
--- a/src/char/Makefile
+++ b/src/char/Makefile
@@ -1,10 +1,10 @@
all: char-server
txt: char-server
-COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/showmsg.o
-COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h
+COMMON_OBJ = ../common/obj/core.o ../common/obj/socket.o ../common/obj/timer.o ../common/obj/db.o ../common/obj/lock.o ../common/obj/malloc.o ../common/obj/showmsg.o ../common/obj/strlib.o
+COMMON_H = ../common/core.h ../common/socket.h ../common/timer.h ../common/mmo.h ../common/db.h ../common/lock.h ../common/timer.h ../common/malloc.h ../common/showmsg.h ../common/strlib.h
char-server: char.o inter.o int_party.o int_guild.o int_storage.o int_pet.o $(COMMON_OBJ)
- $(CC) -o ../../$@ $>
+ $(CC) -o ../../$@ $> $(LIB_S)
char.o: char.c char.h inter.h int_pet.h $(COMMON_H) ../common/version.h
inter.o: inter.c inter.h int_party.h int_guild.h int_storage.h int_pet.h char.h $(COMMON_H)
diff --git a/src/char/char.c b/src/char/char.c
index 7ad959bd8..73efbc864 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -2,29 +2,39 @@
// original : char2.c 2003/03/14 11:58:35 Rev.1.5
#include <sys/types.h>
-#include <sys/socket.h>
#include <stdio.h>
#include <stdlib.h>
+
+#ifdef _WIN32
+#include <winsock.h>
+typedef long in_addr_t;
+#else
+#include <sys/socket.h>
#include <netinet/in.h>
-#include <sys/time.h>
-#include <time.h>
+#include <arpa/inet.h>
+#include <netdb.h>
#include <sys/ioctl.h>
+#include <sys/time.h>
#include <unistd.h>
+#endif
+
+#include <time.h>
#include <signal.h>
#include <fcntl.h>
#include <string.h>
-#include <arpa/inet.h>
-#include <netdb.h>
#include <stdarg.h>
+#include "../common/strlib.h"
#include "core.h"
#include "socket.h"
#include "timer.h"
#include "mmo.h"
+#include "db.h"
#include "version.h"
#include "lock.h"
#include "char.h"
#include "showmsg.h"
+#include "buffer.h"
#include "inter.h"
#include "int_pet.h"
@@ -38,9 +48,6 @@
struct mmo_map_server server[MAX_MAP_SERVERS];
int server_fd[MAX_MAP_SERVERS];
-int server_freezeflag[MAX_MAP_SERVERS]; // Map-server anti-freeze system. Counter. 5 ok, 4...0 freezed
-int anti_freeze_enable = 0;
-int ANTI_FREEZE_INTERVAL = 6;
int login_fd, char_fd;
char userid[24];
@@ -49,11 +56,13 @@ char server_name[20];
char wisp_server_name[24] = "Server";
int login_ip_set_ = 0;
char login_ip_str[16];
-int login_ip;
+in_addr_t login_ip;
int login_port = 6900;
int char_ip_set_ = 0;
char char_ip_str[16];
-int char_ip;
+int bind_ip_set_ = 0;
+char bind_ip_str[16];
+in_addr_t char_ip;
int char_port = 6121;
int char_maintenance;
int char_new;
@@ -103,6 +112,7 @@ int char_id_count = 150000;
struct mmo_charstatus *char_dat;
int char_num, char_max;
int max_connect_user = 0;
+int gm_allow_level = 99;
int autosave_interval = DEFAULT_AUTOSAVE_INTERVAL;
int start_zeny = 500;
int start_weapon = 1201;
@@ -151,7 +161,7 @@ int char_log(char *fmt, ...) {
fprintf(logfp, RETCODE);
else {
gettimeofday(&tv, NULL);
- strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime(&(tv.tv_sec)));
+ strftime(tmpstr, 24, "%d-%m-%Y %H:%M:%S", localtime((const time_t*)&(tv.tv_sec)));
sprintf(tmpstr + 19, ".%03d: %s", (int)tv.tv_usec / 1000, fmt);
vfprintf(logfp, tmpstr, ap);
}
@@ -162,23 +172,6 @@ int char_log(char *fmt, ...) {
return 0;
}
-//-----------------------------------------------------
-// Function to suppress control characters in a string.
-//-----------------------------------------------------
-int remove_control_chars(unsigned char *str) {
- int i;
- int change = 0;
-
- for(i = 0; str[i]; i++) {
- if (str[i] < 32) {
- str[i] = '_';
- change = 1;
- }
- }
-
- return change;
-}
-
//----------------------------------------------------------------------
// Determine if an account (id) is a GM account
// and returns its level (or 0 if it isn't a GM account or if not found)
@@ -235,6 +228,25 @@ char * search_character_name(int index) {
return unknown_char_name;
}
+//-------------------------------------------------
+// Set Character online/offline [Wizputer]
+//-------------------------------------------------
+
+void set_char_online(int char_id, int account_id) {
+ if (login_fd <= 0 || session[login_fd]->eof)
+ return;
+ WFIFOW(login_fd,0) = 0x272b;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOSET(login_fd,6);
+}
+void set_char_offline(int char_id, int account_id) {
+ if (login_fd <= 0 || session[login_fd]->eof)
+ return;
+ WFIFOW(login_fd,0) = 0x272c;
+ WFIFOL(login_fd,2) = account_id;
+ WFIFOSET(login_fd,6);
+}
+
/*---------------------------------------------------
Make a data line for friends list
--------------------------------------------------*/
@@ -243,7 +255,7 @@ int mmo_friends_list_data_str(char *str, struct mmo_charstatus *p) {
int i;
char *str_p = str;
str_p += sprintf(str_p, "%d", p->char_id);
-
+
for (i=0;i<20;i++)
{
str_p += sprintf(str_p, ",%d,%s", p->friend_id[i],p->friend_name[i]);
@@ -267,9 +279,9 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p) {
str_p += sprintf(str_p, "%d\t%d,%d\t%s\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d"
"\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d"
- "\t%s,%d,%d\t%s,%d,%d,%d\t",
+ "\t%s,%d,%d\t%s,%d,%d,%d,%d,%d,%d\t",
p->char_id, p->account_id, p->char_num, p->name, //
- p->class, p->base_level, p->job_level,
+ p->class_, p->base_level, p->job_level,
p->base_exp, p->job_exp, p->zeny,
p->hp, p->max_hp, p->sp, p->max_sp,
p->str, p->agi, p->vit, p->int_, p->dex, p->luk,
@@ -280,7 +292,7 @@ int mmo_char_tostr(char *str, struct mmo_charstatus *p) {
p->weapon, p->shield, p->head_top, p->head_mid, p->head_bottom,
p->last_point.map, p->last_point.x, p->last_point.y, //
p->save_point.map, p->save_point.x, p->save_point.y,
- p->partner_id);
+ p->partner_id,p->father,p->mother,p->child);
for(i = 0; i < 10; i++)
if (p->memo_point[i].map[0]) {
str_p += sprintf(str_p, "%s,%d,%d", p->memo_point[i].map, p->memo_point[i].x, p->memo_point[i].y);
@@ -329,8 +341,28 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) {
// initilialise character
memset(p, '\0', sizeof(struct mmo_charstatus));
-
- // If it's not char structure of version 1008 and after
+
+ // If it's not char structure of version 1363 and after
+ if ((set = sscanf(str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d"
+ "\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d"
+ "\t%[^,],%d,%d\t%[^,],%d,%d,%d,%d,%d,%d%n",
+ &tmp_int[0], &tmp_int[1], &tmp_int[2], p->name, //
+ &tmp_int[3], &tmp_int[4], &tmp_int[5],
+ &tmp_int[6], &tmp_int[7], &tmp_int[8],
+ &tmp_int[9], &tmp_int[10], &tmp_int[11], &tmp_int[12],
+ &tmp_int[13], &tmp_int[14], &tmp_int[15], &tmp_int[16], &tmp_int[17], &tmp_int[18],
+ &tmp_int[19], &tmp_int[20],
+ &tmp_int[21], &tmp_int[22], &tmp_int[23], //
+ &tmp_int[24], &tmp_int[25], &tmp_int[26],
+ &tmp_int[27], &tmp_int[28], &tmp_int[29],
+ &tmp_int[30], &tmp_int[31], &tmp_int[32], &tmp_int[33], &tmp_int[34],
+ p->last_point.map, &tmp_int[35], &tmp_int[36], //
+ p->save_point.map, &tmp_int[37], &tmp_int[38], &tmp_int[39],
+ &tmp_int[40], &tmp_int[41], &tmp_int[42], &next)) != 46) {
+ tmp_int[40] = 0; // father
+ tmp_int[41] = 0; // mother
+ tmp_int[42] = 0; // child
+ // If it's not char structure of version 1008 and before 1363
if ((set = sscanf(str, "%d\t%d,%d\t%[^\t]\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d\t%d,%d,%d,%d,%d,%d\t%d,%d"
"\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d\t%d,%d,%d,%d,%d"
"\t%[^,],%d,%d\t%[^,],%d,%d,%d%n",
@@ -389,15 +421,20 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) {
}
// Char structure of version 1008+
} else {
+ set+=3;
//printf("char: new char data ver.3\n");
}
- if (set != 43)
+ // Char structture of version 1363+
+ } else {
+ //printf("char: new char data ver.4\n");
+ }
+ if (set != 46)
return 0;
p->char_id = tmp_int[0];
p->account_id = tmp_int[1];
p->char_num = tmp_int[2];
- p->class = tmp_int[3];
+ p->class_ = tmp_int[3];
p->base_level = tmp_int[4];
p->job_level = tmp_int[5];
p->base_exp = tmp_int[6];
@@ -434,6 +471,9 @@ int mmo_char_fromstr(char *str, struct mmo_charstatus *p) {
p->save_point.x = tmp_int[37];
p->save_point.y = tmp_int[38];
p->partner_id = tmp_int[39];
+ p->father = tmp_int[40];
+ p->mother = tmp_int[41];
+ p->child = tmp_int[42];
// Some checks
for(i = 0; i < char_num; i++) {
@@ -574,13 +614,16 @@ int parse_friend_txt(struct mmo_charstatus *p)
char line[1024];
int i,cid=0,temp[20];
FILE *fp;
-
+
// Open the file and look for the ID
fp = fopen(friends_txt, "r");
-
+
+ if(fp == NULL)
+ return 1;
+
while(fgets(line, sizeof(line)-1, fp)) {
-
+
if(line[0] == '/' && line[1] == '/')
continue;
@@ -608,7 +651,7 @@ int parse_friend_txt(struct mmo_charstatus *p)
if (cid == p->char_id)
break;
}
-
+
// No register of friends list
if (cid == 0) {
fclose(fp);
@@ -634,16 +677,11 @@ int mmo_char_init(void) {
FILE *fp;
char_max = 256;
- char_dat = calloc(sizeof(struct mmo_charstatus) * 256, 1);
+ char_dat = (struct mmo_charstatus*)aCalloc(sizeof(struct mmo_charstatus) * 256, 1);
if (!char_dat) {
printf("out of memory: mmo_char_init (calloc of char_dat).\n");
exit(1);
}
- online_chars = calloc(sizeof(struct online_chars) * 256, 1);
- if (!online_chars) {
- printf("out of memory: mmo_char_init (calloc of online_chars).\n");
- exit(1);
- }
for(i = 0; i < char_max; i++)
{
online_chars[i].char_id = -1;
@@ -679,13 +717,13 @@ int mmo_char_init(void) {
if (char_num >= char_max) {
char_max += 256;
- char_dat = realloc(char_dat, sizeof(struct mmo_charstatus) * char_max);
+ char_dat = (struct mmo_charstatus*)aRealloc(char_dat, sizeof(struct mmo_charstatus) * char_max);
if (!char_dat) {
printf("Out of memory: mmo_char_init (realloc of char_dat).\n");
char_log("Out of memory: mmo_char_init (realloc of char_dat)." RETCODE);
exit(1);
}
- online_chars = realloc(online_chars, sizeof(struct online_chars) * char_max);
+ online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * char_max);
if (!online_chars) {
printf("Out of memory: mmo_char_init (realloc of online_chars).\n");
char_log("Out of memory: mmo_char_init (realloc of online_chars)." RETCODE);
@@ -699,10 +737,10 @@ int mmo_char_init(void) {
}
ret = mmo_char_fromstr(line, &char_dat[char_num]);
-
+
// Initialize friends list
parse_friend_txt(&char_dat[char_num]); // Grab friends for the character
-
+
if (ret > 0) { // negative value or zero for errors
if (char_dat[char_num].char_id >= char_id_count)
char_id_count = char_dat[char_num].char_id + 1;
@@ -765,7 +803,8 @@ void mmo_char_sync(void) {
int i, j, k;
int lock;
FILE *fp,*f_fp;
- int id[char_num];
+ //int *id = (int *) aMalloc(sizeof(int) * char_num);
+ CREATE_BUFFER(id, int, char_num);
// Sorting before save (by [Yor])
for(i = 0; i < char_num; i++) {
@@ -804,6 +843,8 @@ void mmo_char_sync(void) {
if (fp == NULL) {
printf("WARNING: Server can't not create backup of characters file.\n");
char_log("WARNING: Server can't not create backup of characters file." RETCODE);
+ //aFree(id); // free up the memory before leaving -.- [Ajarn]
+ DELETE_BUFFER(id);
return;
}
for(i = 0; i < char_num; i++) {
@@ -821,9 +862,12 @@ void mmo_char_sync(void) {
mmo_friends_list_data_str(f_line, &char_dat[id[i]]);
fprintf(f_fp, "%s" RETCODE, f_line);
}
-
+
lock_fclose(f_fp, friends_txt, &lock);
-
+
+ //aFree(id);
+ DELETE_BUFFER(id);
+
return;
}
@@ -843,18 +887,18 @@ int make_new_char(int fd, unsigned char *dat) {
int i, j;
struct char_session_data *sd;
- sd = session[fd]->session_data;
+ sd = (struct char_session_data*)session[fd]->session_data;
// remove control characters from the name
dat[23] = '\0';
- if (remove_control_chars(dat)) {
+ if (remove_control_chars((unsigned char *)(char*)dat)) {
char_log("Make new char error (control char received in the name): (connection #%d, account: %d)." RETCODE,
fd, sd->account_id);
return -1;
}
// check lenght of character name
- if (strlen(dat) < 4) {
+ if (strlen((const char*)dat) < 4) {
char_log("Make new char error (character name too small): (connection #%d, account: %d, name: '%s')." RETCODE,
fd, sd->account_id, dat);
return -1;
@@ -896,8 +940,8 @@ int make_new_char(int fd, unsigned char *dat) {
}
for(i = 0; i < char_num; i++) {
- if ((name_ignoring_case != 0 && strcmp(char_dat[i].name, dat) == 0) ||
- (name_ignoring_case == 0 && strcmpi(char_dat[i].name, dat) == 0)) {
+ if ((name_ignoring_case != 0 && strcmp(char_dat[i].name, (const char*)dat) == 0) ||
+ (name_ignoring_case == 0 && strcmpi(char_dat[i].name, (const char*)dat) == 0)) {
char_log("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %d), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d." RETCODE,
fd, sd->account_id, dat[30], dat, char_dat[i].name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[24] + dat[25] + dat[26] + dat[27] + dat[28] + dat[29], dat[33], dat[31]);
return -1;
@@ -909,7 +953,7 @@ int make_new_char(int fd, unsigned char *dat) {
}
}
- if (strcmp(wisp_server_name, dat) == 0) {
+ if (strcmp(wisp_server_name, (const char*)dat) == 0) {
char_log("Make new char error (name used is wisp name for server): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %d), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d." RETCODE,
fd, sd->account_id, dat[30], dat, char_dat[i].name, dat[24], dat[25], dat[26], dat[27], dat[28], dat[29], dat[24] + dat[25] + dat[26] + dat[27] + dat[28] + dat[29], dat[33], dat[31]);
return -1;
@@ -917,13 +961,13 @@ int make_new_char(int fd, unsigned char *dat) {
if (char_num >= char_max) {
char_max += 256;
- char_dat = realloc(char_dat, sizeof(struct mmo_charstatus) * char_max);
+ char_dat = (struct mmo_charstatus*)aRealloc(char_dat, sizeof(struct mmo_charstatus) * char_max);
if (!char_dat) {
printf("Out of memory: make_new_char (realloc of char_dat).\n");
char_log("Out of memory: make_new_char (realloc of char_dat)." RETCODE);
exit(1);
}
- online_chars = realloc(online_chars, sizeof(struct online_chars) * char_max);
+ online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * char_max);
if (!online_chars) {
printf("Out of memory: make_new_char (realloc of online_chars).\n");
char_log("Out of memory: make_new_char (realloc of online_chars)." RETCODE);
@@ -943,8 +987,8 @@ int make_new_char(int fd, unsigned char *dat) {
char_dat[i].char_id = char_id_count++;
char_dat[i].account_id = sd->account_id;
char_dat[i].char_num = dat[30];
- strcpy(char_dat[i].name, dat);
- char_dat[i].class = 0;
+ strcpy(char_dat[i].name, (const char*)dat);
+ char_dat[i].class_ = 0;
char_dat[i].base_level = 1;
char_dat[i].job_level = 1;
char_dat[i].base_exp = 0;
@@ -994,8 +1038,8 @@ int make_new_char(int fd, unsigned char *dat) {
//----------------------------------------------------
// This function return the name of the job (by [Yor])
//----------------------------------------------------
-char * job_name(int class) {
- switch (class) {
+char * job_name(int class_) {
+ switch (class_) {
case 0: return "Novice";
case 1: return "Swordsman";
case 2: return "Mage";
@@ -1080,7 +1124,7 @@ void create_online_files(void) {
char temp[256]; // to prepare what we must display
time_t time_server; // for number of seconds
struct tm *datetime; // variable for time in structure ->tm_mday, ->tm_sec, ...
- int id[online_players_max];
+ int id[4096];
// don't return here if we display nothing, because server[j].users is updated in the first loop.
@@ -1153,12 +1197,12 @@ void create_online_files(void) {
break;
case 4: // by job (and job level)
for(k = 0; k < players; k++)
- if (char_dat[j].class < char_dat[id[k]].class ||
+ if (char_dat[j].class_ < char_dat[id[k]].class_ ||
// if same job, we sort by job level.
- (char_dat[j].class == char_dat[id[k]].class &&
+ (char_dat[j].class_ == char_dat[id[k]].class_ &&
char_dat[j].job_level < char_dat[id[k]].job_level) ||
// if same job and job level, we sort by job exp.
- (char_dat[j].class == char_dat[id[k]].class &&
+ (char_dat[j].class_ == char_dat[id[k]].class_ &&
char_dat[j].job_level == char_dat[id[k]].job_level &&
char_dat[j].job_exp < char_dat[id[k]].job_exp)) {
for(l = players; l > k; l--)
@@ -1299,7 +1343,7 @@ void create_online_files(void) {
}
// displaying of the job
if (online_display_option & 6) {
- char * jobname = job_name(char_dat[j].class);
+ char * jobname = job_name(char_dat[j].class_);
if ((online_display_option & 6) == 6) {
fprintf(fp2, " <td>%s %d/%d</td>\n", jobname, char_dat[j].base_level, char_dat[j].job_level);
fprintf(fp, "%-18s %3d/%3d ", jobname, char_dat[j].base_level, char_dat[j].job_level);
@@ -1352,8 +1396,9 @@ void create_online_files(void) {
if (players == 0) {
fprintf(fp2, " <p>No user is online.</p>\n");
fprintf(fp, "No user is online.\n");
- // no display if only 1 player
} else if (players == 1) {
+ fprintf(fp2, " <p>%d user is online.</p>\n", players);
+ fprintf(fp, "%d user is online.\n", players);
} else {
fprintf(fp2, " <p>%d users are online.</p>\n", players);
fprintf(fp, "%d users are online.\n", players);
@@ -1433,9 +1478,15 @@ int mmo_char_send006b(int fd, struct char_session_data *sd) {
WFIFOW(fd,j+46) = (p->sp > 0x7fff) ? 0x7fff : p->sp;
WFIFOW(fd,j+48) = (p->max_sp > 0x7fff) ? 0x7fff : p->max_sp;
WFIFOW(fd,j+50) = DEFAULT_WALK_SPEED; // p->speed;
- WFIFOW(fd,j+52) = p->class;
+ WFIFOW(fd,j+52) = p->class_;
WFIFOW(fd,j+54) = p->hair;
- WFIFOW(fd,j+56) = p->weapon;
+
+ // pecopeco knights/crusaders crash fix
+ if (p->class_ == 13 || p->class_ == 21 ||
+ p->class_ == 4014 || p->class_ == 4022)
+ WFIFOW(fd,j+56) = 0;
+ else WFIFOW(fd,j+56) = p->weapon;
+
WFIFOW(fd,j+58) = p->base_level;
WFIFOW(fd,j+60) = p->skill_point;
WFIFOW(fd,j+62) = p->head_bottom;
@@ -1501,9 +1552,9 @@ int char_divorce(struct mmo_charstatus *cs) {
//------------------------------------------------------------
// E-mail check: return 0 (not correct) or 1 (valid). by [Yor]
//------------------------------------------------------------
-int e_mail_check(unsigned char *email) {
+int e_mail_check(char *email) {
char ch;
- unsigned char* last_arobas;
+ char* last_arobas;
// athena limits
if (strlen(email) < 3 || strlen(email) > 39)
@@ -1546,7 +1597,7 @@ int disconnect_player(int accound_id) {
// disconnect player if online on char-server
for(i = 0; i < fd_max; i++) {
- if (session[i] && (sd = session[i]->session_data)) {
+ if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) {
if (sd->account_id == accound_id) {
session[i]->eof = 1;
return 1;
@@ -1579,7 +1630,7 @@ static int char_delete(struct mmo_charstatus *cs) {
// 離婚
if (cs->partner_id){
// 離婚情報をmapに通知
- char buf[10];
+ unsigned char buf[10];
WBUFW(buf,0) = 0x2b12;
WBUFL(buf,2) = cs->char_id;
WBUFL(buf,6) = cs->partner_id;
@@ -1608,7 +1659,7 @@ int parse_tologin(int fd) {
return 0;
}
- sd = session[fd]->session_data;
+ sd = (struct char_session_data*)session[fd]->session_data;
while(RFIFOREST(fd) >= 2) {
// printf("parse_tologin: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
@@ -1641,7 +1692,7 @@ int parse_tologin(int fd) {
return 0;
// printf("parse_tologin 2713 : %d\n", RFIFOB(fd,6));
for(i = 0; i < fd_max; i++) {
- if (session[i] && (sd = session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) {
+ if (session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL(fd,2)) {
if (RFIFOB(fd,6) != 0) {
WFIFOW(i,0) = 0x6c;
WFIFOB(i,2) = 0x42;
@@ -1657,6 +1708,10 @@ int parse_tologin(int fd) {
sd->connect_until_time = (time_t)RFIFOL(fd,47);
// send characters to player
mmo_char_send006b(i, sd);
+ } else if(isGM(sd->account_id) >= gm_allow_level) {
+ sd->connect_until_time = (time_t)RFIFOL(fd,47);
+ // send characters to player
+ mmo_char_send006b(i, sd);
} else {
// refuse connection: too much online players
// printf("count_users(): %d < max_connect_use (%d) -> fail...\n", count_users(), max_connect_user);
@@ -1675,7 +1730,7 @@ int parse_tologin(int fd) {
if (RFIFOREST(fd) < 50)
return 0;
for(i = 0; i < fd_max; i++) {
- if (session[i] && (sd = session[i]->session_data)) {
+ if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) {
if (sd->account_id == RFIFOL(fd,2)) {
memcpy(sd->email, RFIFOP(fd,6), 40);
if (e_mail_check(sd->email) == 0)
@@ -1688,6 +1743,42 @@ int parse_tologin(int fd) {
RFIFOSKIP(fd,50);
break;
+ // login-server alive packet
+ case 0x2718:
+ if (RFIFOREST(fd) < 2)
+ return 0;
+ RFIFOSKIP(fd,2);
+ break;
+
+ // Receiving authentification from Freya-type login server (to avoid char->login->char)
+ case 0x2719:
+ if (RFIFOREST(fd) < 18)
+ return 0;
+ // to conserv a maximum of authentification, search if account is already authentified and replace it
+ // that will reduce multiple connection too
+ for(i = 0; i < AUTH_FIFO_SIZE; i++)
+ if (auth_fifo[i].account_id == RFIFOL(fd,2))
+ break;
+ // if not found, use next value
+ if (i == AUTH_FIFO_SIZE) {
+ if (auth_fifo_pos >= AUTH_FIFO_SIZE)
+ auth_fifo_pos = 0;
+ i = auth_fifo_pos;
+ auth_fifo_pos++;
+ }
+ //printf("auth_fifo set (auth #%d) - account: %d, secure: %08x-%08x\n", i, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10));
+ auth_fifo[i].account_id = RFIFOL(fd,2);
+ auth_fifo[i].char_id = 0;
+ auth_fifo[i].login_id1 = RFIFOL(fd,6);
+ auth_fifo[i].login_id2 = RFIFOL(fd,10);
+ auth_fifo[i].delflag = 2; // 0: auth_fifo canceled/void, 2: auth_fifo received from login/map server in memory, 1: connection authentified
+ auth_fifo[i].char_pos = 0;
+ auth_fifo[i].connect_until_time = 0; // unlimited/unknown time by default (not display in map-server)
+ auth_fifo[i].ip = RFIFOL(fd,14);
+ //auth_fifo[i].map_auth = 0;
+ RFIFOSKIP(fd,18);
+ break;
+
case 0x2721: // gm reply
if (RFIFOREST(fd) < 10)
return 0;
@@ -1714,7 +1805,7 @@ int parse_tologin(int fd) {
if (acc > 0) {
for (i = 0; i < char_num; i++) {
if (char_dat[i].account_id == acc) {
- int jobclass = char_dat[i].class;
+ int jobclass = char_dat[i].class_;
char_dat[i].sex = sex;
auth_fifo[i].sex = sex;
if (jobclass == 19 || jobclass == 20 ||
@@ -1722,11 +1813,11 @@ int parse_tologin(int fd) {
jobclass == 4042 || jobclass == 4043) {
// job modification
if (jobclass == 19 || jobclass == 20) {
- char_dat[i].class = (sex) ? 19 : 20;
+ char_dat[i].class_ = (sex) ? 19 : 20;
} else if (jobclass == 4020 || jobclass == 4021) {
- char_dat[i].class = (sex) ? 4020 : 4021;
+ char_dat[i].class_ = (sex) ? 4020 : 4021;
} else if (jobclass == 4042 || jobclass == 4043) {
- char_dat[i].class = (sex) ? 4042 : 4043;
+ char_dat[i].class_ = (sex) ? 4042 : 4043;
}
// remove specifical skills of classes 19, 4020 and 4042
for(j = 315; j <= 322; j++) {
@@ -1780,14 +1871,14 @@ int parse_tologin(int fd) {
if (i == MAX_MAP_SERVERS)
char_log("'ladmin': Receiving a message for broadcast, but no map-server is online." RETCODE);
else {
- char buf[128];
- char message[RFIFOL(fd,4) + 1]; // +1 to add a null terminated if not exist in the packet
+ unsigned char buf[128];
+ char message[4096]; // +1 to add a null terminated if not exist in the packet
int lp;
char *p;
memset(message, '\0', sizeof(message));
memcpy(message, RFIFOP(fd,8), RFIFOL(fd,4));
message[sizeof(message)-1] = '\0';
- remove_control_chars(message);
+ remove_control_chars((unsigned char *)message);
// remove all first spaces
p = message;
while(p[0] == ' ')
@@ -1875,7 +1966,7 @@ int parse_tologin(int fd) {
int j, k;
struct char_session_data *sd2;
for (j = 0; j < fd_max; j++) {
- if (session[j] && (sd2 = session[j]->session_data) &&
+ if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) &&
sd2->account_id == char_dat[char_num-1].account_id) {
for (k = 0; k < 9; k++) {
if (sd2->found_char[k] == char_num-1) {
@@ -1928,10 +2019,10 @@ int parse_tologin(int fd) {
if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
{
- char buf[32000];
+ unsigned char buf[32000];
if (gm_account != NULL)
- free(gm_account);
- gm_account = calloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
+ aFree(gm_account);
+ gm_account = (struct gm_account*)aCalloc(sizeof(struct gm_account) * ((RFIFOW(fd,2) - 4) / 5), 1);
GM_num = 0;
for (i = 4; i < RFIFOW(fd,2); i = i + 5) {
gm_account[GM_num].account_id = RFIFOL(fd,i);
@@ -1950,7 +2041,66 @@ int parse_tologin(int fd) {
RFIFOSKIP(fd,RFIFOW(fd,2));
break;
+ // Receive GM accounts [Freya login server packet by Yor]
+ case 0x2733:
+ // add test here to remember that the login-server is Freya-type
+ // sprintf (login_server_type, "Freya");
+ if (RFIFOREST(fd) < 7)
+ return 0;
+ {
+ unsigned char buf[32000];
+ int new_level = 0;
+ for(i = 0; i < GM_num; i++)
+ if (gm_account[i].account_id == RFIFOL(fd,2)) {
+ if (gm_account[i].level != (int)RFIFOB(fd,6)) {
+ gm_account[i].level = (int)RFIFOB(fd,6);
+ new_level = 1;
+ }
+ break;
+ }
+ // if not found, add it
+ if (i == GM_num) {
+ // limited to 4000, because we send information to char-servers (more than 4000 GM accounts???)
+ // int (id) + int (level) = 8 bytes * 4000 = 32k (limit of packets in windows)
+ if (((int)RFIFOB(fd,6)) > 0 && GM_num < 4000) {
+ if (GM_num == 0) {
+ gm_account = (struct gm_account*)aMalloc(sizeof(struct gm_account));
+ } else {
+ gm_account = (struct gm_account*)aRealloc(gm_account, sizeof(struct gm_account) * (GM_num + 1));
+ }
+ gm_account[GM_num].account_id = RFIFOL(fd,2);
+ gm_account[GM_num].level = (int)RFIFOB(fd,6);
+ new_level = 1;
+ GM_num++;
+ if (GM_num >= 4000) {
+ printf("***WARNING: 4000 GM accounts found. Next GM accounts are not readed.\n");
+ char_log("***WARNING: 4000 GM accounts found. Next GM accounts are not readed." RETCODE);
+ }
+ }
+ }
+ if (new_level == 1) {
+ int len;
+ printf("From login-server: receiving a GM account information (%d: level %d).\n", RFIFOL(fd,2), (int)RFIFOB(fd,6));
+ char_log("From login-server: receiving a GM account information (%d: level %d)." RETCODE, RFIFOL(fd,2), (int)RFIFOB(fd,6));
+ //create_online_files(); // not change online file for only 1 player (in next timer, that will be done
+ // send gm acccounts level to map-servers
+ len = 4;
+ WBUFW(buf,0) = 0x2b15;
+
+ for(i = 0; i < GM_num; i++) {
+ WBUFL(buf, len) = gm_account[i].account_id;
+ WBUFB(buf, len+4) = (unsigned char)gm_account[i].level;
+ len += 5;
+ }
+ WBUFW(buf, 2) = len;
+ mapif_sendall(buf, len);
+ }
+ }
+ RFIFOSKIP(fd,7);
+ break;
+
default:
+ printf("parse_tologin: unknown packet %x! \n", RFIFOW(fd,0));
session[fd]->eof = 1;
return 0;
}
@@ -1960,28 +2110,6 @@ int parse_tologin(int fd) {
return 0;
}
-//--------------------------------
-// Map-server anti-freeze system
-//--------------------------------
-int map_anti_freeze_system(int tid, unsigned int tick, int id, int data) {
- int i;
-
- //printf("Entering in map_anti_freeze_system function to check freeze of servers.\n");
- for(i = 0; i < MAX_MAP_SERVERS; i++) {
- if (server_fd[i] >= 0) {// if map-server is online
- //printf("map_anti_freeze_system: server #%d, flag: %d.\n", i, server_freezeflag[i]);
- if (server_freezeflag[i]-- < 1) { // Map-server anti-freeze system. Counter. 5 ok, 4...0 freezed
- printf("Map-server anti-freeze system: char-server #%d is freezed -> disconnection.\n", i);
- char_log("Map-server anti-freeze system: char-server #%d is freezed -> disconnection." RETCODE,
- i);
- session[server_fd[i]]->eof = 1;
- }
- }
- }
-
- return 0;
-}
-
int parse_frommap(int fd) {
int i, j;
int id;
@@ -2007,6 +2135,14 @@ int parse_frommap(int fd) {
// printf("parse_frommap: connection #%d, packet: 0x%x (with being read: %d bytes).\n", fd, RFIFOW(fd,0), RFIFOREST(fd));
switch(RFIFOW(fd,0)) {
+
+ // map-server alive packet
+ case 0x2718:
+ if (RFIFOREST(fd) < 2)
+ return 0;
+ RFIFOSKIP(fd,2);
+ break;
+
// request from map-server to reload GM accounts. Transmission to login-server (by Yor)
case 0x2af7:
if (login_fd > 0) { // don't send request if no login-server
@@ -2119,8 +2255,6 @@ int parse_frommap(int fd) {
if (RFIFOREST(fd) < 6 || RFIFOREST(fd) < RFIFOW(fd,2))
return 0;
server[id].users = RFIFOW(fd,4);
- if(anti_freeze_enable)
- server_freezeflag[id] = 5; // Map anti-freeze system. Counter. 5 ok, 4...0 freezed
// remove all previously online players of the server
for(i = 0; i < online_players_max; i++)
if (online_chars[i].server == id) {
@@ -2141,7 +2275,7 @@ int parse_frommap(int fd) {
if (j == online_players_max) {
// create 256 new slots
online_players_max += 256;
- online_chars = realloc(online_chars, sizeof(struct online_chars) * online_players_max);
+ online_chars = (struct online_chars*)aRealloc(online_chars, sizeof(struct online_chars) * online_players_max);
if (!online_chars) {
printf("out of memory: parse_frommap - online_chars (realloc).\n");
exit(1);
@@ -2411,20 +2545,23 @@ int parse_frommap(int fd) {
RFIFOSKIP(fd, RFIFOW(fd,2));
// printf("char: save_account_reg (from map)\n");
break;
- }
- // Map server send information to change an email of an account -> login-server
- case 0x3000:
- if (RFIFOREST(fd) < 4 || RFIFOREST(fd) < RFIFOW(fd,2))
+ }
+ // Character disconnected set online 0 [Wizputer]
+ case 0x2b17:
+ if (RFIFOREST(fd) < 6)
return 0;
- if (login_fd > 0) { // don't send request if no login-server
- WFIFOW(login_fd,0) = 0x3000;
- WFIFOW(login_fd,2) = RFIFOW(fd,2);
- WFIFOL(login_fd,4) = RFIFOL(fd,4);
- WFIFOB(login_fd,8) = RFIFOB(fd,8);
- WFIFOSET(login_fd, RFIFOW(fd,2));
- printf("char : change sex -> login %d %d %d \n", RFIFOL(fd,4), RFIFOB(fd,8), RFIFOW(fd,2));
- }
- RFIFOSKIP(fd, RFIFOW(fd,2));
+ //printf("Setting %d char offline\n",RFIFOL(fd,2));
+ set_char_offline(RFIFOL(fd,2),RFIFOL(fd,6));
+ RFIFOSKIP(fd,10);
+ break;
+
+ // Character set online [Wizputer]
+ case 0x2b19:
+ if (RFIFOREST(fd) < 6)
+ return 0;
+ //printf("Setting %d char online\n",RFIFOL(fd,2));
+ set_char_online(RFIFOL(fd,2),RFIFOL(fd,6));
+ RFIFOSKIP(fd,10);
break;
default:
@@ -2513,7 +2650,7 @@ int parse_char(int fd) {
return 0;
}
- sd = session[fd]->session_data;
+ sd = (struct char_session_data*)session[fd]->session_data;
while (RFIFOREST(fd) >= 2) {
cmd = RFIFOW(fd,0);
@@ -2537,7 +2674,7 @@ int parse_char(int fd) {
// if (sd == NULL && cmd != 0x65 && cmd != 0x20b && cmd != 0x187 &&
// cmd != 0x2af8 && cmd != 0x7530 && cmd != 0x7532)
// cmd = 0xffff; // パケットダンプを表示させる
-
+
switch(cmd){
case 0x20b: //20040622暗号化ragexe対応
if (RFIFOREST(fd) < 19)
@@ -2555,7 +2692,9 @@ int parse_char(int fd) {
else
printf("Account Logged On; Account ID: %d.\n", RFIFOL(fd,2));
if (sd == NULL) {
- sd = session[fd]->session_data = calloc(sizeof(struct char_session_data), 1);
+ sd = (struct char_session_data*)aCalloc(sizeof(struct char_session_data), 1);
+ session[fd]->session_data = sd;
+
memset(sd, 0, sizeof(struct char_session_data));
memcpy(sd->email, "no mail", 40); // put here a mail without '@' to refuse deletion if we don't receive the e-mail
sd->connect_until_time = 0; // unknow or illimited (not displaying on map-server)
@@ -2742,7 +2881,7 @@ int parse_char(int fd) {
WFIFOW(fd,2+46) = (char_dat[i].sp > 0x7fff) ? 0x7fff : char_dat[i].sp;
WFIFOW(fd,2+48) = (char_dat[i].max_sp > 0x7fff) ? 0x7fff : char_dat[i].max_sp;
WFIFOW(fd,2+50) = DEFAULT_WALK_SPEED; // char_dat[i].speed;
- WFIFOW(fd,2+52) = char_dat[i].class;
+ WFIFOW(fd,2+52) = char_dat[i].class_;
WFIFOW(fd,2+54) = char_dat[i].hair;
WFIFOW(fd,2+58) = char_dat[i].base_level;
@@ -2835,7 +2974,7 @@ int parse_char(int fd) {
int j, k;
struct char_session_data *sd2;
for (j = 0; j < fd_max; j++) {
- if (session[j] && (sd2 = session[j]->session_data) &&
+ if (session[j] && (sd2 = (struct char_session_data*)session[j]->session_data) &&
sd2->account_id == char_dat[char_num-1].account_id) {
for (k = 0; k < 9; k++) {
if (sd2->found_char[k] == char_num-1) {
@@ -2877,7 +3016,7 @@ int parse_char(int fd) {
if (server_fd[i] < 0)
break;
}
- if (i == MAX_MAP_SERVERS || strcmp(RFIFOP(fd,2), userid) || strcmp(RFIFOP(fd,26), passwd)){
+ if (i == MAX_MAP_SERVERS || strcmp((char*)RFIFOP(fd,2), userid) || strcmp((char*)RFIFOP(fd,26), passwd)){
WFIFOB(fd,2) = 3;
WFIFOSET(fd,3);
RFIFOSKIP(fd,60);
@@ -2886,8 +3025,6 @@ int parse_char(int fd) {
WFIFOB(fd,2) = 0;
session[fd]->func_parse = parse_frommap;
server_fd[i] = fd;
- if(anti_freeze_enable)
- server_freezeflag[i] = 5; // Map anti-freeze system. Counter. 5 ok, 4...0 freezed
server[i].ip = RFIFOL(fd,54);
server[i].port = RFIFOW(fd,58);
server[i].users = 0;
@@ -2945,24 +3082,24 @@ int parse_char(int fd) {
// Console Command Parser [Wizputer]
int parse_console(char *buf) {
char *type,*command;
-
- type = (char *)malloc(64);
- command = (char *)malloc(64);
-
+
+ type = (char *)aMalloc(64);
+ command = (char *)aMalloc(64);
+
memset(type,0,64);
memset(command,0,64);
-
+
printf("Console: %s\n",buf);
-
+
if ( sscanf(buf, "%[^:]:%[^\n]", type , command ) < 2 )
sscanf(buf,"%[^\n]",type);
-
+
printf("Type of command: %s || Command: %s \n",type,command);
-
- if(buf) free(buf);
- if(type) free(type);
- if(command) free(command);
-
+
+ if(buf) aFree(buf);
+ if(type) aFree(type);
+ if(command) aFree(command);
+
return 0;
}
@@ -3015,7 +3152,7 @@ int mapif_send(int fd, unsigned char *buf, unsigned int len) {
int send_users_tologin(int tid, unsigned int tick, int id, int data) {
int users = count_users();
- char buf[16];
+ unsigned char buf[16];
if (login_fd > 0 && session[login_fd]) {
// send number of user to login server
@@ -3103,8 +3240,8 @@ int lan_config_read(const char *lancfgName) {
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
- remove_control_chars(w1);
- remove_control_chars(w2);
+ remove_control_chars((unsigned char *)w1);
+ remove_control_chars((unsigned char *)w2);
if (strcmpi(w1, "lan_map_ip") == 0) { // Read map-server Lan IP Address
h = gethostbyname(w2);
if (h != NULL) {
@@ -3175,8 +3312,8 @@ int char_config_read(const char *cfgName) {
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
continue;
- remove_control_chars(w1);
- remove_control_chars(w2);
+ remove_control_chars((unsigned char *)w1);
+ remove_control_chars((unsigned char *)w2);
if (strcmpi(w1, "userid") == 0) {
memcpy(userid, w2, 24);
} else if (strcmpi(w1, "passwd") == 0) {
@@ -3184,7 +3321,7 @@ int char_config_read(const char *cfgName) {
} else if (strcmpi(w1, "server_name") == 0) {
memcpy(server_name, w2, sizeof(server_name));
server_name[sizeof(server_name) - 1] = '\0';
- printf("%s server has been intialized\n", w2);
+ printf("%s server has been initialized\n", w2);
} else if (strcmpi(w1, "wisp_server_name") == 0) {
if (strlen(w2) >= 4) {
memcpy(wisp_server_name, w2, sizeof(wisp_server_name));
@@ -3208,6 +3345,14 @@ int char_config_read(const char *cfgName) {
sprintf(char_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
} else
memcpy(char_ip_str, w2, 16);
+ } else if (strcmpi(w1, "bind_ip") == 0) {
+ bind_ip_set_ = 1;
+ h = gethostbyname(w2);
+ if (h != NULL) {
+ printf("Character server binding IP address : %s -> %d.%d.%d.%d\n", w2, (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
+ sprintf(bind_ip_str, "%d.%d.%d.%d", (unsigned char)h->h_addr[0], (unsigned char)h->h_addr[1], (unsigned char)h->h_addr[2], (unsigned char)h->h_addr[3]);
+ } else
+ memcpy(bind_ip_str, w2, 16);
} else if (strcmpi(w1, "char_port") == 0) {
char_port = atoi(w2);
} else if (strcmpi(w1, "char_maintenance") == 0) {
@@ -3228,6 +3373,10 @@ int char_config_read(const char *cfgName) {
max_connect_user = atoi(w2);
if (max_connect_user < 0)
max_connect_user = 0; // unlimited online players
+ } else if(strcmpi(w1, "gm_allow_level") == 0) {
+ gm_allow_level = atoi(w2);
+ if(gm_allow_level < 0)
+ gm_allow_level = 99;
} else if (strcmpi(w1, "check_ip_flag") == 0) {
check_ip_flag = config_switch(w2);
} else if (strcmpi(w1, "autosave_time") == 0) {
@@ -3296,12 +3445,6 @@ int char_config_read(const char *cfgName) {
online_refresh_html = 1;
} else if(strcmpi(w1,"db_path")==0) {
strcpy(db_path,w2);
- } else if(strcmpi(w1,"anti_freeze_enable")==0){
- anti_freeze_enable = config_switch(w2);
- } else if (strcmpi(w1, "anti_freeze_interval") == 0) {
- ANTI_FREEZE_INTERVAL = atoi(w2);
- if (ANTI_FREEZE_INTERVAL < 5)
- ANTI_FREEZE_INTERVAL = 5; // minimum 5 seconds
} else if (strcmpi(w1, "import") == 0) {
char_config_read(w2);
} else if (strcmpi(w1, "console") == 0) {
@@ -3343,19 +3486,20 @@ void do_final(void) {
}
create_online_files();
- if(online_chars) free(online_chars);
+ if(online_chars) aFree(online_chars);
mmo_char_sync();
inter_save();
- if(gm_account) free(gm_account);
- if(char_dat) free(char_dat);
+ if(gm_account) aFree(gm_account);
+ if(char_dat) aFree(char_dat);
delete_session(login_fd);
delete_session(char_fd);
- for(i = 0; i < fd_max; i++)
- if(session[i] != NULL) free(session[i]);
+ inter_final();
+ exit_dbn();
+ timer_final();
char_log("----End of char-server (normal end with closing of all files)." RETCODE);
}
@@ -3363,21 +3507,23 @@ void do_final(void) {
int do_init(int argc, char **argv) {
int i;
- // a newline in the log...
- char_log("");
- char_log("The char-server starting..." RETCODE);
-
+ SERVER_TYPE = SERVER_CHAR;
char_config_read((argc < 2) ? CHAR_CONF_NAME : argv[1]);
lan_config_read((argc > 1) ? argv[1] : LOGIN_LAN_CONF_NAME);
- if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) {
+ // a newline in the log...
+ char_log("");
+ // moved behind char_config_read in case we changed the filename [celest]
+ char_log("The char-server starting..." RETCODE);
+
+ if ((naddr_ != 0) && (login_ip_set_ == 0 || char_ip_set_ == 0)) {
// The char server should know what IP address it is running on
// - MouseJstr
int localaddr = ntohl(addr_[0]);
unsigned char *ptr = (unsigned char *) &localaddr;
char buf[16];
sprintf(buf, "%d.%d.%d.%d", ptr[0], ptr[1], ptr[2], ptr[3]);;
- if (naddr_ != 1)
+ if (naddr_ != 1)
printf("Multiple interfaces detected.. using %s as our IP address\n", buf);
else
printf("Defaulting to %s as our IP address\n", buf);
@@ -3386,9 +3532,9 @@ int do_init(int argc, char **argv) {
if (char_ip_set_ == 0)
strcpy(char_ip_str, buf);
- if (ptr[0] == 192 && ptr[1] == 168)
- printf("Firewall detected.. edit lan_support.conf and char_athena.conf");
- }
+ if (ptr[0] == 192 && ptr[1] == 168)
+ printf("Firewall detected.. edit lan_support.conf and char_athena.conf\n");
+ }
login_ip = inet_addr(login_ip_str);
char_ip = inet_addr(char_ip_str);
@@ -3399,7 +3545,7 @@ int do_init(int argc, char **argv) {
}
online_players_max = 256;
- online_chars = calloc(sizeof(struct online_chars) * 256, 1);
+ online_chars = (struct online_chars*)aCalloc(sizeof(struct online_chars) * 256, 1);
if (!online_chars) {
printf("out of memory: do_init (calloc).\n");
exit(1);
@@ -3409,7 +3555,6 @@ int do_init(int argc, char **argv) {
online_chars[i].server = -1;
}
-
mmo_char_init();
update_online = time(NULL);
@@ -3420,12 +3565,15 @@ int do_init(int argc, char **argv) {
set_termfunc(do_final);
set_defaultparse(parse_char);
- char_fd = make_listen_port(char_port);
+ if (bind_ip_set_)
+ char_fd = make_listen_bind(inet_addr(bind_ip_str),char_port);
+ else
+ char_fd = make_listen_bind(INADDR_ANY,char_port);
add_timer_func_list(check_connect_login_server, "check_connect_login_server");
add_timer_func_list(send_users_tologin, "send_users_tologin");
add_timer_func_list(mmo_char_sync_timer, "mmo_char_sync_timer");
-
+
i = add_timer_interval(gettick() + 1000, check_connect_login_server, 0, 0, 10 * 1000);
i = add_timer_interval(gettick() + 1000, send_users_tologin, 0, 0, 5 * 1000);
i = add_timer_interval(gettick() + autosave_interval, mmo_char_sync_timer, 0, 0, autosave_interval);
@@ -3438,13 +3586,6 @@ int do_init(int argc, char **argv) {
if (flush_on)
add_timer_interval(gettick()+10, flush_timer,0,0,flush_time);
-
-
- if(anti_freeze_enable > 0) {
- add_timer_func_list(map_anti_freeze_system, "map_anti_freeze_system");
- i = add_timer_interval(gettick() + 1000, map_anti_freeze_system, 0, 0, ANTI_FREEZE_INTERVAL * 1000); // checks every X seconds user specifies
- }
-
if(console) {
set_defaultconsoleparse(parse_console);
start_console();
@@ -3456,3 +3597,19 @@ int do_init(int argc, char **argv) {
return 0;
}
+
+int char_married(int pl1,int pl2) {
+ if (char_dat[pl1].char_id == char_dat[pl2].partner_id && char_dat[pl2].char_id == char_dat[pl1].partner_id)
+ return 1;
+ else
+ return 0;
+}
+
+int char_child(int parent_id, int child_id) {
+ if (char_dat[parent_id].child == char_dat[child_id].char_id &&
+ ((char_dat[parent_id].char_id == char_dat[child_id].father) ||
+ (char_dat[parent_id].char_id == char_dat[child_id].mother)))
+ return 1;
+ else
+ return 0;
+}
diff --git a/src/char/char.h b/src/char/char.h
index 3ee2f9f6d..78f4f0194 100644
--- a/src/char/char.h
+++ b/src/char/char.h
@@ -24,6 +24,9 @@ int mapif_sendall(unsigned char *buf, unsigned int len);
int mapif_sendallwos(int fd,unsigned char *buf, unsigned int len);
int mapif_send(int fd,unsigned char *buf, unsigned int len);
+int char_married(int pl1,int pl2);
+int char_child(int parent_id, int child_id);
+
int char_log(char *fmt, ...);
extern int autosave_interval;
diff --git a/src/char/int_guild.c b/src/char/int_guild.c
index eb03dd335..9268d9339 100644
--- a/src/char/int_guild.c
+++ b/src/char/int_guild.c
@@ -45,7 +45,7 @@ int inter_guild_tostr(char *str, struct guild *g) {
len += sprintf(str + len, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\t%s\t",
m->account_id, m->char_id,
m->hair, m->hair_color, m->gender,
- m->class, m->lv, m->exp, m->exp_payper, m->position,
+ m->class_, m->lv, m->exp, m->exp_payper, m->position,
((m->account_id > 0) ? m->name : "-"));
}
// 役職
@@ -138,7 +138,7 @@ int inter_guild_fromstr(char *str, struct guild *g) {
m->hair = tmp_int[2];
m->hair_color = tmp_int[3];
m->gender = tmp_int[4];
- m->class = tmp_int[5];
+ m->class_ = tmp_int[5];
m->lv = tmp_int[6];
m->exp = tmp_int[7];
m->exp_payper = tmp_int[8];
@@ -398,7 +398,7 @@ int inter_guild_init() {
continue;
}
- g = calloc(sizeof(struct guild), 1);
+ g = (struct guild *) aCalloc(sizeof(struct guild), 1);
if(g == NULL){
printf("int_guild: out of memory!\n");
exit(0);
@@ -412,7 +412,7 @@ int inter_guild_init() {
guild_calcinfo(g);
} else {
printf("int_guild: broken data [%s] line %d\n", guild_txt, c);
- free(g);
+ aFree(g);
}
c++;
}
@@ -426,7 +426,7 @@ int inter_guild_init() {
}
while(fgets(line, sizeof(line)-1, fp)) {
- gc = calloc(sizeof(struct guild_castle), 1);
+ gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1);
if(gc == NULL){
printf("int_guild: out of memory!\n");
exit(0);
@@ -436,7 +436,7 @@ int inter_guild_init() {
numdb_insert(castle_db, gc->castle_id, gc);
} else {
printf("int_guild: broken data [%s] line %d\n", castle_txt, c);
- free(gc);
+ aFree(gc);
}
c++;
}
@@ -445,7 +445,7 @@ int inter_guild_init() {
printf(" %s - making Default Data...\n", castle_txt);
//デフォルトデータを作成
for(i = 0; i < MAX_GUILDCASTLE; i++) {
- gc = calloc(sizeof(struct guild_castle), 1);
+ gc = (struct guild_castle *) aCalloc(sizeof(struct guild_castle), 1);
if (gc == NULL) {
printf("int_guild: out of memory!\n");
exit(0);
@@ -488,10 +488,28 @@ int inter_guild_init() {
return 0;
}
+int castle_db_final (void *k, void *data, va_list ap)
+{
+ struct guild_castle *gc = (struct guild_castle *) data;
+ if (gc) aFree(gc);
+ return 0;
+}
+int guild_db_final (void *k, void *data, va_list ap)
+{
+ struct guild *g = (struct guild *) data;
+ if (g) aFree(g);
+ return 0;
+}
+void inter_guild_final() {
+ numdb_final(castle_db, castle_db_final);
+ numdb_final(guild_db, guild_db_final);
+ return;
+}
+
struct guild *inter_guild_search(int guild_id) {
struct guild *g;
- g=numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
return g;
}
@@ -577,7 +595,7 @@ int guild_check_empty(struct guild *g) {
numdb_erase(guild_db, g->guild_id);
inter_guild_storage_delete(g->guild_id);
mapif_guild_broken(g->guild_id, 0);
- free(g);
+ aFree(g);
return 1;
}
@@ -656,7 +674,7 @@ int guild_calcinfo(struct guild *g) {
g->next_exp = guild_nextexp(g->guild_lv);
// メンバ上限(ギルド拡張適用)
- g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 2;
+ g->max_member = 16 + guild_checkskill(g, GD_EXTENSION) * 6; //Lupus 2 -> 6
// 平均レベルとオンライン人数
g->average_lv = 0;
@@ -713,7 +731,7 @@ int mapif_guild_noinfo(int fd, int guild_id) {
// ギルド情報まとめ送り
int mapif_guild_info(int fd, struct guild *g) {
- unsigned char buf[4 + sizeof(struct guild)];
+ unsigned char buf[16384];
WBUFW(buf,0) = 0x3831;
memcpy(buf + 4, g, sizeof(struct guild));
@@ -765,9 +783,9 @@ int mapif_guild_memberinfoshort(struct guild *g, int idx) {
WBUFL(buf, 2) = g->guild_id;
WBUFL(buf, 6) = g->member[idx].account_id;
WBUFL(buf,10) = g->member[idx].char_id;
- WBUFB(buf,14) = g->member[idx].online;
+ WBUFB(buf,14) = (unsigned char)g->member[idx].online;
WBUFW(buf,15) = g->member[idx].lv;
- WBUFW(buf,17) = g->member[idx].class;
+ WBUFW(buf,17) = g->member[idx].class_;
mapif_sendall(buf, 19);
return 0;
}
@@ -786,15 +804,15 @@ int mapif_guild_broken(int guild_id, int flag) {
}
// ギルド内発言
-int mapif_guild_message(int guild_id, int account_id, char *mes, int len) {
- unsigned char buf[len+12];
+int mapif_guild_message(int guild_id, int account_id, char *mes, int len, int sfd) {
+ unsigned char buf[2048];
WBUFW(buf,0) = 0x3837;
WBUFW(buf,2) = len + 12;
WBUFL(buf,4) = guild_id;
WBUFL(buf,8) = account_id;
memcpy(WBUFP(buf,12), mes, len);
- mapif_sendall(buf, len + 12);
+ mapif_sendallwos(sfd, buf, len + 12);
return 0;
}
@@ -814,7 +832,7 @@ int mapif_guild_basicinfochanged(int guild_id, int type, const void *data, int l
// ギルドメンバ情報変更通知
int mapif_guild_memberinfochanged(int guild_id, int account_id, int char_id, int type, const void *data, int len) {
- unsigned char buf[len + 18];
+ unsigned char buf[4096];
WBUFW(buf, 0) = 0x383a;
WBUFW(buf, 2) = len + 18;
@@ -860,7 +878,7 @@ int mapif_guild_alliance(int guild_id1, int guild_id2, int account_id1, int acco
// ギルド役職変更通知
int mapif_guild_position(struct guild *g, int idx) {
- unsigned char buf[sizeof(struct guild_position) + 12];
+ unsigned char buf[2048];
WBUFW(buf,0) = 0x383b;
WBUFW(buf,2) = sizeof(struct guild_position) + 12;
@@ -965,7 +983,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem
mapif_guild_created(fd, account_id, NULL);
return 0;
}
- g = calloc(sizeof(struct guild), 1);
+ g = (struct guild *) aCalloc(sizeof(struct guild), 1);
if (g == NULL) {
printf("int_guild: CreateGuild: out of memory !\n");
mapif_guild_created(fd, account_id, NULL);
@@ -1005,7 +1023,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, char *name, struct guild_mem
int mapif_parse_GuildInfo(int fd, int guild_id) {
struct guild *g;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if (g != NULL){
guild_calcinfo(g);
mapif_guild_info(fd, g);
@@ -1020,7 +1038,7 @@ int mapif_parse_GuildAddMember(int fd, int guild_id, struct guild_member *m) {
struct guild *g;
int i;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if (g == NULL) {
mapif_guild_memberadded(fd, guild_id, m->account_id, m->char_id, 1);
return 0;
@@ -1046,7 +1064,7 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
struct guild *g = NULL;
int i, j;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *)numdb_search(guild_db, guild_id);
if (g != NULL) {
for(i = 0; i < MAX_GUILD; i++) {
if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) {
@@ -1085,11 +1103,11 @@ int mapif_parse_GuildLeave(int fd, int guild_id, int account_id, int char_id, in
}
// オンライン/Lv更新
-int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class) {
+int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id, int char_id, int online, int lv, int class_) {
struct guild *g;
int i, alv, c;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if (g == NULL)
return 0;
@@ -1101,7 +1119,7 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id,
if (g->member[i].account_id == account_id && g->member[i].char_id == char_id) {
g->member[i].online = online;
g->member[i].lv = lv;
- g->member[i].class = class;
+ g->member[i].class_ = class_;
mapif_guild_memberinfoshort(g, i);
}
if (g->member[i].account_id > 0) {
@@ -1111,8 +1129,10 @@ int mapif_parse_GuildChangeMemberInfoShort(int fd, int guild_id, int account_id,
if (g->member[i].online)
g->connect_member++;
}
- // 平均レベル
- g->average_lv = alv / c;
+
+ if (c)
+ // 平均レベル
+ g->average_lv = alv / c;
return 0;
}
@@ -1134,7 +1154,7 @@ int guild_break_sub(void *key, void *data, va_list ap) {
int mapif_parse_BreakGuild(int fd, int guild_id) {
struct guild *g;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if(g == NULL)
return 0;
@@ -1145,14 +1165,14 @@ int mapif_parse_BreakGuild(int fd, int guild_id) {
if(log_inter)
inter_log("guild %s (id=%d) broken" RETCODE, g->name, guild_id);
- free(g);
+ aFree(g);
return 0;
}
// ギルドメッセージ送信
int mapif_parse_GuildMessage(int fd, int guild_id, int account_id, char *mes, int len) {
- return mapif_guild_message(guild_id, account_id, mes, len);
+ return mapif_guild_message(guild_id, account_id, mes, len, fd);
}
// ギルド基本データ変更要求
@@ -1160,7 +1180,7 @@ int mapif_parse_GuildBasicInfoChange(int fd, int guild_id, int type, const char
struct guild *g;
short dw = *((short *)data);
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if (g == NULL)
return 0;
@@ -1187,7 +1207,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
int i;
struct guild *g;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if(g == NULL)
return 0;
@@ -1222,7 +1242,7 @@ int mapif_parse_GuildMemberInfoChange(int fd, int guild_id, int account_id, int
// ギルド役職名変更要求
int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_position *p) {
- struct guild *g = numdb_search(guild_db, guild_id);
+ struct guild *g = (struct guild *) numdb_search(guild_db, guild_id);
if (g == NULL || idx < 0 || idx >= MAX_GUILDPOSITION) {
return 0;
@@ -1236,7 +1256,7 @@ int mapif_parse_GuildPosition(int fd, int guild_id, int idx, struct guild_positi
// ギルドスキルアップ要求
int mapif_parse_GuildSkillUp(int fd, int guild_id, int skill_num, int account_id) {
- struct guild *g = numdb_search(guild_db, guild_id);
+ struct guild *g = (struct guild *) numdb_search(guild_db, guild_id);
int idx = skill_num - GD_SKILLBASE;
if (g == NULL || idx < 0 || idx >= MAX_GUILDSKILL)
@@ -1259,8 +1279,8 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_
struct guild *g[2];
int j, i;
- g[0] = numdb_search(guild_db, guild_id1);
- g[1] = numdb_search(guild_db, guild_id2);
+ g[0] = (struct guild *) numdb_search(guild_db, guild_id1);
+ g[1] = (struct guild *) numdb_search(guild_db, guild_id2);
if (g[0] == NULL || g[1] == NULL)
return 0;
@@ -1292,7 +1312,7 @@ int mapif_parse_GuildAlliance(int fd, int guild_id1, int guild_id2, int account_
int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *mes2) {
struct guild *g;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if (g == NULL)
return 0;
memcpy(g->mes1, mes1, 60);
@@ -1305,7 +1325,7 @@ int mapif_parse_GuildNotice(int fd, int guild_id, const char *mes1, const char *
int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char *data) {
struct guild *g;
- g = numdb_search(guild_db, guild_id);
+ g = (struct guild *) numdb_search(guild_db, guild_id);
if (g == NULL)
return 0;
memcpy(g->emblem_data, data, len);
@@ -1316,7 +1336,7 @@ int mapif_parse_GuildEmblem(int fd, int len, int guild_id, int dummy, const char
}
int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) {
- struct guild_castle *gc = numdb_search(castle_db, castle_id);
+ struct guild_castle *gc = (struct guild_castle *) numdb_search(castle_db, castle_id);
if (gc == NULL) {
return mapif_guild_castle_dataload(castle_id, 0, 0);
@@ -1357,7 +1377,7 @@ int mapif_parse_GuildCastleDataLoad(int fd, int castle_id, int index) {
}
int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value) {
- struct guild_castle *gc=numdb_search(castle_db, castle_id);
+ struct guild_castle *gc= (struct guild_castle *) numdb_search(castle_db, castle_id);
if (gc == NULL) {
return mapif_guild_castle_datasave(castle_id, index, value);
@@ -1366,10 +1386,10 @@ int mapif_parse_GuildCastleDataSave(int fd, int castle_id, int index, int value)
case 1:
if (gc->guild_id != value) {
int gid = (value) ? value : gc->guild_id;
- struct guild *g = numdb_search(guild_db, gid);
+ struct guild *g = (struct guild *) numdb_search(guild_db, gid);
if(log_inter)
inter_log("guild %s (id=%d) %s castle id=%d" RETCODE,
- (g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", index);
+ (g) ? g->name : "??", gid, (value) ? "occupy" : "abandon", castle_id);
}
gc->guild_id = value;
break;
@@ -1417,21 +1437,21 @@ int mapif_parse_GuildCheck(int fd, int guild_id, int account_id, int char_id) {
// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
int inter_guild_parse_frommap(int fd) {
switch(RFIFOW(fd,0)) {
- case 0x3030: mapif_parse_CreateGuild(fd, RFIFOL(fd,4), RFIFOP(fd,8), (struct guild_member *)RFIFOP(fd,32)); break;
+ case 0x3030: mapif_parse_CreateGuild(fd, RFIFOL(fd,4), (char*)RFIFOP(fd,8), (struct guild_member *)RFIFOP(fd,32)); break;
case 0x3031: mapif_parse_GuildInfo(fd, RFIFOL(fd,2)); break;
case 0x3032: mapif_parse_GuildAddMember(fd, RFIFOL(fd,4), (struct guild_member *)RFIFOP(fd,8)); break;
- case 0x3034: mapif_parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOP(fd,15)); break;
+ case 0x3034: mapif_parse_GuildLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), (const char*)RFIFOP(fd,15)); break;
case 0x3035: mapif_parse_GuildChangeMemberInfoShort(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOB(fd,14), RFIFOW(fd,15), RFIFOW(fd,17)); break;
case 0x3036: mapif_parse_BreakGuild(fd, RFIFOL(fd,2)); break;
- case 0x3037: mapif_parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
+ case 0x3037: mapif_parse_GuildMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
case 0x3038: mapif_parse_GuildCheck(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
- case 0x3039: mapif_parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), RFIFOP(fd,10), RFIFOW(fd,2)-10); break;
- case 0x303A: mapif_parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), RFIFOP(fd,18), RFIFOW(fd,2)-18); break;
+ case 0x3039: mapif_parse_GuildBasicInfoChange(fd, RFIFOL(fd,4), RFIFOW(fd,8), (const char*)RFIFOP(fd,10), RFIFOW(fd,2)-10); break;
+ case 0x303A: mapif_parse_GuildMemberInfoChange(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOL(fd,12), RFIFOW(fd,16), (const char*)RFIFOP(fd,18), RFIFOW(fd,2)-18); break;
case 0x303B: mapif_parse_GuildPosition(fd, RFIFOL(fd,4), RFIFOL(fd,8), (struct guild_position *)RFIFOP(fd,12)); break;
case 0x303C: mapif_parse_GuildSkillUp(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); break;
case 0x303D: mapif_parse_GuildAlliance(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14), RFIFOB(fd,18)); break;
- case 0x303E: mapif_parse_GuildNotice(fd, RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,66)); break;
- case 0x303F: mapif_parse_GuildEmblem(fd, RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12)); break;
+ case 0x303E: mapif_parse_GuildNotice(fd, RFIFOL(fd,2), (const char*)RFIFOP(fd,6), (const char*)RFIFOP(fd,66)); break;
+ case 0x303F: mapif_parse_GuildEmblem(fd, RFIFOW(fd,2)-12, RFIFOL(fd,4), RFIFOL(fd,8), (const char*)RFIFOP(fd,12)); break;
case 0x3040: mapif_parse_GuildCastleDataLoad(fd, RFIFOW(fd,2), RFIFOB(fd,4)); break;
case 0x3041: mapif_parse_GuildCastleDataSave(fd, RFIFOW(fd,2), RFIFOB(fd,4), RFIFOL(fd,5)); break;
diff --git a/src/char/int_guild.h b/src/char/int_guild.h
index 555f5e123..3eeb1b3db 100644
--- a/src/char/int_guild.h
+++ b/src/char/int_guild.h
@@ -3,6 +3,7 @@
#define _INT_GUILD_H_
int inter_guild_init();
+void inter_guild_final();
int inter_guild_save();
int inter_guild_parse_frommap(int fd);
struct guild *inter_guild_search(int guild_id);
diff --git a/src/char/int_party.c b/src/char/int_party.c
index 0fd58fa14..299a75135 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -19,7 +19,7 @@ int mapif_party_broken(int party_id, int flag);
int party_check_empty(struct party *p);
int mapif_parse_PartyLeave(int fd, int party_id, int account_id);
-// パーティデータの文字列への変換
+// パ?ティデ?タの文字列への?換
int inter_party_tostr(char *str, struct party *p) {
int i, len;
@@ -32,7 +32,7 @@ int inter_party_tostr(char *str, struct party *p) {
return 0;
}
-// パーティデータの文字列からの変換
+// パ?ティデ?タの文字列からの?換
int inter_party_fromstr(char *str, struct party *p) {
int i, j;
int tmp_int[16];
@@ -74,7 +74,7 @@ int inter_party_fromstr(char *str, struct party *p) {
return 0;
}
-// パーティデータのロード
+// パ?ティデ?タのロ?ド
int inter_party_init() {
char line[8192];
struct party *p;
@@ -94,7 +94,7 @@ int inter_party_init() {
continue;
}
- p = calloc(sizeof(struct party), 1);
+ p = (struct party*)aCalloc(sizeof(struct party), 1);
if (p == NULL){
printf("int_party: out of memory!\n");
exit(0);
@@ -107,7 +107,7 @@ int inter_party_init() {
party_check_empty(p);
} else {
printf("int_party: broken data [%s] line %d\n", party_txt, c + 1);
- free(p);
+ aFree(p);
}
c++;
}
@@ -117,7 +117,18 @@ int inter_party_init() {
return 0;
}
-// パーティーデータのセーブ用
+int party_db_final (void *k, void *data, va_list ap) {
+ struct party *p = (struct party *) data;
+ if (p) aFree(p);
+ return 0;
+}
+void inter_party_final()
+{
+ numdb_final(party_db, party_db_final);
+ return;
+}
+
+// パ?ティ?デ?タのセ?ブ用
int inter_party_save_sub(void *key, void *data, va_list ap) {
char line[8192];
FILE *fp;
@@ -129,7 +140,7 @@ int inter_party_save_sub(void *key, void *data, va_list ap) {
return 0;
}
-// パーティーデータのセーブ
+// パ?ティ?デ?タのセ?ブ
int inter_party_save() {
FILE *fp;
int lock;
@@ -146,7 +157,7 @@ int inter_party_save() {
return 0;
}
-// パーティ名検索用
+// パ?ティ名?索用
int search_partyname_sub(void *key,void *data,va_list ap) {
struct party *p = (struct party *)data,**dst;
char *str;
@@ -159,7 +170,7 @@ int search_partyname_sub(void *key,void *data,va_list ap) {
return 0;
}
-// パーティ名検索
+// パ?ティ名?索
struct party* search_partyname(char *str) {
struct party *p = NULL;
numdb_foreach(party_db, search_partyname_sub, str, &p);
@@ -169,7 +180,8 @@ struct party* search_partyname(char *str) {
// EXP公平分配できるかチェック
int party_check_exp_share(struct party *p) {
- int i;
+ int i, dudes=0;
+ int pl1=0,pl2=0,pl3=0;
int maxlv = 0, minlv = 0x7fffffff;
for(i = 0; i < MAX_PARTY; i++) {
@@ -179,13 +191,26 @@ int party_check_exp_share(struct party *p) {
minlv = lv;
if (maxlv < lv)
maxlv = lv;
+ if( lv >= 70 ) dudes+=1000;
+ dudes++;
}
}
-
- return (maxlv == 0 || maxlv-minlv <= party_share_level);
+ if((dudes/1000 >= 2) && (dudes%1000 == 3) && (!strcmp(p->member[0].map,p->member[1].map)) && (!strcmp(p->member[1].map,p->member[2].map))) {
+ pl1=search_character_index(p->member[0].name);
+ pl2=search_character_index(p->member[1].name);
+ pl3=search_character_index(p->member[2].name);
+ printf("PARTY: group of 3 Id1 %d lv %d name %s Id2 %d lv %d name %s Id3 %d lv %d name %s\n",pl1,p->member[0].lv,p->member[0].name,pl2,p->member[1].lv,p->member[1].name,pl3,p->member[2].lv,p->member[2].name);
+ if (char_married(pl1,pl2) && char_child(pl1,pl3))
+ return 1;
+ if (char_married(pl1,pl3) && char_child(pl1,pl2))
+ return 1;
+ if (char_married(pl2,pl3) && char_child(pl2,pl1))
+ return 1;
+ }
+ return (maxlv==0 || maxlv-minlv<=party_share_level);
}
-// パーティが空かどうかチェック
+// パ?ティが空かどうかチェック
int party_check_empty(struct party *p) {
int i;
@@ -199,7 +224,7 @@ int party_check_empty(struct party *p) {
// 誰もいないので解散
mapif_party_broken(p->party_id, 0);
numdb_erase(party_db, p->party_id);
- free(p);
+ aFree(p);
return 1;
}
@@ -214,12 +239,12 @@ int party_check_conflict_sub(void *key, void *data, va_list ap) {
account_id=va_arg(ap, int);
nick=va_arg(ap, char *);
- if (p->party_id == party_id) // 本来の所属なので問題なし
+ if (p->party_id == party_id) // 本?の所?なので問題なし
return 0;
for(i = 0; i < MAX_PARTY; i++) {
if (p->member[i].account_id == account_id && strcmp(p->member[i].name, nick) == 0) {
- // 別のパーティに偽の所属データがあるので脱退
+ // 別のパ?ティに?の所?デ?タがあるので?退
printf("int_party: party conflict! %d %d %d\n", account_id, party_id, p->party_id);
mapif_parse_PartyLeave(-1, p->party_id, account_id);
}
@@ -238,7 +263,7 @@ int party_check_conflict(int party_id, int account_id, char *nick) {
//-------------------------------------------------------------------
// map serverへの通信
-// パーティ作成可否
+// パ?ティ作成可否
int mapif_party_created(int fd,int account_id, struct party *p) {
WFIFOW(fd,0) = 0x3820;
WFIFOL(fd,2) = account_id;
@@ -257,7 +282,7 @@ int mapif_party_created(int fd,int account_id, struct party *p) {
return 0;
}
-// パーティ情報見つからず
+// パ?ティ情報見つからず
int mapif_party_noinfo(int fd, int party_id) {
WFIFOW(fd,0) = 0x3821;
WFIFOW(fd,2) = 8;
@@ -268,9 +293,9 @@ int mapif_party_noinfo(int fd, int party_id) {
return 0;
}
-// パーティ情報まとめ送り
+// パ?ティ情報まとめ送り
int mapif_party_info(int fd, struct party *p) {
- unsigned char buf[4 + sizeof(struct party)];
+ unsigned char buf[2048];
WBUFW(buf,0) = 0x3821;
memcpy(buf + 4, p, sizeof(struct party));
@@ -284,7 +309,7 @@ int mapif_party_info(int fd, struct party *p) {
return 0;
}
-// パーティメンバ追加可否
+// パ?ティメンバ追加可否
int mapif_party_memberadded(int fd, int party_id, int account_id, int flag) {
WFIFOW(fd,0) = 0x3822;
WFIFOL(fd,2) = party_id;
@@ -295,7 +320,7 @@ int mapif_party_memberadded(int fd, int party_id, int account_id, int flag) {
return 0;
}
-// パーティ設定変更通知
+// パ?ティ設定?更通知
int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag) {
unsigned char buf[15];
@@ -314,7 +339,7 @@ int mapif_party_optionchanged(int fd,struct party *p, int account_id, int flag)
return 0;
}
-// パーティ脱退通知
+// パ?ティ?退通知
int mapif_party_leaved(int party_id,int account_id, char *name) {
unsigned char buf[34];
@@ -328,7 +353,7 @@ int mapif_party_leaved(int party_id,int account_id, char *name) {
return 0;
}
-// パーティマップ更新通知
+// パ?ティマップ更新通知
int mapif_party_membermoved(struct party *p, int idx) {
unsigned char buf[29];
@@ -343,7 +368,7 @@ int mapif_party_membermoved(struct party *p, int idx) {
return 0;
}
-// パーティ解散通知
+// パ?ティ解散通知
int mapif_party_broken(int party_id, int flag) {
unsigned char buf[7];
WBUFW(buf,0) = 0x3826;
@@ -355,16 +380,16 @@ int mapif_party_broken(int party_id, int flag) {
return 0;
}
-// パーティ内発言
-int mapif_party_message(int party_id, int account_id, char *mes, int len) {
- unsigned char buf[len+12];
+// パ?ティ??言
+int mapif_party_message(int party_id, int account_id, char *mes, int len, int sfd) {
+ unsigned char buf[2048];
WBUFW(buf,0) = 0x3827;
WBUFW(buf,2) = len + 12;
WBUFL(buf,4) = party_id;
WBUFL(buf,8) = account_id;
memcpy(WBUFP(buf,12), mes, len);
- mapif_sendall(buf,len + 12);
+ mapif_sendallwos(sfd, buf,len + 12);
return 0;
}
@@ -373,8 +398,8 @@ int mapif_party_message(int party_id, int account_id, char *mes, int len) {
// map serverからの通信
-// パーティ
-int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char *map, int lv) {
+// パ?ティ
+int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char *map, int lv, int item, int item2) {
struct party *p;
int i;
@@ -391,7 +416,7 @@ int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char
mapif_party_created(fd, account_id, NULL);
return 0;
}
- p = calloc(sizeof(struct party), 1);
+ p = (struct party *) aCalloc(sizeof(struct party), 1);
if (p == NULL) {
printf("int_party: out of memory !\n");
mapif_party_created(fd,account_id,NULL);
@@ -401,7 +426,12 @@ int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char
p->party_id = party_newid++;
memcpy(p->name, name, 24);
p->exp = 0;
- p->item = 0;
+ p->item = item;
+ //<item1>アイテム?集方法。0で個人別、1でパ?ティ公有
+ //<item2>アイテム分配方法。0で個人別、1でパ?ティに均等分配
+ //difference between "collection" and "distribution" is...? ^^;
+ p->itemc = 0;
+
p->member[0].account_id = account_id;
memcpy(p->member[0].name, nick, 24);
memcpy(p->member[0].map, map, 16);
@@ -417,11 +447,11 @@ int mapif_parse_CreateParty(int fd, int account_id, char *name, char *nick, char
return 0;
}
-// パーティ情報要求
+// パ?ティ情報要求
int mapif_parse_PartyInfo(int fd, int party_id) {
struct party *p;
- p = numdb_search(party_db, party_id);
+ p = (struct party *) numdb_search(party_db, party_id);
if (p != NULL)
mapif_party_info(fd, p);
else
@@ -430,12 +460,12 @@ int mapif_parse_PartyInfo(int fd, int party_id) {
return 0;
}
-// パーティ追加要求
+// パ?ティ追加要求
int mapif_parse_PartyAddMember(int fd, int party_id, int account_id, char *nick, char *map, int lv) {
struct party *p;
int i;
- p = numdb_search(party_db, party_id);
+ p = (struct party *) numdb_search(party_db, party_id);
if (p == NULL) {
mapif_party_memberadded(fd, party_id, account_id, 1);
return 0;
@@ -468,12 +498,12 @@ int mapif_parse_PartyAddMember(int fd, int party_id, int account_id, char *nick,
return 0;
}
-// パーティー設定変更要求
+// パ?ティ?設定?更要求
int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp, int item) {
struct party *p;
int flag = 0;
- p = numdb_search(party_db, party_id);
+ p = (struct party *) numdb_search(party_db, party_id);
if (p == NULL)
return 0;
@@ -489,12 +519,12 @@ int mapif_parse_PartyChangeOption(int fd, int party_id, int account_id, int exp,
return 0;
}
-// パーティ脱退要求
+// パ?ティ?退要求
int mapif_parse_PartyLeave(int fd, int party_id, int account_id) {
struct party *p;
int i;
- p = numdb_search(party_db, party_id);
+ p = (struct party *) numdb_search(party_db, party_id);
if (p != NULL) {
for(i = 0; i < MAX_PARTY; i++) {
if (p->member[i].account_id == account_id) {
@@ -502,7 +532,7 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id) {
memset(&p->member[i], 0, sizeof(struct party_member));
if (party_check_empty(p) == 0)
- mapif_party_info(-1, p);// まだ人がいるのでデータ送信
+ mapif_party_info(-1, p);// まだ人がいるのでデ?タ送信
return 0;
}
}
@@ -511,12 +541,12 @@ int mapif_parse_PartyLeave(int fd, int party_id, int account_id) {
return 0;
}
-// パーティマップ更新要求
+// パ?ティマップ更新要求
int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, char *map, int online, int lv) {
struct party *p;
int i;
- p = numdb_search(party_db, party_id);
+ p = (struct party *) numdb_search(party_db, party_id);
if (p == NULL)
return 0;
@@ -542,11 +572,11 @@ int mapif_parse_PartyChangeMap(int fd, int party_id, int account_id, char *map,
return 0;
}
-// パーティ解散要求
+// パ?ティ解散要求
int mapif_parse_BreakParty(int fd, int party_id) {
struct party *p;
- p = numdb_search(party_db, party_id);
+ p = (struct party *) numdb_search(party_db, party_id);
if (p == NULL)
return 0;
@@ -556,31 +586,31 @@ int mapif_parse_BreakParty(int fd, int party_id) {
return 0;
}
-// パーティメッセージ送信
+// パ?ティメッセ?ジ送信
int mapif_parse_PartyMessage(int fd, int party_id, int account_id, char *mes, int len) {
- return mapif_party_message(party_id, account_id, mes, len);
+ return mapif_party_message(party_id, account_id, mes, len, fd);
}
-// パーティチェック要求
+// パ?ティチェック要求
int mapif_parse_PartyCheck(int fd, int party_id, int account_id, char *nick) {
return party_check_conflict(party_id, account_id, nick);
}
// map server からの通信
-// ・1パケットのみ解析すること
-// ・パケット長データはinter.cにセットしておくこと
-// ・パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
-// ・エラーなら0(false)、そうでないなら1(true)をかえさなければならない
+// ?1パケットのみ解析すること
+// ?パケット長デ?タはinter.cにセットしておくこと
+// ?パケット長チェックや、RFIFOSKIPは呼び出し元で行われるので行ってはならない
+// ?エラ?なら0(false)、そうでないなら1(true)をかえさなければならない
int inter_party_parse_frommap(int fd) {
switch(RFIFOW(fd,0)) {
- case 0x3020: mapif_parse_CreateParty(fd, RFIFOL(fd,2), RFIFOP(fd,6), RFIFOP(fd,30), RFIFOP(fd,54), RFIFOW(fd,70)); break;
+ case 0x3020: mapif_parse_CreateParty(fd, RFIFOL(fd,2), (char*)RFIFOP(fd,6), (char*)RFIFOP(fd,30), (char*)RFIFOP(fd,54), RFIFOW(fd,70), RFIFOB(fd,72), RFIFOB(fd,73)); break;
case 0x3021: mapif_parse_PartyInfo(fd, RFIFOL(fd,2)); break;
- case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOP(fd,10), RFIFOP(fd,34), RFIFOW(fd,50)); break;
+ case 0x3022: mapif_parse_PartyAddMember(fd, RFIFOL(fd,2), RFIFOL(fd,6), (char*)RFIFOP(fd,10), (char*)RFIFOP(fd,34), RFIFOW(fd,50)); break;
case 0x3023: mapif_parse_PartyChangeOption(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOW(fd,10), RFIFOW(fd,12)); break;
case 0x3024: mapif_parse_PartyLeave(fd, RFIFOL(fd,2), RFIFOL(fd,6)); break;
- case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOP(fd,10), RFIFOB(fd,26), RFIFOW(fd,27)); break;
+ case 0x3025: mapif_parse_PartyChangeMap(fd, RFIFOL(fd,2), RFIFOL(fd,6), (char*)RFIFOP(fd,10), RFIFOB(fd,26), RFIFOW(fd,27)); break;
case 0x3026: mapif_parse_BreakParty(fd, RFIFOL(fd,2)); break;
- case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
- case 0x3028: mapif_parse_PartyCheck(fd, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOP(fd,10)); break;
+ case 0x3027: mapif_parse_PartyMessage(fd, RFIFOL(fd,4), RFIFOL(fd,8), (char*)RFIFOP(fd,12), RFIFOW(fd,2)-12); break;
+ case 0x3028: mapif_parse_PartyCheck(fd, RFIFOL(fd,2), RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
default:
return 0;
}
@@ -588,7 +618,7 @@ int inter_party_parse_frommap(int fd) {
return 1;
}
-// サーバーから脱退要求(キャラ削除用)
+// サ?バ?から?退要求(キャラ削除用)
int inter_party_leave(int party_id, int account_id) {
return mapif_parse_PartyLeave(-1, party_id, account_id);
}
diff --git a/src/char/int_party.h b/src/char/int_party.h
index b265b4c2e..e3180f3b7 100644
--- a/src/char/int_party.h
+++ b/src/char/int_party.h
@@ -3,6 +3,7 @@
#define _INT_PARTY_H_
int inter_party_init();
+void inter_party_final();
int inter_party_save();
int inter_party_parse_frommap(int fd);
diff --git a/src/char/int_pet.c b/src/char/int_pet.c
index cff1e434f..ab53d0533 100644
--- a/src/char/int_pet.c
+++ b/src/char/int_pet.c
@@ -30,7 +30,7 @@ int inter_pet_tostr(char *str,struct s_pet *p)
p->intimate = 1000;
len=sprintf(str,"%d,%d,%s\t%d,%d,%d,%d,%d,%d,%d,%d,%d",
- p->pet_id,p->class,p->name,p->account_id,p->char_id,p->level,p->egg_id,
+ p->pet_id,p->class_,p->name,p->account_id,p->char_id,p->level,p->egg_id,
p->equip,p->intimate,p->hungry,p->rename_flag,p->incuvate);
return 0;
@@ -41,18 +41,18 @@ int inter_pet_fromstr(char *str,struct s_pet *p)
int s;
int tmp_int[16];
char tmp_str[256];
-
+
memset(p,0,sizeof(struct s_pet));
-
+
// printf("sscanf pet main info\n");
s=sscanf(str,"%d,%d,%[^\t]\t%d,%d,%d,%d,%d,%d,%d,%d,%d",&tmp_int[0],&tmp_int[1],tmp_str,&tmp_int[2],
&tmp_int[3],&tmp_int[4],&tmp_int[5],&tmp_int[6],&tmp_int[7],&tmp_int[8],&tmp_int[9],&tmp_int[10]);
if(s!=12)
return 1;
-
+
p->pet_id = tmp_int[0];
- p->class = tmp_int[1];
+ p->class_ = tmp_int[1];
memcpy(p->name,tmp_str,24);
p->account_id = tmp_int[2];
p->char_id = tmp_int[3];
@@ -88,7 +88,7 @@ int inter_pet_init()
if( (fp=fopen(pet_txt,"r"))==NULL )
return 1;
while(fgets(line,sizeof(line),fp)){
- p=calloc(sizeof(struct s_pet), 1);
+ p = (struct s_pet*)aCalloc(sizeof(struct s_pet), 1);
if(p==NULL){
printf("int_pet: out of memory!\n");
exit(0);
@@ -100,7 +100,7 @@ int inter_pet_init()
numdb_insert(pet_db,p->pet_id,p);
}else{
printf("int_pet: broken data [%s] line %d\n",pet_txt,c);
- free(p);
+ aFree(p);
}
c++;
}
@@ -109,6 +109,17 @@ int inter_pet_init()
return 0;
}
+int pet_db_final (void *k, void *data, va_list ap) {
+ struct s_pet *p = (struct s_pet *) data;
+ if (p) aFree(p);
+ return 0;
+}
+void inter_pet_final()
+{
+ numdb_final(pet_db, pet_db_final);
+ return;
+}
+
int inter_pet_save_sub(void *key,void *data,va_list ap)
{
char line[8192];
@@ -136,7 +147,7 @@ int inter_pet_save()
int inter_pet_delete(int pet_id)
{
struct s_pet *p;
- p = numdb_search(pet_db,pet_id);
+ p = (struct s_pet *) numdb_search(pet_db,pet_id);
if( p == NULL)
return 1;
else {
@@ -210,7 +221,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet
short pet_equip,short intimate,short hungry,char rename_flag,char incuvate,char *pet_name)
{
struct s_pet *p;
- p=malloc(sizeof(struct s_pet));
+ p= (struct s_pet *) aMalloc(sizeof(struct s_pet));
if(p==NULL){
printf("int_pet: out of memory !\n");
mapif_pet_created(fd,account_id,NULL);
@@ -225,7 +236,7 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet
p->account_id = account_id;
p->char_id = char_id;
}
- p->class = pet_class;
+ p->class_ = pet_class;
p->level = pet_lv;
p->egg_id = pet_egg_id;
p->equip = pet_equip;
@@ -242,18 +253,18 @@ int mapif_create_pet(int fd,int account_id,int char_id,short pet_class,short pet
p->intimate = 0;
else if(p->intimate > 1000)
p->intimate = 1000;
-
+
numdb_insert(pet_db,p->pet_id,p);
-
+
mapif_pet_created(fd,account_id,p);
-
+
return 0;
}
int mapif_load_pet(int fd,int account_id,int char_id,int pet_id)
{
struct s_pet *p;
- p=numdb_search(pet_db,pet_id);
+ p=(struct s_pet *)numdb_search(pet_db,pet_id);
if(p!=NULL) {
if(p->incuvate == 1) {
p->account_id = p->char_id = 0;
@@ -280,9 +291,9 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data)
}
else{
pet_id = data->pet_id;
- p=numdb_search(pet_db,pet_id);
+ p=(struct s_pet *)numdb_search(pet_db,pet_id);
if(p == NULL) {
- p=malloc(sizeof(struct s_pet));
+ p=(struct s_pet *)aMalloc(sizeof(struct s_pet));
if(p==NULL){
printf("int_pet: out of memory !\n");
mapif_save_pet_ack(fd,account_id,1);
@@ -292,7 +303,7 @@ int mapif_save_pet(int fd,int account_id,struct s_pet *data)
p->pet_id = data->pet_id;
if(p->pet_id == 0)
data->pet_id = p->pet_id = pet_newid++;
- numdb_insert(pet_db,p->pet_id,p);
+ numdb_insert(pet_db,p->pet_id,p);
}
if(data->hungry < 0)
data->hungry = 0;
@@ -322,7 +333,7 @@ int mapif_delete_pet(int fd,int pet_id)
int mapif_parse_CreatePet(int fd)
{
mapif_create_pet(fd,RFIFOL(fd,2),RFIFOL(fd,6),RFIFOW(fd,10),RFIFOW(fd,12),RFIFOW(fd,14),RFIFOW(fd,16),RFIFOL(fd,18),
- RFIFOL(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),RFIFOP(fd,24));
+ RFIFOL(fd,20),RFIFOB(fd,22),RFIFOB(fd,23),(char*)RFIFOP(fd,24));
return 0;
}
diff --git a/src/char/int_pet.h b/src/char/int_pet.h
index 993f913ab..3a48ada3b 100644
--- a/src/char/int_pet.h
+++ b/src/char/int_pet.h
@@ -3,6 +3,7 @@
#define _INT_PET_H_
int inter_pet_init();
+void inter_pet_final();
int inter_pet_save();
int inter_pet_delete(int pet_id);
diff --git a/src/char/int_storage.c b/src/char/int_storage.c
index 7a4022a55..eaf9e001a 100644
--- a/src/char/int_storage.c
+++ b/src/char/int_storage.c
@@ -28,11 +28,11 @@ int storage_tostr(char *str,struct storage *p)
str_p += sprintf(str_p,"%d,%d\t",p->account_id,p->storage_amount);
for(i=0;i<MAX_STORAGE;i++)
- if( (p->storage[i].nameid) && (p->storage[i].amount) ){
+ if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){
str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->storage[i].id,p->storage[i].nameid,p->storage[i].amount,p->storage[i].equip,
- p->storage[i].identify,p->storage[i].refine,p->storage[i].attribute,
- p->storage[i].card[0],p->storage[i].card[1],p->storage[i].card[2],p->storage[i].card[3]);
+ p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip,
+ p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute,
+ p->storage_[i].card[0],p->storage_[i].card[1],p->storage_[i].card[2],p->storage_[i].card[3]);
f++;
}
@@ -56,49 +56,49 @@ int storage_fromstr(char *str,struct storage *p)
if(set!=2)
return 1;
if(str[next]=='\n' || str[next]=='\r')
- return 0;
+ return 0;
next++;
for(i=0;str[next] && str[next]!='\t';i++){
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[10], &len) == 12) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &len) == 11) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
-
+
else return 1;
}
return 0;
@@ -111,11 +111,11 @@ int guild_storage_tostr(char *str,struct guild_storage *p)
str_p+=sprintf(str,"%d,%d\t",p->guild_id,p->storage_amount);
for(i=0;i<MAX_GUILD_STORAGE;i++)
- if( (p->storage[i].nameid) && (p->storage[i].amount) ){
+ if( (p->storage_[i].nameid) && (p->storage_[i].amount) ){
str_p += sprintf(str_p,"%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d ",
- p->storage[i].id,p->storage[i].nameid,p->storage[i].amount,p->storage[i].equip,
- p->storage[i].identify,p->storage[i].refine,p->storage[i].attribute,
- p->storage[i].card[0],p->storage[i].card[1],p->storage[i].card[2],p->storage[i].card[3]);
+ p->storage_[i].id,p->storage_[i].nameid,p->storage_[i].amount,p->storage_[i].equip,
+ p->storage_[i].identify,p->storage_[i].refine,p->storage_[i].attribute,
+ p->storage_[i].card[0],p->storage_[i].card[1],p->storage_[i].card[2],p->storage_[i].card[3]);
f++;
}
@@ -138,49 +138,49 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
if(set!=2)
return 1;
if(str[next]=='\n' || str[next]=='\r')
- return 0;
+ return 0;
next++;
for(i=0;str[next] && str[next]!='\t';i++){
if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &tmp_int[10], &len) == 12) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
else if(sscanf(str + next, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d%n",
&tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3],
&tmp_int[4], &tmp_int[5], &tmp_int[6],
&tmp_int[7], &tmp_int[8], &tmp_int[9], &tmp_int[10], &len) == 11) {
- p->storage[i].id = tmp_int[0];
- p->storage[i].nameid = tmp_int[1];
- p->storage[i].amount = tmp_int[2];
- p->storage[i].equip = tmp_int[3];
- p->storage[i].identify = tmp_int[4];
- p->storage[i].refine = tmp_int[5];
- p->storage[i].attribute = tmp_int[6];
- p->storage[i].card[0] = tmp_int[7];
- p->storage[i].card[1] = tmp_int[8];
- p->storage[i].card[2] = tmp_int[9];
- p->storage[i].card[3] = tmp_int[10];
+ p->storage_[i].id = tmp_int[0];
+ p->storage_[i].nameid = tmp_int[1];
+ p->storage_[i].amount = tmp_int[2];
+ p->storage_[i].equip = tmp_int[3];
+ p->storage_[i].identify = tmp_int[4];
+ p->storage_[i].refine = tmp_int[5];
+ p->storage_[i].attribute = tmp_int[6];
+ p->storage_[i].card[0] = tmp_int[7];
+ p->storage_[i].card[1] = tmp_int[8];
+ p->storage_[i].card[2] = tmp_int[9];
+ p->storage_[i].card[3] = tmp_int[10];
next += len;
if (str[next] == ' ')
- next++;
+ next++;
}
-
+
else return 1;
}
return 0;
@@ -190,9 +190,9 @@ int guild_storage_fromstr(char *str,struct guild_storage *p)
struct storage *account2storage(int account_id)
{
struct storage *s;
- s=numdb_search(storage_db,account_id);
+ s= (struct storage *) numdb_search(storage_db,account_id);
if(s == NULL) {
- s = calloc(sizeof(struct storage), 1);
+ s = (struct storage *) aCalloc(sizeof(struct storage), 1);
if(s==NULL){
printf("int_storage: out of memory!\n");
exit(0);
@@ -208,9 +208,9 @@ struct guild_storage *guild2storage(int guild_id)
{
struct guild_storage *gs = NULL;
if(inter_guild_search(guild_id) != NULL) {
- gs=numdb_search(guild_storage_db,guild_id);
+ gs= (struct guild_storage *) numdb_search(guild_storage_db,guild_id);
if(gs == NULL) {
- gs = calloc(sizeof(struct guild_storage), 1);
+ gs = (struct guild_storage *) aCalloc(sizeof(struct guild_storage), 1);
if(gs==NULL){
printf("int_storage: out of memory!\n");
exit(0);
@@ -242,7 +242,7 @@ int inter_storage_init()
}
while(fgets(line,65535,fp)){
sscanf(line,"%d",&tmp_int);
- s=calloc(sizeof(struct storage), 1);
+ s = (struct storage*)aCalloc(sizeof(struct storage), 1);
if(s==NULL){
printf("int_storage: out of memory!\n");
exit(0);
@@ -254,7 +254,7 @@ int inter_storage_init()
}
else{
printf("int_storage: broken data [%s] line %d\n",storage_txt,c);
- free(s);
+ aFree(s);
}
c++;
}
@@ -270,7 +270,7 @@ int inter_storage_init()
}
while(fgets(line,65535,fp)){
sscanf(line,"%d",&tmp_int);
- gs=calloc(sizeof(struct guild_storage), 1);
+ gs = (struct guild_storage*)aCalloc(sizeof(struct guild_storage), 1);
if(gs==NULL){
printf("int_storage: out of memory!\n");
exit(0);
@@ -282,7 +282,7 @@ int inter_storage_init()
}
else{
printf("int_storage: broken data [%s] line %d\n",guild_storage_txt,c);
- free(gs);
+ aFree(gs);
}
c++;
}
@@ -291,6 +291,22 @@ int inter_storage_init()
return 0;
}
+int storage_db_final (void *k, void *data, va_list ap) {
+ struct storage *p = (struct storage *) data;
+ if (p) aFree(p);
+ return 0;
+}
+int guild_storage_db_final (void *k, void *data, va_list ap) {
+ struct guild_storage *p = (struct guild_storage *) data;
+ if (p) aFree(p);
+ return 0;
+}
+void inter_storage_final() {
+ numdb_final(storage_db, storage_db_final);
+ numdb_final(guild_storage_db, guild_storage_db_final);
+ return;
+}
+
int inter_storage_save_sub(void *key,void *data,va_list ap)
{
char line[65536];
@@ -348,15 +364,15 @@ int inter_guild_storage_save()
// 倉庫データ削除
int inter_storage_delete(int account_id)
{
- struct storage *s = numdb_search(storage_db,account_id);
+ struct storage *s = (struct storage *) numdb_search(storage_db,account_id);
if(s) {
int i;
for(i=0;i<s->storage_amount;i++){
- if(s->storage[i].card[0] == (short)0xff00)
- inter_pet_delete(*((long *)(&s->storage[i].card[2])));
+ if(s->storage_[i].card[0] == (short)0xff00)
+ inter_pet_delete(*((long *)(&s->storage_[i].card[2])));
}
numdb_erase(storage_db,account_id);
- free(s);
+ aFree(s);
}
return 0;
}
@@ -364,15 +380,15 @@ int inter_storage_delete(int account_id)
// ギルド倉庫データ削除
int inter_guild_storage_delete(int guild_id)
{
- struct guild_storage *gs = numdb_search(guild_storage_db,guild_id);
+ struct guild_storage *gs = (struct guild_storage *) numdb_search(guild_storage_db,guild_id);
if(gs) {
int i;
for(i=0;i<gs->storage_amount;i++){
- if(gs->storage[i].card[0] == (short)0xff00)
- inter_pet_delete(*((long *)(&gs->storage[i].card[2])));
+ if(gs->storage_[i].card[0] == (short)0xff00)
+ inter_pet_delete(*((long *)(&gs->storage_[i].card[2])));
}
numdb_erase(guild_storage_db,guild_id);
- free(gs);
+ aFree(gs);
}
return 0;
}
diff --git a/src/char/int_storage.h b/src/char/int_storage.h
index d918f5fe3..f228be53d 100644
--- a/src/char/int_storage.h
+++ b/src/char/int_storage.h
@@ -3,6 +3,7 @@
#define _INT_STORAGE_H_
int inter_storage_init();
+void inter_storage_final();
int inter_storage_save();
int inter_guild_storage_save();
int inter_storage_delete(int account_id);
diff --git a/src/char/inter.c b/src/char/inter.c
index bf7bdcccf..0dca38559 100644
--- a/src/char/inter.c
+++ b/src/char/inter.c
@@ -47,7 +47,7 @@ int inter_send_packet_length[] = {
int inter_recv_packet_length[] = {
-1,-1, 7,-1, -1, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
6,-1, 0, 0, 0, 0, 0, 0, 10,-1, 0, 0, 0, 0, 0, 0,
- 72, 6,52,14, 10,29, 6,-1, 34, 0, 0, 0, 0, 0, 0, 0,
+ 74, 6,52,14, 10,29, 6,-1, 34, 0, 0, 0, 0, 0, 0, 0,
-1, 6,-1, 0, 55,19, 6,-1, 14,-1,-1,-1, 14,19,186,-1,
5, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -114,7 +114,7 @@ int inter_accreg_init() {
while(fgets(line, sizeof(line)-1, fp)){
line[sizeof(line)-1] = '\0';
- reg = calloc(sizeof(struct accreg), 1);
+ reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1);
if (reg == NULL) {
printf("inter: accreg: out of memory!\n");
exit(0);
@@ -123,7 +123,7 @@ int inter_accreg_init() {
numdb_insert(accreg_db, reg->account_id, reg);
} else {
printf("inter: accreg: broken data [%s] line %d\n", accreg_txt, c);
- free(reg);
+ aFree(reg);
}
c++;
}
@@ -261,6 +261,29 @@ int inter_init(const char *file) {
return 0;
}
+// finalize
+int accreg_db_final (void *k, void *data, va_list ap) {
+ struct accreg *p = (struct accreg *) data;
+ if (p) aFree(p);
+ return 0;
+}
+int wis_db_final (void *k, void *data, va_list ap) {
+ struct WisData *p = (struct WisData *) data;
+ if (p) aFree(p);
+ return 0;
+}
+void inter_final() {
+ numdb_final(accreg_db, accreg_db_final);
+ numdb_final(wis_db, wis_db_final);
+
+ inter_party_final();
+ inter_guild_final();
+ inter_storage_final();
+ inter_pet_final();
+
+ return;
+}
+
// マップサーバー接続
int inter_mapif_init(int fd) {
inter_guild_mapif_init(fd);
@@ -272,13 +295,13 @@ int inter_mapif_init(int fd) {
// sended packets to map-server
// GMメッセージ送信
-int mapif_GMmessage(unsigned char *mes, int len) {
- unsigned char buf[len];
+int mapif_GMmessage(unsigned char *mes, int len, int sfd) {
+ unsigned char buf[2048];
WBUFW(buf,0) = 0x3800;
WBUFW(buf,2) = len;
memcpy(WBUFP(buf,4), mes, len - 4);
- mapif_sendall(buf, len);
+ mapif_sendallwos(sfd, buf, len);
// printf("inter server: GM:%d %s\n", len, mes);
return 0;
@@ -286,7 +309,7 @@ int mapif_GMmessage(unsigned char *mes, int len) {
// Wisp/page transmission to all map-server
int mapif_wis_message(struct WisData *wd) {
- unsigned char buf[56 + wd->len];
+ unsigned char buf[2048];
WBUFW(buf, 0) = 0x3801;
WBUFW(buf, 2) = 56 + wd->len;
@@ -314,7 +337,7 @@ int mapif_wis_end(struct WisData *wd, int flag) {
// アカウント変数送信
int mapif_account_reg(int fd, unsigned char *src) {
- unsigned char buf[WBUFW(src,2)];
+ unsigned char buf[2048];
memcpy(WBUFP(buf,0),src,WBUFW(src,2));
WBUFW(buf, 0) = 0x3804;
@@ -325,7 +348,7 @@ int mapif_account_reg(int fd, unsigned char *src) {
// アカウント変数要求返信
int mapif_account_reg_reply(int fd,int account_id) {
- struct accreg *reg = numdb_search(accreg_db,account_id);
+ struct accreg *reg = (struct accreg*)numdb_search(accreg_db,account_id);
WFIFOW(fd,0) = 0x3804;
WFIFOL(fd,4) = account_id;
@@ -366,12 +389,12 @@ int check_ttl_wisdata() {
wis_delnum = 0;
numdb_foreach(wis_db, check_ttl_wisdata_sub, tick);
for(i = 0; i < wis_delnum; i++) {
- struct WisData *wd = numdb_search(wis_db, wis_dellist[i]);
+ struct WisData *wd = (struct WisData*)numdb_search(wis_db, wis_dellist[i]);
printf("inter: wis data id=%d time out : from %s to %s\n", wd->id, wd->src, wd->dst);
// removed. not send information after a timeout. Just no answer for the player
//mapif_wis_end(wd, 1); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
numdb_erase(wis_db, wd->id);
- free(wd);
+ aFree(wd);
}
} while(wis_delnum >= WISDELLIST_MAX);
@@ -383,7 +406,7 @@ int check_ttl_wisdata() {
// GMメッセージ送信
int mapif_parse_GMmessage(int fd) {
- mapif_GMmessage(RFIFOP(fd,4), RFIFOW(fd,2));
+ mapif_GMmessage(RFIFOP(fd,4), RFIFOW(fd,2), fd);
return 0;
}
@@ -403,7 +426,7 @@ int mapif_parse_WisRequest(int fd) {
}
// search if character exists before to ask all map-servers
- if ((index = search_character_index(RFIFOP(fd,28))) == -1) {
+ if ((index = search_character_index((char*)RFIFOP(fd,28))) == -1) {
unsigned char buf[27];
WBUFW(buf, 0) = 0x3802;
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), 24);
@@ -413,9 +436,9 @@ int mapif_parse_WisRequest(int fd) {
} else {
// to be sure of the correct name, rewrite it
memset(RFIFOP(fd,28), 0, 24);
- strncpy(RFIFOP(fd,28), search_character_name(index), 24);
+ strncpy((char*)RFIFOP(fd,28), search_character_name(index), 24);
// if source is destination, don't ask other servers.
- if (strcmp(RFIFOP(fd,4),RFIFOP(fd,28)) == 0) {
+ if (strcmp((char*)RFIFOP(fd,4),(char*)RFIFOP(fd,28)) == 0) {
unsigned char buf[27];
WBUFW(buf, 0) = 0x3802;
memcpy(WBUFP(buf, 2), RFIFOP(fd, 4), 24);
@@ -423,7 +446,7 @@ int mapif_parse_WisRequest(int fd) {
mapif_send(fd, buf, 27);
} else {
- wd = (struct WisData *)calloc(sizeof(struct WisData), 1);
+ wd = (struct WisData *)aCalloc(sizeof(struct WisData), 1);
if (wd == NULL){
printf("inter: WisRequest: out of memory !\n");
return 0;
@@ -450,7 +473,7 @@ int mapif_parse_WisRequest(int fd) {
// Wisp/page transmission result
int mapif_parse_WisReply(int fd) {
int id = RFIFOL(fd,2), flag = RFIFOB(fd,6);
- struct WisData *wd = numdb_search(wis_db, id);
+ struct WisData *wd = (struct WisData*)numdb_search(wis_db, id);
if (wd == NULL)
return 0; // This wisp was probably suppress before, because it was timeout of because of target was found on another map-server
@@ -458,7 +481,7 @@ int mapif_parse_WisReply(int fd) {
if ((--wd->count) <= 0 || flag != 1) {
mapif_wis_end(wd, flag); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target
numdb_erase(wis_db, id);
- free(wd);
+ aFree(wd);
}
return 0;
@@ -466,7 +489,7 @@ int mapif_parse_WisReply(int fd) {
// Received wisp message from map-server for ALL gm (just copy the message and resends it to ALL map-servers)
int mapif_parse_WisToGM(int fd) {
- unsigned char buf[RFIFOW(fd,2)]; // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
+ unsigned char buf[2048]; // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B
memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2));
WBUFW(buf, 0) = 0x3803;
@@ -478,10 +501,10 @@ int mapif_parse_WisToGM(int fd) {
// アカウント変数保存要求
int mapif_parse_AccReg(int fd) {
int j, p;
- struct accreg *reg = numdb_search(accreg_db, RFIFOL(fd,4));
+ struct accreg *reg = (struct accreg*)numdb_search(accreg_db, RFIFOL(fd,4));
if (reg == NULL) {
- if ((reg = calloc(sizeof(struct accreg), 1)) == NULL) {
+ if ((reg = (struct accreg*)aCalloc(sizeof(struct accreg), 1)) == NULL) {
printf("inter: accreg: out of memory !\n");
exit(0);
}
diff --git a/src/char/inter.h b/src/char/inter.h
index 0b6f809d7..636ce31d8 100644
--- a/src/char/inter.h
+++ b/src/char/inter.h
@@ -3,6 +3,7 @@
#define _INTER_H_
int inter_init(const char *file);
+void inter_final();
int inter_save();
int inter_parse_frommap(int fd);
int inter_mapif_init(int fd);