From a85ac18efdbf3d53b5b46a66d0f36f7490a52a5b Mon Sep 17 00:00:00 2001 From: skotlex Date: Wed, 28 Nov 2007 10:50:31 +0000 Subject: - Reverted the position of the max_hp/max_sp basic setting, modified the max_hp/max_sp bonuses to use casting in order to work correctly with negative bonuses. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11832 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/pc.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/map/pc.c') diff --git a/src/map/pc.c b/src/map/pc.c index bde2c5270..654d8836e 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1543,20 +1543,18 @@ int pc_bonus(struct map_session_data *sd,int type,int val) status->def_ele=val; break; case SP_MAXHP: - if(sd->state.lr_flag != 2) { - if (val < 0 && status->max_hp <= (unsigned int)(-val)) - status->max_hp = 1; - else - status->max_hp+=val; - } + if(sd->state.lr_flag == 2) + break; + val += (int)status->max_hp; + //Negative bonuses will underflow, this will be handled in status_calc_pc through casting + //If this is called outside of status_calc_pc, you'd better pray they do not underflow and end with UINT_MAX max_hp. + status->max_hp = (unsigned int)val; break; case SP_MAXSP: - if(sd->state.lr_flag != 2) { - if (val < 0 && status->max_sp <= (unsigned int)(-val)) - status->max_sp = 1; - else - status->max_sp+=val; - } + if(sd->state.lr_flag == 2) + break; + val += (int)status->max_sp; + status->max_sp = (unsigned int)val; break; case SP_CASTRATE: if(sd->state.lr_flag != 2) -- cgit v1.2.3-60-g2f50