AzerothCore 3.3.5a
OpenSource WoW Emulator
No Matches
MapInstanced Class Reference

#include "MapInstanced.h"

Inheritance diagram for MapInstanced:
Map GridRefMgr< NGridType > RefMgr< TO, FROM > LinkedListHead

Public Types

using InstancedMaps = std::unordered_map< uint32, Map * >
- Public Types inherited from Map
enum  EnterState {
  CAN_ENTER = 0 ,
typedef MapRefMgr PlayerList
typedef std::unordered_multimap< ObjectGuid::LowType, Creature * > CreatureBySpawnIdContainer
typedef std::unordered_multimap< ObjectGuid::LowType, GameObject * > GameObjectBySpawnIdContainer
- Public Types inherited from GridRefMgr< NGridType >
typedef LinkedListHead::Iterator< GridReference< NGridType > > iterator
- Public Types inherited from RefMgr< TO, FROM >
typedef LinkedListHead::Iterator< Reference< TO, FROM > > iterator
- Public Types inherited from LinkedListHead
typedef Iterator< LinkedListElementiterator

Public Member Functions

 MapInstanced (uint32 id)
 ~MapInstanced () override
void Update (const uint32, const uint32, bool thread=true) override
void DelayedUpdate (const uint32 diff) override
void UnloadAll () override
EnterState CannotEnter (Player *player, bool loginCheck=false) override
MapCreateInstanceForPlayer (const uint32 mapId, Player *player)
MapFindInstanceMap (uint32 instanceId) const
bool DestroyInstance (InstancedMaps::iterator &itr)
InstancedMapsGetInstancedMaps ()
void InitVisibilityDistance () override
- Public Member Functions inherited from Map
 Map (uint32 id, uint32 InstanceId, uint8 SpawnMode, Map *_parent=nullptr)
 ~Map () override
MapEntry const * GetEntry () const
bool CanUnload (uint32 diff)
virtual bool AddPlayerToMap (Player *)
virtual void RemovePlayerFromMap (Player *, bool)
virtual void AfterPlayerUnlinkFromMap ()
template<class T >
bool AddToMap (T *, bool checkTransport=false)
template<class T >
void RemoveFromMap (T *, bool)
void VisitNearbyCellsOf (WorldObject *obj, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &worldVisitor, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &largeGridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &largeWorldVisitor)
void VisitNearbyCellsOfPlayer (Player *player, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &worldVisitor, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &largeGridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &largeWorldVisitor)
virtual void Update (const uint32, const uint32, bool thread=true)
float GetVisibilityRange () const
void SetVisibilityRange (float range)
virtual void InitVisibilityDistance ()
void PlayerRelocation (Player *, float x, float y, float z, float o)
void CreatureRelocation (Creature *creature, float x, float y, float z, float o)
void GameObjectRelocation (GameObject *go, float x, float y, float z, float o)
void DynamicObjectRelocation (DynamicObject *go, float x, float y, float z, float o)
template<class T , class CONTAINER >
void Visit (const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
bool IsRemovalGrid (float x, float y) const
bool IsGridLoaded (float x, float y) const
void LoadGrid (float x, float y)
void LoadAllCells ()
bool UnloadGrid (NGridType &ngrid)
virtual void UnloadAll ()
uint32 GetId () const
Map const * GetParent () const
std::shared_mutex & GetMMapLock () const
void HandleDelayedVisibility ()
float GetHeight (float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
float GetGridHeight (float x, float y) const
float GetMinHeight (float x, float y) const
TransportGetTransportForPos (uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
void GetFullTerrainStatusForPosition (uint32 phaseMask, float x, float y, float z, float collisionHeight, PositionFullTerrainStatus &data, uint8 reqLiquidType=MAP_ALL_LIQUIDS)
LiquidData const GetLiquidData (uint32 phaseMask, float x, float y, float z, float collisionHeight, uint8 ReqLiquidType)
bool GetAreaInfo (uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
uint32 GetAreaId (uint32 phaseMask, float x, float y, float z) const
uint32 GetZoneId (uint32 phaseMask, float x, float y, float z) const
void GetZoneAndAreaId (uint32 phaseMask, uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
float GetWaterLevel (float x, float y) const
bool IsInWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
bool IsUnderWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
bool HasEnoughWater (WorldObject const *searcher, float x, float y, float z) const
bool HasEnoughWater (WorldObject const *searcher, LiquidData const &liquidData) const
void MoveAllCreaturesInMoveList ()
void MoveAllGameObjectsInMoveList ()
void MoveAllDynamicObjectsInMoveList ()
void RemoveAllObjectsInRemoveList ()
virtual void RemoveAllPlayers ()
uint32 GetInstanceId () const
uint8 GetSpawnMode () const
virtual EnterState CannotEnter (Player *, bool)
const char * GetMapName () const
Difficulty GetDifficulty () const
bool IsRegularDifficulty () const
MapDifficulty const * GetMapDifficulty () const
bool Instanceable () const
bool IsDungeon () const
bool IsNonRaidDungeon () const
bool IsRaid () const
bool IsRaidOrHeroicDungeon () const
bool IsHeroic () const
bool Is25ManRaid () const
bool IsBattleground () const
bool IsBattleArena () const
bool IsBattlegroundOrArena () const
bool GetEntrancePos (int32 &mapid, float &x, float &y)
void AddObjectToRemoveList (WorldObject *obj)
void AddObjectToSwitchList (WorldObject *obj, bool on)
virtual void DelayedUpdate (const uint32 diff)
void resetMarkedCells ()
bool isCellMarked (uint32 pCellId)
void markCell (uint32 pCellId)
void resetMarkedCellsLarge ()
bool isCellMarkedLarge (uint32 pCellId)
void markCellLarge (uint32 pCellId)
bool HavePlayers () const
uint32 GetPlayersCountExceptGMs () const
void AddWorldObject (WorldObject *obj)
void RemoveWorldObject (WorldObject *obj)
void SendToPlayers (WorldPacket const *data) const
PlayerList const & GetPlayers () const
void ScriptsStart (std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
 Put scripts in the execution queue.
void ScriptCommandStart (ScriptInfo const &script, uint32 delay, Object *source, Object *target)
template<class T >
void AddToActive (T *obj)
template<class T >
void RemoveFromActive (T *obj)
template<class T >
void SwitchGridContainers (T *obj, bool on)
void UpdateIteratorBack (Player *player)
TempSummonSummonCreature (uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, bool visibleBySummonerOnly=false)
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true)
GameObjectSummonGameObject (uint32 entry, Position const &pos, float rotation0=0.0f, float rotation1=0.0f, float rotation2=0.0f, float rotation3=0.0f, uint32 respawnTime=100, bool checkTransport=true)
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
CorpseGetCorpse (ObjectGuid const guid)
CreatureGetCreature (ObjectGuid const guid)
GameObjectGetGameObject (ObjectGuid const guid)
TransportGetTransport (ObjectGuid const guid)
DynamicObjectGetDynamicObject (ObjectGuid const guid)
PetGetPet (ObjectGuid const guid)
MapStoredObjectTypesContainerGetObjectsStore ()
CreatureBySpawnIdContainerGetCreatureBySpawnIdStore ()
GameObjectBySpawnIdContainerGetGameObjectBySpawnIdStore ()
std::unordered_set< Corpse * > const * GetCorpsesInCell (uint32 cellId) const
CorpseGetCorpseByPlayer (ObjectGuid const &ownerGuid) const
MapInstancedToMapInstanced ()
MapInstanced const * ToMapInstanced () const
InstanceMapToInstanceMap ()
InstanceMap const * ToInstanceMap () const
BattlegroundMapToBattlegroundMap ()
BattlegroundMap const * ToBattlegroundMap () const
float GetWaterOrGroundLevel (uint32 phasemask, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=DEFAULT_COLLISION_HEIGHT) const
float GetHeight (uint32 phasemask, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
bool isInLineOfSight (float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
bool CanReachPositionAndGetValidCoords (WorldObject const *source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 Check if a given source can reach a specific point following a path and normalize the coords. Use this method for long paths, otherwise use the overloaded method with the start coords when you need to do a quick check on small segments.
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 validate the new destination and set reachable coords Check if a given unit can reach a specific point on a segment and set the correct dest coords NOTE: use this method with small segments.
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
bool CheckCollisionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true) const
 validate the new destination and set coords Check if a given unit can face collisions in a specific segment
void Balance ()
void RemoveGameObjectModel (const GameObjectModel &model)
void InsertGameObjectModel (const GameObjectModel &model)
bool ContainsGameObjectModel (const GameObjectModel &model) const
DynamicMapTree const & GetDynamicMapTree () const
bool GetObjectHitPos (uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
float GetGameObjectFloor (uint32 phasemask, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
time_t GetLinkedRespawnTime (ObjectGuid guid) const
time_t GetCreatureRespawnTime (ObjectGuid::LowType dbGuid) const
time_t GetGORespawnTime (ObjectGuid::LowType dbGuid) const
void SaveCreatureRespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
void RemoveCreatureRespawnTime (ObjectGuid::LowType dbGuid)
void SaveGORespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
void RemoveGORespawnTime (ObjectGuid::LowType dbGuid)
void LoadRespawnTimes ()
void DeleteRespawnTimes ()
time_t GetInstanceResetPeriod () const
void LoadCorpseData ()
void DeleteCorpseData ()
void AddCorpse (Corpse *corpse)
void RemoveCorpse (Corpse *corpse)
CorpseConvertCorpseToBones (ObjectGuid const ownerGuid, bool insignia=false)
void RemoveOldCorpses ()
void SendInitTransports (Player *player)
void SendRemoveTransports (Player *player)
void SendZoneDynamicInfo (Player *player)
void SendInitSelf (Player *player)
void PlayDirectSoundToMap (uint32 soundId, uint32 zoneId=0)
void SetZoneMusic (uint32 zoneId, uint32 musicId)
void SetZoneWeather (uint32 zoneId, WeatherState weatherId, float weatherGrade)
void SetZoneOverrideLight (uint32 zoneId, uint32 lightId, Milliseconds fadeInTime)
void UpdateEncounterState (EncounterCreditType type, uint32 creditEntry, Unit *source)
void LogEncounterFinished (EncounterCreditType type, uint32 creditEntry)
void DoForAllPlayers (std::function< void(Player *)> exec)
GridMapGetGrid (float x, float y)
void EnsureGridCreated (const GridCoord &)
bool AllTransportsEmpty () const
void AllTransportsRemovePassengers ()
TransportsContainer const & GetAllTransports () const
template<HighGuid high>
ObjectGuid::LowType GenerateLowGuid ()
void AddUpdateObject (Object *obj)
void RemoveUpdateObject (Object *obj)
size_t GetActiveNonPlayersCount () const
virtual std::string GetDebugInfo () const
void AddToGrid (Creature *obj, Cell const &cell)
void AddToGrid (GameObject *obj, Cell const &cell)
void AddToGrid (DynamicObject *obj, Cell const &cell)
void AddToGrid (Corpse *obj, Cell const &cell)
void SwitchGridContainers (Creature *obj, bool on)
void SwitchGridContainers (GameObject *obj, bool on)
void DeleteFromWorld (Player *player)
void InitializeObject (Creature *)
void InitializeObject (GameObject *)
bool AddToMap (MotionTransport *obj, bool)
void RemoveFromMap (MotionTransport *obj, bool remove)
void AddToActive (Creature *c)
void AddToActive (DynamicObject *d)
void AddToActive (GameObject *d)
void RemoveFromActive (Creature *c)
void RemoveFromActive (DynamicObject *obj)
void RemoveFromActive (GameObject *obj)
- Public Member Functions inherited from GridRefMgr< NGridType >
GridReference< NGridType > * getFirst ()
GridReference< NGridType > * getLast ()
iterator begin ()
iterator end ()
iterator rbegin ()
iterator rend ()
- Public Member Functions inherited from RefMgr< TO, FROM >
 RefMgr ()=default
virtual ~RefMgr ()
Reference< TO, FROM > * getFirst ()
Reference< TO, FROM > const * getFirst () const
Reference< TO, FROM > * getLast ()
Reference< TO, FROM > const * getLast () const
iterator begin ()
iterator end ()
iterator rbegin ()
iterator rend ()
void clearReferences ()
- Public Member Functions inherited from LinkedListHead
 LinkedListHead ()
bool IsEmpty () const
LinkedListElementgetFirst ()
LinkedListElement const * getFirst () const
LinkedListElementgetLast ()
LinkedListElement const * getLast () const
void insertFirst (LinkedListElement *pElem)
void insertLast (LinkedListElement *pElem)
uint32 getSize () const
void incSize ()
void decSize ()

Private Member Functions

InstanceMapCreateInstance (uint32 InstanceId, InstanceSave *save, Difficulty difficulty)
BattlegroundMapCreateBattleground (uint32 InstanceId, Battleground *bg)

Private Attributes

InstancedMaps m_InstancedMaps


class MapMgr

Additional Inherited Members

- Static Public Member Functions inherited from Map
static bool ExistMap (uint32 mapid, int gx, int gy)
static bool ExistVMap (uint32 mapid, int gx, int gy)
static void DeleteRespawnTimesInDB (uint16 mapId, uint32 instanceId)
- Public Attributes inherited from Map
std::unordered_set< Unit * > i_objectsForDelayedVisibility
CreatureGroupHolderType CreatureGroupHolder
DataMap CustomData
- Protected Types inherited from Map
typedef std::set< WorldObject * > ActiveNonPlayers
- Protected Attributes inherited from Map
std::mutex Lock
std::mutex GridLock
std::shared_mutex MMapLock
MapEntry const * i_mapEntry
uint8 i_spawnMode
uint32 i_InstanceId
uint32 m_unloadTimer
float m_VisibleDistance
DynamicMapTree _dynamicTree
time_t _instanceResetPeriod
MapRefMgr m_mapRefMgr
MapRefMgr::iterator m_mapRefIter
ActiveNonPlayers m_activeNonPlayers
ActiveNonPlayers::iterator m_activeNonPlayersIter
TransportsContainer _transports
TransportsContainer::iterator _transportsUpdateIter

Detailed Description

Member Typedef Documentation

◆ InstancedMaps

using MapInstanced::InstancedMaps = std::unordered_map<uint32, Map*>

Constructor & Destructor Documentation

◆ MapInstanced()

MapInstanced::MapInstanced ( uint32  id)
31 // initialize instanced maps list
32 m_InstancedMaps.clear();
Definition: DBCEnums.h:274
Definition: Map.h:312
InstancedMaps m_InstancedMaps
Definition: MapInstanced.h:56

References m_InstancedMaps.

◆ ~MapInstanced()

MapInstanced::~MapInstanced ( )

Member Function Documentation

◆ CannotEnter()

Map::EnterState MapInstanced::CannotEnter ( Player player,
bool  loginCheck = false 

Reimplemented from Map.

273 //ABORT();
274 return CAN_ENTER;
Definition: Map.h:423

References Map::CAN_ENTER.

◆ CreateBattleground()

BattlegroundMap * MapInstanced::CreateBattleground ( uint32  InstanceId,
Battleground bg 
226 // load/create a map
227 std::lock_guard<std::mutex> guard(Lock);
229 LOG_DEBUG("maps", "MapInstanced::CreateBattleground: map bg {} for {} created.", InstanceId, GetId());
231 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), bg->GetMinLevel());
233 uint8 spawnMode;
235 if (bracketEntry)
236 spawnMode = bracketEntry->difficulty;
237 else
240 BattlegroundMap* map = new BattlegroundMap(GetId(), InstanceId, this, spawnMode);
242 map->SetBG(bg);
243 bg->SetBgMap(map);
245 m_InstancedMaps[InstanceId] = map;
246 return map;
#define ASSERT
Definition: Errors.h:68
std::uint8_t uint8
Definition: Define.h:110
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:786
Definition: DBCEnums.h:272
uint32 GetMapId() const
Definition: Battleground.h:420
uint32 GetMinLevel() const
Definition: Battleground.h:328
void SetBgMap(BattlegroundMap *map)
Definition: Battleground.h:423
bool IsBattlegroundOrArena() const
Definition: Map.h:455
std::mutex Lock
Definition: Map.h:698
uint32 GetId() const
Definition: Map.h:378
Definition: Map.h:847
void SetBG(Battleground *bg)
Definition: Map.h:861
Definition: DBCStructure.h:1414
uint32 difficulty
Definition: DBCStructure.h:1420

References ASSERT, PvPDifficultyEntry::difficulty, GetBattlegroundBracketByLevel(), Map::GetId(), Battleground::GetMapId(), Battleground::GetMinLevel(), Map::IsBattlegroundOrArena(), Map::Lock, LOG_DEBUG, m_InstancedMaps, REGULAR_DIFFICULTY, BattlegroundMap::SetBG(), and Battleground::SetBgMap().

Referenced by CreateInstanceForPlayer().

◆ CreateInstance()

InstanceMap * MapInstanced::CreateInstance ( uint32  InstanceId,
InstanceSave save,
Difficulty  difficulty 
184 // load/create a map
185 std::lock_guard<std::mutex> guard(Lock);
187 // make sure we have a valid map id
188 MapEntry const* entry = sMapStore.LookupEntry(GetId());
189 if (!entry)
190 {
191 LOG_ERROR("maps", "CreateInstance: no entry for map {}", GetId());
192 ABORT();
193 }
194 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
195 if (!iTemplate)
196 {
197 LOG_ERROR("maps", "CreateInstance: no instance template for map {}", GetId());
198 ABORT();
199 }
201 // some instances only have one difficulty
204 LOG_DEBUG("maps", "MapInstanced::CreateInstance: {} map instance {} for {} created with difficulty {}", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
206 InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
207 ASSERT(map->IsDungeon());
209 map->LoadRespawnTimes();
210 map->LoadCorpseData();
212 if (save)
214 else
215 map->CreateInstanceScript(false, "", 0);
217 if (!save) // this is for sure a dungeon (assert above), no need to check here
218 sInstanceSaveMgr->AddInstanceSave(GetId(), InstanceId, difficulty);
220 m_InstancedMaps[InstanceId] = map;
221 return map;
#define ABORT
Definition: Errors.h:76
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
MapDifficulty const * GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty)
Definition: DBCStores.cpp:760
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sObjectMgr
Definition: ObjectMgr.h:1640
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
std::string GetInstanceData() const
Definition: InstanceSaveMgr.h:69
uint32 GetCompletedEncounterMask() const
Definition: InstanceSaveMgr.h:71
Definition: Map.h:273
bool IsDungeon() const
Definition: Map.h:447
void LoadRespawnTimes()
Definition: Map.cpp:3396
void LoadCorpseData()
Definition: Map.cpp:3982
Definition: Map.h:813
void CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask)
Definition: Map.cpp:3038
Definition: DBCStructure.h:1308

References ABORT, ASSERT, InstanceMap::CreateInstanceScript(), InstanceSave::GetCompletedEncounterMask(), GetDownscaledMapDifficultyData(), Map::GetId(), InstanceSave::GetInstanceData(), Map::IsDungeon(), Map::LoadCorpseData(), Map::LoadRespawnTimes(), Map::Lock, LOG_DEBUG, LOG_ERROR, m_InstancedMaps, sInstanceSaveMgr, sMapStore, and sObjectMgr.

Referenced by CreateInstanceForPlayer().

◆ CreateInstanceForPlayer()

Map * MapInstanced::CreateInstanceForPlayer ( const uint32  mapId,
Player player 
114 if (GetId() != mapId || !player)
115 return nullptr;
117 Map* map = nullptr;
120 {
121 // instantiate or find existing bg map for player
122 // the instance id is set in battlegroundid
123 uint32 newInstanceId = player->GetBattlegroundId();
124 if (!newInstanceId)
125 return nullptr;
127 map = sMapMgr->FindMap(mapId, newInstanceId);
128 if (!map)
129 {
130 Battleground* bg = player->GetBattleground(true);
131 if (bg && bg->GetStatus() < STATUS_WAIT_LEAVE)
132 map = CreateBattleground(newInstanceId, bg);
133 else
134 {
135 player->TeleportToEntryPoint();
136 return nullptr;
137 }
138 }
139 }
140 else
141 {
142 Difficulty realdiff = player->GetDifficulty(IsRaid());
143 uint32 destInstId = sInstanceSaveMgr->PlayerGetDestinationInstanceId(player, GetId(), realdiff);
145 if (destInstId)
146 {
147 InstanceSave* pSave = sInstanceSaveMgr->GetInstanceSave(destInstId);
148 ASSERT(pSave); // pussywizard: must exist
150 map = FindInstanceMap(destInstId);
151 if (!map)
152 map = CreateInstance(destInstId, pSave, realdiff);
153 else if (IsSharedDifficultyMap(mapId) && !map->HavePlayers() && map->GetDifficulty() != realdiff)
154 {
155 if (player->isBeingLoaded()) // pussywizard: crashfix (assert(passengers.empty) fail in ~transport), could be added to a transport during loading from db
156 return nullptr;
158 if (!map->AllTransportsEmpty())
159 map->AllTransportsRemovePassengers(); // pussywizard: gameobjects / summons (assert(passengers.empty) fail in ~transport)
161 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
162 if (i->first == destInstId)
163 {
165 map = CreateInstance(destInstId, pSave, realdiff);
166 break;
167 }
168 }
169 }
170 else
171 {
172 uint32 newInstanceId = sMapMgr->GenerateInstanceId();
173 ASSERT(!FindInstanceMap(newInstanceId)); // pussywizard: instance with new id can't exist
174 Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
175 map = CreateInstance(newInstanceId, nullptr, diff);
176 }
177 }
179 return map;
std::uint32_t uint32
Definition: Define.h:108
Definition: Battleground.h:198
bool IsSharedDifficultyMap(uint32 mapid)
Definition: DBCStores.cpp:822
#define sMapMgr
Definition: MapMgr.h:221
Definition: DBCEnums.h:271
Definition: Battleground.h:293
BattlegroundStatus GetStatus() const
Definition: Battleground.h:322
bool isBeingLoaded() const override
Definition: PlayerStorage.cpp:4940
Difficulty GetDifficulty(bool isRaid) const
Definition: Player.h:1870
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12097
bool TeleportToEntryPoint()
Definition: Player.cpp:1578
Group * GetGroup()
Definition: Player.h:2418
uint32 GetBattlegroundId() const
Definition: Player.h:2203
Difficulty GetDifficulty(bool isRaid) const
Definition: Group.cpp:2382
Definition: InstanceSaveMgr.h:56
bool IsRaid() const
Definition: Map.h:449
bool HavePlayers() const
Definition: Map.h:475
void AllTransportsRemovePassengers()
Definition: Map.cpp:3553
bool AllTransportsEmpty() const
Definition: Map.cpp:3544
Difficulty GetDifficulty() const
Definition: Map.h:442
Map * FindInstanceMap(uint32 instanceId) const
Definition: MapInstanced.h:42
bool DestroyInstance(InstancedMaps::iterator &itr)
Definition: MapInstanced.cpp:250
BattlegroundMap * CreateBattleground(uint32 InstanceId, Battleground *bg)
Definition: MapInstanced.cpp:224
InstanceMap * CreateInstance(uint32 InstanceId, InstanceSave *save, Difficulty difficulty)
Definition: MapInstanced.cpp:182

References Map::AllTransportsEmpty(), Map::AllTransportsRemovePassengers(), ASSERT, CreateBattleground(), CreateInstance(), DestroyInstance(), FindInstanceMap(), Player::GetBattleground(), Player::GetBattlegroundId(), Map::GetDifficulty(), Player::GetDifficulty(), Group::GetDifficulty(), Player::GetGroup(), Map::GetId(), Battleground::GetStatus(), Map::HavePlayers(), Map::IsBattlegroundOrArena(), Player::isBeingLoaded(), Map::IsRaid(), IsSharedDifficultyMap(), m_InstancedMaps, sInstanceSaveMgr, sMapMgr, STATUS_WAIT_LEAVE, and Player::TeleportToEntryPoint().

◆ DelayedUpdate()

void MapInstanced::DelayedUpdate ( const uint32  diff)

Reimplemented from Map.

77 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
78 i->second->DelayedUpdate(diff);
80 Map::DelayedUpdate(diff); // this may be removed
virtual void DelayedUpdate(const uint32 diff)
Definition: Map.cpp:2619

References Map::DelayedUpdate(), and m_InstancedMaps.

◆ DestroyInstance()

bool MapInstanced::DestroyInstance ( InstancedMaps::iterator &  itr)
252 itr->second->RemoveAllPlayers();
254 if (itr->second->HavePlayers())
255 {
256 ++itr;
257 return false;
258 }
260 sScriptMgr->OnDestroyInstance(this, itr->second);
262 itr->second->UnloadAll();
264 // erase map
265 delete itr->second;
266 m_InstancedMaps.erase(itr++);
268 return true;
#define sScriptMgr
Definition: ScriptMgr.h:2702

References m_InstancedMaps, and sScriptMgr.

Referenced by CreateInstanceForPlayer(), and Update().

◆ FindInstanceMap()

Map * MapInstanced::FindInstanceMap ( uint32  instanceId) const
43 {
44 InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId);
45 return(i == m_InstancedMaps.end() ? nullptr : i->second);
46 }

References m_InstancedMaps.

Referenced by CreateInstanceForPlayer().

◆ GetInstancedMaps()

InstancedMaps & MapInstanced::GetInstancedMaps ( )
49{ return m_InstancedMaps; }

References m_InstancedMaps.

◆ InitVisibilityDistance()

void MapInstanced::InitVisibilityDistance ( )

Reimplemented from Map.

37 if (m_InstancedMaps.empty())
38 return;
39 //initialize visibility distances for all instance copies
40 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
41 {
42 (*i).second->InitVisibilityDistance();
43 }

References m_InstancedMaps.

◆ UnloadAll()

void MapInstanced::UnloadAll ( )

Reimplemented from Map.

93 // Unload instanced maps
94 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
95 i->second->UnloadAll();
97 // Delete the maps only after everything is unloaded to prevent crashes
98 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
99 delete i->second;
101 m_InstancedMaps.clear();
103 // Unload own grids (just dummy(placeholder) grids, neccesary to unload GridMaps!)
virtual void UnloadAll()
Definition: Map.cpp:1278

References m_InstancedMaps, and Map::UnloadAll().

◆ Update()

void MapInstanced::Update ( const uint32  t,
const uint32  s_diff,
bool  thread = true 

Reimplemented from Map.

48 // take care of loaded GridMaps (when unused, unload it!)
49 Map::Update(t, s_diff, false);
51 // update the instanced maps
52 InstancedMaps::iterator i = m_InstancedMaps.begin();
54 while (i != m_InstancedMaps.end())
55 {
56 if (i->second->CanUnload(t))
57 {
58 if (!DestroyInstance(i)) // iterator incremented
59 {
60 //m_unloadTimer
61 }
62 }
63 else
64 {
65 // update only here, because it may schedule some bad things before delete
66 if (sMapMgr->GetMapUpdater()->activated())
67 sMapMgr->GetMapUpdater()->schedule_update(*i->second, t, s_diff);
68 else
69 i->second->Update(t, s_diff);
70 ++i;
71 }
72 }
virtual void Update(const uint32, const uint32, bool thread=true)
Definition: Map.cpp:741

References DestroyInstance(), m_InstancedMaps, sMapMgr, and Map::Update().

Friends And Related Function Documentation

◆ MapMgr

friend class MapMgr

Member Data Documentation

◆ m_InstancedMaps