diff options
author | Haru <haru@dotalux.com> | 2020-04-20 21:15:26 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2020-05-03 23:47:31 +0200 |
commit | 595dae284856bcf442274b39b63cce8746687c13 (patch) | |
tree | 937aecaebfbba7f52496d663218fb3aef301d42e /src/map/skill.c | |
parent | f63790d389277a8277d2663469da8fc8892db509 (diff) | |
download | hercules-595dae284856bcf442274b39b63cce8746687c13.tar.gz hercules-595dae284856bcf442274b39b63cce8746687c13.tar.bz2 hercules-595dae284856bcf442274b39b63cce8746687c13.tar.xz hercules-595dae284856bcf442274b39b63cce8746687c13.zip |
Improve warnings in skill_get_index, to detect the use of unhandled skill ranges
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/skill.c')
-rw-r--r-- | src/map/skill.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/map/skill.c b/src/map/skill.c index 7f66fabe3..0fcd5fd0c 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -133,17 +133,23 @@ static int skill_get_index(int skill_id) } int skill_idx = 0; + bool found = false; // Map Skill ID to Skill Indexes (in reverse order) for (int i = 0; i < length; i++) { // Check if SkillID belongs to this range. if (skill_id <= skill_idx_ranges[i].end && skill_id >= skill_idx_ranges[i].start) { skill_idx += (skill_idx_ranges[i].end - skill_id); + found = true; break; } // Add the difference of current range skill_idx += (skill_idx_ranges[i].end - skill_idx_ranges[i].start + 1); } + if (!found) { + ShowWarning("skill_get_index: skill id '%d' (idx: %d) is not handled as it lies outside the defined ranges!\n", skill_id, skill_idx); + return 0; + } if (skill_idx >= MAX_SKILL_DB) { ShowWarning("skill_get_index: skill id '%d'(idx: %d) is not being handled as it exceeds MAX_SKILL_DB!\n", skill_id, skill_idx); return 0; |