summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/char/char.c10
-rw-r--r--src/common/mmo.h2
-rw-r--r--src/map/atcommand.c48
-rw-r--r--src/map/pc.c13
4 files changed, 25 insertions, 48 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 8dc2661db..9275678e6 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -476,7 +476,7 @@ int char_mmo_char_tosql(int char_id, struct mmo_charstatus* p)
if( SQL_ERROR == SQL->Query(inter->sql_handle, "UPDATE `%s` SET `base_level`='%d', `job_level`='%d',"
"`base_exp`='%u', `job_exp`='%u', `zeny`='%d',"
- "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%u',`skill_point`='%u',"
+ "`max_hp`='%d',`hp`='%d',`max_sp`='%d',`sp`='%d',`status_point`='%d',`skill_point`='%d',"
"`str`='%d',`agi`='%d',`vit`='%d',`int`='%d',`dex`='%d',`luk`='%d',"
"`option`='%u',`party_id`='%d',`guild_id`='%d',`pet_id`='%d',`homun_id`='%d',`elemental_id`='%d',"
"`weapon`='%d',`shield`='%d',`head_top`='%d',`head_mid`='%d',`head_bottom`='%d',"
@@ -973,8 +973,8 @@ int char_mmo_chars_fromsql(struct char_session_data* sd, uint8* buf)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 16, SQLDT_INT, &p.hp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p.max_sp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p.sp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_UINT, &p.status_point, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p.skill_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p.status_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_INT, &p.skill_point, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p.option, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UCHAR, &p.karma, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_SHORT, &p.manner, 0, NULL, NULL)
@@ -1083,8 +1083,8 @@ int char_mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_every
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 17, SQLDT_INT, &p->hp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 18, SQLDT_INT, &p->max_sp, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 19, SQLDT_INT, &p->sp, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_UINT, &p->status_point, 0, NULL, NULL)
- || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_UINT, &p->skill_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 20, SQLDT_INT, &p->status_point, 0, NULL, NULL)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 21, SQLDT_INT, &p->skill_point, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 22, SQLDT_UINT, &p->option, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 23, SQLDT_UCHAR, &p->karma, 0, NULL, NULL)
|| SQL_ERROR == SQL->StmtBindColumn(stmt, 24, SQLDT_SHORT, &p->manner, 0, NULL, NULL)
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 7e01d6960..0a5d9d053 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -570,7 +570,7 @@ struct mmo_charstatus {
int bank_vault;
short class_;
- unsigned int status_point,skill_point;
+ int status_point, skill_point;
int hp,max_hp,sp,max_sp;
unsigned int option;
short manner; // Defines how many minutes a char will be muted, each negative point is equivalent to a minute.
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 969f564ba..66ccbe3b0 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -2296,30 +2296,18 @@ ACMD(displaystatus)
ACMD(statuspoint)
{
int point;
- unsigned int new_status_point;
+ int new_status_point;
if (!*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1010)); // Please enter a number (usage: @stpoint <number of points>).
return false;
}
- if(point < 0)
- {
- if(sd->status.status_point < (unsigned int)(-point))
- {
- new_status_point = 0;
- }
- else
- {
- new_status_point = sd->status.status_point + point;
- }
- }
- else if(UINT_MAX - sd->status.status_point < (unsigned int)point)
- {
- new_status_point = UINT_MAX;
- }
- else
- {
+ if (point < 0 && sd->status.status_point + point < 0) {
+ new_status_point = 0;
+ } else if (point > 0 && (int64)sd->status.status_point + point > INT_MAX) {
+ new_status_point = INT_MAX;
+ } else {
new_status_point = sd->status.status_point + point;
}
@@ -2344,30 +2332,18 @@ ACMD(statuspoint)
ACMD(skillpoint)
{
int point;
- unsigned int new_skill_point;
+ int new_skill_point;
if (!*message || (point = atoi(message)) == 0) {
clif->message(fd, msg_fd(fd,1011)); // Please enter a number (usage: @skpoint <number of points>).
return false;
}
- if(point < 0)
- {
- if(sd->status.skill_point < (unsigned int)(-point))
- {
- new_skill_point = 0;
- }
- else
- {
- new_skill_point = sd->status.skill_point + point;
- }
- }
- else if(UINT_MAX - sd->status.skill_point < (unsigned int)point)
- {
- new_skill_point = UINT_MAX;
- }
- else
- {
+ if (point < 0 && sd->status.skill_point + point < 0) {
+ new_skill_point = 0;
+ } else if (point > 0 && (int64)sd->status.skill_point + point > INT_MAX) {
+ new_skill_point = INT_MAX;
+ } else {
new_skill_point = sd->status.skill_point + point;
}
diff --git a/src/map/pc.c b/src/map/pc.c
index 29eb5e45e..fd4101868 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1762,13 +1762,13 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
if (sd->change_level_3rd == 0) {
sd->change_level_2nd = pc->max_level[pc->class2idx(pc->mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1];
} else {
- sd->change_level_2nd = 1 + skill_point + (int)sd->status.skill_point // FIXME
+ sd->change_level_2nd = 1 + skill_point + sd->status.skill_point
- (sd->status.job_level - 1)
- (sd->change_level_3rd - 1)
- novice_skills;
}
} else {
- sd->change_level_2nd = 1 + skill_point + (int)sd->status.skill_point // FIXME
+ sd->change_level_2nd = 1 + skill_point + sd->status.skill_point
- (sd->status.job_level - 1)
- novice_skills;
@@ -1783,7 +1783,7 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
} else if(sd->class_&JOBL_THIRD) { // limit 3rd class to 2nd class/trans job levels
// regenerate change_level_3rd
if (sd->change_level_3rd == 0) {
- sd->change_level_3rd = 1 + skill_point + (int)sd->status.skill_point // FIXME
+ sd->change_level_3rd = 1 + skill_point + sd->status.skill_point
- (sd->status.job_level - 1)
- (sd->change_level_2nd - 1)
- novice_skills;
@@ -6570,14 +6570,15 @@ int pc_checkbaselevelup(struct map_session_data *sd) {
return 0;
do {
+ int status_points = 0;
sd->status.base_exp -= next;
//Kyoki pointed out that the max overcarry exp is the exp needed for the previous level -1. [Skotlex]
if(!battle_config.multi_level_up && sd->status.base_exp > next-1)
sd->status.base_exp = next-1;
- next = pc->gets_status_point(sd->status.base_level);
+ status_points = pc->gets_status_point(sd->status.base_level);
sd->status.base_level++;
- sd->status.status_point += next;
+ sd->status.status_point += status_points;
} while ((next=pc->nextbaseexp(sd)) > 0 && sd->status.base_exp >= next);
@@ -6639,7 +6640,7 @@ int pc_checkjoblevelup(struct map_session_data *sd)
sd->status.job_exp = next-1;
sd->status.job_level++;
- sd->status.skill_point ++;
+ sd->status.skill_point++;
} while ((next=pc->nextjobexp(sd)) > 0 && sd->status.job_exp >= next);