From 47196c67f11376035671d0758fb6c52d80968c48 Mon Sep 17 00:00:00 2001 From: Haru Date: Sun, 29 Oct 2017 23:57:01 +0100 Subject: 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 --- src/map/skill.c | 15 ++++++++------- 1 file 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 -- cgit v1.2.3-70-g09d2