diff options
Diffstat (limited to 'src/map')
43 files changed, 1943 insertions, 1784 deletions
diff --git a/src/map/GNUmakefile b/src/map/GNUmakefile index a02deda..0945926 100644 --- a/src/map/GNUmakefile +++ b/src/map/GNUmakefile @@ -1,7 +1,7 @@ .SUFFIXES: all: - make -C ../.. map-server + ${MAKE} -C ../.. map-server clean: rm -r ../../obj/map/ %:: - make -C ../.. obj/map/$@ + ${MAKE} -C ../.. obj/map/$@ diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 8f62ca2..c608af5 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -10,6 +10,8 @@ #include <time.h> #include <unistd.h> +#include <array> + #include "../common/socket.hpp" #include "../common/timer.hpp" #include "../common/nullpo.hpp" @@ -38,16 +40,14 @@ static char command_symbol = '@'; // first char of the commands (by [Yor]) -static char msg_table[1000][1024]; // Server messages (0-499 reserved for GM commands, 500-999 reserved for others) - #define ATCOMMAND_FUNC(x) int atcommand_ ## x (const int fd, struct map_session_data* sd, const char* command, const char* message) ATCOMMAND_FUNC (setup); ATCOMMAND_FUNC (broadcast); ATCOMMAND_FUNC (localbroadcast); ATCOMMAND_FUNC (charwarp); -ATCOMMAND_FUNC (warp); +//ATCOMMAND_FUNC (warp); ATCOMMAND_FUNC (where); -ATCOMMAND_FUNC (goto); +//ATCOMMAND_FUNC (goto); ATCOMMAND_FUNC (jump); ATCOMMAND_FUNC (who); ATCOMMAND_FUNC (whogroup); @@ -66,7 +66,7 @@ ATCOMMAND_FUNC (kill); ATCOMMAND_FUNC (alive); ATCOMMAND_FUNC (kami); ATCOMMAND_FUNC (heal); -ATCOMMAND_FUNC (item); +//ATCOMMAND_FUNC (item); ATCOMMAND_FUNC (itemreset); ATCOMMAND_FUNC (itemcheck); ATCOMMAND_FUNC (baselevelup); @@ -79,7 +79,7 @@ ATCOMMAND_FUNC (gvgoff); ATCOMMAND_FUNC (gvgon); ATCOMMAND_FUNC (model); ATCOMMAND_FUNC (go); -ATCOMMAND_FUNC (spawn); +//ATCOMMAND_FUNC (spawn); ATCOMMAND_FUNC (killmonster); ATCOMMAND_FUNC (killmonster2); ATCOMMAND_FUNC (refine); @@ -92,7 +92,7 @@ ATCOMMAND_FUNC (skillpoint); ATCOMMAND_FUNC (zeny); ATCOMMAND_FUNC (param); ATCOMMAND_FUNC (guildlevelup); -ATCOMMAND_FUNC (recall); +//ATCOMMAND_FUNC (recall); ATCOMMAND_FUNC (recallall); ATCOMMAND_FUNC (revive); ATCOMMAND_FUNC (character_stats); @@ -420,6 +420,7 @@ static AtCommandInfo atcommand_info[] = { * This function return the name of the job (by [Yor]) *---------------------------------------------------- */ +static const char *job_name (int pc_class) { switch (pc_class) @@ -566,61 +567,6 @@ const char *job_name (int pc_class) return "Unknown Job"; } -//----------------------------------------------------------- -// Return the message string of the specified number by [Yor] -//----------------------------------------------------------- -char *msg_txt (int msg_number) -{ - if (msg_number >= 0 - && msg_number < (int) (sizeof (msg_table) / sizeof (msg_table[0])) - && msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0') - return msg_table[msg_number]; - - return "??"; -} - -//------------------------------------------------------------ -// 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; -} - /*========================================== * get_atcommand_level @コマンドの必要レベルを取得 *------------------------------------------ @@ -744,7 +690,7 @@ is_atcommand (const int fd, struct map_session_data *sd, const char *message, if (type == AtCommand_Unknown || info.proc == NULL) { - sprintf (output, msg_table[153], command); // %s is Unknown Command. + sprintf (output, "%s is Unknown Command.", command); clif_displaymessage (fd, output); } else @@ -752,7 +698,7 @@ is_atcommand (const int fd, struct map_session_data *sd, const char *message, if (info.proc (fd, sd, command, p) != 0) { // Command can not be executed - sprintf (output, msg_table[154], command); // %s failed. + sprintf (output, "%s failed.", command); clif_displaymessage (fd, output); } else @@ -844,48 +790,6 @@ static int atkillmonster_sub (struct block_list *bl, va_list ap) } /*========================================== - * Read Message Data - *------------------------------------------ - */ -int msg_config_read (const char *cfgName) -{ - int msg_number; - char line[1024], w1[1024], w2[1024]; - FILE *fp; - - if ((fp = fopen_ (cfgName, "r")) == NULL) - { - printf ("Messages file not found: %s\n", cfgName); - return 1; - } - - while (fgets (line, sizeof (line) - 1, fp)) - { - if (line[0] == '/' && line[1] == '/') - continue; - if (sscanf (line, "%[^:]: %[^\r\n]", w1, w2) == 2) - { - if (strcasecmp (w1, "import") == 0) - { - msg_config_read (w2); - } - else - { - msg_number = atoi (w1); - if (msg_number >= 0 - && msg_number < - (int) (sizeof (msg_table) / sizeof (msg_table[0]))) - strcpy (msg_table[msg_number], w2); - // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]); - } - } - } - fclose_ (fp); - - return 0; -} - -/*========================================== * *------------------------------------------ */ @@ -1051,30 +955,30 @@ int atcommand_charwarp (const int fd, struct map_session_data *sd, } if (pc_setpos (pl_sd, map_name, x, y, 3) == 0) { - clif_displaymessage (pl_sd->fd, msg_table[0]); // Warped. - clif_displaymessage (fd, msg_table[15]); // Player warped (message sends to player too). + clif_displaymessage (pl_sd->fd, "Warped."); + clif_displaymessage (fd, "Player warped (message sends to player too)."); } else { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[2]); // Coordinates out of range. + clif_displaymessage (fd, "Coordinates out of range."); return -1; } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -1128,16 +1032,16 @@ int atcommand_warp (const int fd, struct map_session_data *sd, return -1; } if (pc_setpos (sd, map_name, x, y, 3) == 0) - clif_displaymessage (fd, msg_table[0]); // Warped. + clif_displaymessage (fd, "Warped."); else { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[2]); // Coordinates out of range. + clif_displaymessage (fd, "Coordinates out of range."); return -1; } @@ -1172,7 +1076,7 @@ int atcommand_where (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -1217,12 +1121,12 @@ int atcommand_goto (const int fd, struct map_session_data *sd, return -1; } pc_setpos (sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3); - sprintf (output, msg_table[4], character); // Jump to %s + sprintf (output, "Jump to %s", character); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -1264,12 +1168,12 @@ int atcommand_jump (const int fd, struct map_session_data *sd, return -1; } pc_setpos (sd, sd->mapname, x, y, 3); - sprintf (output, msg_table[5], x, y); // Jump to %d %d + sprintf (output, "Jump to %d %d", x, y); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[2]); // Coordinates out of range. + clif_displaymessage (fd, "Coordinates out of range."); return -1; } @@ -1334,12 +1238,12 @@ int atcommand_who (const int fd, struct map_session_data *sd, } if (count == 0) - clif_displaymessage (fd, msg_table[28]); // No player found. + clif_displaymessage (fd, "No player found."); else if (count == 1) - clif_displaymessage (fd, msg_table[29]); // 1 player found. + clif_displaymessage (fd, "1 player found."); else { - sprintf (output, msg_table[30], count); // %d players found. + sprintf (output, "%d players found.", count); clif_displaymessage (fd, output); } @@ -1420,12 +1324,12 @@ int atcommand_whogroup (const int fd, struct map_session_data *sd, } if (count == 0) - clif_displaymessage (fd, msg_table[28]); // No player found. + clif_displaymessage (fd, "No player found."); else if (count == 1) - clif_displaymessage (fd, msg_table[29]); // 1 player found. + clif_displaymessage (fd, "1 player found."); else { - sprintf (output, msg_table[30], count); // %d players found. + sprintf (output, "%d players found.", count); clif_displaymessage (fd, output); } @@ -1492,12 +1396,12 @@ int atcommand_whomap (const int fd, struct map_session_data *sd, } if (count == 0) - sprintf (output, msg_table[54], map[map_id].name); // No player found in map '%s'. + sprintf (output, "No player found in map '%s'.", map[map_id].name); else if (count == 1) - sprintf (output, msg_table[55], map[map_id].name); // 1 player found in map '%s'. + sprintf (output, "1 player found in map '%s'.", map[map_id].name); else { - sprintf (output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'. + sprintf (output, "%d players found in map '%s'.", count, map[map_id].name); } clif_displaymessage (fd, output); @@ -1580,12 +1484,12 @@ int atcommand_whomapgroup (const int fd, struct map_session_data *sd, } if (count == 0) - sprintf (output, msg_table[54], map[map_id].name); // No player found in map '%s'. + sprintf (output, "No player found in map '%s'.", map[map_id].name); else if (count == 1) - sprintf (output, msg_table[55], map[map_id].name); // 1 player found in map '%s'. + sprintf (output, "1 player found in map '%s'.", map[map_id].name); else { - sprintf (output, msg_table[56], count, map[map_id].name); // %d players found in map '%s'. + sprintf (output, "%d players found in map '%s'.", count, map[map_id].name); } clif_displaymessage (fd, output); @@ -1673,12 +1577,12 @@ int atcommand_whogm (const int fd, struct map_session_data *sd, } if (count == 0) - clif_displaymessage (fd, msg_table[150]); // No GM found. + clif_displaymessage (fd, "No GM found."); else if (count == 1) - clif_displaymessage (fd, msg_table[151]); // 1 GM found. + clif_displaymessage (fd, "1 GM found."); else { - sprintf (output, msg_table[152], count); // %d GMs found. + sprintf (output, "%d GMs found.", count); clif_displaymessage (fd, output); } @@ -1697,7 +1601,7 @@ int atcommand_save (const int fd, struct map_session_data *sd, pc_setsavepoint (sd, sd->mapname, sd->bl.x, sd->bl.y); pc_makesavestatus (sd); chrif_save (sd); - clif_displaymessage (fd, msg_table[6]); // Character data respawn point saved. + clif_displaymessage (fd, "Character data respawn point saved."); return 0; } @@ -1729,7 +1633,7 @@ int atcommand_load (const int fd, struct map_session_data *sd, pc_setpos (sd, sd->status.save_point.map, sd->status.save_point.x, sd->status.save_point.y, 0); - clif_displaymessage (fd, msg_table[7]); // Warping to respawn point. + clif_displaymessage (fd, "Warping to respawn point."); return 0; } @@ -1762,7 +1666,7 @@ int atcommand_speed (const int fd, struct map_session_data *sd, //sd->walktimer = x; //この文を追加 by れ clif_updatestatus (sd, SP_SPEED); - clif_displaymessage (fd, msg_table[8]); // Speed changed. + clif_displaymessage (fd, "Speed changed."); } else { @@ -1788,14 +1692,14 @@ int atcommand_storage (const int fd, struct map_session_data *sd, if (sd->state.storage_flag) { - clif_displaymessage (fd, msg_table[250]); + clif_displaymessage (fd, "msg_table[250]"); return -1; } if ((stor = account2storage2 (sd->status.account_id)) != NULL && stor->storage_status == 1) { - clif_displaymessage (fd, msg_table[250]); + clif_displaymessage (fd, "msg_table[250]"); return -1; } @@ -1818,20 +1722,20 @@ int atcommand_guildstorage (const int fd, struct map_session_data *sd, { if (sd->state.storage_flag) { - clif_displaymessage (fd, msg_table[251]); + clif_displaymessage (fd, "msg_table[251]"); return -1; } if ((stor = account2storage2 (sd->status.account_id)) != NULL && stor->storage_status == 1) { - clif_displaymessage (fd, msg_table[251]); + clif_displaymessage (fd, "msg_table[251]"); return -1; } storage_guild_storageopen (sd); } else { - clif_displaymessage (fd, msg_table[252]); + clif_displaymessage (fd, "msg_table[252]"); return -1; } @@ -1908,7 +1812,7 @@ int atcommand_option (const int fd, struct map_session_data *sd, clif_changeoption (&sd->bl); pc_calcstatus (sd, 0); - clif_displaymessage (fd, msg_table[9]); // Options changed. + clif_displaymessage (fd, "Options changed."); return 0; } @@ -1923,12 +1827,12 @@ int atcommand_hide (const int fd, struct map_session_data *sd, if (sd->status.option & OPTION_HIDE) { sd->status.option &= ~OPTION_HIDE; - clif_displaymessage (fd, msg_table[10]); // Invisible: Off + clif_displaymessage (fd, "Invisible: Off."); // Invisible: Off } else { sd->status.option |= OPTION_HIDE; - clif_displaymessage (fd, msg_table[11]); // Invisible: On + clif_displaymessage (fd, "Invisible: On."); // Invisible: On } clif_changeoption (&sd->bl); @@ -1943,7 +1847,7 @@ int atcommand_die (const int fd, struct map_session_data *sd, const char *command, const char *message) { pc_damage (NULL, sd, sd->status.hp + 1); - clif_displaymessage (fd, msg_table[13]); // A pity! You've died. + clif_displaymessage (fd, "A pity! You've died."); return 0; } @@ -1972,17 +1876,17 @@ int atcommand_kill (const int fd, struct map_session_data *sd, if (pc_isGM (sd) >= pc_isGM (pl_sd)) { // you can kill only lower or same level pc_damage (NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage (fd, msg_table[14]); // Character killed. + clif_displaymessage (fd, "Character killed."); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -2004,7 +1908,7 @@ int atcommand_alive (const int fd, struct map_session_data *sd, clif_updatestatus (sd, SP_HP); clif_updatestatus (sd, SP_SP); clif_resurrection (&sd->bl, 1); - clif_displaymessage (fd, msg_table[16]); // You've been revived! It's a miracle! + clif_displaymessage (fd, "You've been revived! It's a miracle!"); return 0; } @@ -2072,13 +1976,13 @@ int atcommand_heal (const int fd, struct map_session_data *sd, { pc_heal (sd, hp, sp); if (hp >= 0 && sp >= 0) - clif_displaymessage (fd, msg_table[17]); // HP, SP recovered. + clif_displaymessage (fd, "HP, SP recovered."); else - clif_displaymessage (fd, msg_table[156]); // HP or/and SP modified. + clif_displaymessage (fd, "HP or/and SP modified."); } else { - clif_displaymessage (fd, msg_table[157]); // HP and SP are already with the good value. + clif_displaymessage (fd, "HP and SP are already with the good value."); return -1; } @@ -2134,11 +2038,11 @@ int atcommand_item (const int fd, struct map_session_data *sd, get_count))) clif_additem ((struct map_session_data *) sd, 0, 0, flag); } - clif_displaymessage (fd, msg_table[18]); // Item created. + clif_displaymessage (fd, "Item created."); } else { - clif_displaymessage (fd, msg_table[19]); // Invalid item ID or name. + clif_displaymessage (fd, "Invalid item ID or name."); return -1; } @@ -2160,7 +2064,7 @@ int atcommand_itemreset (const int fd, struct map_session_data *sd, && sd->status.inventory[i].equip == 0) pc_delitem (sd, i, sd->status.inventory[i].amount, 0); } - clif_displaymessage (fd, msg_table[20]); // All of your items have been removed. + clif_displaymessage (fd, "All of your items have been removed."); return 0; } @@ -2197,7 +2101,7 @@ int atcommand_baselevelup (const int fd, struct map_session_data *sd, { if (sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris - clif_displaymessage (fd, msg_table[47]); // Base level can't go any higher. + clif_displaymessage (fd, "Base level can't go any higher."); return -1; } // End Addition if (level > battle_config.maximum_level || level > (battle_config.maximum_level - sd->status.base_level)) // fix positiv overflow @@ -2211,13 +2115,13 @@ int atcommand_baselevelup (const int fd, struct map_session_data *sd, pc_calcstatus (sd, 0); pc_heal (sd, sd->status.max_hp, sd->status.max_sp); clif_misceffect (&sd->bl, 0); - clif_displaymessage (fd, msg_table[21]); // Base level raised. + clif_displaymessage (fd, "Base level raised."); } else { if (sd->status.base_level == 1) { - clif_displaymessage (fd, msg_table[158]); // Base level can't go any lower. + clif_displaymessage (fd, "Base level can't go any lower."); return -1; } if (level < -battle_config.maximum_level || level < (1 - sd->status.base_level)) // fix negativ overflow @@ -2235,7 +2139,7 @@ int atcommand_baselevelup (const int fd, struct map_session_data *sd, clif_updatestatus (sd, SP_BASELEVEL); clif_updatestatus (sd, SP_NEXTBASEEXP); pc_calcstatus (sd, 0); - clif_displaymessage (fd, msg_table[22]); // Base level lowered. + clif_displaymessage (fd, "Base level lowered."); } return 0; @@ -2267,7 +2171,7 @@ int atcommand_joblevelup (const int fd, struct map_session_data *sd, { if (sd->status.job_level == up_level) { - clif_displaymessage (fd, msg_table[23]); // Job level can't go any higher. + clif_displaymessage (fd, "Job level can't go any higher."); return -1; } if (level > up_level || level > (up_level - sd->status.job_level)) // fix positiv overflow @@ -2279,13 +2183,13 @@ int atcommand_joblevelup (const int fd, struct map_session_data *sd, clif_updatestatus (sd, SP_SKILLPOINT); pc_calcstatus (sd, 0); clif_misceffect (&sd->bl, 1); - clif_displaymessage (fd, msg_table[24]); // Job level raised. + clif_displaymessage (fd, "Job level raised."); } else { if (sd->status.job_level == 1) { - clif_displaymessage (fd, msg_table[159]); // Job level can't go any lower. + clif_displaymessage (fd, "Job level can't go any lower."); return -1; } if (level < -up_level || level < (1 - sd->status.job_level)) // fix negativ overflow @@ -2301,7 +2205,7 @@ int atcommand_joblevelup (const int fd, struct map_session_data *sd, clif_updatestatus (sd, SP_SKILLPOINT); } // to add: remove status points from skills pc_calcstatus (sd, 0); - clif_displaymessage (fd, msg_table[25]); // Job level lowered. + clif_displaymessage (fd, "Job level lowered."); } return 0; @@ -2322,7 +2226,7 @@ int atcommand_help (const int fd, struct map_session_data *sd, if ((fp = fopen_ (help_txt, "r")) != NULL) { - clif_displaymessage (fd, msg_table[26]); // Help commands: + clif_displaymessage (fd, "Help commands:"); gm_level = pc_isGM (sd); while (fgets (buf, sizeof (buf) - 1, fp) != NULL) { @@ -2345,7 +2249,7 @@ int atcommand_help (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[27]); // File help.txt not found. + clif_displaymessage (fd, "File help.txt not found."); return -1; } @@ -2372,7 +2276,7 @@ int atcommand_gm (const int fd, struct map_session_data *sd, if (pc_isGM (sd)) { // a GM can not use this function. only a normal player (become gm is not for gm!) - clif_displaymessage (fd, msg_table[50]); // You already have some GM powers. + clif_displaymessage (fd, "You already have some GM powers."); return -1; } else @@ -2394,7 +2298,7 @@ int atcommand_pvpoff (const int fd, struct map_session_data *sd, if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris] - clif_displaymessage (fd, msg_table[52]); // This option cannot be used in PK Mode. + clif_displaymessage (fd, "This option cannot be used in PK Mode."); return -1; } @@ -2419,11 +2323,11 @@ int atcommand_pvpoff (const int fd, struct map_session_data *sd, } } } - clif_displaymessage (fd, msg_table[31]); // PvP: Off. + clif_displaymessage (fd, "PvP: Off."); } else { - clif_displaymessage (fd, msg_table[160]); // PvP is already Off. + clif_displaymessage (fd, "PvP is already Off."); return -1; } @@ -2442,7 +2346,7 @@ int atcommand_pvpon (const int fd, struct map_session_data *sd, if (battle_config.pk_mode) { //disable command if server is in PK mode [Valaris] - clif_displaymessage (fd, msg_table[52]); // This option cannot be used in PK Mode. + clif_displaymessage (fd, "This option cannot be used in PK Mode."); return -1; } @@ -2466,11 +2370,11 @@ int atcommand_pvpon (const int fd, struct map_session_data *sd, } } } - clif_displaymessage (fd, msg_table[32]); // PvP: On. + clif_displaymessage (fd, "PvP: On."); } else { - clif_displaymessage (fd, msg_table[161]); // PvP is already On. + clif_displaymessage (fd, "PvP is already On."); return -1; } @@ -2488,11 +2392,11 @@ int atcommand_gvgoff (const int fd, struct map_session_data *sd, { map[sd->bl.m].flag.gvg = 0; clif_send0199 (sd->bl.m, 0); - clif_displaymessage (fd, msg_table[33]); // GvG: Off. + clif_displaymessage (fd, "GvG: Off."); } else { - clif_displaymessage (fd, msg_table[162]); // GvG is already Off. + clif_displaymessage (fd, "GvG is already Off."); return -1; } @@ -2510,11 +2414,11 @@ int atcommand_gvgon (const int fd, struct map_session_data *sd, { map[sd->bl.m].flag.gvg = 1; clif_send0199 (sd->bl.m, 3); - clif_displaymessage (fd, msg_table[34]); // GvG: On. + clif_displaymessage (fd, "GvG: On."); } else { - clif_displaymessage (fd, msg_table[163]); // GvG is already On. + clif_displaymessage (fd, "GvG is already On."); return -1; } @@ -2554,7 +2458,7 @@ int atcommand_model (const int fd, struct map_session_data *sd, && (sd->status.pc_class == 12 || sd->status.pc_class == 17)) { //服の色未実装職の判定 - clif_displaymessage (fd, msg_table[35]); // You can't use this command with this class. + clif_displaymessage (fd, "You can't use this command with this class."); return -1; } else @@ -2562,12 +2466,12 @@ int atcommand_model (const int fd, struct map_session_data *sd, pc_changelook (sd, LOOK_HAIR, hair_style); pc_changelook (sd, LOOK_HAIR_COLOR, hair_color); pc_changelook (sd, LOOK_CLOTHES_COLOR, cloth_color); - clif_displaymessage (fd, msg_table[36]); // Appearence changed. + clif_displaymessage (fd, "Appearence changed."); } } else { - clif_displaymessage (fd, msg_table[37]); // An invalid number was specified. + clif_displaymessage (fd, "An invalid number was specified."); return -1; } @@ -2600,18 +2504,18 @@ int atcommand_dye (const int fd, struct map_session_data *sd, if (cloth_color != 0 && sd->status.sex == 1 && (sd->status.pc_class == 12 || sd->status.pc_class == 17)) { - clif_displaymessage (fd, msg_table[35]); // You can't use this command with this class. + clif_displaymessage (fd, "You can't use this command with this class."); return -1; } else { pc_changelook (sd, LOOK_CLOTHES_COLOR, cloth_color); - clif_displaymessage (fd, msg_table[36]); // Appearence changed. + clif_displaymessage (fd, "Appearence changed."); } } else { - clif_displaymessage (fd, msg_table[37]); // An invalid number was specified. + clif_displaymessage (fd, "An invalid number was specified."); return -1; } @@ -2655,18 +2559,18 @@ int atcommand_hair_style (const int fd, struct map_session_data *sd, if (hair_style != 0 && sd->status.sex == 1 && (sd->status.pc_class == 12 || sd->status.pc_class == 17)) { - clif_displaymessage (fd, msg_table[35]); // You can't use this command with this class. + clif_displaymessage (fd, "You can't use this command with this class."); return -1; } else { pc_changelook (sd, LOOK_HAIR, hair_style); - clif_displaymessage (fd, msg_table[36]); // Appearence changed. + clif_displaymessage (fd, "Appearence changed."); } } else { - clif_displaymessage (fd, msg_table[37]); // An invalid number was specified. + clif_displaymessage (fd, "An invalid number was specified."); return -1; } @@ -2710,18 +2614,18 @@ int atcommand_hair_color (const int fd, struct map_session_data *sd, if (hair_color != 0 && sd->status.sex == 1 && (sd->status.pc_class == 12 || sd->status.pc_class == 17)) { - clif_displaymessage (fd, msg_table[35]); // You can't use this command with this class. + clif_displaymessage (fd, "You can't use this command with this class."); return -1; } else { pc_changelook (sd, LOOK_HAIR_COLOR, hair_color); - clif_displaymessage (fd, msg_table[36]); // Appearence changed. + clif_displaymessage (fd, "Appearence changed."); } } else { - clif_displaymessage (fd, msg_table[37]); // An invalid number was specified. + clif_displaymessage (fd, "An invalid number was specified."); return -1; } @@ -2804,8 +2708,8 @@ int atcommand_go (const int fd, struct map_session_data *sd, if (!message || !*message || sscanf (message, "%99s", map_name) < 1 || town < -3 || town >= (int) (sizeof (data) / sizeof (data[0]))) { - clif_displaymessage (fd, msg_table[38]); // Invalid location number or name. - clif_displaymessage (fd, msg_table[82]); // Please, use one of this number/name: + clif_displaymessage (fd, "Invalid location number or name."); + clif_displaymessage (fd, "Please, use one of this number/name:"); clif_displaymessage (fd, "-3=(Memo point 2) 4=Alberta 11=Gon Ryun"); clif_displaymessage (fd, @@ -2934,17 +2838,17 @@ int atcommand_go (const int fd, struct map_session_data *sd, sd->status.memo_point[-town - 1].x, sd->status.memo_point[-town - 1].y, 3) == 0) { - clif_displaymessage (fd, msg_table[0]); // Warped. + clif_displaymessage (fd, "Warped."); } else { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } } else { - sprintf (output, msg_table[164], -town - 1); // Your memo point #%d doesn't exist. + sprintf (output, "Your memo point #%d doesn't exist.", -town - 1); clif_displaymessage (fd, output); return -1; } @@ -2969,17 +2873,17 @@ int atcommand_go (const int fd, struct map_session_data *sd, if (pc_setpos (sd, data[town].map, data[town].x, data[town].y, 3) == 0) { - clif_displaymessage (fd, msg_table[0]); // Warped. + clif_displaymessage (fd, "Warped."); } else { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } } else { // if you arrive here, you have an error in town variable when reading of names - clif_displaymessage (fd, msg_table[38]); // Invalid location number or name. + clif_displaymessage (fd, "Invalid location number or name."); return -1; } } @@ -3009,7 +2913,7 @@ int atcommand_spawn (const int fd, struct map_session_data *sd, if (!message || !*message || sscanf (message, "%99s %d %d %d", monster, &number, &x, &y) < 1) { - clif_displaymessage (fd, msg_table[143]); // Give a monster name/id please. + clif_displaymessage (fd, "Give a monster name/id please."); return -1; } @@ -3019,13 +2923,13 @@ int atcommand_spawn (const int fd, struct map_session_data *sd, if (mob_id == 0) { - clif_displaymessage (fd, msg_table[40]); // Invalid monster ID or name. + clif_displaymessage (fd, "Invalid monster ID or name."); return -1; } if (mob_id == 1288) { - clif_displaymessage (fd, msg_table[83]); // Cannot spawn emperium. + clif_displaymessage (fd, "Cannot spawn emperium."); return -1; } @@ -3066,15 +2970,15 @@ int atcommand_spawn (const int fd, struct map_session_data *sd, if (count != 0) if (number == count) - clif_displaymessage (fd, msg_table[39]); // All monster summoned! + clif_displaymessage (fd, "All monster summoned!"); else { - sprintf (output, msg_table[240], count); // %d monster(s) summoned! + sprintf (output, "%d monster(s) summoned!", count); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[40]); // Invalid monster ID or name. + clif_displaymessage (fd, "Invalid monster ID or name."); return -1; } @@ -3085,6 +2989,7 @@ int atcommand_spawn (const int fd, struct map_session_data *sd, * *------------------------------------------ */ +static void atcommand_killmonster_sub (const int fd, struct map_session_data *sd, const char *message, const int drop) { @@ -3106,7 +3011,7 @@ void atcommand_killmonster_sub (const int fd, struct map_session_data *sd, map_foreachinarea (atkillmonster_sub, map_id, 0, 0, map[map_id].xs, map[map_id].ys, BL_MOB, drop); - clif_displaymessage (fd, msg_table[165]); // All monsters killed! + clif_displaymessage (fd, "All monsters killed!"); return; } @@ -3221,9 +3126,9 @@ int atcommand_produce (const int fd, struct map_session_data *sd, if (battle_config.error_log) printf ("@produce NOT WEAPON [%d]\n", item_id); if (item_id != 0 && itemdb_exists (item_id)) - sprintf (output, msg_table[169], item_id, item_data->name); // This item (%d: '%s') is not an equipment. + sprintf (output, "This item (%d: '%s') is not an equipment.", item_id, item_data->name); else - sprintf (output, "%s", msg_table[170]); // This item is not an equipment. + sprintf (output, "%s", "This item is not an equipment."); clif_displaymessage (fd, output); return -1; } @@ -3235,6 +3140,7 @@ int atcommand_produce (const int fd, struct map_session_data *sd, * Sub-function to display actual memo points *------------------------------------------ */ +static void atcommand_memo_sub (struct map_session_data *sd) { int i; @@ -3251,7 +3157,7 @@ void atcommand_memo_sub (struct map_session_data *sd) sd->status.memo_point[i].map, sd->status.memo_point[i].x, sd->status.memo_point[i].y); else - sprintf (output, msg_table[171], i); // %d - void + sprintf (output, "%d - void", i); clif_displaymessage (sd->fd, output); } @@ -3285,7 +3191,7 @@ int atcommand_memo (const int fd, struct map_session_data *sd, } if (sd->status.memo_point[position].map[0]) { - sprintf (output, msg_table[172], position, sd->status.memo_point[position].map, sd->status.memo_point[position].x, sd->status.memo_point[position].y); // You replace previous memo position %d - %s (%d,%d). + sprintf (output, "You replace previous memo position %d - %s (%d,%d).", position, sd->status.memo_point[position].map, sd->status.memo_point[position].x, sd->status.memo_point[position].y); clif_displaymessage (fd, output); } memcpy (sd->status.memo_point[position].map, map[sd->bl.m].name, @@ -3294,7 +3200,7 @@ int atcommand_memo (const int fd, struct map_session_data *sd, sd->status.memo_point[position].y = sd->bl.y; clif_skill_memo (sd, 0); if (pc_checkskill (sd, AL_WARP) <= (position + 1)) - clif_displaymessage (fd, msg_table[173]); // Note: you don't have the 'Warp' skill level to use it. + clif_displaymessage (fd, "Note: you don't have the 'Warp' skill level to use it."); atcommand_memo_sub (sd); } else @@ -3385,14 +3291,14 @@ int atcommand_statuspoint (const int fd, struct map_session_data *sd, { sd->status.status_point = (short) new_status_point; clif_updatestatus (sd, SP_STATUSPOINT); - clif_displaymessage (fd, msg_table[174]); // Number of status points changed! + clif_displaymessage (fd, "Number of status points changed!"); } else { if (point < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } @@ -3425,14 +3331,14 @@ int atcommand_skillpoint (const int fd, struct map_session_data *sd, { sd->status.skill_point = (short) new_skill_point; clif_updatestatus (sd, SP_SKILLPOINT); - clif_displaymessage (fd, msg_table[175]); // Number of skill points changed! + clif_displaymessage (fd, "Number of skill points changed!"); } else { if (point < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } @@ -3465,14 +3371,14 @@ int atcommand_zeny (const int fd, struct map_session_data *sd, { sd->status.zeny = new_zeny; clif_updatestatus (sd, SP_ZENY); - clif_displaymessage (fd, msg_table[176]); // Number of zenys changed! + clif_displaymessage (fd, "Number of zenys changed!"); } else { if (zeny < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } @@ -3535,14 +3441,14 @@ int atcommand_param (const int fd, struct map_session_data *sd, clif_updatestatus (sd, SP_STR + index); clif_updatestatus (sd, SP_USTR + index); pc_calcstatus (sd, 0); - clif_displaymessage (fd, msg_table[42]); // Stat changed. + clif_displaymessage (fd, "Stat changed."); } else { if (value < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } @@ -3589,13 +3495,13 @@ int atcommand_all_stats (const int fd, struct map_session_data *sd, } if (count > 0) // if at least 1 stat modified - clif_displaymessage (fd, msg_table[84]); // All stats changed! + clif_displaymessage (fd, "All stats changed!"); else { if (value < 0) - clif_displaymessage (fd, msg_table[177]); // Impossible to decrease a stat. + clif_displaymessage (fd, "Impossible to decrease a stat."); else - clif_displaymessage (fd, msg_table[178]); // Impossible to increase a stat. + clif_displaymessage (fd, "Impossible to increase a stat."); return -1; } @@ -3624,12 +3530,12 @@ int atcommand_guildlevelup (const int fd, struct map_session_data *sd, if (sd->status.guild_id <= 0 || (guild_info = guild_search (sd->status.guild_id)) == NULL) { - clif_displaymessage (fd, msg_table[43]); // You're not in a guild. + clif_displaymessage (fd, "You're not in a guild."); return -1; } if (strcmp (sd->status.name, guild_info->master) != 0) { - clif_displaymessage (fd, msg_table[44]); // You're not the master of your guild. + clif_displaymessage (fd, "You're not the master of your guild."); return -1; } @@ -3643,11 +3549,11 @@ int atcommand_guildlevelup (const int fd, struct map_session_data *sd, { intif_guild_change_basicinfo (guild_info->guild_id, GBI_GUILDLV, &added_level, 2); - clif_displaymessage (fd, msg_table[179]); // Guild level changed. + clif_displaymessage (fd, "Guild level changed."); } else { - clif_displaymessage (fd, msg_table[45]); // Guild level change failed. + clif_displaymessage (fd, "Guild level change failed."); return -1; } @@ -3694,18 +3600,18 @@ int atcommand_recall (const int fd, struct map_session_data *sd, return -1; } pc_setpos (pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2); - sprintf (output, msg_table[46], character); // %s recalled! + sprintf (output, "%s recalled!", character); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -3740,11 +3646,11 @@ int atcommand_revive (const int fd, struct map_session_data *sd, clif_updatestatus (pl_sd, SP_HP); clif_updatestatus (pl_sd, SP_SP); clif_resurrection (&pl_sd->bl, 1); - clif_displaymessage (fd, msg_table[51]); // Character revived. + clif_displaymessage (fd, "Character revived."); } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -3814,7 +3720,7 @@ int atcommand_character_stats (const int fd, struct map_session_data *sd, }; sprintf (job_jobname, "Job - %s %s", job_name (pl_sd->status.pc_class), "(level %d)"); - sprintf (output, msg_table[53], pl_sd->status.name); // '%s' stats: + sprintf (output, "'%s' stats:", pl_sd->status.name); clif_displaymessage (fd, output); for (i = 0; output_table[i].format != NULL; i++) { @@ -3824,7 +3730,7 @@ int atcommand_character_stats (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -3878,12 +3784,12 @@ int atcommand_character_stats_all (const int fd, struct map_session_data *sd, } if (count == 0) - clif_displaymessage (fd, msg_table[28]); // No player found. + clif_displaymessage (fd, "No player found."); else if (count == 1) - clif_displaymessage (fd, msg_table[29]); // 1 player found. + clif_displaymessage (fd, "1 player found."); else { - sprintf (output, msg_table[30], count); // %d players found. + sprintf (output, "%d players found.", count); clif_displaymessage (fd, output); } @@ -3960,17 +3866,17 @@ int atcommand_character_option (const int fd, struct map_session_data *sd, } clif_changeoption (&pl_sd->bl); pc_calcstatus (pl_sd, 0); - clif_displaymessage (fd, msg_table[58]); // Character's options changed. + clif_displaymessage (fd, "Character's options changed."); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -3998,18 +3904,18 @@ int atcommand_char_change_sex (const int fd, struct map_session_data *sd, // check player name if (strlen (character) < 4) { - clif_displaymessage (fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. + clif_displaymessage (fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen (character) > 23) { - clif_displaymessage (fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum. + clif_displaymessage (fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { chrif_char_ask_name (sd->status.account_id, character, 5, 0, 0, 0, 0, 0, 0); // type: 5 - changesex - clif_displaymessage (fd, msg_table[88]); // Character name sends to char-server to ask it. + clif_displaymessage (fd, "Character name sends to char-server to ask it."); } return 0; @@ -4037,18 +3943,18 @@ int atcommand_char_block (const int fd, struct map_session_data *sd, // check player name if (strlen (character) < 4) { - clif_displaymessage (fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. + clif_displaymessage (fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen (character) > 23) { - clif_displaymessage (fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum. + clif_displaymessage (fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { chrif_char_ask_name (sd->status.account_id, character, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block - clif_displaymessage (fd, msg_table[88]); // Character name sends to char-server to ask it. + clif_displaymessage (fd, "Character name sends to char-server to ask it."); } return 0; @@ -4143,25 +4049,25 @@ int atcommand_char_ban (const int fd, struct map_session_data *sd, if (year == 0 && month == 0 && day == 0 && hour == 0 && minute == 0 && second == 0) { - clif_displaymessage (fd, msg_table[85]); // Invalid time for ban command. + clif_displaymessage (fd, "Invalid time for ban command."); return -1; } // check player name if (strlen (character) < 4) { - clif_displaymessage (fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. + clif_displaymessage (fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen (character) > 23) { - clif_displaymessage (fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum. + clif_displaymessage (fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { chrif_char_ask_name (sd->status.account_id, character, 2, year, month, day, hour, minute, second); // type: 2 - ban - clif_displaymessage (fd, msg_table[88]); // Character name sends to char-server to ask it. + clif_displaymessage (fd, "Character name sends to char-server to ask it."); } return 0; @@ -4188,19 +4094,19 @@ int atcommand_char_unblock (const int fd, struct map_session_data *sd, // check player name if (strlen (character) < 4) { - clif_displaymessage (fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. + clif_displaymessage (fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen (character) > 23) { - clif_displaymessage (fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum. + clif_displaymessage (fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { // send answer to login server via char-server chrif_char_ask_name (sd->status.account_id, character, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock - clif_displaymessage (fd, msg_table[88]); // Character name sends to char-server to ask it. + clif_displaymessage (fd, "Character name sends to char-server to ask it."); } return 0; @@ -4227,19 +4133,19 @@ int atcommand_char_unban (const int fd, struct map_session_data *sd, // check player name if (strlen (character) < 4) { - clif_displaymessage (fd, msg_table[86]); // Sorry, but a player name have at least 4 characters. + clif_displaymessage (fd, "Sorry, but a player name have at least 4 characters."); return -1; } else if (strlen (character) > 23) { - clif_displaymessage (fd, msg_table[87]); // Sorry, but a player name have 23 characters maximum. + clif_displaymessage (fd, "Sorry, but a player name have 23 characters maximum."); return -1; } else { // send answer to login server via char-server chrif_char_ask_name (sd->status.account_id, character, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban - clif_displaymessage (fd, msg_table[88]); // Character name sends to char-server to ask it. + clif_displaymessage (fd, "Character name sends to char-server to ask it."); } return 0; @@ -4280,7 +4186,7 @@ int atcommand_character_save (const int fd, struct map_session_data *sd, m = map_mapname2mapid (map_name); if (m < 0) { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } else @@ -4293,18 +4199,18 @@ int atcommand_character_save (const int fd, struct map_session_data *sd, return -1; } pc_setsavepoint (pl_sd, map_name, x, y); - clif_displaymessage (fd, msg_table[57]); // Character's respawn point changed. + clif_displaymessage (fd, "Character's respawn point changed."); } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -4331,13 +4237,13 @@ int atcommand_night (const int fd, struct map_session_data *sd, { pl_sd->opt2 |= STATE_BLIND; clif_changeoption (&pl_sd->bl); - clif_displaymessage (pl_sd->fd, msg_table[59]); // Night has fallen. + clif_displaymessage (pl_sd->fd, "Night has fallen."); } } } else { - clif_displaymessage (fd, msg_table[89]); // Sorry, it's already the night. Impossible to execute the command. + clif_displaymessage (fd, "Sorry, it's already the night. Impossible to execute the command."); return -1; } @@ -4364,13 +4270,13 @@ int atcommand_day (const int fd, struct map_session_data *sd, { pl_sd->opt2 &= ~STATE_BLIND; clif_changeoption (&pl_sd->bl); - clif_displaymessage (pl_sd->fd, msg_table[60]); // Day has arrived. + clif_displaymessage (pl_sd->fd, "Day has arrived."); } } } else { - clif_displaymessage (fd, msg_table[90]); // Sorry, it's already the day. Impossible to execute the command. + clif_displaymessage (fd, "Sorry, it's already the day. Impossible to execute the command."); return -1; } @@ -4394,10 +4300,10 @@ int atcommand_doom (const int fd, struct map_session_data *sd, && pc_isGM (sd) >= pc_isGM (pl_sd)) { // you can doom only lower or same gm level pc_damage (NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage (pl_sd->fd, msg_table[61]); // The holy messenger has given judgement. + clif_displaymessage (pl_sd->fd, "The holy messenger has given judgement."); } } - clif_displaymessage (fd, msg_table[62]); // Judgement was made. + clif_displaymessage (fd, "Judgement was made."); return 0; } @@ -4419,10 +4325,10 @@ int atcommand_doommap (const int fd, struct map_session_data *sd, && pc_isGM (sd) >= pc_isGM (pl_sd)) { // you can doom only lower or same gm level pc_damage (NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage (pl_sd->fd, msg_table[61]); // The holy messenger has given judgement. + clif_displaymessage (pl_sd->fd, "The holy messenger has given judgement."); } } - clif_displaymessage (fd, msg_table[62]); // Judgement was made. + clif_displaymessage (fd, "Judgement was made."); return 0; } @@ -4441,7 +4347,7 @@ static void atcommand_raise_sub (struct map_session_data *sd) clif_updatestatus (sd, SP_HP); clif_updatestatus (sd, SP_SP); clif_resurrection (&sd->bl, 1); - clif_displaymessage (sd->fd, msg_table[63]); // Mercy has been shown. + clif_displaymessage (sd->fd, "Mercy has been shown."); } } @@ -4459,7 +4365,7 @@ int atcommand_raise (const int fd, struct map_session_data *sd, if (session[i]) atcommand_raise_sub ((struct map_session_data *)session[i]->session_data); } - clif_displaymessage (fd, msg_table[64]); // Mercy has been granted. + clif_displaymessage (fd, "Mercy has been granted."); return 0; } @@ -4480,7 +4386,7 @@ int atcommand_raisemap (const int fd, struct map_session_data *sd, && pl_sd->state.auth && sd->bl.m == pl_sd->bl.m) atcommand_raise_sub (pl_sd); } - clif_displaymessage (fd, msg_table[64]); // Mercy has been granted. + clif_displaymessage (fd, "Mercy has been granted."); return 0; } @@ -4516,7 +4422,7 @@ int atcommand_character_baselevel (const int fd, struct map_session_data *sd, { if (pl_sd->status.base_level == battle_config.maximum_level) { // check for max level by Valaris - clif_displaymessage (fd, msg_table[91]); // Character's base level can't go any higher. + clif_displaymessage (fd, "Character's base level can't go any higher."); return 0; } // End Addition if (level > battle_config.maximum_level || level > (battle_config.maximum_level - pl_sd->status.base_level)) // fix positiv overflow @@ -4533,13 +4439,13 @@ int atcommand_character_baselevel (const int fd, struct map_session_data *sd, pc_calcstatus (pl_sd, 0); pc_heal (pl_sd, pl_sd->status.max_hp, pl_sd->status.max_sp); clif_misceffect (&pl_sd->bl, 0); - clif_displaymessage (fd, msg_table[65]); // Character's base level raised. + clif_displaymessage (fd, "Character's base level raised."); } else { if (pl_sd->status.base_level == 1) { - clif_displaymessage (fd, msg_table[193]); // Character's base level can't go any lower. + clif_displaymessage (fd, "Character's base level can't go any lower."); return -1; } if (level < -battle_config.maximum_level || level < (1 - pl_sd->status.base_level)) // fix negativ overflow @@ -4559,20 +4465,20 @@ int atcommand_character_baselevel (const int fd, struct map_session_data *sd, clif_updatestatus (pl_sd, SP_NEXTBASEEXP); clif_updatestatus (pl_sd, SP_BASEEXP); pc_calcstatus (pl_sd, 0); - clif_displaymessage (fd, msg_table[66]); // Character's base level lowered. + clif_displaymessage (fd, "Character's base level lowered."); } // Reset their stat points to prevent extra points from stacking atcommand_charstreset(fd, sd,"@charstreset", character); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -4617,7 +4523,7 @@ int atcommand_character_joblevel (const int fd, struct map_session_data *sd, { if (pl_sd->status.job_level == max_level) { - clif_displaymessage (fd, msg_table[67]); // Character's job level can't go any higher. + clif_displaymessage (fd, "Character's job level can't go any higher."); return -1; } if (pl_sd->status.job_level + level > max_level) @@ -4629,13 +4535,13 @@ int atcommand_character_joblevel (const int fd, struct map_session_data *sd, clif_updatestatus (pl_sd, SP_SKILLPOINT); pc_calcstatus (pl_sd, 0); clif_misceffect (&pl_sd->bl, 1); - clif_displaymessage (fd, msg_table[68]); // character's job level raised. + clif_displaymessage (fd, "character's job level raised."); } else { if (pl_sd->status.job_level == 1) { - clif_displaymessage (fd, msg_table[194]); // Character's job level can't go any lower. + clif_displaymessage (fd, "Character's job level can't go any lower."); return -1; } if (pl_sd->status.job_level + level < 1) @@ -4651,18 +4557,18 @@ int atcommand_character_joblevel (const int fd, struct map_session_data *sd, clif_updatestatus (pl_sd, SP_SKILLPOINT); } // to add: remove status points from skills pc_calcstatus (pl_sd, 0); - clif_displaymessage (fd, msg_table[69]); // Character's job level lowered. + clif_displaymessage (fd, "Character's job level lowered."); } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -4694,13 +4600,13 @@ int atcommand_kick (const int fd, struct map_session_data *sd, clif_GM_kick (sd, pl_sd, 1); else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -4727,7 +4633,7 @@ int atcommand_kickall (const int fd, struct map_session_data *sd, } } - clif_displaymessage (fd, msg_table[195]); // All players have been kicked! + clif_displaymessage (fd, "All players have been kicked!"); return 0; } @@ -4742,7 +4648,7 @@ int atcommand_allskills (const int fd, struct map_session_data *sd, pc_allskillup (sd); // all skills sd->status.skill_point = 0; // 0 skill points clif_updatestatus (sd, SP_SKILLPOINT); // update - clif_displaymessage (fd, msg_table[76]); // You have received all skills. + clif_displaymessage (fd, "You have received all skills."); return 0; } @@ -4770,23 +4676,23 @@ int atcommand_questskill (const int fd, struct map_session_data *sd, if (pc_checkskill (sd, skill_id) == 0) { pc_skill (sd, skill_id, 1, 0); - clif_displaymessage (fd, msg_table[70]); // You have learned the skill. + clif_displaymessage (fd, "You have learned the skill."); } else { - clif_displaymessage (fd, msg_table[196]); // You already have this quest skill. + clif_displaymessage (fd, "You already have this quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill. + clif_displaymessage (fd, "This skill number doesn't exist or isn't a quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[198]); // This skill number doesn't exist. + clif_displaymessage (fd, "This skill number doesn't exist."); return -1; } @@ -4824,29 +4730,29 @@ int atcommand_charquestskill (const int fd, struct map_session_data *sd, if (pc_checkskill (pl_sd, skill_id) == 0) { pc_skill (pl_sd, skill_id, 1, 0); - clif_displaymessage (fd, msg_table[199]); // This player has learned the skill. + clif_displaymessage (fd, "This player has learned the skill."); } else { - clif_displaymessage (fd, msg_table[200]); // This player already has this quest skill. + clif_displaymessage (fd, "This player already has this quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill. + clif_displaymessage (fd, "This skill number doesn't exist or isn't a quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[198]); // This skill number doesn't exist. + clif_displaymessage (fd, "This skill number doesn't exist."); return -1; } @@ -4878,23 +4784,23 @@ int atcommand_lostskill (const int fd, struct map_session_data *sd, sd->status.skill[skill_id].lv = 0; sd->status.skill[skill_id].flags = 0; clif_skillinfoblock (sd); - clif_displaymessage (fd, msg_table[71]); // You have forgotten the skill. + clif_displaymessage (fd, "You have forgotten the skill."); } else { - clif_displaymessage (fd, msg_table[201]); // You don't have this quest skill. + clif_displaymessage (fd, "You don't have this quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill. + clif_displaymessage (fd, "This skill number doesn't exist or isn't a quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[198]); // This skill number doesn't exist. + clif_displaymessage (fd, "This skill number doesn't exist."); return -1; } @@ -4934,29 +4840,29 @@ int atcommand_charlostskill (const int fd, struct map_session_data *sd, pl_sd->status.skill[skill_id].lv = 0; pl_sd->status.skill[skill_id].flags = 0; clif_skillinfoblock (pl_sd); - clif_displaymessage (fd, msg_table[202]); // This player has forgotten the skill. + clif_displaymessage (fd, "This player has forgotten the skill."); } else { - clif_displaymessage (fd, msg_table[203]); // This player doesn't have this quest skill. + clif_displaymessage (fd, "This player doesn't have this quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[197]); // This skill number doesn't exist or isn't a quest skill. + clif_displaymessage (fd, "This skill number doesn't exist or isn't a quest skill."); return -1; } } else { - clif_displaymessage (fd, msg_table[198]); // This skill number doesn't exist. + clif_displaymessage (fd, "This skill number doesn't exist."); return -1; } @@ -5022,13 +4928,13 @@ int atcommand_agitstart (const int fd, struct map_session_data *sd, { if (agit_flag == 1) { - clif_displaymessage (fd, msg_table[73]); // Already it has started siege warfare. + clif_displaymessage (fd, "Already it has started siege warfare."); return -1; } agit_flag = 1; guild_agit_start (); - clif_displaymessage (fd, msg_table[72]); // Guild siege warfare start! + clif_displaymessage (fd, "Guild siege warfare start!"); return 0; } @@ -5042,13 +4948,13 @@ int atcommand_agitend (const int fd, struct map_session_data *sd, { if (agit_flag == 0) { - clif_displaymessage (fd, msg_table[75]); // Siege warfare hasn't started yet. + clif_displaymessage (fd, "Siege warfare hasn't started yet."); return -1; } agit_flag = 0; guild_agit_end (); - clif_displaymessage (fd, msg_table[74]); // Guild siege warfare end! + clif_displaymessage (fd, "Guild siege warfare end!"); return 0; } @@ -5101,7 +5007,7 @@ int atcommand_idsearch (const int fd, struct map_session_data *sd, return -1; } - sprintf (output, msg_table[77], item_name); // The reference result of '%s' (name: id): + sprintf (output, "The reference result of '%s' (name: id):", item_name); clif_displaymessage (fd, output); match = 0; for (i = 0; i < 20000; i++) @@ -5110,11 +5016,11 @@ int atcommand_idsearch (const int fd, struct map_session_data *sd, && strstr (item->jname, item_name) != NULL) { match++; - sprintf (output, msg_table[78], item->jname, item->nameid); // %s: %d + sprintf (output, "%s: %d", item->jname, item->nameid); clif_displaymessage (fd, output); } } - sprintf (output, msg_table[79], match); // It is %d affair above. + sprintf (output, "It is %d affair above.", match); clif_displaymessage (fd, output); return 0; @@ -5146,18 +5052,18 @@ int atcommand_charskreset (const int fd, struct map_session_data *sd, if (pc_isGM (sd) >= pc_isGM (pl_sd)) { // you can reset skill points only lower or same gm level pc_resetskill (pl_sd); - sprintf (output, msg_table[206], character); // '%s' skill points reseted! + sprintf (output, "'%s' skill points reseted!", character); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5190,18 +5096,18 @@ int atcommand_charstreset (const int fd, struct map_session_data *sd, if (pc_isGM (sd) >= pc_isGM (pl_sd)) { // you can reset stats points only lower or same gm level pc_resetstate (pl_sd); - sprintf (output, msg_table[207], character); // '%s' stats points reseted! + sprintf (output, "'%s' stats points reseted!", character); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5237,18 +5143,18 @@ int atcommand_charreset (const int fd, struct map_session_data *sd, pc_resetskill (pl_sd); pc_setglobalreg (pl_sd, "MAGIC_FLAGS", 0); // [Fate] Reset magic quest variables pc_setglobalreg (pl_sd, "MAGIC_EXP", 0); // [Fate] Reset magic experience - sprintf (output, msg_table[208], character); // '%s' skill and stats points reseted! + sprintf (output, "'%s' skill and stats points reseted!", character); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5327,18 +5233,18 @@ int atcommand_char_wipe (const int fd, struct map_session_data *sd, pc_setglobalreg (pl_sd, "MAGIC_FLAGS", 0); // [Fate] Reset magic quest variables pc_setglobalreg (pl_sd, "MAGIC_EXP", 0); // [Fate] Reset magic experience - sprintf (output, "%s: wiped.", character); // '%s' skill and stats points reseted! + sprintf (output, "%s: wiped.", character); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5384,7 +5290,7 @@ int atcommand_charmodel (const int fd, struct map_session_data *sd, pl_sd->status.sex == 1 && (pl_sd->status.pc_class == 12 || pl_sd->status.pc_class == 17)) { - clif_displaymessage (fd, msg_table[35]); // You can't use this command with this class. + clif_displaymessage (fd, "You can't use this command with this class."); return -1; } else @@ -5392,18 +5298,18 @@ int atcommand_charmodel (const int fd, struct map_session_data *sd, pc_changelook (pl_sd, LOOK_HAIR, hair_style); pc_changelook (pl_sd, LOOK_HAIR_COLOR, hair_color); pc_changelook (pl_sd, LOOK_CLOTHES_COLOR, cloth_color); - clif_displaymessage (fd, msg_table[36]); // Appearence changed. + clif_displaymessage (fd, "Appearence changed."); } } else { - clif_displaymessage (fd, msg_table[37]); // An invalid number was specified. + clif_displaymessage (fd, "An invalid number was specified."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5444,20 +5350,20 @@ int atcommand_charskpoint (const int fd, struct map_session_data *sd, { pl_sd->status.skill_point = new_skill_point; clif_updatestatus (pl_sd, SP_SKILLPOINT); - clif_displaymessage (fd, msg_table[209]); // Character's number of skill points changed! + clif_displaymessage (fd, "Character's number of skill points changed!"); } else { if (point < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5498,20 +5404,20 @@ int atcommand_charstpoint (const int fd, struct map_session_data *sd, { pl_sd->status.status_point = new_status_point; clif_updatestatus (pl_sd, SP_STATUSPOINT); - clif_displaymessage (fd, msg_table[210]); // Character's number of status points changed! + clif_displaymessage (fd, "Character's number of status points changed!"); } else { if (point < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5550,20 +5456,20 @@ int atcommand_charzeny (const int fd, struct map_session_data *sd, { pl_sd->status.zeny = new_zeny; clif_updatestatus (pl_sd, SP_ZENY); - clif_displaymessage (fd, msg_table[211]); // Character's number of zenys changed! + clif_displaymessage (fd, "Character's number of zenys changed!"); } else { if (zeny < 0) - clif_displaymessage (fd, msg_table[41]); // Impossible to decrease the number/value. + clif_displaymessage (fd, "Impossible to decrease the number/value."); else - clif_displaymessage (fd, msg_table[149]); // Impossible to increase the number/value. + clif_displaymessage (fd, "Impossible to increase the number/value."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -5608,7 +5514,7 @@ int atcommand_recallall (const int fd, struct map_session_data *sd, } } - clif_displaymessage (fd, msg_table[92]); // All characters recalled! + clif_displaymessage (fd, "All characters recalled!"); if (count) { sprintf (output, @@ -5670,7 +5576,7 @@ int atcommand_guildrecall (const int fd, struct map_session_data *sd, pc_setpos (pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2); } } - sprintf (output, msg_table[93], g->name); // All online characters of the %s guild are near you. + sprintf (output, "All online characters of the %s guild are near you.", g->name); clif_displaymessage (fd, output); if (count) { @@ -5682,7 +5588,7 @@ int atcommand_guildrecall (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online. + clif_displaymessage (fd, "Incorrect name/ID, or no one from the guild is online."); return -1; } @@ -5739,7 +5645,7 @@ int atcommand_partyrecall (const int fd, struct map_session_data *sd, pc_setpos (pl_sd, sd->mapname, sd->bl.x, sd->bl.y, 2); } } - sprintf (output, msg_table[95], p->name); // All online characters of the %s party are near you. + sprintf (output, "All online characters of the %s party are near you.", p->name); clif_displaymessage (fd, output); if (count) { @@ -5751,7 +5657,7 @@ int atcommand_partyrecall (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online. + clif_displaymessage (fd, "Incorrect name or ID, or no one from the party is online."); return -1; } @@ -5766,7 +5672,7 @@ int atcommand_reloaditemdb (const int fd, struct map_session_data *sd, const char *command, const char *message) { itemdb_reload (); - clif_displaymessage (fd, msg_table[97]); // Item database reloaded. + clif_displaymessage (fd, "Item database reloaded."); return 0; } @@ -5779,7 +5685,7 @@ int atcommand_reloadmobdb (const int fd, struct map_session_data *sd, const char *command, const char *message) { mob_reload (); - clif_displaymessage (fd, msg_table[98]); // Monster database reloaded. + clif_displaymessage (fd, "Monster database reloaded."); return 0; } @@ -5792,7 +5698,7 @@ int atcommand_reloadskilldb (const int fd, struct map_session_data *sd, const char *command, const char *message) { skill_reload (); - clif_displaymessage (fd, msg_table[99]); // Skill database reloaded. + clif_displaymessage (fd, "Skill database reloaded."); return 0; } @@ -5809,7 +5715,7 @@ int atcommand_reloadscript (const int fd, struct map_session_data *sd, npc_event_do_oninit (); - clif_displaymessage (fd, msg_table[100]); // Scripts reloaded. + clif_displaymessage (fd, "Scripts reloaded."); return 0; } @@ -5824,7 +5730,7 @@ int atcommand_reloadgmdb ( // by [Yor] { chrif_reloadGMdb (); - clif_displaymessage (fd, msg_table[101]); // Login-server asked to reload GM accounts and their level. + clif_displaymessage (fd, "Login-server asked to reload GM accounts and their level."); return 0; } @@ -5868,7 +5774,7 @@ int atcommand_mapinfo (const int fd, struct map_session_data *sd, if ((m_id = map_mapname2mapid (map_name)) < 0) { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } @@ -6033,7 +5939,7 @@ int atcommand_mount_peco (const int fd, struct map_session_data *sd, { if (sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] - clif_displaymessage (fd, msg_table[212]); // Cannot mount a Peco while in disguise. + clif_displaymessage (fd, "Cannot mount a Peco while in disguise."); return -1; } @@ -6051,11 +5957,11 @@ int atcommand_mount_peco (const int fd, struct map_session_data *sd, else if (sd->status.pc_class == 4015) sd->status.pc_class = sd->view_class = 4022; pc_setoption (sd, sd->status.option | 0x0020); - clif_displaymessage (fd, msg_table[102]); // Mounted Peco. + clif_displaymessage (fd, "Mounted Peco."); } else { - clif_displaymessage (fd, msg_table[213]); // You can not mount a peco with your job. + clif_displaymessage (fd, "You can not mount a peco with your job."); return -1; } } @@ -6070,7 +5976,7 @@ int atcommand_mount_peco (const int fd, struct map_session_data *sd, else if (sd->status.pc_class == 4022) sd->status.pc_class = sd->view_class = 4015; pc_setoption (sd, sd->status.option & ~0x0020); - clif_displaymessage (fd, msg_table[214]); // Unmounted Peco. + clif_displaymessage (fd, "Unmounted Peco."); } return 0; @@ -6099,7 +6005,7 @@ int atcommand_char_mount_peco (const int fd, struct map_session_data *sd, { if (pl_sd->disguise > 0) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] - clif_displaymessage (fd, msg_table[215]); // This player cannot mount a Peco while in disguise. + clif_displaymessage (fd, "This player cannot mount a Peco while in disguise."); return -1; } @@ -6117,11 +6023,11 @@ int atcommand_char_mount_peco (const int fd, struct map_session_data *sd, else if (pl_sd->status.pc_class == 4015) pl_sd->status.pc_class = pl_sd->view_class = 4022; pc_setoption (pl_sd, pl_sd->status.option | 0x0020); - clif_displaymessage (fd, msg_table[216]); // Now, this player mounts a peco. + clif_displaymessage (fd, "Now, this player mounts a peco."); } else { - clif_displaymessage (fd, msg_table[217]); // This player can not mount a peco with his/her job. + clif_displaymessage (fd, "This player can not mount a peco with his/her job."); return -1; } } @@ -6136,12 +6042,12 @@ int atcommand_char_mount_peco (const int fd, struct map_session_data *sd, else if (pl_sd->status.pc_class == 4022) pl_sd->status.pc_class = pl_sd->view_class = 4015; pc_setoption (pl_sd, pl_sd->status.option & ~0x0020); - clif_displaymessage (fd, msg_table[218]); // Now, this player has not more peco. + clif_displaymessage (fd, "Now, this player has not more peco."); } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -6175,19 +6081,19 @@ int atcommand_guildspy (const int fd, struct map_session_data *sd, if (sd->guildspy == g->guild_id) { sd->guildspy = 0; - sprintf (output, msg_table[103], g->name); // No longer spying on the %s guild. + sprintf (output, "No longer spying on the %s guild.", g->name); clif_displaymessage (fd, output); } else { sd->guildspy = g->guild_id; - sprintf (output, msg_table[104], g->name); // Spying on the %s guild. + sprintf (output, "Spying on the %s guild.", g->name); clif_displaymessage (fd, output); } } else { - clif_displaymessage (fd, msg_table[94]); // Incorrect name/ID, or no one from the guild is online. + clif_displaymessage (fd, "Incorrect name/ID, or no one from the guild is online."); return -1; } @@ -6221,19 +6127,19 @@ int atcommand_partyspy (const int fd, struct map_session_data *sd, if (sd->partyspy == p->party_id) { sd->partyspy = 0; - sprintf (output, msg_table[105], p->name); // No longer spying on the %s party. + sprintf (output, "No longer spying on the %s party.", p->name); clif_displaymessage (fd, output); } else { sd->partyspy = p->party_id; - sprintf (output, msg_table[106], p->name); // Spying on the %s party. + sprintf (output, "Spying on the %s party.", p->name); clif_displaymessage (fd, output); } } else { - clif_displaymessage (fd, msg_table[96]); // Incorrect name or ID, or no one from the party is online. + clif_displaymessage (fd, "Incorrect name or ID, or no one from the party is online."); return -1; } @@ -6261,11 +6167,11 @@ int atcommand_enablenpc (const int fd, struct map_session_data *sd, if (npc_name2id (NPCname) != NULL) { npc_enable (NPCname, 1); - clif_displaymessage (fd, msg_table[110]); // Npc Enabled. + clif_displaymessage (fd, "Npc Enabled."); } else { - clif_displaymessage (fd, msg_table[111]); // This NPC doesn't exist. + clif_displaymessage (fd, "This NPC doesn't exist."); return -1; } @@ -6293,11 +6199,11 @@ int atcommand_disablenpc (const int fd, struct map_session_data *sd, if (npc_name2id (NPCname) != NULL) { npc_enable (NPCname, 0); - clif_displaymessage (fd, msg_table[112]); // Npc Disabled. + clif_displaymessage (fd, "Npc Disabled."); } else { - clif_displaymessage (fd, msg_table[111]); // This NPC doesn't exist. + clif_displaymessage (fd, "This NPC doesn't exist."); return -1; } @@ -6308,7 +6214,8 @@ int atcommand_disablenpc (const int fd, struct map_session_data *sd, * time in txt for time command (by [Yor]) *------------------------------------------ */ -char *txt_time (unsigned int duration) +static +const char *txt_time (unsigned int duration) { int days, hours, minutes, seconds; char temp[256]; @@ -6328,21 +6235,21 @@ char *txt_time (unsigned int duration) seconds = duration - (60 * minutes); if (days < 2) - sprintf (temp, msg_table[219], days); // %d day + sprintf (temp, "%d day", days); else - sprintf (temp, msg_table[220], days); // %d days + sprintf (temp, "%d days", days); if (hours < 2) - sprintf (temp1, msg_table[221], temp, hours); // %s %d hour + sprintf (temp1, "%s %d hour", temp, hours); else - sprintf (temp1, msg_table[222], temp, hours); // %s %d hours + sprintf (temp1, "%s %d hours", temp, hours); if (minutes < 2) - sprintf (temp, msg_table[223], temp1, minutes); // %s %d minute + sprintf (temp, "%s %d minute", temp1, minutes); else - sprintf (temp, msg_table[224], temp1, minutes); // %s %d minutes + sprintf (temp, "%s %d minutes", temp1, minutes); if (seconds < 2) - sprintf (temp1, msg_table[225], temp, seconds); // %s and %d second + sprintf (temp1, "%s and %d second", temp, seconds); else - sprintf (temp1, msg_table[226], temp, seconds); // %s and %d seconds + sprintf (temp1, "%s and %d seconds", temp, seconds); return temp1; } @@ -6366,64 +6273,64 @@ int atcommand_servertime (const int fd, struct map_session_data *sd, time (&time_server); // get time in seconds since 1/1/1970 datetime = gmtime (&time_server); // convert seconds in structure // like sprintf, but only for date/time (Sunday, November 02 2003 15:12:52) - strftime (temp, sizeof (temp) - 1, msg_table[230], datetime); // Server time (normal time): %A, %B %d %Y %X. + strftime (temp, sizeof (temp) - 1, "Server time (normal time): %A, %B %d %Y %X.", datetime); clif_displaymessage (fd, temp); if (battle_config.night_duration == 0 && battle_config.day_duration == 0) { if (night_flag == 0) - clif_displaymessage (fd, msg_table[231]); // Game time: The game is in permanent daylight. + clif_displaymessage (fd, "Game time: The game is in permanent daylight."); else - clif_displaymessage (fd, msg_table[232]); // Game time: The game is in permanent night. + clif_displaymessage (fd, "Game time: The game is in permanent night."); } else if (battle_config.night_duration == 0) if (night_flag == 1) { // we start with night timer_data = get_timer (day_timer_tid); - sprintf (temp, msg_table[233], txt_time ((timer_data->tick - gettick ()) / 1000)); // Game time: The game is actualy in night for %s. + sprintf (temp, "Game time: The game is actualy in night for %s.", txt_time ((timer_data->tick - gettick ()) / 1000)); clif_displaymessage (fd, temp); - clif_displaymessage (fd, msg_table[234]); // Game time: After, the game will be in permanent daylight. + clif_displaymessage (fd, "Game time: After, the game will be in permanent daylight."); } else - clif_displaymessage (fd, msg_table[231]); // Game time: The game is in permanent daylight. + clif_displaymessage (fd, "Game time: The game is in permanent daylight."); else if (battle_config.day_duration == 0) if (night_flag == 0) { // we start with day timer_data = get_timer (night_timer_tid); - sprintf (temp, msg_table[235], txt_time ((timer_data->tick - gettick ()) / 1000)); // Game time: The game is actualy in daylight for %s. + sprintf (temp, "Game time: The game is actualy in daylight for %s.", txt_time ((timer_data->tick - gettick ()) / 1000)); clif_displaymessage (fd, temp); - clif_displaymessage (fd, msg_table[236]); // Game time: After, the game will be in permanent night. + clif_displaymessage (fd, "Game time: After, the game will be in permanent night."); } else - clif_displaymessage (fd, msg_table[232]); // Game time: The game is in permanent night. + clif_displaymessage (fd, "Game time: The game is in permanent night."); else { if (night_flag == 0) { timer_data = get_timer (night_timer_tid); timer_data2 = get_timer (day_timer_tid); - sprintf (temp, msg_table[235], txt_time ((timer_data->tick - gettick ()) / 1000)); // Game time: The game is actualy in daylight for %s. + sprintf (temp, "Game time: The game is actualy in daylight for %s.", txt_time ((timer_data->tick - gettick ()) / 1000)); clif_displaymessage (fd, temp); if (timer_data->tick > timer_data2->tick) - sprintf (temp, msg_table[237], txt_time ((timer_data->interval - abs (timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in night for %s. + sprintf (temp, "Game time: After, the game will be in night for %s.", txt_time ((timer_data->interval - abs (timer_data->tick - timer_data2->tick)) / 1000)); else - sprintf (temp, msg_table[237], txt_time (abs (timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in night for %s. + sprintf (temp, "Game time: After, the game will be in night for %s.", txt_time (abs (timer_data->tick - timer_data2->tick) / 1000)); clif_displaymessage (fd, temp); - sprintf (temp, msg_table[238], txt_time (timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. + sprintf (temp, "Game time: A day cycle has a normal duration of %s.", txt_time (timer_data->interval / 1000)); clif_displaymessage (fd, temp); } else { timer_data = get_timer (day_timer_tid); timer_data2 = get_timer (night_timer_tid); - sprintf (temp, msg_table[233], txt_time ((timer_data->tick - gettick ()) / 1000)); // Game time: The game is actualy in night for %s. + sprintf (temp, "Game time: The game is actualy in night for %s.", txt_time ((timer_data->tick - gettick ()) / 1000)); clif_displaymessage (fd, temp); if (timer_data->tick > timer_data2->tick) - sprintf (temp, msg_table[239], txt_time ((timer_data->interval - abs (timer_data->tick - timer_data2->tick)) / 1000)); // Game time: After, the game will be in daylight for %s. + sprintf (temp, "Game time: After, the game will be in daylight for %s.", txt_time ((timer_data->interval - abs (timer_data->tick - timer_data2->tick)) / 1000)); else - sprintf (temp, msg_table[239], txt_time (abs (timer_data->tick - timer_data2->tick) / 1000)); // Game time: After, the game will be in daylight for %s. + sprintf (temp, "Game time: After, the game will be in daylight for %s.", txt_time (abs (timer_data->tick - timer_data2->tick) / 1000)); clif_displaymessage (fd, temp); - sprintf (temp, msg_table[238], txt_time (timer_data->interval / 1000)); // Game time: A day cycle has a normal duration of %s. + sprintf (temp, "Game time: A day cycle has a normal duration of %s.", txt_time (timer_data->interval / 1000)); clif_displaymessage (fd, temp); } } @@ -6482,35 +6389,35 @@ int atcommand_chardelitem (const int fd, struct map_session_data *sd, count++; item_position = pc_search_inventory (pl_sd, item_id); // for next loop } - sprintf (output, msg_table[113], count); // %d item(s) removed by a GM. + sprintf (output, "%d item(s) removed by a GM.", count); clif_displaymessage (pl_sd->fd, output); if (number == count) - sprintf (output, msg_table[114], count); // %d item(s) removed from the player. + sprintf (output, "%d item(s) removed from the player.", count); else - sprintf (output, msg_table[115], count, count, number); // %d item(s) removed. Player had only %d on %d items. + sprintf (output, "%d item(s) removed. Player had only %d on %d items.", count, count, number); clif_displaymessage (fd, output); } else { - clif_displaymessage (fd, msg_table[116]); // Character does not have the item. + clif_displaymessage (fd, "Character does not have the item."); return -1; } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[19]); // Invalid item ID or name. + clif_displaymessage (fd, "Invalid item ID or name."); return -1; } @@ -6556,24 +6463,24 @@ int atcommand_jail (const int fd, struct map_session_data *sd, if (pc_setpos (pl_sd, "sec_pri.gat", x, y, 3) == 0) { pc_setsavepoint (pl_sd, "sec_pri.gat", x, y); // Save Char Respawn Point in the jail room [Lupus] - clif_displaymessage (pl_sd->fd, msg_table[117]); // GM has send you in jails. - clif_displaymessage (fd, msg_table[118]); // Player warped in jails. + clif_displaymessage (pl_sd->fd, "GM has send you in jails."); + clif_displaymessage (fd, "Player warped in jails."); } else { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -6606,30 +6513,30 @@ int atcommand_unjail (const int fd, struct map_session_data *sd, { // you can jail only lower or same GM if (pl_sd->bl.m != map_mapname2mapid ("sec_pri.gat")) { - clif_displaymessage (fd, msg_table[119]); // This player is not in jails. + clif_displaymessage (fd, "This player is not in jails."); return -1; } else if (pc_setpos (pl_sd, "prontera.gat", 156, 191, 3) == 0) { pc_setsavepoint (pl_sd, "prontera.gat", 156, 191); // Save char respawn point in Prontera - clif_displaymessage (pl_sd->fd, msg_table[120]); // GM has discharge you. - clif_displaymessage (fd, msg_table[121]); // Player warped to Prontera. + clif_displaymessage (pl_sd->fd, "GM has discharge you."); + clif_displaymessage (fd, "Player warped to Prontera."); } else { - clif_displaymessage (fd, msg_table[1]); // Map not found. + clif_displaymessage (fd, "Map not found."); return -1; } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -6662,17 +6569,17 @@ int atcommand_disguise (const int fd, struct map_session_data *sd, { // monsters if (pc_isriding (sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] - clif_displaymessage (fd, msg_table[227]); // Cannot wear disguise while riding a Peco. + clif_displaymessage (fd, "Cannot wear disguise while riding a Peco."); return -1; } sd->disguiseflag = 1; // set to override items with disguise script [Valaris] sd->disguise = mob_id; pc_setpos (sd, sd->mapname, sd->bl.x, sd->bl.y, 3); - clif_displaymessage (fd, msg_table[122]); // Disguise applied. + clif_displaymessage (fd, "Disguise applied."); } else { - clif_displaymessage (fd, msg_table[123]); // Monster/NPC name/id hasn't been found. + clif_displaymessage (fd, "Monster/NPC name/id hasn't been found."); return -1; } @@ -6691,11 +6598,11 @@ int atcommand_undisguise (const int fd, struct map_session_data *sd, clif_clearchar (&sd->bl, 9); sd->disguise = 0; pc_setpos (sd, sd->mapname, sd->bl.x, sd->bl.y, 3); - clif_displaymessage (fd, msg_table[124]); // Undisguise applied. + clif_displaymessage (fd, "Undisguise applied."); } else { - clif_displaymessage (fd, msg_table[125]); // You're not disguised. + clif_displaymessage (fd, "You're not disguised."); return -1; } @@ -6771,17 +6678,17 @@ int atcommand_ignorelist (const int fd, struct map_session_data *sd, if (sd->ignoreAll == 0) if (count == 0) - clif_displaymessage (fd, msg_table[126]); // You accept any wisp (no wisper is refused). + clif_displaymessage (fd, "You accept any wisp (no wisper is refused)."); else { - sprintf (output, msg_table[127], count); // You accept any wisp, except thoses from %d player(s): + sprintf (output, "You accept any wisp, except thoses from %d player(s):", count); clif_displaymessage (fd, output); } else if (count == 0) - clif_displaymessage (fd, msg_table[128]); // You refuse all wisps (no specifical wisper is refused). + clif_displaymessage (fd, "You refuse all wisps (no specifical wisper is refused)."); else { - sprintf (output, msg_table[129], count); // You refuse all wisps, AND refuse wisps from %d player(s): + sprintf (output, "You refuse all wisps, AND refuse wisps from %d player(s):", count); clif_displaymessage (fd, output); } @@ -6829,22 +6736,22 @@ int atcommand_charignorelist (const int fd, struct map_session_data *sd, if (pl_sd->ignoreAll == 0) if (count == 0) { - sprintf (output, msg_table[130], pl_sd->status.name); // '%s' accept any wisp (no wisper is refused). + sprintf (output, "'%s' accept any wisp (no wisper is refused).", pl_sd->status.name); clif_displaymessage (fd, output); } else { - sprintf (output, msg_table[131], pl_sd->status.name, count); // '%s' accept any wisp, except thoses from %d player(s): + sprintf (output, "'%s' accept any wisp, except thoses from %d player(s):", pl_sd->status.name, count); clif_displaymessage (fd, output); } else if (count == 0) { - sprintf (output, msg_table[132], pl_sd->status.name); // '%s' refuse all wisps (no specifical wisper is refused). + sprintf (output, "'%s' refuse all wisps (no specifical wisper is refused).", pl_sd->status.name); clif_displaymessage (fd, output); } else { - sprintf (output, msg_table[133], pl_sd->status.name, count); // '%s' refuse all wisps, AND refuse wisps from %d player(s): + sprintf (output, "'%s' refuse all wisps, AND refuse wisps from %d player(s):", pl_sd->status.name, count); clif_displaymessage (fd, output); } @@ -6859,7 +6766,7 @@ int atcommand_charignorelist (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -6893,17 +6800,17 @@ int atcommand_inall (const int fd, struct map_session_data *sd, { // you can change wisp option only to lower or same level if (pl_sd->ignoreAll == 0) { - sprintf (output, msg_table[134], pl_sd->status.name); // '%s' already accepts all wispers. + sprintf (output, "'%s' already accepts all wispers.", pl_sd->status.name); clif_displaymessage (fd, output); return -1; } else { pl_sd->ignoreAll = 0; - sprintf (output, msg_table[135], pl_sd->status.name); // '%s' now accepts all wispers. + sprintf (output, "'%s' now accepts all wispers.", pl_sd->status.name); clif_displaymessage (fd, output); // message to player - clif_displaymessage (pl_sd->fd, msg_table[136]); // A GM has authorised all wispers for you. + clif_displaymessage (pl_sd->fd, "A GM has authorised all wispers for you."); WFIFOW (pl_sd->fd, 0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail WFIFOB (pl_sd->fd, 2) = 1; WFIFOB (pl_sd->fd, 3) = 0; // success @@ -6912,13 +6819,13 @@ int atcommand_inall (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -6952,17 +6859,17 @@ int atcommand_exall (const int fd, struct map_session_data *sd, { // you can change wisp option only to lower or same level if (pl_sd->ignoreAll == 1) { - sprintf (output, msg_table[137], pl_sd->status.name); // '%s' already blocks all wispers. + sprintf (output, "'%s' already blocks all wispers.", pl_sd->status.name); clif_displaymessage (fd, output); return -1; } else { pl_sd->ignoreAll = 1; - sprintf (output, msg_table[138], pl_sd->status.name); // '%s' blocks now all wispers. + sprintf (output, "'%s' blocks now all wispers.", pl_sd->status.name); clif_displaymessage (fd, output); // message to player - clif_displaymessage (pl_sd->fd, msg_table[139]); // A GM has blocked all wispers for you. + clif_displaymessage (pl_sd->fd, "A GM has blocked all wispers for you."); WFIFOW (pl_sd->fd, 0) = 0x0d2; // R 00d2 <type>.B <fail>.B: type: 0: deny, 1: allow, fail: 0: success, 1: fail WFIFOB (pl_sd->fd, 2) = 0; WFIFOB (pl_sd->fd, 3) = 0; // success @@ -6971,13 +6878,13 @@ int atcommand_exall (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -7021,30 +6928,30 @@ int atcommand_chardisguise (const int fd, struct map_session_data *sd, { // monsters if (pc_isriding (pl_sd)) { // temporary prevention of crash caused by peco + disguise, will look into a better solution [Valaris] - clif_displaymessage (fd, msg_table[228]); // Character cannot wear disguise while riding a Peco. + clif_displaymessage (fd, "Character cannot wear disguise while riding a Peco."); return -1; } pl_sd->disguiseflag = 1; // set to override items with disguise script [Valaris] pl_sd->disguise = mob_id; pc_setpos (pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3); - clif_displaymessage (fd, msg_table[140]); // Character's disguise applied. + clif_displaymessage (fd, "Character's disguise applied."); } else { - clif_displaymessage (fd, msg_table[123]); // Monster/NPC name/id hasn't been found. + clif_displaymessage (fd, "Monster/NPC name/id hasn't been found."); return -1; } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -7080,23 +6987,23 @@ int atcommand_charundisguise (const int fd, struct map_session_data *sd, pl_sd->disguise = 0; pc_setpos (pl_sd, pl_sd->mapname, pl_sd->bl.x, pl_sd->bl.y, 3); - clif_displaymessage (fd, msg_table[141]); // Character's undisguise applied. + clif_displaymessage (fd, "Character's undisguise applied."); } else { - clif_displaymessage (fd, msg_table[142]); // Character is not disguised. + clif_displaymessage (fd, "Character is not disguised."); return -1; } } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -7126,28 +7033,28 @@ int atcommand_email (const int fd, struct map_session_data *sd, if (e_mail_check (actual_email) == 0) { - clif_displaymessage (fd, msg_table[144]); // Invalid actual email. If you have default e-mail, give a@a.com. + clif_displaymessage (fd, "Invalid actual email. If you have default e-mail, type a@a.com."); // Invalid actual email. If you have default e-mail, give a@a.com. return -1; } else if (e_mail_check (new_email) == 0) { - clif_displaymessage (fd, msg_table[145]); // Invalid new email. Please enter a real e-mail. + clif_displaymessage (fd, "Invalid new email. Please enter a real e-mail."); return -1; } else if (strcasecmp (new_email, "a@a.com") == 0) { - clif_displaymessage (fd, msg_table[146]); // New email must be a real e-mail. + clif_displaymessage (fd, "New email must be a real e-mail."); return -1; } else if (strcasecmp (actual_email, new_email) == 0) { - clif_displaymessage (fd, msg_table[147]); // New email must be different of the actual e-mail. + clif_displaymessage (fd, "New email must be different of the actual e-mail."); return -1; } else { chrif_changeemail (sd->status.account_id, actual_email, new_email); - clif_displaymessage (fd, msg_table[148]); // Information sended to login-server via char-server. + clif_displaymessage (fd, "Information sended to login-server via char-server."); } return 0; @@ -7172,7 +7079,7 @@ int atcommand_effect (const int fd, struct map_session_data *sd, if (flag <= 0) { clif_specialeffect (&sd->bl, type, flag); - clif_displaymessage (fd, msg_table[229]); // Your effect has changed. + clif_displaymessage (fd, "Your Effect Has Changed."); // Your effect has changed. } else { @@ -7182,7 +7089,7 @@ int atcommand_effect (const int fd, struct map_session_data *sd, && pl_sd->state.auth) { clif_specialeffect (&pl_sd->bl, type, flag); - clif_displaymessage (pl_sd->fd, msg_table[229]); // Your effect has changed. + clif_displaymessage (pl_sd->fd, "Your Effect Has Changed."); // Your effect has changed. } } } @@ -7329,13 +7236,13 @@ atcommand_character_item_list (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -7455,13 +7362,13 @@ atcommand_character_storage_list (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -7570,13 +7477,13 @@ atcommand_character_cart_list (const int fd, struct map_session_data *sd, } else { - clif_displaymessage (fd, msg_table[81]); // Your GM level don't authorise you to do this action on this player. + clif_displaymessage (fd, "Your GM level don't authorise you to do this action on this player."); return -1; } } else { - clif_displaymessage (fd, msg_table[3]); // Character not found. + clif_displaymessage (fd, "Character not found."); return -1; } @@ -7595,9 +7502,9 @@ atcommand_killer (const int fd, struct map_session_data *sd, sd->special_state.killer = !sd->special_state.killer; if (sd->special_state.killer) - clif_displaymessage (fd, msg_table[241]); + clif_displaymessage (fd, "You be a killa..."); else - clif_displaymessage (fd, msg_table[242]); + clif_displaymessage (fd, "You gonna be own3d..."); return 0; } @@ -7614,9 +7521,9 @@ atcommand_killable (const int fd, struct map_session_data *sd, sd->special_state.killable = !sd->special_state.killable; if (sd->special_state.killable) - clif_displaymessage (fd, msg_table[242]); + clif_displaymessage (fd, "You gonna be own3d..."); else - clif_displaymessage (fd, msg_table[241]); + clif_displaymessage (fd, "You be a killa..."); return 0; } @@ -7658,7 +7565,7 @@ atcommand_skillon (const int fd, struct map_session_data *sd, const char *command, const char *message) { map[sd->bl.m].flag.noskill = 0; - clif_displaymessage (fd, msg_table[244]); + clif_displaymessage (fd, "Map skills are on."); return 0; } @@ -7672,7 +7579,7 @@ atcommand_skilloff (const int fd, struct map_session_data *sd, const char *command, const char *message) { map[sd->bl.m].flag.noskill = 1; - clif_displaymessage (fd, msg_table[243]); + clif_displaymessage (fd, "Map skills are off."); return 0; } @@ -7802,7 +7709,7 @@ atcommand_chareffect (const int fd, struct map_session_data *sd, return -1; clif_specialeffect (&pl_sd->bl, type, 0); - clif_displaymessage (fd, msg_table[229]); // Your effect has changed. + clif_displaymessage (fd, "Your Effect Has Changed."); // Your effect has changed. return 0; } @@ -8282,7 +8189,7 @@ int atcommand_unmute (const int fd, struct map_session_data *sd, static int magic_base = TMW_MAGIC; #define magic_skills_nr 6 -static char *magic_skill_names[magic_skills_nr] = +static const char *magic_skill_names[magic_skills_nr] = { "magic", "life", "war", "transmute", "nature", "astral" }; int @@ -8426,6 +8333,7 @@ atcommand_visible (const int fd, struct map_session_data *sd, return 0; } +static int atcommand_jump_iterate (const int fd, struct map_session_data *sd, const char *command, const char *message, struct map_session_data *(*get_start) (void), @@ -8468,7 +8376,7 @@ int atcommand_jump_iterate (const int fd, struct map_session_data *sd, return -1; } pc_setpos (sd, map[pl_sd->bl.m].name, pl_sd->bl.x, pl_sd->bl.y, 3); - sprintf (output, msg_table[4], pl_sd->status.name); // Jump to %s + sprintf (output, "Jump to %s", pl_sd->status.name); clif_displaymessage (fd, output); sd->followtarget = pl_sd->bl.id; @@ -8546,7 +8454,7 @@ int atcommand_skillpool_info (const int fd, struct map_session_data *sd, for (i = 0; i < skill_pool_skills_size; ++i) { - char *name = skill_name (skill_pool_skills[i]); + const char *name = skill_name (skill_pool_skills[i]); int lvl = pl_sd->status.skill[skill_pool_skills[i]].lv; if (lvl) @@ -8719,10 +8627,10 @@ int atcommand_doomspot(const int fd, struct map_session_data *sd, && pc_isGM (sd) >= pc_isGM (pl_sd)) { // you can doom only lower or same gm level pc_damage (NULL, pl_sd, pl_sd->status.hp + 1); - clif_displaymessage (pl_sd->fd, msg_table[61]); // The holy messenger has given judgement. + clif_displaymessage (pl_sd->fd, "The holy messenger has given judgement."); } } - clif_displaymessage (fd, msg_table[62]); // Judgement was made. + clif_displaymessage (fd, "Judgement was made."); return 0; } diff --git a/src/map/atcommand.hpp b/src/map/atcommand.hpp index 824a7cf..d35cb4f 100644 --- a/src/map/atcommand.hpp +++ b/src/map/atcommand.hpp @@ -209,8 +209,6 @@ AtCommandType atcommand (const int level, const char *message, AtCommandInfo * info); int get_atcommand_level (const AtCommandType type); -char *msg_txt (int msg_number); // [Yor] - int atcommand_item (const int fd, struct map_session_data *sd, const char *command, const char *message); // [Valaris] int atcommand_warp (const int fd, struct map_session_data *sd, const char *command, const char *message); // [Yor] int atcommand_spawn (const int fd, struct map_session_data *sd, const char *command, const char *message); // [Valaris] @@ -218,9 +216,10 @@ int atcommand_goto (const int fd, struct map_session_data *sd, const char *comm int atcommand_recall (const int fd, struct map_session_data *sd, const char *command, const char *message); // [Yor] int atcommand_config_read (const char *cfgName); -int msg_config_read (const char *cfgName); +__attribute__((format(printf, 2, 3))) void log_atcommand (struct map_session_data *sd, const char *fmt, ...); +__attribute__((format(printf, 1, 2))) void gm_log (const char *fmt, ...); #endif diff --git a/src/map/battle.cpp b/src/map/battle.cpp index a46db13..818d77e 100644 --- a/src/map/battle.cpp +++ b/src/map/battle.cpp @@ -521,6 +521,7 @@ int battle_get_flee2 (struct block_list *bl) * 戻りは整数で1以上 *------------------------------------------ */ +static int battle_get_critical (struct block_list *bl) { int critical = 1; @@ -625,6 +626,7 @@ int battle_get_atk (struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ +static int battle_get_atk_ (struct block_list *bl) { nullpo_retr (0, bl); @@ -687,6 +689,7 @@ int battle_get_atk2 (struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ +static int battle_get_atk_2 (struct block_list *bl) { nullpo_retr (0, bl); @@ -701,6 +704,7 @@ int battle_get_atk_2 (struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ +static int battle_get_matk1 (struct block_list *bl) { struct status_change *sc_data; @@ -727,6 +731,7 @@ int battle_get_matk1 (struct block_list *bl) * 戻りは整数で0以上 *------------------------------------------ */ +static int battle_get_matk2 (struct block_list *bl) { struct status_change *sc_data = battle_get_sc_data (bl); @@ -1422,6 +1427,7 @@ struct battle_delay_damage_ int damage; int flag; }; +static void battle_delay_damage_sub (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct battle_delay_damage_ *dat = (struct battle_delay_damage_ *) data; @@ -1853,6 +1859,7 @@ int battle_calc_damage (struct block_list *src, struct block_list *bl, * 修練ダメージ *------------------------------------------ */ +static int battle_addmastery (struct map_session_data *sd, struct block_list *target, int dmg, int type) { diff --git a/src/map/chat.cpp b/src/map/chat.cpp index 0615b41..cb274f8 100644 --- a/src/map/chat.cpp +++ b/src/map/chat.cpp @@ -22,7 +22,7 @@ int chat_triggerevent (struct chat_data *cd); *------------------------------------------ */ int chat_createchat (struct map_session_data *sd, int limit, int pub, - char *pass, char *title, int titlelen) + const char *pass, const char *title, int titlelen) { struct chat_data *cd; @@ -65,7 +65,7 @@ int chat_createchat (struct map_session_data *sd, int limit, int pub, * 既存チャットルームに参加 *------------------------------------------ */ -int chat_joinchat (struct map_session_data *sd, int chatid, char *pass) +int chat_joinchat (struct map_session_data *sd, int chatid, const char *pass) { struct chat_data *cd; @@ -165,7 +165,7 @@ int chat_leavechat (struct map_session_data *sd) * チャットルームの持ち主を譲る *------------------------------------------ */ -int chat_changechatowner (struct map_session_data *sd, char *nextownername) +int chat_changechatowner (struct map_session_data *sd, const char *nextownername) { struct chat_data *cd; struct map_session_data *tmp_sd; @@ -213,7 +213,7 @@ int chat_changechatowner (struct map_session_data *sd, char *nextownername) *------------------------------------------ */ int chat_changechatstatus (struct map_session_data *sd, int limit, int pub, - char *pass, char *title, int titlelen) + const char *pass, const char *title, int titlelen) { struct chat_data *cd; @@ -241,7 +241,7 @@ int chat_changechatstatus (struct map_session_data *sd, int limit, int pub, * チャットルームから蹴り出す *------------------------------------------ */ -int chat_kickchat (struct map_session_data *sd, char *kickusername) +int chat_kickchat (struct map_session_data *sd, const char *kickusername) { struct chat_data *cd; int i, kickuser; @@ -273,7 +273,7 @@ int chat_kickchat (struct map_session_data *sd, char *kickusername) *------------------------------------------ */ int chat_createnpcchat (struct npc_data *nd, int limit, int pub, int trigger, - char *title, int titlelen, const char *ev) + const char *title, int titlelen, const char *ev) { struct chat_data *cd; diff --git a/src/map/chat.hpp b/src/map/chat.hpp index 3a9ccb6..fca9217 100644 --- a/src/map/chat.hpp +++ b/src/map/chat.hpp @@ -4,17 +4,17 @@ #include "map.hpp" -int chat_createchat (struct map_session_data *, int, int, char *, char *, +int chat_createchat (struct map_session_data *, int, int, const char *, const char *, int); -int chat_joinchat (struct map_session_data *, int, char *); +int chat_joinchat (struct map_session_data *, int, const char *); int chat_leavechat (struct map_session_data *); -int chat_changechatowner (struct map_session_data *, char *); -int chat_changechatstatus (struct map_session_data *, int, int, char *, - char *, int); -int chat_kickchat (struct map_session_data *, char *); +int chat_changechatowner (struct map_session_data *, const char *); +int chat_changechatstatus (struct map_session_data *, int, int, const char *, + const char *, int); +int chat_kickchat (struct map_session_data *, const char *); int chat_createnpcchat (struct npc_data *nd, int limit, int pub, int trigger, - char *title, int titlelen, const char *ev); + const char *title, int titlelen, const char *ev); int chat_deletenpcchat (struct npc_data *nd); int chat_enableevent (struct chat_data *cd); int chat_disableevent (struct chat_data *cd); diff --git a/src/map/chrif.cpp b/src/map/chrif.cpp index 0223e67..24d5d26 100644 --- a/src/map/chrif.cpp +++ b/src/map/chrif.cpp @@ -133,13 +133,14 @@ int chrif_save (struct map_session_data *sd) * *------------------------------------------ */ +static int chrif_connect (int fd) { WFIFOW (fd, 0) = 0x2af8; memcpy (WFIFOP (fd, 2), userid, 24); memcpy (WFIFOP (fd, 26), passwd, 24); WFIFOL (fd, 50) = 0; - WFIFOL (fd, 54) = clif_getip (); + WFIFOL (fd, 54) = clif_getip ().s_addr; WFIFOW (fd, 58) = clif_getport (); // [Valaris] thanks to fov WFIFOSET (fd, 60); @@ -150,6 +151,7 @@ int chrif_connect (int fd) * マップ送信 *------------------------------------------ */ +static int chrif_sendmap (int fd) { int i; @@ -170,25 +172,25 @@ int chrif_sendmap (int fd) * マップ受信 *------------------------------------------ */ +static int chrif_recvmap (int fd) { - int i, j, ip, port; - unsigned char *p = (unsigned char *) &ip; + int i, j, port; if (chrif_state < 2) // まだ準備中 return -1; - ip = RFIFOL (fd, 4); + struct in_addr ip; + ip.s_addr = RFIFOL (fd, 4); port = RFIFOW (fd, 8); for (i = 10, j = 0; i < RFIFOW (fd, 2); i += 16, j++) { - map_setipport (RFIFOP (fd, i), ip, port); + map_setipport ((const char *)RFIFOP (fd, i), ip, port); // if (battle_config.etc_log) // printf("recv map %d %s\n", j, RFIFOP(fd,i)); } if (battle_config.etc_log) - printf ("recv map on %d.%d.%d.%d:%d (%d maps)\n", p[0], p[1], p[2], - p[3], port, j); + printf ("recv map on %s:%d (%d maps)\n", ip2str(ip), port, j); return 0; } @@ -198,7 +200,7 @@ int chrif_recvmap (int fd) *------------------------------------------ */ int chrif_changemapserver (struct map_session_data *sd, char *name, int x, - int y, int ip, short port) + int y, struct in_addr ip, short port) { int i, s_ip; @@ -220,7 +222,7 @@ int chrif_changemapserver (struct map_session_data *sd, char *name, int x, memcpy (WFIFOP (char_fd, 18), name, 16); WFIFOW (char_fd, 34) = x; WFIFOW (char_fd, 36) = y; - WFIFOL (char_fd, 38) = ip; + WFIFOL (char_fd, 38) = ip.s_addr; WFIFOL (char_fd, 42) = port; WFIFOB (char_fd, 44) = sd->status.sex; WFIFOL (char_fd, 45) = s_ip; @@ -233,6 +235,7 @@ int chrif_changemapserver (struct map_session_data *sd, char *name, int x, * マップ鯖間移動ack *------------------------------------------ */ +static int chrif_changemapserverack (int fd) { struct map_session_data *sd = map_id2sd (RFIFOL (fd, 2)); @@ -247,8 +250,8 @@ int chrif_changemapserverack (int fd) pc_authfail (sd->fd); return 0; } - clif_changemapserver (sd, RFIFOP (fd, 18), RFIFOW (fd, 34), - RFIFOW (fd, 36), RFIFOL (fd, 38), RFIFOW (fd, 42)); + clif_changemapserver (sd, (const char *)RFIFOP (fd, 18), RFIFOW (fd, 34), + RFIFOW (fd, 36), in_addr{RFIFOL (fd, 38)}, RFIFOW (fd, 42)); return 0; } @@ -257,6 +260,7 @@ int chrif_changemapserverack (int fd) * *------------------------------------------ */ +static int chrif_connectack (int fd) { if (RFIFOB (fd, 2)) @@ -284,6 +288,7 @@ int chrif_connectack (int fd) * *------------------------------------------ */ +static int chrif_sendmapack (int fd) { if (RFIFOB (fd, 2)) @@ -465,6 +470,7 @@ int chrif_char_ask_name (int id, char *character_name, short operation_type, * 3: login-server offline *------------------------------------------ */ +static int chrif_char_ask_name_answer (int fd) { int acc; @@ -608,6 +614,7 @@ int chrif_char_ask_name_answer (int fd) * End of GM change (@GM) (modified by Yor) *------------------------------------------ */ +static int chrif_changedgm (int fd) { int acc, level; @@ -636,6 +643,7 @@ int chrif_changedgm (int fd) * 性別変化終了 (modified by Yor) *------------------------------------------ */ +static int chrif_changedsex (int fd) { int acc, sex, i; @@ -736,6 +744,7 @@ int chrif_saveaccountreg2 (struct map_session_data *sd) * アカウント変数通知 *------------------------------------------ */ +static int chrif_accountreg2 (int fd) { int j, p; @@ -762,6 +771,7 @@ int chrif_accountreg2 (int fd) * ack from a map-server divorce request *------------------------------------------ */ +static int chrif_divorce (int char_id, int partner_id) { struct map_session_data *sd = NULL; @@ -808,6 +818,7 @@ int chrif_send_divorce (int char_id) * Disconnection of a player (account has been deleted in login-server) by [Yor] *------------------------------------------ */ +static int chrif_accountdeletion (int fd) { int acc; @@ -840,6 +851,7 @@ int chrif_accountdeletion (int fd) * Disconnection of a player (account has been banned of has a status, from login-server) by [Yor] *------------------------------------------ */ +static int chrif_accountban (int fd) { int acc; @@ -930,6 +942,7 @@ int chrif_accountban (int fd) * Receiving GM accounts and their levels from char-server by [Yor] *------------------------------------------ */ +static int chrif_recvgmaccounts (int fd) { printf ("From login-server: receiving of %d GM accounts information.\n", @@ -1092,6 +1105,7 @@ static int ladmin_itemfrob_c2 (struct block_list *bl, int source_id, return 0; } +static int ladmin_itemfrob_c (struct block_list *bl, va_list va_args) { int source_id = va_arg (va_args, int); @@ -1099,6 +1113,7 @@ int ladmin_itemfrob_c (struct block_list *bl, va_list va_args) return ladmin_itemfrob_c2 (bl, source_id, dest_id); } +static void ladmin_itemfrob (int fd) { int source_id = RFIFOL (fd, 2); @@ -1121,6 +1136,7 @@ void ladmin_itemfrob (int fd) * *------------------------------------------ */ +static void chrif_parse (int fd) { int packet_len, cmd; @@ -1203,7 +1219,7 @@ void chrif_parse (int fd) chrif_changemapserverack (fd); break; case 0x2b09: - map_addchariddb (RFIFOL (fd, 2), RFIFOP (fd, 6)); + map_addchariddb (RFIFOL (fd, 2), (const char *)RFIFOP (fd, 6)); break; case 0x2b0b: chrif_changedgm (fd); @@ -1246,6 +1262,7 @@ void chrif_parse (int fd) * 今このmap鯖に繋がっているクライアント人数をchar鯖へ送る *------------------------------------------ */ +static void send_users_tochar (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { int users = 0, i; @@ -1276,6 +1293,7 @@ void send_users_tochar (timer_id tid, tick_t tick, custom_id_t id, custom_data_t * char鯖との接続を確認し、もし切れていたら再度接続する *------------------------------------------ */ +static void check_connect_char_server (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { if (char_fd <= 0 || session[char_fd] == NULL) diff --git a/src/map/chrif.hpp b/src/map/chrif.hpp index 5b0341e..82bfe0d 100644 --- a/src/map/chrif.hpp +++ b/src/map/chrif.hpp @@ -16,7 +16,7 @@ int chrif_save (struct map_session_data *); int chrif_charselectreq (struct map_session_data *); int chrif_changemapserver (struct map_session_data *sd, char *name, int x, - int y, int ip, short port); + int y, struct in_addr ip, short port); int chrif_searchcharid (int char_id); int chrif_changegm (int id, const char *pass, int len); diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 2d6ddf1..fd22160 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -132,7 +132,7 @@ enum #define WFIFOPOS2(fd,pos,x0,y0,x1,y1) { WBUFPOS2(WFIFOP(fd,pos),0,x0,y0,x1,y1); } static char map_ip_str[16]; -static in_addr_t map_ip; +static struct in_addr map_ip; static int map_port = 5121; int map_fd; char talkie_mes[80]; @@ -141,10 +141,10 @@ char talkie_mes[80]; * map鯖のip設定 *------------------------------------------ */ -void clif_setip (char *ip) +void clif_setip (const char *ip) { memcpy (map_ip_str, ip, 16); - map_ip = inet_addr (map_ip_str); + map_ip.s_addr = inet_addr (map_ip_str); } /*========================================== @@ -160,7 +160,7 @@ void clif_setport (int port) * map鯖のip読み出し *------------------------------------------ */ -in_addr_t clif_getip (void) +struct in_addr clif_getip (void) { return map_ip; } @@ -232,6 +232,7 @@ static char *clif_validate_chat (struct map_session_data *sd, int type, * clif_sendでAREA*指定時用 *------------------------------------------ */ +static int clif_send_sub (struct block_list *bl, va_list ap) { unsigned char *buf; @@ -305,7 +306,8 @@ int clif_send_sub (struct block_list *bl, va_list ap) * *------------------------------------------ */ -int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) +static +int clif_send (const uint8_t *buf, int len, struct block_list *bl, int type) { int i; struct map_session_data *sd; @@ -320,8 +322,8 @@ int clif_send (unsigned char *buf, int len, struct block_list *bl, int type) if (bl->type == BL_PC) { - struct map_session_data *sd = (struct map_session_data *) bl; - if (sd->status.option & OPTION_INVISIBILITY) + struct map_session_data *sd2 = (struct map_session_data *) bl; + if (sd2->status.option & OPTION_INVISIBILITY) { // Obscure hidden GMs @@ -661,7 +663,7 @@ int clif_charselectok (int id) * *------------------------------------------ */ -static int clif_set009e (struct flooritem_data *fitem, char *buf) +static int clif_set009e (struct flooritem_data *fitem, uint8_t *buf) { int view; @@ -690,7 +692,7 @@ static int clif_set009e (struct flooritem_data *fitem, char *buf) */ int clif_dropflooritem (struct flooritem_data *fitem) { - char buf[64]; + uint8_t buf[64]; nullpo_retr (0, fitem); @@ -981,7 +983,7 @@ static int clif_set007b (struct map_session_data *sd, unsigned char *buf) */ int clif_npc_class_change (struct block_list *bl, int npc_class, int type) { - char buf[16]; + uint8_t buf[16]; nullpo_retr (0, bl); @@ -1003,7 +1005,7 @@ int clif_npc_class_change (struct block_list *bl, int npc_class, int type) */ int clif_mob_class_change (struct mob_data *md, int class_) { - char buf[16]; + uint8_t buf[16]; int view = mob_get_viewclass (class_); nullpo_retr (0, md); @@ -1430,6 +1432,7 @@ int clif_spawnmob (struct mob_data *md) * *------------------------------------------ */ +static int clif_servertick (struct map_session_data *sd) { int fd; @@ -1499,6 +1502,7 @@ int clif_movechar (struct map_session_data *sd) * *------------------------------------------ */ +static void clif_quitsave (int fd, struct map_session_data *sd) { map_quit (sd); @@ -1527,7 +1531,7 @@ void clif_setwaitclose (int fd) * *------------------------------------------ */ -int clif_changemap (struct map_session_data *sd, char *mapname, int x, int y) +int clif_changemap (struct map_session_data *sd, const char *mapname, int x, int y) { int fd; @@ -1551,8 +1555,8 @@ int clif_changemap (struct map_session_data *sd, char *mapname, int x, int y) * *------------------------------------------ */ -int clif_changemapserver (struct map_session_data *sd, char *mapname, int x, - int y, int ip, int port) +int clif_changemapserver (struct map_session_data *sd, const char *mapname, int x, + int y, struct in_addr ip, int port) { int fd; @@ -1563,7 +1567,7 @@ int clif_changemapserver (struct map_session_data *sd, char *mapname, int x, memcpy (WFIFOP (fd, 2), mapname, 16); WFIFOW (fd, 18) = x; WFIFOW (fd, 20) = y; - WFIFOL (fd, 22) = ip; + WFIFOL (fd, 22) = ip.s_addr; WFIFOW (fd, 26) = port; WFIFOSET (fd, packet_len_table[0x92]); @@ -1576,7 +1580,7 @@ int clif_changemapserver (struct map_session_data *sd, char *mapname, int x, */ int clif_fixpos (struct block_list *bl) { - char buf[16]; + uint8_t buf[16]; nullpo_retr (0, bl); @@ -1679,7 +1683,7 @@ int clif_selllist (struct map_session_data *sd) * *------------------------------------------ */ -int clif_scriptmes (struct map_session_data *sd, int npcid, char *mes) +int clif_scriptmes (struct map_session_data *sd, int npcid, const char *mes) { int fd; @@ -1689,7 +1693,7 @@ int clif_scriptmes (struct map_session_data *sd, int npcid, char *mes) WFIFOW (fd, 0) = 0xb4; WFIFOW (fd, 2) = strlen (mes) + 9; WFIFOL (fd, 4) = npcid; - strcpy (WFIFOP (fd, 8), mes); + strcpy ((char *)WFIFOP (fd, 8), mes); WFIFOSET (fd, WFIFOW (fd, 2)); return 0; @@ -1735,7 +1739,7 @@ int clif_scriptclose (struct map_session_data *sd, int npcid) * *------------------------------------------ */ -int clif_scriptmenu (struct map_session_data *sd, int npcid, char *mes) +int clif_scriptmenu (struct map_session_data *sd, int npcid, const char *mes) { int fd; @@ -1745,7 +1749,7 @@ int clif_scriptmenu (struct map_session_data *sd, int npcid, char *mes) WFIFOW (fd, 0) = 0xb7; WFIFOW (fd, 2) = strlen (mes) + 8; WFIFOL (fd, 4) = npcid; - strcpy (WFIFOP (fd, 8), mes); + strcpy ((char *)WFIFOP (fd, 8), mes); WFIFOSET (fd, WFIFOW (fd, 2)); return 0; @@ -1815,7 +1819,7 @@ int clif_viewpoint (struct map_session_data *sd, int npc_id, int type, int x, * *------------------------------------------ */ -int clif_cutin (struct map_session_data *sd, char *image, int type) +int clif_cutin (struct map_session_data *sd, const char *image, int type) { int fd; @@ -2682,6 +2686,7 @@ int clif_changelook_towards (struct block_list *bl, int type, int val, * *------------------------------------------ */ +static int clif_initialstatus (struct map_session_data *sd) { int fd; @@ -2844,7 +2849,7 @@ int clif_unequipitemack (struct map_session_data *sd, int n, int pos, int ok) */ int clif_misceffect (struct block_list *bl, int type) { - char buf[32]; + uint8_t buf[32]; nullpo_retr (0, bl); @@ -2863,7 +2868,7 @@ int clif_misceffect (struct block_list *bl, int type) */ int clif_changeoption (struct block_list *bl) { - char buf[32]; + uint8_t buf[32]; short option; struct status_change *sc_data; static const int omask[] = { 0x10, 0x20 }; @@ -2933,7 +2938,7 @@ int clif_useitemack (struct map_session_data *sd, int index, int amount, } else { - char buf[32]; + uint8_t buf[32]; WBUFW (buf, 0) = 0x1c8; WBUFW (buf, 2) = index + 2; @@ -2975,7 +2980,7 @@ int clif_createchat (struct map_session_data *sd, int fail) */ int clif_dispchat (struct chat_data *cd, int fd) { - char buf[128]; // 最大title(60バイト)+17 + uint8_t buf[128]; // 最大title(60バイト)+17 if (cd == NULL || *cd->owner == NULL) return 1; @@ -2987,7 +2992,7 @@ int clif_dispchat (struct chat_data *cd, int fd) WBUFW (buf, 12) = cd->limit; WBUFW (buf, 14) = cd->users; WBUFB (buf, 16) = cd->pub; - strcpy (WBUFP (buf, 17), cd->title); + strcpy ((char *)WBUFP (buf, 17), cd->title); if (fd) { memcpy (WFIFOP (fd, 0), buf, WBUFW (buf, 2)); @@ -3008,7 +3013,7 @@ int clif_dispchat (struct chat_data *cd, int fd) */ int clif_changechatstatus (struct chat_data *cd) { - char buf[128]; // 最大title(60バイト)+17 + uint8_t buf[128]; // 最大title(60バイト)+17 if (cd == NULL || cd->usersd[0] == NULL) return 1; @@ -3020,7 +3025,7 @@ int clif_changechatstatus (struct chat_data *cd) WBUFW (buf, 12) = cd->limit; WBUFW (buf, 14) = cd->users; WBUFB (buf, 16) = cd->pub; - strcpy (WBUFP (buf, 17), cd->title); + strcpy ((char *)WBUFP (buf, 17), cd->title); clif_send (buf, WBUFW (buf, 2), &cd->usersd[0]->bl, CHAT); return 0; @@ -3032,7 +3037,7 @@ int clif_changechatstatus (struct chat_data *cd) */ int clif_clearchat (struct chat_data *cd, int fd) { - char buf[32]; + uint8_t buf[32]; nullpo_retr (0, cd); @@ -3102,7 +3107,7 @@ int clif_joinchatok (struct map_session_data *sd, struct chat_data *cd) */ int clif_addchat (struct chat_data *cd, struct map_session_data *sd) { - char buf[32]; + uint8_t buf[32]; nullpo_retr (0, sd); nullpo_retr (0, cd); @@ -3121,7 +3126,7 @@ int clif_addchat (struct chat_data *cd, struct map_session_data *sd) */ int clif_changechatowner (struct chat_data *cd, struct map_session_data *sd) { - char buf[64]; + uint8_t buf[64]; nullpo_retr (0, sd); nullpo_retr (0, cd); @@ -3144,7 +3149,7 @@ int clif_changechatowner (struct chat_data *cd, struct map_session_data *sd) */ int clif_leavechat (struct chat_data *cd, struct map_session_data *sd) { - char buf[32]; + uint8_t buf[32]; nullpo_retr (0, sd); nullpo_retr (0, cd); @@ -3163,7 +3168,7 @@ int clif_leavechat (struct chat_data *cd, struct map_session_data *sd) * 取り引き要請受け *------------------------------------------ */ -int clif_traderequest (struct map_session_data *sd, char *name) +int clif_traderequest (struct map_session_data *sd, const char *name) { int fd; @@ -3171,7 +3176,7 @@ int clif_traderequest (struct map_session_data *sd, char *name) fd = sd->fd; WFIFOW (fd, 0) = 0xe5; - strcpy (WFIFOP (fd, 2), name); + strcpy ((char *)WFIFOP (fd, 2), name); WFIFOSET (fd, packet_len_table[0xe5]); return 0; @@ -3575,6 +3580,7 @@ clif_changelook_accessories (struct block_list *bl, * PC表示 *------------------------------------------ */ +static void clif_getareachar_pc (struct map_session_data *sd, struct map_session_data *dstsd) { @@ -3624,6 +3630,7 @@ void clif_getareachar_pc (struct map_session_data *sd, * NPC表示 *------------------------------------------ */ +static void clif_getareachar_npc (struct map_session_data *sd, struct npc_data *nd) { int len; @@ -3770,6 +3777,7 @@ int clif_damage (struct block_list *src, struct block_list *dst, * *------------------------------------------ */ +static void clif_getareachar_mob (struct map_session_data *sd, struct mob_data *md) { int len; @@ -3795,6 +3803,7 @@ void clif_getareachar_mob (struct map_session_data *sd, struct mob_data *md) * *------------------------------------------ */ +static void clif_getareachar_item (struct map_session_data *sd, struct flooritem_data *fitem) { @@ -3825,6 +3834,7 @@ void clif_getareachar_item (struct map_session_data *sd, * 場所スキルエフェクトが視界に入る *------------------------------------------ */ +static int clif_getareachar_skillunit (struct map_session_data *sd, struct skill_unit *unit) { @@ -3886,6 +3896,7 @@ int clif_getareachar_skillunit (struct map_session_data *sd, * 場所スキルエフェクトが視界から消える *------------------------------------------ */ +static int clif_clearchar_skillunit (struct skill_unit *unit, int fd) { nullpo_retr (0, unit); @@ -3905,7 +3916,7 @@ int clif_clearchar_skillunit (struct skill_unit *unit, int fd) */ int clif_01ac (struct block_list *bl) { - char buf[32]; + uint8_t buf[32]; nullpo_retr (0, bl); @@ -3920,6 +3931,7 @@ int clif_01ac (struct block_list *bl) * *------------------------------------------ */ +static int clif_getareachar (struct block_list *bl, va_list ap) { struct map_session_data *sd; @@ -4587,7 +4599,7 @@ int clif_status_change (struct block_list *bl, int type, int flag) * Send message (modified by [Yor]) *------------------------------------------ */ -int clif_displaymessage (const int fd, char *mes) +int clif_displaymessage (int fd, const char *mes) { int len_mes = strlen (mes); @@ -4606,7 +4618,7 @@ int clif_displaymessage (const int fd, char *mes) * 天の声を送信する *------------------------------------------ */ -int clif_GMmessage (struct block_list *bl, char *mes, int len, int flag) +int clif_GMmessage (struct block_list *bl, const char *mes, int len, int flag) { unsigned char lbuf[255]; unsigned char *buf = @@ -4703,7 +4715,7 @@ int clif_pvpset (struct map_session_data *sd, int pvprank, int pvpnum, } else { - char buf[32]; + uint8_t buf[32]; WBUFW (buf, 0) = 0x19a; WBUFL (buf, 2) = sd->bl.id; @@ -4726,12 +4738,12 @@ int clif_pvpset (struct map_session_data *sd, int pvprank, int pvpnum, * *------------------------------------------ */ -int clif_send0199 (int map, int type) +int clif_send0199 (int m, int type) { struct block_list bl; - char buf[16]; + uint8_t buf[16]; - bl.m = map; + bl.m = m; WBUFW (buf, 0) = 0x199; WBUFW (buf, 2) = type; clif_send (buf, packet_len_table[0x199], &bl, ALL_SAMEMAP); @@ -4759,7 +4771,7 @@ int clif_refine (int fd, struct map_session_data *sd, int fail, int index, * Wisp/page is transmitted to the destination player *------------------------------------------ */ -int clif_wis_message (int fd, char *nick, char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B +int clif_wis_message (int fd, const char *nick, const char *mes, int mes_len) // R 0097 <len>.w <nick>.24B <message>.?B { WFIFOW (fd, 0) = 0x97; WFIFOW (fd, 2) = mes_len + 24 + 4; @@ -5310,7 +5322,7 @@ int clif_party_invite (struct map_session_data *sd, * 4 The character is in the same party. *------------------------------------------ */ -int clif_party_inviteack (struct map_session_data *sd, char *nick, int flag) +int clif_party_inviteack (struct map_session_data *sd, const char *nick, int flag) { int fd; @@ -5366,7 +5378,7 @@ int clif_party_option (struct party *p, struct map_session_data *sd, int flag) *------------------------------------------ */ int clif_party_leaved (struct party *p, struct map_session_data *sd, - int account_id, char *name, int flag) + int account_id, const char *name, int flag) { unsigned char buf[64]; int i; @@ -5399,7 +5411,7 @@ int clif_party_leaved (struct party *p, struct map_session_data *sd, * パーティメッセージ送信 *------------------------------------------ */ -int clif_party_message (struct party *p, int account_id, char *mes, int len) +int clif_party_message (struct party *p, int account_id, const char *mes, int len) { struct map_session_data *sd; int i; @@ -5670,7 +5682,7 @@ int clif_bladestop (struct block_list *src, struct block_list *dst, int boolean) int clif_changemapcell (int m, int x, int y, int cell_type, int type) { struct block_list bl; - char buf[32]; + uint8_t buf[32]; bl.m = m; bl.x = x; @@ -5821,6 +5833,7 @@ int clif_guild_memberlogin_notice (struct guild *g, int idx, int flag) * ギルドマスター通知(14dへの応答) *------------------------------------------ */ +static int clif_guild_masterormember (struct map_session_data *sd) { int type = 0x57, fd; @@ -5955,7 +5968,7 @@ int clif_guild_allianceinfo (struct map_session_data *sd) WFIFOW (fd, 0) = 0x14c; for (i = c = 0; i < MAX_GUILDALLIANCE; i++) { - struct guild_alliance *a = &g->alliance[i]; + GuildAlliance *a = &g->alliance[i]; if (a->guild_id > 0) { WFIFOL (fd, c * 32 + 4) = a->opposition; @@ -6015,6 +6028,7 @@ int clif_guild_memberlist (struct map_session_data *sd) * ギルド役職名リスト *------------------------------------------ */ +static int clif_guild_positionnamelist (struct map_session_data *sd) { int i, fd; @@ -6041,6 +6055,7 @@ int clif_guild_positionnamelist (struct map_session_data *sd) * ギルド役職情報リスト *------------------------------------------ */ +static int clif_guild_positioninfolist (struct map_session_data *sd) { int i, fd; @@ -6272,6 +6287,7 @@ int clif_guild_explusion (struct map_session_data *sd, const char *name, * ギルド追放メンバリスト *------------------------------------------ */ +static int clif_guild_explusionlist (struct map_session_data *sd) { int fd; @@ -6287,7 +6303,7 @@ int clif_guild_explusionlist (struct map_session_data *sd) WFIFOW (fd, 0) = 0x163; for (i = c = 0; i < MAX_GUILDEXPLUSION; i++) { - struct guild_explusion *e = &g->explusion[i]; + GuildExpulsion *e = &g->explusion[i]; if (e->account_id > 0) { memcpy (WFIFOP (fd, c * 88 + 4), e->name, 24); @@ -6490,7 +6506,7 @@ static void clif_emotion_towards (struct block_list *bl, * トーキーボックス *------------------------------------------ */ -void clif_talkiebox (struct block_list *bl, char *talkie) +void clif_talkiebox (struct block_list *bl, const char *talkie) { unsigned char buf[86]; @@ -6563,7 +6579,7 @@ void clif_sitting (int fd, struct map_session_data *sd) * *------------------------------------------ */ -int clif_disp_onlyself (struct map_session_data *sd, char *mes, int len) +int clif_disp_onlyself (struct map_session_data *sd, const char *mes, int len) { unsigned char lbuf[255]; unsigned char *buf = @@ -6620,6 +6636,7 @@ int clif_GM_kick (struct map_session_data *sd, struct map_session_data *tsd, * Wis拒否許可応答 *------------------------------------------ */ +static int clif_wisexin (struct map_session_data *sd, int type, int flag) { int fd; @@ -6639,6 +6656,7 @@ int clif_wisexin (struct map_session_data *sd, int type, int flag) * Wis全拒否許可応答 *------------------------------------------ */ +static int clif_wisall (struct map_session_data *sd, int type, int flag) { int fd; @@ -6659,7 +6677,7 @@ int clif_wisall (struct map_session_data *sd, int type, int flag) *------------------------------------------ */ void clif_soundeffect (struct map_session_data *sd, struct block_list *bl, - char *name, int type) + const char *name, int type) { int fd; @@ -6719,6 +6737,7 @@ int clif_specialeffect (struct block_list *bl, int type, int flag) * *------------------------------------------ */ +static void clif_parse_WantToConnection (int fd, struct map_session_data *sd) { struct map_session_data *old_sd; @@ -6772,6 +6791,7 @@ void clif_parse_WantToConnection (int fd, struct map_session_data *sd) * map侵入時に必要なデータを全て送りつける *------------------------------------------ */ +static void clif_parse_LoadEndAck (int fd, struct map_session_data *sd) { // struct item_data* item; @@ -6928,6 +6948,7 @@ void clif_parse_LoadEndAck (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_TickSend (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -6941,6 +6962,7 @@ void clif_parse_TickSend (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_WalkToXY (int fd, struct map_session_data *sd) { int x, y; @@ -7033,6 +7055,7 @@ void clif_parse_QuitGame (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) { struct block_list *bl; @@ -7063,7 +7086,7 @@ void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) struct guild *g = NULL; struct party *p = NULL; - char *guild_name = "", *guild_pos = "", *party_name = ""; + const char *guild_name = "", *guild_pos = "", *party_name = ""; int send = 0; @@ -7105,7 +7128,7 @@ void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) if (pc_isGM(sd) >= battle_config.hack_info_GM_level) { - in_addr_t ip = ssd->ip; + struct in_addr ip = ssd->ip; WFIFOW (fd, 0) = 0x20C; // Mask the IP using the char-server password @@ -7113,7 +7136,7 @@ void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) ip = MD5_ip(chrif_getpasswd (), ssd->ip); WFIFOL (fd, 2) = account_id; - WFIFOL (fd, 6) = ip; + WFIFOL (fd, 6) = ip.s_addr; WFIFOSET (fd, packet_len_table[0x20C]); } @@ -7122,7 +7145,7 @@ void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) case BL_NPC: memcpy (WFIFOP (fd, 6), ((struct npc_data *) bl)->name, 24); { - char *start = WFIFOP (fd, 6); + char *start = (char *)WFIFOP (fd, 6); char *end = strchr (start, '#'); // [fate] elim hashed out/invisible names for the client if (end) while (*end) @@ -7159,10 +7182,12 @@ void clif_parse_GetCharNameRequest (int fd, struct map_session_data *sd) * (S 008c <len>.w <message>.?B) *------------------------------------------ */ +static void clif_parse_GlobalMessage (int fd, struct map_session_data *sd) { int msg_len = RFIFOW (fd, 2) - 4; /* Header (2) + length (2). */ size_t message_len = 0; + // sometimes uint8_t char *buf = NULL; char *message = NULL; /* The message text only. */ @@ -7170,8 +7195,7 @@ void clif_parse_GlobalMessage (int fd, struct map_session_data *sd) if (!(buf = clif_validate_chat (sd, 2, &message, &message_len))) { - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -7189,8 +7213,7 @@ void clif_parse_GlobalMessage (int fd, struct map_session_data *sd) if (tmw_CheckChatSpam (sd, message)) { free (buf); - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -7199,7 +7222,8 @@ void clif_parse_GlobalMessage (int fd, struct map_session_data *sd) WBUFW (buf, 2) = msg_len + 8; /* Header (2) + length (2) + ID (4). */ WBUFL (buf, 4) = sd->bl.id; - clif_send (buf, msg_len + 8, &sd->bl, + // evil multiuse buffer! + clif_send ((const uint8_t *)buf, msg_len + 8, &sd->bl, sd->chatID ? CHAT_WOS : AREA_CHAT_WOC); } @@ -7212,7 +7236,7 @@ void clif_parse_GlobalMessage (int fd, struct map_session_data *sd) return; } -int clif_message (struct block_list *bl, char *msg) +int clif_message (struct block_list *bl, const char *msg) { unsigned short msg_len = strlen (msg) + 1; unsigned char buf[512]; @@ -7236,6 +7260,7 @@ int clif_message (struct block_list *bl, char *msg) * *------------------------------------------ */ +static void clif_parse_MapMove (int fd, struct map_session_data *sd) { // /m /mapmove (as @rura GM command) @@ -7264,6 +7289,7 @@ void clif_parse_MapMove (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_ChangeDir (int fd, struct map_session_data *sd) { unsigned char buf[64]; @@ -7294,6 +7320,7 @@ void clif_parse_ChangeDir (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_Emotion (int fd, struct map_session_data *sd) { unsigned char buf[64]; @@ -7316,6 +7343,7 @@ void clif_parse_Emotion (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_HowManyConnections (int fd, struct map_session_data *sd) { WFIFOW (fd, 0) = 0xc2; @@ -7327,6 +7355,7 @@ void clif_parse_HowManyConnections (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_ActionRequest (int fd, struct map_session_data *sd) { unsigned int tick; @@ -7397,6 +7426,7 @@ void clif_parse_ActionRequest (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_Restart (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7445,6 +7475,7 @@ void clif_parse_Restart (int fd, struct map_session_data *sd) * [remoitnane] *------------------------------------------ */ +static void clif_parse_Wis (int fd, struct map_session_data *sd) { size_t message_len = 0; @@ -7456,8 +7487,7 @@ void clif_parse_Wis (int fd, struct map_session_data *sd) if (!(buf = clif_validate_chat (sd, 1, &message, &message_len))) { - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -7473,8 +7503,7 @@ void clif_parse_Wis (int fd, struct map_session_data *sd) if (tmw_CheckChatSpam (sd, message)) { free (buf); - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -7484,16 +7513,15 @@ void clif_parse_Wis (int fd, struct map_session_data *sd) * conflict (for instance, "Test" versus "test"), the char-server must * settle the discrepancy. */ - if (!(dstsd = map_nick2sd (RFIFOP (fd, 4))) - || strcmp (dstsd->status.name, RFIFOP (fd, 4)) != 0) - intif_wis_message (sd, RFIFOP (fd, 4), message, RFIFOW (fd, 2) - 28); + if (!(dstsd = map_nick2sd ((const char *)RFIFOP (fd, 4))) + || strcmp (dstsd->status.name, (const char *)RFIFOP (fd, 4)) != 0) + intif_wis_message (sd, (const char *)RFIFOP (fd, 4), message, RFIFOW (fd, 2) - 28); else { /* Refuse messages addressed to self. */ if (dstsd->fd == fd) { - /* "You cannot page yourself." */ - char *mes = msg_txt (504); + const char *mes = "You cannot page yourself."; clif_wis_message (fd, wisp_server_name, mes, strlen (mes) + 1); } else @@ -7535,6 +7563,7 @@ void clif_parse_Wis (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_GMmessage (int fd, struct map_session_data *sd) { char m[512]; @@ -7544,7 +7573,7 @@ void clif_parse_GMmessage (int fd, struct map_session_data *sd) if ((battle_config.atc_gmonly == 0 || pc_isGM (sd)) && (pc_isGM (sd) >= get_atcommand_level (AtCommand_Broadcast))) { - strncpy (m, RFIFOP (fd, 4), RFIFOW (fd, 2) - 4); + strncpy (m, (const char *)RFIFOP (fd, 4), RFIFOW (fd, 2) - 4); m[RFIFOW (fd, 2) - 4] = 0; log_atcommand (sd, "/announce %s", m); @@ -7559,6 +7588,7 @@ void clif_parse_GMmessage (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_TakeItem (int fd, struct map_session_data *sd) { struct flooritem_data *fitem; @@ -7599,6 +7629,7 @@ void clif_parse_TakeItem (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_DropItem (int fd, struct map_session_data *sd) { int item_index, item_amount; @@ -7634,6 +7665,7 @@ void clif_parse_DropItem (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_UseItem (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7660,6 +7692,7 @@ void clif_parse_UseItem (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_EquipItem (int fd, struct map_session_data *sd) { int index; @@ -7700,6 +7733,7 @@ void clif_parse_EquipItem (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_UnequipItem (int fd, struct map_session_data *sd) { int index; @@ -7732,6 +7766,7 @@ void clif_parse_UnequipItem (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcClicked (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7750,6 +7785,7 @@ void clif_parse_NpcClicked (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcBuySellSelected (int fd, struct map_session_data *sd) { npc_buysellsel (sd, RFIFOL (fd, 2), RFIFOB (fd, 6)); @@ -7759,6 +7795,7 @@ void clif_parse_NpcBuySellSelected (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcBuyListSend (int fd, struct map_session_data *sd) { int fail = 0, n; @@ -7778,6 +7815,7 @@ void clif_parse_NpcBuyListSend (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcSellListSend (int fd, struct map_session_data *sd) { int fail = 0, n; @@ -7797,53 +7835,59 @@ void clif_parse_NpcSellListSend (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_CreateChatRoom (int fd, struct map_session_data *sd) { - chat_createchat (sd, RFIFOW (fd, 4), RFIFOB (fd, 6), RFIFOP (fd, 7), - RFIFOP (fd, 15), RFIFOW (fd, 2) - 15); + chat_createchat (sd, RFIFOW (fd, 4), RFIFOB (fd, 6), (const char *)RFIFOP (fd, 7), + (const char *)RFIFOP (fd, 15), RFIFOW (fd, 2) - 15); } /*========================================== * *------------------------------------------ */ +static void clif_parse_ChatAddMember (int fd, struct map_session_data *sd) { - chat_joinchat (sd, RFIFOL (fd, 2), RFIFOP (fd, 6)); + chat_joinchat (sd, RFIFOL (fd, 2), (const char *)RFIFOP (fd, 6)); } /*========================================== * *------------------------------------------ */ +static void clif_parse_ChatRoomStatusChange (int fd, struct map_session_data *sd) { - chat_changechatstatus (sd, RFIFOW (fd, 4), RFIFOB (fd, 6), RFIFOP (fd, 7), - RFIFOP (fd, 15), RFIFOW (fd, 2) - 15); + chat_changechatstatus (sd, RFIFOW (fd, 4), RFIFOB (fd, 6), (const char *)RFIFOP (fd, 7), + (const char *)RFIFOP (fd, 15), RFIFOW (fd, 2) - 15); } /*========================================== * *------------------------------------------ */ +static void clif_parse_ChangeChatOwner (int fd, struct map_session_data *sd) { - chat_changechatowner (sd, RFIFOP (fd, 6)); + chat_changechatowner (sd, (const char *)RFIFOP (fd, 6)); } /*========================================== * *------------------------------------------ */ +static void clif_parse_KickFromChat (int fd, struct map_session_data *sd) { - chat_kickchat (sd, RFIFOP (fd, 2)); + chat_kickchat (sd, (const char *)RFIFOP (fd, 2)); } /*========================================== * *------------------------------------------ */ +static void clif_parse_ChatLeave (int fd, struct map_session_data *sd) { chat_leavechat (sd); @@ -7853,6 +7897,7 @@ void clif_parse_ChatLeave (int fd, struct map_session_data *sd) * 取引要請を相手に送る *------------------------------------------ */ +static void clif_parse_TradeRequest (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7870,6 +7915,7 @@ void clif_parse_TradeRequest (int fd, struct map_session_data *sd) * 取引要請 *------------------------------------------ */ +static void clif_parse_TradeAck (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7881,6 +7927,7 @@ void clif_parse_TradeAck (int fd, struct map_session_data *sd) * アイテム追加 *------------------------------------------ */ +static void clif_parse_TradeAddItem (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7892,6 +7939,7 @@ void clif_parse_TradeAddItem (int fd, struct map_session_data *sd) * アイテム追加完了(ok押し) *------------------------------------------ */ +static void clif_parse_TradeOk (int fd, struct map_session_data *sd) { trade_tradeok (sd); @@ -7901,6 +7949,7 @@ void clif_parse_TradeOk (int fd, struct map_session_data *sd) * 取引キャンセル *------------------------------------------ */ +static void clif_parse_TradeCansel (int fd, struct map_session_data *sd) { trade_tradecancel (sd); @@ -7910,6 +7959,7 @@ void clif_parse_TradeCansel (int fd, struct map_session_data *sd) * 取引許諾(trade押し) *------------------------------------------ */ +static void clif_parse_TradeCommit (int fd, struct map_session_data *sd) { trade_tradecommit (sd); @@ -7919,6 +7969,7 @@ void clif_parse_TradeCommit (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_StopAttack (int fd, struct map_session_data *sd) { pc_stopattack (sd); @@ -7928,6 +7979,7 @@ void clif_parse_StopAttack (int fd, struct map_session_data *sd) * カートへアイテムを移す *------------------------------------------ */ +static void clif_parse_PutItemToCart (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7941,6 +7993,7 @@ void clif_parse_PutItemToCart (int fd, struct map_session_data *sd) * カートからアイテムを出す *------------------------------------------ */ +static void clif_parse_GetItemFromCart (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -7954,6 +8007,7 @@ void clif_parse_GetItemFromCart (int fd, struct map_session_data *sd) * 付属品(鷹,ペコ,カート)をはずす *------------------------------------------ */ +static void clif_parse_RemoveOption (int fd, struct map_session_data *sd) { if (pc_isriding (sd)) @@ -7978,6 +8032,7 @@ void clif_parse_RemoveOption (int fd, struct map_session_data *sd) * チェンジカート *------------------------------------------ */ +static void clif_parse_ChangeCart (int fd, struct map_session_data *sd) { pc_setcart (sd, RFIFOW (fd, 2)); @@ -7987,6 +8042,7 @@ void clif_parse_ChangeCart (int fd, struct map_session_data *sd) * ステータスアップ *------------------------------------------ */ +static void clif_parse_StatusUp (int fd, struct map_session_data *sd) { pc_statusup (sd, RFIFOW (fd, 2)); @@ -7996,6 +8052,7 @@ void clif_parse_StatusUp (int fd, struct map_session_data *sd) * スキルレベルアップ *------------------------------------------ */ +static void clif_parse_SkillUp (int fd, struct map_session_data *sd) { pc_skillup (sd, RFIFOW (fd, 2)); @@ -8005,6 +8062,7 @@ void clif_parse_SkillUp (int fd, struct map_session_data *sd) * スキル使用(ID指定) *------------------------------------------ */ +static void clif_parse_UseSkillToId (int fd, struct map_session_data *sd) { int skillnum, skilllv, lv, target_id; @@ -8082,6 +8140,7 @@ void clif_parse_UseSkillToId (int fd, struct map_session_data *sd) * スキル使用(場所指定) *------------------------------------------ */ +static void clif_parse_UseSkillToPos (int fd, struct map_session_data *sd) { int skillnum, skilllv, lv, x, y; @@ -8152,6 +8211,7 @@ void clif_parse_UseSkillToPos (int fd, struct map_session_data *sd) * スキル使用(map指定) *------------------------------------------ */ +static void clif_parse_UseSkillMap (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8172,13 +8232,14 @@ void clif_parse_UseSkillMap (int fd, struct map_session_data *sd) if (sd->invincible_timer != -1) pc_delinvincibletimer (sd); - skill_castend_map (sd, RFIFOW (fd, 2), RFIFOP (fd, 4)); + skill_castend_map (sd, RFIFOW (fd, 2), (const char *)RFIFOP (fd, 4)); } /*========================================== * メモ要求 *------------------------------------------ */ +static void clif_parse_RequestMemo (int fd, struct map_session_data *sd) { pc_memo (sd, -1); @@ -8188,6 +8249,7 @@ void clif_parse_RequestMemo (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcSelectMenu (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8200,6 +8262,7 @@ void clif_parse_NpcSelectMenu (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcNextClicked (int fd, struct map_session_data *sd) { map_scriptcont (sd, RFIFOL (fd, 2)); @@ -8209,6 +8272,7 @@ void clif_parse_NpcNextClicked (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcAmountInput (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8228,6 +8292,7 @@ void clif_parse_NpcAmountInput (int fd, struct map_session_data *sd) * (S 01d5 <len>.w <npc_ID>.l <message>.?B) *------------------------------------------ */ +static void clif_parse_NpcStringInput (int fd, struct map_session_data *sd) { int len; @@ -8249,7 +8314,7 @@ void clif_parse_NpcStringInput (int fd, struct map_session_data *sd) } if (len > 0) - strncpy (sd->npc_str, RFIFOP (fd, 8), len); + strncpy (sd->npc_str, (const char *)RFIFOP (fd, 8), len); sd->npc_str[len] = '\0'; map_scriptcont (sd, RFIFOL (fd, 4)); @@ -8259,6 +8324,7 @@ void clif_parse_NpcStringInput (int fd, struct map_session_data *sd) * *------------------------------------------ */ +static void clif_parse_NpcCloseClicked (int fd, struct map_session_data *sd) { map_scriptcont (sd, RFIFOL (fd, 2)); @@ -8268,6 +8334,7 @@ void clif_parse_NpcCloseClicked (int fd, struct map_session_data *sd) * アイテム鑑定 *------------------------------------------ */ +static void clif_parse_ItemIdentify (int fd, struct map_session_data *sd) { pc_item_identify (sd, RFIFOW (fd, 2) - 2); @@ -8277,6 +8344,7 @@ void clif_parse_ItemIdentify (int fd, struct map_session_data *sd) * オートスペル受信 *------------------------------------------ */ +static void clif_parse_AutoSpell (int fd, struct map_session_data *sd) { skill_autospell (sd, RFIFOW (fd, 2)); @@ -8286,6 +8354,7 @@ void clif_parse_AutoSpell (int fd, struct map_session_data *sd) * カード使用 *------------------------------------------ */ +static void clif_parse_UseCard (int fd, struct map_session_data *sd) { clif_use_card (sd, RFIFOW (fd, 2) - 2); @@ -8295,6 +8364,7 @@ void clif_parse_UseCard (int fd, struct map_session_data *sd) * カード挿入装備選択 *------------------------------------------ */ +static void clif_parse_InsertCard (int fd, struct map_session_data *sd) { pc_insert_card (sd, RFIFOW (fd, 2) - 2, RFIFOW (fd, 4) - 2); @@ -8304,6 +8374,7 @@ void clif_parse_InsertCard (int fd, struct map_session_data *sd) * 0193 キャラID名前引き *------------------------------------------ */ +static void clif_parse_SolveCharName (int fd, struct map_session_data *sd) { int char_id; @@ -8316,6 +8387,7 @@ void clif_parse_SolveCharName (int fd, struct map_session_data *sd) * 0197 /resetskill /resetstate *------------------------------------------ */ +static void clif_parse_ResetChar (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8344,6 +8416,7 @@ void clif_parse_ResetChar (int fd, struct map_session_data *sd) * 019c /lb等 *------------------------------------------ */ +static void clif_parse_LGMmessage (int fd, struct map_session_data *sd) { unsigned char buf[64]; @@ -8364,6 +8437,7 @@ void clif_parse_LGMmessage (int fd, struct map_session_data *sd) * カプラ倉庫へ入れる *------------------------------------------ */ +static void clif_parse_MoveToKafra (int fd, struct map_session_data *sd) { int item_index, item_amount; @@ -8387,6 +8461,7 @@ void clif_parse_MoveToKafra (int fd, struct map_session_data *sd) * カプラ倉庫から出す *------------------------------------------ */ +static void clif_parse_MoveFromKafra (int fd, struct map_session_data *sd) { int item_index, item_amount; @@ -8410,6 +8485,7 @@ void clif_parse_MoveFromKafra (int fd, struct map_session_data *sd) * カプラ倉庫へカートから入れる *------------------------------------------ */ +static void clif_parse_MoveToKafraFromCart (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8428,6 +8504,7 @@ void clif_parse_MoveToKafraFromCart (int fd, struct map_session_data *sd) * カプラ倉庫から出す *------------------------------------------ */ +static void clif_parse_MoveFromKafraToCart (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8446,6 +8523,7 @@ void clif_parse_MoveFromKafraToCart (int fd, struct map_session_data *sd) * カプラ倉庫を閉じる *------------------------------------------ */ +static void clif_parse_CloseKafra (int fd, struct map_session_data *sd) { nullpo_retv (sd); @@ -8463,12 +8541,13 @@ void clif_parse_CloseKafra (int fd, struct map_session_data *sd) * (S 00f9 <party_name>.24B) *------------------------------------------ */ +static void clif_parse_CreateParty (int fd, struct map_session_data *sd) { if (battle_config.basic_skill_check == 0 || pc_checkskill (sd, NV_PARTY) >= 2) { - party_create (sd, RFIFOP (fd, 2)); + party_create (sd, (const char *)RFIFOP (fd, 2)); } else clif_skill_fail (sd, 1, 0, 4); @@ -8486,12 +8565,13 @@ void clif_parse_CreateParty (int fd, struct map_session_data *sd) * incomplete here. *------------------------------------------ */ +static void clif_parse_CreateParty2 (int fd, struct map_session_data *sd) { if (battle_config.basic_skill_check == 0 || pc_checkskill (sd, NV_PARTY) >= 2) { - party_create (sd, RFIFOP (fd, 2)); + party_create (sd, (const char *)RFIFOP (fd, 2)); } else clif_skill_fail (sd, 1, 0, 4); @@ -8504,6 +8584,7 @@ void clif_parse_CreateParty2 (int fd, struct map_session_data *sd) * (S 00fc <account_ID>.l) *------------------------------------------ */ +static void clif_parse_PartyInvite (int fd, struct map_session_data *sd) { party_invite (sd, RFIFOL (fd, 2)); @@ -8516,6 +8597,7 @@ void clif_parse_PartyInvite (int fd, struct map_session_data *sd) * (S 00ff <account_ID>.l <flag>.l) *------------------------------------------ */ +static void clif_parse_ReplyPartyInvite (int fd, struct map_session_data *sd) { if (battle_config.basic_skill_check == 0 @@ -8534,6 +8616,7 @@ void clif_parse_ReplyPartyInvite (int fd, struct map_session_data *sd) * パーティ脱退要求 *------------------------------------------ */ +static void clif_parse_LeaveParty (int fd, struct map_session_data *sd) { party_leave (sd); @@ -8543,15 +8626,17 @@ void clif_parse_LeaveParty (int fd, struct map_session_data *sd) * パーティ除名要求 *------------------------------------------ */ +static void clif_parse_RemovePartyMember (int fd, struct map_session_data *sd) { - party_removemember (sd, RFIFOL (fd, 2), RFIFOP (fd, 6)); + party_removemember (sd, RFIFOL (fd, 2), (const char *)RFIFOP (fd, 6)); } /*========================================== * パーティ設定変更要求 *------------------------------------------ */ +static void clif_parse_PartyChangeOption (int fd, struct map_session_data *sd) { party_changeoption (sd, RFIFOW (fd, 2), RFIFOW (fd, 4)); @@ -8565,6 +8650,7 @@ void clif_parse_PartyChangeOption (int fd, struct map_session_data *sd) * (S 0108 <len>.w <message>.?B) *------------------------------------------ */ +static void clif_parse_PartyMessage (int fd, struct map_session_data *sd) { size_t message_len = 0; @@ -8575,8 +8661,7 @@ void clif_parse_PartyMessage (int fd, struct map_session_data *sd) if (!(buf = clif_validate_chat (sd, 0, &message, &message_len))) { - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -8592,8 +8677,7 @@ void clif_parse_PartyMessage (int fd, struct map_session_data *sd) if (tmw_CheckChatSpam (sd, message)) { free (buf); - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -8605,6 +8689,7 @@ void clif_parse_PartyMessage (int fd, struct map_session_data *sd) * /monster /item rewriten by [Yor] *------------------------------------------ */ +static void clif_parse_GM_Monster_Item (int fd, struct map_session_data *sd) { char monster_item_name[25]; @@ -8646,15 +8731,17 @@ void clif_parse_GM_Monster_Item (int fd, struct map_session_data *sd) * Note: The account ID seems to be ignored. *------------------------------------------ */ +static void clif_parse_CreateGuild (int fd, struct map_session_data *sd) { - guild_create (sd, RFIFOP (fd, 6)); + guild_create (sd, (const char *)RFIFOP (fd, 6)); } /*========================================== * ギルドマスターかどうか確認 *------------------------------------------ */ +static void clif_parse_GuildCheckMaster (int fd, struct map_session_data *sd) { clif_guild_masterormember (sd); @@ -8664,6 +8751,7 @@ void clif_parse_GuildCheckMaster (int fd, struct map_session_data *sd) * ギルド情報要求 *------------------------------------------ */ +static void clif_parse_GuildReqeustInfo (int fd, struct map_session_data *sd) { switch (RFIFOL (fd, 2)) @@ -8698,6 +8786,7 @@ void clif_parse_GuildReqeustInfo (int fd, struct map_session_data *sd) * ギルド役職変更 *------------------------------------------ */ +static void clif_parse_GuildChangePositionInfo (int fd, struct map_session_data *sd) { struct guild *g; @@ -8717,7 +8806,7 @@ void clif_parse_GuildChangePositionInfo (int fd, struct map_session_data *sd) for (i = 4; i < RFIFOW (fd, 2); i += 40) { guild_change_position (sd, RFIFOL (fd, i), RFIFOL (fd, i + 4), - RFIFOL (fd, i + 12), RFIFOP (fd, i + 16)); + RFIFOL (fd, i + 12), (const char *)RFIFOP (fd, i + 16)); } } @@ -8725,6 +8814,7 @@ void clif_parse_GuildChangePositionInfo (int fd, struct map_session_data *sd) * ギルドメンバ役職変更 *------------------------------------------ */ +static void clif_parse_GuildChangeMemberPosition (int fd, struct map_session_data *sd) { @@ -8754,6 +8844,7 @@ void clif_parse_GuildChangeMemberPosition (int fd, * ギルドエンブレム要求 *------------------------------------------ */ +static void clif_parse_GuildRequestEmblem (int fd, struct map_session_data *sd) { struct guild *g = guild_search (RFIFOL (fd, 2)); @@ -8765,24 +8856,27 @@ void clif_parse_GuildRequestEmblem (int fd, struct map_session_data *sd) * ギルドエンブレム変更 *------------------------------------------ */ +static void clif_parse_GuildChangeEmblem (int fd, struct map_session_data *sd) { - guild_change_emblem (sd, RFIFOW (fd, 2) - 4, RFIFOP (fd, 4)); + guild_change_emblem (sd, RFIFOW (fd, 2) - 4, (const char *)RFIFOP (fd, 4)); } /*========================================== * ギルド告知変更 *------------------------------------------ */ +static void clif_parse_GuildChangeNotice (int fd, struct map_session_data *sd) { - guild_change_notice (sd, RFIFOL (fd, 2), RFIFOP (fd, 6), RFIFOP (fd, 66)); + guild_change_notice (sd, RFIFOL (fd, 2), (const char *)RFIFOP (fd, 6), (const char *)RFIFOP (fd, 66)); } /*========================================== * ギルド勧誘 *------------------------------------------ */ +static void clif_parse_GuildInvite (int fd, struct map_session_data *sd) { guild_invite (sd, RFIFOL (fd, 2)); @@ -8792,6 +8886,7 @@ void clif_parse_GuildInvite (int fd, struct map_session_data *sd) * ギルド勧誘返信 *------------------------------------------ */ +static void clif_parse_GuildReplyInvite (int fd, struct map_session_data *sd) { guild_reply_invite (sd, RFIFOL (fd, 2), RFIFOB (fd, 6)); @@ -8801,20 +8896,22 @@ void clif_parse_GuildReplyInvite (int fd, struct map_session_data *sd) * ギルド脱退 *------------------------------------------ */ +static void clif_parse_GuildLeave (int fd, struct map_session_data *sd) { guild_leave (sd, RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOL (fd, 10), - RFIFOP (fd, 14)); + (const char *)RFIFOP (fd, 14)); } /*========================================== * ギルド追放 *------------------------------------------ */ +static void clif_parse_GuildExplusion (int fd, struct map_session_data *sd) { guild_explusion (sd, RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOL (fd, 10), - RFIFOP (fd, 14)); + (const char *)RFIFOP (fd, 14)); } /*========================================== @@ -8825,6 +8922,7 @@ void clif_parse_GuildExplusion (int fd, struct map_session_data *sd) * (S 017e <len>.w <message>.?B) *------------------------------------------ */ +static void clif_parse_GuildMessage (int fd, struct map_session_data *sd) { size_t message_len = 0; @@ -8835,8 +8933,7 @@ void clif_parse_GuildMessage (int fd, struct map_session_data *sd) if (!(buf = clif_validate_chat (sd, 2, &message, &message_len))) { - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -8852,8 +8949,7 @@ void clif_parse_GuildMessage (int fd, struct map_session_data *sd) if (tmw_CheckChatSpam (sd, message)) { free (buf); - /* "Your message could not be sent." */ - clif_displaymessage (fd, msg_txt (505)); + clif_displaymessage (fd, "Your message could not be sent."); return; } @@ -8865,6 +8961,7 @@ void clif_parse_GuildMessage (int fd, struct map_session_data *sd) * ギルド同盟要求 *------------------------------------------ */ +static void clif_parse_GuildRequestAlliance (int fd, struct map_session_data *sd) { guild_reqalliance (sd, RFIFOL (fd, 2)); @@ -8874,6 +8971,7 @@ void clif_parse_GuildRequestAlliance (int fd, struct map_session_data *sd) * ギルド同盟要求返信 *------------------------------------------ */ +static void clif_parse_GuildReplyAlliance (int fd, struct map_session_data *sd) { guild_reply_reqalliance (sd, RFIFOL (fd, 2), RFIFOL (fd, 6)); @@ -8883,6 +8981,7 @@ void clif_parse_GuildReplyAlliance (int fd, struct map_session_data *sd) * ギルド関係解消 *------------------------------------------ */ +static void clif_parse_GuildDelAlliance (int fd, struct map_session_data *sd) { guild_delalliance (sd, RFIFOL (fd, 2), RFIFOL (fd, 6)); @@ -8892,6 +8991,7 @@ void clif_parse_GuildDelAlliance (int fd, struct map_session_data *sd) * ギルド敵対 *------------------------------------------ */ +static void clif_parse_GuildOpposition (int fd, struct map_session_data *sd) { guild_opposition (sd, RFIFOL (fd, 2)); @@ -8901,12 +9001,14 @@ void clif_parse_GuildOpposition (int fd, struct map_session_data *sd) * ギルド解散 *------------------------------------------ */ +static void clif_parse_GuildBreak (int fd, struct map_session_data *sd) { - guild_break (sd, RFIFOP (fd, 2)); + guild_break (sd, (const char *)RFIFOP (fd, 2)); } // Kick (right click menu for GM "(name) force to quit") +static void clif_parse_GMKick (int fd, struct map_session_data *sd) { struct block_list *target; @@ -8948,6 +9050,7 @@ void clif_parse_GMKick (int fd, struct map_session_data *sd) * /shift *------------------------------------------ */ +static void clif_parse_Shift (int fd, struct map_session_data *sd) { // Rewriten by [Yor] char player_name[25]; @@ -8971,6 +9074,7 @@ void clif_parse_Shift (int fd, struct map_session_data *sd) * /recall *------------------------------------------ */ +static void clif_parse_Recall (int fd, struct map_session_data *sd) { // Added by RoVeRT char player_name[25]; @@ -8990,6 +9094,7 @@ void clif_parse_Recall (int fd, struct map_session_data *sd) return; } +static void clif_parse_GMHide (int fd, struct map_session_data *sd) { // Modified by [Yor] nullpo_retv (sd); @@ -9002,14 +9107,12 @@ void clif_parse_GMHide (int fd, struct map_session_data *sd) if (sd->status.option & OPTION_HIDE) { // OPTION_HIDE = 0x40 sd->status.option &= ~OPTION_HIDE; // OPTION_HIDE = 0x40 - /* "Invisible: Off." */ - clif_displaymessage (fd, msg_txt (10)); + clif_displaymessage (fd, "Invisible: Off."); } else { sd->status.option |= OPTION_HIDE; // OPTION_HIDE = 0x40 - /* "Invisible: On." */ - clif_displaymessage (fd, msg_txt (11)); + clif_displaymessage (fd, "Invisible: On."); } clif_changeoption (&sd->bl); } @@ -9019,6 +9122,7 @@ void clif_parse_GMHide (int fd, struct map_session_data *sd) * GMによるチャット禁止時間付与 *------------------------------------------ */ +static void clif_parse_GMReqNoChat (int fd, struct map_session_data *sd) { int tid = RFIFOL (fd, 2); @@ -9032,8 +9136,7 @@ void clif_parse_GMReqNoChat (int fd, struct map_session_data *sd) if (!battle_config.muting_players) { - /* "Muting is disabled." */ - clif_displaymessage (fd, msg_txt (245)); + clif_displaymessage (fd, "Muting is disabled."); return; } @@ -9069,19 +9172,21 @@ void clif_parse_GMReqNoChat (int fd, struct map_session_data *sd) * GMによるチャット禁止時間参照(?) *------------------------------------------ */ +static void clif_parse_GMReqNoChatCount (int fd, struct map_session_data *sd) { int tid = RFIFOL (fd, 2); WFIFOW (fd, 0) = 0x1e0; WFIFOL (fd, 2) = tid; - sprintf (WFIFOP (fd, 6), "%d", tid); + sprintf ((char *)WFIFOP (fd, 6), "%d", tid); // memcpy(WFIFOP(fd,6),"TESTNAME",24); WFIFOSET (fd, packet_len_table[0x1e0]); return; } +static void clif_parse_PMIgnore (int fd, struct map_session_data *sd) { // Rewritten by [Yor] char output[1024]; @@ -9091,7 +9196,7 @@ void clif_parse_PMIgnore (int fd, struct map_session_data *sd) memset (output, '\0', sizeof (output)); - nick = RFIFOP (fd, 2); // speed up + nick = (char *)RFIFOP (fd, 2); // speed up //printf("Ignore: char '%s' state: %d\n", nick, RFIFOB(fd,26)); // we ask for deny (we add nick only if it's not already exist if (RFIFOB (fd, 26) == 0) @@ -9221,6 +9326,7 @@ void clif_parse_PMIgnore (int fd, struct map_session_data *sd) return; } +static void clif_parse_PMIgnoreAll (int fd, struct map_session_data *sd) { // Rewritten by [Yor] //printf("Ignore all: state: %d\n", RFIFOB(fd,2)); @@ -9266,6 +9372,7 @@ void clif_parse_PMIgnoreAll (int fd, struct map_session_data *sd) return; } +static void clif_parse_skillMessage (int fd, struct map_session_data *sd) { // Added by RoVeRT int skillid, skilllv, x, y; @@ -9277,12 +9384,13 @@ void clif_parse_skillMessage (int fd, struct map_session_data *sd) y = RFIFOB (fd, 6); x = RFIFOB (fd, 8); - mes = RFIFOP (fd, 10); + mes = (char *)RFIFOP (fd, 10); // skill 220 = graffiti // printf("skill: %d %d location: %3d %3d message: %s\n", skillid, skilllv, x, y, (char*)mes); } +static int monk (struct map_session_data *sd, struct block_list *target, int type) { //R 01d1 <Monk id>L <Target monster id>L <Bool>L @@ -9300,6 +9408,7 @@ int monk (struct map_session_data *sd, struct block_list *target, int type) * スパノビの/doridoriによるSPR2倍 *------------------------------------------ */ +static void clif_parse_sn_doridori (int fd, struct map_session_data *sd) { if (sd) @@ -9312,6 +9421,7 @@ void clif_parse_sn_doridori (int fd, struct map_session_data *sd) * スパノビの爆裂波動 *------------------------------------------ */ +static void clif_parse_sn_explosionspirits (int fd, struct map_session_data *sd) { if (sd) @@ -9904,6 +10014,7 @@ func_table clif_parse_func_table[0x220] = // *INDENT-ON* // Checks for packet flooding +static int clif_check_packet_flood(int fd, int cmd) { struct map_session_data *sd = (struct map_session_data *)session[fd]->session_data; @@ -10057,7 +10168,7 @@ static char *clif_validate_chat (struct map_session_data *sd, int type, return NULL; } - p = (char *) (type != 1) ? RFIFOP (fd, 4) : RFIFOP (fd, 28); + p = (char *) ((type != 1) ? RFIFOP (fd, 4) : RFIFOP (fd, 28)); buf_len = (type == 1) ? msg_len - min_len: msg_len; /* diff --git a/src/map/clif.hpp b/src/map/clif.hpp index f484a18..01f6a50 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -4,21 +4,16 @@ #include <sys/types.h> -#ifdef LCCWIN32 -#include <winsock.h> -typedef unsigned int in_addr_t; -#else #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> -#endif #include "map.hpp" -void clif_setip (char *); +void clif_setip (const char *); void clif_setport (int); -in_addr_t clif_getip (void); +struct in_addr clif_getip (void); int clif_getport (void); int clif_countusers (void); void clif_setwaitclose (int); @@ -40,21 +35,21 @@ int clif_spawnmob (struct mob_data *); // area int clif_walkok (struct map_session_data *); // self int clif_movechar (struct map_session_data *); // area int clif_movemob (struct mob_data *); //area -int clif_changemap (struct map_session_data *, char *, int, int); //self -int clif_changemapserver (struct map_session_data *, char *, int, int, int, int); //self +int clif_changemap (struct map_session_data *, const char *, int, int); //self +int clif_changemapserver (struct map_session_data *, const char *, int, int, struct in_addr, int); //self int clif_fixpos (struct block_list *); // area int clif_fixmobpos (struct mob_data *md); int clif_fixpcpos (struct map_session_data *sd); int clif_npcbuysell (struct map_session_data *, int); //self int clif_buylist (struct map_session_data *, struct npc_data *); //self int clif_selllist (struct map_session_data *); //self -int clif_scriptmes (struct map_session_data *, int, char *); //self +int clif_scriptmes (struct map_session_data *, int, const char *); //self int clif_scriptnext (struct map_session_data *, int); //self int clif_scriptclose (struct map_session_data *, int); //self -int clif_scriptmenu (struct map_session_data *, int, char *); //self +int clif_scriptmenu (struct map_session_data *, int, const char *); //self int clif_scriptinput (struct map_session_data *, int); //self int clif_scriptinputstr (struct map_session_data *sd, int npcid); // self -int clif_cutin (struct map_session_data *, char *, int); //self +int clif_cutin (struct map_session_data *, const char *, int); //self int clif_viewpoint (struct map_session_data *, int, int, int, int, int, int); //self int clif_additem (struct map_session_data *, int, int, int); //self int clif_delitem (struct map_session_data *, int, int); //self @@ -85,16 +80,16 @@ int clif_leavechat (struct chat_data *, struct map_session_data *); // chat int clif_changechatstatus (struct chat_data *); // chat void clif_emotion (struct block_list *bl, int type); -void clif_talkiebox (struct block_list *bl, char *talkie); +void clif_talkiebox (struct block_list *bl, const char *talkie); void clif_wedding_effect (struct block_list *bl); void clif_sitting (int fd, struct map_session_data *sd); //void clif_callpartner(struct map_session_data *sd); //void clif_sitting(struct map_session_data *sd); void clif_soundeffect (struct map_session_data *sd, struct block_list *bl, - char *name, int type); + const char *name, int type); // trade -int clif_traderequest (struct map_session_data *sd, char *name); +int clif_traderequest (struct map_session_data *sd, const char *name); int clif_tradestart (struct map_session_data *sd, int type); int clif_tradeadditem (struct map_session_data *sd, struct map_session_data *tsd, int index, int amount); @@ -182,7 +177,7 @@ int clif_changemapcell (int m, int x, int y, int cell_type, int type); int clif_status_change (struct block_list *bl, int type, int flag); -int clif_wis_message (int fd, char *nick, char *mes, int mes_len); +int clif_wis_message (int fd, const char *nick, const char *mes, int mes_len); int clif_wis_end (int fd, int flag); int clif_solved_charname (struct map_session_data *sd, int char_id); @@ -217,12 +212,12 @@ int clif_party_created (struct map_session_data *sd, int flag); int clif_party_info (struct party *p, int fd); int clif_party_invite (struct map_session_data *sd, struct map_session_data *tsd); -int clif_party_inviteack (struct map_session_data *sd, char *nick, int flag); +int clif_party_inviteack (struct map_session_data *sd, const char *nick, int flag); int clif_party_option (struct party *p, struct map_session_data *sd, int flag); int clif_party_leaved (struct party *p, struct map_session_data *sd, - int account_id, char *name, int flag); -int clif_party_message (struct party *p, int account_id, char *mes, int len); + int account_id, const char *name, int flag); +int clif_party_message (struct party *p, int account_id, const char *mes, int len); int clif_party_move (struct party *p, struct map_session_data *sd, int online); int clif_party_xy (struct party *p, struct map_session_data *sd); @@ -258,9 +253,9 @@ int clif_guild_oppositionack (struct map_session_data *sd, int flag); int clif_guild_broken (struct map_session_data *sd, int flag); // atcommand -int clif_displaymessage (const int fd, char *mes); -int clif_disp_onlyself (struct map_session_data *sd, char *mes, int len); -int clif_GMmessage (struct block_list *bl, char *mes, int len, int flag); +int clif_displaymessage (int fd, const char *mes); +int clif_disp_onlyself (struct map_session_data *sd, const char *mes, int len); +int clif_GMmessage (struct block_list *bl, const char *mes, int len, int flag); int clif_heal (int fd, int type, int val); int clif_resurrection (struct block_list *bl, int type); int clif_set0199 (int fd, int type); @@ -271,7 +266,7 @@ int clif_refine (int fd, struct map_session_data *sd, int fail, int index, int val); int clif_specialeffect (struct block_list *bl, int type, int flag); // special effects [Valaris] -int clif_message (struct block_list *bl, char *msg); // messages (from mobs/npcs) [Valaris] +int clif_message (struct block_list *bl, const char *msg); // messages (from mobs/npcs) [Valaris] int clif_GM_kickack (struct map_session_data *sd, int id); int clif_GM_kick (struct map_session_data *sd, struct map_session_data *tsd, diff --git a/src/map/guild.cpp b/src/map/guild.cpp index c001f78..eba856d 100644 --- a/src/map/guild.cpp +++ b/src/map/guild.cpp @@ -165,6 +165,7 @@ struct guild *guild_search (int guild_id) return (struct guild *)numdb_search (guild_db, guild_id); } +static void guild_searchname_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data, **dst; @@ -176,7 +177,7 @@ void guild_searchname_sub (db_key_t key, db_val_t data, va_list ap) } // ギルド名検索 -struct guild *guild_searchname (char *str) +struct guild *guild_searchname (const char *str) { struct guild *g = NULL; numdb_foreach (guild_db, guild_searchname_sub, str, &g); @@ -189,7 +190,7 @@ struct guild_castle *guild_castle_search (int gcid) } // mapnameに対応したアジトのgcを返す -struct guild_castle *guild_mapname2gc (char *mapname) +struct guild_castle *guild_mapname2gc (const char *mapname) { int i; struct guild_castle *gc = NULL; @@ -245,6 +246,7 @@ int guild_getposition (struct map_session_data *sd, struct guild *g) } // メンバー情報の作成 +static void guild_makemember (struct guild_member *m, struct map_session_data *sd) { nullpo_retv (sd); @@ -266,6 +268,7 @@ void guild_makemember (struct guild_member *m, struct map_session_data *sd) } // ギルド競合確認 +static int guild_check_conflict (struct map_session_data *sd) { nullpo_retr (0, sd); @@ -276,6 +279,7 @@ int guild_check_conflict (struct map_session_data *sd) } // ギルドのEXPキャッシュをinter鯖にフラッシュする +static void guild_payexp_timer_sub (db_key_t key, db_val_t data, va_list ap) { int i, *dellist, *delp, dataid = key.i; @@ -316,7 +320,7 @@ void guild_payexp_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_ //------------------------------------------------------------------------ /* Process a guild creation request. */ -int guild_create (struct map_session_data *sd, char *name) +int guild_create (struct map_session_data *sd, const char *name) { char pname[24]; @@ -425,6 +429,7 @@ int guild_npc_request_info (int guild_id, const char *event) } // 所属キャラの確認 +static int guild_check_member (const struct guild *g) { int i; @@ -905,7 +910,7 @@ int guild_recv_memberinfoshort (int guild_id, int account_id, int char_id, } // ギルド会話送信 -int guild_send_message (struct map_session_data *sd, char *mes, int len) +int guild_send_message (struct map_session_data *sd, const char *mes, int len) { nullpo_retr (0, sd); @@ -917,7 +922,7 @@ int guild_send_message (struct map_session_data *sd, char *mes, int len) } // ギルド会話受信 -int guild_recv_message (int guild_id, int account_id, char *mes, int len) +int guild_recv_message (int guild_id, int account_id, const char *mes, int len) { struct guild *g; if ((g = guild_search (guild_id)) == NULL) @@ -1141,6 +1146,7 @@ int guild_skillupack (int guild_id, int skill_num, int account_id) } // ギルド同盟数所得 +static int guild_get_alliance_count (struct guild *g, int flag) { int i, c; @@ -1442,6 +1448,7 @@ int guild_allianceack (int guild_id1, int guild_id2, int account_id1, } // ギルド解散通知用 +static void guild_broken_sub (db_key_t key, db_val_t data, va_list ap) { struct guild *g = (struct guild *) data; @@ -1493,7 +1500,7 @@ int guild_broken (int guild_id, int flag) } // ギルド解散 -int guild_break (struct map_session_data *sd, char *name) +int guild_break (struct map_session_data *sd, const char *name) { struct guild *g; int i; diff --git a/src/map/guild.hpp b/src/map/guild.hpp index f6d1356..983934c 100644 --- a/src/map/guild.hpp +++ b/src/map/guild.hpp @@ -20,17 +20,17 @@ int guild_isallied (struct guild *g, struct guild_castle *gc); void do_init_guild (void); struct guild *guild_search (int guild_id); -struct guild *guild_searchname (char *str); +struct guild *guild_searchname (const char *str); struct guild_castle *guild_castle_search (int gcid); -struct guild_castle *guild_mapname2gc (char *mapname); +struct guild_castle *guild_mapname2gc (const char *mapname); struct map_session_data *guild_getavailablesd (struct guild *g); int guild_getindex (struct guild *g, int account_id, int char_id); int guild_getposition (struct map_session_data *sd, struct guild *g); int guild_payexp (struct map_session_data *sd, int exp); -int guild_create (struct map_session_data *sd, char *name); +int guild_create (struct map_session_data *sd, const char *name); int guild_created (int account_id, int guild_id); int guild_request_info (int guild_id); int guild_recv_noinfo (int guild_id); @@ -73,10 +73,10 @@ int guild_change_emblem (struct map_session_data *sd, int len, const char *data); int guild_emblem_changed (int len, int guild_id, int emblem_id, const char *data); -int guild_send_message (struct map_session_data *sd, char *mes, int len); -int guild_recv_message (int guild_id, int account_id, char *mes, int len); +int guild_send_message (struct map_session_data *sd, const char *mes, int len); +int guild_recv_message (int guild_id, int account_id, const char *mes, int len); int guild_skillupack (int guild_id, int skill_num, int account_id); -int guild_break (struct map_session_data *sd, char *name); +int guild_break (struct map_session_data *sd, const char *name); int guild_broken (int guild_id, int flag); int guild_addcastleinfoevent (int castle_id, int index, const char *name); diff --git a/src/map/intif.cpp b/src/map/intif.cpp index 3ccb13a..dfbc665 100644 --- a/src/map/intif.cpp +++ b/src/map/intif.cpp @@ -55,7 +55,7 @@ extern int char_fd; // inter serverのfdはchar_fdを使う // inter serverへの送信 // Message for all GMs on all map servers -int intif_GMmessage (char *mes, int len, int flag) +int intif_GMmessage (const char *mes, int len, int flag) { int lp = (flag & 0x10) ? 8 : 4; WFIFOW (inter_fd, 0) = 0x3000; @@ -68,7 +68,7 @@ int intif_GMmessage (char *mes, int len, int flag) } // The transmission of Wisp/Page to inter-server (player not found on this server) -int intif_wis_message (struct map_session_data *sd, char *nick, char *mes, +int intif_wis_message (struct map_session_data *sd, const char *nick, const char *mes, int mes_len) { nullpo_retr (0, sd); @@ -88,6 +88,7 @@ int intif_wis_message (struct map_session_data *sd, char *nick, char *mes, } // The reply of Wisp/page +static int intif_wis_replay (int id, int flag) { WFIFOW (inter_fd, 0) = 0x3002; @@ -102,7 +103,7 @@ int intif_wis_replay (int id, int flag) } // The transmission of GM only Wisp/Page from server to inter-server -int intif_wis_message_to_gm (char *Wisp_name, int min_gm_level, char *mes, +int intif_wis_message_to_gm (const char *Wisp_name, int min_gm_level, const char *mes, int mes_len) { WFIFOW (inter_fd, 0) = 0x3003; @@ -192,7 +193,7 @@ int intif_send_guild_storage (int account_id, struct guild_storage *gstor) } // パーティ作成要求 -int intif_create_party (struct map_session_data *sd, char *name) +int intif_create_party (struct map_session_data *sd, const char *name) { nullpo_retr (0, sd); @@ -291,7 +292,7 @@ int intif_break_party (int party_id) } // パーティ会話送信 -int intif_party_message (int party_id, int account_id, char *mes, int len) +int intif_party_message (int party_id, int account_id, const char *mes, int len) { // if(battle_config.etc_log) // printf("intif_party_message: %s\n",mes); @@ -305,7 +306,7 @@ int intif_party_message (int party_id, int account_id, char *mes, int len) } // パーティ競合チェック要求 -int intif_party_checkconflict (int party_id, int account_id, char *nick) +int intif_party_checkconflict (int party_id, int account_id, const char *nick) { WFIFOW (inter_fd, 0) = 0x3028; WFIFOL (inter_fd, 2) = party_id; @@ -389,7 +390,7 @@ int intif_guild_break (int guild_id) } // ギルド会話送信 -int intif_guild_message (int guild_id, int account_id, char *mes, int len) +int intif_guild_message (int guild_id, int account_id, const char *mes, int len) { WFIFOW (inter_fd, 0) = 0x3037; WFIFOW (inter_fd, 2) = len + 12; @@ -526,26 +527,26 @@ int intif_guild_castle_datasave (int castle_id, int index, int value) // Packets receive from inter server // Wisp/Page reception +static int intif_parse_WisMessage (int fd) { // rewritten by [Yor] struct map_session_data *sd; int i; - char *wisp_source; if (battle_config.etc_log) printf ("intif_parse_wismessage: id: %d, from: %s, to: %s, message: '%s'\n", RFIFOL (fd, 4), RFIFOP (fd, 8), RFIFOP (fd, 32), RFIFOP (fd, 56)); - sd = map_nick2sd (RFIFOP (fd, 32)); // Searching destination player - if (sd != NULL && strcmp (sd->status.name, RFIFOP (fd, 32)) == 0) + sd = map_nick2sd ((const char *)RFIFOP (fd, 32)); // Searching destination player + if (sd != NULL && strcmp (sd->status.name, (const char *)RFIFOP (fd, 32)) == 0) { // exactly same name (inter-server have checked the name before) // if player ignore all if (sd->ignoreAll == 1) intif_wis_replay (RFIFOL (fd, 4), 2); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target else { - wisp_source = RFIFOP (fd, 8); // speed up + const char *wisp_source = (const char *)RFIFOP (fd, 8); // speed up // if player ignore the source character for (i = 0; i < (sizeof (sd->ignore) / sizeof (sd->ignore[0])); i++) @@ -557,7 +558,7 @@ int intif_parse_WisMessage (int fd) // if source player not found in ignore list if (i == (sizeof (sd->ignore) / sizeof (sd->ignore[0]))) { - clif_wis_message (sd->fd, RFIFOP (fd, 8), RFIFOP (fd, 56), + clif_wis_message (sd->fd, (const char *)RFIFOP (fd, 8), (const char *)RFIFOP (fd, 56), RFIFOW (fd, 2) - 56); intif_wis_replay (RFIFOL (fd, 4), 0); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target } @@ -569,13 +570,14 @@ int intif_parse_WisMessage (int fd) } // Wisp/page transmission result reception +static int intif_parse_WisEnd (int fd) { struct map_session_data *sd; if (battle_config.etc_log) printf ("intif_parse_wisend: player: %s, flag: %d\n", RFIFOP (fd, 2), RFIFOB (fd, 26)); // flag: 0: success to send wisper, 1: target character is not loged in?, 2: ignored by target - sd = map_nick2sd (RFIFOP (fd, 2)); + sd = map_nick2sd ((const char *)RFIFOP (fd, 2)); if (sd != NULL) clif_wis_end (sd->fd, RFIFOB (fd, 26)); @@ -583,6 +585,7 @@ int intif_parse_WisEnd (int fd) } // Received wisp message from map-server via char-server for ALL gm +static int mapif_parse_WisToGM (int fd) { // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B int i, min_gm_level, len; @@ -616,6 +619,7 @@ int mapif_parse_WisToGM (int fd) } // アカウント変数通知 +static int intif_parse_AccountReg (int fd) { int j, p; @@ -636,6 +640,7 @@ int intif_parse_AccountReg (int fd) } // 倉庫データ受信 +static int intif_parse_LoadStorage (int fd) { struct storage *stor; @@ -688,6 +693,7 @@ int intif_parse_LoadStorage (int fd) } // 倉庫データ送信成功 +static int intif_parse_SaveStorage (int fd) { if (battle_config.save_log) @@ -697,6 +703,7 @@ int intif_parse_SaveStorage (int fd) return 0; } +static int intif_parse_LoadGuildStorage (int fd) { struct guild_storage *gstor; @@ -760,6 +767,7 @@ int intif_parse_LoadGuildStorage (int fd) return 0; } +static int intif_parse_SaveGuildStorage (int fd) { if (battle_config.save_log) @@ -772,16 +780,18 @@ int intif_parse_SaveGuildStorage (int fd) } // パーティ作成可否 +static int intif_parse_PartyCreated (int fd) { if (battle_config.etc_log) printf ("intif: party created\n"); party_created (RFIFOL (fd, 2), RFIFOB (fd, 6), RFIFOL (fd, 7), - RFIFOP (fd, 11)); + (const char *)RFIFOP (fd, 11)); return 0; } // パーティ情報 +static int intif_parse_PartyInfo (int fd) { if (RFIFOW (fd, 2) == 8) @@ -805,6 +815,7 @@ int intif_parse_PartyInfo (int fd) } // パーティ追加通知 +static int intif_parse_PartyMemberAdded (int fd) { if (battle_config.etc_log) @@ -815,6 +826,7 @@ int intif_parse_PartyMemberAdded (int fd) } // パーティ設定変更通知 +static int intif_parse_PartyOptionChanged (int fd) { party_optionchanged (RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOW (fd, 10), @@ -823,16 +835,18 @@ int intif_parse_PartyOptionChanged (int fd) } // パーティ脱退通知 +static int intif_parse_PartyMemberLeaved (int fd) { if (battle_config.etc_log) printf ("intif: party member leaved %d %d %s\n", RFIFOL (fd, 2), - RFIFOL (fd, 6), RFIFOP (fd, 10)); - party_member_leaved (RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOP (fd, 10)); + RFIFOL (fd, 6), (const char *)RFIFOP (fd, 10)); + party_member_leaved (RFIFOL (fd, 2), RFIFOL (fd, 6), (const char *)RFIFOP (fd, 10)); return 0; } // パーティ解散通知 +static int intif_parse_PartyBroken (int fd) { party_broken (RFIFOL (fd, 2)); @@ -840,26 +854,29 @@ int intif_parse_PartyBroken (int fd) } // パーティ移動通知 +static int intif_parse_PartyMove (int fd) { // if(battle_config.etc_log) // printf("intif: party move %d %d %s %d %d\n",RFIFOL(fd,2),RFIFOL(fd,6),RFIFOP(fd,10),RFIFOB(fd,26),RFIFOW(fd,27)); - party_recv_movemap (RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOP (fd, 10), + party_recv_movemap (RFIFOL (fd, 2), RFIFOL (fd, 6), (const char *)RFIFOP (fd, 10), RFIFOB (fd, 26), RFIFOW (fd, 27)); return 0; } // パーティメッセージ +static int intif_parse_PartyMessage (int fd) { // if(battle_config.etc_log) // printf("intif_parse_PartyMessage: %s\n",RFIFOP(fd,12)); - party_recv_message (RFIFOL (fd, 4), RFIFOL (fd, 8), RFIFOP (fd, 12), + party_recv_message (RFIFOL (fd, 4), RFIFOL (fd, 8), (const char *)RFIFOP (fd, 12), RFIFOW (fd, 2) - 12); return 0; } // ギルド作成可否 +static int intif_parse_GuildCreated (int fd) { guild_created (RFIFOL (fd, 2), RFIFOL (fd, 6)); @@ -867,6 +884,7 @@ int intif_parse_GuildCreated (int fd) } // ギルド情報 +static int intif_parse_GuildInfo (int fd) { if (RFIFOW (fd, 2) == 8) @@ -891,6 +909,7 @@ int intif_parse_GuildInfo (int fd) } // ギルドメンバ追加通知 +static int intif_parse_GuildMemberAdded (int fd) { if (battle_config.etc_log) @@ -902,14 +921,16 @@ int intif_parse_GuildMemberAdded (int fd) } // ギルドメンバ脱退/追放通知 +static int intif_parse_GuildMemberLeaved (int fd) { guild_member_leaved (RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOL (fd, 10), - RFIFOB (fd, 14), RFIFOP (fd, 55), RFIFOP (fd, 15)); + RFIFOB (fd, 14), (const char *)RFIFOP (fd, 55), (const char *)RFIFOP (fd, 15)); return 0; } // ギルドメンバオンライン状態/Lv変更通知 +static int intif_parse_GuildMemberInfoShort (int fd) { guild_recv_memberinfoshort (RFIFOL (fd, 2), RFIFOL (fd, 6), @@ -920,6 +941,7 @@ int intif_parse_GuildMemberInfoShort (int fd) } // ギルド解散通知 +static int intif_parse_GuildBroken (int fd) { guild_broken (RFIFOL (fd, 2), RFIFOB (fd, 6)); @@ -927,6 +949,7 @@ int intif_parse_GuildBroken (int fd) } // ギルド基本情報変更通知 +static int intif_parse_GuildBasicInfoChanged (int fd) { int type = RFIFOW (fd, 8), guild_id = RFIFOL (fd, 4); @@ -952,6 +975,7 @@ int intif_parse_GuildBasicInfoChanged (int fd) } // ギルドメンバ情報変更通知 +static int intif_parse_GuildMemberInfoChanged (int fd) { int type = RFIFOW (fd, 16), guild_id = RFIFOL (fd, 4); @@ -976,6 +1000,7 @@ int intif_parse_GuildMemberInfoChanged (int fd) } // ギルド役職変更通知 +static int intif_parse_GuildPosition (int fd) { if (RFIFOW (fd, 2) != sizeof (struct guild_position) + 12) @@ -991,6 +1016,7 @@ int intif_parse_GuildPosition (int fd) } // ギルドスキル割り振り通知 +static int intif_parse_GuildSkillUp (int fd) { guild_skillupack (RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOL (fd, 10)); @@ -998,38 +1024,43 @@ int intif_parse_GuildSkillUp (int fd) } // ギルド同盟/敵対通知 +static int intif_parse_GuildAlliance (int fd) { guild_allianceack (RFIFOL (fd, 2), RFIFOL (fd, 6), RFIFOL (fd, 10), - RFIFOL (fd, 14), RFIFOB (fd, 18), RFIFOP (fd, 19), - RFIFOP (fd, 43)); + RFIFOL (fd, 14), RFIFOB (fd, 18), (const char *)RFIFOP (fd, 19), + (const char *)RFIFOP (fd, 43)); return 0; } // ギルド告知変更通知 +static int intif_parse_GuildNotice (int fd) { - guild_notice_changed (RFIFOL (fd, 2), RFIFOP (fd, 6), RFIFOP (fd, 66)); + guild_notice_changed (RFIFOL (fd, 2), (const char *)RFIFOP (fd, 6), (const char *)RFIFOP (fd, 66)); return 0; } // ギルドエンブレム変更通知 +static int intif_parse_GuildEmblem (int fd) { guild_emblem_changed (RFIFOW (fd, 2) - 12, RFIFOL (fd, 4), RFIFOL (fd, 8), - RFIFOP (fd, 12)); + (const char *)RFIFOP (fd, 12)); return 0; } // ギルド会話受信 +static int intif_parse_GuildMessage (int fd) { - guild_recv_message (RFIFOL (fd, 4), RFIFOL (fd, 8), RFIFOP (fd, 12), + guild_recv_message (RFIFOL (fd, 4), RFIFOL (fd, 8), (const char *)RFIFOP (fd, 12), RFIFOW (fd, 2) - 12); return 0; } // ギルド城データ要求返信 +static int intif_parse_GuildCastleDataLoad (int fd) { return guild_castledataloadack (RFIFOW (fd, 2), RFIFOB (fd, 4), @@ -1037,6 +1068,7 @@ int intif_parse_GuildCastleDataLoad (int fd) } // ギルド城データ変更通知 +static int intif_parse_GuildCastleDataSave (int fd) { return guild_castledatasaveack (RFIFOW (fd, 2), RFIFOB (fd, 4), @@ -1044,6 +1076,7 @@ int intif_parse_GuildCastleDataSave (int fd) } // ギルド城データ一括受信(初期化時) +static int intif_parse_GuildCastleAllDataLoad (int fd) { return guild_castlealldataload (RFIFOW (fd, 2), @@ -1084,7 +1117,7 @@ int intif_parse (int fd) switch (cmd) { case 0x3800: - clif_GMmessage (NULL, RFIFOP (fd, 4), packet_len - 4, 0); + clif_GMmessage (NULL, (const char *)RFIFOP (fd, 4), packet_len - 4, 0); break; case 0x3801: intif_parse_WisMessage (fd); diff --git a/src/map/intif.hpp b/src/map/intif.hpp index dc002e5..fcca523 100644 --- a/src/map/intif.hpp +++ b/src/map/intif.hpp @@ -1,14 +1,14 @@ // $Id: intif.h,v 1.2 2004/09/25 05:32:18 MouseJstr Exp $ #ifndef INTIF_HPP -#define INFIF_HPP +#define INTIF_HPP int intif_parse (int fd); -int intif_GMmessage (char *mes, int len, int flag); +int intif_GMmessage (const char *mes, int len, int flag); -int intif_wis_message (struct map_session_data *sd, char *nick, char *mes, +int intif_wis_message (struct map_session_data *sd, const char *nick, const char *mes, int mes_len); -int intif_wis_message_to_gm (char *Wisp_name, int min_gm_level, char *mes, +int intif_wis_message_to_gm (const char *Wisp_name, int min_gm_level, const char *mes, int mes_len); int intif_saveaccountreg (struct map_session_data *sd); @@ -19,7 +19,7 @@ int intif_send_storage (struct storage *stor); int intif_request_guild_storage (int account_id, int guild_id); int intif_send_guild_storage (int account_id, struct guild_storage *gstor); -int intif_create_party (struct map_session_data *sd, char *name); +int intif_create_party (struct map_session_data *sd, const char *name); int intif_request_partyinfo (int party_id); int intif_party_addmember (int party_id, int account_id); int intif_party_changeoption (int party_id, int account_id, int exp, @@ -27,8 +27,8 @@ int intif_party_changeoption (int party_id, int account_id, int exp, int intif_party_leave (int party_id, int accound_id); int intif_party_changemap (struct map_session_data *sd, int online); int intif_break_party (int party_id); -int intif_party_message (int party_id, int account_id, char *mes, int len); -int intif_party_checkconflict (int party_id, int account_id, char *nick); +int intif_party_message (int party_id, int account_id, const char *mes, int len); +int intif_party_checkconflict (int party_id, int account_id, const char *nick); int intif_guild_create (const char *name, const struct guild_member *master); int intif_guild_request_info (int guild_id); @@ -38,7 +38,7 @@ int intif_guild_leave (int guild_id, int account_id, int char_id, int flag, int intif_guild_memberinfoshort (int guild_id, int account_id, int char_id, int online, int lv, int class_); int intif_guild_break (int guild_id); -int intif_guild_message (int guild_id, int account_id, char *mes, int len); +int intif_guild_message (int guild_id, int account_id, const char *mes, int len); int intif_guild_checkconflict (int guild_id, int account_id, int char_id); int intif_guild_change_basicinfo (int guild_id, int type, const void *data, int len); diff --git a/src/map/itemdb.cpp b/src/map/itemdb.cpp index c1255bd..03e59d6 100644 --- a/src/map/itemdb.cpp +++ b/src/map/itemdb.cpp @@ -42,13 +42,13 @@ static int itemdb_read_randomitem (void); static int itemdb_read_itemavail (void); static int itemdb_read_itemnametable (void); static int itemdb_read_noequip (void); -void itemdb_reload (void); /*========================================== * 名前で検索用 *------------------------------------------ */ // name = item alias, so we should find items aliases first. if not found then look for "jname" (full name) +static void itemdb_searchname_sub (db_key_t key, db_val_t data, va_list ap) { struct item_data *item = (struct item_data *) data, **dst; @@ -65,6 +65,7 @@ void itemdb_searchname_sub (db_key_t key, db_val_t data, va_list ap) * 名前で検索用 *------------------------------------------ */ +static int itemdb_searchjname_sub (void *key, void *data, va_list ap) { struct item_data *item = (struct item_data *) data, **dst; @@ -259,7 +260,7 @@ int itemdb_isdropable (int nameid) static int itemdb_read_itemslottable (void) { char *buf, *p; - int s; + size_t s; buf = (char *)grfio_reads ("data\\itemslottable.txt", &s); if (buf == NULL) @@ -297,7 +298,7 @@ static int itemdb_readdb (void) char *str[32], *p, *np; struct item_data *id; int i = 0; - char *filename[] = { "db/item_db.txt", "db/item_db2.txt" }; + const char *filename[] = { "db/item_db.txt", "db/item_db2.txt" }; for (i = 0; i < 2; i++) { @@ -542,7 +543,7 @@ static int itemdb_read_itemavail (void) static int itemdb_read_itemnametable (void) { char *buf, *p; - int s; + size_t s; buf = (char *)grfio_reads ("data\\idnum2itemdisplaynametable.txt", &s); @@ -588,7 +589,7 @@ static int itemdb_read_itemnametable (void) static int itemdb_read_cardillustnametable (void) { char *buf, *p; - int s; + size_t s; buf = (char *)grfio_reads ("data\\num2cardillustnametable.txt", &s); @@ -677,9 +678,9 @@ static void itemdb_final (db_key_t key, db_val_t data, va_list ap) nullpo_retv (id = (struct item_data *)data); if (id->use_script) - free (id->use_script); + free (const_cast<ScriptCode *>(id->use_script)); if (id->equip_script) - free (id->equip_script); + free (const_cast<ScriptCode *>(id->equip_script)); free (id); } diff --git a/src/map/itemdb.hpp b/src/map/itemdb.hpp index ef5eab2..e03892d 100644 --- a/src/map/itemdb.hpp +++ b/src/map/itemdb.hpp @@ -3,6 +3,7 @@ #define ITEMDB_HPP #include "map.hpp" +#include "script.hpp" struct item_data { @@ -25,8 +26,8 @@ struct item_data int elv; int wlv; int refine; - char *use_script; - char *equip_script; + const ScriptCode *use_script; + const ScriptCode *equip_script; struct { unsigned available:1; diff --git a/src/map/magic-expr-eval.hpp b/src/map/magic-expr-eval.hpp index 71c1d86..a08b964 100644 --- a/src/map/magic-expr-eval.hpp +++ b/src/map/magic-expr-eval.hpp @@ -6,9 +6,8 @@ static int heading_x[8] = { 0, -1, -1, -1, 0, 1, 1, 1 }; static int heading_y[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; -int - magic_signature_check (char *opname, char *funname, char *signature, - int args_nr, val_t * args, int line, int column); +int magic_signature_check (const char *opname, const char *funname, const char *signature, + int args_nr, val_t * args, int line, int column); void magic_area_rect (int *m, int *x, int *y, int *width, int *height, diff --git a/src/map/magic-expr.cpp b/src/map/magic-expr.cpp index d75042d..4b4e3a3 100644 --- a/src/map/magic-expr.cpp +++ b/src/map/magic-expr.cpp @@ -83,7 +83,8 @@ void magic_clear_var (val_t * v) } } -static char *show_entity (entity_t * entity) +static +const char *show_entity (entity_t * entity) { switch (entity->type) { @@ -109,7 +110,7 @@ static char *show_entity (entity_t * entity) static void stringify (val_t * v, int within_op) { - static char *dirs[8] = + static const char *dirs[8] = { "south", "south-west", "west", "north-west", "north", "north-east", "east", "south-east" }; @@ -180,6 +181,7 @@ static void intify (val_t * v) v->v.v_int = 1; } +static area_t *area_new (int ty) { area_t *retval; @@ -188,6 +190,7 @@ area_t *area_new (int ty) return retval; } +static area_t *area_union (area_t * area, area_t * other_area) { area_t *retval = area_new (AREA_UNION); @@ -204,7 +207,7 @@ static void make_area (val_t * v) { if (v->ty == TY_LOCATION) { - area_t *a = (char *)malloc (sizeof (area_t)); + area_t *a = (area_t *)malloc (sizeof (area_t)); v->ty = TY_AREA; a->ty = AREA_LOCATION; a->a.a_loc = v->v.v_location; @@ -1238,6 +1241,7 @@ static fun_t functions[] = { static int functions_are_sorted = 0; +static int compare_fun (const void *lhs, const void *rhs) { return strcmp (((fun_t *) lhs)->name, ((fun_t *) rhs)->name); @@ -1436,9 +1440,8 @@ static int type_key (char ty_key) } } -int -magic_signature_check (char *opname, char *funname, char *signature, - int args_nr, val_t * args, int line, int column) +int magic_signature_check (const char *opname, const char *funname, const char *signature, + int args_nr, val_t * args, int line, int column) { int i; for (i = 0; i < args_nr; i++) @@ -1520,8 +1523,13 @@ magic_signature_check (char *opname, char *funname, char *signature, return 0; } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" void magic_eval (env_t * env, val_t * dest, expr_t * expr) { +#ifdef RECENT_GCC +#pragma GCC diagnostic pop +#endif switch (expr->ty) { case EXPR_VAL: @@ -1598,9 +1606,16 @@ void magic_eval (env_t * env, val_t * dest, expr_t * expr) dest->ty = TY_UNDEF; else { +#ifdef RECENT_GCC +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wshadow" +#endif env_t *env = t->env; - val_t v = VAR (id); - magic_copy_var (dest, &v); +#ifdef RECENT_GCC +#pragma GCC diagnostic pop +#endif + val_t val = VAR (id); + magic_copy_var (dest, &val); } } else @@ -1620,6 +1635,9 @@ void magic_eval (env_t * env, val_t * dest, expr_t * expr) break; } } +#ifndef RECENT_GCC +#pragma GCC diagnostic pop +#endif int magic_eval_int (env_t * env, expr_t * expr) { diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp index 4551585..7a251df 100644 --- a/src/map/magic-expr.hpp +++ b/src/map/magic-expr.hpp @@ -29,16 +29,16 @@ */ typedef struct fun { - char *name; - char *signature; + const char *name; + const char *signature; char ret_ty; int (*fun) (env_t * env, int args_nr, val_t * result, val_t * args); } fun_t; typedef struct op { - char *name; - char *signature; + const char *name; + const char *signature; int (*op) (env_t * env, int args_nr, val_t * args); } op_t; diff --git a/src/map/magic-interpreter-base.cpp b/src/map/magic-interpreter-base.cpp index 1dc90a5..0305192 100644 --- a/src/map/magic-interpreter-base.cpp +++ b/src/map/magic-interpreter-base.cpp @@ -46,7 +46,7 @@ env_t magic_default_env = { &magic_conf, NULL }; static int spells_sorted = 0; -char *magic_find_invocation (char *spellname) +const char *magic_find_invocation(const char *spellname) { int i; @@ -99,7 +99,7 @@ static int compare_teleport_anchor (const void *lhs, const void *rhs) (*((teleport_anchor_t **) rhs))->invocation); } -char *magic_find_anchor_invocation (char *anchor_name) +const char *magic_find_anchor_invocation(const char *anchor_name) { int i; diff --git a/src/map/magic-interpreter-parser.ypp b/src/map/magic-interpreter-parser.ypp index 2648be9..5fe2646 100644 --- a/src/map/magic-interpreter-parser.ypp +++ b/src/map/magic-interpreter-parser.ypp @@ -1,9 +1,13 @@ -%{ -#include "magic-interpreter.hpp" +%code requires { #include "magic-expr.hpp" +} +%code{ +#include "magic-interpreter-parser.hpp" + +#include "magic-interpreter.hpp" #include <stdarg.h> -magic_conf_t magic_conf; +#define YYLEX_PARAM 0, 0 static int intern_id(const char *id_name); @@ -49,8 +53,7 @@ add_teleport_anchor(teleport_anchor_t *anchor, int line_nr); static effect_t * op_effect(char *name, int args_nr, expr_t **args, int line, int column); -int -magic_frontend_lex(void); +int magic_frontend_lex(YYSTYPE *, YYLTYPE *); static void install_proc(proc_t *proc); @@ -64,8 +67,7 @@ bind_constant(char *name, val_t *val, int line_nr); static val_t * find_constant(char *name); - -%} +} %name-prefix="magic_frontend_" @@ -678,7 +680,7 @@ effect : '(' effect_list ')' } | SCRIPT_DATA { $$ = new_effect(EFFECT_SCRIPT); - $$->e.e_script = parse_script((unsigned char *) $1, @1.first_line); + $$->e.e_script = parse_script($1, @1.first_line); free($1); if ($$->e.e_script == NULL) fail(@1.first_line, @1.first_column, "Failed to compile script\n"); @@ -771,8 +773,8 @@ add_teleport_anchor(teleport_anchor_t *anchor, int line_nr) } -static void -fail(int line, int column, const char *fmt, ...) +static __attribute__((format(printf, 3, 4))) +void fail(int line, int column, const char *fmt, ...) { va_list ap; fprintf(stderr, "[magic-init] L%d:%d: ", line, column); @@ -1030,13 +1032,14 @@ find_constant(char *name) extern FILE *magic_frontend_in; -int -magic_init(char *conffile) // must be called after itemdb initialisation +// must be called after itemdb initialisation +int magic_init(const char *conffile) { int error_flag = 0; magic_conf.vars_nr = 0; - magic_conf.var_name = (char **)malloc(1); + // can these be left NULL ? I'm afraid to change anything. + magic_conf.var_name = (const char **)malloc(1); magic_conf.vars = (val_t *)malloc(1); magic_conf.obscure_chance = 95; diff --git a/src/map/magic-interpreter.hpp b/src/map/magic-interpreter.hpp index e040975..21e8d39 100644 --- a/src/map/magic-interpreter.hpp +++ b/src/map/magic-interpreter.hpp @@ -226,7 +226,7 @@ typedef struct effect struct effect *true_branch, *false_branch; } e_if; expr_t *e_sleep; /* sleep time */ - unsigned char *e_script; + const ScriptCode *e_script; struct { int id; @@ -497,4 +497,8 @@ typedef struct effect_t *body; } proc_t; +// must be called after itemdb initialisation +int magic_init(const char *); +void spell_update_location (invocation_t * invocation); + #endif /* !defined (MAGIC_INTERPRETER_H) */ diff --git a/src/map/magic-stmt.cpp b/src/map/magic-stmt.cpp index 20130dd..5dd51d7 100644 --- a/src/map/magic-stmt.cpp +++ b/src/map/magic-stmt.cpp @@ -3,10 +3,6 @@ #include "magic-expr-eval.hpp" #include "magic-interpreter-aux.hpp" -int - clif_spawn_fake_npc_for_player (struct map_session_data *sd, - int fake_npc_id); - #define INVISIBLE_NPC 127 /* used for local spell effects */ //#define DEBUG @@ -683,7 +679,8 @@ static int op_spawn (env_t * env, int args_nr, val_t * args) return 0; } -static char *get_invocation_name (env_t * env) +static +const char *get_invocation_name (env_t * env) { invocation_t *invocation; @@ -853,6 +850,7 @@ static op_t operations[] = { static int operations_sorted = 0; static int operation_count; +static int compare_operations (const void *lhs, const void *rhs) { return strcmp (((op_t *) lhs)->name, ((op_t *) rhs)->name); @@ -1405,16 +1403,14 @@ static int spell_run (invocation_t * invocation, int allow_delete) if (caster) { env_t *env = invocation->env; - character_t *caster = - (character_t *) map_id2bl (invocation->caster); - argrec_t arg[] = { {"@target",.v.i = + argrec_t arg[] = { {"@target", VAR (VAR_TARGET).ty == TY_ENTITY ? 0 : VAR (VAR_TARGET). v.v_int} , - {"@caster",.v.i = invocation->caster} + {"@caster", invocation->caster} , - {"@caster_name$",.v.s = caster ? caster->status.name : ""} + {"@caster_name$", caster ? caster->status.name : ""} }; int message_recipient = VAR (VAR_SCRIPTTARGET).ty == @@ -1501,8 +1497,7 @@ static int spell_run (invocation_t * invocation, int allow_delete) #undef REFRESH_INVOCATION } -extern void spell_update_location (invocation_t * invocation); - +static void spell_execute_d (invocation_t * invocation, int allow_deletion) { int delta; diff --git a/src/map/magic.cpp b/src/map/magic.cpp index 03b18a4..4311f09 100644 --- a/src/map/magic.cpp +++ b/src/map/magic.cpp @@ -122,8 +122,6 @@ int magic_message (character_t * caster, char *spell_, size_t spell_len) return 0; /* Not a spell */ } -int magic_init (char *conffile); // must be called after itemdb initialisation - void do_init_magic (void) { magic_init (MAGIC_CONFIG_FILE); diff --git a/src/map/magic.hpp b/src/map/magic.hpp index 0c776ea..168a05f 100644 --- a/src/map/magic.hpp +++ b/src/map/magic.hpp @@ -53,14 +53,14 @@ void do_init_magic (void); * * Returns NULL if not found */ -char *magic_find_invocation (char *spellame); +const char *magic_find_invocation (const char *spellame); /** * Identifies the invocation used to denote a teleport location * * Returns NULL if not found */ -char *magic_find_anchor_invocation (char *teleport_location); +const char *magic_find_anchor_invocation (const char *teleport_location); /** * Execute a spell invocation and sets up timers to finish diff --git a/src/map/map.cpp b/src/map/map.cpp index 3c778df..6470d97 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1019,7 +1019,7 @@ int map_addflooritem (struct item *item_data, int amount, int m, int x, int y, * charid_dbへ追加(返信待ちがあれば返信) *------------------------------------------ */ -void map_addchariddb (int charid, char *name) +void map_addchariddb (int charid, const char *name) { struct charid2nick *p = (struct charid2nick *)numdb_search (charid_db, charid); if (p == NULL) @@ -1277,7 +1277,7 @@ struct map_session_data *map_get_prev_session (struct map_session_data *d) * return map_session_data pointer or NULL *------------------------------------------ */ -struct map_session_data *map_nick2sd (char *nick) +struct map_session_data *map_nick2sd (const char *nick) { int i, quantity = 0, nicklen; struct map_session_data *sd = NULL; @@ -1375,6 +1375,7 @@ int map_addnpc (int m, struct npc_data *nd) return i; } +static void map_removenpc (void) { int i, m, n = 0; @@ -1406,7 +1407,7 @@ void map_removenpc (void) * map名からmap番号へ変換 *------------------------------------------ */ -int map_mapname2mapid (char *name) +int map_mapname2mapid (const char *name) { struct map_data *md = (struct map_data *)strdb_search (map_db, name); if (md == NULL || md->gat == NULL) @@ -1418,7 +1419,7 @@ int map_mapname2mapid (char *name) * 他鯖map名からip,port変換 *------------------------------------------ */ -int map_mapname2ipport (char *name, int *ip, int *port) +int map_mapname2ipport (const char *name, struct in_addr *ip, int *port) { struct map_data_other_server *mdos = (struct map_data_other_server *)strdb_search (map_db, name); if (mdos == NULL || mdos->gat) @@ -1553,7 +1554,7 @@ int map_setcell (int m, int x, int y, int t) * 他鯖管理のマップをdbに追加 *------------------------------------------ */ -int map_setipport (char *name, unsigned long ip, int port) +int map_setipport (const char *name, struct in_addr ip, int port) { struct map_data_other_server *mdos = NULL; @@ -1571,9 +1572,9 @@ int map_setipport (char *name, unsigned long ip, int port) { if (md->gat) { // local -> check data - if (ip != clif_getip () || port != clif_getport ()) + if (ip.s_addr != clif_getip ().s_addr || port != clif_getport ()) { - printf ("from char server : %s -> %08lx:%d\n", name, ip, + printf ("from char server : %s -> %s:%d\n", name, ip2str(ip), port); return 1; } @@ -1727,6 +1728,7 @@ static int map_readmap (int m, char *fn, char *alias) * 全てのmapデータを読み込む *------------------------------------------ */ +static int map_readallmap (void) { int i, maps_removed = 0; @@ -1785,6 +1787,7 @@ int map_readallmap (void) * 読み込むmapを追加する *------------------------------------------ */ +static int map_addmap (char *mapname) { if (strcasecmp (mapname, "clear") == 0) @@ -1868,7 +1871,7 @@ static void map_start_logfile (long suffix) free (filename_buf); } -static void map_set_logfile (char *filename) +static void map_set_logfile (const char *filename) { struct timeval tv; @@ -1880,7 +1883,7 @@ static void map_set_logfile (char *filename) MAP_LOG ("log-start v3"); } -void map_write_log (char *format, ...) +void map_write_log (const char *format, ...) { struct timeval tv; va_list args; @@ -1903,7 +1906,8 @@ void map_write_log (char *format, ...) * 設定ファイルを読み込む *------------------------------------------ */ -int map_config_read (char *cfgName) +static +int map_config_read (const char *cfgName) { char line[1024], w1[1024], w2[1024]; FILE *fp; @@ -2131,11 +2135,11 @@ int do_init (int argc, char *argv[]) { int i; - unsigned char *MAP_CONF_NAME = "conf/map_athena.conf"; - unsigned char *BATTLE_CONF_FILENAME = "conf/battle_athena.conf"; - unsigned char *ATCOMMAND_CONF_FILENAME = "conf/atcommand_athena.conf"; - unsigned char *SCRIPT_CONF_NAME = "conf/script_athena.conf"; - unsigned char *MSG_CONF_NAME = "conf/msg_athena.conf"; + const char *MAP_CONF_NAME = "conf/map_athena.conf"; + const char *BATTLE_CONF_FILENAME = "conf/battle_athena.conf"; + const char *ATCOMMAND_CONF_FILENAME = "conf/atcommand_athena.conf"; + const char *SCRIPT_CONF_NAME = "conf/script_athena.conf"; + const char *MSG_CONF_NAME = "conf/msg_athena.conf"; for (i = 1; i < argc; i++) { @@ -2159,7 +2163,6 @@ int do_init (int argc, char *argv[]) battle_config_read (BATTLE_CONF_FILENAME); atcommand_config_read (ATCOMMAND_CONF_FILENAME); script_config_read (SCRIPT_CONF_NAME); - msg_config_read (MSG_CONF_NAME); id_db = numdb_init (); map_db = strdb_init (16); diff --git a/src/map/map.hpp b/src/map/map.hpp index 5d3e0a2..8130739 100644 --- a/src/map/map.hpp +++ b/src/map/map.hpp @@ -10,6 +10,7 @@ #include "../common/mmo.hpp" #include "../common/timer.hpp" #include "../common/db.hpp" +#include "script.hpp" #ifndef MAX # define MAX(x,y) (((x)>(y)) ? (x) : (y)) @@ -225,7 +226,7 @@ struct map_session_data int npc_menu; int npc_amount; int npc_stack, npc_stackmax; - char *npc_script, *npc_scriptroot; + const ScriptCode *npc_script, *npc_scriptroot; char *npc_stackbuf; char npc_str[256]; struct @@ -404,7 +405,7 @@ struct map_session_data time_t packet_flood_reset_due; int packet_flood_in; - in_addr_t ip; + struct in_addr ip; }; struct npc_timerevent_list @@ -435,7 +436,7 @@ struct npc_data { struct { - char *script; + const ScriptCode *script; short xs, ys; int guild_id; int timer, timerid, timeramount, nexttimer; @@ -614,7 +615,7 @@ struct map_data_other_server { char name[24]; unsigned char *gat; // NULL固定にして判断 - unsigned long ip; + struct in_addr ip; unsigned int port; }; #define read_gat(m,x,y) (map[m].gat[(x)+(y)*map[m].xs]) @@ -701,8 +702,8 @@ struct chat_data { struct block_list bl; - unsigned char pass[8]; /* password */ - unsigned char title[61]; /* room title MAX 60 */ + char pass[8]; /* password */ + char title[61]; /* room title MAX 60 */ unsigned char limit; /* join limit */ unsigned char trigger; unsigned char users; /* current users */ @@ -758,7 +759,8 @@ int map_quit (struct map_session_data *); int map_addnpc (int, struct npc_data *); extern FILE *map_logfile; -void map_write_log (char *format, ...); +__attribute__((format(printf, 1, 2))) +void map_write_log (const char *format, ...); #define MAP_LOG(format, args...) {if (map_logfile) map_write_log(format, ##args);} #define MAP_LOG_PC(sd, fmt, args...) MAP_LOG("PC%d %d:%d,%d " fmt, sd->status.char_id, sd->bl.m, sd->bl.x, sd->bl.y, ## args) @@ -776,23 +778,23 @@ int map_addflooritem (struct item *, int, int, int, int, int map_searchrandfreecell (int, int, int, int); // キャラid=>キャラ名 変換関連 -void map_addchariddb (int charid, char *name); +void map_addchariddb (int charid, const char *name); void map_delchariddb (int charid); int map_reqchariddb (struct map_session_data *sd, int charid); char *map_charid2nick (int); struct map_session_data *map_id2sd (int); struct block_list *map_id2bl (int); -int map_mapname2mapid (char *); -int map_mapname2ipport (char *, int *, int *); -int map_setipport (char *name, unsigned long ip, int port); -int map_eraseipport (char *name, unsigned long ip, int port); +int map_mapname2mapid (const char *); +int map_mapname2ipport (const char *, struct in_addr *, int *); +int map_setipport (const char *name, struct in_addr ip, int port); +int map_eraseipport (const char *name, struct in_addr ip, int port); void map_addiddb (struct block_list *); void map_deliddb (struct block_list *bl); int map_foreachiddb (db_func_t, ...); void map_addnickdb (struct map_session_data *); int map_scriptcont (struct map_session_data *sd, int id); /* Continues a script either on a spell or on an NPC */ -struct map_session_data *map_nick2sd (char *); +struct map_session_data *map_nick2sd (const char *); int compare_item (struct item *a, struct item *b); struct map_session_data *map_get_first_session (void); diff --git a/src/map/mob.cpp b/src/map/mob.cpp index a722920..c329a14 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -44,7 +44,6 @@ struct mob_db mob_db[2001]; static int distance (int, int, int, int); static int mob_makedummymobdb (int); static void mob_timer (timer_id, tick_t, custom_id_t, custom_data_t); -int mobskill_use (struct mob_data *md, unsigned int tick, int event); int mobskill_deltimer (struct mob_data *md); int mob_skillid2skillidx (int mob_class, int skillid); int mobskill_use_id (struct mob_data *md, struct block_list *target, @@ -90,6 +89,7 @@ static void mob_init (struct mob_data *md); * The minimum data set for MOB spawning *------------------------------------------ */ +static int mob_spawn_dataset (struct mob_data *md, const char *mobname, int mob_class) { nullpo_retr (0, md); @@ -259,12 +259,13 @@ static void mob_mutate (struct mob_data *md, int stat, int intensity) // inten } // This calculates the exp of a given mob +static int mob_gen_exp (struct mob_db *mob) { if (mob->max_hp <= 1) return 1; double mod_def = 100 - mob->def; - if (mod_def == 0) + if (100 == mob->def) mod_def = 1; double effective_hp = ((50 - mob->luk) * mob->max_hp / 50.0) + @@ -338,7 +339,7 @@ static void mob_init (struct mob_data *md) * The MOB appearance for one time (for scripts) *------------------------------------------ */ -int mob_once_spawn (struct map_session_data *sd, char *mapname, +int mob_once_spawn (struct map_session_data *sd, const char *mapname, int x, int y, const char *mobname, int mob_class, int amount, const char *event) { @@ -444,7 +445,7 @@ int mob_once_spawn (struct map_session_data *sd, char *mapname, * The MOB appearance for one time (& area specification for scripts) *------------------------------------------ */ -int mob_once_spawn_area (struct map_session_data *sd, char *mapname, +int mob_once_spawn_area (struct map_session_data *sd, const char *mapname, int x0, int y0, int x1, int y1, const char *mobname, int mob_class, int amount, const char *event) @@ -494,7 +495,7 @@ int mob_once_spawn_area (struct map_session_data *sd, char *mapname, * Summoning Guardians [Valaris] *------------------------------------------ */ -int mob_spawn_guardian (struct map_session_data *sd, char *mapname, +int mob_spawn_guardian (struct map_session_data *sd, const char *mapname, int x, int y, const char *mobname, int mob_class, int amount, const char *event, int guardian) { @@ -663,6 +664,7 @@ int mob_get_equip (int mob_class) // mob equip [Valaris] * Is MOB in the state in which the present movement is possible or not? *------------------------------------------ */ +static int mob_can_move (struct mob_data *md) { nullpo_retr (0, md); @@ -955,6 +957,7 @@ static int mob_attack (struct mob_data *md, unsigned int tick, int data) * The callback function of clif_foreachclient *------------------------------------------ */ +static int mob_stopattacked (struct map_session_data *sd, va_list ap) { int id; @@ -1161,6 +1164,7 @@ static void mob_delayspawn (timer_id tid, tick_t tick, custom_id_t m, custom_dat * spawn timing calculation *------------------------------------------ */ +static int mob_setdelayspawn (int id) { unsigned int spawntime, spawntime1, spawntime2, spawntime3; @@ -1412,6 +1416,7 @@ int mob_stop_walking (struct mob_data *md, int type) * Reachability to a Specification ID existence place *------------------------------------------ */ +static int mob_can_reach (struct mob_data *md, struct block_list *bl, int range) { int dx, dy; @@ -2542,6 +2547,7 @@ void mob_timer_delete (timer_id tid, tick_t tick, custom_id_t id, custom_data_t * *------------------------------------------ */ +static int mob_deleteslave_sub (struct block_list *bl, va_list ap) { struct mob_data *md; @@ -2583,7 +2589,7 @@ const static double damage_bonus_factor[DAMAGE_BONUS_COUNT + 1] = { int mob_damage (struct block_list *src, struct mob_data *md, int damage, int type) { - int i, count, minpos, mindmg; + int count, minpos, mindmg; struct map_session_data *sd = NULL, *tmpsd[DAMAGELOG_SIZE]; struct { @@ -2598,7 +2604,6 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, double dmg_rate, tdmg, temp; struct item item; int ret; - int drop_rate; int skill, sp; nullpo_retr (0, md); //srcはNULLで呼ばれる場合もあるので、他でチェック @@ -2659,6 +2664,7 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, { if (sd != NULL) { + int i; for (i = 0, minpos = 0, mindmg = 0x7fffffff; i < DAMAGELOG_SIZE; i++) { @@ -2700,6 +2706,7 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, } nullpo_retr (0, md2); + int i; for (i = 0, minpos = 0, mindmg = 0x7fffffff; i < DAMAGELOG_SIZE; i++) { @@ -2869,7 +2876,9 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, // overkill分は無いけどsumはmax_hpとは違う tdmg = 0; - for (i = 0, count = 0, mvp_damage = 0; i < DAMAGELOG_SIZE; i++) + count = 0; + mvp_damage = 0; + for (int i = 0; i < DAMAGELOG_SIZE; i++) { if (md->dmglog[i].id == 0) continue; @@ -2900,7 +2909,7 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, dmg_rate = 1; // 経験値の分配 - for (i = 0; i < DAMAGELOG_SIZE; i++) + for (int i = 0; i < DAMAGELOG_SIZE; i++) { int pid, base_exp, job_exp, flag = 1; @@ -2983,14 +2992,14 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, pc_gainexp (tmpsd[i], base_exp, job_exp); } // 公平分配 - for (i = 0; i < pnum; i++) + for (int i = 0; i < pnum; i++) party_exp_share (pt[i].p, md->bl.m, pt[i].base_exp, pt[i].job_exp); // item drop if (!(type & 1)) { - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { struct delay_item_drop *ditem; int drop_rate; @@ -3025,7 +3034,7 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, } if (sd && sd->state.attack_type == BF_WEAPON) { - for (i = 0; i < sd->monster_drop_item_count; i++) + for (int i = 0; i < sd->monster_drop_item_count; i++) { struct delay_item_drop *ditem; int race = battle_get_race (&md->bl); @@ -3061,7 +3070,7 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, } if (md->lootitem) { - for (i = 0; i < md->lootitem_count; i++) + for (int i = 0; i < md->lootitem_count; i++) { struct delay_item_drop2 *ditem; @@ -3097,10 +3106,10 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, pc_gainexp (mvp_sd, mexp, 0); for (j = 0; j < 3; j++) { - i = MRAND (3); + int i = MRAND (3); if (mob_db[md->mob_class].mvpitem[i].nameid <= 0) continue; - drop_rate = mob_db[md->mob_class].mvpitem[i].p; + int drop_rate = mob_db[md->mob_class].mvpitem[i].p; if (drop_rate <= 0 && battle_config.drop_rate0item == 1) drop_rate = 1; if (drop_rate < battle_config.item_drop_mvp_min) @@ -3149,16 +3158,16 @@ int mob_damage (struct block_list *src, struct mob_data *md, int damage, sd = mvp_sd; else { - struct map_session_data *tmpsd; + struct map_session_data *tmp_sd; int i; for (i = 0; i < fd_max; i++) { - if (session[i] && (tmpsd = (struct map_session_data *)session[i]->session_data) - && tmpsd->state.auth) + if (session[i] && (tmp_sd = (struct map_session_data *)session[i]->session_data) + && tmp_sd->state.auth) { - if (md->bl.m == tmpsd->bl.m) + if (md->bl.m == tmp_sd->bl.m) { - sd = tmpsd; + sd = tmp_sd; break; } } @@ -3304,6 +3313,7 @@ int mob_heal (struct mob_data *md, int heal) * Added by RoVeRT *------------------------------------------ */ +static int mob_warpslave_sub (struct block_list *bl, va_list ap) { struct mob_data *md = (struct mob_data *) bl; @@ -3322,6 +3332,7 @@ int mob_warpslave_sub (struct block_list *bl, va_list ap) * Added by RoVeRT *------------------------------------------ */ +static int mob_warpslave (struct mob_data *md, int x, int y) { //printf("warp slave\n"); @@ -3417,6 +3428,7 @@ int mob_warp (struct mob_data *md, int m, int x, int y, int type) * 画面内の取り巻きの数計算用(foreachinarea) *------------------------------------------ */ +static int mob_countslave_sub (struct block_list *bl, va_list ap) { int id, *c; @@ -3438,6 +3450,7 @@ int mob_countslave_sub (struct block_list *bl, va_list ap) * 画面内の取り巻きの数計算 *------------------------------------------ */ +static int mob_countslave (struct mob_data *md) { int c = 0; @@ -3991,6 +4004,7 @@ int mobskill_use_id (struct mob_data *md, struct block_list *target, * スキル使用(場所指定) *------------------------------------------ */ +static int mobskill_use_pos (struct mob_data *md, int skill_x, int skill_y, int skill_idx) { @@ -4089,6 +4103,7 @@ int mobskill_use_pos (struct mob_data *md, * Friendly Mob whose HP is decreasing by a nearby MOB is looked for. *------------------------------------------ */ +static int mob_getfriendhpltmaxrate_sub (struct block_list *bl, va_list ap) { int rate; @@ -4109,6 +4124,7 @@ int mob_getfriendhpltmaxrate_sub (struct block_list *bl, va_list ap) return 0; } +static struct mob_data *mob_getfriendhpltmaxrate (struct mob_data *md, int rate) { struct mob_data *fr = NULL; @@ -4126,6 +4142,7 @@ struct mob_data *mob_getfriendhpltmaxrate (struct mob_data *md, int rate) * What a status state suits by nearby MOB is looked for. *------------------------------------------ */ +static int mob_getfriendstatus_sub (struct block_list *bl, va_list ap) { int cond1, cond2; @@ -4158,6 +4175,7 @@ int mob_getfriendstatus_sub (struct block_list *bl, va_list ap) return 0; } +static struct mob_data *mob_getfriendstatus (struct mob_data *md, int cond1, int cond2) { @@ -4180,7 +4198,7 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) { struct mob_skill *ms; // struct block_list *target=NULL; - int i, max_hp; + int max_hp; nullpo_retr (0, md); nullpo_retr (0, ms = mob_db[md->mob_class].skill); @@ -4196,24 +4214,24 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) if (md->sc_data[SC_SELFDESTRUCTION].timer != -1) //自爆中はスキルを使わない return 0; - for (i = 0; i < mob_db[md->mob_class].maxskill; i++) + for (int ii = 0; ii < mob_db[md->mob_class].maxskill; ii++) { - int c2 = ms[i].cond2, flag = 0; + int c2 = ms[ii].cond2, flag = 0; struct mob_data *fmd = NULL; // ディレイ中 - if (DIFF_TICK (tick, md->skilldelay[i]) < ms[i].delay) + if (DIFF_TICK (tick, md->skilldelay[ii]) < ms[ii].delay) continue; // 状態判定 - if (ms[i].state >= 0 && ms[i].state != md->state.skillstate) + if (ms[ii].state >= 0 && ms[ii].state != md->state.skillstate) continue; // 条件判定 - flag = (event == ms[i].cond1); + flag = (event == ms[ii].cond1); if (!flag) { - switch (ms[i].cond1) + switch (ms[ii].cond1) { case MSC_ALWAYS: flag = 1; @@ -4223,7 +4241,7 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) break; case MSC_MYSTATUSON: // status[num] on case MSC_MYSTATUSOFF: // status[num] off - if (ms[i].cond2 == -1) + if (ms[ii].cond2 == -1) { int j; for (j = SC_STONE; j <= SC_BLIND && !flag; j++) @@ -4232,21 +4250,21 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) } } else - flag = (md->sc_data[ms[i].cond2].timer != -1); - flag ^= (ms[i].cond1 == MSC_MYSTATUSOFF); + flag = (md->sc_data[ms[ii].cond2].timer != -1); + flag ^= (ms[ii].cond1 == MSC_MYSTATUSOFF); break; case MSC_FRIENDHPLTMAXRATE: // friend HP < maxhp% flag = ((fmd = mob_getfriendhpltmaxrate (md, - ms[i].cond2)) != NULL); + ms[ii].cond2)) != NULL); break; case MSC_FRIENDSTATUSON: // friend status[num] on case MSC_FRIENDSTATUSOFF: // friend status[num] off flag = ((fmd = - mob_getfriendstatus (md, ms[i].cond1, - ms[i].cond2)) != NULL); + mob_getfriendstatus (md, ms[ii].cond1, + ms[ii].cond2)) != NULL); break; case MSC_NOTINTOWN: // Only outside of towns. flag = !map[md->bl.m].flag.town; @@ -4271,17 +4289,17 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) } // 確率判定 - if (flag && MRAND (10000) < ms[i].permillage) + if (flag && MRAND (10000) < ms[ii].permillage) { - if (skill_get_inf (ms[i].skill_id) & 2) + if (skill_get_inf (ms[ii].skill_id) & 2) { // 場所指定 struct block_list *bl = NULL; int x = 0, y = 0; - if (ms[i].target <= MST_AROUND) + if (ms[ii].target <= MST_AROUND) { - if (ms[i].target == MST_MASTER) + if (ms[ii].target == MST_MASTER) { bl = &md->bl; if (md->master_id) @@ -4289,11 +4307,11 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) } else { - bl = ((ms[i].target == MST_TARGET - || ms[i].target == + bl = ((ms[ii].target == MST_TARGET + || ms[ii].target == MST_AROUND5) ? map_id2bl (md-> target_id) - : (ms[i].target == + : (ms[ii].target == MST_FRIEND) ? &fmd->bl : &md->bl); } @@ -4306,7 +4324,7 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) if (x <= 0 || y <= 0) continue; // 自分の周囲 - if (ms[i].target >= MST_AROUND1) + if (ms[ii].target >= MST_AROUND1) { int bx = x, by = y, i = 0, c, m = bl->m, r = ms[i].target - MST_AROUND1; @@ -4326,7 +4344,7 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) } } // 相手の周囲 - if (ms[i].target >= MST_AROUND5) + if (ms[ii].target >= MST_AROUND5) { int bx = x, by = y, i = 0, c, m = bl->m, r = (ms[i].target - MST_AROUND5) + 1; @@ -4345,37 +4363,37 @@ int mobskill_use (struct mob_data *md, unsigned int tick, int event) y = by; } } - if (!mobskill_use_pos (md, x, y, i)) + if (!mobskill_use_pos (md, x, y, ii)) return 0; } else { - if (ms[i].target == MST_MASTER) + if (ms[ii].target == MST_MASTER) { struct block_list *bl = &md->bl; if (md->master_id) bl = map_id2bl (md->master_id); - if (bl && !mobskill_use_id (md, bl, i)) + if (bl && !mobskill_use_id (md, bl, ii)) return 0; } // ID指定 - if (ms[i].target <= MST_FRIEND) + if (ms[ii].target <= MST_FRIEND) { struct block_list *bl = NULL; - bl = ((ms[i].target == + bl = ((ms[ii].target == MST_TARGET) ? map_id2bl (md-> - target_id) : (ms[i].target + target_id) : (ms[ii].target == MST_FRIEND) ? &fmd->bl : &md->bl); - if (bl && !mobskill_use_id (md, bl, i)) + if (bl && !mobskill_use_id (md, bl, ii)) return 0; } } - if (ms[i].emotion >= 0) - clif_emotion (&md->bl, ms[i].emotion); + if (ms[ii].emotion >= 0) + clif_emotion (&md->bl, ms[ii].emotion); return 1; } } @@ -4521,30 +4539,30 @@ static int mob_readdb (void) { FILE *fp; char line[1024]; - char *filename[] = { "db/mob_db.txt", "db/mob_db2.txt" }; - int i; + const char *filename[] = { "db/mob_db.txt", "db/mob_db2.txt" }; memset (mob_db, 0, sizeof (mob_db)); - for (i = 0; i < 2; i++) + for (int j = 0; j < 2; j++) { - fp = fopen_ (filename[i], "r"); + fp = fopen_ (filename[j], "r"); if (fp == NULL) { - if (i > 0) + if (j > 0) continue; return -1; } while (fgets (line, 1020, fp)) { - int mob_class, i; + int mob_class; char *str[57], *p, *np; if (line[0] == '/' && line[1] == '/') continue; - for (i = 0, p = line; i < 57; i++) + p = line; + for (int i = 0; i < 57; i++) { while (*p == '\t' || *p == ' ') p++; @@ -4615,7 +4633,7 @@ static int mob_readdb (void) mob_db[mob_class].amotion = atoi (str[27]); mob_db[mob_class].dmotion = atoi (str[28]); - for (i = 0; i < 8; i++) + for (int i = 0; i < 8; i++) { int rate = 0, type, ratemin, ratemax; mob_db[mob_class].dropitem[i].nameid = atoi (str[29 + i * 2]); @@ -4660,7 +4678,7 @@ static int mob_readdb (void) mob_db[mob_class].mexp = atoi (str[45]) * battle_config.mvp_exp_rate / 100; mob_db[mob_class].mexpper = atoi (str[46]); - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { mob_db[mob_class].mvpitem[i].nameid = atoi (str[47 + i * 2]); mob_db[mob_class].mvpitem[i].p = @@ -4670,7 +4688,7 @@ static int mob_readdb (void) mob_db[mob_class].mutations_nr = atoi (str[55]); mob_db[mob_class].mutation_power = atoi (str[56]); - for (i = 0; i < MAX_RANDOMMONSTER; i++) + for (int i = 0; i < MAX_RANDOMMONSTER; i++) mob_db[mob_class].summonper[i] = 0; mob_db[mob_class].maxskill = 0; @@ -4688,7 +4706,7 @@ static int mob_readdb (void) mob_db[mob_class].base_exp = mob_gen_exp (&mob_db[mob_class]); } fclose_ (fp); - printf ("read %s done\n", filename[i]); + printf ("read %s done\n", filename[j]); } return 0; } @@ -4936,7 +4954,7 @@ static int mob_readskilldb (void) "around", MST_AROUND},}; int x; - char *filename[] = { "db/mob_skill_db.txt", "db/mob_skill_db2.txt" }; + const char *filename[] = { "db/mob_skill_db.txt", "db/mob_skill_db2.txt" }; for (x = 0; x < 2; x++) { diff --git a/src/map/mob.hpp b/src/map/mob.hpp index 6161bab..19addf2 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -95,14 +95,14 @@ enum int mobdb_searchname (const char *str); int mobdb_checkid (const int id); -int mob_once_spawn (struct map_session_data *sd, char *mapname, +int mob_once_spawn (struct map_session_data *sd, const char *mapname, int x, int y, const char *mobname, int class_, int amount, const char *event); -int mob_once_spawn_area (struct map_session_data *sd, char *mapname, int x0, +int mob_once_spawn_area (struct map_session_data *sd, const char *mapname, int x0, int y0, int x1, int y1, const char *mobname, int class_, int amount, const char *event); -int mob_spawn_guardian (struct map_session_data *sd, char *mapname, // Spawning Guardians [Valaris] +int mob_spawn_guardian (struct map_session_data *sd, const char *mapname, // Spawning Guardians [Valaris] int x, int y, const char *mobname, int class_, int amount, const char *event, int guardian); // Spawning Guardians [Valaris] int mob_walktoxy (struct mob_data *md, int x, int y, int easy); diff --git a/src/map/npc.cpp b/src/map/npc.cpp index b2612f0..c25f585 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -58,6 +58,7 @@ static struct tm ev_tm_b; // 時計イベント用 * npc_enable_sub 有効時にOnTouchイベントを実行 *------------------------------------------ */ +static int npc_enable_sub (struct block_list *bl, va_list ap) { struct map_session_data *sd; @@ -248,6 +249,7 @@ int npc_timer(int tid,unsigned int tick,int id,int data) // Added by RoVeRT * npc_parse_script->strdb_foreachから呼ばれる *------------------------------------------ */ +static int npc_event_export (void *key, void *data, va_list ap) { char *lname = (char *) key; @@ -287,6 +289,7 @@ int npc_event_export (void *key, void *data, va_list ap) * 全てのNPCのOn*イベント実行 *------------------------------------------ */ +static void npc_event_doall_sub (db_key_t key, db_val_t data, va_list ap) { const char *p = key.s; @@ -324,6 +327,7 @@ int npc_event_doall_l (const char *name, int rid, int argc, argrec_t * args) return c; } +static void npc_event_do_sub (db_key_t key, db_val_t data, va_list ap) { const char *p = key.s; @@ -367,6 +371,7 @@ int npc_event_do_l (const char *name, int rid, int argc, argrec_t * args) * 時計イベント実行 *------------------------------------------ */ +static void npc_event_do_clock (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { time_t timer; @@ -415,6 +420,7 @@ int npc_event_do_oninit (void) * OnTimer NPC event - by RoVeRT *------------------------------------------ */ +static int npc_addeventtimer (struct npc_data *nd, int tick, const char *name) { int i; @@ -436,6 +442,7 @@ int npc_addeventtimer (struct npc_data *nd, int tick, const char *name) return 0; } +static int npc_deleventtimer (struct npc_data *nd, const char *name) { int i; @@ -453,6 +460,7 @@ int npc_deleventtimer (struct npc_data *nd, const char *name) return 0; } +static int npc_cleareventtimer (struct npc_data *nd) { int i; @@ -466,6 +474,7 @@ int npc_cleareventtimer (struct npc_data *nd) return 0; } +static void npc_do_ontimer_sub (db_key_t key, db_val_t data, va_list ap) { const char *p = key.s; @@ -497,9 +506,9 @@ void npc_do_ontimer_sub (db_key_t key, db_val_t data, va_list ap) } } -int npc_do_ontimer (int npc_id, struct map_session_data *sd, int option) +int npc_do_ontimer (int id, struct map_session_data *sd, int option) { - strdb_foreach (ev_db, npc_do_ontimer_sub, &npc_id, sd, option); + strdb_foreach (ev_db, npc_do_ontimer_sub, &id, sd, option); return 0; } @@ -508,6 +517,7 @@ int npc_do_ontimer (int npc_id, struct map_session_data *sd, int option) * npc_parse_script->strdb_foreachから呼ばれる *------------------------------------------ */ +static int npc_timerevent_import (void *key, void *data, va_list ap) { char *lname = (char *) key; @@ -519,7 +529,8 @@ int npc_timerevent_import (void *key, void *data, va_list ap) { // タイマーイベント struct npc_timerevent_list *te = nd->u.scr.timer_event; - int j, i = nd->u.scr.timeramount; + int j; + i = nd->u.scr.timeramount; RECREATE (te, struct npc_timerevent_list, i+1); for (j = 0; j < i; j++) { @@ -542,6 +553,7 @@ int npc_timerevent_import (void *key, void *data, va_list ap) * タイマーイベント実行 *------------------------------------------ */ +static void npc_timerevent (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { int next, t; @@ -744,6 +756,7 @@ int npc_event (struct map_session_data *sd, const char *eventname, return 0; } +static void npc_command_sub (db_key_t key, db_val_t data, va_list ap) { const char *p = key.s; @@ -762,7 +775,7 @@ void npc_command_sub (db_key_t key, db_val_t data, va_list ap) } } -int npc_command (struct map_session_data *sd, char *npcname, char *command) +int npc_command (struct map_session_data *sd, const char *npcname, const char *command) { strdb_foreach (ev_db, npc_command_sub, npcname, command); @@ -1184,6 +1197,7 @@ int npc_selllist (struct map_session_data *sd, int n, * 読み込むnpcファイルのクリア *------------------------------------------ */ +static void npc_clearsrcfile (void) { struct npc_src_list *p = npc_src_first; @@ -1256,7 +1270,7 @@ void npc_delsrcfile (char *name) * warp行解析 *------------------------------------------ */ -int npc_parse_warp (char *w1, char *w2, char *w3, char *w4) +int npc_parse_warp (const char *w1, const char *w2, const char *w3, const char *w4) { int x, y, xs, ys, to_x, to_y, m; int i, j; @@ -1431,6 +1445,7 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4) * NPCのラベルデータコンバート *------------------------------------------ */ +static void npc_convertlabel_db (db_key_t key, db_val_t data, va_list ap) { const char *lname = key.s; @@ -1438,7 +1453,8 @@ void npc_convertlabel_db (db_key_t key, db_val_t data, va_list ap) struct npc_data *nd; struct npc_label_list *lst; int num; - char *p = strchr (lname, ':'); + // this exists for evil purposes + char *p = const_cast<char *>(strchr (lname, ':')); nullpo_retv (ap); nullpo_retv (nd = va_arg (ap, struct npc_data *)); @@ -1456,6 +1472,7 @@ void npc_convertlabel_db (db_key_t key, db_val_t data, va_list ap) realloc (lst, sizeof (struct npc_label_list) * (num + 1)); *p = '\0'; + // temporarily NUL-terminate lname strncpy (lst[num].name, lname, sizeof(lst[num].name)-1); lst[num].name[sizeof(lst[num].name)-1] = '\0'; *p = ':'; @@ -1468,16 +1485,17 @@ void npc_convertlabel_db (db_key_t key, db_val_t data, va_list ap) * script行解析 *------------------------------------------ */ -static int npc_parse_script (char *w1, char *w2, char *w3, char *w4, - char *first_line, FILE * fp, int *lines) +static +int npc_parse_script (char *w1, char *w2, char *w3, char *w4, + const char *first_line, FILE * fp, int *lines) { int x, y, dir = 0, m, xs = 0, ys = 0, npc_class = 0; // [Valaris] thanks to fov char mapname[24]; - unsigned char *srcbuf = NULL, *script; + char *srcbuf = NULL; + const ScriptCode *script = NULL; int srcsize = 65536; int startline = 0; - unsigned char line[1024]; - int i; + char line[1024]; struct npc_data *nd; int evflag = 0; struct dbt *label_db; @@ -1517,6 +1535,7 @@ static int npc_parse_script (char *w1, char *w2, char *w3, char *w4, srcbuf[0] = 0; while (1) { + int i; for (i = strlen (srcbuf) - 1; i >= 0 && isspace (srcbuf[i]); i--); if (i >= 0 && srcbuf[i] == '}') break; @@ -1705,7 +1724,7 @@ static int npc_parse_script (char *w1, char *w2, char *w3, char *w4, //----------------------------------------- // イベント用ラベルデータのエクスポート - for (i = 0; i < nd->u.scr.label_list_num; i++) + for (int i = 0; i < nd->u.scr.label_list_num; i++) { char *lname = nd->u.scr.label_list[i].name; int pos = nd->u.scr.label_list[i].pos; @@ -1736,12 +1755,12 @@ static int npc_parse_script (char *w1, char *w2, char *w3, char *w4, //----------------------------------------- // ラベルデータからタイマーイベント取り込み - for (i = 0; i < nd->u.scr.label_list_num; i++) + for (int i = 0; i < nd->u.scr.label_list_num; i++) { - int t = 0, k = 0; + int t = 0, n = 0; char *lname = nd->u.scr.label_list[i].name; int pos = nd->u.scr.label_list[i].pos; - if (sscanf (lname, "OnTimer%d%n", &t, &k) == 1 && lname[k] == '\0') + if (sscanf (lname, "OnTimer%d%n", &t, &n) == 1 && lname[n] == '\0') { // タイマーイベント struct npc_timerevent_list *te = nd->u.scr.timer_event; @@ -1783,7 +1802,8 @@ static int npc_parse_script (char *w1, char *w2, char *w3, char *w4, static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *first_line, FILE * fp, int *lines) { - char *srcbuf = NULL, *script; + char *srcbuf = NULL; + const ScriptCode *script; int srcsize = 65536; int startline = 0; char line[1024]; @@ -1854,7 +1874,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, * mob行解析 *------------------------------------------ */ -int npc_parse_mob (char *w1, char *w2, char *w3, char *w4) +int npc_parse_mob (const char *w1, const char *w2, const char *w3, const char *w4) { int m, x, y, xs, ys, mob_class, num, delay1, delay2; int i; @@ -2125,7 +2145,7 @@ static void ev_db_final (db_key_t key, db_val_t data, va_list ap) } struct npc_data *npc_spawn_text (int m, int x, int y, - int npc_class, char *name, char *message) + int npc_class, const char *name, const char *message) { struct npc_data *retval = (struct npc_data *) calloc (1, sizeof (struct npc_data)); @@ -2171,7 +2191,7 @@ static void npc_free_internal (struct npc_data *nd) { if (nd->u.scr.script) { - free (nd->u.scr.script); + free (const_cast<ScriptCode *>(nd->u.scr.script)); nd->u.scr.script = NULL; } if (nd->u.scr.label_list) @@ -2188,6 +2208,7 @@ static void npc_free_internal (struct npc_data *nd) free (nd); } +static void npc_propagate_update (struct npc_data *nd) { map_foreachinarea (npc_enable_sub, @@ -2244,6 +2265,7 @@ int do_final_npc (void) return 0; } +static void ev_release (db_key_t key, db_val_t val) { free ((char*)key.s); diff --git a/src/map/npc.hpp b/src/map/npc.hpp index 6bb9370..6204316 100644 --- a/src/map/npc.hpp +++ b/src/map/npc.hpp @@ -12,7 +12,7 @@ int npc_event_dequeue (struct map_session_data *sd); void npc_event_timer (timer_id, tick_t, custom_id_t, custom_data_t); int npc_event (struct map_session_data *sd, const char *npcname, int); int npc_timer_event (const char *eventname); // Added by RoVeRT -int npc_command (struct map_session_data *sd, char *npcname, char *command); +int npc_command (struct map_session_data *sd, const char *npcname, const char *command); int npc_touch_areanpc (struct map_session_data *, int, int, int); int npc_click (struct map_session_data *, int); int npc_scriptcont (struct map_session_data *, int); @@ -20,8 +20,8 @@ int npc_checknear (struct map_session_data *, int); int npc_buysellsel (struct map_session_data *, int, int); int npc_buylist (struct map_session_data *, int, unsigned short *); int npc_selllist (struct map_session_data *, int, unsigned short *); -int npc_parse_mob (char *w1, char *w2, char *w3, char *w4); -int npc_parse_warp (char *w1, char *w2, char *w3, char *w4); +int npc_parse_mob (const char *w1, const char *w2, const char *w3, const char *w4); +int npc_parse_warp (const char *w1, const char *w2, const char *w3, const char *w4); int npc_enable (const char *name, int flag); struct npc_data *npc_name2id (const char *name); @@ -33,7 +33,7 @@ int npc_get_new_npc_id (void); * * \param message The message to speak. If message is NULL, the NPC will not do anything at all. */ -struct npc_data *npc_spawn_text (int m, int x, int y, int class_, char *name, char *message); // message is strdup'd within +struct npc_data *npc_spawn_text (int m, int x, int y, int class_, const char *name, const char *message); // message is strdup'd within /** * Uninstalls and frees an NPC diff --git a/src/map/party.cpp b/src/map/party.cpp index 1c4088a..95763b8 100644 --- a/src/map/party.cpp +++ b/src/map/party.cpp @@ -55,18 +55,19 @@ struct party *party_search (int party_id) return (struct party *)numdb_search (party_db, party_id); } +static void party_searchname_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 *); + const char *str; + str = va_arg (ap, const char *); dst = va_arg (ap, struct party **); if (strcasecmp (p->name, str) == 0) *dst = p; } // パーティ名検索 -struct party *party_searchname (char *str) +struct party *party_searchname (const char *str) { struct party *p = NULL; numdb_foreach (party_db, party_searchname_sub, str, &p); @@ -74,7 +75,7 @@ struct party *party_searchname (char *str) } /* Process a party creation request. */ -int party_create (struct map_session_data *sd, char *name) +int party_create (struct map_session_data *sd, const char *name) { char pname[24]; nullpo_retr (0, sd); @@ -97,7 +98,7 @@ int party_create (struct map_session_data *sd, char *name) } /* Relay the result of a party creation request. */ -int party_created (int account_id, int fail, int party_id, char *name) +int party_created (int account_id, int fail, int party_id, const char *name) { struct map_session_data *sd; sd = map_id2sd (account_id); @@ -138,6 +139,7 @@ int party_request_info (int party_id) } // 所属キャラの確認 +static int party_check_member (struct party *p) { int i; @@ -382,7 +384,7 @@ int party_member_added (int party_id, int account_id, int flag) // パーティ除名要求 int party_removemember (struct map_session_data *sd, int account_id, - char *name) + const char *name) { struct party *p; int i; @@ -433,7 +435,7 @@ int party_leave (struct map_session_data *sd) } // パーティメンバが脱退した -int party_member_leaved (int party_id, int account_id, char *name) +int party_member_leaved (int party_id, int account_id, const char *name) { struct map_session_data *sd = map_id2sd (account_id); struct party *p = party_search (party_id); @@ -512,7 +514,7 @@ int party_optionchanged (int party_id, int account_id, int exp, int item, } // パーティメンバの移動通知 -int party_recv_movemap (int party_id, int account_id, char *map, int online, +int party_recv_movemap (int party_id, int account_id, const char *map, int online, int lv) { struct party *p; @@ -611,7 +613,7 @@ int party_send_logout (struct map_session_data *sd) } // パーティメッセージ送信 -int party_send_message (struct map_session_data *sd, char *mes, int len) +int party_send_message (struct map_session_data *sd, const char *mes, int len) { if (sd->status.party_id == 0) return 0; @@ -621,7 +623,7 @@ int party_send_message (struct map_session_data *sd, char *mes, int len) } // パーティメッセージ受信 -int party_recv_message (int party_id, int account_id, char *mes, int len) +int party_recv_message (int party_id, int account_id, const char *mes, int len) { struct party *p; if ((p = party_search (party_id)) == NULL) @@ -641,6 +643,7 @@ int party_check_conflict (struct map_session_data *sd) } // 位置やHP通知用 +static void party_send_xyhp_timer_sub (db_key_t key, db_val_t data, va_list ap) { struct party *p = (struct party *) data; diff --git a/src/map/party.hpp b/src/map/party.hpp index e40609a..b4d462e 100644 --- a/src/map/party.hpp +++ b/src/map/party.hpp @@ -11,22 +11,22 @@ struct block_list; void do_init_party (void); void do_final_party (void); struct party *party_search (int party_id); -struct party *party_searchname (char *str); +struct party *party_searchname (const char *str); -int party_create (struct map_session_data *sd, char *name); -int party_created (int account_id, int fail, int party_id, char *name); +int party_create (struct map_session_data *sd, const char *name); +int party_created (int account_id, int fail, int party_id, const char *name); int party_request_info (int party_id); int party_invite (struct map_session_data *sd, int account_id); int party_member_added (int party_id, int account_id, int flag); int party_leave (struct map_session_data *sd); int party_removemember (struct map_session_data *sd, int account_id, - char *name); -int party_member_leaved (int party_id, int account_id, char *name); + const char *name); +int party_member_leaved (int party_id, int account_id, const char *name); int party_reply_invite (struct map_session_data *sd, int account_id, int flag); int party_recv_noinfo (int party_id); int party_recv_info (struct party *sp); -int party_recv_movemap (int party_id, int account_id, char *map, int online, +int party_recv_movemap (int party_id, int account_id, const char *map, int online, int lv); int party_broken (int party_id); int party_optionchanged (int party_id, int account_id, int exp, int item, @@ -36,8 +36,8 @@ int party_changeoption (struct map_session_data *sd, int exp, int item); int party_send_movemap (struct map_session_data *sd); int party_send_logout (struct map_session_data *sd); -int party_send_message (struct map_session_data *sd, char *mes, int len); -int party_recv_message (int party_id, int account_id, char *mes, int len); +int party_send_message (struct map_session_data *sd, const char *mes, int len); +int party_recv_message (int party_id, int account_id, const char *mes, int len); int party_check_conflict (struct map_session_data *sd); diff --git a/src/map/pc.cpp b/src/map/pc.cpp index 7d02545..256244a 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -64,6 +64,9 @@ pc_readglobalreg(sd, "MAGIC_EXPERIENCE") & 0xffff, \ (pc_readglobalreg(sd, "MAGIC_EXPERIENCE") >> 24) & 0xff) +timer_id day_timer_tid; +timer_id night_timer_tid; + static int max_weight_base[MAX_PC_CLASS]; static int hp_coefficient[MAX_PC_CLASS]; static int hp_coefficient2[MAX_PC_CLASS]; @@ -526,6 +529,7 @@ int pc_equippoint (struct map_session_data *sd, int n) return ep; } +static int pc_setinventorydata (struct map_session_data *sd) { int i, id; @@ -540,6 +544,7 @@ int pc_setinventorydata (struct map_session_data *sd) return 0; } +static int pc_calcweapontype (struct map_session_data *sd) { nullpo_retr (0, sd); @@ -566,6 +571,7 @@ int pc_calcweapontype (struct map_session_data *sd) return 0; } +static int pc_setequipindex (struct map_session_data *sd) { int i, j; @@ -758,7 +764,6 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, struct party *p; struct guild *g; - int i; unsigned long tick = gettick (); struct sockaddr_in sai; socklen_t sa_len = sizeof(struct sockaddr); @@ -827,13 +832,13 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, sd->doridori_counter = 0; sd->spiritball = 0; - for (i = 0; i < MAX_SKILL_LEVEL; i++) + for (int i = 0; i < MAX_SKILL_LEVEL; i++) sd->spirit_timer[i] = -1; - for (i = 0; i < MAX_SKILLTIMERSKILL; i++) + for (int i = 0; i < MAX_SKILLTIMERSKILL; i++) sd->skilltimerskill[i].timer = -1; memset (&sd->dev, 0, sizeof (struct square)); - for (i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) { sd->dev.val1[i] = 0; sd->dev.val2[i] = 0; @@ -847,7 +852,7 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, pc_checkitem (sd); // ステータス異常の初期化 - for (i = 0; i < MAX_STATUSCHANGE; i++) + for (int i = 0; i < MAX_STATUSCHANGE; i++) { sd->sc_data[i].timer = -1; sd->sc_data[i].val1 = sd->sc_data[i].val2 = sd->sc_data[i].val3 = @@ -881,7 +886,7 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, // イベント関係の初期化 memset (sd->eventqueue, 0, sizeof (sd->eventqueue)); - for (i = 0; i < MAX_EVENTTIMER; i++) + for (int i = 0; i < MAX_EVENTTIMER; i++) sd->eventtimer[i] = -1; // 位置の設定 @@ -914,7 +919,7 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, if (night_flag == 1) { char tmpstr[1024]; - strcpy (tmpstr, msg_txt (500)); // Actually, it's the night... + strcpy (tmpstr, "Actually, it's the night..."); clif_wis_message (sd->fd, wisp_server_name, tmpstr, strlen (tmpstr) + 1); sd->opt2 |= STATE_BLIND; @@ -942,8 +947,7 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, { while (fgets (buf, sizeof (buf) - 1, fp) != NULL) { - int i; - for (i = 0; buf[i]; i++) + for (int i = 0; buf[i]; i++) { if (buf[i] == '\r' || buf[i] == '\n') { @@ -969,13 +973,13 @@ int pc_authok (int id, int login_id2, time_t connect_until_time, // Obtain IP address (if they are still connected) if (!getpeername(sd->fd, (struct sockaddr *)&sai, &sa_len)) - sd->ip = sai.sin_addr.s_addr; + sd->ip = sai.sin_addr; // message of the limited time of the account if (connect_until_time != 0) { // don't display if it's unlimited or unknow value char tmpstr[1024]; - strftime (tmpstr, sizeof (tmpstr) - 1, msg_txt (501), gmtime (&connect_until_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S." + strftime (tmpstr, sizeof (tmpstr) - 1, "Your account time limit is: %d-%m-%Y %H:%M:%S.", gmtime (&connect_until_time)); clif_wis_message (sd->fd, wisp_server_name, tmpstr, strlen (tmpstr) + 1); } @@ -1020,6 +1024,7 @@ static int pc_calc_skillpoint (struct map_session_data *sd) * 覚えられるスキルの計算 *------------------------------------------ */ +static int pc_calc_skilltree (struct map_session_data *sd) { int i, id = 0, flag; @@ -1228,6 +1233,7 @@ int pc_checkweighticon (struct map_session_data *sd) return 0; } +static void pc_set_weapon_look (struct map_session_data *sd) { if (sd->attack_spell_override) @@ -3652,6 +3658,7 @@ int pc_takeitem (struct map_session_data *sd, struct flooritem_data *fitem) return 0; } +static int pc_isUseitem (struct map_session_data *sd, int n) { struct item_data *item; @@ -3915,6 +3922,7 @@ int pc_item_identify (struct map_session_data *sd, int idx) * スティル品公開 *------------------------------------------ */ +static int pc_show_steal (struct block_list *bl, va_list ap) { struct map_session_data *sd; @@ -4058,7 +4066,7 @@ int pc_steal_coin (struct map_session_data *sd, struct block_list *bl) * PCの位置設定 *------------------------------------------ */ -int pc_setpos (struct map_session_data *sd, char *mapname_org, int x, int y, +int pc_setpos (struct map_session_data *sd, const char *mapname_org, int x, int y, int clrtype) { char mapname[24]; @@ -4124,7 +4132,8 @@ int pc_setpos (struct map_session_data *sd, char *mapname_org, int x, int y, { if (sd->mapname[0]) { - int ip, port; + struct in_addr ip; + int port; if (map_mapname2ipport (mapname, &ip, &port) == 0) { skill_stop_dancing (&sd->bl, 1); @@ -4803,6 +4812,7 @@ struct pc_base_job pc_calc_base_job (int b_class) * PCの攻撃 (timer関数) *------------------------------------------ */ +static void pc_attack_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct map_session_data *sd; @@ -5008,6 +5018,7 @@ int pc_stopattack (struct map_session_data *sd) return 0; } +static void pc_follow_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct map_session_data *sd, *bl; @@ -5133,6 +5144,7 @@ int pc_checkbaselevelup (struct map_session_data *sd) * Compute the maximum for sd->skill_point, i.e., the max. number of skill points that can still be filled in *---------------------------------------- */ +static int pc_skillpt_potential (struct map_session_data *sd) { int skill_id; @@ -6928,7 +6940,7 @@ char *pc_readregstr (struct map_session_data *sd, int reg) * script用文字列変数の値を設定 *------------------------------------------ */ -int pc_setregstr (struct map_session_data *sd, int reg, char *str) +int pc_setregstr (struct map_session_data *sd, int reg, const char *str) { int i; @@ -6958,7 +6970,7 @@ int pc_setregstr (struct map_session_data *sd, int reg, char *str) * script用グローバル変数の値を読む *------------------------------------------ */ -int pc_readglobalreg (struct map_session_data *sd, char *reg) +int pc_readglobalreg (struct map_session_data *sd, const char *reg) { int i; @@ -6977,7 +6989,7 @@ int pc_readglobalreg (struct map_session_data *sd, char *reg) * script用グローバル変数の値を設定 *------------------------------------------ */ -int pc_setglobalreg (struct map_session_data *sd, char *reg, int val) +int pc_setglobalreg (struct map_session_data *sd, const char *reg, int val) { int i; @@ -7029,7 +7041,7 @@ int pc_setglobalreg (struct map_session_data *sd, char *reg, int val) * script用アカウント変数の値を読む *------------------------------------------ */ -int pc_readaccountreg (struct map_session_data *sd, char *reg) +int pc_readaccountreg (struct map_session_data *sd, const char *reg) { int i; @@ -7048,7 +7060,7 @@ int pc_readaccountreg (struct map_session_data *sd, char *reg) * script用アカウント変数の値を設定 *------------------------------------------ */ -int pc_setaccountreg (struct map_session_data *sd, char *reg, int val) +int pc_setaccountreg (struct map_session_data *sd, const char *reg, int val) { int i; @@ -7097,7 +7109,7 @@ int pc_setaccountreg (struct map_session_data *sd, char *reg, int val) * script用アカウント変数2の値を読む *------------------------------------------ */ -int pc_readaccountreg2 (struct map_session_data *sd, char *reg) +int pc_readaccountreg2 (struct map_session_data *sd, const char *reg) { int i; @@ -7116,7 +7128,7 @@ int pc_readaccountreg2 (struct map_session_data *sd, char *reg) * script用アカウント変数2の値を設定 *------------------------------------------ */ -int pc_setaccountreg2 (struct map_session_data *sd, char *reg, int val) +int pc_setaccountreg2 (struct map_session_data *sd, const char *reg, int val) { int i; @@ -7192,6 +7204,7 @@ int pc_percentrefinery (struct map_session_data *sd, struct item *item) * イベントタイマー処理 *------------------------------------------ */ +static void pc_eventtimer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct map_session_data *sd = map_id2sd (id); @@ -7746,6 +7759,7 @@ int pc_checkoversp (struct map_session_data *sd) * PVP順位計算用(foreachinarea) *------------------------------------------ */ +static int pc_calc_pvprank_sub (struct block_list *bl, va_list ap) { struct map_session_data *sd1, *sd2 = NULL; @@ -8260,7 +8274,6 @@ static int pc_spirit_heal_sp (struct map_session_data *sd, int level) * HP/SP 自然回復 各クライアント *------------------------------------------ */ -static int pc_itemheal_effect (struct map_session_data *sd, int hp, int sp); static int pc_quickregenerate_effect (struct quick_regeneration *quick_regen, @@ -8363,6 +8376,7 @@ static int pc_natural_heal_sub (struct map_session_data *sd, va_list ap) * HP/SP自然回復 (interval timer関数) *------------------------------------------ */ +static void pc_natural_heal (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { natural_heal_tick = tick; @@ -8377,7 +8391,7 @@ void pc_natural_heal (timer_id tid, tick_t tick, custom_id_t id, custom_data_t d * セーブポイントの保存 *------------------------------------------ */ -int pc_setsavepoint (struct map_session_data *sd, char *mapname, int x, int y) +int pc_setsavepoint (struct map_session_data *sd, const char *mapname, int x, int y) { nullpo_retr (0, sd); @@ -8440,6 +8454,7 @@ static int pc_autosave_sub (struct map_session_data *sd, va_list ap) * 自動セーブ (timer関数) *------------------------------------------ */ +static void pc_autosave (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { int interval; @@ -8487,7 +8502,7 @@ void map_day_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t dat { // if we want a day if (night_flag != 0) { - strcpy (tmpstr, msg_txt (502)); // The day has arrived! + strcpy (tmpstr, "The day has arrived!"); night_flag = 0; // 0=day, 1=night [Yor] for (i = 0; i < fd_max; i++) { @@ -8518,7 +8533,7 @@ void map_night_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t d { // if we want a night if (night_flag == 0) { - strcpy (tmpstr, msg_txt (503)); // The night has fallen... + strcpy (tmpstr, "The night has fallen..."); night_flag = 1; // 0=day, 1=night [Yor] for (i = 0; i < fd_max; i++) { @@ -8559,6 +8574,7 @@ void pc_setstand (struct map_session_data *sd) * refine_db.txt 精錬データテーブル *------------------------------------------ */ +static int pc_readdb (void) { int i, j, k; diff --git a/src/map/pc.hpp b/src/map/pc.hpp index 7237957..cc433b8 100644 --- a/src/map/pc.hpp +++ b/src/map/pc.hpp @@ -56,8 +56,8 @@ int pc_can_reach (struct map_session_data *, int, int); int pc_walktoxy (struct map_session_data *, int, int); int pc_stop_walking (struct map_session_data *, int); int pc_movepos (struct map_session_data *, int, int); -int pc_setpos (struct map_session_data *, char *, int, int, int); -int pc_setsavepoint (struct map_session_data *, char *, int, int); +int pc_setpos (struct map_session_data *, const char *, int, int, int); +int pc_setsavepoint (struct map_session_data *, const char *, int, int); int pc_randomwarp (struct map_session_data *sd, int type); int pc_memo (struct map_session_data *sd, int i); @@ -132,7 +132,6 @@ int pc_resetskill (struct map_session_data *); int pc_equipitem (struct map_session_data *, int, int); int pc_unequipitem (struct map_session_data *, int, int); int pc_unequipinvyitem (struct map_session_data *, int, int); -int pc_checkitem (struct map_session_data *); int pc_useitem (struct map_session_data *, int); int pc_damage (struct block_list *, struct map_session_data *, int); @@ -152,13 +151,13 @@ int pc_setparam (struct map_session_data *, int, int); int pc_readreg (struct map_session_data *, int); int pc_setreg (struct map_session_data *, int, int); char *pc_readregstr (struct map_session_data *sd, int reg); -int pc_setregstr (struct map_session_data *sd, int reg, char *str); -int pc_readglobalreg (struct map_session_data *, char *); -int pc_setglobalreg (struct map_session_data *, char *, int); -int pc_readaccountreg (struct map_session_data *, char *); -int pc_setaccountreg (struct map_session_data *, char *, int); -int pc_readaccountreg2 (struct map_session_data *, char *); -int pc_setaccountreg2 (struct map_session_data *, char *, int); +int pc_setregstr (struct map_session_data *sd, int reg, const char *str); +int pc_readglobalreg (struct map_session_data *, const char *); +int pc_setglobalreg (struct map_session_data *, const char *, int); +int pc_readaccountreg (struct map_session_data *, const char *); +int pc_setaccountreg (struct map_session_data *, const char *, int); +int pc_readaccountreg2 (struct map_session_data *, const char *); +int pc_setaccountreg2 (struct map_session_data *, const char *, int); int pc_percentrefinery (struct map_session_data *sd, struct item *item); int pc_addeventtimer (struct map_session_data *sd, int tick, @@ -202,8 +201,8 @@ enum { ADDITEM_EXIST, ADDITEM_NEW, ADDITEM_OVERAMOUNT }; // timer for night.day -timer_id day_timer_tid; -timer_id night_timer_tid; +extern timer_id day_timer_tid; +extern timer_id night_timer_tid; void map_day_timer (timer_id, tick_t, custom_id_t, custom_data_t); // by [yor] void map_night_timer (timer_id, tick_t, custom_id_t, custom_data_t); // by [yor] diff --git a/src/map/script.cpp b/src/map/script.cpp index 9e851bb..b5b9618 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -15,6 +15,8 @@ #include <time.h> #include <math.h> +#include <cassert> + #include "../common/socket.hpp" #include "../common/timer.hpp" #include "../common/lock.hpp" @@ -46,14 +48,14 @@ #define SCRIPT_BLOCK_SIZE 256 enum { LABEL_NEXTLINE = 1, LABEL_START }; -static unsigned char *script_buf; +static ScriptCode *script_buf; static int script_pos, script_size; char *str_buf; int str_pos, str_size; static struct str_data_t { - int type; + ScriptCode type; int str; int backpatch; int label; @@ -106,7 +108,7 @@ static int parse_cmd; * ローカルプロトタイプ宣言 (必要な物のみ) *------------------------------------------ */ -unsigned char *parse_subexpr (unsigned char *, int); +const char *parse_subexpr (const char *, int); int buildin_mes (struct script_state *st); int buildin_goto (struct script_state *st); int buildin_callsub (struct script_state *st); @@ -277,13 +279,10 @@ int buildin_get_unactivated_pool_skills (struct script_state *st); // [PO] int buildin_activate_pool_skill (struct script_state *st); // [fate] int buildin_deactivate_pool_skill (struct script_state *st); // [fate] int buildin_check_pool_skill (struct script_state *st); // [fate] -int buildin_getskilllist (struct script_state *st); -int buildin_getskilllist (struct script_state *st); int buildin_clearitem (struct script_state *st); int buildin_classchange (struct script_state *st); int buildin_misceffect (struct script_state *st); int buildin_soundeffect (struct script_state *st); -int buildin_setcastledata (struct script_state *st); int buildin_mapwarp (struct script_state *st); int buildin_inittimer (struct script_state *st); int buildin_stoptimer (struct script_state *st); @@ -324,8 +323,8 @@ int mapreg_setregstr (int num, const char *str); struct { int (*func) (struct script_state *); - char *name; - char *arg; + const char *name; + const char *arg; } buildin_func[] = { { @@ -743,24 +742,27 @@ struct { NULL, NULL, NULL},}; -int buildin_message (struct script_state *st); // [MouseJstr] - -enum +#ifdef RECENT_GCC +enum class ScriptCode : uint8_t { - C_NOP, C_POS, C_INT, C_PARAM, C_FUNC, C_STR, C_CONSTSTR, C_ARG, - C_NAME, C_EOL, C_RETINFO, + // tyoes and specials + NOP, POS, INT, PARAM, FUNC, STR, CONSTSTR, ARG, + NAME, EOL, RETINFO, - C_LOR, C_LAND, C_LE, C_LT, C_GE, C_GT, C_EQ, C_NE, //operator - C_XOR, C_OR, C_AND, C_ADD, C_SUB, C_MUL, C_DIV, C_MOD, C_NEG, C_LNOT, - C_NOT, C_R_SHIFT, C_L_SHIFT + // unary and binary operators + LOR, LAND, LE, LT, GE, GT, EQ, NE, + XOR, OR, AND, ADD, SUB, MUL, DIV, MOD, NEG, LNOT, + NOT, R_SHIFT, L_SHIFT }; +#endif /*========================================== * 文字列のハッシュを計算 *------------------------------------------ */ -static int calc_hash (const unsigned char *p) +static int calc_hash (const char *s) { + const unsigned char *p = (const unsigned char *)s; int h = 0; while (*p) { @@ -775,7 +777,7 @@ static int calc_hash (const unsigned char *p) *------------------------------------------ */ // 既存のであれば番号、無ければ-1 -static int search_str (const unsigned char *p) +static int search_str (const char *p) { int i; i = str_hash[calc_hash (p)]; @@ -795,7 +797,7 @@ static int search_str (const unsigned char *p) *------------------------------------------ */ // 既存のであれば番号、無ければ登録して新規番号 -static int add_str (const unsigned char *p) +static int add_str (const char *p) { int i; char *lowcase; @@ -843,7 +845,7 @@ static int add_str (const unsigned char *p) memset (str_buf + (str_size - 256), '\0', 256); } strcpy (str_buf + str_pos, p); - str_data[str_num].type = C_NOP; + str_data[str_num].type = ScriptCode::NOP; str_data[str_num].str = str_pos; str_data[str_num].next = 0; str_data[str_num].func = NULL; @@ -862,7 +864,7 @@ static void check_script_buf (int size) if (script_pos + size >= script_size) { script_size += SCRIPT_BLOCK_SIZE; - script_buf = (char *) realloc (script_buf, script_size); + script_buf = (ScriptCode *) realloc (script_buf, script_size); memset (script_buf + script_size - SCRIPT_BLOCK_SIZE, '\0', SCRIPT_BLOCK_SIZE); } @@ -872,7 +874,8 @@ static void check_script_buf (int size) * スクリプトバッファに1バイト書き込む *------------------------------------------ */ -static void add_scriptb (int a) +static +void add_scriptc (ScriptCode a) { check_script_buf (1); script_buf[script_pos++] = a; @@ -882,14 +885,10 @@ static void add_scriptb (int a) * スクリプトバッファにデータタイプを書き込む *------------------------------------------ */ -static void add_scriptc (int a) +static +void add_scriptb (uint8_t a) { - while (a >= 0x40) - { - add_scriptb ((a & 0x3f) | 0x40); - a = (a - 0x40) >> 6; - } - add_scriptb (a & 0x3f); + add_scriptc(static_cast<ScriptCode>(a)); } /*========================================== @@ -917,29 +916,29 @@ static void add_scriptl (int l) switch (str_data[l].type) { - case C_POS: - add_scriptc (C_POS); - add_scriptb (str_data[l].label); - add_scriptb (str_data[l].label >> 8); - add_scriptb (str_data[l].label >> 16); + case ScriptCode::POS: + add_scriptc (ScriptCode::POS); + add_scriptb ({uint8_t(str_data[l].label)}); + add_scriptb ({uint8_t(str_data[l].label >> 8)}); + add_scriptb ({uint8_t(str_data[l].label >> 16)}); break; - case C_NOP: + case ScriptCode::NOP: // ラベルの可能性があるのでbackpatch用データ埋め込み - add_scriptc (C_NAME); + add_scriptc (ScriptCode::NAME); str_data[l].backpatch = script_pos; - add_scriptb (backpatch); - add_scriptb (backpatch >> 8); - add_scriptb (backpatch >> 16); + add_scriptb ({uint8_t(backpatch)}); + add_scriptb ({uint8_t(backpatch >> 8)}); + add_scriptb ({uint8_t(backpatch >> 16)}); break; - case C_INT: + case ScriptCode::INT: add_scripti (str_data[l].val); break; default: // もう他の用途と確定してるので数字をそのまま - add_scriptc (C_NAME); - add_scriptb (l); - add_scriptb (l >> 8); - add_scriptb (l >> 16); + add_scriptc (ScriptCode::NAME); + add_scriptb ({uint8_t(l)}); + add_scriptb ({uint8_t(l >> 8)}); + add_scriptb ({uint8_t(l >> 16)}); break; } } @@ -948,19 +947,20 @@ static void add_scriptl (int l) * ラベルを解決する *------------------------------------------ */ -void set_label (int l, int pos) +static +void set_label (int l, int pos_) { int i, next; - str_data[l].type = C_POS; - str_data[l].label = pos; + str_data[l].type = ScriptCode::POS; + str_data[l].label = pos_; for (i = str_data[l].backpatch; i >= 0 && i != 0x00ffffff;) { next = (*(int *) (script_buf + i)) & 0x00ffffff; - script_buf[i - 1] = C_POS; - script_buf[i] = pos; - script_buf[i + 1] = pos >> 8; - script_buf[i + 2] = pos >> 16; + script_buf[i - 1] = ScriptCode::POS; + script_buf[i] = static_cast<ScriptCode>(pos_); + script_buf[i + 1] = static_cast<ScriptCode>(pos_ >> 8); + script_buf[i + 2] = static_cast<ScriptCode>(pos_ >> 16); i = next; } } @@ -969,7 +969,7 @@ void set_label (int l, int pos) * スペース/コメント読み飛ばし *------------------------------------------ */ -static unsigned char *skip_space (unsigned char *p) +static const char *skip_space (const char *p) { while (1) { @@ -998,7 +998,8 @@ static unsigned char *skip_space (unsigned char *p) * 1単語スキップ *------------------------------------------ */ -static unsigned char *skip_word (unsigned char *p) +static +const char *skip_word (const char *p) { // prefix if (*p == '$') @@ -1012,13 +1013,8 @@ static unsigned char *skip_word (unsigned char *p) if (*p == 'l') p++; // 一時的変数用(like weiss) - while (isalnum (*p) || *p == '_' || *p >= 0x81) - if (*p >= 0x81 && p[1]) - { - p += 2; - } - else - p++; + while (isalnum (*p) || *p == '_') + p++; // postfix if (*p == '$') @@ -1027,35 +1023,36 @@ static unsigned char *skip_word (unsigned char *p) return p; } -static unsigned char *startptr; +static const char *startptr; static int startline; /*========================================== * エラーメッセージ出力 *------------------------------------------ */ -static void disp_error_message (const char *mes, const unsigned char *pos) +static void disp_error_message (const char *mes, const char *pos_) { - int line, c = 0, i; - unsigned char *p, *linestart, *lineend; + int line; + const char *p; for (line = startline, p = startptr; p && *p; line++) { - linestart = p; - lineend = strchr (p, '\n'); + const char *linestart = p; + char *lineend = const_cast<char *>(strchr (p, '\n')); + char c; if (lineend) { c = *lineend; *lineend = 0; } - if (lineend == NULL || pos < lineend) + if (lineend == NULL || pos_ < lineend) { printf ("%s line %d : ", mes, line); - for (i = 0; + for (int i = 0; (linestart[i] != '\r') && (linestart[i] != '\n') && linestart[i]; i++) { - if (linestart + i != pos) + if (linestart + i != pos_) printf ("%c", linestart[i]); else printf ("\'%c\'", linestart[i]); @@ -1074,7 +1071,8 @@ static void disp_error_message (const char *mes, const unsigned char *pos) * 項の解析 *------------------------------------------ */ -unsigned char *parse_simpleexpr (unsigned char *p) +static +const char *parse_simpleexpr (const char *p) { int i; p = skip_space (p); @@ -1108,7 +1106,7 @@ unsigned char *parse_simpleexpr (unsigned char *p) } else if (*p == '"') { - add_scriptc (C_STR); + add_scriptc (ScriptCode::STR); p++; while (*p && *p != '"') { @@ -1131,16 +1129,15 @@ unsigned char *parse_simpleexpr (unsigned char *p) } else { - int c, l; - char *p2; + int l; // label , register , function etc if (skip_word (p) == p) { disp_error_message ("unexpected character", p); exit (1); } - p2 = skip_word (p); - c = *p2; + char *p2 = const_cast<char *>(skip_word(p)); + char c = *p2; *p2 = 0; // 名前をadd_strする l = add_str (p); @@ -1159,11 +1156,11 @@ unsigned char *parse_simpleexpr (unsigned char *p) *p2 = c; p = p2; - if (str_data[l].type != C_FUNC && c == '[') + if (str_data[l].type != ScriptCode::FUNC && c == '[') { // array(name[i] => getelementofarray(name,i) ) add_scriptl (search_str ("getelementofarray")); - add_scriptc (C_ARG); + add_scriptc (ScriptCode::ARG); add_scriptl (l); p = parse_subexpr (p + 1, -1); p = skip_space (p); @@ -1172,7 +1169,7 @@ unsigned char *parse_simpleexpr (unsigned char *p) disp_error_message ("unmatch ']'", p); exit (1); } - add_scriptc (C_FUNC); + add_scriptc (ScriptCode::FUNC); } else add_scriptl (l); @@ -1190,10 +1187,10 @@ unsigned char *parse_simpleexpr (unsigned char *p) * 式の解析 *------------------------------------------ */ -unsigned char *parse_subexpr (unsigned char *p, int limit) +const char *parse_subexpr (const char *p, int limit) { - int op, opl, len; - char *tmpp; + ScriptCode op; + int opl, len; #ifdef DEBUG_FUNCIN if (battle_config.etc_log) @@ -1203,7 +1200,7 @@ unsigned char *parse_subexpr (unsigned char *p, int limit) if (*p == '-') { - tmpp = skip_space (p + 1); + const char *tmpp = skip_space (p + 1); if (*tmpp == ';' || *tmpp == ',') { add_scriptl (LABEL_NEXTLINE); @@ -1211,9 +1208,9 @@ unsigned char *parse_subexpr (unsigned char *p, int limit) return p; } } - tmpp = p; - if ((op = C_NEG, *p == '-') || (op = C_LNOT, *p == '!') - || (op = C_NOT, *p == '~')) + const char *tmpp = p; + if ((op = ScriptCode::NEG, *p == '-') || (op = ScriptCode::LNOT, *p == '!') + || (op = ScriptCode::NOT, *p == '~')) { p = parse_subexpr (p + 1, 100); add_scriptc (op); @@ -1221,39 +1218,39 @@ unsigned char *parse_subexpr (unsigned char *p, int limit) else p = parse_simpleexpr (p); p = skip_space (p); - while (((op = C_ADD, opl = 6, len = 1, *p == '+') || - (op = C_SUB, opl = 6, len = 1, *p == '-') || - (op = C_MUL, opl = 7, len = 1, *p == '*') || - (op = C_DIV, opl = 7, len = 1, *p == '/') || - (op = C_MOD, opl = 7, len = 1, *p == '%') || - (op = C_FUNC, opl = 8, len = 1, *p == '(') || - (op = C_LAND, opl = 1, len = 2, *p == '&' && p[1] == '&') || - (op = C_AND, opl = 5, len = 1, *p == '&') || - (op = C_LOR, opl = 0, len = 2, *p == '|' && p[1] == '|') || - (op = C_OR, opl = 4, len = 1, *p == '|') || - (op = C_XOR, opl = 3, len = 1, *p == '^') || - (op = C_EQ, opl = 2, len = 2, *p == '=' && p[1] == '=') || - (op = C_NE, opl = 2, len = 2, *p == '!' && p[1] == '=') || - (op = C_R_SHIFT, opl = 5, len = 2, *p == '>' && p[1] == '>') || - (op = C_GE, opl = 2, len = 2, *p == '>' && p[1] == '=') || - (op = C_GT, opl = 2, len = 1, *p == '>') || - (op = C_L_SHIFT, opl = 5, len = 2, *p == '<' && p[1] == '<') || - (op = C_LE, opl = 2, len = 2, *p == '<' && p[1] == '=') || - (op = C_LT, opl = 2, len = 1, *p == '<')) && opl > limit) + while (((op = ScriptCode::ADD, opl = 6, len = 1, *p == '+') || + (op = ScriptCode::SUB, opl = 6, len = 1, *p == '-') || + (op = ScriptCode::MUL, opl = 7, len = 1, *p == '*') || + (op = ScriptCode::DIV, opl = 7, len = 1, *p == '/') || + (op = ScriptCode::MOD, opl = 7, len = 1, *p == '%') || + (op = ScriptCode::FUNC, opl = 8, len = 1, *p == '(') || + (op = ScriptCode::LAND, opl = 1, len = 2, *p == '&' && p[1] == '&') || + (op = ScriptCode::AND, opl = 5, len = 1, *p == '&') || + (op = ScriptCode::LOR, opl = 0, len = 2, *p == '|' && p[1] == '|') || + (op = ScriptCode::OR, opl = 4, len = 1, *p == '|') || + (op = ScriptCode::XOR, opl = 3, len = 1, *p == '^') || + (op = ScriptCode::EQ, opl = 2, len = 2, *p == '=' && p[1] == '=') || + (op = ScriptCode::NE, opl = 2, len = 2, *p == '!' && p[1] == '=') || + (op = ScriptCode::R_SHIFT, opl = 5, len = 2, *p == '>' && p[1] == '>') || + (op = ScriptCode::GE, opl = 2, len = 2, *p == '>' && p[1] == '=') || + (op = ScriptCode::GT, opl = 2, len = 1, *p == '>') || + (op = ScriptCode::L_SHIFT, opl = 5, len = 2, *p == '<' && p[1] == '<') || + (op = ScriptCode::LE, opl = 2, len = 2, *p == '<' && p[1] == '=') || + (op = ScriptCode::LT, opl = 2, len = 1, *p == '<')) && opl > limit) { p += len; - if (op == C_FUNC) + if (op == ScriptCode::FUNC) { int i = 0, func = parse_cmd; const char *plist[128]; - if (str_data[func].type != C_FUNC) + if (str_data[func].type != ScriptCode::FUNC) { disp_error_message ("expect function", tmpp); exit (0); } - add_scriptc (C_ARG); + add_scriptc (ScriptCode::ARG); while (*p && *p != ')' && i < 128) { plist[i] = p; @@ -1276,7 +1273,7 @@ unsigned char *parse_subexpr (unsigned char *p, int limit) exit (1); } - if (str_data[func].type == C_FUNC + if (str_data[func].type == ScriptCode::FUNC && script_config.warn_func_mismatch_paramnum) { const char *arg = buildin_func[str_data[func].val].arg; @@ -1291,7 +1288,7 @@ unsigned char *parse_subexpr (unsigned char *p, int limit) } } } - else // not op == C_FUNC + else // not op == ScriptCode::FUNC { p = parse_subexpr (p, opl); } @@ -1309,7 +1306,8 @@ unsigned char *parse_subexpr (unsigned char *p, int limit) * 式の評価 *------------------------------------------ */ -unsigned char *parse_expr (unsigned char *p) +static +const char *parse_expr (const char *p) { #ifdef DEBUG_FUNCIN if (battle_config.etc_log) @@ -1338,11 +1336,11 @@ unsigned char *parse_expr (unsigned char *p) * 行の解析 *------------------------------------------ */ -unsigned char *parse_line (unsigned char *p) +static +const char *parse_line (const char *p) { int i = 0, cmd; const char *plist[128]; - char *p2; p = skip_space (p); if (*p == ';') @@ -1351,18 +1349,18 @@ unsigned char *parse_line (unsigned char *p) parse_cmd_if = 0; // warn_cmd_no_commaのために必要 // 最初は関数名 - p2 = p; + const char *p2 = p; p = parse_simpleexpr (p); p = skip_space (p); cmd = parse_cmd; - if (str_data[cmd].type != C_FUNC) + if (str_data[cmd].type != ScriptCode::FUNC) { disp_error_message ("expect command", p2); // exit(0); } - add_scriptc (C_ARG); + add_scriptc (ScriptCode::ARG); while (p && *p && *p != ';' && i < 128) { plist[i] = p; @@ -1386,9 +1384,9 @@ unsigned char *parse_line (unsigned char *p) disp_error_message ("need ';'", p); exit (1); } - add_scriptc (C_FUNC); + add_scriptc (ScriptCode::FUNC); - if (str_data[cmd].type == C_FUNC + if (str_data[cmd].type == ScriptCode::FUNC && script_config.warn_cmd_mismatch_paramnum) { const char *arg = buildin_func[str_data[cmd].val].arg; @@ -1416,7 +1414,7 @@ static void add_buildin_func (void) for (i = 0; buildin_func[i].func; i++) { n = add_str (buildin_func[i].name); - str_data[n].type = C_FUNC; + str_data[n].type = ScriptCode::FUNC; str_data[n].val = i; str_data[n].func = buildin_func[i].func; } @@ -1450,9 +1448,9 @@ static void read_constdb (void) name[i] = tolower (name[i]); n = add_str (name); if (type == 0) - str_data[n].type = C_INT; + str_data[n].type = ScriptCode::INT; else - str_data[n].type = C_PARAM; + str_data[n].type = ScriptCode::PARAM; str_data[n].val = val; } } @@ -1463,9 +1461,9 @@ static void read_constdb (void) * スクリプトの解析 *------------------------------------------ */ -unsigned char *parse_script (unsigned char *src, int line) +const ScriptCode *parse_script (const char *src, int line) { - unsigned char *p, *tmpp; + const char *p; int i; static int first = 1; @@ -1475,17 +1473,17 @@ unsigned char *parse_script (unsigned char *src, int line) read_constdb (); } first = 0; - script_buf = (unsigned char *) calloc (SCRIPT_BLOCK_SIZE, 1); + script_buf = (ScriptCode *) calloc (SCRIPT_BLOCK_SIZE, 1); script_pos = 0; script_size = SCRIPT_BLOCK_SIZE; - str_data[LABEL_NEXTLINE].type = C_NOP; + str_data[LABEL_NEXTLINE].type = ScriptCode::NOP; str_data[LABEL_NEXTLINE].backpatch = -1; str_data[LABEL_NEXTLINE].label = -1; for (i = LABEL_START; i < str_num; i++) { - if (str_data[i].type == C_POS || str_data[i].type == C_NAME) + if (str_data[i].type == ScriptCode::POS || str_data[i].type == ScriptCode::NAME) { - str_data[i].type = C_NOP; + str_data[i].type = ScriptCode::NOP; str_data[i].backpatch = -1; str_data[i].label = -1; } @@ -1511,23 +1509,21 @@ unsigned char *parse_script (unsigned char *src, int line) { p = skip_space (p); // labelだけ特殊処理 - tmpp = skip_space (skip_word (p)); - if (*tmpp == ':') + if (*skip_space (skip_word (p)) == ':') { - int l, c; - - c = *skip_word (p); - *skip_word (p) = 0; - l = add_str (p); + char *tmpp = const_cast<char *>(skip_word(p)); + char c = *tmpp; + *tmpp = '\0'; + int l = add_str (p); if (str_data[l].label != -1) { - *skip_word (p) = c; + *tmpp = c; disp_error_message ("dup label ", p); exit (1); } set_label (l, script_pos); strdb_insert (scriptlabel_db, (const char*)p, script_pos); // 外部用label db登録 - *skip_word (p) = c; + *tmpp = c; p = tmpp + 1; continue; } @@ -1535,33 +1531,33 @@ unsigned char *parse_script (unsigned char *src, int line) // 他は全部一緒くた p = parse_line (p); p = skip_space (p); - add_scriptc (C_EOL); + add_scriptc (ScriptCode::EOL); set_label (LABEL_NEXTLINE, script_pos); - str_data[LABEL_NEXTLINE].type = C_NOP; + str_data[LABEL_NEXTLINE].type = ScriptCode::NOP; str_data[LABEL_NEXTLINE].backpatch = -1; str_data[LABEL_NEXTLINE].label = -1; } - add_scriptc (C_NOP); + add_scriptc (ScriptCode::NOP); script_size = script_pos; - script_buf = (char *) realloc (script_buf, script_pos + 1); + script_buf = (ScriptCode *) realloc (script_buf, script_pos + 1); // 未解決のラベルを解決 for (i = LABEL_START; i < str_num; i++) { - if (str_data[i].type == C_NOP) + if (str_data[i].type == ScriptCode::NOP) { int j, next; - str_data[i].type = C_NAME; + str_data[i].type = ScriptCode::NAME; str_data[i].label = i; for (j = str_data[i].backpatch; j >= 0 && j != 0x00ffffff;) { next = (*(int *) (script_buf + j)) & 0x00ffffff; - script_buf[j] = i; - script_buf[j + 1] = i >> 8; - script_buf[j + 2] = i >> 16; + script_buf[j] = static_cast<ScriptCode>(i); + script_buf[j + 1] = static_cast<ScriptCode>(i >> 8); + script_buf[j + 2] = static_cast<ScriptCode>(i >> 16); j = next; } } @@ -1592,6 +1588,7 @@ enum * ridからsdへの解決 *------------------------------------------ */ +static struct map_session_data *script_rid2sd (struct script_state *st) { struct map_session_data *sd = map_id2sd (st->rid); @@ -1606,10 +1603,11 @@ struct map_session_data *script_rid2sd (struct script_state *st) * 変数の読み取り *------------------------------------------ */ +static int get_val (struct script_state *st, struct script_data *data) { struct map_session_data *sd = NULL; - if (data->type == C_NAME) + if (data->type == ScriptCode::NAME) { char *name = str_buf + str_data[data->u.num & 0x00ffffff].str; char prefix = *name; @@ -1623,7 +1621,7 @@ int get_val (struct script_state *st, struct script_data *data) if (postfix == '$') { - data->type = C_CONSTSTR; + data->type = ScriptCode::CONSTSTR; if (prefix == '@' || prefix == 'l') { if (sd) @@ -1646,12 +1644,12 @@ int get_val (struct script_state *st, struct script_data *data) else { - data->type = C_INT; - if (str_data[data->u.num & 0x00ffffff].type == C_INT) + data->type = ScriptCode::INT; + if (str_data[data->u.num & 0x00ffffff].type == ScriptCode::INT) { data->u.num = str_data[data->u.num & 0x00ffffff].val; } - else if (str_data[data->u.num & 0x00ffffff].type == C_PARAM) + else if (str_data[data->u.num & 0x00ffffff].type == ScriptCode::PARAM) { if (sd) data->u.num = @@ -1694,30 +1692,29 @@ int get_val (struct script_state *st, struct script_data *data) * 変数の読み取り2 *------------------------------------------ */ -void *get_val2 (struct script_state *st, int num) +static +struct script_data get_val2 (struct script_state *st, int num) { struct script_data dat; - dat.type = C_NAME; + dat.type = ScriptCode::NAME; dat.u.num = num; get_val (st, &dat); - if (dat.type == C_INT) - return (void *) dat.u.num; - else - return (void *) dat.u.str; + return dat; } /*========================================== * 変数設定用 *------------------------------------------ */ -static int set_reg (struct map_session_data *sd, int num, char *name, void *v) +static +int set_reg (struct map_session_data *sd, int num, const char *name, struct script_data vd) { char prefix = *name; char postfix = name[strlen (name) - 1]; if (postfix == '$') { - char *str = (char *) v; + const char *str = vd.u.str; if (prefix == '@' || prefix == 'l') { pc_setregstr (sd, num, str); @@ -1734,8 +1731,8 @@ static int set_reg (struct map_session_data *sd, int num, char *name, void *v) else { // 数値 - int val = (int) v; - if (str_data[num & 0x00ffffff].type == C_PARAM) + int val = vd.u.num; + if (str_data[num & 0x00ffffff].type == ScriptCode::PARAM) { pc_setparam (sd, str_data[num & 0x00ffffff].val, val); } @@ -1762,26 +1759,43 @@ static int set_reg (struct map_session_data *sd, int num, char *name, void *v) return 0; } +static +int set_reg (struct map_session_data *sd, int num, const char *name, int id) +{ + struct script_data vd; + vd.u.num = id; + return set_reg(sd, num, name, vd); +} + +static +int set_reg (struct map_session_data *sd, int num, const char *name, const char *zd) +{ + struct script_data vd; + vd.u.str = zd; + return set_reg(sd, num, name, vd); +} + /*========================================== * 文字列への変換 *------------------------------------------ */ -char *conv_str (struct script_state *st, struct script_data *data) +static +const char *conv_str (struct script_state *st, struct script_data *data) { get_val (st, data); - if (data->type == C_INT) + if (data->type == ScriptCode::INT) { char *buf; buf = (char *) calloc (16, 1); sprintf (buf, "%d", data->u.num); - data->type = C_STR; + data->type = ScriptCode::STR; data->u.str = buf; #if 1 } - else if (data->type == C_NAME) + else if (data->type == ScriptCode::NAME) { // テンポラリ。本来無いはず - data->type = C_CONSTSTR; + data->type = ScriptCode::CONSTSTR; data->u.str = str_buf + str_data[data->u.num].str; #endif } @@ -1792,17 +1806,17 @@ char *conv_str (struct script_state *st, struct script_data *data) * 数値へ変換 *------------------------------------------ */ +static int conv_num (struct script_state *st, struct script_data *data) { - char *p; get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { - p = data->u.str; + const char *p = data->u.str; data->u.num = atoi (p); - if (data->type == C_STR) - free (p); - data->type = C_INT; + if (data->type == ScriptCode::STR) + free(const_cast<char *>(p)); + data->type = ScriptCode::INT; } return data->u.num; } @@ -1811,7 +1825,7 @@ int conv_num (struct script_state *st, struct script_data *data) * スタックへ数値をプッシュ *------------------------------------------ */ -void push_val (struct script_stack *stack, int type, int val) +void push_val (struct script_stack *stack, ScriptCode type, int val) { if (stack->sp >= stack->sp_max) { @@ -1833,7 +1847,8 @@ void push_val (struct script_stack *stack, int type, int val) * スタックへ文字列をプッシュ *------------------------------------------ */ -void push_str (struct script_stack *stack, int type, unsigned char *str) +static +void push_str (struct script_stack *stack, ScriptCode type, const char *str) { if (stack->sp >= stack->sp_max) { @@ -1855,19 +1870,20 @@ void push_str (struct script_stack *stack, int type, unsigned char *str) * スタックへ複製をプッシュ *------------------------------------------ */ -void push_copy (struct script_stack *stack, int pos) +static +void push_copy (struct script_stack *stack, int pos_) { - switch (stack->stack_data[pos].type) + switch (stack->stack_data[pos_].type) { - case C_CONSTSTR: - push_str (stack, C_CONSTSTR, stack->stack_data[pos].u.str); + case ScriptCode::CONSTSTR: + push_str (stack, ScriptCode::CONSTSTR, stack->stack_data[pos_].u.str); break; - case C_STR: - push_str (stack, C_STR, strdup (stack->stack_data[pos].u.str)); + case ScriptCode::STR: + push_str (stack, ScriptCode::STR, strdup (stack->stack_data[pos_].u.str)); break; default: - push_val (stack, stack->stack_data[pos].type, - stack->stack_data[pos].u.num); + push_val (stack, stack->stack_data[pos_].type, + stack->stack_data[pos_].u.num); break; } } @@ -1876,14 +1892,15 @@ void push_copy (struct script_stack *stack, int pos) * スタックからポップ *------------------------------------------ */ +static void pop_stack (struct script_stack *stack, int start, int end) { int i; for (i = start; i < end; i++) { - if (stack->stack_data[i].type == C_STR) + if (stack->stack_data[i].type == ScriptCode::STR) { - free (stack->stack_data[i].u.str); + free (const_cast<char *>(stack->stack_data[i].u.str)); } } if (stack->sp > end) @@ -1915,17 +1932,14 @@ int buildin_mes (struct script_state *st) */ int buildin_goto (struct script_state *st) { - int pos; - - if (st->stack->stack_data[st->start + 2].type != C_POS) + if (st->stack->stack_data[st->start + 2].type != ScriptCode::POS) { printf ("script: goto: not label !\n"); st->state = END; return 0; } - pos = conv_num (st, &(st->stack->stack_data[st->start + 2])); - st->pos = pos; + st->pos = conv_num (st, &(st->stack->stack_data[st->start + 2])); st->state = GOTO; return 0; } @@ -1936,19 +1950,19 @@ int buildin_goto (struct script_state *st) */ int buildin_callfunc (struct script_state *st) { - char *scr; - char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const ScriptCode *scr; + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); - if ((scr = (char*)strdb_search (script_get_userfunc_db (), str))) + if ((scr = (const ScriptCode *)strdb_search (script_get_userfunc_db (), str))) { int i, j; for (i = st->start + 3, j = 0; i < st->end; i++, j++) push_copy (st->stack, i); - push_val (st->stack, C_INT, j); // 引数の数をプッシュ - push_val (st->stack, C_INT, st->defsp); // 現在の基準スタックポインタをプッシュ - push_val (st->stack, C_INT, (int) st->script); // 現在のスクリプトをプッシュ - push_val (st->stack, C_RETINFO, st->pos); // 現在のスクリプト位置をプッシュ + push_val (st->stack, ScriptCode::INT, j); // 引数の数をプッシュ + push_val (st->stack, ScriptCode::INT, st->defsp); // 現在の基準スタックポインタをプッシュ + push_val (st->stack, ScriptCode::INT, (int) st->script); // 現在のスクリプトをプッシュ + push_val (st->stack, ScriptCode::RETINFO, st->pos); // 現在のスクリプト位置をプッシュ st->pos = 0; st->script = scr; @@ -1969,17 +1983,17 @@ int buildin_callfunc (struct script_state *st) */ int buildin_callsub (struct script_state *st) { - int pos = conv_num (st, &(st->stack->stack_data[st->start + 2])); + int pos_ = conv_num (st, &(st->stack->stack_data[st->start + 2])); int i, j; for (i = st->start + 3, j = 0; i < st->end; i++, j++) push_copy (st->stack, i); - push_val (st->stack, C_INT, j); // 引数の数をプッシュ - push_val (st->stack, C_INT, st->defsp); // 現在の基準スタックポインタをプッシュ - push_val (st->stack, C_INT, (int) st->script); // 現在のスクリプトをプッシュ - push_val (st->stack, C_RETINFO, st->pos); // 現在のスクリプト位置をプッシュ + push_val (st->stack, ScriptCode::INT, j); // 引数の数をプッシュ + push_val (st->stack, ScriptCode::INT, st->defsp); // 現在の基準スタックポインタをプッシュ + push_val (st->stack, ScriptCode::INT, (int) st->script); // 現在のスクリプトをプッシュ + push_val (st->stack, ScriptCode::RETINFO, st->pos); // 現在のスクリプト位置をプッシュ - st->pos = pos; + st->pos = pos_; st->defsp = st->start + 4 + j; st->state = GOTO; return 0; @@ -1994,7 +2008,7 @@ int buildin_getarg (struct script_state *st) int num = conv_num (st, &(st->stack->stack_data[st->start + 2])); int max, stsp; if (st->defsp < 4 - || st->stack->stack_data[st->defsp - 1].type != C_RETINFO) + || st->stack->stack_data[st->defsp - 1].type != ScriptCode::RETINFO) { printf ("script:getarg without callfunc or callsub!\n"); st->state = END; @@ -2112,19 +2126,17 @@ int buildin_menu (struct script_state *st) sd->state.menu_or_input = 0; if (sd->npc_menu > 0 && sd->npc_menu <= menu_choices) { - int pos; if (st->stack-> - stack_data[st->start + sd->npc_menu * 2 + 1].type != C_POS) + stack_data[st->start + sd->npc_menu * 2 + 1].type != ScriptCode::POS) { st->state = END; return 0; } - pos = + st->pos = conv_num (st, &(st-> stack->stack_data[st->start + sd->npc_menu * 2 + 1])); - st->pos = pos; st->state = GOTO; } } @@ -2151,12 +2163,12 @@ int buildin_rand (struct script_state *st) max = tmp; } range = max - min + 1; - push_val (st->stack, C_INT, (range <= 0 ? 0 : MRAND (range)) + min); + push_val (st->stack, ScriptCode::INT, (range <= 0 ? 0 : MRAND (range)) + min); } else { range = conv_num (st, &(st->stack->stack_data[st->start + 2])); - push_val (st->stack, C_INT, range <= 0 ? 0 : MRAND (range)); + push_val (st->stack, ScriptCode::INT, range <= 0 ? 0 : MRAND (range)); } return 0; } @@ -2172,7 +2184,7 @@ int buildin_pow (struct script_state *st) a = conv_num (st, &(st->stack->stack_data[st->start + 2])); b = conv_num (st, &(st->stack->stack_data[st->start + 3])); - push_val (st->stack, C_INT, (int) pow (a * 0.001, b)); + push_val (st->stack, ScriptCode::INT, (int) pow (a * 0.001, b)); return 0; } @@ -2184,17 +2196,16 @@ int buildin_pow (struct script_state *st) int buildin_isat (struct script_state *st) { int x, y; - char *str; struct map_session_data *sd = script_rid2sd (st); - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); if (!sd) return 1; - push_val (st->stack, C_INT, + push_val (st->stack, ScriptCode::INT, (x == sd->bl.x) && (y == sd->bl.y) && (!strcmp (str, map[sd->bl.m].name))); @@ -2208,10 +2219,9 @@ int buildin_isat (struct script_state *st) int buildin_warp (struct script_state *st) { int x, y; - char *str; struct map_session_data *sd = script_rid2sd (st); - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); if (strcmp (str, "Random") == 0) @@ -2241,33 +2251,31 @@ int buildin_warp (struct script_state *st) * エリア指定ワープ *------------------------------------------ */ +static int buildin_areawarp_sub (struct block_list *bl, va_list ap) { int x, y; - char *map; - map = va_arg (ap, char *); + const char *mapname = va_arg (ap, const char *); x = va_arg (ap, int); y = va_arg (ap, int); - if (strcmp (map, "Random") == 0) + if (strcmp (mapname, "Random") == 0) pc_randomwarp ((struct map_session_data *) bl, 3); else - pc_setpos ((struct map_session_data *) bl, map, x, y, 0); + pc_setpos ((struct map_session_data *) bl, mapname, x, y, 0); return 0; } int buildin_areawarp (struct script_state *st) { int x, y, m; - char *str; - char *mapname; int x0, y0, x1, y1; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y0 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 5])); y1 = conv_num (st, &(st->stack->stack_data[st->start + 6])); - str = conv_str (st, &(st->stack->stack_data[st->start + 7])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 7])); x = conv_num (st, &(st->stack->stack_data[st->start + 8])); y = conv_num (st, &(st->stack->stack_data[st->start + 9])); @@ -2349,7 +2357,7 @@ int buildin_input (struct script_state *st) int num = (st->end > st->start + 2) ? st->stack->stack_data[st->start + 2].u.num : 0; - char *name = + const char *name = (st->end > st->start + 2) ? str_buf + str_data[num & 0x00ffffff].str : ""; // char prefix=*name; @@ -2364,7 +2372,7 @@ int buildin_input (struct script_state *st) // 文字列 if (st->end > st->start + 2) { // 引数1個 - set_reg (sd, num, name, (void *) sd->npc_str); + set_reg (sd, num, name, sd->npc_str); } else { @@ -2385,7 +2393,7 @@ int buildin_input (struct script_state *st) // 数値 if (st->end > st->start + 2) { // 引数1個 - set_reg (sd, num, name, (void *) sd->npc_amount); + set_reg (sd, num, name, sd->npc_amount); } else { @@ -2421,7 +2429,7 @@ int buildin_if (struct script_state *st) // 関数名をコピー push_copy (st->stack, st->start + 3); // 間に引数マーカを入れて - push_val (st->stack, C_ARG, 0); + push_val (st->stack, ScriptCode::ARG, 0); // 残りの引数をコピー for (i = st->start + 4; i < st->end; i++) { @@ -2444,7 +2452,7 @@ int buildin_set (struct script_state *st) char prefix = *name; char postfix = name[strlen (name) - 1]; - if (st->stack->stack_data[st->start + 2].type != C_NAME) + if (st->stack->stack_data[st->start + 2].type != ScriptCode::NAME) { printf ("script: buildin_set: not name\n"); return 0; @@ -2456,14 +2464,14 @@ int buildin_set (struct script_state *st) if (postfix == '$') { // 文字列 - char *str = conv_str (st, &(st->stack->stack_data[st->start + 3])); - set_reg (sd, num, name, (void *) str); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 3])); + set_reg (sd, num, name, str); } else { // 数値 int val = conv_num (st, &(st->stack->stack_data[st->start + 3])); - set_reg (sd, num, name, (void *) val); + set_reg (sd, num, name, val); } return 0; @@ -2492,12 +2500,10 @@ int buildin_setarray (struct script_state *st) for (j = 0, i = st->start + 3; i < st->end && j < 128; i++, j++) { - void *v; if (postfix == '$') - v = (void *) conv_str (st, &(st->stack->stack_data[i])); + set_reg(sd, num + (j << 24), name, conv_str(st, &(st->stack->stack_data[i]))); else - v = (void *) conv_num (st, &(st->stack->stack_data[i])); - set_reg (sd, num + (j << 24), name, v); + set_reg(sd, num + (j << 24), name, conv_num(st, &(st->stack->stack_data[i]))); } return 0; } @@ -2526,12 +2532,12 @@ int buildin_cleararray (struct script_state *st) sd = script_rid2sd (st); if (postfix == '$') - v = (void *) conv_str (st, &(st->stack->stack_data[st->start + 3])); + for (i = 0; i < sz; i++) + set_reg(sd, num + (i << 24), name, conv_str(st, &(st->stack->stack_data[st->start + 3]))); else - v = (void *) conv_num (st, &(st->stack->stack_data[st->start + 3])); + for (i = 0; i < sz; i++) + set_reg(sd, num + (i << 24), name, conv_num(st, &(st->stack->stack_data[st->start + 3]))); - for (i = 0; i < sz; i++) - set_reg (sd, num + (i << 24), name, v); return 0; } @@ -2580,10 +2586,8 @@ static int getarraysize (struct script_state *st, int num, int postfix) int i = (num >> 24), c = i; for (; i < 128; i++) { - void *v = get_val2 (st, num + (i << 24)); - if (postfix == '$' && *((char *) v)) - c = i; - if (postfix != '$' && (int) v) + struct script_data vd = get_val2 (st, num + (i << 24)); + if (postfix == '$' ? bool(vd.u.str) : bool(vd.u.num)) c = i; } return c + 1; @@ -2602,7 +2606,7 @@ int buildin_getarraysize (struct script_state *st) return 0; } - push_val (st->stack, C_INT, getarraysize (st, num, postfix)); + push_val (st->stack, ScriptCode::INT, getarraysize (st, num, postfix)); return 0; } @@ -2652,7 +2656,7 @@ int buildin_deletearray (struct script_state *st) */ int buildin_getelementofarray (struct script_state *st) { - if (st->stack->stack_data[st->start + 2].type == C_NAME) + if (st->stack->stack_data[st->start + 2].type == ScriptCode::NAME) { int i = conv_num (st, &(st->stack->stack_data[st->start + 3])); if (i > 127 || i < 0) @@ -2660,11 +2664,11 @@ int buildin_getelementofarray (struct script_state *st) printf ("script: getelementofarray (operator[]): param2 illegal number %d\n", i); - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } else { - push_val (st->stack, C_NAME, + push_val (st->stack, ScriptCode::NAME, (i << 24) | st->stack->stack_data[st->start + 2].u.num); } } @@ -2672,7 +2676,7 @@ int buildin_getelementofarray (struct script_state *st) { printf ("script: getelementofarray (operator[]): param1 not name !\n"); - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; } @@ -2760,7 +2764,7 @@ int buildin_countitem (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data; @@ -2781,7 +2785,7 @@ int buildin_countitem (struct script_state *st) if (battle_config.error_log) printf ("wrong item ID : countitem(%i)\n", nameid); } - push_val (st->stack, C_INT, count); + push_val (st->stack, ScriptCode::INT, count); return 0; } @@ -2800,7 +2804,7 @@ int buildin_checkweight (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data = itemdb_searchname (name); @@ -2813,17 +2817,17 @@ int buildin_checkweight (struct script_state *st) amount = conv_num (st, &(st->stack->stack_data[st->start + 3])); if (amount <= 0 || nameid < 500) { //if get wrong item ID or amount<=0, don't count weight of non existing items - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } sd = script_rid2sd (st); if (itemdb_weight (nameid) * amount + sd->weight > sd->max_weight) { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } else { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } return 0; @@ -2844,7 +2848,7 @@ int buildin_getitem (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data = itemdb_searchname (name); @@ -2899,7 +2903,6 @@ int buildin_getitem2 (struct script_state *st) { int nameid, amount, flag = 0; int iden, ref, attr, c1, c2, c3, c4; - struct item_data *item_data; struct item item_tmp; struct map_session_data *sd; struct script_data *data; @@ -2908,7 +2911,7 @@ int buildin_getitem2 (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data = itemdb_searchname (name); @@ -2942,7 +2945,7 @@ int buildin_getitem2 (struct script_state *st) if (nameid > 0) { memset (&item_tmp, 0, sizeof (item_tmp)); - item_data = itemdb_search (nameid); + struct item_data *item_data = itemdb_search (nameid); if (item_data->type == 4 || item_data->type == 5) { if (ref > 10) @@ -2989,7 +2992,6 @@ int buildin_makeitem (struct script_state *st) { int nameid, amount, flag = 0; int x, y, m; - char *mapname; struct item item_tmp; struct map_session_data *sd; struct script_data *data; @@ -2998,7 +3000,7 @@ int buildin_makeitem (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data = itemdb_searchname (name); @@ -3010,7 +3012,7 @@ int buildin_makeitem (struct script_state *st) nameid = conv_num (st, data); amount = conv_num (st, &(st->stack->stack_data[st->start + 3])); - mapname = conv_str (st, &(st->stack->stack_data[st->start + 4])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 4])); x = conv_num (st, &(st->stack->stack_data[st->start + 5])); y = conv_num (st, &(st->stack->stack_data[st->start + 6])); @@ -3055,7 +3057,7 @@ int buildin_delitem (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data = itemdb_searchname (name); @@ -3124,11 +3126,11 @@ int buildin_readparam (struct script_state *st) if (sd == NULL) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } - push_val (st->stack, C_INT, pc_readparam (sd, type)); + push_val (st->stack, ScriptCode::INT, pc_readparam (sd, type)); return 0; } @@ -3150,17 +3152,17 @@ int buildin_getcharid (struct script_state *st) sd = script_rid2sd (st); if (sd == NULL) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } if (num == 0) - push_val (st->stack, C_INT, sd->status.char_id); + push_val (st->stack, ScriptCode::INT, sd->status.char_id); if (num == 1) - push_val (st->stack, C_INT, sd->status.party_id); + push_val (st->stack, ScriptCode::INT, sd->status.party_id); if (num == 2) - push_val (st->stack, C_INT, sd->status.guild_id); + push_val (st->stack, ScriptCode::INT, sd->status.guild_id); if (num == 3) - push_val (st->stack, C_INT, sd->status.account_id); + push_val (st->stack, ScriptCode::INT, sd->status.account_id); return 0; } @@ -3168,6 +3170,7 @@ int buildin_getcharid (struct script_state *st) *指定IDのPT名取得 *------------------------------------------ */ +static char *buildin_getpartyname_sub (int party_id) { struct party *p; @@ -3194,9 +3197,9 @@ int buildin_getpartyname (struct script_state *st) party_id = conv_num (st, &(st->stack->stack_data[st->start + 2])); name = buildin_getpartyname_sub (party_id); if (name != 0) - push_str (st->stack, C_STR, name); + push_str (st->stack, ScriptCode::STR, name); else - push_str (st->stack, C_CONSTSTR, "null"); + push_str (st->stack, ScriptCode::CONSTSTR, "null"); return 0; } @@ -3235,6 +3238,7 @@ int buildin_getpartymember (struct script_state *st) *指定IDのギルド名取得 *------------------------------------------ */ +static char *buildin_getguildname_sub (int guild_id) { struct guild *g = NULL; @@ -3256,9 +3260,9 @@ int buildin_getguildname (struct script_state *st) int guild_id = conv_num (st, &(st->stack->stack_data[st->start + 2])); name = buildin_getguildname_sub (guild_id); if (name != 0) - push_str (st->stack, C_STR, name); + push_str (st->stack, ScriptCode::STR, name); else - push_str (st->stack, C_CONSTSTR, "null"); + push_str (st->stack, ScriptCode::CONSTSTR, "null"); return 0; } @@ -3266,6 +3270,7 @@ int buildin_getguildname (struct script_state *st) *指定IDのGuildMaster名取得 *------------------------------------------ */ +static char *buildin_getguildmaster_sub (int guild_id) { struct guild *g = NULL; @@ -3288,9 +3293,9 @@ int buildin_getguildmaster (struct script_state *st) int guild_id = conv_num (st, &(st->stack->stack_data[st->start + 2])); master = buildin_getguildmaster_sub (guild_id); if (master != 0) - push_str (st->stack, C_STR, master); + push_str (st->stack, ScriptCode::STR, master); else - push_str (st->stack, C_CONSTSTR, "null"); + push_str (st->stack, ScriptCode::CONSTSTR, "null"); return 0; } @@ -3304,14 +3309,14 @@ int buildin_getguildmasterid (struct script_state *st) { if ((sd = map_nick2sd (master)) == NULL) { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } - push_val (st->stack, C_INT, sd->status.char_id); + push_val (st->stack, ScriptCode::INT, sd->status.char_id); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; } @@ -3332,25 +3337,25 @@ int buildin_strcharinfo (struct script_state *st) char *buf; buf = (char *) calloc (24, 1); strncpy (buf, sd->status.name, 23); - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); } if (num == 1) { char *buf; buf = buildin_getpartyname_sub (sd->status.party_id); if (buf != 0) - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); else - push_str (st->stack, C_CONSTSTR, ""); + push_str (st->stack, ScriptCode::CONSTSTR, ""); } if (num == 2) { char *buf; buf = buildin_getguildname_sub (sd->status.guild_id); if (buf != 0) - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); else - push_str (st->stack, C_CONSTSTR, ""); + push_str (st->stack, ScriptCode::CONSTSTR, ""); } return 0; @@ -3383,13 +3388,13 @@ int buildin_getequipid (struct script_state *st) { item = sd->inventory_data[i]; if (item) - push_val (st->stack, C_INT, item->nameid); + push_val (st->stack, ScriptCode::INT, item->nameid); else - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } else { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); } return 0; } @@ -3421,7 +3426,7 @@ int buildin_getequipname (struct script_state *st) { sprintf (buf, "%s-[%s]", pos[num - 1], pos[10]); } - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); return 0; } @@ -3451,7 +3456,7 @@ int buildin_getbrokenid (struct script_state *st) } } - push_val (st->stack, C_INT, id); + push_val (st->stack, ScriptCode::INT, id); return 0; } @@ -3503,11 +3508,11 @@ int buildin_getequipisequiped (struct script_state *st) i = pc_checkequip (sd, equip[num - 1]); if (i >= 0) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; @@ -3532,11 +3537,11 @@ int buildin_getequipisenableref (struct script_state *st) || (sd->inventory_data[i]->def <= 0 && sd->inventory_data[i]->equip_script != NULL))) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; @@ -3555,9 +3560,9 @@ int buildin_getequipisidentify (struct script_state *st) sd = script_rid2sd (st); i = pc_checkequip (sd, equip[num - 1]); if (i >= 0) - push_val (st->stack, C_INT, sd->status.inventory[i].identify); + push_val (st->stack, ScriptCode::INT, sd->status.inventory[i].identify); else - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } @@ -3575,9 +3580,9 @@ int buildin_getequiprefinerycnt (struct script_state *st) sd = script_rid2sd (st); i = pc_checkequip (sd, equip[num - 1]); if (i >= 0) - push_val (st->stack, C_INT, sd->status.inventory[i].refine); + push_val (st->stack, ScriptCode::INT, sd->status.inventory[i].refine); else - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } @@ -3595,9 +3600,9 @@ int buildin_getequipweaponlv (struct script_state *st) sd = script_rid2sd (st); i = pc_checkequip (sd, equip[num - 1]); if (i >= 0 && sd->inventory_data[i]) - push_val (st->stack, C_INT, sd->inventory_data[i]->wlv); + push_val (st->stack, ScriptCode::INT, sd->inventory_data[i]->wlv); else - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } @@ -3615,10 +3620,10 @@ int buildin_getequippercentrefinery (struct script_state *st) sd = script_rid2sd (st); i = pc_checkequip (sd, equip[num - 1]); if (i >= 0) - push_val (st->stack, C_INT, + push_val (st->stack, ScriptCode::INT, pc_percentrefinery (sd, &sd->status.inventory[i])); else - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } @@ -3831,7 +3836,7 @@ int buildin_guildskill (struct script_state *st) int buildin_getskilllv (struct script_state *st) { int id = conv_num (st, &(st->stack->stack_data[st->start + 2])); - push_val (st->stack, C_INT, pc_checkskill (script_rid2sd (st), id)); + push_val (st->stack, ScriptCode::INT, pc_checkskill (script_rid2sd (st), id)); return 0; } @@ -3849,7 +3854,7 @@ int buildin_getgdskilllv (struct script_state *st) int guild_id = conv_num (st, &(st->stack->stack_data[st->start + 2])); int skill_id = conv_num (st, &(st->stack->stack_data[st->start + 3])); struct guild *g = guild_search (guild_id); - push_val (st->stack, C_INT, + push_val (st->stack, ScriptCode::INT, (g == NULL) ? -1 : guild_checkskill (g, skill_id)); return 0; /* @@ -3861,9 +3866,9 @@ int buildin_getgdskilllv (struct script_state *st) sd=script_rid2sd(st); if(sd && sd->status.guild_id > 0) g=guild_search(sd->status.guild_id); if(sd && g) { - push_val(st->stack,C_INT, guild_checkskill(g,skill_id+9999) ); + push_val(st->stack,ScriptCode::INT, guild_checkskill(g,skill_id+9999) ); } else { - push_val(st->stack,C_INT,-1); + push_val(st->stack,ScriptCode::INT,-1); } return 0; */ @@ -3875,7 +3880,7 @@ int buildin_getgdskilllv (struct script_state *st) */ int buildin_basicskillcheck (struct script_state *st) { - push_val (st->stack, C_INT, battle_config.basic_skill_check); + push_val (st->stack, ScriptCode::INT, battle_config.basic_skill_check); return 0; } @@ -3885,7 +3890,7 @@ int buildin_basicskillcheck (struct script_state *st) */ int buildin_getgmlevel (struct script_state *st) { - push_val (st->stack, C_INT, pc_isGM (script_rid2sd (st))); + push_val (st->stack, ScriptCode::INT, pc_isGM (script_rid2sd (st))); return 0; } @@ -3910,7 +3915,7 @@ int buildin_getopt2 (struct script_state *st) sd = script_rid2sd (st); - push_val (st->stack, C_INT, sd->opt2); + push_val (st->stack, ScriptCode::INT, sd->opt2); return 0; } @@ -3950,11 +3955,11 @@ int buildin_checkoption (struct script_state *st) if (sd->status.option & type) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; @@ -3989,11 +3994,11 @@ int buildin_checkcart (struct script_state *st) if (pc_iscarton (sd)) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; } @@ -4025,11 +4030,11 @@ int buildin_checkfalcon (struct script_state *st) if (pc_isfalcon (sd)) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; @@ -4062,11 +4067,11 @@ int buildin_checkriding (struct script_state *st) if (pc_isriding (sd)) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); } else { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } return 0; @@ -4093,9 +4098,8 @@ int buildin_setriding (struct script_state *st) int buildin_savepoint (struct script_state *st) { int x, y; - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); pc_setsavepoint (script_rid2sd (st), str, x, y); @@ -4127,18 +4131,18 @@ int buildin_gettimetick (struct script_state *st) /* Asgard Version */ time (&timer); t = gmtime (&timer); - push_val (st->stack, C_INT, + push_val (st->stack, ScriptCode::INT, ((t->tm_hour) * 3600 + (t->tm_min) * 60 + t->tm_sec)); break; } /* Seconds since Unix epoch. */ case 2: - push_val (st->stack, C_INT, (int) time (NULL)); + push_val (st->stack, ScriptCode::INT, (int) time (NULL)); break; /* System tick (unsigned int, and yes, it will wrap). */ case 0: default: - push_val (st->stack, C_INT, gettick ()); + push_val (st->stack, ScriptCode::INT, gettick ()); break; } return 0; @@ -4165,28 +4169,28 @@ int buildin_gettime (struct script_state *st) /* Asgard Version */ switch (type) { case 1: //Sec(0~59) - push_val (st->stack, C_INT, t->tm_sec); + push_val (st->stack, ScriptCode::INT, t->tm_sec); break; case 2: //Min(0~59) - push_val (st->stack, C_INT, t->tm_min); + push_val (st->stack, ScriptCode::INT, t->tm_min); break; case 3: //Hour(0~23) - push_val (st->stack, C_INT, t->tm_hour); + push_val (st->stack, ScriptCode::INT, t->tm_hour); break; case 4: //WeekDay(0~6) - push_val (st->stack, C_INT, t->tm_wday); + push_val (st->stack, ScriptCode::INT, t->tm_wday); break; case 5: //MonthDay(01~31) - push_val (st->stack, C_INT, t->tm_mday); + push_val (st->stack, ScriptCode::INT, t->tm_mday); break; case 6: //Month(01~12) - push_val (st->stack, C_INT, t->tm_mon + 1); + push_val (st->stack, ScriptCode::INT, t->tm_mon + 1); break; case 7: //Year(20xx) - push_val (st->stack, C_INT, t->tm_year + 1900); + push_val (st->stack, ScriptCode::INT, t->tm_year + 1900); break; default: //(format error) - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); break; } return 0; @@ -4199,18 +4203,17 @@ int buildin_gettime (struct script_state *st) /* Asgard Version */ int buildin_gettimestr (struct script_state *st) { char *tmpstr; - char *fmtstr; int maxlen; time_t now = time (NULL); - fmtstr = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *fmtstr = conv_str (st, &(st->stack->stack_data[st->start + 2])); maxlen = conv_num (st, &(st->stack->stack_data[st->start + 3])); tmpstr = (char *) calloc (maxlen + 1, 1); strftime (tmpstr, maxlen, fmtstr, gmtime (&now)); tmpstr[maxlen] = '\0'; - push_str (st->stack, C_STR, tmpstr); + push_str (st->stack, ScriptCode::STR, tmpstr); return 0; } @@ -4239,7 +4242,7 @@ int buildin_guildopenstorage (struct script_state *st) int ret; st->state = STOP; ret = storage_guild_storageopen (sd); - push_val (st->stack, C_INT, ret); + push_val (st->stack, ScriptCode::INT, ret); return 0; } @@ -4250,12 +4253,11 @@ int buildin_guildopenstorage (struct script_state *st) int buildin_itemskill (struct script_state *st) { int id, lv; - char *str; struct map_session_data *sd = script_rid2sd (st); id = conv_num (st, &(st->stack->stack_data[st->start + 2])); lv = conv_num (st, &(st->stack->stack_data[st->start + 3])); - str = conv_str (st, &(st->stack->stack_data[st->start + 4])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 4])); // 詠唱中にスキルアイテムは使用できない if (sd->skilltimer != -1) @@ -4293,18 +4295,18 @@ int buildin_getexp (struct script_state *st) int buildin_monster (struct script_state *st) { int mob_class, amount, x, y; - char *str, *map, *event = ""; + const char *event = ""; - map = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); - str = conv_str (st, &(st->stack->stack_data[st->start + 5])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 5])); mob_class = conv_num (st, &(st->stack->stack_data[st->start + 6])); amount = conv_num (st, &(st->stack->stack_data[st->start + 7])); if (st->end > st->start + 8) event = conv_str (st, &(st->stack->stack_data[st->start + 8])); - mob_once_spawn (map_id2sd (st->rid), map, x, y, str, mob_class, amount, + mob_once_spawn (map_id2sd (st->rid), mapname, x, y, str, mob_class, amount, event); return 0; } @@ -4316,20 +4318,20 @@ int buildin_monster (struct script_state *st) int buildin_areamonster (struct script_state *st) { int mob_class, amount, x0, y0, x1, y1; - char *str, *map, *event = ""; + const char *event = ""; - map = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y0 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 5])); y1 = conv_num (st, &(st->stack->stack_data[st->start + 6])); - str = conv_str (st, &(st->stack->stack_data[st->start + 7])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 7])); mob_class = conv_num (st, &(st->stack->stack_data[st->start + 8])); amount = conv_num (st, &(st->stack->stack_data[st->start + 9])); if (st->end > st->start + 10) event = conv_str (st, &(st->stack->stack_data[st->start + 10])); - mob_once_spawn_area (map_id2sd (st->rid), map, x0, y0, x1, y1, str, mob_class, + mob_once_spawn_area (map_id2sd (st->rid), mapname, x0, y0, x1, y1, str, mob_class, amount, event); return 0; } @@ -4338,6 +4340,7 @@ int buildin_areamonster (struct script_state *st) * モンスター削除 *------------------------------------------ */ +static int buildin_killmonster_sub (struct block_list *bl, va_list ap) { char *event = va_arg (ap, char *); @@ -4361,10 +4364,9 @@ int buildin_killmonster_sub (struct block_list *bl, va_list ap) int buildin_killmonster (struct script_state *st) { - char *mapname, *event; int m, allflag = 0; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); - event = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 3])); if (strcmp (event, "All") == 0) allflag = 1; @@ -4375,6 +4377,7 @@ int buildin_killmonster (struct script_state *st) return 0; } +static int buildin_killmonsterall_sub (struct block_list *bl, va_list ap) { mob_delete ((struct mob_data *) bl); @@ -4383,9 +4386,8 @@ int buildin_killmonsterall_sub (struct block_list *bl, va_list ap) int buildin_killmonsterall (struct script_state *st) { - char *mapname; int m; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); if ((m = map_mapname2mapid (mapname)) < 0) return 0; @@ -4400,8 +4402,7 @@ int buildin_killmonsterall (struct script_state *st) */ int buildin_doevent (struct script_state *st) { - char *event; - event = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 2])); npc_event (map_id2sd (st->rid), event, 0); return 0; } @@ -4412,8 +4413,7 @@ int buildin_doevent (struct script_state *st) */ int buildin_donpcevent (struct script_state *st) { - char *event; - event = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 2])); npc_event_do (event); return 0; } @@ -4424,10 +4424,9 @@ int buildin_donpcevent (struct script_state *st) */ int buildin_addtimer (struct script_state *st) { - char *event; int tick; tick = conv_num (st, &(st->stack->stack_data[st->start + 2])); - event = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 3])); pc_addeventtimer (script_rid2sd (st), tick, event); return 0; } @@ -4438,8 +4437,7 @@ int buildin_addtimer (struct script_state *st) */ int buildin_deltimer (struct script_state *st) { - char *event; - event = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 2])); pc_deleventtimer (script_rid2sd (st), event); return 0; } @@ -4450,9 +4448,8 @@ int buildin_deltimer (struct script_state *st) */ int buildin_addtimercount (struct script_state *st) { - char *event; int tick; - event = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 2])); tick = conv_num (st, &(st->stack->stack_data[st->start + 3])); pc_addeventtimercount (script_rid2sd (st), event, tick); return 0; @@ -4537,7 +4534,7 @@ int buildin_getnpctimer (struct script_state *st) val = nd->u.scr.timeramount; break; } - push_val (st->stack, C_INT, val); + push_val (st->stack, ScriptCode::INT, val); return 0; } @@ -4566,9 +4563,8 @@ int buildin_setnpctimer (struct script_state *st) */ int buildin_announce (struct script_state *st) { - char *str; int flag; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); flag = conv_num (st, &(st->stack->stack_data[st->start + 3])); if (flag & 0x0f) @@ -4586,6 +4582,7 @@ int buildin_announce (struct script_state *st) * 天の声アナウンス(特定マップ) *------------------------------------------ */ +static int buildin_mapannounce_sub (struct block_list *bl, va_list ap) { char *str; @@ -4599,11 +4596,10 @@ int buildin_mapannounce_sub (struct block_list *bl, va_list ap) int buildin_mapannounce (struct script_state *st) { - char *mapname, *str; int flag, m; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); - str = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 3])); flag = conv_num (st, &(st->stack->stack_data[st->start + 4])); if ((m = map_mapname2mapid (mapname)) < 0) @@ -4620,19 +4616,18 @@ int buildin_mapannounce (struct script_state *st) */ int buildin_areaannounce (struct script_state *st) { - char *map, *str; int flag, m; int x0, y0, x1, y1; - map = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y0 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 5])); y1 = conv_num (st, &(st->stack->stack_data[st->start + 6])); - str = conv_str (st, &(st->stack->stack_data[st->start + 7])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 7])); flag = conv_num (st, &(st->stack->stack_data[st->start + 8])); - if ((m = map_mapname2mapid (map)) < 0) + if ((m = map_mapname2mapid (mapname)) < 0) return 0; map_foreachinarea (buildin_mapannounce_sub, @@ -4659,7 +4654,7 @@ int buildin_getusers (struct script_state *st) val = map_getusers (); break; } - push_val (st->stack, C_INT, val); + push_val (st->stack, ScriptCode::INT, val); return 0; } @@ -4669,15 +4664,14 @@ int buildin_getusers (struct script_state *st) */ int buildin_getmapusers (struct script_state *st) { - char *str; int m; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); if ((m = map_mapname2mapid (str)) < 0) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } - push_val (st->stack, C_INT, map[m].users); + push_val (st->stack, ScriptCode::INT, map[m].users); return 0; } @@ -4685,12 +4679,15 @@ int buildin_getmapusers (struct script_state *st) * エリア指定ユーザー数所得 *------------------------------------------ */ +static int buildin_getareausers_sub (struct block_list *bl, va_list ap) { int *users = va_arg (ap, int *); (*users)++; return 0; } + +static int buildin_getareausers_living_sub (struct block_list *bl, va_list ap) { int *users = va_arg (ap, int *); @@ -4701,9 +4698,8 @@ int buildin_getareausers_living_sub (struct block_list *bl, va_list ap) int buildin_getareausers (struct script_state *st) { - char *str; int m, x0, y0, x1, y1, users = 0; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y0 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 5])); @@ -4716,12 +4712,12 @@ int buildin_getareausers (struct script_state *st) } if ((m = map_mapname2mapid (str)) < 0) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } map_foreachinarea (living ? buildin_getareausers_living_sub: buildin_getareausers_sub, m, x0, y0, x1, y1, BL_PC, &users); - push_val (st->stack, C_INT, users); + push_val (st->stack, ScriptCode::INT, users); return 0; } @@ -4729,6 +4725,7 @@ int buildin_getareausers (struct script_state *st) * エリア指定ドロップアイテム数所得 *------------------------------------------ */ +static int buildin_getareadropitem_sub (struct block_list *bl, va_list ap) { int item = va_arg (ap, int); @@ -4741,6 +4738,7 @@ int buildin_getareadropitem_sub (struct block_list *bl, va_list ap) return 0; } +static int buildin_getareadropitem_sub_anddelete (struct block_list *bl, va_list ap) { int item = va_arg (ap, int); @@ -4757,11 +4755,10 @@ int buildin_getareadropitem_sub_anddelete (struct block_list *bl, va_list ap) int buildin_getareadropitem (struct script_state *st) { - char *str; int m, x0, y0, x1, y1, item, amount = 0, delitems = 0; struct script_data *data; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y0 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 5])); @@ -4769,7 +4766,7 @@ int buildin_getareadropitem (struct script_state *st) data = &(st->stack->stack_data[st->start + 7]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); struct item_data *item_data = itemdb_searchname (name); @@ -4785,7 +4782,7 @@ int buildin_getareadropitem (struct script_state *st) if ((m = map_mapname2mapid (str)) < 0) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } if (delitems) @@ -4795,7 +4792,7 @@ int buildin_getareadropitem (struct script_state *st) map_foreachinarea (buildin_getareadropitem_sub, m, x0, y0, x1, y1, BL_ITEM, item, &amount); - push_val (st->stack, C_INT, amount); + push_val (st->stack, ScriptCode::INT, amount); return 0; } @@ -4805,8 +4802,7 @@ int buildin_getareadropitem (struct script_state *st) */ int buildin_enablenpc (struct script_state *st) { - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); npc_enable (str, 1); return 0; } @@ -4817,8 +4813,7 @@ int buildin_enablenpc (struct script_state *st) */ int buildin_disablenpc (struct script_state *st) { - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); npc_enable (str, 0); return 0; } @@ -4855,8 +4850,7 @@ int buildin_disablearena (struct script_state *st) // Added by RoVeRT */ int buildin_hideoffnpc (struct script_state *st) { - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); npc_enable (str, 2); return 0; } @@ -4867,8 +4861,7 @@ int buildin_hideoffnpc (struct script_state *st) */ int buildin_hideonnpc (struct script_state *st) { - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); npc_enable (str, 4); return 0; } @@ -4950,7 +4943,7 @@ int buildin_sc_check (struct script_state *st) && ((struct map_session_data *) bl)->state.potionpitcher_flag) bl = map_id2bl (((struct map_session_data *) bl)->skilltarget); - push_val (st->stack, C_INT, skill_status_change_active (bl, type)); + push_val (st->stack, ScriptCode::INT, skill_status_change_active (bl, type)); return 0; } @@ -4989,7 +4982,7 @@ int buildin_getscrate (struct script_state *st) sc_def = sc_def_luk2; rate = rate * sc_def / 100; - push_val (st->stack, C_INT, rate); + push_val (st->stack, ScriptCode::INT, rate); return 0; @@ -5111,7 +5104,7 @@ int buildin_changesex (struct script_state *st) */ int buildin_waitingroom (struct script_state *st) { - char *name, *ev = ""; + const char *name, *ev = ""; int limit, trigger = 0, pub = 1; name = conv_str (st, &(st->stack->stack_data[st->start + 2])); limit = conv_num (st, &(st->stack->stack_data[st->start + 3])); @@ -5122,7 +5115,7 @@ int buildin_waitingroom (struct script_state *st) { struct script_data *data = &(st->stack->stack_data[st->start + 5]); get_val (st, data); - if (data->type == C_INT) + if (data->type == ScriptCode::INT) { // 新Athena仕様(旧Athena仕様と互換性あり) ev = conv_str (st, &(st->stack->stack_data[st->start + 4])); @@ -5166,6 +5159,7 @@ int buildin_delwaitingroom (struct script_state *st) * npcチャット全員蹴り出す *------------------------------------------ */ +static int buildin_waitingroomkickall (struct script_state *st) { struct npc_data *nd; @@ -5247,7 +5241,7 @@ int buildin_getwaitingroomstate (struct script_state *st) if (nd == NULL || (cd = (struct chat_data *) map_id2bl (nd->chat_id)) == NULL) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } @@ -5273,16 +5267,16 @@ int buildin_getwaitingroomstate (struct script_state *st) break; case 4: - push_str (st->stack, C_CONSTSTR, cd->title); + push_str (st->stack, ScriptCode::CONSTSTR, cd->title); return 0; case 5: - push_str (st->stack, C_CONSTSTR, cd->pass); + push_str (st->stack, ScriptCode::CONSTSTR, cd->pass); return 0; case 16: - push_str (st->stack, C_CONSTSTR, cd->npc_event); + push_str (st->stack, ScriptCode::CONSTSTR, cd->npc_event); return 0; } - push_val (st->stack, C_INT, val); + push_val (st->stack, ScriptCode::INT, val); return 0; } @@ -5293,7 +5287,6 @@ int buildin_getwaitingroomstate (struct script_state *st) int buildin_warpwaitingpc (struct script_state *st) { int x, y, i, n; - char *str; struct npc_data *nd = (struct npc_data *) map_id2bl (st->oid); struct chat_data *cd; @@ -5302,7 +5295,7 @@ int buildin_warpwaitingpc (struct script_state *st) return 0; n = cd->trigger & 0x7f; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); @@ -5339,7 +5332,7 @@ int buildin_warpwaitingpc (struct script_state *st) int buildin_attachrid (struct script_state *st) { st->rid = conv_num (st, &(st->stack->stack_data[st->start + 2])); - push_val (st->stack, C_INT, (map_id2sd (st->rid) != NULL)); + push_val (st->stack, ScriptCode::INT, (map_id2sd (st->rid) != NULL)); return 0; } @@ -5359,7 +5352,7 @@ int buildin_detachrid (struct script_state *st) */ int buildin_isloggedin (struct script_state *st) { - push_val (st->stack, C_INT, + push_val (st->stack, ScriptCode::INT, map_id2sd (conv_num (st, &(st->stack->stack_data[st->start + 2]))) != NULL); @@ -5381,10 +5374,9 @@ enum int buildin_setmapflagnosave (struct script_state *st) { int m, x, y; - char *str, *str2; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); - str2 = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str2 = conv_str (st, &(st->stack->stack_data[st->start + 3])); x = conv_num (st, &(st->stack->stack_data[st->start + 4])); y = conv_num (st, &(st->stack->stack_data[st->start + 5])); m = map_mapname2mapid (str); @@ -5402,9 +5394,8 @@ int buildin_setmapflagnosave (struct script_state *st) int buildin_setmapflag (struct script_state *st) { int m, i; - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); i = conv_num (st, &(st->stack->stack_data[st->start + 3])); m = map_mapname2mapid (str); if (m >= 0) @@ -5474,9 +5465,8 @@ int buildin_setmapflag (struct script_state *st) int buildin_removemapflag (struct script_state *st) { int m, i; - char *str; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); i = conv_num (st, &(st->stack->stack_data[st->start + 3])); m = map_mapname2mapid (str); if (m >= 0) @@ -5547,10 +5537,9 @@ int buildin_removemapflag (struct script_state *st) int buildin_pvpon (struct script_state *st) { int m, i; - char *str; struct map_session_data *pl_sd = NULL; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); m = map_mapname2mapid (str); if (m >= 0 && !map[m].flag.pvp && !map[m].flag.nopvp) { @@ -5584,10 +5573,9 @@ int buildin_pvpon (struct script_state *st) int buildin_pvpoff (struct script_state *st) { int m, i; - char *str; struct map_session_data *pl_sd = NULL; - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); m = map_mapname2mapid (str); if (m >= 0 && map[m].flag.pvp && map[m].flag.nopvp) { @@ -5622,9 +5610,7 @@ int buildin_pvpoff (struct script_state *st) int buildin_gvgon (struct script_state *st) { int m; - char *str; - - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); m = map_mapname2mapid (str); if (m >= 0 && !map[m].flag.gvg) { @@ -5638,9 +5624,7 @@ int buildin_gvgon (struct script_state *st) int buildin_gvgoff (struct script_state *st) { int m; - char *str; - - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); m = map_mapname2mapid (str); if (m >= 0 && map[m].flag.gvg) { @@ -5666,6 +5650,7 @@ int buildin_emotion (struct script_state *st) return 0; } +static int buildin_maprespawnguildid_sub (struct block_list *bl, va_list ap) { int g_id = va_arg (ap, int); @@ -5699,7 +5684,7 @@ int buildin_maprespawnguildid_sub (struct block_list *bl, va_list ap) int buildin_maprespawnguildid (struct script_state *st) { - char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); int g_id = conv_num (st, &(st->stack->stack_data[st->start + 3])); int flag = conv_num (st, &(st->stack->stack_data[st->start + 4])); @@ -5746,9 +5731,9 @@ int buildin_agitcheck (struct script_state *st) if (cond == 0) { if (agit_flag == 1) - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); if (agit_flag == 0) - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } else { @@ -5774,7 +5759,7 @@ int buildin_flagemblem (struct script_state *st) int buildin_getcastlename (struct script_state *st) { - char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); struct guild_castle *gc; int i; char *buf = NULL; @@ -5791,17 +5776,17 @@ int buildin_getcastlename (struct script_state *st) } } if (buf) - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); else - push_str (st->stack, C_CONSTSTR, ""); + push_str (st->stack, ScriptCode::CONSTSTR, ""); return 0; } int buildin_getcastledata (struct script_state *st) { - char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); int index = conv_num (st, &(st->stack->stack_data[st->start + 3])); - char *event = NULL; + const char *event = NULL; struct guild_castle *gc; int i, j; @@ -5831,95 +5816,95 @@ int buildin_getcastledata (struct script_state *st) guild_castledataload (gc->castle_id, j); break; // Initialize[AgitInit] case 1: - push_val (st->stack, C_INT, gc->guild_id); + push_val (st->stack, ScriptCode::INT, gc->guild_id); break; case 2: - push_val (st->stack, C_INT, gc->economy); + push_val (st->stack, ScriptCode::INT, gc->economy); break; case 3: - push_val (st->stack, C_INT, gc->defense); + push_val (st->stack, ScriptCode::INT, gc->defense); break; case 4: - push_val (st->stack, C_INT, gc->triggerE); + push_val (st->stack, ScriptCode::INT, gc->triggerE); break; case 5: - push_val (st->stack, C_INT, gc->triggerD); + push_val (st->stack, ScriptCode::INT, gc->triggerD); break; case 6: - push_val (st->stack, C_INT, gc->nextTime); + push_val (st->stack, ScriptCode::INT, gc->nextTime); break; case 7: - push_val (st->stack, C_INT, gc->payTime); + push_val (st->stack, ScriptCode::INT, gc->payTime); break; case 8: - push_val (st->stack, C_INT, gc->createTime); + push_val (st->stack, ScriptCode::INT, gc->createTime); break; case 9: - push_val (st->stack, C_INT, gc->visibleC); + push_val (st->stack, ScriptCode::INT, gc->visibleC); break; case 10: - push_val (st->stack, C_INT, gc->visibleG0); + push_val (st->stack, ScriptCode::INT, gc->visibleG0); break; case 11: - push_val (st->stack, C_INT, gc->visibleG1); + push_val (st->stack, ScriptCode::INT, gc->visibleG1); break; case 12: - push_val (st->stack, C_INT, gc->visibleG2); + push_val (st->stack, ScriptCode::INT, gc->visibleG2); break; case 13: - push_val (st->stack, C_INT, gc->visibleG3); + push_val (st->stack, ScriptCode::INT, gc->visibleG3); break; case 14: - push_val (st->stack, C_INT, gc->visibleG4); + push_val (st->stack, ScriptCode::INT, gc->visibleG4); break; case 15: - push_val (st->stack, C_INT, gc->visibleG5); + push_val (st->stack, ScriptCode::INT, gc->visibleG5); break; case 16: - push_val (st->stack, C_INT, gc->visibleG6); + push_val (st->stack, ScriptCode::INT, gc->visibleG6); break; case 17: - push_val (st->stack, C_INT, gc->visibleG7); + push_val (st->stack, ScriptCode::INT, gc->visibleG7); break; case 18: - push_val (st->stack, C_INT, gc->Ghp0); + push_val (st->stack, ScriptCode::INT, gc->Ghp0); break; case 19: - push_val (st->stack, C_INT, gc->Ghp1); + push_val (st->stack, ScriptCode::INT, gc->Ghp1); break; case 20: - push_val (st->stack, C_INT, gc->Ghp2); + push_val (st->stack, ScriptCode::INT, gc->Ghp2); break; case 21: - push_val (st->stack, C_INT, gc->Ghp3); + push_val (st->stack, ScriptCode::INT, gc->Ghp3); break; case 22: - push_val (st->stack, C_INT, gc->Ghp4); + push_val (st->stack, ScriptCode::INT, gc->Ghp4); break; case 23: - push_val (st->stack, C_INT, gc->Ghp5); + push_val (st->stack, ScriptCode::INT, gc->Ghp5); break; case 24: - push_val (st->stack, C_INT, gc->Ghp6); + push_val (st->stack, ScriptCode::INT, gc->Ghp6); break; case 25: - push_val (st->stack, C_INT, gc->Ghp7); + push_val (st->stack, ScriptCode::INT, gc->Ghp7); break; default: - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); break; } return 0; } } } - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } int buildin_setcastledata (struct script_state *st) { - char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); int index = conv_num (st, &(st->stack->stack_data[st->start + 3])); int value = conv_num (st, &(st->stack->stack_data[st->start + 4])); struct guild_castle *gc; @@ -6027,7 +6012,7 @@ int buildin_setcastledata (struct script_state *st) int buildin_requestguildinfo (struct script_state *st) { int guild_id = conv_num (st, &(st->stack->stack_data[st->start + 2])); - char *event = NULL; + const char *event = NULL; if (st->end > st->start + 3) event = conv_str (st, &(st->stack->stack_data[st->start + 3])); @@ -6052,7 +6037,7 @@ int buildin_getequipcardcnt (struct script_state *st) i = pc_checkequip (sd, equip[num - 1]); if (sd->status.inventory[i].card[0] == 0x00ff) { // 製造武器はカードなし - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } do @@ -6061,12 +6046,12 @@ int buildin_getequipcardcnt (struct script_state *st) (sd->status.inventory[i].card[c - 1] < 5000)) { - push_val (st->stack, C_INT, (c)); + push_val (st->stack, ScriptCode::INT, (c)); return 0; } } while (c--); - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } @@ -6217,16 +6202,14 @@ int buildin_failedremovecards (struct script_state *st) int buildin_mapwarp (struct script_state *st) // Added by RoVeRT { int x, y, m; - char *str; - char *mapname; int x0, y0, x1, y1; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = 0; y0 = 0; x1 = map[map_mapname2mapid (mapname)].xs; y1 = map[map_mapname2mapid (mapname)].ys; - str = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 3])); x = conv_num (st, &(st->stack->stack_data[st->start + 4])); y = conv_num (st, &(st->stack->stack_data[st->start + 5])); @@ -6240,10 +6223,8 @@ int buildin_mapwarp (struct script_state *st) // Added by RoVeRT int buildin_cmdothernpc (struct script_state *st) // Added by RoVeRT { - char *npc, *command; - - npc = conv_str (st, &(st->stack->stack_data[st->start + 2])); - command = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *npc = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *command = conv_str (st, &(st->stack->stack_data[st->start + 3])); npc_command (map_id2sd (st->rid), npc, command); return 0; @@ -6269,6 +6250,7 @@ int buildin_stoptimer (struct script_state *st) // Added by RoVeRT return 0; } +static int buildin_mobcount_sub (struct block_list *bl, va_list ap) // Added by RoVeRT { char *event = va_arg (ap, char *); @@ -6281,36 +6263,35 @@ int buildin_mobcount_sub (struct block_list *bl, va_list ap) // Added by RoVe int buildin_mobcount (struct script_state *st) // Added by RoVeRT { - char *mapname, *event; int m, c = 0; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); - event = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 3])); if ((m = map_mapname2mapid (mapname)) < 0) { - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } map_foreachinarea (buildin_mobcount_sub, m, 0, 0, map[m].xs, map[m].ys, BL_MOB, event, &c); - push_val (st->stack, C_INT, (c - 1)); + push_val (st->stack, ScriptCode::INT, (c - 1)); return 0; } int buildin_marriage (struct script_state *st) { - char *partner = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *partner = conv_str (st, &(st->stack->stack_data[st->start + 2])); struct map_session_data *sd = script_rid2sd (st); struct map_session_data *p_sd = map_nick2sd (partner); if (sd == NULL || p_sd == NULL || pc_marriage (sd, p_sd) < 0) { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); return 0; } @@ -6334,11 +6315,11 @@ int buildin_divorce (struct script_state *st) if (sd == NULL || pc_divorce (sd) < 0) { - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); return 0; } @@ -6359,26 +6340,26 @@ int buildin_strmobinfo (struct script_state *st) { char *buf; buf = mob_db[mob_class].name; - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); return 0; } else if (num == 2) { char *buf; buf = mob_db[mob_class].jname; - push_str (st->stack, C_STR, buf); + push_str (st->stack, ScriptCode::STR, buf); return 0; } else if (num == 3) - push_val (st->stack, C_INT, mob_db[mob_class].lv); + push_val (st->stack, ScriptCode::INT, mob_db[mob_class].lv); else if (num == 4) - push_val (st->stack, C_INT, mob_db[mob_class].max_hp); + push_val (st->stack, ScriptCode::INT, mob_db[mob_class].max_hp); else if (num == 5) - push_val (st->stack, C_INT, mob_db[mob_class].max_sp); + push_val (st->stack, ScriptCode::INT, mob_db[mob_class].max_sp); else if (num == 6) - push_val (st->stack, C_INT, mob_db[mob_class].base_exp); + push_val (st->stack, ScriptCode::INT, mob_db[mob_class].base_exp); else if (num == 7) - push_val (st->stack, C_INT, mob_db[mob_class].job_exp); + push_val (st->stack, ScriptCode::INT, mob_db[mob_class].job_exp); return 0; } @@ -6389,19 +6370,19 @@ int buildin_strmobinfo (struct script_state *st) int buildin_guardian (struct script_state *st) { int mob_class = 0, amount = 1, x = 0, y = 0, guardian = 0; - char *str, *map, *event = ""; + const char *event = ""; - map = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); - str = conv_str (st, &(st->stack->stack_data[st->start + 5])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 5])); mob_class = conv_num (st, &(st->stack->stack_data[st->start + 6])); amount = conv_num (st, &(st->stack->stack_data[st->start + 7])); event = conv_str (st, &(st->stack->stack_data[st->start + 8])); if (st->end > st->start + 9) guardian = conv_num (st, &(st->stack->stack_data[st->start + 9])); - mob_spawn_guardian (map_id2sd (st->rid), map, x, y, str, mob_class, amount, + mob_spawn_guardian (map_id2sd (st->rid), mapname, x, y, str, mob_class, amount, event, guardian); return 0; @@ -6418,23 +6399,23 @@ int buildin_guardianinfo (struct script_state *st) struct guild_castle *gc = guild_mapname2gc (map[sd->bl.m].name); if (guardian == 0 && gc->visibleG0 == 1) - push_val (st->stack, C_INT, gc->Ghp0); + push_val (st->stack, ScriptCode::INT, gc->Ghp0); if (guardian == 1 && gc->visibleG1 == 1) - push_val (st->stack, C_INT, gc->Ghp1); + push_val (st->stack, ScriptCode::INT, gc->Ghp1); if (guardian == 2 && gc->visibleG2 == 1) - push_val (st->stack, C_INT, gc->Ghp2); + push_val (st->stack, ScriptCode::INT, gc->Ghp2); if (guardian == 3 && gc->visibleG3 == 1) - push_val (st->stack, C_INT, gc->Ghp3); + push_val (st->stack, ScriptCode::INT, gc->Ghp3); if (guardian == 4 && gc->visibleG4 == 1) - push_val (st->stack, C_INT, gc->Ghp4); + push_val (st->stack, ScriptCode::INT, gc->Ghp4); if (guardian == 5 && gc->visibleG5 == 1) - push_val (st->stack, C_INT, gc->Ghp5); + push_val (st->stack, ScriptCode::INT, gc->Ghp5); if (guardian == 6 && gc->visibleG6 == 1) - push_val (st->stack, C_INT, gc->Ghp6); + push_val (st->stack, ScriptCode::INT, gc->Ghp6); if (guardian == 7 && gc->visibleG7 == 1) - push_val (st->stack, C_INT, gc->Ghp7); + push_val (st->stack, ScriptCode::INT, gc->Ghp7); else - push_val (st->stack, C_INT, -1); + push_val (st->stack, ScriptCode::INT, -1); return 0; } @@ -6451,7 +6432,7 @@ int buildin_getitemname (struct script_state *st) data = &(st->stack->stack_data[st->start + 2]); get_val (st, data); - if (data->type == C_STR || data->type == C_CONSTSTR) + if (data->type == ScriptCode::STR || data->type == ScriptCode::CONSTSTR) { const char *name = conv_str (st, data); i_data = itemdb_searchname (name); @@ -6468,38 +6449,32 @@ int buildin_getitemname (struct script_state *st) else strncpy (item_name, "Unknown Item", 23); - push_str (st->stack, C_STR, item_name); + push_str (st->stack, ScriptCode::STR, item_name); return 0; } int buildin_getspellinvocation (struct script_state *st) { - char *name; - char *invocation; - - name = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *name = conv_str (st, &(st->stack->stack_data[st->start + 2])); - invocation = magic_find_invocation (name); + const char *invocation = magic_find_invocation (name); if (!invocation) invocation = "..."; - push_str (st->stack, C_STR, strdup (invocation)); + push_str (st->stack, ScriptCode::STR, strdup (invocation)); return 0; } int buildin_getanchorinvocation (struct script_state *st) { - char *name; - char *invocation; - - name = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *name = conv_str (st, &(st->stack->stack_data[st->start + 2])); - invocation = magic_find_anchor_invocation (name); + const char *invocation = magic_find_anchor_invocation (name); if (!invocation) invocation = "..."; - push_str (st->stack, C_STR, strdup (invocation)); + push_str (st->stack, ScriptCode::STR, strdup (invocation)); return 0; } @@ -6507,7 +6482,7 @@ int buildin_getpartnerid (struct script_state *st) { struct map_session_data *sd = script_rid2sd (st); - push_val (st->stack, C_INT, sd->status.partner_id); + push_val (st->stack, ScriptCode::INT, sd->status.partner_id); return 0; } @@ -6698,7 +6673,7 @@ int buildin_check_pool_skill (struct script_state *st) struct map_session_data *sd = script_rid2sd (st); int skill_id = conv_num (st, &(st->stack->stack_data[st->start + 2])); - push_val (st->stack, C_INT, skill_pool_is_activated (sd, skill_id)); + push_val (st->stack, ScriptCode::INT, skill_pool_is_activated (sd, skill_id)); return 0; } @@ -6752,7 +6727,7 @@ int buildin_misceffect (struct script_state *st) { int type; int id = 0; - char *name = NULL; + const char *name = NULL; struct block_list *bl = NULL; type = conv_num (st, &(st->stack->stack_data[st->start + 2])); @@ -6763,7 +6738,7 @@ int buildin_misceffect (struct script_state *st) get_val (st, sdata); - if (sdata->type == C_STR || sdata->type == C_CONSTSTR) + if (sdata->type == ScriptCode::STR || sdata->type == ScriptCode::CONSTSTR) name = conv_str (st, sdata); else id = conv_num (st, sdata); @@ -6799,10 +6774,9 @@ int buildin_misceffect (struct script_state *st) int buildin_soundeffect (struct script_state *st) { struct map_session_data *sd = script_rid2sd (st); - char *name; int type = 0; - name = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *name = conv_str (st, &(st->stack->stack_data[st->start + 2])); type = conv_num (st, &(st->stack->stack_data[st->start + 3])); if (sd) { @@ -6920,10 +6894,9 @@ int buildin_unequip_by_id (struct script_state *st) int buildin_gmcommand (struct script_state *st) { struct map_session_data *sd; - char *cmd; sd = script_rid2sd (st); - cmd = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *cmd = conv_str (st, &(st->stack->stack_data[st->start + 2])); is_atcommand (sd->fd, sd, cmd, 99); @@ -6938,15 +6911,14 @@ int buildin_gmcommand (struct script_state *st) int buildin_movenpc (struct script_state *st) { struct map_session_data *sd; - char *map, *npc; int x, y; sd = script_rid2sd (st); - map = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x = conv_num (st, &(st->stack->stack_data[st->start + 3])); y = conv_num (st, &(st->stack->stack_data[st->start + 4])); - npc = conv_str (st, &(st->stack->stack_data[st->start + 5])); + const char *npc = conv_str (st, &(st->stack->stack_data[st->start + 5])); return 0; } @@ -6959,12 +6931,11 @@ int buildin_movenpc (struct script_state *st) int buildin_npcwarp (struct script_state *st) { int x, y; - char *npc; struct npc_data *nd = NULL; x = conv_num (st, &(st->stack->stack_data[st->start + 2])); y = conv_num (st, &(st->stack->stack_data[st->start + 3])); - npc = conv_str (st, &(st->stack->stack_data[st->start + 4])); + const char *npc = conv_str (st, &(st->stack->stack_data[st->start + 4])); nd = npc_name2id (npc); if (!nd) @@ -6995,11 +6966,10 @@ int buildin_npcwarp (struct script_state *st) int buildin_message (struct script_state *st) { - char *msg, *player; struct map_session_data *pl_sd = NULL; - player = conv_str (st, &(st->stack->stack_data[st->start + 2])); - msg = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *player = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *msg = conv_str (st, &(st->stack->stack_data[st->start + 3])); if ((pl_sd = map_nick2sd ((char *) player)) == NULL) return 1; @@ -7016,11 +6986,10 @@ int buildin_message (struct script_state *st) int buildin_npctalk (struct script_state *st) { - char *str; char message[255]; struct npc_data *nd = (struct npc_data *) map_id2bl (st->oid); - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); if (nd) { @@ -7051,12 +7020,12 @@ int buildin_hasitems (struct script_state *st) { if (sd->status.inventory[i].amount) { - push_val (st->stack, C_INT, 1); + push_val (st->stack, ScriptCode::INT, 1); return 0; } } - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); return 0; } @@ -7103,7 +7072,7 @@ int buildin_getlook (struct script_state *st) break; } - push_val (st->stack, C_INT, val); + push_val (st->stack, ScriptCode::INT, val); return 0; } @@ -7128,13 +7097,13 @@ int buildin_getsavepoint (struct script_state *st) case 0: mapname = (char*)calloc (24, 1); strncpy (mapname, sd->status.save_point.map, 23); - push_str (st->stack, C_STR, mapname); + push_str (st->stack, ScriptCode::STR, mapname); break; case 1: - push_val (st->stack, C_INT, x); + push_val (st->stack, ScriptCode::INT, x); break; case 2: - push_val (st->stack, C_INT, y); + push_val (st->stack, ScriptCode::INT, y); break; } return 0; @@ -7144,6 +7113,7 @@ int buildin_getsavepoint (struct script_state *st) * areatimer *------------------------------------------ */ +static int buildin_areatimer_sub (struct block_list *bl, va_list ap) { int tick; @@ -7157,17 +7127,15 @@ int buildin_areatimer_sub (struct block_list *bl, va_list ap) int buildin_areatimer (struct script_state *st) { int tick, m; - char *event; - char *mapname; int x0, y0, x1, y1; - mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *mapname = conv_str (st, &(st->stack->stack_data[st->start + 2])); x0 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y0 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 5])); y1 = conv_num (st, &(st->stack->stack_data[st->start + 6])); tick = conv_num (st, &(st->stack->stack_data[st->start + 7])); - event = conv_str (st, &(st->stack->stack_data[st->start + 8])); + const char *event = conv_str (st, &(st->stack->stack_data[st->start + 8])); if ((m = map_mapname2mapid (mapname)) < 0) return 0; @@ -7184,10 +7152,9 @@ int buildin_areatimer (struct script_state *st) int buildin_isin (struct script_state *st) { int x1, y1, x2, y2; - char *str; struct map_session_data *sd = script_rid2sd (st); - str = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *str = conv_str (st, &(st->stack->stack_data[st->start + 2])); x1 = conv_num (st, &(st->stack->stack_data[st->start + 3])); y1 = conv_num (st, &(st->stack->stack_data[st->start + 4])); x2 = conv_num (st, &(st->stack->stack_data[st->start + 5])); @@ -7196,7 +7163,7 @@ int buildin_isin (struct script_state *st) if (!sd) return 1; - push_val (st->stack, C_INT, + push_val (st->stack, ScriptCode::INT, (sd->bl.x >= x1 && sd->bl.x <= x2) && (sd->bl.y >= y1 && sd->bl.y <= y2) && (!strcmp (str, map[sd->bl.m].name))); @@ -7230,7 +7197,7 @@ int buildin_isdead (struct script_state *st) { struct map_session_data *sd = script_rid2sd (st); - push_val (st->stack, C_INT, pc_isdead (sd)); + push_val (st->stack, ScriptCode::INT, pc_isdead (sd)); return 0; } @@ -7240,12 +7207,11 @@ int buildin_isdead (struct script_state *st) */ int buildin_fakenpcname (struct script_state *st) { - char *name, *newname; int newsprite; struct npc_data *nd; - name = conv_str (st, &(st->stack->stack_data[st->start + 2])); - newname = conv_str (st, &(st->stack->stack_data[st->start + 3])); + const char *name = conv_str (st, &(st->stack->stack_data[st->start + 2])); + const char *newname = conv_str (st, &(st->stack->stack_data[st->start + 3])); newsprite = conv_num (st, &(st->stack->stack_data[st->start + 4])); nd = npc_name2id (name); if (!nd) @@ -7270,7 +7236,7 @@ int buildin_getx (struct script_state *st) { struct map_session_data *sd = script_rid2sd (st); - push_val (st->stack, C_INT, sd->bl.x); + push_val (st->stack, ScriptCode::INT, sd->bl.x); return 0; } @@ -7282,7 +7248,7 @@ int buildin_gety (struct script_state *st) { struct map_session_data *sd = script_rid2sd (st); - push_val (st->stack, C_INT, sd->bl.y); + push_val (st->stack, ScriptCode::INT, sd->bl.y); return 0; } @@ -7293,82 +7259,58 @@ int buildin_gety (struct script_state *st) * コマンドの読み取り *------------------------------------------ */ -static int unget_com_data = -1; -int get_com (unsigned char *script, int *pos) -{ - int i, j; - if (unget_com_data >= 0) - { - i = unget_com_data; - unget_com_data = -1; - return i; - } - if (script[*pos] >= 0x80) - { - return C_INT; - } - i = 0; - j = 0; - while (script[*pos] >= 0x40) - { - i = script[(*pos)++] << j; - j += 6; - } - return i + (script[(*pos)++] << j); -} - -/*========================================== - * コマンドのプッシュバック - *------------------------------------------ - */ -void unget_com (int c) +static +ScriptCode get_com (const ScriptCode *script, int *pos_) { - if (unget_com_data != -1) + if (static_cast<uint8_t>(script[*pos_]) >= 0x80) { - if (battle_config.error_log) - printf ("unget_com can back only 1 data\n"); + return ScriptCode::INT; } - unget_com_data = c; + return script[(*pos_)++]; } /*========================================== * 数値の所得 *------------------------------------------ */ -int get_num (unsigned char *script, int *pos) +static +int get_num (const ScriptCode *scr, int *pos_) { + const uint8_t *script = reinterpret_cast<const uint8_t *>(scr); int i, j; i = 0; j = 0; - while (script[*pos] >= 0xc0) + while (script[*pos_] >= 0xc0) { - i += (script[(*pos)++] & 0x7f) << j; + i += (script[(*pos_)++] & 0x7f) << j; j += 6; } - return i + ((script[(*pos)++] & 0x7f) << j); + return i + ((script[(*pos_)++] & 0x7f) << j); } /*========================================== * スタックから値を取り出す *------------------------------------------ */ +static int pop_val (struct script_state *st) { if (st->stack->sp <= 0) return 0; st->stack->sp--; get_val (st, &(st->stack->stack_data[st->stack->sp])); - if (st->stack->stack_data[st->stack->sp].type == C_INT) + if (st->stack->stack_data[st->stack->sp].type == ScriptCode::INT) return st->stack->stack_data[st->stack->sp].u.num; return 0; } -#define isstr(c) ((c).type==C_STR || (c).type==C_CONSTSTR) +#define isstr(c) ((c).type==ScriptCode::STR || (c).type==ScriptCode::CONSTSTR) /*========================================== * 加算演算子 *------------------------------------------ */ +static void op_add (struct script_state *st) { st->stack->sp--; @@ -7381,7 +7323,7 @@ void op_add (struct script_state *st) conv_str (st, &(st->stack->stack_data[st->stack->sp])); conv_str (st, &(st->stack->stack_data[st->stack->sp - 1])); } - if (st->stack->stack_data[st->stack->sp].type == C_INT) + if (st->stack->stack_data[st->stack->sp].type == ScriptCode::INT) { // ii st->stack->stack_data[st->stack->sp - 1].u.num += st->stack->stack_data[st->stack->sp].u.num; @@ -7395,11 +7337,11 @@ void op_add (struct script_state *st) 1); strcpy (buf, st->stack->stack_data[st->stack->sp - 1].u.str); strcat (buf, st->stack->stack_data[st->stack->sp].u.str); - if (st->stack->stack_data[st->stack->sp - 1].type == C_STR) - free (st->stack->stack_data[st->stack->sp - 1].u.str); - if (st->stack->stack_data[st->stack->sp].type == C_STR) - free (st->stack->stack_data[st->stack->sp].u.str); - st->stack->stack_data[st->stack->sp - 1].type = C_STR; + if (st->stack->stack_data[st->stack->sp - 1].type == ScriptCode::STR) + free(const_cast<char *>(st->stack->stack_data[st->stack->sp - 1].u.str)); + if (st->stack->stack_data[st->stack->sp].type == ScriptCode::STR) + free(const_cast<char *>(st->stack->stack_data[st->stack->sp].u.str)); + st->stack->stack_data[st->stack->sp - 1].type = ScriptCode::STR; st->stack->stack_data[st->stack->sp - 1].u.str = buf; } } @@ -7408,30 +7350,31 @@ void op_add (struct script_state *st) * 二項演算子(文字列) *------------------------------------------ */ -void op_2str (struct script_state *st, int op, int sp1, int sp2) +static +void op_2str (struct script_state *st, ScriptCode op, int sp1, int sp2) { - char *s1 = st->stack->stack_data[sp1].u.str, - *s2 = st->stack->stack_data[sp2].u.str; + const char *s1 = st->stack->stack_data[sp1].u.str; + const char *s2 = st->stack->stack_data[sp2].u.str; int a = 0; switch (op) { - case C_EQ: + case ScriptCode::EQ: a = (strcmp (s1, s2) == 0); break; - case C_NE: + case ScriptCode::NE: a = (strcmp (s1, s2) != 0); break; - case C_GT: + case ScriptCode::GT: a = (strcmp (s1, s2) > 0); break; - case C_GE: + case ScriptCode::GE: a = (strcmp (s1, s2) >= 0); break; - case C_LT: + case ScriptCode::LT: a = (strcmp (s1, s2) < 0); break; - case C_LE: + case ScriptCode::LE: a = (strcmp (s1, s2) <= 0); break; default: @@ -7439,85 +7382,87 @@ void op_2str (struct script_state *st, int op, int sp1, int sp2) break; } - push_val (st->stack, C_INT, a); + push_val (st->stack, ScriptCode::INT, a); - if (st->stack->stack_data[sp1].type == C_STR) - free (s1); - if (st->stack->stack_data[sp2].type == C_STR) - free (s2); + if (st->stack->stack_data[sp1].type == ScriptCode::STR) + free(const_cast<char *>(s1)); + if (st->stack->stack_data[sp2].type == ScriptCode::STR) + free(const_cast<char *>(s2)); } /*========================================== * 二項演算子(数値) *------------------------------------------ */ -void op_2num (struct script_state *st, int op, int i1, int i2) +static +void op_2num (struct script_state *st, ScriptCode op, int i1, int i2) { switch (op) { - case C_SUB: + case ScriptCode::SUB: i1 -= i2; break; - case C_MUL: + case ScriptCode::MUL: i1 *= i2; break; - case C_DIV: + case ScriptCode::DIV: i1 /= i2; break; - case C_MOD: + case ScriptCode::MOD: i1 %= i2; break; - case C_AND: + case ScriptCode::AND: i1 &= i2; break; - case C_OR: + case ScriptCode::OR: i1 |= i2; break; - case C_XOR: + case ScriptCode::XOR: i1 ^= i2; break; - case C_LAND: + case ScriptCode::LAND: i1 = i1 && i2; break; - case C_LOR: + case ScriptCode::LOR: i1 = i1 || i2; break; - case C_EQ: + case ScriptCode::EQ: i1 = i1 == i2; break; - case C_NE: + case ScriptCode::NE: i1 = i1 != i2; break; - case C_GT: + case ScriptCode::GT: i1 = i1 > i2; break; - case C_GE: + case ScriptCode::GE: i1 = i1 >= i2; break; - case C_LT: + case ScriptCode::LT: i1 = i1 < i2; break; - case C_LE: + case ScriptCode::LE: i1 = i1 <= i2; break; - case C_R_SHIFT: + case ScriptCode::R_SHIFT: i1 = i1 >> i2; break; - case C_L_SHIFT: + case ScriptCode::L_SHIFT: i1 = i1 << i2; break; } - push_val (st->stack, C_INT, i1); + push_val (st->stack, ScriptCode::INT, i1); } /*========================================== * 二項演算子 *------------------------------------------ */ -void op_2 (struct script_state *st, int op) +static +void op_2 (struct script_state *st, ScriptCode op) { int i1, i2; - char *s1 = NULL, *s2 = NULL; + const char *s1 = NULL, *s2 = NULL; i2 = pop_val (st); if (isstr (st->stack->stack_data[st->stack->sp])) @@ -7541,7 +7486,7 @@ void op_2 (struct script_state *st, int op) { // si,is => error printf ("script: op_2: int&str, str&int not allow."); - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } } @@ -7549,23 +7494,24 @@ void op_2 (struct script_state *st, int op) * 単項演算子 *------------------------------------------ */ -void op_1num (struct script_state *st, int op) +static +void op_1num (struct script_state *st, ScriptCode op) { int i1; i1 = pop_val (st); switch (op) { - case C_NEG: + case ScriptCode::NEG: i1 = -i1; break; - case C_NOT: + case ScriptCode::NOT: i1 = ~i1; break; - case C_LNOT: + case ScriptCode::LNOT: i1 = !i1; break; } - push_val (st->stack, C_INT, i1); + push_val (st->stack, ScriptCode::INT, i1); } /*========================================== @@ -7577,7 +7523,7 @@ int run_func (struct script_state *st) int i, start_sp, end_sp, func; end_sp = st->stack->sp; - for (i = end_sp - 1; i >= 0 && st->stack->stack_data[i].type != C_ARG; + for (i = end_sp - 1; i >= 0 && st->stack->stack_data[i].type != ScriptCode::ARG; i--); if (i == 0) { @@ -7592,8 +7538,8 @@ int run_func (struct script_state *st) st->end = end_sp; func = st->stack->stack_data[st->start].u.num; - if (st->stack->stack_data[st->start].type != C_NAME - || str_data[func].type != C_FUNC) + if (st->stack->stack_data[st->start].type != ScriptCode::NAME + || str_data[func].type != ScriptCode::FUNC) { printf ("run_func: not function and command! \n"); // st->stack->sp=0; @@ -7610,18 +7556,18 @@ int run_func (struct script_state *st) { switch (st->stack->stack_data[i].type) { - case C_INT: + case ScriptCode::INT: printf (" int(%d)", st->stack->stack_data[i].u.num); break; - case C_NAME: + case ScriptCode::NAME: printf (" name(%s)", str_buf + str_data[st->stack->stack_data[i].u.num].str); break; - case C_ARG: + case ScriptCode::ARG: printf (" arg"); break; - case C_POS: + case ScriptCode::POS: printf (" pos(%d)", st->stack->stack_data[i].u.num); break; default: @@ -7641,7 +7587,7 @@ int run_func (struct script_state *st) if (battle_config.error_log) printf ("run_func : %s? (%d(%d))\n", str_buf + str_data[func].str, func, str_data[func].type); - push_val (st->stack, C_INT, 0); + push_val (st->stack, ScriptCode::INT, 0); } pop_stack (st->stack, start_sp, end_sp); @@ -7650,11 +7596,10 @@ int run_func (struct script_state *st) { // ユーザー定義関数からの復帰 int olddefsp = st->defsp; - int i; pop_stack (st->stack, st->defsp, start_sp); // 復帰に邪魔なスタック削除 if (st->defsp < 4 - || st->stack->stack_data[st->defsp - 1].type != C_RETINFO) + || st->stack->stack_data[st->defsp - 1].type != ScriptCode::RETINFO) { printf ("script:run_func(return) return without callfunc or callsub!\n"); @@ -7663,7 +7608,7 @@ int run_func (struct script_state *st) } i = conv_num (st, &(st->stack->stack_data[st->defsp - 4])); // 引数の数所得 st->pos = conv_num (st, &(st->stack->stack_data[st->defsp - 1])); // スクリプト位置の復元 - st->script = (char *) conv_num (st, &(st->stack->stack_data[st->defsp - 2])); // スクリプトを復元 + st->script = (ScriptCode *) conv_num (st, &(st->stack->stack_data[st->defsp - 2])); // スクリプトを復元 st->defsp = conv_num (st, &(st->stack->stack_data[st->defsp - 3])); // 基準スタックポインタを復元 pop_stack (st->stack, olddefsp - 4 - i, olddefsp); // 要らなくなったスタック(引数と復帰用データ)削除 @@ -7678,10 +7623,11 @@ int run_func (struct script_state *st) * スクリプトの実行メイン部分 *------------------------------------------ */ -int run_script_main (unsigned char *script, int pos, int rid, int oid, - struct script_state *st, unsigned char *rootscript) +static +int run_script_main (const ScriptCode *script, int pos_, int rid, int oid, + struct script_state *st, const ScriptCode *rootscript) { - int c, rerun_pos; + int rerun_pos; int cmdcount = script_config.check_cmdcount; int gotocount = script_config.check_gotocount; struct script_stack *stack = st->stack; @@ -7692,9 +7638,9 @@ int run_script_main (unsigned char *script, int pos, int rid, int oid, rerun_pos = st->pos; for (st->state = 0; st->state == 0;) { - switch (c = get_com (script, &st->pos)) + switch (ScriptCode c = get_com (script, &st->pos)) { - case C_EOL: + case ScriptCode::EOL: if (stack->sp != st->defsp) { if (battle_config.error_log) @@ -7704,22 +7650,22 @@ int run_script_main (unsigned char *script, int pos, int rid, int oid, } rerun_pos = st->pos; break; - case C_INT: - push_val (stack, C_INT, get_num (script, &st->pos)); + case ScriptCode::INT: + push_val (stack, ScriptCode::INT, get_num (script, &st->pos)); break; - case C_POS: - case C_NAME: + case ScriptCode::POS: + case ScriptCode::NAME: push_val (stack, c, (*(int *) (script + st->pos)) & 0xffffff); st->pos += 3; break; - case C_ARG: + case ScriptCode::ARG: push_val (stack, c, 0); break; - case C_STR: - push_str (stack, C_CONSTSTR, script + st->pos); - while (script[st->pos++]); + case ScriptCode::STR: + push_str (stack, ScriptCode::CONSTSTR, reinterpret_cast<const char *>(script + st->pos)); + while (script[st->pos++] != ScriptCode::NOP); break; - case C_FUNC: + case ScriptCode::FUNC: run_func (st); if (st->state == GOTO) { @@ -7734,43 +7680,43 @@ int run_script_main (unsigned char *script, int pos, int rid, int oid, } break; - case C_ADD: + case ScriptCode::ADD: op_add (st); break; - case C_SUB: - case C_MUL: - case C_DIV: - case C_MOD: - case C_EQ: - case C_NE: - case C_GT: - case C_GE: - case C_LT: - case C_LE: - case C_AND: - case C_OR: - case C_XOR: - case C_LAND: - case C_LOR: - case C_R_SHIFT: - case C_L_SHIFT: + case ScriptCode::SUB: + case ScriptCode::MUL: + case ScriptCode::DIV: + case ScriptCode::MOD: + case ScriptCode::EQ: + case ScriptCode::NE: + case ScriptCode::GT: + case ScriptCode::GE: + case ScriptCode::LT: + case ScriptCode::LE: + case ScriptCode::AND: + case ScriptCode::OR: + case ScriptCode::XOR: + case ScriptCode::LAND: + case ScriptCode::LOR: + case ScriptCode::R_SHIFT: + case ScriptCode::L_SHIFT: op_2 (st, c); break; - case C_NEG: - case C_NOT: - case C_LNOT: + case ScriptCode::NEG: + case ScriptCode::NOT: + case ScriptCode::LNOT: op_1num (st, c); break; - case C_NOP: + case ScriptCode::NOP: st->state = END; break; default: if (battle_config.error_log) - printf ("unknown command : %d @ %d\n", c, pos); + printf ("unknown command : %d @ %d\n", c, pos_); st->state = END; break; } @@ -7825,23 +7771,23 @@ int run_script_main (unsigned char *script, int pos, int rid, int oid, * スクリプトの実行 *------------------------------------------ */ -int run_script (unsigned char *script, int pos, int rid, int oid) +int run_script (const ScriptCode *script, int pos_, int rid, int oid) { - return run_script_l (script, pos, rid, oid, 0, NULL); + return run_script_l (script, pos_, rid, oid, 0, NULL); } -int run_script_l (unsigned char *script, int pos, int rid, int oid, +int run_script_l (const ScriptCode *script, int pos_, int rid, int oid, int args_nr, argrec_t * args) { struct script_stack stack; struct script_state st; struct map_session_data *sd = map_id2sd (rid); - unsigned char *rootscript = script; + const ScriptCode *rootscript = script; int i; - if (script == NULL || pos < 0) + if (script == NULL || pos_ < 0) return -1; - if (sd && sd->npc_stackbuf && sd->npc_scriptroot == (char *) rootscript) + if (sd && sd->npc_stackbuf && sd->npc_scriptroot == rootscript) { // 前回のスタックを復帰 script = sd->npc_script; @@ -7863,7 +7809,7 @@ int run_script_l (unsigned char *script, int pos, int rid, int oid, calloc (stack.sp_max, sizeof (stack.stack_data[0])); } st.stack = &stack; - st.pos = pos; + st.pos = pos_; st.rid = rid; st.oid = oid; for (i = 0; i < args_nr; i++) @@ -7873,7 +7819,7 @@ int run_script_l (unsigned char *script, int pos, int rid, int oid, else pc_setreg (sd, add_str (args[i].name), args[i].v.i); } - run_script_main (script, pos, rid, oid, &st, rootscript); + run_script_main (script, pos_, rid, oid, &st, rootscript); free (stack.stack_data); stack.stack_data = NULL; @@ -8046,7 +7992,7 @@ static int set_posword (char *p) return 0; } -int script_config_read (char *cfgName) +int script_config_read (const char *cfgName) { int i; char line[1024], w1[1024], w2[1024]; diff --git a/src/map/script.hpp b/src/map/script.hpp index a96bc5a..6b345c4 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -2,13 +2,48 @@ #ifndef SCRIPT_HPP #define SCRIPT_HPP +// values are private, but gcc < 4.6 doesn't +// support forward-declared enums +enum class ScriptCode : uint8_t +#ifdef RECENT_GCC +; +#else +{ + // types and specials + NOP, POS, INT, PARAM, FUNC, STR, CONSTSTR, ARG, + NAME, EOL, RETINFO, + + // unary and binary operators + LOR, LAND, LE, LT, GE, GT, EQ, NE, + XOR, OR, AND, ADD, SUB, MUL, DIV, MOD, NEG, LNOT, + NOT, R_SHIFT, L_SHIFT, + + // really nasty workaround for gcc < 4.6 + + x20, x21, x22, x23, x24, x25, x26, x27, x28, x29, x2a, x2b, x2c, x2d, x2e, x2f, + x30, x31, x32, x33, x34, x35, x36, x37, x38, x39, x3a, x3b, x3c, x3d, x3e, x3f, + x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x4a, x4b, x4c, x4d, x4e, x4f, + x50, x51, x52, x53, x54, x55, x56, x57, x58, x59, x5a, x5b, x5c, x5d, x5e, x5f, + x60, x61, x62, x63, x64, x65, x66, x67, x68, x69, x6a, x6b, x6c, x6d, x6e, x6f, + x70, x71, x72, x73, x74, x75, x76, x77, x78, x79, x7a, x7b, x7c, x7d, x7e, x7f, + x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x8a, x8b, x8c, x8d, x8e, x8f, + x90, x91, x92, x93, x94, x95, x96, x97, x98, x99, x9a, x9b, x9c, x9d, x9e, x9f, + xa0, xa1, xa2, xa3, xa4, xa5, xa6, xa7, xa8, xa9, xaa, xab, xac, xad, xae, xaf, + xb0, xb1, xb2, xb3, xb4, xb5, xb6, xb7, xb8, xb9, xba, xbb, xbc, xbd, xbe, xbf, + xc0, xc1, xc2, xc3, xc4, xc5, xc6, xc7, xc8, xc9, xca, xcb, xcc, xcd, xce, xcf, + xd0, xd1, xd2, xd3, xd4, xd5, xd6, xd7, xd8, xd9, xda, xdb, xdc, xdd, xde, xdf, + xe0, xe1, xe2, xe3, xe4, xe5, xe6, xe7, xe8, xe9, xea, xeb, xec, xed, xee, xef, + xf0, xf1, xf2, xf3, xf4, xf5, xf6, xf7, xf8, xf9, xfa, xfb, xfc, xfd, xfe, xff, +}; +#endif + struct script_data { - int type; + ScriptCode type; union { int num; - char *str; + const char *str; } u; }; @@ -17,33 +52,38 @@ struct script_stack int sp, sp_max; struct script_data *stack_data; }; + struct script_state { struct script_stack *stack; int start, end; int pos, state; int rid, oid; - char *script, *new_script; + const ScriptCode *script, *new_script; int defsp, new_pos, new_defsp; }; -unsigned char *parse_script (unsigned char *, int); +const ScriptCode *parse_script (const char *, int); typedef struct argrec { - char *name; - union + const char *name; + union _aru { int i; - char *s; + const char *s; + + _aru() = default; + _aru(int n) : i(n) {} + _aru(const char *z) : s(z) {} } v; } argrec_t; -int run_script_l (unsigned char *, int, int, int, int, argrec_t * args); -int run_script (unsigned char *, int, int, int); +int run_script_l (const ScriptCode *, int, int, int, int, argrec_t * args); +int run_script (const ScriptCode *, int, int, int); struct dbt *script_get_label_db (void); struct dbt *script_get_userfunc_db (void); -int script_config_read (char *cfgName); +int script_config_read (const char *cfgName); int do_init_script (void); int do_final_script (void); diff --git a/src/map/skill-pools.cpp b/src/map/skill-pools.cpp index 6ab6ea5..204036d 100644 --- a/src/map/skill-pools.cpp +++ b/src/map/skill-pools.cpp @@ -27,7 +27,7 @@ int skill_pool_skills[MAX_POOL_SKILLS]; int skill_pool_skills_size = 0; -extern void skill_pool_register (int id) +void skill_pool_register(int id) { if (skill_pool_skills_size + 1 >= MAX_POOL_SKILLS) { @@ -39,7 +39,7 @@ extern void skill_pool_register (int id) skill_pool_skills[skill_pool_skills_size++] = id; } -char *skill_name (int skill) +const char *skill_name (int skill) { if (skill > 0 && skill < MAX_SKILL_DB) return skill_names[skill].desc; diff --git a/src/map/skill.cpp b/src/map/skill.cpp index 779af98..dfacf8c 100644 --- a/src/map/skill.cpp +++ b/src/map/skill.cpp @@ -830,6 +830,7 @@ int skill_get_mhp (int id, int lv) return (lv <= 0) ? 0 : skill_db[id].mhp[lv - 1]; } +static int skill_get_castnodex (int id, int lv) { return (lv <= 0) ? 0 : skill_db[id].castnodex[lv - 1]; @@ -840,9 +841,6 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, int skillid, int skilllv, int x, int y, int flag); int skill_check_condition (struct map_session_data *sd, int type); -int skill_castend_damage_id (struct block_list *src, struct block_list *bl, - int skillid, int skilllv, unsigned int tick, - int flag); int skill_frostjoke_scream (struct block_list *bl, va_list ap); int skill_status_change_timer_sub (struct block_list *bl, va_list ap); int skill_attack_area (struct block_list *bl, va_list ap); @@ -1533,6 +1531,7 @@ int skill_additional_effect (struct block_list *src, struct block_list *bl, /*========================================================================= スキル攻撃吹き飛ばし処理 -------------------------------------------------------------------------*/ +static int skill_blown (struct block_list *src, struct block_list *target, int count) { int dx = 0, dy = 0, nx, ny; @@ -2091,6 +2090,7 @@ int skill_attack (int attack_type, struct block_list *src, static int skill_area_temp[8]; /* 一時変数。必要なら使う。 */ typedef int (*SkillFunc) (struct block_list *, struct block_list *, int, int, unsigned int, int); +static int skill_area_sub (struct block_list *bl, va_list ap) { struct block_list *src; @@ -2237,6 +2237,7 @@ int skill_check_unit_range2 (int m, int x, int y, int range) * 範囲スキル使用処理小分けここから */ /* 対象の数をカウントする。(skill_area_temp[0]を初期化しておくこと) */ +static int skill_area_sub_count (struct block_list *src, struct block_list *target, int skillid, int skilllv, unsigned int tick, int flag) @@ -2250,7 +2251,7 @@ int skill_area_sub_count (struct block_list *src, struct block_list *target, * *------------------------------------------ */ -static void skill_timerskill (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) +static void skill_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct map_session_data *sd = NULL; struct mob_data *md = NULL; @@ -2433,7 +2434,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, if (sd->skilltimerskill[i].timer == -1) { sd->skilltimerskill[i].timer = - add_timer (tick, skill_timerskill, src->id, i); + add_timer (tick, skill_timer, src->id, i); sd->skilltimerskill[i].src_id = src->id; sd->skilltimerskill[i].target_id = target; sd->skilltimerskill[i].skill_id = skill_id; @@ -2458,7 +2459,7 @@ int skill_addtimerskill (struct block_list *src, unsigned int tick, if (md->skilltimerskill[i].timer == -1) { md->skilltimerskill[i].timer = - add_timer (tick, skill_timerskill, src->id, i); + add_timer (tick, skill_timer, src->id, i); md->skilltimerskill[i].src_id = src->id; md->skilltimerskill[i].target_id = target; md->skilltimerskill[i].skill_id = skill_id; @@ -2496,7 +2497,7 @@ int skill_cleartimerskill (struct block_list *src) { if (sd->skilltimerskill[i].timer != -1) { - delete_timer (sd->skilltimerskill[i].timer, skill_timerskill); + delete_timer (sd->skilltimerskill[i].timer, skill_timer); sd->skilltimerskill[i].timer = -1; } } @@ -2509,7 +2510,7 @@ int skill_cleartimerskill (struct block_list *src) { if (md->skilltimerskill[i].timer != -1) { - delete_timer (md->skilltimerskill[i].timer, skill_timerskill); + delete_timer (md->skilltimerskill[i].timer, skill_timer); md->skilltimerskill[i].timer = -1; } } @@ -2532,7 +2533,6 @@ int skill_castend_damage_id (struct block_list *src, struct block_list *bl, int flag) { struct map_session_data *sd = NULL; - int i; nullpo_retr (1, src); nullpo_retr (1, bl); @@ -2687,7 +2687,7 @@ int skill_castend_damage_id (struct block_list *src, struct block_list *bl, flag); if (sd) { - for (i = 1; i < sd->spiritball_old; i++) + for (int i = 1; i < sd->spiritball_old; i++) skill_addtimerskill (src, tick + i * 200, bl->id, 0, 0, skillid, skilllv, BF_WEAPON, flag); @@ -3173,7 +3173,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, struct map_session_data *dstsd = NULL; struct mob_data *md = NULL; struct mob_data *dstmd = NULL; - int i; int sc_def_vit, sc_def_mdef, strip_fix, strip_time, strip_per; int sc_dex, sc_luk; //クラスチェンジ用ボスモンスターID @@ -3727,7 +3726,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, map_freeblock_unlock (); return 1; } - for (i = 0; i < skilllv; i++) + for (int i = 0; i < skilllv; i++) { if (!sd->dev.val1[i]) { // 空きがあったら入れる @@ -3764,7 +3763,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, if (sd) { clif_skill_nodamage (src, bl, skillid, skilllv, 1); - for (i = 0; i < 5; i++) + for (int i = 0; i < 5; i++) pc_addspiritball (sd, skill_get_time (skillid, skilllv), 5); } @@ -3776,7 +3775,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, skill_get_time (skillid, skilllv), 0); break; case MO_ABSORBSPIRITS: // 気奪 - i = 0; + { + int i = 0; if (sd && dstsd) { if (sd == dstsd || map[sd->bl.m].flag.pvp @@ -3811,6 +3811,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, else clif_skill_nodamage (src, bl, skillid, skilllv, 0); break; + } case AC_MAKINGARROW: /* 矢作成 */ /* if(sd) { @@ -4334,7 +4335,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, skilllv, 0, 0, 0, strip_time, 0); if (dstsd) { - for (i = 0; i < MAX_INVENTORY; i++) + for (int i = 0; i < MAX_INVENTORY; i++) { if (dstsd->status.inventory[i].equip && dstsd->status.inventory[i].equip & 0x0002) @@ -4364,7 +4365,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, skilllv, 0, 0, 0, strip_time, 0); if (dstsd) { - for (i = 0; i < MAX_INVENTORY; i++) + for (int i = 0; i < MAX_INVENTORY; i++) { if (dstsd->status.inventory[i].equip && dstsd->status.inventory[i].equip & 0x0020) @@ -4394,7 +4395,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, skilllv, 0, 0, 0, strip_time, 0); if (dstsd) { - for (i = 0; i < MAX_INVENTORY; i++) + for (int i = 0; i < MAX_INVENTORY; i++) { if (dstsd->status.inventory[i].equip && dstsd->status.inventory[i].equip & 0x0010) @@ -4423,7 +4424,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, skilllv, 0, 0, 0, strip_time, 0); if (dstsd) { - for (i = 0; i < MAX_INVENTORY; i++) + for (int i = 0; i < MAX_INVENTORY; i++) { if (dstsd->status.inventory[i].equip && dstsd->status.inventory[i].equip & 0x0100) @@ -4956,7 +4957,6 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, { struct skill_unit *su = NULL; struct item item_tmp; - int flag; if ((bl->type == BL_SKILL) && (su = (struct skill_unit *) bl) && (su->group->src_id == src->id || map[bl->m].flag.pvp @@ -4969,7 +4969,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, { if (battle_config.skill_removetrap_type == 1) { - for (i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { if (skill_db[su->group->skill_id].itemid[i] > 0) @@ -4979,14 +4979,15 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, skill_db[su->group-> skill_id].itemid[i]; item_tmp.identify = 1; + int item_flag; if (item_tmp.nameid - && (flag = + && (item_flag = pc_additem (sd, &item_tmp, skill_db[su-> group->skill_id].amount [i]))) { - clif_additem (sd, 0, 0, flag); + clif_additem (sd, 0, 0, item_flag); map_addflooritem (&item_tmp, skill_db[su-> group->skill_id].amount @@ -5003,10 +5004,11 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, memset (&item_tmp, 0, sizeof (item_tmp)); item_tmp.nameid = 1065; item_tmp.identify = 1; + int item_flag; if (item_tmp.nameid - && (flag = pc_additem (sd, &item_tmp, 1))) + && (item_flag = pc_additem (sd, &item_tmp, 1))) { - clif_additem (sd, 0, 0, flag); + clif_additem (sd, 0, 0, item_flag); map_addflooritem (&item_tmp, 1, sd->bl.m, sd->bl.x, sd->bl.y, NULL, NULL, NULL, 0); @@ -5143,6 +5145,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, * スキル使用(詠唱完了、ID指定) *------------------------------------------ */ +static void skill_castend_id (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct map_session_data *sd = map_id2sd (id) /*,*target_sd=NULL */ ; @@ -5414,7 +5417,7 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, case WZ_METEOR: //メテオストーム { - int flag = 0; + int flag_ = 0; for (i = 0; i < 2 + (skilllv >> 1); i++) { int j = 0, c; @@ -5436,21 +5439,21 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, && j < 100); if (j >= 100) continue; - if (flag == 0) + if (flag_ == 0) { clif_skill_poseffect (src, skillid, skilllv, tmpx, tmpy, tick); - flag = 1; + flag_ = 1; } if (i > 0) skill_addtimerskill (src, tick + i * 1000, 0, tmpx, tmpy, skillid, skilllv, (x1 << 16) | y1, - flag); + flag_); x1 = tmpx; y1 = tmpy; } skill_addtimerskill (src, tick + i * 1000, 0, tmpx, tmpy, skillid, - skilllv, -1, flag); + skilllv, -1, flag_); } break; @@ -5534,7 +5537,7 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, *------------------------------------------ */ int skill_castend_map (struct map_session_data *sd, int skill_num, - const char *map) + const char *mapname) { int x = 0, y = 0; @@ -5563,16 +5566,16 @@ int skill_castend_map (struct map_session_data *sd, int skill_num, if (battle_config.pc_skill_log) printf ("PC %d skill castend skill =%d map=%s\n", sd->bl.id, - skill_num, map); + skill_num, mapname); pc_stop_walking (sd, 0); - if (strcmp (map, "cancel") == 0) + if (strcmp (mapname, "cancel") == 0) return 0; switch (skill_num) { case AL_TELEPORT: /* テレポート */ - if (strcmp (map, "Random") == 0) + if (strcmp (mapname, "Random") == 0) pc_randomwarp (sd, 3); else pc_setpos (sd, sd->status.save_point.map, @@ -5611,7 +5614,7 @@ int skill_castend_map (struct map_session_data *sd, int skill_num, for (i = 0; i < sd->skilllv; i++) { - if (strcmp (map, p[i]->map) == 0) + if (strcmp (mapname, p[i]->map) == 0) { x = p[i]->x; y = p[i]->y; @@ -5646,8 +5649,8 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, int y, int flag) { struct skill_unit_group *group; - int i, count = 1, limit = 10000, val1 = 0, val2 = 0; - int target = BCT_ENEMY, interval = 1000, range = 0; + int i, count = 1, limit_ = 10000, val1_ = 0, val2_ = 0; + int target = BCT_ENEMY, interval = 1000, range_ = 0; int dir = 0, aoe_diameter = 0; // -- aoe_diameter (moonsoul) added for sage Area Of Effect skills nullpo_retr (0, src); @@ -5656,8 +5659,8 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, { /* 設定 */ case MG_SAFETYWALL: /* セイフティウォール */ - limit = skill_get_time (skillid, skilllv); - val2 = skilllv + 1; + limit_ = skill_get_time (skillid, skilllv); + val2_ = skilllv + 1; interval = -1; target = (battle_config.defnotenemy) ? BCT_NOENEMY : BCT_ALL; break; @@ -5671,13 +5674,13 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, count = 5; else count = 3; - limit = skill_get_time (skillid, skilllv); - val2 = 4 + skilllv; + limit_ = skill_get_time (skillid, skilllv); + val2_ = 4 + skilllv; interval = 1; break; case AL_PNEUMA: /* ニューマ */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); interval = -1; target = (battle_config.defnotenemy) ? BCT_NOENEMY : BCT_ALL; count = 9; @@ -5685,81 +5688,81 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, case AL_WARP: /* ワープポータル */ target = BCT_ALL; - val1 = skilllv + 6; + val1_ = skilllv + 6; if (flag == 0) - limit = 2000; + limit_ = 2000; else - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); break; case PR_SANCTUARY: /* サンクチュアリ */ count = 21; - limit = skill_get_time (skillid, skilllv); - val1 = skilllv + 3; - val2 = (skilllv > 6) ? 777 : skilllv * 100; + limit_ = skill_get_time (skillid, skilllv); + val1_ = skilllv + 3; + val2_ = (skilllv > 6) ? 777 : skilllv * 100; target = BCT_ALL; - range = 1; + range_ = 1; break; case PR_MAGNUS: /* マグヌスエクソシズム */ count = 33; - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); interval = 3000; break; case WZ_FIREPILLAR: /* ファイアーピラー */ if (flag == 0) - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); else - limit = 1000; + limit_ = 1000; interval = 2000; - val1 = skilllv + 2; - range = 1; + val1_ = skilllv + 2; + range_ = 1; break; case MG_THUNDERSTORM: /* サンダーストーム */ - limit = 500; - range = 1; + limit_ = 500; + range_ = 1; break; case WZ_FROSTNOVA: /* フロストノヴァ */ - limit = 500; - range = 5; + limit_ = 500; + range_ = 5; break; case WZ_HEAVENDRIVE: /* ヘヴンズドライブ */ - limit = 500; - range = 2; + limit_ = 500; + range_ = 2; break; case WZ_METEOR: /* メテオストーム */ - limit = 500; - range = 3; + limit_ = 500; + range_ = 3; break; case WZ_SIGHTRASHER: - limit = 500; + limit_ = 500; count = 41; break; case WZ_VERMILION: /* ロードオブヴァーミリオン */ - limit = 4100; + limit_ = 4100; interval = 1000; - range = 6; + range_ = 6; break; case WZ_ICEWALL: /* アイスウォール */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); count = 5; break; case WZ_STORMGUST: /* ストームガスト */ - limit = 4600; + limit_ = 4600; interval = 450; - range = 5; + range_ = 5; break; case WZ_QUAGMIRE: /* クァグマイア */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); interval = 200; count = 25; break; @@ -5773,45 +5776,45 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, case HT_FREEZINGTRAP: /* フリージングトラップ */ case HT_BLASTMINE: /* ブラストマイン */ case HT_CLAYMORETRAP: /* クレイモアートラップ */ - limit = skill_get_time (skillid, skilllv); - range = 1; + limit_ = skill_get_time (skillid, skilllv); + range_ = 1; break; case HT_TALKIEBOX: /* トーキーボックス */ - limit = skill_get_time (skillid, skilllv); - range = 1; + limit_ = skill_get_time (skillid, skilllv); + range_ = 1; target = BCT_ALL; break; case HT_SHOCKWAVE: /* ショックウェーブトラップ */ - limit = skill_get_time (skillid, skilllv); - range = 1; - val1 = skilllv * 15 + 10; + limit_ = skill_get_time (skillid, skilllv); + range_ = 1; + val1_ = skilllv * 15 + 10; break; case AS_VENOMDUST: /* ベノムダスト */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); interval = 1000; count = 5; break; case CR_GRANDCROSS: /* グランドクロス */ count = 29; - limit = 1000; + limit_ = 1000; interval = 300; break; case SA_VOLCANO: /* ボルケーノ */ case SA_DELUGE: /* デリュージ */ case SA_VIOLENTGALE: /* バイオレントゲイル */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); count = skilllv <= 2 ? 25 : (skilllv <= 4 ? 49 : 81); target = BCT_ALL; break; case SA_LANDPROTECTOR: /* グランドクロス */ - limit = skill_get_time (skillid, skilllv); // changed to get duration from cast_db (moonsoul) - val1 = skilllv * 15 + 10; + limit_ = skill_get_time (skillid, skilllv); // changed to get duration from cast_db (moonsoul) + val1_ = skilllv * 15 + 10; aoe_diameter = skilllv + skilllv % 2 + 5; target = BCT_ALL; count = aoe_diameter * aoe_diameter; // -- this will not function if changed to ^2 (moonsoul) @@ -5821,8 +5824,8 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, case BD_ETERNALCHAOS: /* エターナルカオス */ case BD_ROKISWEIL: /* ロキの叫び */ count = 81; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_ALL; break; case BD_RICHMANKIM: @@ -5831,165 +5834,165 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, case BD_INTOABYSS: /* 深淵の中に */ case BD_SIEGFRIED: /* 不死身のジークフリード */ count = 81; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_PARTY; break; case BA_WHISTLE: /* 口笛 */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_NOENEMY; if (src->type == BL_PC) - val1 = + val1_ = (pc_checkskill ((struct map_session_data *) src, BA_MUSICALLESSON) + 1) >> 1; - val2 = ((battle_get_agi (src) / 10) & 0xffff) << 16; - val2 |= (battle_get_luk (src) / 10) & 0xffff; + val2_ = ((battle_get_agi (src) / 10) & 0xffff) << 16; + val2_ |= (battle_get_luk (src) / 10) & 0xffff; break; case DC_HUMMING: /* ハミング */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_NOENEMY; if (src->type == BL_PC) - val1 = + val1_ = (pc_checkskill ((struct map_session_data *) src, DC_DANCINGLESSON) + 1) >> 1; - val2 = battle_get_dex (src) / 10; + val2_ = battle_get_dex (src) / 10; break; case BA_DISSONANCE: /* 不協和音 */ case DC_UGLYDANCE: /* 自分勝手なダンス */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_ENEMY; break; case DC_DONTFORGETME: /* 私を忘れないで… */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_ENEMY; if (src->type == BL_PC) - val1 = + val1_ = (pc_checkskill ((struct map_session_data *) src, DC_DANCINGLESSON) + 1) >> 1; - val2 = ((battle_get_str (src) / 20) & 0xffff) << 16; - val2 |= (battle_get_agi (src) / 10) & 0xffff; + val2_ = ((battle_get_str (src) / 20) & 0xffff) << 16; + val2_ |= (battle_get_agi (src) / 10) & 0xffff; break; case BA_POEMBRAGI: /* ブラギの詩 */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_NOENEMY; if (src->type == BL_PC) - val1 = + val1_ = pc_checkskill ((struct map_session_data *) src, BA_MUSICALLESSON); - val2 = ((battle_get_dex (src) / 10) & 0xffff) << 16; - val2 |= (battle_get_int (src) / 5) & 0xffff; + val2_ = ((battle_get_dex (src) / 10) & 0xffff) << 16; + val2_ |= (battle_get_int (src) / 5) & 0xffff; break; case BA_APPLEIDUN: /* イドゥンの林檎 */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_NOENEMY; if (src->type == BL_PC) - val1 = + val1_ = ((pc_checkskill ((struct map_session_data *) src, BA_MUSICALLESSON)) & 0xffff) << 16; else - val1 = 0; - val1 |= (battle_get_vit (src)) & 0xffff; - val2 = 0; //回復用タイムカウンタ(6秒毎に1増加) + val1_ = 0; + val1_ |= (battle_get_vit (src)) & 0xffff; + val2_ = 0; //回復用タイムカウンタ(6秒毎に1増加) break; case DC_SERVICEFORYOU: /* サービスフォーユー */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_PARTY; if (src->type == BL_PC) - val1 = + val1_ = (pc_checkskill ((struct map_session_data *) src, DC_DANCINGLESSON) + 1) >> 1; - val2 = battle_get_int (src) / 10; + val2_ = battle_get_int (src) / 10; break; case BA_ASSASSINCROSS: /* 夕陽のアサシンクロス */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_NOENEMY; if (src->type == BL_PC) - val1 = + val1_ = (pc_checkskill ((struct map_session_data *) src, BA_MUSICALLESSON) + 1) >> 1; - val2 = battle_get_agi (src) / 20; + val2_ = battle_get_agi (src) / 20; break; case DC_FORTUNEKISS: /* 幸運のキス */ count = 49; - limit = skill_get_time (skillid, skilllv); - range = 5; + limit_ = skill_get_time (skillid, skilllv); + range_ = 5; target = BCT_NOENEMY; if (src->type == BL_PC) - val1 = + val1_ = (pc_checkskill ((struct map_session_data *) src, DC_DANCINGLESSON) + 1) >> 1; - val2 = battle_get_luk (src) / 10; + val2_ = battle_get_luk (src) / 10; break; case AM_DEMONSTRATION: /* デモンストレーション */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); interval = 1000; - range = 1; + range_ = 1; target = BCT_ENEMY; break; case WE_CALLPARTNER: /* あなたに逢いたい */ - limit = skill_get_time (skillid, skilllv); - range = -1; + limit_ = skill_get_time (skillid, skilllv); + range_ = -1; break; case HP_BASILICA: /* バジリカ */ - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); target = BCT_ALL; - range = 3; + range_ = 3; //Fix to prevent the priest from walking while Basilica is up. battle_stopwalking (src, 1); - skill_status_change_start (src, SC_ANKLE, skilllv, 0, 0, 0, limit, + skill_status_change_start (src, SC_ANKLE, skilllv, 0, 0, 0, limit_, 0); break; case PA_GOSPEL: /* ゴスペル */ count = 49; target = BCT_PARTY; - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); break; case PF_FOGWALL: /* フォグウォール */ count = 15; - limit = skill_get_time (skillid, skilllv); + limit_ = skill_get_time (skillid, skilllv); break; case RG_GRAFFITI: /* Graffiti */ count = 1; // Leave this at 1 [Valaris] - limit = 600000; // Time length [Valaris] + limit_ = 600000; // Time length [Valaris] break; }; nullpo_retr (NULL, group = skill_initunitgroup (src, count, skillid, skilllv, skill_get_unit_id (skillid, flag & 1))); - group->limit = limit; - group->val1 = val1; - group->val2 = val2; + group->limit = limit_; + group->val1 = val1_; + group->val2 = val2_; group->target_flag = target; group->interval = interval; - group->range = range; + group->range = range_; if (skillid == HT_TALKIEBOX || skillid == RG_GRAFFITI) { CREATE (group->valstr, char, 80); @@ -6087,8 +6090,6 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, case WZ_ICEWALL: /* アイスウォール */ { - static const int dirx[8] = { 0, -1, -1, -1, 0, 1, 1, 1 }; - static const int diry[8] = { 1, 1, 0, -1, -1, -1, 0, 1 }; if (skilllv <= 1) val1 = 500; else @@ -6261,6 +6262,7 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, * スキルユニットの発動イベント *------------------------------------------ */ +static int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned int tick) { @@ -6721,6 +6723,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, * スキルユニットから離脱する(もしくはしている)場合 *------------------------------------------ */ +static int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned int tick) { @@ -6850,6 +6853,7 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, * スキルユニットの削除イベント *------------------------------------------ */ +static int skill_unit_ondelete (struct skill_unit *src, struct block_list *bl, unsigned int tick) { @@ -6907,6 +6911,7 @@ int skill_unit_ondelete (struct skill_unit *src, struct block_list *bl, * スキルユニットの限界イベント *------------------------------------------ */ +static int skill_unit_onlimit (struct skill_unit *src, unsigned int tick) { struct skill_unit_group *sg; @@ -6987,6 +6992,7 @@ int skill_unit_ondamaged (struct skill_unit *src, struct block_list *bl, * スキル使用(詠唱完了、場所指定) *------------------------------------------ */ +static void skill_castend_pos (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { struct map_session_data *sd = map_id2sd (id) /*,*target_sd=NULL */ ; @@ -7345,7 +7351,7 @@ static int skill_check_condition_mob_master_sub (struct block_list *bl, */ int skill_check_condition (struct map_session_data *sd, int type) { - int i, hp, sp, hp_rate, sp_rate, zeny, weapon, state, spiritball, skill, + int hp, sp, hp_rate, sp_rate, zeny, weapon, state, spiritball, skill, lv, mhp; int index[10], itemid[10], amount[10]; @@ -7418,7 +7424,7 @@ int skill_check_condition (struct map_session_data *sd, int type) state = skill_db[skill].state; spiritball = (lv <= 0) ? 0 : skill_db[skill].spiritball[lv - 1]; mhp = skill_get_mhp (skill, lv); /* 消費HP */ - for (i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { itemid[i] = skill_db[skill].itemid[i]; amount[i] = skill_db[skill].amount[i]; @@ -7738,7 +7744,7 @@ int skill_check_condition (struct map_session_data *sd, int type) break; } - for (i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { int x = lv % 11 - 1; index[i] = -1; @@ -7771,7 +7777,7 @@ int skill_check_condition (struct map_session_data *sd, int type) { if (skill == AL_WARP && !(type & 2)) return 1; - for (i = 0; i < 10; i++) + for (int i = 0; i < 10; i++) { if (index[i] >= 0) pc_delitem (sd, index[i], amount[i], 0); // アイテム消費 @@ -7910,7 +7916,7 @@ int skill_use_id (struct map_session_data *sd, int target_id, int skill_num, int skill_lv) { unsigned int tick; - int casttime = 0, delay = 0, skill, range; + int casttime = 0, delay = 0, skill, range_; struct map_session_data *target_sd = NULL; int forcecast = 0; struct block_list *bl; @@ -8093,10 +8099,10 @@ int skill_use_id (struct map_session_data *sd, int target_id, return 0; /* 射程と障害物チェック */ - range = skill_get_range (skill_num, skill_lv); - if (range < 0) - range = battle_get_range (&sd->bl) - (range + 1); - if (!battle_check_range (&sd->bl, bl, range)) + range_ = skill_get_range (skill_num, skill_lv); + if (range_ < 0) + range_ = battle_get_range (&sd->bl) - (range_ + 1); + if (!battle_check_range (&sd->bl, bl, range_)) return 0; if (bl->type == BL_PC) @@ -8182,10 +8188,10 @@ int skill_use_id (struct map_session_data *sd, int target_id, return 0; target_id = p_sd->bl.id; //rangeをもう1回検査 - range = skill_get_range (skill_num, skill_lv); - if (range < 0) - range = battle_get_range (&sd->bl) - (range + 1); - if (!battle_check_range (&sd->bl, &p_sd->bl, range)) + range_ = skill_get_range (skill_num, skill_lv); + if (range_ < 0) + range_ = battle_get_range (&sd->bl) - (range_ + 1); + if (!battle_check_range (&sd->bl, &p_sd->bl, range_)) { return 0; } @@ -8978,6 +8984,7 @@ int skill_landprotector (struct block_list *bl, va_list ap) * イドゥンの林檎の回復処理(foreachinarea) *------------------------------------------ */ +static int skill_idun_heal (struct block_list *bl, va_list ap) { struct skill_unit *unit; @@ -11331,6 +11338,7 @@ int skill_unitgrouptickset_delete (struct block_list *bl, int group_id) * スキルユニットタイマー発動処理用(foreachinarea) *------------------------------------------ */ +static int skill_unit_timer_sub_onplace (struct block_list *bl, va_list ap) { struct block_list *src; @@ -11385,6 +11393,7 @@ int skill_unit_timer_sub_ondelete (struct block_list *bl, va_list ap) * スキルユニットタイマー処理用(foreachobject) *------------------------------------------ */ +static int skill_unit_timer_sub (struct block_list *bl, va_list ap) { struct skill_unit *unit; @@ -11475,6 +11484,7 @@ int skill_unit_timer_sub (struct block_list *bl, va_list ap) * スキルユニットタイマー処理 *------------------------------------------ */ +static void skill_unit_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t data) { map_freeblock_lock (); @@ -11488,6 +11498,7 @@ void skill_unit_timer (timer_id tid, tick_t tick, custom_id_t id, custom_data_t * スキルユニット移動時処理用(foreachinarea) *------------------------------------------ */ +static int skill_unit_out_all_sub (struct block_list *bl, va_list ap) { struct skill_unit *unit; @@ -11543,6 +11554,7 @@ int skill_unit_out_all (struct block_list *bl, unsigned int tick, int range) * スキルユニット移動時処理用(foreachinarea) *------------------------------------------ */ +static int skill_unit_move_sub (struct block_list *bl, va_list ap) { struct skill_unit *unit; @@ -11601,6 +11613,7 @@ int skill_unit_move (struct block_list *bl, unsigned int tick, int range) * スキルユニット自体の移動時処理(foreachinarea) *------------------------------------------ */ +static int skill_unit_move_unit_group_sub (struct block_list *bl, va_list ap) { struct skill_unit *unit; @@ -11814,14 +11827,13 @@ static int scan_stat (char *statname) return 0; } -extern void skill_pool_register (int id); // [Fate] Remember that a certain skill ID belongs to a pool skill - /*========================================== * スキル関係ファイル読み込み * skill_db.txt スキルデータ * skill_cast_db.txt スキルの詠唱時間とディレイデータ *------------------------------------------ */ +static int skill_readdb (void) { int i, j, k, l; @@ -11933,14 +11945,15 @@ int skill_readdb (void) skill_db[i].stat = scan_stat (split[16]); - skill_names[i].desc = strdup (split[17]); + char *tmp = strdup (split[17]); + skill_names[i].desc = tmp; { // replace "_" by " " - char *s = skill_names[i].desc; + char *s = tmp; while ((s = strchr (s, '_'))) *s = ' '; - if ((s = strchr (skill_names[i].desc, '\t')) - || (s = strchr (skill_names[i].desc, ' ')) - || (s = strchr (skill_names[i].desc, '\n'))) + if ((s = strchr (tmp, '\t')) + || (s = strchr (tmp, ' ')) + || (s = strchr (tmp, '\n'))) *s = '\000'; } } diff --git a/src/map/skill.hpp b/src/map/skill.hpp index e2aaba5..3dea4d3 100644 --- a/src/map/skill.hpp +++ b/src/map/skill.hpp @@ -881,11 +881,12 @@ void skill_pool_empty (struct map_session_data *sd); // Deactivate all pool s int skill_pool_activate (struct map_session_data *sd, int skill); // Skill into skill pool. Return is zero iff okay. int skill_pool_is_activated (struct map_session_data *sd, int skill); // Skill into skill pool. Return is zero when activated. int skill_pool_deactivate (struct map_session_data *sd, int skill); // Skill out of skill pool. Return is zero iff okay. -char *skill_name (int skill); // Yield configurable skill name +const char *skill_name(int skill); // Yield configurable skill name int skill_stat (int skill); // Yields the stat associated with a skill. Returns zero if none, or SP_STR, SP_VIT, ... otherwise int skill_power (struct map_session_data *sd, int skill); // Yields the power of a skill. This is zero if the skill is unknown or if it's a pool skill that is outside of the skill pool, // otherwise a value from 0 to 255 (with 200 being the `normal maximum') int skill_power_bl (struct block_list *bl, int skill); // Yields the power of a skill. This is zero if the skill is unknown or if it's a pool skill that is outside of the skill pool, // otherwise a value from 0 to 255 (with 200 being the `normal maximum') +void skill_pool_register (int id); // [Fate] Remember that a certain skill ID belongs to a pool skill #endif diff --git a/src/map/storage.cpp b/src/map/storage.cpp index d1d3cb0..7d54343 100644 --- a/src/map/storage.cpp +++ b/src/map/storage.cpp @@ -485,6 +485,7 @@ struct guild_storage *guild2storage (int guild_id) return gs; } +static struct guild_storage *guild2storage2 (int guild_id) { //For just locating a storage without creating one. [Skotlex] return (struct guild_storage *) numdb_search (guild_storage_db, guild_id); diff --git a/src/map/tmw.cpp b/src/map/tmw.cpp index 7506270..4b1831b 100644 --- a/src/map/tmw.cpp +++ b/src/map/tmw.cpp @@ -30,7 +30,7 @@ #include "storage.hpp" #include "trade.hpp" -int tmw_CheckChatSpam (struct map_session_data *sd, char *message) +int tmw_CheckChatSpam (struct map_session_data *sd, const char *message) { nullpo_retr (1, sd); time_t now = time (NULL); @@ -86,16 +86,14 @@ int tmw_CheckChatSpam (struct map_session_data *sd, char *message) (sd->chat_lines_in >= battle_config.chat_spam_warn || sd->chat_total_repeats >= battle_config.chat_spam_warn)) { - /* "WARNING: You are about to be automatically banned for spam!" */ - clif_displaymessage (sd->fd, msg_txt (506)); - /* "WARNING: Please slow down, do not repeat, and do not SHOUT!" */ - clif_displaymessage (sd->fd, msg_txt (507)); + clif_displaymessage (sd->fd, "WARNING: You are about to be automatically banned for spam!"); + clif_displaymessage (sd->fd, "WARNING: Please slow down, do not repeat, and do not SHOUT!"); } return 0; } -void tmw_AutoBan(struct map_session_data *sd, char *reason, int length) +void tmw_AutoBan(struct map_session_data *sd, const char *reason, int length) { char anotherbuf[512]; @@ -111,8 +109,7 @@ void tmw_AutoBan(struct map_session_data *sd, char *reason, int length) map[sd->bl.m].name, sd->bl.x, sd->bl.y, sd->status.name, length, reason); - /* "You have been banned for %s spamming. Please do not spam." */ - snprintf (anotherbuf, 511, msg_txt (508), reason); + snprintf (anotherbuf, 511, "You have been banned for %s spamming. Please do not spam.", reason); clif_displaymessage (sd->fd, anotherbuf); /* type: 2 - ban (year, month, day, hour, minute, second) */ @@ -121,7 +118,7 @@ void tmw_AutoBan(struct map_session_data *sd, char *reason, int length) } // Compares the length of two strings and returns that of the shorter -int tmw_ShorterStrlen (char *s1, char *s2) +int tmw_ShorterStrlen (const char *s1, const char *s2) { int s1_len = strlen (s1); int s2_len = strlen (s2); @@ -129,7 +126,7 @@ int tmw_ShorterStrlen (char *s1, char *s2) } // Returns true if more than 50% of input message is caps or punctuation -int tmw_CheckChatLameness (struct map_session_data *sd, char *message) +int tmw_CheckChatLameness (struct map_session_data *sd, const char *message) { int count, lame; diff --git a/src/map/tmw.hpp b/src/map/tmw.hpp index 5b20a6c..71de462 100644 --- a/src/map/tmw.hpp +++ b/src/map/tmw.hpp @@ -4,11 +4,12 @@ #include "map.hpp" -int tmw_CheckChatSpam (struct map_session_data *sd, char *message); -int tmw_ShorterStrlen (char *s1, char *s2); -int tmw_CheckChatLameness (struct map_session_data *sd, char *message); +int tmw_CheckChatSpam (struct map_session_data *sd, const char *message); +int tmw_ShorterStrlen (const char *s1, const char *s2); +int tmw_CheckChatLameness (struct map_session_data *sd, const char *message); +__attribute__((format(printf, 1, 2))) void tmw_GmHackMsg (const char *fmt, ...); -void tmw_AutoBan (struct map_session_data *sd, char *reason, int length); +void tmw_AutoBan (struct map_session_data *sd, const char *reason, int length); void tmw_TrimStr (char *str); #endif /* TMW_H_ */ |