Переглянути джерело

* 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://svn.code.sf.net/p/rathena/svn/trunk@14774 54d463be-8e91-2dee-dedb-b68131a5f0ec

ai4rei 14 роки тому
батько
коміт
f49808fa5d
2 змінених файлів з 35 додано та 12 видалено
  1. 5 0
      Changelog-Trunk.txt
  2. 30 12
      src/map/pc.c

+ 5 - 0
Changelog-Trunk.txt

@@ -1,6 +1,11 @@
 Date	Added
 
 2011/04/06
+	* Resolved some pc_setparam issues. [Ai4rei]
+	- 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.
 	* Fixed script command 'warpwaitingpc' not checking, whether or not the player still has required amount of Zeny (since r14765). [Ai4rei]
 	- Fixed warping through 'warpwaitingpc' to savepoint would take the fee twice ( missing {} ).
 	- Fixed random warping through 'warpwaitingpc' would not take away fee Zeny at all.

+ 30 - 12
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;