mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +00:00
[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:
parent
1187c8698c
commit
b76c4c2f3c
29 changed files with 99 additions and 99 deletions
|
|
@ -31,9 +31,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;
|
||||
|
||||
|
|
|
|||
|
|
@ -182,8 +182,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)
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
#include "Timer.h"
|
||||
|
||||
class WorldObject;
|
||||
class Map;
|
||||
|
||||
#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 UpdateTraveller(TRAVELLER &traveller, uint32 diff, bool force_update=false, 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;
|
||||
|
||||
|
|
|
|||
|
|
@ -126,9 +126,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;
|
||||
|
|
@ -158,7 +158,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() )
|
||||
{
|
||||
|
|
@ -180,8 +180,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;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -517,7 +517,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))
|
||||
{
|
||||
|
|
@ -550,7 +550,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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -69,8 +69,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -558,7 +558,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;
|
||||
|
||||
|
|
@ -575,7 +575,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);
|
||||
|
|
|
|||
|
|
@ -2315,7 +2315,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());
|
||||
|
|
@ -2408,7 +2408,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())
|
||||
{
|
||||
|
|
@ -2483,7 +2483,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());
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,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])
|
||||
|
|
@ -422,10 +422,9 @@ template<class T>
|
|||
void
|
||||
Map::Add(T *obj)
|
||||
{
|
||||
CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY());
|
||||
|
||||
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 )
|
||||
{
|
||||
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);
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class MANGOS_DLL_DECL MapInstanced : public Map
|
|||
void UnloadAll(bool pForce);
|
||||
|
||||
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);
|
||||
|
||||
|
|
@ -65,10 +65,9 @@ class MANGOS_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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ void MapManager::checkAndCorrectGridStatesArray()
|
|||
}
|
||||
|
||||
Map*
|
||||
MapManager::_GetBaseMap(uint32 id)
|
||||
MapManager::_createBaseMap(uint32 id)
|
||||
{
|
||||
Map *m = _findMap(id);
|
||||
|
||||
|
|
@ -124,19 +124,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);
|
||||
}
|
||||
|
||||
|
|
@ -223,14 +228,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)
|
||||
{
|
||||
|
|
@ -283,13 +288,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 = MaNGOS::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)
|
||||
|
|
|
|||
|
|
@ -38,16 +38,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
|
||||
|
|
@ -83,7 +82,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);
|
||||
|
|
@ -106,7 +105,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();
|
||||
|
|
@ -140,7 +139,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);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,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;
|
||||
|
|
@ -66,7 +66,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
|
||||
|
|
@ -77,7 +77,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()))
|
||||
{
|
||||
|
|
@ -184,7 +184,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);
|
||||
|
|
|
|||
|
|
@ -1063,17 +1063,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()
|
||||
|
|
@ -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
|
||||
{
|
||||
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
|
||||
}
|
||||
|
|
@ -1578,7 +1578,7 @@ Map* WorldObject::GetMap() const
|
|||
|
||||
Map const* WorldObject::GetBaseMap() const
|
||||
{
|
||||
return MapManager::Instance().GetBaseMap(GetMapId());
|
||||
return MapManager::Instance().CreateBaseMap(GetMapId());
|
||||
}
|
||||
|
||||
void WorldObject::AddObjectToRemoveList()
|
||||
|
|
|
|||
|
|
@ -98,14 +98,14 @@ 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) {}
|
||||
};
|
||||
|
||||
class MANGOS_DLL_SPEC Object
|
||||
|
|
@ -363,12 +363,6 @@ class MANGOS_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 SetOrientation(float orientation) { m_orientation = orientation; }
|
||||
|
||||
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
|
||||
{ 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(); }
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -2042,7 +2042,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)
|
||||
|
|
@ -5623,7 +5623,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;
|
||||
|
|
@ -14061,7 +14061,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);
|
||||
}
|
||||
}
|
||||
|
|
@ -14173,7 +14175,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();
|
||||
|
|
@ -15428,10 +15430,10 @@ void Player::SaveToDB()
|
|||
{
|
||||
ss << GetTeleportDest().mapid << ", "
|
||||
<< (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;
|
||||
|
|
@ -15503,10 +15505,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() );
|
||||
|
|
|
|||
|
|
@ -884,7 +884,7 @@ class MANGOS_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)
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -306,7 +306,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;
|
||||
|
|
|
|||
|
|
@ -34,8 +34,7 @@ RandomMovementGenerator<Creature>::_setRandomLocation(Creature &creature)
|
|||
creature.GetRespawnCoord(X, Y, Z, &ori, &wander_distance);
|
||||
|
||||
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(); // not used?
|
||||
|
|
|
|||
|
|
@ -4396,7 +4396,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
|||
float fx = m_caster->GetPositionX() + dis * cos(m_caster->GetOrientation());
|
||||
float fy = m_caster->GetPositionY() + dis * sin(m_caster->GetOrientation());
|
||||
// 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
|
||||
return SPELL_FAILED_TRY_AGAIN;
|
||||
|
||||
|
|
|
|||
|
|
@ -2742,7 +2742,7 @@ void Spell::EffectPersistentAA(uint32 i)
|
|||
dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003);
|
||||
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee);
|
||||
m_caster->AddDynObject(dynObj);
|
||||
dynObj->GetMap()->Add(dynObj);
|
||||
m_caster->GetMap()->Add(dynObj);
|
||||
}
|
||||
|
||||
void Spell::EffectEnergize(uint32 i)
|
||||
|
|
@ -3536,7 +3536,7 @@ void Spell::EffectAddFarsight(uint32 i)
|
|||
dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65);
|
||||
dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002);
|
||||
m_caster->AddDynObject(dynObj);
|
||||
dynObj->GetMap()->Add(dynObj);
|
||||
m_caster->GetMap()->Add(dynObj);
|
||||
if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)m_caster)->SetFarSightGUID(dynObj->GetGUID());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,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;
|
||||
|
|
|
|||
|
|
@ -3229,12 +3229,12 @@ bool Unit::isInAccessablePlaceFor(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()
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ void WaypointManager::Load()
|
|||
MaNGOS::NormalizeMapCoord(node.y);
|
||||
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;
|
||||
}
|
||||
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);
|
||||
|
|
|
|||
|
|
@ -249,7 +249,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());
|
||||
|
||||
player.Unmount();
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
#include "World.h"
|
||||
#include "ObjectAccessor.h"
|
||||
#include "BattleGroundMgr.h"
|
||||
#include "MapManager.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "zlib/zlib.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8025"
|
||||
#define REVISION_NR "8026"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue