summaryrefslogtreecommitdiff
path: root/src/map/mercenary.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-11-05 21:13:14 +0100
committerHaru <haru@dotalux.com>2017-11-05 21:13:14 +0100
commit3edcd549cee863ecc8a2a96dfb5bbb56d435d97a (patch)
treec08ceaa38363344110bb0d2b7b4e556e3a88c436 /src/map/mercenary.c
parent09d5c20572424e7a92dff5cf560001278c6ffaa0 (diff)
downloadhercules-3edcd549cee863ecc8a2a96dfb5bbb56d435d97a.tar.gz
hercules-3edcd549cee863ecc8a2a96dfb5bbb56d435d97a.tar.bz2
hercules-3edcd549cee863ecc8a2a96dfb5bbb56d435d97a.tar.xz
hercules-3edcd549cee863ecc8a2a96dfb5bbb56d435d97a.zip
Fix/clarify various incorrect modulo operations
Most relevantly, `skill_lv%11 - 1` is not a valid skill item requirement index, since it can return -1 depending on the skill_lv. It was replaced with `(skill_lv - 1) % MAX_SKILL_ITEM_REQUIRE`, which always returns a value in the 0 ~ MAX_SKILL_ITEM_REQUIRE range. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/mercenary.c')
-rw-r--r--src/map/mercenary.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/map/mercenary.c b/src/map/mercenary.c
index f5d3fe11c..c4b692008 100644
--- a/src/map/mercenary.c
+++ b/src/map/mercenary.c
@@ -465,7 +465,7 @@ bool read_mercenarydb_sub(char* str[], int columns, int current) {
mstatus->race = atoi(str[20]);
ele = atoi(str[21]);
- mstatus->def_ele = ele%10;
+ mstatus->def_ele = ele % ELE_MAX;
mstatus->ele_lv = ele/20;
if( mstatus->def_ele >= ELE_MAX ) {
ShowWarning("Mercenary %d has invalid element type %d (max element is %d)\n", db->class_, mstatus->def_ele, ELE_MAX - 1);