summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Longbons <b.r.longbons@gmail.com>2014-08-28 16:13:33 -0700
committerBen Longbons <b.r.longbons@gmail.com>2014-08-28 16:16:03 -0700
commit1aa55242d929fd85ceaa462348e3ecb2636487bc (patch)
tree57b2a2f9c6e16aa7fd8fa3d9793267b06aea3e0d
parent7245589dcbc08c377f783a637deeaa09604c6213 (diff)
downloadtmwa-1aa55242d929fd85ceaa462348e3ecb2636487bc.tar.gz
tmwa-1aa55242d929fd85ceaa462348e3ecb2636487bc.tar.bz2
tmwa-1aa55242d929fd85ceaa462348e3ecb2636487bc.tar.xz
tmwa-1aa55242d929fd85ceaa462348e3ecb2636487bc.zip
Prevent skills from being set out of bounds by privileged users
-rw-r--r--src/map/atcommand.cpp2
-rw-r--r--src/map/script.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 342f6ef..0d70b36 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -4552,6 +4552,8 @@ ATCE atcommand_magic_info(Session *s, dumb_ptr<map_session_data>,
static
void set_skill(dumb_ptr<map_session_data> sd, SkillID i, int level)
{
+ level = std::min(level, MAX_SKILL_LEVEL);
+ level = std::max(level, 0);
sd->status.skill[i].lv = level;
}
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 4aeb7d9..40dfc0e 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -2414,6 +2414,8 @@ void builtin_setskill(ScriptState *st)
level = conv_num(st, &AARGO2(3));
sd = script_rid2sd(st);
+ level = std::min(level, MAX_SKILL_LEVEL);
+ level = std::max(level, 0);
sd->status.skill[id].lv = level;
clif_skillinfoblock(sd);
}