diff options
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/Makefile | 4 | ||||
-rw-r--r-- | src/char/char.c | 302 | ||||
-rw-r--r-- | src/char/int_guild.c | 62 | ||||
-rw-r--r-- | src/char/int_party.c | 33 | ||||
-rw-r--r-- | src/char/int_storage.c | 46 | ||||
-rw-r--r-- | src/char/inter.c | 52 |
6 files changed, 166 insertions, 333 deletions
diff --git a/src/char/Makefile b/src/char/Makefile index 308747d..c448627 100644 --- a/src/char/Makefile +++ b/src/char/Makefile @@ -2,8 +2,8 @@ include ../../make.defs all: char -COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/malloc.o ../common/mt_rand.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/mt_rand.h +COMMON_OBJ = ../common/core.o ../common/socket.o ../common/timer.o ../common/db.o ../common/lock.o ../common/mt_rand.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/mt_rand.h char: char.o inter.o int_party.o int_guild.o int_storage.o $(COMMON_OBJ) char.o: char.c char.h inter.h $(COMMON_H) ../common/version.h diff --git a/src/char/char.c b/src/char/char.c index 5ac11d4..d340f1d 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -199,7 +199,7 @@ int search_character_index (char *character_name) for (i = 0; i < char_num; i++) { // Without case sensitive check (increase the number of similar character names found) - if (stricmp (char_dat[i].name, character_name) == 0) + if (strcasecmp (char_dat[i].name, character_name) == 0) { // Strict comparison (if found, we finish the function immediatly with correct value) if (strcmp (char_dat[i].name, character_name) == 0) @@ -427,7 +427,7 @@ int mmo_char_fromstr (char *str, struct mmo_charstatus *p) } } - if (strcmpi (wisp_server_name, p->name) == 0) + if (strcasecmp (wisp_server_name, p->name) == 0) { printf ("mmo_auth_init: ******WARNING: character name has wisp server name.\n"); @@ -592,18 +592,8 @@ int mmo_char_init (void) FILE *fp; char_max = 256; - char_dat = calloc (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 (int) * 256, 1); - if (!online_chars) - { - printf ("out of memory: mmo_char_init (calloc of online_chars).\n"); - exit (1); - } + CREATE (char_dat, struct mmo_charstatus, 256); + CREATE (online_chars, int, 256); for (i = 0; i < char_max; i++) online_chars[i] = -1; @@ -640,27 +630,8 @@ int mmo_char_init (void) if (char_num >= char_max) { char_max += 256; - char_dat = - realloc (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 (int) * 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); - exit (1); - } + RECREATE (char_dat, struct mmo_charstatus, char_max); + RECREATE (online_chars, int, char_max); for (i = char_max - 256; i < char_max; i++) online_chars[i] = -1; } @@ -829,7 +800,7 @@ void mmo_char_sync (void) //---------------------------------------------------- // Function to save (in a periodic way) datas in files //---------------------------------------------------- -int mmo_char_sync_timer (int tid, unsigned int tick, int id, int data) +void mmo_char_sync_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { if (pid != 0) { @@ -839,14 +810,14 @@ int mmo_char_sync_timer (int tid, unsigned int tick, int id, int data) // Need to check status too? if (temp == 0) { - return 0; + return; } } // This can take a lot of time. Fork a child to handle the work and return at once // If we're unable to fork just continue running the function normally if ((pid = fork ()) > 0) - return 0; + return; mmo_char_sync (); inter_save (); @@ -854,8 +825,6 @@ int mmo_char_sync_timer (int tid, unsigned int tick, int id, int data) // If we're a child we should suicide now. if (pid == 0) _exit (0); - - return 0; } //---------------------------------------------------- @@ -972,7 +941,7 @@ int make_new_char (int fd, unsigned char *dat) { if ((name_ignoring_case != 0 && strcmp (char_dat[i].name, dat) == 0) || (name_ignoring_case == 0 - && strcmpi (char_dat[i].name, dat) == 0)) + && strcasecmp (char_dat[i].name, dat) == 0)) { char_log ("Make new char error (name already exists): (connection #%d, account: %d) slot %d, name: %s (actual name of other char: %s), stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d." @@ -1009,25 +978,8 @@ 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); - 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 (int) * 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); - exit (1); - } + RECREATE (char_dat, struct mmo_charstatus, char_max); + RECREATE (online_chars, int, char_max); for (j = char_max - 256; j < char_max; j++) online_chars[j] = -1; } @@ -1282,9 +1234,9 @@ void create_online_files (void) { char *p_name = char_dat[i].name; //speed up sorting when there are a lot of players. But very rarely players have same name. for (j = 0; j < players; j++) - if (stricmp (p_name, char_dat[id[j]].name) < 0 || + if (strcasecmp (p_name, char_dat[id[j]].name) < 0 || // if same name, we sort with case sensitive. - (stricmp (p_name, char_dat[id[j]].name) == 0 && + (strcasecmp (p_name, char_dat[id[j]].name) == 0 && strcmp (p_name, char_dat[id[j]].name) < 0)) { for (k = players; k > j; k--) @@ -1299,7 +1251,7 @@ void create_online_files (void) if (char_dat[i].zeny < char_dat[id[j]].zeny || // if same number of zenys, we sort by name. (char_dat[i].zeny == char_dat[id[j]].zeny && - stricmp (char_dat[i].name, + strcasecmp (char_dat[i].name, char_dat[id[j]].name) < 0)) { for (k = players; k > j; k--) @@ -1348,10 +1300,10 @@ void create_online_files (void) { int cpm_result; // A lot of player maps are identical. So, test if done often twice. for (j = 0; j < players; j++) - if ((cpm_result = strcmp (char_dat[i].last_point.map, char_dat[id[j]].last_point.map)) < 0 || // no map are identical and with upper cases (not use stricmp) + if ((cpm_result = strcmp (char_dat[i].last_point.map, char_dat[id[j]].last_point.map)) < 0 || // no map are identical and with upper cases (not use strcasecmp) // if same map name, we sort by name. (cpm_result == 0 && - stricmp (char_dat[i].name, + strcasecmp (char_dat[i].name, char_dat[id[j]].name) < 0)) { for (k = players; k > j; k--) @@ -1876,7 +1828,7 @@ static int char_delete (struct mmo_charstatus *cs) return 0; } -int parse_tologin (int fd) +void parse_tologin (int fd) { int i; struct char_session_data *sd; @@ -1894,7 +1846,7 @@ int parse_tologin (int fd) } close (fd); delete_session (fd); - return 0; + return; } sd = session[fd]->session_data; @@ -1907,7 +1859,7 @@ int parse_tologin (int fd) { case 0x2711: if (RFIFOREST (fd) < 3) - return 0; + return; if (RFIFOB (fd, 2)) { // printf("connect login server error : %d\n", RFIFOB(fd,2)); @@ -1936,7 +1888,7 @@ int parse_tologin (int fd) case 0x2713: if (RFIFOREST (fd) < 51) - return 0; + return; // printf("parse_tologin 2713 : %d\n", RFIFOB(fd,6)); for (i = 0; i < fd_max; i++) { @@ -1980,7 +1932,7 @@ int parse_tologin (int fd) // Receiving of an e-mail/time limit from the login-server (answer of a request because a player comes back from map-server to char-server) by [Yor] case 0x2717: if (RFIFOREST (fd) < 50) - return 0; + return; for (i = 0; i < fd_max; i++) { if (session[i] && (sd = session[i]->session_data)) @@ -2000,7 +1952,7 @@ int parse_tologin (int fd) case 0x2721: // gm reply if (RFIFOREST (fd) < 10) - return 0; + return; { unsigned char buf[10]; WBUFW (buf, 0) = 0x2b0b; @@ -2014,7 +1966,7 @@ int parse_tologin (int fd) case 0x2723: // changesex reply (modified by [Yor]) if (RFIFOREST (fd) < 7) - return 0; + return; { int acc, sex, i, j; unsigned char buf[7]; @@ -2079,7 +2031,7 @@ int parse_tologin (int fd) case 0x2726: // Request to send a broadcast message (no answer) if (RFIFOREST (fd) < 8 || RFIFOREST (fd) < (8 + RFIFOL (fd, 4))) - return 0; + return; if (RFIFOL (fd, 4) < 1) char_log ("Receiving a message for broadcast, but message is void." @@ -2166,7 +2118,7 @@ int parse_tologin (int fd) // account_reg2変更通知 case 0x2729: if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; { struct global_reg reg[ACCOUNT_REG2_NUM]; unsigned char buf[4096]; @@ -2192,7 +2144,7 @@ int parse_tologin (int fd) case 0x7924: { // [Fate] Itemfrob package: forwarded from login-server if (RFIFOREST (fd) < 10) - return 0; + return; int source_id = RFIFOL (fd, 2); int dest_id = RFIFOL (fd, 6); unsigned char buf[10]; @@ -2240,7 +2192,7 @@ int parse_tologin (int fd) // Account deletion notification (from login-server) case 0x2730: if (RFIFOREST (fd) < 6) - return 0; + return; // Deletion of all characters of the account for (i = 0; i < char_num; i++) { @@ -2302,7 +2254,7 @@ int parse_tologin (int fd) // State change of account/ban notification (from login-server) by [Yor] case 0x2731: if (RFIFOREST (fd) < 11) - return 0; + return; // send to all map-servers to disconnect the player { unsigned char buf[11]; @@ -2320,14 +2272,12 @@ int parse_tologin (int fd) // Receiving GM acounts info from login-server (by [Yor]) case 0x2732: if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; { char buf[32000]; if (gm_account != NULL) free (gm_account); - gm_account = - calloc (sizeof (struct gm_account) * - ((RFIFOW (fd, 2) - 4) / 5), 1); + CREATE (gm_account, struct gm_account, (RFIFOW (fd, 2) - 4) / 5); GM_num = 0; for (i = 4; i < RFIFOW (fd, 2); i = i + 5) { @@ -2353,7 +2303,7 @@ int parse_tologin (int fd) case 0x2741: // change password reply if (RFIFOREST (fd) < 7) - return 0; + return; { int acc, status, i; acc = RFIFOL (fd, 2); @@ -2378,18 +2328,17 @@ int parse_tologin (int fd) default: session[fd]->eof = 1; - return 0; + return; } } RFIFOFLUSH (fd); - - return 0; } //-------------------------------- // Map-server anti-freeze system //-------------------------------- -int map_anti_freeze_system (int tid, unsigned int tick, int id, int data) +typedef void (*timer_func) (timer_id, tick_t, custom_id_t, custom_data_t); +void map_anti_freeze_system (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { int i; @@ -2411,11 +2360,9 @@ int map_anti_freeze_system (int tid, unsigned int tick, int id, int data) } } } - - return 0; } -int parse_frommap (int fd) +void parse_frommap (int fd) { int i, j; int id; @@ -2438,7 +2385,7 @@ int parse_frommap (int fd) } close (fd); delete_session (fd); - return 0; + return; } while (RFIFOREST (fd) >= 2) @@ -2461,7 +2408,7 @@ int parse_frommap (int fd) // Receiving map names list from the map-server case 0x2afa: if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; memset (server[id].map, 0, sizeof (server[id].map)); j = 0; for (i = 4; i < RFIFOW (fd, 2); i += 16) @@ -2531,7 +2478,7 @@ int parse_frommap (int fd) // 認証要求 case 0x2afc: if (RFIFOREST (fd) < 22) - return 0; + return; //printf("auth_fifo search: account: %d, char: %d, secure: %08x-%08x\n", RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10), RFIFOL(fd,14)); for (i = 0; i < AUTH_FIFO_SIZE; i++) { @@ -2581,7 +2528,7 @@ int parse_frommap (int fd) // MAPサーバー上のユーザー数受信 case 0x2aff: if (RFIFOREST (fd) < 6 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; server[id].users = RFIFOW (fd, 4); if (anti_freeze_enable) server_freezeflag[id] = 5; // Map anti-freeze system. Counter. 5 ok, 4...0 freezed @@ -2613,7 +2560,7 @@ int parse_frommap (int fd) // キャラデータ保存 case 0x2b01: if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; for (i = 0; i < char_num; i++) { if (char_dat[i].account_id == RFIFOL (fd, 4) && @@ -2629,7 +2576,7 @@ int parse_frommap (int fd) // キャラセレ要求 case 0x2b02: if (RFIFOREST (fd) < 18) - return 0; + return; if (auth_fifo_pos >= AUTH_FIFO_SIZE) auth_fifo_pos = 0; //printf("auth_fifo set (auth #%d) - account: %d, secure: %08x-%08x\n", auth_fifo_pos, RFIFOL(fd,2), RFIFOL(fd,6), RFIFOL(fd,10)); @@ -2652,7 +2599,7 @@ int parse_frommap (int fd) // マップサーバー間移動要求 case 0x2b05: if (RFIFOREST (fd) < 49) - return 0; + return; if (auth_fifo_pos >= AUTH_FIFO_SIZE) auth_fifo_pos = 0; WFIFOW (fd, 0) = 0x2b06; @@ -2684,7 +2631,7 @@ int parse_frommap (int fd) // キャラ名検索 case 0x2b08: if (RFIFOREST (fd) < 6) - return 0; + return; for (i = 0; i < char_num; i++) { if (char_dat[i].char_id == RFIFOL (fd, 2)) @@ -2703,7 +2650,7 @@ int parse_frommap (int fd) // it is a request to become GM case 0x2b0a: if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; // printf("parse_frommap: change gm -> login, account: %d, pass: '%s'.\n", RFIFOL(fd,4), RFIFOP(fd,8)); if (login_fd > 0) { // don't send request if no login-server @@ -2725,7 +2672,7 @@ int parse_frommap (int fd) // Map server send information to change an email of an account -> login-server case 0x2b0c: if (RFIFOREST (fd) < 86) - return 0; + return; if (login_fd > 0) { // don't send request if no login-server memcpy (WFIFOP (login_fd, 0), RFIFOP (fd, 0), 86); // 0x2722 <account_id>.L <actual_e-mail>.40B <new_e-mail>.40B @@ -2738,7 +2685,7 @@ int parse_frommap (int fd) // Map server ask char-server about a character name to do some operations (all operations are transmitted to login-server) case 0x2b0e: if (RFIFOREST (fd) < 44) - return 0; + return; { char character_name[24]; int acc = RFIFOL (fd, 2); // account_id of who ask (-1 if nobody) @@ -2877,7 +2824,7 @@ int parse_frommap (int fd) // account_reg保存要求 case 0x2b10: if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) - return 0; + return; { struct global_reg reg[ACCOUNT_REG2_NUM]; int p, acc; @@ -2910,7 +2857,7 @@ int parse_frommap (int fd) // Map server is requesting a divorce case 0x2b16: if (RFIFOREST (fd) < 4) - return 0; + return; { for (i = 0; i < char_num; i++) if (char_dat[i].char_id == RFIFOL (fd, 2)) @@ -2931,17 +2878,16 @@ int parse_frommap (int fd) if (r == 1) // 処理できた break; if (r == 2) // パケット長が足りない - return 0; + return; } // inter server処理でもない場合は切断 printf ("char: unknown packet 0x%04x (%d bytes to read in buffer)! (from map).\n", RFIFOW (fd, 0), RFIFOREST (fd)); session[fd]->eof = 1; - return 0; + return; } } - return 0; } int search_mapserver (char *map) @@ -3002,7 +2948,7 @@ int lan_ip_check (unsigned char *p) return lancheck; } -int parse_char (int fd) +void parse_char (int fd) { int i, ch; char email[40]; @@ -3015,7 +2961,7 @@ int parse_char (int fd) login_fd = -1; close (fd); delete_session (fd); - return 0; + return; } sd = session[fd]->session_data; @@ -3029,13 +2975,13 @@ int parse_char (int fd) { case 0x20b: //20040622暗号化ragexe対応 if (RFIFOREST (fd) < 19) - return 0; + return; RFIFOSKIP (fd, 19); break; case 0x61: // change password request if (RFIFOREST (fd) < 50) - return 0; + return; { WFIFOW (login_fd, 0) = 0x2740; WFIFOL (login_fd, 2) = sd->account_id; @@ -3048,7 +2994,7 @@ int parse_char (int fd) case 0x65: // 接続要求 if (RFIFOREST (fd) < 17) - return 0; + return; { int GM_value; if ((GM_value = isGM (RFIFOL (fd, 2)))) @@ -3060,9 +3006,8 @@ int parse_char (int fd) RFIFOL (fd, 2)); if (sd == NULL) { - sd = session[fd]->session_data = - calloc (sizeof (struct char_session_data), 1); - memset (sd, 0, sizeof (struct char_session_data)); + CREATE (sd, struct char_session_data, 1); + session[fd]->session_data = sd; 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) } @@ -3141,7 +3086,7 @@ int parse_char (int fd) case 0x66: // キャラ選択 if (!sd || RFIFOREST (fd) < 3) - return 0; + return; char ip[16]; unsigned char *sin_addr = @@ -3311,7 +3256,7 @@ int parse_char (int fd) case 0x67: // 作成 if (!sd || RFIFOREST (fd) < 37) - return 0; + return; i = make_new_char (fd, RFIFOP (fd, 2)); if (i < 0) { @@ -3386,7 +3331,7 @@ int parse_char (int fd) case 0x68: // delete char //Yor's Fix if (!sd || RFIFOREST (fd) < 46) - return 0; + return; memcpy (email, RFIFOP (fd, 6), 40); if (e_mail_check (email) == 0) strncpy (email, "a@a.com", 40); // default e-mail @@ -3440,7 +3385,7 @@ int parse_char (int fd) } else { - /*if (strcmpi(email, sd->email) != 0) { // if it's an invalid email + /*if (strcasecmp(email, sd->email) != 0) { // if it's an invalid email * WFIFOW(fd, 0) = 0x70; * WFIFOB(fd, 2) = 0; // 00 = Incorrect Email address * WFIFOSET(fd, 3); @@ -3512,7 +3457,7 @@ int parse_char (int fd) case 0x2af8: // マップサーバーログイン if (RFIFOREST (fd) < 60) - return 0; + return; WFIFOW (fd, 0) = 0x2af9; for (i = 0; i < MAX_MAP_SERVERS; i++) { @@ -3555,13 +3500,13 @@ int parse_char (int fd) } WFIFOW (fd, 2) = len; WFIFOSET (fd, len); - return 0; + return; } break; case 0x187: // Alive信号? if (RFIFOREST (fd) < 6) - return 0; + return; RFIFOSKIP (fd, 6); break; @@ -3576,19 +3521,17 @@ int parse_char (int fd) WFIFOW (fd, 8) = ATHENA_MOD_VERSION; WFIFOSET (fd, 10); RFIFOSKIP (fd, 2); - return 0; + return; case 0x7532: // 接続の切断(defaultと処理は一緒だが明示的にするため) session[fd]->eof = 1; - return 0; + return; default: session[fd]->eof = 1; - return 0; + return; } } - RFIFOFLUSH (fd); - return 0; } // 全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) @@ -3649,7 +3592,7 @@ int mapif_send (int fd, unsigned char *buf, unsigned int len) return 0; } -int send_users_tologin (int tid, unsigned int tick, int id, int data) +void send_users_tologin (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { int users = count_users (); char buf[16]; @@ -3665,17 +3608,15 @@ int send_users_tologin (int tid, unsigned int tick, int id, int data) WBUFW (buf, 0) = 0x2b00; WBUFL (buf, 2) = users; mapif_sendall (buf, 6); - - return 0; } -int check_connect_login_server (int tid, unsigned int tick, int id, int data) +void check_connect_login_server (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { if (login_fd <= 0 || session[login_fd] == NULL) { printf ("Attempt to connect to login-server...\n"); if ((login_fd = make_connection (login_ip, login_port)) < 0) - return 0; + return; session[login_fd]->func_parse = parse_tologin; realloc_fifo (login_fd, FIFOSIZE_SERVERLINK, FIFOSIZE_SERVERLINK); WFIFOW (login_fd, 0) = 0x2710; @@ -3696,7 +3637,6 @@ int check_connect_login_server (int tid, unsigned int tick, int id, int data) WFIFOW (login_fd, 84) = char_new; WFIFOSET (login_fd, 86); } - return 0; } //---------------------------------------------------------- @@ -3705,12 +3645,12 @@ int check_connect_login_server (int tid, unsigned int tick, int id, int data) //---------------------------------------------------------- int config_switch (const char *str) { - if (strcmpi (str, "on") == 0 || strcmpi (str, "yes") == 0 - || strcmpi (str, "oui") == 0 || strcmpi (str, "ja") == 0 - || strcmpi (str, "si") == 0) + if (strcasecmp (str, "on") == 0 || strcasecmp (str, "yes") == 0 + || strcasecmp (str, "oui") == 0 || strcasecmp (str, "ja") == 0 + || strcasecmp (str, "si") == 0) return 1; - if (strcmpi (str, "off") == 0 || strcmpi (str, "no") == 0 - || strcmpi (str, "non") == 0 || strcmpi (str, "nein") == 0) + if (strcasecmp (str, "off") == 0 || strcasecmp (str, "no") == 0 + || strcasecmp (str, "non") == 0 || strcasecmp (str, "nein") == 0) return 0; return atoi (str); @@ -3756,7 +3696,7 @@ int lan_config_read (const char *lancfgName) remove_control_chars (w1); remove_control_chars (w2); - if (strcmpi (w1, "lan_map_ip") == 0) + if (strcasecmp (w1, "lan_map_ip") == 0) { // Read map-server Lan IP Address h = gethostbyname (w2); if (h != NULL) @@ -3774,7 +3714,7 @@ int lan_config_read (const char *lancfgName) } printf ("LAN IP of map-server: %s.\n", lan_map_ip); } - else if (strcmpi (w1, "subnet") == 0) + else if (strcasecmp (w1, "subnet") == 0) { // Read Subnetwork for (j = 0; j < 4; j++) subneti[j] = 0; @@ -3792,7 +3732,7 @@ int lan_config_read (const char *lancfgName) printf ("Sub-network of the map-server: %d.%d.%d.%d.\n", subneti[0], subneti[1], subneti[2], subneti[3]); } - else if (strcmpi (w1, "subnetmask") == 0) + else if (strcasecmp (w1, "subnetmask") == 0) { // Read Subnetwork Mask for (j = 0; j < 4; j++) subnetmaski[j] = 255; @@ -3859,21 +3799,21 @@ int char_config_read (const char *cfgName) remove_control_chars (w1); remove_control_chars (w2); - if (strcmpi (w1, "userid") == 0) + if (strcasecmp (w1, "userid") == 0) { memcpy (userid, w2, 24); } - else if (strcmpi (w1, "passwd") == 0) + else if (strcasecmp (w1, "passwd") == 0) { memcpy (passwd, w2, 24); } - else if (strcmpi (w1, "server_name") == 0) + else if (strcasecmp (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); } - else if (strcmpi (w1, "wisp_server_name") == 0) + else if (strcasecmp (w1, "wisp_server_name") == 0) { if (strlen (w2) >= 4) { @@ -3881,7 +3821,7 @@ int char_config_read (const char *cfgName) wisp_server_name[sizeof (wisp_server_name) - 1] = '\0'; } } - else if (strcmpi (w1, "login_ip") == 0) + else if (strcasecmp (w1, "login_ip") == 0) { h = gethostbyname (w2); if (h != NULL) @@ -3900,11 +3840,11 @@ int char_config_read (const char *cfgName) else memcpy (login_ip_str, w2, 16); } - else if (strcmpi (w1, "login_port") == 0) + else if (strcasecmp (w1, "login_port") == 0) { login_port = atoi (w2); } - else if (strcmpi (w1, "char_ip") == 0) + else if (strcasecmp (w1, "char_ip") == 0) { h = gethostbyname (w2); if (h != NULL) @@ -3923,51 +3863,51 @@ int char_config_read (const char *cfgName) else memcpy (char_ip_str, w2, 16); } - else if (strcmpi (w1, "char_port") == 0) + else if (strcasecmp (w1, "char_port") == 0) { char_port = atoi (w2); } - else if (strcmpi (w1, "char_maintenance") == 0) + else if (strcasecmp (w1, "char_maintenance") == 0) { char_maintenance = atoi (w2); } - else if (strcmpi (w1, "char_new") == 0) + else if (strcasecmp (w1, "char_new") == 0) { char_new = atoi (w2); } - else if (strcmpi (w1, "email_creation") == 0) + else if (strcasecmp (w1, "email_creation") == 0) { email_creation = config_switch (w2); } - else if (strcmpi (w1, "char_txt") == 0) + else if (strcasecmp (w1, "char_txt") == 0) { strcpy (char_txt, w2); } - else if (strcmpi (w1, "backup_txt") == 0) + else if (strcasecmp (w1, "backup_txt") == 0) { //By zanetheinsane strcpy (backup_txt, w2); } - else if (strcmpi (w1, "backup_txt_flag") == 0) + else if (strcasecmp (w1, "backup_txt_flag") == 0) { // The backup_txt file was created because char deletion bug existed. Now it's finish and that take a lot of time to create a second file when there are a lot of characters. By [Yor] backup_txt_flag = config_switch (w2); } - else if (strcmpi (w1, "max_connect_user") == 0) + else if (strcasecmp (w1, "max_connect_user") == 0) { max_connect_user = atoi (w2); if (max_connect_user < 0) max_connect_user = 0; // unlimited online players } - else if (strcmpi (w1, "check_ip_flag") == 0) + else if (strcasecmp (w1, "check_ip_flag") == 0) { check_ip_flag = config_switch (w2); } - else if (strcmpi (w1, "autosave_time") == 0) + else if (strcasecmp (w1, "autosave_time") == 0) { autosave_interval = atoi (w2) * 1000; if (autosave_interval <= 0) autosave_interval = DEFAULT_AUTOSAVE_INTERVAL; } - else if (strcmpi (w1, "start_point") == 0) + else if (strcasecmp (w1, "start_point") == 0) { char map[32]; int x, y; @@ -3980,85 +3920,85 @@ int char_config_read (const char *cfgName) start_point.y = y; } } - else if (strcmpi (w1, "start_zeny") == 0) + else if (strcasecmp (w1, "start_zeny") == 0) { start_zeny = atoi (w2); if (start_zeny < 0) start_zeny = 0; } - else if (strcmpi (w1, "start_weapon") == 0) + else if (strcasecmp (w1, "start_weapon") == 0) { start_weapon = atoi (w2); if (start_weapon < 0) start_weapon = 0; } - else if (strcmpi (w1, "start_armor") == 0) + else if (strcasecmp (w1, "start_armor") == 0) { start_armor = atoi (w2); if (start_armor < 0) start_armor = 0; } - else if (strcmpi (w1, "unknown_char_name") == 0) + else if (strcasecmp (w1, "unknown_char_name") == 0) { strcpy (unknown_char_name, w2); unknown_char_name[24] = 0; } - else if (strcmpi (w1, "char_log_filename") == 0) + else if (strcasecmp (w1, "char_log_filename") == 0) { strcpy (char_log_filename, w2); } - else if (strcmpi (w1, "name_ignoring_case") == 0) + else if (strcasecmp (w1, "name_ignoring_case") == 0) { name_ignoring_case = config_switch (w2); } - else if (strcmpi (w1, "char_name_option") == 0) + else if (strcasecmp (w1, "char_name_option") == 0) { char_name_option = atoi (w2); } - else if (strcmpi (w1, "char_name_letters") == 0) + else if (strcasecmp (w1, "char_name_letters") == 0) { strcpy (char_name_letters, w2); // online files options } - else if (strcmpi (w1, "online_txt_filename") == 0) + else if (strcasecmp (w1, "online_txt_filename") == 0) { strcpy (online_txt_filename, w2); } - else if (strcmpi (w1, "online_html_filename") == 0) + else if (strcasecmp (w1, "online_html_filename") == 0) { strcpy (online_html_filename, w2); } - else if (strcmpi (w1, "online_sorting_option") == 0) + else if (strcasecmp (w1, "online_sorting_option") == 0) { online_sorting_option = atoi (w2); } - else if (strcmpi (w1, "online_display_option") == 0) + else if (strcasecmp (w1, "online_display_option") == 0) { online_display_option = atoi (w2); } - else if (strcmpi (w1, "online_gm_display_min_level") == 0) + else if (strcasecmp (w1, "online_gm_display_min_level") == 0) { // minimum GM level to display 'GM' when we want to display it online_gm_display_min_level = atoi (w2); if (online_gm_display_min_level < 5) // send online file every 5 seconds to player is enough online_gm_display_min_level = 5; } - else if (strcmpi (w1, "online_refresh_html") == 0) + else if (strcasecmp (w1, "online_refresh_html") == 0) { online_refresh_html = atoi (w2); if (online_refresh_html < 1) online_refresh_html = 1; } - else if (strcmpi (w1, "anti_freeze_enable") == 0) + else if (strcasecmp (w1, "anti_freeze_enable") == 0) { anti_freeze_enable = config_switch (w2); } - else if (strcmpi (w1, "anti_freeze_interval") == 0) + else if (strcasecmp (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) + else if (strcasecmp (w1, "import") == 0) { char_config_read (w2); } @@ -4068,7 +4008,7 @@ int char_config_read (const char *cfgName) return 0; } -void do_final (void) +void term_func (void) { int i; @@ -4119,15 +4059,14 @@ int do_init (int argc, char **argv) inter_init ((argc > 2) ? argv[2] : inter_cfgName); // inter server 初期化 - set_termfunc (do_final); +// set_termfunc (do_final); set_defaultparse (parse_char); char_fd = make_listen_port (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"); +// 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); @@ -4138,8 +4077,7 @@ int do_init (int argc, char **argv) if (anti_freeze_enable > 0) { - add_timer_func_list (map_anti_freeze_system, - "map_anti_freeze_system"); +// 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 } diff --git a/src/char/int_guild.c b/src/char/int_guild.c index e145b66..9715700 100644 --- a/src/char/int_guild.c +++ b/src/char/int_guild.c @@ -30,7 +30,7 @@ int guild_calcinfo (struct guild *g); int mapif_guild_basicinfochanged (int guild_id, int type, const void *data, int len); int mapif_guild_info (int fd, struct guild *g); -int guild_break_sub (void *key, void *data, va_list ap); +void guild_break_sub (db_key_t key, db_val_t data, va_list ap); // ギルドデータの文字列への変換 int inter_guild_tostr (char *str, struct guild *g) @@ -448,14 +448,7 @@ int inter_guild_init () guild_newid = i; continue; } - - g = calloc (sizeof (struct guild), 1); - if (g == NULL) - { - printf ("int_guild: out of memory!\n"); - exit (0); - } - memset (g, 0, sizeof (struct guild)); + CREATE (g, struct guild, 1); if (inter_guild_fromstr (line, g) == 0 && g->guild_id > 0) { if (g->guild_id >= guild_newid) @@ -483,13 +476,7 @@ int inter_guild_init () while (fgets (line, sizeof (line) - 1, fp)) { - gc = calloc (sizeof (struct guild_castle), 1); - if (gc == NULL) - { - printf ("int_guild: out of memory!\n"); - exit (0); - } - memset (gc, 0, sizeof (struct guild_castle)); + CREATE (gc, struct guild_castle, 1); if (inter_guildcastle_fromstr (line, gc) == 0) { numdb_insert (castle_db, gc->castle_id, gc); @@ -508,13 +495,7 @@ int inter_guild_init () //デフォルトデータを作成 for (i = 0; i < MAX_GUILDCASTLE; i++) { - gc = calloc (sizeof (struct guild_castle), 1); - if (gc == NULL) - { - printf ("int_guild: out of memory!\n"); - exit (0); - } - memset (gc, 0, sizeof (struct guild_castle)); + CREATE (gc, struct guild_castle, 1); gc->castle_id = i; gc->guild_id = 0; gc->economy = 0; @@ -562,7 +543,7 @@ struct guild *inter_guild_search (int guild_id) } // ギルドデータのセーブ用 -int inter_guild_save_sub (void *key, void *data, va_list ap) +void inter_guild_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[16384]; FILE *fp; @@ -570,12 +551,10 @@ int inter_guild_save_sub (void *key, void *data, va_list ap) inter_guild_tostr (line, (struct guild *) data); fp = va_arg (ap, FILE *); fprintf (fp, "%s" RETCODE, line); - - return 0; } // ギルド城データのセーブ用 -int inter_castle_save_sub (void *key, void *data, va_list ap) +void inter_castle_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[16384]; FILE *fp; @@ -583,8 +562,6 @@ int inter_castle_save_sub (void *key, void *data, va_list ap) inter_guildcastle_tostr (line, (struct guild_castle *) data); fp = va_arg (ap, FILE *); fprintf (fp, "%s" RETCODE, line); - - return 0; } // ギルドデータのセーブ @@ -617,16 +594,15 @@ int inter_guild_save () } // ギルド名検索用 -int search_guildname_sub (void *key, void *data, va_list ap) +void search_guildname_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data, **dst; char *str; str = va_arg (ap, char *); dst = va_arg (ap, struct guild **); - if (strcmpi (g->name, str) == 0) + if (strcasecmp (g->name, str) == 0) *dst = g; - return 0; } // ギルド名検索 @@ -660,7 +636,7 @@ int guild_check_empty (struct guild *g) } // キャラの競合がないかチェック用 -int guild_check_conflict_sub (void *key, void *data, va_list ap) +void guild_check_conflict_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data; int guild_id, account_id, char_id, i; @@ -670,7 +646,7 @@ int guild_check_conflict_sub (void *key, void *data, va_list ap) char_id = va_arg (ap, int); if (g->guild_id == guild_id) // 本来の所属なので問題なし - return 0; + return; for (i = 0; i < MAX_GUILD; i++) { @@ -683,8 +659,6 @@ int guild_check_conflict_sub (void *key, void *data, va_list ap) "**データ競合**"); } } - - return 0; } // キャラの競合がないかチェック @@ -1037,7 +1011,7 @@ int mapif_guild_castle_datasave (int castle_id, int index, int value) return 0; } -int mapif_guild_castle_alldataload_sub (void *key, void *data, va_list ap) +void mapif_guild_castle_alldataload_sub (db_key_t key, db_val_t data, va_list ap) { int fd = va_arg (ap, int); int *p = va_arg (ap, int *); @@ -1045,8 +1019,6 @@ int mapif_guild_castle_alldataload_sub (void *key, void *data, va_list ap) memcpy (WFIFOP (fd, *p), (struct guild_castle *) data, sizeof (struct guild_castle)); (*p) += sizeof (struct guild_castle); - - return 0; } int mapif_guild_castle_alldataload (int fd) @@ -1087,14 +1059,7 @@ int mapif_parse_CreateGuild (int fd, int account_id, char *name, mapif_guild_created (fd, account_id, NULL); return 0; } - g = calloc (sizeof (struct guild), 1); - if (g == NULL) - { - printf ("int_guild: CreateGuild: out of memory !\n"); - mapif_guild_created (fd, account_id, NULL); - exit (0); - } - memset (g, 0, sizeof (struct guild)); + CREATE (g, struct guild, 1); g->guild_id = guild_newid++; memcpy (g->name, name, 24); memcpy (g->master, master->name, 24); @@ -1263,7 +1228,7 @@ int mapif_parse_GuildChangeMemberInfoShort (int fd, int guild_id, } // ギルド解散処理用(同盟/敵対を解除) -int guild_break_sub (void *key, void *data, va_list ap) +void guild_break_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data; int guild_id = va_arg (ap, int); @@ -1274,7 +1239,6 @@ int guild_break_sub (void *key, void *data, va_list ap) if (g->alliance[i].guild_id == guild_id) g->alliance[i].guild_id = 0; } - return 0; } // ギルド解散要求 diff --git a/src/char/int_party.c b/src/char/int_party.c index c5ed033..b728b1e 100644 --- a/src/char/int_party.c +++ b/src/char/int_party.c @@ -110,13 +110,7 @@ int inter_party_init () continue; } - p = calloc (sizeof (struct party), 1); - if (p == NULL) - { - printf ("int_party: out of memory!\n"); - exit (0); - } - memset (p, 0, sizeof (struct party)); + CREATE (p, struct party, 1); if (inter_party_fromstr (line, p) == 0 && p->party_id > 0) { if (p->party_id >= party_newid) @@ -139,7 +133,7 @@ int inter_party_init () } // パーティーデータのセーブ用 -int inter_party_save_sub (void *key, void *data, va_list ap) +void inter_party_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[8192]; FILE *fp; @@ -147,8 +141,6 @@ int inter_party_save_sub (void *key, void *data, va_list ap) inter_party_tostr (line, (struct party *) data); fp = va_arg (ap, FILE *); fprintf (fp, "%s" RETCODE, line); - - return 0; } // パーティーデータのセーブ @@ -172,17 +164,15 @@ int inter_party_save () } // パーティ名検索用 -int search_partyname_sub (void *key, void *data, va_list ap) +void search_partyname_sub (db_key_t key, db_val_t data, va_list ap) { struct party *p = (struct party *) data, **dst; char *str; str = va_arg (ap, char *); dst = va_arg (ap, struct party **); - if (strcmpi (p->name, str) == 0) + if (strcasecmp (p->name, str) == 0) *dst = p; - - return 0; } // パーティ名検索 @@ -238,7 +228,7 @@ int party_check_empty (struct party *p) } // キャラの競合がないかチェック用 -int party_check_conflict_sub (void *key, void *data, va_list ap) +void party_check_conflict_sub (db_key_t key, db_val_t data, va_list ap) { struct party *p = (struct party *) data; int party_id, account_id, i; @@ -249,7 +239,7 @@ int party_check_conflict_sub (void *key, void *data, va_list ap) nick = va_arg (ap, char *); if (p->party_id == party_id) // 本来の所属なので問題なし - return 0; + return; for (i = 0; i < MAX_PARTY; i++) { @@ -262,8 +252,6 @@ int party_check_conflict_sub (void *key, void *data, va_list ap) mapif_parse_PartyLeave (-1, p->party_id, account_id); } } - - return 0; } // キャラの競合がないかチェック @@ -449,14 +437,7 @@ int mapif_parse_CreateParty (int fd, int account_id, char *name, char *nick, mapif_party_created (fd, account_id, NULL); return 0; } - p = calloc (sizeof (struct party), 1); - if (p == NULL) - { - printf ("int_party: out of memory !\n"); - mapif_party_created (fd, account_id, NULL); - return 0; - } - memset (p, 0, sizeof (struct party)); + CREATE (p, struct party, 1); p->party_id = party_newid++; memcpy (p->name, name, 24); p->exp = 0; diff --git a/src/char/int_storage.c b/src/char/int_storage.c index 744a59f..99af725 100644 --- a/src/char/int_storage.c +++ b/src/char/int_storage.c @@ -7,7 +7,6 @@ #include "../common/socket.h" #include "../common/db.h" #include "../common/lock.h" -#include "../common/malloc.h" #include "char.h" #include "inter.h" #include "int_storage.h" @@ -222,12 +221,7 @@ struct storage *account2storage (int account_id) s = (struct storage *) numdb_search (storage_db, account_id); if (s == NULL) { - s = (struct storage *) aCalloc (sizeof (struct storage), 1); - if (s == NULL) - { - printf ("int_storage: out of memory!\n"); - exit (0); - } + CREATE (s, struct storage, 1); memset (s, 0, sizeof (struct storage)); s->account_id = account_id; numdb_insert (storage_db, s->account_id, s); @@ -244,14 +238,7 @@ struct guild_storage *guild2storage (int guild_id) guild_id); if (gs == NULL) { - gs = (struct guild_storage *) - aCalloc (sizeof (struct guild_storage), 1); - if (gs == NULL) - { - printf ("int_storage: out of memory!\n"); - exit (0); - } -// memset(gs,0,sizeof(struct guild_storage)); aCalloc does this! [Skotlex] + CREATE (gs, struct guild_storage, 1); gs->guild_id = guild_id; numdb_insert (guild_storage_db, gs->guild_id, gs); } @@ -280,13 +267,7 @@ int inter_storage_init () while (fgets (line, 65535, fp)) { sscanf (line, "%d", &tmp_int); - s = (struct storage *) aCalloc (sizeof (struct storage), 1); - if (s == NULL) - { - printf ("int_storage: out of memory!\n"); - exit (0); - } -// memset(s,0,sizeof(struct storage)); aCalloc does this... + CREATE (s, struct storage, 1); s->account_id = tmp_int; if (s->account_id > 0 && storage_fromstr (line, s) == 0) { @@ -314,14 +295,7 @@ int inter_storage_init () while (fgets (line, 65535, fp)) { sscanf (line, "%d", &tmp_int); - gs = (struct guild_storage *) aCalloc (sizeof (struct guild_storage), - 1); - if (gs == NULL) - { - printf ("int_storage: out of memory!\n"); - exit (0); - } -// memset(gs,0,sizeof(struct guild_storage)); aCalloc... + CREATE (gs, struct guild_storage, 1); gs->guild_id = tmp_int; if (gs->guild_id > 0 && guild_storage_fromstr (line, gs) == 0) { @@ -340,20 +314,18 @@ int inter_storage_init () return 0; } -int storage_db_final (void *k, void *data, va_list ap) +void storage_db_final (db_key_t k, db_val_t data, va_list ap) { struct storage *p = (struct storage *) data; if (p) free (p); - return 0; } -int guild_storage_db_final (void *k, void *data, va_list ap) +void guild_storage_db_final (db_key_t k, db_val_t data, va_list ap) { struct guild_storage *p = (struct guild_storage *) data; if (p) free (p); - return 0; } void inter_storage_final () @@ -363,7 +335,7 @@ void inter_storage_final () return; } -int inter_storage_save_sub (void *key, void *data, va_list ap) +void inter_storage_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[65536]; FILE *fp; @@ -371,7 +343,6 @@ int inter_storage_save_sub (void *key, void *data, va_list ap) fp = va_arg (ap, FILE *); if (*line) fprintf (fp, "%s" RETCODE, line); - return 0; } //--------------------------------------------------------- @@ -396,7 +367,7 @@ int inter_storage_save () return 0; } -int inter_guild_storage_save_sub (void *key, void *data, va_list ap) +void inter_guild_storage_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[65536]; FILE *fp; @@ -409,7 +380,6 @@ int inter_guild_storage_save_sub (void *key, void *data, va_list ap) if (*line) fprintf (fp, "%s" RETCODE, line); } - return 0; } //--------------------------------------------------------- diff --git a/src/char/inter.c b/src/char/inter.c index 5bee90f..f563931 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -120,13 +120,7 @@ int inter_accreg_init () while (fgets (line, sizeof (line) - 1, fp)) { line[sizeof (line) - 1] = '\0'; - - reg = calloc (sizeof (struct accreg), 1); - if (reg == NULL) - { - printf ("inter: accreg: out of memory!\n"); - exit (0); - } + CREATE (reg, struct accreg, 1); if (inter_accreg_fromstr (line, reg) == 0 && reg->account_id > 0) { numdb_insert (accreg_db, reg->account_id, reg); @@ -146,7 +140,7 @@ int inter_accreg_init () } // アカウント変数のセーブ用 -int inter_accreg_save_sub (void *key, void *data, va_list ap) +void inter_accreg_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[8192]; FILE *fp; @@ -158,8 +152,6 @@ int inter_accreg_save_sub (void *key, void *data, va_list ap) fp = va_arg (ap, FILE *); fprintf (fp, "%s" RETCODE, line); } - - return 0; } // アカウント変数のセーブ @@ -207,41 +199,41 @@ int inter_config_read (const char *cfgName) if (sscanf (line, "%[^:]: %[^\r\n]", w1, w2) != 2) continue; - if (strcmpi (w1, "storage_txt") == 0) + if (strcasecmp (w1, "storage_txt") == 0) { strncpy (storage_txt, w2, sizeof (storage_txt)); } - else if (strcmpi (w1, "party_txt") == 0) + else if (strcasecmp (w1, "party_txt") == 0) { strncpy (party_txt, w2, sizeof (party_txt)); } - else if (strcmpi (w1, "guild_txt") == 0) + else if (strcasecmp (w1, "guild_txt") == 0) { strncpy (guild_txt, w2, sizeof (guild_txt)); } - else if (strcmpi (w1, "castle_txt") == 0) + else if (strcasecmp (w1, "castle_txt") == 0) { strncpy (castle_txt, w2, sizeof (castle_txt)); } - else if (strcmpi (w1, "accreg_txt") == 0) + else if (strcasecmp (w1, "accreg_txt") == 0) { strncpy (accreg_txt, w2, sizeof (accreg_txt)); } - else if (strcmpi (w1, "guild_storage_txt") == 0) + else if (strcasecmp (w1, "guild_storage_txt") == 0) { strncpy (guild_storage_txt, w2, sizeof (guild_storage_txt)); } - else if (strcmpi (w1, "party_share_level") == 0) + else if (strcasecmp (w1, "party_share_level") == 0) { party_share_level = atoi (w2); if (party_share_level < 0) party_share_level = 0; } - else if (strcmpi (w1, "inter_log_filename") == 0) + else if (strcasecmp (w1, "inter_log_filename") == 0) { strncpy (inter_log_filename, w2, sizeof (inter_log_filename)); } - else if (strcmpi (w1, "import") == 0) + else if (strcasecmp (w1, "import") == 0) { inter_config_read (w2); } @@ -392,7 +384,7 @@ int mapif_account_reg_reply (int fd, int account_id) //-------------------------------------------------------- // Existence check of WISP data -int check_ttl_wisdata_sub (void *key, void *data, va_list ap) +void check_ttl_wisdata_sub (db_key_t key, db_val_t data, va_list ap) { unsigned long tick; struct WisData *wd = (struct WisData *) data; @@ -401,8 +393,6 @@ int check_ttl_wisdata_sub (void *key, void *data, va_list ap) if (DIFF_TICK (tick, wd->tick) > WISDATA_TTL && wis_delnum < WISDELLIST_MAX) wis_dellist[wis_delnum++] = wd->id; - - return 0; } int check_ttl_wisdata () @@ -485,13 +475,7 @@ int mapif_parse_WisRequest (int fd) } else { - - wd = (struct WisData *) calloc (sizeof (struct WisData), 1); - if (wd == NULL) - { - printf ("inter: WisRequest: out of memory !\n"); - return 0; - } + CREATE (wd, struct WisData, 1); // Whether the failure of previous wisp/page transmission (timeout) check_ttl_wisdata (); @@ -546,17 +530,13 @@ 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 = numdb_search (accreg_db, (numdb_key_t)RFIFOL (fd, 4)); if (reg == NULL) { - if ((reg = calloc (sizeof (struct accreg), 1)) == NULL) - { - printf ("inter: accreg: out of memory !\n"); - exit (0); - } + CREATE (reg, struct accreg, 1); reg->account_id = RFIFOL (fd, 4); - numdb_insert (accreg_db, RFIFOL (fd, 4), reg); + numdb_insert (accreg_db, (numdb_key_t)RFIFOL (fd, 4), reg); } for (j = 0, p = 8; j < ACCOUNT_REG_NUM && p < RFIFOW (fd, 2); |