Getting some (mostly atcommand) code cleaning out of the way...

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@11222 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
ultramage 2007-09-15 21:49:21 +00:00
parent 8f931716ed
commit a71c730693
12 changed files with 158 additions and 284 deletions

View File

@ -597,19 +597,6 @@ char atcmd_output[200];
char atcmd_player_name[NAME_LENGTH]; char atcmd_player_name[NAME_LENGTH];
char atcmd_temp[100]; 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 // compare function for sorting high to lowest
int hightolow_compare (const void * a, const void * b) int hightolow_compare (const void * a, const void * b)
{ {
@ -637,32 +624,19 @@ char * msg_txt(int msg_number)
//----------------------------------------------------------- //-----------------------------------------------------------
// Returns Players title (from msg_athena.conf) [Lupus] // Returns Players title (from msg_athena.conf) [Lupus]
//----------------------------------------------------------- //-----------------------------------------------------------
char * player_title_txt(int level) { static char* player_title_txt(int level)
if (level < battle_config.title_lvl1) {
return ""; //w/o any titles const char* format;
format = (level >= battle_config.title_lvl8) ? msg_txt(332)
if (level >= battle_config.title_lvl8) : (level >= battle_config.title_lvl7) ? msg_txt(331)
sprintf(atcmd_temp, msg_txt(332), level); : (level >= battle_config.title_lvl6) ? msg_txt(330)
else : (level >= battle_config.title_lvl5) ? msg_txt(329)
if (level >= battle_config.title_lvl7) : (level >= battle_config.title_lvl4) ? msg_txt(328)
sprintf(atcmd_temp, msg_txt(331), level); : (level >= battle_config.title_lvl3) ? msg_txt(327)
else : (level >= battle_config.title_lvl2) ? msg_txt(326)
if (level >= battle_config.title_lvl6) : (level >= battle_config.title_lvl1) ? msg_txt(325)
sprintf(atcmd_temp, msg_txt(330), level); : "";
else sprintf(atcmd_temp, format, level);
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
return atcmd_temp; return atcmd_temp;
} }
@ -825,25 +799,29 @@ int msg_config_read(const char *cfgName)
if ((--called) == 0) if ((--called) == 0)
memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG); memset(msg_table, 0, sizeof(msg_table[0]) * MAX_MSG);
while(fgets(line, sizeof(line), fp)) while(fgets(line, sizeof(line), fp))
{ {
if (line[0] == '/' && line[1] == '/') if (line[0] == '/' && line[1] == '/')
continue; continue;
if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) == 2) { if (sscanf(line, "%[^:]: %[^\r\n]", w1, w2) != 2)
if (strcmpi(w1, "import") == 0) { continue;
if (strcmpi(w1, "import") == 0)
msg_config_read(w2); msg_config_read(w2);
} else { else
{
msg_number = atoi(w1); msg_number = atoi(w1);
if (msg_number >= 0 && msg_number < MAX_MSG) { if (msg_number >= 0 && msg_number < MAX_MSG)
{
if (msg_table[msg_number] != NULL) if (msg_table[msg_number] != NULL)
aFree(msg_table[msg_number]); aFree(msg_table[msg_number]);
msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char)); msg_table[msg_number] = (char *)aMalloc((strlen(w2) + 1)*sizeof (char));
strcpy(msg_table[msg_number],w2); strcpy(msg_table[msg_number],w2);
// printf("message #%d: '%s'.\n", msg_number, msg_table[msg_number]);
}
} }
} }
} }
fclose(fp); fclose(fp);
return 0; return 0;
@ -1269,29 +1247,15 @@ int atcommand_where(const int fd, struct map_session_data* sd, const char* comma
return -1; 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. clif_displaymessage(fd, msg_txt(3)); // Character not found.
return -1; return -1;
} }
if(strncmp(pl_sd->status.name,atcmd_player_name,NAME_LENGTH)!=0) 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, "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);
clif_displaymessage(fd, atcmd_output); clif_displaymessage(fd, atcmd_output);
return 0; 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) 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; int job = 0, upper = 0;
nullpo_retr(-1, sd); 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) 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); atcommand_killmonster_sub(fd, sd, message, 1);
return 0; 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) 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); atcommand_killmonster_sub(fd, sd, message, 0);
return 0; return 0;
} }
@ -3561,12 +3521,7 @@ int atcommand_refine(const int fd, struct map_session_data* sd, const char* comm
return -1; return -1;
} }
if (refine < -MAX_REFINE) refine = cap_value(refine, -MAX_REFINE, MAX_REFINE);
refine = -MAX_REFINE;
else if (refine > MAX_REFINE)
refine = MAX_REFINE;
else if (refine == 0)
refine = 1;
count = 0; count = 0;
for (j = 0; j < EQI_MAX-1; j++) { 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)) if(position && !(sd->status.inventory[i].equip & position))
continue; continue;
final_refine = sd->status.inventory[i].refine + refine; final_refine = cap_value(sd->status.inventory[i].refine + refine, 0, MAX_REFINE);
if (final_refine > MAX_REFINE)
final_refine = MAX_REFINE;
else if (final_refine < 0)
final_refine = 0;
if (sd->status.inventory[i].refine != final_refine) { if (sd->status.inventory[i].refine != final_refine) {
sd->status.inventory[i].refine = final_refine; sd->status.inventory[i].refine = final_refine;
current_position = sd->status.inventory[i].equip; 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; 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 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. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
}
return 0; return 0;
} }
@ -4332,17 +4274,8 @@ int atcommand_char_ban(const int fd, struct map_session_data* sd, const char* co
return -1; 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 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. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
}
return 0; return 0;
} }
@ -4361,18 +4294,9 @@ int atcommand_char_unblock(const int fd, struct map_session_data* sd, const char
return -1; 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 // 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 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. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
}
return 0; return 0;
} }
@ -4391,18 +4315,9 @@ int atcommand_char_unban(const int fd, struct map_session_data* sd, const char*
return -1; 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 // 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 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. clif_displaymessage(fd, msg_txt(88)); // Character name sent to char-server to ask it.
}
return 0; 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+>)."); clif_displaymessage(fd, "Please, enter a quest skill number (usage: @questskill <#:0+>).");
return -1; return -1;
} }
if (skill_id < 0 && skill_id >= MAX_SKILL_DB) {
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 {
clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
return -1; 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; 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+>)."); clif_displaymessage(fd, "Please, enter a quest skill number (usage: @lostskill <#:0+>).");
return -1; return -1;
} }
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;
}
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].lv = 0;
sd->status.skill[skill_id].flag = 0; sd->status.skill[skill_id].flag = 0;
clif_skillinfoblock(sd); clif_skillinfoblock(sd);
clif_displaymessage(fd, msg_txt(71)); // You have forgotten the skill. 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 {
clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
return -1;
}
return 0; return 0;
} }
@ -6101,7 +6010,7 @@ int atcommand_disguise(const int fd, struct map_session_data* sd, const char* co
if(pc_isriding(sd)) 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. //clif_displaymessage(fd, msg_txt(227)); // Character cannot wear disguise while riding a PecoPeco.
return -1; return -1;
} }
@ -7703,38 +7612,31 @@ int atcommand_petid(const int fd, struct map_session_data* sd, const char* comma
{ {
char searchtext[100]; char searchtext[100];
char temp0[100]; char temp0[100];
char temp1[100];
int cnt = 0, i = 0; int cnt = 0, i = 0;
nullpo_retr(-1, sd); nullpo_retr(-1, sd);
if (!message || !*message || sscanf(message, "%99s", searchtext) < 1) 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; return -1;
} }
estr_lower(searchtext); snprintf(temp0, sizeof(temp0), "First %i search results for: %s", MAX_SEARCH, searchtext);
snprintf(temp0, sizeof(temp0), "Search results for: %s", searchtext);
clif_displaymessage(fd,temp0); clif_displaymessage(fd,temp0);
while (i < MAX_PET_DB) {
strcpy(temp1,pet_db[i].name); for (i = 0; i < MAX_PET_DB; i++)
strcpy(temp1, estr_lower(temp1)); {
strcpy(temp0,pet_db[i].jname); if (stristr(pet_db[i].name, searchtext) || stristr(pet_db[i].jname, searchtext))
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 {
clif_displaymessage(fd, temp0);
}
cnt++; 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);
} }
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); clif_displaymessage(fd, temp0);
return 0; return 0;
@ -8309,13 +8211,14 @@ int atcommand_homevolution(const int fd, struct map_session_data* sd, const char
return -1; return -1;
} }
if ( merc_hom_evolution(sd->hd) ) if ( !merc_hom_evolution(sd->hd) ) {
return 0;
clif_displaymessage(fd, "Your homunculus doesn't evolve."); clif_displaymessage(fd, "Your homunculus doesn't evolve.");
return -1; return -1;
} }
return 0;
}
/*========================================== /*==========================================
* call choosen homunculus [orn] * call choosen homunculus [orn]
*------------------------------------------*/ *------------------------------------------*/
@ -8365,10 +8268,7 @@ int atcommand_homfriendly(const int fd, struct map_session_data* sd, const char*
} }
friendly = atoi(message); friendly = atoi(message);
if (friendly < 0) friendly = cap_value(friendly, 0, 1000);
friendly = 0;
else if (friendly > 1000)
friendly = 1000;
sd->hd->homunculus.intimacy = friendly * 100 ; sd->hd->homunculus.intimacy = friendly * 100 ;
clif_send_homdata(sd,SP_INTIMATE,friendly); 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); hungry = atoi(message);
if (hungry < 0) hungry = cap_value(hungry, 0, 100);
hungry = 0;
else if (hungry > 100)
hungry = 100;
sd->hd->homunculus.hunger = hungry; sd->hd->homunculus.hunger = hungry;
clif_send_homdata(sd,SP_HUNGRY,hungry); clif_send_homdata(sd,SP_HUNGRY,hungry);

View File

@ -300,8 +300,6 @@ int atcommand_config_read(const char *cfgName);
int msg_config_read(const char *cfgName); int msg_config_read(const char *cfgName);
void do_final_msg(void); void do_final_msg(void);
char* estr_lower(char* str);
extern char atcommand_symbol; extern char atcommand_symbol;
#define MAX_MSG 1000 #define MAX_MSG 1000
extern char* msg_table[MAX_MSG]; extern char* msg_table[MAX_MSG];

View File

@ -548,10 +548,7 @@ int charcommand_petfriendly(const int fd, struct map_session_data* sd, const cha
return -1; return -1;
} }
if (friendly < 0) friendly = cap_value(friendly, 0, 1000);
friendly = 0;
else if (friendly > 1000)
friendly = 1000;
pd = pl_sd->pd; pd = pl_sd->pd;
if (friendly == pd->pet.intimate) { if (friendly == pd->pet.intimate) {
@ -1519,28 +1516,25 @@ int charcommand_questskill(const int fd, struct map_session_data* sd, const char
return -1; return -1;
} }
if (skill_id >= 0 && skill_id < MAX_SKILL_DB) { 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 {
clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist. clif_displaymessage(fd, msg_txt(198)); // This skill number doesn't exist.
return -1; 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; return 0;
} }
@ -3269,7 +3263,7 @@ int charcommand_disguise(const int fd, struct map_session_data* sd, const char*
if(pc_isriding(pl_sd)) 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. //clif_displaymessage(fd, msg_txt(228)); // Character cannot wear disguise while riding a PecoPeco.
return -1; return -1;
} }
@ -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)) if(!merc_is_hom_active(pl_sd->hd))
return -1; return -1;
hd = pl_sd->hd; hd = pl_sd->hd;
status = status_get_status_data(&hd->bl); status = status_get_status_data(&hd->bl);
clif_displaymessage(fd, "Homunculus stats :"); clif_displaymessage(fd, "Homunculus stats :");
snprintf(output, sizeof(output) ,"HP : %d/%d - SP : %d/%d", snprintf(output, sizeof(output), "HP : %d/%d - SP : %d/%d", status->hp, status->max_hp, status->sp, status->max_sp);
status->hp, status->max_hp, status->sp, status->max_sp);
clif_displaymessage(fd, output); clif_displaymessage(fd, output);
snprintf(output, sizeof(output) ,"ATK : %d - MATK : %d~%d", snprintf(output, sizeof(output), "ATK : %d - MATK : %d~%d", status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
status->rhw.atk2 +status->batk, status->matk_min, status->matk_max);
clif_displaymessage(fd, output); clif_displaymessage(fd, output);
snprintf(output, sizeof(output) ,"Hungry : %d - Intimacy : %u", snprintf(output, sizeof(output), "Hungry : %d - Intimacy : %u", hd->homunculus.hunger, hd->homunculus.intimacy/100);
hd->homunculus.hunger, hd->homunculus.intimacy/100);
clif_displaymessage(fd, output); clif_displaymessage(fd, output);
snprintf(output, sizeof(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);
"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); clif_displaymessage(fd, output);
return 0; return 0;

View File

@ -476,7 +476,7 @@ void chrif_authok(int fd)
} }
// Awaiting for client to connect. // Awaiting for client to connect.
auth_data = (struct auth_node *)aCalloc(1,sizeof(struct auth_node)); 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->account_id=RFIFOL(fd, 4);
auth_data->login_id1=RFIFOL(fd, 8); auth_data->login_id1=RFIFOL(fd, 8);

View File

@ -49,7 +49,7 @@ struct Clif_Config {
int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex] int connect_cmd[MAX_PACKET_VER + 1]; //Store the connect command for all versions. [Skotlex]
} clif_config; } 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. //Converts item type in case of pet eggs.
#define itemtype(a) (a == IT_PETEGG)?IT_WEAPON:a #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; return;
} }
if (is_atcommand(fd, sd, message) != AtCommand_None || if (is_atcommand(fd, sd, message) != AtCommand_None || is_charcommand(fd, sd, message) != CharCommand_None)
is_charcommand(fd, sd, message) != CharCommand_None)
return; return;
if (sd->sc.count && if (sd->sc.count &&
@ -8779,8 +8778,7 @@ void clif_parse_Wis(int fd, struct map_session_data *sd)
memcpy(msg, RFIFOP(fd, 28), len); memcpy(msg, RFIFOP(fd, 28), len);
mes_len_check(msg, len, CHATBOX_SIZE); mes_len_check(msg, len, CHATBOX_SIZE);
if ((is_charcommand(fd, sd, command) != CharCommand_None) || if ((is_charcommand(fd, sd, command) != CharCommand_None) || (is_atcommand(fd, sd, command) != AtCommand_None)) {
(is_atcommand(fd, sd, command) != AtCommand_None)) {
aFree(command); aFree(command);
return; return;
} }
@ -10192,21 +10190,17 @@ 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; int len;
len = RFIFOW(fd,2) - 4; len = RFIFOW(fd,2) - 4;
mes = (char*)RFIFOP(fd,4); message = (char*)RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE); mes_len_check(message, len, CHAT_SIZE);
if (is_charcommand(fd, sd, mes) != CharCommand_None || if (is_charcommand(fd, sd, message) != CharCommand_None || is_atcommand(fd, sd, message) != AtCommand_None)
is_atcommand(fd, sd, mes) != AtCommand_None)
return; return;
if (sd->sc.count && ( if (sd->sc.data[SC_BERSERK].timer!=-1 || (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT))
sd->sc.data[SC_BERSERK].timer!=-1 ||
(sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
))
return; return;
if (battle_config.min_chat_delay) 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; sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
} }
party_send_message(sd, mes, len); party_send_message(sd, message, len);
} }
/*========================================== /*==========================================
@ -10447,21 +10441,17 @@ 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; int len;
len = RFIFOW(fd,2) - 4; len = RFIFOW(fd,2) - 4;
mes = (char*)RFIFOP(fd,4); message = (char*)RFIFOP(fd,4);
mes_len_check(mes, len, CHAT_SIZE); mes_len_check(message, len, CHAT_SIZE);
if (is_charcommand(fd, sd, mes) != CharCommand_None || if (is_charcommand(fd, sd, message) != CharCommand_None || is_atcommand(fd, sd, message) != AtCommand_None)
is_atcommand(fd, sd, mes) != AtCommand_None)
return; return;
if (sd->sc.count && ( if (sd->sc.data[SC_BERSERK].timer!=-1 || (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT))
sd->sc.data[SC_BERSERK].timer!=-1 ||
(sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOCHAT)
))
return; return;
if (battle_config.min_chat_delay) 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; 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 ( if (
((level = pc_isGM(sd)) > pc_isGM(dstsd) && level >= get_atcommand_level(AtCommand_Mute)) ((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)); clif_GM_silence(sd, dstsd, ((type == 2) ? 1 : type));
dstsd->status.manner -= limit; dstsd->status.manner -= limit;
if(dstsd->status.manner < 0) if(dstsd->status.manner < 0)
@ -12015,7 +12006,7 @@ static int packetdb_readdb(void)
for(i=0;i<=MAX_PACKET_DB;i++){ for(i=0;i<=MAX_PACKET_DB;i++){
if (packet_db[packet_ver][i].func == clif_parse_func[j].func) 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; break;
} }
} }

View File

@ -35,7 +35,7 @@ struct guild;
#define MAX_PACKET_DB 0x300 #define MAX_PACKET_DB 0x300
#define MAX_PACKET_VER 22 #define MAX_PACKET_VER 22
struct packet_db_t { struct s_packet_db {
short len; short len;
void (*func)(int, struct map_session_data *); void (*func)(int, struct map_session_data *);
short pos[20]; short pos[20];
@ -44,7 +44,7 @@ struct packet_db_t {
// packet_db[SERVER] is reserved for server use // packet_db[SERVER] is reserved for server use
#define SERVER 0 #define SERVER 0
#define packet_len(cmd) packet_db[SERVER][cmd].len #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 // local define
enum send_target { enum send_target {

View File

@ -595,7 +595,7 @@ struct map_session_data {
struct mmo_charstatus status; struct mmo_charstatus status;
struct registry save_reg; 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]; short equip_index[11];
unsigned int weight,max_weight; unsigned int weight,max_weight;
int cart_weight,cart_num; int cart_weight,cart_num;
@ -1037,7 +1037,7 @@ enum {
struct map_data { struct map_data {
char name[MAP_NAME_LENGTH]; char name[MAP_NAME_LENGTH];
unsigned short index; //Index is the map index used by the mapindex* functions. 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. unsigned char *cell; //Contains temporary cell data that is set/unset on tiles.
#ifdef CELL_NOSTACK #ifdef CELL_NOSTACK
unsigned char *cell_bl; //Holds amount of bls in any given cell. unsigned char *cell_bl; //Holds amount of bls in any given cell.
@ -1117,7 +1117,7 @@ struct map_data {
struct map_data_other_server { struct map_data_other_server {
char name[MAP_NAME_LENGTH]; char name[MAP_NAME_LENGTH];
unsigned short index; //Index is the map index used by the mapindex* functions. 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; uint32 ip;
uint16 port; uint16 port;
}; };

View File

@ -1698,7 +1698,7 @@ static int npc_parse_shop(char* w1, char* w2, char* w3, char* w4)
} else { } else {
// 引数の個数チェック // 引数の個数チェック
char mapname[MAP_NAME_LENGTH_EXT]; 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); ShowError("bad shop line : %s\n", w3);
return 1; return 1;
} }

View File

@ -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. //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; TBL_PC* target = NULL;
int i; int i;

View File

@ -652,8 +652,7 @@ int pc_authok(struct map_session_data *sd, int login_id2, time_t connect_until_t
pc_checkitem(sd); pc_checkitem(sd);
status_change_init(&sd->bl); status_change_init(&sd->bl);
if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && if ((battle_config.atc_gmonly == 0 || pc_isGM(sd)) && (pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide)))
(pc_isGM(sd) >= get_atcommand_level(AtCommand_Hide)))
sd->status.option &= (OPTION_MASK | OPTION_INVISIBLE); sd->status.option &= (OPTION_MASK | OPTION_INVISIBLE);
else else
sd->status.option &= OPTION_MASK; sd->status.option &= OPTION_MASK;

View File

@ -212,11 +212,11 @@ int pet_sc_check(struct map_session_data *sd, int type)
nullpo_retr(0, sd); nullpo_retr(0, sd);
pd = sd->pd; pd = sd->pd;
if (pd == NULL || if( pd == NULL
(battle_config.pet_equip_required && pd->pet.equip == 0) || || (battle_config.pet_equip_required && pd->pet.equip == 0)
pd->recovery == NULL || || pd->recovery == NULL
pd->recovery->timer != -1 || || pd->recovery->timer != -1
pd->recovery->type != type) || pd->recovery->type != type )
return 1; return 1;
pd->recovery->timer = add_timer(gettick()+pd->recovery->delay*1000,pet_recovery_timer,sd->bl.id,0); pd->recovery->timer = add_timer(gettick()+pd->recovery->delay*1000,pet_recovery_timer,sd->bl.id,0);