summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-10-29 23:57:01 +0100
committerHaru <haru@dotalux.com>2017-11-05 18:16:27 +0100
commit47196c67f11376035671d0758fb6c52d80968c48 (patch)
tree6b46ce4b88cf2d1aa1bdf046a4058ee75df8d5c1
parentb236779fd1686d5f486eee3525d3368ac8680661 (diff)
downloadhercules-47196c67f11376035671d0758fb6c52d80968c48.tar.gz
hercules-47196c67f11376035671d0758fb6c52d80968c48.tar.bz2
hercules-47196c67f11376035671d0758fb6c52d80968c48.tar.xz
hercules-47196c67f11376035671d0758fb6c52d80968c48.zip
Fix a subtle error in case skill->unit_group_newid overflows
The incorrect handling of the overflowed values would cause certain skill unit entries to get stuck and never get deleted correctly. A possible symptom of the issue are monsters that become immune to certain AoE spells having the UF_NOOVERLAP flag (Storm Gust, Lord of Vermillion, etc). Signed-off-by: Haru <haru@dotalux.com>
-rw-r--r--src/map/skill.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/map/skill.c b/src/map/skill.c
index 726deaa9a..13e8925ed 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -16618,15 +16618,16 @@ struct skill_unit_group* skill_id2group(int group_id)
/// Fatal error if nothing is available.
int skill_get_new_group_id(void)
{
- if( skill->unit_group_newid >= MAX_SKILL_DB && skill->id2group(skill->unit_group_newid) == NULL )
+ if (skill->unit_group_newid > MAX_SKILL_ID && skill->id2group(skill->unit_group_newid) == NULL)
return skill->unit_group_newid++;// available
- {// find next id
+
+ {
+ // find next id
int base_id = skill->unit_group_newid;
- while( base_id != ++skill->unit_group_newid )
- {
- if( skill->unit_group_newid < MAX_SKILL_DB )
- skill->unit_group_newid = MAX_SKILL_DB;
- if( skill->id2group(skill->unit_group_newid) == NULL )
+ while (base_id != ++skill->unit_group_newid) {
+ if (skill->unit_group_newid <= MAX_SKILL_ID)
+ skill->unit_group_newid = MAX_SKILL_ID + 1;
+ if (skill->id2group(skill->unit_group_newid) == NULL)
return skill->unit_group_newid++;// available
}
// full loop, nothing available