From 5f857bae116433a2a0fd38b8c3539352c5453f7a Mon Sep 17 00:00:00 2001 From: ultramage Date: Sat, 22 Dec 2007 09:00:57 +0000 Subject: Fixed mob AI code iterating over non-mob objects without checking, when monster_ai flag 0x20 is set (caused by r11943) Cleaned up macros that wrap unit_stop_attack() (bugreport:357) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11957 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/atcommand.c | 31 +++++++++++++++++-------------- src/map/intif.c | 1 + src/map/mercenary.h | 2 +- src/map/mob.c | 2 +- src/map/mob.h | 2 +- src/map/party.c | 2 +- src/map/pc.h | 2 +- src/map/pet.h | 2 +- src/map/skill.c | 2 +- 9 files changed, 25 insertions(+), 21 deletions(-) (limited to 'src/map') diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 9cd024a32..816484cdd 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -6033,10 +6033,10 @@ int atcommand_partyoption(const int fd, struct map_session_data* sd, const char* if(!message || !*message || sscanf(message, "%15s %15s", w1, w2) < 2) { - clif_displaymessage(fd, "Command usage: @changeoption "); + clif_displaymessage(fd, "Command usage: @partyoption "); return -1; } - + option = (config_switch(w1)?1:0)|(config_switch(w2)?2:0); //Change item share type. @@ -6390,12 +6390,6 @@ int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* com { char mes[100],temp[100]; struct pet_data *pd; - const char* emo[] = { "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...", - "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2", - "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg", - "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh", - "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa", - "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice", NULL }; nullpo_retr(-1, sd); @@ -6415,13 +6409,22 @@ int atcommand_pettalk(const int fd, struct map_session_data* sd, const char* com return -1; } - if (message[0] == '/') { + if (message[0] == '/') + {// pet emotion processing + const char* emo[] = { + "/!", "/?", "/ho", "/lv", "/swt", "/ic", "/an", "/ag", "/$", "/...", + "/scissors", "/rock", "/paper", "/korea", "/lv2", "/thx", "/wah", "/sry", "/heh", "/swt2", + "/hmm", "/no1", "/??", "/omg", "/O", "/X", "/hlp", "/go", "/sob", "/gg", + "/kis", "/kis2", "/pif", "/ok", "-?-", "-?-", "/bzz", "/rice", "/awsm", "/meh", + "/shy", "/pat", "/mp", "/slur", "/com", "/yawn", "/grat", "/hp", "/philippines", "/usa", + "/indonesia", "/brazil", "/fsh", "/spin", "/sigh", "/dum", "/crwd", "/desp", "/dice" + }; int i; - for (i = 0; emo[i] != NULL; i++) { - if (!stricmp(message, emo[i])) { - clif_emotion(&pd->bl, i); - return 0; - } + ARR_FIND( 0, ARRAYLENGTH(emo), i, stricmp(message, emo[i]) == 0 ); + if( i < ARRAYLENGTH(emo) ) + { + clif_emotion(&pd->bl, i); + return 0; } } diff --git a/src/map/intif.c b/src/map/intif.c index bcb1eef2a..49791ed94 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -1032,6 +1032,7 @@ int intif_parse_LoadGuildStorage(int fd) gstor=guild2storage(guild_id); if(!gstor) { ShowWarning("intif_parse_LoadGuildStorage: error guild_id %d not exist\n",guild_id); + return 1; } if (gstor->storage_status == 1) { // Already open.. lets ignore this update ShowWarning("intif_parse_LoadGuildStorage: storage received for a client already open (User %d:%d)\n", sd->status.account_id, sd->status.char_id); diff --git a/src/map/mercenary.h b/src/map/mercenary.h index ba5db0ba8..95193df0a 100644 --- a/src/map/mercenary.h +++ b/src/map/mercenary.h @@ -55,7 +55,7 @@ int merc_hom_hungry_timer_delete(struct homun_data *hd); int merc_hom_change_name(struct map_session_data *sd,char *name); int merc_hom_change_name_ack(struct map_session_data *sd, char* name, int flag); #define merc_stop_walking(hd, type) unit_stop_walking(&(hd)->bl, type) -#define merc_stop_attack(hd) { if((hd)->ud.attacktimer != -1) unit_stop_attack(&(hd)->bl); hd->ud.target = 0; } +#define merc_stop_attack(hd) unit_stop_attack(&(hd)->bl) int merc_hom_increase_intimacy(struct homun_data * hd, unsigned int value); int merc_hom_decrease_intimacy(struct homun_data * hd, unsigned int value); int merc_skill_tree_get_max(int id, int b_class); diff --git a/src/map/mob.c b/src/map/mob.c index 8b01df25b..1c28584d3 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -1454,7 +1454,7 @@ static int mob_ai_hard(int tid,unsigned int tick,int id,int data) { if (battle_config.mob_ai&0x20) - map_foreachiddb(mob_ai_sub_lazy,tick); + map_foreachmob(mob_ai_sub_lazy,tick); else clif_foreachclient(mob_ai_sub_foreachclient,tick); diff --git a/src/map/mob.h b/src/map/mob.h index a731df847..69b555deb 100644 --- a/src/map/mob.h +++ b/src/map/mob.h @@ -178,7 +178,7 @@ void mob_revive(struct mob_data *md, unsigned int hp); void mob_heal(struct mob_data *md,unsigned int heal); #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type) -#define mob_stop_attack(md) { if((md)->ud.attacktimer != -1) unit_stop_attack(&(md)->bl); } +#define mob_stop_attack(md) unit_stop_attack(&(md)->bl) void mob_clear_spawninfo(); int do_init_mob(void); diff --git a/src/map/party.c b/src/map/party.c index dc5ddb1f9..1b3a9eaf7 100644 --- a/src/map/party.c +++ b/src/map/party.c @@ -437,7 +437,7 @@ int party_member_leaved(int party_id, int account_id, int char_id) } } - if( sd && sd->status.party_id==party_id && sd->status.char_id == char_id ) + if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id ) { sd->status.party_id = 0; sd->state.party_sent = 0; diff --git a/src/map/pc.h b/src/map/pc.h index 6e76115d6..2b06b5126 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -119,7 +119,7 @@ enum { #define pc_maxparameter(sd) ( (sd)->class_&JOBL_BABY ? battle_config.max_baby_parameter : battle_config.max_parameter ) #define pc_stop_walking(sd, type) unit_stop_walking(&(sd)->bl, type) -#define pc_stop_attack(sd) { if((sd)->ud.attacktimer != -1) { unit_stop_attack(&(sd)->bl); (sd)->ud.target = 0; } } +#define pc_stop_attack(sd) unit_stop_attack(&(sd)->bl) //Weapon check considering dual wielding. #define pc_check_weapontype(sd, type) ((type)&((sd)->status.weapon < MAX_WEAPON_TYPE? \ diff --git a/src/map/pet.h b/src/map/pet.h index 835d8a04d..b5dda0944 100644 --- a/src/map/pet.h +++ b/src/map/pet.h @@ -59,7 +59,7 @@ int pet_recovery_timer(int tid,unsigned int tick,int id,int data); // [Valaris] int pet_heal_timer(int tid,unsigned int tick,int id,int data); // [Valaris] #define pet_stop_walking(pd, type) unit_stop_walking(&(pd)->bl, type) -#define pet_stop_attack(pd) { if((pd)->ud.attacktimer != -1) unit_stop_attack(&(pd)->bl); } +#define pet_stop_attack(pd) unit_stop_attack(&(pd)->bl) int read_petdb(void); int do_init_pet(void); diff --git a/src/map/skill.c b/src/map/skill.c index 6e9935e33..f3709e93a 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -4567,7 +4567,7 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in if( (su) && (sg = su->group) && (sg->src_id == src->id || map_flag_vs(bl->m)) - && (skill_get_inf2(sg->skill_id)&INF2_TRAP) ) + && (skill_get_inf2(sg->skill_id)&INF2_TRAP) ) { // prevent picking up expired traps if( !(sg->unit_id == UNT_USED_TRAPS || (sg->unit_id == UNT_ANKLESNARE && sg->val2 != 0 )) ) { -- cgit v1.2.3-70-g09d2