AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
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 ,
  CANNOT_ENTER_ALREADY_IN_MAP = 1 ,
  CANNOT_ENTER_NO_ENTRY ,
  CANNOT_ENTER_UNINSTANCED_DUNGEON ,
  CANNOT_ENTER_DIFFICULTY_UNAVAILABLE ,
  CANNOT_ENTER_NOT_IN_RAID ,
  CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE ,
  CANNOT_ENTER_INSTANCE_BIND_MISMATCH ,
  CANNOT_ENTER_TOO_MANY_INSTANCES ,
  CANNOT_ENTER_MAX_PLAYERS ,
  CANNOT_ENTER_ZONE_IN_COMBAT ,
  CANNOT_ENTER_UNSPECIFIED_REASON
}
 
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 IsWorldMap () 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. More...
 
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. More...
 
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. More...
 
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 More...
 
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 ScheduleCreatureRespawn (ObjectGuid, Milliseconds)
 
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)
 
std::size_t GetActiveNonPlayersCount () const
 
virtual std::string GetDebugInfo () const
 
template<>
void AddToGrid (Creature *obj, Cell const &cell)
 
template<>
void AddToGrid (GameObject *obj, Cell const &cell)
 
template<>
void AddToGrid (DynamicObject *obj, Cell const &cell)
 
template<>
void AddToGrid (Corpse *obj, Cell const &cell)
 
template<>
void SwitchGridContainers (Creature *obj, bool on)
 
template<>
void SwitchGridContainers (GameObject *obj, bool on)
 
template<>
void DeleteFromWorld (Player *player)
 
template<>
void InitializeObject (Creature *)
 
template<>
void InitializeObject (GameObject *)
 
template<>
bool AddToMap (MotionTransport *obj, bool)
 
template<>
void RemoveFromMap (MotionTransport *obj, bool remove)
 
template<>
void AddToActive (Creature *c)
 
template<>
void AddToActive (DynamicObject *d)
 
template<>
void AddToActive (GameObject *d)
 
template<>
void RemoveFromActive (Creature *c)
 
template<>
void RemoveFromActive (DynamicObject *obj)
 
template<>
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
 

Friends

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
 
TaskScheduler _creatureRespawnScheduler
 
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)
28{
29 // initialize instanced maps list
30 m_InstancedMaps.clear();
31}
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:269
Definition: Map.h:311
InstancedMaps m_InstancedMaps
Definition: MapInstanced.h:56

References m_InstancedMaps.

◆ ~MapInstanced()

MapInstanced::~MapInstanced ( )
inlineoverride
32{}

Member Function Documentation

◆ CannotEnter()

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

Reimplemented from Map.

270{
271 //ABORT();
272 return CAN_ENTER;
273}
@ CAN_ENTER
Definition: Map.h:422

References Map::CAN_ENTER.

◆ CreateBattleground()

BattlegroundMap * MapInstanced::CreateBattleground ( uint32  InstanceId,
Battleground bg 
)
private
223{
224 // load/create a map
225 std::lock_guard<std::mutex> guard(Lock);
226
227 LOG_DEBUG("maps", "MapInstanced::CreateBattleground: map bg {} for {} created.", InstanceId, GetId());
228
229 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), bg->GetMinLevel());
230
231 uint8 spawnMode;
232
233 if (bracketEntry)
234 spawnMode = bracketEntry->difficulty;
235 else
236 spawnMode = REGULAR_DIFFICULTY;
237
238 BattlegroundMap* map = new BattlegroundMap(GetId(), InstanceId, this, spawnMode);
240 map->SetBG(bg);
241 bg->SetBgMap(map);
242
243 m_InstancedMaps[InstanceId] = map;
244 return map;
245}
#define ASSERT
Definition: Errors.h:68
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
std::uint8_t uint8
Definition: Define.h:109
@ REGULAR_DIFFICULTY
Definition: DBCEnums.h:267
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:793
uint32 GetMapId() const
Definition: Battleground.h:445
uint32 GetMinLevel() const
Definition: Battleground.h:338
void SetBgMap(BattlegroundMap *map)
Definition: Battleground.h:448
bool IsBattlegroundOrArena() const
Definition: Map.h:454
std::mutex Lock
Definition: Map.h:702
uint32 GetId() const
Definition: Map.h:377
Definition: Map.h:851
void SetBG(Battleground *bg)
Definition: Map.h:865
Definition: DBCStructure.h:1430
uint32 difficulty
Definition: DBCStructure.h:1436

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 
)
private
181{
182 // load/create a map
183 std::lock_guard<std::mutex> guard(Lock);
184
185 // make sure we have a valid map id
186 MapEntry const* entry = sMapStore.LookupEntry(GetId());
187 if (!entry)
188 {
189 LOG_ERROR("maps", "CreateInstance: no entry for map {}", GetId());
190 ABORT();
191 }
192 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
193 if (!iTemplate)
194 {
195 LOG_ERROR("maps", "CreateInstance: no instance template for map {}", GetId());
196 ABORT();
197 }
198
199 // some instances only have one difficulty
201
202 LOG_DEBUG("maps", "MapInstanced::CreateInstance: {} map instance {} for {} created with difficulty {}", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
203
204 InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
205 ASSERT(map->IsDungeon());
206
207 map->LoadRespawnTimes();
208 map->LoadCorpseData();
209
210 if (save)
212 else
213 map->CreateInstanceScript(false, "", 0);
214
215 if (!save) // this is for sure a dungeon (assert above), no need to check here
216 sInstanceSaveMgr->AddInstanceSave(GetId(), InstanceId, difficulty);
217
218 m_InstancedMaps[InstanceId] = map;
219 return map;
220}
#define ABORT
Definition: Errors.h:76
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
#define sObjectMgr
Definition: ObjectMgr.h:1635
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
MapDifficulty const * GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty)
Definition: DBCStores.cpp:767
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
std::string GetInstanceData() const
Definition: InstanceSaveMgr.h:69
uint32 GetCompletedEncounterMask() const
Definition: InstanceSaveMgr.h:71
Definition: Map.h:272
bool IsDungeon() const
Definition: Map.h:446
void LoadRespawnTimes()
Definition: Map.cpp:3420
void LoadCorpseData()
Definition: Map.cpp:4017
Definition: Map.h:817
void CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask)
Definition: Map.cpp:3060
Definition: DBCStructure.h:1324

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 
)
111{
112 if (GetId() != mapId || !player)
113 return nullptr;
114
115 Map* map = nullptr;
116
118 {
119 // instantiate or find existing bg map for player
120 // the instance id is set in battlegroundid
121 uint32 newInstanceId = player->GetBattlegroundId();
122 if (!newInstanceId)
123 return nullptr;
124
125 map = sMapMgr->FindMap(mapId, newInstanceId);
126 if (!map)
127 {
128 Battleground* bg = player->GetBattleground(true);
129 if (bg && bg->GetStatus() < STATUS_WAIT_LEAVE)
130 map = CreateBattleground(newInstanceId, bg);
131 else
132 {
133 player->TeleportToEntryPoint();
134 return nullptr;
135 }
136 }
137 }
138 else
139 {
140 Difficulty realdiff = player->GetDifficulty(IsRaid());
141 uint32 destInstId = sInstanceSaveMgr->PlayerGetDestinationInstanceId(player, GetId(), realdiff);
142
143 if (destInstId)
144 {
145 InstanceSave* pSave = sInstanceSaveMgr->GetInstanceSave(destInstId);
146 ASSERT(pSave); // pussywizard: must exist
147
148 map = FindInstanceMap(destInstId);
149 if (!map)
150 map = CreateInstance(destInstId, pSave, realdiff);
151 else if (IsSharedDifficultyMap(mapId) && !map->HavePlayers() && map->GetDifficulty() != realdiff)
152 {
153 if (player->isBeingLoaded()) // pussywizard: crashfix (assert(passengers.empty) fail in ~transport), could be added to a transport during loading from db
154 return nullptr;
155
156 if (!map->AllTransportsEmpty())
157 map->AllTransportsRemovePassengers(); // pussywizard: gameobjects / summons (assert(passengers.empty) fail in ~transport)
158
159 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
160 if (i->first == destInstId)
161 {
163 map = CreateInstance(destInstId, pSave, realdiff);
164 break;
165 }
166 }
167 }
168 else
169 {
170 uint32 newInstanceId = sMapMgr->GenerateInstanceId();
171 ASSERT(!FindInstanceMap(newInstanceId)); // pussywizard: instance with new id can't exist
172 Difficulty diff = player->GetGroup() ? player->GetGroup()->GetDifficulty(IsRaid()) : player->GetDifficulty(IsRaid());
173 map = CreateInstance(newInstanceId, nullptr, diff);
174 }
175 }
176
177 return map;
178}
std::uint32_t uint32
Definition: Define.h:107
Difficulty
Definition: DBCEnums.h:266
#define sMapMgr
Definition: MapMgr.h:219
bool IsSharedDifficultyMap(uint32 mapid)
Definition: DBCStores.cpp:829
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:203
Definition: Battleground.h:303
BattlegroundStatus GetStatus() const
Definition: Battleground.h:332
bool isBeingLoaded() const override
Definition: PlayerStorage.cpp:4914
Difficulty GetDifficulty(bool isRaid) const
Definition: Player.h:1920
Battleground * GetBattleground(bool create=false) const
Definition: Player.cpp:12228
bool TeleportToEntryPoint()
Definition: Player.cpp:1601
Group * GetGroup()
Definition: Player.h:2468
uint32 GetBattlegroundId() const
Definition: Player.h:2254
Difficulty GetDifficulty(bool isRaid) const
Definition: Group.cpp:2439
Definition: InstanceSaveMgr.h:56
bool IsRaid() const
Definition: Map.h:448
bool HavePlayers() const
Definition: Map.h:475
void AllTransportsRemovePassengers()
Definition: Map.cpp:3577
bool AllTransportsEmpty() const
Definition: Map.cpp:3568
Difficulty GetDifficulty() const
Definition: Map.h:441
Map * FindInstanceMap(uint32 instanceId) const
Definition: MapInstanced.h:42
bool DestroyInstance(InstancedMaps::iterator &itr)
Definition: MapInstanced.cpp:248
BattlegroundMap * CreateBattleground(uint32 InstanceId, Battleground *bg)
Definition: MapInstanced.cpp:222
InstanceMap * CreateInstance(uint32 InstanceId, InstanceSave *save, Difficulty difficulty)
Definition: MapInstanced.cpp:180

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)
overridevirtual

Reimplemented from Map.

74{
75 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
76 i->second->DelayedUpdate(diff);
77
78 Map::DelayedUpdate(diff); // this may be removed
79}
virtual void DelayedUpdate(const uint32 diff)
Definition: Map.cpp:2638

References Map::DelayedUpdate(), and m_InstancedMaps.

◆ DestroyInstance()

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

References m_InstancedMaps, and sScriptMgr.

Referenced by CreateInstanceForPlayer(), and Update().

◆ FindInstanceMap()

Map * MapInstanced::FindInstanceMap ( uint32  instanceId) const
inline
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 ( )
inline
49{ return m_InstancedMaps; }

References m_InstancedMaps.

◆ InitVisibilityDistance()

void MapInstanced::InitVisibilityDistance ( )
overridevirtual

Reimplemented from Map.

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

References m_InstancedMaps.

◆ UnloadAll()

void MapInstanced::UnloadAll ( )
overridevirtual

Reimplemented from Map.

90{
91 // Unload instanced maps
92 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
93 i->second->UnloadAll();
94
95 // Delete the maps only after everything is unloaded to prevent crashes
96 for (InstancedMaps::iterator i = m_InstancedMaps.begin(); i != m_InstancedMaps.end(); ++i)
97 delete i->second;
98
99 m_InstancedMaps.clear();
100
101 // Unload own grids (just dummy(placeholder) grids, neccesary to unload GridMaps!)
103}
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 
)
overridevirtual

Reimplemented from Map.

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

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

Friends And Related Function Documentation

◆ MapMgr

friend class MapMgr
friend

Member Data Documentation

◆ m_InstancedMaps