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)
29{
30 // initialize instanced maps list
31 m_InstancedMaps.clear();
32}
@ DUNGEON_DIFFICULTY_NORMAL
Definition: DBCEnums.h:269
Definition: Map.h:313
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.

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

References Map::CAN_ENTER.

◆ CreateBattleground()

BattlegroundMap * MapInstanced::CreateBattleground ( uint32  InstanceId,
Battleground bg 
)
private
224{
225 // load/create a map
226 std::lock_guard<std::mutex> guard(Lock);
227
228 LOG_DEBUG("maps", "MapInstanced::CreateBattleground: map bg {} for {} created.", InstanceId, GetId());
229
230 PvPDifficultyEntry const* bracketEntry = GetBattlegroundBracketByLevel(bg->GetMapId(), bg->GetMinLevel());
231
232 uint8 spawnMode;
233
234 if (bracketEntry)
235 spawnMode = bracketEntry->difficulty;
236 else
237 spawnMode = REGULAR_DIFFICULTY;
238
239 BattlegroundMap* map = new BattlegroundMap(GetId(), InstanceId, this, spawnMode);
241 map->SetBG(bg);
242 bg->SetBgMap(map);
243
244 m_InstancedMaps[InstanceId] = map;
245 return map;
246}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
std::uint8_t uint8
Definition: Define.h:109
#define ASSERT
Definition: Errors.h:68
PvPDifficultyEntry const * GetBattlegroundBracketByLevel(uint32 mapid, uint32 level)
Definition: DBCStores.cpp:793
@ REGULAR_DIFFICULTY
Definition: DBCEnums.h:267
uint32 GetMapId() const
Definition: Battleground.h:428
uint32 GetMinLevel() const
Definition: Battleground.h:333
void SetBgMap(BattlegroundMap *map)
Definition: Battleground.h:431
bool IsBattlegroundOrArena() const
Definition: Map.h:456
std::mutex Lock
Definition: Map.h:704
uint32 GetId() const
Definition: Map.h:379
Definition: Map.h:853
void SetBG(Battleground *bg)
Definition: Map.h:867
Definition: DBCStructure.h:1431
uint32 difficulty
Definition: DBCStructure.h:1437

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
182{
183 // load/create a map
184 std::lock_guard<std::mutex> guard(Lock);
185
186 // make sure we have a valid map id
187 MapEntry const* entry = sMapStore.LookupEntry(GetId());
188 if (!entry)
189 {
190 LOG_ERROR("maps", "CreateInstance: no entry for map {}", GetId());
191 ABORT();
192 }
193 InstanceTemplate const* iTemplate = sObjectMgr->GetInstanceTemplate(GetId());
194 if (!iTemplate)
195 {
196 LOG_ERROR("maps", "CreateInstance: no instance template for map {}", GetId());
197 ABORT();
198 }
199
200 // some instances only have one difficulty
202
203 LOG_DEBUG("maps", "MapInstanced::CreateInstance: {} map instance {} for {} created with difficulty {}", save ? "" : "new ", InstanceId, GetId(), difficulty ? "heroic" : "normal");
204
205 InstanceMap* map = new InstanceMap(GetId(), InstanceId, difficulty, this);
206 ASSERT(map->IsDungeon());
207
208 map->LoadRespawnTimes();
209 map->LoadCorpseData();
210
211 if (save)
213 else
214 map->CreateInstanceScript(false, "", 0);
215
216 if (!save) // this is for sure a dungeon (assert above), no need to check here
217 sInstanceSaveMgr->AddInstanceSave(GetId(), InstanceId, difficulty);
218
219 m_InstancedMaps[InstanceId] = map;
220 return map;
221}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
#define ABORT
Definition: Errors.h:76
#define sInstanceSaveMgr
Definition: InstanceSaveMgr.h:202
#define sObjectMgr
Definition: ObjectMgr.h:1623
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:274
bool IsDungeon() const
Definition: Map.h:448
void LoadRespawnTimes()
Definition: Map.cpp:3417
void LoadCorpseData()
Definition: Map.cpp:4014
Definition: Map.h:819
void CreateInstanceScript(bool load, std::string data, uint32 completedEncounterMask)
Definition: Map.cpp:3057
Definition: DBCStructure.h:1325

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

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.

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

References Map::DelayedUpdate(), and m_InstancedMaps.

◆ DestroyInstance()

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

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.

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

References m_InstancedMaps.

◆ UnloadAll()

void MapInstanced::UnloadAll ( )
overridevirtual

Reimplemented from Map.

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

References m_InstancedMaps, and Map::UnloadAll().

◆ Update()

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

Reimplemented from Map.

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

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

Friends And Related Function Documentation

◆ MapMgr

friend class MapMgr
friend

Member Data Documentation

◆ m_InstancedMaps