Selaa lähdekoodia

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://svn.code.sf.net/p/rathena/svn/trunk@13872 54d463be-8e91-2dee-dedb-b68131a5f0ec
Inkfish 16 vuotta sitten
vanhempi
commit
11c91fd0bd
2 muutettua tiedostoa jossa 21 lisäystä ja 47 poistoa
  1. 2 0
      Changelog-Trunk.txt
  2. 19 47
      src/map/pc.c

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
+09/06/09
+	* Fixed applying autocasts with negative rate before the positive one made it fail to remove the autocast. [Inkfish]
 09/06/08
 	* Rev. 13869 Follow up to r13867, corrected the newly added MD_TARGETWEAK. Monsters with this mode will now only target players five level LOWER than itself. [L0ne_W0lf]
 09/06/08

+ 19 - 47
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 )