diff options
Diffstat (limited to 'src/char')
-rw-r--r-- | src/char/GNUmakefile | 4 | ||||
-rw-r--r-- | src/char/char.cpp | 203 | ||||
-rw-r--r-- | src/char/char.hpp | 11 | ||||
-rw-r--r-- | src/char/int_guild.cpp | 77 | ||||
-rw-r--r-- | src/char/int_party.cpp | 54 | ||||
-rw-r--r-- | src/char/int_storage.cpp | 17 | ||||
-rw-r--r-- | src/char/inter.cpp | 27 | ||||
-rw-r--r-- | src/char/inter.hpp | 3 |
8 files changed, 224 insertions, 172 deletions
diff --git a/src/char/GNUmakefile b/src/char/GNUmakefile index cd7ad57..0e1aece 100644 --- a/src/char/GNUmakefile +++ b/src/char/GNUmakefile @@ -1,7 +1,7 @@ .SUFFIXES: all: - make -C ../.. char-server + ${MAKE} -C ../.. char-server clean: rm -r ../../obj/char/ %:: - make -C ../.. obj/char/$@ + ${MAKE} -C ../.. obj/char/$@ diff --git a/src/char/char.cpp b/src/char/char.cpp index a57520b..acb52fd 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -120,7 +120,7 @@ pid_t pid = 0; // For forked DB writes //------------------------------ // Writing function of logs file //------------------------------ -int char_log (char *fmt, ...) +int char_log (const char *fmt, ...) { FILE *logfp; va_list ap; @@ -148,30 +148,11 @@ 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) //---------------------------------------------------------------------- +static int isGM (int account_id) { int i; @@ -190,7 +171,7 @@ int isGM (int account_id) // and returns index if only 1 character is found // and similar to the searched name. //---------------------------------------------- -int search_character_index (char *character_name) +int search_character_index (const char *character_name) { int i, quantity, index; @@ -232,6 +213,7 @@ char *search_character_name (int index) //------------------------------------------------- // Function to create the character line (for save) //------------------------------------------------- +static int mmo_char_tostr (char *str, struct mmo_charstatus *p) { int i; @@ -312,6 +294,7 @@ int mmo_char_tostr (char *str, struct mmo_charstatus *p) //------------------------------------------------------------------------- // Function to set the character from the line (at read of characters file) //------------------------------------------------------------------------- +static int mmo_char_fromstr (char *str, struct mmo_charstatus *p) { int tmp_int[256]; @@ -584,17 +567,17 @@ int mmo_char_fromstr (char *str, struct mmo_charstatus *p) //--------------------------------- // Function to read characters file //--------------------------------- +static int mmo_char_init (void) { char line[65536]; - int i; int ret, line_count; FILE *fp; char_max = 256; CREATE (char_dat, struct mmo_charstatus, 256); CREATE (online_chars, int, 256); - for (i = 0; i < char_max; i++) + for (int i = 0; i < char_max; i++) online_chars[i] = -1; char_num = 0; @@ -717,6 +700,7 @@ int mmo_char_init (void) //--------------------------------------------------------- // Function to save characters in files (speed up by [Yor]) //--------------------------------------------------------- +static void mmo_char_sync (void) { char line[65536]; @@ -791,6 +775,7 @@ void mmo_char_sync (void) //---------------------------------------------------- // Function to save (in a periodic way) datas in files //---------------------------------------------------- +static void mmo_char_sync_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { if (pid != 0) @@ -845,14 +830,17 @@ static void remove_prefix_blanks (char *name) //----------------------------------- // Function to create a new character //----------------------------------- +static int make_new_char (int fd, unsigned char *dat) { + // ugh + char *cdat = (char *)dat; int i, j; struct char_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)) + cdat[23] = '\0'; + if (remove_control_chars (cdat)) { char_log ("Make new char error (control char received in the name): (connection #%d, account: %d).\n", @@ -861,45 +849,46 @@ int make_new_char (int fd, unsigned char *dat) } // Eliminate whitespace - remove_trailing_blanks ((char *) dat); - remove_prefix_blanks ((char *) dat); + remove_trailing_blanks (cdat); + remove_prefix_blanks (cdat); // check lenght of character name - if (strlen (dat) < 4) + if (strlen (cdat) < 4) { char_log ("Make new char error (character name too small): (connection #%d, account: %d, name: '%s').\n", - fd, sd->account_id, dat); + fd, sd->account_id, cdat); return -1; } // Check Authorised letters/symbols in the name of the character if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised - for (i = 0; dat[i]; i++) - if (strchr (char_name_letters, dat[i]) == NULL) + for (i = 0; cdat[i]; i++) + if (strchr (char_name_letters, cdat[i]) == NULL) { char_log ("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n", - fd, sd->account_id, dat, dat[i]); + fd, sd->account_id, cdat, cdat[i]); return -1; } } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden - for (i = 0; dat[i]; i++) - if (strchr (char_name_letters, dat[i]) != NULL) + for (i = 0; cdat[i]; i++) + if (strchr (char_name_letters, cdat[i]) != NULL) { char_log ("Make new char error (invalid letter in the name): (connection #%d, account: %d), name: %s, invalid letter: %c.\n", - fd, sd->account_id, dat, dat[i]); + fd, sd->account_id, cdat, cdat[i]); return -1; } } // else, all letters/symbols are authorised (except control char removed before) + // this is why it needs to be unsigned if (dat[24] + dat[25] + dat[26] + dat[27] + dat[28] + dat[29] != 5 * 6 || // stats dat[30] >= 9 || // slots (dat[30] can not be negativ) - dat[33] < 0 || dat[33] >= 20 || // hair style + dat[33] >= 20 || // hair style dat[31] >= 12) { // hair color (dat[31] can not be negativ) char_log @@ -928,13 +917,13 @@ 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) + if ((name_ignoring_case != 0 && strcmp (char_dat[i].name, cdat) == 0) || (name_ignoring_case == 0 - && strcasecmp (char_dat[i].name, dat) == 0)) + && strcasecmp (char_dat[i].name, cdat) == 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.\n", - fd, sd->account_id, dat[30], dat, char_dat[i].name, + fd, sd->account_id, dat[30], cdat, 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]); @@ -945,7 +934,7 @@ int make_new_char (int fd, unsigned char *dat) { char_log ("Make new char error (slot already used): (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.\n", - fd, sd->account_id, dat[30], dat, char_dat[i].name, + fd, sd->account_id, dat[30], cdat, 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]); @@ -953,11 +942,11 @@ int make_new_char (int fd, unsigned char *dat) } } - if (strcmp (wisp_server_name, dat) == 0) + if (strcmp (wisp_server_name, cdat) == 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.\n", - fd, sd->account_id, dat[30], dat, char_dat[i].name, + ("Make new char error (name used is wisp name for server): (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.\n", + fd, sd->account_id, dat[30], cdat, 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]); @@ -981,7 +970,7 @@ int make_new_char (int fd, unsigned char *dat) char_log ("Creation of New Character: (connection #%d, account: %d) slot %d, character Name: %s, stats: %d+%d+%d+%d+%d+%d=%d, hair: %d, hair color: %d. [%s]\n", - fd, sd->account_id, dat[30], dat, dat[24], dat[25], dat[26], + fd, sd->account_id, dat[30], cdat, 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], ip); @@ -991,7 +980,7 @@ 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); + strcpy (char_dat[i].name, cdat); char_dat[i].pc_class = 0; char_dat[i].base_level = 1; char_dat[i].job_level = 1; @@ -1043,7 +1032,8 @@ int make_new_char (int fd, unsigned char *dat) //---------------------------------------------------- // This function return the name of the job (by [Yor]) //---------------------------------------------------- -char *job_name (int pc_class) +static +const char *job_name (int pc_class) { switch (pc_class) { @@ -1192,6 +1182,7 @@ char *job_name (int pc_class) //------------------------------------------------------------- // Function to create the online files (txt and html). by [Yor] //------------------------------------------------------------- +static void create_online_files (void) { int i, j, k, l; // for loops @@ -1448,7 +1439,7 @@ void create_online_files (void) // displaying of the job if (online_display_option & 6) { - char *jobname = job_name (char_dat[j].pc_class); + const char *jobname = job_name (char_dat[j].pc_class); if ((online_display_option & 6) == 6) { fprintf (fp2, " <td>%s %d/%d</td>\n", @@ -1549,6 +1540,7 @@ void create_online_files (void) //--------------------------------------------------------------------- // This function return the number of online players in all map-servers //--------------------------------------------------------------------- +static int count_users (void) { int i, users; @@ -1577,6 +1569,7 @@ static int find_equip_view (struct mmo_charstatus *p, unsigned int equipmask) //---------------------------------------- // Function to send characters to a player //---------------------------------------- +static int mmo_char_send006b (int fd, struct char_session_data *sd) { int i, j, found_num; @@ -1657,6 +1650,7 @@ int mmo_char_send006b (int fd, struct char_session_data *sd) return 0; } +static int set_account_reg2 (int acc, int num, struct global_reg *reg) { int i, c; @@ -1676,10 +1670,11 @@ int set_account_reg2 (int acc, int num, struct global_reg *reg) } // Divorce a character from it's partner and let the map server know +static int char_divorce (struct mmo_charstatus *cs) { int i; - char buf[10]; + uint8_t buf[10]; if (cs == NULL) return 0; @@ -1726,51 +1721,10 @@ int char_divorce (struct mmo_charstatus *cs) return 0; } -//------------------------------------------------------------ -// E-mail check: return 0 (not correct) or 1 (valid). by [Yor] -//------------------------------------------------------------ -int e_mail_check (unsigned char *email) -{ - char ch; - unsigned char *last_arobas; - - // athena limits - if (strlen (email) < 3 || strlen (email) > 39) - return 0; - - // part of RFC limits (official reference of e-mail description) - if (strchr (email, '@') == NULL || email[strlen (email) - 1] == '@') - return 0; - - if (email[strlen (email) - 1] == '.') - return 0; - - last_arobas = strrchr (email, '@'); - - if (strstr (last_arobas, "@.") != NULL || - strstr (last_arobas, "..") != NULL) - return 0; - - for (ch = 1; ch < 32; ch++) - { - if (strchr (last_arobas, ch) != NULL) - { - return 0; - break; - } - } - - if (strchr (last_arobas, ' ') != NULL || - strchr (last_arobas, ';') != NULL) - return 0; - - // all correct - return 1; -} - //---------------------------------------------------------------------- // Force disconnection of an online player (with account value) by [Yor] //---------------------------------------------------------------------- +static int disconnect_player (int accound_id) { int i; @@ -1817,9 +1771,9 @@ static int char_delete (struct mmo_charstatus *cs) return 0; } +static void parse_tologin (int fd) { - int i; struct char_session_data *sd; // only login-server can have an access to here. @@ -1866,6 +1820,7 @@ void parse_tologin (int fd) printf ("Connected to login-server (connection #%d).\n", fd); // if no map-server already connected, display a message... + int i; for (i = 0; i < MAX_MAP_SERVERS; i++) if (server_fd[i] >= 0 && server[i].map[0][0]) // if map-server online and at least 1 map break; @@ -1879,7 +1834,7 @@ void parse_tologin (int fd) if (RFIFOREST (fd) < 51) return; // printf("parse_tologin 2713 : %d\n", RFIFOB(fd,6)); - for (i = 0; i < fd_max; i++) + for (int i = 0; i < fd_max; i++) { if (session[i] && (sd = (struct char_session_data*)session[i]->session_data) && sd->account_id == RFIFOL (fd, 2)) @@ -1922,7 +1877,7 @@ void parse_tologin (int fd) case 0x2717: if (RFIFOREST (fd) < 50) return; - for (i = 0; i < fd_max; i++) + for (int i = 0; i < fd_max; i++) { if (session[i] && (sd = (struct char_session_data*)session[i]->session_data)) { @@ -2026,6 +1981,7 @@ void parse_tologin (int fd) ("Receiving a message for broadcast, but message is void.\n"); else { + int i; // at least 1 map-server for (i = 0; i < MAX_MAP_SERVERS; i++) if (server_fd[i] >= 0) @@ -2035,7 +1991,7 @@ void parse_tologin (int fd) ("'ladmin': Receiving a message for broadcast, but no map-server is online.\n"); else { - char buf[128]; + uint8_t buf[128]; char message[RFIFOL (fd, 4) + 1]; // +1 to add a null terminated if not exist in the packet int lp; char *p; @@ -2140,7 +2096,7 @@ void parse_tologin (int fd) WBUFL (buf, 6) = dest_id; mapif_sendall (buf, 10); // forward package to map servers - for (i = 0; i < char_num; i++) + for (int i = 0; i < char_num; i++) { struct mmo_charstatus *c = char_dat + i; struct storage *s = account2storage (c->account_id); @@ -2180,7 +2136,7 @@ void parse_tologin (int fd) if (RFIFOREST (fd) < 6) return; // Deletion of all characters of the account - for (i = 0; i < char_num; i++) + for (int i = 0; i < char_num; i++) { if (char_dat[i].account_id == RFIFOL (fd, 2)) { @@ -2260,12 +2216,12 @@ void parse_tologin (int fd) if (RFIFOREST (fd) < 4 || RFIFOREST (fd) < RFIFOW (fd, 2)) return; { - char buf[32000]; + uint8_t buf[32000]; if (gm_account != NULL) free (gm_account); CREATE (gm_account, struct gm_account, (RFIFOW (fd, 2) - 4) / 5); GM_num = 0; - for (i = 4; i < RFIFOW (fd, 2); i = i + 5) + for (int i = 4; i < RFIFOW (fd, 2); i = i + 5) { gm_account[GM_num].account_id = RFIFOL (fd, i); gm_account[GM_num].level = (int) RFIFOB (fd, i + 4); @@ -2323,6 +2279,7 @@ void parse_tologin (int fd) //-------------------------------- // Map-server anti-freeze system //-------------------------------- +static void map_anti_freeze_system (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { int i; @@ -2347,6 +2304,7 @@ void map_anti_freeze_system (timer_id tid, tick_t tick, custom_id_t id, custom_d } } +static void parse_frommap (int fd) { int i, j; @@ -2875,7 +2833,8 @@ void parse_frommap (int fd) } } -int search_mapserver (char *map) +static +int search_mapserver (const char *map) { int i, j; char temp_map[16]; @@ -2911,6 +2870,7 @@ static int char_mapif_init (int fd) //----------------------------------------------------- // Test to know if an IP come from LAN or WAN. by [Yor] //----------------------------------------------------- +static int lan_ip_check (unsigned char *p) { int i; @@ -2933,6 +2893,7 @@ int lan_ip_check (unsigned char *p) return lancheck; } +static void parse_char (int fd) { int i, ch; @@ -3072,12 +3033,8 @@ void parse_char (int fd) case 0x66: // キャラ選択 if (!sd || RFIFOREST (fd) < 3) return; - - char ip[16]; - unsigned char *sin_addr = - (unsigned char *) &session[fd]->client_addr.sin_addr; - sprintf (ip, "%d.%d.%d.%d", sin_addr[0], sin_addr[1], - sin_addr[2], sin_addr[3]); + { + const char *ip = ip2str(session[fd]->client_addr.sin_addr); // if we activated email creation and email is default email if (email_creation != 0 && strcmp (sd->email, "a@a.com") == 0 @@ -3236,6 +3193,7 @@ void parse_char (int fd) auth_fifo_pos++; } } + } RFIFOSKIP (fd, 3); break; @@ -3449,8 +3407,8 @@ void 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 ((const char *)RFIFOP (fd, 2), userid) + || strcmp ((const char *)RFIFOP (fd, 26), passwd)) { WFIFOB (fd, 2) = 3; WFIFOSET (fd, 3); @@ -3520,7 +3478,7 @@ void parse_char (int fd) } // 全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendall (char *buf, unsigned int len) +int mapif_sendall (const uint8_t *buf, unsigned int len) { int i, c; @@ -3539,7 +3497,7 @@ int mapif_sendall (char *buf, unsigned int len) } // 自分以外の全てのMAPサーバーにデータ送信(送信したmap鯖の数を返す) -int mapif_sendallwos (int sfd, unsigned char *buf, unsigned int len) +int mapif_sendallwos (int sfd, const uint8_t *buf, unsigned int len) { int i, c; @@ -3558,7 +3516,7 @@ int mapif_sendallwos (int sfd, unsigned char *buf, unsigned int len) } // MAPサーバーにデータ送信(map鯖生存確認有り) -int mapif_send (int fd, unsigned char *buf, unsigned int len) +int mapif_send (int fd, const uint8_t *buf, unsigned int len) { int i; @@ -3577,10 +3535,11 @@ int mapif_send (int fd, unsigned char *buf, unsigned int len) return 0; } +static 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]; + uint8_t buf[16]; if (login_fd > 0 && session[login_fd]) { @@ -3595,6 +3554,7 @@ void send_users_tologin (timer_id tid, tick_t tick, custom_id_t id, custom_data_ mapif_sendall (buf, 6); } +static 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) @@ -3624,26 +3584,10 @@ void check_connect_login_server (timer_id tid, tick_t tick, custom_id_t id, cust } } -//---------------------------------------------------------- -// Return numerical value of a switch configuration by [Yor] -// on/off, english, français, deutsch, español -//---------------------------------------------------------- -int config_switch (const char *str) -{ - if (strcasecmp (str, "on") == 0 || strcasecmp (str, "yes") == 0 - || strcasecmp (str, "oui") == 0 || strcasecmp (str, "ja") == 0 - || strcasecmp (str, "si") == 0) - return 1; - if (strcasecmp (str, "off") == 0 || strcasecmp (str, "no") == 0 - || strcasecmp (str, "non") == 0 || strcasecmp (str, "nein") == 0) - return 0; - - return atoi (str); -} - //------------------------------------------- // Reading Lan Support configuration by [Yor] //------------------------------------------- +static int lan_config_read (const char *lancfgName) { int j; @@ -3761,6 +3705,7 @@ int lan_config_read (const char *lancfgName) return 0; } +static int char_config_read (const char *cfgName) { struct hostent *h = NULL; diff --git a/src/char/char.hpp b/src/char/char.hpp index 22b7678..f93e86b 100644 --- a/src/char/char.hpp +++ b/src/char/char.hpp @@ -18,14 +18,15 @@ struct mmo_map_server char map[MAX_MAP_PER_SERVER][16]; }; -int search_character_index (char *character_name); +int search_character_index (const char *character_name); char *search_character_name (int index); -int mapif_sendall (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 mapif_sendall (const uint8_t *buf, unsigned int len); +int mapif_sendallwos (int fd, const uint8_t *buf, unsigned int len); +int mapif_send (int fd, const uint8_t *buf, unsigned int len); -int char_log (char *fmt, ...); +__attribute__((format(printf, 1, 2))) +int char_log (const char *fmt, ...); extern int autosave_interval; diff --git a/src/char/int_guild.cpp b/src/char/int_guild.cpp index fe9a95b..318297e 100644 --- a/src/char/int_guild.cpp +++ b/src/char/int_guild.cpp @@ -33,6 +33,7 @@ int mapif_guild_info (int fd, struct guild *g); void guild_break_sub (db_key_t key, db_val_t data, va_list ap); // ギルドデータの文字列への変換 +static int inter_guild_tostr (char *str, struct guild *g) { int i, c, len; @@ -76,7 +77,7 @@ int inter_guild_tostr (char *str, struct guild *g) len += sprintf (str + len, "%d\t", c); for (i = 0; i < MAX_GUILDALLIANCE; i++) { - struct guild_alliance *a = &g->alliance[i]; + GuildAlliance *a = &g->alliance[i]; if (a->guild_id > 0) len += sprintf (str + len, "%d,%d\t%s\t", a->guild_id, a->opposition, @@ -90,7 +91,7 @@ int inter_guild_tostr (char *str, struct guild *g) len += sprintf (str + len, "%d\t", c); for (i = 0; i < MAX_GUILDEXPLUSION; i++) { - struct guild_explusion *e = &g->explusion[i]; + GuildExpulsion *e = &g->explusion[i]; if (e->account_id > 0) len += sprintf (str + len, "%d,%d,%d,%d\t%s\t%s\t%s#\t", e->account_id, e->rsv1, e->rsv2, e->rsv3, @@ -107,6 +108,7 @@ int inter_guild_tostr (char *str, struct guild *g) } // ギルドデータの文字列からの変換 +static int inter_guild_fromstr (char *str, struct guild *g) { int i, j, c; @@ -218,7 +220,7 @@ int inter_guild_fromstr (char *str, struct guild *g) str = strchr (str + 1, '\t'); // 位置スキップ for (i = 0; i < c; i++) { - struct guild_alliance *a = &g->alliance[i]; + GuildAlliance *a = &g->alliance[i]; if (sscanf (str + 1, "%d,%d\t%[^\t]\t", &tmp_int[0], &tmp_int[1], tmp_str[0]) < 3) @@ -237,7 +239,7 @@ int inter_guild_fromstr (char *str, struct guild *g) str = strchr (str + 1, '\t'); // 位置スキップ for (i = 0; i < c; i++) { - struct guild_explusion *e = &g->explusion[i]; + GuildExpulsion *e = &g->explusion[i]; if (sscanf (str + 1, "%d,%d,%d,%d\t%[^\t]\t%[^\t]\t%[^\t]\t", &tmp_int[0], &tmp_int[1], &tmp_int[2], &tmp_int[3], tmp_str[0], tmp_str[1], tmp_str[2]) < 6) @@ -271,6 +273,7 @@ int inter_guild_fromstr (char *str, struct guild *g) } // ギルド城データの文字列への変換 +static int inter_guildcastle_tostr (char *str, struct guild_castle *gc) { int len; @@ -287,6 +290,7 @@ int inter_guildcastle_tostr (char *str, struct guild_castle *gc) } // ギルド城データの文字列からの変換 +static int inter_guildcastle_fromstr (char *str, struct guild_castle *gc) { int tmp_int[26]; @@ -398,6 +402,7 @@ int inter_guildcastle_fromstr (char *str, struct guild_castle *gc) } // ギルド関連データベース読み込み +static int inter_guild_readdb (void) { int i; @@ -541,6 +546,7 @@ struct guild *inter_guild_search (int guild_id) } // ギルドデータのセーブ用 +static void inter_guild_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[16384]; @@ -552,6 +558,7 @@ void inter_guild_save_sub (db_key_t key, db_val_t data, va_list ap) } // ギルド城データのセーブ用 +static void inter_castle_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[16384]; @@ -592,6 +599,7 @@ int inter_guild_save (void) } // ギルド名検索用 +static void search_guildname_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data, **dst; @@ -604,7 +612,8 @@ void search_guildname_sub (db_key_t key, db_val_t data, va_list ap) } // ギルド名検索 -struct guild *search_guildname (char *str) +static +struct guild *search_guildname (const char *str) { struct guild *g = NULL; numdb_foreach (guild_db, search_guildname_sub, str, &g); @@ -634,6 +643,7 @@ int guild_check_empty (struct guild *g) } // キャラの競合がないかチェック用 +static void guild_check_conflict_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data; @@ -660,6 +670,7 @@ void guild_check_conflict_sub (db_key_t key, db_val_t data, va_list ap) } // キャラの競合がないかチェック +static int guild_check_conflict (int guild_id, int account_id, int char_id) { numdb_foreach (guild_db, guild_check_conflict_sub, guild_id, account_id, @@ -668,6 +679,7 @@ int guild_check_conflict (int guild_id, int account_id, int char_id) return 0; } +static int guild_nextexp (int level) { if (level < 100) @@ -677,6 +689,7 @@ int guild_nextexp (int level) } // ギルドスキルがあるか確認 +static int guild_checkskill (struct guild *g, int id) { return g->skill[id - 10000].lv; @@ -745,6 +758,7 @@ int guild_calcinfo (struct guild *g) // map serverへの通信 // ギルド作成可否 +static int mapif_guild_created (int fd, int account_id, struct guild *g) { WFIFOW (fd, 0) = 0x3830; @@ -763,6 +777,7 @@ int mapif_guild_created (int fd, int account_id, struct guild *g) } // ギルド情報見つからず +static int mapif_guild_noinfo (int fd, int guild_id) { WFIFOW (fd, 0) = 0x3831; @@ -793,6 +808,7 @@ int mapif_guild_info (int fd, struct guild *g) } // メンバ追加可否 +static int mapif_guild_memberadded (int fd, int guild_id, int account_id, int char_id, int flag) { @@ -807,6 +823,7 @@ int mapif_guild_memberadded (int fd, int guild_id, int account_id, } // 脱退/追放通知 +static int mapif_guild_leaved (int guild_id, int account_id, int char_id, int flag, const char *name, const char *mes) { @@ -827,6 +844,7 @@ int mapif_guild_leaved (int guild_id, int account_id, int char_id, int flag, } // オンライン状態とLv更新通知 +static int mapif_guild_memberinfoshort (struct guild *g, int idx) { unsigned char buf[19]; @@ -857,7 +875,8 @@ int mapif_guild_broken (int guild_id, int flag) } // ギルド内発言 -int mapif_guild_message (int guild_id, int account_id, char *mes, int len) +static +int mapif_guild_message (int guild_id, int account_id, const char *mes, int len) { unsigned char buf[len + 12]; @@ -887,6 +906,7 @@ int mapif_guild_basicinfochanged (int guild_id, int type, const void *data, } // ギルドメンバ情報変更通知 +static int mapif_guild_memberinfochanged (int guild_id, int account_id, int char_id, int type, const void *data, int len) { @@ -905,6 +925,7 @@ int mapif_guild_memberinfochanged (int guild_id, int account_id, int char_id, } // ギルドスキルアップ通知 +static int mapif_guild_skillupack (int guild_id, int skill_num, int account_id) { unsigned char buf[14]; @@ -919,6 +940,7 @@ int mapif_guild_skillupack (int guild_id, int skill_num, int account_id) } // ギルド同盟/敵対通知 +static int mapif_guild_alliance (int guild_id1, int guild_id2, int account_id1, int account_id2, int flag, const char *name1, const char *name2) @@ -939,6 +961,7 @@ int mapif_guild_alliance (int guild_id1, int guild_id2, int account_id1, } // ギルド役職変更通知 +static int mapif_guild_position (struct guild *g, int idx) { unsigned char buf[sizeof (struct guild_position) + 12]; @@ -955,6 +978,7 @@ int mapif_guild_position (struct guild *g, int idx) } // ギルド告知変更通知 +static int mapif_guild_notice (struct guild *g) { unsigned char buf[186]; @@ -969,6 +993,7 @@ int mapif_guild_notice (struct guild *g) } // ギルドエンブレム変更通知 +static int mapif_guild_emblem (struct guild *g) { unsigned char buf[2048]; @@ -983,6 +1008,7 @@ int mapif_guild_emblem (struct guild *g) return 0; } +static int mapif_guild_castle_dataload (int castle_id, int index, int value) { unsigned char buf[9]; @@ -996,6 +1022,7 @@ int mapif_guild_castle_dataload (int castle_id, int index, int value) return 0; } +static int mapif_guild_castle_datasave (int castle_id, int index, int value) { unsigned char buf[9]; @@ -1009,6 +1036,7 @@ int mapif_guild_castle_datasave (int castle_id, int index, int value) return 0; } +static void mapif_guild_castle_alldataload_sub (db_key_t key, db_val_t data, va_list ap) { int fd = va_arg (ap, int); @@ -1019,6 +1047,7 @@ void mapif_guild_castle_alldataload_sub (db_key_t key, db_val_t data, va_list ap (*p) += sizeof (struct guild_castle); } +static int mapif_guild_castle_alldataload (int fd) { int len = 4; @@ -1035,7 +1064,8 @@ int mapif_guild_castle_alldataload (int fd) // map serverからの通信 // ギルド作成要求 -int mapif_parse_CreateGuild (int fd, int account_id, char *name, +static +int mapif_parse_CreateGuild (int fd, int account_id, const char *name, struct guild_member *master) { struct guild *g; @@ -1087,6 +1117,7 @@ int mapif_parse_CreateGuild (int fd, int account_id, char *name, } // ギルド情報要求 +static int mapif_parse_GuildInfo (int fd, int guild_id) { struct guild *g = (struct guild *)numdb_search (guild_db, guild_id); @@ -1102,6 +1133,7 @@ int mapif_parse_GuildInfo (int fd, int guild_id) } // ギルドメンバ追加要求 +static int mapif_parse_GuildAddMember (int fd, int guild_id, struct guild_member *m) { struct guild *g = (struct guild *)numdb_search (guild_db, guild_id); @@ -1181,6 +1213,7 @@ int mapif_parse_GuildLeave (int fd, int guild_id, int account_id, int char_id, } // オンライン/Lv更新 +static int mapif_parse_GuildChangeMemberInfoShort (int fd, int guild_id, int account_id, int char_id, int online, int lv, int pc_class) @@ -1231,6 +1264,7 @@ void guild_break_sub (db_key_t key, db_val_t data, va_list ap) } // ギルド解散要求 +static int mapif_parse_BreakGuild (int fd, int guild_id) { struct guild *g = (struct guild *)numdb_search (guild_db, guild_id); @@ -1249,13 +1283,15 @@ int mapif_parse_BreakGuild (int fd, int guild_id) } // ギルドメッセージ送信 -int mapif_parse_GuildMessage (int fd, int guild_id, int account_id, char *mes, +static +int mapif_parse_GuildMessage (int fd, int guild_id, int account_id, const char *mes, int len) { return mapif_guild_message (guild_id, account_id, mes, len); } // ギルド基本データ変更要求 +static int mapif_parse_GuildBasicInfoChange (int fd, int guild_id, int type, const char *data, int len) { @@ -1288,6 +1324,7 @@ int mapif_parse_GuildBasicInfoChange (int fd, int guild_id, int type, } // ギルドメンバデータ変更要求 +static int mapif_parse_GuildMemberInfoChange (int fd, int guild_id, int account_id, int char_id, int type, const char *data, int len) @@ -1332,6 +1369,7 @@ int mapif_parse_GuildMemberInfoChange (int fd, int guild_id, int account_id, } // ギルド役職名変更要求 +static int mapif_parse_GuildPosition (int fd, int guild_id, int idx, struct guild_position *p) { @@ -1349,6 +1387,7 @@ int mapif_parse_GuildPosition (int fd, int guild_id, int idx, } // ギルドスキルアップ要求 +static int mapif_parse_GuildSkillUp (int fd, int guild_id, int skill_num, int account_id) { @@ -1372,6 +1411,7 @@ int mapif_parse_GuildSkillUp (int fd, int guild_id, int skill_num, } // ギルド同盟要求 +static int mapif_parse_GuildAlliance (int fd, int guild_id1, int guild_id2, int account_id1, int account_id2, int flag) { @@ -1417,6 +1457,7 @@ int mapif_parse_GuildAlliance (int fd, int guild_id1, int guild_id2, } // ギルド告知変更要求 +static int mapif_parse_GuildNotice (int fd, int guild_id, const char *mes1, const char *mes2) { @@ -1430,6 +1471,7 @@ int mapif_parse_GuildNotice (int fd, int guild_id, const char *mes1, } // ギルドエンブレム変更要求 +static int mapif_parse_GuildEmblem (int fd, int len, int guild_id, int dummy, const char *data) { @@ -1443,6 +1485,7 @@ int mapif_parse_GuildEmblem (int fd, int len, int guild_id, int dummy, return mapif_guild_emblem (g); } +static int mapif_parse_GuildCastleDataLoad (int fd, int castle_id, int index) { struct guild_castle *gc = (struct guild_castle *)numdb_search (castle_db, castle_id); @@ -1537,6 +1580,7 @@ int mapif_parse_GuildCastleDataLoad (int fd, int castle_id, int index) return 0; } +static int mapif_parse_GuildCastleDataSave (int fd, int castle_id, int index, int value) { @@ -1642,6 +1686,7 @@ int mapif_parse_GuildCastleDataSave (int fd, int castle_id, int index, } // ギルドチェック要求 +static int mapif_parse_GuildCheck (int fd, int guild_id, int account_id, int char_id) { return guild_check_conflict (guild_id, account_id, 0 /*char_id*/); @@ -1657,7 +1702,7 @@ int inter_guild_parse_frommap (int fd) switch (RFIFOW (fd, 0)) { case 0x3030: - mapif_parse_CreateGuild (fd, RFIFOL (fd, 4), RFIFOP (fd, 8), + mapif_parse_CreateGuild (fd, RFIFOL (fd, 4), (const char *)RFIFOP (fd, 8), (struct guild_member *) RFIFOP (fd, 32)); break; case 0x3031: @@ -1671,7 +1716,7 @@ int inter_guild_parse_frommap (int fd) case 0x3034: mapif_parse_GuildLeave (fd, RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOL (fd, 10), RFIFOB (fd, 14), - RFIFOP (fd, 15)); + (const char *)RFIFOP (fd, 15)); break; case 0x3035: mapif_parse_GuildChangeMemberInfoShort (fd, RFIFOL (fd, 2), @@ -1686,7 +1731,7 @@ int inter_guild_parse_frommap (int fd) break; case 0x3037: mapif_parse_GuildMessage (fd, RFIFOL (fd, 4), RFIFOL (fd, 8), - RFIFOP (fd, 12), RFIFOW (fd, 2) - 12); + (const char *)RFIFOP (fd, 12), RFIFOW (fd, 2) - 12); break; case 0x3038: mapif_parse_GuildCheck (fd, RFIFOL (fd, 2), RFIFOL (fd, 6), @@ -1694,14 +1739,14 @@ int inter_guild_parse_frommap (int fd) break; case 0x3039: mapif_parse_GuildBasicInfoChange (fd, RFIFOL (fd, 4), - RFIFOW (fd, 8), RFIFOP (fd, 10), + 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), RFIFOP (fd, + RFIFOW (fd, 16), (const char *)RFIFOP (fd, 18), RFIFOW (fd, 2) - 18); break; @@ -1720,12 +1765,12 @@ int inter_guild_parse_frommap (int fd) RFIFOB (fd, 18)); break; case 0x303E: - mapif_parse_GuildNotice (fd, RFIFOL (fd, 2), RFIFOP (fd, 6), - RFIFOP (fd, 66)); + 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), RFIFOP (fd, 12)); + RFIFOL (fd, 8), (const char *)RFIFOP (fd, 12)); break; case 0x3040: mapif_parse_GuildCastleDataLoad (fd, RFIFOW (fd, 2), diff --git a/src/char/int_party.cpp b/src/char/int_party.cpp index 7d0e0ce..6602ce5 100644 --- a/src/char/int_party.cpp +++ b/src/char/int_party.cpp @@ -20,6 +20,7 @@ int party_check_empty (struct party *p); int mapif_parse_PartyLeave (int fd, int party_id, int account_id); // パーティデータの文字列への変換 +static int inter_party_tostr (char *str, struct party *p) { int i, len; @@ -39,6 +40,7 @@ int inter_party_tostr (char *str, struct party *p) } // パーティデータの文字列からの変換 +static int inter_party_fromstr (char *str, struct party *p) { int i, j; @@ -133,6 +135,7 @@ int inter_party_init (void) } // パーティーデータのセーブ用 +static void inter_party_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[8192]; @@ -164,6 +167,7 @@ int inter_party_save (void) } // パーティ名検索用 +static void search_partyname_sub (db_key_t key, db_val_t data, va_list ap) { struct party *p = (struct party *) data, **dst; @@ -176,7 +180,8 @@ void search_partyname_sub (db_key_t key, db_val_t data, va_list ap) } // パーティ名検索 -struct party *search_partyname (char *str) +static +struct party *search_partyname (const char *str) { struct party *p = NULL; numdb_foreach (party_db, search_partyname_sub, str, &p); @@ -185,6 +190,7 @@ struct party *search_partyname (char *str) } // EXP公平分配できるかチェック +static int party_check_exp_share (struct party *p) { int i; @@ -228,6 +234,7 @@ int party_check_empty (struct party *p) } // キャラの競合がないかチェック用 +static void party_check_conflict_sub (db_key_t key, db_val_t data, va_list ap) { struct party *p = (struct party *) data; @@ -255,7 +262,8 @@ void party_check_conflict_sub (db_key_t key, db_val_t data, va_list ap) } // キャラの競合がないかチェック -int party_check_conflict (int party_id, int account_id, char *nick) +static +int party_check_conflict (int party_id, int account_id, const char *nick) { numdb_foreach (party_db, party_check_conflict_sub, party_id, account_id, nick); @@ -267,6 +275,7 @@ int party_check_conflict (int party_id, int account_id, char *nick) // map serverへの通信 // パーティ作成可否 +static int mapif_party_created (int fd, int account_id, struct party *p) { WFIFOW (fd, 0) = 0x3820; @@ -290,6 +299,7 @@ int mapif_party_created (int fd, int account_id, struct party *p) } // パーティ情報見つからず +static int mapif_party_noinfo (int fd, int party_id) { WFIFOW (fd, 0) = 0x3821; @@ -302,6 +312,7 @@ int mapif_party_noinfo (int fd, int party_id) } // パーティ情報まとめ送り +static int mapif_party_info (int fd, struct party *p) { unsigned char buf[4 + sizeof (struct party)]; @@ -319,6 +330,7 @@ int mapif_party_info (int fd, struct party *p) } // パーティメンバ追加可否 +static int mapif_party_memberadded (int fd, int party_id, int account_id, int flag) { WFIFOW (fd, 0) = 0x3822; @@ -331,6 +343,7 @@ int mapif_party_memberadded (int fd, int party_id, int account_id, int flag) } // パーティ設定変更通知 +static int mapif_party_optionchanged (int fd, struct party *p, int account_id, int flag) { @@ -353,6 +366,7 @@ int mapif_party_optionchanged (int fd, struct party *p, int account_id, } // パーティ脱退通知 +static int mapif_party_leaved (int party_id, int account_id, char *name) { unsigned char buf[34]; @@ -368,6 +382,7 @@ int mapif_party_leaved (int party_id, int account_id, char *name) } // パーティマップ更新通知 +static int mapif_party_membermoved (struct party *p, int idx) { unsigned char buf[29]; @@ -397,7 +412,8 @@ int mapif_party_broken (int party_id, int flag) } // パーティ内発言 -int mapif_party_message (int party_id, int account_id, char *mes, int len) +static +int mapif_party_message (int party_id, int account_id, const char *mes, int len) { unsigned char buf[len + 12]; @@ -415,8 +431,9 @@ 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) +static +int mapif_parse_CreateParty (int fd, int account_id, const char *name, const char *nick, + const char *map, int lv) { struct party *p; int i; @@ -458,6 +475,7 @@ int mapif_parse_CreateParty (int fd, int account_id, char *name, char *nick, } // パーティ情報要求 +static int mapif_parse_PartyInfo (int fd, int party_id) { struct party *p = (struct party *)numdb_search (party_db, party_id); @@ -470,8 +488,9 @@ int mapif_parse_PartyInfo (int fd, int party_id) } // パーティ追加要求 +static int mapif_parse_PartyAddMember (int fd, int party_id, int account_id, - char *nick, char *map, int lv) + const char *nick, const char *map, int lv) { struct party *p = (struct party *)numdb_search (party_db, party_id); if (p == NULL) @@ -511,6 +530,7 @@ int mapif_parse_PartyAddMember (int fd, int party_id, int account_id, } // パーティー設定変更要求 +static int mapif_parse_PartyChangeOption (int fd, int party_id, int account_id, int exp, int item) { @@ -556,8 +576,9 @@ int mapif_parse_PartyLeave (int fd, int party_id, int account_id) } // パーティマップ更新要求 +static int mapif_parse_PartyChangeMap (int fd, int party_id, int account_id, - char *map, int online, int lv) + const char *map, int online, int lv) { struct party *p = (struct party *)numdb_search (party_db, party_id); if (p == NULL) @@ -589,6 +610,7 @@ int mapif_parse_PartyChangeMap (int fd, int party_id, int account_id, } // パーティ解散要求 +static int mapif_parse_BreakParty (int fd, int party_id) { struct party *p = (struct party *)numdb_search (party_db, party_id); @@ -602,14 +624,16 @@ int mapif_parse_BreakParty (int fd, int party_id) } // パーティメッセージ送信 -int mapif_parse_PartyMessage (int fd, int party_id, int account_id, char *mes, +static +int mapif_parse_PartyMessage (int fd, int party_id, int account_id, const char *mes, int len) { return mapif_party_message (party_id, account_id, mes, len); } // パーティチェック要求 -int mapif_parse_PartyCheck (int fd, int party_id, int account_id, char *nick) +static +int mapif_parse_PartyCheck (int fd, int party_id, int account_id, const char *nick) { return party_check_conflict (party_id, account_id, nick); } @@ -624,8 +648,8 @@ 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), + mapif_parse_CreateParty (fd, RFIFOL (fd, 2), (const char *)RFIFOP (fd, 6), + (const char *)RFIFOP (fd, 30), (const char *)RFIFOP (fd, 54), RFIFOW (fd, 70)); break; case 0x3021: @@ -633,7 +657,7 @@ int inter_party_parse_frommap (int fd) break; case 0x3022: mapif_parse_PartyAddMember (fd, RFIFOL (fd, 2), RFIFOL (fd, 6), - RFIFOP (fd, 10), RFIFOP (fd, 34), + (const char *)RFIFOP (fd, 10), (const char *)RFIFOP (fd, 34), RFIFOW (fd, 50)); break; case 0x3023: @@ -645,7 +669,7 @@ int inter_party_parse_frommap (int fd) break; case 0x3025: mapif_parse_PartyChangeMap (fd, RFIFOL (fd, 2), RFIFOL (fd, 6), - RFIFOP (fd, 10), RFIFOB (fd, 26), + (const char *)RFIFOP (fd, 10), RFIFOB (fd, 26), RFIFOW (fd, 27)); break; case 0x3026: @@ -653,11 +677,11 @@ int inter_party_parse_frommap (int fd) break; case 0x3027: mapif_parse_PartyMessage (fd, RFIFOL (fd, 4), RFIFOL (fd, 8), - RFIFOP (fd, 12), RFIFOW (fd, 2) - 12); + (const char *)RFIFOP (fd, 12), RFIFOW (fd, 2) - 12); break; case 0x3028: mapif_parse_PartyCheck (fd, RFIFOL (fd, 2), RFIFOL (fd, 6), - RFIFOP (fd, 10)); + (const char *)RFIFOP (fd, 10)); break; default: return 0; diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp index b197213..a962b92 100644 --- a/src/char/int_storage.cpp +++ b/src/char/int_storage.cpp @@ -21,6 +21,7 @@ static struct dbt *storage_db; static struct dbt *guild_storage_db; // 倉庫データを文字列に変換 +static int storage_tostr (char *str, struct storage *p) { int i, f = 0; @@ -49,6 +50,7 @@ int storage_tostr (char *str, struct storage *p) } // 文字列を倉庫データに変換 +static int storage_fromstr (char *str, struct storage *p) { int tmp_int[256]; @@ -118,6 +120,7 @@ int storage_fromstr (char *str, struct storage *p) return 0; } +static int guild_storage_tostr (char *str, struct guild_storage *p) { int i, f = 0; @@ -145,6 +148,7 @@ int guild_storage_tostr (char *str, struct guild_storage *p) return 0; } +static int guild_storage_fromstr (char *str, struct guild_storage *p) { int tmp_int[256]; @@ -229,6 +233,7 @@ struct storage *account2storage (int account_id) return s; } +static struct guild_storage *guild2storage (int guild_id) { struct guild_storage *gs = NULL; @@ -314,6 +319,7 @@ int inter_storage_init (void) return 0; } +static void storage_db_final (db_key_t k, db_val_t data, va_list ap) { struct storage *p = (struct storage *) data; @@ -321,6 +327,7 @@ void storage_db_final (db_key_t k, db_val_t data, va_list ap) free (p); } +static void guild_storage_db_final (db_key_t k, db_val_t data, va_list ap) { struct guild_storage *p = (struct guild_storage *) data; @@ -335,6 +342,7 @@ void inter_storage_final (void) return; } +static void inter_storage_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[65536]; @@ -367,6 +375,7 @@ int inter_storage_save (void) return 0; } +static void inter_guild_storage_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[65536]; @@ -434,6 +443,7 @@ int inter_guild_storage_delete (int guild_id) // map serverへの通信 // 倉庫データの送信 +static int mapif_load_storage (int fd, int account_id) { struct storage *s = account2storage (account_id); @@ -446,6 +456,7 @@ int mapif_load_storage (int fd, int account_id) } // 倉庫データ保存完了送信 +static int mapif_save_storage_ack (int fd, int account_id) { WFIFOW (fd, 0) = 0x3811; @@ -455,6 +466,7 @@ int mapif_save_storage_ack (int fd, int account_id) return 0; } +static int mapif_load_guild_storage (int fd, int account_id, int guild_id) { struct guild_storage *gs = guild2storage (guild_id); @@ -477,6 +489,7 @@ int mapif_load_guild_storage (int fd, int account_id, int guild_id) return 0; } +static int mapif_save_guild_storage_ack (int fd, int account_id, int guild_id, int fail) { @@ -492,6 +505,7 @@ int mapif_save_guild_storage_ack (int fd, int account_id, int guild_id, // map serverからの通信 // 倉庫データ要求受信 +static int mapif_parse_LoadStorage (int fd) { mapif_load_storage (fd, RFIFOL (fd, 2)); @@ -499,6 +513,7 @@ int mapif_parse_LoadStorage (int fd) } // 倉庫データ受信&保存 +static int mapif_parse_SaveStorage (int fd) { struct storage *s; @@ -518,12 +533,14 @@ int mapif_parse_SaveStorage (int fd) return 0; } +static int mapif_parse_LoadGuildStorage (int fd) { mapif_load_guild_storage (fd, RFIFOL (fd, 2), RFIFOL (fd, 6)); return 0; } +static int mapif_parse_SaveGuildStorage (int fd) { struct guild_storage *gs; diff --git a/src/char/inter.cpp b/src/char/inter.cpp index af95a2d..7752cb4 100644 --- a/src/char/inter.cpp +++ b/src/char/inter.cpp @@ -68,6 +68,7 @@ static int wis_dellist[WISDELLIST_MAX], wis_delnum; //-------------------------------------------------------- // アカウント変数を文字列へ変換 +static int inter_accreg_tostr (char *str, struct accreg *reg) { int j; @@ -83,6 +84,7 @@ int inter_accreg_tostr (char *str, struct accreg *reg) } // アカウント変数を文字列から変換 +static int inter_accreg_fromstr (const char *str, struct accreg *reg) { int j, v, n; @@ -106,6 +108,7 @@ int inter_accreg_fromstr (const char *str, struct accreg *reg) } // アカウント変数の読み込み +static int inter_accreg_init (void) { char line[8192]; @@ -140,6 +143,7 @@ int inter_accreg_init (void) } // アカウント変数のセーブ用 +static void inter_accreg_save_sub (db_key_t key, db_val_t data, va_list ap) { char line[8192]; @@ -155,6 +159,7 @@ void inter_accreg_save_sub (db_key_t key, db_val_t data, va_list ap) } // アカウント変数のセーブ +static int inter_accreg_save (void) { FILE *fp; @@ -179,6 +184,7 @@ int inter_accreg_save (void) * 設定ファイルを読み込む *------------------------------------------ */ +static int inter_config_read (const char *cfgName) { char line[1024], w1[1024], w2[1024]; @@ -244,7 +250,7 @@ int inter_config_read (const char *cfgName) } // ログ書き出し -int inter_log (char *fmt, ...) +int inter_log (const char *fmt, ...) { FILE *logfp; va_list ap; @@ -300,6 +306,7 @@ int inter_mapif_init (int fd) // sended packets to map-server // GMメッセージ送信 +static int mapif_GMmessage (unsigned char *mes, int len) { unsigned char buf[len]; @@ -314,6 +321,7 @@ int mapif_GMmessage (unsigned char *mes, int len) } // Wisp/page transmission to all map-server +static int mapif_wis_message (struct WisData *wd) { unsigned char buf[56 + wd->len]; @@ -330,6 +338,7 @@ int mapif_wis_message (struct WisData *wd) } // Wisp/page transmission result to map-server +static int mapif_wis_end (struct WisData *wd, int flag) { unsigned char buf[27]; @@ -344,6 +353,7 @@ int mapif_wis_end (struct WisData *wd, int flag) } // アカウント変数送信 +static int mapif_account_reg (int fd, unsigned char *src) { unsigned char buf[WBUFW (src, 2)]; @@ -356,6 +366,7 @@ int mapif_account_reg (int fd, unsigned char *src) } // アカウント変数要求返信 +static int mapif_account_reg_reply (int fd, int account_id) { struct accreg *reg = (struct accreg *)numdb_search (accreg_db, account_id); @@ -384,6 +395,7 @@ int mapif_account_reg_reply (int fd, int account_id) //-------------------------------------------------------- // Existence check of WISP data +static void check_ttl_wisdata_sub (db_key_t key, db_val_t data, va_list ap) { unsigned long tick; @@ -395,6 +407,7 @@ void check_ttl_wisdata_sub (db_key_t key, db_val_t data, va_list ap) wis_dellist[wis_delnum++] = wd->id; } +static int check_ttl_wisdata (void) { unsigned long tick = gettick (); @@ -424,6 +437,7 @@ int check_ttl_wisdata (void) // received packets from map-server // GMメッセージ送信 +static int mapif_parse_GMmessage (int fd) { mapif_GMmessage (RFIFOP (fd, 4), RFIFOW (fd, 2)); @@ -432,6 +446,7 @@ int mapif_parse_GMmessage (int fd) } // Wisp/page request to send +static int mapif_parse_WisRequest (int fd) { struct WisData *wd; @@ -450,7 +465,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 ((const char *)RFIFOP (fd, 28))) == -1) { unsigned char buf[27]; WBUFW (buf, 0) = 0x3802; @@ -463,9 +478,9 @@ int mapif_parse_WisRequest (int fd) { // 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 ((const char *)RFIFOP (fd, 4), (const char *)RFIFOP (fd, 28)) == 0) { unsigned char buf[27]; WBUFW (buf, 0) = 0x3802; @@ -496,6 +511,7 @@ int mapif_parse_WisRequest (int fd) } // Wisp/page transmission result +static int mapif_parse_WisReply (int fd) { int id = RFIFOL (fd, 2), flag = RFIFOB (fd, 6); @@ -515,6 +531,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) +static 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 @@ -527,6 +544,7 @@ int mapif_parse_WisToGM (int fd) } // アカウント変数保存要求 +static int mapif_parse_AccReg (int fd) { int j, p; @@ -553,6 +571,7 @@ int mapif_parse_AccReg (int fd) } // アカウント変数送信要求 +static int mapif_parse_AccRegRequest (int fd) { // printf("mapif: accreg request\n"); diff --git a/src/char/inter.hpp b/src/char/inter.hpp index 769324c..56960be 100644 --- a/src/char/inter.hpp +++ b/src/char/inter.hpp @@ -9,7 +9,8 @@ int inter_mapif_init (int fd); int inter_check_length (int fd, int length); -int inter_log (char *fmt, ...); +__attribute__((format(printf, 1, 2))) +int inter_log (const char *fmt, ...); #define inter_cfgName "conf/inter_athena.conf" |