aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/BattleGround.cpp1
-rw-r--r--src/game/Debugcmds.cpp1
-rw-r--r--src/game/GameEventMgr.cpp3
-rw-r--r--src/game/Level2.cpp5
-rw-r--r--src/game/Object.cpp1
-rw-r--r--src/game/ObjectMgr.cpp2
-rw-r--r--src/game/PoolHandler.cpp1
-rw-r--r--src/game/SpellAuras.h2
-rw-r--r--src/game/SpellMgr.cpp2
-rw-r--r--src/game/Unit.cpp11
-rw-r--r--src/game/Unit.h2
11 files changed, 26 insertions, 5 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index aebe9bd28b1..426f5de6655 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -1590,6 +1590,7 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
Creature* pCreature = new Creature;
if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, PHASEMASK_NORMAL, entry, 0, teamval, x, y, z, o))
{
+ pCreature->CleanupsBeforeDelete();
sLog.outError("Can't create creature entry: %u",entry);
delete pCreature;
return NULL;
diff --git a/src/game/Debugcmds.cpp b/src/game/Debugcmds.cpp
index ff720872f6b..372afa95d62 100644
--- a/src/game/Debugcmds.cpp
+++ b/src/game/Debugcmds.cpp
@@ -794,6 +794,7 @@ bool ChatHandler::HandleDebugSpawnVehicle(const char* args)
if(!v->Create(objmgr.GenerateLowGuid(HIGHGUID_VEHICLE), map, m_session->GetPlayer()->GetPhaseMask(), entry, id, m_session->GetPlayer()->GetTeam(), x, y, z, o))
{
+ v->CleanupsBeforeDelete();
delete v;
return false;
}
diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp
index a884db5dc0f..ed742c9368b 100644
--- a/src/game/GameEventMgr.cpp
+++ b/src/game/GameEventMgr.cpp
@@ -1283,7 +1283,10 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
Creature* pCreature = new Creature;
//sLog.outDebug("Spawning creature %u",*itr);
if (!pCreature->LoadFromDB(*itr, map))
+ {
+ pCreature->CleanupsBeforeDelete();
delete pCreature;
+ }
else
map->Add(pCreature);
}
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index 401d1a75c39..b15497e3d3b 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -1014,6 +1014,7 @@ bool ChatHandler::HandleNpcAddCommand(const char* args)
Creature* pCreature = new Creature;
if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, (uint32)teamval, x, y, z, o))
{
+ pCreature->CleanupsBeforeDelete();
delete pCreature;
return false;
}
@@ -2830,6 +2831,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args)
Creature* wpCreature2 = new Creature;
if (!wpCreature2->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), VISUAL_WAYPOINT, 0, 0, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), chr->GetOrientation()))
{
+ wpCreature2->CleanupsBeforeDelete();
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, VISUAL_WAYPOINT);
delete wpCreature2;
return false;
@@ -3039,6 +3041,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
Creature* wpCreature = new Creature;
if (!wpCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
{
+ wpCreature->CleanupsBeforeDelete();
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete wpCreature;
delete result;
@@ -3094,6 +3097,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
Creature* pCreature = new Creature;
if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT),map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
{
+ pCreature->CleanupsBeforeDelete();
PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
delete pCreature;
delete result;
@@ -3149,6 +3153,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args)
Creature* pCreature = new Creature;
if (!pCreature->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), map, chr->GetPhaseMaskForSpawn(), id, 0, 0, x, y, z, o))
{
+ pCreature->CleanupsBeforeDelete();
PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);
delete pCreature;
delete result;
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index eeb96db5798..28c50a9e38e 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1759,6 +1759,7 @@ TempSummon *Map::SummonCreature(uint32 entry, const Position &pos, SummonPropert
if(!summon->Create(objmgr.GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, team, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
{
+ summon->CleanupsBeforeDelete();
delete summon;
return NULL;
}
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 7c2c2e6a658..b1da7a6ae94 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -1470,6 +1470,7 @@ bool ObjectMgr::MoveCreData(uint32 guid, uint32 mapId, Position pos)
Creature *creature = new Creature;
if(!creature->LoadFromDB(guid, map))
{
+ creature->CleanupsBeforeDelete();
sLog.outError("AddCreature: cannot add creature entry %u to map", guid);
delete creature;
return false;
@@ -1521,6 +1522,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 team, uint32 mapId, float x, f
Creature* creature = new Creature;
if(!creature->LoadFromDB(guid, map))
{
+ creature->CleanupsBeforeDelete();
sLog.outError("AddCreature: cannot add creature entry %u to map", entry);
delete creature;
return 0;
diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp
index c2cb8045b81..1774907bcd0 100644
--- a/src/game/PoolHandler.cpp
+++ b/src/game/PoolHandler.cpp
@@ -255,6 +255,7 @@ bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
//sLog.outDebug("Spawning creature %u",guid);
if (!pCreature->LoadFromDB(guid, map))
{
+ pCreature->CleanupsBeforeDelete();
delete pCreature;
return false;
}
diff --git a/src/game/SpellAuras.h b/src/game/SpellAuras.h
index dc29a2d79a5..1d0900c437e 100644
--- a/src/game/SpellAuras.h
+++ b/src/game/SpellAuras.h
@@ -46,7 +46,7 @@ class AuraApplication
AuraRemoveMode m_removeMode:8; // Store info for know remove aura reason
bool m_needClientUpdate:1;
bool m_isNeedManyNegativeEffects:1;
- bool m_canBeRemoved:1; // used only in aura list update of AuraBase
+ bool m_canBeRemoved:1; // used only in aura list update of Aura
explicit AuraApplication(Unit * target, Unit * caster, Aura * base);
void _Remove();
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 08d6e971f55..d0255983de7 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -899,7 +899,7 @@ bool SpellMgr::_isPositiveEffect(uint32 spellId, uint32 effIndex, bool deep) con
// part of positive spell if casted at self
if(spellproto->EffectImplicitTargetA[effIndex] != TARGET_UNIT_CASTER)
return false;
- // but not this if this first effect (don't found batter check)
+ // but not this if this first effect (didn't find batter check)
if(spellproto->Attributes & 0x4000000 && effIndex==0)
return false;
break;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 04102254a65..e52faf0e875 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -182,6 +182,8 @@ Unit::Unit()
// remove aurastates allowing special moves
for (uint8 i = 0; i < MAX_REACTIVE; ++i)
m_reactiveTimer[i] = 0;
+
+ m_cleanupDone = false;
}
Unit::~Unit()
@@ -205,6 +207,7 @@ Unit::~Unit()
if (m_vehicleKit)
delete m_vehicleKit;
+ assert(m_cleanupDone);
assert(!m_attacking);
assert(m_attackers.empty());
assert(m_sharedVision.empty());
@@ -3234,8 +3237,7 @@ void Unit::_UpdateSpells( uint32 time )
}
}
- // update auraBases
- // m_auraBaseUpdateIterator can be updated in indirect called code at aura remove to skip next planned to update but removed auras
+ // m_auraUpdateIterator can be updated in indirect called code at aura remove to skip next planned to update but removed auras
for (m_auraUpdateIterator = m_ownedAuras.begin(); m_auraUpdateIterator != m_ownedAuras.end();)
{
Aura * i_aura = m_auraUpdateIterator->second;
@@ -3529,6 +3531,7 @@ void Unit::DeMorph()
void Unit::_AddAura(UnitAura * aura, Unit * caster)
{
+ assert(!m_cleanupDone);
m_ownedAuras.insert(AuraMap::value_type(aura->GetId(), aura));
// passive and Incanter's Absorption and auras with different type can stack with themselves any number of times
@@ -3579,7 +3582,8 @@ void Unit::_AddAura(UnitAura * aura, Unit * caster)
AuraApplication * Unit::__ApplyAura(Aura * aura)
{
- // auraBase musn't be removed
+ assert(!m_cleanupDone);
+ // aura musn't be removed
assert(!aura->IsRemoved());
SpellEntry const* aurSpellInfo = aura->GetSpellProto();
@@ -12965,6 +12969,7 @@ void Unit::CleanupsBeforeDelete()
//A unit may be in removelist and not in world, but it is still in grid
//and may have some references during delete
RemoveAllAuras();
+ m_cleanupDone = true;
InterruptNonMeleeSpells(true);
m_Events.KillAllEvents(false); // non-delatable (currently casted spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
CombatStop();
diff --git a/src/game/Unit.h b/src/game/Unit.h
index a13d09e5b09..592922ee6c4 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -2069,6 +2069,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
uint32 m_reducedThreatPercent;
uint64 m_misdirectionTargetGUID;
+
+ bool m_cleanupDone;
};
namespace Trinity