diff options
author | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-07-01 11:21:33 +0000 |
---|---|---|
committer | shennetsind <shennetsind@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2012-07-01 11:21:33 +0000 |
commit | 23a884ba4d24efdb80fc7a81ac2199e5ec7a2bb0 (patch) | |
tree | 4d2c9bea3a36f52cf8b8b0023a9fa9b32ac97a09 /src/map/battle.c | |
parent | 85b119962ce618097aa58e513975e4454cc15610 (diff) | |
download | hercules-23a884ba4d24efdb80fc7a81ac2199e5ec7a2bb0.tar.gz hercules-23a884ba4d24efdb80fc7a81ac2199e5ec7a2bb0.tar.bz2 hercules-23a884ba4d24efdb80fc7a81ac2199e5ec7a2bb0.tar.xz hercules-23a884ba4d24efdb80fc7a81ac2199e5ec7a2bb0.zip |
Fixed bugreport:6123 fixed issue with null dat->src crash. Also applied a performance improvement by removing the idb lookup on every delayed damage
Super mega thanks to Cookie and Wildcard.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16359 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/battle.c')
-rw-r--r-- | src/map/battle.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/map/battle.c b/src/map/battle.c index e1901503b..7d09ff17f 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -186,7 +186,7 @@ struct block_list* battle_getenemyarea(struct block_list *src, int x, int y, int // ƒ_??[ƒW‚Ì’x‰„ struct delay_damage { struct block_list *src; - int target; + struct block_list *target; int damage; int delay; unsigned short distance; @@ -199,27 +199,26 @@ struct delay_damage { int battle_delay_damage_sub(int tid, unsigned int tick, int id, intptr_t data) { struct delay_damage *dat = (struct delay_damage *)data; - struct block_list *target = map_id2bl(dat->target); - if ( target && dat && target->prev != NULL && !status_isdead(target) ) { - if( id == dat->src->id && - target->m == dat->src->m && - (target->type != BL_PC || ((TBL_PC*)target)->invincible_timer == INVALID_TIMER) && - check_distance_bl(dat->src, target, dat->distance) ) //Check to see if you haven't teleported. [Skotlex] + if ( dat && dat->target && dat->target->prev != NULL && !status_isdead(dat->target) ) { + if( dat->src && dat->src->prev != NULL && id == dat->src->id && + dat->target->m == dat->src->m && + (dat->target->type != BL_PC || ((TBL_PC*)dat->target)->invincible_timer == INVALID_TIMER) && + check_distance_bl(dat->src, dat->target, dat->distance) ) //Check to see if you haven't teleported. [Skotlex] { map_freeblock_lock(); - status_fix_damage(dat->src, target, dat->damage, dat->delay); - if( dat->attack_type && !status_isdead(target) ) - skill_additional_effect(dat->src,target,dat->skill_id,dat->skill_lv,dat->attack_type,dat->dmg_lv,tick); + status_fix_damage(dat->src, dat->target, dat->damage, dat->delay); + if( dat->attack_type && !status_isdead(dat->target) ) + skill_additional_effect(dat->src,dat->target,dat->skill_id,dat->skill_lv,dat->attack_type,dat->dmg_lv,tick); if( dat->dmg_lv > ATK_BLOCK && dat->attack_type ) - skill_counter_additional_effect(dat->src,target,dat->skill_id,dat->skill_lv,dat->attack_type,tick); + skill_counter_additional_effect(dat->src,dat->target,dat->skill_id,dat->skill_lv,dat->attack_type,tick); map_freeblock_unlock(); } else if( dat->skill_id == CR_REFLECTSHIELD && !map_id2bl(id) ) { /** * it was monster reflected damage, and the monster died, we pass the damage to the character as expected **/ map_freeblock_lock(); - status_fix_damage(target, target, dat->damage, dat->delay); + status_fix_damage(dat->target, dat->target, dat->damage, dat->delay); map_freeblock_unlock(); } } @@ -251,7 +250,7 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src, } dat = ers_alloc(delay_damage_ers, struct delay_damage); dat->src = src; - dat->target = target->id; + dat->target = target; dat->skill_id = skill_id; dat->skill_lv = skill_lv; dat->attack_type = attack_type; |