Core/Auras

* Fixed unsafe removal of charm auras, it is now safe to remove them inside AI hooks
* Fixes crash in SmartAI::EnterEvadeMode

Closes #8679
This commit is contained in:
Shauren committed 2013-08-20 00:43:03 +02:00
1 parent 8ae88954aa
commit 75cc4e7b25
4 files changed
+13 -11

No files matched your search

@@ -522,12 +522,17 @@ void Creature::Update(uint32 diff)
if (!IsAlive())
break;
// if creature is charmed, switch to charmed AI
// if creature is charmed, switch to charmed AI (and back)
if (NeedChangeAI)
{
UpdateCharmAI();
NeedChangeAI = false;
IsAIEnabled = true;
if (!IsInEvadeMode() && LastCharmerGUID)
if (Unit* charmer = ObjectAccessor::GetUnit(*this, LastCharmerGUID))
i_AI->AttackStart(charmer);
LastCharmerGUID = 0;
}
if (!IsInEvadeMode() && IsAIEnabled)
+5 -8
View File
@@ -162,7 +162,7 @@ ProcEventInfo::ProcEventInfo(Unit* actor, Unit* actionTarget, Unit* procTarget,
#endif
Unit::Unit(bool isWorldObject) :
WorldObject(isWorldObject), m_movedPlayer(NULL), m_lastSanctuaryTime(0),
IsAIEnabled(false), NeedChangeAI(false),
IsAIEnabled(false), NeedChangeAI(false), LastCharmerGUID(0),
m_ControlledByPlayer(false), movespline(new Movement::MoveSpline()),
i_AI(NULL), i_disabledAI(NULL), m_AutoRepeatFirstCast(false), m_procDeep(0),
m_removedAurasCount(0), i_motionMaster(this), m_ThreatManager(this),
@@ -15836,16 +15836,13 @@ void Unit::RemoveCharmedBy(Unit* charmer)
if (Creature* creature = ToCreature())
{
// Creature will restore its old AI on next update
if (creature->AI())
creature->AI()->OnCharmed(false);
if (type != CHARM_TYPE_VEHICLE) // Vehicles' AI is never modified
{
creature->AIM_Initialize();
if (creature->AI() && charmer && charmer->IsAlive())
creature->AI()->AttackStart(charmer);
}
// Vehicle should not attack its passenger after he exists the seat
if (type != CHARM_TYPE_VEHICLE)
LastCharmerGUID = charmer->GetGUID();
}
else
ToPlayer()->SetClientControl(this, 1);
+1
View File
@@ -2074,6 +2074,7 @@ class Unit : public WorldObject
friend class VehicleJoinEvent;
bool IsAIEnabled, NeedChangeAI;
uint64 LastCharmerGUID;
bool CreateVehicleKit(uint32 id, uint32 creatureEntry);
void RemoveVehicleKit();
Vehicle* GetVehicleKit()const { return m_vehicleKit; }
+1 -2
View File
@@ -217,8 +217,7 @@ void ObjectGridStoper::Visit(CreatureMapType &m)
{
iter->GetSource()->CombatStop();
iter->GetSource()->DeleteThreatList();
if (iter->GetSource()->IsAIEnabled)
iter->GetSource()->AI()->EnterEvadeMode();
iter->GetSource()->AI()->EnterEvadeMode();
}
}
}