summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorInkfish <Inkfish@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-06-09 14:03:24 +0000
committerInkfish <Inkfish@54d463be-8e91-2dee-dedb-b68131a5f0ec>2009-06-09 14:03:24 +0000
commite79922e50324c9724448cd2e003361c4bb3dc4f0 (patch)
tree6b27c0e2246cfacce42650689880dae344480ab6 /src/map/pc.c
parent73a88a624ad1aabc7c92956eaffe7b60f9c8a40a (diff)
downloadhercules-e79922e50324c9724448cd2e003361c4bb3dc4f0.tar.gz
hercules-e79922e50324c9724448cd2e003361c4bb3dc4f0.tar.bz2
hercules-e79922e50324c9724448cd2e003361c4bb3dc4f0.tar.xz
hercules-e79922e50324c9724448cd2e003361c4bb3dc4f0.zip
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
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c66
1 files changed, 19 insertions, 47 deletions
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 )