prevent stack overflow caused by MoveInLineOfSight calls
should close #995 issue --HG-- branch : trunk
This commit is contained in:
@@ -104,6 +104,17 @@ void CreatureAI::DoZoneInCombat(Creature* creature)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// scripts does not take care about MoveInLineOfSight loops
|
||||||
|
// MoveInLineOfSight can be called inside another MoveInLineOfSight and cause stack overflow
|
||||||
|
void CreatureAI::MoveInLineOfSight_Safe(Unit *who)
|
||||||
|
{
|
||||||
|
if(m_MoveInLineOfSight_locked == true)
|
||||||
|
return;
|
||||||
|
m_MoveInLineOfSight_locked = true;
|
||||||
|
MoveInLineOfSight(who);
|
||||||
|
m_MoveInLineOfSight_locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
void CreatureAI::MoveInLineOfSight(Unit *who)
|
void CreatureAI::MoveInLineOfSight(Unit *who)
|
||||||
{
|
{
|
||||||
if(me->getVictim())
|
if(me->getVictim())
|
||||||
|
|||||||
@@ -83,14 +83,14 @@ class CreatureAI : public UnitAI
|
|||||||
Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
Creature *DoSummonFlyer(uint32 uiEntry, WorldObject *obj, float fZ, float fRadius = 5.0f, uint32 uiDespawntime = 30000, TempSummonType uiType = TEMPSUMMON_CORPSE_TIMED_DESPAWN);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c) {}
|
explicit CreatureAI(Creature *c) : UnitAI((Unit*)c), me(c), m_creature(c), m_MoveInLineOfSight_locked(false) {}
|
||||||
|
|
||||||
virtual ~CreatureAI() {}
|
virtual ~CreatureAI() {}
|
||||||
|
|
||||||
///== Reactions At =================================
|
///== Reactions At =================================
|
||||||
|
|
||||||
// Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter
|
// Called if IsVisible(Unit *who) is true at each *who move, reaction at visibility zone enter
|
||||||
virtual void MoveInLineOfSight(Unit *);
|
void MoveInLineOfSight_Safe(Unit *who);
|
||||||
|
|
||||||
// Called for reaction at stopping attack at no attackers or targets
|
// Called for reaction at stopping attack at no attackers or targets
|
||||||
virtual void EnterEvadeMode();
|
virtual void EnterEvadeMode();
|
||||||
@@ -174,7 +174,12 @@ class CreatureAI : public UnitAI
|
|||||||
virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {}
|
virtual void PassengerBoarded(Unit *who, int8 seatId, bool apply) {}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
virtual void MoveInLineOfSight(Unit *);
|
||||||
|
|
||||||
bool _EnterEvadeMode();
|
bool _EnterEvadeMode();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_MoveInLineOfSight_locked;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Permitions
|
enum Permitions
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ inline void CreatureUnitRelocationWorker(Creature* c, Unit* u)
|
|||||||
|
|
||||||
if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_SIGHTLESS))
|
if(c->HasReactState(REACT_AGGRESSIVE) && !c->hasUnitState(UNIT_STAT_SIGHTLESS))
|
||||||
if(c->_IsWithinDist(u, c->m_SightDistance, true) && c->IsAIEnabled)
|
if(c->_IsWithinDist(u, c->m_SightDistance, true) && c->IsAIEnabled)
|
||||||
c->AI()->MoveInLineOfSight(u);
|
c->AI()->MoveInLineOfSight_Safe(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerRelocationNotifier::Visit(PlayerMapType &m)
|
void PlayerRelocationNotifier::Visit(PlayerMapType &m)
|
||||||
|
|||||||
Reference in New Issue
Block a user