diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 295 | ||||
-rw-r--r-- | src/map/atcommand.h | 2 | ||||
-rw-r--r-- | src/map/charcommand.c | 59 | ||||
-rw-r--r-- | src/map/chrif.c | 2 | ||||
-rw-r--r-- | src/map/clif.c | 55 | ||||
-rw-r--r-- | src/map/clif.h | 4 | ||||
-rw-r--r-- | src/map/map.h | 6 | ||||
-rw-r--r-- | src/map/mob.c | 2 | ||||
-rw-r--r-- | src/map/npc.c | 2 | ||||
-rw-r--r-- | src/map/party.c | 2 | ||||
-rw-r--r-- | src/map/pc.c | 3 | ||||
-rw-r--r-- | src/map/pet.c | 10 |
12 files changed, 158 insertions, 284 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 11d10534f..da86e6073 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -597,19 +597,6 @@ char atcmd_output[200]; char atcmd_player_name[NAME_LENGTH]; char atcmd_temp[100]; -/*========================================== - * estr_lower (replace strlwr, non ANSI function that doesn't exist in all C compilator) - *------------------------------------------*/ -char *estr_lower(char *str) -{ - int i; - - for (i=0; str[i]; i++) - if ((str[i] >= 65) && (str[i] <= 90)) - str[i] += 32; - return str; -} - // compare function for sorting high to lowest int hightolow_compare (const void * a, const void * b) { @@ -625,7 +612,7 @@ int lowtohigh_compare (const void * a, const void * b) //----------------------------------------------------------- // Return the message string of the specified number by [Yor] //----------------------------------------------------------- -char * msg_txt(int msg_number) +char* msg_txt(int msg_number) { if (msg_number >= 0 && msg_number < MAX_MSG && msg_table[msg_number] != NULL && msg_table[msg_number][0] != '\0') @@ -637,32 +624,19 @@ char * msg_txt(int msg_number) //----------------------------------------------------------- // Returns Players title (from msg_athena.conf) [Lupus] //----------------------------------------------------------- -char * player_title_txt(int level) { - if (level < battle_config.title_lvl1) - return ""; //w/o any titles - - if (level >= battle_config.title_lvl8) - sprintf(atcmd_temp, msg_txt(332), level); - else - if (level >= battle_config.title_lvl7) - sprintf(atcmd_temp, msg_txt(331), level); - else - if (level >= battle_config.title_lvl6) - sprintf(atcmd_temp, msg_txt(330), level); - else - if (level >= battle_config.title_lvl5) - sprintf(atcmd_temp, msg_txt(329), level); - else - if (level >= battle_config.title_lvl4) - sprintf(atcmd_temp, msg_txt(328), level); - else - if (level >= battle_config.title_lvl3) - sprintf(atcmd_temp, msg_txt(327), level); - else - if (level >= battle_config.title_lvl2) - sprintf(atcmd_temp, msg_txt(326), level); - else - sprintf(atcmd_temp, msg_txt(325), level); //lvl1 +static char* player_title_txt(int level) +{ + const char* format; + format = (level >= battle_config.title_lvl8) ? msg_txt(332) + : (level >= battle_config.title_lvl7) ? msg_txt(331) + : (level >= battle_config.title_lvl6) ? msg_txt(330) + : (level >= battle_config.title_lvl5) ? msg_txt(329) + : (level >= battle_config.title_lvl4) ? msg_txt(328) + : (level >= battle_config.title_lvl3) ? msg_txt(327) + : (level >= battle_config.title_lvl2) ? msg_txt(326) + : (level >= battle_config.title_lvl1) ? msg_txt(325) + : ""; + sprintf(atcmd_temp, format, level); return atcmd_temp; } @@ -811,7 +785,7 @@ AtCommandType atcommand(struct map_session_data* sd, const int level, const char /*========================================== * Read Message Data *------------------------------------------*/ -int msg_config_read(const char *cfgName) +int msg_config_read(const char* cfgName) { int msg_number; char line[1024], w1[1024], w2[1024]; @@ -825,25 +799,29 @@ int msg_config_read(const char *cfgName) if ((--called) == 0) memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG); + while(fgets(line, sizeof(line), fp)) { if (line[0] == '/' && line[1] == '/') continue; - if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) { - if (strcmpi(w1, "import") == 0) { - msg_config_read(w2); - } else { - msg_number = atoi(w1); - if (msg_number >= 0 && msg_number < MAX_MSG) { - if (msg_table[msg_number] != NULL) - aFree(msg_table[msg_number]); - msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char)); - strcpy(msg_table[msg_number],w2); - // printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]); - } + if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2) + continue; + + if (strcmpi(w1, "import") == 0) + msg_config_read(w2); + else + { + msg_number = atoi(w1); + if (msg_number >= 0 && msg_number < MAX_MSG) + { + if (msg_table[msg_number] != NULL) + aFree(msg_table[msg_number]); + msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char)); + strcpy(msg_table[msg_number],w2); } } } + fclose(fp); return 0; @@ -852,7 +830,7 @@ int msg_config_read(const char *cfgName) /*========================================== * Cleanup Message Data *------------------------------------------*/ -void do_final_msg (void) +void do_final_msg(void) { int i; for (i = 0; i < MAX_MSG; i++) @@ -1269,29 +1247,15 @@ int atcommand_where(const int fd, struct map_session_data* sd, const char* comma return -1; } - if ((pl_sd = map_nick2sd(atcmd_player_name)) == NULL) - { + if((pl_sd = map_nick2sd(atcmd_player_name)) == NULL + || strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH) != 0 + || battle_config.hide_GM_session && pc_isGM(sd) < pc_isGM(pl_sd) && !(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid) + ) { clif_displaymessage(fd, msg_txt(3)); // Character not found. return -1; } - if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0) - { - clif_displaymessage(fd, "You already know where you are..."); - return -1; - } - - if (battle_config.hide_GM_session) { - if(pc_isGM(sd) < pc_isGM(pl_sd)) { - if (!(battle_config.who_display_aid && pc_isGM(sd) >= battle_config.who_display_aid)) { - clif_displaymessage(fd, msg_txt(3)); // Character not found. - return -1; - } - } - } - - snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", - pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); + snprintf(atcmd_output, sizeof atcmd_output, "%s %s %d %d", pl_sd->status.name, mapindex_id2name(pl_sd->mapindex), pl_sd->bl.x, pl_sd->bl.y); clif_displaymessage(fd, atcmd_output); return 0; @@ -2093,7 +2057,7 @@ int atcommand_hide(const int fd, struct map_session_data* sd, const char* comman *------------------------------------------*/ int atcommand_jobchange(const int fd, struct map_session_data* sd, const char* command, const char* message) { - //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table + //FIXME: redundancy, potentially wrong code, should use job_name() or similar instead of hardcoding the table [ultramage] int job = 0, upper = 0; nullpo_retr(-1, sd); @@ -3508,9 +3472,7 @@ void atcommand_killmonster_sub(const int fd, struct map_session_data* sd, const int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* command, const char* message) { - if (!sd) return 0; atcommand_killmonster_sub(fd, sd, message, 1); - return 0; } @@ -3519,9 +3481,7 @@ int atcommand_killmonster(const int fd, struct map_session_data* sd, const char* *------------------------------------------*/ int atcommand_killmonster2(const int fd, struct map_session_data* sd, const char* command, const char* message) { - if (!sd) return 0; atcommand_killmonster_sub(fd, sd, message, 0); - return 0; } @@ -3561,12 +3521,7 @@ int atcommand_refine(const int fd, struct map_session_data* sd, const char* comm return -1; } - if (refine < -MAX_REFINE) - refine = -MAX_REFINE; - else if (refine > MAX_REFINE) - refine = MAX_REFINE; - else if (refine == 0) - refine = 1; + refine = cap_value(refine, -MAX_REFINE, MAX_REFINE); count = 0; for (j = 0; j < EQI_MAX-1; j++) { @@ -3582,11 +3537,7 @@ int atcommand_refine(const int fd, struct map_session_data* sd, const char* comm if(position && !(sd->status.inventory[i].equip & position)) continue; - final_refine = sd->status.inventory[i].refine + refine; - if (final_refine > MAX_REFINE) - final_refine = MAX_REFINE; - else if (final_refine < 0) - final_refine = 0; + final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE); if (sd->status.inventory[i].refine != final_refine) { sd->status.inventory[i].refine = final_refine; current_position = sd->status.inventory[i].equip; @@ -4247,17 +4198,8 @@ int atcommand_char_block(const int fd, struct map_session_data* sd, const char* return -1; } - // check player name - if (strlen(atcmd_player_name) < 4) { - clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters. - return -1; - } else if (strlen(atcmd_player_name) > 23) { - clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum. - return -1; - } else { - chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block - clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. - } + chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 1, 0, 0, 0, 0, 0, 0); // type: 1 - block + clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. return 0; } @@ -4332,17 +4274,8 @@ int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* co return -1; } - // check player name - if (strlen(atcmd_player_name) < 4) { - clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters. - return -1; - } else if (strlen(atcmd_player_name) > 23) { - clif_displaymessage(fd, msg_txt(87)); // Sorry, but a player name have 23 characters maximum. - return -1; - } else { - chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban - clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. - } + chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 2, year, month, day, hour, minute, second); // type: 2 - ban + clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. return 0; } @@ -4361,18 +4294,9 @@ int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char return -1; } - // check player name - if (strlen(atcmd_player_name) < 4) { - clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters. - return -1; - } else if (strlen(atcmd_player_name) > 23) { - clif_displaymessage(fd, msg_txt(87)); // 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, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock - clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. - } + // send answer to login server via char-server + chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 3, 0, 0, 0, 0, 0, 0); // type: 3 - unblock + clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. return 0; } @@ -4391,18 +4315,9 @@ int atcommand_char_unban(const int fd, struct map_session_data* sd, const char* return -1; } - // check player name - if (strlen(atcmd_player_name) < 4) { - clif_displaymessage(fd, msg_txt(86)); // Sorry, but a player name have at least 4 characters. - return -1; - } else if (strlen(atcmd_player_name) > 23) { - clif_displaymessage(fd, msg_txt(87)); // 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, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban - clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. - } + // send answer to login server via char-server + chrif_char_ask_name(sd->status.account_id, atcmd_player_name, 4, 0, 0, 0, 0, 0, 0); // type: 4 - unban + clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it. return 0; } @@ -4622,24 +4537,21 @@ int atcommand_questskill(const int fd, struct map_session_data* sd, const char* clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>)."); return -1; } - - if (skill_id >= 0 && skill_id < MAX_SKILL_DB) { - if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) { - if (pc_checkskill(sd, skill_id) == 0) { - pc_skill(sd, skill_id, 1, 0); - clif_displaymessage(fd, msg_txt(70)); // You have learned the skill. - } else { - clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill. - return -1; - } - } else { - clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill. - return -1; - } - } else { + if (skill_id < 0 && skill_id >= MAX_SKILL_DB) { clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist. return -1; } + if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) { + clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill. + return -1; + } + if (pc_checkskill(sd, skill_id) > 0) { + clif_displaymessage(fd, msg_txt(196)); // You already have this quest skill. + return -1; + } + + pc_skill(sd, skill_id, 1, 0); + clif_displaymessage(fd, msg_txt(70)); // You have learned the skill. return 0; } @@ -4656,26 +4568,23 @@ int atcommand_lostskill(const int fd, struct map_session_data* sd, const char* c clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>)."); return -1; } - - if (skill_id >= 0 && skill_id < MAX_SKILL) { - if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) { - if (pc_checkskill(sd, skill_id) > 0) { - sd->status.skill[skill_id].lv = 0; - sd->status.skill[skill_id].flag = 0; - clif_skillinfoblock(sd); - clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill. - } else { - clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill. - return -1; - } - } else { - clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill. - return -1; - } - } else { + if (skill_id < 0 && skill_id >= MAX_SKILL) { clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist. return -1; } + if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) { + clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill. + return -1; + } + if (pc_checkskill(sd, skill_id) == 0) { + clif_displaymessage(fd, msg_txt(201)); // You don't have this quest skill. + return -1; + } + + sd->status.skill[skill_id].lv = 0; + sd->status.skill[skill_id].flag = 0; + clif_skillinfoblock(sd); + clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill. return 0; } @@ -6101,7 +6010,7 @@ int atcommand_disguise(const int fd, struct map_session_data* sd, const char* co if(pc_isriding(sd)) { - //FIXME: wrong message + //FIXME: wrong message [ultramage] //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco. return -1; } @@ -7703,39 +7612,32 @@ int atcommand_petid(const int fd, struct map_session_data* sd, const char* comma { char searchtext[100]; char temp0[100]; - char temp1[100]; int cnt = 0, i = 0; nullpo_retr(-1, sd); if (!message || !*message || sscanf(message, "%99s", searchtext) < 1) { - clif_displaymessage(fd, "Please, enter a player name (usage: @petid <monster name>)."); + clif_displaymessage(fd, "Please, enter a pet name (usage: @petid <part of pet name>)."); return -1; } - estr_lower(searchtext); - snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext); + snprintf(temp0, sizeof(temp0), "First %i search results for: %s", MAX_SEARCH, searchtext); clif_displaymessage(fd,temp0); - while (i < MAX_PET_DB) { - strcpy(temp1,pet_db[i].name); - strcpy(temp1, estr_lower(temp1)); - strcpy(temp0,pet_db[i].jname); - strcpy(temp0, estr_lower(temp1)); - if (strstr(temp1, searchtext) || strstr(temp0, searchtext) ) { - snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_, - pet_db[i].jname); - if (cnt >= 100) { // Only if there are custom pets - clif_displaymessage(fd, "Be more specific, can't send more than" - " 100 results."); - } else { + + for (i = 0; i < MAX_PET_DB; i++) + { + if (stristr(pet_db[i].name, searchtext) || stristr(pet_db[i].jname, searchtext)) + { + cnt++; + if (cnt <= MAX_SEARCH) { // limits the number of search results + snprintf(temp0, sizeof(temp0), "ID: %i -- Name: %s", pet_db[i].class_, pet_db[i].jname); clif_displaymessage(fd, temp0); } - cnt++; } - i++; } - snprintf(temp0, sizeof(temp0),"%i pets have '%s' in their name.", cnt, searchtext); + + snprintf(temp0, sizeof(temp0), "%i pets have '%s' in their name.", cnt, searchtext); clif_displaymessage(fd, temp0); return 0; } @@ -8309,11 +8211,12 @@ int atcommand_homevolution(const int fd, struct map_session_data* sd, const char return -1; } - if ( merc_hom_evolution(sd->hd) ) - return 0; + if ( !merc_hom_evolution(sd->hd) ) { + clif_displaymessage(fd, "Your homunculus doesn't evolve."); + return -1; + } - clif_displaymessage(fd, "Your homunculus doesn't evolve."); - return -1; + return 0; } /*========================================== @@ -8365,10 +8268,7 @@ int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char* } friendly = atoi(message); - if (friendly < 0) - friendly = 0; - else if (friendly > 1000) - friendly = 1000; + friendly = cap_value(friendly, 0, 1000); sd->hd->homunculus.intimacy = friendly * 100 ; clif_send_homdata(sd,SP_INTIMATE,friendly); @@ -8395,10 +8295,7 @@ int atcommand_homhungry(const int fd, struct map_session_data* sd, const char* c } hungry = atoi(message); - if (hungry < 0) - hungry = 0; - else if (hungry > 100) - hungry = 100; + hungry = cap_value(hungry, 0, 100); sd->hd->homunculus.hunger = hungry; clif_send_homdata(sd,SP_HUNGRY,hungry); diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 9b775a00c..5e2ed5d63 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -300,8 +300,6 @@ int atcommand_config_read(const char *cfgName); int msg_config_read(const char *cfgName); void do_final_msg(void); -char* estr_lower(char* str); - extern char atcommand_symbol; #define MAX_MSG 1000 extern char* msg_table[MAX_MSG]; diff --git a/src/map/charcommand.c b/src/map/charcommand.c index d6d46d19f..fac0999bf 100644 --- a/src/map/charcommand.c +++ b/src/map/charcommand.c @@ -548,10 +548,7 @@ int charcommand_petfriendly(const int fd, struct map_session_data* sd, const cha return -1; } - if (friendly < 0) - friendly = 0; - else if (friendly > 1000) - friendly = 1000; + friendly = cap_value(friendly, 0, 1000); pd = pl_sd->pd; if (friendly == pd->pet.intimate) { @@ -1519,28 +1516,25 @@ int charcommand_questskill(const int fd, struct map_session_data* sd, const char return -1; } - if (skill_id >= 0 && skill_id < MAX_SKILL_DB) { - if (skill_get_inf2(skill_id) & INF2_QUEST_SKILL) { - if ((pl_sd = map_nick2sd(player)) != NULL) { - if (pc_checkskill(pl_sd, skill_id) == 0) { - pc_skill(pl_sd, skill_id, 1, 0); - clif_displaymessage(fd, msg_txt(199)); // This player has learned the skill. - } else { - clif_displaymessage(fd, msg_txt(200)); // This player already has this quest skill. - return -1; - } - } else { - clif_displaymessage(fd, msg_txt(3)); // Character not found. - return -1; - } - } else { - clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill. - return -1; - } - } else { + if (skill_id < 0 && skill_id >= MAX_SKILL_DB) { clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist. return -1; } + if (!(skill_get_inf2(skill_id) & INF2_QUEST_SKILL)) { + clif_displaymessage(fd, msg_txt(197)); // This skill number doesn't exist or isn't a quest skill. + return -1; + } + if ((pl_sd = map_nick2sd(player)) == NULL) { + clif_displaymessage(fd, msg_txt(3)); // Character not found. + return -1; + } + if (pc_checkskill(pl_sd, skill_id) > 0) { + clif_displaymessage(fd, msg_txt(200)); // This player already has this quest skill. + return -1; + } + + pc_skill(pl_sd, skill_id, 1, 0); + clif_displaymessage(fd, msg_txt(199)); // This player has learned the skill. return 0; } @@ -3269,7 +3263,7 @@ int charcommand_disguise(const int fd, struct map_session_data* sd, const char* if(pc_isriding(pl_sd)) { - //FIXME: wrong message + //FIXME: wrong message [ultramage] //clif_displaymessage(fd, msg_txt(228)); // Character cannot wear disguise while riding a PecoPeco. return -1; } @@ -3935,7 +3929,7 @@ int charcommand_hominfo(const int fd, struct map_session_data* sd, const char* c clif_displaymessage(fd, "Please, enter a player name (usage: #hominfo <player>)."); return -1; } - + if ( (pl_sd = map_nick2sd(character)) == NULL ) { clif_displaymessage(fd, msg_txt(3)); // Character not found. @@ -3950,26 +3944,21 @@ int charcommand_hominfo(const int fd, struct map_session_data* sd, const char* c if(!merc_is_hom_active(pl_sd->hd)) return -1; + hd = pl_sd->hd; status = status_get_status_data(&hd->bl); clif_displaymessage(fd, "Homunculus stats :"); - snprintf(output, sizeof(output) ,"HP : %d/%d - SP : %d/%d", - status->hp, status->max_hp, status->sp, status->max_sp); + snprintf(output, sizeof(output), "HP : %d/%d - SP : %d/%d", status->hp, status->max_hp, status->sp, status->max_sp); clif_displaymessage(fd, output); - snprintf(output, sizeof(output) ,"ATK : %d - MATK : %d~%d", - status->rhw.atk2 +status->batk, status->matk_min, status->matk_max); + snprintf(output, sizeof(output), "ATK : %d - MATK : %d~%d", status->rhw.atk2 +status->batk, status->matk_min, status->matk_max); clif_displaymessage(fd, output); - snprintf(output, sizeof(output) ,"Hungry : %d - Intimacy : %u", - hd->homunculus.hunger, hd->homunculus.intimacy/100); + snprintf(output, sizeof(output), "Hungry : %d - Intimacy : %u", hd->homunculus.hunger, hd->homunculus.intimacy/100); clif_displaymessage(fd, output); - snprintf(output, sizeof(output) , - "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d", - status->str, status->agi, status->vit, - status->int_, status->dex, status->luk); + snprintf(output, sizeof(output), "Stats: Str %d / Agi %d / Vit %d / Int %d / Dex %d / Luk %d", status->str, status->agi, status->vit, status->int_, status->dex, status->luk); clif_displaymessage(fd, output); return 0; diff --git a/src/map/chrif.c b/src/map/chrif.c index 9513c7ea7..b333dbeaf 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -476,7 +476,7 @@ void chrif_authok(int fd) } // Awaiting for client to connect. auth_data = (struct auth_node *)aCalloc(1,sizeof(struct auth_node)); - auth_data->char_dat = (struct mmo_charstatus *) aCalloc(1,sizeof(struct mmo_charstatus)); + auth_data->char_dat = (struct mmo_charstatus *) aMalloc(sizeof(struct mmo_charstatus)); auth_data->account_id=RFIFOL(fd, 4); auth_data->login_id1=RFIFOL(fd, 8); diff --git a/src/map/clif.c b/src/map/clif.c index 557e80041..5845ee102 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -49,7 +49,7 @@ struct Clif_Config { int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex] } clif_config; -struct packet_db_t packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; +struct s_packet_db packet_db[MAX_PACKET_VER + 1][MAX_PACKET_DB + 1]; //Converts item type in case of pet eggs. #define itemtype(a) (a == IT_PETEGG)?IT_WEAPON:a @@ -8434,8 +8434,7 @@ void clif_parse_GlobalMessage(int fd, struct map_session_data* sd) return; } - if (is_atcommand(fd, sd, message) != AtCommand_None || - is_charcommand(fd, sd, message) != CharCommand_None) + if (is_atcommand(fd, sd, message) != AtCommand_None || is_charcommand(fd, sd, message) != CharCommand_None) return; if (sd->sc.count && @@ -8532,7 +8531,7 @@ void clif_parse_MapMove(int fd, struct map_session_data *sd) { char output[MAP_NAME_LENGTH_EXT+15]; // Max length of a short: ' -6XXXX' -> 7 digits char message[MAP_NAME_LENGTH_EXT+15+5]; // "/mm "+output - char *map_name; + char* map_name; if (battle_config.atc_gmonly && !pc_isGM(sd)) return; @@ -8751,7 +8750,7 @@ void clif_parse_Restart(int fd, struct map_session_data *sd) /*========================================== * Transmission of a wisp (S 0096 <len>.w <nick>.24B <message>.?B) *------------------------------------------*/ -void clif_parse_Wis(int fd, struct map_session_data *sd) +void clif_parse_Wis(int fd, struct map_session_data* sd) { char *command, *msg; struct map_session_data *dstsd; @@ -8779,8 +8778,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd) memcpy(msg, RFIFOP(fd, 28), len); mes_len_check(msg, len, CHATBOX_SIZE); - if ((is_charcommand(fd, sd, command) != CharCommand_None) || - (is_atcommand(fd, sd, command) != AtCommand_None)) { + if ((is_charcommand(fd, sd, command) != CharCommand_None) || (is_atcommand(fd, sd, command) != AtCommand_None)) { aFree(command); return; } @@ -10190,23 +10188,19 @@ void clif_parse_PartyChangeOption(int fd, struct map_session_data *sd) /*========================================== * パーティメッセージ送信要求 *------------------------------------------*/ -void clif_parse_PartyMessage(int fd, struct map_session_data *sd) +void clif_parse_PartyMessage(int fd, struct map_session_data* sd) { - char *mes; + char* message; int len; len = RFIFOW(fd,2) - 4; - mes = (char*)RFIFOP(fd,4); - mes_len_check(mes, len, CHAT_SIZE); + message = (char*)RFIFOP(fd,4); + mes_len_check(message, len, CHAT_SIZE); - if (is_charcommand(fd, sd, mes) != CharCommand_None || - is_atcommand(fd, sd, mes) != AtCommand_None) + if (is_charcommand(fd, sd, message) != CharCommand_None || is_atcommand(fd, sd, message) != AtCommand_None) return; - if (sd->sc.count && ( - sd->sc.data[SC_BERSERK].timer!=-1 || - (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) - )) + if (sd->sc.data[SC_BERSERK].timer!=-1 || (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)) return; if (battle_config.min_chat_delay) @@ -10216,7 +10210,7 @@ void clif_parse_PartyMessage(int fd, struct map_session_data *sd) sd->cantalk_tick = gettick() + battle_config.min_chat_delay; } - party_send_message(sd, mes, len); + party_send_message(sd, message, len); } /*========================================== @@ -10445,23 +10439,19 @@ void clif_parse_GuildExpulsion(int fd,struct map_session_data *sd) /*========================================== * ギルド会話 *------------------------------------------*/ -void clif_parse_GuildMessage(int fd,struct map_session_data *sd) +void clif_parse_GuildMessage(int fd, struct map_session_data* sd) { - char *mes; + char* message; int len; len = RFIFOW(fd,2) - 4; - mes = (char*)RFIFOP(fd,4); - mes_len_check(mes, len, CHAT_SIZE); + message = (char*)RFIFOP(fd,4); + mes_len_check(message, len, CHAT_SIZE); - if (is_charcommand(fd, sd, mes) != CharCommand_None || - is_atcommand(fd, sd, mes) != AtCommand_None) + if (is_charcommand(fd, sd, message) != CharCommand_None || is_atcommand(fd, sd, message) != AtCommand_None) return; - if (sd->sc.count && ( - sd->sc.data[SC_BERSERK].timer!=-1 || - (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT) - )) + if (sd->sc.data[SC_BERSERK].timer!=-1 || (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)) return; if (battle_config.min_chat_delay) @@ -10471,7 +10461,7 @@ void clif_parse_GuildMessage(int fd,struct map_session_data *sd) sd->cantalk_tick = gettick() + battle_config.min_chat_delay; } - guild_send_message(sd, mes, len); + guild_send_message(sd, message, len); } /*========================================== @@ -10783,7 +10773,8 @@ void clif_parse_GMReqNoChat(int fd,struct map_session_data *sd) if ( ((level = pc_isGM(sd)) > pc_isGM(dstsd) && level >= get_atcommand_level(AtCommand_Mute)) - || (type == 2 && !level)) { + || (type == 2 && !level)) + { clif_GM_silence(sd, dstsd, ((type == 2) ? 1 : type)); dstsd->status.manner -= limit; if(dstsd->status.manner < 0) @@ -11223,7 +11214,7 @@ void clif_parse_FriendsListRemove(int fd, struct map_session_data *sd) /*========================================== * /killall *------------------------------------------*/ -void clif_parse_GMKillAll(int fd,struct map_session_data *sd) +void clif_parse_GMKillAll(int fd, struct map_session_data* sd) { char message[50]; @@ -12015,7 +12006,7 @@ static int packetdb_readdb(void) for(i=0;i<=MAX_PACKET_DB;i++){ if (packet_db[packet_ver][i].func == clif_parse_func[j].func) { - memset(&packet_db[packet_ver][i], 0, sizeof(struct packet_db_t)); + memset(&packet_db[packet_ver][i], 0, sizeof(struct s_packet_db)); break; } } diff --git a/src/map/clif.h b/src/map/clif.h index db8dd92dd..0d33810b9 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -35,7 +35,7 @@ struct guild; #define MAX_PACKET_DB 0x300 #define MAX_PACKET_VER 22 -struct packet_db_t { +struct s_packet_db { short len; void (*func)(int, struct map_session_data *); short pos[20]; @@ -44,7 +44,7 @@ struct packet_db_t { // packet_db[SERVER] is reserved for server use #define SERVER 0 #define packet_len(cmd) packet_db[SERVER][cmd].len -extern struct packet_db_t packet_db[MAX_PACKET_VER+1][MAX_PACKET_DB+1]; +extern struct s_packet_db packet_db[MAX_PACKET_VER+1][MAX_PACKET_DB+1]; // local define enum send_target { diff --git a/src/map/map.h b/src/map/map.h index 5f3672e2a..15a0ece81 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -595,7 +595,7 @@ struct map_session_data { struct mmo_charstatus status; struct registry save_reg; - struct item_data *inventory_data[MAX_INVENTORY]; + struct item_data* inventory_data[MAX_INVENTORY]; // direct pointers to itemdb entries (faster than doing item_id lookups) short equip_index[11]; unsigned int weight,max_weight; int cart_weight,cart_num; @@ -1037,7 +1037,7 @@ enum { struct map_data { char name[MAP_NAME_LENGTH]; unsigned short index; //Index is the map index used by the mapindex* functions. - unsigned char *gat; // If this is NULL the map is not on this map-server + unsigned char *gat; // If this is NULL, the map is not on this map-server unsigned char *cell; //Contains temporary cell data that is set/unset on tiles. #ifdef CELL_NOSTACK unsigned char *cell_bl; //Holds amount of bls in any given cell. @@ -1117,7 +1117,7 @@ struct map_data { struct map_data_other_server { char name[MAP_NAME_LENGTH]; unsigned short index; //Index is the map index used by the mapindex* functions. - unsigned char *gat; // If this is NULL the map is not on this map-server + unsigned char *gat; // If this is NULL, the map is not on this map-server uint32 ip; uint16 port; }; diff --git a/src/map/mob.c b/src/map/mob.c index c6ab7418e..7de4fd50a 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1921,7 +1921,7 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type) if(base_exp && md->dmglog[i].flag) //tmpsd[i] is null if it has no homunc. merc_hom_gainexp(tmpsd[i]->hd, base_exp); if(base_exp || job_exp) - pc_gainexp(tmpsd[i], &md->bl, base_exp,job_exp); + pc_gainexp(tmpsd[i], &md->bl, base_exp, job_exp); if(zeny) // zeny from mobs [Valaris] pc_getzeny(tmpsd[i], zeny); } diff --git a/src/map/npc.c b/src/map/npc.c index c2ab39446..4adf4b946 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -1698,7 +1698,7 @@ static int npc_parse_shop(char* w1, char* w2, char* w3, char* w4) } else { // 引数の個数チェック char mapname[MAP_NAME_LENGTH_EXT]; - if (sscanf(w1, "%15[^,],%d,%d,%d", mapname, &x, &y, &dir) < 4 || strchr(w4, ',') == NULL) { + if (sscanf(w1, "%15[^,],%d,%d,%d", mapname, &x, &y, &dir) != 4 || strchr(w4, ',') == NULL) { ShowError("bad shop line : %s\n", w3); return 1; } diff --git a/src/map/party.c b/src/map/party.c index 7d6c871ab..e4b960342 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -763,7 +763,7 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b } //Does party loot. first holds the id of the player who has time priority to take the item. -int party_share_loot(struct party_data* p, TBL_PC* sd, struct item* item_data, int first) +int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item_data, int first) { TBL_PC* target = NULL; int i; diff --git a/src/map/pc.c b/src/map/pc.c index 2578903a0..00662e91c 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -652,8 +652,7 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t pc_checkitem(sd); status_change_init(&sd->bl); - if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && - (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) + if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide))) sd->status.option &= (OPTION_MASK | OPTION_INVISIBLE); else sd->status.option &= OPTION_MASK; diff --git a/src/map/pet.c b/src/map/pet.c index ebfbc6a0e..b593cbdff 100644 --- a/src/map/pet.c +++ b/src/map/pet.c @@ -212,11 +212,11 @@ int pet_sc_check(struct map_session_data *sd, int type) nullpo_retr(0, sd); pd = sd->pd; - if (pd == NULL || - (battle_config.pet_equip_required && pd->pet.equip == 0) || - pd->recovery == NULL || - pd->recovery->timer != -1 || - pd->recovery->type != type) + if( pd == NULL + || (battle_config.pet_equip_required && pd->pet.equip == 0) + || pd->recovery == NULL + || pd->recovery->timer != -1 + || pd->recovery->type != type ) return 1; pd->recovery->timer = add_timer(gettick()+pd->recovery->delay*1000,pet_recovery_timer,sd->bl.id,0); |