aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQAston <none@none>2009-08-01 20:23:23 +0200
committerQAston <none@none>2009-08-01 20:23:23 +0200
commitaa60def6acd9b15267cf3c95f9a7e65531838796 (patch)
tree1152d6944696f0a88c2008413281b0ed5c6bff95
parentd577d00313c673b51e79181ed8a5eb3146aded9e (diff)
*Teleport player to homebind if instance can't be created in WorldSession::HandleMoveWorldportAckOpcode.
--HG-- branch : trunk
-rw-r--r--src/game/GameObject.cpp9
-rw-r--r--src/game/GameObject.h2
-rw-r--r--src/game/MovementHandler.cpp2
-rw-r--r--src/game/ObjectAccessor.h19
4 files changed, 26 insertions, 6 deletions
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index e6ff16f251c..f934d3d1fe7 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -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()
diff --git a/src/game/GameObject.h b/src/game/GameObject.h
index 97c532605d3..b96213bfad5 100644
--- a/src/game/GameObject.h
+++ b/src/game/GameObject.h
@@ -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; }
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 68deb5af9f4..5ec73f9cb48 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -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);
diff --git a/src/game/ObjectAccessor.h b/src/game/ObjectAccessor.h
index 2dd1b56641f..403470f9446 100644
--- a/src/game/ObjectAccessor.h
+++ b/src/game/ObjectAccessor.h
@@ -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);