فهرست منبع

- Fixed the weight icon dissapearing and reappearing when attacking. (introduced by me at r9600, fix based on ultramage's code)
Ref: http://www.eathena.ws/board/index.php?showtopic=131211

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

FlavioJS 18 سال پیش
والد
کامیت
56921611e1
2فایلهای تغییر یافته به همراه28 افزوده شده و 19 حذف شده
  1. 3 0
      Changelog-Trunk.txt
  2. 25 19
      src/map/pc.c

+ 3 - 0
Changelog-Trunk.txt

@@ -3,6 +3,9 @@ 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.
 
+2007/01/06
+	* Fixed the weight icon dissapearing and reappearing when attacking.
+	  (introduced by me at r9600, fix based on ultramage's code) [FlavioJS]
 2007/01/05
 	* Also discarded some veeery old utils code that has got equivalents
 	  in the std libs (and therefore is silently causing a nasty collision).

+ 25 - 19
src/map/pc.c

@@ -1094,31 +1094,37 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd) {
 /*==========================================
  * Updates the weight status
  *------------------------------------------
+ * 1: overweight 50%
+ * 2: overweight 90%
+ * It's assumed that SC_WEIGHT50 and SC_WEIGHT90 are only started/stopped here.
  */
 int pc_updateweightstatus(struct map_session_data *sd)
 {
-	int flag=0;
+	int old_overweight;
+	int new_overweight;
 
-	nullpo_retr(0, sd);
+	nullpo_retr(1, sd);
+
+	old_overweight = (sd->sc.data[SC_WEIGHT90].timer != -1) ? 2 : (sd->sc.data[SC_WEIGHT50].timer != -1) ? 1 : 0;
+	new_overweight = (pc_is90overweight(sd)) ? 2 : (pc_is50overweight(sd)) ? 1 : 0;
+
+	if( old_overweight == new_overweight )
+		return 0; // no change
+
+	// stop old status change
+	if( old_overweight == 1 )
+		status_change_end(&sd->bl, SC_WEIGHT50, -1);
+	else if( old_overweight == 2 )
+		status_change_end(&sd->bl, SC_WEIGHT90, -1);
+
+	// start new status change
+	if( new_overweight == 1 )
+		sc_start(&sd->bl, SC_WEIGHT50, 100, 0, 0);
+	else if( new_overweight == 2 )
+		sc_start(&sd->bl, SC_WEIGHT90, 100, 0, 0);
 
-	if( pc_is90overweight(sd) )
-		flag=2;
-	else if( pc_is50overweight(sd) )
-		flag=1;
-
-	// 50% overweight icon
-	if( flag == 1 && sd->sc.data[SC_WEIGHT50].timer == -1 )
-		sc_start(&sd->bl,SC_WEIGHT50,100,0,0);
-	else if( sd->sc.data[SC_WEIGHT50].timer != -1 )
-		status_change_end(&sd->bl,SC_WEIGHT50,-1);
-	// 90% overwheight icon
-	if( flag == 2 && sd->sc.data[SC_WEIGHT90].timer == -1 )
-		sc_start(&sd->bl,SC_WEIGHT90,100,0,0);
-	else if( sd->sc.data[SC_WEIGHT90].timer != -1 )
-		status_change_end(&sd->bl,SC_WEIGHT90,-1);
 	// update overweight status
-	if (flag != sd->regen.state.overweight)
-		sd->regen.state.overweight = flag;
+	sd->regen.state.overweight = new_overweight;
 
 	return 0;
 }