Ver Fonte

- Corrected aspd calculation code to avoid negative overflows.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6827 54d463be-8e91-2dee-dedb-b68131a5f0ec
skotlex há 19 anos atrás
pai
commit
38eeb73b96
2 ficheiros alterados com 17 adições e 16 exclusões
  1. 1 0
      Changelog-Trunk.txt
  2. 16 16
      src/map/status.c

+ 1 - 0
Changelog-Trunk.txt

@@ -4,6 +4,7 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/05/29
+	* Corrected aspd calculation code to avoid negative overflows. [Skotlex]
 	* Fixed battle_check_target check on BCT_ALL to check versus BL_CHAR
 	  instead of BL_PC and BL_MOB [Skotlex]
 	* [Fixed]:

+ 16 - 16
src/map/status.c

@@ -51,6 +51,9 @@ int current_equip_card_id; //To prevent card-stacking (from jA) [Skotlex]
 //we need it for new cards 15 Feb 2005, to check if the combo cards are insrerted into the CURRENT weapon only
 //to avoid cards exploits
 
+//Caps values to min/max
+#define cap_value(a, min, max) (a>max?max:a<min?min:a)
+
 //Initializes the StatusIconChangeTable variable. May seem somewhat slower than directly defining the array,
 //but it is much less prone to errors. [Skotlex]
 void initChangeTables(void) {
@@ -1737,15 +1740,17 @@ int status_calc_pc(struct map_session_data* sd,int first)
 
 	// Basic ASPD value
 	if (sd->status.weapon < MAX_WEAPON_TYPE)
-		status->amotion = aspd_base[sd->status.class_][sd->status.weapon]-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->status.weapon]/1000;
+		i = aspd_base[sd->status.class_][sd->status.weapon]-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->status.weapon]/1000;
 	else
-		status->amotion = (
+		i = (
 			(aspd_base[sd->status.class_][sd->weapontype1]
 			-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->weapontype1]/1000) +
 			(aspd_base[sd->status.class_][sd->weapontype2]
 			-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->weapontype2]/1000)
 			) *2/3; //From what I read in rodatazone, 2/3 should be more accurate than 0.7 -> 140 / 200; [Skotlex]
 
+	status->amotion = cap_value(i,battle_config.max_aspd,2000);
+
 	// Relative modifiers from passive skills
 	if((skill=pc_checkskill(sd,SA_ADVANCEDBOOK))>0 && sd->status.weapon == W_BOOK)
 		status->aspd_rate -= (skill/2);
@@ -2168,9 +2173,9 @@ void status_calc_bl_sub_pc(struct map_session_data *sd, unsigned long flag)
 
 	if(flag&(SCB_ASPD|SCB_AGI|SCB_DEX)) {
 		if (sd->status.weapon < MAX_WEAPON_TYPE)
-			status->amotion = aspd_base[sd->status.class_][sd->status.weapon]-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->status.weapon]/1000;
+			skill = aspd_base[sd->status.class_][sd->status.weapon]-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->status.weapon]/1000;
 		else
-			status->amotion = (
+			skill = (
 				(aspd_base[sd->status.class_][sd->weapontype1]
 				-(status->agi*4+status->dex)*aspd_base[sd->status.class_][sd->weapontype1]/1000) +
 				(aspd_base[sd->status.class_][sd->weapontype2]
@@ -2181,10 +2186,9 @@ void status_calc_bl_sub_pc(struct map_session_data *sd, unsigned long flag)
 		
 		// Apply all relative modifiers
 		if(status->aspd_rate != 100)
-			status->amotion = status->amotion*status->aspd_rate/100;
+			skill = skill *status->aspd_rate/100;
 
-		if(status->amotion < battle_config.max_aspd)
-			status->amotion = battle_config.max_aspd;
+		status->amotion = cap_value(skill,battle_config.max_aspd,2000);
 
 		status->adelay = 2*status->amotion;
 		if ((skill=pc_checkskill(sd,SA_FREECAST))>0) {
@@ -2464,20 +2468,16 @@ void status_calc_bl(struct block_list *bl, unsigned long flag)
 	
 	if(flag&SCB_ASPD) {
 		status->aspd_rate = status_calc_aspd_rate(bl, sc , b_status->aspd_rate);
-		status->amotion = status->aspd_rate*b_status->amotion/100;
-		status->adelay = status->aspd_rate*b_status->adelay/100;
-
-		if(status->adelay < battle_config.monster_max_aspd<<1)
-			status->adelay = battle_config.monster_max_aspd<<1;
-		if(status->amotion < battle_config.monster_max_aspd)
-			status->amotion = battle_config.monster_max_aspd;
+		temp = status->aspd_rate*b_status->amotion/100;
+		status->amotion = cap_value(temp, battle_config.monster_max_aspd, 2000);
+		
+		temp = status->aspd_rate*b_status->adelay/100;
+		status->adelay = cap_value(temp, battle_config.monster_max_aspd<<1, 4000);
 	}
 
 	if(flag&SCB_DSPD)
 		status->dmotion = status_calc_dmotion(bl, sc, b_status->dmotion);
 }
-//Caps values to min/max
-#define cap_value(a, min, max) (a>max?max:a<min?min:a)
 /*==========================================
  * Apply shared stat mods from status changes [DracoRPG]
  *------------------------------------------