summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-02 15:11:17 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-08-02 15:11:17 +0000
commitefb193b6cec5e5dd4f4790efcf00b28b437a34df (patch)
treeb0b445d52c54603a79e0f8cff742c73b2bcfd29d /src
parent64eec61f11b45b6458fd08552f98b0326d32c10f (diff)
downloadhercules-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
Diffstat (limited to 'src')
-rw-r--r--src/map/battle.c29
1 files changed, 7 insertions, 22 deletions
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;
}