AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Map Class Reference

#include "Map.h"

Inheritance diagram for Map:
GridRefMgr< MapGridType > RefMgr< TO, FROM > LinkedListHead BattlegroundMap InstanceMap MapInstanced TestMap

Classes

struct  RespawnEntry
 

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 MapRefMgr PlayerList
 
typedef std::unordered_multimap< ObjectGuid::LowType, Creature * > CreatureBySpawnIdContainer
 
typedef std::unordered_multimap< ObjectGuid::LowType, GameObject * > GameObjectBySpawnIdContainer
 
typedef std::vector< WorldObject * > UpdatableObjectList
 
typedef std::unordered_set< WorldObject * > PendingAddUpdatableObjectList
 
- Public Types inherited from GridRefMgr< MapGridType >
typedef LinkedListHead::Iterator< GridReference< MapGridType > > iterator
 
- Public Types inherited from RefMgr< TO, FROM >
typedef LinkedListHead::Iterator< Reference< TO, FROM > > iterator
 
- Public Types inherited from LinkedListHead
typedef Iterator< LinkedListElementiterator
 

Public Member Functions

 Map (uint32 id, uint32 InstanceId, uint8 SpawnMode, Map *_parent=nullptr)
 
 ~Map () override
 
MapEntry const * GetEntry () const
 
bool CanUnload (uint32 diff)
 
virtual bool AddPlayerToMap (Player *)
 
virtual void RemovePlayerFromMap (Player *, bool)
 
virtual void AfterPlayerUnlinkFromMap ()
 
template<class T >
bool AddToMap (T *, bool checkTransport=false)
 
template<class T >
void RemoveFromMap (T *, bool)
 
void MarkNearbyCellsOf (WorldObject *obj)
 
virtual void Update (const uint32, const uint32, bool thread=true)
 
float GetVisibilityRange () const
 
void SetVisibilityRange (float range)
 
void OnCreateMap ()
 
virtual void InitVisibilityDistance ()
 
void PlayerRelocation (Player *, float x, float y, float z, float o)
 
void CreatureRelocation (Creature *creature, float x, float y, float z, float o)
 
void GameObjectRelocation (GameObject *go, float x, float y, float z, float o)
 
void DynamicObjectRelocation (DynamicObject *go, float x, float y, float z, float o)
 
template<class T , class CONTAINER >
void Visit (Cell const &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
 
bool IsGridLoaded (GridCoord const &gridCoord) const
 
bool IsGridLoaded (float x, float y) const
 
bool IsGridCreated (GridCoord const &gridCoord) const
 
bool IsGridCreated (float x, float y) const
 
void LoadGrid (float x, float y)
 
void LoadAllGrids ()
 
void LoadGridsInRange (Position const &center, float radius)
 
bool UnloadGrid (MapGridType &grid)
 
virtual void UnloadAll ()
 
std::shared_ptr< GridTerrainDataGetGridTerrainDataSharedPtr (GridCoord const &gridCoord)
 
GridTerrainDataGetGridTerrainData (GridCoord const &gridCoord)
 
GridTerrainDataGetGridTerrainData (float x, float y)
 
uint32 GetId () const
 
Map const * GetParent () const
 
void HandleDelayedVisibility ()
 
float GetHeight (float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
float GetHeight (Position const &pos, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
float GetGridHeight (float x, float y) const
 
float GetMinHeight (float x, float y) const
 
TransportGetTransportForPos (uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
 
void GetFullTerrainStatusForPosition (uint32 phaseMask, float x, float y, float z, float collisionHeight, PositionFullTerrainStatus &data, Optional< uint8 > reqLiquidType={})
 
LiquidData const GetLiquidData (uint32 phaseMask, float x, float y, float z, float collisionHeight, Optional< uint8 > ReqLiquidType)
 
bool GetAreaInfo (uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
 
uint32 GetAreaId (uint32 phaseMask, float x, float y, float z) const
 
uint32 GetZoneId (uint32 phaseMask, float x, float y, float z) const
 
void GetZoneAndAreaId (uint32 phaseMask, uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
 
float GetWaterLevel (float x, float y) const
 
bool IsInWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
 
bool IsUnderWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
 
bool HasEnoughWater (WorldObject const *searcher, float x, float y, float z) const
 
bool HasEnoughWater (WorldObject const *searcher, LiquidData const &liquidData) const
 
void MoveAllCreaturesInMoveList ()
 
void MoveAllGameObjectsInMoveList ()
 
void MoveAllDynamicObjectsInMoveList ()
 
void RemoveAllObjectsInRemoveList ()
 
virtual void RemoveAllPlayers ()
 
uint32 GetInstanceId () const
 
uint8 GetSpawnMode () const
 
virtual EnterState CannotEnter (Player *, bool)
 
char const * GetMapName () const
 
Difficulty GetDifficulty () const
 
bool IsRegularDifficulty () const
 
MapDifficulty const * GetMapDifficulty () const
 
bool Instanceable () const
 
bool IsDungeon () const
 
bool IsNonRaidDungeon () const
 
bool IsRaid () const
 
bool IsRaidOrHeroicDungeon () const
 
bool IsHeroic () const
 
bool Is25ManRaid () const
 
bool IsBattleground () const
 
bool IsBattleArena () const
 
bool IsBattlegroundOrArena () const
 
bool IsWorldMap () const
 
bool GetEntrancePos (int32 &mapid, float &x, float &y)
 
void AddObjectToRemoveList (WorldObject *obj)
 
virtual void DelayedUpdate (const uint32 diff)
 
void resetMarkedCells ()
 
bool isCellMarked (uint32 pCellId)
 
void markCell (uint32 pCellId)
 
bool HavePlayers () const
 
uint32 GetPlayersCountExceptGMs (bool aliveOnly=false) const
 
void SendToPlayers (WorldPacket const *data) const
 
void StartPlayersRedirectKickTimer ()
 
void StopPlayersRedirectKickTimer ()
 
bool IsPlayerRedirectKickTimerActive ()
 
PlayerList const & GetPlayers () const
 
void ScriptsStart (std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
 Put scripts in the execution queue.
 
void ScriptCommandStart (ScriptInfo const &script, uint32 delay, Object *source, Object *target)
 
void UpdateIteratorBack (Player *player)
 
TempSummonSummonCreature (uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, bool visibleBySummonerOnly=false)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true)
 
GameObjectSummonGameObject (uint32 entry, Position const &pos, float rotation0=0.0f, float rotation1=0.0f, float rotation2=0.0f, float rotation3=0.0f, uint32 respawnTime=100, bool checkTransport=true)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
 
void SummonGameObjectGroup (uint8 group, std::list< GameObject * > *list=nullptr)
 
CorpseGetCorpse (ObjectGuid const &guid)
 
CreatureGetCreature (ObjectGuid const &guid)
 
GameObjectGetGameObject (ObjectGuid const &guid)
 
TransportGetTransport (ObjectGuid const &guid)
 
DynamicObjectGetDynamicObject (ObjectGuid const &guid)
 
PetGetPet (ObjectGuid const &guid)
 
MapStoredObjectTypesContainerGetObjectsStore ()
 
CreatureBySpawnIdContainerGetCreatureBySpawnIdStore ()
 
GameObjectBySpawnIdContainerGetGameObjectBySpawnIdStore ()
 
std::unordered_set< Corpse * > const * GetCorpsesInGrid (uint32 gridId) const
 
CorpseGetCorpseByPlayer (ObjectGuid const &ownerGuid) const
 
SpawnedPoolDataGetPoolData ()
 
SpawnedPoolData const & GetPoolData () const
 
MapInstancedToMapInstanced ()
 
MapInstanced const * ToMapInstanced () const
 
InstanceMapToInstanceMap ()
 
InstanceMap const * ToInstanceMap () const
 
BattlegroundMapToBattlegroundMap ()
 
BattlegroundMap const * ToBattlegroundMap () const
 
float GetWaterOrGroundLevel (uint32 phasemask, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=DEFAULT_COLLISION_HEIGHT) const
 
float GetHeight (uint32 phasemask, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
bool isInLineOfSight (float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 Check if a given source can reach a specific point following a path and normalize the coords. Use this method for long paths, otherwise use the overloaded method with the start coords when you need to do a quick check on small segments.
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 validate the new destination and set reachable coords Check if a given unit can reach a specific point on a segment and set the correct dest coords NOTE: use this method with small segments.
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 
bool CheckCollisionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true) const
 validate the new destination and set coords Check if a given unit can face collisions in a specific segment
 
void Balance ()
 
void RemoveGameObjectModel (GameObjectModel const &model)
 
void InsertGameObjectModel (GameObjectModel const &model)
 
bool ContainsGameObjectModel (GameObjectModel const &model) const
 
DynamicMapTree const & GetDynamicMapTree () const
 
float GetGameObjectFloor (uint32 phasemask, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
time_t GetLinkedRespawnTime (ObjectGuid guid) const
 
time_t GetCreatureRespawnTime (ObjectGuid::LowType dbGuid) const
 
time_t GetGORespawnTime (ObjectGuid::LowType dbGuid) const
 
void SaveCreatureRespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
 
void RemoveCreatureRespawnTime (ObjectGuid::LowType dbGuid)
 
void SaveGORespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
 
void RemoveGORespawnTime (ObjectGuid::LowType dbGuid)
 
std::unordered_map< ObjectGuid::LowType, time_t > const & GetCreatureRespawnTimes () const
 
std::unordered_map< ObjectGuid::LowType, time_t > const & GetGORespawnTimes () const
 
void LoadRespawnTimes ()
 
void DeleteRespawnTimes ()
 
time_t GetInstanceResetPeriod () const
 
void UpdatePlayerZoneStats (uint32 oldZone, uint32 newZone)
 
uint32 ApplyDynamicModeRespawnScaling (WorldObject const *obj, uint32 respawnDelay) const
 
bool SpawnGroupSpawn (uint32 groupId, bool ignoreRespawn=false, bool force=false)
 
bool SpawnGroupDespawn (uint32 groupId, bool deleteRespawnTimes=false)
 
bool IsSpawnGroupActive (uint32 groupId) const
 
void ProcessRespawns ()
 
void ProcessCreatureRespawn (ObjectGuid::LowType spawnId)
 
void ProcessGameObjectRespawn (ObjectGuid::LowType spawnId)
 
time_t GetRespawnTime (SpawnObjectType type, ObjectGuid::LowType spawnId) const
 
void RemoveRespawnTime (SpawnObjectType type, ObjectGuid::LowType spawnId)
 
void ScheduleCreatureRespawn (ObjectGuid, Milliseconds, Position pos=Position())
 
void LoadCorpseData ()
 
void DeleteCorpseData ()
 
void AddCorpse (Corpse *corpse)
 
void RemoveCorpse (Corpse *corpse)
 
CorpseConvertCorpseToBones (ObjectGuid const &ownerGuid, bool insignia=false)
 
void RemoveOldCorpses ()
 
bool SendZoneMessage (uint32 zone, WorldPacket const *packet, WorldSession const *self=nullptr, TeamId teamId=TEAM_NEUTRAL) const
 Send a packet to all players (or players selected team) in the zone (except self if mentioned)
 
void SendZoneText (uint32 zoneId, char const *text, WorldSession const *self=nullptr, TeamId teamId=TEAM_NEUTRAL) const
 Send a System Message to all players in the zone (except self if mentioned)
 
void SendInitTransports (Player *player)
 
void SendRemoveTransports (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 SendInitSelf (Player *player)
 
void UpdateWeather (uint32 const diff)
 
void UpdateExpiredCorpses (uint32 const diff)
 
void PlayDirectSoundToMap (uint32 soundId, uint32 zoneId=0)
 
void SetZoneMusic (uint32 zoneId, uint32 musicId)
 
WeatherGetOrGenerateZoneDefaultWeather (uint32 zoneId)
 
void SetZoneWeather (uint32 zoneId, WeatherState weatherId, float weatherGrade)
 
void SetZoneOverrideLight (uint32 zoneId, uint32 lightId, Milliseconds fadeInTime)
 
void UpdateEncounterState (EncounterCreditType type, uint32 creditEntry, Unit *source)
 
void LogEncounterFinished (EncounterCreditType type, uint32 creditEntry)
 
void DoForAllPlayers (std::function< void(Player *)> exec)
 
void EnsureGridCreated (GridCoord const &gridCoord)
 
bool AllTransportsEmpty () const
 
void AllTransportsRemovePassengers ()
 
TransportsContainer const & GetAllTransports () const
 
template<HighGuid high>
ObjectGuid::LowType GenerateLowGuid ()
 
void AddUpdateObject (Object *obj)
 
void RemoveUpdateObject (Object *obj)
 
size_t GetUpdatableObjectsCount () const
 
virtual std::string GetDebugInfo () const
 
uint32 GetCreatedGridsCount ()
 
uint32 GetLoadedGridsCount ()
 
uint32 GetCreatedCellsInGridCount (uint16 const x, uint16 const y)
 
uint32 GetCreatedCellsInMapCount ()
 
void AddObjectToPendingUpdateList (WorldObject *obj)
 
void RemoveObjectFromMapUpdateList (WorldObject *obj)
 
void AddWorldObjectToFarVisibleMap (WorldObject *obj)
 
void RemoveWorldObjectFromFarVisibleMap (WorldObject *obj)
 
void AddWorldObjectToZoneWideVisibleMap (uint32 zoneId, WorldObject *obj)
 
void RemoveWorldObjectFromZoneWideVisibleMap (uint32 zoneId, WorldObject *obj)
 
ZoneWideVisibleWorldObjectsSet const * GetZoneWideVisibleWorldObjectsForZone (uint32 zoneId) const
 
uint32 GetPlayerCountInZone (uint32 zoneId) const
 
MapCollisionDataGetMapCollisionData ()
 
MapCollisionData const & GetMapCollisionData () const
 
template<>
void AddToGrid (Creature *obj, Cell const &cell)
 
template<>
void AddToGrid (GameObject *obj, Cell const &cell)
 
template<>
void AddToGrid (Player *obj, Cell const &cell)
 
template<>
void AddToGrid (Corpse *obj, Cell const &cell)
 
template<>
void DeleteFromWorld (Player *player)
 
template<>
void InitializeObject (Creature *)
 
template<>
void InitializeObject (GameObject *)
 
template<>
bool AddToMap (Transport *obj, bool)
 
template<>
void RemoveFromMap (Transport *obj, bool remove)
 
- Public Member Functions inherited from GridRefMgr< MapGridType >
GridReference< MapGridType > * getFirst ()
 
GridReference< MapGridType > * getLast ()
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
- Public Member Functions inherited from RefMgr< TO, FROM >
 RefMgr ()=default
 
virtual ~RefMgr ()
 
Reference< TO, FROM > * getFirst ()
 
Reference< TO, FROM > const * getFirst () const
 
Reference< TO, FROM > * getLast ()
 
Reference< TO, FROM > const * getLast () const
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
void clearReferences ()
 
- Public Member Functions inherited from LinkedListHead
 LinkedListHead ()
 
bool IsEmpty () const
 
LinkedListElementgetFirst ()
 
LinkedListElement const * getFirst () const
 
LinkedListElementgetLast ()
 
LinkedListElement const * getLast () const
 
void insertFirst (LinkedListElement *pElem)
 
void insertLast (LinkedListElement *pElem)
 
uint32 getSize () const
 
void incSize ()
 
void decSize ()
 

Static Public Member Functions

static void DeleteRespawnTimesInDB (uint16 mapId, uint32 instanceId)
 

Public Attributes

std::unordered_set< Unit * > i_objectsForDelayedVisibility
 
CreatureGroupHolderType CreatureGroupHolder
 
EventProcessor Events
 
DataMap CustomData
 

Protected Member Functions

template<class T >
void AddToGrid (T *object, Cell const &cell)
 

Protected Attributes

std::mutex Lock
 
MapGridManager _mapGridManager
 
MapEntry const * i_mapEntry
 
MapCollisionData _mapCollisionData
 
uint8 i_spawnMode
 
uint32 i_InstanceId
 
uint32 m_unloadTimer
 
float m_VisibleDistance
 
time_t _instanceResetPeriod
 
MapRefMgr m_mapRefMgr
 
MapRefMgr::iterator m_mapRefIter
 
TransportsContainer _transports
 
TransportsContainer::iterator _transportsUpdateIter
 

Private Types

typedef std::multimap< time_t, ScriptActionScriptScheduleMap
 

Private Member Functions

template<class T >
void InitializeObject (T *obj)
 
void AddCreatureToMoveList (Creature *c)
 
void RemoveCreatureFromMoveList (Creature *c)
 
void AddGameObjectToMoveList (GameObject *go)
 
void RemoveGameObjectFromMoveList (GameObject *go)
 
void AddDynamicObjectToMoveList (DynamicObject *go)
 
void RemoveDynamicObjectFromMoveList (DynamicObject *go)
 
bool EnsureGridLoaded (Cell const &cell)
 
MapGridTypeGetMapGrid (uint16 const x, uint16 const y)
 
void ScriptsProcess ()
 Process queued scripts.
 
void SendObjectUpdates ()
 
void UpdatePlayersRedirectKickEvent (uint32 diff)
 
Player_GetScriptPlayerSourceOrTarget (Object *source, Object *target, ScriptInfo const *scriptInfo) const
 
Creature_GetScriptCreatureSourceOrTarget (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
 
template<class T >
void DeleteFromWorld (T *)
 
void UpdateNonPlayerObjects (uint32 const diff)
 
void _AddObjectToUpdateList (WorldObject *obj)
 
void _RemoveObjectFromUpdateList (WorldObject *obj)
 
template<HighGuid high>
ObjectGuidGeneratorBaseGetGuidSequenceGenerator ()
 

Private Attributes

std::vector< Creature * > _creaturesToMove
 
std::vector< GameObject * > _gameObjectsToMove
 
std::vector< DynamicObject * > _dynamicObjectsToMove
 
Mapm_parentMap
 
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAPmarked_cells
 
bool i_scriptLock
 
std::unordered_set< WorldObject * > i_objectsToRemove
 
ScriptScheduleMap m_scriptSchedule
 
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
 
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
 
std::set< RespawnEntry_respawnQueue
 
std::unique_ptr< SpawnedPoolData_poolData
 
std::unordered_set< uint32_toggledSpawnGroupIds
 
uint32 _respawnCheckTimer {0}
 
std::unordered_map< uint32, uint32_zonePlayerCountMap
 
ZoneDynamicInfoMap _zoneDynamicInfo
 
IntervalTimer _weatherUpdateTimer
 
uint32 _defaultLight
 
IntervalTimer _corpseUpdateTimer
 
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
 
MapStoredObjectTypesContainer _objectsStore
 
CreatureBySpawnIdContainer _creatureBySpawnIdStore
 
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
 
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByGrid
 
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
 
std::unordered_set< Corpse * > _corpseBones
 
std::unordered_set< Object * > _updateObjects
 
UpdatableObjectList _updatableObjectList
 
PendingAddUpdatableObjectList _pendingAddUpdatableObjectList
 
IntervalTimer _updatableObjectListRecheckTimer
 
ZoneWideVisibleWorldObjectsMap _zoneWideVisibleWorldObjectsMap
 
TimeTrackerSmall _redirectKickTimer
 
TimeTrackerSmall _lastAnnounceRedirectKickTimer
 

Friends

class MapReference
 
class GridObjectLoader
 

Detailed Description

Member Typedef Documentation

◆ CreatureBySpawnIdContainer

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

◆ GameObjectBySpawnIdContainer

◆ PendingAddUpdatableObjectList

typedef std::unordered_set<WorldObject*> Map::PendingAddUpdatableObjectList

◆ PlayerList

◆ ScriptScheduleMap

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

◆ UpdatableObjectList

typedef std::vector<WorldObject*> Map::UpdatableObjectList

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 
274 {
275 CAN_ENTER = 0,
276 CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
277 CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
278 CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
279 CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
280 CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
281 CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
282 CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
283 CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
284 CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
285 CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
287 };
@ CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE
Definition Map.h:281
@ CANNOT_ENTER_TOO_MANY_INSTANCES
Definition Map.h:283
@ CANNOT_ENTER_MAX_PLAYERS
Definition Map.h:284
@ CANNOT_ENTER_ZONE_IN_COMBAT
Definition Map.h:285
@ CAN_ENTER
Definition Map.h:275
@ CANNOT_ENTER_ALREADY_IN_MAP
Definition Map.h:276
@ CANNOT_ENTER_UNSPECIFIED_REASON
Definition Map.h:286
@ CANNOT_ENTER_NO_ENTRY
Definition Map.h:277
@ CANNOT_ENTER_DIFFICULTY_UNAVAILABLE
Definition Map.h:279
@ CANNOT_ENTER_INSTANCE_BIND_MISMATCH
Definition Map.h:282
@ CANNOT_ENTER_UNINSTANCED_DUNGEON
Definition Map.h:278
@ CANNOT_ENTER_NOT_IN_RAID
Definition Map.h:280

Constructor & Destructor Documentation

◆ Map()

Map::Map ( uint32  id,
uint32  InstanceId,
uint8  SpawnMode,
Map _parent = nullptr 
)
68 :
69 _mapGridManager(this), i_mapEntry(sMapStore.LookupEntry(id)), _mapCollisionData(*this, _parent),
70 i_spawnMode(SpawnMode), i_InstanceId(InstanceId), m_unloadTimer(0),
73{
74 m_parentMap = (_parent ? _parent : this);
75
76 _zonePlayerCountMap.clear();
78
79 //lets initialize visibility distance for map
81
84
85 _poolData = sPoolMgr->InitPoolsForMap(this);
86}
constexpr auto IN_MILLISECONDS
Definition Common.h:53
constexpr auto MINUTE
Definition Common.h:47
uint32 GetDefaultMapLight(uint32 mapId)
Definition DBCStores.cpp:880
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define UPDATABLE_OBJECT_LIST_RECHECK_TIMER
Definition Map.h:96
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
#define sPoolMgr
Definition PoolMgr.h:216
MapEntry const * i_mapEntry
Definition Map.h:607
uint8 i_spawnMode
Definition Map.h:609
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition Map.h:677
TransportsContainer::iterator _transportsUpdateIter
Definition Map.h:619
uint32 m_unloadTimer
Definition Map.h:611
uint32 _defaultLight
Definition Map.h:681
IntervalTimer _weatherUpdateTimer
Definition Map.h:680
Map * m_parentMap
Definition Map.h:633
IntervalTimer _updatableObjectListRecheckTimer
Definition Map.h:707
MapCollisionData _mapCollisionData
Definition Map.h:608
bool i_scriptLock
Definition Map.h:637
IntervalTimer _corpseUpdateTimer
Definition Map.h:683
time_t _instanceResetPeriod
Definition Map.h:613
float m_VisibleDistance
Definition Map.h:612
MapGridManager _mapGridManager
Definition Map.h:606
virtual void InitVisibilityDistance()
Definition Map.cpp:98
TransportsContainer _transports
Definition Map.h:618
uint32 i_InstanceId
Definition Map.h:610
std::unique_ptr< SpawnedPoolData > _poolData
Definition Map.h:672
void SetInterval(time_t interval)
Definition Timer.h:179

References _corpseUpdateTimer, _poolData, _updatableObjectListRecheckTimer, _weatherUpdateTimer, _zonePlayerCountMap, IN_MILLISECONDS, InitVisibilityDistance(), m_parentMap, MINUTE, IntervalTimer::SetInterval(), sPoolMgr, and UPDATABLE_OBJECT_LIST_RECHECK_TIMER.

◆ ~Map()

Map::~Map ( )
override
55{
56 // UnloadAll must be called before deleting the map
57
58 // Kill all scheduled events without executing them, since the map and its objects are being destroyed.
59 // This prevents events from running on invalid or deleted objects during map destruction.
60 Events.KillAllEvents(false);
61
62 sScriptMgr->OnDestroyMap(this);
63
64 if (!m_scriptSchedule.empty())
65 sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
66}
#define sScriptMgr
Definition ScriptMgr.h:743
Events
Definition alterac_valley.cpp:53
ScriptScheduleMap m_scriptSchedule
Definition Map.h:641

References m_scriptSchedule, and sScriptMgr.

Member Function Documentation

◆ _AddObjectToUpdateList()

void Map::_AddObjectToUpdateList ( WorldObject obj)
private
598{
599 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
600 ASSERT(mapUpdatableObject && mapUpdatableObject->GetUpdateState() == UpdatableMapObject::UpdateState::PendingAdd);
601
603 mapUpdatableObject->SetMapUpdateListOffset(_updatableObjectList.size());
604 _updatableObjectList.push_back(obj);
605}
#define ASSERT
Definition Errors.h:68
UpdatableObjectList _updatableObjectList
Definition Map.h:705
Definition Object.h:433
void SetUpdateState(UpdateState state)
Definition Object.h:460
UpdateState GetUpdateState() const
Definition Object.h:465
@ PendingAdd
Definition Object.h:440
@ Updating
Definition Object.h:441
void SetMapUpdateListOffset(std::size_t const offset)
Definition Object.h:448

References _updatableObjectList, ASSERT, UpdatableMapObject::GetUpdateState(), UpdatableMapObject::PendingAdd, UpdatableMapObject::SetMapUpdateListOffset(), UpdatableMapObject::SetUpdateState(), and UpdatableMapObject::Updating.

Referenced by UpdateNonPlayerObjects().

◆ _FindGameObject()

GameObject * Map::_FindGameObject ( WorldObject pWorldObject,
ObjectGuid::LowType  guid 
) const
inlineprivate
268{
269 auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
270 if (bounds.first == bounds.second)
271 return nullptr;
272
273 return bounds.first->second;
274}

References GetGameObjectBySpawnIdStore(), and WorldObject::GetMap().

Referenced by _ScriptProcessDoor(), and ScriptsProcess().

◆ _GetScriptCreature()

Creature * Map::_GetScriptCreature ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
187{
188 Creature* creature = nullptr;
189 if (!obj)
190 LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
191 else
192 {
193 creature = obj->ToCreature();
194 if (!creature)
195 LOG_ERROR("maps.script", "{} {} object is not a creature ({}).", scriptInfo->GetDebugInfo(),
196 isSource ? "source" : "target", obj->GetGUID().ToString());
197 }
198 return creature;
199}
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
Definition Creature.h:47
Creature * ToCreature()
Definition Object.h:206
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250

References ScriptInfo::GetDebugInfo(), Object::GetGUID(), LOG_ERROR, Object::ToCreature(), and ObjectGuid::ToString().

Referenced by ScriptsProcess().

◆ _GetScriptCreatureSourceOrTarget()

Creature * Map::_GetScriptCreatureSourceOrTarget ( Object source,
Object target,
ScriptInfo const *  scriptInfo,
bool  bReverse = false 
) const
inlineprivate
121{
122 Creature* creature = nullptr;
123 if (!source && !target)
124 LOG_ERROR("maps.script", "{} source and target objects are nullptr.", scriptInfo->GetDebugInfo());
125 else
126 {
127 if (bReverse)
128 {
129 // Check target first, then source.
130 if (target)
131 creature = target->ToCreature();
132 if (!creature && source)
133 creature = source->ToCreature();
134 }
135 else
136 {
137 // Check source first, then target.
138 if (source)
139 creature = source->ToCreature();
140 if (!creature && target)
141 creature = target->ToCreature();
142 }
143
144 if (!creature)
145 LOG_ERROR("maps.script", "{} neither source nor target are creatures (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.",
146 scriptInfo->GetDebugInfo(),
147 source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString() : "",
148 target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString() : "");
149 }
150 return creature;
151}
MapEntry const * GetEntry() const
Definition Map.h:175
TypeID GetTypeId() const
Definition Object.h:129

References ScriptInfo::GetDebugInfo(), Object::GetEntry(), Object::GetGUID(), Object::GetTypeId(), LOG_ERROR, Object::ToCreature(), and ObjectGuid::ToString().

Referenced by ScriptsProcess().

◆ _GetScriptPlayer()

Player * Map::_GetScriptPlayer ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
172{
173 Player* player = nullptr;
174 if (!obj)
175 LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
176 else
177 {
178 player = obj->ToPlayer();
179 if (!player)
180 LOG_ERROR("maps.script", "{} {} object is not a player ({}).",
181 scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetGUID().ToString());
182 }
183 return player;
184}
Player * ToPlayer()
Definition Object.h:202
Definition Player.h:1086

References ScriptInfo::GetDebugInfo(), Object::GetGUID(), LOG_ERROR, Object::ToPlayer(), and ObjectGuid::ToString().

Referenced by ScriptsProcess().

◆ _GetScriptPlayerSourceOrTarget()

Player * Map::_GetScriptPlayerSourceOrTarget ( Object source,
Object target,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
99{
100 Player* player = nullptr;
101 if (!source && !target)
102 LOG_ERROR("maps.script", "{} source and target objects are nullptr.", scriptInfo->GetDebugInfo());
103 else
104 {
105 // Check target first, then source.
106 if (target)
107 player = target->ToPlayer();
108 if (!player && source)
109 player = source->ToPlayer();
110
111 if (!player)
112 LOG_ERROR("maps.script", "{} neither source nor target object is player (source: TypeId: {}, Entry: {}, GUID: {}; target: TypeId: {}, Entry: {}, GUID: {}), skipping.",
113 scriptInfo->GetDebugInfo(),
114 source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, source ? source->GetGUID().ToString() : "",
115 target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, target ? target->GetGUID().ToString() : "");
116 }
117 return player;
118}

References ScriptInfo::GetDebugInfo(), Object::GetEntry(), Object::GetGUID(), Object::GetTypeId(), LOG_ERROR, Object::ToPlayer(), and ObjectGuid::ToString().

Referenced by ScriptsProcess().

◆ _GetScriptUnit()

Unit * Map::_GetScriptUnit ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
154{
155 Unit* unit = nullptr;
156 if (!obj)
157 LOG_ERROR("maps.script", "{} {} object is nullptr.", scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
158 else if (!obj->IsUnit())
159 LOG_ERROR("maps.script", "{} {} object is not unit (TypeId: {}, Entry: {}, GUID: {}), skipping.",
160 scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString());
161 else
162 {
163 unit = obj->ToUnit();
164 if (!unit)
165 LOG_ERROR("maps.script", "{} {} object could not be casted to unit.",
166 scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
167 }
168 return unit;
169}
bool IsUnit() const
Definition Object.h:209
Unit * ToUnit()
Definition Object.h:210
Definition Unit.h:665

References ScriptInfo::GetDebugInfo(), Object::GetEntry(), Object::GetGUID(), Object::GetTypeId(), Object::IsUnit(), LOG_ERROR, ObjectGuid::ToString(), and Object::ToUnit().

Referenced by ScriptsProcess().

◆ _GetScriptWorldObject()

WorldObject * Map::_GetScriptWorldObject ( Object obj,
bool  isSource,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
202{
203 WorldObject* pWorldObject = nullptr;
204 if (!obj)
205 LOG_ERROR("maps.script", "{} {} object is nullptr.",
206 scriptInfo->GetDebugInfo(), isSource ? "source" : "target");
207 else
208 {
209 pWorldObject = dynamic_cast<WorldObject*>(obj);
210 if (!pWorldObject)
211 LOG_ERROR("maps.script", "{} {} object is not a world object ({}).",
212 scriptInfo->GetDebugInfo(), isSource ? "source" : "target", obj->GetGUID().ToString());
213 }
214 return pWorldObject;
215}
Definition Object.h:476

References ScriptInfo::GetDebugInfo(), Object::GetGUID(), LOG_ERROR, and ObjectGuid::ToString().

Referenced by ScriptsProcess().

◆ _RemoveObjectFromUpdateList()

void Map::_RemoveObjectFromUpdateList ( WorldObject obj)
private
609{
610 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
611 ASSERT(mapUpdatableObject && mapUpdatableObject->GetUpdateState() == UpdatableMapObject::UpdateState::Updating);
612
613 if (obj != _updatableObjectList.back())
614 {
615 dynamic_cast<UpdatableMapObject*>(_updatableObjectList.back())->SetMapUpdateListOffset(mapUpdatableObject->GetMapUpdateListOffset());
616 std::swap(_updatableObjectList[mapUpdatableObject->GetMapUpdateListOffset()], _updatableObjectList.back());
617 }
618
619 _updatableObjectList.pop_back();
621}
size_t GetMapUpdateListOffset() const
Definition Object.h:454
@ NotUpdating
Definition Object.h:439

References _updatableObjectList, ASSERT, UpdatableMapObject::GetMapUpdateListOffset(), UpdatableMapObject::GetUpdateState(), UpdatableMapObject::NotUpdating, UpdatableMapObject::SetUpdateState(), and UpdatableMapObject::Updating.

Referenced by RemoveObjectFromMapUpdateList(), and UpdateNonPlayerObjects().

◆ _ScriptProcessDoor()

void Map::_ScriptProcessDoor ( Object source,
Object target,
ScriptInfo const *  scriptInfo 
) const
inlineprivate
218{
219 bool bOpen = false;
220 ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid;
221 int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay));
222 switch (scriptInfo->command)
223 {
225 bOpen = true;
226 break;
228 break;
229 default:
230 LOG_ERROR("maps.script", "{} unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo());
231 return;
232 }
233 if (!guid)
234 LOG_ERROR("maps.script", "{} door guid is not specified.", scriptInfo->GetDebugInfo());
235 else if (!source)
236 LOG_ERROR("maps.script", "{} source object is nullptr.", scriptInfo->GetDebugInfo());
237 else if (!source->IsUnit())
238 LOG_ERROR("maps.script", "{} source object is not unit ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString());
239 else
240 {
241 WorldObject* wSource = dynamic_cast <WorldObject*> (source);
242 if (!wSource)
243 LOG_ERROR("maps.script", "{} source object could not be casted to world object ({}), skipping.", scriptInfo->GetDebugInfo(), source->GetGUID().ToString());
244 else
245 {
246 GameObject* pDoor = _FindGameObject(wSource, guid);
247 if (!pDoor)
248 LOG_ERROR("maps.script", "{} gameobject was not found (guid: {}).", scriptInfo->GetDebugInfo(), guid);
249 else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
250 LOG_ERROR("maps.script", "{} gameobject is not a door ({}).",
251 scriptInfo->GetDebugInfo(), pDoor->GetGUID().ToString());
252 else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
253 {
254 pDoor->UseDoorOrButton(nTimeToToggle);
255
256 if (target && target->isType(TYPEMASK_GAMEOBJECT))
257 {
258 GameObject* goTarget = target->ToGameObject();
259 if (goTarget && goTarget->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
260 goTarget->UseDoorOrButton(nTimeToToggle);
261 }
262 }
263 }
264 }
265}
std::int32_t int32
Definition Define.h:103
@ GO_STATE_READY
Definition GameObjectData.h:709
@ TYPEMASK_GAMEOBJECT
Definition ObjectGuid.h:54
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition ObjectMgr.h:107
@ SCRIPT_COMMAND_OPEN_DOOR
Definition ObjectMgr.h:106
@ GAMEOBJECT_TYPE_BUTTON
Definition SharedDefines.h:1565
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1564
Definition GameObject.h:120
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition GameObject.cpp:1413
GOState GetGoState() const
Definition GameObject.h:205
GameobjectTypes GetGoType() const
Definition GameObject.h:203
GameObject * _FindGameObject(WorldObject *pWorldObject, ObjectGuid::LowType guid) const
Definition MapScripts.cpp:267
std::string ToString() const
Definition ObjectGuid.cpp:48
uint32 LowType
Definition ObjectGuid.h:125
bool isType(uint16 mask) const
Definition Object.h:130
GameObject * ToGameObject()
Definition Object.h:214
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:114

References _FindGameObject(), ScriptInfo::command, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_DOOR, ScriptInfo::GetDebugInfo(), GameObject::GetGoState(), GameObject::GetGoType(), Object::GetGUID(), GO_STATE_READY, ScriptInfo::GOGuid, Object::isType(), Object::IsUnit(), LOG_ERROR, ScriptInfo::ResetDelay, SCRIPT_COMMAND_CLOSE_DOOR, SCRIPT_COMMAND_OPEN_DOOR, Object::ToGameObject(), ScriptInfo::ToggleDoor, ObjectGuid::ToString(), TYPEMASK_GAMEOBJECT, and GameObject::UseDoorOrButton().

Referenced by ScriptsProcess().

◆ AddCorpse()

void Map::AddCorpse ( Corpse corpse)
3045{
3046 corpse->SetMap(this);
3047
3048 GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
3049 _corpsesByGrid[gridCoord.GetId()].insert(corpse);
3050 if (corpse->GetType() != CORPSE_BONES)
3051 _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
3052 else
3053 _corpseBones.insert(corpse);
3054}
@ CORPSE_BONES
Definition Corpse.h:28
ObjectGuid GetOwnerGUID() const
Definition Corpse.h:68
CorpseType GetType() const
Definition Corpse.h:72
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition Map.h:700
std::unordered_set< Corpse * > _corpseBones
Definition Map.h:701
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByGrid
Definition Map.h:699
virtual void SetMap(Map *map)
Definition Object.cpp:2191
GridCoord ComputeGridCoord(float x, float y)
Definition GridDefines.h:185
Definition GridDefines.h:88
uint32 GetId() const
Definition GridDefines.h:150
float GetPositionX() const
Definition Position.h:121
float GetPositionY() const
Definition Position.h:122

References _corpseBones, _corpsesByGrid, _corpsesByPlayer, Acore::ComputeGridCoord(), CORPSE_BONES, CoordPair< LIMIT >::GetId(), Corpse::GetOwnerGUID(), Position::GetPositionX(), Position::GetPositionY(), Corpse::GetType(), and WorldObject::SetMap().

Referenced by ConvertCorpseToBones(), Player::CreateCorpse(), and LoadCorpseData().

◆ AddCreatureToMoveList()

void Map::AddCreatureToMoveList ( Creature c)
private
890{
892 _creaturesToMove.push_back(c);
894}
@ MAP_OBJECT_CELL_MOVE_ACTIVE
Definition Object.h:410
@ MAP_OBJECT_CELL_MOVE_NONE
Definition Object.h:409
std::vector< Creature * > _creaturesToMove
Definition Map.h:586
MapObjectCellMoveState _moveState
Definition Object.h:429

References _creaturesToMove, MovableMapObject::_moveState, MAP_OBJECT_CELL_MOVE_ACTIVE, and MAP_OBJECT_CELL_MOVE_NONE.

Referenced by CreatureRelocation().

◆ AddDynamicObjectToMoveList()

void Map::AddDynamicObjectToMoveList ( DynamicObject go)
private
916{
917 if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
918 _dynamicObjectsToMove.push_back(dynObj);
919 dynObj->_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE;
920}
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition Map.h:588

References _dynamicObjectsToMove, MovableMapObject::_moveState, MAP_OBJECT_CELL_MOVE_ACTIVE, and MAP_OBJECT_CELL_MOVE_NONE.

Referenced by DynamicObjectRelocation().

◆ AddGameObjectToMoveList()

void Map::AddGameObjectToMoveList ( GameObject go)
private
903{
905 _gameObjectsToMove.push_back(go);
907}
std::vector< GameObject * > _gameObjectsToMove
Definition Map.h:587

References _gameObjectsToMove, MovableMapObject::_moveState, MAP_OBJECT_CELL_MOVE_ACTIVE, and MAP_OBJECT_CELL_MOVE_NONE.

Referenced by GameObjectRelocation().

◆ AddObjectToPendingUpdateList()

void Map::AddObjectToPendingUpdateList ( WorldObject obj)
584{
585 if (!obj->CanBeAddedToMapUpdateList())
586 return;
587
588 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
589 if (!mapUpdatableObject || mapUpdatableObject->GetUpdateState() != UpdatableMapObject::UpdateState::NotUpdating)
590 return;
591
594}
PendingAddUpdatableObjectList _pendingAddUpdatableObjectList
Definition Map.h:706
bool CanBeAddedToMapUpdateList()
Definition Object.cpp:3250

References _pendingAddUpdatableObjectList, WorldObject::CanBeAddedToMapUpdateList(), UpdatableMapObject::GetUpdateState(), UpdatableMapObject::NotUpdating, UpdatableMapObject::PendingAdd, and UpdatableMapObject::SetUpdateState().

Referenced by WorldObject::AddToWorld(), WorldObject::setActive(), and Player::UpdateVisibilityOf().

◆ AddObjectToRemoveList()

void Map::AddObjectToRemoveList ( WorldObject obj)
1796{
1797 ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
1798
1799 obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
1800
1801 i_objectsToRemove.insert(obj);
1802 //LOG_DEBUG("maps", "Object ({}) added to removing list.", obj->GetGUID().ToString());
1803}
std::unordered_set< WorldObject * > i_objectsToRemove
Definition Map.h:638
uint32 GetId() const
Definition Map.h:234
uint32 GetInstanceId() const
Definition Map.h:270
uint32 GetMapId() const
Definition Position.h:281
uint32 GetInstanceId() const
Definition Object.h:514
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition Object.cpp:1160

References ASSERT, WorldObject::CleanupsBeforeDelete(), GetId(), WorldObject::GetInstanceId(), GetInstanceId(), WorldLocation::GetMapId(), and i_objectsToRemove.

Referenced by WorldObject::AddObjectToRemoveList(), and wp_commandscript::HandleWpModifyCommand().

◆ AddPlayerToMap()

bool Map::AddPlayerToMap ( Player player)
virtual

Reimplemented in InstanceMap, and BattlegroundMap.

259{
260 CellCoord cellCoord = Acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
261 if (!cellCoord.IsCoordValid())
262 {
263 LOG_ERROR("maps", "Map::Add: Player ({}) has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
264 player->GetGUID().ToString(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
265 return false;
266 }
267
268 Cell cell(cellCoord);
270 AddToGrid(player, cell);
271
272 // Check if we are adding to correct map
273 ASSERT (player->GetMap() == this);
274 player->SetMap(this);
275 player->AddToWorld();
276
277 SendInitTransports(player);
278 SendInitSelf(player);
279
280 player->UpdateObjectVisibility(false);
281
282 if (player->IsAlive())
283 ConvertCorpseToBones(player->GetGUID());
284
285 sScriptMgr->OnPlayerEnterMap(this, player);
286 return true;
287}
#define MAX_VISIBILITY_DISTANCE
Definition ObjectDefines.h:30
void LoadGridsInRange(Position const &center, float radius)
Definition Map.cpp:228
Corpse * ConvertCorpseToBones(ObjectGuid const &ownerGuid, bool insignia=false)
Definition Map.cpp:3077
void SendInitSelf(Player *player)
Definition Map.cpp:1624
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:116
void SendInitTransports(Player *player)
Definition Map.cpp:1670
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition PlayerUpdates.cpp:1625
void AddToWorld() override
Definition Player.cpp:1744
void SetMap(Map *map) override
Definition Player.cpp:15082
bool IsAlive() const
Definition Unit.h:1793
Map * GetMap() const
Definition Object.h:631
CellCoord ComputeCellCoord(float x, float y)
Definition GridDefines.h:197
Definition Cell.h:45
bool IsCoordValid() const
Definition GridDefines.h:138
uint32 x_coord
Definition GridDefines.h:155
uint32 y_coord
Definition GridDefines.h:156

References AddToGrid(), Player::AddToWorld(), ASSERT, Acore::ComputeCellCoord(), ConvertCorpseToBones(), Object::GetGUID(), WorldObject::GetMap(), Position::GetPositionX(), Position::GetPositionY(), Unit::IsAlive(), CoordPair< LIMIT >::IsCoordValid(), LoadGridsInRange(), LOG_ERROR, MAX_VISIBILITY_DISTANCE, SendInitSelf(), SendInitTransports(), Player::SetMap(), sScriptMgr, ObjectGuid::ToString(), Player::UpdateObjectVisibility(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by InstanceMap::AddPlayerToMap(), BattlegroundMap::AddPlayerToMap(), and WorldSession::HandlePlayerLoginFromDB().

◆ AddToGrid() [1/5]

template<>
void Map::AddToGrid ( Corpse obj,
Cell const &  cell 
)
155{
156 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
157 // Corpses are a special object type - they can be added to grid via a call to AddToMap
158 // or loaded through ObjectGridLoader.
159 // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
160 // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
161 // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
162 // to avoid failing an assertion in GridObject::AddToGrid
163 if (grid->IsObjectDataLoaded())
164 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
165}
Definition MapGrid.h:33
void AddGridObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:49
bool IsObjectDataLoaded() const
Definition MapGrid.h:46
MapGridType * GetMapGrid(uint16 const x, uint16 const y)
Definition Map.cpp:201

References MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::AddGridObject(), Cell::CellX(), Cell::CellY(), GetMapGrid(), Cell::GridX(), Cell::GridY(), and MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::IsObjectDataLoaded().

◆ AddToGrid() [2/5]

template<>
void Map::AddToGrid ( Creature obj,
Cell const &  cell 
)
126{
127 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
128 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
129 if (obj->IsFarVisible())
130 grid->AddFarVisibleObject(cell.CellX(), cell.CellY(), obj);
131
132 obj->SetCurrentCell(cell);
133}
void AddFarVisibleObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:59
void SetCurrentCell(Cell const &cell)
Definition Object.h:426
bool IsFarVisible() const
Definition Object.h:682

References MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::AddFarVisibleObject(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::AddGridObject(), Cell::CellX(), Cell::CellY(), GetMapGrid(), Cell::GridX(), Cell::GridY(), WorldObject::IsFarVisible(), and MovableMapObject::SetCurrentCell().

◆ AddToGrid() [3/5]

template<>
void Map::AddToGrid ( GameObject obj,
Cell const &  cell 
)

◆ AddToGrid() [4/5]

template<>
void Map::AddToGrid ( Player obj,
Cell const &  cell 
)
148{
149 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
150 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
151}

References MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::AddGridObject(), Cell::CellX(), Cell::CellY(), GetMapGrid(), Cell::GridX(), and Cell::GridY().

◆ AddToGrid() [5/5]

template<class T >
void Map::AddToGrid ( T *  object,
Cell const &  cell 
)
protected

◆ AddToMap() [1/2]

template<class T >
bool Map::AddToMap ( T *  obj,
bool  checkTransport = false 
)
308{
309 //TODO: Needs clean up. An object should not be added to map twice.
310 if (obj->IsInWorld())
311 {
312 ASSERT(obj->IsInGrid());
313 obj->UpdateObjectVisibility(true);
314 return true;
315 }
316
317 CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
318 //It will create many problems (including crashes) if an object is not added to grid after creation
319 //The correct way to fix it is to make AddToMap return false and delete the object if it is not added to grid
320 //But now AddToMap is used in too many places, I will just see how many ASSERT failures it will cause
321 ASSERT(cellCoord.IsCoordValid());
322 if (!cellCoord.IsCoordValid())
323 {
324 LOG_ERROR("maps", "Map::AddToMap: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
325 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
326 return false; //Should delete object
327 }
328
329 Cell cell(cellCoord);
330 if (obj->isActiveObject())
331 EnsureGridLoaded(cell);
332 else
333 EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
334
335 AddToGrid(obj, cell);
336
337 //Must already be set before AddToMap. Usually during obj->Create.
338 //obj->SetMap(this);
339 obj->AddToWorld();
340
341 if (checkTransport)
342 if (!(obj->IsGameObject() && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d
343 if (Transport* transport = GetTransportForPos(obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj))
344 transport->AddPassenger(obj, true);
345
346 InitializeObject(obj);
347
348 //something, such as vehicle, needs to be update immediately
349 //also, trigger needs to cast spell, if not update, cannot see visual
350 obj->UpdateObjectVisibilityOnCreate();
351
352 // Post-visibility so accessories seat after the vehicle's create packet reaches clients.
353 if (obj->IsCreature())
354 if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit())
355 vehicle->Reset();
356 return true;
357}
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition GridDefines.h:171
void InitializeObject(T *obj)
Definition Map.cpp:290
Transport * GetTransportForPos(uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
Definition Map.cpp:1139
void EnsureGridCreated(GridCoord const &gridCoord)
Definition Map.cpp:183
bool EnsureGridLoaded(Cell const &cell)
Definition Map.cpp:188
Definition Transport.h:30
Definition Vehicle.h:28

References AddToGrid(), ASSERT, Acore::ComputeCellCoord(), EnsureGridCreated(), EnsureGridLoaded(), GetTransportForPos(), Cell::GridX(), Cell::GridY(), InitializeObject(), CoordPair< LIMIT >::IsCoordValid(), LOG_ERROR, CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by Battleground::AddCreature(), Battleground::AddObject(), Player::BuildPlayerRepop(), ConvertCorpseToBones(), GameObject::Create(), MotionTransport::CreateGOPassenger(), MotionTransport::CreateNPCPassenger(), Player::CreatePet(), Player::CreatePet(), TransportMgr::CreateTransport(), MotionTransport::DelayedTeleportTransport(), Spell::EffectCreateTamedPet(), Spell::EffectDuel(), Spell::EffectSummonObject(), Spell::EffectSummonObjectWild(), Spell::EffectTameCreature(), Spell::EffectTransmitted(), GameEventMgr::GameEventSpawn(), debug_commandscript::HandleDebugSpawnVehicleCommand(), OutdoorPvPSI::HandleDropFlag(), Pet::LoadPetFromDB(), GameObject::Refresh(), ScriptsProcess(), Battlefield::SpawnCreature(), Battlefield::SpawnGameObject(), SummonCreature(), SummonGameObject(), WorldObject::SummonGameObject(), Player::SummonPet(), and GameObject::Update().

◆ AddToMap() [2/2]

template<>
bool Map::AddToMap ( Transport obj,
bool   
)
361{
362 //TODO: Needs clean up. An object should not be added to map twice.
363 if (obj->IsInWorld())
364 return true;
365
367 if (!cellCoord.IsCoordValid())
368 {
369 LOG_ERROR("maps", "Map::Add: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
370 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
371 return false; //Should delete object
372 }
373
374 Cell cell(cellCoord);
375 EnsureGridLoaded(cell);
376
377 obj->AddToWorld();
378
379 _transports.insert(obj);
380
381 // Broadcast creation to players
382 // Skip players that are not in world. Sending the create to their loading client
383 // could materialize a lingering transport on whatever map they are teleporting to.
384 // They get the correct transport list from SendInitTransports when added to their new map
385 for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
386 {
387 if (itr->GetSource()->IsInWorld() && itr->GetSource()->GetTransport() != obj)
388 {
389 UpdateData data;
390 obj->BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
391 WorldPacket packet;
392 data.BuildPacket(packet);
393 itr->GetSource()->SendDirectMessage(&packet);
394 }
395 }
396
397 return true;
398}
void AddToWorld() override
Definition GameObject.cpp:156
iterator begin()
Definition GridRefMgr.h:35
Definition LinkedList.h:139
iterator end()
Definition MapRefMgr.h:37
PlayerList const & GetPlayers() const
Definition Map.h:335
bool IsInWorld() const
Definition Object.h:109
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition Object.cpp:182
Definition UpdateData.h:52
bool BuildPacket(WorldPacket &packet)
Definition UpdateData.cpp:48
Definition WorldPacket.h:26

References _transports, GameObject::AddToWorld(), GridRefMgr< MapGridType >::begin(), Object::BuildCreateUpdateBlockForPlayer(), UpdateData::BuildPacket(), Acore::ComputeCellCoord(), MapRefMgr::end(), EnsureGridLoaded(), Object::GetGUID(), GetPlayers(), Position::GetPositionX(), Position::GetPositionY(), CoordPair< LIMIT >::IsCoordValid(), Object::IsInWorld(), LOG_ERROR, ObjectGuid::ToString(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

◆ AddUpdateObject()

void Map::AddUpdateObject ( Object obj)
inline
535 {
536 _updateObjects.insert(obj);
537 }
std::unordered_set< Object * > _updateObjects
Definition Map.h:703

References _updateObjects.

Referenced by WorldObject::AddToObjectUpdate().

◆ AddWorldObjectToFarVisibleMap()

void Map::AddWorldObjectToFarVisibleMap ( WorldObject obj)
637{
638 if (Creature* creature = obj->ToCreature())
639 {
640 if (!creature->IsInGrid())
641 return;
642
643 Cell curr_cell = creature->GetCurrentCell();
644 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
645 grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
646 }
647 else if (GameObject* go = obj->ToGameObject())
648 {
649 if (!go->IsInGrid())
650 return;
651
652 Cell curr_cell = go->GetCurrentCell();
653 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
654 grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
655 }
656}
uint32 GridX() const
Definition Cell.h:71
uint32 GridY() const
Definition Cell.h:72
uint32 CellX() const
Definition Cell.h:69
uint32 CellY() const
Definition Cell.h:70

References MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::AddFarVisibleObject(), Cell::CellX(), Cell::CellY(), GetMapGrid(), Cell::GridX(), Cell::GridY(), Object::ToCreature(), and Object::ToGameObject().

Referenced by WorldObject::AddToMapVisibilityOverrideContainers().

◆ AddWorldObjectToZoneWideVisibleMap()

void Map::AddWorldObjectToZoneWideVisibleMap ( uint32  zoneId,
WorldObject obj 
)
676{
677 _zoneWideVisibleWorldObjectsMap[zoneId].insert(obj);
678}
ZoneWideVisibleWorldObjectsMap _zoneWideVisibleWorldObjectsMap
Definition Map.h:708

References _zoneWideVisibleWorldObjectsMap.

Referenced by WorldObject::AddToMapVisibilityOverrideContainers(), WorldObject::AddToWorld(), and WorldObject::ProcessPositionDataChanged().

◆ AfterPlayerUnlinkFromMap()

void Map::AfterPlayerUnlinkFromMap ( )
virtual

◆ AllTransportsEmpty()

bool Map::AllTransportsEmpty ( ) const
3013{
3014 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
3015 if (!(*itr)->GetPassengers().empty())
3016 return false;
3017
3018 return true;
3019}

References _transports.

Referenced by MapInstanced::CreateInstanceForPlayer(), and UnloadAll().

◆ AllTransportsRemovePassengers()

void Map::AllTransportsRemovePassengers ( )
3022{
3023 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
3024 while (!(*itr)->GetPassengers().empty())
3025 (*itr)->RemovePassenger(*((*itr)->GetPassengers().begin()), true);
3026}

References _transports.

Referenced by MapInstanced::CreateInstanceForPlayer(), and UnloadAll().

◆ ApplyDynamicModeRespawnScaling()

uint32 Map::ApplyDynamicModeRespawnScaling ( WorldObject const *  obj,
uint32  respawnDelay 
) const
1731{
1732 ASSERT(obj->GetMap() == this);
1733
1734 float rate = sWorld->getFloatConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICRATE_CREATURE);
1735
1736 if (rate == 1.0f)
1737 return respawnDelay;
1738
1739 // No instanced maps (dungeons, battlegrounds, arenas etc.)
1740 if (obj->GetMap()->Instanceable())
1741 return respawnDelay;
1742
1743 if (Creature const* creature = obj->ToCreature())
1744 {
1745 // Temporary spawns (no DB spawn id, e.g. summons / battlefield-spawned
1746 // creatures such as Wintergrasp turrets) are not part of the respawn system.
1747 if (!creature->GetSpawnId())
1748 return respawnDelay;
1749
1750 // No quest givers or world bosses
1751 if (creature->IsQuestGiver() || creature->isWorldBoss()
1752 || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RARE)
1753 || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RAREELITE))
1754 return respawnDelay;
1755 }
1756 // Temporary gameobjects (no DB spawn id) are likewise excluded.
1757 else if (GameObject const* go = obj->ToGameObject())
1758 {
1759 if (!go->GetSpawnId())
1760 return respawnDelay;
1761 }
1762
1763 auto it = _zonePlayerCountMap.find(obj->GetZoneId());
1764 if (it == _zonePlayerCountMap.end())
1765 return respawnDelay;
1766 uint32 const playerCount = it->second;
1767 if (!playerCount)
1768 return respawnDelay;
1769 double const adjustFactor = rate / playerCount;
1770 if (adjustFactor >= 1.0) // nothing to do here
1771 return respawnDelay;
1772 uint32 const timeMinimum = sWorld->getIntConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE);
1773 if (respawnDelay <= timeMinimum)
1774 return respawnDelay;
1775
1776 return std::max<uint32>(std::ceil(respawnDelay * adjustFactor), timeMinimum);
1777}
std::uint32_t uint32
Definition Define.h:107
@ CREATURE_ELITE_RARE
Definition SharedDefines.h:2968
@ CREATURE_ELITE_RAREELITE
Definition SharedDefines.h:2966
@ CONFIG_RESPAWN_DYNAMICRATE_CREATURE
Definition WorldConfig.h:168
@ CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE
Definition WorldConfig.h:402
@ CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT
Definition WorldConfig.h:167
@ CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT
Definition WorldConfig.h:401
#define sWorld
Definition World.h:318

References _zonePlayerCountMap, ASSERT, CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE, CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT, CONFIG_RESPAWN_DYNAMICRATE_CREATURE, CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT, CREATURE_ELITE_RARE, CREATURE_ELITE_RAREELITE, WorldObject::GetMap(), WorldObject::GetZoneId(), Instanceable(), Object::IsGameObject(), sWorld, Object::ToCreature(), and Object::ToGameObject().

Referenced by Creature::setDeathState(), and GameObject::Update().

◆ Balance()

void Map::Balance ( )
inline
void balance()
Definition DynamicTree.cpp:132
DynamicVMapCollisionData & GetDynamicTree()
Definition MapCollisionData.h:82

References _mapCollisionData, DynamicMapTree::balance(), and MapCollisionData::GetDynamicTree().

Referenced by EnsureGridLoaded().

◆ CannotEnter()

virtual EnterState Map::CannotEnter ( Player ,
bool   
)
inlinevirtual

◆ CanReachPositionAndGetValidCoords() [1/3]

bool Map::CanReachPositionAndGetValidCoords ( WorldObject const *  source,
float &  destX,
float &  destY,
float &  destZ,
bool  failOnCollision = true,
bool  failOnSlopes = true 
) const

validate the new destination and set reachable coords Check if a given unit can reach a specific point on a segment and set the correct dest coords NOTE: use this method with small segments.

Parameters
failOnCollisionif true, the methods will return false when a collision occurs
failOnSlopesif true, the methods will return false when a non walkable slope is found
Returns
true if the destination is valid, false otherwise
3373{
3374 return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
3375}
bool CanReachPositionAndGetValidCoords(WorldObject const *source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
Check if a given source can reach a specific point following a path and normalize the coords....
Definition Map.cpp:3332

References CanReachPositionAndGetValidCoords(), Position::GetPositionX(), Position::GetPositionY(), and Position::GetPositionZ().

◆ CanReachPositionAndGetValidCoords() [2/3]

bool Map::CanReachPositionAndGetValidCoords ( WorldObject const *  source,
float  startX,
float  startY,
float  startZ,
float &  destX,
float &  destY,
float &  destZ,
bool  failOnCollision = true,
bool  failOnSlopes = true 
) const
3378{
3379 if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
3380 {
3381 return false;
3382 }
3383
3384 Unit const* unit = source->ToUnit();
3385 // if it's not an unit (Object) then we do not have to continue
3386 // with walkable checks
3387 if (!unit)
3388 {
3389 return true;
3390 }
3391
3392 /*
3393 * Walkable checks
3394 */
3395 bool isWaterNext = HasEnoughWater(unit, destX, destY, destZ);
3396 Creature const* creature = unit->ToCreature();
3397 bool cannotEnterWater = isWaterNext && (creature && !creature->CanEnterWater());
3398 bool cannotWalkOrFly = !isWaterNext && !source->ToPlayer() && !unit->CanFly() && (creature && !creature->CanWalk());
3399 if (cannotEnterWater || cannotWalkOrFly ||
3400 (failOnSlopes && !PathGenerator::IsWalkableClimb(startX, startY, startZ, destX, destY, destZ, source->GetCollisionHeight())))
3401 {
3402 return false;
3403 }
3404
3405 return true;
3406}
bool CanWalk() const
Definition Creature.h:84
bool CanEnterWater() const override
Definition Creature.cpp:3383
bool HasEnoughWater(WorldObject const *searcher, float x, float y, float z) const
Definition Map.cpp:1605
bool CheckCollisionAndGetValidCoords(WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true) const
validate the new destination and set coords Check if a given unit can face collisions in a specific s...
Definition Map.cpp:3415
bool IsWalkableClimb(float const *v1, float const *v2) const
Definition PathGenerator.cpp:1068
virtual bool CanFly() const =0

References Creature::CanEnterWater(), Unit::CanFly(), Creature::CanWalk(), CheckCollisionAndGetValidCoords(), WorldObject::GetCollisionHeight(), HasEnoughWater(), PathGenerator::IsWalkableClimb(), Object::ToCreature(), Object::ToPlayer(), and Object::ToUnit().

◆ CanReachPositionAndGetValidCoords() [3/3]

bool Map::CanReachPositionAndGetValidCoords ( WorldObject const *  source,
PathGenerator path,
float &  destX,
float &  destY,
float &  destZ,
bool  failOnCollision = true,
bool  failOnSlopes = true 
) const

Check if a given source can reach a specific point following a path and normalize the coords. Use this method for long paths, otherwise use the overloaded method with the start coords when you need to do a quick check on small segments.

3333{
3334 G3D::Vector3 prevPath = path->GetStartPosition();
3335 for (auto& vector : path->GetPath())
3336 {
3337 float x = vector.x;
3338 float y = vector.y;
3339 float z = vector.z;
3340
3341 if (!CanReachPositionAndGetValidCoords(source, prevPath.x, prevPath.y, prevPath.z, x, y, z, failOnCollision, failOnSlopes))
3342 {
3343 destX = x;
3344 destY = y;
3345 destZ = z;
3346 return false;
3347 }
3348
3349 prevPath = vector;
3350 }
3351
3352 destX = prevPath.x;
3353 destY = prevPath.y;
3354 destZ = prevPath.z;
3355
3356 return true;
3357}
G3D::Vector3 const & GetStartPosition() const
Definition PathGenerator.h:86

References CanReachPositionAndGetValidCoords(), PathGenerator::GetPath(), and PathGenerator::GetStartPosition().

Referenced by CanReachPositionAndGetValidCoords(), CanReachPositionAndGetValidCoords(), MotionMaster::MoveBackwards(), and MotionMaster::MoveForwards().

◆ CanUnload()

bool Map::CanUnload ( uint32  diff)
inline
179 {
180 if (!m_unloadTimer || Events.HasEvents())
181 return false;
182
183 if (m_unloadTimer <= diff)
184 return true;
185
186 m_unloadTimer -= diff;
187 return false;
188 }

References m_unloadTimer.

◆ CheckCollisionAndGetValidCoords()

bool Map::CheckCollisionAndGetValidCoords ( WorldObject const *  source,
float  startX,
float  startY,
float  startZ,
float &  destX,
float &  destY,
float &  destZ,
bool  failOnCollision = true 
) const

validate the new destination and set coords Check if a given unit can face collisions in a specific segment

Returns
true if the destination is valid, false otherwise
3416{
3417 // Prevent invalid coordinates here, position is unchanged
3418 if (!Acore::IsValidMapCoord(startX, startY, startZ) || !Acore::IsValidMapCoord(destX, destY, destZ))
3419 {
3420 LOG_FATAL("maps", "Map::CheckCollisionAndGetValidCoords invalid coordinates startX: {}, startY: {}, startZ: {}, destX: {}, destY: {}, destZ: {}", startX, startY, startZ, destX, destY, destZ);
3421 return false;
3422 }
3423
3424 bool isWaterNext = IsInWater(source->GetPhaseMask(), destX, destY, destZ, source->GetCollisionHeight());
3425
3426 PathGenerator path(source);
3427
3428 // Use a detour raycast to get our first collision point
3429 path.SetUseRaycast(true);
3430 bool result = path.CalculatePath(startX, startY, startZ, destX, destY, destZ, false);
3431
3432 Unit const* unit = source->ToUnit();
3433 bool notOnGround = path.GetPathType() & PATHFIND_NOT_USING_PATH
3434 || isWaterNext || (unit && unit->IsFlying());
3435
3436 // Check for valid path types before we proceed
3437 if (!result || (!notOnGround && path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END)))
3438 {
3439 return false;
3440 }
3441
3442 G3D::Vector3 endPos = path.GetPath().back();
3443 destX = endPos.x;
3444 destY = endPos.y;
3445 destZ = endPos.z;
3446
3447 // collision check
3448 bool collided = false;
3449
3450 // check static LOS
3451 float halfHeight = source->GetCollisionHeight() * 0.5f;
3452
3453 // Unit is not on the ground, check for potential collision via vmaps
3454 if (notOnGround)
3455 {
3456 bool col = _mapCollisionData.GetStaticTree().GetObjectHitPos(startX, startY, startZ + halfHeight,
3457 destX, destY, destZ + halfHeight,
3458 destX, destY, destZ, -CONTACT_DISTANCE);
3459
3460 destZ -= halfHeight;
3461
3462 // Collided with static LOS object, move back to collision point
3463 if (col)
3464 {
3465 collided = true;
3466 }
3467 }
3468
3469 // check dynamic collision
3470 bool col = _mapCollisionData.GetDynamicTree().GetObjectHitPos(source->GetPhaseMask(),
3471 startX, startY, startZ + halfHeight,
3472 destX, destY, destZ + halfHeight,
3473 destX, destY, destZ, -CONTACT_DISTANCE);
3474
3475 destZ -= halfHeight;
3476
3477 // Collided with a gameobject, move back to collision point
3478 if (col)
3479 {
3480 collided = true;
3481 }
3482
3483 float groundZ = VMAP_INVALID_HEIGHT_VALUE;
3484 source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
3485
3486 // position has no ground under it (or is too far away)
3487 if (groundZ <= INVALID_HEIGHT && unit && !unit->CanFly())
3488 {
3489 // fall back to gridHeight if any
3490 float gridHeight = GetGridHeight(destX, destY);
3491 if (gridHeight > INVALID_HEIGHT)
3492 {
3493 destZ = gridHeight + unit->GetHoverHeight();
3494 }
3495 else
3496 {
3497 return false;
3498 }
3499 }
3500
3501 return !failOnCollision || !collided;
3502}
#define INVALID_HEIGHT
Definition GridTerrainData.h:27
#define VMAP_INVALID_HEIGHT_VALUE
Definition IVMapMgr.h:51
#define LOG_FATAL(filterType__,...)
Definition Log.h:141
#define CONTACT_DISTANCE
Definition ObjectDefines.h:23
@ PATHFIND_FARFROMPOLY_END
Definition PathGenerator.h:54
@ PATHFIND_NOT_USING_PATH
Definition PathGenerator.h:51
@ PATHFIND_NORMAL
Definition PathGenerator.h:47
@ PATHFIND_SHORTCUT
Definition PathGenerator.h:48
@ PATHFIND_INCOMPLETE
Definition PathGenerator.h:49
bool GetObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist) const
Definition MapCollisionData.cpp:163
StaticVMapCollisionData & GetStaticTree()
Definition MapCollisionData.h:84
bool IsInWater(uint32 phaseMask, float x, float y, float z, float collisionHeight) const
Definition Map.cpp:1593
float GetGridHeight(float x, float y) const
Definition Map.cpp:1200
Definition PathGenerator.h:59
bool GetObjectHitPos(float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist) const
Definition MapCollisionData.cpp:89
float GetCollisionHeight() const override
Return collision height sent to client.
Definition Unit.cpp:17151
float GetHoverHeight() const
Definition Unit.h:1721
bool IsFlying() const
Definition Unit.h:1717
bool IsValidMapCoord(float c)
Definition GridDefines.h:210

References _mapCollisionData, PathGenerator::CalculatePath(), CanFly, CONTACT_DISTANCE, WorldObject::GetCollisionHeight(), MapCollisionData::GetDynamicTree(), GetGridHeight(), Unit::GetHoverHeight(), StaticVMapCollisionData::GetObjectHitPos(), DynamicVMapCollisionData::GetObjectHitPos(), PathGenerator::GetPath(), PathGenerator::GetPathType(), WorldObject::GetPhaseMask(), MapCollisionData::GetStaticTree(), INVALID_HEIGHT, Unit::IsFlying(), IsInWater(), Acore::IsValidMapCoord(), LOG_FATAL, PATHFIND_FARFROMPOLY_END, PATHFIND_INCOMPLETE, PATHFIND_NORMAL, PATHFIND_NOT_USING_PATH, PATHFIND_SHORTCUT, PathGenerator::SetUseRaycast(), Object::ToUnit(), WorldObject::UpdateAllowedPositionZ(), and VMAP_INVALID_HEIGHT_VALUE.

Referenced by CanReachPositionAndGetValidCoords().

◆ ContainsGameObjectModel()

bool Map::ContainsGameObjectModel ( GameObjectModel const &  model) const
inline
406{ return _mapCollisionData.GetDynamicTree().contains(model);}
bool contains(GameObjectModel const &) const
Definition DynamicTree.cpp:127

References _mapCollisionData, DynamicMapTree::contains(), and MapCollisionData::GetDynamicTree().

◆ ConvertCorpseToBones()

Corpse * Map::ConvertCorpseToBones ( ObjectGuid const &  ownerGuid,
bool  insignia = false 
)
3078{
3079 Corpse* corpse = GetCorpseByPlayer(ownerGuid);
3080 if (!corpse)
3081 return nullptr;
3082
3083 RemoveCorpse(corpse);
3084
3085 // remove corpse from DB
3086 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3087 corpse->DeleteFromDB(trans);
3088 CharacterDatabase.CommitTransaction(trans);
3089
3090 Corpse* bones = NULL;
3091
3092 // create the bones only if the map and the grid is loaded at the corpse's location
3093 // ignore bones creating option in case insignia
3094 if ((insignia ||
3096 IsGridLoaded(corpse->GetPositionX(), corpse->GetPositionY()))
3097 {
3098 // Create bones, don't change Corpse
3099 bones = new Corpse();
3100 bones->Create(corpse->GetGUID().GetCounter());
3101
3102 for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
3103 bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
3104
3105 bones->SetCellCoord(corpse->GetCellCoord());
3106 bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
3107 bones->SetPhaseMask(corpse->GetPhaseMask(), false);
3108
3110 bones->SetGuidValue(CORPSE_FIELD_OWNER, corpse->GetOwnerGUID());
3111
3112 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
3113 if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
3114 bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
3115
3116 AddCorpse(bones);
3117
3118 bones->UpdatePositionData();
3119
3120 // add bones in grid store if grid loaded where corpse placed
3121 AddToMap(bones);
3122 }
3123
3124 // all references to the corpse should be removed at this point
3125 delete corpse;
3126
3127 return bones;
3128}
@ CORPSE_FLAG_BONES
Definition Corpse.h:40
@ CORPSE_FLAG_UNK2
Definition Corpse.h:42
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition DatabaseEnvFwd.h:69
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint8_t uint8
Definition Define.h:109
@ EQUIPMENT_SLOT_END
Definition Player.h:681
@ CORPSE_FIELD_FLAGS
Definition UpdateFields.h:427
@ CORPSE_END
Definition UpdateFields.h:430
@ CORPSE_FIELD_ITEM
Definition UpdateFields.h:423
@ CORPSE_FIELD_OWNER
Definition UpdateFields.h:420
@ OBJECT_FIELD_TYPE
Definition UpdateFields.h:26
@ CONFIG_DEATH_BONES_BG_OR_ARENA
Definition WorldConfig.h:62
@ CONFIG_DEATH_BONES_WORLD
Definition WorldConfig.h:61
Definition Corpse.h:49
bool Create(ObjectGuid::LowType guidlow)
Definition Corpse.cpp:61
CellCoord const & GetCellCoord() const
Definition Corpse.h:74
void SetCellCoord(CellCoord const &cellCoord)
Definition Corpse.h:75
void DeleteFromDB(CharacterDatabaseTransaction trans)
Definition Corpse.cpp:119
bool IsBattlegroundOrArena() const
Definition Map.h:307
void AddCorpse(Corpse *corpse)
Definition Map.cpp:3044
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:206
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition Map.h:375
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:307
void RemoveCorpse(Corpse *corpse)
Definition Map.cpp:3056
LowType GetCounter() const
Definition ObjectGuid.h:149
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:298
void SetGuidValue(uint16 index, ObjectGuid value)
Definition Object.cpp:716
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:643
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
Definition Object.cpp:2994
uint32 GetPhaseMask() const
Definition Object.h:517
void UpdatePositionData()
Definition Object.cpp:1183
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
void Relocate(float x, float y)
Definition Position.h:77

References AddCorpse(), AddToMap(), CharacterDatabase, CONFIG_DEATH_BONES_BG_OR_ARENA, CONFIG_DEATH_BONES_WORLD, CORPSE_END, CORPSE_FIELD_FLAGS, CORPSE_FIELD_ITEM, CORPSE_FIELD_OWNER, CORPSE_FLAG_BONES, CORPSE_FLAG_UNK2, Corpse::Create(), Corpse::DeleteFromDB(), EQUIPMENT_SLOT_END, Corpse::GetCellCoord(), GetCorpseByPlayer(), ObjectGuid::GetCounter(), Object::GetGUID(), Position::GetOrientation(), Corpse::GetOwnerGUID(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), Object::GetUInt32Value(), IsBattlegroundOrArena(), IsGridLoaded(), OBJECT_FIELD_TYPE, Position::Relocate(), RemoveCorpse(), Corpse::SetCellCoord(), Object::SetGuidValue(), WorldObject::SetPhaseMask(), Object::SetUInt32Value(), sWorld, and WorldObject::UpdatePositionData().

Referenced by AddPlayerToMap(), Player::RemovedInsignia(), and RemoveOldCorpses().

◆ CreatureRelocation()

void Map::CreatureRelocation ( Creature creature,
float  x,
float  y,
float  z,
float  o 
)
827{
828 Cell old_cell = creature->GetCurrentCell();
829 Cell new_cell(x, y);
830
831 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
832 {
833 if (old_cell.DiffGrid(new_cell))
834 EnsureGridLoaded(new_cell);
835
836 AddCreatureToMoveList(creature);
837 }
838 else
840
841 creature->Relocate(x, y, z, o);
842 if (creature->IsVehicle())
843 creature->GetVehicleKit()->RelocatePassengers();
844 creature->UpdatePositionData();
845 creature->UpdateObjectVisibility(false);
846}
void AddCreatureToMoveList(Creature *c)
Definition Map.cpp:889
void RemoveCreatureFromMoveList(Creature *c)
Definition Map.cpp:896
Cell const & GetCurrentCell() const
Definition Object.h:423
bool IsVehicle() const
Definition Unit.h:801
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition Unit.cpp:15372
Vehicle * GetVehicleKit() const
Definition Unit.h:1925
void RelocatePassengers()
Definition Vehicle.cpp:532
bool DiffGrid(Cell const &cell) const
Definition Cell.h:63
bool DiffCell(Cell const &cell) const
Definition Cell.h:57

References AddCreatureToMoveList(), Cell::DiffCell(), Cell::DiffGrid(), EnsureGridLoaded(), MovableMapObject::GetCurrentCell(), Unit::GetVehicleKit(), Unit::IsVehicle(), Position::Relocate(), Vehicle::RelocatePassengers(), RemoveCreatureFromMoveList(), Unit::UpdateObjectVisibility(), and WorldObject::UpdatePositionData().

Referenced by Creature::SetPosition(), StaticTransport::UpdatePassengerPositions(), MotionTransport::UpdatePassengerPositions(), and Unit::UpdatePosition().

◆ DelayedUpdate()

void Map::DelayedUpdate ( const uint32  diff)
virtual

Reimplemented in MapInstanced.

1780{
1782 {
1783 Transport* transport = *_transportsUpdateIter;
1785
1786 if (!transport->IsInWorld())
1787 continue;
1788
1789 transport->DelayedUpdate(t_diff);
1790 }
1791
1793}
void RemoveAllObjectsInRemoveList()
Definition Map.cpp:1805
virtual void DelayedUpdate(uint32)
Definition Transport.h:41

References _transports, _transportsUpdateIter, Transport::DelayedUpdate(), Object::IsInWorld(), and RemoveAllObjectsInRemoveList().

Referenced by MapInstanced::DelayedUpdate().

◆ DeleteCorpseData()

void Map::DeleteCorpseData ( )
3542{
3543 // DELETE FROM corpse WHERE mapId = ? AND instanceId = ?
3545 stmt->SetData(0, GetId());
3546 stmt->SetData(1, GetInstanceId());
3547 CharacterDatabase.Execute(stmt);
3548}
@ CHAR_DEL_CORPSES_FROM_MAP
Definition CharacterDatabase.h:250
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

References CHAR_DEL_CORPSES_FROM_MAP, CharacterDatabase, GetId(), GetInstanceId(), and PreparedStatementBase::SetData().

Referenced by InstanceMap::UnloadAll().

◆ DeleteFromWorld() [1/2]

template<>
void Map::DeleteFromWorld ( Player player)
176{
178
179 RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway
180 delete player;
181}
void RemoveUpdateObject(Object *obj)
Definition Map.h:539
void RemoveObject(T *object)
Definition ObjectAccessor.h:95

References ObjectAccessor::RemoveObject(), and RemoveUpdateObject().

◆ DeleteFromWorld() [2/2]

template<class T >
void Map::DeleteFromWorld ( T *  obj)
private
169{
170 // Note: In case resurrectable corpse and pet its removed from global lists in own destructor
171 delete obj;
172}

Referenced by RemoveFromMap(), RemoveFromMap(), and RemovePlayerFromMap().

◆ DeleteRespawnTimes()

void Map::DeleteRespawnTimes ( )
2575{
2576 _creatureRespawnTimes.clear();
2577 _goRespawnTimes.clear();
2578 _respawnQueue.clear();
2579
2581}
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
Definition Map.cpp:2583
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition Map.h:651
std::set< RespawnEntry > _respawnQueue
Definition Map.h:670
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition Map.h:652

References _creatureRespawnTimes, _goRespawnTimes, _respawnQueue, DeleteRespawnTimesInDB(), GetId(), and GetInstanceId().

Referenced by InstanceMap::UnloadAll().

◆ DeleteRespawnTimesInDB()

void Map::DeleteRespawnTimesInDB ( uint16  mapId,
uint32  instanceId 
)
static
2584{
2586 stmt->SetData(0, mapId);
2587 stmt->SetData(1, instanceId);
2588 CharacterDatabase.Execute(stmt);
2589
2590 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
2591 stmt->SetData(0, mapId);
2592 stmt->SetData(1, instanceId);
2593 CharacterDatabase.Execute(stmt);
2594}
@ CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE
Definition CharacterDatabase.h:256
@ CHAR_DEL_GO_RESPAWN_BY_INSTANCE
Definition CharacterDatabase.h:261

References CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE, CHAR_DEL_GO_RESPAWN_BY_INSTANCE, CharacterDatabase, and PreparedStatementBase::SetData().

Referenced by InstanceSaveMgr::_ResetSave(), InstanceSaveMgr::DeleteInstanceSaveIfNeeded(), and DeleteRespawnTimes().

◆ DoForAllPlayers()

void Map::DoForAllPlayers ( std::function< void(Player *)>  exec)
3316{
3317 for (auto const& it : GetPlayers())
3318 {
3319 if (Player* player = it.GetSource())
3320 {
3321 exec(player);
3322 }
3323 }
3324}

References GetPlayers().

Referenced by Battleground::_ProcessProgress(), ArenaSeasonMgr::BroadcastUpdatedWorldState(), WorldState::BuffAdalsSongOfBattle(), WorldState::BuffMagtheridonTeam(), BattlegroundSA::CaptureGraveyard(), WorldState::DispelAdalsSongOfBattle(), WorldState::DispelMagtheridonTeam(), npc_thrall_warchief::npc_thrall_warchiefAI::DoAction(), InstanceScript::DoCastSpellOnPlayers(), InstanceScript::DoRemoveAurasDueToSpellOnPlayers(), ScriptedAI::DoRewardPlayersInArea(), InstanceScript::DoSendNotifyToInstance(), InstanceScript::DoStartTimedAchievement(), InstanceScript::DoStopTimedAchievement(), InstanceScript::DoUpdateAchievementCriteria(), BattlegroundSA::EventPlayerDamagedGO(), BattlegroundSA::EventPlayerUsedGO(), boss_yoggsaron_sara::HasAlivePlayerInIllusion(), boss_azuregos::boss_azuregosAI::JustDied(), boss_rajaxx::JustDied(), boss_alar::JustDied(), boss_devourer_of_souls::JustEngagedWith(), boss_felblood_kaelthas::LapseAction(), spell_malygos_vortex_visual::OnRemove(), BattlegroundSA::PostUpdateImpl(), spell_fire_festival_fortitude::PrepareSpellScript(), boss_azuregos::boss_azuregosAI::Reset(), boss_yoggsaron_sara::Reset(), npc_minigob_manabonk::SelectTargetInDalaran(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::SetBossState(), instance_halls_of_reflection::SetBossState(), instance_ulduar::instance_ulduar_InstanceMapScript::SetBossState(), instance_halls_of_reflection::SetData(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetData(), Battleground::SpiritOfCompetitionEvent(), boss_nefarian::UpdateAI(), boss_cthun::UpdateAI(), boss_malygos::UpdateAI(), npc_gunship::npc_gunshipAI::UpdateAI(), npc_midsummer_bonfire::UpdateBonfireBlessingBuffs(), instance_halls_of_reflection::UpdateOutro(), and instance_eye_of_eternity::VortexHandling().

◆ DynamicObjectRelocation()

void Map::DynamicObjectRelocation ( DynamicObject go,
float  x,
float  y,
float  z,
float  o 
)
870{
871 Cell old_cell = dynObj->GetCurrentCell();
872 Cell new_cell(x, y);
873
874 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
875 {
876 if (old_cell.DiffGrid(new_cell))
877 EnsureGridLoaded(new_cell);
878
880 }
881 else
883
884 dynObj->Relocate(x, y, z, o);
885 dynObj->SetPositionDataUpdate();
886 dynObj->UpdateObjectVisibility(false);
887}
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
Definition Map.cpp:922
void AddDynamicObjectToMoveList(DynamicObject *go)
Definition Map.cpp:915

References AddDynamicObjectToMoveList(), Cell::DiffCell(), Cell::DiffGrid(), EnsureGridLoaded(), MovableMapObject::GetCurrentCell(), Position::Relocate(), RemoveDynamicObjectFromMoveList(), WorldObject::SetPositionDataUpdate(), and WorldObject::UpdateObjectVisibility().

Referenced by StaticTransport::UpdatePassengerPositions(), and MotionTransport::UpdatePassengerPositions().

◆ EnsureGridCreated()

void Map::EnsureGridCreated ( GridCoord const &  gridCoord)
184{
185 _mapGridManager.CreateGrid(gridCoord.x_coord, gridCoord.y_coord);
186}
void CreateGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:5

References _mapGridManager, MapGridManager::CreateGrid(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by AddToMap(), MapGridManager::CreateGrid(), EnsureGridLoaded(), and GetGridTerrainData().

◆ EnsureGridLoaded()

bool Map::EnsureGridLoaded ( Cell const &  cell)
private
189{
190 EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
191
192 if (_mapGridManager.LoadGrid(cell.GridX(), cell.GridY()))
193 {
194 Balance();
195 return true;
196 }
197
198 return false;
199}
bool LoadGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:33
void Balance()
Definition Map.h:403

References _mapGridManager, Balance(), EnsureGridCreated(), Cell::GridX(), Cell::GridY(), and MapGridManager::LoadGrid().

Referenced by AddToMap(), AddToMap(), CreatureRelocation(), DynamicObjectRelocation(), GameObjectRelocation(), LoadGrid(), LoadGridsInRange(), MoveAllCreaturesInMoveList(), MoveAllDynamicObjectsInMoveList(), MoveAllGameObjectsInMoveList(), PlayerRelocation(), and SummonCreature().

◆ GameObjectRelocation()

void Map::GameObjectRelocation ( GameObject go,
float  x,
float  y,
float  z,
float  o 
)
849{
850 Cell old_cell = go->GetCurrentCell();
851 Cell new_cell(x, y);
852
853 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
854 {
855 if (old_cell.DiffGrid(new_cell))
856 EnsureGridLoaded(new_cell);
857
859 }
860 else
862
863 go->Relocate(x, y, z, o);
866 go->UpdateObjectVisibility(false);
867}
void UpdateModelPosition()
Definition GameObject.cpp:2936
void AddGameObjectToMoveList(GameObject *go)
Definition Map.cpp:902
void RemoveGameObjectFromMoveList(GameObject *go)
Definition Map.cpp:909
void SetPositionDataUpdate()
Definition Object.cpp:1174
virtual void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false)
Definition Object.cpp:3067

References AddGameObjectToMoveList(), Cell::DiffCell(), Cell::DiffGrid(), EnsureGridLoaded(), MovableMapObject::GetCurrentCell(), Position::Relocate(), RemoveGameObjectFromMoveList(), WorldObject::SetPositionDataUpdate(), GameObject::UpdateModelPosition(), and WorldObject::UpdateObjectVisibility().

Referenced by GameObject::SetPosition(), StaticTransport::UpdatePassengerPositions(), and MotionTransport::UpdatePassengerPositions().

◆ GenerateLowGuid()

◆ GetAllTransports()

TransportsContainer const & Map::GetAllTransports ( ) const
inline

◆ GetAreaId()

uint32 Map::GetAreaId ( uint32  phaseMask,
float  x,
float  y,
float  z 
) const
1261{
1262 uint32 mogpFlags;
1263 int32 adtId, rootId, groupId;
1264 float vmapZ = z;
1265 bool hasVmapArea = GetAreaInfo(phaseMask, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
1266
1267 uint32 gridAreaId = 0;
1268 float gridMapHeight = INVALID_HEIGHT;
1269 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1270 {
1271 gridAreaId = gmap->getArea(x, y);
1272 gridMapHeight = gmap->getHeight(x, y);
1273 }
1274
1275 uint16 areaId = 0;
1276
1277 // floor is the height we are closer to (but only if above)
1278 if (hasVmapArea && G3D::fuzzyGe(z, vmapZ - GROUND_HEIGHT_TOLERANCE) && (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapZ > gridMapHeight))
1279 {
1280 // wmo found
1281 if (WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId))
1282 areaId = wmoEntry->areaId;
1283
1284 if (!areaId)
1285 areaId = gridAreaId;
1286 }
1287 else
1288 areaId = gridAreaId;
1289
1290 if (!areaId)
1291 areaId = i_mapEntry->linked_zone;
1292
1293 return areaId;
1294}
WMOAreaTableEntry const * GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
Definition DBCStores.cpp:694
std::uint16_t uint16
Definition Define.h:108
float const GROUND_HEIGHT_TOLERANCE
Definition SharedDefines.h:26
Definition GridTerrainData.h:222
Definition Map.h:168
bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition Map.cpp:1221
GridTerrainData * GetGridTerrainData(GridCoord const &gridCoord)
Definition Map.cpp:1102
uint32 linked_zone
Definition DBCStructure.h:1333
Definition DBCStructure.h:2131

References GetAreaInfo(), GetGridTerrainData(), GetWMOAreaTableEntryByTripple(), GROUND_HEIGHT_TOLERANCE, i_mapEntry, INVALID_HEIGHT, and MapEntry::linked_zone.

Referenced by MapMgr::GetAreaId(), GetLiquidData(), GetZoneAndAreaId(), and GetZoneId().

◆ GetAreaInfo()

bool Map::GetAreaInfo ( uint32  phaseMask,
float  x,
float  y,
float  z,
uint32 mogpflags,
int32 adtId,
int32 rootId,
int32 groupId 
) const
1222{
1223 float check_z = z;
1226
1227 bool hasVmapAreaInfo = _mapCollisionData.GetStaticTree().GetAreaAndLiquidData(x, y, z, {}, vdata) && vdata.areaInfo.has_value();
1228 bool hasDynamicAreaInfo = _mapCollisionData.GetDynamicTree().GetAreaAndLiquidData(x, y, z, phaseMask, {}, ddata) && ddata.areaInfo.has_value();
1229 auto useVmap = [&] { check_z = vdata.floorZ; groupId = vdata.areaInfo->groupId; adtId = vdata.areaInfo->adtId; rootId = vdata.areaInfo->rootId; flags = vdata.areaInfo->mogpFlags; };
1230 auto useDyn = [&] { check_z = ddata.floorZ; groupId = ddata.areaInfo->groupId; adtId = ddata.areaInfo->adtId; rootId = ddata.areaInfo->rootId; flags = ddata.areaInfo->mogpFlags; };
1231 if (hasVmapAreaInfo)
1232 {
1233 if (hasDynamicAreaInfo && ddata.floorZ > vdata.floorZ)
1234 useDyn();
1235 else
1236 useVmap();
1237 }
1238 else if (hasDynamicAreaInfo)
1239 {
1240 useDyn();
1241 }
1242
1243 if (hasVmapAreaInfo || hasDynamicAreaInfo)
1244 {
1245 // check if there's terrain between player height and object height
1246 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1247 {
1248 float mapHeight = gmap->getHeight(x, y);
1249 // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
1250 if (z + 2.0f > mapHeight && mapHeight > check_z)
1251 return false;
1252 }
1253
1254 return true;
1255 }
1256
1257 return false;
1258}
bool GetAreaAndLiquidData(float x, float y, float z, uint32 phasemask, Optional< uint8 > reqLiquidType, VMAP::AreaAndLiquidData &data) const
Definition DynamicTree.cpp:292
bool GetAreaAndLiquidData(float x, float y, float z, Optional< uint8 > reqLiquidType, VMAP::AreaAndLiquidData &data) const
Definition MapCollisionData.cpp:136
Definition IVMapMgr.h:54
Optional< AreaInfo > areaInfo
Definition IVMapMgr.h:77
float floorZ
Definition IVMapMgr.h:76

References _mapCollisionData, VMAP::AreaAndLiquidData::areaInfo, VMAP::AreaAndLiquidData::floorZ, StaticVMapCollisionData::GetAreaAndLiquidData(), DynamicMapTree::GetAreaAndLiquidData(), MapCollisionData::GetDynamicTree(), GetGridTerrainData(), and MapCollisionData::GetStaticTree().

Referenced by GetAreaId().

◆ GetCorpse()

Corpse * Map::GetCorpse ( ObjectGuid const &  guid)
2410{
2411 return _objectsStore.Find<Corpse>(guid);
2412}
MapStoredObjectTypesContainer _objectsStore
Definition Map.h:696
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition TypeContainer.h:189

References _objectsStore, and TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Find().

Referenced by ObjectAccessor::GetCorpse(), and ScriptsProcess().

◆ GetCorpseByPlayer()

Corpse * Map::GetCorpseByPlayer ( ObjectGuid const &  ownerGuid) const
inline
376 {
377 auto itr = _corpsesByPlayer.find(ownerGuid);
378 if (itr != _corpsesByPlayer.end())
379 return itr->second;
380
381 return nullptr;
382 }

References _corpsesByPlayer.

Referenced by ConvertCorpseToBones(), Player::GetCorpse(), and WorldSession::HandleMoveWorldportAck().

◆ GetCorpsesInGrid()

std::unordered_set< Corpse * > const * Map::GetCorpsesInGrid ( uint32  gridId) const
inline
367 {
368 auto itr = _corpsesByGrid.find(gridId);
369 if (itr != _corpsesByGrid.end())
370 return &itr->second;
371
372 return nullptr;
373 }

References _corpsesByGrid.

Referenced by GridObjectLoader::LoadAllCellsInGrid().

◆ GetCreatedCellsInGridCount()

uint32 Map::GetCreatedCellsInGridCount ( uint16 const  x,
uint16 const  y 
)
3570{
3572}
uint32 GetCreatedCellsInGridCount(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:106

References _mapGridManager, and MapGridManager::GetCreatedCellsInGridCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreatedCellsInMapCount()

uint32 Map::GetCreatedCellsInMapCount ( )
3575{
3577}
uint32 GetCreatedCellsInMapCount()
Definition MapGridManager.cpp:115

References _mapGridManager, and MapGridManager::GetCreatedCellsInMapCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreatedGridsCount()

uint32 Map::GetCreatedGridsCount ( )
3560{
3562}
uint32 GetCreatedGridsCount()
Definition MapGridManager.cpp:96

References _mapGridManager, and MapGridManager::GetCreatedGridsCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreature()

Creature * Map::GetCreature ( ObjectGuid const &  guid)
2415{
2416 return _objectsStore.Find<Creature>(guid);
2417}

References _objectsStore, and TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Find().

Referenced by Battleground::_ProcessResurrect(), instance_blood_furnace::instance_blood_furnace_InstanceMapScript::ActivatePrisoners(), boss_tyrannus::boss_tyrannusAI::boss_tyrannusAI(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::CallNextRajaxxLeader(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::CheckAchievementCriteriaMeet(), spell_sha_fire_nova::CheckFireTotem(), instance_molten_core::CheckMajordomoExecutus(), boss_prince_valanar_icc::boss_prince_valanarAI::CheckRoom(), instance_blackrock_depths::CheckTombReset(), instance_stratholme::instance_stratholme_InstanceMapScript::CheckZiggurats(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::CleanupInstance(), instance_molten_core::DoAction(), boss_ayamiss::DoAction(), npc_vh_void_sentry::DoAction(), npc_pos_martin_or_gorkun_second::npc_pos_martin_or_gorkun_secondAI::DoAction(), boss_black_knight::boss_black_knightAI::DoAction(), boss_tyrannus::boss_tyrannusAI::DoAction(), InstanceScript::DoCastSpellOnPlayer(), WorldSession::DoLootRelease(), InstanceScript::DoRespawnCreature(), InstanceScript::DoRespawnCreature(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::DoSummonGrandChampion(), instance_blackrock_spire::Dragonspireroomcheck(), Spell::EffectDestroyAllTotems(), boss_tyrannus::boss_tyrannusAI::EnterEvadeMode(), BattlegroundEY::EventTeamCapturedPoint(), boss_erekem::ExecuteEvent(), boss_xevozz::ExecuteEvent(), WorldState::GetActiveZones(), Battleground::GetBGCreature(), boss_erekem::GetChainHealTargetGuid(), Battlefield::GetCreature(), InstanceScript::GetCreature(), ObjectAccessor::GetCreature(), npc_ranshalla::npc_ranshallaAI::GetSpeakerByEntry(), SmartScript::GetTargets(), WorldState::HandleActiveZone(), WorldSession::HandleAreaSpiritHealerQueryOpcode(), WorldSession::HandleAreaSpiritHealerQueueOpcode(), WorldSession::HandleAutostoreLootItemOpcode(), WorldSession::HandleBattlemasterHelloOpcode(), WorldSession::HandleBattlemasterJoinArena(), BattlegroundIC::HandleCapturedNodes(), BattlegroundIC::HandleContestedNodes(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::HandleDropAttempt(), spell_sha_fire_nova::HandleDummy(), WorldSession::HandleLootMasterGiveOpcode(), WorldSession::HandleLootMoneyOpcode(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::HandleOutro(), spell_sha_stoneclaw_totem::HandleScriptEffect(), WorldSession::HandleTotemDestroyed(), instance_halls_of_reflection::HandleWaveWipe(), wp_commandscript::HandleWpModifyCommand(), wp_commandscript::HandleWpShowCommand(), TempSummon::InitStats(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::InstanceCleanup(), instance_violet_hold::instance_violet_hold_InstanceMapScript::InstanceCleanup(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::InstanceCleanup(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::IsAnyChannelerAlive(), Unit::isAttackingPlayer(), instance_ulduar::instance_ulduar_InstanceMapScript::IsEncounterInProgress(), instance_zulfarrak::instance_zulfarrak_InstanceMapScript::IsWaveAllDead(), npc_ranshalla::npc_ranshallaAI::JustDidDialogueStep(), boss_rajaxx::JustDied(), boss_jormungarAI::JustDied(), boss_skarvald_the_constructor::JustDied(), boss_dalronn_the_controller::JustDied(), npc_vh_void_sentry::JustDied(), boss_anubarak_trial::boss_anubarak_trialAI::JustEngagedWith(), npc_pos_deathwhisper_necrolyte::npc_pos_deathwhisper_necrolyteAI::JustEngagedWith(), boss_prince_keleseth_icc::boss_prince_kelesethAI::JustEngagedWith(), boss_prince_taldaram_icc::boss_prince_taldaramAI::JustEngagedWith(), boss_prince_valanar_icc::boss_prince_valanarAI::JustEngagedWith(), boss_skarvald_the_constructor::JustEngagedWith(), boss_dalronn_the_controller::JustEngagedWith(), boss_erekem::JustEngagedWith(), instance_nexus::instance_nexus_InstanceMapScript::KillAllFrayers(), Player::KilledMonsterCredit(), boss_professor_putricide::boss_professor_putricideAI::MovementInform(), npc_hor_lich_king::MovementInform(), instance_zulfarrak::instance_zulfarrak_InstanceMapScript::MoveNPCIfAlive(), BattlegroundAB::NodeOccupied(), npc_pos_leader_second::npc_pos_leader_secondAI::npc_pos_leader_secondAI(), npc_pos_martin_or_gorkun_second::npc_pos_martin_or_gorkun_secondAI::npc_pos_martin_or_gorkun_secondAI(), instance_blackwing_lair::OnCreatureCreate(), instance_shadowfang_keep::instance_shadowfang_keep_InstanceMapScript::OnCreatureCreate(), instance_ruby_sanctum::instance_ruby_sanctum_InstanceMapScript::OnCreatureCreate(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::OnCreatureCreate(), WorldState::OnDisable(), WorldState::OnDisable(), instance_molten_core::OnGameObjectCreate(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate(), instance_ruby_sanctum::instance_ruby_sanctum_InstanceMapScript::OnPlayerEnter(), instance_vault_of_archavon::instance_vault_of_archavon_InstanceMapScript::OnPlayerEnter(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::OnPlayerEnter(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::OnPlayerEnter(), instance_blackrock_depths::OnUnitDeath(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::OnUnitDeath(), instance_azjol_nerub::instance_azjol_nerub_InstanceScript::OnUnitDeath(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnUnitDeath(), instance_halls_of_stone::instance_halls_of_stone_InstanceMapScript::OnUnitDeath(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::OnUnitDeath(), BattlegroundAV::PopulateNode(), BattlegroundIC::PostUpdateImpl(), BattlegroundRV::PostUpdateImpl(), instance_blackrock_spire::ProcessEvent(), instance_stratholme::instance_stratholme_InstanceMapScript::ProcessSlaughterEvent(), instance_halls_of_reflection::RandomizeCompositionsAndShow(), instance_zulgurub::instance_zulgurub_InstanceMapScript::RemoveHakkarPowerStack(), instance_blackrock_depths::ReplaceMoiraIfSaved(), instance_zulaman::instance_zulaman_InstanceMapScript::ResetAkilzonGauntlet(), instance_blood_furnace::instance_blood_furnace_InstanceMapScript::ResetPrisoners(), ScheduleCreatureRespawn(), ScriptsProcess(), instance_zulfarrak::instance_zulfarrak_InstanceMapScript::SendAddsUpStairs(), Player::SendLoot(), Group::SendPendingRollsToPlayer(), instance_molten_core::SetBossState(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::SetBossState(), instance_blackrock_spire::SetBossState(), instance_blackwing_lair::SetBossState(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::SetBossState(), instance_ruby_sanctum::instance_ruby_sanctum_InstanceMapScript::SetBossState(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetBossState(), instance_black_temple::instance_black_temple_InstanceMapScript::SetBossState(), instance_blackrock_depths::SetData(), instance_blackrock_spire::SetData(), instance_blackwing_lair::SetData(), instance_karazhan::instance_karazhan_InstanceMapScript::SetData(), instance_scarlet_monastery::instance_scarlet_monastery_InstanceMapScript::SetData(), instance_scholomance::instance_scholomance_InstanceMapScript::SetData(), instance_shadowfang_keep::instance_shadowfang_keep_InstanceMapScript::SetData(), instance_stratholme::instance_stratholme_InstanceMapScript::SetData(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::SetData(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::SetData(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::SetData(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::SetData(), instance_dire_maul::instance_dire_maul_InstanceMapScript::SetData(), instance_wailing_caverns::instance_wailing_caverns_InstanceMapScript::SetData(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SetData(), instance_halls_of_reflection::SetData(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetData(), instance_oculus::instance_oculus_InstanceMapScript::SetData(), instance_halls_of_stone::instance_halls_of_stone_InstanceMapScript::SetData(), instance_utgarde_keep::instance_utgarde_keep_InstanceMapScript::SetData(), instance_utgarde_pinnacle::instance_utgarde_pinnacle_InstanceMapScript::SetData(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::SetData(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::SetData(), Unit::SetPhaseMask(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SpawnAnubArak(), instance_ulduar::instance_ulduar_InstanceMapScript::SpawnLeviathanEncounterVehicles(), instance_zulaman::instance_zulaman_InstanceMapScript::StartAkilzonGauntlet(), instance_violet_hold::instance_violet_hold_InstanceMapScript::StartBossEncounter(), instance_halls_of_reflection::StartNextWave(), instance_molten_core::SummonMajordomoExecutus(), WorldState::SummonMouth(), WorldState::SummonPallid(), instance_blackrock_spire::SummonSolakarWave(), instance_blackrock_depths::TombOfSevenEvent(), instance_blackrock_depths::TombOfSevenReset(), instance_blackwing_lair::Update(), instance_stratholme::instance_stratholme_InstanceMapScript::Update(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::Update(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::Update(), instance_zulfarrak::instance_zulfarrak_InstanceMapScript::Update(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::Update(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::Update(), instance_halls_of_reflection::Update(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::Update(), instance_vault_of_archavon::instance_vault_of_archavon_InstanceMapScript::Update(), instance_violet_hold::instance_violet_hold_InstanceMapScript::Update(), instance_shattered_halls::instance_shattered_halls_InstanceMapScript::Update(), boss_vaelastrasz::UpdateAI(), boss_black_knight::boss_black_knightAI::UpdateAI(), npc_hor_lich_king::UpdateAI(), boss_krick::boss_krickAI::UpdateAI(), boss_tyrannus::boss_tyrannusAI::UpdateAI(), npc_pos_leader::npc_pos_leaderAI::UpdateAI(), npc_pos_after_first_boss::npc_pos_after_first_bossAI::UpdateAI(), npc_pos_tyrannus_events::npc_pos_tyrannus_eventsAI::UpdateAI(), npc_pos_martin_or_gorkun_second::npc_pos_martin_or_gorkun_secondAI::UpdateAI(), npc_pos_leader_second::npc_pos_leader_secondAI::UpdateAI(), boss_prince_valanar_icc::boss_prince_valanarAI::UpdateAI(), npc_vh_teleportation_portal::UpdateAI(), and instance_eye_of_eternity::VortexHandling().

◆ GetCreatureBySpawnIdStore()

◆ GetCreatureRespawnTime()

time_t Map::GetCreatureRespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
417 {
418 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
419 if (itr != _creatureRespawnTimes.end())
420 return itr->second;
421
422 return time_t(0);
423 }

References _creatureRespawnTimes.

Referenced by MotionTransport::CreateNPCPassenger(), GetLinkedRespawnTime(), GetRespawnTime(), misc_commandscript::HandleRespawnCreatureByGuidCommand(), and Creature::LoadCreatureFromDB().

◆ GetCreatureRespawnTimes()

◆ GetDebugInfo()

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

Reimplemented in InstanceMap.

3551{
3552 std::stringstream sstr;
3553 sstr << std::boolalpha
3554 << "Id: " << GetId() << " InstanceId: " << GetInstanceId() << " Difficulty: " << std::to_string(GetDifficulty())
3555 << " HasPlayers: " << HavePlayers();
3556 return sstr.str();
3557}
bool HavePlayers() const
Definition Map.h:324
Difficulty GetDifficulty() const
Definition Map.h:294

References GetDifficulty(), GetId(), GetInstanceId(), and HavePlayers().

Referenced by InstanceMap::GetDebugInfo().

◆ GetDifficulty()

◆ GetDynamicMapTree()

DynamicMapTree const & Map::GetDynamicMapTree ( ) const
inline

◆ GetDynamicObject()

DynamicObject * Map::GetDynamicObject ( ObjectGuid const &  guid)
2439{
2440 return _objectsStore.Find<DynamicObject>(guid);
2441}
Definition DynamicObject.h:35

References _objectsStore, and TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Find().

Referenced by ObjectAccessor::GetDynamicObject().

◆ GetEntrancePos()

bool Map::GetEntrancePos ( int32 mapid,
float &  x,
float &  y 
)
inline
311 {
312 if (!i_mapEntry)
313 return false;
314 return i_mapEntry->GetEntrancePos(mapid, x, y);
315 }
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
Definition DBCStructure.h:1360

References MapEntry::GetEntrancePos(), and i_mapEntry.

◆ GetEntry()

◆ GetFullTerrainStatusForPosition()

void Map::GetFullTerrainStatusForPosition ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight,
PositionFullTerrainStatus data,
Optional< uint8 reqLiquidType = {} 
)
1398{
1399 GridTerrainData* gmap = GetGridTerrainData(x, y);
1400
1401 VMAP::AreaAndLiquidData vmapData;
1403 VMAP::AreaAndLiquidData* wmoData = nullptr;
1404 _mapCollisionData.GetStaticTree().GetAreaAndLiquidData(x, y, z, reqLiquidType, vmapData);
1405 _mapCollisionData.GetDynamicTree().GetAreaAndLiquidData(x, y, z, phaseMask, reqLiquidType, dynData);
1406
1407 uint32 gridAreaId = 0;
1408 float gridMapHeight = INVALID_HEIGHT;
1409 if (gmap)
1410 {
1411 gridAreaId = gmap->getArea(x, y);
1412 gridMapHeight = gmap->getHeight(x, y);
1413 }
1414
1415 bool useGridLiquid = true;
1416
1417 // floor is the height we are closer to (but only if above)
1419 if (gridMapHeight > INVALID_HEIGHT && G3D::fuzzyGe(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE))
1420 data.floorZ = gridMapHeight;
1421
1422 if (vmapData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
1423 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapData.floorZ > gridMapHeight))
1424 {
1425 data.floorZ = vmapData.floorZ;
1426 wmoData = &vmapData;
1427 }
1428
1429 // NOTE: Objects will not detect a case when a wmo providing area/liquid despawns from under them
1430 // but this is fine as these kind of objects are not meant to be spawned and despawned a lot
1431 // example: Lich King platform
1432 if (dynData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, dynData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
1433 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > gridMapHeight) &&
1434 (G3D::fuzzyLt(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > vmapData.floorZ))
1435 {
1436 data.floorZ = dynData.floorZ;
1437 wmoData = &dynData;
1438 }
1439
1440 if (wmoData)
1441 {
1442 if (wmoData->areaInfo)
1443 {
1444 // wmo found
1445 WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId);
1446 data.outdoors = (wmoData->areaInfo->mogpFlags & 0x8) != 0;
1447 if (wmoEntry)
1448 {
1449 data.areaId = wmoEntry->areaId;
1450 if (wmoEntry->Flags & 4)
1451 data.outdoors = true;
1452 else if (wmoEntry->Flags & 2)
1453 data.outdoors = false;
1454 }
1455
1456 if (!data.areaId)
1457 data.areaId = gridAreaId;
1458
1459 useGridLiquid = !IsInWMOInterior(wmoData->areaInfo->mogpFlags);
1460 }
1461 }
1462 else
1463 {
1464 data.outdoors = true;
1465 data.areaId = gridAreaId;
1466 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId))
1467 data.outdoors = (areaEntry->flags & (AREA_FLAG_INSIDE | AREA_FLAG_OUTSIDE)) != AREA_FLAG_INSIDE;
1468 }
1469
1470 if (!data.areaId)
1472
1473 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId);
1474
1475 // liquid processing
1476 if (wmoData && wmoData->liquidInfo && wmoData->liquidInfo->level > wmoData->floorZ)
1477 {
1478 uint32 liquidType = wmoData->liquidInfo->type;
1479 if (GetId() == MAP_OUTLAND && liquidType == 2) // gotta love blizzard hacks
1480 liquidType = 15;
1481
1482 uint32 liquidFlagType = 0;
1483 if (LiquidTypeEntry const* liquidData = sLiquidTypeStore.LookupEntry(liquidType))
1484 liquidFlagType = liquidData->Type;
1485
1486 if (liquidType && liquidType < 21 && areaEntry)
1487 {
1488 uint32 overrideLiquid = areaEntry->LiquidTypeOverride[liquidFlagType];
1489 if (!overrideLiquid && areaEntry->zone)
1490 {
1491 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->zone);
1492 if (zoneEntry)
1493 overrideLiquid = zoneEntry->LiquidTypeOverride[liquidFlagType];
1494 }
1495
1496 if (LiquidTypeEntry const* overrideData = sLiquidTypeStore.LookupEntry(overrideLiquid))
1497 {
1498 liquidType = overrideLiquid;
1499 liquidFlagType = overrideData->Type;
1500 }
1501 }
1502
1503 data.liquidInfo.Level = wmoData->liquidInfo->level;
1504 data.liquidInfo.DepthLevel = wmoData->floorZ;
1505 data.liquidInfo.Entry = liquidType;
1506 data.liquidInfo.Flags = 1 << liquidFlagType;
1507
1508 // Get position delta
1509 float delta = wmoData->liquidInfo->level - z;
1510
1511 if (delta > collisionHeight)
1513 else if (delta > 0.0f)
1515 else if (delta > -0.1f)
1517 else
1519 }
1520
1521 // look up liquid data from grid map
1522 if (gmap && useGridLiquid)
1523 {
1524 LiquidData const& gridLiquidData = gmap->GetLiquidData(x, y, z, collisionHeight, reqLiquidType);
1525 if (gridLiquidData.Status != LIQUID_MAP_NO_WATER && (!wmoData || gridLiquidData.Level > wmoData->floorZ))
1526 {
1527 uint32 liquidEntry = gridLiquidData.Entry;
1528 if (GetId() == MAP_OUTLAND && liquidEntry == 2)
1529 liquidEntry = 15;
1530
1531 data.liquidInfo = gridLiquidData;
1532 data.liquidInfo.Entry = liquidEntry;
1533 }
1534 }
1535}
@ MAP_OUTLAND
Definition AreaDefines.h:217
@ AREA_FLAG_OUTSIDE
Definition DBCEnums.h:260
@ AREA_FLAG_INSIDE
Definition DBCEnums.h:259
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
DBCStorage< LiquidTypeEntry > sLiquidTypeStore(LiquidTypefmt)
@ LIQUID_MAP_UNDER_WATER
Definition GridTerrainData.h:195
@ LIQUID_MAP_NO_WATER
Definition GridTerrainData.h:191
@ LIQUID_MAP_IN_WATER
Definition GridTerrainData.h:194
@ LIQUID_MAP_ABOVE_WATER
Definition GridTerrainData.h:192
@ LIQUID_MAP_WATER_WALK
Definition GridTerrainData.h:193
#define VMAP_INVALID_HEIGHT
Definition IVMapMgr.h:50
static bool IsInWMOInterior(uint32 mogpFlags)
Definition Map.cpp:1216
LiquidData const GetLiquidData(float x, float y, float z, float collisionHeight, Optional< uint8 > ReqLiquidType) const
Definition GridTerrainData.cpp:530
float getHeight(float x, float y) const
Definition GridTerrainData.h:249
uint16 getArea(float x, float y) const
Definition GridTerrainData.cpp:214
Definition DBCStructure.h:519
uint32 zone
Definition DBCStructure.h:522
uint32 LiquidTypeOverride[4]
Definition DBCStructure.h:530
Definition GridTerrainData.h:199
float Level
Definition GridTerrainData.h:204
uint32 Flags
Definition GridTerrainData.h:203
uint32 Entry
Definition GridTerrainData.h:202
LiquidStatus Status
Definition GridTerrainData.h:206
float DepthLevel
Definition GridTerrainData.h:205
Definition DBCStructure.h:1283
float floorZ
Definition Map.h:102
uint32 areaId
Definition Map.h:101
LiquidData liquidInfo
Definition Map.h:104
bool outdoors
Definition Map.h:103
Optional< LiquidInfo > liquidInfo
Definition IVMapMgr.h:78
uint32 Flags
Definition DBCStructure.h:2141
uint32 areaId
Definition DBCStructure.h:2142

References _mapCollisionData, AREA_FLAG_INSIDE, AREA_FLAG_OUTSIDE, PositionFullTerrainStatus::areaId, WMOAreaTableEntry::areaId, VMAP::AreaAndLiquidData::areaInfo, LiquidData::DepthLevel, LiquidData::Entry, LiquidData::Flags, WMOAreaTableEntry::Flags, VMAP::AreaAndLiquidData::floorZ, PositionFullTerrainStatus::floorZ, GridTerrainData::getArea(), StaticVMapCollisionData::GetAreaAndLiquidData(), DynamicMapTree::GetAreaAndLiquidData(), MapCollisionData::GetDynamicTree(), GetGridTerrainData(), GridTerrainData::getHeight(), GetId(), GridTerrainData::GetLiquidData(), MapCollisionData::GetStaticTree(), GetWMOAreaTableEntryByTripple(), GROUND_HEIGHT_TOLERANCE, i_mapEntry, INVALID_HEIGHT, IsInWMOInterior(), LiquidData::Level, MapEntry::linked_zone, LIQUID_MAP_ABOVE_WATER, LIQUID_MAP_IN_WATER, LIQUID_MAP_NO_WATER, LIQUID_MAP_UNDER_WATER, LIQUID_MAP_WATER_WALK, VMAP::AreaAndLiquidData::liquidInfo, PositionFullTerrainStatus::liquidInfo, AreaTableEntry::LiquidTypeOverride, MAP_OUTLAND, PositionFullTerrainStatus::outdoors, sAreaTableStore, sLiquidTypeStore, LiquidData::Status, VMAP_INVALID_HEIGHT, and AreaTableEntry::zone.

Referenced by Creature::Create(), and WorldObject::UpdatePositionData().

◆ GetGameObject()

GameObject * Map::GetGameObject ( ObjectGuid const &  guid)
2420{
2421 return _objectsStore.Find<GameObject>(guid);
2422}

References _objectsStore, and TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Find().

Referenced by boss_sjonnir::boss_sjonnirAI::ActivatePipe(), Spell::CheckCast(), Player::CheckDuelDistance(), Spell::CheckEffectTarget(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::CheckLichKingAvailability(), instance_stratholme::instance_stratholme_InstanceMapScript::CheckZiggurats(), instance_obsidian_sanctum::instance_obsidian_sanctum_InstanceMapScript::DoAction(), Spell::DoAllEffectOnTarget(), npc_rocknot::DoGo(), WorldSession::DoLootRelease(), InstanceScript::DoRespawnGameObject(), InstanceScript::DoRespawnGameObject(), InstanceScript::DoUseDoorOrButton(), instance_blackrock_spire::Dragonspireroomcheck(), instance_blackrock_spire::Dragonspireroomstore(), Player::DuelComplete(), Spell::EffectSummonObject(), Battleground::GetBGObject(), Battlefield::GetGameObject(), InstanceScript::GetGameObject(), ObjectAccessor::GetGameObject(), Player::GetNextQuest(), BattlegroundRV::GetPillarAtPosition(), GetTransport(), WorldSession::HandleAutostoreLootItemOpcode(), InstanceScript::HandleGameObject(), WorldSession::HandleGameobjectReportUse(), WorldSession::HandleGossipSelectOptionOpcode(), WorldSession::HandleLootMasterGiveOpcode(), WorldSession::HandleLootMoneyOpcode(), WorldSession::HandleMoverRelocation(), boss_urok_doomhowl::InitializeAI(), instance_violet_hold::instance_violet_hold_InstanceMapScript::InstanceCleanup(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::InstanceCleanup(), npc_ranshalla::npc_ranshallaAI::JustDidDialogueStep(), boss_rend_blackhand::JustDied(), boss_shade_of_aran::JustDied(), npc_gunship::npc_gunshipAI::JustDied(), boss_sjonnir::boss_sjonnirAI::JustDied(), boss_shade_of_aran::JustEngagedWith(), boss_sjonnir::boss_sjonnirAI::JustEngagedWith(), instance_temple_of_ahnqiraj::instance_temple_of_ahnqiraj_InstanceMapScript::OnCreatureCreate(), instance_temple_of_ahnqiraj::instance_temple_of_ahnqiraj_InstanceMapScript::OnUnitDeath(), boss_pyroguard_emberseer::OpenDoors(), Player::PrepareQuestMenu(), instance_blackrock_spire::ProcessEvent(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::ProcessEvent(), instance_stratholme::instance_stratholme_InstanceMapScript::ProcessSlaughterEvent(), boss_sartharion_dragonAI::RemoveTwilightPortal(), boss_rend_blackhand::Reset(), boss_shade_of_aran::Reset(), boss_sjonnir::boss_sjonnirAI::Reset(), boss_palehoof::boss_palehoofAI::Reset(), ScriptsProcess(), Player::SendLoot(), instance_molten_core::SetBossState(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::SetBossState(), instance_blackwing_lair::SetBossState(), instance_gundrak::instance_gundrak_InstanceMapScript::SetBossState(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetBossState(), instance_serpent_shrine::instance_serpentshrine_cavern_InstanceMapScript::SetBossState(), instance_hellfire_ramparts::instance_hellfire_ramparts_InstanceMapScript::SetBossState(), instance_blackrock_spire::SetData(), instance_scarlet_monastery::instance_scarlet_monastery_InstanceMapScript::SetData(), instance_scholomance::instance_scholomance_InstanceMapScript::SetData(), instance_stratholme::instance_stratholme_InstanceMapScript::SetData(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::SetData(), instance_hyjal::instance_mount_hyjal_InstanceMapScript::SetData(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SetData(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::SetData(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetData(), instance_oculus::instance_oculus_InstanceMapScript::SetData(), instance_halls_of_stone::instance_halls_of_stone_InstanceMapScript::SetData(), instance_ulduar::instance_ulduar_InstanceMapScript::SetData(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::SetData(), instance_gundrak::instance_gundrak_InstanceMapScript::SetData(), instance_serpent_shrine::instance_serpentshrine_cavern_InstanceMapScript::SetData(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::SetData(), boss_pyroguard_emberseer::SetData(), boss_rend_blackhand::SummonWave(), brann_bronzebeard::SwitchHeadVisual(), instance_stratholme::instance_stratholme_InstanceMapScript::Update(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::Update(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::Update(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::Update(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::Update(), instance_violet_hold::instance_violet_hold_InstanceMapScript::Update(), boss_rend_blackhand::UpdateAI(), npc_arthas::npc_arthasAI::UpdateAI(), npc_pos_leader_second::npc_pos_leader_secondAI::UpdateAI(), boss_freya_nature_bomb::UpdateAI(), npc_pet_gen_plump_turkey::UpdateAI(), BattlegroundRV::UpdatePillars(), boss_pyroguard_emberseer::UpdateRunes(), npc_ranshalla::npc_ranshallaAI::WaypointReached(), and npc_arthas::npc_arthasAI::WaypointReached().

◆ GetGameObjectBySpawnIdStore()

◆ GetGameObjectFloor()

float Map::GetGameObjectFloor ( uint32  phasemask,
float  x,
float  y,
float  z,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
inline
409 {
410 return _mapCollisionData.GetDynamicTree().getHeight(x, y, z, maxSearchDist, phasemask);
411 }
float getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const
Definition DynamicTree.cpp:275

References _mapCollisionData, MapCollisionData::GetDynamicTree(), and DynamicMapTree::getHeight().

◆ GetGORespawnTime()

time_t Map::GetGORespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
426 {
427 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid);
428 if (itr != _goRespawnTimes.end())
429 return itr->second;
430
431 return time_t(0);
432 }

References _goRespawnTimes.

Referenced by MotionTransport::CreateGOPassenger(), GetLinkedRespawnTime(), GetRespawnTime(), misc_commandscript::HandleRespawnGameObjectByGuidCommand(), and GameObject::LoadGameObjectFromDB().

◆ GetGORespawnTimes()

◆ GetGridHeight()

float Map::GetGridHeight ( float  x,
float  y 
) const
1201{
1202 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1203 return gmap->getHeight(x, y);
1204
1205 return INVALID_HEIGHT;
1206}

References GetGridTerrainData(), and INVALID_HEIGHT.

Referenced by CheckCollisionAndGetValidCoords(), and GetHeight().

◆ GetGridTerrainData() [1/2]

GridTerrainData * Map::GetGridTerrainData ( float  x,
float  y 
)
1113{
1114 GridCoord const gridCoord = Acore::ComputeGridCoord(x, y);
1115 return GetGridTerrainData(gridCoord);
1116}

References Acore::ComputeGridCoord(), and GetGridTerrainData().

◆ GetGridTerrainData() [2/2]

GridTerrainData * Map::GetGridTerrainData ( GridCoord const &  gridCoord)
1103{
1104 if (!MapGridManager::IsValidGridCoordinates(gridCoord.x_coord, gridCoord.y_coord))
1105 return nullptr;
1106
1107 // ensure GridMap is created
1108 EnsureGridCreated(gridCoord);
1109 return _mapGridManager.GetGrid(gridCoord.x_coord, gridCoord.y_coord)->GetTerrainData();
1110}
MapGridType * GetGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:88
static bool IsValidGridCoordinates(uint16 const x, uint16 const y)
Definition MapGridManager.h:42
GridTerrainData * GetTerrainData() const
Definition MapGrid.h:101

References _mapGridManager, EnsureGridCreated(), MapGridManager::GetGrid(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::GetTerrainData(), MapGridManager::IsValidGridCoordinates(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by GetAreaId(), GetAreaInfo(), GetFullTerrainStatusForPosition(), GetGridHeight(), GetGridTerrainData(), GetLiquidData(), GetMinHeight(), and GetWaterLevel().

◆ GetGridTerrainDataSharedPtr()

std::shared_ptr< GridTerrainData > Map::GetGridTerrainDataSharedPtr ( GridCoord const &  gridCoord)
1096{
1097 MapGridType* grid = _mapGridManager.GetGrid(gridCoord.x_coord, gridCoord.y_coord);
1098 ASSERT(grid); // Grid should always exist during this call
1099 return grid->GetTerrainDataSharedPtr();
1100}
std::shared_ptr< GridTerrainData > GetTerrainDataSharedPtr()
Definition MapGrid.h:102

References _mapGridManager, ASSERT, MapGridManager::GetGrid(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::GetTerrainDataSharedPtr(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by GridTerrainLoader::LoadMap().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & Map::GetGuidSequenceGenerator ( )
inlineprivate
687 {
688 auto itr = _guidGenerators.find(high);
689 if (itr == _guidGenerators.end())
690 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
691
692 return *itr->second;
693 }
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition Map.h:695
Definition ObjectGuid.h:302

References _guidGenerators.

◆ GetHeight() [1/3]

float Map::GetHeight ( float  x,
float  y,
float  z,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
1167{
1168 // find raw .map surface under Z coordinates
1169 float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
1170 float gridHeight = GetGridHeight(x, y);
1171 if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
1172 mapHeight = gridHeight;
1173
1174 float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
1175 if (checkVMap)
1176 vmapHeight = _mapCollisionData.GetStaticTree().getHeight(x, y, z, maxSearchDist); // look from a bit higher pos to find the floor
1177
1178 // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT
1179 // vmapheight set for any under Z value or <= INVALID_HEIGHT
1180 if (vmapHeight > INVALID_HEIGHT)
1181 {
1182 if (mapHeight > INVALID_HEIGHT)
1183 {
1184 // we have mapheight and vmapheight and must select more appropriate
1185
1186 // we are already under the surface or vmap height above map heigt
1187 // or if the distance of the vmap height is less the land height distance
1188 if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
1189 return vmapHeight;
1190 else
1191 return mapHeight; // better use .map surface height
1192 }
1193 else
1194 return vmapHeight; // we have only vmapHeight (if have)
1195 }
1196
1197 return mapHeight; // explicitly use map data
1198}
float getHeight(float x, float y, float z, float maxSearchDist) const
Definition MapCollisionData.cpp:116

References _mapCollisionData, GetGridHeight(), StaticVMapCollisionData::getHeight(), MapCollisionData::GetStaticTree(), GROUND_HEIGHT_TOLERANCE, INVALID_HEIGHT, and VMAP_INVALID_HEIGHT_VALUE.

Referenced by BattlegroundRV::CheckPositionForUnit(), boss_ick::boss_ickAI::DamageTaken(), GetHeight(), WorldObject::GetMapHeight(), GetTransportForPos(), GetWaterOrGroundLevel(), go_commandscript::HandleGoGridCommand(), go_commandscript::HandleGoXYZCommand(), go_commandscript::HandleGoZoneXYCommand(), spell_winter_veil_racer_rocket_slam::HandleTriggerSpell(), spell_svalna_revive_champion::Land(), Creature::LoadCreatureFromDB(), spell_mimiron_magnetic_core_summon::ModDest(), Spell::SelectImplicitCasterDestTargets(), boss_yoggsaron_sara::SpawnTentacle(), boss_yoggsaron_death_ray::UpdateAI(), and npc_cork_gizelton::npc_cork_gizeltonAI::WaypointReached().

◆ GetHeight() [2/3]

float Map::GetHeight ( Position const &  pos,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
inline
245{ return GetHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), checkVMap, maxSearchDist); }
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:1166

References GetHeight(), Position::GetPositionX(), Position::GetPositionY(), and Position::GetPositionZ().

Referenced by GetHeight().

◆ GetHeight() [3/3]

float Map::GetHeight ( uint32  phasemask,
float  x,
float  y,
float  z,
bool  vmap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
1586{
1587 float h1, h2;
1588 h1 = GetHeight(x, y, z, vmap, maxSearchDist);
1589 h2 = _mapCollisionData.GetDynamicTree().getHeight(x, y, z, maxSearchDist, phasemask);
1590 return std::max<float>(h1, h2);
1591}

References _mapCollisionData, MapCollisionData::GetDynamicTree(), GetHeight(), and DynamicMapTree::getHeight().

◆ GetId()

uint32 Map::GetId ( ) const
inline
234{ return i_mapEntry->MapID; }
uint32 MapID
Definition DBCStructure.h:1326

References i_mapEntry, and MapEntry::MapID.

Referenced by Group::_cancelHomebindIfInstance(), AddObjectToRemoveList(), InstanceMap::AddPlayerToMap(), WorldState::BroadcastSIWorldstates(), WorldState::BuffAdalsSongOfBattle(), WorldState::BuffMagtheridonTeam(), MapUpdateRequest::call(), MapPreloadRequest::call(), InstanceMap::CannotEnter(), Player::CanRollForItemInLFG(), InstanceScript::CheckAchievementCriteriaMeet(), Spell::CheckCast(), GameObject::Create(), StaticTransport::Create(), MapInstanced::CreateBattleground(), MapInstanced::CreateInstance(), MapInstanced::CreateInstanceForPlayer(), InstanceMap::CreateInstanceScript(), TransportMgr::CreateInstanceTransports(), OPvPCapturePoint::DelCreature(), DeleteCorpseData(), DeleteRespawnTimes(), WorldState::DispelAdalsSongOfBattle(), WorldState::DispelMagtheridonTeam(), CreatureAI::DoZoneInCombat(), GetDebugInfo(), GetFullTerrainStatusForPosition(), GetLiquidData(), GetMapDifficulty(), debug_commandscript::HandleDebugObjectCountMap(), spell_valkyr_touch_aura::HandleEffectPeriodic(), gobject_commandscript::HandleGameObjectAddCommand(), go_commandscript::HandleGoZoneXYCommand(), instance_commandscript::HandleInstanceGetBossStateCommand(), list_commandscript::HandleListRespawnsCommand(), WorldSession::HandleMoveWorldportAck(), npc_commandscript::HandleNpcAddCommand(), WorldSession::HandlePlayerLoginFromDB(), WorldSession::HandlePlayerLoginToCharInWorld(), WorldSession::HandleSetRaidDifficultyOpcode(), wp_commandscript::HandleWpModifyCommand(), wp_commandscript::HandleWpShowCommand(), PoolMgr::InitPoolsForMap(), InitVisibilityDistance(), InstanceMap::InitVisibilityDistance(), Player::inRandomLfgDungeon(), DisableMgr::IsPathfindingEnabled(), InstanceScript::IsTwoFactionInstance(), GridObjectLoader::LoadAllCellsInGrid(), LoadCorpseData(), GridTerrainLoader::LoadMap(), GridTerrainLoader::LoadMMap(), MapCollisionData::LoadMMapTile(), LoadRespawnTimes(), GridTerrainLoader::LoadVMap(), LogEncounterFinished(), MapCollisionData::MapCollisionData(), AchievementCriteriaData::Meets(), MotionMaster::MoveFall(), lfg::LFGPlayerScript::OnPlayerMapChanged(), InstanceMap::PermBindAllPlayers(), RemoveAllPlayers(), RemoveCreatureRespawnTime(), RemoveGORespawnTime(), InstanceMap::Reset(), Player::RewardReputation(), SaveCreatureRespawnTime(), SaveGORespawnTime(), Group::SendPendingRollsToPlayer(), InstanceMap::SendResetWarnings(), World::SetInitialWorldSettings(), WorldObject::SetMap(), Player::SetMover(), SpawnGroupDespawn(), SpawnGroupSpawn(), SummonCreatureGroup(), SummonGameObjectGroup(), MotionTransport::TeleportTransport(), UnloadGrid(), Update(), and UpdateEncounterState().

◆ GetInstanceId()

◆ GetInstanceResetPeriod()

time_t Map::GetInstanceResetPeriod ( ) const
inline

◆ GetLinkedRespawnTime()

time_t Map::GetLinkedRespawnTime ( ObjectGuid  guid) const
3029{
3030 ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
3031 switch (linkedGuid.GetHigh())
3032 {
3033 case HighGuid::Unit:
3034 return GetCreatureRespawnTime(linkedGuid.GetCounter());
3036 return GetGORespawnTime(linkedGuid.GetCounter());
3037 default:
3038 break;
3039 }
3040
3041 return time_t(0);
3042}
#define sObjectMgr
Definition ObjectMgr.h:1730
time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:416
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:425
Definition ObjectGuid.h:121
HighGuid GetHigh() const
Definition ObjectGuid.h:146

References GameObject, ObjectGuid::GetCounter(), GetCreatureRespawnTime(), GetGORespawnTime(), ObjectGuid::GetHigh(), sObjectMgr, and Unit.

Referenced by ProcessCreatureRespawn(), Creature::Respawn(), and GameObject::Update().

◆ GetLiquidData()

LiquidData const Map::GetLiquidData ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight,
Optional< uint8 ReqLiquidType 
)
1315{
1316 LiquidData liquidData;
1317 liquidData.Status = LIQUID_MAP_NO_WATER;
1318
1319 VMAP::AreaAndLiquidData vmapData;
1320 bool useGridLiquid = true;
1321 if (_mapCollisionData.GetStaticTree().GetAreaAndLiquidData(x, y, z, ReqLiquidType, vmapData) && vmapData.liquidInfo)
1322 {
1323 useGridLiquid = !vmapData.areaInfo || !IsInWMOInterior(vmapData.areaInfo->mogpFlags);
1324 LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: {} ground: {} type: {}", vmapData.liquidInfo->level, vmapData.floorZ, vmapData.liquidInfo->type);
1325 // Check water level and ground level
1326 if (vmapData.liquidInfo->level > vmapData.floorZ && G3D::fuzzyGe(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE))
1327 {
1328 // hardcoded in client like this
1329 if (GetId() == MAP_OUTLAND && vmapData.liquidInfo->type == 2)
1330 vmapData.liquidInfo->type = 15;
1331
1332 uint32 liquidFlagType = 0;
1333 if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(vmapData.liquidInfo->type))
1334 liquidFlagType = liq->Type;
1335
1336 if (vmapData.liquidInfo->type && vmapData.liquidInfo->type < 21)
1337 {
1338 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseMask, x, y, z)))
1339 {
1340 uint32 overrideLiquid = area->LiquidTypeOverride[liquidFlagType];
1341 if (!overrideLiquid && area->zone)
1342 {
1343 area = sAreaTableStore.LookupEntry(area->zone);
1344 if (area)
1345 overrideLiquid = area->LiquidTypeOverride[liquidFlagType];
1346 }
1347
1348 if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
1349 {
1350 vmapData.liquidInfo->type = overrideLiquid;
1351 liquidFlagType = liq->Type;
1352 }
1353 }
1354 }
1355
1356 liquidData.Level = vmapData.liquidInfo->level;
1357 liquidData.DepthLevel = vmapData.floorZ;
1358 liquidData.Entry = vmapData.liquidInfo->type;
1359 liquidData.Flags = 1 << liquidFlagType;
1360 }
1361
1362 float delta = vmapData.liquidInfo->level - z;
1363
1364 // Get position delta
1365 if (delta > collisionHeight)
1366 liquidData.Status = LIQUID_MAP_UNDER_WATER;
1367 else if (delta > 0.0f)
1368 liquidData.Status = LIQUID_MAP_IN_WATER;
1369 else if (delta > -0.1f)
1370 liquidData.Status = LIQUID_MAP_WATER_WALK;
1371 else
1372 liquidData.Status = LIQUID_MAP_ABOVE_WATER;
1373 }
1374
1375 if (useGridLiquid)
1376 {
1377 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1378 {
1379 LiquidData const& map_data = gmap->GetLiquidData(x, y, z, collisionHeight, ReqLiquidType);
1380 // Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
1381 if (map_data.Status != LIQUID_MAP_NO_WATER && (map_data.Level > vmapData.floorZ))
1382 {
1383 // hardcoded in client like this
1384 uint32 liquidEntry = map_data.Entry;
1385 if (GetId() == MAP_OUTLAND && liquidEntry == 2)
1386 liquidEntry = 15;
1387
1388 liquidData = map_data;
1389 liquidData.Entry = liquidEntry;
1390 }
1391 }
1392 }
1393
1394 return liquidData;
1395}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157
uint32 GetAreaId(uint32 phaseMask, float x, float y, float z) const
Definition Map.cpp:1260

References _mapCollisionData, VMAP::AreaAndLiquidData::areaInfo, LiquidData::DepthLevel, LiquidData::Entry, LiquidData::Flags, VMAP::AreaAndLiquidData::floorZ, StaticVMapCollisionData::GetAreaAndLiquidData(), GetAreaId(), GetGridTerrainData(), GetId(), MapCollisionData::GetStaticTree(), GROUND_HEIGHT_TOLERANCE, IsInWMOInterior(), LiquidData::Level, LIQUID_MAP_ABOVE_WATER, LIQUID_MAP_IN_WATER, LIQUID_MAP_NO_WATER, LIQUID_MAP_UNDER_WATER, LIQUID_MAP_WATER_WALK, VMAP::AreaAndLiquidData::liquidInfo, LOG_DEBUG, MAP_OUTLAND, sAreaTableStore, sLiquidTypeStore, and LiquidData::Status.

Referenced by PathGenerator::BuildPolyPath(), PathGenerator::GetNavTerrain(), GetWaterOrGroundLevel(), HasEnoughWater(), IsInWater(), IsUnderWater(), Spell::SelectImplicitCasterDestTargets(), and spell_spawn_blood_pool::SetDest().

◆ GetLoadedGridsCount()

uint32 Map::GetLoadedGridsCount ( )
3565{
3567}
uint32 GetLoadedGridsCount()
Definition MapGridManager.cpp:101

References _mapGridManager, and MapGridManager::GetLoadedGridsCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetMapCollisionData() [1/2]

◆ GetMapCollisionData() [2/2]

MapCollisionData const & Map::GetMapCollisionData ( ) const
inline
574{ return _mapCollisionData; }

References _mapCollisionData.

◆ GetMapDifficulty()

MapDifficulty const * Map::GetMapDifficulty ( ) const
2310{
2312}
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition DBCStores.cpp:761

References GetDifficulty(), GetId(), and GetMapDifficultyData().

Referenced by InstanceMap::GetMaxPlayers(), and InstanceMap::GetMaxResetDelay().

◆ GetMapGrid()

◆ GetMapName()

char const * Map::GetMapName ( ) const

◆ GetMinHeight()

float Map::GetMinHeight ( float  x,
float  y 
) const
1209{
1210 if (GridTerrainData const* grid = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1211 return grid->getMinHeight(x, y);
1212
1213 return MIN_HEIGHT;
1214}
#define MIN_HEIGHT
Definition GridTerrainData.h:29

References GetGridTerrainData(), and MIN_HEIGHT.

◆ GetObjectsStore()

◆ GetOrGenerateZoneDefaultWeather()

Weather * Map::GetOrGenerateZoneDefaultWeather ( uint32  zoneId)
3276{
3277 WeatherData const* weatherData = WeatherMgr::GetWeatherData(zoneId);
3278 if (!weatherData)
3279 return nullptr;
3280
3281 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
3282
3283 if (!info.DefaultWeather)
3284 {
3285 info.DefaultWeather = std::make_unique<Weather>(this, zoneId, weatherData);
3286 info.DefaultWeather->ReGenerate();
3287 info.DefaultWeather->UpdateWeather();
3288 }
3289
3290 return info.DefaultWeather.get();
3291}
ZoneDynamicInfoMap _zoneDynamicInfo
Definition Map.h:679
WeatherData const * GetWeatherData(uint32 zone_id)
Definition WeatherMgr.cpp:39
Definition Weather.h:40
Definition Map.h:138
std::unique_ptr< Weather > DefaultWeather
Definition Map.h:142

References _zoneDynamicInfo, ZoneDynamicInfo::DefaultWeather, and WeatherMgr::GetWeatherData().

Referenced by misc_commandscript::HandleChangeWeather(), npc_herald_of_the_lich_king::UpdateWeather(), npc_pallid_horror::UpdateWeather(), and Player::UpdateZone().

◆ GetParent()

Map const * Map::GetParent ( ) const
inline
236{ return m_parentMap; }

References m_parentMap.

Referenced by MapGridManager::CreateGrid(), and GridTerrainLoader::LoadMap().

◆ GetPet()

Pet * Map::GetPet ( ObjectGuid const &  guid)
2425{
2426 return dynamic_cast<Pet*>(_objectsStore.Find<Creature>(guid));
2427}
Definition Pet.h:41

References _objectsStore, and TypeUnorderedMapContainer< OBJECT_TYPES, KEY_TYPE >::Find().

Referenced by ObjectAccessor::GetPet(), and ScriptsProcess().

◆ GetPlayerCountInZone()

uint32 Map::GetPlayerCountInZone ( uint32  zoneId) const
inline
566 {
567 if (auto const& it = _zonePlayerCountMap.find(zoneId); it != _zonePlayerCountMap.end())
568 return it->second;
569
570 return 0;
571 };

References _zonePlayerCountMap.

Referenced by debug_commandscript::HandleDebugZoneStatsCommand().

◆ GetPlayers()

PlayerList const & Map::GetPlayers ( ) const
inline
335{ return m_mapRefMgr; }
MapRefMgr m_mapRefMgr
Definition Map.h:615

References m_mapRefMgr.

Referenced by AddToMap(), MotionTransport::BuildUpdate(), StaticTransport::BuildUpdate(), InstanceMap::CannotEnter(), boss_professor_putricide::boss_professor_putricideAI::ChangePhase(), boss_gothik::boss_gothikAI::CheckGroupSplitted(), boss_volazj::CheckPhaseMinions(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::ChromieWhisper(), npc_arthas::npc_arthasAI::DoAction(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::DoCheckDedicatedInsanity(), boss_algalon_the_observer::DoCheckHeraldOfTheTitans(), DoForAllPlayers(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::DoNeedCleanup(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::DoNeedCleanup(), ScriptedAI::DoPlayMusic(), InstanceScript::DoSendNotifyToInstance(), ScriptedAI::DoTeleportAll(), boss_icehowl::boss_icehowlAI::DoTrampleIfValid(), InstanceScript::DoUpdateWorldState(), CreatureAI::DoZoneInCombat(), boss_sapphiron::boss_sapphironAI::EnterCombatSelfFunction(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::EnterEvadeMode(), boss_thorim::GetArenaPlayer(), spell_teron_gorefiend_shadowy_construct::HandleEffectApply(), spell_valkyr_touch_aura::HandleEffectPeriodic(), MotionTransport::HandleFirstDepartureSync(), spell_yogg_saron_brain_link_aura::HandleOnEffectApply(), WorldSession::HandleSetRaidDifficultyOpcode(), boss_ichoron::IchoronDoCastToAllHostilePlayers(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::InstanceCleanup(), boss_halion::boss_halionAI::IsAnyPlayerValid(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::IsEncounterInProgress(), boss_apothecary_hummel::boss_apothecary_hummelAI::JustDied(), npc_coren_direbrew::JustDied(), boss_headless_horseman::JustDied(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::JustDied(), boss_yoggsaron::JustDied(), boss_ahune::JustDied(), boss_lady_deathwhisper::boss_lady_deathwhisperAI::JustSummoned(), boss_gothik::boss_gothikAI::JustSummoned(), LogEncounterFinished(), WorldSession::LogoutPlayer(), npc_image_of_medivh::npc_image_of_medivhAI::NextStep(), spell_hor_shared_suffering_aura::OnRemove(), PlayDirectSoundToMap(), SmartScript::ProcessAction(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::RemoveBackPack(), RemoveFromMap(), boss_krystallus::boss_krystallusAI::RemoveStonedEffect(), instance_blackrock_depths::ReplaceMoiraIfSaved(), boss_volazj::ResetPlayersPhaseMask(), boss_yoggsaron_constrictor_tentacle::SelectConstrictTarget(), boss_yoggsaron_corruptor_tentacle::SelectCorruptionTarget(), boss_gluth::boss_gluthAI::SelectPlayerInRoom(), boss_thorim_arena_npcs::SelectT(), spell_gen_rallying_cry_of_the_dragonslayer::SelectTarget(), ScriptedAI::SelectTargetFromPlayerList(), CreatureTextMgr::SendChatPacket(), CreatureTextMgr::SendNonChatPacket(), SendPacketToPlayers(), npc_highlord_darion_mograine::SendUpdateWorldState(), SendZoneMessage(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::SetData(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SetData(), GameObject::SetLootRecipient(), Creature::SetLootRecipient(), boss_hodir::SpawnHelpers(), instance_stratholme::instance_stratholme_InstanceMapScript::Update(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::Update(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::Update(), instance_halls_of_reflection::Update(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::Update(), instance_vault_of_archavon::instance_vault_of_archavon_InstanceMapScript::Update(), boss_chromaggus::UpdateAI(), npc_highlord_darion_mograine::UpdateAI(), npc_thrall_old_hillsbrad::npc_thrall_old_hillsbradAI::UpdateAI(), npc_toc5_grand_champion_minion::npc_toc5_grand_champion_minionAI::UpdateAI(), boss_grand_champion::boss_grand_championAI::UpdateAI(), npc_snobold_vassal::npc_snobold_vassalAI::UpdateAI(), boss_gormok::boss_gormokAI::UpdateAI(), boss_twin_valkyrAI::UpdateAI(), npc_hor_lich_king::UpdateAI(), npc_hor_leader_second::npc_hor_leader_secondAI::UpdateAI(), boss_blood_queen_lana_thel::boss_blood_queen_lana_thelAI::UpdateAI(), boss_deathbringer_saurfang::boss_deathbringer_saurfangAI::UpdateAI(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::UpdateAI(), npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::UpdateAI(), npc_gunship_boarding_addAI::UpdateAI(), npc_gunship_gunner::npc_gunship_gunnerAI::UpdateAI(), boss_lady_deathwhisper::boss_lady_deathwhisperAI::UpdateAI(), boss_the_lich_king::boss_the_lich_kingAI::UpdateAI(), npc_tirion_fordring_tft::npc_tirion_fordringAI::UpdateAI(), npc_icc_gauntlet_controller::npc_icc_gauntlet_controllerAI::UpdateAI(), npc_icc_putricades_trap::npc_icc_putricades_trapAI::UpdateAI(), boss_gothik::boss_gothikAI::UpdateAI(), boss_sapphiron::boss_sapphironAI::UpdateAI(), boss_keristrasza::UpdateAI(), boss_freya::UpdateAI(), boss_vezax::UpdateAI(), boss_hodir::UpdateAI(), boss_ignis::UpdateAI(), boss_mimiron::UpdateAI(), npc_ulduar_leviathan_mkii::UpdateAI(), npc_ulduar_flames_initial::UpdateAI(), UpdateEncounterState(), npc_grimstone::UpdateEscortAI(), npc_varian_wrynn::npc_varian_wrynnAI::UpdateWorldState(), and npc_thrall_bfu::npc_thrall_bfuAI::UpdateWorldState().

◆ GetPlayersCountExceptGMs()

◆ GetPoolData() [1/2]

◆ GetPoolData() [2/2]

SpawnedPoolData const & Map::GetPoolData ( ) const
inline
385{ return *_poolData; }

References _poolData.

◆ GetRespawnTime()

time_t Map::GetRespawnTime ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId 
) const
inline
455 {
456 switch (type)
457 {
459 return GetCreatureRespawnTime(spawnId);
461 return GetGORespawnTime(spawnId);
462 default:
463 return time_t(0);
464 }
465 }
@ SPAWN_TYPE_GAMEOBJECT
Definition SpawnData.h:28
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:27

References GetCreatureRespawnTime(), GetGORespawnTime(), SPAWN_TYPE_CREATURE, and SPAWN_TYPE_GAMEOBJECT.

Referenced by SpawnGroupSpawn().

◆ GetSpawnMode()

◆ GetTransport()

Transport * Map::GetTransport ( ObjectGuid const &  guid)

◆ GetTransportForPos()

Transport * Map::GetTransportForPos ( uint32  phase,
float  x,
float  y,
float  z,
WorldObject worldobject = nullptr 
)
1140{
1141 G3D::Vector3 v(x, y, z + 2.0f);
1142 G3D::Ray r(v, G3D::Vector3(0, 0, -1));
1143 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1144 if ((*itr)->IsInWorld() && (*itr)->GetExactDistSq(x, y, z) < 75.0f * 75.0f && (*itr)->m_model)
1145 {
1146 float dist = 30.0f;
1147 bool hit = (*itr)->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
1148 if (hit)
1149 return *itr;
1150 }
1151
1152 if (worldobject)
1153 if (GameObject* staticTrans = worldobject->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_TRANSPORT, 75.0f))
1154 if (staticTrans->m_model)
1155 {
1156 float dist = 10.0f;
1157 bool hit = staticTrans->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
1158 if (hit)
1159 if (GetHeight(phase, x, y, z, true, 30.0f) < (v.z - dist + 1.0f))
1160 return staticTrans->ToTransport();
1161 }
1162
1163 return nullptr;
1164}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1575
GameObject * FindNearestGameObjectOfType(GameobjectTypes type, float range) const
Definition Object.cpp:2571

References _transports, WorldObject::FindNearestGameObjectOfType(), GAMEOBJECT_TYPE_TRANSPORT, GetHeight(), and VMAP::Nothing.

Referenced by AddToMap(), and Creature::Update().

◆ GetUpdatableObjectsCount()

size_t Map::GetUpdatableObjectsCount ( ) const
inline

◆ GetVisibilityRange()

◆ GetWaterLevel()

float Map::GetWaterLevel ( float  x,
float  y 
) const
1538{
1539 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1540 return gmap->getLiquidLevel(x, y);
1541
1542 return INVALID_HEIGHT;
1543}

References GetGridTerrainData(), and INVALID_HEIGHT.

Referenced by go_commandscript::HandleGoGridCommand(), go_commandscript::HandleGoXYZCommand(), and go_commandscript::HandleGoZoneXYCommand().

◆ GetWaterOrGroundLevel()

float Map::GetWaterOrGroundLevel ( uint32  phasemask,
float  x,
float  y,
float  z,
float *  ground = nullptr,
bool  swim = false,
float  collisionHeight = DEFAULT_COLLISION_HEIGHT 
) const
1119{
1120 // we need ground level (including grid height version) for proper return water level in point
1121 float ground_z = GetHeight(phasemask, x, y, z + Z_OFFSET_FIND_HEIGHT, true, 50.0f);
1122 if (ground)
1123 *ground = ground_z;
1124
1125 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phasemask, x, y, ground_z, collisionHeight, {});
1126 switch (liquidData.Status)
1127 {
1129 return std::max<float>(liquidData.Level, ground_z);
1131 return ground_z;
1132 default:
1133 return liquidData.Level;
1134 }
1135
1137}
constexpr float Z_OFFSET_FIND_HEIGHT
Definition SharedDefines.h:27
LiquidData const GetLiquidData(uint32 phaseMask, float x, float y, float z, float collisionHeight, Optional< uint8 > ReqLiquidType)
Definition Map.cpp:1314

References GetHeight(), GetLiquidData(), LiquidData::Level, LIQUID_MAP_ABOVE_WATER, LIQUID_MAP_NO_WATER, LiquidData::Status, VMAP_INVALID_HEIGHT_VALUE, and Z_OFFSET_FIND_HEIGHT.

Referenced by WorldObject::GetMapWaterOrGroundLevel().

◆ GetZoneAndAreaId()

void Map::GetZoneAndAreaId ( uint32  phaseMask,
uint32 zoneid,
uint32 areaid,
float  x,
float  y,
float  z 
) const
1307{
1308 areaid = zoneid = GetAreaId(phaseMask, x, y, z);
1309 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
1310 if (area->zone)
1311 zoneid = area->zone;
1312}

References GetAreaId(), and sAreaTableStore.

Referenced by WorldObject::AddToWorld(), and MapMgr::GetZoneAndAreaId().

◆ GetZoneId()

uint32 Map::GetZoneId ( uint32  phaseMask,
float  x,
float  y,
float  z 
) const
1297{
1298 uint32 areaId = GetAreaId(phaseMask, x, y, z);
1299 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
1300 if (area->zone)
1301 return area->zone;
1302
1303 return areaId;
1304}

References GetAreaId(), and sAreaTableStore.

Referenced by MapMgr::GetZoneId().

◆ GetZoneWideVisibleWorldObjectsForZone()

ZoneWideVisibleWorldObjectsSet const * Map::GetZoneWideVisibleWorldObjectsForZone ( uint32  zoneId) const
690{
691 ZoneWideVisibleWorldObjectsMap::const_iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
692 if (itr == _zoneWideVisibleWorldObjectsMap.end())
693 return nullptr;
694
695 return &itr->second;
696}

References _zoneWideVisibleWorldObjectsMap.

Referenced by debug_commandscript::HandleDebugVisibilityDataCommand(), and Acore::VisibleNotifier::SendToSelf().

◆ HandleDelayedVisibility()

void Map::HandleDelayedVisibility ( )
699{
701 return;
702 for (std::unordered_set<Unit*>::iterator itr = i_objectsForDelayedVisibility.begin(); itr != i_objectsForDelayedVisibility.end(); ++itr)
703 (*itr)->ExecuteDelayedUnitRelocationEvent();
705}
std::unordered_set< Unit * > i_objectsForDelayedVisibility
Definition Map.h:239

References i_objectsForDelayedVisibility.

Referenced by Update().

◆ HasEnoughWater() [1/2]

bool Map::HasEnoughWater ( WorldObject const *  searcher,
float  x,
float  y,
float  z 
) const
1606{
1607 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(
1608 searcher->GetPhaseMask(), x, y, z, searcher->GetCollisionHeight(), MAP_ALL_LIQUIDS);
1609
1610 if ((liquidData.Status & MAP_LIQUID_STATUS_SWIMMING) == 0)
1611 return false;
1612
1613 float minHeightInWater = searcher->GetMinHeightInWater();
1614 return liquidData.Level > INVALID_HEIGHT &&
1615 liquidData.Level > liquidData.DepthLevel &&
1616 liquidData.Level - liquidData.DepthLevel >= minHeightInWater;
1617}
#define MAP_ALL_LIQUIDS
Definition GridTerrainData.h:40
#define MAP_LIQUID_STATUS_SWIMMING
Definition GridTerrainData.h:31

References LiquidData::DepthLevel, WorldObject::GetCollisionHeight(), GetLiquidData(), WorldObject::GetMinHeightInWater(), WorldObject::GetPhaseMask(), INVALID_HEIGHT, LiquidData::Level, MAP_ALL_LIQUIDS, MAP_LIQUID_STATUS_SWIMMING, and LiquidData::Status.

Referenced by CanReachPositionAndGetValidCoords().

◆ HasEnoughWater() [2/2]

bool Map::HasEnoughWater ( WorldObject const *  searcher,
LiquidData const &  liquidData 
) const

◆ HavePlayers()

◆ InitializeObject() [1/3]

template<>
void Map::InitializeObject ( Creature )
296{
297 //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
298}

◆ InitializeObject() [2/3]

template<>
void Map::InitializeObject ( GameObject )
302{
303 //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
304}

◆ InitializeObject() [3/3]

template<class T >
void Map::InitializeObject ( T *  obj)
private
291{
292}

Referenced by AddToMap().

◆ InitVisibilityDistance()

void Map::InitVisibilityDistance ( )
virtual

Reimplemented in InstanceMap, BattlegroundMap, and MapInstanced.

99{
100 //init visibility for continents
102
103 switch (GetId())
104 {
105 case MAP_EBON_HOLD: // Scarlet Enclave (DK starting zone)
106 m_VisibleDistance = 125.0f;
107 break;
108 case MAP_SCOTT_TEST: // (box map)
109 m_VisibleDistance = 200.0f;
110 break;
111 }
112}
@ MAP_EBON_HOLD
Definition AreaDefines.h:260
@ MAP_SCOTT_TEST
Definition AreaDefines.h:188
static float GetMaxVisibleDistanceOnContinents()
Definition World.h:213

References GetId(), World::GetMaxVisibleDistanceOnContinents(), m_VisibleDistance, MAP_EBON_HOLD, and MAP_SCOTT_TEST.

Referenced by MapInstanced::InitVisibilityDistance(), and Map().

◆ InsertGameObjectModel()

void Map::InsertGameObjectModel ( GameObjectModel const &  model)
inline

◆ Instanceable()

◆ Is25ManRaid()

◆ IsBattleArena()

◆ IsBattleground()

bool Map::IsBattleground ( ) const
inline

◆ IsBattlegroundOrArena()

◆ isCellMarked()

bool Map::isCellMarked ( uint32  pCellId)
inline
321{ return marked_cells.test(pCellId); }
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition Map.h:635

References marked_cells.

◆ IsDungeon()

bool Map::IsDungeon ( ) const
inline
299{ return i_mapEntry && i_mapEntry->IsDungeon(); }
bool IsDungeon() const
Definition DBCStructure.h:1351

References i_mapEntry, and MapEntry::IsDungeon().

Referenced by Group::_cancelHomebindIfInstance(), Group::_homebindIfInstance(), InstanceSaveMgr::_ResetOrWarnAll(), InstanceMap::AddPlayerToMap(), GameObject::AddToSkillupList(), Spell::CheckCast(), TransportMgr::CreateTransport(), ScriptedAI::DoTeleportAll(), CreatureAI::DoZoneInCombat(), Spell::EffectSanctuary(), Spell::EffectTeleportUnits(), UnitAI::EvadeTimerExpired(), SmartScript::FillScript(), WorldObject::GetInstanceScript(), Unit::GetMeleeAttackPoint(), SpellMgr::GetSpellIdForDifficulty(), misc_commandscript::HandleAppearCommand(), WorldSession::HandleAreaTriggerOpcode(), spell_freezing_circle::HandleDamage(), spell_item_nitro_boots::HandleDummy(), instance_commandscript::HandleInstanceSaveDataCommand(), WorldSession::HandleSetDungeonDifficultyOpcode(), WorldSession::HandleSetRaidDifficultyOpcode(), misc_commandscript::HandleSummonCommand(), InstanceSave::InsertToDB(), Player::IsAtGroupRewardDistance(), boss_ossirian::JustEngagedWith(), Unit::Kill(), WorldSession::LogoutPlayer(), Condition::Meets(), AchievementCriteriaData::Meets(), npc_image_of_medivh::npc_image_of_medivhAI::NextStep(), InstanceMap::PermBindAllPlayers(), SmartScript::ProcessAction(), boss_krystallus::boss_krystallusAI::RemoveStonedEffect(), CreatureTextMgr::SendChatPacket(), Player::SetEntryPoint(), Creature::SetLootRecipient(), lfg::LFGMgr::TeleportPlayer(), ToInstanceMap(), ToInstanceMap(), and AchievementMgr::UpdateAchievementCriteria().

◆ IsGridCreated() [1/2]

bool Map::IsGridCreated ( float  x,
float  y 
) const
inline
220 {
222 }
bool IsGridCreated(GridCoord const &gridCoord) const
Definition Map.cpp:211

References Acore::ComputeGridCoord(), and IsGridCreated().

◆ IsGridCreated() [2/2]

bool Map::IsGridCreated ( GridCoord const &  gridCoord) const
212{
213 return _mapGridManager.IsGridCreated(gridCoord.x_coord, gridCoord.y_coord);
214}
bool IsGridCreated(uint16 const x, uint16 const y) const
Definition MapGridManager.cpp:72

References _mapGridManager, MapGridManager::IsGridCreated(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by IsGridCreated().

◆ IsGridLoaded() [1/2]

bool Map::IsGridLoaded ( float  x,
float  y 
) const
inline
215 {
217 }

References Acore::ComputeGridCoord(), and IsGridLoaded().

◆ IsGridLoaded() [2/2]

◆ IsHeroic()

bool Map::IsHeroic ( ) const
inline
@ DUNGEON_DIFFICULTY_HEROIC
Definition DBCEnums.h:270
@ RAID_DIFFICULTY_10MAN_HEROIC
Definition DBCEnums.h:275

References DUNGEON_DIFFICULTY_HEROIC, i_spawnMode, IsRaid(), and RAID_DIFFICULTY_10MAN_HEROIC.

Referenced by spell_svala_ritual_strike_aura::CalculateAmount(), boss_eregos::boss_eregosAI::DamageTaken(), npc_molten_golem::DamageTaken(), npc_orb_carrier::npc_orb_carrierAI::DoAction(), brann_bronzebeard::EndTribunalFight(), BattleExperienceEvent::Execute(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::GetData(), spell_freezing_circle::HandleDamage(), instance_commandscript::HandleInstanceGetBossStateCommand(), spell_prince_taldaram_conjure_flame_sphere::HandleScript(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::InstanceCleanup(), npc_valkyr_shadowguard::npc_valkyr_shadowguardAI::IsHeroic(), npc_strangulate_vehicle::npc_strangulate_vehicleAI::IsHeroic(), boss_krystallus::boss_krystallusAI::JustEngagedWith(), npc_tirion_fordring_tft::npc_tirion_fordringAI::JustReachedHome(), npc_frost_tomb::npc_frost_tomb(), instance_gundrak::instance_gundrak_InstanceMapScript::OnGameObjectCreate(), instance_gundrak::instance_gundrak_InstanceMapScript::OnGameObjectRemove(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::OnPlayerEnter(), at_shattered_halls_execution::OnTrigger(), instance_gundrak::instance_gundrak_InstanceMapScript::OnUnitDeath(), spell_blood_queen_pact_of_the_darkfallen_dmg_aura::PeriodicTick(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::ReadSaveDataMore(), npc_tirion_fordring_tft::npc_tirion_fordringAI::Reset(), brann_bronzebeard::SchedulePhaseAbilities(), ScriptedAI::ScriptedAI(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetBossState(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::SetData(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SetData(), instance_oculus::instance_oculus_InstanceMapScript::SetData(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::SetData(), npc_tirion_fordring_tft::npc_tirion_fordringAI::sGossipSelect(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::Update(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::Update(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::Update(), npc_time_rift::UpdateAI(), UpdateEncounterState(), instance_halls_of_reflection::UpdateOutro(), and instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::WriteSaveDataMore().

◆ isInLineOfSight()

bool Map::isInLineOfSight ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
uint32  phasemask,
LineOfSightChecks  checks,
VMAP::ModelIgnoreFlags  ignoreFlags 
) const
1546{
1547 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_PVP_LOS))
1548 {
1550 {
1551 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1552 }
1553 }
1554
1555 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD))
1556 {
1557 if (IsWorldMap())
1558 {
1559 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1560 }
1561 }
1562
1563 if ((checks & LINEOFSIGHT_CHECK_VMAP) && !_mapCollisionData.GetStaticTree().isInLineOfSight(x1, y1, z1, x2, y2, z2, ignoreFlags))
1564 {
1565 return false;
1566 }
1567
1568 if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT_ALL))
1569 {
1570 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1571 if (!(checks & LINEOFSIGHT_CHECK_GOBJECT_M2))
1572 {
1573 ignoreFlags = VMAP::ModelIgnoreFlags::M2;
1574 }
1575
1576 if (!_mapCollisionData.GetDynamicTree().isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask, ignoreFlags))
1577 {
1578 return false;
1579 }
1580 }
1581
1582 return true;
1583}
@ LINEOFSIGHT_CHECK_GOBJECT_M2
Definition Map.h:111
@ LINEOFSIGHT_CHECK_VMAP
Definition Map.h:109
@ LINEOFSIGHT_CHECK_GOBJECT_ALL
Definition Map.h:113
@ CONFIG_CHECK_GOBJECT_LOS
Definition WorldConfig.h:116
@ CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD
Definition WorldConfig.h:138
@ CONFIG_VMAP_BLIZZLIKE_PVP_LOS
Definition WorldConfig.h:137
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, VMAP::ModelIgnoreFlags ignoreFlags) const
Definition DynamicTree.cpp:257
bool IsWorldMap() const
Definition Map.h:308
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, VMAP::ModelIgnoreFlags ignoreFlags) const
Definition MapCollisionData.cpp:71

References _mapCollisionData, CONFIG_CHECK_GOBJECT_LOS, CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD, CONFIG_VMAP_BLIZZLIKE_PVP_LOS, MapCollisionData::GetDynamicTree(), MapCollisionData::GetStaticTree(), IsBattlegroundOrArena(), DynamicMapTree::isInLineOfSight(), StaticVMapCollisionData::isInLineOfSight(), IsWorldMap(), LINEOFSIGHT_CHECK_GOBJECT_ALL, LINEOFSIGHT_CHECK_GOBJECT_M2, LINEOFSIGHT_CHECK_VMAP, VMAP::M2, VMAP::Nothing, and sWorld.

Referenced by Unit::_ExitVehicle(), RandomMovementGenerator< T >::_setRandomLocation(), WorldObject::IsWithinLOS(), WorldObject::IsWithinLOSInMap(), npc_ulduar_snow_mound::MoveInLineOfSight(), spell_blood_council_summon_shadow_resonance::SetDest(), and PathGenerator::ShortenPathUntilDist().

◆ IsInWater()

bool Map::IsInWater ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight 
) const
1594{
1595 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phaseMask, x, y, pZ, collisionHeight, {});
1596 return (liquidData.Status & MAP_LIQUID_STATUS_SWIMMING) != 0;
1597}

References GetLiquidData(), MAP_LIQUID_STATUS_SWIMMING, and LiquidData::Status.

Referenced by CheckCollisionAndGetValidCoords(), ConfusedMovementGenerator< T >::DoInitialize(), PathGenerator::IsSwimmableSegment(), and Spell::SelectImplicitCasterDestTargets().

◆ IsNonRaidDungeon()

bool Map::IsNonRaidDungeon ( ) const
inline
300{ return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); }
bool IsNonRaidDungeon() const
Definition DBCStructure.h:1352

References i_mapEntry, and MapEntry::IsNonRaidDungeon().

Referenced by WorldSession::HandleSetDungeonDifficultyOpcode(), and Player::RewardReputation().

◆ IsPlayerRedirectKickTimerActive()

bool Map::IsPlayerRedirectKickTimerActive ( )
inline
332{ return !_redirectKickTimer.Passed(); }
TimeTrackerSmall _redirectKickTimer
Definition Map.h:710
bool Passed() const
Definition Timer.h:244

References _redirectKickTimer, and TimeTrackerSmall::Passed().

◆ IsRaid()

◆ IsRaidOrHeroicDungeon()

bool Map::IsRaidOrHeroicDungeon ( ) const
inline
@ DUNGEON_DIFFICULTY_NORMAL
Definition DBCEnums.h:269

References DUNGEON_DIFFICULTY_NORMAL, i_spawnMode, and IsRaid().

Referenced by Unit::Kill(), and WorldSession::LogoutPlayer().

◆ IsRegularDifficulty()

bool Map::IsRegularDifficulty ( ) const
inline
295{ return GetDifficulty() == REGULAR_DIFFICULTY; }
@ REGULAR_DIFFICULTY
Definition DBCEnums.h:267

References GetDifficulty(), and REGULAR_DIFFICULTY.

◆ IsSpawnGroupActive()

bool Map::IsSpawnGroupActive ( uint32  groupId) const
2597{
2598 SpawnGroupTemplateData const* data = sObjectMgr->GetSpawnGroupData(groupId);
2599 if (!data)
2600 return false;
2601
2602 // System groups are always active
2603 if (data->flags & SPAWNGROUP_FLAG_SYSTEM)
2604 return true;
2605
2606 // Per-map toggled state: XOR with default.
2607 // MANUAL_SPAWN groups default to inactive; toggling makes them active.
2608 // Non-MANUAL groups default to active; toggling makes them inactive.
2609 bool toggled = _toggledSpawnGroupIds.count(groupId) != 0;
2610 bool defaultActive = !(data->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN);
2611 return toggled != defaultActive; // XOR: toggled flips the default
2612}
@ SPAWNGROUP_FLAG_MANUAL_SPAWN
Definition SpawnData.h:46
@ SPAWNGROUP_FLAG_SYSTEM
Definition SpawnData.h:44
std::unordered_set< uint32 > _toggledSpawnGroupIds
Definition Map.h:674
Definition SpawnData.h:58
SpawnGroupFlags flags
Definition SpawnData.h:62

References _toggledSpawnGroupIds, SpawnGroupTemplateData::flags, sObjectMgr, SPAWNGROUP_FLAG_MANUAL_SPAWN, and SPAWNGROUP_FLAG_SYSTEM.

Referenced by GridObjectLoader::LoadCreatures(), GridObjectLoader::LoadGameObjects(), ProcessCreatureRespawn(), and ProcessGameObjectRespawn().

◆ IsUnderWater()

bool Map::IsUnderWater ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight 
) const
1600{
1601 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phaseMask, x, y, z, collisionHeight, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN);
1602 return liquidData.Status == LIQUID_MAP_UNDER_WATER;
1603}
#define MAP_LIQUID_TYPE_WATER
Definition GridTerrainData.h:35
#define MAP_LIQUID_TYPE_OCEAN
Definition GridTerrainData.h:36

References GetLiquidData(), LIQUID_MAP_UNDER_WATER, MAP_LIQUID_TYPE_OCEAN, MAP_LIQUID_TYPE_WATER, and LiquidData::Status.

Referenced by WorldSession::ProcessMovementInfo().

◆ IsWorldMap()

bool Map::IsWorldMap ( ) const
inline
308{ return i_mapEntry && i_mapEntry->IsWorldMap(); }
bool IsWorldMap() const
Definition DBCStructure.h:1358

References i_mapEntry, and MapEntry::IsWorldMap().

Referenced by isInLineOfSight().

◆ LoadAllGrids()

void Map::LoadAllGrids ( )
222{
223 for (uint32 cellX = 0; cellX < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellX++)
224 for (uint32 cellY = 0; cellY < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellY++)
226}
#define TOTAL_NUMBER_OF_CELLS_PER_MAP
Definition GridDefines.h:47
#define CENTER_GRID_CELL_ID
Definition GridDefines.h:44
#define SIZE_OF_GRID_CELL
Definition GridDefines.h:42
void LoadGrid(float x, float y)
Definition Map.cpp:216

References CENTER_GRID_CELL_ID, LoadGrid(), SIZE_OF_GRID_CELL, and TOTAL_NUMBER_OF_CELLS_PER_MAP.

Referenced by MapPreloadRequest::call(), OnCreateMap(), and World::SetInitialWorldSettings().

◆ LoadCorpseData()

void Map::LoadCorpseData ( )
3505{
3507 stmt->SetData(0, GetId());
3508 stmt->SetData(1, GetInstanceId());
3509
3510 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3511 // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
3512 PreparedQueryResult result = CharacterDatabase.Query(stmt);
3513 if (!result)
3514 return;
3515
3516 do
3517 {
3518 Field* fields = result->Fetch();
3519 CorpseType type = CorpseType(fields[13].Get<uint8>());
3520 uint32 guid = fields[16].Get<uint32>();
3521 if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
3522 {
3523 LOG_ERROR("maps", "Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
3524 continue;
3525 }
3526
3527 Corpse* corpse = new Corpse(type);
3528
3529 if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
3530 {
3531 delete corpse;
3532 continue;
3533 }
3534
3535 AddCorpse(corpse);
3536
3537 corpse->UpdatePositionData();
3538 } while (result->NextRow());
3539}
@ CHAR_SEL_CORPSES
Definition CharacterDatabase.h:247
CorpseType
Definition Corpse.h:27
#define MAX_CORPSE_TYPE
Definition Corpse.h:32
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field *fields)
Definition Corpse.cpp:131
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112

References AddCorpse(), CHAR_SEL_CORPSES, CharacterDatabase, CORPSE_BONES, Field::Get(), GetId(), GetInstanceId(), Corpse::LoadCorpseFromDB(), LOG_ERROR, MAX_CORPSE_TYPE, PreparedStatementBase::SetData(), and WorldObject::UpdatePositionData().

Referenced by MapMgr::CreateBaseMap().

◆ LoadGrid()

◆ LoadGridsInRange()

void Map::LoadGridsInRange ( Position const &  center,
float  radius 
)
229{
231 return;
232
233 float const x = center.GetPositionX();
234 float const y = center.GetPositionY();
235
236 CellCoord cellCoord(Acore::ComputeCellCoord(x, y));
237 if (!cellCoord.IsCoordValid())
238 return;
239
240 if (radius > SIZE_OF_GRIDS)
241 radius = SIZE_OF_GRIDS;
242
243 CellArea area = Cell::CalculateCellArea(x, y, radius);
244 if (!area)
245 return;
246
247 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
248 {
249 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
250 {
251 CellCoord cellCoord(x, y);
252 Cell cell(cellCoord);
253 EnsureGridLoaded(cell);
254 }
255 }
256}
#define SIZE_OF_GRIDS
Definition MapDefines.h:26
bool IsGridsFullyLoaded() const
Definition MapGridManager.cpp:134
Definition Cell.h:28
CellCoord high_bound
Definition Cell.h:41
CellCoord low_bound
Definition Cell.h:40
static CellArea CalculateCellArea(float x, float y, float radius)
Definition CellImpl.h:42

References _mapGridManager, Cell::CalculateCellArea(), Acore::ComputeCellCoord(), EnsureGridLoaded(), Position::GetPositionX(), Position::GetPositionY(), CellArea::high_bound, CoordPair< LIMIT >::IsCoordValid(), MapGridManager::IsGridsFullyLoaded(), CellArea::low_bound, SIZE_OF_GRIDS, CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by AddPlayerToMap(), Unit::ExecuteDelayedUnitRelocationEvent(), CinematicMgr::StartCinematicCamera(), and CinematicMgr::UpdateCinematic().

◆ LoadRespawnTimes()

void Map::LoadRespawnTimes ( )
2540{
2542 stmt->SetData(0, GetId());
2543 stmt->SetData(1, GetInstanceId());
2544 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2545 {
2546 do
2547 {
2548 Field* fields = result->Fetch();
2549 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
2550 time_t respawnTime = time_t(fields[1].Get<uint32>());
2551
2552 _creatureRespawnTimes[lowguid] = respawnTime;
2553 _respawnQueue.insert({respawnTime, SPAWN_TYPE_CREATURE, lowguid});
2554 } while (result->NextRow());
2555 }
2556
2557 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GO_RESPAWNS);
2558 stmt->SetData(0, GetId());
2559 stmt->SetData(1, GetInstanceId());
2560 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2561 {
2562 do
2563 {
2564 Field* fields = result->Fetch();
2565 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
2566 time_t respawnTime = time_t(fields[1].Get<uint32>());
2567
2568 _goRespawnTimes[lowguid] = respawnTime;
2569 _respawnQueue.insert({respawnTime, SPAWN_TYPE_GAMEOBJECT, lowguid});
2570 } while (result->NextRow());
2571 }
2572}
@ CHAR_SEL_CREATURE_RESPAWNS
Definition CharacterDatabase.h:253
@ CHAR_SEL_GO_RESPAWNS
Definition CharacterDatabase.h:258

References _creatureRespawnTimes, _goRespawnTimes, _respawnQueue, CHAR_SEL_CREATURE_RESPAWNS, CHAR_SEL_GO_RESPAWNS, CharacterDatabase, Field::Get(), GetId(), GetInstanceId(), PreparedStatementBase::SetData(), SPAWN_TYPE_CREATURE, and SPAWN_TYPE_GAMEOBJECT.

Referenced by MapMgr::CreateBaseMap().

◆ LogEncounterFinished()

void Map::LogEncounterFinished ( EncounterCreditType  type,
uint32  creditEntry 
)
2984{
2985 if (!IsRaid() || !GetEntry() || GetEntry()->Expansion() < 2) // only for wotlk raids, because logs take up tons of mysql memory
2986 return;
2987 InstanceMap* map = ToInstanceMap();
2988 if (!map)
2989 return;
2990 std::string playersInfo;
2991 char buffer[16384], buffer2[255];
2992 Map::PlayerList const& pl = map->GetPlayers();
2993 for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
2994 if (Player* p = itr->GetSource())
2995 {
2996 std::string auraStr;
2997 Unit::AuraApplicationMap const& a = p->GetAppliedAuras();
2998 for (auto iterator = a.begin(); iterator != a.end(); ++iterator)
2999 {
3000 snprintf(buffer2, 255, "%u(%u) ", iterator->first, iterator->second->GetEffectMask());
3001 auraStr += buffer2;
3002 }
3003
3004 snprintf(buffer, 16384, "%s (%s, acc: %u, ip: %s, guild: %u), xyz: (%.1f, %.1f, %.1f), auras: %s\n",
3005 p->GetName().c_str(), p->GetGUID().ToString().c_str(), p->GetSession()->GetAccountId(), p->GetSession()->GetRemoteAddress().c_str(), p->GetGuildId(), p->GetPositionX(), p->GetPositionY(), p->GetPositionZ(), auraStr.c_str());
3006 playersInfo += buffer;
3007 }
3008 CleanStringForMysqlQuery(playersInfo);
3009 CharacterDatabase.Execute("INSERT INTO log_encounter VALUES(NOW(), {}, {}, {}, {}, '{}')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo);
3010}
void CleanStringForMysqlQuery(std::string &str)
Definition Common.cpp:97
LinkedListHead::Iterator< GridReference< MapGridType > > iterator
Definition GridRefMgr.h:30
Definition Map.h:724
Definition MapRefMgr.h:26
iterator begin()
Definition MapRefMgr.h:36
InstanceMap * ToInstanceMap()
Definition Map.h:390
boost::container::flat_multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:674

References MapRefMgr::begin(), CharacterDatabase, CleanStringForMysqlQuery(), MapRefMgr::end(), GetDifficulty(), GetEntry(), GetId(), GetPlayers(), IsRaid(), and ToInstanceMap().

Referenced by UpdateEncounterState().

◆ markCell()

void Map::markCell ( uint32  pCellId)
inline
322{ marked_cells.set(pCellId); }

References marked_cells.

Referenced by MarkNearbyCellsOf().

◆ MarkNearbyCellsOf()

void Map::MarkNearbyCellsOf ( WorldObject obj)
401{
402 // Check for valid position
403 if (!obj->IsPositionValid())
404 return;
405
406 // Update mobs/objects in ALL visible cells around object!
408 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
409 {
410 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
411 {
412 // marked cells are those that have been visited
413 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
414 markCell(cell_id);
415 }
416 }
417}
void markCell(uint32 pCellId)
Definition Map.h:322
float GetGridActivationRange() const
Definition Object.cpp:1683
bool IsPositionValid() const
Definition Position.cpp:183

References Cell::CalculateCellArea(), WorldObject::GetGridActivationRange(), Position::GetPositionX(), Position::GetPositionY(), CellArea::high_bound, Position::IsPositionValid(), CellArea::low_bound, markCell(), TOTAL_NUMBER_OF_CELLS_PER_MAP, CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by Update().

◆ MoveAllCreaturesInMoveList()

void Map::MoveAllCreaturesInMoveList ( )
929{
930 for (std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr)
931 {
932 Creature* c = *itr;
933 if (c->FindMap() != this)
934 continue;
935
937 {
939 continue;
940 }
941
943 if (!c->IsInWorld())
944 continue;
945
946 Cell const& old_cell = c->GetCurrentCell();
947 Cell new_cell(c->GetPositionX(), c->GetPositionY());
948 if (c->IsFarVisible())
949 {
950 // Removes via GetCurrentCell, added back in AddToGrid
952 }
953
954 c->RemoveFromGrid();
955 if (old_cell.DiffGrid(new_cell))
956 EnsureGridLoaded(new_cell);
957 AddToGrid(c, new_cell);
958 }
959 _creaturesToMove.clear();
960}
void RemoveFromGrid()
Definition Object.h:374
void RemoveWorldObjectFromFarVisibleMap(WorldObject *obj)
Definition Map.cpp:658
Map * FindMap() const
Definition Object.h:632

References _creaturesToMove, MovableMapObject::_moveState, AddToGrid(), Cell::DiffGrid(), EnsureGridLoaded(), WorldObject::FindMap(), MovableMapObject::GetCurrentCell(), Position::GetPositionX(), Position::GetPositionY(), WorldObject::IsFarVisible(), Object::IsInWorld(), MAP_OBJECT_CELL_MOVE_ACTIVE, MAP_OBJECT_CELL_MOVE_NONE, GridObject< T >::RemoveFromGrid(), and RemoveWorldObjectFromFarVisibleMap().

Referenced by Update().

◆ MoveAllDynamicObjectsInMoveList()

void Map::MoveAllDynamicObjectsInMoveList ( )
998{
999 for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr)
1000 {
1001 DynamicObject* dynObj = *itr;
1002 if (dynObj->FindMap() != this)
1003 continue;
1004
1006 {
1008 continue;
1009 }
1010
1012 if (!dynObj->IsInWorld())
1013 continue;
1014
1015 Cell const& old_cell = dynObj->GetCurrentCell();
1016 Cell new_cell(dynObj->GetPositionX(), dynObj->GetPositionY());
1017
1018 dynObj->RemoveFromGrid();
1019 if (old_cell.DiffGrid(new_cell))
1020 EnsureGridLoaded(new_cell);
1021 AddToGrid(dynObj, new_cell);
1022 }
1023 _dynamicObjectsToMove.clear();
1024}

References _dynamicObjectsToMove, MovableMapObject::_moveState, AddToGrid(), Cell::DiffGrid(), EnsureGridLoaded(), WorldObject::FindMap(), MovableMapObject::GetCurrentCell(), Position::GetPositionX(), Position::GetPositionY(), Object::IsInWorld(), MAP_OBJECT_CELL_MOVE_ACTIVE, MAP_OBJECT_CELL_MOVE_NONE, and GridObject< T >::RemoveFromGrid().

Referenced by Update().

◆ MoveAllGameObjectsInMoveList()

void Map::MoveAllGameObjectsInMoveList ( )
963{
964 for (std::vector<GameObject*>::iterator itr = _gameObjectsToMove.begin(); itr != _gameObjectsToMove.end(); ++itr)
965 {
966 GameObject* go = *itr;
967 if (go->FindMap() != this)
968 continue;
969
971 {
973 continue;
974 }
975
977 if (!go->IsInWorld())
978 continue;
979
980 Cell const& old_cell = go->GetCurrentCell();
981 Cell new_cell(go->GetPositionX(), go->GetPositionY());
982
983 if (go->IsFarVisible())
984 {
985 // Removes via GetCurrentCell, added back in AddToGrid
987 }
988
989 go->RemoveFromGrid();
990 if (old_cell.DiffGrid(new_cell))
991 EnsureGridLoaded(new_cell);
992 AddToGrid(go, new_cell);
993 }
994 _gameObjectsToMove.clear();
995}

References _gameObjectsToMove, MovableMapObject::_moveState, AddToGrid(), Cell::DiffGrid(), EnsureGridLoaded(), WorldObject::FindMap(), MovableMapObject::GetCurrentCell(), Position::GetPositionX(), Position::GetPositionY(), WorldObject::IsFarVisible(), Object::IsInWorld(), MAP_OBJECT_CELL_MOVE_ACTIVE, MAP_OBJECT_CELL_MOVE_NONE, GridObject< T >::RemoveFromGrid(), and RemoveWorldObjectFromFarVisibleMap().

Referenced by Update().

◆ OnCreateMap()

void Map::OnCreateMap ( )
90{
91 // Instances load all grids by default (both base map and child maps)
92 if (GetInstanceId())
94
95 sScriptMgr->OnCreateMap(this);
96}
void LoadAllGrids()
Definition Map.cpp:221

References GetInstanceId(), LoadAllGrids(), and sScriptMgr.

Referenced by MapMgr::CreateBaseMap(), and MapInstanced::CreateBattleground().

◆ PlayDirectSoundToMap()

void Map::PlayDirectSoundToMap ( uint32  soundId,
uint32  zoneId = 0 
)
3253{
3254 Map::PlayerList const& players = GetPlayers();
3255 if (!players.IsEmpty())
3256 {
3258 data << uint32(soundId);
3259
3260 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3261 if (Player* player = itr->GetSource())
3262 if (!zoneId || player->GetZoneId() == zoneId)
3263 player->SendDirectMessage(&data);
3264 }
3265}
@ SMSG_PLAY_SOUND
Definition Opcodes.h:752

References MapRefMgr::begin(), MapRefMgr::end(), GetPlayers(), LinkedListHead::IsEmpty(), and SMSG_PLAY_SOUND.

Referenced by instance_naxxramas::Update().

◆ PlayerRelocation()

void Map::PlayerRelocation ( Player player,
float  x,
float  y,
float  z,
float  o 
)
805{
806 Cell old_cell(player->GetPositionX(), player->GetPositionY());
807 Cell new_cell(x, y);
808
809 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
810 {
811 player->RemoveFromGrid();
812
813 if (old_cell.DiffGrid(new_cell))
814 EnsureGridLoaded(new_cell);
815
816 AddToGrid(player, new_cell);
817 }
818
819 player->Relocate(x, y, z, o);
820 if (player->IsVehicle())
822 player->UpdatePositionData();
823 player->UpdateObjectVisibility(false);
824}

References AddToGrid(), Cell::DiffCell(), Cell::DiffGrid(), EnsureGridLoaded(), Position::GetPositionX(), Position::GetPositionY(), Unit::GetVehicleKit(), Unit::IsVehicle(), Position::Relocate(), Vehicle::RelocatePassengers(), GridObject< T >::RemoveFromGrid(), Player::UpdateObjectVisibility(), and WorldObject::UpdatePositionData().

Referenced by at_icc_saurfang_portal::OnTrigger(), StaticTransport::UpdatePassengerPositions(), MotionTransport::UpdatePassengerPositions(), and Unit::UpdatePosition().

◆ ProcessCreatureRespawn()

void Map::ProcessCreatureRespawn ( ObjectGuid::LowType  spawnId)
2784{
2785 // Pool members are handled entirely by the pool system on this map's pool data
2786 if (uint32 poolId = sPoolMgr->IsPartOfAPool<Creature>(spawnId))
2787 {
2788 sPoolMgr->UpdatePool<Creature>(GetPoolData(), poolId, spawnId);
2790 return;
2791 }
2792
2793 CreatureData const* data = sObjectMgr->GetCreatureData(spawnId);
2794 if (!data)
2795 {
2797 return;
2798 }
2799
2800 // Compat-mode creatures handle their own respawn in-place — don't interfere.
2801 // Clean up the stale respawn time entry since the legacy system manages these.
2802 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(data->spawnGroupId);
2803 if (!groupData || (groupData->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE))
2804 {
2806 return;
2807 }
2808
2809 // Don't respawn if the spawn group is not active
2810 if (!IsSpawnGroupActive(data->spawnGroupId))
2811 {
2812 // Re-queue — will be checked again next ProcessRespawns() tick
2813 _respawnQueue.insert({GameTime::GetGameTime().count() + 5, SPAWN_TYPE_CREATURE, spawnId});
2814 return;
2815 }
2816
2817 // Skip if grid isn't loaded (will be handled in grid loader)
2818 if (!IsGridLoaded(data->posX, data->posY))
2819 {
2820 _respawnQueue.insert({GameTime::GetGameTime().count() + 5, SPAWN_TYPE_CREATURE, spawnId});
2821 return;
2822 }
2823
2824 // Skip if already alive
2825 auto bounds = _creatureBySpawnIdStore.equal_range(spawnId);
2826 for (auto itr = bounds.first; itr != bounds.second; ++itr)
2827 {
2828 if (itr->second->IsAlive())
2829 {
2831 return;
2832 }
2833 }
2834
2835 // Check linked_respawn: don't spawn if the master creature is still dead.
2836 // This mirrors the check in Creature::Respawn() for compat-mode creatures:
2837 // hard-reset creatures bypass it (they despawn on evade and must always
2838 // come back), and a creature linked to itself never auto-respawns.
2839 ObjectGuid dbtableHighGuid = ObjectGuid::Create<HighGuid::Unit>(data->id, spawnId);
2840 time_t linkedRespawntime = GetLinkedRespawnTime(dbtableHighGuid);
2841 CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(data->id);
2842 if (linkedRespawntime && !(cInfo && cInfo->HasFlagsExtra(CREATURE_FLAG_EXTRA_HARD_RESET)))
2843 {
2844 time_t now = GameTime::GetGameTime().count();
2845 time_t newRespawnTime;
2846 if (sObjectMgr->GetLinkedRespawnGuid(dbtableHighGuid) == dbtableHighGuid)
2847 newRespawnTime = now + DAY; // if linking self, never respawn (check delayed to next day)
2848 else
2849 newRespawnTime = (now > linkedRespawntime ? now : linkedRespawntime) + urand(5, MINUTE); // master is still dead; re-queue at the master's respawn time + a small offset
2850 SaveCreatureRespawnTime(spawnId, newRespawnTime);
2851 return;
2852 }
2853
2854 // Remove respawn time BEFORE LoadFromDB, otherwise the creature
2855 // reads it back and loads as DEAD instead of ALIVE
2857
2858 Creature* creature = new Creature();
2859 if (!creature->LoadCreatureFromDB(spawnId, this, true, true))
2860 delete creature;
2861}
constexpr auto DAY
Definition Common.h:49
@ CREATURE_FLAG_EXTRA_HARD_RESET
Definition CreatureData.h:77
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
@ SPAWNGROUP_FLAG_COMPATIBILITY_MODE
Definition SpawnData.h:45
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true, bool allowDuplicate=false)
Definition Creature.cpp:1677
void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2478
time_t GetLinkedRespawnTime(ObjectGuid guid) const
Definition Map.cpp:3028
void SaveCreatureRespawnTime(ObjectGuid::LowType dbGuid, time_t &respawnTime)
Definition Map.cpp:2449
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:2596
SpawnedPoolData & GetPoolData()
Definition Map.h:384
Seconds GetGameTime()
Definition GameTime.cpp:38
Definition CreatureData.h:370
uint32 id
Definition CreatureData.h:372
Definition CreatureData.h:187
bool HasFlagsExtra(uint32 flag) const
Definition CreatureData.h:278
float posX
Definition SpawnData.h:71
float posY
Definition SpawnData.h:72
uint32 spawnGroupId
Definition SpawnData.h:78

References _creatureBySpawnIdStore, _respawnQueue, CREATURE_FLAG_EXTRA_HARD_RESET, DAY, SpawnGroupTemplateData::flags, GameTime::GetGameTime(), GetLinkedRespawnTime(), GetPoolData(), CreatureTemplate::HasFlagsExtra(), CreatureData::id, IsGridLoaded(), IsSpawnGroupActive(), Creature::LoadCreatureFromDB(), MINUTE, SpawnData::posX, SpawnData::posY, RemoveCreatureRespawnTime(), SaveCreatureRespawnTime(), sObjectMgr, SPAWN_TYPE_CREATURE, SPAWNGROUP_FLAG_COMPATIBILITY_MODE, SpawnData::spawnGroupId, sPoolMgr, and urand().

Referenced by ProcessRespawns().

◆ ProcessGameObjectRespawn()

void Map::ProcessGameObjectRespawn ( ObjectGuid::LowType  spawnId)
2864{
2865 // Pool members are handled entirely by the pool system on this map's pool data
2866 if (uint32 poolId = sPoolMgr->IsPartOfAPool<GameObject>(spawnId))
2867 {
2868 sPoolMgr->UpdatePool<GameObject>(GetPoolData(), poolId, spawnId);
2869 RemoveGORespawnTime(spawnId);
2870 return;
2871 }
2872
2873 GameObjectData const* data = sObjectMgr->GetGameObjectData(spawnId);
2874 if (!data)
2875 {
2876 RemoveGORespawnTime(spawnId);
2877 return;
2878 }
2879
2880 // Compat-mode gameobjects handle their own respawn — don't interfere.
2881 // Clean up the stale respawn time entry since the legacy system manages these.
2882 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(data->spawnGroupId);
2883 if (!groupData || (groupData->flags & SPAWNGROUP_FLAG_COMPATIBILITY_MODE))
2884 {
2885 RemoveGORespawnTime(spawnId);
2886 return;
2887 }
2888
2889 // Don't respawn if the spawn group is not active
2890 if (!IsSpawnGroupActive(data->spawnGroupId))
2891 {
2892 _respawnQueue.insert({GameTime::GetGameTime().count() + 5, SPAWN_TYPE_GAMEOBJECT, spawnId});
2893 return;
2894 }
2895
2896 // Skip if grid isn't loaded (will be handled in grid loader)
2897 if (!IsGridLoaded(data->posX, data->posY))
2898 {
2899 _respawnQueue.insert({GameTime::GetGameTime().count() + 5, SPAWN_TYPE_GAMEOBJECT, spawnId});
2900 return;
2901 }
2902
2903 if (_gameobjectBySpawnIdStore.count(spawnId))
2904 {
2905 RemoveGORespawnTime(spawnId);
2906 return;
2907 }
2908
2909 // Remove respawn time BEFORE LoadFromDB, otherwise the GO
2910 // reads it back and loads as despawned
2911 RemoveGORespawnTime(spawnId);
2912
2913 GameObject* gameobject = new GameObject();
2914 if (!gameobject->LoadGameObjectFromDB(spawnId, this, true))
2915 delete gameobject;
2916}
virtual bool LoadGameObjectFromDB(ObjectGuid::LowType guid, Map *map, bool addToMap=true)
Definition GameObject.cpp:1102
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2523
Definition GameObjectData.h:715

References _gameobjectBySpawnIdStore, _respawnQueue, SpawnGroupTemplateData::flags, GameTime::GetGameTime(), GetPoolData(), IsGridLoaded(), IsSpawnGroupActive(), GameObject::LoadGameObjectFromDB(), SpawnData::posX, SpawnData::posY, RemoveGORespawnTime(), sObjectMgr, SPAWN_TYPE_GAMEOBJECT, SPAWNGROUP_FLAG_COMPATIBILITY_MODE, SpawnData::spawnGroupId, and sPoolMgr.

Referenced by ProcessRespawns().

◆ ProcessRespawns()

void Map::ProcessRespawns ( )
2758{
2759 time_t now = GameTime::GetGameTime().count();
2760
2761 // Process due respawns from the time-ordered queue.
2762 // Entries are sorted by respawnTime — once we hit a future time, we're done.
2763 while (!_respawnQueue.empty())
2764 {
2765 auto it = _respawnQueue.begin();
2766 if (it->respawnTime > now)
2767 break; // nothing else is due this tick
2768
2769 SpawnObjectType type = it->type;
2770 ObjectGuid::LowType spawnId = it->spawnId;
2771
2772 // Remove from queue first — handlers below call Remove*RespawnTime()
2773 // which also erases from queue, so we must pop before processing.
2774 _respawnQueue.erase(it);
2775
2776 if (type == SPAWN_TYPE_CREATURE)
2777 ProcessCreatureRespawn(spawnId);
2778 else if (type == SPAWN_TYPE_GAMEOBJECT)
2779 ProcessGameObjectRespawn(spawnId);
2780 }
2781}
SpawnObjectType
Definition SpawnData.h:26
void ProcessCreatureRespawn(ObjectGuid::LowType spawnId)
Definition Map.cpp:2783
void ProcessGameObjectRespawn(ObjectGuid::LowType spawnId)
Definition Map.cpp:2863

References _respawnQueue, GameTime::GetGameTime(), ProcessCreatureRespawn(), ProcessGameObjectRespawn(), SPAWN_TYPE_CREATURE, and SPAWN_TYPE_GAMEOBJECT.

Referenced by Update().

◆ RemoveAllObjectsInRemoveList()

void Map::RemoveAllObjectsInRemoveList ( )
1806{
1807 while (!i_objectsToRemove.empty())
1808 {
1809 std::unordered_set<WorldObject*>::iterator itr = i_objectsToRemove.begin();
1810 WorldObject* obj = *itr;
1811 i_objectsToRemove.erase(itr);
1812
1813 switch (obj->GetTypeId())
1814 {
1815 case TYPEID_CORPSE:
1816 {
1817 Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
1818 if (!corpse)
1819 LOG_ERROR("maps", "Tried to delete corpse/bones {} that is not in map.", obj->GetGUID().ToString());
1820 else
1821 RemoveFromMap(corpse, true);
1822 break;
1823 }
1825 RemoveFromMap((DynamicObject*)obj, true);
1826 break;
1827 case TYPEID_GAMEOBJECT:
1828 if (Transport* transport = obj->ToGameObject()->ToTransport())
1829 RemoveFromMap(transport, true);
1830 else
1831 RemoveFromMap(obj->ToGameObject(), true);
1832 break;
1833 case TYPEID_UNIT:
1834 // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call
1835 // make sure that like sources auras/etc removed before destructor start
1837 RemoveFromMap(obj->ToCreature(), true);
1838 break;
1839 default:
1840 LOG_ERROR("maps", "Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->GetTypeId());
1841 break;
1842 }
1843 }
1844}
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:41
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:40
@ TYPEID_UNIT
Definition ObjectGuid.h:38
@ TYPEID_CORPSE
Definition ObjectGuid.h:42
void RemoveFromMap(T *, bool)
Definition Map.cpp:745
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:12631
Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:203

References Unit::CleanupsBeforeDelete(), ObjectAccessor::GetCorpse(), Object::GetGUID(), Object::GetTypeId(), i_objectsToRemove, LOG_ERROR, RemoveFromMap(), Object::ToCreature(), Object::ToGameObject(), ObjectGuid::ToString(), GameObject::ToTransport(), TYPEID_CORPSE, TYPEID_DYNAMICOBJECT, TYPEID_GAMEOBJECT, and TYPEID_UNIT.

Referenced by DelayedUpdate(), and MapGridManager::UnloadGrid().

◆ RemoveAllPlayers()

void Map::RemoveAllPlayers ( )
virtual

Reimplemented in BattlegroundMap.

1036{
1037 if (HavePlayers())
1038 {
1039 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1040 {
1041 Player* player = itr->GetSource();
1042 if (!player->IsBeingTeleportedFar())
1043 {
1044 // this is happening for bg
1045 LOG_ERROR("maps", "Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->GetName(), GetId());
1046 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
1047 }
1048 }
1049 }
1050}
float m_homebindZ
Definition Player.h:2422
bool IsBeingTeleportedFar() const
Definition Player.h:2122
uint32 m_homebindMapId
Definition Player.h:2418
float m_homebindY
Definition Player.h:2421
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1399
float m_homebindX
Definition Player.h:2420
std::string const & GetName() const
Definition Object.h:529

References MapRefMgr::begin(), MapRefMgr::end(), GetId(), WorldObject::GetName(), Position::GetOrientation(), HavePlayers(), Player::IsBeingTeleportedFar(), LOG_ERROR, Player::m_homebindMapId, Player::m_homebindX, Player::m_homebindY, Player::m_homebindZ, m_mapRefMgr, and Player::TeleportTo().

◆ RemoveCorpse()

void Map::RemoveCorpse ( Corpse corpse)
3057{
3058 ASSERT(corpse);
3059 GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
3060
3061 corpse->DestroyForVisiblePlayers();
3062 if (corpse->IsInGrid())
3063 RemoveFromMap(corpse, false);
3064 else
3065 {
3066 corpse->RemoveFromWorld();
3067 corpse->ResetMap();
3068 }
3069
3070 _corpsesByGrid[gridCoord.GetId()].erase(corpse);
3071 if (corpse->GetType() != CORPSE_BONES)
3072 _corpsesByPlayer.erase(corpse->GetOwnerGUID());
3073 else
3074 _corpseBones.erase(corpse);
3075}
void RemoveFromWorld() override
Definition Corpse.cpp:52
bool IsInGrid() const
Definition Object.h:365
virtual void ResetMap()
Definition Object.cpp:2214
void DestroyForVisiblePlayers()
Definition Object.cpp:3050

References _corpseBones, _corpsesByGrid, _corpsesByPlayer, ASSERT, Acore::ComputeGridCoord(), CORPSE_BONES, WorldObject::DestroyForVisiblePlayers(), CoordPair< LIMIT >::GetId(), Corpse::GetOwnerGUID(), Position::GetPositionX(), Position::GetPositionY(), Corpse::GetType(), GridObject< T >::IsInGrid(), RemoveFromMap(), Corpse::RemoveFromWorld(), and WorldObject::ResetMap().

Referenced by ConvertCorpseToBones(), and RemoveOldCorpses().

◆ RemoveCreatureFromMoveList()

void Map::RemoveCreatureFromMoveList ( Creature c)
private

◆ RemoveCreatureRespawnTime()

void Map::RemoveCreatureRespawnTime ( ObjectGuid::LowType  dbGuid)
2479{
2480 auto itr = _creatureRespawnTimes.find(spawnId);
2481 if (itr != _creatureRespawnTimes.end())
2482 {
2483 _respawnQueue.erase({itr->second, SPAWN_TYPE_CREATURE, spawnId});
2484 _creatureRespawnTimes.erase(itr);
2485 }
2486
2488 stmt->SetData(0, spawnId);
2489 stmt->SetData(1, GetId());
2490 stmt->SetData(2, GetInstanceId());
2491 CharacterDatabase.Execute(stmt);
2492}
@ CHAR_DEL_CREATURE_RESPAWN
Definition CharacterDatabase.h:255

References _creatureRespawnTimes, _respawnQueue, CHAR_DEL_CREATURE_RESPAWN, CharacterDatabase, GetId(), GetInstanceId(), PreparedStatementBase::SetData(), and SPAWN_TYPE_CREATURE.

Referenced by Creature::DeleteFromDB(), ProcessCreatureRespawn(), RemoveRespawnTime(), Creature::Respawn(), and SaveCreatureRespawnTime().

◆ RemoveDynamicObjectFromMoveList()

void Map::RemoveDynamicObjectFromMoveList ( DynamicObject go)
private

◆ RemoveFromMap() [1/2]

template<class T >
void Map::RemoveFromMap ( T *  obj,
bool  remove 
)
746{
747 obj->RemoveFromWorld();
748
749 obj->RemoveFromGrid();
750
751 obj->ResetMap();
752
753 if (remove)
754 {
756 DeleteFromWorld(obj);
757 }
758}
void RemoveObjectFromMapUpdateList(WorldObject *obj)
Definition Map.cpp:623
void DeleteFromWorld(T *)
Definition Map.cpp:168

References DeleteFromWorld(), and RemoveObjectFromMapUpdateList().

Referenced by MotionTransport::DelayedTeleportTransport(), RemoveAllObjectsInRemoveList(), and RemoveCorpse().

◆ RemoveFromMap() [2/2]

template<>
void Map::RemoveFromMap ( Transport obj,
bool  remove 
)
762{
763 obj->RemoveFromWorld();
764
765 Map::PlayerList const& players = GetPlayers();
766 if (!players.IsEmpty())
767 {
768 UpdateData data;
769 obj->BuildOutOfRangeUpdateBlock(&data);
770 WorldPacket packet;
771 data.BuildPacket(packet);
772 // Skip players that are not in world
773 // Their client already received the destroy from SendRemoveTransports when leaving this map
774 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
775 if (itr->GetSource()->IsInWorld() && itr->GetSource()->GetTransport() != obj)
776 itr->GetSource()->SendDirectMessage(&packet);
777 }
778
780 {
781 TransportsContainer::iterator itr = _transports.find(obj);
782 if (itr == _transports.end())
783 return;
784 if (itr == _transportsUpdateIter)
786 _transports.erase(itr);
787 }
788 else
789 _transports.erase(obj);
790
791 obj->ResetMap();
792
794
795 if (remove)
796 {
797 // if option set then object already saved at this moment
798 if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
799 obj->SaveRespawnTime();
800 DeleteFromWorld(obj);
801 }
802}
@ CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY
Definition WorldConfig.h:49
void RemoveFromWorld() override
Definition GameObject.cpp:184
void SaveRespawnTime() override
Definition GameObject.h:244
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
Definition Object.cpp:262

References _transports, _transportsUpdateIter, MapRefMgr::begin(), Object::BuildOutOfRangeUpdateBlock(), UpdateData::BuildPacket(), CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY, DeleteFromWorld(), MapRefMgr::end(), GetPlayers(), LinkedListHead::IsEmpty(), GameObject::RemoveFromWorld(), RemoveObjectFromMapUpdateList(), WorldObject::ResetMap(), GameObject::SaveRespawnTime(), and sWorld.

◆ RemoveGameObjectFromMoveList()

void Map::RemoveGameObjectFromMoveList ( GameObject go)
private

◆ RemoveGameObjectModel()

void Map::RemoveGameObjectModel ( GameObjectModel const &  model)
inline

◆ RemoveGORespawnTime()

void Map::RemoveGORespawnTime ( ObjectGuid::LowType  dbGuid)
2524{
2525 auto itr = _goRespawnTimes.find(spawnId);
2526 if (itr != _goRespawnTimes.end())
2527 {
2528 _respawnQueue.erase({itr->second, SPAWN_TYPE_GAMEOBJECT, spawnId});
2529 _goRespawnTimes.erase(itr);
2530 }
2531
2533 stmt->SetData(0, spawnId);
2534 stmt->SetData(1, GetId());
2535 stmt->SetData(2, GetInstanceId());
2536 CharacterDatabase.Execute(stmt);
2537}
@ CHAR_DEL_GO_RESPAWN
Definition CharacterDatabase.h:260

References _goRespawnTimes, _respawnQueue, CHAR_DEL_GO_RESPAWN, CharacterDatabase, GetId(), GetInstanceId(), PreparedStatementBase::SetData(), and SPAWN_TYPE_GAMEOBJECT.

Referenced by GameObject::DeleteFromDB(), GameObject::LoadGameObjectFromDB(), ProcessGameObjectRespawn(), RemoveRespawnTime(), GameObject::Respawn(), and SaveGORespawnTime().

◆ RemoveObjectFromMapUpdateList()

void Map::RemoveObjectFromMapUpdateList ( WorldObject obj)

◆ RemoveOldCorpses()

void Map::RemoveOldCorpses ( )
3131{
3132 time_t now = GameTime::GetGameTime().count();
3133
3134 std::vector<ObjectGuid> corpses;
3135 corpses.reserve(_corpsesByPlayer.size());
3136
3137 for (auto const& p : _corpsesByPlayer)
3138 if (p.second->IsExpired(now))
3139 corpses.push_back(p.first);
3140
3141 for (ObjectGuid const& ownerGuid : corpses)
3142 ConvertCorpseToBones(ownerGuid);
3143
3144 std::vector<Corpse*> expiredBones;
3145 for (Corpse* bones : _corpseBones)
3146 if (bones->IsExpired(now))
3147 expiredBones.push_back(bones);
3148
3149 for (Corpse* bones : expiredBones)
3150 {
3151 RemoveCorpse(bones);
3152 delete bones;
3153 }
3154}

References _corpseBones, _corpsesByPlayer, ConvertCorpseToBones(), GameTime::GetGameTime(), and RemoveCorpse().

Referenced by server_commandscript::HandleServerCorpsesCommand(), and UpdateExpiredCorpses().

◆ RemovePlayerFromMap()

void Map::RemovePlayerFromMap ( Player player,
bool  remove 
)
virtual

Reimplemented in InstanceMap, and BattlegroundMap.

720{
722
723 player->GetThreatMgr().RemoveMeFromThreatLists(); // pussywizard: multithreading crashfix
724
725 player->RemoveFromWorld();
726 SendRemoveTransports(player);
727
728 if (player->IsInGrid())
729 player->RemoveFromGrid();
730 else
731 ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map
732
733 sScriptMgr->OnPlayerLeaveMap(this, player);
734 if (remove)
735 {
736 DeleteFromWorld(player);
737 }
738}
#define MAP_INVALID_ZONE
Definition Map.cpp:49
void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone)
Definition Map.cpp:419
void SendRemoveTransports(Player *player)
Definition Map.cpp:1689
void RemoveFromWorld() override
Definition Player.cpp:1756
void RemoveMeFromThreatLists()
Definition ThreatManager.cpp:789
ThreatManager & GetThreatMgr()
Definition Unit.h:952
uint32 GetZoneId() const
Definition Object.cpp:3166

References ASSERT, DeleteFromWorld(), Unit::GetThreatMgr(), WorldObject::GetZoneId(), GridObject< T >::IsInGrid(), MAP_INVALID_ZONE, GridObject< T >::RemoveFromGrid(), Player::RemoveFromWorld(), ThreatManager::RemoveMeFromThreatLists(), SendRemoveTransports(), sScriptMgr, and UpdatePlayerZoneStats().

Referenced by WorldSession::HandleMoveWorldportAck(), WorldSession::HandleSetRaidDifficultyOpcode(), InstanceMap::RemovePlayerFromMap(), BattlegroundMap::RemovePlayerFromMap(), and Player::TeleportTo().

◆ RemoveRespawnTime()

void Map::RemoveRespawnTime ( SpawnObjectType  type,
ObjectGuid::LowType  spawnId 
)
inline
467 {
468 switch (type)
469 {
472 break;
474 RemoveGORespawnTime(spawnId);
475 break;
476 default:
477 break;
478 }
479 }

References RemoveCreatureRespawnTime(), RemoveGORespawnTime(), SPAWN_TYPE_CREATURE, and SPAWN_TYPE_GAMEOBJECT.

Referenced by SpawnGroupDespawn(), and SpawnGroupSpawn().

◆ RemoveUpdateObject()

void Map::RemoveUpdateObject ( Object obj)
inline
540 {
541 _updateObjects.erase(obj);
542 }

References _updateObjects.

Referenced by DeleteFromWorld(), and WorldObject::RemoveFromObjectUpdate().

◆ RemoveWorldObjectFromFarVisibleMap()

void Map::RemoveWorldObjectFromFarVisibleMap ( WorldObject obj)
659{
660 if (Creature* creature = obj->ToCreature())
661 {
662 Cell curr_cell = creature->GetCurrentCell();
663 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
664 grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
665 }
666 else if (GameObject* go = obj->ToGameObject())
667 {
668 Cell curr_cell = go->GetCurrentCell();
669 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
670 grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
671 }
672}
void RemoveFarVisibleObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:64

References Cell::CellX(), Cell::CellY(), GetMapGrid(), Cell::GridX(), Cell::GridY(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::RemoveFarVisibleObject(), Object::ToCreature(), and Object::ToGameObject().

Referenced by MoveAllCreaturesInMoveList(), MoveAllGameObjectsInMoveList(), and WorldObject::RemoveFromMapVisibilityOverrideContainers().

◆ RemoveWorldObjectFromZoneWideVisibleMap()

void Map::RemoveWorldObjectFromZoneWideVisibleMap ( uint32  zoneId,
WorldObject obj 
)
681{
682 ZoneWideVisibleWorldObjectsMap::iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
683 if (itr == _zoneWideVisibleWorldObjectsMap.end())
684 return;
685
686 itr->second.erase(obj);
687}

References _zoneWideVisibleWorldObjectsMap.

Referenced by WorldObject::ProcessPositionDataChanged(), and WorldObject::RemoveFromMapVisibilityOverrideContainers().

◆ resetMarkedCells()

void Map::resetMarkedCells ( )
inline
320{ marked_cells.reset(); }

References marked_cells.

Referenced by Update().

◆ SaveCreatureRespawnTime()

void Map::SaveCreatureRespawnTime ( ObjectGuid::LowType  dbGuid,
time_t &  respawnTime 
)
2450{
2451 if (!respawnTime)
2452 {
2453 // Delete only
2455 return;
2456 }
2457
2458 time_t now = GameTime::GetGameTime().count();
2459 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
2460 respawnTime = now + YEAR;
2461
2462 // Remove old queue entry if updating an existing respawn time
2463 auto itr = _creatureRespawnTimes.find(spawnId);
2464 if (itr != _creatureRespawnTimes.end())
2465 _respawnQueue.erase({itr->second, SPAWN_TYPE_CREATURE, spawnId});
2466
2467 _creatureRespawnTimes[spawnId] = respawnTime;
2468 _respawnQueue.insert({respawnTime, SPAWN_TYPE_CREATURE, spawnId});
2469
2471 stmt->SetData(0, spawnId);
2472 stmt->SetData(1, uint32(respawnTime));
2473 stmt->SetData(2, GetId());
2474 stmt->SetData(3, GetInstanceId());
2475 CharacterDatabase.Execute(stmt);
2476}
@ CHAR_REP_CREATURE_RESPAWN
Definition CharacterDatabase.h:254
constexpr auto YEAR
Definition Common.h:52
time_t GetInstanceResetPeriod() const
Definition Map.h:442

References _creatureRespawnTimes, _respawnQueue, CHAR_REP_CREATURE_RESPAWN, CharacterDatabase, GameTime::GetGameTime(), GetId(), GetInstanceId(), GetInstanceResetPeriod(), RemoveCreatureRespawnTime(), PreparedStatementBase::SetData(), SPAWN_TYPE_CREATURE, and YEAR.

Referenced by misc_commandscript::HandleRespawnAllCommand(), misc_commandscript::HandleRespawnCreatureByEntryCommand(), misc_commandscript::HandleRespawnCreatureByGuidCommand(), ProcessCreatureRespawn(), Creature::Respawn(), and Creature::SaveRespawnTime().

◆ SaveGORespawnTime()

void Map::SaveGORespawnTime ( ObjectGuid::LowType  dbGuid,
time_t &  respawnTime 
)
2495{
2496 if (!respawnTime)
2497 {
2498 // Delete only
2499 RemoveGORespawnTime(spawnId);
2500 return;
2501 }
2502
2503 time_t now = GameTime::GetGameTime().count();
2504 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
2505 respawnTime = now + YEAR;
2506
2507 // Remove old queue entry if updating an existing respawn time
2508 auto itr = _goRespawnTimes.find(spawnId);
2509 if (itr != _goRespawnTimes.end())
2510 _respawnQueue.erase({itr->second, SPAWN_TYPE_GAMEOBJECT, spawnId});
2511
2512 _goRespawnTimes[spawnId] = respawnTime;
2513 _respawnQueue.insert({respawnTime, SPAWN_TYPE_GAMEOBJECT, spawnId});
2514
2516 stmt->SetData(0, spawnId);
2517 stmt->SetData(1, uint32(respawnTime));
2518 stmt->SetData(2, GetId());
2519 stmt->SetData(3, GetInstanceId());
2520 CharacterDatabase.Execute(stmt);
2521}
@ CHAR_REP_GO_RESPAWN
Definition CharacterDatabase.h:259

References _goRespawnTimes, _respawnQueue, CHAR_REP_GO_RESPAWN, CharacterDatabase, GameTime::GetGameTime(), GetId(), GetInstanceId(), GetInstanceResetPeriod(), RemoveGORespawnTime(), PreparedStatementBase::SetData(), SPAWN_TYPE_GAMEOBJECT, and YEAR.

Referenced by misc_commandscript::HandleRespawnAllCommand(), misc_commandscript::HandleRespawnGameObjectByEntryCommand(), misc_commandscript::HandleRespawnGameObjectByGuidCommand(), and GameObject::SaveRespawnTime().

◆ ScheduleCreatureRespawn()

void Map::ScheduleCreatureRespawn ( ObjectGuid  creatureGuid,
Milliseconds  respawnTimer,
Position  pos = Position() 
)
3157{
3158 Events.AddEventAtOffset([this, creatureGuid, pos]()
3159 {
3160 if (Creature* creature = GetCreature(creatureGuid))
3161 creature->Respawn();
3162 else
3163 SummonCreature(creatureGuid.GetEntry(), pos);
3164 }, respawnTimer);
3165}
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, bool visibleBySummonerOnly=false)
Definition Object.cpp:2241
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2414
uint32 GetEntry() const
Definition ObjectGuid.h:147

References GetCreature(), ObjectGuid::GetEntry(), and SummonCreature().

Referenced by Creature::DespawnOnEvade(), and Creature::ForcedDespawn().

◆ ScriptCommandStart()

void Map::ScriptCommandStart ( ScriptInfo const &  script,
uint32  delay,
Object source,
Object target 
)
  • If effects should be immediate, launch the script execution
70{
71 // NOTE: script record _must_ exist until command executed
72
73 // prepare static data
74 ObjectGuid sourceGUID = source ? source->GetGUID() : ObjectGuid::Empty;
75 ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty;
76 ObjectGuid ownerGUID = (source && source->IsItem()) ? ((Item*)source)->GetOwnerGUID() : ObjectGuid::Empty;
77
78 ScriptAction sa;
79 sa.sourceGUID = sourceGUID;
80 sa.targetGUID = targetGUID;
81 sa.ownerGUID = ownerGUID;
82
83 sa.script = &script;
84 m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(GameTime::GetGameTime().count() + delay), sa));
85
86 sScriptMgr->IncreaseScheduledScriptsCount();
87
89 if (delay == 0 && !i_scriptLock)
90 {
91 i_scriptLock = true;
93 i_scriptLock = false;
94 }
95}
Definition Item.h:220
void ScriptsProcess()
Process queued scripts.
Definition MapScripts.cpp:277
static ObjectGuid const Empty
Definition ObjectGuid.h:123
bool IsItem() const
Definition Object.h:225
Definition Map.h:87
ObjectGuid targetGUID
Definition Map.h:89
ObjectGuid ownerGUID
Definition Map.h:90
ObjectGuid sourceGUID
Definition Map.h:88
ScriptInfo const * script
Definition Map.h:91

References ObjectGuid::Empty, GameTime::GetGameTime(), Object::GetGUID(), i_scriptLock, Object::IsItem(), m_scriptSchedule, ScriptAction::ownerGUID, ScriptAction::script, ScriptsProcess(), ScriptAction::sourceGUID, sScriptMgr, and ScriptAction::targetGUID.

◆ ScriptsProcess()

void Map::ScriptsProcess ( )
private

Process queued scripts.

  • Process overdue queued scripts
Todo:
: Allow gameobjects to be targets and casters
278{
279 if (m_scriptSchedule.empty())
280 return;
281
283 ScriptScheduleMap::iterator iter = m_scriptSchedule.begin();
284 // ok as multimap is a *sorted* associative container
285 while (!m_scriptSchedule.empty() && (iter->first <= GameTime::GetGameTime().count()))
286 {
287 ScriptAction const& step = iter->second;
288
289 Object* source = nullptr;
290 if (step.sourceGUID)
291 {
292 switch (step.sourceGUID.GetHigh())
293 {
294 case HighGuid::Item: // as well as HIGHGUID_CONTAINER
295 if (Player* player = ObjectAccessor::GetPlayer(this, step.ownerGUID))
296 source = player->GetItemByGuid(step.sourceGUID);
297 break;
298 case HighGuid::Unit:
300 source = GetCreature(step.sourceGUID);
301 break;
302 case HighGuid::Pet:
303 source = GetPet(step.sourceGUID);
304 break;
305 case HighGuid::Player:
307 break;
310 source = GetGameObject(step.sourceGUID);
311 break;
312 case HighGuid::Corpse:
313 source = GetCorpse(step.sourceGUID);
314 break;
316 source = GetTransport(step.sourceGUID);
317 break;
318 default:
319 LOG_ERROR("maps.script", "{} source with unsupported high guid ({}).",
320 step.script->GetDebugInfo(), step.sourceGUID.ToString());
321 break;
322 }
323 }
324
325 WorldObject* target = nullptr;
326 if (step.targetGUID)
327 {
328 switch (step.targetGUID.GetHigh())
329 {
330 case HighGuid::Unit:
332 target = GetCreature(step.targetGUID);
333 break;
334 case HighGuid::Pet:
335 target = GetPet(step.targetGUID);
336 break;
337 case HighGuid::Player: // empty GUID case also
339 break;
342 target = GetGameObject(step.targetGUID);
343 break;
344 case HighGuid::Corpse:
345 target = GetCorpse(step.targetGUID);
346 break;
348 target = GetTransport(step.targetGUID);
349 break;
350 default:
351 LOG_ERROR("maps.script", "{} target with unsupported high guid ({}).",
352 step.script->GetDebugInfo(), step.targetGUID.ToString());
353 break;
354 }
355 }
356
357 switch (step.script->command)
358 {
360 {
362 {
363 LOG_ERROR("maps.script", "{} invalid chat type ({}) specified, skipping.", step.script->GetDebugInfo(), step.script->Talk.ChatType);
364 break;
365 }
366
368 {
369 source = _GetScriptPlayerSourceOrTarget(source, target, step.script);
370 }
371 else
372 {
373 source = _GetScriptCreatureSourceOrTarget(source, target, step.script);
374 }
375
376 if (source)
377 {
378 Unit* sourceUnit = source->ToUnit();
379 if (!sourceUnit)
380 {
381 LOG_ERROR("scripts", "{} source object ({}) is not an unit, skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString());
382 break;
383 }
384
385 switch (step.script->Talk.ChatType)
386 {
387 case CHAT_TYPE_SAY:
388 sourceUnit->Say(step.script->Talk.TextID, target);
389 break;
390 case CHAT_TYPE_YELL:
391 sourceUnit->Yell(step.script->Talk.TextID, target);
392 break;
395 sourceUnit->TextEmote(step.script->Talk.TextID, target, step.script->Talk.ChatType == CHAT_TYPE_BOSS_EMOTE);
396 break;
399 {
400 Player* receiver = target ? target->ToPlayer() : nullptr;
401 if (!receiver)
402 LOG_ERROR("scripts", "{} attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo());
403 else
404 sourceUnit->Whisper(step.script->Talk.TextID, receiver, step.script->Talk.ChatType == CHAT_MSG_RAID_BOSS_WHISPER);
405 break;
406 }
407 default:
408 break; // must be already checked at load
409 }
410 }
411 break;
412 }
414 // Source or target must be Creature.
415 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
416 {
418 cSource->SetUInt32Value(UNIT_NPC_EMOTESTATE, step.script->Emote.EmoteID);
419 else
420 cSource->HandleEmoteCommand(step.script->Emote.EmoteID);
421 }
422 break;
423
425 // Source or target must be Creature.
426 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
427 {
428 // Validate field number.
429 if (step.script->FieldSet.FieldID <= OBJECT_FIELD_ENTRY || step.script->FieldSet.FieldID >= cSource->GetValuesCount())
430 LOG_ERROR("maps.script", "{} wrong field {} (max count: {}) in object ({}) specified, skipping.",
431 step.script->GetDebugInfo(), step.script->FieldSet.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString());
432 else
433 cSource->SetUInt32Value(step.script->FieldSet.FieldID, step.script->FieldSet.FieldValue);
434 }
435 break;
436
438 // Source or target must be Creature.
439 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
440 {
441 Unit* unit = (Unit*)cSource;
442 if (step.script->MoveTo.TravelTime != 0)
443 {
444 float speed = unit->GetDistance(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ) / ((float)step.script->MoveTo.TravelTime * 0.001f);
446 }
447 else
449 }
450 break;
451
453 // Source or target must be Creature.
454 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
455 {
456 // Validate field number.
457 if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
458 LOG_ERROR("maps.script", "{} wrong field {} (max count: {}) in object ({}) specified, skipping.",
459 step.script->GetDebugInfo(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString());
460 else
461 cSource->SetFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
462 }
463 break;
464
466 // Source or target must be Creature.
467 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
468 {
469 // Validate field number.
470 if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
471 LOG_ERROR("maps.script", "{} wrong field {} (max count: {}) in object ({}) specified, skipping.",
472 step.script->GetDebugInfo(), step.script->FlagToggle.FieldID, cSource->GetValuesCount(), cSource->GetGUID().ToString());
473 else
474 cSource->RemoveFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
475 }
476 break;
477
480 {
481 // Source or target must be Creature.
482 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true))
483 cSource->NearTeleportTo(step.script->TeleportTo.DestX, step.script->TeleportTo.DestY, step.script->TeleportTo.DestZ, step.script->TeleportTo.Orientation);
484 }
485 else
486 {
487 // Source or target must be Player.
488 if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
489 player->TeleportTo(step.script->TeleportTo.MapID, step.script->TeleportTo.DestX, step.script->TeleportTo.DestY, step.script->TeleportTo.DestZ, step.script->TeleportTo.Orientation);
490 }
491 break;
492
494 {
495 if (!source)
496 {
497 LOG_ERROR("maps.script", "{} source object is nullptr.", step.script->GetDebugInfo());
498 break;
499 }
500 if (!target)
501 {
502 LOG_ERROR("maps.script", "{} target object is nullptr.", step.script->GetDebugInfo());
503 break;
504 }
505
506 // when script called for item spell casting then target == (unit or GO) and source is player
507 WorldObject* worldObject;
508 Player* player = target->ToPlayer();
509 if (player)
510 {
511 if (!source->IsCreature() && !source->IsGameObject() && !source->IsPlayer())
512 {
513 LOG_ERROR("maps.script", "{} source is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), source->GetGUID().ToString());
514 break;
515 }
516 worldObject = dynamic_cast<WorldObject*>(source);
517 }
518 else
519 {
520 player = source->ToPlayer();
521 if (player)
522 {
523 if (!target->IsCreature() && !target->IsGameObject() && !target->IsPlayer())
524 {
525 LOG_ERROR("maps.script", "{} target is not unit, gameobject or player ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString());
526 break;
527 }
528 worldObject = dynamic_cast<WorldObject*>(target);
529 }
530 else
531 {
532 LOG_ERROR("maps.script", "{} neither source nor target is player (source: {}; target: {}), skipping.",
533 step.script->GetDebugInfo(), source->GetGUID().ToString(), target->GetGUID().ToString());
534 break;
535 }
536 }
537
538 // quest id and flags checked at script loading
539 if ((!worldObject->IsCreature() || ((Unit*)worldObject)->IsAlive()) &&
540 (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
541 player->GroupEventHappens(step.script->QuestExplored.QuestID, worldObject);
542 else
543 player->FailQuest(step.script->QuestExplored.QuestID);
544
545 break;
546 }
547
549 // Source or target must be Player.
550 if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
551 {
554 else
556 }
557 break;
558
561 {
562 LOG_ERROR("maps.script", "{} gameobject guid (datalong) is not specified.", step.script->GetDebugInfo());
563 break;
564 }
565
566 // Source or target must be WorldObject.
567 if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
568 {
570 if (!pGO)
571 {
572 LOG_ERROR("maps.script", "{} gameobject was not found (guid: {}).", step.script->GetDebugInfo(), step.script->RespawnGameobject.GOGuid);
573 break;
574 }
575
580 {
581 LOG_ERROR("maps.script", "{} can not be used with gameobject of type {} (guid: {}).",
583 break;
584 }
585
586 // Check that GO is not spawned
587 if (!pGO->isSpawned())
588 {
589 int32 nTimeToDespawn = std::max(5, int32(step.script->RespawnGameobject.DespawnDelay));
591 pGO->SetRespawnTime(nTimeToDespawn);
592
593 pGO->GetMap()->AddToMap(pGO);
594 }
595 }
596 break;
597
599 {
600 // Source must be WorldObject.
601 if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
602 {
604 LOG_ERROR("maps.script", "{} creature entry (datalong) is not specified.", step.script->GetDebugInfo());
605 else
606 {
608
609 float x = step.script->TempSummonCreature.PosX;
610 float y = step.script->TempSummonCreature.PosY;
611 float z = step.script->TempSummonCreature.PosZ;
612 float o = step.script->TempSummonCreature.Orientation;
613
615 if (Unit* trigger = pSummoner->SummonTrigger(x, y, z, o, 1))
616 if (trigger->FindNearestCreature(entry, 60.0f))
617 break;
618
619 if (!pSummoner->SummonCreature(entry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->TempSummonCreature.DespawnDelay))
620 LOG_ERROR("maps.script", "{} creature was not spawned (entry: {}).", step.script->GetDebugInfo(), step.script->TempSummonCreature.CreatureEntry);
621 }
622 }
623 break;
624 }
625
628 _ScriptProcessDoor(source, target, step.script);
629 break;
630
632 // Source must be Unit.
633 if (Unit* unit = _GetScriptUnit(source, true, step.script))
634 {
635 // Target must be GameObject.
636 if (!target)
637 {
638 LOG_ERROR("maps.script", "{} target object is nullptr.", step.script->GetDebugInfo());
639 break;
640 }
641
642 if (!target->IsGameObject())
643 {
644 LOG_ERROR("maps.script", "{} target object is not gameobject ({}), skipping.", step.script->GetDebugInfo(), target->GetGUID().ToString());
645 break;
646 }
647
648 if (GameObject* pGO = target->ToGameObject())
649 pGO->Use(unit);
650 }
651 break;
652
654 {
655 // Source (datalong2 != 0) or target (datalong2 == 0) must be Unit.
656 bool bReverse = step.script->RemoveAura.Flags & SF_REMOVEAURA_REVERSE;
657 if (Unit* unit = _GetScriptUnit(bReverse ? source : target, bReverse, step.script))
658 unit->RemoveAurasDueToSpell(step.script->RemoveAura.SpellID);
659 break;
660 }
661
663 {
665 if (!source && !target)
666 {
667 LOG_ERROR("maps.script", "{} source and target objects are nullptr.", step.script->GetDebugInfo());
668 break;
669 }
670
671 Unit* uSource = nullptr;
672 Unit* uTarget = nullptr;
673 // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
674 switch (step.script->CastSpell.Flags)
675 {
676 case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target
677 uSource = source ? source->ToUnit() : nullptr;
678 uTarget = target ? target->ToUnit() : nullptr;
679 break;
680 case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source
681 uSource = source ? source->ToUnit() : nullptr;
682 uTarget = uSource;
683 break;
684 case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target
685 uSource = target ? target->ToUnit() : nullptr;
686 uTarget = uSource;
687 break;
688 case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source
689 uSource = target ? target->ToUnit() : nullptr;
690 uTarget = source ? source->ToUnit() : nullptr;
691 break;
692 case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry
693 uSource = source ? source->ToUnit() : nullptr;
694 uTarget = uSource ? GetClosestCreatureWithEntry(uSource, std::abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : nullptr;
695 break;
696 }
697
698 if (!uSource || !uSource->IsUnit())
699 {
700 LOG_ERROR("maps.script", "{} no source unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID);
701 break;
702 }
703
704 if (!uTarget || !uTarget->IsUnit())
705 {
706 LOG_ERROR("maps.script", "{} no target unit found for spell {}", step.script->GetDebugInfo(), step.script->CastSpell.SpellID);
707 break;
708 }
709
710 bool triggered = (step.script->CastSpell.Flags != 4) ?
712 step.script->CastSpell.CreatureEntry < 0;
713 uSource->CastSpell(uTarget, step.script->CastSpell.SpellID, triggered);
714 break;
715 }
716
718 // Source must be WorldObject.
719 if (WorldObject* object = _GetScriptWorldObject(source, true, step.script))
720 {
721 // Playsound.Flags bitmask: 0/1=anyone/target
722 Player* player = nullptr;
724 {
725 // Target must be Player.
726 player = _GetScriptPlayer(target, false, step.script);
727 if (!target)
728 break;
729 }
730
731 // Playsound.Flags bitmask: 0/2/4=without/with distance dependent/radius
733 object->PlayRadiusSound(step.script->Playsound.SoundID, step.script->Playsound.Radius);
735 object->PlayDistanceSound(step.script->Playsound.SoundID, player);
736 else
737 object->PlayDirectSound(step.script->Playsound.SoundID, player);
738 }
739 break;
740
742 // Target or source must be Player.
743 if (Player* pReceiver = _GetScriptPlayerSourceOrTarget(source, target, step.script))
744 {
745 ItemPosCountVec dest;
746 InventoryResult msg = pReceiver->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, step.script->CreateItem.ItemEntry, step.script->CreateItem.Amount);
747 if (msg == EQUIP_ERR_OK)
748 {
749 if (Item* item = pReceiver->StoreNewItem(dest, step.script->CreateItem.ItemEntry, true))
750 pReceiver->SendNewItem(item, step.script->CreateItem.Amount, false, true);
751 }
752 else
753 pReceiver->SendEquipError(msg, nullptr, nullptr, step.script->CreateItem.ItemEntry);
754 }
755 break;
756
758 // Target or source must be Creature.
759 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true))
760 cSource->DespawnOrUnsummon(Milliseconds(step.script->DespawnSelf.DespawnDelay));
761 break;
762
764 // Source must be Unit.
765 if (Unit* unit = _GetScriptUnit(source, true, step.script))
766 {
767 if (!sWaypointMgr->GetPath(step.script->LoadPath.PathID))
768 LOG_ERROR("maps.script", "{} source object has an invalid path ({}), skipping.", step.script->GetDebugInfo(), step.script->LoadPath.PathID);
769 else
771 }
772 break;
773
775 {
777 {
778 LOG_ERROR("maps.script", "{} creature entry is not specified, skipping.", step.script->GetDebugInfo());
779 break;
780 }
781 if (!step.script->CallScript.ScriptID)
782 {
783 LOG_ERROR("maps.script", "{} script id is not specified, skipping.", step.script->GetDebugInfo());
784 break;
785 }
786
787 Creature* cTarget = nullptr;
788 auto creatureBounds = _creatureBySpawnIdStore.equal_range(step.script->CallScript.CreatureEntry);
789 if (creatureBounds.first != creatureBounds.second)
790 {
791 // Prefer alive (last respawned) creature
792 auto creatureItr = std::find_if(creatureBounds.first, creatureBounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
793 {
794 return pair.second->IsAlive();
795 });
796 cTarget = creatureItr != creatureBounds.second ? creatureItr->second : creatureBounds.first->second;
797 }
798
799 if (!cTarget)
800 {
801 LOG_ERROR("maps.script", "{} target was not found (entry: {})", step.script->GetDebugInfo(), step.script->CallScript.CreatureEntry);
802 break;
803 }
804
805 //Lets choose our ScriptMap map
807 //if no scriptmap present...
808 if (!datamap)
809 {
810 LOG_ERROR("maps.script", "{} unknown scriptmap ({}) specified, skipping.", step.script->GetDebugInfo(), step.script->CallScript.ScriptType);
811 break;
812 }
813
814 // Insert script into schedule but do not start it
815 ScriptsStart(*datamap, step.script->CallScript.ScriptID, cTarget, nullptr);
816 break;
817 }
818
820 // Source or target must be Creature.
821 if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
822 {
823 if (cSource->isDead())
824 LOG_ERROR("maps.script", "{} creature is already dead ({})", step.script->GetDebugInfo(), cSource->GetGUID().ToString());
825 else
826 {
827 cSource->setDeathState(DeathState::JustDied);
828 if (step.script->Kill.RemoveCorpse == 1)
829 cSource->RemoveCorpse();
830 }
831 }
832 break;
833
835 // Source must be Unit.
836 if (Unit* sourceUnit = _GetScriptUnit(source, true, step.script))
837 {
839 {
840 // Target must be Unit.
841 Unit* targetUnit = _GetScriptUnit(target, false, step.script);
842 if (!targetUnit)
843 break;
844
845 sourceUnit->SetFacingToObject(targetUnit);
846 }
847 else
848 sourceUnit->SetFacingTo(step.script->Orientation.Orientation);
849 }
850 break;
851
853 // Source must be Creature.
854 if (Creature* cSource = _GetScriptCreature(source, true, step.script))
855 cSource->LoadEquipment(step.script->Equip.EquipmentID);
856 break;
857
859 // Source must be Creature.
860 if (Creature* cSource = _GetScriptCreature(source, true, step.script))
861 cSource->SetDisplayId(step.script->Model.ModelID);
862 break;
863
865 // Source must be Player.
866 if (Player* player = _GetScriptPlayer(source, true, step.script))
868 break;
869
871 // Source must be Player.
872 if (Player* player = _GetScriptPlayer(source, true, step.script))
873 player->SendMovieStart(step.script->PlayMovie.MovieID);
874 break;
875
877 // Source must be Creature.
878 if (Creature* cSource = _GetScriptCreature(source, true, step.script))
879 {
880 if (!cSource->IsAlive())
881 return;
882
883 cSource->GetMotionMaster()->MoveIdle();
884
885 switch (step.script->Movement.MovementType)
886 {
888 cSource->GetMotionMaster()->MoveRandom((float)step.script->Movement.MovementDistance);
889 break;
891 cSource->GetMotionMaster()->MoveWaypoint(step.script->Movement.Path, false);
892 break;
893 }
894 }
895 break;
896
897 default:
898 LOG_ERROR("maps.script", "Unknown script command {}.", step.script->GetDebugInfo());
899 break;
900 }
901
902 m_scriptSchedule.erase(iter);
903 iter = m_scriptSchedule.begin();
904 sScriptMgr->DecreaseScheduledScriptCount();
905 }
906}
@ CHAT_TYPE_SAY
Definition CreatureData.h:412
@ CHAT_TYPE_TEXT_EMOTE
Definition CreatureData.h:414
@ CHAT_TYPE_BOSS_EMOTE
Definition CreatureData.h:415
@ CHAT_TYPE_WHISPER
Definition CreatureData.h:416
@ CHAT_TYPE_YELL
Definition CreatureData.h:413
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:27
@ GO_READY
Definition GameObject.h:111
InventoryResult
Definition Item.h:46
@ EQUIP_ERR_OK
Definition Item.h:47
@ NULL_BAG
Definition Item.h:40
@ NULL_SLOT
Definition Item.h:41
@ WAYPOINT_MOTION_TYPE
Definition MotionMaster.h:41
@ RANDOM_MOTION_TYPE
Definition MotionMaster.h:40
@ FORCED_MOVEMENT_NONE
Definition MotionMaster.h:86
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition ObjectMgr.cpp:84
@ SF_CASTSPELL_SOURCE_TO_SOURCE
Definition ObjectMgr.h:177
@ SF_CASTSPELL_SOURCE_TO_TARGET
Definition ObjectMgr.h:176
@ SF_CASTSPELL_TRIGGERED
Definition ObjectMgr.h:181
@ SF_CASTSPELL_TARGET_TO_SOURCE
Definition ObjectMgr.h:179
@ SF_REMOVEAURA_REVERSE
Definition ObjectMgr.h:173
@ SF_PLAYSOUND_DISTANCE_SOUND
Definition ObjectMgr.h:185
@ SF_TALK_USE_PLAYER
Definition ObjectMgr.h:161
@ SF_TELEPORT_USE_CREATURE
Definition ObjectMgr.h:167
@ SF_KILLCREDIT_REWARD_GROUP
Definition ObjectMgr.h:170
@ SF_PLAYSOUND_TARGET_PLAYER
Definition ObjectMgr.h:184
@ SF_CASTSPELL_TARGET_TO_TARGET
Definition ObjectMgr.h:178
@ SF_EMOTE_USE_STATE
Definition ObjectMgr.h:164
@ SF_CASTSPELL_SEARCH_CREATURE
Definition ObjectMgr.h:180
@ SF_PLAYSOUND_DISTANCE_RADIUS
Definition ObjectMgr.h:186
@ SF_ORIENTATION_FACE_TARGET
Definition ObjectMgr.h:189
@ SCRIPT_COMMAND_EMOTE
Definition ObjectMgr.h:96
@ SCRIPT_COMMAND_CREATE_ITEM
Definition ObjectMgr.h:112
@ SCRIPT_COMMAND_DESPAWN_SELF
Definition ObjectMgr.h:113
@ SCRIPT_COMMAND_CAST_SPELL
Definition ObjectMgr.h:110
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition ObjectMgr.h:104
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition ObjectMgr.h:102
@ SCRIPT_COMMAND_ACTIVATE_OBJECT
Definition ObjectMgr.h:108
@ SCRIPT_COMMAND_TALK
Definition ObjectMgr.h:95
@ SCRIPT_COMMAND_EQUIP
Definition ObjectMgr.h:121
@ SCRIPT_COMMAND_FIELD_SET
Definition ObjectMgr.h:97
@ SCRIPT_COMMAND_PLAYMOVIE
Definition ObjectMgr.h:124
@ SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT
Definition ObjectMgr.h:116
@ SCRIPT_COMMAND_TELEPORT_TO
Definition ObjectMgr.h:101
@ SCRIPT_COMMAND_MOVE_TO
Definition ObjectMgr.h:98
@ SCRIPT_COMMAND_FLAG_SET
Definition ObjectMgr.h:99
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition ObjectMgr.h:105
@ SCRIPT_COMMAND_MOVEMENT
Definition ObjectMgr.h:125
@ SCRIPT_COMMAND_KILL_CREDIT
Definition ObjectMgr.h:103
@ SCRIPT_COMMAND_KILL
Definition ObjectMgr.h:117
@ SCRIPT_COMMAND_LOAD_PATH
Definition ObjectMgr.h:115
@ SCRIPT_COMMAND_ORIENTATION
Definition ObjectMgr.h:120
@ SCRIPT_COMMAND_PLAY_SOUND
Definition ObjectMgr.h:111
@ SCRIPT_COMMAND_MODEL
Definition ObjectMgr.h:122
@ SCRIPT_COMMAND_CLOSE_GOSSIP
Definition ObjectMgr.h:123
@ SCRIPT_COMMAND_REMOVE_AURA
Definition ObjectMgr.h:109
@ SCRIPT_COMMAND_FLAG_REMOVE
Definition ObjectMgr.h:100
std::map< uint32, ScriptMap > ScriptMapMap
Definition ObjectMgr.h:389
ScriptsType
Definition ObjectMgr.h:148
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition Object.h:49
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:758
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:933
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1570
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1581
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3427
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
@ OBJECT_FIELD_ENTRY
Definition UpdateFields.h:27
#define sWaypointMgr
Definition WaypointMgr.h:54
bool isSpawned() const
Definition GameObject.h:190
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2468
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1287
void Use(Unit *user)
Definition GameObject.cpp:1463
static T * Find(ObjectGuid guid)
Definition ObjectAccessor.cpp:53
Player * _GetScriptPlayer(Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
Definition MapScripts.cpp:171
void ScriptsStart(std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
Put scripts in the execution queue.
Definition MapScripts.cpp:31
Pet * GetPet(ObjectGuid const &guid)
Definition Map.cpp:2424
Creature * _GetScriptCreature(Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
Definition MapScripts.cpp:186
void _ScriptProcessDoor(Object *source, Object *target, ScriptInfo const *scriptInfo) const
Definition MapScripts.cpp:217
WorldObject * _GetScriptWorldObject(Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
Definition MapScripts.cpp:201
Corpse * GetCorpse(ObjectGuid const &guid)
Definition Map.cpp:2409
Player * _GetScriptPlayerSourceOrTarget(Object *source, Object *target, ScriptInfo const *scriptInfo) const
Definition MapScripts.cpp:98
Unit * _GetScriptUnit(Object *obj, bool isSource, ScriptInfo const *scriptInfo) const
Definition MapScripts.cpp:153
Transport * GetTransport(ObjectGuid const &guid)
Definition Map.cpp:2429
Creature * _GetScriptCreatureSourceOrTarget(Object *source, Object *target, ScriptInfo const *scriptInfo, bool bReverse=false) const
Definition MapScripts.cpp:120
void MovePoint(uint32 id, Position const &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true, std::optional< AnimTier > animTier=std::nullopt)
Definition MotionMaster.h:240
void MoveWaypoint(uint32 path_id, bool repeatable, PathSource pathSource=PathSource::WAYPOINT_MGR)
Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:933
Definition Object.h:105
bool IsPlayer() const
Definition Object.h:201
bool IsGameObject() const
Definition Object.h:213
bool IsCreature() const
Definition Object.h:205
void SendCloseGossip()
Definition GossipDef.cpp:239
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition PlayerQuest.cpp:1986
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition PlayerQuest.cpp:1877
void SendMovieStart(uint32 MovieId)
Definition Player.cpp:5864
void FailQuest(uint32 quest_id)
Definition PlayerQuest.cpp:912
PlayerMenu * PlayerTalkClass
Definition Player.h:2285
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:13015
void SetFacingToObject(WorldObject *object, Milliseconds timed=0ms)
Definition Unit.cpp:16465
void SetFacingTo(float ori)
Definition Unit.cpp:16455
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:17184
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:17189
MotionMaster * GetMotionMaster()
Definition Unit.h:1758
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:17194
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition Unit.cpp:1361
void NearTeleportTo(Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
Definition Unit.cpp:15959
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition Unit.cpp:17199
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1381
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1299
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2497
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:244
Definition ChatCommandTags.h:258
float Orientation
Definition ObjectMgr.h:253
struct ScriptInfo::@271::@294 Equip
uint32 Flags
Definition ObjectMgr.h:210
struct ScriptInfo::@271::@291 CallScript
struct ScriptInfo::@271::@278 FlagToggle
uint32 FieldID
Definition ObjectMgr.h:222
struct ScriptInfo::@271::@289 DespawnSelf
uint32 QuestID
Definition ObjectMgr.h:258
float SearchRadius
Definition ObjectMgr.h:307
int32 TextID
Definition ObjectMgr.h:211
struct ScriptInfo::@271::@285 RemoveAura
uint32 MovementType
Definition ObjectMgr.h:379
uint32 MovementDistance
Definition ObjectMgr.h:380
float DestX
Definition ObjectMgr.h:232
uint32 ItemEntry
Definition ObjectMgr.h:319
struct ScriptInfo::@271::@276 FieldSet
uint32 ChatType
Definition ObjectMgr.h:209
uint32 SoundID
Definition ObjectMgr.h:312
uint32 CheckIfExists
Definition ObjectMgr.h:278
struct ScriptInfo::@271::@279 TeleportTo
uint32 ScriptID
Definition ObjectMgr.h:337
uint32 ModelID
Definition ObjectMgr.h:367
uint32 FieldValue
Definition ObjectMgr.h:223
struct ScriptInfo::@271::@280 QuestExplored
float PosY
Definition ObjectMgr.h:281
ScriptCommands command
Definition ObjectMgr.h:197
float DestY
Definition ObjectMgr.h:233
struct ScriptInfo::@271::@274 Talk
uint32 PathID
Definition ObjectMgr.h:330
uint32 MapID
Definition ObjectMgr.h:246
uint32 IsRepeatable
Definition ObjectMgr.h:331
struct ScriptInfo::@271::@297 Movement
struct ScriptInfo::@271::@290 LoadPath
struct ScriptInfo::@271::@281 KillCredit
int32 Path
Definition ObjectMgr.h:381
struct ScriptInfo::@271::@282 RespawnGameobject
int32 RemoveCorpse
Definition ObjectMgr.h:345
float PosZ
Definition ObjectMgr.h:282
struct ScriptInfo::@271::@286 CastSpell
uint32 ScriptType
Definition ObjectMgr.h:338
struct ScriptInfo::@271::@292 Kill
struct ScriptInfo::@271::@288 CreateItem
uint32 DespawnDelay
Definition ObjectMgr.h:271
float PosX
Definition ObjectMgr.h:280
int32 Radius
Definition ObjectMgr.h:314
struct ScriptInfo::@271::@277 MoveTo
uint32 TravelTime
Definition ObjectMgr.h:229
uint32 Distance
Definition ObjectMgr.h:259
struct ScriptInfo::@271::@295 Model
uint32 SpellID
Definition ObjectMgr.h:297
std::string GetDebugInfo() const
Definition ObjectMgr.cpp:202
struct ScriptInfo::@271::@283 TempSummonCreature
float DestZ
Definition ObjectMgr.h:234
uint32 MovieID
Definition ObjectMgr.h:374
uint32 EquipmentID
Definition ObjectMgr.h:362
uint32 GOGuid
Definition ObjectMgr.h:270
struct ScriptInfo::@271::@275 Emote
struct ScriptInfo::@271::@287 Playsound
uint32 CreatureEntry
Definition ObjectMgr.h:264
uint32 Amount
Definition ObjectMgr.h:320
struct ScriptInfo::@271::@296 PlayMovie
uint32 EmoteID
Definition ObjectMgr.h:216

References _creatureBySpawnIdStore, _FindGameObject(), _GetScriptCreature(), _GetScriptCreatureSourceOrTarget(), _GetScriptPlayer(), _GetScriptPlayerSourceOrTarget(), _GetScriptUnit(), _GetScriptWorldObject(), _ScriptProcessDoor(), AddToMap(), ScriptInfo::Amount, ScriptInfo::CallScript, Unit::CastSpell(), ScriptInfo::CastSpell, CHAT_MSG_RAID_BOSS_WHISPER, CHAT_TYPE_BOSS_EMOTE, CHAT_TYPE_SAY, CHAT_TYPE_TEXT_EMOTE, CHAT_TYPE_WHISPER, CHAT_TYPE_YELL, ScriptInfo::ChatType, ScriptInfo::CheckIfExists, ScriptInfo::command, Corpse, ScriptInfo::CreateItem, ScriptInfo::CreatureEntry, ScriptInfo::DespawnDelay, ScriptInfo::DespawnSelf, ScriptInfo::DestX, ScriptInfo::DestY, ScriptInfo::DestZ, ScriptInfo::Distance, ScriptInfo::Emote, ScriptInfo::EmoteID, ScriptInfo::Equip, EQUIP_ERR_OK, ScriptInfo::EquipmentID, Player::FailQuest(), ScriptInfo::FieldID, ScriptInfo::FieldSet, ScriptInfo::FieldValue, HashMapHolder< T >::Find(), ScriptInfo::Flags, ScriptInfo::FlagToggle, FORCED_MOVEMENT_NONE, GameObject, GAMEOBJECT_TYPE_BUTTON, GAMEOBJECT_TYPE_DOOR, GAMEOBJECT_TYPE_FISHINGNODE, GAMEOBJECT_TYPE_TRAP, GetClosestCreatureWithEntry(), GetCorpse(), GetCreature(), ScriptInfo::GetDebugInfo(), WorldObject::GetDistance(), GetGameObject(), GameTime::GetGameTime(), GameObject::GetGoType(), Object::GetGUID(), ObjectGuid::GetHigh(), WorldObject::GetMap(), Unit::GetMotionMaster(), Position::GetOrientation(), GetPet(), ObjectAccessor::GetPlayer(), GetScriptsMapByType(), GetTransport(), GO_READY, ScriptInfo::GOGuid, Player::GroupEventHappens(), Object::IsCreature(), Object::IsGameObject(), Object::IsPlayer(), ScriptInfo::IsRepeatable, GameObject::isSpawned(), Object::IsUnit(), WorldObject::IsWithinDistInMap(), Item, ScriptInfo::ItemEntry, JustDied, ScriptInfo::Kill, ScriptInfo::KillCredit, ScriptInfo::LoadPath, LOG_ERROR, m_scriptSchedule, ScriptInfo::MapID, Mo_Transport, ScriptInfo::Model, ScriptInfo::ModelID, ScriptInfo::Movement, ScriptInfo::MovementDistance, ScriptInfo::MovementType, MotionMaster::MovePoint(), ScriptInfo::MoveTo, ScriptInfo::MovieID, Unit::NearTeleportTo(), NULL_BAG, NULL_SLOT, OBJECT_FIELD_ENTRY, ScriptInfo::Orientation, ScriptAction::ownerGUID, ScriptInfo::Path, ScriptInfo::PathID, Pet, Player, ScriptInfo::PlayMovie, ScriptInfo::Playsound, ScriptInfo::PosX, ScriptInfo::PosY, ScriptInfo::PosZ, ScriptInfo::QuestExplored, ScriptInfo::QuestID, ScriptInfo::Radius, RANDOM_MOTION_TYPE, ScriptInfo::RemoveAura, ScriptInfo::RemoveCorpse, ScriptInfo::RespawnGameobject, Unit::Say(), ScriptAction::script, SCRIPT_COMMAND_ACTIVATE_OBJECT, SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT, SCRIPT_COMMAND_CAST_SPELL, SCRIPT_COMMAND_CLOSE_DOOR, SCRIPT_COMMAND_CLOSE_GOSSIP, SCRIPT_COMMAND_CREATE_ITEM, SCRIPT_COMMAND_DESPAWN_SELF, SCRIPT_COMMAND_EMOTE, SCRIPT_COMMAND_EQUIP, SCRIPT_COMMAND_FIELD_SET, SCRIPT_COMMAND_FLAG_REMOVE, SCRIPT_COMMAND_FLAG_SET, SCRIPT_COMMAND_KILL, SCRIPT_COMMAND_KILL_CREDIT, SCRIPT_COMMAND_LOAD_PATH, SCRIPT_COMMAND_MODEL, SCRIPT_COMMAND_MOVE_TO, SCRIPT_COMMAND_MOVEMENT, SCRIPT_COMMAND_OPEN_DOOR, SCRIPT_COMMAND_ORIENTATION, SCRIPT_COMMAND_PLAY_SOUND, SCRIPT_COMMAND_PLAYMOVIE, SCRIPT_COMMAND_QUEST_EXPLORED, SCRIPT_COMMAND_REMOVE_AURA, SCRIPT_COMMAND_RESPAWN_GAMEOBJECT, SCRIPT_COMMAND_TALK, SCRIPT_COMMAND_TELEPORT_TO, SCRIPT_COMMAND_TEMP_SUMMON_CREATURE, ScriptInfo::ScriptID, ScriptsStart(), ScriptInfo::ScriptType, ScriptInfo::SearchRadius, GameObject::SetLootState(), GameObject::SetRespawnTime(), SF_CASTSPELL_SEARCH_CREATURE, SF_CASTSPELL_SOURCE_TO_SOURCE, SF_CASTSPELL_SOURCE_TO_TARGET, SF_CASTSPELL_TARGET_TO_SOURCE, SF_CASTSPELL_TARGET_TO_TARGET, SF_CASTSPELL_TRIGGERED, SF_EMOTE_USE_STATE, SF_KILLCREDIT_REWARD_GROUP, SF_ORIENTATION_FACE_TARGET, SF_PLAYSOUND_DISTANCE_RADIUS, SF_PLAYSOUND_DISTANCE_SOUND, SF_PLAYSOUND_TARGET_PLAYER, SF_REMOVEAURA_REVERSE, SF_TALK_USE_PLAYER, SF_TELEPORT_USE_CREATURE, ScriptInfo::SoundID, ScriptAction::sourceGUID, ScriptInfo::SpellID, sScriptMgr, WorldObject::SummonTrigger(), sWaypointMgr, ScriptInfo::Talk, ScriptAction::targetGUID, ScriptInfo::TeleportTo, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, ScriptInfo::TempSummonCreature, Unit::TextEmote(), ScriptInfo::TextID, Object::ToGameObject(), Object::ToPlayer(), ObjectGuid::ToString(), Object::ToUnit(), Transport, ScriptInfo::TravelTime, Unit, UNIT_NPC_EMOTESTATE, Vehicle, WAYPOINT_MOTION_TYPE, Unit::Whisper(), and Unit::Yell().

Referenced by ScriptCommandStart(), ScriptsStart(), and Update().

◆ ScriptsStart()

void Map::ScriptsStart ( std::map< uint32, std::multimap< uint32, ScriptInfo > > const &  scripts,
uint32  id,
Object source,
Object target 
)

Put scripts in the execution queue.

  • Find the script map
  • Schedule script execution for all scripts in the script map
  • If one of the effects should be immediate, launch the script execution
32{
34 ScriptMapMap::const_iterator s = scripts.find(id);
35 if (s == scripts.end())
36 return;
37
38 // prepare static data
39 ObjectGuid sourceGUID = source ? source->GetGUID() : ObjectGuid::Empty; //some script commands doesn't have source
40 ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty;
41 ObjectGuid ownerGUID = (source && source->IsItem()) ? ((Item*)source)->GetOwnerGUID() : ObjectGuid::Empty;
42
44 ScriptMap const* s2 = &(s->second);
45 bool immedScript = false;
46 for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter)
47 {
48 ScriptAction sa;
49 sa.sourceGUID = sourceGUID;
50 sa.targetGUID = targetGUID;
51 sa.ownerGUID = ownerGUID;
52
53 sa.script = &iter->second;
54 m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(GameTime::GetGameTime().count() + iter->first), sa));
55 if (iter->first == 0)
56 immedScript = true;
57
58 sScriptMgr->IncreaseScheduledScriptsCount();
59 }
61 if (/*start &&*/ immedScript && !i_scriptLock)
62 {
63 i_scriptLock = true;
65 i_scriptLock = false;
66 }
67}
std::multimap< uint32, ScriptInfo > ScriptMap
Definition ObjectMgr.h:388

References ObjectGuid::Empty, GameTime::GetGameTime(), Object::GetGUID(), i_scriptLock, Object::IsItem(), m_scriptSchedule, ScriptAction::ownerGUID, ScriptAction::script, ScriptsProcess(), ScriptAction::sourceGUID, sScriptMgr, and ScriptAction::targetGUID.

Referenced by MotionTransport::DoEventIfAny(), FlightPathMovementGenerator::DoEventIfAny(), WorldSession::DoLootRelease(), WaypointMovementGenerator< Creature >::DoUpdate(), Spell::EffectDummy(), Spell::EffectScriptEffect(), Spell::EffectSendEvent(), WaypointMovementGenerator< Creature >::ProcessWaypointArrival(), ScriptsProcess(), and GameObject::Use().

◆ SendInitSelf()

void Map::SendInitSelf ( Player player)
1625{
1626 LOG_DEBUG("maps", "Creating player data for himself {}", player->GetGUID().ToString());
1627
1628 WorldPacket packet;
1629 UpdateData data;
1630
1631 // attach to player data current transport data
1632 if (Transport* transport = player->GetTransport())
1633 transport->BuildCreateUpdateBlockForPlayer(&data, player);
1634
1635 // build data for self presence in world at own client (one time for map)
1636 player->BuildCreateUpdateBlockForPlayer(&data, player);
1637
1638 // build and send self update packet before sending to player his own auras
1639 data.BuildPacket(packet);
1640 player->SendDirectMessage(&packet);
1641
1642 // send to player his own auras (this is needed here for timely initialization of some fields on client)
1643 player->GetAurasForTarget(player, true);
1644
1645 // clean buffers for further work
1646 packet.clear();
1647 data.Clear();
1648
1649 // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map
1650 if (Transport* transport = player->GetTransport())
1651 for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
1652 if (player != (*itr) && player->HaveAtClient(*itr))
1653 (*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
1654
1655 data.BuildPacket(packet);
1656 player->SendDirectMessage(&packet);
1657}
void clear()
Definition ByteBuffer.h:122
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5852
bool HaveAtClient(WorldObject const *u) const
Definition Player.cpp:11586
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) override
Definition Player.cpp:3977
void GetAurasForTarget(Unit *target, bool force=false)
Definition Player.cpp:12306
void Clear()
Definition UpdateData.cpp:71
Transport * GetTransport() const
Definition Object.h:694

References Player::BuildCreateUpdateBlockForPlayer(), UpdateData::BuildPacket(), UpdateData::Clear(), ByteBuffer::clear(), Player::GetAurasForTarget(), Object::GetGUID(), WorldObject::GetTransport(), Player::HaveAtClient(), LOG_DEBUG, Player::SendDirectMessage(), and ObjectGuid::ToString().

Referenced by AddPlayerToMap(), and WorldSession::HandlePlayerLoginToCharInWorld().

◆ SendInitTransports()

void Map::SendInitTransports ( Player player)
1671{
1672 if (_transports.empty())
1673 return;
1674
1675 // Hack to send out transports
1676 UpdateData transData;
1677 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1678 if (*itr != player->GetTransport() && (!sToCloud9Sidecar->ClusterModeEnabled() || player->InSamePhase(*itr)))
1679 (*itr)->BuildCreateUpdateBlockForPlayer(&transData, player);
1680
1681 if (!transData.HasData())
1682 return;
1683
1684 WorldPacket packet;
1685 transData.BuildPacket(packet);
1686 player->SendDirectMessage(&packet);
1687}
#define sToCloud9Sidecar
Definition TC9Sidecar.h:76
bool HasData() const
Definition UpdateData.h:60
bool InSamePhase(WorldObject const *obj) const
Definition Object.h:518

References _transports, UpdateData::BuildPacket(), WorldObject::GetTransport(), UpdateData::HasData(), WorldObject::InSamePhase(), Player::SendDirectMessage(), and sToCloud9Sidecar.

Referenced by AddPlayerToMap(), and WorldSession::HandlePlayerLoginToCharInWorld().

◆ SendObjectUpdates()

void Map::SendObjectUpdates ( )
private
1709{
1710 UpdateDataMapType update_players;
1711
1712 while (!_updateObjects.empty())
1713 {
1714 Object* obj = *_updateObjects.begin();
1715 ASSERT(obj->IsInWorld());
1716
1717 _updateObjects.erase(_updateObjects.begin());
1718 obj->BuildUpdate(update_players);
1719 }
1720
1721 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
1722 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
1723 {
1724 iter->second.BuildPacket(packet);
1725 iter->first->SendDirectMessage(&packet);
1726 packet.clear(); // clean the string
1727 }
1728}
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition Object.h:100
virtual void BuildUpdate(UpdateDataMapType &)
Definition Object.h:192

References _updateObjects, ASSERT, Object::BuildUpdate(), ByteBuffer::clear(), and Object::IsInWorld().

Referenced by Update().

◆ SendRemoveTransports()

void Map::SendRemoveTransports ( Player player)
1690{
1691 if (_transports.empty())
1692 return;
1693
1694 // Hack to send out transports
1695 UpdateData transData;
1696 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1697 if (*itr != player->GetTransport())
1698 (*itr)->BuildOutOfRangeUpdateBlock(&transData);
1699
1700 if (!transData.HasData())
1701 return;
1702
1703 WorldPacket packet;
1704 transData.BuildPacket(packet);
1705 player->SendDirectMessage(&packet);
1706}

References _transports, UpdateData::BuildPacket(), WorldObject::GetTransport(), UpdateData::HasData(), and Player::SendDirectMessage().

Referenced by RemovePlayerFromMap().

◆ SendToPlayers()

void Map::SendToPlayers ( WorldPacket const *  data) const
1901{
1902 for (MapRefMgr::const_iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1903 itr->GetSource()->SendDirectMessage(data);
1904}

References MapRefMgr::begin(), MapRefMgr::end(), and m_mapRefMgr.

Referenced by boss_ossirian::JustEngagedWith(), and InstanceScript::SendEncounterUnit().

◆ SendZoneDynamicInfo()

void Map::SendZoneDynamicInfo ( uint32  zoneId,
Player player 
) const
3197{
3198 ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
3199 if (itr == _zoneDynamicInfo.end())
3200 return;
3201
3202 if (uint32 music = itr->second.MusicId)
3203 player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
3204
3205 SendZoneWeather(itr->second, player);
3206
3207 if (uint32 overrideLight = itr->second.OverrideLightId)
3208 {
3209 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4);
3210 data << uint32(_defaultLight);
3211 data << uint32(overrideLight);
3212 data << uint32(itr->second.LightFadeInTime);
3213 player->SendDirectMessage(&data);
3214 }
3215}
void SendZoneWeather(uint32 zoneId, Player *player) const
Definition Map.cpp:3217
Definition MiscPackets.h:58
@ SMSG_OVERRIDE_LIGHT
Definition Opcodes.h:1072

References _defaultLight, _zoneDynamicInfo, Player::SendDirectMessage(), SendZoneWeather(), and SMSG_OVERRIDE_LIGHT.

Referenced by Player::UpdateZone().

◆ SendZoneMessage()

bool Map::SendZoneMessage ( uint32  zone,
WorldPacket const *  packet,
WorldSession const *  self = nullptr,
TeamId  teamId = TEAM_NEUTRAL 
) const

Send a packet to all players (or players selected team) in the zone (except self if mentioned)

3169{
3170 bool foundPlayerToSend = false;
3171
3172 for (MapReference const& ref : GetPlayers())
3173 {
3174 Player* player = ref.GetSource();
3175 if (player->IsInWorld() &&
3176 player->GetZoneId() == zone &&
3177 player->GetSession() != self &&
3178 (teamId == TEAM_NEUTRAL || player->GetTeamId() == teamId))
3179 {
3180 player->SendDirectMessage(packet);
3181 foundPlayerToSend = true;
3182 }
3183 }
3184
3185 return foundPlayerToSend;
3186}
@ TEAM_NEUTRAL
Definition SharedDefines.h:750
Definition MapReference.h:25
TeamId GetTeamId(bool original=false) const
Definition Player.h:2138
WorldSession * GetSession() const
Definition Player.h:2030

References GetPlayers(), Player::GetSession(), Player::GetTeamId(), WorldObject::GetZoneId(), Object::IsInWorld(), Player::SendDirectMessage(), and TEAM_NEUTRAL.

Referenced by SendZoneText(), SetZoneMusic(), SetZoneOverrideLight(), SetZoneWeather(), and Weather::UpdateWeather().

◆ SendZoneText()

void Map::SendZoneText ( uint32  zoneId,
char const *  text,
WorldSession const *  self = nullptr,
TeamId  teamId = TEAM_NEUTRAL 
) const

Send a System Message to all players in the zone (except self if mentioned)

3190{
3191 WorldPacket data;
3192 ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, text);
3193 SendZoneMessage(zoneId, &data, self, teamId);
3194}
@ CHAT_MSG_SYSTEM
Definition SharedDefines.h:3385
@ LANG_UNIVERSAL
Definition SharedDefines.h:723
static std::size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
Definition Chat.cpp:273
bool SendZoneMessage(uint32 zone, WorldPacket const *packet, WorldSession const *self=nullptr, TeamId teamId=TEAM_NEUTRAL) const
Send a packet to all players (or players selected team) in the zone (except self if mentioned)
Definition Map.cpp:3168

References ChatHandler::BuildChatPacket(), CHAT_MSG_SYSTEM, LANG_UNIVERSAL, and SendZoneMessage().

Referenced by OPvPCapturePointEP_EWT::ChangeState(), OPvPCapturePointEP_NPT::ChangeState(), OPvPCapturePointEP_CGT::ChangeState(), OPvPCapturePointEP_PWT::ChangeState(), OPvPCapturePointHP::ChangeState(), OPvPCapturePointTF::ChangeState(), OPvPCapturePointZM_Beacon::ChangeState(), OPvPCapturePointNA::FactionTakeOver(), OutdoorPvPSI::HandleAreaTrigger(), OPvPCapturePointZM_Graveyard::HandleOpenGo(), and OPvPCapturePointNA::Update().

◆ SendZoneWeather() [1/2]

void Map::SendZoneWeather ( uint32  zoneId,
Player player 
) const
3218{
3219 ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
3220 if (itr == _zoneDynamicInfo.end())
3221 return;
3222
3223 SendZoneWeather(itr->second, player);
3224}

References _zoneDynamicInfo, and SendZoneWeather().

Referenced by SendZoneDynamicInfo(), and SendZoneWeather().

◆ SendZoneWeather() [2/2]

void Map::SendZoneWeather ( ZoneDynamicInfo const &  zoneDynamicInfo,
Player player 
) const
3227{
3228 if (WeatherState weatherId = zoneDynamicInfo.WeatherId)
3229 {
3230 WorldPackets::Misc::Weather weather(weatherId, zoneDynamicInfo.WeatherGrade);
3231 player->SendDirectMessage(weather.Write());
3232 }
3233 else if (zoneDynamicInfo.DefaultWeather)
3234 zoneDynamicInfo.DefaultWeather->SendWeatherUpdateToPlayer(player);
3235 else
3237}
Definition MiscPackets.h:32
WeatherState
Definition Weather.h:46
static void SendFineWeatherUpdateToPlayer(Player *player)
Definition Weather.cpp:193

References ZoneDynamicInfo::DefaultWeather, Player::SendDirectMessage(), Weather::SendFineWeatherUpdateToPlayer(), ZoneDynamicInfo::WeatherGrade, ZoneDynamicInfo::WeatherId, and WorldPackets::Misc::Weather::Write().

◆ SetVisibilityRange()

◆ SetZoneMusic()

◆ SetZoneOverrideLight()

void Map::SetZoneOverrideLight ( uint32  zoneId,
uint32  lightId,
Milliseconds  fadeInTime 
)
3303{
3304 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
3305 info.OverrideLightId = lightId;
3306 info.LightFadeInTime = static_cast<uint32>(fadeInTime.count());
3307
3308 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4);
3309 data << uint32(_defaultLight);
3310 data << uint32(lightId);
3311 data << uint32(static_cast<uint32>(fadeInTime.count()));
3312 SendZoneMessage(zoneId, &data);
3313}
uint32 LightFadeInTime
Definition Map.h:146
uint32 OverrideLightId
Definition Map.h:145

References _defaultLight, _zoneDynamicInfo, ZoneDynamicInfo::LightFadeInTime, ZoneDynamicInfo::OverrideLightId, SendZoneMessage(), and SMSG_OVERRIDE_LIGHT.

Referenced by boss_the_lich_king::boss_the_lich_kingAI::DoAction(), boss_malygos::EnterEvadeMode(), boss_malygos::MovementInform(), boss_the_lich_king::boss_the_lich_kingAI::SpellHitTarget(), npc_tirion_fordring_tft::npc_tirion_fordringAI::UpdateAI(), and boss_malygos::UpdateAI().

◆ SetZoneWeather()

void Map::SetZoneWeather ( uint32  zoneId,
WeatherState  weatherId,
float  weatherGrade 
)

◆ SpawnGroupDespawn()

bool Map::SpawnGroupDespawn ( uint32  groupId,
bool  deleteRespawnTimes = false 
)
2699{
2700 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(groupId);
2701 if (!groupData || (groupData->flags & SPAWNGROUP_FLAG_SYSTEM))
2702 {
2703 LOG_ERROR("maps", "Tried to despawn non-existing (or system) spawn group {}. Blocked.", groupId);
2704 return false;
2705 }
2706
2707 if (groupData->mapId != SPAWNGROUP_MAP_UNSET && groupData->mapId != GetId())
2708 {
2709 LOG_ERROR("maps", "Tried to despawn group {} on map {}, but group has map {}. Blocked.",
2710 groupId, GetId(), groupData->mapId);
2711 return false;
2712 }
2713
2714 // Mark group as inactive on this map (toggle to inactive state)
2715 if (groupData->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN)
2716 _toggledSpawnGroupIds.erase(groupId);
2717 else
2718 _toggledSpawnGroupIds.insert(groupId);
2719
2720 std::vector<WorldObject*> toUnload;
2721 auto range = sObjectMgr->GetSpawnDataForGroup(groupId);
2722 for (auto it = range.first; it != range.second; ++it)
2723 {
2724 SpawnData const* data = it->second;
2725 ObjectGuid::LowType spawnId = data->spawnId;
2726
2727 if (deleteRespawnTimes)
2728 RemoveRespawnTime(data->type, spawnId);
2729
2730 switch (data->type)
2731 {
2733 {
2734 auto bounds = _creatureBySpawnIdStore.equal_range(spawnId);
2735 for (auto itr = bounds.first; itr != bounds.second; ++itr)
2736 toUnload.emplace_back(itr->second);
2737 break;
2738 }
2740 {
2741 auto bounds = _gameobjectBySpawnIdStore.equal_range(spawnId);
2742 for (auto itr = bounds.first; itr != bounds.second; ++itr)
2743 toUnload.emplace_back(itr->second);
2744 break;
2745 }
2746 default:
2747 break;
2748 }
2749 }
2750
2751 for (WorldObject* obj : toUnload)
2752 obj->AddObjectToRemoveList();
2753
2754 return true;
2755}
constexpr uint32 SPAWNGROUP_MAP_UNSET
Definition SpawnData.h:55
void AddObjectToRemoveList(WorldObject *obj)
Definition Map.cpp:1795
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId)
Definition Map.h:466
Definition SpawnData.h:66
ObjectGuid::LowType spawnId
Definition SpawnData.h:68
SpawnObjectType const type
Definition SpawnData.h:67
uint32 mapId
Definition SpawnData.h:61

References _creatureBySpawnIdStore, _gameobjectBySpawnIdStore, _toggledSpawnGroupIds, SpawnGroupTemplateData::flags, GetId(), LOG_ERROR, SpawnGroupTemplateData::mapId, RemoveRespawnTime(), sObjectMgr, SPAWN_TYPE_CREATURE, SPAWN_TYPE_GAMEOBJECT, SPAWNGROUP_FLAG_MANUAL_SPAWN, SPAWNGROUP_FLAG_SYSTEM, SPAWNGROUP_MAP_UNSET, SpawnData::spawnId, and SpawnData::type.

Referenced by gobject_commandscript::HandleGameObjectDespawnGroupCommand(), npc_commandscript::HandleNpcDespawnGroupCommand(), and SmartScript::ProcessAction().

◆ SpawnGroupSpawn()

bool Map::SpawnGroupSpawn ( uint32  groupId,
bool  ignoreRespawn = false,
bool  force = false 
)
2615{
2616 SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(groupId);
2617 if (!groupData || (groupData->flags & SPAWNGROUP_FLAG_SYSTEM))
2618 {
2619 LOG_ERROR("maps", "Tried to spawn non-existing (or system) spawn group {}. Blocked.", groupId);
2620 return false;
2621 }
2622
2623 if (groupData->mapId != SPAWNGROUP_MAP_UNSET && groupData->mapId != GetId())
2624 {
2625 LOG_ERROR("maps", "Tried to spawn group {} on map {}, but group has map {}. Blocked.",
2626 groupId, GetId(), groupData->mapId);
2627 return false;
2628 }
2629
2630 // Mark group as active on this map (toggle to active state)
2631 if (groupData->flags & SPAWNGROUP_FLAG_MANUAL_SPAWN)
2632 _toggledSpawnGroupIds.insert(groupId);
2633 else
2634 _toggledSpawnGroupIds.erase(groupId);
2635
2636 auto range = sObjectMgr->GetSpawnDataForGroup(groupId);
2637 for (auto it = range.first; it != range.second; ++it)
2638 {
2639 SpawnData const* data = it->second;
2640 ObjectGuid::LowType spawnId = data->spawnId;
2641
2642 // Check if there's already an alive instance
2643 if (!force)
2644 {
2645 if (data->type == SPAWN_TYPE_CREATURE)
2646 {
2647 auto bounds = _creatureBySpawnIdStore.equal_range(spawnId);
2648 bool alive = false;
2649 for (auto itr = bounds.first; itr != bounds.second; ++itr)
2650 if (itr->second->IsAlive())
2651 alive = true;
2652 if (alive)
2653 continue;
2654 }
2655 else if (data->type == SPAWN_TYPE_GAMEOBJECT)
2656 {
2657 if (_gameobjectBySpawnIdStore.count(spawnId))
2658 continue;
2659 }
2660 }
2661
2662 time_t respawnTime = GetRespawnTime(data->type, spawnId);
2663 if (respawnTime && respawnTime > GameTime::GetGameTime().count())
2664 {
2665 if (!force && !ignoreRespawn)
2666 continue;
2667 RemoveRespawnTime(data->type, spawnId);
2668 }
2669
2670 // Don't spawn if grid isn't loaded (will be handled in grid loader)
2671 if (!IsGridLoaded(data->posX, data->posY))
2672 continue;
2673
2674 switch (data->type)
2675 {
2677 {
2678 Creature* creature = new Creature();
2679 if (!creature->LoadCreatureFromDB(spawnId, this, true, true))
2680 delete creature;
2681 break;
2682 }
2684 {
2685 GameObject* gameobject = new GameObject();
2686 if (!gameobject->LoadGameObjectFromDB(spawnId, this, true))
2687 delete gameobject;
2688 break;
2689 }
2690 default:
2691 break;
2692 }
2693 }
2694
2695 return true;
2696}
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.h:454

References _creatureBySpawnIdStore, _gameobjectBySpawnIdStore, _toggledSpawnGroupIds, SpawnGroupTemplateData::flags, GameTime::GetGameTime(), GetId(), GetRespawnTime(), IsGridLoaded(), Creature::LoadCreatureFromDB(), GameObject::LoadGameObjectFromDB(), LOG_ERROR, SpawnGroupTemplateData::mapId, SpawnData::posX, SpawnData::posY, RemoveRespawnTime(), sObjectMgr, SPAWN_TYPE_CREATURE, SPAWN_TYPE_GAMEOBJECT, SPAWNGROUP_FLAG_MANUAL_SPAWN, SPAWNGROUP_FLAG_SYSTEM, SPAWNGROUP_MAP_UNSET, SpawnData::spawnId, and SpawnData::type.

Referenced by gobject_commandscript::HandleGameObjectSpawnGroupCommand(), npc_commandscript::HandleNpcSpawnGroupCommand(), and SmartScript::ProcessAction().

◆ StartPlayersRedirectKickTimer()

void Map::StartPlayersRedirectKickTimer ( )
1857{
1858 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1859 itr->GetSource()->SendSystemMessage("Preparing to enter parallel dimension... One minute!\nAccelerate transfer: Teleport or type \"/ready\" in chat.");
1860
1863
1865
1866}
constexpr auto SECOND
Definition Common.h:46
TimeTrackerSmall _lastAnnounceRedirectKickTimer
Definition Map.h:711
void Update(int32 diff)
Definition Timer.h:239
void Reset(int32 interval)
Definition Timer.h:249

References _lastAnnounceRedirectKickTimer, _redirectKickTimer, MapRefMgr::begin(), MapRefMgr::end(), IN_MILLISECONDS, m_mapRefMgr, TimeTrackerSmall::Reset(), SECOND, and TimeTrackerSmall::Update().

◆ StopPlayersRedirectKickTimer()

void Map::StopPlayersRedirectKickTimer ( )

◆ SummonCreature()

TempSummon * Map::SummonCreature ( uint32  entry,
Position const &  pos,
SummonPropertiesEntry const *  properties = nullptr,
uint32  duration = 0,
WorldObject summoner = nullptr,
uint32  spellId = 0,
uint32  vehId = 0,
bool  visibleBySummonerOnly = false 
)
2242{
2243 uint32 mask = UNIT_MASK_SUMMON;
2244 if (properties)
2245 {
2246 switch (properties->Category)
2247 {
2249 mask = UNIT_MASK_GUARDIAN;
2250 break;
2252 mask = UNIT_MASK_PUPPET;
2253 break;
2255 mask = UNIT_MASK_MINION;
2256 break;
2260 {
2261 switch (properties->Type)
2262 {
2263 case SUMMON_TYPE_MINION:
2266 mask = UNIT_MASK_GUARDIAN;
2267 break;
2268 case SUMMON_TYPE_TOTEM:
2270 mask = UNIT_MASK_TOTEM;
2271 break;
2274 mask = UNIT_MASK_SUMMON;
2275 break;
2277 case SUMMON_TYPE_JEEVES:
2278 mask = UNIT_MASK_MINION;
2279 break;
2280 default:
2281 if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
2282 mask = UNIT_MASK_GUARDIAN;
2283 break;
2284 }
2285 break;
2286 }
2287 default:
2288 return nullptr;
2289 }
2290 }
2291
2292 uint32 phase = PHASEMASK_NORMAL;
2293 if (summoner)
2294 phase = summoner->GetPhaseMask();
2295
2296 TempSummon* summon = nullptr;
2297 switch (mask)
2298 {
2299 case UNIT_MASK_SUMMON:
2300 summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2301 break;
2302 case UNIT_MASK_GUARDIAN:
2303 summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2304 break;
2305 case UNIT_MASK_PUPPET:
2306 summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2307 break;
2308 case UNIT_MASK_TOTEM:
2309 summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2310 break;
2311 case UNIT_MASK_MINION:
2312 summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2313 break;
2314 default:
2315 return nullptr;
2316 }
2317
2318 EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
2319 if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
2320 {
2321 delete summon;
2322 return nullptr;
2323 }
2324
2325 summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
2326
2327 summon->SetHomePosition(pos);
2328
2329 summon->InitStats(duration);
2330
2331 summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
2332
2333 bool summonerHasTransport = summoner && summoner->GetTransport();
2334 bool summonerIsVehicle = summoner && summoner->IsUnit() && summoner->ToUnit()->IsVehicle();
2335 bool checkTransport = summon->GetOwnerGUID().IsPlayer() || (summonerHasTransport && !summonerIsVehicle);
2336 if (!AddToMap(summon->ToCreature(), checkTransport))
2337 {
2338 delete summon;
2339 return nullptr;
2340 }
2341
2342 summon->InitSummon();
2343
2344 // call MoveInLineOfSight for nearby players and creatures; players are visited
2345 // first (grid typelist order) so aggressive summons prefer them over pets/totems
2346 Acore::AIRelocationNotifier notifier(*summon, true);
2347 Cell::VisitObjects(summon, notifier, GetVisibilityRange());
2348
2349 return summon;
2350}
@ PHASEMASK_NORMAL
Definition Object.h:63
@ SUMMON_TYPE_VEHICLE2
Definition SharedDefines.h:3537
@ SUMMON_TYPE_LIGHTWELL
Definition SharedDefines.h:3538
@ SUMMON_TYPE_MINION
Definition SharedDefines.h:3530
@ SUMMON_TYPE_GUARDIAN
Definition SharedDefines.h:3529
@ SUMMON_TYPE_JEEVES
Definition SharedDefines.h:3539
@ SUMMON_TYPE_TOTEM
Definition SharedDefines.h:3531
@ SUMMON_TYPE_VEHICLE
Definition SharedDefines.h:3536
@ SUMMON_TYPE_MINIPET
Definition SharedDefines.h:3532
@ SUMMON_TYPE_GUARDIAN2
Definition SharedDefines.h:3533
@ SUMMON_CATEGORY_PET
Definition SharedDefines.h:3518
@ SUMMON_CATEGORY_VEHICLE
Definition SharedDefines.h:3520
@ SUMMON_CATEGORY_ALLY
Definition SharedDefines.h:3517
@ SUMMON_CATEGORY_PUPPET
Definition SharedDefines.h:3519
@ SUMMON_CATEGORY_WILD
Definition SharedDefines.h:3516
@ SUMMON_CATEGORY_UNK
Definition SharedDefines.h:3521
@ UNIT_MASK_PUPPET
Definition UnitDefines.h:165
@ UNIT_MASK_TOTEM
Definition UnitDefines.h:162
@ UNIT_MASK_SUMMON
Definition UnitDefines.h:159
@ UNIT_MASK_GUARDIAN
Definition UnitDefines.h:161
@ UNIT_MASK_MINION
Definition UnitDefines.h:160
@ UNIT_CREATED_BY_SPELL
Definition UpdateFields.h:138
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:347
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, CreatureData const *data=nullptr)
Definition Creature.cpp:1151
Definition TemporarySummon.h:106
float GetVisibilityRange() const
Definition Map.h:200
Definition TemporarySummon.h:87
bool IsPlayer() const
Definition ObjectGuid.h:172
Definition TemporarySummon.h:125
Definition TemporarySummon.h:50
virtual void InitSummon()
Definition TemporarySummon.cpp:257
virtual void InitStats(uint32 lifetime)
Definition TemporarySummon.cpp:200
void SetVisibleBySummonerOnly(bool visibleBySummonerOnly)
Definition TemporarySummon.h:71
Definition Totem.h:51
ObjectGuid GetOwnerGUID() const
Definition Unit.h:714
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:17367
Definition GridNotifiers.h:91
static void VisitObjects(WorldObject const *obj, T &visitor, float radius)
Definition CellImpl.h:165

References AddToMap(), SummonPropertiesEntry::Category, Creature::Create(), ObjectGuid::Empty, EnsureGridLoaded(), SummonPropertiesEntry::Flags, Object::GetGUID(), Position::GetOrientation(), Unit::GetOwnerGUID(), WorldObject::GetPhaseMask(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), WorldObject::GetTransport(), GetVisibilityRange(), TempSummon::InitStats(), TempSummon::InitSummon(), ObjectGuid::IsPlayer(), Object::IsUnit(), Unit::IsVehicle(), PHASEMASK_NORMAL, Creature::SetHomePosition(), Unit::SetUInt32Value(), TempSummon::SetVisibleBySummonerOnly(), SUMMON_CATEGORY_ALLY, SUMMON_CATEGORY_PET, SUMMON_CATEGORY_PUPPET, SUMMON_CATEGORY_UNK, SUMMON_CATEGORY_VEHICLE, SUMMON_CATEGORY_WILD, SUMMON_TYPE_GUARDIAN, SUMMON_TYPE_GUARDIAN2, SUMMON_TYPE_JEEVES, SUMMON_TYPE_LIGHTWELL, SUMMON_TYPE_MINION, SUMMON_TYPE_MINIPET, SUMMON_TYPE_TOTEM, SUMMON_TYPE_VEHICLE, SUMMON_TYPE_VEHICLE2, Object::ToCreature(), Object::ToUnit(), SummonPropertiesEntry::Type, UNIT_CREATED_BY_SPELL, UNIT_MASK_GUARDIAN, UNIT_MASK_MINION, UNIT_MASK_PUPPET, UNIT_MASK_SUMMON, UNIT_MASK_TOTEM, and Cell::VisitObjects().

Referenced by instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::ChromieWhisper(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::DoSummonGrandChampion(), Spell::EffectSummonType(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::HandleOutro(), spell_temple_of_atal_hakkar_awaken_the_soulflayer::HandleSendEvent(), spell_halion_damage_aoe_summon::HandleSummon(), spell_putricide_mutated_transformation::HandleSummon(), spell_q13010_jokkum_summon::HandleSummon(), spell_wintergrasp_create_vehicle::HandleSummon(), boss_varos::boss_varosAI::JustDied(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnCreatureCreate(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::OnPlayerEnter(), instance_ulduar::instance_ulduar_InstanceMapScript::OnPlayerEnter(), at_tyrannus_event_starter::OnTrigger(), instance_karazhan::instance_karazhan_InstanceMapScript::OnUnitDeath(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnUnitDeath(), spell_halion_twilight_phasing::Phase(), instance_magisters_terrace::instance_magisters_terrace_InstanceMapScript::ProcessEvent(), instance_sethekk_halls::instance_sethekk_halls_InstanceMapScript::ProcessEvent(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::ProcessEvent(), instance_stratholme::instance_stratholme_InstanceMapScript::ProcessSlaughterEvent(), instance_blackrock_depths::ReplaceMoiraIfSaved(), boss_ossirian::Reset(), ScheduleCreatureRespawn(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::ScheduleNextPortal(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetBossState(), instance_ulduar::instance_ulduar_InstanceMapScript::SetBossState(), instance_blackrock_depths::SetData(), instance_scholomance::instance_scholomance_InstanceMapScript::SetData(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::SetData(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SetData(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::SetData(), instance_ulduar::instance_ulduar_InstanceMapScript::SpawnLeviathanEncounterVehicles(), instance_zulfarrak::instance_zulfarrak_InstanceMapScript::SpawnPyramidWave(), SummonCreatureGroup(), instance_violet_hold::instance_violet_hold_InstanceMapScript::SummonDefenseSystem(), Spell::SummonGuardian(), instance_zulaman::instance_zulaman_InstanceMapScript::SummonHostage(), instance_molten_core::SummonMajordomoExecutus(), WorldState::SummonMouth(), WorldState::SummonPallid(), instance_blackrock_spire::SummonSolakarWave(), instance_blackwing_lair::Update(), instance_stratholme::instance_stratholme_InstanceMapScript::Update(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::Update(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::Update(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::Update(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::Update(), instance_ulduar::instance_ulduar_InstanceMapScript::Update(), boss_the_lich_king::boss_the_lich_kingAI::UpdateAI(), npc_brann_bronzebeard_algalon::UpdateAI(), and instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::UpdateEventState().

◆ SummonCreatureGroup()

void Map::SummonCreatureGroup ( uint8  group,
std::list< TempSummon * > *  list = nullptr 
)

Summons group of creatures.

Parameters
groupId of group to summon.
listList to store pointers to summoned creatures.
2360{
2361 std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetId(), SUMMONER_TYPE_MAP, group);
2362 if (!data)
2363 return;
2364
2365 for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2366 if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, nullptr, itr->time))
2367 if (list)
2368 list->push_back(summon);
2369}
@ SUMMONER_TYPE_MAP
Definition TemporarySummon.h:28

References GetId(), sObjectMgr, SummonCreature(), and SUMMONER_TYPE_MAP.

Referenced by at_ancient_leaf::OnTrigger(), and instance_hyjal::instance_mount_hyjal_InstanceMapScript::ScheduleWaves().

◆ SummonGameObject() [1/2]

GameObject * Map::SummonGameObject ( uint32  entry,
float  x,
float  y,
float  z,
float  ang,
float  rotation0,
float  rotation1,
float  rotation2,
float  rotation3,
uint32  respawnTime,
bool  checkTransport = true 
)
2396{
2397 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
2398 if (!goinfo)
2399 {
2400 LOG_ERROR("sql.sql", "Gameobject template {} not found in database!", entry);
2401 return nullptr;
2402 }
2403
2404 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
2405 if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
2406 {
2407 delete go;
2408 return nullptr;
2409 }
2410
2411 // Xinef: if gameobject is temporary, set custom spellid
2412 if (respawnTime)
2413 go->SetSpellId(1);
2414
2415 go->SetRespawnTime(respawnTime);
2416 go->SetSpawnedByDefault(false);
2417 AddToMap(go, checkTransport);
2418 return go;
2419}
virtual bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const &rotation, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition GameObject.cpp:270
void SetSpawnedByDefault(bool b)
Definition GameObject.h:197
void SetSpellId(uint32 id)
Definition GameObject.h:177
Definition Transport.h:120
Definition GameObjectData.h:32

References AddToMap(), GameObject::Create(), GO_STATE_READY, LOG_ERROR, PHASEMASK_NORMAL, GameObject::SetRespawnTime(), GameObject::SetSpawnedByDefault(), GameObject::SetSpellId(), and sObjectMgr.

Referenced by boss_thorim::DamageTaken(), boss_four_horsemen::boss_four_horsemenAI::JustDied(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::OnGameObjectCreate(), SummonGameObject(), SummonGameObjectGroup(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::Update(), npc_belnistrasz::npc_belnistraszAI::UpdateAI(), and boss_mimiron::UpdateAI().

◆ SummonGameObject() [2/2]

GameObject * Map::SummonGameObject ( uint32  entry,
Position const &  pos,
float  rotation0 = 0.0f,
float  rotation1 = 0.0f,
float  rotation2 = 0.0f,
float  rotation3 = 0.0f,
uint32  respawnTime = 100,
bool  checkTransport = true 
)
2422{
2423 return SummonGameObject(entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), rotation0, rotation1, rotation2, rotation3, respawnTime, checkTransport);
2424}
GameObject * SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true)
Definition Object.cpp:2395

References Position::GetOrientation(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), and SummonGameObject().

◆ SummonGameObjectGroup()

void Map::SummonGameObjectGroup ( uint8  group,
std::list< GameObject * > *  list = nullptr 
)
2372{
2373 std::vector<GameObjectSummonData> const* data = sObjectMgr->GetGameObjectSummonGroup(GetId(), SUMMONER_TYPE_MAP, group);
2374 if (!data)
2375 return;
2376
2377 for (std::vector<GameObjectSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2378 if (GameObject* go = SummonGameObject(itr->entry, itr->pos.GetPositionX(), itr->pos.GetPositionY(), itr->pos.GetPositionZ(), itr->pos.GetOrientation(), itr->rot.x, itr->rot.y, itr->rot.z, itr->rot.w, itr->respawnTime))
2379 if (list)
2380 list->push_back(go);
2381}

References GetId(), sObjectMgr, SUMMONER_TYPE_MAP, and SummonGameObject().

◆ ToBattlegroundMap() [1/2]

◆ ToBattlegroundMap() [2/2]

BattlegroundMap const * Map::ToBattlegroundMap ( ) const
inline
394{ if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; }

References IsBattlegroundOrArena().

◆ ToInstanceMap() [1/2]

◆ ToInstanceMap() [2/2]

InstanceMap const * Map::ToInstanceMap ( ) const
inline
391{ if (IsDungeon()) return (InstanceMap const*)((InstanceMap*)this); else return nullptr; }

References IsDungeon().

◆ ToMapInstanced() [1/2]

MapInstanced * Map::ToMapInstanced ( )
inline
387{ if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); else return nullptr; }
Definition MapInstanced.h:26
bool Instanceable() const
Definition Map.h:298

References Instanceable().

Referenced by MapMgr::DoForAllMaps(), and MapMgr::DoForAllMapsWithMapId().

◆ ToMapInstanced() [2/2]

MapInstanced const * Map::ToMapInstanced ( ) const
inline
388{ if (Instanceable()) return (MapInstanced const*)((MapInstanced*)this); else return nullptr; }

References Instanceable().

◆ UnloadAll()

void Map::UnloadAll ( )
virtual

Reimplemented in InstanceMap, and MapInstanced.

1053{
1054 // clear all delayed moves, useless anyway do this moves before map unload.
1055 _creaturesToMove.clear();
1056 _gameObjectsToMove.clear();
1057
1059 {
1060 MapGridType* grid = i->GetSource();
1061 ++i;
1062 if (grid)
1063 UnloadGrid(*grid);
1064 }
1065
1066 // pussywizard: crashfix, some npc can be left on transport (not a default passenger)
1067 if (!AllTransportsEmpty())
1069
1070 for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
1071 {
1072 Transport* transport = *itr;
1073 ++itr;
1074
1075 RemoveFromMap<Transport>(transport, true);
1076 }
1077
1078 _transports.clear();
1079
1080 for (auto& cellCorpsePair : _corpsesByGrid)
1081 {
1082 for (Corpse* corpse : cellCorpsePair.second)
1083 {
1084 corpse->RemoveFromWorld();
1085 corpse->ResetMap();
1086 delete corpse;
1087 }
1088 }
1089
1090 _corpsesByGrid.clear();
1091 _corpsesByPlayer.clear();
1092 _corpseBones.clear();
1093}
Definition GridRefMgr.h:28
iterator end()
Definition GridRefMgr.h:36
void AllTransportsRemovePassengers()
Definition Map.cpp:3021
bool UnloadGrid(MapGridType &grid)
Definition Map.cpp:1026
bool AllTransportsEmpty() const
Definition Map.cpp:3012

References _corpseBones, _corpsesByGrid, _corpsesByPlayer, _creaturesToMove, _gameObjectsToMove, _transports, AllTransportsEmpty(), AllTransportsRemovePassengers(), GridRefMgr< OBJECT >::end(), and UnloadGrid().

Referenced by InstanceMap::UnloadAll(), and MapInstanced::UnloadAll().

◆ UnloadGrid()

bool Map::UnloadGrid ( MapGridType grid)
1027{
1028 _mapGridManager.UnloadGrid(grid.GetX(), grid.GetY());
1029
1030 ASSERT(i_objectsToRemove.empty());
1031 LOG_DEBUG("maps", "Unloading grid[{}, {}] for map {} finished", grid.GetX(), grid.GetY(), GetId());
1032 return true;
1033}
void UnloadGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:49
uint16 GetY() const
Definition MapGrid.h:44
uint16 GetX() const
Definition MapGrid.h:43

References _mapGridManager, ASSERT, GetId(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::GetX(), MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::GetY(), i_objectsToRemove, LOG_DEBUG, and MapGridManager::UnloadGrid().

Referenced by UnloadAll().

◆ Update()

void Map::Update ( const uint32  t_diff,
const uint32  s_diff,
bool  thread = true 
)
virtual

Process any due respawns (non-compatibility mode spawns)

  • Process necessary scripts

Reimplemented in InstanceMap, and MapInstanced.

437{
438 if (t_diff)
440
441 // Update world sessions and players
443 {
444 Player* player = m_mapRefIter->GetSource();
445 if (player && player->IsInWorld())
446 {
447 // Update session
448 WorldSession* session = player->GetSession();
449 MapSessionFilter updater(session);
450 session->Update(s_diff, updater);
451
452 // update players at tick
453 if (!t_diff)
454 player->Update(s_diff);
455 }
456 }
457
458 Events.Update(t_diff);
459
460 if (!t_diff)
461 {
463 return;
464 }
465
468 {
469 if (_respawnCheckTimer <= t_diff)
470 {
472 _respawnCheckTimer = 5000; // Check every 5 seconds
473 }
474 else
475 _respawnCheckTimer -= t_diff;
476 }
477
480
481 // Update players
483 {
484 Player* player = m_mapRefIter->GetSource();
485
486 if (!player || !player->IsInWorld())
487 continue;
488
489 player->Update(s_diff);
490
492 {
493 MarkNearbyCellsOf(player);
494
495 // If player is using far sight, update viewpoint
496 if (WorldObject* viewPoint = player->GetViewpoint())
497 {
498 if (Creature* viewCreature = viewPoint->ToCreature())
499 MarkNearbyCellsOf(viewCreature);
500 else if (DynamicObject* viewObject = viewPoint->ToDynObject())
501 MarkNearbyCellsOf(viewObject);
502 }
503 }
504 }
505
507
509
511 if (!m_scriptSchedule.empty())
512 {
513 i_scriptLock = true;
515 i_scriptLock = false;
516 }
517
521
523
525
526 UpdateWeather(t_diff);
527 UpdateExpiredCorpses(t_diff);
528
529 sScriptMgr->OnMapUpdate(this, t_diff);
530
531 METRIC_VALUE("map_creatures", uint64(GetObjectsStore().Size<Creature>()),
532 METRIC_TAG("map_id", std::to_string(GetId())),
533 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
534
535 METRIC_VALUE("map_gameobjects", uint64(GetObjectsStore().Size<GameObject>()),
536 METRIC_TAG("map_id", std::to_string(GetId())),
537 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
538}
std::uint64_t uint64
Definition Define.h:106
#define METRIC_VALUE(category, value,...)
Definition Metric.h:197
#define METRIC_TAG(name, value)
Definition Metric.h:163
@ CONFIG_RESPAWN_FORCE_COMPATIBILITY_MODE
Definition WorldConfig.h:404
void update(uint32 diff)
Definition DynamicTree.cpp:142
Definition WorldSession.h:323
void HandleDelayedVisibility()
Definition Map.cpp:698
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:358
void MoveAllGameObjectsInMoveList()
Definition Map.cpp:962
void ProcessRespawns()
Definition Map.cpp:2757
void UpdateNonPlayerObjects(uint32 const diff)
Definition Map.cpp:540
void MarkNearbyCellsOf(WorldObject *obj)
Definition Map.cpp:400
void UpdatePlayersRedirectKickEvent(uint32 diff)
Definition Map.cpp:1874
uint32 _respawnCheckTimer
Definition Map.h:675
void resetMarkedCells()
Definition Map.h:320
void UpdateWeather(uint32 const diff)
Definition Map.cpp:3239
void MoveAllDynamicObjectsInMoveList()
Definition Map.cpp:997
void MoveAllCreaturesInMoveList()
Definition Map.cpp:928
MapRefMgr::iterator m_mapRefIter
Definition Map.h:616
void SendObjectUpdates()
Definition Map.cpp:1708
void UpdateExpiredCorpses(uint32 const diff)
Definition Map.cpp:1659
DynamicObject * ToDynObject()
Definition Object.h:222
void Update(uint32 time) override
Definition PlayerUpdates.cpp:53
WorldObject * GetViewpoint() const
Definition Player.cpp:13512
FROM * GetSource() const
Definition Reference.h:97
Player session in the World.
Definition WorldSession.h:409
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update)
Definition WorldSession.cpp:378
bool Passed()
Definition Timer.h:161
void Update(time_t diff)
Definition Timer.h:152

References _mapCollisionData, _respawnCheckTimer, _updatableObjectListRecheckTimer, MapRefMgr::begin(), CONFIG_RESPAWN_FORCE_COMPATIBILITY_MODE, MapRefMgr::end(), MapCollisionData::GetDynamicTree(), GetId(), GetInstanceId(), GetObjectsStore(), Player::GetSession(), Reference< TO, FROM >::GetSource(), Player::GetViewpoint(), HandleDelayedVisibility(), i_scriptLock, Object::IsInWorld(), m_mapRefIter, m_mapRefMgr, m_scriptSchedule, MarkNearbyCellsOf(), METRIC_TAG, METRIC_VALUE, MoveAllCreaturesInMoveList(), MoveAllDynamicObjectsInMoveList(), MoveAllGameObjectsInMoveList(), IntervalTimer::Passed(), ProcessRespawns(), resetMarkedCells(), ScriptsProcess(), SendObjectUpdates(), sScriptMgr, sWorld, Object::ToCreature(), Object::ToDynObject(), IntervalTimer::Update(), DynamicMapTree::update(), WorldSession::Update(), Player::Update(), UpdateExpiredCorpses(), UpdateNonPlayerObjects(), UpdatePlayersRedirectKickEvent(), and UpdateWeather().

Referenced by MapUpdateRequest::call(), InstanceMap::Update(), and MapInstanced::Update().

◆ UpdateEncounterState()

void Map::UpdateEncounterState ( EncounterCreditType  type,
uint32  creditEntry,
Unit source 
)
2919{
2920 Difficulty difficulty_fixed = (IsSharedDifficultyMap(GetId()) ? Difficulty(GetDifficulty() % 2) : GetDifficulty());
2921 DungeonEncounterList const* encounters;
2922 // 631 : ICC - 724 : Ruby Sanctum --- For heroic difficulties, for some reason, we don't have an encounter list, so we get the encounter list from normal diff. We shouldn't change difficulty_fixed variable.
2923 if ((GetId() == 631 || GetId() == 724) && IsHeroic())
2924 {
2925 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), !Is25ManRaid() ? RAID_DIFFICULTY_10MAN_NORMAL : RAID_DIFFICULTY_25MAN_NORMAL);
2926 }
2927 else
2928 {
2929 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), difficulty_fixed);
2930 }
2931
2932 if (!encounters)
2933 {
2934 return;
2935 }
2936
2937 uint32 dungeonId = 0;
2938 bool updated = false;
2939
2940 for (DungeonEncounterList::const_iterator itr = encounters->begin(); itr != encounters->end(); ++itr)
2941 {
2942 DungeonEncounter const* encounter = *itr;
2943 if (encounter->creditType == type && encounter->creditEntry == creditEntry)
2944 {
2945 if (source)
2946 if (InstanceScript* instanceScript = source->GetInstanceScript())
2947 {
2948 uint32 prevMask = instanceScript->GetCompletedEncounterMask();
2949 instanceScript->SetCompletedEncountersMask((1 << encounter->dbcEntry->encounterIndex) | instanceScript->GetCompletedEncounterMask(), true);
2950 if (prevMask != instanceScript->GetCompletedEncounterMask())
2951 updated = true;
2952 }
2953
2954 if (encounter->lastEncounterDungeon)
2955 {
2956 dungeonId = encounter->lastEncounterDungeon;
2957 break;
2958 }
2959 }
2960 }
2961
2962 // pussywizard:
2963 LogEncounterFinished(type, creditEntry);
2964
2965 sScriptMgr->OnAfterUpdateEncounterState(this, type, creditEntry, source, difficulty_fixed, encounters, dungeonId, updated);
2966
2967 if (dungeonId)
2968 {
2969 Map::PlayerList const& players = GetPlayers();
2970 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
2971 {
2972 if (Player* player = i->GetSource())
2973 if (Group* grp = player->GetGroup())
2974 if (grp->isLFGGroup())
2975 {
2976 sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, this);
2977 return;
2978 }
2979 }
2980 }
2981}
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition DBCEnums.h:273
@ RAID_DIFFICULTY_25MAN_NORMAL
Definition DBCEnums.h:274
bool IsSharedDifficultyMap(uint32 mapid)
Definition DBCStores.cpp:829
#define sLFGMgr
Definition LFGMgr.h:665
std::list< DungeonEncounter const * > DungeonEncounterList
Definition ObjectMgr.h:716
Definition Group.h:177
Definition InstanceScript.h:143
bool Is25ManRaid() const
Definition Map.h:304
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry)
Definition Map.cpp:2983
bool IsHeroic() const
Definition Map.h:303
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1242
uint32 encounterIndex
Definition DBCStructure.h:871
Definition ObjectMgr.h:706
DungeonEncounterEntry const * dbcEntry
Definition ObjectMgr.h:710
EncounterCreditType creditType
Definition ObjectMgr.h:711
uint32 lastEncounterDungeon
Definition ObjectMgr.h:713
uint32 creditEntry
Definition ObjectMgr.h:712

References MapRefMgr::begin(), DungeonEncounter::creditEntry, DungeonEncounter::creditType, DungeonEncounter::dbcEntry, DungeonEncounterEntry::encounterIndex, MapRefMgr::end(), GetDifficulty(), GetId(), WorldObject::GetInstanceScript(), GetPlayers(), Is25ManRaid(), IsHeroic(), IsSharedDifficultyMap(), DungeonEncounter::lastEncounterDungeon, LogEncounterFinished(), RAID_DIFFICULTY_10MAN_NORMAL, RAID_DIFFICULTY_25MAN_NORMAL, sLFGMgr, sObjectMgr, and sScriptMgr.

Referenced by boss_eadric::boss_eadricAI::DamageTaken(), boss_illidari_council::DoAction(), Spell::finish(), instance_karazhan::instance_karazhan_InstanceMapScript::SetBossState(), boss_majordomo::SummonedCreatureDies(), and npc_grimstone::WaypointReached().

◆ UpdateExpiredCorpses()

void Map::UpdateExpiredCorpses ( uint32 const  diff)
1660{
1663 return;
1664
1666
1668}
void RemoveOldCorpses()
Definition Map.cpp:3130
void Reset()
Definition Timer.h:166

References _corpseUpdateTimer, IntervalTimer::Passed(), RemoveOldCorpses(), IntervalTimer::Reset(), and IntervalTimer::Update().

Referenced by Update().

◆ UpdateIteratorBack()

void Map::UpdateIteratorBack ( Player player)
2444{
2445 if (m_mapRefIter == player->GetMapRef())
2447}
MapReference const * nocheck_prev() const
Definition MapReference.h:49
MapReference & GetMapRef()
Definition Player.h:2539

References Player::GetMapRef(), m_mapRefIter, and MapReference::nocheck_prev().

Referenced by Player::ResetMap().

◆ UpdateNonPlayerObjects()

void Map::UpdateNonPlayerObjects ( uint32 const  diff)
private
541{
545
547 {
548 for (uint32 i = 0; i < _updatableObjectList.size();)
549 {
551 if (!obj->IsInWorld())
552 {
553 ++i;
554 continue;
555 }
556
557 obj->Update(diff);
558
559 if (!obj->IsUpdateNeeded())
560 {
562 // Intentional no iteration here, obj is swapped with last element in
563 // _updatableObjectList so next loop will update that object at the same index
564 }
565 else
566 ++i;
567 }
569 }
570 else
571 {
572 for (uint32 i = 0; i < _updatableObjectList.size(); ++i)
573 {
575 if (!obj->IsInWorld())
576 continue;
577
578 obj->Update(diff);
579 }
580 }
581}
void _AddObjectToUpdateList(WorldObject *obj)
Definition Map.cpp:597
virtual bool IsUpdateNeeded()
Definition Object.cpp:3242
virtual void Update(uint32 diff)
Definition Object.cpp:1072

References _AddObjectToUpdateList(), _pendingAddUpdatableObjectList, _RemoveObjectFromUpdateList(), _updatableObjectList, _updatableObjectListRecheckTimer, Object::IsInWorld(), WorldObject::IsUpdateNeeded(), IntervalTimer::Passed(), IntervalTimer::Reset(), and WorldObject::Update().

Referenced by Update().

◆ UpdatePlayersRedirectKickEvent()

void Map::UpdatePlayersRedirectKickEvent ( uint32  diff)
private
1875{
1877 return;
1878
1880
1882 {
1883 auto emptyPacket = WorldPacket();
1884 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1885 itr->GetSource()->GetSession()->HandleTC9PrepareForRedirect(emptyPacket);
1886
1887 return;
1888 }
1889
1891 return;
1892
1894
1896 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1897 itr->GetSource()->SendSystemMessage("Dimensional shift incoming! Prepare to transition in 5 seconds...");
1898}

References _lastAnnounceRedirectKickTimer, _redirectKickTimer, MapRefMgr::begin(), MapRefMgr::end(), m_mapRefMgr, TimeTrackerSmall::Passed(), and TimeTrackerSmall::Update().

Referenced by Update().

◆ UpdatePlayerZoneStats()

void Map::UpdatePlayerZoneStats ( uint32  oldZone,
uint32  newZone 
)
420{
421 // Nothing to do if no change
422 if (oldZone == newZone)
423 return;
424
425 if (oldZone != MAP_INVALID_ZONE)
426 {
427 uint32& oldZoneCount = _zonePlayerCountMap[oldZone];
428 if (oldZoneCount)
429 --oldZoneCount;
430 }
431
432 if (newZone != MAP_INVALID_ZONE)
433 ++_zonePlayerCountMap[newZone];
434}

References _zonePlayerCountMap, and MAP_INVALID_ZONE.

Referenced by RemovePlayerFromMap(), and Player::UpdateZone().

◆ UpdateWeather()

void Map::UpdateWeather ( uint32 const  diff)
3240{
3243 return;
3244
3245 for (auto&& zoneInfo : _zoneDynamicInfo)
3246 if (zoneInfo.second.DefaultWeather && !zoneInfo.second.DefaultWeather->Update(_weatherUpdateTimer.GetInterval()))
3247 zoneInfo.second.DefaultWeather.reset();
3248
3250}
virtual void Update(const uint32, const uint32, bool thread=true)
Definition Map.cpp:436

References _weatherUpdateTimer, _zoneDynamicInfo, IntervalTimer::GetInterval(), IntervalTimer::Passed(), IntervalTimer::Reset(), and IntervalTimer::Update().

Referenced by Update().

◆ Visit()

template<class T , class CONTAINER >
void Map::Visit ( Cell const &  cell,
TypeContainerVisitor< T, CONTAINER > &  visitor 
)
inline
779{
780 uint32 const grid_x = cell.GridX();
781 uint32 const grid_y = cell.GridY();
782
783 // If grid is not loaded, nothing to visit.
784 if (!IsGridLoaded(GridCoord(grid_x, grid_y)))
785 return;
786
787 GetMapGrid(grid_x, grid_y)->VisitCell(cell.CellX(), cell.CellY(), visitor);
788}
void VisitCell(uint16 const x, uint16 const y, TypeContainerVisitor< T, TT > &visitor)
Definition MapGrid.h:87

References Cell::CellX(), Cell::CellY(), GetMapGrid(), Cell::GridX(), Cell::GridY(), IsGridLoaded(), and MapGrid< GRID_OBJECT_TYPES, FAR_VISIBLE_OBJECT_TYPES >::VisitCell().

Referenced by Cell::Visit(), and Cell::VisitCircle().

Friends And Related Symbol Documentation

◆ GridObjectLoader

friend class GridObjectLoader
friend

◆ MapReference

friend class MapReference
friend

Member Data Documentation

◆ _corpseBones

std::unordered_set<Corpse*> Map::_corpseBones
private

◆ _corpsesByGrid

std::unordered_map<uint32, std::unordered_set<Corpse*> > Map::_corpsesByGrid
private

◆ _corpsesByPlayer

std::unordered_map<ObjectGuid, Corpse*> Map::_corpsesByPlayer
private

◆ _corpseUpdateTimer

IntervalTimer Map::_corpseUpdateTimer
private

Referenced by Map(), and UpdateExpiredCorpses().

◆ _creatureBySpawnIdStore

◆ _creatureRespawnTimes

◆ _creaturesToMove

std::vector<Creature*> Map::_creaturesToMove
private

◆ _defaultLight

uint32 Map::_defaultLight
private

◆ _dynamicObjectsToMove

std::vector<DynamicObject*> Map::_dynamicObjectsToMove
private

◆ _gameobjectBySpawnIdStore

◆ _gameObjectsToMove

std::vector<GameObject*> Map::_gameObjectsToMove
private

◆ _goRespawnTimes

std::unordered_map<ObjectGuid::LowType , time_t> Map::_goRespawnTimes
private

◆ _guidGenerators

std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase> > Map::_guidGenerators
private

◆ _instanceResetPeriod

time_t Map::_instanceResetPeriod
protected

◆ _lastAnnounceRedirectKickTimer

◆ _mapCollisionData

◆ _mapGridManager

◆ _objectsStore

◆ _pendingAddUpdatableObjectList

◆ _poolData

std::unique_ptr<SpawnedPoolData> Map::_poolData
private

Referenced by GetPoolData(), GetPoolData(), and Map().

◆ _redirectKickTimer

◆ _respawnCheckTimer

uint32 Map::_respawnCheckTimer {0}
private
675{0};

Referenced by Update().

◆ _respawnQueue

◆ _toggledSpawnGroupIds

std::unordered_set<uint32> Map::_toggledSpawnGroupIds
private

◆ _transports

◆ _transportsUpdateIter

TransportsContainer::iterator Map::_transportsUpdateIter
protected

Referenced by DelayedUpdate(), and RemoveFromMap().

◆ _updatableObjectList

◆ _updatableObjectListRecheckTimer

IntervalTimer Map::_updatableObjectListRecheckTimer
private

Referenced by Map(), Update(), and UpdateNonPlayerObjects().

◆ _updateObjects

std::unordered_set<Object*> Map::_updateObjects
private

◆ _weatherUpdateTimer

IntervalTimer Map::_weatherUpdateTimer
private

Referenced by Map(), and UpdateWeather().

◆ _zoneDynamicInfo

◆ _zonePlayerCountMap

std::unordered_map<uint32, uint32> Map::_zonePlayerCountMap
private

◆ _zoneWideVisibleWorldObjectsMap

◆ CreatureGroupHolder

◆ CustomData

DataMap Map::CustomData

◆ Events

EventProcessor Map::Events

◆ i_InstanceId

uint32 Map::i_InstanceId
protected

Referenced by GetInstanceId().

◆ i_mapEntry

◆ i_objectsForDelayedVisibility

std::unordered_set<Unit*> Map::i_objectsForDelayedVisibility

◆ i_objectsToRemove

std::unordered_set<WorldObject*> Map::i_objectsToRemove
private

◆ i_scriptLock

bool Map::i_scriptLock
private

◆ i_spawnMode

uint8 Map::i_spawnMode
protected

◆ Lock

std::mutex Map::Lock
protected

◆ m_mapRefIter

MapRefMgr::iterator Map::m_mapRefIter
protected

Referenced by Update(), and UpdateIteratorBack().

◆ m_mapRefMgr

◆ m_parentMap

Map* Map::m_parentMap
private

Referenced by GetParent(), and Map().

◆ m_scriptSchedule

ScriptScheduleMap Map::m_scriptSchedule
private

◆ m_unloadTimer

◆ m_VisibleDistance

◆ marked_cells

std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP * TOTAL_NUMBER_OF_CELLS_PER_MAP> Map::marked_cells
private

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