summaryrefslogtreecommitdiff
path: root/src/map/skill.c
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-10-11 06:57:14 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-10-11 06:57:14 +0000
commitc0aedc4c41ebc4959344a283ac7ea4a2296fb204 (patch)
tree9dc1b6e1d647e029b2256dd5d76f5d601d9dace4 /src/map/skill.c
parent7f83ceb98c6b1e0f4c949eaf9e03715b68ab58ca (diff)
downloadhercules-c0aedc4c41ebc4959344a283ac7ea4a2296fb204.tar.gz
hercules-c0aedc4c41ebc4959344a283ac7ea4a2296fb204.tar.bz2
hercules-c0aedc4c41ebc4959344a283ac7ea4a2296fb204.tar.xz
hercules-c0aedc4c41ebc4959344a283ac7ea4a2296fb204.zip
Added safeguards to Redemptio's exp penalty code to prevent arithmetic overflow in case its requirement checks are somehow bypassed (see topic:152196).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@13277 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/skill.c')
-rw-r--r--src/map/skill.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 25988faee..86ec51f33 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -3054,8 +3054,8 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, in
}
skill_area_temp[0] = 5 - skill_area_temp[0]; // The actual penalty...
if (skill_area_temp[0] > 0 && !map[src->m].flag.noexppenalty) { //Apply penalty
- sd->status.base_exp -= pc_nextbaseexp(sd) * skill_area_temp[0] * 2/1000; //0.2% penalty per each.
- sd->status.job_exp -= pc_nextjobexp(sd) * skill_area_temp[0] * 2/1000;
+ sd->status.base_exp -= min(sd->status.base_exp, pc_nextbaseexp(sd) * skill_area_temp[0] * 2/1000); //0.2% penalty per each.
+ sd->status.job_exp -= min(sd->status.job_exp, pc_nextjobexp(sd) * skill_area_temp[0] * 2/1000);
clif_updatestatus(sd,SP_BASEEXP);
clif_updatestatus(sd,SP_JOBEXP);
}
@@ -8152,8 +8152,8 @@ int skill_check_condition(struct map_session_data* sd, short skill, short lv, in
case PR_REDEMPTIO:
{
int exp;
- if(((exp = pc_nextbaseexp(sd)) > 0 && sd->status.base_exp*100/exp < 1) ||
- ((exp = pc_nextjobexp(sd)) > 0 && sd->status.job_exp*100/exp < 1)) {
+ if( ((exp = pc_nextbaseexp(sd)) > 0 && get_percentage(sd->status.base_exp, exp) < 1) ||
+ ((exp = pc_nextjobexp(sd)) > 0 && get_percentage(sd->status.job_exp, exp) < 1)) {
clif_skill_fail(sd,skill,0,0); //Not enough exp.
return 0;
}