TrinityCore
Map Class Reference

#include <Map.h>

Public Types

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 MapRefManager PlayerList
 
typedef std::unordered_multimap< ObjectGuid::LowType, Creature * > CreatureBySpawnIdContainer
 
typedef std::unordered_multimap< ObjectGuid::LowType, GameObject * > GameObjectBySpawnIdContainer
 
typedef std::unordered_multimap< ObjectGuid::LowType, AreaTrigger * > AreaTriggerBySpawnIdContainer
 
typedef std::function< void(Map *)> FarSpellCallback
 
- Public Types inherited from GridRefManager< NGridType >
typedef LinkedListHead::Iterator< GridReference< NGridType > > iterator
 
- Public Types inherited from RefManager< GridRefManager< NGridType >, NGridType >
typedef LinkedListHead::Iterator< Reference< GridRefManager< NGridType >, NGridType > > iterator
 
typedef LinkedListHead::Iterator< Reference< GridRefManager< NGridType >, NGridType > const > const_iterator
 
- Public Types inherited from LinkedListHead
typedef Iterator< LinkedListElementiterator
 

Public Member Functions

 Map (uint32 id, time_t, uint32 InstanceId, Difficulty SpawnMode, Map *_parent=nullptr)
 
virtual ~Map ()
 
MapEntry const * GetEntry () const
 
bool CanUnload (uint32 diff)
 
virtual bool AddPlayerToMap (Player *player, bool initPlayer=true)
 
virtual void RemovePlayerFromMap (Player *, bool)
 
template<class T >
bool AddToMap (T *)
 
template<class T >
void RemoveFromMap (T *, bool)
 
void VisitNearbyCellsOf (WorldObject *obj, TypeContainerVisitor< Trinity::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Trinity::ObjectUpdater, WorldTypeMapContainer > &worldVisitor)
 
virtual void Update (uint32)
 
float GetVisibilityRange () const
 
virtual void InitVisibilityDistance ()
 
void PlayerRelocation (Player *, float x, float y, float z, float orientation)
 
void CreatureRelocation (Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
 
void GameObjectRelocation (GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
 
void DynamicObjectRelocation (DynamicObject *go, float x, float y, float z, float orientation)
 
void AreaTriggerRelocation (AreaTrigger *at, float x, float y, float z, float orientation)
 
template<class T , class CONTAINER >
void Visit (Cell const &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
 
bool IsRemovalGrid (float x, float y) const
 
bool IsRemovalGrid (Position const &pos) const
 
bool IsGridLoaded (uint32 gridId) const
 
bool IsGridLoaded (float x, float y) const
 
bool IsGridLoaded (Position const &pos) const
 
bool GetUnloadLock (GridCoord const &p) const
 
void SetUnloadLock (GridCoord const &p, bool on)
 
void LoadGrid (float x, float y)
 
void LoadGridForActiveObject (float x, float y, WorldObject const *object)
 
void LoadAllCells ()
 
bool UnloadGrid (NGridType &ngrid, bool pForce)
 
void GridMarkNoUnload (uint32 x, uint32 y)
 
void GridUnmarkNoUnload (uint32 x, uint32 y)
 
virtual void UnloadAll ()
 
void ResetGridExpiry (NGridType &grid, float factor=1) const
 
time_t GetGridExpiry () const
 
bool HasChildMapGridFile (uint32 mapId, int32 gx, int32 gy) const
 
void DiscoverGridMapFiles ()
 
MapGetRootParentTerrainMap ()
 
void AddChildTerrainMap (Map *map)
 
void UnlinkAllChildTerrainMaps ()
 
void GetFullTerrainStatusForPosition (float x, float y, float z, PositionFullTerrainStatus &data, map_liquidHeaderTypeFlags reqLiquidType=map_liquidHeaderTypeFlags::AllLiquids, float collisionHeight=2.03128f) const
 
void GetFullTerrainStatusForPosition (PhaseShift const &phaseShift, float x, float y, float z, PositionFullTerrainStatus &data, map_liquidHeaderTypeFlags reqLiquidType=map_liquidHeaderTypeFlags::AllLiquids, float collisionHeight=2.03128f)
 
ZLiquidStatus GetLiquidStatus (PhaseShift const &phaseShift, float x, float y, float z, map_liquidHeaderTypeFlags ReqLiquidType, LiquidData *data=nullptr, float collisionHeight=2.03128f)
 
bool GetAreaInfo (PhaseShift const &phaseShift, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId)
 
uint32 GetAreaId (PhaseShift const &phaseShift, float x, float y, float z)
 
uint32 GetAreaId (PhaseShift const &phaseShift, Position const &pos)
 
uint32 GetZoneId (PhaseShift const &phaseShift, float x, float y, float z)
 
uint32 GetZoneId (PhaseShift const &phaseShift, Position const &pos)
 
void GetZoneAndAreaId (PhaseShift const &phaseShift, uint32 &zoneid, uint32 &areaid, float x, float y, float z)
 
void GetZoneAndAreaId (PhaseShift const &phaseShift, uint32 &zoneid, uint32 &areaid, Position const &pos)
 
float GetWaterLevel (PhaseShift const &phaseShift, float x, float y)
 
bool IsInWater (PhaseShift const &phaseShift, float x, float y, float z, LiquidData *data=nullptr)
 
bool IsUnderWater (PhaseShift const &phaseShift, float x, float y, float z)
 
void MoveAllCreaturesInMoveList ()
 
void MoveAllGameObjectsInMoveList ()
 
void MoveAllDynamicObjectsInMoveList ()
 
void MoveAllAreaTriggersInMoveList ()
 
void RemoveAllObjectsInRemoveList ()
 
virtual void RemoveAllPlayers ()
 
bool CreatureRespawnRelocation (Creature *c, bool diffGridOnly)
 
bool GameObjectRespawnRelocation (GameObject *go, bool diffGridOnly)
 
uint32 GetInstanceId () const
 
virtual EnterState CannotEnter (Player *)
 
char const * GetMapName () const
 
Difficulty GetDifficultyID () const
 
MapDifficultyEntry const * GetMapDifficulty () const
 
ItemContext GetDifficultyLootItemContext () const
 
uint32 GetId () 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 IsScenario () const
 
bool IsGarrison () const
 
bool GetEntrancePos (int32 &mapid, float &x, float &y)
 
void AddObjectToRemoveList (WorldObject *obj)
 
void AddObjectToSwitchList (WorldObject *obj, bool on)
 
virtual void DelayedUpdate (uint32 diff)
 
void resetMarkedCells ()
 
bool isCellMarked (uint32 pCellId)
 
void markCell (uint32 pCellId)
 
bool HavePlayers () const
 
uint32 GetPlayersCountExceptGMs () const
 
bool ActiveObjectsNearGrid (NGridType const &ngrid) const
 
void AddWorldObject (WorldObject *obj)
 
void RemoveWorldObject (WorldObject *obj)
 
void SendToPlayers (WorldPacket const *data) const
 
PlayerList const & GetPlayers () const
 
template<typename T >
void DoOnPlayers (T &&fn)
 
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)
 
void AddToActive (WorldObject *obj)
 
void RemoveFromActive (WorldObject *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, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon *> *list=nullptr)
 
AreaTriggerGetAreaTrigger (ObjectGuid const &guid)
 
SceneObjectGetSceneObject (ObjectGuid const &guid)
 
ConversationGetConversation (ObjectGuid const &guid)
 
PlayerGetPlayer (ObjectGuid const &guid)
 
CorpseGetCorpse (ObjectGuid const &guid)
 
CreatureGetCreature (ObjectGuid const &guid)
 
DynamicObjectGetDynamicObject (ObjectGuid const &guid)
 
GameObjectGetGameObject (ObjectGuid const &guid)
 
PetGetPet (ObjectGuid const &guid)
 
TransportGetTransport (ObjectGuid const &guid)
 
CreatureGetCreatureBySpawnId (ObjectGuid::LowType spawnId) const
 
GameObjectGetGameObjectBySpawnId (ObjectGuid::LowType spawnId) const
 
AreaTriggerGetAreaTriggerBySpawnId (ObjectGuid::LowType spawnId) const
 
WorldObjectGetWorldObjectBySpawnId (SpawnObjectType type, ObjectGuid::LowType spawnId) const
 
MapStoredObjectTypesContainerGetObjectsStore ()
 
CreatureBySpawnIdContainerGetCreatureBySpawnIdStore ()
 
CreatureBySpawnIdContainer const & GetCreatureBySpawnIdStore () const
 
GameObjectBySpawnIdContainerGetGameObjectBySpawnIdStore ()
 
GameObjectBySpawnIdContainer const & GetGameObjectBySpawnIdStore () const
 
AreaTriggerBySpawnIdContainerGetAreaTriggerBySpawnIdStore ()
 
AreaTriggerBySpawnIdContainer const & GetAreaTriggerBySpawnIdStore () const
 
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 (PhaseShift const &phaseShift, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=2.03128f)
 
float GetMinHeight (PhaseShift const &phaseShift, float x, float y)
 
float GetGridHeight (PhaseShift const &phaseShift, float x, float y)
 
float GetStaticHeight (PhaseShift const &phaseShift, float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
 
float GetStaticHeight (PhaseShift const &phaseShift, Position const &pos, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
 
float GetHeight (PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
 
float GetHeight (PhaseShift const &phaseShift, Position const &pos, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
 
bool isInLineOfSight (PhaseShift const &phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
 
void Balance ()
 
void RemoveGameObjectModel (GameObjectModel const &model)
 
void InsertGameObjectModel (GameObjectModel const &model)
 
bool ContainsGameObjectModel (GameObjectModel const &model) const
 
float GetGameObjectFloor (PhaseShift const &phaseShift, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
bool getObjectHitPos (PhaseShift const &phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
 
virtual ObjectGuid::LowType GetOwnerGuildId (uint32=TEAM_OTHER) const
 
time_t GetLinkedRespawnTime (ObjectGuid guid) const
 
time_t GetRespawnTime (SpawnObjectType type, ObjectGuid::LowType spawnId) const
 
time_t GetCreatureRespawnTime (ObjectGuid::LowType spawnId) const
 
time_t GetGORespawnTime (ObjectGuid::LowType spawnId) const
 
void UpdatePlayerZoneStats (uint32 oldZone, uint32 newZone)
 
void SaveRespawnTime (SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, CharacterDatabaseTransaction dbTrans=nullptr, bool startup=false)
 
void SaveRespawnInfoDB (RespawnInfo const &info, CharacterDatabaseTransaction dbTrans=nullptr)
 
void LoadRespawnTimes ()
 
void DeleteRespawnTimes ()
 
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 SendUpdateTransportVisibility (Player *player)
 
void SendZoneDynamicInfo (uint32 zoneId, Player *player) const
 
void SendZoneWeather (uint32 zoneId, Player *player) const
 
void SendZoneWeather (ZoneDynamicInfo const &zoneDynamicInfo, Player *player) const
 
void SetZoneMusic (uint32 zoneId, uint32 musicId)
 
WeatherGetOrGenerateZoneDefaultWeather (uint32 zoneId)
 
WeatherState GetZoneWeather (uint32 zoneId) const
 
void SetZoneWeather (uint32 zoneId, WeatherState weatherId, float intensity)
 
void SetZoneOverrideLight (uint32 zoneId, uint32 areaLightId, uint32 overrideLightId, Milliseconds transitionTime)
 
void UpdateAreaDependentAuras ()
 
template<HighGuid high>
ObjectGuid::LowType GenerateLowGuid ()
 
template<HighGuid high>
ObjectGuid::LowType GetMaxLowGuid ()
 
void AddUpdateObject (Object *obj)
 
void RemoveUpdateObject (Object *obj)
 
size_t GetActiveNonPlayersCount () const
 
virtual std::string GetDebugInfo () const
 
void ProcessRespawns ()
 
void ApplyDynamicModeRespawnScaling (WorldObject const *obj, ObjectGuid::LowType spawnId, uint32 &respawnDelay, uint32 mode) const
 
void GetRespawnInfo (std::vector< RespawnInfo const *> &respawnData, SpawnObjectTypeMask types) const
 
void Respawn (SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
 
void RemoveRespawnTime (SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr, bool alwaysDeleteFromDB=false)
 
size_t DespawnAll (SpawnObjectType type, ObjectGuid::LowType spawnId)
 
bool ShouldBeSpawnedOnGridLoad (SpawnObjectType type, ObjectGuid::LowType spawnId) const
 
template<typename T >
bool ShouldBeSpawnedOnGridLoad (ObjectGuid::LowType spawnId) const
 
SpawnGroupTemplateData const * GetSpawnGroupData (uint32 groupId) const
 
bool IsSpawnGroupActive (uint32 groupId) const
 
bool SpawnGroupSpawn (uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject *> *spawnedObjects=nullptr)
 
bool SpawnGroupDespawn (uint32 groupId, bool deleteRespawnTimes=false, size_t *count=nullptr)
 
void SetSpawnGroupInactive (uint32 groupId)
 
SpawnedPoolDataGetPoolData ()
 
SpawnedPoolData const & GetPoolData () const
 
void AddFarSpellCallback (FarSpellCallback &&callback)
 
MultiPersonalPhaseTrackerGetMultiPersonalPhaseTracker ()
 
void UpdatePersonalPhasesForPlayer (Player const *player)
 
int32 GetWorldStateValue (int32 worldStateId) const
 
void SetWorldStateValue (int32 worldStateId, int32 value)
 
WorldStateValueContainer const & GetWorldStateValues () 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 (AreaTrigger *obj, Cell const &cell)
 
template<>
void AddToGrid (Corpse *obj, Cell const &cell)
 
template<>
void SwitchGridContainers (Creature *obj, bool on)
 
template<>
void DeleteFromWorld (Player *player)
 
template<>
void InitializeObject (Creature *obj)
 
template<>
void InitializeObject (GameObject *obj)
 
template<>
bool AddToMap (Transport *obj)
 
template<>
void RemoveFromMap (Transport *obj, bool remove)
 
template<typename T >
bool MapObjectCellRelocation (T *object, Cell new_cell, [[maybe_unused]] char const *objType)
 
- Public Member Functions inherited from GridRefManager< NGridType >
GridReference< NGridType > * getFirst ()
 
GridReference< NGridType > * getLast ()
 
iterator begin ()
 
iterator end ()
 
- Public Member Functions inherited from RefManager< GridRefManager< NGridType >, NGridType >
 RefManager ()
 
Reference< GridRefManager< NGridType >, NGridType > * getFirst ()
 
Reference< GridRefManager< NGridType >, NGridType > const * getFirst () const
 
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
virtual ~RefManager ()
 
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 ()
 

Static Public Member Functions

static bool ExistMap (uint32 mapid, int gx, int gy, bool log=true)
 
static bool ExistVMap (uint32 mapid, int gx, int gy)
 
static void InitStateMachine ()
 
static void DeleteStateMachine ()
 
template<typename T >
static bool CheckGridIntegrity (T *object, bool moved, char const *objType)
 
static void DeleteRespawnTimesInDB (uint16 mapId, uint32 instanceId)
 

Public Attributes

std::unordered_map< ObjectGuid::LowType, CreatureGroup * > CreatureGroupHolder
 

Protected Types

typedef std::set< WorldObject * > ActiveNonPlayers
 
typedef std::set< Transport * > TransportsContainer
 

Protected Member Functions

virtual void LoadGridObjects (NGridType *grid, Cell const &cell)
 
- Protected Member Functions inherited from LinkedListHead
 ~LinkedListHead ()
 

Protected Attributes

std::mutex _mapLock
 
std::mutex _gridLock
 
MapEntry const * i_mapEntry
 
Difficulty i_spawnMode
 
uint32 i_InstanceId
 
uint32 m_unloadTimer
 
float m_VisibleDistance
 
DynamicMapTree _dynamicTree
 
MapRefManager m_mapRefManager
 
MapRefManager::iterator m_mapRefIter
 
int32 m_VisibilityNotifyPeriod
 
ActiveNonPlayers m_activeNonPlayers
 
ActiveNonPlayers::iterator m_activeNonPlayersIter
 
TransportsContainer _transports
 
TransportsContainer::iterator _transportsUpdateIter
 

Private Types

typedef std::multimap< time_t, ScriptActionScriptScheduleMap
 

Private Member Functions

void LoadMapAndVMap (int gx, int gy)
 
void LoadVMap (int gx, int gy)
 
void LoadMap (int gx, int gy)
 
void UnloadMap (int gx, int gy)
 
void LoadMMap (int gx, int gy)
 
GridMapGetGrid (uint32 mapId, float x, float y)
 
void SetTimer (uint32 t)
 
void SendInitSelf (Player *player)
 
template<typename T >
bool MapObjectCellRelocation (T *object, Cell new_cell, char const *objType)
 
bool CreatureCellRelocation (Creature *creature, Cell new_cell)
 
bool GameObjectCellRelocation (GameObject *go, Cell new_cell)
 
bool DynamicObjectCellRelocation (DynamicObject *go, Cell new_cell)
 
bool AreaTriggerCellRelocation (AreaTrigger *at, Cell new_cell)
 
template<class T >
void InitializeObject (T *obj)
 
void AddCreatureToMoveList (Creature *c, float x, float y, float z, float ang)
 
void RemoveCreatureFromMoveList (Creature *c)
 
void AddGameObjectToMoveList (GameObject *go, float x, float y, float z, float ang)
 
void RemoveGameObjectFromMoveList (GameObject *go)
 
void AddDynamicObjectToMoveList (DynamicObject *go, float x, float y, float z, float ang)
 
void RemoveDynamicObjectFromMoveList (DynamicObject *go)
 
void AddAreaTriggerToMoveList (AreaTrigger *at, float x, float y, float z, float ang)
 
void RemoveAreaTriggerFromMoveList (AreaTrigger *at)
 
bool IsGridLoaded (GridCoord const &) const
 
void EnsureGridCreated (GridCoord const &)
 
void EnsureGridCreated_i (GridCoord const &)
 
bool EnsureGridLoaded (Cell const &)
 
void EnsureGridLoadedForActiveObject (Cell const &, WorldObject const *object)
 
void buildNGridLinkage (NGridType *pNGridType)
 
NGridTypegetNGrid (uint32 x, uint32 y) const
 
bool isGridObjectDataLoaded (uint32 x, uint32 y) const
 
void setGridObjectDataLoaded (bool pLoaded, uint32 x, uint32 y)
 
void setNGrid (NGridType *grid, uint32 x, uint32 y)
 
void ScriptsProcess ()
 Process queued scripts. More...
 
void SendObjectUpdates ()
 
Player_GetScriptPlayerSourceOrTarget (Object *source, Object *target, ScriptInfo const *scriptInfo) const
 
Creature_GetScriptCreatureSourceOrTarget (Object *source, Object *target, ScriptInfo const *scriptInfo, bool bReverse=false) const
 
GameObject_GetScriptGameObjectSourceOrTarget (Object *source, Object *target, ScriptInfo const *scriptInfo, bool bReverse=false) const
 
Unit_GetScriptUnit (Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
 
Player_GetScriptPlayer (Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
 
Creature_GetScriptCreature (Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
 
WorldObject_GetScriptWorldObject (Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
 
void _ScriptProcessDoor (Object *source, Object *target, ScriptInfo const *scriptInfo) const
 
GameObject_FindGameObject (WorldObject *pWorldObject, ObjectGuid::LowType guid) const
 
void ProcessRelocationNotifies (const uint32 diff)
 
bool CheckRespawn (RespawnInfo *info)
 
void DoRespawn (SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gridId)
 
bool AddRespawnInfo (RespawnInfo const &info)
 
void UnloadAllRespawnInfos ()
 
RespawnInfoGetRespawnInfo (SpawnObjectType type, ObjectGuid::LowType spawnId) const
 
void Respawn (RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
 
void DeleteRespawnInfo (RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
 
void DeleteRespawnInfoFromDB (SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
 
template<class T >
void AddToGrid (T *object, Cell const &cell)
 
template<class T >
void DeleteFromWorld (T *)
 
void AddToActiveHelper (WorldObject *obj)
 
void RemoveFromActiveHelper (WorldObject *obj)
 
RespawnInfoMapGetRespawnMapForType (SpawnObjectType type)
 
RespawnInfoMap const * GetRespawnMapForType (SpawnObjectType type) const
 
void SetSpawnGroupActive (uint32 groupId, bool state)
 
void UpdateSpawnGroupConditions ()
 
template<HighGuid high>
ObjectGuidGeneratorBaseGetGuidSequenceGenerator ()
 

Static Private Member Functions

static void LoadMapImpl (Map *map, int gx, int gy)
 
static void UnloadMapImpl (Map *map, int gx, int gy)
 

Private Attributes

bool _creatureToMoveLock
 
std::vector< Creature * > _creaturesToMove
 
bool _gameObjectsToMoveLock
 
std::vector< GameObject * > _gameObjectsToMove
 
bool _dynamicObjectsToMoveLock
 
std::vector< DynamicObject * > _dynamicObjectsToMove
 
bool _areaTriggersToMoveLock
 
std::vector< AreaTrigger * > _areaTriggersToMove
 
time_t i_gridExpiry
 
Mapm_parentMap
 
Mapm_parentTerrainMap
 
std::vector< Map * > * m_childTerrainMaps
 
NGridTypei_grids [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
std::shared_ptr< GridMapGridMaps [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
uint16 GridMapReference [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
std::bitset< MAX_NUMBER_OF_GRIDS *MAX_NUMBER_OF_GRIDSi_gridFileExists
 
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAPmarked_cells
 
bool i_scriptLock
 
std::set< WorldObject * > i_objectsToRemove
 
std::map< WorldObject *, bool > i_objectsToSwitch
 
std::set< WorldObject * > i_worldObjects
 
ScriptScheduleMap m_scriptSchedule
 
RespawnListContainer _respawnTimes
 
RespawnInfoMap _creatureRespawnTimesBySpawnId
 
RespawnInfoMap _gameObjectRespawnTimesBySpawnId
 
std::unordered_set< uint32_toggledSpawnGroupIds
 
uint32 _respawnCheckTimer
 
std::unordered_map< uint32, uint32_zonePlayerCountMap
 
ZoneDynamicInfoMap _zoneDynamicInfo
 
IntervalTimer _weatherUpdateTimer
 
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
 
std::unique_ptr< SpawnedPoolData_poolData
 
MapStoredObjectTypesContainer _objectsStore
 
CreatureBySpawnIdContainer _creatureBySpawnIdStore
 
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
 
AreaTriggerBySpawnIdContainer _areaTriggerBySpawnIdStore
 
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
 
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
 
std::unordered_set< Corpse * > _corpseBones
 
std::unordered_set< Object * > _updateObjects
 
MPSCQueue< FarSpellCallback_farSpellCallbacks
 
MultiPersonalPhaseTracker _multiPersonalPhaseTracker
 
WorldStateValueContainer _worldStateValues
 

Friends

class MapReference
 

Member Typedef Documentation

◆ ActiveNonPlayers

typedef std::set<WorldObject*> Map::ActiveNonPlayers
protected

◆ AreaTriggerBySpawnIdContainer

◆ CreatureBySpawnIdContainer

typedef std::unordered_multimap<ObjectGuid::LowType, Creature*> Map::CreatureBySpawnIdContainer

◆ FarSpellCallback

typedef std::function<void(Map*)> Map::FarSpellCallback

◆ GameObjectBySpawnIdContainer

◆ PlayerList

◆ ScriptScheduleMap

typedef std::multimap<time_t, ScriptAction> Map::ScriptScheduleMap
private

◆ TransportsContainer

typedef std::set<Transport*> Map::TransportsContainer
protected

Member Enumeration Documentation

◆ EnterState

Enumerator
CAN_ENTER 
CANNOT_ENTER_ALREADY_IN_MAP 
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 
383  {
384  CAN_ENTER = 0,
385  CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
386  CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
387  CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
388  CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
389  CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
390  CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
391  CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
392  CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
393  CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
394  CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
396  };
Definition: Map.h:389
Definition: Map.h:386
Definition: Map.h:384
Definition: Map.h:393

Constructor & Destructor Documentation

◆ Map()

Map::Map ( uint32  id,
time_t  expiry,
uint32  InstanceId,
Difficulty  SpawnMode,
Map _parent = nullptr 
)
328  :
330 i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
334 i_gridExpiry(expiry),
336 {
337  if (_parent)
338  {
339  m_parentMap = _parent;
342  }
343  else
344  {
345  m_parentMap = this;
346  m_parentTerrainMap = this;
347  m_childTerrainMaps = new std::vector<Map*>();
348  }
349 
350  for (uint32 x = 0; x < MAX_NUMBER_OF_GRIDS; ++x)
351  {
352  for (uint32 y = 0; y < MAX_NUMBER_OF_GRIDS; ++y)
353  {
354  //z code
355  GridMaps[x][y] = nullptr;
356  GridMapReference[x][y] = 0;
357  setNGrid(nullptr, x, y);
358  }
359  }
360 
361  _zonePlayerCountMap.clear();
362 
363  //lets initialize visibility distance for map
365 
367 
368  GetGuidSequenceGenerator<HighGuid::Transport>().Set(sObjectMgr->GetGenerator<HighGuid::Transport>().GetNextAfterMaxUsed());
369 
370  _poolData = sPoolMgr->InitPoolsForMap(this);
371 
372  sTransportMgr->CreateTransportsForMap(this);
373 
375 
376  _worldStateValues = sWorldStateMgr->GetInitialWorldStatesForMap(this);
377 
378  sScriptMgr->OnCreateMap(this);
379 }
Difficulty i_spawnMode
Definition: Map.h:703
IntervalTimer _weatherUpdateTimer
Definition: Map.h:887
virtual void InitVisibilityDistance()
Definition: Map.cpp:381
MapEntry const * i_mapEntry
Definition: Map.h:702
float m_VisibleDistance
Definition: Map.h:706
time_t i_gridExpiry
Definition: Map.h:734
TransportsContainer _transports
Definition: Map.h:720
Map * m_parentMap
Definition: Map.h:738
#define DEFAULT_VISIBILITY_NOTIFY_PERIOD
Definition: NGrid.h:28
#define sTransportMgr
Definition: TransportMgr.h:184
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:38
TransportsContainer::iterator _transportsUpdateIter
Definition: Map.h:721
#define sWorldStateMgr
Definition: WorldStateMgr.h:48
#define DEFAULT_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:35
#define sWorld
Definition: World.h:946
std::shared_ptr< GridMap > GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:743
#define sObjectMgr
Definition: ObjectMgr.h:1967
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:715
bool i_scriptLock
Definition: Map.h:752
uint32 GetId() const
Definition: Map.cpp:4410
bool _gameObjectsToMoveLock
Definition: Map.h:665
std::vector< Map * > * m_childTerrainMaps
Definition: Map.h:740
void setNGrid(NGridType *grid, uint32 x, uint32 y)
Definition: Map.cpp:3153
void SetInterval(time_t interval)
Definition: Timer.h:94
uint32 m_unloadTimer
Definition: Map.h:705
#define sPoolMgr
Definition: PoolMgr.h:179
bool loadMapInstance(std::string const &basePath, uint32 mapId, uint32 instanceId)
Definition: MMapManager.cpp:229
Definition: Common.h:68
uint32_t uint32
Definition: Define.h:143
bool _areaTriggersToMoveLock
Definition: Map.h:671
bool _dynamicObjectsToMoveLock
Definition: Map.h:668
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition: Map.h:716
int32 m_VisibilityNotifyPeriod
Definition: Map.h:712
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition: Map.h:884
uint32 i_InstanceId
Definition: Map.h:704
uint16 GridMapReference[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:744
static MMapManager * createOrGetMMapManager()
Definition: MMapFactory.cpp:26
#define sScriptMgr
Definition: ScriptMgr.h:1409
std::unique_ptr< SpawnedPoolData > _poolData
Definition: Map.h:900
WorldStateValueContainer _worldStateValues
Definition: Map.h:932
DB2Storage< MapEntry > sMapStore("Map.db2", MapLoadInfo::Instance())
Map * m_parentTerrainMap
Definition: Map.h:739
bool _creatureToMoveLock
Definition: Map.h:662
uint32 _respawnCheckTimer
Definition: Map.h:883
+ Here is the call graph for this function:

◆ ~Map()

Map::~Map ( )
virtual
76 {
77  // UnloadAll must be called before deleting the map
78 
79  sScriptMgr->OnDestroyMap(this);
80 
81  // Delete all waiting spawns, else there will be a memory leak
82  // This doesn't delete from database.
84 
85  while (!i_worldObjects.empty())
86  {
87  WorldObject* obj = *i_worldObjects.begin();
88  ASSERT(obj->IsWorldObject());
89  //ASSERT(obj->GetTypeId() == TYPEID_CORPSE);
90  obj->RemoveFromWorld();
91  obj->ResetMap();
92  }
93 
94  if (!m_scriptSchedule.empty())
95  sMapMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
96 
97  if (m_parentMap == this)
98  delete m_childTerrainMaps;
99 
101 }
virtual void ResetMap()
Definition: Object.cpp:1716
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:758
bool IsWorldObject() const
Definition: Object.cpp:841
Map * m_parentMap
Definition: Map.h:738
Definition: Object.h:430
uint32 GetId() const
Definition: Map.cpp:4410
void UnloadAllRespawnInfos()
Definition: Map.cpp:3352
std::vector< Map * > * m_childTerrainMaps
Definition: Map.h:740
void RemoveFromWorld() override
Definition: Object.cpp:925
std::set< WorldObject * > i_worldObjects
Definition: Map.h:755
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
Definition: MMapManager.cpp:363
#define sMapMgr
Definition: MapManager.h:215
uint32 i_InstanceId
Definition: Map.h:704
#define ASSERT
Definition: Errors.h:68
static MMapManager * createOrGetMMapManager()
Definition: MMapFactory.cpp:26
#define sScriptMgr
Definition: ScriptMgr.h:1409
+ Here is the call graph for this function:

Member Function Documentation

◆ _FindGameObject()

GameObject * Map::_FindGameObject ( WorldObject pWorldObject,
ObjectGuid::LowType  guid 
) const
inlineprivate
303 {
304  auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
305  if (bounds.first == bounds.second)
306  return nullptr;
307 
308  return bounds.first->second;
309 }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptCreature()

Creature * Map::_GetScriptCreature ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
223 {
224  Creature* creature = nullptr;
225  if (!obj)
226  TC_LOG_ERROR("scripts", "%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
227  else
228  {
229  creature = obj->ToCreature();
230  if (!creature)
231  TC_LOG_ERROR("scripts", "%s %s object is not a creature %s.", scriptInfo->GetDebugInfo().c_str(),
232  isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
233  }
234  return creature;
235 }
std::string ToString() const
Definition: ObjectGuid.cpp:531
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Definition: Creature.h:69
static Creature * ToCreature(Object *o)
Definition: Object.h:204
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptCreatureSourceOrTarget()

Creature * Map::_GetScriptCreatureSourceOrTarget ( Object source,
Object target,
ScriptInfo const *  scriptInfo,
bool  bReverse = false 
) const
inlineprivate
124 {
125  Creature* creature = nullptr;
126  if (!source && !target)
127  TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
128  else
129  {
130  if (bReverse)
131  {
132  // Check target first, then source.
133  if (target)
134  creature = target->ToCreature();
135  if (!creature && source)
136  creature = source->ToCreature();
137  }
138  else
139  {
140  // Check source first, then target.
141  if (source)
142  creature = source->ToCreature();
143  if (!creature && target)
144  creature = target->ToCreature();
145  }
146 
147  if (!creature)
148  TC_LOG_ERROR("scripts", "%s neither source nor target are creatures (source: TypeId: %u, Entry: %u, %s; target: TypeId: %u, Entry: %u, %s), skipping.",
149  scriptInfo->GetDebugInfo().c_str(),
150  source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, (source ? source->GetGUID() : ObjectGuid::Empty).ToString().c_str(),
151  target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, (target ? target->GetGUID() : ObjectGuid::Empty).ToString().c_str());
152  }
153  return creature;
154 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:265
TypeID GetTypeId() const
Definition: Object.h:170
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Definition: Creature.h:69
string ToString(int i)
Definition: strutil.h:491
static Creature * ToCreature(Object *o)
Definition: Object.h:204
uint32 GetEntry() const
Definition: Object.h:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptGameObjectSourceOrTarget()

GameObject * Map::_GetScriptGameObjectSourceOrTarget ( Object source,
Object target,
ScriptInfo const *  scriptInfo,
bool  bReverse = false 
) const
inlineprivate
157 {
158  GameObject* gameobject = nullptr;
159  if (!source && !target)
160  TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
161  else
162  {
163  if (bReverse)
164  {
165  // Check target first, then source.
166  if (target)
167  gameobject = target->ToGameObject();
168  if (!gameobject && source)
169  gameobject = source->ToGameObject();
170  }
171  else
172  {
173  // Check source first, then target.
174  if (source)
175  gameobject = source->ToGameObject();
176  if (!gameobject && target)
177  gameobject = target->ToGameObject();
178  }
179 
180  if (!gameobject)
181  TC_LOG_ERROR("scripts", "%s neither source nor target are gameobjects (source: TypeId: %u, Entry: %u, %s; target: TypeId: %u, Entry: %u, %s), skipping.",
182  scriptInfo->GetDebugInfo().c_str(),
183  source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, (source ? source->GetGUID() : ObjectGuid::Empty).ToString().c_str(),
184  target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, (target ? target->GetGUID() : ObjectGuid::Empty).ToString().c_str());
185  }
186  return gameobject;
187 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:265
TypeID GetTypeId() const
Definition: Object.h:170
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
static GameObject * ToGameObject(Object *o)
Definition: Object.h:216
string ToString(int i)
Definition: strutil.h:491
Definition: GameObject.h:125
uint32 GetEntry() const
Definition: Object.h:158
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptPlayer()

Player * Map::_GetScriptPlayer ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
208 {
209  Player* player = nullptr;
210  if (!obj)
211  TC_LOG_ERROR("scripts", "%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
212  else
213  {
214  player = obj->ToPlayer();
215  if (!player)
216  TC_LOG_ERROR("scripts", "%s %s object is not a player %s.",
217  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
218  }
219  return player;
220 }
static Player * ToPlayer(Object *o)
Definition: Object.h:198
std::string ToString() const
Definition: ObjectGuid.cpp:531
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Definition: Player.h:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptPlayerSourceOrTarget()

Player * Map::_GetScriptPlayerSourceOrTarget ( Object source,
Object target,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
102 {
103  Player* player = nullptr;
104  if (!source && !target)
105  TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
106  else
107  {
108  // Check target first, then source.
109  if (target)
110  player = target->ToPlayer();
111  if (!player && source)
112  player = source->ToPlayer();
113 
114  if (!player)
115  TC_LOG_ERROR("scripts", "%s neither source nor target object is player (source: TypeId: %u, Entry: %u, %s; target: TypeId: %u, Entry: %u, %s), skipping.",
116  scriptInfo->GetDebugInfo().c_str(),
117  source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, (source ? source->GetGUID() : ObjectGuid::Empty).ToString().c_str(),
118  target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, (target ? target->GetGUID() : ObjectGuid::Empty).ToString().c_str());
119  }
120  return player;
121 }
static Player * ToPlayer(Object *o)
Definition: Object.h:198
static ObjectGuid const Empty
Definition: ObjectGuid.h:265
TypeID GetTypeId() const
Definition: Object.h:170
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
string ToString(int i)
Definition: strutil.h:491
uint32 GetEntry() const
Definition: Object.h:158
Definition: Player.h:1131
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptUnit()

Unit * Map::_GetScriptUnit ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
190 {
191  Unit* unit = nullptr;
192  if (!obj)
193  TC_LOG_ERROR("scripts", "%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
194  else if (!obj->isType(TYPEMASK_UNIT))
195  TC_LOG_ERROR("scripts", "%s %s object is not unit %s, skipping.",
196  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
197  else
198  {
199  unit = obj->ToUnit();
200  if (!unit)
201  TC_LOG_ERROR("scripts", "%s %s object could not be cast to unit.",
202  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
203  }
204  return unit;
205 }
std::string ToString() const
Definition: ObjectGuid.cpp:531
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Definition: ObjectGuid.h:59
bool isType(uint16 mask) const
Definition: Object.h:171
static Unit * ToUnit(Object *o)
Definition: Object.h:210
Definition: Unit.h:746
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _GetScriptWorldObject()

WorldObject * Map::_GetScriptWorldObject ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
238 {
239  WorldObject* pWorldObject = nullptr;
240  if (!obj)
241  TC_LOG_ERROR("scripts", "%s %s object is NULL.",
242  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
243  else
244  {
245  pWorldObject = dynamic_cast<WorldObject*>(obj);
246  if (!pWorldObject)
247  TC_LOG_ERROR("scripts", "%s %s object is not a world object %s.",
248  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetGUID().ToString().c_str());
249  }
250  return pWorldObject;
251 }
std::string ToString() const
Definition: ObjectGuid.cpp:531
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
Definition: Object.h:430
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _ScriptProcessDoor()

void Map::_ScriptProcessDoor ( Object source,
Object target,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
254 {
255  bool bOpen = false;
256  ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid;
257  int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay));
258  switch (scriptInfo->command)
259  {
260  case SCRIPT_COMMAND_OPEN_DOOR: bOpen = true; break;
261  case SCRIPT_COMMAND_CLOSE_DOOR: break;
262  default:
263  TC_LOG_ERROR("scripts", "%s unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo().c_str());
264  return;
265  }
266  if (!guid)
267  TC_LOG_ERROR("scripts", "%s door guid is not specified.", scriptInfo->GetDebugInfo().c_str());
268  else if (!source)
269  TC_LOG_ERROR("scripts", "%s source object is NULL.", scriptInfo->GetDebugInfo().c_str());
270  else if (!source->isType(TYPEMASK_UNIT))
271  TC_LOG_ERROR("scripts", "%s source object is not unit %s, skipping.", scriptInfo->GetDebugInfo().c_str(),
272  source->GetGUID().ToString().c_str());
273  else
274  {
275  WorldObject* wSource = dynamic_cast <WorldObject*> (source);
276  if (!wSource)
277  TC_LOG_ERROR("scripts", "%s source object could not be cast to world object %s, skipping.",
278  scriptInfo->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str());
279  else
280  {
281  GameObject* pDoor = _FindGameObject(wSource, guid);
282  if (!pDoor)
283  TC_LOG_ERROR("scripts", "%s gameobject was not found (guid: " UI64FMTD ").", scriptInfo->GetDebugInfo().c_str(), guid);
284  else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
285  TC_LOG_ERROR("scripts", "%s gameobject is not a door (GoType: %u, %s).",
286  scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetGUID().ToString().c_str());
287  else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
288  {
289  pDoor->UseDoorOrButton(nTimeToToggle);
290 
291  if (target && target->isType(TYPEMASK_GAMEOBJECT))
292  {
293  GameObject* goTarget = target->ToGameObject();
294  if (goTarget && goTarget->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
295  goTarget->UseDoorOrButton(nTimeToToggle);
296  }
297  }
298  }
299  }
300 }
Definition: ObjectMgr.h:119
Definition: SharedDefines.h:2841
std::string ToString() const
Definition: ObjectGuid.cpp:531
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition: GameObject.cpp:1934
uint64 LowType
Definition: ObjectGuid.h:269
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
static GameObject * ToGameObject(Object *o)
Definition: Object.h:216
Definition: Object.h:430
Definition: ObjectGuid.h:59
Definition: ObjectGuid.h:62
Definition: SharedDefines.h:2733
GameobjectTypes GetGoType() const
Definition: GameObject.h:237
#define UI64FMTD
Definition: Define.h:127
bool isType(uint16 mask) const
Definition: Object.h:171
int32_t int32
Definition: Define.h:139
Definition: GameObject.h:125
GOState GetGoState() const
Definition: GameObject.h:239
GameObject * _FindGameObject(WorldObject *pWorldObject, ObjectGuid::LowType guid) const
Definition: MapScripts.cpp:302
Definition: ObjectMgr.h:120
Definition: SharedDefines.h:2732
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ActiveObjectsNearGrid()

bool Map::ActiveObjectsNearGrid ( NGridType const &  ngrid) const
3858 {
3859  CellCoord cell_min(ngrid.getX() * MAX_NUMBER_OF_CELLS, ngrid.getY() * MAX_NUMBER_OF_CELLS);
3860  CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
3861 
3862  //we must find visible range in cells so we unload only non-visible cells...
3863  float viewDist = GetVisibilityRange();
3864  int cell_range = (int)ceilf(viewDist / SIZE_OF_GRID_CELL) + 1;
3865 
3866  cell_min.dec_x(cell_range);
3867  cell_min.dec_y(cell_range);
3868  cell_max.inc_x(cell_range);
3869  cell_max.inc_y(cell_range);
3870 
3871  for (MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
3872  {
3873  Player* player = iter->GetSource();
3874 
3876  if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
3877  (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
3878  return true;
3879  }
3880 
3881  for (ActiveNonPlayers::const_iterator iter = m_activeNonPlayers.begin(); iter != m_activeNonPlayers.end(); ++iter)
3882  {
3883  WorldObject* obj = *iter;
3884 
3886  if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
3887  (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
3888  return true;
3889  }
3890 
3891  return false;
3892 }
#define SIZE_OF_GRID_CELL
Definition: GridDefines.h:48
float GetVisibilityRange() const
Definition: Map.h:295
#define MAX_NUMBER_OF_CELLS
Definition: GridDefines.h:36
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:205
Definition: Object.h:430
uint32 y_coord
Definition: GridDefines.h:161
uint32 x_coord
Definition: GridDefines.h:160
iterator begin()
Definition: MapRefManager.h:34
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:715
float GetPositionY() const
Definition: Position.h:78
Definition: LinkedList.h:149
float GetPositionX() const
Definition: Position.h:77
MapRefManager m_mapRefManager
Definition: Map.h:709
Definition: Player.h:1131
iterator end()
Definition: MapRefManager.h:35
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddAreaTriggerToMoveList()

void Map::AddAreaTriggerToMoveList ( AreaTrigger at,
float  x,
float  y,
float  z,
float  ang 
)
private
1433 {
1434  if (_areaTriggersToMoveLock) //can this happen?
1435  return;
1436 
1437  if (at->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1438  _areaTriggersToMove.push_back(at);
1439  at->SetNewCellPosition(x, y, z, ang);
1440 }
Definition: MapObject.h:30
std::vector< AreaTrigger * > _areaTriggersToMove
Definition: Map.h:672
bool _areaTriggersToMoveLock
Definition: Map.h:671
+ Here is the caller graph for this function:

◆ AddChildTerrainMap()

void Map::AddChildTerrainMap ( Map map)
inline
346 { m_childTerrainMaps->push_back(map); map->m_parentTerrainMap = this; }
std::vector< Map * > * m_childTerrainMaps
Definition: Map.h:740
Map * m_parentTerrainMap
Definition: Map.h:739
+ Here is the caller graph for this function:

◆ AddCorpse()

void Map::AddCorpse ( Corpse corpse)
4871 {
4872  corpse->SetMap(this);
4873 
4874  _corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse);
4875  if (corpse->GetType() != CORPSE_BONES)
4876  _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
4877  else
4878  _corpseBones.insert(corpse);
4879 }
uint32 GetId() const
Definition: GridDefines.h:155
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:906
ObjectGuid GetOwnerGUID() const override
Definition: Corpse.h:94
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:905
virtual void SetMap(Map *map)
Definition: Object.cpp:1698
std::unordered_set< Corpse * > _corpseBones
Definition: Map.h:907
CorpseType GetType() const
Definition: Corpse.h:122
CellCoord const & GetCellCoord() const
Definition: Corpse.h:124
Definition: Corpse.h:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddCreatureToMoveList()

void Map::AddCreatureToMoveList ( Creature c,
float  x,
float  y,
float  z,
float  ang 
)
private
1376 {
1377  if (_creatureToMoveLock) //can this happen?
1378  return;
1379 
1380  if (c->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1381  _creaturesToMove.push_back(c);
1382  c->SetNewCellPosition(x, y, z, ang);
1383 }
Definition: MapObject.h:30
std::vector< Creature * > _creaturesToMove
Definition: Map.h:663
bool _creatureToMoveLock
Definition: Map.h:662
+ Here is the caller graph for this function:

◆ AddDynamicObjectToMoveList()

void Map::AddDynamicObjectToMoveList ( DynamicObject go,
float  x,
float  y,
float  z,
float  ang 
)
private
1414 {
1415  if (_dynamicObjectsToMoveLock) //can this happen?
1416  return;
1417 
1418  if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1419  _dynamicObjectsToMove.push_back(dynObj);
1420  dynObj->SetNewCellPosition(x, y, z, ang);
1421 }
Definition: MapObject.h:30
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition: Map.h:669
bool _dynamicObjectsToMoveLock
Definition: Map.h:668
+ Here is the caller graph for this function:

◆ AddFarSpellCallback()

void Map::AddFarSpellCallback ( FarSpellCallback &&  callback)
3709 {
3710  _farSpellCallbacks.Enqueue(new FarSpellCallback(std::move(callback)));
3711 }
std::function< void(Map *)> FarSpellCallback
Definition: Map.h:815
MPSCQueue< FarSpellCallback > _farSpellCallbacks
Definition: Map.h:911
+ Here is the caller graph for this function:

◆ AddGameObjectToMoveList()

void Map::AddGameObjectToMoveList ( GameObject go,
float  x,
float  y,
float  z,
float  ang 
)
private
1395 {
1396  if (_gameObjectsToMoveLock) //can this happen?
1397  return;
1398 
1399  if (go->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1400  _gameObjectsToMove.push_back(go);
1401  go->SetNewCellPosition(x, y, z, ang);
1402 }
std::vector< GameObject * > _gameObjectsToMove
Definition: Map.h:666
Definition: MapObject.h:30
bool _gameObjectsToMoveLock
Definition: Map.h:665
+ Here is the caller graph for this function:

◆ AddObjectToRemoveList()

void Map::AddObjectToRemoveList ( WorldObject obj)
3742 {
3743  ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
3744 
3745  obj->SetDestroyedObject(true);
3746  obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
3747 
3748  i_objectsToRemove.insert(obj);
3749 }
uint32 GetInstanceId() const
Definition: Map.h:380
std::set< WorldObject * > i_objectsToRemove
Definition: Map.h:753
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition: Object.cpp:892
uint32 GetId() const
Definition: Map.cpp:4410
uint32 GetMapId() const
Definition: Position.h:186
uint32 GetInstanceId() const
Definition: Object.h:459
#define ASSERT
Definition: Errors.h:68
void SetDestroyedObject(bool destroyed)
Definition: Object.h:193
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddObjectToSwitchList()

void Map::AddObjectToSwitchList ( WorldObject obj,
bool  on 
)
3752 {
3753  ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
3754  // i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses
3755  // the contained objects only if GetTypeId() == TYPEID_UNIT , so we can return in all other cases
3756  if (obj->GetTypeId() != TYPEID_UNIT)
3757  return;
3758 
3759  std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj);
3760  if (itr == i_objectsToSwitch.end())
3761  i_objectsToSwitch.insert(itr, std::make_pair(obj, on));
3762  else if (itr->second != on)
3763  i_objectsToSwitch.erase(itr);
3764  else
3765  ABORT();
3766 }
uint32 GetInstanceId() const
Definition: Map.h:380
TypeID GetTypeId() const
Definition: Object.h:170
std::map< WorldObject *, bool > i_objectsToSwitch
Definition: Map.h:754
Definition: ObjectGuid.h:39
uint32 GetId() const
Definition: Map.cpp:4410
uint32 GetMapId() const
Definition: Position.h:186
uint32 GetInstanceId() const
Definition: Object.h:459
#define ABORT
Definition: Errors.h:74
#define ASSERT
Definition: Errors.h:68
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddPlayerToMap()

bool Map::AddPlayerToMap ( Player player,
bool  initPlayer = true 
)
virtual

Reimplemented in BattlegroundMap, InstanceMap, and GarrisonMap.

650 {
651  CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
652  if (!cellCoord.IsCoordValid())
653  {
654  TC_LOG_ERROR("maps", "Map::Add: Player %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUID().ToString().c_str(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
655  return false;
656  }
657 
658  Cell cell(cellCoord);
659  EnsureGridLoadedForActiveObject(cell, player);
660  AddToGrid(player, cell);
661 
662  // Check if we are adding to correct map
663  ASSERT (player->GetMap() == this);
664  player->SetMap(this);
665  player->AddToWorld();
666 
667  if (initPlayer)
668  SendInitSelf(player);
669 
670  SendInitTransports(player);
671 
672  if (initPlayer)
673  player->m_clientGUIDs.clear();
674 
675  player->UpdateObjectVisibility(false);
677 
678  if (player->IsAlive())
679  ConvertCorpseToBones(player->GetGUID());
680 
681  sScriptMgr->OnPlayerEnterMap(this, player);
682  return true;
683 }
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:390
std::string ToString() const
Definition: ObjectGuid.cpp:531
void AddToWorld() override
Definition: Player.cpp:1613
void SendInitTransports(Player *player)
Definition: Map.cpp:3087
bool IsCoordValid() const
Definition: GridDefines.h:143
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:205
uint32 y_coord
Definition: GridDefines.h:161
uint32 x_coord
Definition: GridDefines.h:160
Corpse * ConvertCorpseToBones(ObjectGuid const &ownerGuid, bool insignia=false)
Definition: Map.cpp:4901
static void SendToPlayer(Player const *player, PhaseShift const &phaseShift)
Definition: PhasingHandler.cpp:478
float GetPositionY() const
Definition: Position.h:78
Map * GetMap() const
Definition: Object.h:555
bool IsAlive() const
Definition: Unit.h:1251
void UpdateObjectVisibility(bool forced=true) override
Definition: Player.cpp:24295
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject const *object)
Definition: Map.cpp:570
Definition: Cell.h:46
float GetPositionX() const
Definition: Position.h:77
GuidUnorderedSet m_clientGUIDs
Definition: Player.h:2488
void SetMap(Map *map) override
Definition: Player.cpp:27592
#define ASSERT
Definition: Errors.h:68
#define sScriptMgr
Definition: ScriptMgr.h:1409
void SendInitSelf(Player *player)
Definition: Map.cpp:3060
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddRespawnInfo()

bool Map::AddRespawnInfo ( RespawnInfo const &  info)
private
3292 {
3293  if (!info.spawnId)
3294  {
3295  TC_LOG_ERROR("maps", "Attempt to insert respawn info for zero spawn id (type %u)", uint32(info.type));
3296  return false;
3297  }
3298 
3299  RespawnInfoMap* bySpawnIdMap = GetRespawnMapForType(info.type);
3300  if (!bySpawnIdMap)
3301  return false;
3302 
3303  // check if we already have the maximum possible number of respawns scheduled
3304  if (SpawnData::TypeHasData(info.type))
3305  {
3306  auto it = bySpawnIdMap->find(info.spawnId);
3307  if (it != bySpawnIdMap->end()) // spawnid already has a respawn scheduled
3308  {
3309  RespawnInfo* const existing = it->second;
3310  if (info.respawnTime <= existing->respawnTime) // delete existing in this case
3311  DeleteRespawnInfo(existing);
3312  else
3313  return false;
3314  }
3315  ASSERT(bySpawnIdMap->find(info.spawnId) == bySpawnIdMap->end(), "Insertion of respawn info with id (%u," UI64FMTD ") into spawn id map failed - state desync.", uint32(info.type), info.spawnId);
3316  }
3317  else
3318  ABORT_MSG("Invalid respawn info for spawn id (%u," UI64FMTD ") being inserted", uint32(info.type), info.spawnId);
3319 
3320  RespawnInfo * ri = new RespawnInfo(info);
3321  ri->handle = _respawnTimes.push(ri);
3322  bySpawnIdMap->emplace(ri->spawnId, ri);
3323  return true;
3324 }
RespawnListHandle handle
Definition: Map.h:248
#define ABORT_MSG
Definition: Errors.h:75
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
std::unordered_map< ObjectGuid::LowType, RespawnInfo * > RespawnInfoMap
Definition: Map.h:240
time_t respawnTime
Definition: Map.h:246
ObjectGuid::LowType spawnId
Definition: Map.h:244
Definition: Map.h:241
#define UI64FMTD
Definition: Define.h:127
RespawnInfoMap * GetRespawnMapForType(SpawnObjectType type)
Definition: Map.h:850
uint32_t uint32
Definition: Define.h:143
RespawnListContainer _respawnTimes
Definition: Map.h:847
#define ASSERT
Definition: Errors.h:68
static constexpr bool TypeHasData(SpawnObjectType type)
Definition: SpawnData.h:85
void DeleteRespawnInfo(RespawnInfo *info, CharacterDatabaseTransaction dbTrans=nullptr)
Definition: Map.cpp:3361
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddToActive()

void Map::AddToActive ( WorldObject obj)
3895 {
3896  AddToActiveHelper(obj);
3897 
3898  Optional<Position> respawnLocation;
3899  switch (obj->GetTypeId())
3900  {
3901  case TYPEID_UNIT:
3902  if (Creature* creature = obj->ToCreature(); !creature->IsPet() && creature->GetSpawnId())
3903  {
3904  respawnLocation.emplace();
3905  creature->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
3906  }
3907  break;
3908  case TYPEID_GAMEOBJECT:
3909  if (GameObject* gameObject = obj->ToGameObject(); gameObject->GetSpawnId())
3910  {
3911  respawnLocation.emplace();
3912  gameObject->GetRespawnPosition(respawnLocation->m_positionX, respawnLocation->m_positionY, respawnLocation->m_positionZ);
3913  }
3914  break;
3915  default:
3916  break;
3917  }
3918 
3919  if (respawnLocation)
3920  {
3921  GridCoord p = Trinity::ComputeGridCoord(respawnLocation->GetPositionX(), respawnLocation->GetPositionY());
3922  if (getNGrid(p.x_coord, p.y_coord))
3924  else
3925  {
3927  TC_LOG_ERROR("maps", "Active object %s added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
3928  obj->GetGUID().ToString().c_str(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
3929  }
3930  }
3931 }
void AddToActiveHelper(WorldObject *obj)
Definition: Map.h:826
TypeID GetTypeId() const
Definition: Object.h:170
std::string ToString() const
Definition: ObjectGuid.cpp:531
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:193
static GameObject * ToGameObject(Object *o)
Definition: Object.h:216
Definition: ObjectGuid.h:39
Definition: Creature.h:69
uint32 y_coord
Definition: GridDefines.h:161
uint32 x_coord
Definition: GridDefines.h:160
float GetPositionY() const
Definition: Position.h:78
bool IsPet() const
Definition: Unit.h:858
Definition: ObjectGuid.h:42
Definition: GridDefines.h:94
Definition: GameObject.h:125
static Creature * ToCreature(Object *o)
Definition: Object.h:204
ObjectGuid::LowType GetSpawnId() const
Definition: GameObject.h:172
void incUnloadActiveLock()
Definition: NGrid.h:107
float GetPositionX() const
Definition: Position.h:77
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:25
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddToActiveHelper()

void Map::AddToActiveHelper ( WorldObject obj)
inlineprivate
827  {
828  m_activeNonPlayers.insert(obj);
829  }
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:715
+ Here is the caller graph for this function:

◆ AddToGrid() [1/6]

template<>
void Map::AddToGrid ( Creature obj,
Cell const &  cell 
)
401 {
402  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
403  if (obj->IsWorldObject())
404  grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
405  else
406  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
407 
408  obj->SetCurrentCell(cell);
409 }
Definition: NGrid.h:69
bool IsWorldObject() const
Definition: Object.cpp:841
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:78
void AddWorldObject(WorldObject *obj)
Definition: Map.h:432
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:

◆ AddToGrid() [2/6]

template<>
void Map::AddToGrid ( GameObject obj,
Cell const &  cell 
)
413 {
414  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
415  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
416 
417  obj->SetCurrentCell(cell);
418 }
Definition: NGrid.h:69
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:78
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:

◆ AddToGrid() [3/6]

template<>
void Map::AddToGrid ( DynamicObject obj,
Cell const &  cell 
)
422 {
423  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
424  if (obj->IsWorldObject())
425  grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
426  else
427  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
428 
429  obj->SetCurrentCell(cell);
430 }
Definition: NGrid.h:69
bool IsWorldObject() const
Definition: Object.cpp:841
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:78
void AddWorldObject(WorldObject *obj)
Definition: Map.h:432
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:

◆ AddToGrid() [4/6]

template<>
void Map::AddToGrid ( AreaTrigger obj,
Cell const &  cell 
)
434 {
435  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
436  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
437 
438  obj->SetCurrentCell(cell);
439 }
Definition: NGrid.h:69
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:78
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:

◆ AddToGrid() [5/6]

template<>
void Map::AddToGrid ( Corpse obj,
Cell const &  cell 
)
443 {
444  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
445  // Corpses are a special object type - they can be added to grid via a call to AddToMap
446  // or loaded through ObjectGridLoader.
447  // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
448  // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
449  // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
450  // to avoid failing an assertion in GridObject::AddToGrid
451  if (grid->isGridObjectDataLoaded())
452  {
453  if (obj->IsWorldObject())
454  grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
455  else
456  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
457  }
458 }
Definition: NGrid.h:69
bool IsWorldObject() const
Definition: Object.cpp:841
bool isGridObjectDataLoaded() const
Definition: NGrid.h:100
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:78
void AddWorldObject(WorldObject *obj)
Definition: Map.h:432
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:

◆ AddToGrid() [6/6]

template<class T >
void Map::AddToGrid ( T *  object,
Cell const &  cell 
)
private
391 {
392  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
393  if (obj->IsWorldObject())
394  grid->GetGridType(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj);
395  else
396  grid->GetGridType(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj);
397 }
Definition: NGrid.h:69
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:78
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddToMap() [1/2]

template<class T >
bool Map::AddToMap ( T *  obj)
Todo:
Needs clean up. An object should not be added to map twice.
746 {
748  if (obj->IsInWorld())
749  {
750  ASSERT(obj->IsInGrid());
751  obj->UpdateObjectVisibility(true);
752  return true;
753  }
754 
755  CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
756  //It will create many problems (including crashes) if an object is not added to grid after creation
757  //The correct way to fix it is to make AddToMap return false and delete the object if it is not added to grid
758  //But now AddToMap is used in too many places, I will just see how many ASSERT failures it will cause
759  ASSERT(cellCoord.IsCoordValid());
760  if (!cellCoord.IsCoordValid())
761  {
762  TC_LOG_ERROR("maps", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
763  return false; //Should delete object
764  }
765 
766  Cell cell(cellCoord);
767  if (obj->isActiveObject())
769  else
770  EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
771  AddToGrid(obj, cell);
772  TC_LOG_DEBUG("maps", "Object %s enters grid[%u, %u]", obj->GetGUID().ToString().c_str(), cell.GridX(), cell.GridY());
773 
774  //Must already be set before AddToMap. Usually during obj->Create.
775  //obj->SetMap(this);
776  obj->AddToWorld();
777 
778  InitializeObject(obj);
779 
780  if (obj->isActiveObject())
781  AddToActive(obj);
782 
783  //something, such as vehicle, needs to be update immediately
784  //also, trigger needs to cast spell, if not update, cannot see visual
785  obj->SetIsNewObject(true);
786  obj->UpdateObjectVisibilityOnCreate();
787  obj->SetIsNewObject(false);
788  return true;
789 }
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:390
bool IsCoordValid() const
Definition: GridDefines.h:143
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
void AddToActive(WorldObject *obj)
Definition: Map.cpp:3894
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:205
uint32 y_coord
Definition: GridDefines.h:161
uint32 x_coord
Definition: GridDefines.h:160
void EnsureGridCreated(GridCoord const &)
Definition: Map.cpp:523
void InitializeObject(T *obj)
Definition: Map.cpp:730
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject const *object)
Definition: Map.cpp:570
Definition: Cell.h:46
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
#define ASSERT
Definition: Errors.h:68
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:176
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AddToMap() [2/2]

template<>
bool Map::AddToMap ( Transport obj)
793 {
794  //TODO: Needs clean up. An object should not be added to map twice.
795  if (obj->IsInWorld())
796  return true;
797 
798  CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
799  if (!cellCoord.IsCoordValid())
800  {
801  TC_LOG_ERROR("maps", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
802  return false; //Should delete object
803  }
804 
805  _transports.insert(obj);
806 
807  if (obj->GetExpectedMapId() == GetId())
808  {
809  obj->AddToWorld();
810 
811  // Broadcast creation to players
812  for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
813  {
814  if (itr->GetSource()->GetTransport() != obj && itr->GetSource()->IsInPhase(obj))
815  {
816  UpdateData data(GetId());
817  obj->BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
818  itr->GetSource()->m_visibleTransports.insert(obj->GetGUID());
819  WorldPacket packet;
820  data.BuildPacket(&packet);
821  itr->GetSource()->SendDirectMessage(&packet);
822  }
823  }
824  }
825 
826  return true;
827 }
bool IsInPhase(WorldObject const *obj) const
Definition: Object.h:461
std::string ToString() const
Definition: ObjectGuid.cpp:531
TransportsContainer _transports
Definition: Map.h:720
bool IsCoordValid() const
Definition: GridDefines.h:143
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:205
bool IsInWorld() const
Definition: Object.h:151
void AddToWorld() override
Definition: GameObject.cpp:580
uint32 y_coord
Definition: GridDefines.h:161
uint32 x_coord
Definition: GridDefines.h:160
Definition: UpdateData.h:36
uint32 GetId() const
Definition: Map.cpp:4410
uint32 GetExpectedMapId() const
Returns id of the map that transport is expected to be on, according to current path progress...
Definition: Transport.cpp:743
float GetPositionY() const
Definition: Position.h:78
PlayerList const & GetPlayers() const
Definition: Map.h:438
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:145
Definition: LinkedList.h:149
float GetPositionX() const
Definition: Position.h:77
iterator begin()
Definition: GridRefManager.h:35
Definition: WorldPacket.h:25
iterator end()
Definition: MapRefManager.h:35
+ Here is the call graph for this function:

◆ AddUpdateObject()

void Map::AddUpdateObject ( Object obj)
inline
614  {
615  _updateObjects.insert(obj);
616  }
std::unordered_set< Object * > _updateObjects
Definition: Map.h:909
+ Here is the caller graph for this function:

◆ AddWorldObject()

void Map::AddWorldObject ( WorldObject obj)
inline
432 { i_worldObjects.insert(obj); }
std::set< WorldObject * > i_worldObjects
Definition: Map.h:755
+ Here is the caller graph for this function:

◆ ApplyDynamicModeRespawnScaling()

void Map::ApplyDynamicModeRespawnScaling ( WorldObject const *  obj,
ObjectGuid::LowType  spawnId,
uint32 respawnDelay,
uint32  mode 
) const
3474 {
3475  ASSERT(mode == 1);
3476  ASSERT(obj->GetMap() == this);
3477 
3478  if (IsBattlegroundOrArena())
3479  return;
3480 
3481  SpawnObjectType type;
3482  switch (obj->GetTypeId())
3483  {
3484  case TYPEID_UNIT:
3485  type = SPAWN_TYPE_CREATURE;
3486  break;
3487  case TYPEID_GAMEOBJECT:
3488  type = SPAWN_TYPE_GAMEOBJECT;
3489  break;
3490  default:
3491  return;
3492  }
3493 
3494  SpawnMetadata const* data = sObjectMgr->GetSpawnMetadata(type, spawnId);
3495  if (!data)
3496  return;
3497 
3499  return;
3500 
3501  auto it = _zonePlayerCountMap.find(obj->GetZoneId());
3502  if (it == _zonePlayerCountMap.end())
3503  return;
3504  uint32 const playerCount = it->second;
3505  if (!playerCount)
3506  return;
3507  double const adjustFactor = sWorld->getFloatConfig(type == SPAWN_TYPE_GAMEOBJECT ? CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICRATE_CREATURE) / playerCount;
3508  if (adjustFactor >= 1.0) // nothing to do here
3509  return;
3511  if (respawnDelay <= timeMinimum)
3512  return;
3513 
3514  respawnDelay = std::max<uint32>(ceil(respawnDelay * adjustFactor), timeMinimum);
3515 }
Definition: SpawnData.h:57
Definition: ObjectGuid.h:39
Definition: SpawnData.h:35
bool IsBattlegroundOrArena() const
Definition: Map.cpp:4462
#define sWorld
Definition: World.h:946
#define sObjectMgr
Definition: ObjectMgr.h:1967
SpawnObjectType
Definition: SpawnData.h:32
Definition: SpawnData.h:82
Definition: ObjectGuid.h:42
uint32_t uint32
Definition: Define.h:143
Definition: SpawnData.h:34
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition: Map.h:884
#define ASSERT
Definition: Errors.h:68
SpawnGroupTemplateData const * spawnGroupData
Definition: SpawnData.h:96
SpawnGroupFlags flags
Definition: SpawnData.h:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AreaTriggerCellRelocation()

bool Map::AreaTriggerCellRelocation ( AreaTrigger at,
Cell  new_cell 
)
private
1712 {
1713  return MapObjectCellRelocation(at, new_cell, "AreaTrigger");
1714 }
bool MapObjectCellRelocation(T *object, Cell new_cell, char const *objType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ AreaTriggerRelocation()

void Map::AreaTriggerRelocation ( AreaTrigger at,
float  x,
float  y,
float  z,
float  orientation 
)
1346 {
1347  ASSERT(CheckGridIntegrity(at, false, "AreaTrigger"));
1348  Cell new_cell(x, y);
1349 
1350  if (!getNGrid(new_cell.GridX(), new_cell.GridY()))
1351  return;
1352 
1353  Cell old_cell = at->GetCurrentCell();
1354 
1355  // delay areatrigger move for grid/cell to grid/cell moves
1356  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1357  {
1358 #ifdef TRINITY_DEBUG
1359  TC_LOG_DEBUG("maps", "AreaTrigger (%s) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", at->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1360 #endif
1361  AddAreaTriggerToMoveList(at, x, y, z, orientation);
1362  // in diffcell/diffgrid case notifiers called at finishing move at in Map::MoveAllAreaTriggersInMoveList
1363  }
1364  else
1365  {
1366  at->Relocate(x, y, z, orientation);
1367  at->UpdateShape();
1368  at->UpdateObjectVisibility(false);
1370  }
1371 
1372  ASSERT(CheckGridIntegrity(at, true, "AreaTrigger"));
1373 }
uint32 CellY() const
Definition: Cell.h:72
bool DiffCell(Cell const &cell) const
Definition: Cell.h:59
std::string ToString() const
Definition: ObjectGuid.cpp:531
uint32 GridY() const
Definition: Cell.h:74
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
static bool CheckGridIntegrity(T *object, bool moved, char const *objType)
Definition: Map.cpp:1210
void UpdateShape()
Definition: AreaTrigger.cpp:669
void Relocate(float x, float y)
Definition: Position.h:64
void RemoveAreaTriggerFromMoveList(AreaTrigger *at)
Definition: Map.cpp:1442
void AddAreaTriggerToMoveList(AreaTrigger *at, float x, float y, float z, float ang)
Definition: Map.cpp:1432
uint32 CellX() const
Definition: Cell.h:71
uint32 GridX() const
Definition: Cell.h:73
Definition: Cell.h:46
bool DiffGrid(Cell const &cell) const
Definition: Cell.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3486
#define ASSERT
Definition: Errors.h:68
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Balance()

void Map::Balance ( )
inline
542 { _dynamicTree.balance(); }
void balance()
Definition: DynamicTree.cpp:130
DynamicMapTree _dynamicTree
Definition: Map.h:707
+ Here is the caller graph for this function:

◆ buildNGridLinkage()

void Map::buildNGridLinkage ( NGridType pNGridType)
inlineprivate
680 { pNGridType->link(this); }
void link(GridRefManager< NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES > > *pTo)
Definition: NGrid.h:96
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CannotEnter()

virtual EnterState Map::CannotEnter ( Player )
inlinevirtual

Reimplemented in BattlegroundMap, InstanceMap, and MapInstanced.

397 { return CAN_ENTER; }
Definition: Map.h:384
+ Here is the caller graph for this function:

◆ CanUnload()

bool Map::CanUnload ( uint32  diff)
inline
275  {
276  if (!m_unloadTimer)
277  return false;
278 
279  if (m_unloadTimer <= diff)
280  return true;
281 
282  m_unloadTimer -= diff;
283  return false;
284  }
uint32 m_unloadTimer
Definition: Map.h:705
+ Here is the call graph for this function:

◆ CheckGridIntegrity()

template<typename T >
bool Map::CheckGridIntegrity ( T *  object,
bool  moved,
char const *  objType 
)
static
1211 {
1212  Cell const& cur_cell = object->GetCurrentCell();
1213  Cell xy_cell(object->GetPositionX(), object->GetPositionY());
1214  if (xy_cell != cur_cell)
1215  {
1216  TC_LOG_DEBUG("maps", "%s %s X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
1217  objType, object->GetGUID().ToString().c_str(),
1218  object->GetPositionX(), object->GetPositionY(), (moved ? "final" : "original"),
1219  cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(),
1220  xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY());
1221  return true; // not crash at error, just output error in debug mode
1222  }
1223 
1224  return true;
1225 }
uint32 CellY() const
Definition: Cell.h:72
uint32 GridY() const
Definition: Cell.h:74
uint32 CellX() const
Definition: Cell.h:71
uint32 GridX() const
Definition: Cell.h:73
Definition: Cell.h:46
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CheckRespawn()

bool Map::CheckRespawn ( RespawnInfo info)
private
3189 {
3190  SpawnData const* data = sObjectMgr->GetSpawnData(info->type, info->spawnId);
3191  ASSERT(data, "Invalid respawn info with type %u, spawnID " UI64FMTD " in respawn queue.", info->type, info->spawnId);
3192 
3193  // First, check if this creature's spawn group is inactive
3195  {
3196  info->respawnTime = 0;
3197  return false;
3198  }
3199 
3200  // Next, check if there's already an instance of this object that would block the respawn
3201  bool alreadyExists = false;
3202  switch (info->type)
3203  {
3204  case SPAWN_TYPE_CREATURE:
3205  {
3206  // escort check for creatures only (if the world config boolean is set)
3207  bool const isEscort = (sWorld->getBoolConfig(CONFIG_RESPAWN_DYNAMIC_ESCORTNPC) && data->spawnGroupData->flags & SPAWNGROUP_FLAG_ESCORTQUESTNPC);
3208 
3209  auto range = _creatureBySpawnIdStore.equal_range(info->spawnId);
3210  for (auto it = range.first; it != range.second; ++it)
3211  {
3212  Creature* creature = it->second;
3213  if (!creature->IsAlive())
3214  continue;
3215  // escort NPCs are allowed to respawn as long as all other instances are already escorting
3216  if (isEscort && creature->IsEscorted())
3217  continue;
3218  alreadyExists = true;
3219  break;
3220  }
3221  break;
3222  }
3223  case SPAWN_TYPE_GAMEOBJECT:
3224  // gameobject check is simpler - they cannot be dead or escorting
3226  alreadyExists = true;
3227  break;
3228  default:
3229  ABORT_MSG("Invalid spawn type %u with spawnId " UI64FMTD " on map %u", uint32(info->type), info->spawnId, GetId());
3230  return true;
3231  }
3232  if (alreadyExists)
3233  {
3234  info->respawnTime = 0;
3235  return false;
3236  }
3237 
3238  // next, check linked respawn time
3239  ObjectGuid thisGUID = info->type == SPAWN_TYPE_GAMEOBJECT
3240  ? ObjectGuid::Create<HighGuid::GameObject>(GetId(), info->entry, info->spawnId)
3241  : ObjectGuid::Create<HighGuid::Creature>(GetId(), info->entry, info->spawnId);
3242  if (time_t linkedTime = GetLinkedRespawnTime(thisGUID))
3243  {
3244  time_t now = GameTime::GetGameTime();
3245  time_t respawnTime;
3246  if (linkedTime == std::numeric_limits<time_t>::max())
3247  respawnTime = linkedTime;
3248  else if (sObjectMgr->GetLinkedRespawnGuid(thisGUID) == thisGUID) // never respawn, save "something" in DB
3249  respawnTime = now + WEEK;
3250  else // set us to check again shortly after linked unit
3251  respawnTime = std::max<time_t>(now, linkedTime) + urand(5, 15);
3252  info->respawnTime = respawnTime;
3253  return false;
3254  }
3255  // everything ok, let's spawn
3256  return true;
3257 }
bool IsEscorted() const
Definition: Creature.cpp:3491
Definition: World.h:194
#define ABORT_MSG
Definition: Errors.h:75
time_t GetLinkedRespawnTime(ObjectGuid guid) const
Definition: Map.cpp:4761
time_t respawnTime
Definition: Map.h:246
Definition: SpawnData.h:35
Definition: Creature.h:69
#define sWorld
Definition: World.h:946
#define sObjectMgr
Definition: ObjectMgr.h:1967
uint32 GetId() const
Definition: Map.cpp:4410
ObjectGuid::LowType spawnId
Definition: Map.h:244
uint32 entry
Definition: Map.h:245
Definition: Common.h:65
Definition: SpawnData.h:102
bool IsAlive() const
Definition: Unit.h:1251
time_t GetGameTime()
Definition: GameTime.cpp:39
#define UI64FMTD
Definition: Define.h:127
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition: Map.h:902
uint32_t uint32
Definition: Define.h:143
bool IsSpawnGroupActive(uint32 groupId) const
Definition: Map.cpp:3672
Definition: SpawnData.h:34
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:42
#define ASSERT
Definition: Errors.h:68
SpawnObjectType type
Definition: Map.h:243
uint32 groupId
Definition: SpawnData.h:67
SpawnGroupTemplateData const * spawnGroupData
Definition: SpawnData.h:96
Definition: ObjectGuid.h:258
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
Definition: Map.h:903
SpawnGroupFlags flags
Definition: SpawnData.h:70
Definition: SpawnData.h:58
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ContainsGameObjectModel()

bool Map::ContainsGameObjectModel ( GameObjectModel const &  model) const
inline
545 { return _dynamicTree.contains(model);}
bool contains(GameObjectModel const &) const
Definition: DynamicTree.cpp:125
DynamicMapTree _dynamicTree
Definition: Map.h:707

◆ ConvertCorpseToBones()

Corpse * Map::ConvertCorpseToBones ( ObjectGuid const &  ownerGuid,
bool  insignia = false 
)
4902 {
4903  Corpse* corpse = GetCorpseByPlayer(ownerGuid);
4904  if (!corpse)
4905  return nullptr;
4906 
4907  RemoveCorpse(corpse);
4908 
4909  // remove corpse from DB
4910  CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
4911  corpse->DeleteFromDB(trans);
4912  CharacterDatabase.CommitTransaction(trans);
4913 
4914  Corpse* bones = nullptr;
4915 
4916  // create the bones only if the map and the grid is loaded at the corpse's location
4917  // ignore bones creating option in case insignia
4918  if ((insignia ||
4920  !IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
4921  {
4922  // Create bones, don't change Corpse
4923  bones = new Corpse();
4924  bones->Create(corpse->GetGUID().GetCounter(), this);
4925 
4927  bones->SetOwnerGUID(corpse->m_corpseData->Owner);
4928  bones->SetPartyGUID(corpse->m_corpseData->PartyGUID);
4929  bones->SetGuildGUID(corpse->m_corpseData->GuildGUID);
4930  bones->SetDisplayId(corpse->m_corpseData->DisplayID);
4931  bones->SetRace(corpse->m_corpseData->RaceID);
4932  bones->SetSex(corpse->m_corpseData->Sex);
4933  bones->SetClass(corpse->m_corpseData->Class);
4934  bones->SetCustomizations(Trinity::Containers::MakeIteratorPair(corpse->m_corpseData->Customizations.begin(), corpse->m_corpseData->Customizations.end()));
4935  bones->ReplaceAllFlags(corpse->m_corpseData->Flags | CORPSE_FLAG_BONES);
4936  bones->SetFactionTemplate(corpse->m_corpseData->FactionTemplate);
4937 
4938  bones->SetCellCoord(corpse->GetCellCoord());
4939  bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
4940 
4941  PhasingHandler::InheritPhaseShift(bones, corpse);
4942 
4943  AddCorpse(bones);
4944 
4945  bones->UpdatePositionData();
4946  bones->SetZoneScript();
4947 
4948  // add bones in grid store if grid loaded where corpse placed
4949  AddToMap(bones);
4950  }
4951 
4952  // all references to the corpse should be removed at this point
4953  delete corpse;
4954 
4955  return bones;
4956 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: Corpse.h:51
void SetFactionTemplate(int32 factionTemplate)
Definition: Corpse.h:103
void RemoveCorpse(Corpse *corpse)
Definition: Map.cpp:4881
void SetCellCoord(CellCoord const &cellCoord)
Definition: Corpse.h:125
CorpseDynFlags GetCorpseDynamicFlags() const
Definition: Corpse.h:89
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
LowType GetCounter() const
Definition: ObjectGuid.h:284
void UpdatePositionData()
Definition: Object.cpp:901
static void InheritPhaseShift(WorldObject *target, WorldObject const *source)
Definition: PhasingHandler.cpp:256
float GetOrientation() const
Definition: Position.h:80
void SetPartyGUID(ObjectGuid partyGuid)
Definition: Corpse.h:96
bool IsBattlegroundOrArena() const
Definition: Map.cpp:4462
#define sWorld
Definition: World.h:946
void SetDisplayId(uint32 displayId)
Definition: Corpse.h:98
void DeleteFromDB(CharacterDatabaseTransaction trans)
Definition: Corpse.cpp:147
Definition: World.h:131
float GetPositionY() const
Definition: Position.h:78
void ReplaceAllFlags(uint32 flags)
Definition: Corpse.h:102
void SetCustomizations(Trinity::IteratorPair< Iter > customizations)
Definition: Corpse.h:109
void Relocate(float x, float y)
Definition: Position.h:64
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition: Map.h:516
bool AddToMap(T *)
Definition: Map.cpp:745
float GetPositionZ() const
Definition: Position.h:79
void SetRace(uint8 race)
Definition: Corpse.h:99
void SetOwnerGUID(ObjectGuid owner)
Definition: Corpse.h:95
bool Create(ObjectGuid::LowType guidlow, Map *map)
Definition: Corpse.cpp:64
float GetPositionX() const
Definition: Position.h:77
CellCoord const & GetCellCoord() const
Definition: Corpse.h:124
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:308
void SetZoneScript()
Definition: Object.cpp:1913
constexpr Trinity::IteratorPair< iterator > MakeIteratorPair(iterator first, iterator second)
Definition: IteratorPair.h:48
void SetGuildGUID(ObjectGuid guildGuid)
Definition: Corpse.h:97
Definition: World.h:132
void AddCorpse(Corpse *corpse)
Definition: Map.cpp:4870
void ReplaceAllCorpseDynamicFlags(CorpseDynFlags dynamicFlags)
Definition: Corpse.h:92
void SetSex(uint8 sex)
Definition: Corpse.h:101
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:72
Definition: Corpse.h:42
UF::UpdateField< UF::CorpseData, 0, TYPEID_CORPSE > m_corpseData
Definition: Corpse.h:132
void SetClass(uint8 playerClass)
Definition: Corpse.h:100
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreatureCellRelocation()

bool Map::CreatureCellRelocation ( Creature creature,
Cell  new_cell 
)
private
1697 {
1698  return MapObjectCellRelocation(c, new_cell, "Creature");
1699 }
bool MapObjectCellRelocation(T *object, Cell new_cell, char const *objType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreatureRelocation()

void Map::CreatureRelocation ( Creature creature,
float  x,
float  y,
float  z,
float  ang,
bool  respawnRelocationOnFail = true 
)
1255 {
1256  ASSERT(CheckGridIntegrity(creature, false, "Creature"));
1257 
1258  Cell new_cell(x, y);
1259 
1260  if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
1261  return;
1262 
1263  Cell old_cell = creature->GetCurrentCell();
1264  // delay creature move for grid/cell to grid/cell moves
1265  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1266  {
1267 #ifdef TRINITY_DEBUG
1268  TC_LOG_DEBUG("maps", "Creature %s added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", creature->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1269 #endif
1270  AddCreatureToMoveList(creature, x, y, z, ang);
1271  // in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList
1272  }
1273  else
1274  {
1275  creature->Relocate(x, y, z, ang);
1276  if (creature->IsVehicle())
1277  creature->GetVehicleKit()->RelocatePassengers();
1278  creature->UpdateObjectVisibility(false);
1279  creature->UpdatePositionData();
1280  RemoveCreatureFromMoveList(creature);
1281  }
1282 
1283  ASSERT(CheckGridIntegrity(creature, true, "Creature"));
1284 }
uint32 CellY() const
Definition: Cell.h:72
bool DiffCell(Cell const &cell) const
Definition: Cell.h:59
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
Definition: Vehicle.cpp:553
void AddCreatureToMoveList(Creature *c, float x, float y, float z, float ang)
Definition: Map.cpp:1375
std::string ToString() const
Definition: ObjectGuid.cpp:531
uint32 GridY() const
Definition: Cell.h:74
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
void RemoveCreatureFromMoveList(Creature *c)
Definition: Map.cpp:1385
Vehicle * GetVehicleKit() const
Definition: Unit.h:1800
void UpdatePositionData()
Definition: Object.cpp:901
static bool CheckGridIntegrity(T *object, bool moved, char const *objType)
Definition: Map.cpp:1210
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:11733
void Relocate(float x, float y)
Definition: Position.h:64
bool IsVehicle() const
Definition: Unit.h:861
uint32 CellX() const
Definition: Cell.h:71
uint32 GridX() const
Definition: Cell.h:73
Definition: Cell.h:46
bool DiffGrid(Cell const &cell) const
Definition: Cell.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
#define ASSERT
Definition: Errors.h:68
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CreatureRespawnRelocation()

bool Map::CreatureRespawnRelocation ( Creature c,
bool  diffGridOnly 
)
1717 {
1718  float resp_x, resp_y, resp_z, resp_o;
1719  c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
1720  Cell resp_cell(resp_x, resp_y);
1721 
1722  //creature will be unloaded with grid
1723  if (diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell))
1724  return true;
1725 
1726  c->CombatStop();
1727  c->GetMotionMaster()->Clear();
1728 
1729 #ifdef TRINITY_DEBUG
1730  TC_LOG_DEBUG("maps", "Creature %s moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
1731 #endif
1732 
1733  // teleport it to respawn point (like normal respawn if player see)
1734  if (CreatureCellRelocation(c, resp_cell))
1735  {
1736  c->Relocate(resp_x, resp_y, resp_z, resp_o);
1737  c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators
1738  //CreatureRelocationNotify(c, resp_cell, resp_cell.GetCellCoord());
1739  c->UpdatePositionData();
1740  c->UpdateObjectVisibility(false);
1741  return true;
1742  }
1743 
1744  return false;
1745 }
void CombatStop(bool includingCast=false, bool mutualPvP=true)
Definition: Unit.cpp:5670
std::string ToString() const
Definition: ObjectGuid.cpp:531
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
MotionMaster * GetMotionMaster()
Definition: Unit.h:1736
void UpdatePositionData()
Definition: Object.cpp:901
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:11733
void Relocate(float x, float y)
Definition: Position.h:64
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition: Creature.cpp:2742
void Clear()
Definition: MotionMaster.cpp:433
Definition: Cell.h:46
bool CreatureCellRelocation(Creature *creature, Cell new_cell)
Definition: Map.cpp:1696
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
void Initialize()
Definition: MotionMaster.cpp:97
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayedUpdate()

void Map::DelayedUpdate ( uint32  diff)
virtual

Reimplemented in MapInstanced.

3714 {
3715  {
3716  FarSpellCallback* callback;
3717  while (_farSpellCallbacks.Dequeue(callback))
3718  {
3719  (*callback)(this);
3720  delete callback;
3721  }
3722  }
3723 
3725 
3726  // Don't unload grids if it's battleground, since we may have manually added GOs, creatures, those doesn't load from DB at grid re-load !
3727  // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended
3728  if (!IsBattlegroundOrArena())
3729  {
3731  {
3732  NGridType *grid = i->GetSource();
3733  GridInfo* info = i->GetSource()->getGridInfoRef();
3734  ++i; // The update might delete the map and we need the next map before the iterator gets invalid
3735  ASSERT(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE);
3736  si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, t_diff);
3737  }
3738  }
3739 }
Definition: NGrid.h:69
Definition: NGrid.h:30
bool IsBattlegroundOrArena() const
Definition: Map.cpp:4462
grid_state_t GetGridState(void) const
Definition: NGrid.h:91
void RemoveAllObjectsInRemoveList()
Definition: Map.cpp:3768
iterator end()
Definition: GridRefManager.h:36
std::function< void(Map *)> FarSpellCallback
Definition: Map.h:815
Definition: NGrid.h:59
#define ASSERT
Definition: Errors.h:68
GridState * si_GridStates[MAX_GRID_STATE]
Definition: Map.cpp:70
Definition: GridReference.h:24
virtual void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const =0
MPSCQueue< FarSpellCallback > _farSpellCallbacks
Definition: Map.h:911
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteCorpseData()

void Map::DeleteCorpseData ( )
4862 {
4863  // DELETE cp, c FROM corpse_phases cp INNER JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?
4865  stmt->setUInt32(0, GetId());
4866  stmt->setUInt32(1, GetInstanceId());
4867  CharacterDatabase.Execute(stmt);
4868 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetInstanceId() const
Definition: Map.h:380
Definition: DatabaseEnvFwd.h:40
uint32 GetId() const
Definition: Map.cpp:4410
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:48
Definition: CharacterDatabase.h:334
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteFromWorld() [1/2]

template<>
void Map::DeleteFromWorld ( Player player)
Todo:
I do not know why we need this, it should be removed in ~Object anyway
517 {
519  RemoveUpdateObject(player);
520  delete player;
521 }
void RemoveUpdateObject(Object *obj)
Definition: Map.h:618
void RemoveObject(T *object)
Definition: ObjectAccessor.h:100
+ Here is the call graph for this function:

◆ DeleteFromWorld() [2/2]

template<class T >
void Map::DeleteFromWorld ( T *  obj)
private
510 {
511  // Note: In case resurrectable corpse and pet its removed from global lists in own destructor
512  delete obj;
513 }
+ Here is the caller graph for this function:

◆ DeleteRespawnInfo()

void Map::DeleteRespawnInfo ( RespawnInfo info,
CharacterDatabaseTransaction  dbTrans = nullptr 
)
private
3362 {
3363  // Delete from all relevant containers to ensure consistency
3364  ASSERT(info);
3365 
3366  // spawnid store
3367  auto spawnMap = GetRespawnMapForType(info->type);
3368  if (!spawnMap)
3369  return;
3370 
3371  auto range = spawnMap->equal_range(info->spawnId);
3372  auto it = std::find_if(range.first, range.second, [info](RespawnInfoMap::value_type const& pair) { return (pair.second == info); });
3373  ASSERT(it != range.second, "Respawn stores inconsistent for map %u, spawnid " UI64FMTD " (type %u)", GetId(), info->spawnId, uint32(info->type));
3374  spawnMap->erase(it);
3375 
3376  // respawn heap
3377  _respawnTimes.erase(info->handle);
3378 
3379  // database
3380  DeleteRespawnInfoFromDB(info->type, info->spawnId, dbTrans);
3381 
3382  // then cleanup the object
3383  delete info;
3384 }
RespawnListHandle handle
Definition: Map.h:248
void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
Definition: Map.cpp:3386
uint32 GetId() const
Definition: Map.cpp:4410
ObjectGuid::LowType spawnId
Definition: Map.h:244
#define UI64FMTD
Definition: Define.h:127
RespawnInfoMap * GetRespawnMapForType(SpawnObjectType type)
Definition: Map.h:850
uint32_t uint32
Definition: Define.h:143
RespawnListContainer _respawnTimes
Definition: Map.h:847
#define ASSERT
Definition: Errors.h:68
SpawnObjectType type
Definition: Map.h:243
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteRespawnInfoFromDB()

void Map::DeleteRespawnInfoFromDB ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId,
CharacterDatabaseTransaction  dbTrans = nullptr 
)
private
3387 {
3389  stmt->setUInt16(0, type);
3390  stmt->setUInt64(1, spawnId);
3391  stmt->setUInt16(2, GetId());
3392  stmt->setUInt32(3, GetInstanceId());
3393  CharacterDatabase.ExecuteOrAppend(dbTrans, stmt);
3394 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetInstanceId() const
Definition: Map.h:380
Definition: CharacterDatabase.h:345
Definition: DatabaseEnvFwd.h:40
uint32 GetId() const
Definition: Map.cpp:4410
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:42
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:48
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:54
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteRespawnTimes()

void Map::DeleteRespawnTimes ( )
inline
uint32 GetInstanceId() const
Definition: Map.h:380
uint32 GetId() const
Definition: Map.cpp:4410
void UnloadAllRespawnInfos()
Definition: Map.cpp:3352
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
Definition: Map.cpp:4753
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteRespawnTimesInDB()

void Map::DeleteRespawnTimesInDB ( uint16  mapId,
uint32  instanceId 
)
static
4754 {
4756  stmt->setUInt16(0, mapId);
4757  stmt->setUInt32(1, instanceId);
4758  CharacterDatabase.Execute(stmt);
4759 }
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: DatabaseEnvFwd.h:40
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:42
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:48
Definition: CharacterDatabase.h:346
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DeleteStateMachine()

void Map::DeleteStateMachine ( )
static
321 {
326 }
Definition: NGrid.h:56
Definition: NGrid.h:57
Definition: NGrid.h:55
Definition: NGrid.h:58
GridState * si_GridStates[MAX_GRID_STATE]
Definition: Map.cpp:70
+ Here is the caller graph for this function:

◆ DespawnAll()

size_t Map::DespawnAll ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId 
)
3269 {
3270  std::vector<WorldObject*> toUnload;
3271  switch (type)
3272  {
3273  case SPAWN_TYPE_CREATURE:
3274  for (auto const& pair : Trinity::Containers::MapEqualRange(GetCreatureBySpawnIdStore(), spawnId))
3275  toUnload.push_back(pair.second);
3276  break;
3277  case SPAWN_TYPE_GAMEOBJECT:
3278  for (auto const& pair : Trinity::Containers::MapEqualRange(GetGameObjectBySpawnIdStore(), spawnId))
3279  toUnload.push_back(pair.second);
3280  break;
3281  default:
3282  break;
3283  }
3284 
3285  for (WorldObject* o : toUnload)
3287 
3288  return toUnload.size();
3289 }
auto MapEqualRange(M &map, typename M::key_type const &key) -> IteratorPair< decltype(map.begin())>
Definition: IteratorPair.h:60
Definition: SpawnData.h:35
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:3741
Definition: Object.h:430
Definition: SpawnData.h:34
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:496
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:500
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DiscoverGridMapFiles()

void Map::DiscoverGridMapFiles ( )
104 {
105  std::string tileListName = Trinity::StringFormat("%smaps/%04u.tilelist", sWorld->GetDataPath().c_str(), GetId());
106  // tile list is optional
107  if (FILE* tileList = fopen(tileListName.c_str(), "rb"))
108  {
109  u_map_magic mapMagic = { };
110  uint32 versionMagic = { };
111  uint32 build;
112  char tilesData[MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS] = { };
113  if (fread(mapMagic.data(), mapMagic.size(), 1, tileList) == 1
114  && mapMagic == MapMagic
115  && fread(&versionMagic, sizeof(versionMagic), 1, tileList) == 1
116  && versionMagic == MapVersionMagic
117  && fread(&build, sizeof(build), 1, tileList) == 1
118  && fread(&tilesData[0], MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS, 1, tileList) == 1)
119  {
120  i_gridFileExists = std::bitset<MAX_NUMBER_OF_GRIDS * MAX_NUMBER_OF_GRIDS>(tilesData, std::size(tilesData));
121  fclose(tileList);
122  return;
123  }
124 
125  fclose(tileList);
126  }
127 
128  for (uint32 gx = 0; gx < MAX_NUMBER_OF_GRIDS; ++gx)
129  for (uint32 gy = 0; gy < MAX_NUMBER_OF_GRIDS; ++gy)
130  i_gridFileExists[gx * MAX_NUMBER_OF_GRIDS + gy] = ExistMap(GetId(), gx, gy, false);
131 }
std::bitset< MAX_NUMBER_OF_GRIDS *MAX_NUMBER_OF_GRIDS > i_gridFileExists
Definition: Map.h:745
uint32 const MapVersionMagic
Definition: MapDefines.cpp:21
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:38
#define sWorld
Definition: World.h:946
uint32 GetId() const
Definition: Map.cpp:4410
u_map_magic const MapMagic
Definition: MapDefines.cpp:20
static bool ExistMap(uint32 mapid, int gx, int gy, bool log=true)
Definition: Map.cpp:142
uint32_t uint32
Definition: Define.h:143
std::array< char, 4 > u_map_magic
Represents a map magic value of 4 bytes (used in versions)
Definition: MapDefines.h:26
std::string StringFormat(Format &&fmt, Args &&... args)
Default TC string format function.
Definition: StringFormat.h:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoOnPlayers()

template<typename T >
void Map::DoOnPlayers ( T &&  fn)
inline
442  {
443  for (MapReference const& ref : GetPlayers())
444  if (Player* player = ref.GetSource())
445  fn(player);
446  }
PlayerList const & GetPlayers() const
Definition: Map.h:438
Definition: Player.h:1131
Definition: MapReference.h:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DoRespawn()

void Map::DoRespawn ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId,
uint32  gridId 
)
private
3397 {
3398  if (!IsGridLoaded(gridId)) // if grid isn't loaded, this will be processed in grid load handler
3399  return;
3400 
3401  switch (type)
3402  {
3403  case SPAWN_TYPE_CREATURE:
3404  {
3405  Creature* obj = new Creature();
3406  if (!obj->LoadFromDB(spawnId, this, true, true))
3407  delete obj;
3408  break;
3409  }
3410  case SPAWN_TYPE_GAMEOBJECT:
3411  {
3412  GameObject* obj = new GameObject();
3413  if (!obj->LoadFromDB(spawnId, this, true))
3414  delete obj;
3415  break;
3416  }
3417  default:
3418  ABORT_MSG("Invalid spawn type %u (spawnid " UI64FMTD ") on map %u", uint32(type), spawnId, GetId());
3419  }
3420 }
bool IsGridLoaded(uint32 gridId) const
Definition: Map.h:315
#define ABORT_MSG
Definition: Errors.h:75
Definition: SpawnData.h:35
Definition: Creature.h:69
uint32 GetId() const
Definition: Map.cpp:4410
#define UI64FMTD
Definition: Define.h:127
uint32_t uint32
Definition: Define.h:143
Definition: GameObject.h:125
Definition: SpawnData.h:34
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool allowDuplicate)
Definition: Creature.cpp:1717
bool LoadFromDB(ObjectGuid::LowType spawnId, Map *map, bool addToMap, bool=true)
Definition: GameObject.cpp:1550
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DynamicObjectCellRelocation()

bool Map::DynamicObjectCellRelocation ( DynamicObject go,
Cell  new_cell 
)
private
1707 {
1708  return MapObjectCellRelocation(go, new_cell, "DynamicObject");
1709 }
bool MapObjectCellRelocation(T *object, Cell new_cell, char const *objType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DynamicObjectRelocation()

void Map::DynamicObjectRelocation ( DynamicObject go,
float  x,
float  y,
float  z,
float  orientation 
)
1316 {
1317  ASSERT(CheckGridIntegrity(dynObj, false, "DynamicObject"));
1318  Cell new_cell(x, y);
1319 
1320  if (!getNGrid(new_cell.GridX(), new_cell.GridY()))
1321  return;
1322 
1323  Cell old_cell = dynObj->GetCurrentCell();
1324 
1325  // delay creature move for grid/cell to grid/cell moves
1326  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1327  {
1328 #ifdef TRINITY_DEBUG
1329  TC_LOG_DEBUG("maps", "GameObject %s added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", dynObj->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1330 #endif
1331  AddDynamicObjectToMoveList(dynObj, x, y, z, orientation);
1332  // in diffcell/diffgrid case notifiers called at finishing move dynObj in Map::MoveAllGameObjectsInMoveList
1333  }
1334  else
1335  {
1336  dynObj->Relocate(x, y, z, orientation);
1337  dynObj->UpdatePositionData();
1338  dynObj->UpdateObjectVisibility(false);
1340  }
1341 
1342  ASSERT(CheckGridIntegrity(dynObj, true, "DynamicObject"));
1343 }
uint32 CellY() const
Definition: Cell.h:72
bool DiffCell(Cell const &cell) const
Definition: Cell.h:59
uint32 GridY() const
Definition: Cell.h:74
static bool CheckGridIntegrity(T *object, bool moved, char const *objType)
Definition: Map.cpp:1210
uint32 CellX() const
Definition: Cell.h:71
uint32 GridX() const
Definition: Cell.h:73
Definition: Cell.h:46
bool DiffGrid(Cell const &cell) const
Definition: Cell.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
#define ASSERT
Definition: Errors.h:68
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
Definition: Map.cpp:1423
void AddDynamicObjectToMoveList(DynamicObject *go, float x, float y, float z, float ang)
Definition: Map.cpp:1413
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnsureGridCreated()

void Map::EnsureGridCreated ( GridCoord const &  p)
private
524 {
525  std::lock_guard<std::mutex> lock(_gridLock);
527 }
void EnsureGridCreated_i(GridCoord const &)
Definition: Map.cpp:531
std::mutex _gridLock
Definition: Map.h:700
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnsureGridCreated_i()

void Map::EnsureGridCreated_i ( GridCoord const &  p)
private
532 {
533  if (!getNGrid(p.x_coord, p.y_coord))
534  {
535  TC_LOG_DEBUG("maps", "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
536 
537  NGridType* ngrid = new NGridType(p.x_coord * MAX_NUMBER_OF_GRIDS + p.y_coord, p.x_coord, p.y_coord, i_gridExpiry, sWorld->getBoolConfig(CONFIG_GRID_UNLOAD));
538  setNGrid(ngrid, p.x_coord, p.y_coord);
539 
540  // build a linkage between this map and NGridType
541  buildNGridLinkage(ngrid);
542 
544 
545  //z coord
546  int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord;
547  int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord;
548 
549  if (!GridMaps[gx][gy])
550  {
551  Map* rootParentTerrainMap = m_parentMap->GetRootParentTerrainMap();
552  // because LoadMapAndVMap is always entered using rootParentTerrainMap, we can only lock that once and not have to do it for every child map
553  std::unique_lock<std::mutex> lock(rootParentTerrainMap->_gridLock, std::defer_lock);
554  if (this != rootParentTerrainMap)
555  lock.lock();
556 
557  if (!m_parentMap->GridMaps[gx][gy])
558  rootParentTerrainMap->LoadMapAndVMap(gx, gy);
559 
560  if (m_parentMap->GridMaps[gx][gy])
561  {
562  GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
563  ++rootParentTerrainMap->GridMapReference[gx][gy];
564  }
565  }
566  }
567 }
Definition: NGrid.h:69
time_t i_gridExpiry
Definition: Map.h:734
Map * m_parentMap
Definition: Map.h:738
Definition: World.h:106
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:38
Map * GetRootParentTerrainMap()
Definition: Map.cpp:133
#define sWorld
Definition: World.h:946
std::shared_ptr< GridMap > GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:743
uint32 GetId() const
Definition: Map.cpp:4410
void setNGrid(NGridType *grid, uint32 x, uint32 y)
Definition: Map.cpp:3153
Definition: NGrid.h:57
void LoadMapAndVMap(int gx, int gy)
Definition: Map.cpp:294
void SetGridState(grid_state_t s)
Definition: NGrid.h:92
Definition: Map.h:264
void buildNGridLinkage(NGridType *pNGridType)
Definition: Map.h:680
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
uint32 i_InstanceId
Definition: Map.h:704
uint16 GridMapReference[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:744
std::mutex _gridLock
Definition: Map.h:700
NGrid< MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes > NGridType
Definition: GridDefines.h:88
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnsureGridLoaded()

bool Map::EnsureGridLoaded ( Cell const &  cell)
private
590 {
591  EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
592  NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
593 
594  ASSERT(grid != nullptr);
595  if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY()))
596  {
597  TC_LOG_DEBUG("maps", "Loading grid[%u, %u] for map %u instance %u", cell.GridX(), cell.GridY(), GetId(), i_InstanceId);
598 
599  setGridObjectDataLoaded(true, cell.GridX(), cell.GridY());
600 
601  LoadGridObjects(grid, cell);
602 
603  Balance();
604  return true;
605  }
606 
607  return false;
608 }
Definition: NGrid.h:69
uint32 GetId() const
Definition: Map.cpp:4410
void EnsureGridCreated(GridCoord const &)
Definition: Map.cpp:523
virtual void LoadGridObjects(NGridType *grid, Cell const &cell)
Definition: Map.cpp:610
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
Definition: Map.h:688
void Balance()
Definition: Map.h:542
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
uint32 i_InstanceId
Definition: Map.h:704
#define ASSERT
Definition: Errors.h:68
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
Definition: Map.h:689
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:176
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ EnsureGridLoadedForActiveObject()

void Map::EnsureGridLoadedForActiveObject ( Cell const &  cell,
WorldObject const *  object 
)
private
571 {
572  EnsureGridLoaded(cell);
573  NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
574  ASSERT(grid != nullptr);
575 
576  if (object->IsPlayer())
577  GetMultiPersonalPhaseTracker().LoadGrid(object->GetPhaseShift(), *grid, this, cell);
578 
579  // refresh grid state & timer
580  if (grid->GetGridState() != GRID_STATE_ACTIVE)
581  {
582  TC_LOG_DEBUG("maps", "Active object %s triggers loading of grid [%u, %u] on map %u", object->GetGUID().ToString().c_str(), cell.GridX(), cell.GridY(), GetId());
583  ResetGridExpiry(*grid, 0.1f);
585  }
586 }
Definition: NGrid.h:69
bool EnsureGridLoaded(Cell const &)
Definition: Map.cpp:589
grid_state_t GetGridState(void) const
Definition: NGrid.h:91
uint32 GetId() const
Definition: Map.cpp:4410
Definition: NGrid.h:56
void LoadGrid(PhaseShift const &phaseShift, NGridType &grid, Map *map, Cell const &cell)
Definition: PersonalPhaseTracker.cpp:119
void SetGridState(grid_state_t s)
Definition: NGrid.h:92
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
#define ASSERT
Definition: Errors.h:68
MultiPersonalPhaseTracker & GetMultiPersonalPhaseTracker()
Definition: Map.h:917
void ResetGridExpiry(NGridType &grid, float factor=1) const
Definition: Map.h:329
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExistMap()

bool Map::ExistMap ( uint32  mapid,
int  gx,
int  gy,
bool  log = true 
)
static
143 {
144  std::string fileName = Trinity::StringFormat("%smaps/%04u_%02u_%02u.map", sWorld->GetDataPath().c_str(), mapid, gx, gy);
145 
146  bool ret = false;
147  FILE* file = fopen(fileName.c_str(), "rb");
148  if (!file)
149  {
150  if (log)
151  {
152  TC_LOG_ERROR("maps", "Map file '%s' does not exist!", fileName.c_str());
153  TC_LOG_ERROR("maps", "Please place MAP-files (*.map) in the appropriate directory (%s), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath() + "maps/").c_str());
154  }
155  }
156  else
157  {
158  map_fileheader header;
159  if (fread(&header, sizeof(header), 1, file) == 1)
160  {
161  if (header.mapMagic != MapMagic || header.versionMagic != MapVersionMagic)
162  {
163  if (log)
164  TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s v%u), %.*s v%u is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files. If you still have problems search on forum for error TCE00018.",
165  fileName.c_str(), 4, header.mapMagic.data(), header.versionMagic, 4, MapMagic.data(), MapVersionMagic);
166  }
167  else
168  ret = true;
169  }
170  fclose(file);
171  }
172 
173  return ret;
174 }
uint32 const MapVersionMagic
Definition: MapDefines.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
#define sWorld
Definition: World.h:946
u_map_magic const MapMagic
Definition: MapDefines.cpp:20
Definition: MapDefines.h:37
std::string StringFormat(Format &&fmt, Args &&... args)
Default TC string format function.
Definition: StringFormat.h:27
u_map_magic mapMagic
Definition: MapDefines.h:39
uint32 versionMagic
Definition: MapDefines.h:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ExistVMap()

bool Map::ExistVMap ( uint32  mapid,
int  gx,
int  gy 
)
static
177 {
179  {
180  if (vmgr->isMapLoadingEnabled())
181  {
182  VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), mapid, gx, gy);
183  std::string name = vmgr->getDirFileName(mapid, gx, gy);
184  switch (result)
185  {
187  break;
189  TC_LOG_ERROR("maps", "VMap file '%s' does not exist", (sWorld->GetDataPath() + "vmaps/" + name).c_str());
190  TC_LOG_ERROR("maps", "Please place VMAP files (*.vmtree and *.vmtile) in the vmap directory (%s), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath() + "vmaps/").c_str());
191  return false;
193  TC_LOG_ERROR("maps", "VMap file '%s' couldn't be loaded", (sWorld->GetDataPath() + "vmaps/" + name).c_str());
194  TC_LOG_ERROR("maps", "This is because the version of the VMap file and the version of this module are different, please re-extract the maps with the tools compiled with this module.");
195  return false;
197  TC_LOG_ERROR("maps", "VMap file '%s' couldn't be loaded", (sWorld->GetDataPath() + "vmaps/" + name).c_str());
198  TC_LOG_ERROR("maps", "This is because VMAP files are corrupted, please re-extract the maps with the tools compiled with this module.");
199  return false;
200  }
201  }
202  }
203 
204  return true;
205 }
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:185
static VMapManager2 * createOrGetVMapManager()
Definition: VMapFactory.cpp:27
#define sWorld
Definition: World.h:946
LoadResult
Definition: IVMapManager.h:42
Definition: IVMapManager.h:75
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameObjectCellRelocation()

bool Map::GameObjectCellRelocation ( GameObject go,
Cell  new_cell 
)
private
1702 {
1703  return MapObjectCellRelocation(go, new_cell, "GameObject");
1704 }
bool MapObjectCellRelocation(T *object, Cell new_cell, char const *objType)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameObjectRelocation()

void Map::GameObjectRelocation ( GameObject go,
float  x,
float  y,
float  z,
float  orientation,
bool  respawnRelocationOnFail = true 
)
1287 {
1288  ASSERT(CheckGridIntegrity(go, false, "GameObject"));
1289  Cell new_cell(x, y);
1290 
1291  if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
1292  return;
1293 
1294  Cell old_cell = go->GetCurrentCell();
1295 
1296  // delay creature move for grid/cell to grid/cell moves
1297  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1298  {
1299 #ifdef TRINITY_DEBUG
1300  TC_LOG_DEBUG("maps", "GameObject %s added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1301 #endif
1302  AddGameObjectToMoveList(go, x, y, z, orientation);
1303  // in diffcell/diffgrid case notifiers called at finishing move go in Map::MoveAllGameObjectsInMoveList
1304  }
1305  else
1306  {
1307  go->Relocate(x, y, z, orientation);
1308  go->AfterRelocation();
1310  }
1311 
1312  ASSERT(CheckGridIntegrity(go, true, "GameObject"));
1313 }
uint32 CellY() const
Definition: Cell.h:72
bool DiffCell(Cell const &cell) const
Definition: Cell.h:59
std::string ToString() const
Definition: ObjectGuid.cpp:531
uint32 GridY() const
Definition: Cell.h:74
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
static bool CheckGridIntegrity(T *object, bool moved, char const *objType)
Definition: Map.cpp:1210
void Relocate(float x, float y)
Definition: Position.h:64
void RemoveGameObjectFromMoveList(GameObject *go)
Definition: Map.cpp:1404
uint32 CellX() const
Definition: Cell.h:71
uint32 GridX() const
Definition: Cell.h:73
void AddGameObjectToMoveList(GameObject *go, float x, float y, float z, float ang)
Definition: Map.cpp:1394
Definition: Cell.h:46
bool DiffGrid(Cell const &cell) const
Definition: Cell.h:65
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
#define ASSERT
Definition: Errors.h:68
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:682
void AfterRelocation()
Definition: GameObject.cpp:3369
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GameObjectRespawnRelocation()

bool Map::GameObjectRespawnRelocation ( GameObject go,
bool  diffGridOnly 
)
1748 {
1749  float resp_x, resp_y, resp_z, resp_o;
1750  go->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
1751  Cell resp_cell(resp_x, resp_y);
1752 
1753  //GameObject will be unloaded with grid
1754  if (diffGridOnly && !go->GetCurrentCell().DiffGrid(resp_cell))
1755  return true;
1756 
1757 #ifdef TRINITY_DEBUG
1758  TC_LOG_DEBUG("maps", "GameObject %s moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetCurrentCell().GridX(), go->GetCurrentCell().GridY(), go->GetCurrentCell().CellX(), go->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
1759 #endif
1760 
1761  // teleport it to respawn point (like normal respawn if player see)
1762  if (GameObjectCellRelocation(go, resp_cell))
1763  {
1764  go->Relocate(resp_x, resp_y, resp_z, resp_o);
1765  go->UpdatePositionData();
1766  go->UpdateObjectVisibility(false);
1767  return true;
1768  }
1769 
1770  return false;
1771 }
std::string ToString() const
Definition: ObjectGuid.cpp:531
bool GameObjectCellRelocation(GameObject *go, Cell new_cell)
Definition: Map.cpp:1701
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr) const
Definition: GameObject.cpp:3336
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:156
void UpdatePositionData()
Definition: Object.cpp:901
void Relocate(float x, float y)
Definition: Position.h:64
Definition: Cell.h:46
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:176
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3486
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GenerateLowGuid()

template<HighGuid high>
ObjectGuid::LowType Map::GenerateLowGuid ( )
inline
601  {
602  static_assert(ObjectGuidTraits<high>::SequenceSource.HasFlag(ObjectGuidSequenceSource::Map), "Only map specific guid can be generated in Map context");
603  return GetGuidSequenceGenerator<high>().Generate();
604  }
Definition: ObjectGuid.h:163
+ Here is the caller graph for this function:

◆ GetActiveNonPlayersCount()

size_t Map::GetActiveNonPlayersCount ( ) const
inline
624  {
625  return m_activeNonPlayers.size();
626  }
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:715
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaId() [1/2]

uint32 Map::GetAreaId ( PhaseShift const &  phaseShift,
float  x,
float  y,
float  z 
)
2725 {
2726  uint32 mogpFlags;
2727  int32 adtId, rootId, groupId;
2728  float vmapZ = z;
2729  bool hasVmapArea = GetAreaInfo(phaseShift, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
2730 
2731  uint32 gridAreaId = 0;
2732  float gridMapHeight = INVALID_HEIGHT;
2733  if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
2734  {
2735  gridAreaId = gmap->getArea(x, y);
2736  gridMapHeight = gmap->getHeight(x, y);
2737  }
2738 
2739  uint32 areaId = 0;
2740 
2741  // floor is the height we are closer to (but only if above)
2742  if (hasVmapArea && G3D::fuzzyGe(z, vmapZ - GROUND_HEIGHT_TOLERANCE) && (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapZ > gridMapHeight))
2743  {
2744  // wmo found
2745  if (WMOAreaTableEntry const* wmoEntry = sDB2Manager.GetWMOAreaTable(rootId, adtId, groupId))
2746  areaId = wmoEntry->AreaTableID;
2747 
2748  if (!areaId)
2749  areaId = gridAreaId;
2750  }
2751  else
2752  areaId = gridAreaId;
2753 
2754  if (!areaId)
2755  areaId = i_mapEntry->AreaTableID;
2756 
2757  return areaId;
2758 }
uint16 AreaTableID
Definition: DB2Structure.h:2501
#define sDB2Manager
Definition: DB2Stores.h:479
MapEntry const * i_mapEntry
Definition: Map.h:702
Definition: Map.h:131
bool GetAreaInfo(PhaseShift const &phaseShift, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId)
Definition: Map.cpp:2676
float const GROUND_HEIGHT_TOLERANCE
Definition: SharedDefines.h:24
GridMap * GetGrid(uint32 mapId, float x, float y)
Definition: Map.cpp:2567
Definition: DB2Structure.h:4029
int32_t int32
Definition: Define.h:139
uint32_t uint32
Definition: Define.h:143
static uint32 GetTerrainMapId(PhaseShift const &phaseShift, Map const *map, float x, float y)
Definition: PhasingHandler.cpp:565
#define INVALID_HEIGHT
Definition: Map.h:226
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaId() [2/2]

uint32 Map::GetAreaId ( PhaseShift const &  phaseShift,
Position const &  pos 
)
inline
355 { return GetAreaId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
uint32 GetAreaId(PhaseShift const &phaseShift, float x, float y, float z)
Definition: Map.cpp:2724
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaInfo()

bool Map::GetAreaInfo ( PhaseShift const &  phaseShift,
float  x,
float  y,
float  z,
uint32 mogpflags,
int32 adtId,
int32 rootId,
int32 groupId 
)
2677 {
2678  float vmap_z = z;
2679  float dynamic_z = z;
2680  float check_z = z;
2681  uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
2683  uint32 vflags;
2684  int32 vadtId;
2685  int32 vrootId;
2686  int32 vgroupId;
2687  uint32 dflags;
2688  int32 dadtId;
2689  int32 drootId;
2690  int32 dgroupId;
2691 
2692  bool hasVmapAreaInfo = vmgr->getAreaInfo(terrainMapId, x, y, vmap_z, vflags, vadtId, vrootId, vgroupId);
2693  bool hasDynamicAreaInfo = _dynamicTree.getAreaInfo(x, y, dynamic_z, phaseShift, dflags, dadtId, drootId, dgroupId);
2694  auto useVmap = [&]() { check_z = vmap_z; mogpflags = vflags; adtId = vadtId; rootId = vrootId; groupId = vgroupId; };
2695  auto useDyn = [&]() { check_z = dynamic_z; mogpflags = dflags; adtId = dadtId; rootId = drootId; groupId = dgroupId; };
2696 
2697  if (hasVmapAreaInfo)
2698  {
2699  if (hasDynamicAreaInfo && dynamic_z > vmap_z)
2700  useDyn();
2701  else
2702  useVmap();
2703  }
2704  else if (hasDynamicAreaInfo)
2705  {
2706  useDyn();
2707  }
2708 
2709  if (hasVmapAreaInfo || hasDynamicAreaInfo)
2710  {
2711  // check if there's terrain between player height and object height
2712  if (GridMap* gmap = GetGrid(terrainMapId, x, y))
2713  {
2714  float mapHeight = gmap->getHeight(x, y);
2715  // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
2716  if (z + 2.0f > mapHeight && mapHeight > check_z)
2717  return false;
2718  }
2719  return true;
2720  }
2721  return false;
2722 }
Definition: Map.h:131
bool getAreaInfo(float x, float y, float &z, PhaseShift const &phaseShift, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition: DynamicTree.cpp:267
static VMapManager2 * createOrGetVMapManager()
Definition: VMapFactory.cpp:27
GridMap * GetGrid(uint32 mapId, float x, float y)
Definition: Map.cpp:2567
int32_t int32
Definition: Define.h:139
uint32_t uint32
Definition: Define.h:143
Definition: IVMapManager.h:75
DynamicMapTree _dynamicTree
Definition: Map.h:707
static uint32 GetTerrainMapId(PhaseShift const &phaseShift, Map const *map, float x, float y)
Definition: PhasingHandler.cpp:565
virtual bool getAreaInfo(uint32 mapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const =0
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaTrigger()

AreaTrigger * Map::GetAreaTrigger ( ObjectGuid const &  guid)
4583 {
4584  return _objectsStore.Find<AreaTrigger>(guid);
4585 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:128
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:901
Definition: AreaTrigger.h:42
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetAreaTriggerBySpawnId()

AreaTrigger * Map::GetAreaTriggerBySpawnId ( ObjectGuid::LowType  spawnId) const
4665 {
4666  auto const bounds = GetAreaTriggerBySpawnIdStore().equal_range(spawnId);
4667  if (bounds.first == bounds.second)
4668  return nullptr;
4669 
4670  return bounds.first->second;
4671 }
AreaTriggerBySpawnIdContainer & GetAreaTriggerBySpawnIdStore()
Definition: Map.h:504
+ Here is the call graph for this function:

◆ GetAreaTriggerBySpawnIdStore() [1/2]

AreaTriggerBySpawnIdContainer& Map::GetAreaTriggerBySpawnIdStore ( )
inline
504 { return _areaTriggerBySpawnIdStore; }
AreaTriggerBySpawnIdContainer _areaTriggerBySpawnIdStore
Definition: Map.h:904
+ Here is the caller graph for this function:

◆ GetAreaTriggerBySpawnIdStore() [2/2]

AreaTriggerBySpawnIdContainer const& Map::GetAreaTriggerBySpawnIdStore ( ) const
inline
505 { return _areaTriggerBySpawnIdStore; }
AreaTriggerBySpawnIdContainer _areaTriggerBySpawnIdStore
Definition: Map.h:904

◆ GetConversation()

Conversation * Map::GetConversation ( ObjectGuid const &  guid)
4593 {
4594  return _objectsStore.Find<Conversation>(guid);
4595 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:128
Definition: Conversation.h:29
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCorpse()

Corpse * Map::GetCorpse ( ObjectGuid const &  guid)
4603 {
4604  return _objectsStore.Find<Corpse>(guid);
4605 }
Definition: Corpse.h:51
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:128
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCorpseByPlayer()

Corpse* Map::GetCorpseByPlayer ( ObjectGuid const &  ownerGuid) const
inline
517  {
518  auto itr = _corpsesByPlayer.find(ownerGuid);
519  if (itr != _corpsesByPlayer.end())
520  return itr->second;
521 
522  return nullptr;
523  }
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:906
+ Here is the caller graph for this function:

◆ GetCorpsesInCell()

std::unordered_set<Corpse*> const* Map::GetCorpsesInCell ( uint32  cellId) const
inline
508  {
509  auto itr = _corpsesByCell.find(cellId);
510  if (itr != _corpsesByCell.end())
511  return &itr->second;
512 
513  return nullptr;
514  }
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:905

◆ GetCreature()

Creature * Map::GetCreature ( ObjectGuid const &  guid)
4608 {
4609  return _objectsStore.Find<Creature>(guid);
4610 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:128
Definition: Creature.h:69
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetCreatureBySpawnId()

Creature * Map::GetCreatureBySpawnId ( ObjectGuid::LowType  spawnId) const
4637 {
4638  auto const bounds = GetCreatureBySpawnIdStore().equal_range(spawnId);
4639  if (bounds.first == bounds.second)
4640  return nullptr;
4641 
4642  std::unordered_multimap<ObjectGuid::LowType, Creature*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
4643  {
4644  return pair.second->IsAlive();
4645  });
4646 
4647  return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
4648 }
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition: Map.h:496
+ Here is the call graph for this function:

◆ GetCreatureBySpawnIdStore() [1/2]

CreatureBySpawnIdContainer& Map::GetCreatureBySpawnIdStore ( )
inline
496 { return _creatureBySpawnIdStore; }
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition: Map.h:902
+ Here is the caller graph for this function:

◆ GetCreatureBySpawnIdStore() [2/2]

CreatureBySpawnIdContainer const& Map::GetCreatureBySpawnIdStore ( ) const
inline
497 { return _creatureBySpawnIdStore; }
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition: Map.h:902

◆ GetCreatureRespawnTime()

time_t Map::GetCreatureRespawnTime ( ObjectGuid::LowType  spawnId) const
inline
566 { return GetRespawnTime(SPAWN_TYPE_CREATURE, spawnId); }
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition: Map.h:557
Definition: SpawnData.h:34
+ Here is the caller graph for this function:

◆ GetDebugInfo()

std::string Map::GetDebugInfo ( ) const
virtual

Reimplemented in InstanceMap.

5151 {
5152  std::stringstream sstr;
5153  sstr << std::boolalpha
5154  << "Id: " << GetId() << " InstanceId: " << GetInstanceId() << " Difficulty: " << std::to_string(GetDifficultyID())
5155  << " HasPlayers: " << HavePlayers();
5156  return sstr.str();
5157 }
uint32 GetInstanceId() const
Definition: Map.h:380
Difficulty GetDifficultyID() const
Definition: Map.h:401
uint32 GetId() const
Definition: Map.cpp:4410
bool HavePlayers() const
Definition: Map.h:428
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDifficultyID()

Difficulty Map::GetDifficultyID ( ) const
inline
401 { return Difficulty(i_spawnMode); }
Difficulty
Definition: DBCEnums.h:664
Difficulty i_spawnMode
Definition: Map.h:703
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDifficultyLootItemContext()

ItemContext Map::GetDifficultyLootItemContext ( ) const
4399 {
4400  if (MapDifficultyEntry const* mapDifficulty = GetMapDifficulty())
4401  if (mapDifficulty->ItemContext)
4402  return ItemContext(mapDifficulty->ItemContext);
4403 
4404  if (DifficultyEntry const* difficulty = sDifficultyStore.LookupEntry(GetDifficultyID()))
4405  return ItemContext(difficulty->ItemContext);
4406 
4407  return ItemContext::NONE;
4408 }
Difficulty GetDifficultyID() const
Definition: Map.h:401
DB2Storage< DifficultyEntry > sDifficultyStore("Difficulty.db2", DifficultyLoadInfo::Instance())
MapDifficultyEntry const * GetMapDifficulty() const
Definition: Map.cpp:4393
Definition: DB2Structure.h:2559
ItemContext
Definition: DBCEnums.h:872
Definition: DB2Structure.h:1324
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetDynamicObject()

DynamicObject * Map::GetDynamicObject ( ObjectGuid const &  guid)
4613 {
4614  return _objectsStore.Find<DynamicObject>(guid);
4615 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:128
Definition: DynamicObject.h:36
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetEntrancePos()

bool Map::GetEntrancePos ( int32 mapid,
float &  x,
float &  y 
)
4478 {
4479  if (!i_mapEntry)
4480  return false;
4481  return i_mapEntry->GetEntrancePos(mapid, x, y);
4482 }
MapEntry const * i_mapEntry
Definition: Map.h:702
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
Definition: DB2Structure.h:2528
+ Here is the call graph for this function:

◆ GetEntry()

MapEntry const* Map::GetEntry ( ) const
inline
271 { return i_mapEntry; }
MapEntry const * i_mapEntry
Definition: Map.h:702
+ Here is the caller graph for this function:

◆ GetFullTerrainStatusForPosition() [1/2]

void Map::GetFullTerrainStatusForPosition ( float  x,
float  y,
float  z,
PositionFullTerrainStatus data,
map_liquidHeaderTypeFlags  reqLiquidType = map_liquidHeaderTypeFlags::AllLiquids,
float  collisionHeight = 2.03128f 
) const
+ Here is the caller graph for this function:

◆ GetFullTerrainStatusForPosition() [2/2]

void Map::GetFullTerrainStatusForPosition ( PhaseShift const &  phaseShift,
float  x,
float  y,
float  z,
PositionFullTerrainStatus data,
map_liquidHeaderTypeFlags  reqLiquidType = map_liquidHeaderTypeFlags::AllLiquids,
float  collisionHeight = 2.03128f 
)
2871 {
2873  VMAP::AreaAndLiquidData vmapData;
2874  VMAP::AreaAndLiquidData dynData;
2875  VMAP::AreaAndLiquidData* wmoData = nullptr;
2876  uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
2877  GridMap* gmap = GetGrid(terrainMapId, x, y);
2878  vmgr->getAreaAndLiquidData(terrainMapId, x, y, z, AsUnderlyingType(reqLiquidType), vmapData);
2879  _dynamicTree.getAreaAndLiquidData(x, y, z, phaseShift, AsUnderlyingType(reqLiquidType), dynData);
2880 
2881  uint32 gridAreaId = 0;
2882  float gridMapHeight = INVALID_HEIGHT;
2883  if (gmap)
2884  {
2885  gridAreaId = gmap->getArea(x, y);
2886  gridMapHeight = gmap->getHeight(x, y);
2887  }
2888 
2889  bool useGridLiquid = true;
2890 
2891  // floor is the height we are closer to (but only if above)
2892  data.floorZ = VMAP_INVALID_HEIGHT;
2893  if (gridMapHeight > INVALID_HEIGHT && G3D::fuzzyGe(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE))
2894  data.floorZ = gridMapHeight;
2895  if (vmapData.floorZ > VMAP_INVALID_HEIGHT &&
2896  G3D::fuzzyGe(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
2897  (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapData.floorZ > gridMapHeight))
2898  {
2899  data.floorZ = vmapData.floorZ;
2900  wmoData = &vmapData;
2901  }
2902  // NOTE: Objects will not detect a case when a wmo providing area/liquid despawns from under them
2903  // but this is fine as these kind of objects are not meant to be spawned and despawned a lot
2904  // example: Lich King platform
2905  if (dynData.floorZ > VMAP_INVALID_HEIGHT &&
2906  G3D::fuzzyGe(z, dynData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
2907  (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > gridMapHeight) &&
2908  (G3D::fuzzyLt(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > vmapData.floorZ))
2909  {
2910  data.floorZ = dynData.floorZ;
2911  wmoData = &dynData;
2912  }
2913 
2914  if (wmoData)
2915  {
2916  if (wmoData->areaInfo)
2917  {
2918  data.areaInfo.emplace(wmoData->areaInfo->adtId, wmoData->areaInfo->rootId, wmoData->areaInfo->groupId, wmoData->areaInfo->mogpFlags);
2919  // wmo found
2920  WMOAreaTableEntry const* wmoEntry = sDB2Manager.GetWMOAreaTable(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId);
2921  data.outdoors = (wmoData->areaInfo->mogpFlags & 0x8) != 0;
2922  if (wmoEntry)
2923  {
2924  data.areaId = wmoEntry->AreaTableID;
2925  if (wmoEntry->Flags & 4)
2926  data.outdoors = true;
2927  else if (wmoEntry->Flags & 2)
2928  data.outdoors = false;
2929  }
2930 
2931  if (!data.areaId)
2932  data.areaId = gridAreaId;
2933 
2934  useGridLiquid = !IsInWMOInterior(wmoData->areaInfo->mogpFlags);
2935  }
2936  }
2937  else
2938  {
2939  data.outdoors = true;
2940  data.areaId = gridAreaId;
2941  if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId))
2942  data.outdoors = (areaEntry->Flags[0] & (AREA_FLAG_INSIDE | AREA_FLAG_OUTSIDE)) != AREA_FLAG_INSIDE;
2943  }
2944 
2945  if (!data.areaId)
2946  data.areaId = i_mapEntry->AreaTableID;
2947 
2948  AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId);
2949 
2950  // liquid processing
2952  if (wmoData && wmoData->liquidInfo && wmoData->liquidInfo->level > wmoData->floorZ)
2953  {
2954  uint32 liquidType = wmoData->liquidInfo->type;
2955  if (GetId() == 530 && liquidType == 2) // gotta love blizzard hacks
2956  liquidType = 15;
2957 
2958  uint32 liquidFlagType = 0;
2959  if (LiquidTypeEntry const* liquidData = sLiquidTypeStore.LookupEntry(liquidType))
2960  liquidFlagType = liquidData->SoundBank;
2961 
2962  if (liquidType && liquidType < 21 && areaEntry)
2963  {
2964  uint32 overrideLiquid = areaEntry->LiquidTypeID[liquidFlagType];
2965  if (!overrideLiquid && areaEntry->ParentAreaID)
2966  {
2967  AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->ParentAreaID);
2968  if (zoneEntry)
2969  overrideLiquid = zoneEntry->LiquidTypeID[liquidFlagType];
2970  }
2971 
2972  if (LiquidTypeEntry const* overrideData = sLiquidTypeStore.LookupEntry(overrideLiquid))
2973  {
2974  liquidType = overrideLiquid;
2975  liquidFlagType = overrideData->SoundBank;
2976  }
2977  }
2978 
2979  data.liquidInfo.emplace();
2980  data.liquidInfo->level = wmoData->liquidInfo->level;
2981  data.liquidInfo->depth_level = wmoData->floorZ;
2982  data.liquidInfo->entry = liquidType;
2983  data.liquidInfo->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType);
2984 
2985  float delta = wmoData->liquidInfo->level - z;
2986  if (delta > collisionHeight)
2988  else if (delta > 0.0f)
2990  else if (delta > -0.1f)
2992  else
2994  }
2995  // look up liquid data from grid map
2996  if (gmap && useGridLiquid)
2997  {
2998  LiquidData gridMapLiquid;
2999  ZLiquidStatus gridMapStatus = gmap->GetLiquidStatus(x, y, z, reqLiquidType, &gridMapLiquid, collisionHeight);
3000  if (gridMapStatus != LIQUID_MAP_NO_WATER && (!wmoData || gridMapLiquid.level > wmoData->floorZ))
3001  {
3002  if (GetId() == 530 && gridMapLiquid.entry == 2)
3003  gridMapLiquid.entry = 15;
3004  data.liquidInfo = gridMapLiquid;
3005  data.liquidStatus = gridMapStatus;
3006  }
3007  }
3008 }
uint32 areaId
Definition: Map.h:123
Definition: DB2Structure.h:125
constexpr std::underlying_type< E >::type AsUnderlyingType(E enumValue)
Definition: Util.h:473
uint16 AreaTableID
Definition: DB2Structure.h:2501
#define sDB2Manager
Definition: DB2Stores.h:479
virtual void getAreaAndLiquidData(unsigned int mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData &data) const =0
static bool IsInWMOInterior(uint32 mogpFlags)
Definition: Map.cpp:2671
MapEntry const * i_mapEntry
Definition: Map.h:702
Definition: IVMapManager.h:53
float floorZ
Definition: Map.h:124
#define VMAP_INVALID_HEIGHT
Definition: IVMapManager.h:50
Definition: Map.h:131
Definition: Map.h:103
ZLiquidStatus
Definition: Map.h:91
uint16 getArea(float x, float y) const
Definition: Map.cpp:2171
static VMapManager2 * createOrGetVMapManager()
Definition: VMapFactory.cpp:27
DB2Storage< LiquidTypeEntry > sLiquidTypeStore("LiquidType.db2", LiquidTypeLoadInfo::Instance())
Definition: Map.h:95
Definition: Map.h:93
uint32 GetId() const
Definition: Map.cpp:4410
float const GROUND_HEIGHT_TOLERANCE
Definition: SharedDefines.h:24
std::array< uint16, 4 > LiquidTypeID
Definition: DB2Structure.h:150
GridMap * GetGrid(uint32 mapId, float x, float y)
Definition: Map.cpp:2567
Definition: DB2Structure.h:4029
map_liquidHeaderTypeFlags
Definition: MapDefines.h:95
Definition: DBCEnums.h:136
Definition: DB2Structure.h:2444
float level
Definition: Map.h:107
uint32_t uint32
Definition: Define.h:143
bool outdoors
Definition: Map.h:125
Definition: IVMapManager.h:75
Optional< AreaInfo > areaInfo
Definition: Map.h:127
void getAreaAndLiquidData(float x, float y, float z, PhaseShift const &phaseShift, uint8 reqLiquidType, VMAP::AreaAndLiquidData &data) const
Definition: DynamicTree.cpp:284
DB2Storage< AreaTableEntry > sAreaTableStore("AreaTable.db2", AreaTableLoadInfo::Instance())
uint32 entry
Definition: Map.h:106
Definition: Map.h:96
uint16 AreaTableID
Definition: DB2Structure.h:4044
DynamicMapTree _dynamicTree
Definition: Map.h:707
ZLiquidStatus GetLiquidStatus(float x, float y, float z, Optional< map_liquidHeaderTypeFlags > ReqLiquidType, LiquidData *data=nullptr, float collisionHeight=2.03128f)
Definition: Map.cpp:2476
static uint32 GetTerrainMapId(PhaseShift const &phaseShift, Map const *map, float x, float y)
Definition: PhasingHandler.cpp:565
Optional< LiquidInfo > liquidInfo
Definition: IVMapManager.h:72
Optional< AreaInfo > areaInfo
Definition: IVMapManager.h:71
ZLiquidStatus liquidStatus
Definition: Map.h:126
#define INVALID_HEIGHT
Definition: Map.h:226
float getHeight(float x, float y) const
Definition: Map.h:196
Definition: DBCEnums.h:137
uint8 Flags
Definition: DB2Structure.h:4045
Definition: Map.h:94
float floorZ
Definition: IVMapManager.h:70
Optional< LiquidData > liquidInfo
Definition: Map.h:128
Definition: Map.h:97
uint16 ParentAreaID
Definition: DB2Structure.h:131
+ Here is the call graph for this function:

◆ GetGameObject()

GameObject * Map::GetGameObject ( ObjectGuid const &  guid)
4618 {
4619  return _objectsStore.Find<GameObject>(guid);
4620 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:128
Definition: GameObject.h:125
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:901
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGameObjectBySpawnId()

GameObject * Map::GetGameObjectBySpawnId ( ObjectGuid::LowType  spawnId) const
4651 {
4652  auto const bounds = GetGameObjectBySpawnIdStore().equal_range(spawnId);
4653  if (bounds.first == bounds.second)
4654  return nullptr;
4655 
4656  std::unordered_multimap<ObjectGuid::LowType, GameObject*>::const_iterator creatureItr = std::find_if(bounds.first, bounds.second, [](Map::GameObjectBySpawnIdContainer::value_type const& pair)
4657  {
4658  return pair.second->isSpawned();
4659  });
4660 
4661  return creatureItr != bounds.second ? creatureItr->second : bounds.first->second;
4662 }
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition: Map.h:500
+ Here is the call graph for this function:

◆ GetGameObjectBySpawnIdStore() [1/2]

GameObjectBySpawnIdContainer& Map::GetGameObjectBySpawnIdStore ( )
inline
500 { return _gameobjectBySpawnIdStore; }
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
Definition: Map.h:903
+ Here is the caller graph for this function:

◆ GetGameObjectBySpawnIdStore() [2/2]

GameObjectBySpawnIdContainer const& Map::GetGameObjectBySpawnIdStore ( ) const
inline
501 { return _gameobjectBySpawnIdStore; }
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
Definition: Map.h:903

◆ GetGameObjectFloor()

float Map::GetGameObjectFloor ( PhaseShift const &  phaseShift,
float  x,
float  y,
float  z,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
inline
547  {
548  return _dynamicTree.getHeight(x, y, z, maxSearchDist, phaseShift);
549  }
DynamicMapTree _dynamicTree
Definition: Map.h:707
float getHeight(float x, float y, float z, float maxSearchDist, PhaseShift const &phaseShift) const
Definition: DynamicTree.cpp:254
+ Here is the caller graph for this function:

◆ GetGORespawnTime()

time_t Map::GetGORespawnTime ( ObjectGuid::LowType  spawnId) const
inline
567 { return GetRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId); }
Definition: SpawnData.h:35
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition: Map.h:557
+ Here is the caller graph for this function:

◆ GetGrid()

GridMap * Map::GetGrid ( uint32  mapId,
float  x,
float  y 
)
private
2568 {
2569  // half opt method
2570  int gx = (int)(CENTER_GRID_ID - x / SIZE_OF_GRIDS); //grid x
2571  int gy = (int)(CENTER_GRID_ID - y / SIZE_OF_GRIDS); //grid y
2572 
2573  // ensure GridMap is loaded
2575 
2576  GridMap* grid = GridMaps[gx][gy].get();
2577  auto childMapItr = std::find_if(m_childTerrainMaps->begin(), m_childTerrainMaps->end(), [mapId](Map* childTerrainMap) { return childTerrainMap->GetId() == mapId; });
2578  if (childMapItr != m_childTerrainMaps->end() && (*childMapItr)->GridMaps[gx][gy])
2579  grid = (*childMapItr)->GridMaps[gx][gy].get();
2580 
2581  return grid;
2582 }
#define SIZE_OF_GRIDS
Definition: GridDefines.h:40
#define CENTER_GRID_ID
Definition: GridDefines.h:41
Definition: Map.h:131
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:38
std::shared_ptr< GridMap > GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:743
std::vector< Map * > * m_childTerrainMaps
Definition: Map.h:740
void EnsureGridCreated(GridCoord const &)
Definition: Map.cpp:523
Definition: Map.h:264
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:176
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGridExpiry()

time_t Map::GetGridExpiry ( ) const
inline
334 { return i_gridExpiry; }
time_t i_gridExpiry
Definition: Map.h:734
+ Here is the caller graph for this function:

◆ GetGridHeight()

float Map::GetGridHeight ( PhaseShift const &  phaseShift,
float  x,
float  y 
)
2656 {
2657  if (GridMap* gmap = GetGrid(PhasingHandler::GetTerrainMapId(phaseShift, this, x, y), x, y))
2658  return gmap->getHeight(x, y);
2659 
2661 }
Definition: Map.h:131
GridMap * GetGrid(uint32 mapId, float x, float y)
Definition: Map.cpp:2567
#define VMAP_INVALID_HEIGHT_VALUE
Definition: IVMapManager.h:51
static uint32 GetTerrainMapId(PhaseShift const &phaseShift, Map const *map, float x, float y)
Definition: PhasingHandler.cpp:565
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase& Map::GetGuidSequenceGenerator ( )
inlineprivate
891  {
892  auto itr = _guidGenerators.find(high);
893  if (itr == _guidGenerators.end())
894  itr = _guidGenerators.insert(std::make_pair(high, std::make_unique<ObjectGuidGenerator<high>>())).first;
895 
896  return *itr->second;
897  }
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition: Map.h:899
Definition: ObjectGuid.h:408

◆ GetHeight() [1/2]

float Map::GetHeight ( PhaseShift const &  phaseShift,
float  x,
float  y,
float  z,
bool  vmap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
)
inline
539 { return std::max<float>(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phaseShift, x, y, z, maxSearchDist)); }
float GetGameObjectFloor(PhaseShift const &phaseShift, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.h:546
float GetStaticHeight(PhaseShift const &phaseShift, float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition: Map.cpp:2616
+ Here is the caller graph for this function:

◆ GetHeight() [2/2]

float Map::GetHeight ( PhaseShift const &  phaseShift,
Position const &  pos,
bool  vmap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
)
inline
540 { return GetHeight(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); }
float GetHeight(PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition: Map.h:539
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetId()

uint32 Map::GetId ( ) const
4411 {
4412  return i_mapEntry->ID;
4413 }
MapEntry const * i_mapEntry
Definition: Map.h:702
uint32 ID
Definition: DB2Structure.h:2490
+ Here is the caller graph for this function:

◆ GetInstanceId()

uint32 Map::GetInstanceId ( ) const
inline
380 { return i_InstanceId; }
uint32 i_InstanceId
Definition: Map.h:704
+ Here is the caller graph for this function:

◆ GetLinkedRespawnTime()

time_t Map::GetLinkedRespawnTime ( ObjectGuid  guid) const
4762 {
4763  ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
4764  switch (linkedGuid.GetHigh())
4765  {
4766  case HighGuid::Creature:
4767  return GetCreatureRespawnTime(linkedGuid.GetCounter());
4768  case HighGuid::GameObject:
4769  return GetGORespawnTime(linkedGuid.GetCounter());
4770  default:
4771  break;
4772  }
4773 
4774  return time_t(0);
4775 }
LowType GetCounter() const
Definition: ObjectGuid.h:284
HighGuid GetHigh() const
Definition: ObjectGuid.h:279
#define sObjectMgr
Definition: ObjectMgr.h:1967
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
Definition: Map.h:566
Definition: ObjectGuid.h:258
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
Definition: Map.h:567
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetLiquidStatus()

ZLiquidStatus Map::GetLiquidStatus ( PhaseShift const &  phaseShift,
float  x,
float  y,
float  z,
map_liquidHeaderTypeFlags  ReqLiquidType,
LiquidData data = nullptr,
float  collisionHeight = 2.03128f 
)
2779 {
2782  float liquid_level = INVALID_HEIGHT;
2783  float ground_level = INVALID_HEIGHT;
2784  uint32 liquid_type = 0;
2785  uint32 mogpFlags = 0;
2786  bool useGridLiquid = true;
2787  uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
2788  if (vmgr->GetLiquidLevel(terrainMapId, x, y, z, AsUnderlyingType(ReqLiquidType), liquid_level, ground_level, liquid_type, mogpFlags))
2789  {
2790  useGridLiquid = !IsInWMOInterior(mogpFlags);
2791  TC_LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: %f ground: %f type: %u", liquid_level, ground_level, liquid_type);
2792  // Check water level and ground level
2793  if (liquid_level > ground_level && G3D::fuzzyGe(z, ground_level - GROUND_HEIGHT_TOLERANCE))
2794  {
2795  // All ok in water -> store data
2796  if (data)
2797  {
2798  // hardcoded in client like this
2799  if (GetId() == 530 && liquid_type == 2)
2800  liquid_type = 15;
2801 
2802  uint32 liquidFlagType = 0;
2803  if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(liquid_type))
2804  liquidFlagType = liq->SoundBank;
2805 
2806  if (liquid_type && liquid_type < 21)
2807  {
2808  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseShift, x, y, z)))
2809  {
2810  uint32 overrideLiquid = area->LiquidTypeID[liquidFlagType];
2811  if (!overrideLiquid && area->ParentAreaID)
2812  {
2813  area = sAreaTableStore.LookupEntry(area->ParentAreaID);
2814  if (area)
2815  overrideLiquid = area->LiquidTypeID[liquidFlagType];
2816  }
2817 
2818  if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
2819  {
2820  liquid_type = overrideLiquid;
2821  liquidFlagType = liq->SoundBank;
2822  }
2823  }
2824  }
2825 
2826  data->level = liquid_level;
2827  data->depth_level = ground_level;
2828 
2829  data->entry = liquid_type;
2830  data->type_flags = map_liquidHeaderTypeFlags(1 << liquidFlagType);
2831  }