aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-16 11:19:59 -0500
committermegamage <none@none>2009-06-16 11:19:59 -0500
commit3cf2be604275ec1ae7321b78dc6b62e559a5d7c7 (patch)
treed119d51bcee396d8fe913fa6b709ff45da2a2c2e /src
parentaaec3c819167afb3f40410142654ed4d57926b10 (diff)
[8026] Obtain object's map directly by calling appropriate WorldObject::GetMap()/GetBaseMap() functions instead of accessing MapManager. Code cleanups. Big thanks Infinity for tests. Author: Ambal
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/ConfusedMovementGenerator.cpp3
-rw-r--r--src/game/Creature.cpp4
-rw-r--r--src/game/DestinationHolder.h3
-rw-r--r--src/game/DestinationHolderImp.h10
-rw-r--r--src/game/FleeingMovementGenerator.cpp2
-rw-r--r--src/game/GameEventMgr.cpp4
-rw-r--r--src/game/GameObject.cpp13
-rw-r--r--src/game/InstanceSaveMgr.cpp4
-rw-r--r--src/game/Level1.cpp6
-rw-r--r--src/game/Map.cpp7
-rw-r--r--src/game/MapInstanced.h7
-rw-r--r--src/game/MapManager.cpp28
-rw-r--r--src/game/MapManager.h13
-rw-r--r--src/game/MovementHandler.cpp8
-rw-r--r--src/game/Object.cpp10
-rw-r--r--src/game/Object.h25
-rw-r--r--src/game/ObjectMgr.cpp4
-rw-r--r--src/game/Player.cpp32
-rw-r--r--src/game/Player.h2
-rw-r--r--src/game/PoolHandler.cpp4
-rw-r--r--src/game/QueryHandler.cpp2
-rw-r--r--src/game/RandomMovementGenerator.cpp3
-rw-r--r--src/game/Transports.cpp2
-rw-r--r--src/game/Unit.cpp4
-rw-r--r--src/game/WaypointMovementGenerator.cpp2
-rw-r--r--src/game/WorldSession.cpp2
26 files changed, 104 insertions, 100 deletions
diff --git a/src/game/ConfusedMovementGenerator.cpp b/src/game/ConfusedMovementGenerator.cpp
index cc64a6ae31f..98a8973612f 100644
--- a/src/game/ConfusedMovementGenerator.cpp
+++ b/src/game/ConfusedMovementGenerator.cpp
@@ -38,9 +38,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
x = unit.GetPositionX();
y = unit.GetPositionY();
z = unit.GetPositionZ();
- uint32 mapid=unit.GetMapId();
- Map const* map = MapManager::Instance().GetBaseMap(mapid);
+ Map const* map = unit.GetBaseMap();
i_nextMove = 1;
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 1fbea2da325..eb711a77ab5 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -263,8 +263,8 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
CreatureInfo const *cinfo = normalInfo;
if(normalInfo->HeroicEntry)
{
- Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId());
- if(map && map->IsHeroic())
+ //we already have valid Map pointer for current creature!
+ if(GetMap()->IsHeroic())
{
cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry);
if(!cinfo)
diff --git a/src/game/DestinationHolder.h b/src/game/DestinationHolder.h
index c37b60e8b54..17b9e5153bc 100644
--- a/src/game/DestinationHolder.h
+++ b/src/game/DestinationHolder.h
@@ -25,6 +25,7 @@
#include "Timer.h"
class WorldObject;
+class Map;
#define TRAVELLER_UPDATE_INTERVAL 300
@@ -53,7 +54,7 @@ class TRINITY_DLL_DECL DestinationHolder
bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool micro_movement=false);
uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true);
- void GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D = false) const;
+ void GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D = false) const;
void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
float GetDistance2dFromDestSq(const WorldObject &obj) const;
diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h
index 0286851cbb7..d50d8c3e727 100644
--- a/src/game/DestinationHolderImp.h
+++ b/src/game/DestinationHolderImp.h
@@ -120,9 +120,9 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
return true;
if(traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT))
- GetLocationNow(traveller.GetTraveller().GetMapId() ,x, y, z, true); // Should repositione Object with right Coord, so I can bypass some Grid Relocation
+ GetLocationNow(traveller.GetTraveller().GetBaseMap() ,x, y, z, true); // Should reposition Object with right Coord, so I can bypass some Grid Relocation
else
- GetLocationNow(traveller.GetTraveller().GetMapId(), x, y, z, false);
+ GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false);
if( x == -431602080 )
return false;
@@ -153,7 +153,7 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
template<typename TRAVELLER>
void
-DestinationHolder<TRAVELLER>::GetLocationNow(uint32 mapid, float &x, float &y, float &z, bool is3D) const
+DestinationHolder<TRAVELLER>::GetLocationNow(const Map * map, float &x, float &y, float &z, bool is3D) const
{
if( HasArrived() )
{
@@ -175,8 +175,8 @@ DestinationHolder<TRAVELLER>::GetLocationNow(uint32 mapid, float &x, float &y, f
z = z2;
else
{
- //That part is good for mob Walking on the floor. But the floor is not allways what we thought.
- z = MapManager::Instance().GetBaseMap(mapid)->GetHeight(x,y,i_fromZ,false); // Disable cave check
+ //That part is good for mob Walking on the floor. But the floor is not always what we thought.
+ z = map->GetHeight(x,y,i_fromZ,false); // Disable cave check
const float groundDist = sqrt(distanceX*distanceX + distanceY*distanceY);
const float zDist = fabs(i_fromZ - z) + 0.000001f;
const float slope = groundDist / zDist;
diff --git a/src/game/FleeingMovementGenerator.cpp b/src/game/FleeingMovementGenerator.cpp
index 27c4490801d..2eddd2a128c 100644
--- a/src/game/FleeingMovementGenerator.cpp
+++ b/src/game/FleeingMovementGenerator.cpp
@@ -78,7 +78,7 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
z = owner.GetPositionZ();
float temp_x, temp_y, angle;
- const Map * _map = MapManager::Instance().GetBaseMap(owner.GetMapId());
+ const Map * _map = owner.GetBaseMap();
//primitive path-finding
for(uint8 i = 0; i < 18; ++i)
{
diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp
index b96fab9ab8b..0984c896eac 100644
--- a/src/game/GameEventMgr.cpp
+++ b/src/game/GameEventMgr.cpp
@@ -1228,7 +1228,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
objmgr.AddCreatureToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
- Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(data->mapid));
+ Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
// We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(data->posX,data->posY))
{
@@ -1261,7 +1261,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
objmgr.AddGameobjectToGrid(*itr, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
- Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(data->mapid));
+ Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
// We use current coords to unspawn, not spawn coords since creature can have changed grid
if(!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
{
diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp
index 19acc73820b..1169cc780f4 100644
--- a/src/game/GameObject.cpp
+++ b/src/game/GameObject.cpp
@@ -74,8 +74,17 @@ GameObject::~GameObject()
Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
if(owner)
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));
+ else
+ {
+ char * ownerType = "creature";
+ if(IS_PLAYER_GUID(owner_guid))
+ ownerType = "player";
+ else if(IS_PET_GUID(owner_guid))
+ ownerType = "pet";
+
+ sLog.outError("Delete GameObject (GUID: %u Entry: %u SpellId %u LinkedGO %u) that lost references to owner (GUID %u Type '%s') GO list. Crash possible later.",
+ GetGUIDLow(), GetGOInfo()->id, m_spellId, GetLinkedGameObjectEntry(), GUID_LOPART(owner_guid), ownerType);
+ }
}
}*/
}
diff --git a/src/game/InstanceSaveMgr.cpp b/src/game/InstanceSaveMgr.cpp
index 2c304191136..d45e3fac451 100644
--- a/src/game/InstanceSaveMgr.cpp
+++ b/src/game/InstanceSaveMgr.cpp
@@ -580,7 +580,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr)
void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
{
sLog.outDebug("InstanceSaveMgr::_ResetInstance %u, %u", mapid, instanceId);
- Map *map = (MapInstanced*)MapManager::Instance().GetBaseMap(mapid);
+ Map *map = (MapInstanced*)MapManager::Instance().CreateBaseMap(mapid);
if(!map->Instanceable())
return;
@@ -597,7 +597,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe
{
// global reset for all instances of the given map
// note: this isn't fast but it's meant to be executed very rarely
- Map const *map = MapManager::Instance().GetBaseMap(mapid);
+ Map const *map = MapManager::Instance().CreateBaseMap(mapid);
if(!map->Instanceable())
return;
uint64 now = (uint64)time(NULL);
diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index b3a1b73f59f..1451e66b04a 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -2757,7 +2757,7 @@ bool ChatHandler::HandleGoXYCommand(const char* args)
else
_player->SaveRecallPosition();
- Map const *map = MapManager::Instance().GetBaseMap(mapid);
+ Map const *map = MapManager::Instance().CreateBaseMap(mapid);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
@@ -2850,7 +2850,7 @@ bool ChatHandler::HandleGoZoneXYCommand(const char* args)
// update to parent zone if exist (client map show only zones without parents)
AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry;
- Map const *map = MapManager::Instance().GetBaseMap(zoneEntry->mapid);
+ Map const *map = MapManager::Instance().CreateBaseMap(zoneEntry->mapid);
if(map->Instanceable())
{
@@ -2925,7 +2925,7 @@ bool ChatHandler::HandleGoGridCommand(const char* args)
else
_player->SaveRecallPosition();
- Map const *map = MapManager::Instance().GetBaseMap(mapid);
+ Map const *map = MapManager::Instance().CreateBaseMap(mapid);
float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
diff --git a/src/game/Map.cpp b/src/game/Map.cpp
index 4a102b92051..344fcbc74a2 100644
--- a/src/game/Map.cpp
+++ b/src/game/Map.cpp
@@ -127,7 +127,7 @@ void Map::LoadMap(int gx,int gy, bool reload)
if(GridMaps[gx][gy])
return;
- Map* baseMap = const_cast<Map*>(MapManager::Instance().GetBaseMap(i_id));
+ Map* baseMap = const_cast<Map*>(MapManager::Instance().CreateBaseMap(i_id));
// load grid map for base map
if (!baseMap->GridMaps[gx][gy])
@@ -498,9 +498,6 @@ void
Map::Add(T *obj)
{
CellPair p = Trinity::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
-
- assert(obj);
-
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{
sLog.outError("Map::Add: Object " UI64FMTD " have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
@@ -1161,7 +1158,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool unloadAll)
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx);
}
else
- ((MapInstanced*)(MapManager::Instance().GetBaseMap(i_id)))->RemoveGridMapReference(GridPair(gx, gy));
+ ((MapInstanced*)(MapManager::Instance().CreateBaseMap(i_id)))->RemoveGridMapReference(GridPair(gx, gy));
GridMaps[gx][gy] = NULL;
}
DEBUG_LOG("Unloading grid[%u,%u] for map %u finished", x,y, i_id);
diff --git a/src/game/MapInstanced.h b/src/game/MapInstanced.h
index bbca6ca0abb..6338726fd47 100644
--- a/src/game/MapInstanced.h
+++ b/src/game/MapInstanced.h
@@ -43,7 +43,7 @@ class TRINITY_DLL_DECL MapInstanced : public Map
bool CanEnter(Player* player);
Map* GetInstance(const WorldObject* obj);
- Map* FindMap(uint32 InstanceId) { return _FindMap(InstanceId); }
+ Map* FindMap(uint32 InstanceId) const { return _FindMap(InstanceId); }
void DestroyInstance(uint32 InstanceId);
void DestroyInstance(InstancedMaps::iterator &itr);
@@ -69,10 +69,9 @@ class TRINITY_DLL_DECL MapInstanced : public Map
InstancedMaps m_InstancedMaps;
- Map* _FindMap(uint32 InstanceId)
+ Map* _FindMap(uint32 InstanceId) const
{
- InstancedMaps::iterator i = m_InstancedMaps.find(InstanceId);
-
+ InstancedMaps::const_iterator i = m_InstancedMaps.find(InstanceId);
return(i == m_InstancedMaps.end() ? NULL : i->second);
}
diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp
index 43c778858b5..6c74237406f 100644
--- a/src/game/MapManager.cpp
+++ b/src/game/MapManager.cpp
@@ -101,7 +101,7 @@ void MapManager::checkAndCorrectGridStatesArray()
}
Map*
-MapManager::_GetBaseMap(uint32 id)
+MapManager::_createBaseMap(uint32 id)
{
Map *m = _findMap(id);
@@ -127,19 +127,24 @@ MapManager::_GetBaseMap(uint32 id)
Map* MapManager::GetMap(uint32 id, const WorldObject* obj)
{
+ ASSERT(obj);
//if(!obj->IsInWorld()) sLog.outError("GetMap: called for map %d with object (typeid %d, guid %d, mapid %d, instanceid %d) who is not in world!", id, obj->GetTypeId(), obj->GetGUIDLow(), obj->GetMapId(), obj->GetInstanceId());
- Map *m = _GetBaseMap(id);
+ Map *m = _createBaseMap(id);
if (m && obj && m->Instanceable()) m = ((MapInstanced*)m)->GetInstance(obj);
return m;
}
-Map* MapManager::FindMap(uint32 mapid, uint32 instanceId)
+Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
{
- Map *map = FindMap(mapid);
- if(!map) return NULL;
- if(!map->Instanceable()) return instanceId == 0 ? map : NULL;
+ Map *map = _findMap(mapid);
+ if(!map)
+ return NULL;
+
+ if(!map->Instanceable())
+ return instanceId == 0 ? map : NULL;
+
return ((MapInstanced*)map)->FindMap(instanceId);
}
@@ -224,14 +229,14 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
{
- Map *m = _GetBaseMap(mapid);
+ Map *m = _createBaseMap(mapid);
if (m && m->Instanceable())
((MapInstanced*)m)->DestroyInstance(instanceId);
}
void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y)
{
- bool remove_result = _GetBaseMap(mapid)->RemoveBones(guid, x, y);
+ bool remove_result = _createBaseMap(mapid)->RemoveBones(guid, x, y);
if (!remove_result)
{
@@ -290,13 +295,6 @@ bool MapManager::IsValidMAP(uint32 mapid)
// TODO: add check for battleground template
}
-/*void MapManager::LoadGrid(int mapid, float x, float y, const WorldObject* obj, bool no_unload)
-{
- CellPair p = Trinity::ComputeCellPair(x,y);
- Cell cell(p);
- GetMap(mapid, obj)->LoadGrid(cell,no_unload);
-}*/
-
void MapManager::UnloadAll()
{
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
diff --git a/src/game/MapManager.h b/src/game/MapManager.h
index b54c1cfbfa1..b07a26ed0f0 100644
--- a/src/game/MapManager.h
+++ b/src/game/MapManager.h
@@ -40,16 +40,15 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
public:
Map* GetMap(uint32, const WorldObject* obj);
- Map* FindMap(uint32 mapid) { return _findMap(mapid); }
- Map* FindMap(uint32 mapid, uint32 instanceId);
+ Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); }
+ Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
// only const version for outer users
- Map const* GetBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_GetBaseMap(id); }
void DeleteInstance(uint32 mapid, uint32 instanceId);
uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const
{
- Map const* m = GetBaseMap(mapid);
+ Map const* m = CreateBaseMap(mapid);
return m->GetAreaFlag(x, y, z);
}
uint32 GetAreaId(uint32 mapid, float x, float y, float z) const
@@ -85,7 +84,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
i_timer.Reset();
}
- //void LoadGrid(int mapid, float x, float y, const WorldObject* obj, bool no_unload = false);
+ //void LoadGrid(int mapid, int instId, float x, float y, const WorldObject* obj, bool no_unload = false);
void UnloadAll();
static bool ExistMapAndVMap(uint32 mapid, float x, float y);
@@ -108,7 +107,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
static bool IsValidMapCoord(WorldLocation const& loc)
{
- return IsValidMapCoord(loc.mapid,loc.x,loc.y,loc.z,loc.o);
+ return IsValidMapCoord(loc.mapid,loc.coord_x,loc.coord_y,loc.coord_z,loc.orientation);
}
void DoDelayedMovesAndRemoves();
@@ -142,7 +141,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
MapManager(const MapManager &);
MapManager& operator=(const MapManager &);
- Map* _GetBaseMap(uint32 id);
+ Map* _createBaseMap(uint32 id);
Map* _findMap(uint32 id) const
{
MapMapType::const_iterator iter = i_maps.find(id);
diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp
index 1a483a8869d..7d7733763cd 100644
--- a/src/game/MovementHandler.cpp
+++ b/src/game/MovementHandler.cpp
@@ -50,7 +50,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
WorldLocation &loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check
- if(!MapManager::IsValidMapCoord(loc.mapid, loc.x, loc.y, loc.z, loc.o))
+ if(!MapManager::IsValidMapCoord(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation))
{
LogoutPlayer(false);
return;
@@ -68,7 +68,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// relocate the player to the teleport destination
GetPlayer()->SetMapId(loc.mapid);
- GetPlayer()->Relocate(loc.x, loc.y, loc.z, loc.o);
+ GetPlayer()->Relocate(loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
// since the MapId is set before the GetInstance call, the InstanceId must be set to 0
// to let GetInstance() determine the proper InstanceId based on the player's binds
@@ -79,7 +79,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// while the player is in transit, for example the map may get full
if(!GetPlayer()->GetMap()->Add(GetPlayer()))
{
- sLog.outDebug("WORLD: teleport of player %s (%d) to location %d, %f, %f, %f, %f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.x, loc.y, loc.z, loc.o);
+ sLog.outDebug("WORLD: teleport of player %s (%d) to location %d, %f, %f, %f, %f failed", GetPlayer()->GetName(), GetPlayer()->GetGUIDLow(), loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, loc.orientation);
// teleport the player home
if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()))
{
@@ -186,7 +186,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
WorldLocation const& dest = plMover->GetTeleportDest();
- plMover->SetPosition(dest.x, dest.y, dest.z, dest.o, true);
+ plMover->SetPosition(dest.coord_x, dest.coord_y, dest.coord_z, dest.orientation, true);
uint32 newzone, newarea;
plMover->GetZoneAndAreaId(newzone, newarea);
diff --git a/src/game/Object.cpp b/src/game/Object.cpp
index b2ad38ceb47..0e7eed9bff0 100644
--- a/src/game/Object.cpp
+++ b/src/game/Object.cpp
@@ -1101,17 +1101,17 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint
uint32 WorldObject::GetZoneId() const
{
- return MapManager::Instance().GetBaseMap(m_mapId)->GetZoneId(m_positionX, m_positionY, m_positionZ);
+ return GetBaseMap()->GetZoneId(m_positionX, m_positionY, m_positionZ);
}
uint32 WorldObject::GetAreaId() const
{
- return MapManager::Instance().GetBaseMap(m_mapId)->GetAreaId(m_positionX, m_positionY, m_positionZ);
+ return GetBaseMap()->GetAreaId(m_positionX, m_positionY, m_positionZ);
}
void WorldObject::GetZoneAndAreaId(uint32& zoneid, uint32& areaid) const
{
- MapManager::Instance().GetBaseMap(m_mapId)->GetZoneAndAreaId(zoneid, areaid, m_positionX, m_positionY, m_positionZ);
+ GetBaseMap()->GetZoneAndAreaId(zoneid, areaid, m_positionX, m_positionY, m_positionZ);
}
InstanceData* WorldObject::GetInstanceData()
@@ -1448,7 +1448,7 @@ void WorldObject::GetRandomPoint( float x, float y, float z, float distance, flo
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const
{
- float new_z = MapManager::Instance().GetBaseMap(GetMapId())->GetHeight(x,y,z,true);
+ float new_z = GetBaseMap()->GetHeight(x,y,z,true);
if(new_z > INVALID_HEIGHT)
z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface
}
@@ -1679,7 +1679,7 @@ Map* WorldObject::_findMap()
Map const* WorldObject::GetBaseMap() const
{
- return MapManager::Instance().GetBaseMap(GetMapId());
+ return MapManager::Instance().CreateBaseMap(GetMapId());
}
void WorldObject::AddObjectToRemoveList()
diff --git a/src/game/Object.h b/src/game/Object.h
index bf5df0148c9..8e86ff1c87b 100644
--- a/src/game/Object.h
+++ b/src/game/Object.h
@@ -111,16 +111,18 @@ typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
struct WorldLocation
{
uint32 mapid;
- float x;
- float y;
- float z;
- float o;
+ float coord_x;
+ float coord_y;
+ float coord_z;
+ float orientation;
explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0)
- : mapid(_mapid), x(_x), y(_y), z(_z), o(_o) {}
+ : mapid(_mapid), coord_x(_x), coord_y(_y), coord_z(_z), orientation(_o) {}
WorldLocation(WorldLocation const &loc)
- : mapid(loc.mapid), x(loc.x), y(loc.y), z(loc.z), o(loc.o) {}
+ : mapid(loc.mapid), coord_x(loc.coord_x), coord_y(loc.coord_y), coord_z(loc.coord_z), orientation(loc.orientation) {}
};
+typedef float Position[4];
+
class TRINITY_DLL_SPEC Object
{
public:
@@ -394,11 +396,8 @@ class TRINITY_DLL_SPEC WorldObject : public Object
m_positionZ = z;
}
- void Relocate(WorldLocation const & loc)
- {
- SetMapId(loc.mapid);
- Relocate(loc.x, loc.y, loc.z, loc.o);
- }
+ void Relocate(Position pos)
+ { m_positionX = pos[0]; m_positionY = pos[1]; m_positionZ = pos[2]; m_orientation = pos[3]; }
void SetOrientation(float orientation) { m_orientation = orientation; }
@@ -408,7 +407,9 @@ class TRINITY_DLL_SPEC WorldObject : public Object
void GetPosition( float &x, float &y, float &z ) const
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
void GetPosition( WorldLocation &loc ) const
- { loc.mapid = GetMapId(); GetPosition(loc.x, loc.y, loc.z); loc.o = GetOrientation(); }
+ { loc.mapid = m_mapId; GetPosition(loc.coord_x, loc.coord_y, loc.coord_z); loc.orientation = GetOrientation(); }
+ void GetPosition(Position pos) const
+ { pos[0] = m_positionX; pos[1] = m_positionY; pos[2] = m_positionZ; pos[3] = m_orientation; }
float GetOrientation( ) const { return m_orientation; }
void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const;
void GetNearPoint( WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d,float absAngle) const;
diff --git a/src/game/ObjectMgr.cpp b/src/game/ObjectMgr.cpp
index 867da4401d3..682c91a1f3b 100644
--- a/src/game/ObjectMgr.cpp
+++ b/src/game/ObjectMgr.cpp
@@ -1405,7 +1405,7 @@ uint32 ObjectMgr::AddGameObject(uint32 entry, uint32 mapId, float x, float y, fl
AddGameobjectToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
- if(Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(mapId)))
+ if(Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId)))
{
// We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
@@ -1454,7 +1454,7 @@ uint32 ObjectMgr::AddCreature(uint32 entry, uint32 team, uint32 mapId, float x,
AddCreatureToGrid(guid, &data);
// Spawn if necessary (loaded grids only)
- if(Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(mapId)))
+ if(Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(mapId)))
{
// We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(x, y))
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 9c37f9a6bee..cbcf52789bb 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -1703,11 +1703,11 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
// near teleport, triggering send MSG_MOVE_TELEPORT_ACK from client at landing
if(!GetSession()->PlayerLogout())
{
- WorldLocation oldLoc;
- GetPosition(oldLoc);
+ Position oldPos;
+ GetPosition(oldPos);
Relocate(x, y, z, orientation);
SendTeleportAckMsg();
- Relocate(oldLoc);
+ Relocate(oldPos);
}
}
else
@@ -2124,7 +2124,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes
bool Player::IsUnderWater() const
{
return IsInWater() &&
- GetPositionZ() < (MapManager::Instance().GetBaseMap(GetMapId())->GetWaterLevel(GetPositionX(),GetPositionY())-2);
+ GetPositionZ() < (GetBaseMap()->GetWaterLevel(GetPositionX(),GetPositionY())-2);
}
void Player::SetInWater(bool apply)
@@ -5747,7 +5747,7 @@ void Player::CheckExploreSystem()
if (isInFlight())
return;
- uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ());
+ uint16 areaFlag = GetBaseMap()->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ());
if(areaFlag==0xffff)
return;
int offset = areaFlag / 32;
@@ -14457,7 +14457,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
}
else
{
- Relocate(GetBattleGroundEntryPoint());
+ const WorldLocation& _loc = GetBattleGroundEntryPoint();
+ SetMapId(_loc.mapid);
+ Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation);
//RemoveArenaAuras(true);
}
}
@@ -14604,7 +14606,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(at)
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
else
- sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no aretrigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId());
+ sLog.outError("Player %s(GUID: %u) logged in to a reset instance (map: %u) and there is no area-trigger leading to this map. Thus he can't be ported back to the entrance. This _might_ be an exploit attempt.", GetName(), GetGUIDLow(), GetMapId());
}
SaveRecallPosition();
@@ -15929,10 +15931,10 @@ void Player::SaveToDB()
ss << GetTeleportDest().mapid << ", "
<< (uint32)0 << ", "
<< (uint32)GetDifficulty() << ", "
- << finiteAlways(GetTeleportDest().x) << ", "
- << finiteAlways(GetTeleportDest().y) << ", "
- << finiteAlways(GetTeleportDest().z) << ", "
- << finiteAlways(GetTeleportDest().o) << ", '";
+ << finiteAlways(GetTeleportDest().coord_x) << ", "
+ << finiteAlways(GetTeleportDest().coord_y) << ", "
+ << finiteAlways(GetTeleportDest().coord_z) << ", "
+ << finiteAlways(GetTeleportDest().orientation) << ", '";
}
uint16 i;
@@ -16007,10 +16009,10 @@ void Player::SaveToDB()
ss << GetBGTeam();
ss << ", ";
ss << m_bgEntryPoint.mapid << ", "
- << finiteAlways(m_bgEntryPoint.x) << ", "
- << finiteAlways(m_bgEntryPoint.y) << ", "
- << finiteAlways(m_bgEntryPoint.z) << ", "
- << finiteAlways(m_bgEntryPoint.o);
+ << finiteAlways(m_bgEntryPoint.coord_x) << ", "
+ << finiteAlways(m_bgEntryPoint.coord_y) << ", "
+ << finiteAlways(m_bgEntryPoint.coord_z) << ", "
+ << finiteAlways(m_bgEntryPoint.orientation);
ss << ")";
CharacterDatabase.Execute( ss.str().c_str() );
diff --git a/src/game/Player.h b/src/game/Player.h
index b6720abaa39..3d2f876bc3b 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -856,7 +856,7 @@ class TRINITY_DLL_SPEC Player : public Unit
bool TeleportTo(WorldLocation const &loc, uint32 options = 0)
{
- return TeleportTo(loc.mapid, loc.x, loc.y, loc.z, options);
+ return TeleportTo(loc.mapid, loc.coord_x, loc.coord_y, loc.coord_z, options);
}
void SetSummonPoint(uint32 mapid, float x, float y, float z)
diff --git a/src/game/PoolHandler.cpp b/src/game/PoolHandler.cpp
index 753b6a249e6..09a1d4293b7 100644
--- a/src/game/PoolHandler.cpp
+++ b/src/game/PoolHandler.cpp
@@ -233,7 +233,7 @@ bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
objmgr.AddCreatureToGrid(guid, data);
// Spawn if necessary (loaded grids only)
- Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(data->mapid));
+ Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
// We use spawn coords to spawn
if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
{
@@ -263,7 +263,7 @@ bool PoolGroup<GameObject>::Spawn1Object(uint32 guid)
objmgr.AddGameobjectToGrid(guid, data);
// Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed
- Map* map = const_cast<Map*>(MapManager::Instance().GetBaseMap(data->mapid));
+ Map* map = const_cast<Map*>(MapManager::Instance().CreateBaseMap(data->mapid));
// We use current coords to unspawn, not spawn coords since creature can have changed grid
if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
{
diff --git a/src/game/QueryHandler.cpp b/src/game/QueryHandler.cpp
index e07941d57ca..9da24d404f9 100644
--- a/src/game/QueryHandler.cpp
+++ b/src/game/QueryHandler.cpp
@@ -308,7 +308,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
if(corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0)
{
// if corpse map have entrance
- if(Map const* entranceMap = MapManager::Instance().GetBaseMap(corpseMapEntry->entrance_map))
+ if(Map const* entranceMap = MapManager::Instance().CreateBaseMap(corpseMapEntry->entrance_map))
{
mapid = corpseMapEntry->entrance_map;
x = corpseMapEntry->entrance_x;
diff --git a/src/game/RandomMovementGenerator.cpp b/src/game/RandomMovementGenerator.cpp
index e354e41827c..d93689514c9 100644
--- a/src/game/RandomMovementGenerator.cpp
+++ b/src/game/RandomMovementGenerator.cpp
@@ -54,8 +54,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
creature.GetHomePosition(X, Y, Z, ori);
z = creature.GetPositionZ();
- uint32 mapid=creature.GetMapId();
- Map const* map = MapManager::Instance().GetBaseMap(mapid);
+ Map const* map = creature.GetBaseMap();
// For 2D/3D system selection
bool is_land_ok = creature.canWalk();
diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp
index 58e2447e6c4..11089f053d1 100644
--- a/src/game/Transports.cpp
+++ b/src/game/Transports.cpp
@@ -93,7 +93,7 @@ void MapManager::LoadTransports()
uint32 mapid;
x = t->m_WayPoints[0].x; y = t->m_WayPoints[0].y; z = t->m_WayPoints[0].z; mapid = t->m_WayPoints[0].mapid; o = 1;
- // creates the Gameobject
+ // creates the Gameobject
if(!t->Create(entry, mapid, x, y, z, o, 100, 0))
{
delete t;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index e74068bfb2d..d6e75153915 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -3582,12 +3582,12 @@ bool Unit::isInAccessiblePlaceFor(Creature const* c) const
bool Unit::IsInWater() const
{
- return MapManager::Instance().GetBaseMap(GetMapId())->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ());
+ return GetBaseMap()->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ());
}
bool Unit::IsUnderWater() const
{
- return MapManager::Instance().GetBaseMap(GetMapId())->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ());
+ return GetBaseMap()->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ());
}
void Unit::DeMorph()
diff --git a/src/game/WaypointMovementGenerator.cpp b/src/game/WaypointMovementGenerator.cpp
index d256b01bd5d..cef7fd8d596 100644
--- a/src/game/WaypointMovementGenerator.cpp
+++ b/src/game/WaypointMovementGenerator.cpp
@@ -264,7 +264,7 @@ void FlightPathMovementGenerator::Finalize(Player & player)
player.clearUnitState(UNIT_STAT_IN_FLIGHT);
float x, y, z;
- i_destinationHolder.GetLocationNow(player.GetMapId(), x, y, z);
+ i_destinationHolder.GetLocationNow(player.GetBaseMap(), x, y, z);
player.SetPosition(x, y, z, player.GetOrientation());
}
diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp
index 91d1e6e018a..9ffbc8e1b4d 100644
--- a/src/game/WorldSession.cpp
+++ b/src/game/WorldSession.cpp
@@ -37,7 +37,7 @@
#include "ObjectAccessor.h"
#include "BattleGroundMgr.h"
#include "OutdoorPvPMgr.h"
-//#include "Language.h" // for CMSG_CANCEL_MOUNT_AURA handler
+#include "MapManager.h"
#include "SocialMgr.h"
#include "zlib/zlib.h"