mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +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
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue