From 43a24c0c88bdf19935d15d1b8392e3527ff090cd Mon Sep 17 00:00:00 2001 From: shennetsind Date: Sun, 18 Jan 2015 19:53:10 -0200 Subject: For bug report 8367 While unable to reproduce, I implemented a countermeasure to the issue in question (settick failing, which'd cause blockskill[] not to be filled). Hopefully someone who can reproduce is able to shed some light on the conditions required, allowing for a proper fix to be made. http://hercules.ws/board/tracker/issue-8367-timer-settick-issue/ Signed-off-by: shennetsind --- src/map/skill.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'src/map/skill.c') diff --git a/src/map/skill.c b/src/map/skill.c index 1fad55364..00c0caaa4 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -17890,7 +17890,7 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) sd->blockskill[idx] = false; return -1; } - + if( battle_config.display_status_timers ) clif->skill_cooldown(sd, skill_id, tick); @@ -17898,9 +17898,10 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) cd = ers_alloc(skill->cd_ers, struct skill_cd); idb_put( skill->cd_db, sd->status.char_id, cd ); + } else { int i; - + for(i = 0; i < cd->cursor; i++) { if( cd->entry[i] && cd->entry[i]->skidx == idx ) break; @@ -17912,8 +17913,25 @@ int skill_blockpc_start_(struct map_session_data *sd, uint16 skill_id, int tick) cd->entry[i]->total = tick; #endif cd->entry[i]->started = now; - timer->settick(cd->entry[i]->timer,now+tick); - return 0; + if( timer->settick(cd->entry[i]->timer,now+tick) != -1 ) + return 0; + else { + int cursor; + /** somehow, the timer vanished. (bugreport:8367) **/ + ers_free(skill->cd_entry_ers, cd->entry[i]); + + cd->entry[i] = NULL; + + for( i = 0, cursor = 0; i < cd->cursor; i++ ) { + if( !cd->entry[i] ) + continue; + if( cursor != i ) + cd->entry[cursor] = cd->entry[i]; + cursor++; + } + + cd->cursor = cursor; + } } } -- cgit v1.2.3-60-g2f50