summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-06 13:49:29 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-04-06 13:49:29 +0000
commit54f28419528e592b2d7628ce596fd49205be94d3 (patch)
tree75aade9d9b39b5efb29d65dfe2348fc235664784 /src/map/atcommand.c
parent63a3353ffbc81b3a7c761cdd7a3283a144cd3f87 (diff)
downloadhercules-54f28419528e592b2d7628ce596fd49205be94d3.tar.gz
hercules-54f28419528e592b2d7628ce596fd49205be94d3.tar.bz2
hercules-54f28419528e592b2d7628ce596fd49205be94d3.tar.xz
hercules-54f28419528e592b2d7628ce596fd49205be94d3.zip
- Modified @allstats to prevent negative/overflow issues.
- Fixed HP/SP requirements for WE_MALE/WE_FEMALE - Fixed a typo in skill.h which fixes a compilation warning. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5925 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 9cd75df42..089c88c3c 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -4205,7 +4205,7 @@ int atcommand_stat_all(
const int fd, struct map_session_data* sd,
const char* command, const char* message)
{
- int index, count, value = 0, new_value;
+ int index, count, value = 0, max, new_value;
short* status[] = {
&sd->status.str, &sd->status.agi, &sd->status.vit,
&sd->status.int_, &sd->status.dex, &sd->status.luk
@@ -4216,14 +4216,16 @@ int atcommand_stat_all(
value = pc_maxparameter(sd);
count = 0;
+ max = pc_maxparameter(sd);
for (index = 0; index < (int)(sizeof(status) / sizeof(status[0])); index++) {
- new_value = (int)*status[index] + value;
- if (value > 0 && (value > pc_maxparameter(sd) || new_value > pc_maxparameter(sd))) // fix positiv overflow
- new_value = pc_maxparameter(sd);
- else if (value < 0 && (value < -(int)pc_maxparameter(sd) || new_value < 1)) // fix negative overflow
+ if (value > 0 && *status[index] > max - value)
+ new_value = max;
+ else if (value < 0 && *status[index] <= -value)
new_value = 1;
-
+ else
+ new_value = *status[index] +value;
+
if (new_value != (int)*status[index]) {
*status[index] = new_value;
clif_updatestatus(sd, SP_STR + index);