aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-31 09:18:39 -0600
committermegamage <none@none>2009-03-31 09:18:39 -0600
commit031df598ab444ae4ed3d3d66996168d3577fb29d (patch)
treeb85408862f7001e8dc43447bc74bd77ce817e93e
parentbe89c6bb2a6a2c5f1a62e2010a9ee97efb8529b2 (diff)
*Try to fix crash.
--HG-- branch : trunk
-rw-r--r--src/game/BattleGround.cpp1
-rw-r--r--src/game/Creature.cpp2
-rw-r--r--src/game/GameObject.cpp13
-rw-r--r--src/game/Level2.cpp1
-rw-r--r--src/game/Object.cpp20
-rw-r--r--src/game/Object.h2
-rw-r--r--src/game/OutdoorPvP.cpp4
-rw-r--r--src/game/Pet.cpp4
-rw-r--r--src/game/Player.cpp4
-rw-r--r--src/game/TemporarySummon.cpp14
-rw-r--r--src/game/Totem.cpp2
-rw-r--r--src/game/Unit.cpp11
-rw-r--r--src/game/Unit.h1
-rw-r--r--src/game/Vehicle.cpp6
14 files changed, 36 insertions, 49 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp
index 4dbd1ae5a3b..a7f0e2b4ec3 100644
--- a/src/game/BattleGround.cpp
+++ b/src/game/BattleGround.cpp
@@ -1489,7 +1489,6 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
}
pCreature->SetHomePosition(x, y, z, o);
- pCreature->AIM_Initialize();
//pCreature->SetDungeonDifficulty(0);
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 538a755e8ad..fa82c3b1eac 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -174,6 +174,7 @@ void Creature::AddToWorld()
{
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
+ AIM_Initialize();
SearchFormation();
}
}
@@ -1451,7 +1452,6 @@ bool Creature::LoadFromDB(uint32 guid, Map *map)
// checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType);
- AIM_Initialize();
return true;
}
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index eb0dd10b7d4..5c945000579 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -63,7 +63,7 @@ GameObject::GameObject() : WorldObject()
GameObject::~GameObject()
{
- if(m_uint32Values) // field array can be not exist if GameOBject not loaded
+ /*if(m_uint32Values) // field array can be not exist if GameOBject not loaded
{
// Possible crash at access to deleted GO in Unit::m_gameobj
uint64 owner_guid = GetOwnerGUID();
@@ -75,7 +75,7 @@ GameObject::~GameObject()
else if(!IS_PLAYER_GUID(owner_guid))
sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
}
- }
+ }*/
}
void GameObject::AddToWorld()
@@ -93,6 +93,15 @@ void GameObject::RemoveFromWorld()
///- Remove the gameobject from the accessor
if(IsInWorld())
{
+ // Possible crash at access to deleted GO in Unit::m_gameobj
+ if(uint64 owner_guid = GetOwnerGUID())
+ {
+ Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
+ if(owner)
+ owner->RemoveGameObject(this,false);
+ else if(!IS_PLAYER_GUID(owner_guid))
+ sLog.outError("Delete GameObject (GUID: %u Entry: %u ) that have references in not found creature %u GO list. Crash possible later.",GetGUIDLow(),GetGOInfo()->id,GUID_LOPART(owner_guid));
+ }
WorldObject::RemoveFromWorld();
ObjectAccessor::Instance().RemoveObject(this);
}
diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp
index a6aca23f80c..91f5fc516da 100644
--- a/src/game/Level2.cpp
+++ b/src/game/Level2.cpp
@@ -4368,7 +4368,6 @@ bool ChatHandler::HandleCreatePetCommand(const char* args)
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
- pet->AIM_Initialize();
pet->InitPetCreateSpells();
pet->SetHealth(pet->GetMaxHealth());
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index 3189c3123ed..18f4375dbeb 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -97,6 +97,8 @@ Object::~Object( )
//DEBUG_LOG("Object desctr 1 check (%p)",(void*)this);
delete [] m_uint32Values;
delete [] m_uint32Values_mirror;
+ m_uint32Values = NULL;
+ m_uint32Values_mirror = NULL;
//DEBUG_LOG("Object desctr 2 check (%p)",(void*)this);
}
}
@@ -1451,13 +1453,13 @@ void Object::ForceValuesUpdateAtIndex(uint32 i)
{
m_uint32Values_mirror[i] = GetUInt32Value(i) + 1; // makes server think the field changed
if(m_inWorld)
- {
+ {
if(!m_objectUpdated)
- {
+ {
ObjectAccessor::Instance().AddUpdateObject(this);
m_objectUpdated = true;
- }
}
+ }
}
namespace Trinity
@@ -1730,19 +1732,8 @@ TempSummon* WorldObject::SummonCreature(uint32 entry, float x, float y, float z,
return NULL;
pCreature->SetHomePosition(x, y, z, ang);
- pCreature->InitSummon(duration);
pCreature->SetTempSummonType(spwtype);
- if(GetTypeId()==TYPEID_UNIT && ((Creature*)this)->IsAIEnabled)
- ((Creature*)this)->AI()->JustSummoned(pCreature);
-
- if(pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && pCreature->m_spells[0])
- {
- if(GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER)
- pCreature->setFaction(((Unit*)this)->getFaction());
- pCreature->CastSpell(pCreature, pCreature->m_spells[0], false, 0, 0, GetGUID());
- }
-
return pCreature;
}
@@ -1840,7 +1831,6 @@ Pet* Player::SummonPet(uint32 entry, float x, float y, float z, float ang, PetTy
// this enables pet details window (Shift+P)
pet->GetCharmInfo()->SetPetNumber(pet_number, false);
- pet->AIM_Initialize();
map->Add((Creature*)pet);
pet->setPowerType(POWER_MANA);
diff --git a/src/game/Object.h b/src/game/Object.h
index 8b8efda6fd4..3448fb83899 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -313,8 +313,6 @@ class TRINITY_DLL_SPEC Object
uint16 GetValuesCount() const { return m_valuesCount; }
- void InitValues() { _InitValues(); }
-
virtual bool hasQuest(uint32 /* quest_id */) const { return false; }
virtual bool hasInvolvedQuest(uint32 /* quest_id */) const { return false; }
diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp
index 8aa117b5c4a..acbc5979f84 100644
--- a/src/game/OutdoorPvP.cpp
+++ b/src/game/OutdoorPvP.cpp
@@ -163,8 +163,6 @@ bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval,
return true;
}
- pCreature->AIM_Initialize();
-
pCreature->Relocate(x, y, z, o);
if(!pCreature->IsPositionValid())
@@ -276,8 +274,6 @@ bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, flo
}
else
{
- pCreature->AIM_Initialize();
-
pCreature->Relocate(x, y, z, o);
if(!pCreature->IsPositionValid())
diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp
index a3591e47f65..74dba64bd1c 100644
--- a/src/game/Pet.cpp
+++ b/src/game/Pet.cpp
@@ -63,7 +63,6 @@ Pet::~Pet()
for (PetSpellMap::iterator i = m_spells.begin(); i != m_spells.end(); ++i)
delete i->second;
- ObjectAccessor::Instance().RemoveObject(this);
}
delete m_declinedname;
@@ -77,6 +76,7 @@ void Pet::AddToWorld()
///- Register the pet for guid lookup
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
+ AIM_Initialize();
}
}
@@ -168,7 +168,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
CreatureInfo const *cinfo = GetCreatureInfo();
if(cinfo->type == CREATURE_TYPE_CRITTER)
{
- AIM_Initialize();
map->Add((Creature*)this);
delete result;
return true;
@@ -185,7 +184,6 @@ bool Pet::LoadPetFromDB( Player* owner, uint32 petentry, uint32 petnumber, bool
SetUInt32Value(UNIT_NPC_FLAGS, 0);
SetName(fields[9].GetString());
- AIM_Initialize();
map->Add((Creature*)this);
owner->SetGuardian(this, true);
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 707467cd03d..1b885c99874 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -521,12 +521,12 @@ Player::~Player ()
void Player::CleanupsBeforeDelete()
{
- if(m_uint32Values) // only for fully created Object
+ if(IsInWorld()) // only for fully created Object
{
TradeCancel(false);
DuelComplete(DUEL_INTERUPTED);
+ Unit::CleanupsBeforeDelete();
}
- Unit::CleanupsBeforeDelete();
}
bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 class_, uint8 gender, uint8 skin, uint8 face, uint8 hairStyle, uint8 hairColor, uint8 facialHair, uint8 outfitId )
diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp
index fde2f4d7d84..4ae2c86b96a 100644
--- a/src/game/TemporarySummon.cpp
+++ b/src/game/TemporarySummon.cpp
@@ -174,8 +174,6 @@ void TempSummon::InitSummon(uint32 duration)
if(m_type == TEMPSUMMON_MANUAL_DESPAWN)
m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;
- AIM_Initialize();
-
if(!m_Properties)
return;
@@ -194,6 +192,18 @@ void TempSummon::InitSummon(uint32 duration)
}
}
+ if(owner)
+ {
+ if(owner->GetTypeId()==TYPEID_UNIT && ((Creature*)owner)->IsAIEnabled)
+ ((Creature*)owner)->AI()->JustSummoned(this);
+
+ if(GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && m_spells[0])
+ {
+ setFaction(owner->getFaction());
+ CastSpell(this, m_spells[0], false, 0, 0, m_summonerGUID);
+ }
+ }
+
if(m_Properties->Faction)
setFaction(m_Properties->Faction);
}
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index df6c55dae82..3b1879feca7 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -88,8 +88,6 @@ void Totem::Summon(Unit* owner)
data << GetGUID();
SendMessageToSet(&data,true);
- AIM_Initialize();
-
switch(m_type)
{
case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index d10fbbc98da..2a958411f58 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -11313,11 +11313,6 @@ uint32 Unit::GetCreatePowers( Powers power ) const
return 0;
}
-void Unit::AddToWorld()
-{
- WorldObject::AddToWorld();
-}
-
void Unit::RemoveFromWorld()
{
// cleanup
@@ -11338,7 +11333,7 @@ void Unit::RemoveFromWorld()
void Unit::CleanupsBeforeDelete()
{
- if(m_uint32Values) // only for fully created object
+ if(IsInWorld()) // only for fully created object
{
RemoveAllAuras();
InterruptNonMeleeSpells(true);
@@ -11350,8 +11345,9 @@ void Unit::CleanupsBeforeDelete()
RemoveAllGameObjects();
RemoveAllDynObjects();
GetMotionMaster()->Clear(false); // remove different non-standard movement generators.
+
+ RemoveFromWorld();
}
- RemoveFromWorld();
}
void Unit::UpdateCharmAI()
@@ -12540,7 +12536,6 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id)
pet->GetCharmInfo()->SetPetNumber(objmgr.GeneratePetNumber(), true);
// this enables pet details window (Shift+P)
- pet->AIM_Initialize();
pet->InitPetCreateSpells();
pet->InitTalentForLevel();
pet->SetHealth(pet->GetMaxHealth());
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 38ff55d526c..be729616f26 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -863,7 +863,6 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
virtual ~Unit ( );
- void AddToWorld();
void RemoveFromWorld();
void CleanupsBeforeDelete(); // used in ~Creature/~Player (or before mass creature delete to remove cross-references to already deleted units)
diff --git a/src/game/Vehicle.cpp b/src/game/Vehicle.cpp
index e5f45722eba..377b1d263b2 100644
--- a/src/game/Vehicle.cpp
+++ b/src/game/Vehicle.cpp
@@ -31,8 +31,6 @@ Vehicle::Vehicle() : Creature(), m_vehicleId(0)
Vehicle::~Vehicle()
{
- if(m_uint32Values) // only for fully created Object
- ObjectAccessor::Instance().RemoveObject(this);
}
void Vehicle::AddToWorld()
@@ -41,6 +39,7 @@ void Vehicle::AddToWorld()
{
ObjectAccessor::Instance().AddObject(this);
Unit::AddToWorld();
+ AIM_Initialize();
}
}
@@ -79,8 +78,6 @@ bool Vehicle::Create(uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, u
m_defaultMovementType = IDLE_MOTION_TYPE;
- AIM_Initialize();
-
SetVehicleId(vehicleId);
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
@@ -173,6 +170,5 @@ bool Vehicle::LoadFromDB(uint32 guid, Map *map)
// checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType);
- AIM_Initialize();
return true;
}