*Teleport player to homebind if instance can't be created in WorldSession::HandleMoveWorldportAckOpcode.

--HG--
branch : trunk
This commit is contained in:
QAston
2009-08-01 20:23:23 +02:00
parent d577d00313
commit aa60def6ac
4 changed files with 26 additions and 6 deletions
+5 -4
View File
@@ -123,8 +123,7 @@ void GameObject::RemoveFromWorld()
// Possible crash at access to deleted GO in Unit::m_gameobj // Possible crash at access to deleted GO in Unit::m_gameobj
if(uint64 owner_guid = GetOwnerGUID()) if(uint64 owner_guid = GetOwnerGUID())
{ {
Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid); if(Unit * owner = GetOwner(false))
if(owner)
owner->RemoveGameObject(this,false); owner->RemoveGameObject(this,false);
else if(!IS_PLAYER_GUID(owner_guid)) 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)); 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));
@@ -707,9 +706,11 @@ bool GameObject::IsTransport() const
return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT; return gInfo->type == GAMEOBJECT_TYPE_TRANSPORT || gInfo->type == GAMEOBJECT_TYPE_MO_TRANSPORT;
} }
Unit* GameObject::GetOwner() const Unit* GameObject::GetOwner(bool inWorld) const
{ {
return ObjectAccessor::GetUnit(*this, GetOwnerGUID()); if (inWorld)
return ObjectAccessor::GetUnit(*this, GetOwnerGUID());
return ObjectAccessor::GetUnitInOrOutOfWorld(*this, GetOwnerGUID());
} }
void GameObject::SaveRespawnTime() void GameObject::SaveRespawnTime()
+1 -1
View File
@@ -593,7 +593,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
void SetOwnerGUID(uint64 owner); void SetOwnerGUID(uint64 owner);
uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); } uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
Unit* GetOwner() const; Unit* GetOwner(bool inWorld = true) const;
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; } uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
+1 -1
View File
@@ -72,7 +72,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
Map * newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0); Map * newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0);
// the CanEnter checks are done in TeleporTo but conditions may change // the CanEnter checks are done in TeleporTo but conditions may change
// while the player is in transit, for example the map may get full // while the player is in transit, for example the map may get full
if (!newMap->CanEnter(GetPlayer())) if (!newMap || !newMap->CanEnter(GetPlayer()))
{ {
sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.mapid, GetPlayer()->GetGUIDLow()); sLog.outError("Map %d could not be created for player %d, porting player to homebind", loc.mapid, GetPlayer()->GetGUIDLow());
GetPlayer()->RelocateToHomebind(loc.mapid); GetPlayer()->RelocateToHomebind(loc.mapid);
+19
View File
@@ -121,6 +121,24 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
return (Unit*)HashMapHolder<Vehicle>::Find(guid); return (Unit*)HashMapHolder<Vehicle>::Find(guid);
} }
static Unit* GetUnitInOrOutOfWorld(uint64 guid, Unit* /*fake*/)
{
if(!guid)
return NULL;
if (IS_PLAYER_GUID(guid))
{
Unit * u = (Unit*)HashMapHolder<Player>::Find(guid);
if(!u)
return NULL;
return u;
}
// Other object types than player are unloaded while out of world
return GetObjectInWorld(guid, ((Unit*)NULL));
}
template<class T> static T* GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/) template<class T> static T* GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/)
{ {
T* obj = HashMapHolder<T>::Find(guid); T* obj = HashMapHolder<T>::Find(guid);
@@ -150,6 +168,7 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask); static Object* GetObjectByTypeMask(WorldObject const &, uint64, uint32 typemask);
static Creature* GetCreatureOrPetOrVehicle(WorldObject const &, uint64); static Creature* GetCreatureOrPetOrVehicle(WorldObject const &, uint64);
static Unit* GetUnit(WorldObject const &, uint64 guid) { return GetObjectInWorld(guid, (Unit*)NULL); } static Unit* GetUnit(WorldObject const &, uint64 guid) { return GetObjectInWorld(guid, (Unit*)NULL); }
static Unit* GetUnitInOrOutOfWorld(WorldObject const &, uint64 guid) { return GetUnitInOrOutOfWorld(guid, (Unit*)NULL); }
static Pet* GetPet(Unit const &, uint64 guid) { return GetPet(guid); } static Pet* GetPet(Unit const &, uint64 guid) { return GetPet(guid); }
static Player* GetPlayer(Unit const &, uint64 guid) { return FindPlayer(guid); } static Player* GetPlayer(Unit const &, uint64 guid) { return FindPlayer(guid); }
static Corpse* GetCorpse(WorldObject const &u, uint64 guid); static Corpse* GetCorpse(WorldObject const &u, uint64 guid);