Allow constant only access to m_mapRefManager using Map::GetPlayers()

This commit is contained in:
VladimirMangos 2008-11-17 14:54:12 +03:00
parent fc0e3e87a8
commit 5439dd0fd4
3 changed files with 8 additions and 8 deletions

View file

@ -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);
}

View file

@ -125,6 +125,7 @@ typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList;
class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>, public MaNGOS::ObjectLevelLockable<Map, ZThread::Mutex>
{
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<NGridType>, 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<NGridType>, 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<Player *> 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;

View file

@ -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;
}