Is it the good way ?
With this, I can compile...
OutdoorPvPObjectiveAI.cpp
@ -23,43 +23,48 @@
#include "OutdoorPvPMgr.h"
#include "World.h"
#define MAX_OUTDOOR_PVP_DISTANCE 200 // the max value in capture point type go data0 is 100 currently, so use twice that much to handle leaving as well
-OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature &c) : i_creature(c)
+OutdoorPvPObjectiveAI::OutdoorPvPObjectiveAI(Creature *c) : CreatureAI(c)
{
- sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", c.GetGUIDLow());
+ sLog.outDebug("OutdoorPvP objective AI assigned to creature guid %u", c->GetGUIDLow());
}
void OutdoorPvPObjectiveAI::MoveInLineOfSight(Unit *u)
{
// IsVisible only passes for players in range, so no need to check again
// leaving/entering distance will be checked based on go range data
- sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),&i_creature);
+ sOutdoorPvPMgr.HandleCaptureCreaturePlayerMoveInLos(((Player*)u),m_creature);
}
int OutdoorPvPObjectiveAI::Permissible(const Creature * c)
{
// this AI can only be assigned if the AIName is OutdoorPvPObjectiveAI. It shouldn't be returned by permissible check.
return PERMIT_BASE_NO;
}
bool OutdoorPvPObjectiveAI::IsVisible(Unit *pl) const
{
- return (pl->GetTypeId() == TYPEID_PLAYER) && (i_creature.GetDistance(pl) < MAX_OUTDOOR_PVP_DISTANCE * MAX_OUTDOOR_PVP_DISTANCE);
+ return (pl->GetTypeId() == TYPEID_PLAYER) && (m_creature->GetDistance(pl) < MAX_OUTDOOR_PVP_DISTANCE * MAX_OUTDOOR_PVP_DISTANCE);
}
void OutdoorPvPObjectiveAI::AttackStart(Unit *)
{
EnterEvadeMode();
}
void OutdoorPvPObjectiveAI::EnterEvadeMode()
{
- i_creature.DeleteThreatList();
- i_creature.CombatStop();
+ m_creature->DeleteThreatList();
+ m_creature->CombatStop();
}
void OutdoorPvPObjectiveAI::UpdateAI(const uint32 diff)
{
}
+Creature& OutdoorPvPObjectiveAI::getCreature()
+{
+ return static_cast<Creature&>(*m_creature);
+}
OutdoorPvPObjectiveAI.h
@@ -25,19 +25,19 @@ class Creature;
class MANGOS_DLL_DECL OutdoorPvPObjectiveAI : public CreatureAI
{
public:
- OutdoorPvPObjectiveAI(Creature &c);
+ explicit OutdoorPvPObjectiveAI(Creature *c);
void MoveInLineOfSight(Unit *);
bool IsVisible(Unit *) const;
void AttackStart(Unit *);
void EnterEvadeMode();
void UpdateAI(const uint32 diff);
static int Permissible(const Creature *);
- private:
- Creature &i_creature;
+ protected:
+ Creature& getCreature();
};
#endif