From 3336e16f8df0e8e3634275416b77121628c81b35 Mon Sep 17 00:00:00 2001 From: ai4rei Date: Wed, 6 Apr 2011 18:38:08 +0000 Subject: * Resolved some pc_setparam issues. - Fixed HP/MaxHP/SP/MaxSP could be set to arbitrary values, thus disregarding configuration limits and causing client crashes on certain conditions (bugreport:4177). - Fixed HP/SP not getting adjusted to MaxHP/MaxSP respectively, when the max. value is reduced below the value of the cur. value. - Fixed STR/AGI/VIT/INT/DEX/LUK values could be set beyond character's max. stat limit. - Fixed Gender not being limited to male/female. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14774 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/pc.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) (limited to 'src/map') diff --git a/src/map/pc.c b/src/map/pc.c index 3006b2138..60498efa4 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -6001,7 +6001,7 @@ int pc_readparam(struct map_session_data* sd,int type) *------------------------------------------*/ int pc_setparam(struct map_session_data *sd,int type,int val) { - int i = 0; + int i = 0, statlimit; nullpo_ret(sd); @@ -6064,7 +6064,7 @@ int pc_setparam(struct map_session_data *sd,int type,int val) } break; case SP_SEX: - sd->status.sex = val; + sd->status.sex = val ? SEX_MALE : SEX_FEMALE; break; case SP_WEIGHT: sd->weight = val; @@ -6073,34 +6073,52 @@ int pc_setparam(struct map_session_data *sd,int type,int val) sd->max_weight = val; break; case SP_HP: - sd->battle_status.hp = val; + sd->battle_status.hp = cap_value(val, 1, (int)sd->battle_status.max_hp); break; case SP_MAXHP: - sd->battle_status.max_hp = val; + sd->battle_status.max_hp = cap_value(val, 1, battle_config.max_hp); + + if( sd->battle_status.max_hp < sd->battle_status.hp ) + { + sd->battle_status.hp = sd->battle_status.max_hp; + clif_updatestatus(sd, SP_HP); + } break; case SP_SP: - sd->battle_status.sp = val; + sd->battle_status.sp = cap_value(val, 0, (int)sd->battle_status.max_sp); break; case SP_MAXSP: - sd->battle_status.max_sp = val; + sd->battle_status.max_sp = cap_value(val, 1, battle_config.max_sp); + + if( sd->battle_status.max_sp < sd->battle_status.sp ) + { + sd->battle_status.sp = sd->battle_status.max_sp; + clif_updatestatus(sd, SP_SP); + } break; case SP_STR: - sd->status.str = val; + statlimit = pc_maxparameter(sd); + sd->status.str = cap_value(val, 1, statlimit); break; case SP_AGI: - sd->status.agi = val; + statlimit = pc_maxparameter(sd); + sd->status.agi = cap_value(val, 1, statlimit); break; case SP_VIT: - sd->status.vit = val; + statlimit = pc_maxparameter(sd); + sd->status.vit = cap_value(val, 1, statlimit); break; case SP_INT: - sd->status.int_ = val; + statlimit = pc_maxparameter(sd); + sd->status.int_ = cap_value(val, 1, statlimit); break; case SP_DEX: - sd->status.dex = val; + statlimit = pc_maxparameter(sd); + sd->status.dex = cap_value(val, 1, statlimit); break; case SP_LUK: - sd->status.luk = val; + statlimit = pc_maxparameter(sd); + sd->status.luk = cap_value(val, 1, statlimit); break; case SP_KARMA: sd->status.karma = val; -- cgit v1.2.3-70-g09d2