summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
authorFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-06 07:27:52 +0000
committerFlavioJS <FlavioJS@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-01-06 07:27:52 +0000
commitf044795aa8967ff4d99c3579553474d6bab4bf90 (patch)
tree72f2f444187a82a5a84af8d071e7cc37bd66a796 /src/map/pc.c
parentaa2b91126827e6460a86ba0622a1f41328a7303e (diff)
downloadhercules-f044795aa8967ff4d99c3579553474d6bab4bf90.tar.gz
hercules-f044795aa8967ff4d99c3579553474d6bab4bf90.tar.bz2
hercules-f044795aa8967ff4d99c3579553474d6bab4bf90.tar.xz
hercules-f044795aa8967ff4d99c3579553474d6bab4bf90.zip
- 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://rathena.svn.sourceforge.net/svnroot/rathena/trunk@9620 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 0b2e7a56e..0434d3377 100644
--- a/src/map/pc.c
+++ b/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;
}