*Try to fix crash.
--HG-- branch : trunk
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+11
-2
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
+5
-15
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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())
|
||||
|
||||
+1
-3
@@ -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);
|
||||
|
||||
|
||||
+2
-2
@@ -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 )
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
+3
-8
@@ -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());
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user