浏览代码

- Added a division by zero check in mob_dead to prevent the (impossible) case where a mob dies with received damage of zero.
- Fixed compilation errors with SC_FLING...


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@6821 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 年之前
父节点
当前提交
048bd9bd8f
共有 3 个文件被更改,包括 12 次插入8 次删除
  1. 2 0
      Changelog-Trunk.txt
  2. 5 3
      src/map/mob.c
  3. 5 5
      src/map/status.c

+ 2 - 0
Changelog-Trunk.txt

@@ -4,6 +4,8 @@ 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.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
 2006/05/29
 2006/05/29
+	* Added a division by zero check in mob_dead to prevent the (impossible)
+	  case where a mob dies with received damage of zero. [Skotlex]
 	* Modified skill_get_range2 to return range 9 for skills with range 0 for
 	* Modified skill_get_range2 to return range 9 for skills with range 0 for
 	  Non-Players. This usually signals Self skills, and mobs/pets should be able
 	  Non-Players. This usually signals Self skills, and mobs/pets should be able
 	  to use them in other characters. [Skotlex]
 	  to use them in other characters. [Skotlex]

+ 5 - 3
src/map/mob.c

@@ -1768,10 +1768,12 @@ int mob_dead(struct mob_data *md, struct block_list *src, int type)
 		double per; //Your share of the mob's exp
 		double per; //Your share of the mob's exp
 		int bonus; //Bonus on top of your share.
 		int bonus; //Bonus on top of your share.
 		
 		
-		if (battle_config.exp_calc_type)	// eAthena's exp formula based on max hp.
-			per = (double)md->dmglog[i].dmg/(double)status->max_hp;
-		else //jAthena's exp formula based on total damage.
+		if (!battle_config.exp_calc_type && md->tdmg)
+			//jAthena's exp formula based on total damage.
 			per = (double)md->dmglog[i].dmg/(double)md->tdmg;
 			per = (double)md->dmglog[i].dmg/(double)md->tdmg;
+		else
+			//eAthena's exp formula based on max hp.
+			per = (double)md->dmglog[i].dmg/(double)status->max_hp;
 	
 	
 		if (count>1)	
 		if (count>1)	
 			per *= (9.+(double)((count > 6)? 6:count))/10.; //attackers count bonus.
 			per *= (9.+(double)((count > 6)? 6:count))/10.; //attackers count bonus.

+ 5 - 5
src/map/status.c

@@ -344,7 +344,7 @@ void initChangeTables(void) {
 	set_sc(GS_ADJUSTMENT, SC_ADJUSTMENT, SI_ADJUSTMENT, SCB_HIT|SCB_FLEE);
 	set_sc(GS_ADJUSTMENT, SC_ADJUSTMENT, SI_ADJUSTMENT, SCB_HIT|SCB_FLEE);
 	set_sc(GS_INCREASING, SC_INCREASING, SI_ACCURACY, SCB_AGI|SCB_DEX|SCB_HIT);
 	set_sc(GS_INCREASING, SC_INCREASING, SI_ACCURACY, SCB_AGI|SCB_DEX|SCB_HIT);
 	set_sc(GS_GATLINGFEVER, SC_GATLINGFEVER, SI_GATLINGFEVER, SCB_FLEE|SCB_SPEED|SCB_ASPD);
 	set_sc(GS_GATLINGFEVER, SC_GATLINGFEVER, SI_GATLINGFEVER, SCB_FLEE|SCB_SPEED|SCB_ASPD);
-	set_sc(GS_FLING, SC_FLING, SI_NONE, SCB_DEF|SCB_DEF2);
+	set_sc(GS_FLING, SC_FLING, SI_BLANK, SCB_DEF|SCB_DEF2);
 
 
 	//Uncomment and update when you plan on implementing.
 	//Uncomment and update when you plan on implementing.
 //	set_sc(NJ_TATAMIGAESHI, SC_TATAMIGAESHI, SI_BLANK);
 //	set_sc(NJ_TATAMIGAESHI, SC_TATAMIGAESHI, SI_BLANK);
@@ -2889,8 +2889,8 @@ static unsigned char status_calc_def(struct block_list *bl, struct status_change
 		def -= def * sc->data[SC_PROVOKE].val4/100;
 		def -= def * sc->data[SC_PROVOKE].val4/100;
 	if(sc->data[SC_STRIPSHIELD].timer!=-1)
 	if(sc->data[SC_STRIPSHIELD].timer!=-1)
 		def -= def * sc->data[SC_STRIPSHIELD].val2/100;
 		def -= def * sc->data[SC_STRIPSHIELD].val2/100;
-	if (sd->data[SC_FLING].timer!=-1)
-		def -= def * (sd->data[SC_FLING].val2)/100;
+	if (sc->data[SC_FLING].timer!=-1)
+		def -= def * (sc->data[SC_FLING].val2)/100;
 	return cap_value(def,0,UCHAR_MAX);
 	return cap_value(def,0,UCHAR_MAX);
 }
 }
 
 
@@ -2921,8 +2921,8 @@ static unsigned short status_calc_def2(struct block_list *bl, struct status_chan
 		else if(sc->data[SC_JOINTBEAT].val2==4)
 		else if(sc->data[SC_JOINTBEAT].val2==4)
 			def2 -= def2 * 25/100;
 			def2 -= def2 * 25/100;
 	}
 	}
-	if (sd->data[SC_FLING].timer!=-1)
-		def2 -= def2 * (sd->data[SC_FLING].val3)/100;
+	if(sc->data[SC_FLING].timer!=-1)
+		def2 -= def2 * (sc->data[SC_FLING].val3)/100;
 
 
 	return cap_value(def2,0,USHRT_MAX);
 	return cap_value(def2,0,USHRT_MAX);
 }
 }