[8026] Obtain object's map directly by calling appropriate WorldObject::GetMap()/GetBaseMap() functions instead of accessing MapManager. Code cleanups. Big thanks Infinity for tests.

Signed-off-by: AlexDereka <dereka.alex@gmail.com>
This commit is contained in:
Ambal 2009-06-16 12:20:11 +04:00 committed by AlexDereka
parent 1187c8698c
commit b76c4c2f3c
29 changed files with 99 additions and 99 deletions

View file

@ -31,9 +31,8 @@ ConfusedMovementGenerator<T>::Initialize(T &unit)
x = unit.GetPositionX(); x = unit.GetPositionX();
y = unit.GetPositionY(); y = unit.GetPositionY();
z = unit.GetPositionZ(); z = unit.GetPositionZ();
uint32 mapid=unit.GetMapId();
Map const* map = MapManager::Instance().GetBaseMap(mapid); Map const* map = unit.GetBaseMap();
i_nextMove = 1; i_nextMove = 1;

View file

@ -182,8 +182,8 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
CreatureInfo const *cinfo = normalInfo; CreatureInfo const *cinfo = normalInfo;
if(normalInfo->HeroicEntry) if(normalInfo->HeroicEntry)
{ {
Map *map = MapManager::Instance().FindMap(GetMapId(), GetInstanceId()); //we already have valid Map pointer for current creature!
if(map && map->IsHeroic()) if(GetMap()->IsHeroic())
{ {
cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry); cinfo = objmgr.GetCreatureTemplate(normalInfo->HeroicEntry);
if(!cinfo) if(!cinfo)

View file

@ -23,6 +23,7 @@
#include "Timer.h" #include "Timer.h"
class WorldObject; class WorldObject;
class Map;
#define TRAVELLER_UPDATE_INTERVAL 300 #define TRAVELLER_UPDATE_INTERVAL 300
@ -51,7 +52,7 @@ class MANGOS_DLL_DECL DestinationHolder
bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); } bool HasArrived(void) const { return (i_totalTravelTime == 0 || i_timeElapsed >= i_totalTravelTime); }
bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false); bool UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, bool micro_movement=false);
uint32 StartTravel(TRAVELLER &traveller, bool sendMove = true); 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 void GetLocationNowNoMicroMovement(float &x, float &y, float &z) const; // For use without micro movement
float GetDistance2dFromDestSq(const WorldObject &obj) const; float GetDistance2dFromDestSq(const WorldObject &obj) const;

View file

@ -126,9 +126,9 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
return true; return true;
if(traveller.GetTraveller().hasUnitState(UNIT_STAT_IN_FLIGHT)) 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 else
GetLocationNow(traveller.GetTraveller().GetMapId(), x, y, z, false); GetLocationNow(traveller.GetTraveller().GetBaseMap(), x, y, z, false);
if( x == -431602080 ) if( x == -431602080 )
return false; return false;
@ -158,7 +158,7 @@ DestinationHolder<TRAVELLER>::UpdateTraveller(TRAVELLER &traveller, uint32 diff,
template<typename TRAVELLER> template<typename TRAVELLER>
void 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() ) if( HasArrived() )
{ {
@ -180,8 +180,8 @@ DestinationHolder<TRAVELLER>::GetLocationNow(uint32 mapid, float &x, float &y, f
z = z2; z = z2;
else else
{ {
//That part is good for mob Walking on the floor. But the floor is not allways what we thought. //That part is good for mob Walking on the floor. But the floor is not always what we thought.
z = MapManager::Instance().GetBaseMap(mapid)->GetHeight(x,y,i_fromZ,false); // Disable cave check z = map->GetHeight(x,y,i_fromZ,false); // Disable cave check
const float groundDist = sqrt(distanceX*distanceX + distanceY*distanceY); const float groundDist = sqrt(distanceX*distanceX + distanceY*distanceY);
const float zDist = fabs(i_fromZ - z) + 0.000001f; const float zDist = fabs(i_fromZ - z) + 0.000001f;
const float slope = groundDist / zDist; const float slope = groundDist / zDist;

View file

@ -60,7 +60,7 @@ FleeingMovementGenerator<T>::_getPoint(T &owner, float &x, float &y, float &z)
z = owner.GetPositionZ(); z = owner.GetPositionZ();
float temp_x, temp_y, angle; float temp_x, temp_y, angle;
const Map * _map = MapManager::Instance().GetBaseMap(owner.GetMapId()); const Map * _map = owner.GetBaseMap();
//primitive path-finding //primitive path-finding
for(uint8 i = 0; i < 18; ++i) for(uint8 i = 0; i < 18; ++i)
{ {

View file

@ -517,7 +517,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
objmgr.AddCreatureToGrid(*itr, data); objmgr.AddCreatureToGrid(*itr, data);
// Spawn if necessary (loaded grids only) // 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 // We use spawn coords to spawn
if(!map->Instanceable() && !map->IsRemovalGrid(data->posX,data->posY)) if(!map->Instanceable() && !map->IsRemovalGrid(data->posX,data->posY))
{ {
@ -550,7 +550,7 @@ void GameEventMgr::GameEventSpawn(int16 event_id)
objmgr.AddGameobjectToGrid(*itr, data); objmgr.AddGameobjectToGrid(*itr, data);
// Spawn if necessary (loaded grids only) // Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed // 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 // We use current coords to unspawn, not spawn coords since creature can have changed grid
if(!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY)) if(!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
{ {

View file

@ -69,8 +69,17 @@ GameObject::~GameObject()
Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid); Unit* owner = ObjectAccessor::GetUnit(*this,owner_guid);
if(owner) if(owner)
owner->RemoveGameObject(this,false); owner->RemoveGameObject(this,false);
else if(!IS_PLAYER_GUID(owner_guid)) else
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)); {
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);
}
} }
} }
} }

View file

@ -558,7 +558,7 @@ void InstanceSaveManager::_ResetSave(InstanceSaveHashMap::iterator &itr)
void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId) void InstanceSaveManager::_ResetInstance(uint32 mapid, uint32 instanceId)
{ {
sLog.outDebug("InstanceSaveMgr::_ResetInstance %u, %u", mapid, 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()) if(!map->Instanceable())
return; return;
@ -575,7 +575,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, bool warn, uint32 timeLe
{ {
// global reset for all instances of the given map // global reset for all instances of the given map
// note: this isn't fast but it's meant to be executed very rarely // 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()) if(!map->Instanceable())
return; return;
uint64 now = (uint64)time(NULL); uint64 now = (uint64)time(NULL);

View file

@ -2315,7 +2315,7 @@ bool ChatHandler::HandleGoXYCommand(const char* args)
else else
_player->SaveRecallPosition(); _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)); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());
@ -2408,7 +2408,7 @@ bool ChatHandler::HandleGoZoneXYCommand(const char* args)
// update to parent zone if exist (client map show only zones without parents) // update to parent zone if exist (client map show only zones without parents)
AreaTableEntry const* zoneEntry = areaEntry->zone ? GetAreaEntryByAreaID(areaEntry->zone) : areaEntry; 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()) if(map->Instanceable())
{ {
@ -2483,7 +2483,7 @@ bool ChatHandler::HandleGoGridCommand(const char* args)
else else
_player->SaveRecallPosition(); _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)); float z = std::max(map->GetHeight(x, y, MAX_HEIGHT), map->GetWaterLevel(x, y));
_player->TeleportTo(mapid, x, y, z, _player->GetOrientation()); _player->TeleportTo(mapid, x, y, z, _player->GetOrientation());

View file

@ -124,7 +124,7 @@ void Map::LoadMap(int gx,int gy, bool reload)
if(GridMaps[gx][gy]) if(GridMaps[gx][gy])
return; 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 // load grid map for base map
if (!baseMap->GridMaps[gx][gy]) if (!baseMap->GridMaps[gx][gy])
@ -422,10 +422,9 @@ template<class T>
void void
Map::Add(T *obj) Map::Add(T *obj)
{ {
CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
assert(obj); assert(obj);
CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP ) if(p.x_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP || p.y_coord >= TOTAL_NUMBER_OF_CELLS_PER_MAP )
{ {
sLog.outError("Map::Add: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord); sLog.outError("Map::Add: Object (GUID: %u TypeId: %u) have invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
@ -1022,7 +1021,7 @@ bool Map::UnloadGrid(const uint32 &x, const uint32 &y, bool pForce)
VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx); VMAP::VMapFactory::createOrGetVMapManager()->unloadMap(GetId(), gy, gx);
} }
else 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; GridMaps[gx][gy] = NULL;
} }
DEBUG_LOG("Unloading grid[%u,%u] for map %u finished", x,y, i_id); DEBUG_LOG("Unloading grid[%u,%u] for map %u finished", x,y, i_id);

View file

@ -39,7 +39,7 @@ class MANGOS_DLL_DECL MapInstanced : public Map
void UnloadAll(bool pForce); void UnloadAll(bool pForce);
Map* GetInstance(const WorldObject* obj); 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(uint32 InstanceId);
void DestroyInstance(InstancedMaps::iterator &itr); void DestroyInstance(InstancedMaps::iterator &itr);
@ -65,10 +65,9 @@ class MANGOS_DLL_DECL MapInstanced : public Map
InstancedMaps m_InstancedMaps; 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); return(i == m_InstancedMaps.end() ? NULL : i->second);
} }

View file

@ -98,7 +98,7 @@ void MapManager::checkAndCorrectGridStatesArray()
} }
Map* Map*
MapManager::_GetBaseMap(uint32 id) MapManager::_createBaseMap(uint32 id)
{ {
Map *m = _findMap(id); Map *m = _findMap(id);
@ -124,19 +124,24 @@ MapManager::_GetBaseMap(uint32 id)
Map* MapManager::GetMap(uint32 id, const WorldObject* obj) 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()); //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); if (m && obj && m->Instanceable()) m = ((MapInstanced*)m)->GetInstance(obj);
return m; return m;
} }
Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) Map* MapManager::FindMap(uint32 mapid, uint32 instanceId) const
{ {
Map *map = FindMap(mapid); Map *map = _findMap(mapid);
if(!map) return NULL; if(!map)
if(!map->Instanceable()) return instanceId == 0 ? map : NULL; return NULL;
if(!map->Instanceable())
return instanceId == 0 ? map : NULL;
return ((MapInstanced*)map)->FindMap(instanceId); return ((MapInstanced*)map)->FindMap(instanceId);
} }
@ -223,14 +228,14 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player)
void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId) void MapManager::DeleteInstance(uint32 mapid, uint32 instanceId)
{ {
Map *m = _GetBaseMap(mapid); Map *m = _createBaseMap(mapid);
if (m && m->Instanceable()) if (m && m->Instanceable())
((MapInstanced*)m)->DestroyInstance(instanceId); ((MapInstanced*)m)->DestroyInstance(instanceId);
} }
void MapManager::RemoveBonesFromMap(uint32 mapid, uint64 guid, float x, float y) 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) if (!remove_result)
{ {
@ -283,13 +288,6 @@ bool MapManager::IsValidMAP(uint32 mapid)
// TODO: add check for battleground template // TODO: add check for battleground template
} }
void MapManager::LoadGrid(int mapid, float x, float y, const WorldObject* obj, bool no_unload)
{
CellPair p = MaNGOS::ComputeCellPair(x,y);
Cell cell(p);
GetMap(mapid, obj)->LoadGrid(cell,no_unload);
}
void MapManager::UnloadAll() void MapManager::UnloadAll()
{ {
for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter) for(MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)

View file

@ -38,16 +38,15 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
public: public:
Map* GetMap(uint32, const WorldObject* obj); Map* GetMap(uint32, const WorldObject* obj);
Map* FindMap(uint32 mapid) { return _findMap(mapid); } Map const* CreateBaseMap(uint32 id) const { return const_cast<MapManager*>(this)->_createBaseMap(id); }
Map* FindMap(uint32 mapid, uint32 instanceId); Map* FindMap(uint32 mapid, uint32 instanceId = 0) const;
// only const version for outer users // 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); void DeleteInstance(uint32 mapid, uint32 instanceId);
uint16 GetAreaFlag(uint32 mapid, float x, float y, float z) const 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); return m->GetAreaFlag(x, y, z);
} }
uint32 GetAreaId(uint32 mapid, float x, float y, float z) const uint32 GetAreaId(uint32 mapid, float x, float y, float z) const
@ -83,7 +82,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
i_timer.Reset(); 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(); void UnloadAll();
static bool ExistMapAndVMap(uint32 mapid, float x, float y); static bool ExistMapAndVMap(uint32 mapid, float x, float y);
@ -106,7 +105,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
static bool IsValidMapCoord(WorldLocation const& loc) 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(); void DoDelayedMovesAndRemoves();
@ -140,7 +139,7 @@ class MANGOS_DLL_DECL MapManager : public MaNGOS::Singleton<MapManager, MaNGOS::
MapManager(const MapManager &); MapManager(const MapManager &);
MapManager& operator=(const MapManager &); MapManager& operator=(const MapManager &);
Map* _GetBaseMap(uint32 id); Map* _createBaseMap(uint32 id);
Map* _findMap(uint32 id) const Map* _findMap(uint32 id) const
{ {
MapMapType::const_iterator iter = i_maps.find(id); MapMapType::const_iterator iter = i_maps.find(id);

View file

@ -48,7 +48,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
WorldLocation &loc = GetPlayer()->GetTeleportDest(); WorldLocation &loc = GetPlayer()->GetTeleportDest();
// possible errors in the coordinate validity check // 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); LogoutPlayer(false);
return; return;
@ -66,7 +66,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// relocate the player to the teleport destination // relocate the player to the teleport destination
GetPlayer()->SetMapId(loc.mapid); 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 // 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 // to let GetInstance() determine the proper InstanceId based on the player's binds
@ -77,7 +77,7 @@ void WorldSession::HandleMoveWorldportAckOpcode()
// 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(!GetPlayer()->GetMap()->Add(GetPlayer())) 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 // teleport the player home
if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation())) if(!GetPlayer()->TeleportTo(GetPlayer()->m_homebindMapId, GetPlayer()->m_homebindX, GetPlayer()->m_homebindY, GetPlayer()->m_homebindZ, GetPlayer()->GetOrientation()))
{ {
@ -184,7 +184,7 @@ void WorldSession::HandleMoveTeleportAck(WorldPacket& recv_data)
WorldLocation const& dest = plMover->GetTeleportDest(); 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; uint32 newzone, newarea;
plMover->GetZoneAndAreaId(newzone, newarea); plMover->GetZoneAndAreaId(newzone, newarea);

View file

@ -1063,17 +1063,17 @@ void WorldObject::_Create( uint32 guidlow, HighGuid guidhigh, uint32 mapid, uint
uint32 WorldObject::GetZoneId() const 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 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 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() InstanceData* WorldObject::GetInstanceData()
@ -1345,7 +1345,7 @@ void WorldObject::GetRandomPoint( float x, float y, float z, float distance, flo
void WorldObject::UpdateGroundPositionZ(float x, float y, float &z) const 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) if(new_z > INVALID_HEIGHT)
z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface z = new_z+ 0.05f; // just to be sure that we are not a few pixel under the surface
} }
@ -1578,7 +1578,7 @@ Map* WorldObject::GetMap() const
Map const* WorldObject::GetBaseMap() const Map const* WorldObject::GetBaseMap() const
{ {
return MapManager::Instance().GetBaseMap(GetMapId()); return MapManager::Instance().CreateBaseMap(GetMapId());
} }
void WorldObject::AddObjectToRemoveList() void WorldObject::AddObjectToRemoveList()

View file

@ -98,14 +98,14 @@ typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
struct WorldLocation struct WorldLocation
{ {
uint32 mapid; uint32 mapid;
float x; float coord_x;
float y; float coord_y;
float z; float coord_z;
float o; float orientation;
explicit WorldLocation(uint32 _mapid = 0, float _x = 0, float _y = 0, float _z = 0, float _o = 0) 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) 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) {}
}; };
class MANGOS_DLL_SPEC Object class MANGOS_DLL_SPEC Object
@ -363,12 +363,6 @@ class MANGOS_DLL_SPEC WorldObject : public Object
m_positionZ = z; m_positionZ = z;
} }
void Relocate(WorldLocation const & loc)
{
SetMapId(loc.mapid);
Relocate(loc.x, loc.y, loc.z, loc.o);
}
void SetOrientation(float orientation) { m_orientation = orientation; } void SetOrientation(float orientation) { m_orientation = orientation; }
float GetPositionX( ) const { return m_positionX; } float GetPositionX( ) const { return m_positionX; }
@ -377,7 +371,7 @@ class MANGOS_DLL_SPEC WorldObject : public Object
void GetPosition( float &x, float &y, float &z ) const void GetPosition( float &x, float &y, float &z ) const
{ x = m_positionX; y = m_positionY; z = m_positionZ; } { x = m_positionX; y = m_positionY; z = m_positionZ; }
void GetPosition( WorldLocation &loc ) const 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(); }
float GetOrientation( ) const { return m_orientation; } float GetOrientation( ) const { return m_orientation; }
void GetNearPoint2D( float &x, float &y, float distance, float absAngle) const; 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; void GetNearPoint( WorldObject const* searcher, float &x, float &y, float &z, float searcher_size, float distance2d,float absAngle) const;

View file

@ -2042,7 +2042,7 @@ GameObject* Player::GetGameObjectIfCanInteractWith(uint64 guid, GameobjectTypes
bool Player::IsUnderWater() const bool Player::IsUnderWater() const
{ {
return IsInWater() && return IsInWater() &&
GetPositionZ() < (MapManager::Instance().GetBaseMap(GetMapId())->GetWaterLevel(GetPositionX(),GetPositionY())-2); GetPositionZ() < (GetBaseMap()->GetWaterLevel(GetPositionX(),GetPositionY())-2);
} }
void Player::SetInWater(bool apply) void Player::SetInWater(bool apply)
@ -5623,7 +5623,7 @@ void Player::CheckExploreSystem()
if (isInFlight()) if (isInFlight())
return; return;
uint16 areaFlag=MapManager::Instance().GetBaseMap(GetMapId())->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ()); uint16 areaFlag = GetBaseMap()->GetAreaFlag(GetPositionX(),GetPositionY(),GetPositionZ());
if(areaFlag==0xffff) if(areaFlag==0xffff)
return; return;
int offset = areaFlag / 32; int offset = areaFlag / 32;
@ -14061,7 +14061,9 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
} }
else else
{ {
Relocate(GetBattleGroundEntryPoint()); const WorldLocation& _loc = GetBattleGroundEntryPoint();
SetMapId(_loc.mapid);
Relocate(_loc.coord_x, _loc.coord_y, _loc.coord_z, _loc.orientation);
//RemoveArenaAuras(true); //RemoveArenaAuras(true);
} }
} }
@ -14173,7 +14175,7 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
if(at) if(at)
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation); Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
else 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(); SaveRecallPosition();
@ -15428,10 +15430,10 @@ void Player::SaveToDB()
{ {
ss << GetTeleportDest().mapid << ", " ss << GetTeleportDest().mapid << ", "
<< (uint32)GetDifficulty() << ", " << (uint32)GetDifficulty() << ", "
<< finiteAlways(GetTeleportDest().x) << ", " << finiteAlways(GetTeleportDest().coord_x) << ", "
<< finiteAlways(GetTeleportDest().y) << ", " << finiteAlways(GetTeleportDest().coord_y) << ", "
<< finiteAlways(GetTeleportDest().z) << ", " << finiteAlways(GetTeleportDest().coord_z) << ", "
<< finiteAlways(GetTeleportDest().o) << ", '"; << finiteAlways(GetTeleportDest().orientation) << ", '";
} }
uint16 i; uint16 i;
@ -15503,10 +15505,10 @@ void Player::SaveToDB()
ss << GetBGTeam(); ss << GetBGTeam();
ss << ", "; ss << ", ";
ss << m_bgEntryPoint.mapid << ", " ss << m_bgEntryPoint.mapid << ", "
<< finiteAlways(m_bgEntryPoint.x) << ", " << finiteAlways(m_bgEntryPoint.coord_x) << ", "
<< finiteAlways(m_bgEntryPoint.y) << ", " << finiteAlways(m_bgEntryPoint.coord_y) << ", "
<< finiteAlways(m_bgEntryPoint.z) << ", " << finiteAlways(m_bgEntryPoint.coord_z) << ", "
<< finiteAlways(m_bgEntryPoint.o); << finiteAlways(m_bgEntryPoint.orientation);
ss << ")"; ss << ")";
CharacterDatabase.Execute( ss.str().c_str() ); CharacterDatabase.Execute( ss.str().c_str() );

View file

@ -884,7 +884,7 @@ class MANGOS_DLL_SPEC Player : public Unit
bool TeleportTo(WorldLocation const &loc, uint32 options = 0) 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) void SetSummonPoint(uint32 mapid, float x, float y, float z)

View file

@ -233,7 +233,7 @@ bool PoolGroup<Creature>::Spawn1Object(uint32 guid)
objmgr.AddCreatureToGrid(guid, data); objmgr.AddCreatureToGrid(guid, data);
// Spawn if necessary (loaded grids only) // 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 // We use spawn coords to spawn
if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY)) if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
{ {
@ -263,7 +263,7 @@ bool PoolGroup<GameObject>::Spawn1Object(uint32 guid)
objmgr.AddGameobjectToGrid(guid, data); objmgr.AddGameobjectToGrid(guid, data);
// Spawn if necessary (loaded grids only) // Spawn if necessary (loaded grids only)
// this base map checked as non-instanced and then only existed // 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 // We use current coords to unspawn, not spawn coords since creature can have changed grid
if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY)) if (!map->Instanceable() && !map->IsRemovalGrid(data->posX, data->posY))
{ {

View file

@ -306,7 +306,7 @@ void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
if(corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0) if(corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0)
{ {
// if corpse map have entrance // 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; mapid = corpseMapEntry->entrance_map;
x = corpseMapEntry->entrance_x; x = corpseMapEntry->entrance_x;

View file

@ -34,8 +34,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
creature.GetRespawnCoord(X, Y, Z, &ori, &wander_distance); creature.GetRespawnCoord(X, Y, Z, &ori, &wander_distance);
z = creature.GetPositionZ(); z = creature.GetPositionZ();
uint32 mapid=creature.GetMapId(); Map const* map = creature.GetBaseMap();
Map const* map = MapManager::Instance().GetBaseMap(mapid);
// For 2D/3D system selection // For 2D/3D system selection
//bool is_land_ok = creature.canWalk(); // not used? //bool is_land_ok = creature.canWalk(); // not used?

View file

@ -4396,7 +4396,7 @@ SpellCastResult Spell::CheckCast(bool strict)
float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation()); float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation());
float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation()); float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation());
// teleport a bit above terrain level to avoid falling below it // teleport a bit above terrain level to avoid falling below it
float fz = MapManager::Instance().GetBaseMap(m_caster->GetMapId())->GetHeight(fx,fy,m_caster->GetPositionZ(),true); float fz = m_caster->GetBaseMap()->GetHeight(fx,fy,m_caster->GetPositionZ(),true);
if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled if(fz <= INVALID_HEIGHT) // note: this also will prevent use effect in instances without vmaps height enabled
return SPELL_FAILED_TRY_AGAIN; return SPELL_FAILED_TRY_AGAIN;

View file

@ -2742,7 +2742,7 @@ void Spell::EffectPersistentAA(uint32 i)
dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003); dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003);
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee); dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee);
m_caster->AddDynObject(dynObj); m_caster->AddDynObject(dynObj);
dynObj->GetMap()->Add(dynObj); m_caster->GetMap()->Add(dynObj);
} }
void Spell::EffectEnergize(uint32 i) void Spell::EffectEnergize(uint32 i)
@ -3536,7 +3536,7 @@ void Spell::EffectAddFarsight(uint32 i)
dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65);
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002);
m_caster->AddDynObject(dynObj); m_caster->AddDynObject(dynObj);
dynObj->GetMap()->Add(dynObj); m_caster->GetMap()->Add(dynObj);
if(m_caster->GetTypeId() == TYPEID_PLAYER) if(m_caster->GetTypeId() == TYPEID_PLAYER)
((Player*)m_caster)->SetFarSightGUID(dynObj->GetGUID()); ((Player*)m_caster)->SetFarSightGUID(dynObj->GetGUID());
} }

View file

@ -3229,12 +3229,12 @@ bool Unit::isInAccessablePlaceFor(Creature const* c) const
bool Unit::IsInWater() const bool Unit::IsInWater() const
{ {
return MapManager::Instance().GetBaseMap(GetMapId())->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ()); return GetBaseMap()->IsInWater(GetPositionX(),GetPositionY(), GetPositionZ());
} }
bool Unit::IsUnderWater() const bool Unit::IsUnderWater() const
{ {
return MapManager::Instance().GetBaseMap(GetMapId())->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ()); return GetBaseMap()->IsUnderWater(GetPositionX(),GetPositionY(),GetPositionZ());
} }
void Unit::DeMorph() void Unit::DeMorph()

View file

@ -118,7 +118,7 @@ void WaypointManager::Load()
MaNGOS::NormalizeMapCoord(node.y); MaNGOS::NormalizeMapCoord(node.y);
if(result1) if(result1)
{ {
node.z = MapManager::Instance ().GetBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z); node.z = MapManager::Instance ().CreateBaseMap(result1->Fetch()[1].GetUInt32())->GetHeight(node.x, node.y, node.z);
delete result1; delete result1;
} }
WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point); WorldDatabase.PExecute("UPDATE creature_movement SET position_x = '%f', position_y = '%f', position_z = '%f' WHERE id = '%u' AND point = '%u'", node.x, node.y, node.z, id, point);

View file

@ -249,7 +249,7 @@ void FlightPathMovementGenerator::Finalize(Player & player)
player.clearUnitState(UNIT_STAT_IN_FLIGHT); player.clearUnitState(UNIT_STAT_IN_FLIGHT);
float x, y, z; 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()); player.SetPosition(x, y, z, player.GetOrientation());
player.Unmount(); player.Unmount();

View file

@ -34,6 +34,7 @@
#include "World.h" #include "World.h"
#include "ObjectAccessor.h" #include "ObjectAccessor.h"
#include "BattleGroundMgr.h" #include "BattleGroundMgr.h"
#include "MapManager.h"
#include "SocialMgr.h" #include "SocialMgr.h"
#include "zlib/zlib.h" #include "zlib/zlib.h"

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "8025" #define REVISION_NR "8026"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__