summaryrefslogtreecommitdiff
path: root/src/map/elemental.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/elemental.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/elemental.c')
-rw-r--r--src/map/elemental.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/map/elemental.c b/src/map/elemental.c
index ae1fda0a2..cf1d485e1 100644
--- a/src/map/elemental.c
+++ b/src/map/elemental.c
@@ -885,7 +885,7 @@ int read_elementaldb(void) {
estatus->race = atoi(str[20]);
ele = atoi(str[21]);
- estatus->def_ele = ele%10;
+ estatus->def_ele = ele % ELE_MAX;
estatus->ele_lv = ele/20;
if( estatus->def_ele >= ELE_MAX ) {
ShowWarning("Elemental %d has invalid element type %d (max element is %d)\n", db->class_, estatus->def_ele, ELE_MAX - 1);