From fc0e3e87a8ca0143b5befd6577467147b36f099a Mon Sep 17 00:00:00 2001 From: ApoC Date: Mon, 17 Nov 2008 12:25:04 +0100 Subject: [PATCH 1/5] [6834] Fixed typo in Unit::RemoveAura leading to crash. Signed-off-by: ApoC --- src/game/Unit.cpp | 2 +- src/shared/revision_nr.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 4bd6e5fe8..1517578bc 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -4105,7 +4105,7 @@ void Unit::RemoveAura(AuraMap::iterator &i, AuraRemoveMode mode) if (IsSingleTargetSpell(AurSpellInfo)) { caster = Aur->GetCaster(); - if(!caster) + if(caster) { AuraList& scAuras = caster->GetSingleCastAuras(); scAuras.remove(Aur); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 1cf8f518c..5fa461f5f 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6833" + #define REVISION_NR "6834" #endif // __REVISION_NR_H__ From 5439dd0fd4ff0806a7e505a7e316e2ff0d2ce5ea Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 17 Nov 2008 14:54:12 +0300 Subject: [PATCH 2/5] Allow constant only access to m_mapRefManager using Map::GetPlayers() --- src/game/Map.cpp | 4 ++-- src/game/Map.h | 10 +++++----- src/game/MapManager.cpp | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/game/Map.cpp b/src/game/Map.cpp index 59c99e61a..606d53df6 100644 --- a/src/game/Map.cpp +++ b/src/game/Map.cpp @@ -1783,9 +1783,9 @@ void InstanceMap::UnloadAll(bool pForce) Map::UnloadAll(pForce); } -void InstanceMap::SendResetWarnings(uint32 timeLeft) +void InstanceMap::SendResetWarnings(uint32 timeLeft) const { - for(MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) + for(MapRefManager::const_iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr) itr->getSource()->SendInstanceResetWarning(GetId(), timeLeft); } diff --git a/src/game/Map.h b/src/game/Map.h index b3f85215b..d24523e84 100644 --- a/src/game/Map.h +++ b/src/game/Map.h @@ -125,6 +125,7 @@ typedef UNORDERED_MAP CreatureMoveList; class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::ObjectLevelLockable { + friend class MapReference; public: Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); virtual ~Map(); @@ -240,8 +241,8 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj void SendToPlayers(WorldPacket const* data) const; - MapRefManager m_mapRefManager; - + typedef MapRefManager PlayerList; + PlayerList const& GetPlayers() const { return m_mapRefManager; } private: void LoadVMap(int pX, int pY); void LoadMap(uint32 mapid, uint32 instanceid, int x,int y); @@ -290,6 +291,7 @@ class MANGOS_DLL_SPEC Map : public GridRefManager, public MaNGOS::Obj uint32 i_InstanceId; uint32 m_unloadTimer; + MapRefManager m_mapRefManager; private: typedef GridReadGuard ReadGuard; typedef GridWriteGuard WriteGuard; @@ -329,8 +331,6 @@ enum InstanceResetMethod class MANGOS_DLL_SPEC InstanceMap : public Map { public: - typedef std::list PlayerList; // online players only - InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode); ~InstanceMap(); bool Add(Player *); @@ -344,7 +344,7 @@ class MANGOS_DLL_SPEC InstanceMap : public Map time_t GetResetTime(); void UnloadAll(bool pForce); bool CanEnter(Player* player); - void SendResetWarnings(uint32 timeLeft); + void SendResetWarnings(uint32 timeLeft) const; void SetResetSchedule(bool on); private: bool m_resetAfterUnload; diff --git a/src/game/MapManager.cpp b/src/game/MapManager.cpp index bf2239e6e..8833b8322 100644 --- a/src/game/MapManager.cpp +++ b/src/game/MapManager.cpp @@ -336,7 +336,7 @@ uint32 MapManager::GetNumPlayersInInstances() MapInstanced::InstancedMaps &maps = ((MapInstanced *)map)->GetInstancedMaps(); for(MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr) if(mitr->second->IsDungeon()) - ret += ((InstanceMap*)mitr->second)->m_mapRefManager.getSize(); + ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize(); } return ret; } From 2a3c3195b78350e540017cf9451ceaf809df9f89 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 17 Nov 2008 14:55:37 +0300 Subject: [PATCH 3/5] [6835] Check instanceid at search creature by guid. --- src/game/ObjectAccessor.cpp | 10 +++++++++- src/shared/revision_nr.h | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index 26b5be0e4..a9954dcec 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -140,7 +140,15 @@ Creature* ObjectAccessor::GetCreature(WorldObject const &u, uint64 guid) { Creature * ret = GetObjectInWorld(guid, (Creature*)NULL); - if(ret && ret->GetMapId() != u.GetMapId()) ret = NULL; + if(!ret) + return NULL; + + if(ret->GetMapId() != u.GetMapId()) + return NULL; + + if(ret->GetInstanceId() != u.GetInstanceId()) + return NULL; + return ret; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 5fa461f5f..8c3c86f2e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6834" + #define REVISION_NR "6835" #endif // __REVISION_NR_H__ From c37cfd0c2f9043baee6e06bbea9196f88e4b5c40 Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Mon, 17 Nov 2008 17:55:58 +0300 Subject: [PATCH 4/5] [6836] Use /bigobj option in VC80/VC90 x64 builds for game.vcproj buuld. This will solve problems with fatal error (too many sections in ObjectMrg.obj). --- src/shared/revision_nr.h | 2 +- win/VC80/game.vcproj | 8 ++++---- win/VC90/game.vcproj | 9 +++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index 8c3c86f2e..b00550a9b 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "6835" + #define REVISION_NR "6836" #endif // __REVISION_NR_H__ diff --git a/win/VC80/game.vcproj b/win/VC80/game.vcproj index 37fcfc736..ecbb21223 100644 --- a/win/VC80/game.vcproj +++ b/win/VC80/game.vcproj @@ -125,7 +125,7 @@ /> Date: Sun, 16 Nov 2008 12:11:45 +0100 Subject: [PATCH 5/5] Replace some MapManager::Instance().GetMap() calls with WorldObject::GetMap() --- src/game/CharacterHandler.cpp | 2 +- src/game/Chat.cpp | 2 +- src/game/Creature.cpp | 6 ++-- src/game/DynamicObject.cpp | 4 +-- src/game/GameObject.cpp | 14 ++++----- src/game/Level1.cpp | 12 ++++---- src/game/Level2.cpp | 14 ++++----- src/game/Level3.cpp | 2 +- src/game/MovementHandler.cpp | 2 +- src/game/Object.cpp | 10 +++---- src/game/ObjectAccessor.cpp | 6 ++-- src/game/ObjectGridLoader.cpp | 2 +- src/game/Player.cpp | 16 +++++------ src/game/Spell.cpp | 54 +++++++++++++++++------------------ src/game/SpellAuras.cpp | 8 +++--- src/game/SpellEffects.cpp | 22 +++++++------- src/game/TemporarySummon.cpp | 2 +- src/game/TotemAI.cpp | 4 +-- src/game/Transports.cpp | 6 ++-- src/game/Traveller.h | 4 +-- src/game/Unit.cpp | 6 ++-- src/game/World.cpp | 10 +++---- src/game/WorldSession.cpp | 2 +- 23 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/game/CharacterHandler.cpp b/src/game/CharacterHandler.cpp index 0d55aa001..33f653dae 100644 --- a/src/game/CharacterHandler.cpp +++ b/src/game/CharacterHandler.cpp @@ -607,7 +607,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder * holder) pCurrChar->SetRank(0); } - if (!MapManager::Instance().GetMap(pCurrChar->GetMapId(), pCurrChar)->Add(pCurrChar)) + if (!pCurrChar->GetMap()->Add(pCurrChar)) { AreaTrigger const* at = objmgr.GetGoBackTrigger(pCurrChar->GetMapId()); if(at) diff --git a/src/game/Chat.cpp b/src/game/Chat.cpp index 0eaaeabc4..fcfe47891 100644 --- a/src/game/Chat.cpp +++ b/src/game/Chat.cpp @@ -1173,7 +1173,7 @@ GameObject* ChatHandler::GetObjectGlobalyWithGuidOrNearWithDbGuid(uint32 lowguid TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); + cell_lock->Visit(cell_lock, object_checker, *pl->GetMap()); } return obj; diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 256f7bb1d..e5d5a48fe 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -149,7 +149,7 @@ void Creature::RemoveCorpse() float x,y,z,o; GetRespawnCoord(x, y, z, &o); - MapManager::Instance().GetMap(GetMapId(), this)->CreatureRelocation(this,x,y,z,o); + GetMap()->CreatureRelocation(this,x,y,z,o); } /** @@ -337,7 +337,7 @@ void Creature::Update(uint32 diff) //Call AI respawn virtual function i_AI->JustRespawned(); - MapManager::Instance().GetMap(GetMapId(), this)->Add(this); + GetMap()->Add(this); } break; } @@ -1686,7 +1686,7 @@ void Creature::CallAssistence() TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, grid_creature_searcher, *GetMap()); } for(std::list::iterator iter = assistList.begin(); iter != assistList.end(); ++iter) diff --git a/src/game/DynamicObject.cpp b/src/game/DynamicObject.cpp index 86d621905..7e6d2a88f 100644 --- a/src/game/DynamicObject.cpp +++ b/src/game/DynamicObject.cpp @@ -122,8 +122,8 @@ void DynamicObject::Update(uint32 p_time) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, world_object_notifier, *GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *GetMap()); if(deleteThis) { diff --git a/src/game/GameObject.cpp b/src/game/GameObject.cpp index 116085b92..a1677f972 100644 --- a/src/game/GameObject.cpp +++ b/src/game/GameObject.cpp @@ -258,7 +258,7 @@ void GameObject::Update(uint32 /*p_time*/) return; } // respawn timer - MapManager::Instance().GetMap(GetMapId(), this)->Add(this); + GetMap()->Add(this); break; } } @@ -309,13 +309,13 @@ void GameObject::Update(uint32 /*p_time*/) CellLock cell_lock(cell, p); TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); - cell_lock->Visit(cell_lock, grid_object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, grid_object_checker, *GetMap()); // or unfriendly player/pet if(!ok) { TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); - cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, world_object_checker, *GetMap()); } } else // environmental trap @@ -330,7 +330,7 @@ void GameObject::Update(uint32 /*p_time*/) CellLock cell_lock(cell, p); TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); - cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, world_object_checker, *GetMap()); ok = p_ok; } @@ -444,7 +444,7 @@ void GameObject::Refresh() return; if(isSpawned()) - MapManager::Instance().GetMap(GetMapId(), this)->Add(this); + GetMap()->Add(this); } void GameObject::AddUniqueUse(Player* player) @@ -787,7 +787,7 @@ void GameObject::TriggeringLinkedGameObject( uint32 trapEntry, Unit* target) TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, object_checker, *GetMap()); } // found correct GO @@ -809,7 +809,7 @@ GameObject* GameObject::LookupFishingHoleAround(float range) CellLock cell_lock(cell, p); TypeContainerVisitor, GridTypeMapContainer > grid_object_checker(checker); - cell_lock->Visit(cell_lock, grid_object_checker, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, grid_object_checker, *GetMap()); return ok; } diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp index 3bb2475cd..5730ad1d6 100644 --- a/src/game/Level1.cpp +++ b/src/game/Level1.cpp @@ -288,7 +288,7 @@ bool ChatHandler::HandleGPSCommand(const char* args) Map2ZoneCoordinates(zone_x,zone_y,zone_id); - Map const *map = MapManager::Instance().GetMap(obj->GetMapId(), obj); + Map const *map = obj->GetMap(); float ground_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), MAX_HEIGHT); float floor_z = map->GetHeight(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ()); @@ -349,11 +349,11 @@ bool ChatHandler::HandleNamegoCommand(const char* args) return false; } - Map* pMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); + Map* pMap = m_session->GetPlayer()->GetMap(); if(pMap->Instanceable()) { - Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); + Map* cMap = chr->GetMap(); if( cMap->Instanceable() && cMap->GetInstanceId() != pMap->GetInstanceId() ) { // cannot summon from instance to instance @@ -435,7 +435,7 @@ bool ChatHandler::HandleGonameCommand(const char* args) Player *chr = objmgr.GetPlayer(name.c_str()); if (chr) { - Map* cMap = MapManager::Instance().GetMap(chr->GetMapId(),chr); + Map* cMap = chr->GetMap(); if(cMap->Instanceable()) { // we have to go to instance, and can go to player only if: @@ -2058,7 +2058,7 @@ bool ChatHandler::HandleGroupgoCommand(const char* args) return false; } - Map* gmMap = MapManager::Instance().GetMap(m_session->GetPlayer()->GetMapId(),m_session->GetPlayer()); + Map* gmMap = m_session->GetPlayer()->GetMap(); bool to_instance = gmMap->Instanceable(); // we are in instance, and can summon only player in our group with us as lead @@ -2088,7 +2088,7 @@ bool ChatHandler::HandleGroupgoCommand(const char* args) if (to_instance) { - Map* plMap = MapManager::Instance().GetMap(pl->GetMapId(),pl); + Map* plMap = pl->GetMap(); if ( plMap->Instanceable() && plMap->GetInstanceId() != gmMap->GetInstanceId() ) { diff --git a/src/game/Level2.cpp b/src/game/Level2.cpp index f22458b26..e8862f0ca 100644 --- a/src/game/Level2.cpp +++ b/src/game/Level2.cpp @@ -1056,7 +1056,7 @@ bool ChatHandler::HandleTurnObjectCommand(const char* args) float rot2 = sin(o/2); float rot3 = cos(o/2); - Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); + Map* map = obj->GetMap(); map->Remove(obj,false); obj->Relocate(obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), o); @@ -1140,7 +1140,7 @@ bool ChatHandler::HandleNpcMoveCommand(const char* args) const_cast(data)->posZ = z; const_cast(data)->orientation = o; } - MapManager::Instance().GetMap(pCreature->GetMapId(),pCreature)->CreatureRelocation(pCreature,x, y, z,o); + pCreature->GetMap()->CreatureRelocation(pCreature,x, y, z,o); pCreature->GetMotionMaster()->Initialize(); if(pCreature->isAlive()) // dead creature will reset movement generator at respawn { @@ -1187,7 +1187,7 @@ bool ChatHandler::HandleMoveObjectCommand(const char* args) { Player *chr = m_session->GetPlayer(); - Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); + Map* map = obj->GetMap(); map->Remove(obj,false); obj->Relocate(chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ(), obj->GetOrientation()); @@ -1213,7 +1213,7 @@ bool ChatHandler::HandleMoveObjectCommand(const char* args) return false; } - Map* map = MapManager::Instance().GetMap(obj->GetMapId(),obj); + Map* map = obj->GetMap(); map->Remove(obj,false); obj->Relocate(x, y, z, obj->GetOrientation()); @@ -2675,7 +2675,7 @@ bool ChatHandler::HandleWpModifyCommand(const char* args) // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); wpCreature2->LoadFromDB(wpCreature2->GetDBTableGUIDLow(), map); map->Add(wpCreature2); - //MapManager::Instance().GetMap(npcCreature->GetMapId())->Add(wpCreature2); + //npcCreature->GetMap()->Add(wpCreature2); } WaypointMgr.SetNodePosition(lowguid, point, chr->GetPositionX(), chr->GetPositionY(), chr->GetPositionZ()); @@ -2985,7 +2985,7 @@ bool ChatHandler::HandleWpShowCommand(const char* args) // To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells(); wpCreature->LoadFromDB(wpCreature->GetDBTableGUIDLow(),map); map->Add(wpCreature); - //MapManager::Instance().GetMap(wpCreature->GetMapId())->Add(wpCreature); + //wpCreature->GetMap()->Add(wpCreature); }while( result->NextRow() ); // Cleanup memory @@ -4164,7 +4164,7 @@ bool ChatHandler::HandleNpcTameCommand(const char* /*args*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); // add to world - MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); + pet->GetMap()->Add((Creature*)pet); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); diff --git a/src/game/Level3.cpp b/src/game/Level3.cpp index f10c9c96f..125a6609d 100644 --- a/src/game/Level3.cpp +++ b/src/game/Level3.cpp @@ -5413,7 +5413,7 @@ bool ChatHandler::HandleRespawnCommand(const char* /*args*/) TypeContainerVisitor, GridTypeMapContainer > obj_worker(worker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, obj_worker, *MapManager::Instance().GetMap(pl->GetMapId(), pl)); + cell_lock->Visit(cell_lock, obj_worker, *pl->GetMap()); return true; } diff --git a/src/game/MovementHandler.cpp b/src/game/MovementHandler.cpp index a171e7b9a..448d184e5 100644 --- a/src/game/MovementHandler.cpp +++ b/src/game/MovementHandler.cpp @@ -72,7 +72,7 @@ void WorldSession::HandleMoveWorldportAckOpcode() GetPlayer()->SendInitialPacketsBeforeAddToMap(); // the CanEnter checks are done in TeleporTo but conditions may change // while the player is in transit, for example the map may get full - if(!MapManager::Instance().GetMap(GetPlayer()->GetMapId(), GetPlayer())->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); // teleport the player home diff --git a/src/game/Object.cpp b/src/game/Object.cpp index 24ce65ded..41709664b 100644 --- a/src/game/Object.cpp +++ b/src/game/Object.cpp @@ -976,7 +976,7 @@ uint32 WorldObject::GetAreaId() const InstanceData* WorldObject::GetInstanceData() { - Map *map = MapManager::Instance().GetMap(m_mapId, this); + Map *map = GetMap(); return map->IsDungeon() ? ((InstanceMap*)map)->GetInstanceData() : NULL; } @@ -1347,12 +1347,12 @@ void WorldObject::BuildTeleportAckMsg(WorldPacket *data, float x, float y, float void WorldObject::SendMessageToSet(WorldPacket *data, bool /*bToSelf*/) { - MapManager::Instance().GetMap(m_mapId, this)->MessageBroadcast(this, data); + GetMap()->MessageBroadcast(this, data); } void WorldObject::SendMessageToSetInRange(WorldPacket *data, float dist, bool /*bToSelf*/) { - MapManager::Instance().GetMap(m_mapId, this)->MessageDistBroadcast(this, data, dist); + GetMap()->MessageDistBroadcast(this, data, dist); } void WorldObject::SendObjectDeSpawnAnim(uint64 guid) @@ -1541,8 +1541,8 @@ void WorldObject::GetNearPoint(WorldObject const* searcher, float &x, float &y, TypeContainerVisitor, WorldTypeMapContainer > world_obj_worker(worker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_obj_worker, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, world_obj_worker, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, grid_obj_worker, *GetMap()); + cell_lock->Visit(cell_lock, world_obj_worker, *GetMap()); } // maybe can just place in primary position diff --git a/src/game/ObjectAccessor.cpp b/src/game/ObjectAccessor.cpp index a9954dcec..9934b2fe1 100644 --- a/src/game/ObjectAccessor.cpp +++ b/src/game/ObjectAccessor.cpp @@ -341,7 +341,7 @@ ObjectAccessor::_buildChangeObjectForPlayer(WorldObject *obj, UpdateDataMapType WorldObjectChangeAccumulator notifier(*obj, update_players); TypeContainerVisitor player_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, player_notifier, *MapManager::Instance().GetMap(obj->GetMapId(), obj)); + cell_lock->Visit(cell_lock, player_notifier, *obj->GetMap()); } Pet* @@ -533,14 +533,14 @@ ObjectAccessor::UpdateObjectVisibility(WorldObject *obj) CellPair p = MaNGOS::ComputeCellPair(obj->GetPositionX(), obj->GetPositionY()); Cell cell(p); - MapManager::Instance().GetMap(obj->GetMapId(), obj)->UpdateObjectVisibility(obj,cell,p); + obj->GetMap()->UpdateObjectVisibility(obj,cell,p); } void ObjectAccessor::UpdateVisibilityForPlayer( Player* player ) { CellPair p = MaNGOS::ComputeCellPair(player->GetPositionX(), player->GetPositionY()); Cell cell(p); - Map* m = MapManager::Instance().GetMap(player->GetMapId(),player); + Map* m = player->GetMap(); m->UpdatePlayerVisibility(player,cell,p); m->UpdateObjectsVisibilityFor(player,cell,p); diff --git a/src/game/ObjectGridLoader.cpp b/src/game/ObjectGridLoader.cpp index 8b6db82bd..d43296e4c 100644 --- a/src/game/ObjectGridLoader.cpp +++ b/src/game/ObjectGridLoader.cpp @@ -68,7 +68,7 @@ ObjectGridRespawnMover::Visit(CreatureMapType &m) if(cur_cell.DiffGrid(resp_cell)) { - MapManager::Instance().GetMap(c->GetMapId(), c)->CreatureRespawnRelocation(c); + c->GetMap()->CreatureRespawnRelocation(c); // false result ignored: will be unload with other creatures at grid } } diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 8d809914d..939120841 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -1554,7 +1554,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati else { // far teleport to another map - Map* oldmap = IsInWorld() ? MapManager::Instance().GetMap(GetMapId(), this) : NULL; + Map* oldmap = IsInWorld() ? GetMap() : NULL; // check if we can enter before stopping combat / removing pet / totems / interrupting spells // Check enter rights before map getting to avoid creating instance copy for player @@ -5128,7 +5128,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele return false; } - Map *m = MapManager::Instance().GetMap(GetMapId(), this); + Map *m = GetMap(); const float old_x = GetPositionX(); const float old_y = GetPositionY(); @@ -5146,7 +5146,7 @@ bool Player::SetPosition(float x, float y, float z, float orientation, bool tele m->PlayerRelocation(this, x, y, z, orientation); // reread after Map::Relocation - m = MapManager::Instance().GetMap(GetMapId(), this); + m = GetMap(); x = GetPositionX(); y = GetPositionY(); z = GetPositionZ(); @@ -5175,17 +5175,17 @@ void Player::SaveRecallPosition() void Player::SendMessageToSet(WorldPacket *data, bool self) { - MapManager::Instance().GetMap(GetMapId(), this)->MessageBroadcast(this, data, self); + GetMap()->MessageBroadcast(this, data, self); } void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self) { - MapManager::Instance().GetMap(GetMapId(), this)->MessageDistBroadcast(this, data, dist, self); + GetMap()->MessageDistBroadcast(this, data, dist, self); } void Player::SendMessageToSetInRange(WorldPacket *data, float dist, bool self, bool own_team_only) { - MapManager::Instance().GetMap(GetMapId(), this)->MessageDistBroadcast(this, data, dist, self,own_team_only); + GetMap()->MessageDistBroadcast(this, data, dist, self,own_team_only); } void Player::SendDirectMessage(WorldPacket *data) @@ -16107,8 +16107,8 @@ void Player::HandleStealthedUnitsDetection() TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap()); for (std::list::iterator i = stealthedUnits.begin(); i != stealthedUnits.end();) { diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp index b42c59eb9..cff2fade4 100644 --- a/src/game/Spell.cpp +++ b/src/game/Spell.cpp @@ -475,12 +475,12 @@ void Spell::FillTargetMap() TypeContainerVisitor, GridTypeMapContainer > grid_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_searcher, *m_caster->GetMap()); if(!result) { TypeContainerVisitor, WorldTypeMapContainer > world_searcher(searcher); - cell_lock->Visit(cell_lock, world_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_searcher, *m_caster->GetMap()); } if(result) @@ -1208,8 +1208,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap()); } if(tempUnitMap.empty()) @@ -1307,8 +1307,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_unit_searcher, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *m_caster->GetMap()); } tempUnitMap.sort(TargetDistanceOrder(pUnitTarget)); @@ -1365,8 +1365,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); // exclude caster (this can be important if this not original caster) TagUnitMap.remove(m_caster); @@ -1448,8 +1448,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); }break; case TARGET_ALL_FRIENDLY_UNITS_AROUND_CASTER: { @@ -1464,8 +1464,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); }break; case TARGET_ALL_FRIENDLY_UNITS_IN_AREA: { @@ -1480,8 +1480,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); }break; // TARGET_SINGLE_PARTY means that the spells can only be casted on a party member and not on the caster (some seals, fire shield from imp, etc..) case TARGET_SINGLE_PARTY: @@ -1557,8 +1557,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); }break; case TARGET_DUELVSPLAYER: { @@ -1607,8 +1607,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); } }break; case TARGET_MINION: @@ -1726,8 +1726,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_object_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_object_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_object_notifier, *m_caster->GetMap()); } @@ -1791,8 +1791,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor world_notifier(notifier); TypeContainerVisitor grid_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_notifier, *m_caster->GetMap()); } } }break; @@ -1848,8 +1848,8 @@ void Spell::SetTargetMap(uint32 i,uint32 cur,std::list &TagUnitMap) TypeContainerVisitor grid_notifier(notifier); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); - cell_lock->Visit(cell_lock, grid_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, world_notifier, *m_caster->GetMap()); + cell_lock->Visit(cell_lock, grid_notifier, *m_caster->GetMap()); } } else @@ -3383,7 +3383,7 @@ uint8 Spell::CanCast(bool strict) TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, object_checker, *m_caster->GetMap()); if(p_GameObject) { @@ -3422,7 +3422,7 @@ uint8 Spell::CanCast(bool strict) TypeContainerVisitor, GridTypeMapContainer > grid_creature_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_creature_searcher, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, grid_creature_searcher, *m_caster->GetMap()); if(p_Creature ) { @@ -4449,7 +4449,7 @@ uint8 Spell::CheckItems() TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); + cell_lock->Visit(cell_lock, object_checker, *m_caster->GetMap()); if(!ok) return (uint8)SPELL_FAILED_REQUIRES_SPELL_FOCUS; diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index fbb1d2e84..b4741b435 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -671,8 +671,8 @@ void AreaAura::Update(uint32 diff) TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); + cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap()); break; } case AREA_AURA_ENEMY: @@ -687,8 +687,8 @@ void AreaAura::Update(uint32 diff) TypeContainerVisitor, WorldTypeMapContainer > world_unit_searcher(searcher); TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(caster->GetMapId(), caster)); + cell_lock->Visit(cell_lock, world_unit_searcher, *caster->GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *caster->GetMap()); break; } case AREA_AURA_OWNER: diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp index a6815898e..14fe6cd10 100644 --- a/src/game/SpellEffects.cpp +++ b/src/game/SpellEffects.cpp @@ -1938,7 +1938,7 @@ void Spell::EffectTeleportUnits(uint32 i) ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); else { - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); + m_caster->GetMap()->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); WorldPacket data; unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); unitTarget->SendMessageToSet(&data, false); @@ -1964,7 +1964,7 @@ void Spell::EffectTeleportUnits(uint32 i) ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); else { - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); + m_caster->GetMap()->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); WorldPacket data; unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); unitTarget->SendMessageToSet(&data, false); @@ -2626,7 +2626,7 @@ void Spell::EffectPersistentAA(uint32 i) dynObj->SetUInt32Value(GAMEOBJECT_DISPLAYID, 368003); dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x01eeeeee); m_caster->AddDynObject(dynObj); - MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj); + dynObj->GetMap()->Add(dynObj); } void Spell::EffectEnergize(uint32 i) @@ -3467,7 +3467,7 @@ void Spell::EffectAddFarsight(uint32 i) dynObj->SetUInt32Value(OBJECT_FIELD_TYPE, 65); dynObj->SetUInt32Value(DYNAMICOBJECT_BYTES, 0x80000002); m_caster->AddDynObject(dynObj); - MapManager::Instance().GetMap(dynObj->GetMapId(), dynObj)->Add(dynObj); + dynObj->GetMap()->Add(dynObj); m_caster->SetUInt64Value(PLAYER_FARSIGHT, dynObj->GetGUID()); } @@ -3664,7 +3664,7 @@ void Spell::EffectTeleUnitsFaceCaster(uint32 i) if(unitTarget->GetTypeId() == TYPEID_PLAYER) ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, -m_caster->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); else - MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); + m_caster->GetMap()->CreatureRelocation((Creature*)m_caster, fx, fy, fz, -m_caster->GetOrientation()); } void Spell::EffectLearnSkill(uint32 i) @@ -3905,7 +3905,7 @@ void Spell::EffectTameCreature(uint32 /*i*/) pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()-1); // add to world - MapManager::Instance().GetMap(pet->GetMapId(), pet)->Add((Creature*)pet); + pet->GetMap()->Add((Creature*)pet); // visual effect for levelup pet->SetUInt32Value(UNIT_FIELD_LEVEL,creatureTarget->getLevel()); @@ -3935,14 +3935,14 @@ void Spell::EffectSummonPet(uint32 i) if( OldSummon->isDead() ) return; - MapManager::Instance().GetMap(OldSummon->GetMapId(), OldSummon)->Remove((Creature*)OldSummon,false); + OldSummon->GetMap()->Remove((Creature*)OldSummon,false); OldSummon->SetMapId(m_caster->GetMapId()); float px, py, pz; m_caster->GetClosePoint(px, py, pz, OldSummon->GetObjectSize()); OldSummon->Relocate(px, py, pz, OldSummon->GetOrientation()); - MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->Add((Creature*)OldSummon); + m_caster->GetMap()->Add((Creature*)OldSummon); if(m_caster->GetTypeId() == TYPEID_PLAYER && OldSummon->isControlled() ) { @@ -5438,7 +5438,7 @@ void Spell::EffectMomentMove(uint32 i) if(unitTarget->GetTypeId() == TYPEID_PLAYER) ((Player*)unitTarget)->TeleportTo(mapid, fx, fy, fz, unitTarget->GetOrientation(), TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); else - MapManager::Instance().GetMap(mapid, unitTarget)->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation()); + m_caster->GetMap()->CreatureRelocation((Creature*)unitTarget, fx, fy, fz, unitTarget->GetOrientation()); } } @@ -5548,7 +5548,7 @@ void Spell::EffectCharge(uint32 /*i*/) m_caster->SendMonsterMove(x, y, z, 0, MOVEMENTFLAG_WALK_MODE, 1); if(m_caster->GetTypeId() != TYPEID_PLAYER) - MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); + m_caster->GetMap()->CreatureRelocation((Creature*)m_caster,x,y,z,m_caster->GetOrientation()); // not all charge effects used in negative spells if ( !IsPositiveSpell(m_spellInfo->Id)) @@ -5984,7 +5984,7 @@ void Spell::EffectTransmitted(uint32 effIndex) linkedGO->SetSpellId(m_spellInfo->Id); linkedGO->SetOwnerGUID(m_caster->GetGUID() ); - MapManager::Instance().GetMap(linkedGO->GetMapId(), linkedGO)->Add(linkedGO); + linkedGO->GetMap()->Add(linkedGO); } else { diff --git a/src/game/TemporarySummon.cpp b/src/game/TemporarySummon.cpp index 928cd3fe1..0d653b2b2 100644 --- a/src/game/TemporarySummon.cpp +++ b/src/game/TemporarySummon.cpp @@ -158,7 +158,7 @@ void TemporarySummon::Summon(TempSummonType type, uint32 lifetime) m_timer = lifetime; m_lifetime = lifetime; - MapManager::Instance().GetMap(GetMapId(), this)->Add((Creature*)this); + GetMap()->Add((Creature*)this); AIM_Initialize(); } diff --git a/src/game/TotemAI.cpp b/src/game/TotemAI.cpp index f3f280ce1..572a8b04d 100644 --- a/src/game/TotemAI.cpp +++ b/src/game/TotemAI.cpp @@ -93,8 +93,8 @@ TotemAI::UpdateAI(const uint32 /*diff*/) TypeContainerVisitor, WorldTypeMapContainer > world_object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, grid_object_checker, *MapManager::Instance().GetMap(i_totem.GetMapId(), &i_totem)); - cell_lock->Visit(cell_lock, world_object_checker, *MapManager::Instance().GetMap(i_totem.GetMapId(), &i_totem)); + cell_lock->Visit(cell_lock, grid_object_checker, *i_totem.GetMap()); + cell_lock->Visit(cell_lock, world_object_checker, *i_totem.GetMap()); } // If have target diff --git a/src/game/Transports.cpp b/src/game/Transports.cpp index 658fd8f8c..3c736b8fb 100644 --- a/src/game/Transports.cpp +++ b/src/game/Transports.cpp @@ -105,7 +105,7 @@ void MapManager::LoadTransports() //If we someday decide to use the grid to track transports, here: //MapManager::Instance().LoadGrid(mapid,x,y,true); - //MapManager::Instance().GetMap(t->GetMapId())->Add((GameObject *)t); + //t->GetMap()->Add((GameObject *)t); ++count; } while(result->NextRow()); delete result; @@ -430,11 +430,11 @@ Transport::WayPointMap::iterator Transport::GetNextWayPoint() void Transport::TeleportTransport(uint32 newMapid, float x, float y, float z) { - //MapManager::Instance().GetMap(oldMapid)->Remove((GameObject *)this, false); + //GetMap()->Remove((GameObject *)this, false); SetMapId(newMapid); //MapManager::Instance().LoadGrid(newMapid,x,y,true); Relocate(x, y, z); - //MapManager::Instance().GetMap(newMapid)->Add((GameObject *)this); + //GetMap()->Add((GameObject *)this); for(PlayerSet::iterator itr = m_passengers.begin(); itr != m_passengers.end();) { diff --git a/src/game/Traveller.h b/src/game/Traveller.h index 8a7a85d3d..1d50d488a 100644 --- a/src/game/Traveller.h +++ b/src/game/Traveller.h @@ -65,7 +65,7 @@ inline float Traveller::Speed() template<> inline void Traveller::Relocation(float x, float y, float z, float orientation) { - MapManager::Instance().GetMap(i_traveller.GetMapId(), &i_traveller)->CreatureRelocation(&i_traveller, x, y, z, orientation); + i_traveller.GetMap()->CreatureRelocation(&i_traveller, x, y, z, orientation); } template<> @@ -87,7 +87,7 @@ inline float Traveller::Speed() template<> inline void Traveller::Relocation(float x, float y, float z, float orientation) { - MapManager::Instance().GetMap(i_traveller.GetMapId(), &i_traveller)->PlayerRelocation(&i_traveller, x, y, z, orientation); + i_traveller.GetMap()->PlayerRelocation(&i_traveller, x, y, z, orientation); } template<> diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 1517578bc..ed9524447 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -8740,7 +8740,7 @@ void Unit::SetVisibility(UnitVisibility x) if(IsInWorld()) { - Map *m = MapManager::Instance().GetMap(GetMapId(), this); + Map *m = GetMap(); if(GetTypeId()==TYPEID_PLAYER) m->PlayerRelocation((Player*)this,GetPositionX(),GetPositionY(),GetPositionZ(),GetOrientation()); @@ -10493,8 +10493,8 @@ Unit* Unit::SelectNearbyTarget() const TypeContainerVisitor, GridTypeMapContainer > grid_unit_searcher(searcher); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, world_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); - cell_lock->Visit(cell_lock, grid_unit_searcher, *MapManager::Instance().GetMap(GetMapId(), this)); + cell_lock->Visit(cell_lock, world_unit_searcher, *GetMap()); + cell_lock->Visit(cell_lock, grid_unit_searcher, *GetMap()); } // remove current target diff --git a/src/game/World.cpp b/src/game/World.cpp index 546cdbbf6..3c4a66402 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1644,7 +1644,7 @@ void World::ScriptsProcess() break; } ((Unit *)source)->SendMonsterMoveWithSpeed(step.script->x, step.script->y, step.script->z, ((Unit *)source)->GetUnitMovementFlags(), step.script->datalong2 ); - MapManager::Instance().GetMap(((Unit *)source)->GetMapId(), ((Unit *)source))->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); + ((Unit *)source)->GetMap()->CreatureRelocation(((Creature *)source), step.script->x, step.script->y, step.script->z, 0); break; case SCRIPT_COMMAND_FLAG_SET: if(!source) @@ -1770,7 +1770,7 @@ void World::ScriptsProcess() TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(summoner->GetMapId(), summoner)); + cell_lock->Visit(cell_lock, object_checker, *summoner->GetMap()); if ( !go ) { @@ -1794,7 +1794,7 @@ void World::ScriptsProcess() go->SetLootState(GO_READY); go->SetRespawnTime(time_to_despawn); //despawn object in ? seconds - MapManager::Instance().GetMap(go->GetMapId(), go)->Add(go); + go->GetMap()->Add(go); break; } case SCRIPT_COMMAND_OPEN_DOOR: @@ -1831,7 +1831,7 @@ void World::ScriptsProcess() TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); + cell_lock->Visit(cell_lock, object_checker, *caster->GetMap()); if ( !door ) { @@ -1887,7 +1887,7 @@ void World::ScriptsProcess() TypeContainerVisitor, GridTypeMapContainer > object_checker(checker); CellLock cell_lock(cell, p); - cell_lock->Visit(cell_lock, object_checker, *MapManager::Instance().GetMap(caster->GetMapId(), (Unit*)source)); + cell_lock->Visit(cell_lock, object_checker, *caster->GetMap()); if ( !door ) { diff --git a/src/game/WorldSession.cpp b/src/game/WorldSession.cpp index 59e236c24..49266910f 100644 --- a/src/game/WorldSession.cpp +++ b/src/game/WorldSession.cpp @@ -364,7 +364,7 @@ void WorldSession::LogoutPlayer(bool Save) // the player may not be in the world when logging out // e.g if he got disconnected during a transfer to another map // calls to GetMap in this case may cause crashes - if(_player->IsInWorld()) MapManager::Instance().GetMap(_player->GetMapId(), _player)->Remove(_player, false); + if(_player->IsInWorld()) _player->GetMap()->Remove(_player, false); // RemoveFromWorld does cleanup that requires the player to be in the accessor ObjectAccessor::Instance().RemoveObject(_player);