TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MapManager Class Reference

#include <MapManager.h>

Public Member Functions

MapCreateBaseMap (uint32 mapId)
 
MapFindBaseNonInstanceMap (uint32 mapId) const
 
MapCreateMap (uint32 mapId, Player *player, uint32 loginInstanceId=0)
 
MapFindMap (uint32 mapId, uint32 instanceId) const
 
uint32 GetAreaId (uint32 mapid, float x, float y, float z) const
 
uint32 GetZoneId (uint32 mapid, float x, float y, float z) const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid, uint32 mapid, float x, float y, float z)
 
void Initialize (void)
 
void Update (uint32)
 
void SetGridCleanUpDelay (uint32 t)
 
void SetMapUpdateInterval (uint32 t)
 
void UnloadAll ()
 
void DoDelayedMovesAndRemoves ()
 
Map::EnterState PlayerCannotEnter (uint32 mapid, Player *player, bool loginCheck=false)
 
void InitializeVisibilityDistanceInfo ()
 
uint32 GetNumInstances ()
 
uint32 GetNumPlayersInInstances ()
 
void InitInstanceIds ()
 
uint32 GenerateInstanceId ()
 
void RegisterInstanceId (uint32 instanceId)
 
void FreeInstanceId (uint32 instanceId)
 
uint32 GetNextInstanceId () const
 
void SetNextInstanceId (uint32 nextInstanceId)
 
MapUpdaterGetMapUpdater ()
 
template<typename Worker >
void DoForAllMaps (Worker &&worker)
 
template<typename Worker >
void DoForAllMapsWithMapId (uint32 mapId, Worker &&worker)
 

Static Public Member Functions

static MapManagerinstance ()
 
static bool ExistMapAndVMap (uint32 mapid, float x, float y)
 
static bool IsValidMAP (uint32 mapid, bool startUp)
 
static bool IsValidMapCoord (uint32 mapid, float x, float y)
 
static bool IsValidMapCoord (uint32 mapid, float x, float y, float z)
 
static bool IsValidMapCoord (uint32 mapid, float x, float y, float z, float o)
 
static bool IsValidMapCoord (WorldLocation const &loc)
 

Private Types

typedef std::unordered_map
< uint32, Map * > 
MapMapType
 
typedef std::vector< boolInstanceIds
 

Private Member Functions

 MapManager ()
 
 ~MapManager ()
 
MapFindBaseMap (uint32 mapId) const
 
 MapManager (const MapManager &)
 
MapManageroperator= (const MapManager &)
 

Private Attributes

std::mutex _mapsLock
 
uint32 i_gridCleanUpDelay
 
MapMapType i_maps
 
IntervalTimer i_timer
 
InstanceIds _instanceIds
 
uint32 _nextInstanceId
 
MapUpdater m_updater
 

Member Typedef Documentation

typedef std::vector<bool> MapManager::InstanceIds
private
typedef std::unordered_map<uint32, Map*> MapManager::MapMapType
private

Constructor & Destructor Documentation

MapManager::MapManager ( )
private
41 {
44  _nextInstanceId = 0;
45 }
uint32 _nextInstanceId
Definition: MapManager.h:151
uint32 i_gridCleanUpDelay
Definition: MapManager.h:146
#define sWorld
Definition: World.h:887
void SetInterval(time_t interval)
Definition: Timer.h:79
Definition: World.h:211
IntervalTimer i_timer
Definition: MapManager.h:148
Definition: World.h:212

+ Here is the call graph for this function:

MapManager::~MapManager ( )
private
47 { }
MapManager::MapManager ( const MapManager )
private

Member Function Documentation

Map * MapManager::CreateBaseMap ( uint32  mapId)
72 {
73  Map* map = FindBaseMap(id);
74 
75  if (map == NULL)
76  {
77  std::lock_guard<std::mutex> lock(_mapsLock);
78 
79  MapEntry const* entry = sMapStore.LookupEntry(id);
80  ASSERT(entry);
81 
82  if (entry->Instanceable())
83  map = new MapInstanced(id, i_gridCleanUpDelay);
84  else
85  {
86  map = new Map(id, i_gridCleanUpDelay, 0, DIFFICULTY_NONE);
87  map->LoadRespawnTimes();
88  map->LoadCorpseData();
89  }
90 
91  i_maps[id] = map;
92  }
93 
94  ASSERT(map);
95  return map;
96 }
Definition: MapInstanced.h:28
Definition: DBCEnums.h:404
Map * FindBaseMap(uint32 mapId) const
Definition: MapManager.h:136
bool Instanceable() const
Definition: DBCStructure.h:859
Definition: DBCStructure.h:830
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 i_gridCleanUpDelay
Definition: MapManager.h:146
MapMapType i_maps
Definition: MapManager.h:147
Definition: Map.h:259
void LoadCorpseData()
Definition: Map.cpp:3700
DBCStorage< MapEntry > sMapStore(Mapfmt)
#define ASSERT
Definition: Errors.h:55
void LoadRespawnTimes()
Definition: Map.cpp:3630
std::mutex _mapsLock
Definition: MapManager.h:145

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Map * MapManager::CreateMap ( uint32  mapId,
Player player,
uint32  loginInstanceId = 0 
)
107 {
108  Map* m = CreateBaseMap(id);
109 
110  if (m && m->Instanceable())
111  m = ((MapInstanced*)m)->CreateInstanceForPlayer(id, player, loginInstanceId);
112 
113  return m;
114 }
Definition: MapInstanced.h:28
Map * CreateBaseMap(uint32 mapId)
Definition: MapManager.cpp:71
Definition: Map.h:259
bool Instanceable() const
Definition: Map.h:394

+ Here is the call graph for this function:

void MapManager::DoDelayedMovesAndRemoves ( )
235 { }
template<typename Worker >
void MapManager::DoForAllMaps ( Worker &&  worker)
157 {
158  std::lock_guard<std::mutex> lock(_mapsLock);
159 
160  for (auto& mapPair : i_maps)
161  {
162  Map* map = mapPair.second;
163  if (MapInstanced* mapInstanced = map->ToMapInstanced())
164  {
165  MapInstanced::InstancedMaps& instances = mapInstanced->GetInstancedMaps();
166  for (auto& instancePair : instances)
167  worker(instancePair.second);
168  }
169  else
170  worker(map);
171  }
172 }
Definition: MapInstanced.h:28
std::unordered_map< uint32, Map * > InstancedMaps
Definition: MapInstanced.h:32
MapMapType i_maps
Definition: MapManager.h:147
Definition: Map.h:259
MapInstanced * ToMapInstanced()
Definition: Map.h:492
std::mutex _mapsLock
Definition: MapManager.h:145

+ Here is the call graph for this function:

template<typename Worker >
void MapManager::DoForAllMapsWithMapId ( uint32  mapId,
Worker &&  worker 
)
inline
176 {
177  std::lock_guard<std::mutex> lock(_mapsLock);
178 
179  auto itr = i_maps.find(mapId);
180  if (itr != i_maps.end())
181  {
182  Map* map = itr->second;
183  if (MapInstanced* mapInstanced = map->ToMapInstanced())
184  {
185  MapInstanced::InstancedMaps& instances = mapInstanced->GetInstancedMaps();
186  for (auto& p : instances)
187  worker(p.second);
188  }
189  else
190  worker(map);
191  }
192 }
Definition: MapInstanced.h:28
std::unordered_map< uint32, Map * > InstancedMaps
Definition: MapInstanced.h:32
MapMapType i_maps
Definition: MapManager.h:147
Definition: Map.h:259
MapInstanced * ToMapInstanced()
Definition: Map.h:492
std::mutex _mapsLock
Definition: MapManager.h:145

+ Here is the call graph for this function:

bool MapManager::ExistMapAndVMap ( uint32  mapid,
float  x,
float  y 
)
static
238 {
240 
241  int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord;
242  int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord;
243 
244  return Map::ExistMap(mapid, gx, gy) && Map::ExistVMap(mapid, gx, gy);
245 }
static bool ExistVMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:107
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:188
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GridDefines.h:89
static bool ExistMap(uint32 mapid, int gx, int gy)
Definition: Map.cpp:79
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Map* MapManager::FindBaseMap ( uint32  mapId) const
inlineprivate
137  {
138  MapMapType::const_iterator iter = i_maps.find(mapId);
139  return (iter == i_maps.end() ? NULL : iter->second);
140  }
arena_t NULL
Definition: jemalloc_internal.h:624
MapMapType i_maps
Definition: MapManager.h:147

+ Here is the caller graph for this function:

Map * MapManager::FindBaseNonInstanceMap ( uint32  mapId) const
99 {
100  Map* map = FindBaseMap(mapId);
101  if (map && map->Instanceable())
102  return NULL;
103  return map;
104 }
Map * FindBaseMap(uint32 mapId) const
Definition: MapManager.h:136
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Map.h:259
bool Instanceable() const
Definition: Map.h:394

+ Here is the call graph for this function:

Map * MapManager::FindMap ( uint32  mapId,
uint32  instanceId 
) const
117 {
118  Map* map = FindBaseMap(mapid);
119  if (!map)
120  return NULL;
121 
122  if (!map->Instanceable())
123  return instanceId == 0 ? map : NULL;
124 
125  return ((MapInstanced*)map)->FindInstanceMap(instanceId);
126 }
Definition: MapInstanced.h:28
Map * FindBaseMap(uint32 mapId) const
Definition: MapManager.h:136
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Map.h:259
bool Instanceable() const
Definition: Map.h:394

+ Here is the call graph for this function:

void MapManager::FreeInstanceId ( uint32  instanceId)
367 {
368  // If freed instance id is lower than the next id available for new instances, use the freed one instead
369  if (instanceId < _nextInstanceId)
370  SetNextInstanceId(instanceId);
371 
372  _instanceIds[instanceId] = false;
373  sAchievementMgr->OnInstanceDestroyed(instanceId);
374 }
uint32 _nextInstanceId
Definition: MapManager.h:151
void SetNextInstanceId(uint32 nextInstanceId)
Definition: MapManager.h:119
InstanceIds _instanceIds
Definition: MapManager.h:150
#define sAchievementMgr
Definition: AchievementMgr.h:501

+ Here is the call graph for this function:

uint32 MapManager::GenerateInstanceId ( )
330 {
331  uint32 newInstanceId = _nextInstanceId;
332 
333  // Find the lowest available id starting from the current NextInstanceId (which should be the lowest according to the logic in FreeInstanceId()
334  for (uint32 i = ++_nextInstanceId; i < 0xFFFFFFFF; ++i)
335  {
336  if ((i < _instanceIds.size() && !_instanceIds[i]) || i >= _instanceIds.size())
337  {
338  _nextInstanceId = i;
339  break;
340  }
341  }
342 
343  if (newInstanceId == _nextInstanceId)
344  {
345  TC_LOG_ERROR("maps", "Instance ID overflow!! Can't continue, shutting down server. ");
347  }
348 
349  // Allocate space if necessary
350  if (newInstanceId >= uint32(_instanceIds.size()))
351  {
352  // Due to the odd memory allocation behavior of vector<bool> we match size to capacity before triggering a new allocation
353  if (_instanceIds.size() < _instanceIds.capacity())
354  {
355  _instanceIds.resize(_instanceIds.capacity());
356  }
357  else
358  _instanceIds.resize((newInstanceId / 32) * 32 + (newInstanceId % 32 > 0 ? 32 : 0));
359  }
360 
361  _instanceIds[newInstanceId] = true;
362 
363  return newInstanceId;
364 }
uint32 _nextInstanceId
Definition: MapManager.h:151
InstanceIds _instanceIds
Definition: MapManager.h:150
Definition: World.h:74
uint32_t uint32
Definition: Define.h:150
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
static void StopNow(uint8 exitcode)
Definition: World.h:662

+ Here is the call graph for this function:

uint32 MapManager::GetAreaId ( uint32  mapid,
float  x,
float  y,
float  z 
) const
inline
42  {
43  Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
44  return m->GetAreaId(x, y, z);
45  }
uint32 GetAreaId(float x, float y, float z, bool *isOutdoors) const
Definition: Map.cpp:2426
Map * CreateBaseMap(uint32 mapId)
Definition: MapManager.cpp:71
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
Definition: MapManager.h:31
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

MapUpdater* MapManager::GetMapUpdater ( )
inline
121 { return &m_updater; }
MapUpdater m_updater
Definition: MapManager.h:152
uint32 MapManager::GetNextInstanceId ( ) const
inline
118 { return _nextInstanceId; };
uint32 _nextInstanceId
Definition: MapManager.h:151
uint32 MapManager::GetNumInstances ( )
275 {
276  std::lock_guard<std::mutex> lock(_mapsLock);
277 
278  uint32 ret = 0;
279  for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
280  {
281  Map* map = itr->second;
282  if (!map->Instanceable())
283  continue;
284  MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
285  for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
286  if (mitr->second->IsDungeon()) ret++;
287  }
288  return ret;
289 }
Definition: MapInstanced.h:28
std::unordered_map< uint32, Map * > InstancedMaps
Definition: MapInstanced.h:32
MapMapType i_maps
Definition: MapManager.h:147
uint32_t uint32
Definition: Define.h:150
Definition: Map.h:259
bool Instanceable() const
Definition: Map.h:394
std::mutex _mapsLock
Definition: MapManager.h:145

+ Here is the call graph for this function:

uint32 MapManager::GetNumPlayersInInstances ( )
292 {
293  std::lock_guard<std::mutex> lock(_mapsLock);
294 
295  uint32 ret = 0;
296  for (MapMapType::iterator itr = i_maps.begin(); itr != i_maps.end(); ++itr)
297  {
298  Map* map = itr->second;
299  if (!map->Instanceable())
300  continue;
301  MapInstanced::InstancedMaps &maps = ((MapInstanced*)map)->GetInstancedMaps();
302  for (MapInstanced::InstancedMaps::iterator mitr = maps.begin(); mitr != maps.end(); ++mitr)
303  if (mitr->second->IsDungeon())
304  ret += ((InstanceMap*)mitr->second)->GetPlayers().getSize();
305  }
306  return ret;
307 }
Definition: MapInstanced.h:28
std::unordered_map< uint32, Map * > InstancedMaps
Definition: MapInstanced.h:32
TC_GAME_API HashMapHolder< Player >::MapType const & GetPlayers()
Definition: ObjectAccessor.cpp:258
MapMapType i_maps
Definition: MapManager.h:147
Definition: Map.h:758
uint32_t uint32
Definition: Define.h:150
Definition: Map.h:259
bool Instanceable() const
Definition: Map.h:394
std::mutex _mapsLock
Definition: MapManager.h:145

+ Here is the call graph for this function:

void MapManager::GetZoneAndAreaId ( uint32 zoneid,
uint32 areaid,
uint32  mapid,
float  x,
float  y,
float  z 
)
inline
52  {
53  Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
54  m->GetZoneAndAreaId(zoneid, areaid, x, y, z);
55  }
void GetZoneAndAreaId(uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
Definition: Map.cpp:2481
Map * CreateBaseMap(uint32 mapId)
Definition: MapManager.cpp:71
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
Definition: MapManager.h:31
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

uint32 MapManager::GetZoneId ( uint32  mapid,
float  x,
float  y,
float  z 
) const
inline
47  {
48  Map const* m = const_cast<MapManager*>(this)->CreateBaseMap(mapid);
49  return m->GetZoneId(x, y, z);
50  }
Map * CreateBaseMap(uint32 mapId)
Definition: MapManager.cpp:71
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
uint32 GetZoneId(float x, float y, float z) const
Definition: Map.cpp:2471
Definition: MapManager.h:31
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

void MapManager::Initialize ( void  )
50 {
52 
53  int num_threads(sWorld->getIntConfig(CONFIG_NUMTHREADS));
54  // Start mtmaps if needed.
55  if (num_threads > 0)
56  m_updater.activate(num_threads);
57 }
#define sWorld
Definition: World.h:887
void activate(size_t num_threads)
Definition: MapUpdater.cpp:47
MapUpdater m_updater
Definition: MapManager.h:152
static void InitStateMachine()
Definition: Map.cpp:211
Definition: World.h:322

+ Here is the call graph for this function:

void MapManager::InitializeVisibilityDistanceInfo ( )
60 {
61  for (MapMapType::iterator iter=i_maps.begin(); iter != i_maps.end(); ++iter)
62  (*iter).second->InitVisibilityDistance();
63 }
MapMapType i_maps
Definition: MapManager.h:147
void MapManager::InitInstanceIds ( )
310 {
311  _nextInstanceId = 1;
312 
313  QueryResult result = CharacterDatabase.Query("SELECT MAX(id) FROM instance");
314  if (result)
315  {
316  uint32 maxId = (*result)[0].GetUInt32();
317 
318  // Resize to multiples of 32 (vector<bool> allocates memory the same way)
319  _instanceIds.resize((maxId / 32) * 32 + (maxId % 32 > 0 ? 32 : 0));
320  }
321 }
uint32 _nextInstanceId
Definition: MapManager.h:151
InstanceIds _instanceIds
Definition: MapManager.h:150
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

MapManager * MapManager::instance ( )
static
66 {
67  static MapManager instance;
68  return &instance;
69 }
static MapManager * instance()
Definition: MapManager.cpp:65
Definition: MapManager.h:31

+ Here is the caller graph for this function:

bool MapManager::IsValidMAP ( uint32  mapid,
bool  startUp 
)
static
Todo:
add check for battleground template
248 {
249  MapEntry const* mEntry = sMapStore.LookupEntry(mapid);
250 
251  if (startUp)
252  return mEntry ? true : false;
253  else
254  return mEntry && (!mEntry->IsDungeon() || sObjectMgr->GetInstanceTemplate(mapid));
255 
257 }
Definition: DBCStructure.h:830
#define sObjectMgr
Definition: ObjectMgr.h:1567
bool IsDungeon() const
Definition: DBCStructure.h:857
DBCStorage< MapEntry > sMapStore(Mapfmt)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool MapManager::IsValidMapCoord ( uint32  mapid,
float  x,
float  y 
)
inlinestatic
84  {
85  return IsValidMAP(mapid, false) && Trinity::IsValidMapCoord(x, y);
86  }
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition: MapManager.cpp:247
bool IsValidMapCoord(float c)
Definition: GridDefines.h:218
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool MapManager::IsValidMapCoord ( uint32  mapid,
float  x,
float  y,
float  z 
)
inlinestatic
89  {
90  return IsValidMAP(mapid, false) && Trinity::IsValidMapCoord(x, y, z);
91  }
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition: MapManager.cpp:247
bool IsValidMapCoord(float c)
Definition: GridDefines.h:218
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

static bool MapManager::IsValidMapCoord ( uint32  mapid,
float  x,
float  y,
float  z,
float  o 
)
inlinestatic
94  {
95  return IsValidMAP(mapid, false) && Trinity::IsValidMapCoord(x, y, z, o);
96  }
static bool IsValidMAP(uint32 mapid, bool startUp)
Definition: MapManager.cpp:247
bool IsValidMapCoord(float c)
Definition: GridDefines.h:218
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

static bool MapManager::IsValidMapCoord ( WorldLocation const loc)
inlinestatic
99  {
100  return IsValidMapCoord(loc.GetMapId(), loc.GetPositionX(), loc.GetPositionY(), loc.GetPositionZ(), loc.GetOrientation());
101  }
static bool IsValidMapCoord(uint32 mapid, float x, float y)
Definition: MapManager.h:83

+ Here is the call graph for this function:

MapManager& MapManager::operator= ( const MapManager )
private
Map::EnterState MapManager::PlayerCannotEnter ( uint32  mapid,
Player player,
bool  loginCheck = false 
)
129 {
130  MapEntry const* entry = sMapStore.LookupEntry(mapid);
131  if (!entry)
133 
134  if (!entry->IsDungeon())
135  return Map::CAN_ENTER;
136 
137  InstanceTemplate const* instance = sObjectMgr->GetInstanceTemplate(mapid);
138  if (!instance)
140 
141  Difficulty targetDifficulty, requestedDifficulty;
142  targetDifficulty = requestedDifficulty = player->GetDifficultyID(entry);
143  // Get the highest available difficulty if current setting is higher than the instance allows
144  MapDifficultyEntry const* mapDiff = GetDownscaledMapDifficultyData(entry->ID, targetDifficulty);
145  if (!mapDiff)
147 
148  //Bypass checks for GMs
149  if (player->IsGameMaster())
150  return Map::CAN_ENTER;
151 
152  char const* mapName = entry->MapName_lang;
153 
154  Group* group = player->GetGroup();
155  if (entry->IsRaid()) // can only enter in a raid group
156  if ((!group || !group->isRaidGroup()) && !sWorld->getBoolConfig(CONFIG_INSTANCE_IGNORE_RAID))
158 
159  if (!player->IsAlive())
160  {
161  if (player->HasCorpse())
162  {
163  // let enter in ghost mode in instance that connected to inner instance with corpse
164  uint32 corpseMap = player->GetCorpseLocation().GetMapId();
165  do
166  {
167  if (corpseMap == mapid)
168  break;
169 
170  InstanceTemplate const* corpseInstance = sObjectMgr->GetInstanceTemplate(corpseMap);
171  corpseMap = corpseInstance ? corpseInstance->Parent : 0;
172  } while (corpseMap);
173 
174  if (!corpseMap)
176 
177  TC_LOG_DEBUG("maps", "MAP: Player '%s' has corpse in instance '%s' and can enter.", player->GetName().c_str(), mapName);
178  }
179  else
180  TC_LOG_DEBUG("maps", "Map::CanPlayerEnter - player '%s' is dead but does not have a corpse!", player->GetName().c_str());
181  }
182 
183  //Get instance where player's group is bound & its map
184  if (!loginCheck && group)
185  {
186  InstanceGroupBind* boundInstance = group->GetBoundInstance(entry);
187  if (boundInstance && boundInstance->save)
188  if (Map* boundMap = sMapMgr->FindMap(mapid, boundInstance->save->GetInstanceId()))
189  if (Map::EnterState denyReason = boundMap->CannotEnter(player))
190  return denyReason;
191  }
192 
193  // players are only allowed to enter 5 instances per hour
194  if (entry->IsDungeon() && (!player->GetGroup() || (player->GetGroup() && !player->GetGroup()->isLFGGroup())))
195  {
196  uint32 instanceIdToCheck = 0;
197  if (InstanceSave* save = player->GetInstanceSave(mapid))
198  instanceIdToCheck = save->GetInstanceId();
199 
200  // instanceId can never be 0 - will not be found
201  if (!player->CheckInstanceCount(instanceIdToCheck) && !player->isDead())
203  }
204 
205  //Other requirements
206  if (player->Satisfy(sObjectMgr->GetAccessRequirement(mapid, targetDifficulty), mapid, true))
207  return Map::CAN_ENTER;
208  else
210 }
InstanceSave * save
Definition: Group.h:170
Difficulty
Definition: DBCEnums.h:402
Definition: Map.h:222
Definition: Group.h:168
bool isRaidGroup() const
Definition: Group.cpp:2509
Definition: Map.h:378
Definition: DBCStructure.h:830
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
MapDifficultyEntry const * GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty)
Definition: DBCStores.cpp:737
static MapManager * instance()
Definition: MapManager.cpp:65
Definition: World.h:115
uint32 Parent
Definition: Map.h:224
Definition: Map.h:375
Definition: Map.h:373
uint32_t uint32
Definition: Define.h:150
bool IsDungeon() const
Definition: DBCStructure.h:857
uint32 ID
Definition: DBCStructure.h:832
Definition: Map.h:259
Definition: InstanceSaveMgr.h:44
bool IsRaid() const
Definition: DBCStructure.h:860
Definition: DBCStructure.h:885
DBCStorage< MapEntry > sMapStore(Mapfmt)
#define sMapMgr
Definition: MapManager.h:194
EnterState
Definition: Map.h:371
char * MapName_lang
Definition: DBCStructure.h:838
InstanceGroupBind * GetBoundInstance(Player *player)
Definition: Group.cpp:2191
uint32 GetInstanceId() const
Definition: InstanceSaveMgr.h:64
Definition: Group.h:191

+ Here is the call graph for this function:

void MapManager::RegisterInstanceId ( uint32  instanceId)
324 {
325  // Allocation and sizing was done in InitInstanceIds()
326  _instanceIds[instanceId] = true;
327 }
InstanceIds _instanceIds
Definition: MapManager.h:150
void MapManager::SetGridCleanUpDelay ( uint32  t)
inline
61  {
62  if (t < MIN_GRID_DELAY)
64  else
66  }
#define MIN_GRID_DELAY
Definition: GridDefines.h:44
uint32 i_gridCleanUpDelay
Definition: MapManager.h:146
void MapManager::SetMapUpdateInterval ( uint32  t)
inline
69  {
70  if (t < MIN_MAP_UPDATE_DELAY)
72 
74  i_timer.Reset();
75  }
void SetInterval(time_t interval)
Definition: Timer.h:79
#define MIN_MAP_UPDATE_DELAY
Definition: GridDefines.h:45
void Reset()
Definition: Timer.h:68
IntervalTimer i_timer
Definition: MapManager.h:148
void MapManager::SetNextInstanceId ( uint32  nextInstanceId)
inline
119 { _nextInstanceId = nextInstanceId; };
uint32 _nextInstanceId
Definition: MapManager.h:151

+ Here is the caller graph for this function:

void MapManager::UnloadAll ( )
260 {
261  for (MapMapType::iterator iter = i_maps.begin(); iter != i_maps.end();)
262  {
263  iter->second->UnloadAll();
264  delete iter->second;
265  i_maps.erase(iter++);
266  }
267 
268  if (m_updater.activated())
270 
272 }
void deactivate()
Definition: MapUpdater.cpp:55
static void DeleteStateMachine()
Definition: Map.cpp:219
MapMapType i_maps
Definition: MapManager.h:147
MapUpdater m_updater
Definition: MapManager.h:152
bool activated()
Definition: MapUpdater.cpp:88

+ Here is the call graph for this function:

void MapManager::Update ( uint32  diff)
213 {
214  i_timer.Update(diff);
215  if (!i_timer.Passed())
216  return;
217 
218  MapMapType::iterator iter = i_maps.begin();
219  for (; iter != i_maps.end(); ++iter)
220  {
221  if (m_updater.activated())
223  else
224  iter->second->Update(uint32(i_timer.GetCurrent()));
225  }
226  if (m_updater.activated())
227  m_updater.wait();
228 
229  for (iter = i_maps.begin(); iter != i_maps.end(); ++iter)
230  iter->second->DelayedUpdate(uint32(i_timer.GetCurrent()));
231 
232  i_timer.SetCurrent(0);
233 }
void schedule_update(Map &map, uint32 diff)
Definition: MapUpdater.cpp:79
MapMapType i_maps
Definition: MapManager.h:147
bool Passed()
Definition: Timer.h:63
MapUpdater m_updater
Definition: MapManager.h:152
uint32_t uint32
Definition: Define.h:150
void Update(time_t diff)
Definition: Timer.h:56
time_t GetCurrent() const
Definition: Timer.h:89
uint32_t uint32
Definition: g3dmath.h:168
void wait()
Definition: MapUpdater.cpp:69
void SetCurrent(time_t current)
Definition: Timer.h:74
bool activated()
Definition: MapUpdater.cpp:88
IntervalTimer i_timer
Definition: MapManager.h:148

+ Here is the call graph for this function:

Member Data Documentation

InstanceIds MapManager::_instanceIds
private
std::mutex MapManager::_mapsLock
private
uint32 MapManager::_nextInstanceId
private
uint32 MapManager::i_gridCleanUpDelay
private
MapMapType MapManager::i_maps
private
IntervalTimer MapManager::i_timer
private
MapUpdater MapManager::m_updater
private

The documentation for this class was generated from the following files: