From e79922e50324c9724448cd2e003361c4bb3dc4f0 Mon Sep 17 00:00:00 2001 From: Inkfish Date: Tue, 9 Jun 2009 14:03:24 +0000 Subject: Fixed applying autocasts with negative rate before the positive one was applied made it fail to remove the autocast. (bugreport:3193) (related revision: r7312, r9905, r12041) git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13872 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/pc.c | 66 +++++++++++++++++------------------------------------------- 1 file changed, 19 insertions(+), 47 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index 6edc70d96..fdd44339e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1459,48 +1459,18 @@ void pc_autoscript_clear(struct map_session_data *sd) memset(&sd->autoscript3, 0, sizeof(sd->autoscript3)); } -static int pc_bonus_autospell_del(struct s_autospell* spell, int max, short id, short lv, short rate, short card_id) -{ - int i, j; - for(i=max-1; i>=0 && !spell[i].id; i--); - if (i<0) return 0; //Nothing to substract from. - - j = i; - for(; i>=0 && rate>0; i--) - { - if (spell[i].id != id || spell[i].lv != lv) continue; - if (rate >= spell[i].rate) { - rate-= spell[i].rate; - spell[i].rate = 0; - memmove(&spell[i], &spell[j], sizeof(struct s_autospell)); - memset(&spell[j], 0, sizeof(struct s_autospell)); - j--; - } else { - spell[i].rate -= rate; - rate = 0; - } - } - if (rate > 0 && ++j < max) - { //Tag this as "pending" autospell to remove. - spell[j].id = id; - spell[j].lv = lv; - spell[j].rate = -rate; - spell[j].card_id = card_id; - } - return rate; -} - static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, short lv, short rate, short flag, short card_id) { int i; - if (rate < 0) return //Remove the autobonus. - pc_bonus_autospell_del(spell, max, id, lv, -rate, card_id); - for (i = 0; i < max && spell[i].id; i++) { - if ((spell[i].card_id == card_id || spell[i].rate < 0) && - spell[i].id == id && spell[i].lv == lv) + if( !rate ) + return 0; + + for( i = 0; i < max && spell[i].id; i++ ) + { + if( (spell[i].card_id == card_id || spell[i].rate < 0 || rate < 0) && spell[i].id == id && spell[i].lv == lv ) { - if (!battle_config.autospell_stacking && spell[i].rate > 0) + if( !battle_config.autospell_stacking && spell[i].rate > 0 && rate > 0 ) return 0; rate += spell[i].rate; break; @@ -1528,17 +1498,19 @@ static int pc_bonus_autospell(struct s_autospell *spell, int max, short id, shor static int pc_bonus_autospell_onskill(struct s_autospell *spell, int max, short src_skill, short id, short lv, short rate, short card_id) { int i; - if( rate < 0 ) - return pc_bonus_autospell_del(spell, max, id, lv, -rate, card_id); - for( i = 0; i < max && spell[i].id; i++ ) - { - if( spell[i].flag == src_skill && spell[i].id == id && spell[i].lv == lv && spell[i].card_id == card_id ) - { - if( !battle_config.autospell_stacking ) - rate += spell[i].rate; - break; - } + if( !rate ) + return 0; + + for( i = 0; i < max && spell[i].id; i++ ) + { + if( spell[i].flag == src_skill && spell[i].id == id && spell[i].lv == lv && (spell[i].card_id == card_id || spell[i].rate <= 0 || rate < 0) ) + { + if( !battle_config.autospell_stacking && spell[i].rate > 0 && rate > 0 ) + return 0; + rate += spell[i].rate; + break; + } } if( i == max ) -- cgit v1.2.3-60-g2f50