diff options
author | megamage <none@none> | 2009-04-01 21:17:59 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-04-01 21:17:59 -0600 |
commit | 30eedaa72d0873489464239f636c0705a7459b06 (patch) | |
tree | bb09de51539bd8fad8a98cd0d371b9ebd61f6dcc /src | |
parent | 1b6c44dae5c229bba6c883175745557425695cf1 (diff) |
*Try to fix some crash.
--HG--
branch : trunk
Diffstat (limited to 'src')
-rw-r--r-- | src/game/BattleGround.cpp | 1 | ||||
-rw-r--r-- | src/game/Object.cpp | 11 | ||||
-rw-r--r-- | src/game/Object.h | 8 | ||||
-rw-r--r-- | src/game/ObjectAccessor.cpp | 31 | ||||
-rw-r--r-- | src/game/OutdoorPvP.cpp | 5 |
5 files changed, 22 insertions, 34 deletions
diff --git a/src/game/BattleGround.cpp b/src/game/BattleGround.cpp index a7f0e2b4ec3..772b8c596ca 100644 --- a/src/game/BattleGround.cpp +++ b/src/game/BattleGround.cpp @@ -1485,6 +1485,7 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f if(!pCreature->IsPositionValid()) { sLog.outError("Creature (guidlow %d, entry %d) not added to battleground. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + delete pCreature; return NULL; } diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 18f4375dbeb..83a64262d24 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -82,16 +82,16 @@ Object::Object( ) Object::~Object( ) { - if(m_objectUpdated) - ObjectAccessor::Instance().RemoveUpdateObject(this); + //if(m_objectUpdated) + // ObjectAccessor::Instance().RemoveUpdateObject(this); if(m_uint32Values) { if(IsInWorld()) { ///- Do NOT call RemoveFromWorld here, if the object is a player it will crash - sLog.outError("Object::~Object - guid="I64FMTD", typeid=%d deleted but still in world!!", GetGUID(), GetTypeId()); - //assert(0); + sLog.outCrash("Object::~Object - guid="I64FMTD", typeid=%d deleted but still in world!!", GetGUID(), GetTypeId()); + assert(false); } //DEBUG_LOG("Object desctr 1 check (%p)",(void*)this); @@ -1893,7 +1893,10 @@ GameObject* WorldObject::SummonGameObject(uint32 entry, float x, float y, float Map *map = GetMap(); GameObject *go = new GameObject(); if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x,y,z,ang,rotation0,rotation1,rotation2,rotation3,100,1)) + { + delete go; return NULL; + } go->SetRespawnTime(respawnTime); if(GetTypeId()==TYPEID_PLAYER || GetTypeId()==TYPEID_UNIT) //not sure how to handle this ((Unit*)this)->AddGameObject(go); diff --git a/src/game/Object.h b/src/game/Object.h index 3448fb83899..a4b7506ca30 100644 --- a/src/game/Object.h +++ b/src/game/Object.h @@ -133,6 +133,8 @@ class TRINITY_DLL_SPEC Object if(m_inWorld) return; + assert(m_uint32Values); + m_inWorld = true; // synchronize values mirror with values array (changes will send in updatecreate opcode any way @@ -143,10 +145,10 @@ class TRINITY_DLL_SPEC Object if(!m_inWorld) return; - // if we remove from world then sending changes not required - if(m_uint32Values) - ClearUpdateMask(true); m_inWorld = false; + + // if we remove from world then sending changes not required + ClearUpdateMask(true); } const uint64& GetGUID() const { return GetUInt64Value(0); } diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index f1243e7afec..c506450c821 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -259,30 +259,10 @@ ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer) void ObjectAccessor::_buildUpdateObject(Object *obj, UpdateDataMapType &update_players) { - bool build_for_all = true; - Player *pl = NULL; - if( obj->isType(TYPEMASK_ITEM) ) - { - Item *item = static_cast<Item *>(obj); - pl = item->GetOwner(); - build_for_all = false; - } - - if( pl != NULL ) - _buildPacket(pl, obj, update_players); - - // Capt: okey for all those fools who think its a real fix - // THIS IS A TEMP FIX - if( build_for_all ) - { - WorldObject * temp = dynamic_cast<WorldObject*>(obj); - - //assert(dynamic_cast<WorldObject*>(obj)!=NULL); - if (temp) - _buildChangeObjectForPlayer(temp, update_players); - else - sLog.outDebug("ObjectAccessor: Ln 405 Temp bug fix"); - } + if(obj->isType(TYPEMASK_ITEM)) + _buildPacket(((Item*)obj)->GetOwner(), obj, update_players); + else + _buildChangeObjectForPlayer((WorldObject*)obj, update_players); } void @@ -472,9 +452,8 @@ ObjectAccessor::Update(uint32 diff) while(!i_objects.empty()) { Object* obj = *i_objects.begin(); + assert(obj && obj->IsInWorld()); i_objects.erase(i_objects.begin()); - if (!obj || !obj->IsInWorld()) - continue; _buildUpdateObject(obj, update_players); obj->ClearUpdateMask(false); } diff --git a/src/game/OutdoorPvP.cpp b/src/game/OutdoorPvP.cpp index 0efa3bfdeaf..d702ea6d047 100644 --- a/src/game/OutdoorPvP.cpp +++ b/src/game/OutdoorPvP.cpp @@ -160,7 +160,7 @@ bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval, { sLog.outError("Can't create creature entry: %u",entry); delete pCreature; - return true; + return false; } pCreature->Relocate(x, y, z, o); @@ -168,6 +168,7 @@ bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval, if(!pCreature->IsPositionValid()) { sLog.outError("ERROR: Creature (guidlow %d, entry %d) not added to opvp. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + delete pCreature; return false; } @@ -271,6 +272,7 @@ bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, flo { sLog.outError("Can't create creature entry: %u",entry); delete pCreature; + return false; } else { @@ -279,6 +281,7 @@ bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, flo if(!pCreature->IsPositionValid()) { sLog.outError("ERROR: Creature (guidlow %d, entry %d) not added to opvp. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY()); + delete pCreature; return false; } |