diff options
author | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-08-02 15:11:17 +0000 |
---|---|---|
committer | skotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2006-08-02 15:11:17 +0000 |
commit | efb193b6cec5e5dd4f4790efcf00b28b437a34df (patch) | |
tree | b0b445d52c54603a79e0f8cff742c73b2bcfd29d | |
parent | 64eec61f11b45b6458fd08552f98b0326d32c10f (diff) | |
download | hercules-efb193b6cec5e5dd4f4790efcf00b28b437a34df.tar.gz hercules-efb193b6cec5e5dd4f4790efcf00b28b437a34df.tar.bz2 hercules-efb193b6cec5e5dd4f4790efcf00b28b437a34df.tar.xz hercules-efb193b6cec5e5dd4f4790efcf00b28b437a34df.zip |
- Made recursive master check the default (otherwise it messes skill -> pet -> player kind of herarchies) and cleaned up some the battle_get_master code to prevent infinite loops in the weird case someone specifies that their master is itself.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@8055 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r-- | Changelog-Trunk.txt | 4 | ||||
-rw-r--r-- | src/map/battle.c | 29 |
2 files changed, 11 insertions, 22 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 20d020f79..a934c255c 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2006/08/02
+ * Made recursive master check the default (otherwise it messes skill -> pet
+ -> player kind of herarchies) and cleaned up some the battle_get_master
+ code to prevent infinite loops in the weird case someone specifies that
+ their master is itself. [Skotlex]
* Recoded the GuildAura code to use val3 & val4, allowing much greater stat
bonuses (in case someone wants to get Guild Skill level 20 or something
crazy like that) [Skotlex]
diff --git a/src/map/battle.c b/src/map/battle.c index cffec76cb..6c0f57651 100644 --- a/src/map/battle.c +++ b/src/map/battle.c @@ -25,9 +25,6 @@ #include "guild.h" #include "party.h" -// Recursive master check to prevent custom AIs from messing with each other. -// #define RECURSIVE_MASTER_CHECK - #define is_boss(bl) status_get_mexp(bl) // Can refine later [Aru] int attr_fix_table[4][ELE_MAX][ELE_MAX]; @@ -3073,40 +3070,28 @@ int battle_check_undead(int race,int element) //Returns the upmost level master starting with the given object static struct block_list* battle_get_master(struct block_list *src) { + struct block_list *mst; //Used for infinite loop check (master of yourself?) do { + mst = src; switch (src->type) { case BL_PET: if (((TBL_PET*)src)->msd) - src = (struct block_list*)((TBL_PET*)src)->msd; - else - return src; + mst = (struct block_list*)((TBL_PET*)src)->msd; break; case BL_MOB: if (((TBL_MOB*)src)->master_id) - src = map_id2bl(((TBL_MOB*)src)->master_id); - else - return src; + mst = map_id2bl(((TBL_MOB*)src)->master_id); break; case BL_HOMUNCULUS: if (((TBL_HOMUNCULUS*)src)->master) - src = (struct block_list*)((TBL_HOMUNCULUS*)src)->master; - else - return src; + mst = (struct block_list*)((TBL_HOMUNCULUS*)src)->master; break; case BL_SKILL: if (((TBL_SKILL*)src)->group && ((TBL_SKILL*)src)->group->src_id) - src = map_id2bl(((TBL_SKILL*)src)->group->src_id); - else - return src; + mst = map_id2bl(((TBL_SKILL*)src)->group->src_id); break; - default: - return src; } -#ifdef RECURSIVE_MASTER_CHECK - } while (src); -#else - } while (0); //Single pass check. -#endif + } while (mst && src != mst); return src; } |