From f044795aa8967ff4d99c3579553474d6bab4bf90 Mon Sep 17 00:00:00 2001 From: FlavioJS Date: Sat, 6 Jan 2007 07:27:52 +0000 Subject: - 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 --- Changelog-Trunk.txt | 3 +++ src/map/pc.c | 44 +++++++++++++++++++++++++------------------- 2 files changed, 28 insertions(+), 19 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index a68b2f8fa..948900531 100644 --- a/Changelog-Trunk.txt +++ b/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). 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; } -- cgit v1.2.3-60-g2f50