[7667] Add to CreatureAI field pointing to creature itself. Use it instead diff. fields in subclases. Author: VladimirMangos

Also send pointer to AI constructors ans mark constructors as explicit.

    This changes allow move now some generic often used AI code to CreatureAI helper functions.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-14 19:54:49 -05:00
parent 4f4c6aeaf5
commit 3a65800218
15 changed files with 289 additions and 294 deletions
+4 -3
View File
@@ -75,7 +75,7 @@ class TRINITY_DLL_SPEC UnitAI
protected:
Unit *me;
public:
UnitAI(Unit *u) : me(u) {}
explicit UnitAI(Unit *u) : me(u) {}
virtual void AttackStart(Unit *);
virtual void UpdateAI(const uint32 diff) = 0;
@@ -97,7 +97,7 @@ class TRINITY_DLL_SPEC PlayerAI : public UnitAI
protected:
Player *me;
public:
PlayerAI(Player *p) : UnitAI((Unit*)p), me(p) {}
explicit PlayerAI(Player *p) : UnitAI((Unit*)p), me(p) {}
void OnCharmed(bool apply);
};
@@ -112,10 +112,11 @@ class TRINITY_DLL_SPEC CreatureAI : public UnitAI
{
protected:
Creature *me;
Creature *m_creature;
bool UpdateVictim();
public:
CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c) {}
explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c) {}
virtual ~CreatureAI() {}