*Teleport player to homebind if instance can't be created in WorldSession::HandleMoveWorldportAckOpcode.
--HG-- branch : trunk
This commit is contained in:
@@ -123,8 +123,7 @@ void GameObject::RemoveFromWorld()
|
||||
// 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)
|
||||
if(Unit * owner = GetOwner(false))
|
||||
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));
|
||||
@@ -707,9 +706,11 @@ bool GameObject::IsTransport() const
|
||||
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()
|
||||
|
||||
@@ -593,7 +593,7 @@ class TRINITY_DLL_SPEC GameObject : public WorldObject
|
||||
|
||||
void SetOwnerGUID(uint64 owner);
|
||||
uint64 GetOwnerGUID() const { return GetUInt64Value(OBJECT_FIELD_CREATED_BY); }
|
||||
Unit* GetOwner() const;
|
||||
Unit* GetOwner(bool inWorld = true) const;
|
||||
|
||||
uint32 GetDBTableGUIDLow() const { return m_DBTableGuid; }
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
|
||||
Map * newMap = MapManager::Instance().CreateMap(loc.mapid, GetPlayer(), 0);
|
||||
// the CanEnter checks are done in TeleporTo but conditions may change
|
||||
// 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());
|
||||
GetPlayer()->RelocateToHomebind(loc.mapid);
|
||||
|
||||
@@ -121,6 +121,24 @@ class MANGOS_DLL_DECL ObjectAccessor : public MaNGOS::Singleton<ObjectAccessor,
|
||||
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*/)
|
||||
{
|
||||
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 Creature* GetCreatureOrPetOrVehicle(WorldObject const &, uint64);
|
||||
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 Player* GetPlayer(Unit const &, uint64 guid) { return FindPlayer(guid); }
|
||||
static Corpse* GetCorpse(WorldObject const &u, uint64 guid);
|
||||
|
||||
Reference in New Issue
Block a user