*Try to fix some crash.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-04-01 21:17:59 -06:00
parent 1b6c44dae5
commit 30eedaa72d
5 changed files with 22 additions and 34 deletions
+1
View File
@@ -1485,6 +1485,7 @@ Creature* BattleGround::AddCreature(uint32 entry, uint32 type, uint32 teamval, f
if(!pCreature->IsPositionValid()) 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()); 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; return NULL;
} }
+7 -4
View File
@@ -82,16 +82,16 @@ Object::Object( )
Object::~Object( ) Object::~Object( )
{ {
if(m_objectUpdated) //if(m_objectUpdated)
ObjectAccessor::Instance().RemoveUpdateObject(this); // ObjectAccessor::Instance().RemoveUpdateObject(this);
if(m_uint32Values) if(m_uint32Values)
{ {
if(IsInWorld()) if(IsInWorld())
{ {
///- Do NOT call RemoveFromWorld here, if the object is a player it will crash ///- 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()); sLog.outCrash("Object::~Object - guid="I64FMTD", typeid=%d deleted but still in world!!", GetGUID(), GetTypeId());
//assert(0); assert(false);
} }
//DEBUG_LOG("Object desctr 1 check (%p)",(void*)this); //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(); Map *map = GetMap();
GameObject *go = new GameObject(); GameObject *go = new GameObject();
if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x,y,z,ang,rotation0,rotation1,rotation2,rotation3,100,1)) if(!go->Create(objmgr.GenerateLowGuid(HIGHGUID_GAMEOBJECT), entry, map, GetPhaseMask(), x,y,z,ang,rotation0,rotation1,rotation2,rotation3,100,1))
{
delete go;
return NULL; return NULL;
}
go->SetRespawnTime(respawnTime); go->SetRespawnTime(respawnTime);
if(GetTypeId()==TYPEID_PLAYER || GetTypeId()==TYPEID_UNIT) //not sure how to handle this if(GetTypeId()==TYPEID_PLAYER || GetTypeId()==TYPEID_UNIT) //not sure how to handle this
((Unit*)this)->AddGameObject(go); ((Unit*)this)->AddGameObject(go);
+5 -3
View File
@@ -133,6 +133,8 @@ class TRINITY_DLL_SPEC Object
if(m_inWorld) if(m_inWorld)
return; return;
assert(m_uint32Values);
m_inWorld = true; m_inWorld = true;
// synchronize values mirror with values array (changes will send in updatecreate opcode any way // 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) if(!m_inWorld)
return; return;
// if we remove from world then sending changes not required
if(m_uint32Values)
ClearUpdateMask(true);
m_inWorld = false; m_inWorld = false;
// if we remove from world then sending changes not required
ClearUpdateMask(true);
} }
const uint64& GetGUID() const { return GetUInt64Value(0); } const uint64& GetGUID() const { return GetUInt64Value(0); }
+3 -24
View File
@@ -259,30 +259,10 @@ ObjectAccessor::UpdateObject(Object* obj, Player* exceptPlayer)
void void
ObjectAccessor::_buildUpdateObject(Object *obj, UpdateDataMapType &update_players) ObjectAccessor::_buildUpdateObject(Object *obj, UpdateDataMapType &update_players)
{ {
bool build_for_all = true;
Player *pl = NULL;
if(obj->isType(TYPEMASK_ITEM)) if(obj->isType(TYPEMASK_ITEM))
{ _buildPacket(((Item*)obj)->GetOwner(), obj, update_players);
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 else
sLog.outDebug("ObjectAccessor: Ln 405 Temp bug fix"); _buildChangeObjectForPlayer((WorldObject*)obj, update_players);
}
} }
void void
@@ -472,9 +452,8 @@ ObjectAccessor::Update(uint32 diff)
while(!i_objects.empty()) while(!i_objects.empty())
{ {
Object* obj = *i_objects.begin(); Object* obj = *i_objects.begin();
assert(obj && obj->IsInWorld());
i_objects.erase(i_objects.begin()); i_objects.erase(i_objects.begin());
if (!obj || !obj->IsInWorld())
continue;
_buildUpdateObject(obj, update_players); _buildUpdateObject(obj, update_players);
obj->ClearUpdateMask(false); obj->ClearUpdateMask(false);
} }
+4 -1
View File
@@ -160,7 +160,7 @@ bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval,
{ {
sLog.outError("Can't create creature entry: %u",entry); sLog.outError("Can't create creature entry: %u",entry);
delete pCreature; delete pCreature;
return true; return false;
} }
pCreature->Relocate(x, y, z, o); pCreature->Relocate(x, y, z, o);
@@ -168,6 +168,7 @@ bool OutdoorPvPObjective::AddCreature(uint32 type, uint32 entry, uint32 teamval,
if(!pCreature->IsPositionValid()) 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()); 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; 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); sLog.outError("Can't create creature entry: %u",entry);
delete pCreature; delete pCreature;
return false;
} }
else else
{ {
@@ -279,6 +281,7 @@ bool OutdoorPvPObjective::AddCapturePoint(uint32 entry, uint32 map, float x, flo
if(!pCreature->IsPositionValid()) 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()); 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; return false;
} }