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

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 (const Cell &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
 
std::shared_mutex & GetMMapLock () const
 
void HandleDelayedVisibility ()
 
float GetHeight (float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
float GetGridHeight (float x, float y) const
 
float GetMinHeight (float x, float y) const
 
TransportGetTransportForPos (uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
 
void GetFullTerrainStatusForPosition (uint32 phaseMask, float x, float y, float z, float collisionHeight, PositionFullTerrainStatus &data, 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)
 
const char * GetMapName () const
 
Difficulty GetDifficulty () const
 
bool IsRegularDifficulty () const
 
MapDifficulty const * GetMapDifficulty () const
 
bool Instanceable () const
 
bool IsDungeon () const
 
bool IsNonRaidDungeon () const
 
bool IsRaid () const
 
bool IsRaidOrHeroicDungeon () const
 
bool IsHeroic () const
 
bool Is25ManRaid () const
 
bool IsBattleground () const
 
bool IsBattleArena () const
 
bool IsBattlegroundOrArena () const
 
bool IsWorldMap () const
 
bool GetEntrancePos (int32 &mapid, float &x, float &y)
 
void AddObjectToRemoveList (WorldObject *obj)
 
virtual void DelayedUpdate (const uint32 diff)
 
void resetMarkedCells ()
 
bool isCellMarked (uint32 pCellId)
 
void markCell (uint32 pCellId)
 
bool HavePlayers () const
 
uint32 GetPlayersCountExceptGMs () const
 
void SendToPlayers (WorldPacket const *data) const
 
PlayerList const & GetPlayers () const
 
void ScriptsStart (std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
 Put scripts in the execution queue.
 
void ScriptCommandStart (ScriptInfo const &script, uint32 delay, Object *source, Object *target)
 
void UpdateIteratorBack (Player *player)
 
TempSummonSummonCreature (uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, bool visibleBySummonerOnly=false)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true)
 
GameObjectSummonGameObject (uint32 entry, Position const &pos, float rotation0=0.0f, float rotation1=0.0f, float rotation2=0.0f, float rotation3=0.0f, uint32 respawnTime=100, bool checkTransport=true)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
 
CorpseGetCorpse (ObjectGuid const &guid)
 
CreatureGetCreature (ObjectGuid const &guid)
 
GameObjectGetGameObject (ObjectGuid const &guid)
 
TransportGetTransport (ObjectGuid const &guid)
 
DynamicObjectGetDynamicObject (ObjectGuid const &guid)
 
PetGetPet (ObjectGuid const &guid)
 
MapStoredObjectTypesContainerGetObjectsStore ()
 
CreatureBySpawnIdContainerGetCreatureBySpawnIdStore ()
 
GameObjectBySpawnIdContainerGetGameObjectBySpawnIdStore ()
 
std::unordered_set< Corpse * > const * GetCorpsesInGrid (uint32 gridId) const
 
CorpseGetCorpseByPlayer (ObjectGuid const &ownerGuid) const
 
MapInstancedToMapInstanced ()
 
MapInstanced const * ToMapInstanced () const
 
InstanceMapToInstanceMap ()
 
InstanceMap const * ToInstanceMap () const
 
BattlegroundMapToBattlegroundMap ()
 
BattlegroundMap const * ToBattlegroundMap () const
 
float GetWaterOrGroundLevel (uint32 phasemask, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=DEFAULT_COLLISION_HEIGHT) const
 
float GetHeight (uint32 phasemask, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
bool isInLineOfSight (float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 Check if a given source can reach a specific point following a path and normalize the coords. Use this method for long paths, otherwise use the overloaded method with the start coords when you need to do a quick check on small segments.
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 validate the new destination and set reachable coords Check if a given unit can reach a specific point on a segment and set the correct dest coords NOTE: use this method with small segments.
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 
bool CheckCollisionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true) const
 validate the new destination and set coords Check if a given unit can face collisions in a specific segment
 
void Balance ()
 
void RemoveGameObjectModel (const GameObjectModel &model)
 
void InsertGameObjectModel (const GameObjectModel &model)
 
bool ContainsGameObjectModel (const GameObjectModel &model) const
 
DynamicMapTree const & GetDynamicMapTree () const
 
bool GetObjectHitPos (uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
 
float GetGameObjectFloor (uint32 phasemask, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
time_t GetLinkedRespawnTime (ObjectGuid guid) const
 
time_t GetCreatureRespawnTime (ObjectGuid::LowType dbGuid) const
 
time_t GetGORespawnTime (ObjectGuid::LowType dbGuid) const
 
void SaveCreatureRespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
 
void RemoveCreatureRespawnTime (ObjectGuid::LowType dbGuid)
 
void SaveGORespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
 
void RemoveGORespawnTime (ObjectGuid::LowType dbGuid)
 
void LoadRespawnTimes ()
 
void DeleteRespawnTimes ()
 
time_t GetInstanceResetPeriod () const
 
void UpdatePlayerZoneStats (uint32 oldZone, uint32 newZone)
 
uint32 ApplyDynamicModeRespawnScaling (WorldObject const *obj, uint32 respawnDelay) const
 
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
 
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
 
std::shared_mutex MMapLock
 
MapGridManager _mapGridManager
 
MapEntry const * i_mapEntry
 
uint8 i_spawnMode
 
uint32 i_InstanceId
 
uint32 m_unloadTimer
 
float m_VisibleDistance
 
DynamicMapTree _dynamicTree
 
time_t _instanceResetPeriod
 
MapRefMgr m_mapRefMgr
 
MapRefMgr::iterator m_mapRefIter
 
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 ()
 
Player_GetScriptPlayerSourceOrTarget (Object *source, Object *target, const ScriptInfo *scriptInfo) const
 
Creature_GetScriptCreatureSourceOrTarget (Object *source, Object *target, const ScriptInfo *scriptInfo, bool bReverse=false) const
 
Unit_GetScriptUnit (Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
 
Player_GetScriptPlayer (Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
 
Creature_GetScriptCreature (Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
 
WorldObject_GetScriptWorldObject (Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
 
void _ScriptProcessDoor (Object *source, Object *target, const ScriptInfo *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::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
 

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

Constructor & Destructor Documentation

◆ Map()

Map::Map ( uint32  id,
uint32  InstanceId,
uint8  SpawnMode,
Map _parent = nullptr 
)
69 :
70 _mapGridManager(this), i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
73{
74 m_parentMap = (_parent ? _parent : this);
75
76 _zonePlayerCountMap.clear();
78
79 //lets initialize visibility distance for map
81
84}
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:91
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
MapEntry const * i_mapEntry
Definition Map.h:555
uint8 i_spawnMode
Definition Map.h:556
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition Map.h:602
TransportsContainer::iterator _transportsUpdateIter
Definition Map.h:567
uint32 m_unloadTimer
Definition Map.h:558
uint32 _defaultLight
Definition Map.h:606
IntervalTimer _weatherUpdateTimer
Definition Map.h:605
Map * m_parentMap
Definition Map.h:581
IntervalTimer _updatableObjectListRecheckTimer
Definition Map.h:632
bool i_scriptLock
Definition Map.h:585
IntervalTimer _corpseUpdateTimer
Definition Map.h:608
time_t _instanceResetPeriod
Definition Map.h:561
float m_VisibleDistance
Definition Map.h:559
MapGridManager _mapGridManager
Definition Map.h:554
virtual void InitVisibilityDistance()
Definition Map.cpp:96
TransportsContainer _transports
Definition Map.h:566
uint32 i_InstanceId
Definition Map.h:557
void SetInterval(time_t interval)
Definition Timer.h:179

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

◆ ~Map()

Map::~Map ( )
override
54{
55 // UnloadAll must be called before deleting the map
56
57 // Kill all scheduled events without executing them, since the map and its objects are being destroyed.
58 // This prevents events from running on invalid or deleted objects during map destruction.
59 Events.KillAllEvents(false);
60
61 sScriptMgr->OnDestroyMap(this);
62
63 if (!m_scriptSchedule.empty())
64 sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
65
67}
#define sScriptMgr
Definition ScriptMgr.h:728
Events
Definition alterac_valley.cpp:53
static MMapMgr * createOrGetMMapMgr()
Definition MMapFactory.cpp:27
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
Definition MMapMgr.cpp:276
ScriptScheduleMap m_scriptSchedule
Definition Map.h:589
uint32 GetId() const
Definition Map.h:229

References MMAP::MMapFactory::createOrGetMMapMgr(), GetId(), i_InstanceId, m_scriptSchedule, sScriptMgr, and MMAP::MMapMgr::unloadMapInstance().

Member Function Documentation

◆ _AddObjectToUpdateList()

void Map::_AddObjectToUpdateList ( WorldObject obj)
private
580{
581 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
582 ASSERT(mapUpdatableObject && mapUpdatableObject->GetUpdateState() == UpdatableMapObject::UpdateState::PendingAdd);
583
585 mapUpdatableObject->SetMapUpdateListOffset(_updatableObjectList.size());
586 _updatableObjectList.push_back(obj);
587}
#define ASSERT
Definition Errors.h:68
UpdatableObjectList _updatableObjectList
Definition Map.h:630
Definition Object.h:429
void SetUpdateState(UpdateState state)
Definition Object.h:456
UpdateState GetUpdateState() const
Definition Object.h:461
@ PendingAdd
Definition Object.h:436
@ Updating
Definition Object.h:437
void SetMapUpdateListOffset(std::size_t const offset)
Definition Object.h:444

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,
const ScriptInfo 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:158
Definition Creature.h:47
Creature * ToCreature()
Definition Object.h:206
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250
std::string GetDebugInfo() const
Definition ObjectMgr.cpp:201

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

Referenced by ScriptsProcess().

◆ _GetScriptCreatureSourceOrTarget()

Creature * Map::_GetScriptCreatureSourceOrTarget ( Object source,
Object target,
const ScriptInfo 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:170
TypeID GetTypeId() const
Definition Object.h:128

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,
const ScriptInfo 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:1071

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

Referenced by ScriptsProcess().

◆ _GetScriptPlayerSourceOrTarget()

Player * Map::_GetScriptPlayerSourceOrTarget ( Object source,
Object target,
const ScriptInfo 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,
const ScriptInfo 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:650

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,
const ScriptInfo 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:472

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

Referenced by ScriptsProcess().

◆ _RemoveObjectFromUpdateList()

void Map::_RemoveObjectFromUpdateList ( WorldObject obj)
private
591{
592 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
593 ASSERT(mapUpdatableObject && mapUpdatableObject->GetUpdateState() == UpdatableMapObject::UpdateState::Updating);
594
595 if (obj != _updatableObjectList.back())
596 {
597 dynamic_cast<UpdatableMapObject*>(_updatableObjectList.back())->SetMapUpdateListOffset(mapUpdatableObject->GetMapUpdateListOffset());
598 std::swap(_updatableObjectList[mapUpdatableObject->GetMapUpdateListOffset()], _updatableObjectList.back());
599 }
600
601 _updatableObjectList.pop_back();
603}
size_t GetMapUpdateListOffset() const
Definition Object.h:450
@ NotUpdating
Definition Object.h:435

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,
const ScriptInfo 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:692
@ TYPEMASK_GAMEOBJECT
Definition ObjectGuid.h:51
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition ObjectMgr.h:104
@ SCRIPT_COMMAND_OPEN_DOOR
Definition ObjectMgr.h:103
@ GAMEOBJECT_TYPE_BUTTON
Definition SharedDefines.h:1572
@ GAMEOBJECT_TYPE_DOOR
Definition SharedDefines.h:1571
Definition GameObject.h:120
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition GameObject.cpp:1410
GOState GetGoState() const
Definition GameObject.h:204
GameobjectTypes GetGoType() const
Definition GameObject.h:202
GameObject * _FindGameObject(WorldObject *pWorldObject, ObjectGuid::LowType guid) const
Definition MapScripts.cpp:267
std::string ToString() const
Definition ObjectGuid.cpp:47
uint32 LowType
Definition ObjectGuid.h:122
bool isType(uint16 mask) const
Definition Object.h:129
GameObject * ToGameObject()
Definition Object.h:214
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
ScriptCommands command
Definition ObjectMgr.h:194
uint32 ResetDelay
Definition ObjectMgr.h:287
uint32 GOGuid
Definition ObjectMgr.h:267
struct ScriptInfo::@267::@280 ToggleDoor

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)
2641{
2642 corpse->SetMap(this);
2643
2644 GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
2645 _corpsesByGrid[gridCoord.GetId()].insert(corpse);
2646 if (corpse->GetType() != CORPSE_BONES)
2647 _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
2648 else
2649 _corpseBones.insert(corpse);
2650}
@ 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:625
std::unordered_set< Corpse * > _corpseBones
Definition Map.h:626
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByGrid
Definition Map.h:624
virtual void SetMap(Map *map)
Definition Object.cpp:2115
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
870{
872 _creaturesToMove.push_back(c);
874}
@ MAP_OBJECT_CELL_MOVE_ACTIVE
Definition Object.h:406
@ MAP_OBJECT_CELL_MOVE_NONE
Definition Object.h:405
std::vector< Creature * > _creaturesToMove
Definition Map.h:535
MapObjectCellMoveState _moveState
Definition Object.h:425

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
896{
897 if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
898 _dynamicObjectsToMove.push_back(dynObj);
899 dynObj->_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE;
900}
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition Map.h:537

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
883{
885 _gameObjectsToMove.push_back(go);
887}
std::vector< GameObject * > _gameObjectsToMove
Definition Map.h:536

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

Referenced by GameObjectRelocation().

◆ AddObjectToPendingUpdateList()

void Map::AddObjectToPendingUpdateList ( WorldObject obj)
566{
567 if (!obj->CanBeAddedToMapUpdateList())
568 return;
569
570 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
572 return;
573
576}
PendingAddUpdatableObjectList _pendingAddUpdatableObjectList
Definition Map.h:631
bool CanBeAddedToMapUpdateList()
Definition Object.cpp:3147

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)
1784{
1785 ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
1786
1787 obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
1788
1789 i_objectsToRemove.insert(obj);
1790 //LOG_DEBUG("maps", "Object ({}) added to removing list.", obj->GetGUID().ToString());
1791}
std::unordered_set< WorldObject * > i_objectsToRemove
Definition Map.h:586
uint32 GetInstanceId() const
Definition Map.h:266
uint32 GetMapId() const
Definition Position.h:281
uint32 GetInstanceId() const
Definition Object.h:510
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition Object.cpp:1139

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.

257{
258 CellCoord cellCoord = Acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
259 if (!cellCoord.IsCoordValid())
260 {
261 LOG_ERROR("maps", "Map::Add: Player ({}) has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
262 player->GetGUID().ToString(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
263 return false;
264 }
265
266 Cell cell(cellCoord);
268 AddToGrid(player, cell);
269
270 // Check if we are adding to correct map
271 ASSERT (player->GetMap() == this);
272 player->SetMap(this);
273 player->AddToWorld();
274
275 SendInitTransports(player);
276 SendInitSelf(player);
277
278 player->UpdateObjectVisibility(false);
279
280 if (player->IsAlive())
281 ConvertCorpseToBones(player->GetGUID());
282
283 sScriptMgr->OnPlayerEnterMap(this, player);
284 return true;
285}
#define MAX_VISIBILITY_DISTANCE
Definition ObjectDefines.h:30
void LoadGridsInRange(Position const &center, float radius)
Definition Map.cpp:226
Corpse * ConvertCorpseToBones(ObjectGuid const &ownerGuid, bool insignia=false)
Definition Map.cpp:2673
void SendInitSelf(Player *player)
Definition Map.cpp:1625
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:114
void SendInitTransports(Player *player)
Definition Map.cpp:1671
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition PlayerUpdates.cpp:1604
void AddToWorld() override
Definition Player.cpp:1698
void SetMap(Map *map) override
Definition Player.cpp:14793
bool IsAlive() const
Definition Unit.h:1748
Map * GetMap() const
Definition Object.h:621
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 
)
153{
154 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
155 // Corpses are a special object type - they can be added to grid via a call to AddToMap
156 // or loaded through ObjectGridLoader.
157 // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
158 // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
159 // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
160 // to avoid failing an assertion in GridObject::AddToGrid
161 if (grid->IsObjectDataLoaded())
162 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
163}
Definition MapGrid.h:32
void AddGridObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:48
bool IsObjectDataLoaded() const
Definition MapGrid.h:45
MapGridType * GetMapGrid(uint16 const x, uint16 const y)
Definition Map.cpp:199

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 
)
124{
125 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
126 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
127 if (obj->IsFarVisible())
128 grid->AddFarVisibleObject(cell.CellX(), cell.CellY(), obj);
129
130 obj->SetCurrentCell(cell);
131}
void AddFarVisibleObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:58
void SetCurrentCell(Cell const &cell)
Definition Object.h:422
bool IsFarVisible() const
Definition Object.h:671

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 
)
146{
147 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
148 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
149}

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 
)
306{
307 //TODO: Needs clean up. An object should not be added to map twice.
308 if (obj->IsInWorld())
309 {
310 ASSERT(obj->IsInGrid());
311 obj->UpdateObjectVisibilityOnCreate();
312 return true;
313 }
314
315 CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
316 //It will create many problems (including crashes) if an object is not added to grid after creation
317 //The correct way to fix it is to make AddToMap return false and delete the object if it is not added to grid
318 //But now AddToMap is used in too many places, I will just see how many ASSERT failures it will cause
319 ASSERT(cellCoord.IsCoordValid());
320 if (!cellCoord.IsCoordValid())
321 {
322 LOG_ERROR("maps", "Map::AddToMap: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
323 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
324 return false; //Should delete object
325 }
326
327 Cell cell(cellCoord);
328 if (obj->isActiveObject())
329 EnsureGridLoaded(cell);
330 else
331 EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
332
333 AddToGrid(obj, cell);
334
335 //Must already be set before AddToMap. Usually during obj->Create.
336 //obj->SetMap(this);
337 obj->AddToWorld();
338
339 if (checkTransport)
340 if (!(obj->IsGameObject() && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d
341 if (Transport* transport = GetTransportForPos(obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj))
342 transport->AddPassenger(obj, true);
343
344 InitializeObject(obj);
345
346 //something, such as vehicle, needs to be update immediately
347 //also, trigger needs to cast spell, if not update, cannot see visual
348 obj->UpdateObjectVisibility(true);
349
350 // Xinef: little hack for vehicles, accessories have to be added after visibility update so they wont fall off the vehicle, moved from Creature::AIM_Initialize
351 // Initialize vehicle, this is done only for summoned npcs, DB creatures are handled by grid loaders
352 if (obj->IsCreature())
353 if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit())
354 vehicle->Reset();
355 return true;
356}
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition GridDefines.h:171
void InitializeObject(T *obj)
Definition Map.cpp:288
Transport * GetTransportForPos(uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
Definition Map.cpp:1118
void EnsureGridCreated(GridCoord const &gridCoord)
Definition Map.cpp:181
bool EnsureGridLoaded(Cell const &cell)
Definition Map.cpp:186
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   
)
360{
361 //TODO: Needs clean up. An object should not be added to map twice.
362 if (obj->IsInWorld())
363 return true;
364
366 if (!cellCoord.IsCoordValid())
367 {
368 LOG_ERROR("maps", "Map::Add: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
369 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
370 return false; //Should delete object
371 }
372
373 Cell cell(cellCoord);
374 EnsureGridLoaded(cell);
375
376 obj->AddToWorld();
377
378 _transports.insert(obj);
379
380 // Broadcast creation to players
381 for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
382 {
383 if (itr->GetSource()->GetTransport() != obj)
384 {
385 UpdateData data;
386 obj->BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
387 WorldPacket packet;
388 data.BuildPacket(packet);
389 itr->GetSource()->SendDirectMessage(&packet);
390 }
391 }
392
393 return true;
394}
void AddToWorld() override
Definition GameObject.cpp:140
iterator begin()
Definition GridRefMgr.h:35
Definition LinkedList.h:139
iterator end()
Definition MapRefMgr.h:37
PlayerList const & GetPlayers() const
Definition Map.h:326
bool IsInWorld() const
Definition Object.h:108
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition Object.cpp:178
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
487 {
488 _updateObjects.insert(obj);
489 }
std::unordered_set< Object * > _updateObjects
Definition Map.h:628

References _updateObjects.

Referenced by WorldObject::AddToObjectUpdate().

◆ AddWorldObjectToFarVisibleMap()

void Map::AddWorldObjectToFarVisibleMap ( WorldObject obj)
619{
620 if (Creature* creature = obj->ToCreature())
621 {
622 if (!creature->IsInGrid())
623 return;
624
625 Cell curr_cell = creature->GetCurrentCell();
626 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
627 grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
628 }
629 else if (GameObject* go = obj->ToGameObject())
630 {
631 if (!go->IsInGrid())
632 return;
633
634 Cell curr_cell = go->GetCurrentCell();
635 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
636 grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
637 }
638}
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 
)
658{
659 _zoneWideVisibleWorldObjectsMap[zoneId].insert(obj);
660}
ZoneWideVisibleWorldObjectsMap _zoneWideVisibleWorldObjectsMap
Definition Map.h:633

References _zoneWideVisibleWorldObjectsMap.

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

◆ AfterPlayerUnlinkFromMap()

void Map::AfterPlayerUnlinkFromMap ( )
virtual

◆ AllTransportsEmpty()

bool Map::AllTransportsEmpty ( ) const
2609{
2610 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2611 if (!(*itr)->GetPassengers().empty())
2612 return false;
2613
2614 return true;
2615}

References _transports.

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

◆ AllTransportsRemovePassengers()

void Map::AllTransportsRemovePassengers ( )
2618{
2619 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2620 while (!(*itr)->GetPassengers().empty())
2621 (*itr)->RemovePassenger(*((*itr)->GetPassengers().begin()), true);
2622}

References _transports.

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

◆ ApplyDynamicModeRespawnScaling()

uint32 Map::ApplyDynamicModeRespawnScaling ( WorldObject const *  obj,
uint32  respawnDelay 
) const
1732{
1733 ASSERT(obj->GetMap() == this);
1734
1735 float rate = sWorld->getFloatConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICRATE_CREATURE);
1736
1737 if (rate == 1.0f)
1738 return respawnDelay;
1739
1740 // No instanced maps (dungeons, battlegrounds, arenas etc.)
1741 if (obj->GetMap()->Instanceable())
1742 return respawnDelay;
1743
1744 // No quest givers or world bosses
1745 if (Creature const* creature = obj->ToCreature())
1746 if (creature->IsQuestGiver() || creature->isWorldBoss()
1747 || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RARE)
1748 || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RAREELITE))
1749 return respawnDelay;
1750
1751 auto it = _zonePlayerCountMap.find(obj->GetZoneId());
1752 if (it == _zonePlayerCountMap.end())
1753 return respawnDelay;
1754 uint32 const playerCount = it->second;
1755 if (!playerCount)
1756 return respawnDelay;
1757 double const adjustFactor = rate / playerCount;
1758 if (adjustFactor >= 1.0) // nothing to do here
1759 return respawnDelay;
1760 uint32 const timeMinimum = sWorld->getIntConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE);
1761 if (respawnDelay <= timeMinimum)
1762 return respawnDelay;
1763
1764 return std::max<uint32>(std::ceil(respawnDelay * adjustFactor), timeMinimum);
1765}
std::uint32_t uint32
Definition Define.h:107
@ CREATURE_ELITE_RARE
Definition SharedDefines.h:2985
@ CREATURE_ELITE_RAREELITE
Definition SharedDefines.h:2983
@ CONFIG_RESPAWN_DYNAMICRATE_CREATURE
Definition WorldConfig.h:162
@ CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE
Definition WorldConfig.h:387
@ CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT
Definition WorldConfig.h:161
@ CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT
Definition WorldConfig.h:386
#define sWorld
Definition World.h:316

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, and Object::ToCreature().

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

◆ Balance()

void Map::Balance ( )
inline
void balance()
Definition DynamicTree.cpp:132
DynamicMapTree _dynamicTree
Definition Map.h:560

References _dynamicTree, and DynamicMapTree::balance().

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
2969{
2970 return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
2971}
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:2928

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
2974{
2975 if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
2976 {
2977 return false;
2978 }
2979
2980 Unit const* unit = source->ToUnit();
2981 // if it's not an unit (Object) then we do not have to continue
2982 // with walkable checks
2983 if (!unit)
2984 {
2985 return true;
2986 }
2987
2988 /*
2989 * Walkable checks
2990 */
2991 bool isWaterNext = HasEnoughWater(unit, destX, destY, destZ);
2992 Creature const* creature = unit->ToCreature();
2993 bool cannotEnterWater = isWaterNext && (creature && !creature->CanEnterWater());
2994 bool cannotWalkOrFly = !isWaterNext && !source->ToPlayer() && !unit->CanFly() && (creature && !creature->CanWalk());
2995 if (cannotEnterWater || cannotWalkOrFly ||
2996 (failOnSlopes && !PathGenerator::IsWalkableClimb(startX, startY, startZ, destX, destY, destZ, source->GetCollisionHeight())))
2997 {
2998 return false;
2999 }
3000
3001 return true;
3002}
bool CanWalk() const
Definition Creature.h:83
bool CanEnterWater() const override
Definition Creature.cpp:3262
bool HasEnoughWater(WorldObject const *searcher, float x, float y, float z) const
Definition Map.cpp:1606
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:3011
bool IsWalkableClimb(float const *v1, float const *v2) const
Definition PathGenerator.cpp:969
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.

2929{
2930 G3D::Vector3 prevPath = path->GetStartPosition();
2931 for (auto& vector : path->GetPath())
2932 {
2933 float x = vector.x;
2934 float y = vector.y;
2935 float z = vector.z;
2936
2937 if (!CanReachPositionAndGetValidCoords(source, prevPath.x, prevPath.y, prevPath.z, x, y, z, failOnCollision, failOnSlopes))
2938 {
2939 destX = x;
2940 destY = y;
2941 destZ = z;
2942 return false;
2943 }
2944
2945 prevPath = vector;
2946 }
2947
2948 destX = prevPath.x;
2949 destY = prevPath.y;
2950 destZ = prevPath.z;
2951
2952 return true;
2953}
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
174 {
175 if (!m_unloadTimer || Events.HasEvents())
176 return false;
177
178 if (m_unloadTimer <= diff)
179 return true;
180
181 m_unloadTimer -= diff;
182 return false;
183 }

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
3012{
3013 // Prevent invalid coordinates here, position is unchanged
3014 if (!Acore::IsValidMapCoord(startX, startY, startZ) || !Acore::IsValidMapCoord(destX, destY, destZ))
3015 {
3016 LOG_FATAL("maps", "Map::CheckCollisionAndGetValidCoords invalid coordinates startX: {}, startY: {}, startZ: {}, destX: {}, destY: {}, destZ: {}", startX, startY, startZ, destX, destY, destZ);
3017 return false;
3018 }
3019
3020 bool isWaterNext = IsInWater(source->GetPhaseMask(), destX, destY, destZ, source->GetCollisionHeight());
3021
3022 PathGenerator path(source);
3023
3024 // Use a detour raycast to get our first collision point
3025 path.SetUseRaycast(true);
3026 bool result = path.CalculatePath(startX, startY, startZ, destX, destY, destZ, false);
3027
3028 Unit const* unit = source->ToUnit();
3029 bool notOnGround = path.GetPathType() & PATHFIND_NOT_USING_PATH
3030 || isWaterNext || (unit && unit->IsFlying());
3031
3032 // Check for valid path types before we proceed
3033 if (!result || (!notOnGround && path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END)))
3034 {
3035 return false;
3036 }
3037
3038 G3D::Vector3 endPos = path.GetPath().back();
3039 destX = endPos.x;
3040 destY = endPos.y;
3041 destZ = endPos.z;
3042
3043 // collision check
3044 bool collided = false;
3045
3046 // check static LOS
3047 float halfHeight = source->GetCollisionHeight() * 0.5f;
3048
3049 // Unit is not on the ground, check for potential collision via vmaps
3050 if (notOnGround)
3051 {
3052 bool col = VMAP::VMapFactory::createOrGetVMapMgr()->GetObjectHitPos(source->GetMapId(),
3053 startX, startY, startZ + halfHeight,
3054 destX, destY, destZ + halfHeight,
3055 destX, destY, destZ, -CONTACT_DISTANCE);
3056
3057 destZ -= halfHeight;
3058
3059 // Collided with static LOS object, move back to collision point
3060 if (col)
3061 {
3062 collided = true;
3063 }
3064 }
3065
3066 // check dynamic collision
3067 bool col = source->GetMap()->GetObjectHitPos(source->GetPhaseMask(),
3068 startX, startY, startZ + halfHeight,
3069 destX, destY, destZ + halfHeight,
3070 destX, destY, destZ, -CONTACT_DISTANCE);
3071
3072 destZ -= halfHeight;
3073
3074 // Collided with a gameobject, move back to collision point
3075 if (col)
3076 {
3077 collided = true;
3078 }
3079
3080 float groundZ = VMAP_INVALID_HEIGHT_VALUE;
3081 source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
3082
3083 // position has no ground under it (or is too far away)
3084 if (groundZ <= INVALID_HEIGHT && unit && !unit->CanFly())
3085 {
3086 // fall back to gridHeight if any
3087 float gridHeight = GetGridHeight(destX, destY);
3088 if (gridHeight > INVALID_HEIGHT)
3089 {
3090 destZ = gridHeight + unit->GetHoverHeight();
3091 }
3092 else
3093 {
3094 return false;
3095 }
3096 }
3097
3098 return !failOnCollision || !collided;
3099}
#define INVALID_HEIGHT
Definition GridTerrainData.h:27
#define VMAP_INVALID_HEIGHT_VALUE
Definition IVMapMgr.h:49
#define LOG_FATAL(filterType__,...)
Definition Log.h:154
#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 IsInWater(uint32 phaseMask, float x, float y, float z, float collisionHeight) const
Definition Map.cpp:1594
float GetGridHeight(float x, float y) const
Definition Map.cpp:1182
Definition PathGenerator.h:59
float GetCollisionHeight() const override
Return collision height sent to client.
Definition Unit.cpp:20982
float GetHoverHeight() const
Definition Unit.h:1672
bool IsFlying() const
Definition Unit.h:1668
static VMapMgr2 * createOrGetVMapMgr()
Definition VMapFactory.cpp:27
bool GetObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist) override
Definition VMapMgr2.cpp:201
bool IsValidMapCoord(float c)
Definition GridDefines.h:210

References PathGenerator::CalculatePath(), CanFly, CONTACT_DISTANCE, VMAP::VMapFactory::createOrGetVMapMgr(), WorldObject::GetCollisionHeight(), GetGridHeight(), Unit::GetHoverHeight(), WorldObject::GetMap(), WorldLocation::GetMapId(), GetObjectHitPos(), VMAP::VMapMgr2::GetObjectHitPos(), PathGenerator::GetPath(), PathGenerator::GetPathType(), WorldObject::GetPhaseMask(), 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 ( const GameObjectModel model) const
inline
393{ return _dynamicTree.contains(model);}
bool contains(const GameObjectModel &) const
Definition DynamicTree.cpp:127

References _dynamicTree, and DynamicMapTree::contains().

◆ ConvertCorpseToBones()

Corpse * Map::ConvertCorpseToBones ( ObjectGuid const &  ownerGuid,
bool  insignia = false 
)
2674{
2675 Corpse* corpse = GetCorpseByPlayer(ownerGuid);
2676 if (!corpse)
2677 return nullptr;
2678
2679 RemoveCorpse(corpse);
2680
2681 // remove corpse from DB
2682 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2683 corpse->DeleteFromDB(trans);
2684 CharacterDatabase.CommitTransaction(trans);
2685
2686 Corpse* bones = NULL;
2687
2688 // create the bones only if the map and the grid is loaded at the corpse's location
2689 // ignore bones creating option in case insignia
2690 if ((insignia ||
2692 IsGridLoaded(corpse->GetPositionX(), corpse->GetPositionY()))
2693 {
2694 // Create bones, don't change Corpse
2695 bones = new Corpse();
2696 bones->Create(corpse->GetGUID().GetCounter());
2697
2698 for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
2699 bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
2700
2701 bones->SetCellCoord(corpse->GetCellCoord());
2702 bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
2703 bones->SetPhaseMask(corpse->GetPhaseMask(), false);
2704
2706 bones->SetGuidValue(CORPSE_FIELD_OWNER, corpse->GetOwnerGUID());
2707
2708 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
2709 if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
2710 bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
2711
2712 AddCorpse(bones);
2713
2714 bones->UpdatePositionData();
2715
2716 // add bones in grid store if grid loaded where corpse placed
2717 AddToMap(bones);
2718 }
2719
2720 // all references to the corpse should be removed at this point
2721 delete corpse;
2722
2723 return bones;
2724}
@ 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:689
@ 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:65
@ CONFIG_DEATH_BONES_WORLD
Definition WorldConfig.h:64
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:303
void AddCorpse(Corpse *corpse)
Definition Map.cpp:2640
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:204
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition Map.h:365
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:305
void RemoveCorpse(Corpse *corpse)
Definition Map.cpp:2652
LowType GetCounter() const
Definition ObjectGuid.h:145
uint32 GetUInt32Value(uint16 index) const
Definition Object.cpp:294
void SetGuidValue(uint16 index, ObjectGuid value)
Definition Object.cpp:712
void SetUInt32Value(uint16 index, uint32 value)
Definition Object.cpp:639
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
Definition Object.cpp:2891
uint32 GetPhaseMask() const
Definition Object.h:513
void UpdatePositionData()
Definition Object.cpp:1162
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 
)
807{
808 Cell old_cell = creature->GetCurrentCell();
809 Cell new_cell(x, y);
810
811 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
812 {
813 if (old_cell.DiffGrid(new_cell))
814 EnsureGridLoaded(new_cell);
815
816 AddCreatureToMoveList(creature);
817 }
818 else
820
821 creature->Relocate(x, y, z, o);
822 if (creature->IsVehicle())
823 creature->GetVehicleKit()->RelocatePassengers();
824 creature->UpdatePositionData();
825 creature->UpdateObjectVisibility(false);
826}
void AddCreatureToMoveList(Creature *c)
Definition Map.cpp:869
void RemoveCreatureFromMoveList(Creature *c)
Definition Map.cpp:876
Cell const & GetCurrentCell() const
Definition Object.h:419
bool IsVehicle() const
Definition Unit.h:783
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition Unit.cpp:19161
Vehicle * GetVehicleKit() const
Definition Unit.h:1879
void RelocatePassengers()
Definition Vehicle.cpp:516
bool DiffGrid(const Cell &cell) const
Definition Cell.h:63
bool DiffCell(const Cell &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.

1768{
1770 {
1771 Transport* transport = *_transportsUpdateIter;
1773
1774 if (!transport->IsInWorld())
1775 continue;
1776
1777 transport->DelayedUpdate(t_diff);
1778 }
1779
1781}
void RemoveAllObjectsInRemoveList()
Definition Map.cpp:1793
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 ( )
3139{
3140 // DELETE FROM corpse WHERE mapId = ? AND instanceId = ?
3142 stmt->SetData(0, GetId());
3143 stmt->SetData(1, GetInstanceId());
3144 CharacterDatabase.Execute(stmt);
3145}
@ CHAR_DEL_CORPSES_FROM_MAP
Definition CharacterDatabase.h:249
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)
174{
176
177 RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway
178 delete player;
179}
void RemoveUpdateObject(Object *obj)
Definition Map.h:491
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
167{
168 // Note: In case resurrectable corpse and pet its removed from global lists in own destructor
169 delete obj;
170}

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

◆ DeleteRespawnTimes()

void Map::DeleteRespawnTimes ( )
2494{
2495 _creatureRespawnTimes.clear();
2496 _goRespawnTimes.clear();
2497
2499}
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
Definition Map.cpp:2501
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition Map.h:599
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition Map.h:600

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

Referenced by InstanceMap::UnloadAll().

◆ DeleteRespawnTimesInDB()

void Map::DeleteRespawnTimesInDB ( uint16  mapId,
uint32  instanceId 
)
static
2502{
2504 stmt->SetData(0, mapId);
2505 stmt->SetData(1, instanceId);
2506 CharacterDatabase.Execute(stmt);
2507
2508 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
2509 stmt->SetData(0, mapId);
2510 stmt->SetData(1, instanceId);
2511 CharacterDatabase.Execute(stmt);
2512}
@ CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE
Definition CharacterDatabase.h:255
@ CHAR_DEL_GO_RESPAWN_BY_INSTANCE
Definition CharacterDatabase.h:260

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)
2912{
2913 for (auto const& it : GetPlayers())
2914 {
2915 if (Player* player = it.GetSource())
2916 {
2917 exec(player);
2918 }
2919 }
2920}

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(), InstanceScript::DoSendNotifyToInstance(), InstanceScript::DoStartTimedAchievement(), InstanceScript::DoStopTimedAchievement(), InstanceScript::DoUpdateAchievementCriteria(), BattlegroundSA::EventPlayerDamagedGO(), BattlegroundSA::EventPlayerUsedGO(), boss_azuregos::boss_azuregosAI::JustDied(), boss_rajaxx::JustDied(), boss_alar::JustDied(), boss_felblood_kaelthas::LapseAction(), BattlegroundSA::PostUpdateImpl(), spell_fire_festival_fortitude::PrepareSpellScript(), boss_azuregos::boss_azuregosAI::Reset(), boss_yoggsaron_sara::boss_yoggsaron_saraAI::Reset(), npc_minigob_manabonk::SelectTargetInDalaran(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::SetBossState(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetData(), Battleground::SpiritOfCompetitionEvent(), boss_nefarian::UpdateAI(), boss_cthun::UpdateAI(), npc_gunship::npc_gunshipAI::UpdateAI(), and npc_midsummer_bonfire::UpdateBonfireBlessingBuffs().

◆ DynamicObjectRelocation()

void Map::DynamicObjectRelocation ( DynamicObject go,
float  x,
float  y,
float  z,
float  o 
)
850{
851 Cell old_cell = dynObj->GetCurrentCell();
852 Cell new_cell(x, y);
853
854 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
855 {
856 if (old_cell.DiffGrid(new_cell))
857 EnsureGridLoaded(new_cell);
858
860 }
861 else
863
864 dynObj->Relocate(x, y, z, o);
865 dynObj->SetPositionDataUpdate();
866 dynObj->UpdateObjectVisibility(false);
867}
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
Definition Map.cpp:902
void AddDynamicObjectToMoveList(DynamicObject *go)
Definition Map.cpp:895

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)
182{
183 _mapGridManager.CreateGrid(gridCoord.x_coord, gridCoord.y_coord);
184}
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(), EnsureGridLoaded(), GetGridTerrainData(), and GetGridTerrainDataSharedPtr().

◆ EnsureGridLoaded()

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

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 
)
829{
830 Cell old_cell = go->GetCurrentCell();
831 Cell new_cell(x, y);
832
833 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
834 {
835 if (old_cell.DiffGrid(new_cell))
836 EnsureGridLoaded(new_cell);
837
839 }
840 else
842
843 go->Relocate(x, y, z, o);
846 go->UpdateObjectVisibility(false);
847}
void UpdateModelPosition()
Definition GameObject.cpp:2902
void AddGameObjectToMoveList(GameObject *go)
Definition Map.cpp:882
void RemoveGameObjectFromMoveList(GameObject *go)
Definition Map.cpp:889
void SetPositionDataUpdate()
Definition Object.cpp:1153
virtual void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false)
Definition Object.cpp:2964

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
475{ return _transports; }

References _transports.

Referenced by npc_preparations_for_war_vehicle::UpdateAI().

◆ GetAreaId()

uint32 Map::GetAreaId ( uint32  phaseMask,
float  x,
float  y,
float  z 
) const
1244{
1245 uint32 mogpFlags;
1246 int32 adtId, rootId, groupId;
1247 float vmapZ = z;
1248 bool hasVmapArea = GetAreaInfo(phaseMask, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
1249
1250 uint32 gridAreaId = 0;
1251 float gridMapHeight = INVALID_HEIGHT;
1252 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1253 {
1254 gridAreaId = gmap->getArea(x, y);
1255 gridMapHeight = gmap->getHeight(x, y);
1256 }
1257
1258 uint16 areaId = 0;
1259
1260 // floor is the height we are closer to (but only if above)
1261 if (hasVmapArea && G3D::fuzzyGe(z, vmapZ - GROUND_HEIGHT_TOLERANCE) && (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapZ > gridMapHeight))
1262 {
1263 // wmo found
1264 if (WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId))
1265 areaId = wmoEntry->areaId;
1266
1267 if (!areaId)
1268 areaId = gridAreaId;
1269 }
1270 else
1271 areaId = gridAreaId;
1272
1273 if (!areaId)
1274 areaId = i_mapEntry->linked_zone;
1275
1276 return areaId;
1277}
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:163
bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition Map.cpp:1203
GridTerrainData * GetGridTerrainData(GridCoord const &gridCoord)
Definition Map.cpp:1081
uint32 linked_zone
Definition DBCStructure.h:1334
Definition DBCStructure.h:2132

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
1204{
1205 float check_z = z;
1209
1210 bool hasVmapAreaInfo = vmgr->GetAreaAndLiquidData(GetId(), x, y, z, {}, vdata) && vdata.areaInfo.has_value();
1211 bool hasDynamicAreaInfo = _dynamicTree.GetAreaAndLiquidData(x, y, z, phaseMask, {}, ddata) && ddata.areaInfo.has_value();
1212 auto useVmap = [&] { check_z = vdata.floorZ; groupId = vdata.areaInfo->groupId; adtId = vdata.areaInfo->adtId; rootId = vdata.areaInfo->rootId; flags = vdata.areaInfo->mogpFlags; };
1213 auto useDyn = [&] { check_z = ddata.floorZ; groupId = ddata.areaInfo->groupId; adtId = ddata.areaInfo->adtId; rootId = ddata.areaInfo->rootId; flags = ddata.areaInfo->mogpFlags; };
1214 if (hasVmapAreaInfo)
1215 {
1216 if (hasDynamicAreaInfo && ddata.floorZ > vdata.floorZ)
1217 useDyn();
1218 else
1219 useVmap();
1220 }
1221 else if (hasDynamicAreaInfo)
1222 {
1223 useDyn();
1224 }
1225
1226 if (hasVmapAreaInfo || hasDynamicAreaInfo)
1227 {
1228 // check if there's terrain between player height and object height
1229 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1230 {
1231 float mapHeight = gmap->getHeight(x, y);
1232 // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
1233 if (z + 2.0f > mapHeight && mapHeight > check_z)
1234 return false;
1235 }
1236
1237 return true;
1238 }
1239
1240 return false;
1241}
bool GetAreaAndLiquidData(float x, float y, float z, uint32 phasemask, Optional< uint8 > reqLiquidType, VMAP::AreaAndLiquidData &data) const
Definition DynamicTree.cpp:292
Definition IVMapMgr.h:81
virtual bool GetAreaAndLiquidData(uint32 mapId, float x, float y, float z, Optional< uint8 > reqLiquidType, AreaAndLiquidData &data) const =0
Definition IVMapMgr.h:52
Optional< AreaInfo > areaInfo
Definition IVMapMgr.h:75
float floorZ
Definition IVMapMgr.h:74

References _dynamicTree, VMAP::AreaAndLiquidData::areaInfo, VMAP::VMapFactory::createOrGetVMapMgr(), VMAP::AreaAndLiquidData::floorZ, DynamicMapTree::GetAreaAndLiquidData(), VMAP::IVMapMgr::GetAreaAndLiquidData(), GetGridTerrainData(), and GetId().

Referenced by GetAreaId().

◆ GetCorpse()

Corpse * Map::GetCorpse ( ObjectGuid const &  guid)
2353{
2354 return _objectsStore.Find<Corpse>(guid);
2355}
MapStoredObjectTypesContainer _objectsStore
Definition Map.h:621
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
366 {
367 auto itr = _corpsesByPlayer.find(ownerGuid);
368 if (itr != _corpsesByPlayer.end())
369 return itr->second;
370
371 return nullptr;
372 }

References _corpsesByPlayer.

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

◆ GetCorpsesInGrid()

std::unordered_set< Corpse * > const * Map::GetCorpsesInGrid ( uint32  gridId) const
inline
357 {
358 auto itr = _corpsesByGrid.find(gridId);
359 if (itr != _corpsesByGrid.end())
360 return &itr->second;
361
362 return nullptr;
363 }

References _corpsesByGrid.

Referenced by GridObjectLoader::LoadAllCellsInGrid().

◆ GetCreatedCellsInGridCount()

uint32 Map::GetCreatedCellsInGridCount ( uint16 const  x,
uint16 const  y 
)
3167{
3169}
uint32 GetCreatedCellsInGridCount(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:98

References _mapGridManager, and MapGridManager::GetCreatedCellsInGridCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreatedCellsInMapCount()

uint32 Map::GetCreatedCellsInMapCount ( )
3172{
3174}
uint32 GetCreatedCellsInMapCount()
Definition MapGridManager.cpp:107

References _mapGridManager, and MapGridManager::GetCreatedCellsInMapCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreatedGridsCount()

uint32 Map::GetCreatedGridsCount ( )
3157{
3159}
uint32 GetCreatedGridsCount()
Definition MapGridManager.cpp:88

References _mapGridManager, and MapGridManager::GetCreatedGridsCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreature()

Creature * Map::GetCreature ( ObjectGuid const &  guid)
2358{
2359 return _objectsStore.Find<Creature>(guid);
2360}

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

Referenced by Battleground::_ProcessResurrect(), instance_blood_furnace::instance_blood_furnace_InstanceMapScript::ActivatePrisoners(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::AddWave1(), 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(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::CheckAchievementCriteriaMeet(), instance_obsidian_sanctum::instance_obsidian_sanctum_InstanceMapScript::CheckAchievementCriteriaMeet(), spell_sha_fire_nova::CheckFireTotem(), instance_molten_core::instance_molten_core_InstanceMapScript::CheckMajordomoExecutus(), boss_prince_valanar_icc::boss_prince_valanarAI::CheckRoom(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::CheckTombReset(), instance_stratholme::instance_stratholme_InstanceMapScript::CheckZiggurats(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::CleanupInstance(), violet_hold_trashAI::ClearDoorSealAura(), npc_hor_lich_king::npc_hor_lich_kingAI::DoAction(), npc_vh_void_sentry::npc_vh_void_sentryAI::DoAction(), instance_molten_core::instance_molten_core_InstanceMapScript::DoAction(), boss_ayamiss::DoAction(), instance_obsidian_sanctum::instance_obsidian_sanctum_InstanceMapScript::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_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::DoWipe1(), instance_blackrock_spire::instance_blackrock_spireMapScript::Dragonspireroomcheck(), Spell::EffectDestroyAllTotems(), Spell::EffectScriptEffect(), boss_tyrannus::boss_tyrannusAI::EnterEvadeMode(), BattlegroundEY::EventTeamCapturedPoint(), WorldState::GetActiveZones(), Battleground::GetBGCreature(), boss_erekem::boss_erekemAI::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(), 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(), WorldSession::HandleTotemDestroyed(), 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(), 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(), npc_ulduar_hodir_priest::npc_ulduar_hodir_priestAI::JustDied(), npc_ulduar_hodir_druid::npc_ulduar_hodir_druidAI::JustDied(), npc_ulduar_hodir_shaman::npc_ulduar_hodir_shamanAI::JustDied(), npc_ulduar_hodir_mage::npc_ulduar_hodir_mageAI::JustDied(), boss_skarvald_the_constructor::JustDied(), boss_dalronn_the_controller::JustDied(), npc_ichor_globule::npc_ichor_globuleAI::JustDied(), npc_vh_void_sentry::npc_vh_void_sentryAI::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::boss_erekemAI::JustEngagedWith(), npc_erekem_guard::npc_erekem_guardAI::JustEngagedWith(), Player::KilledMonsterCredit(), boss_professor_putricide::boss_professor_putricideAI::MovementInform(), npc_hor_lich_king::npc_hor_lich_kingAI::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::instance_blackwing_lair_InstanceMapScript::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(), instance_ulduar::instance_ulduar_InstanceMapScript::OnCreatureCreate(), WorldState::OnDisable(), WorldState::OnDisable(), instance_molten_core::instance_molten_core_InstanceMapScript::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::instance_blackrock_depths_InstanceMapScript::OnUnitDeath(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::OnUnitDeath(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::OnUnitDeath(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnUnitDeath(), instance_ulduar::instance_ulduar_InstanceMapScript::OnUnitDeath(), BattlegroundAV::PopulateNode(), BattlegroundIC::PostUpdateImpl(), BattlegroundRV::PostUpdateImpl(), instance_blackrock_spire::instance_blackrock_spireMapScript::ProcessEvent(), instance_eye_of_eternity::instance_eye_of_eternity_InstanceMapScript::ProcessEvent(), instance_stratholme::instance_stratholme_InstanceMapScript::ProcessSlaughterEvent(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::RandomizeCompositionsAndShow(), instance_zulgurub::instance_zulgurub_InstanceMapScript::RemoveHakkarPowerStack(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::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(), instance_molten_core::instance_molten_core_InstanceMapScript::SetBossState(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::SetBossState(), instance_blackrock_spire::instance_blackrock_spireMapScript::SetBossState(), instance_blackwing_lair::instance_blackwing_lair_InstanceMapScript::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::instance_blackrock_depths_InstanceMapScript::SetData(), instance_blackrock_spire::instance_blackrock_spireMapScript::SetData(), instance_blackwing_lair::instance_blackwing_lair_InstanceMapScript::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::instance_halls_of_reflection_InstanceMapScript::SetData(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetData(), instance_eye_of_eternity::instance_eye_of_eternity_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_utgarde_keep::instance_utgarde_keep_InstanceMapScript::SetData(), instance_utgarde_pinnacle::instance_utgarde_pinnacle_InstanceMapScript::SetData(), instance_violet_hold::instance_violet_hold_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_molten_core::instance_molten_core_InstanceMapScript::SummonMajordomoExecutus(), WorldState::SummonMouth(), WorldState::SummonPallid(), instance_blackrock_spire::instance_blackrock_spireMapScript::SummonSolakarWave(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::TombOfSevenEvent(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::TombOfSevenReset(), instance_blackwing_lair::instance_blackwing_lair_InstanceMapScript::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::instance_halls_of_reflection_InstanceMapScript::Update(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::Update(), instance_ulduar::instance_ulduar_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::boss_vaelAI::UpdateAI(), boss_black_knight::boss_black_knightAI::UpdateAI(), npc_fos_corrupted_soul_fragment::npc_fos_corrupted_soul_fragmentAI::UpdateAI(), npc_hor_leader::npc_hor_leaderAI::UpdateAI(), npc_hor_lich_king::npc_hor_lich_kingAI::UpdateAI(), npc_hor_leader_second::npc_hor_leader_secondAI::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_power_spark::npc_power_sparkAI::UpdateAI(), boss_erekem::boss_erekemAI::UpdateAI(), boss_xevozz::boss_xevozzAI::UpdateAI(), npc_vh_teleportation_portal::npc_vh_teleportation_portalAI::UpdateAI(), and npc_ichor_globule::npc_ichor_globuleAI::UpdateAI().

◆ GetCreatureBySpawnIdStore()

◆ GetCreatureRespawnTime()

time_t Map::GetCreatureRespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
405 {
406 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
407 if (itr != _creatureRespawnTimes.end())
408 return itr->second;
409
410 return time_t(0);
411 }

References _creatureRespawnTimes.

Referenced by GetLinkedRespawnTime(), and Creature::LoadCreatureFromDB().

◆ GetDebugInfo()

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

Reimplemented in InstanceMap.

3148{
3149 std::stringstream sstr;
3150 sstr << std::boolalpha
3151 << "Id: " << GetId() << " InstanceId: " << GetInstanceId() << " Difficulty: " << std::to_string(GetDifficulty())
3152 << " HasPlayers: " << HavePlayers();
3153 return sstr.str();
3154}
bool HavePlayers() const
Definition Map.h:320
Difficulty GetDifficulty() const
Definition Map.h:290

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

Referenced by InstanceMap::GetDebugInfo().

◆ GetDifficulty()

◆ GetDynamicMapTree()

DynamicMapTree const & Map::GetDynamicMapTree ( ) const
inline
394{ return _dynamicTree; }

References _dynamicTree.

Referenced by BattlegroundRV::CheckPositionForUnit().

◆ GetDynamicObject()

DynamicObject * Map::GetDynamicObject ( ObjectGuid const &  guid)
2382{
2383 return _objectsStore.Find<DynamicObject>(guid);
2384}
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
307 {
308 if (!i_mapEntry)
309 return false;
310 return i_mapEntry->GetEntrancePos(mapid, x, y);
311 }
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
Definition DBCStructure.h:1361

References MapEntry::GetEntrancePos(), and i_mapEntry.

◆ GetEntry()

MapEntry const * Map::GetEntry ( ) const
inline

◆ GetFullTerrainStatusForPosition()

void Map::GetFullTerrainStatusForPosition ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight,
PositionFullTerrainStatus data,
Optional< uint8 reqLiquidType = {} 
)
1382{
1383 GridTerrainData* gmap = GetGridTerrainData(x, y);
1384
1386 VMAP::AreaAndLiquidData vmapData;
1387 // VMAP::AreaAndLiquidData dynData;
1388 VMAP::AreaAndLiquidData* wmoData = nullptr;
1389 vmgr->GetAreaAndLiquidData(GetId(), x, y, z, reqLiquidType, vmapData);
1390 // _dynamicTree.GetAreaAndLiquidData(x, y, z, phaseMask, reqLiquidType, dynData);
1391
1392 uint32 gridAreaId = 0;
1393 float gridMapHeight = INVALID_HEIGHT;
1394 if (gmap)
1395 {
1396 gridAreaId = gmap->getArea(x, y);
1397 gridMapHeight = gmap->getHeight(x, y);
1398 }
1399
1400 bool useGridLiquid = true;
1401
1402 // floor is the height we are closer to (but only if above)
1404 if (gridMapHeight > INVALID_HEIGHT && G3D::fuzzyGe(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE))
1405 data.floorZ = gridMapHeight;
1406
1407 if (vmapData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
1408 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapData.floorZ > gridMapHeight))
1409 {
1410 data.floorZ = vmapData.floorZ;
1411 wmoData = &vmapData;
1412 }
1413
1414 // NOTE: Objects will not detect a case when a wmo providing area/liquid despawns from under them
1415 // but this is fine as these kind of objects are not meant to be spawned and despawned a lot
1416 // example: Lich King platform
1417 /*
1418 if (dynData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, dynData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
1419 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > gridMapHeight) &&
1420 (G3D::fuzzyLt(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > vmapData.floorZ))
1421 {
1422 data.floorZ = dynData.floorZ;
1423 wmoData = &dynData;
1424 }
1425 */
1426
1427 if (wmoData)
1428 {
1429 if (wmoData->areaInfo)
1430 {
1431 // wmo found
1432 WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId);
1433 data.outdoors = (wmoData->areaInfo->mogpFlags & 0x8) != 0;
1434 if (wmoEntry)
1435 {
1436 data.areaId = wmoEntry->areaId;
1437 if (wmoEntry->Flags & 4)
1438 data.outdoors = true;
1439 else if (wmoEntry->Flags & 2)
1440 data.outdoors = false;
1441 }
1442
1443 if (!data.areaId)
1444 data.areaId = gridAreaId;
1445
1446 useGridLiquid = !IsInWMOInterior(wmoData->areaInfo->mogpFlags);
1447 }
1448 }
1449 else
1450 {
1451 data.outdoors = true;
1452 data.areaId = gridAreaId;
1453 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId))
1454 data.outdoors = (areaEntry->flags & (AREA_FLAG_INSIDE | AREA_FLAG_OUTSIDE)) != AREA_FLAG_INSIDE;
1455 }
1456
1457 if (!data.areaId)
1459
1460 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId);
1461
1462 // liquid processing
1463 if (wmoData && wmoData->liquidInfo && wmoData->liquidInfo->level > wmoData->floorZ)
1464 {
1465 uint32 liquidType = wmoData->liquidInfo->type;
1466 if (GetId() == MAP_OUTLAND && liquidType == 2) // gotta love blizzard hacks
1467 liquidType = 15;
1468
1469 uint32 liquidFlagType = 0;
1470 if (LiquidTypeEntry const* liquidData = sLiquidTypeStore.LookupEntry(liquidType))
1471 liquidFlagType = liquidData->Type;
1472
1473 if (liquidType && liquidType < 21 && areaEntry)
1474 {
1475 uint32 overrideLiquid = areaEntry->LiquidTypeOverride[liquidFlagType];
1476 if (!overrideLiquid && areaEntry->zone)
1477 {
1478 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->zone);
1479 if (zoneEntry)
1480 overrideLiquid = zoneEntry->LiquidTypeOverride[liquidFlagType];
1481 }
1482
1483 if (LiquidTypeEntry const* overrideData = sLiquidTypeStore.LookupEntry(overrideLiquid))
1484 {
1485 liquidType = overrideLiquid;
1486 liquidFlagType = overrideData->Type;
1487 }
1488 }
1489
1490 data.liquidInfo.Level = wmoData->liquidInfo->level;
1491 data.liquidInfo.DepthLevel = wmoData->floorZ;
1492 data.liquidInfo.Entry = liquidType;
1493 data.liquidInfo.Flags = 1 << liquidFlagType;
1494
1495 // Get position delta
1496 float delta = wmoData->liquidInfo->level - z;
1497
1498 if (delta > collisionHeight)
1500 else if (delta > 0.0f)
1502 else if (delta > -0.1f)
1504 else
1506 }
1507
1508 // look up liquid data from grid map
1509 if (gmap && useGridLiquid)
1510 {
1511 LiquidData const& gridLiquidData = gmap->GetLiquidData(x, y, z, collisionHeight, reqLiquidType);
1512 if (gridLiquidData.Status != LIQUID_MAP_NO_WATER && (!wmoData || gridLiquidData.Level > wmoData->floorZ))
1513 {
1514 uint32 liquidEntry = gridLiquidData.Entry;
1515 if (GetId() == MAP_OUTLAND && liquidEntry == 2)
1516 liquidEntry = 15;
1517
1518 data.liquidInfo = gridLiquidData;
1519 data.liquidInfo.Entry = liquidEntry;
1520 }
1521 }
1522}
@ MAP_OUTLAND
Definition AreaDefines.h:216
@ 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:48
static bool IsInWMOInterior(uint32 mogpFlags)
Definition Map.cpp:1198
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:1284
float floorZ
Definition Map.h:97
uint32 areaId
Definition Map.h:96
LiquidData liquidInfo
Definition Map.h:99
bool outdoors
Definition Map.h:98
Optional< LiquidInfo > liquidInfo
Definition IVMapMgr.h:76
uint32 Flags
Definition DBCStructure.h:2142
uint32 areaId
Definition DBCStructure.h:2143

References AREA_FLAG_INSIDE, AREA_FLAG_OUTSIDE, PositionFullTerrainStatus::areaId, WMOAreaTableEntry::areaId, VMAP::AreaAndLiquidData::areaInfo, VMAP::VMapFactory::createOrGetVMapMgr(), LiquidData::DepthLevel, LiquidData::Entry, LiquidData::Flags, WMOAreaTableEntry::Flags, VMAP::AreaAndLiquidData::floorZ, PositionFullTerrainStatus::floorZ, GridTerrainData::getArea(), VMAP::IVMapMgr::GetAreaAndLiquidData(), GetGridTerrainData(), GridTerrainData::getHeight(), GetId(), GridTerrainData::GetLiquidData(), 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)
2363{
2364 return _objectsStore.Find<GameObject>(guid);
2365}

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(), boss_hodir::boss_hodirAI::DoAction(), instance_obsidian_sanctum::instance_obsidian_sanctum_InstanceMapScript::DoAction(), Spell::DoAllEffectOnTarget(), npc_rocknot::npc_rocknotAI::DoGo(), WorldSession::DoLootRelease(), InstanceScript::DoRespawnGameObject(), InstanceScript::DoRespawnGameObject(), InstanceScript::DoUseDoorOrButton(), instance_blackrock_spire::instance_blackrock_spireMapScript::Dragonspireroomcheck(), instance_blackrock_spire::instance_blackrock_spireMapScript::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::boss_urok_doomhowlAI::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::boss_rend_blackhandAI::JustDied(), boss_shade_of_aran::JustDied(), npc_gunship::npc_gunshipAI::JustDied(), boss_sjonnir::boss_sjonnirAI::JustDied(), boss_kologarn::boss_kologarnAI::JustDied(), boss_shade_of_aran::JustEngagedWith(), boss_sjonnir::boss_sjonnirAI::JustEngagedWith(), boss_kologarn::boss_kologarnAI::JustEngagedWith(), instance_temple_of_ahnqiraj::instance_temple_of_ahnqiraj_InstanceMapScript::OnCreatureCreate(), instance_ulduar::instance_ulduar_InstanceMapScript::OnPlayerEnter(), instance_eye_of_eternity::instance_eye_of_eternity_InstanceMapScript::OnPlayerEnter(), instance_temple_of_ahnqiraj::instance_temple_of_ahnqiraj_InstanceMapScript::OnUnitDeath(), boss_pyroguard_emberseer::boss_pyroguard_emberseerAI::OpenDoors(), Player::PrepareQuestMenu(), instance_blackrock_spire::instance_blackrock_spireMapScript::ProcessEvent(), instance_eye_of_eternity::instance_eye_of_eternity_InstanceMapScript::ProcessEvent(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::ProcessEvent(), instance_stratholme::instance_stratholme_InstanceMapScript::ProcessSlaughterEvent(), instance_eye_of_eternity::instance_eye_of_eternity_InstanceMapScript::ReadSaveDataMore(), boss_sartharion_dragonAI::RemoveTwilightPortal(), boss_rend_blackhand::boss_rend_blackhandAI::Reset(), boss_shade_of_aran::Reset(), boss_sjonnir::boss_sjonnirAI::Reset(), boss_kologarn::boss_kologarnAI::Reset(), boss_palehoof::boss_palehoofAI::Reset(), ScriptsProcess(), Player::SendLoot(), instance_molten_core::instance_molten_core_InstanceMapScript::SetBossState(), instance_magtheridons_lair::instance_magtheridons_lair_InstanceMapScript::SetBossState(), instance_blackwing_lair::instance_blackwing_lair_InstanceMapScript::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_ulduar::instance_ulduar_InstanceMapScript::setChestsLootable(), instance_blackrock_spire::instance_blackrock_spireMapScript::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_eye_of_eternity::instance_eye_of_eternity_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::boss_pyroguard_emberseerAI::SetData(), boss_rend_blackhand::boss_rend_blackhandAI::SummonWave(), brann_bronzebeard::brann_bronzebeardAI::SwitchHeadVisaul(), 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::boss_rend_blackhandAI::UpdateAI(), npc_arthas::npc_arthasAI::UpdateAI(), npc_hor_leader::npc_hor_leaderAI::UpdateAI(), npc_pos_leader_second::npc_pos_leader_secondAI::UpdateAI(), boss_freya_nature_bomb::boss_freya_nature_bombAI::UpdateAI(), boss_hodir::boss_hodirAI::UpdateAI(), npc_pet_gen_plump_turkey::UpdateAI(), BattlegroundRV::UpdatePillars(), boss_pyroguard_emberseer::boss_pyroguard_emberseerAI::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
397 {
398 return _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
399 }
float getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const
Definition DynamicTree.cpp:275

References _dynamicTree, and DynamicMapTree::getHeight().

◆ GetGORespawnTime()

time_t Map::GetGORespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
414 {
415 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid);
416 if (itr != _goRespawnTimes.end())
417 return itr->second;
418
419 return time_t(0);
420 }

References _goRespawnTimes.

Referenced by GetLinkedRespawnTime(), and GameObject::LoadGameObjectFromDB().

◆ GetGridHeight()

float Map::GetGridHeight ( float  x,
float  y 
) const
1183{
1184 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1185 return gmap->getHeight(x, y);
1186
1187 return INVALID_HEIGHT;
1188}

References GetGridTerrainData(), and INVALID_HEIGHT.

Referenced by CheckCollisionAndGetValidCoords(), and GetHeight().

◆ GetGridTerrainData() [1/2]

GridTerrainData * Map::GetGridTerrainData ( float  x,
float  y 
)
1092{
1093 GridCoord const gridCoord = Acore::ComputeGridCoord(x, y);
1094 return GetGridTerrainData(gridCoord);
1095}

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

◆ GetGridTerrainData() [2/2]

GridTerrainData * Map::GetGridTerrainData ( GridCoord const &  gridCoord)
1082{
1083 if (!MapGridManager::IsValidGridCoordinates(gridCoord.x_coord, gridCoord.y_coord))
1084 return nullptr;
1085
1086 // ensure GridMap is created
1087 EnsureGridCreated(gridCoord);
1088 return _mapGridManager.GetGrid(gridCoord.x_coord, gridCoord.y_coord)->GetTerrainData();
1089}
MapGridType * GetGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:80
static bool IsValidGridCoordinates(uint16 const x, uint16 const y)
Definition MapGridManager.h:42
GridTerrainData * GetTerrainData() const
Definition MapGrid.h:100

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)
1075{
1076 // ensure GridMap is created
1077 EnsureGridCreated(gridCoord);
1078 return _mapGridManager.GetGrid(gridCoord.x_coord, gridCoord.y_coord)->GetTerrainDataSharedPtr();
1079}
std::shared_ptr< GridTerrainData > GetTerrainDataSharedPtr()
Definition MapGrid.h:101

References _mapGridManager, EnsureGridCreated(), 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
612 {
613 auto itr = _guidGenerators.find(high);
614 if (itr == _guidGenerators.end())
615 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
616
617 return *itr->second;
618 }
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition Map.h:620
Definition ObjectGuid.h:297

References _guidGenerators.

◆ GetHeight() [1/2]

float Map::GetHeight ( float  x,
float  y,
float  z,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
1146{
1147 // find raw .map surface under Z coordinates
1148 float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
1149 float gridHeight = GetGridHeight(x, y);
1150 if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
1151 mapHeight = gridHeight;
1152
1153 float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
1154 if (checkVMap)
1155 {
1157 vmapHeight = vmgr->getHeight(GetId(), x, y, z, maxSearchDist); // look from a bit higher pos to find the floor
1158 }
1159
1160 // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT
1161 // vmapheight set for any under Z value or <= INVALID_HEIGHT
1162 if (vmapHeight > INVALID_HEIGHT)
1163 {
1164 if (mapHeight > INVALID_HEIGHT)
1165 {
1166 // we have mapheight and vmapheight and must select more appropriate
1167
1168 // we are already under the surface or vmap height above map heigt
1169 // or if the distance of the vmap height is less the land height distance
1170 if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
1171 return vmapHeight;
1172 else
1173 return mapHeight; // better use .map surface height
1174 }
1175 else
1176 return vmapHeight; // we have only vmapHeight (if have)
1177 }
1178
1179 return mapHeight; // explicitly use map data
1180}
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist)=0

References VMAP::VMapFactory::createOrGetVMapMgr(), GetGridHeight(), VMAP::IVMapMgr::getHeight(), GetId(), 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::SelectImplicitCasterDestTargets(), and npc_cork_gizelton::npc_cork_gizeltonAI::WaypointReached().

◆ GetHeight() [2/2]

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

References _dynamicTree, GetHeight(), and DynamicMapTree::getHeight().

◆ GetId()

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

References i_mapEntry, and MapEntry::MapID.

Referenced by Group::_cancelHomebindIfInstance(), AddObjectToRemoveList(), InstanceMap::AddPlayerToMap(), WorldState::BroadcastSIWorldstates(), WorldState::BuffAdalsSongOfBattle(), WorldState::BuffMagtheridonTeam(), spell_gen_consumption::CalculateDamage(), 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(), GetAreaInfo(), GetDebugInfo(), GetFullTerrainStatusForPosition(), GetHeight(), GetLiquidData(), GetMapDifficulty(), debug_commandscript::HandleDebugObjectCountMap(), spell_valkyr_touch_aura::HandleEffectPeriodic(), gobject_commandscript::HandleGameObjectAddCommand(), go_commandscript::HandleGoZoneXYCommand(), WorldSession::HandleMoveWorldportAck(), npc_commandscript::HandleNpcAddCommand(), WorldSession::HandlePlayerLoginFromDB(), WorldSession::HandlePlayerLoginToCharInWorld(), WorldSession::HandleSetRaidDifficultyOpcode(), wp_commandscript::HandleWpModifyCommand(), wp_commandscript::HandleWpShowCommand(), InitVisibilityDistance(), InstanceMap::InitVisibilityDistance(), Player::inRandomLfgDungeon(), isInLineOfSight(), DisableMgr::IsPathfindingEnabled(), InstanceScript::IsTwoFactionInstance(), GridObjectLoader::LoadAllCellsInGrid(), LoadCorpseData(), GridTerrainLoader::LoadMap(), GridTerrainLoader::LoadMMap(), LoadRespawnTimes(), GridTerrainLoader::LoadVMap(), LogEncounterFinished(), AchievementCriteriaData::Meets(), MotionMaster::MoveFall(), lfg::LFGPlayerScript::OnPlayerMapChanged(), InstanceMap::PermBindAllPlayers(), RemoveAllPlayers(), RemoveCreatureRespawnTime(), RemoveGORespawnTime(), InstanceMap::Reset(), Player::RewardReputation(), SaveCreatureRespawnTime(), SaveGORespawnTime(), InstanceMap::SendResetWarnings(), World::SetInitialWorldSettings(), WorldObject::SetMap(), Player::SetMover(), SummonCreatureGroup(), MotionTransport::TeleportTransport(), UnloadGrid(), GridTerrainUnloader::UnloadTerrain(), Update(), UpdateEncounterState(), and ~Map().

◆ GetInstanceId()

◆ GetInstanceResetPeriod()

time_t Map::GetInstanceResetPeriod ( ) const
inline

◆ GetLinkedRespawnTime()

time_t Map::GetLinkedRespawnTime ( ObjectGuid  guid) const
2625{
2626 ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
2627 switch (linkedGuid.GetHigh())
2628 {
2629 case HighGuid::Unit:
2630 return GetCreatureRespawnTime(linkedGuid.GetCounter());
2632 return GetGORespawnTime(linkedGuid.GetCounter());
2633 default:
2634 break;
2635 }
2636
2637 return time_t(0);
2638}
#define sObjectMgr
Definition ObjectMgr.h:1650
time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:404
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:413
Definition ObjectGuid.h:118
HighGuid GetHigh() const
Definition ObjectGuid.h:143

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

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

◆ GetLiquidData()

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

References VMAP::AreaAndLiquidData::areaInfo, VMAP::VMapFactory::createOrGetVMapMgr(), LiquidData::DepthLevel, LiquidData::Entry, LiquidData::Flags, VMAP::AreaAndLiquidData::floorZ, VMAP::IVMapMgr::GetAreaAndLiquidData(), GetAreaId(), GetGridTerrainData(), GetId(), 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 ( )
3162{
3164}
uint32 GetLoadedGridsCount()
Definition MapGridManager.cpp:93

References _mapGridManager, and MapGridManager::GetLoadedGridsCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetMapDifficulty()

MapDifficulty const * Map::GetMapDifficulty ( ) const
2253{
2255}
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
1191{
1192 if (GridTerrainData const* grid = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1193 return grid->getMinHeight(x, y);
1194
1195 return MIN_HEIGHT;
1196}
#define MIN_HEIGHT
Definition GridTerrainData.h:29

References GetGridTerrainData(), and MIN_HEIGHT.

◆ GetMMapLock()

std::shared_mutex & Map::GetMMapLock ( ) const
inline
234{ return *(const_cast<std::shared_mutex*>(&MMapLock)); }
std::shared_mutex MMapLock
Definition Map.h:552

References MMapLock.

◆ GetObjectHitPos()

bool Map::GetObjectHitPos ( uint32  phasemask,
float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
float &  rx,
float &  ry,
float &  rz,
float  modifyDist 
)
1573{
1574 G3D::Vector3 startPos(x1, y1, z1);
1575 G3D::Vector3 dstPos(x2, y2, z2);
1576
1577 G3D::Vector3 resultPos;
1578 bool result = _dynamicTree.GetObjectHitPos(phasemask, startPos, dstPos, resultPos, modifyDist);
1579
1580 rx = resultPos.x;
1581 ry = resultPos.y;
1582 rz = resultPos.z;
1583 return result;
1584}
bool GetObjectHitPos(uint32 phasemask, const G3D::Vector3 &pPos1, const G3D::Vector3 &pPos2, G3D::Vector3 &pResultHitPos, float pModifyDist) const
Definition DynamicTree.cpp:211

References _dynamicTree, and DynamicMapTree::GetObjectHitPos().

Referenced by CheckCollisionAndGetValidCoords(), and Spell::SelectImplicitCasterDestTargets().

◆ GetObjectsStore()

◆ GetOrGenerateZoneDefaultWeather()

Weather * Map::GetOrGenerateZoneDefaultWeather ( uint32  zoneId)
2872{
2873 WeatherData const* weatherData = WeatherMgr::GetWeatherData(zoneId);
2874 if (!weatherData)
2875 return nullptr;
2876
2877 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
2878
2879 if (!info.DefaultWeather)
2880 {
2881 info.DefaultWeather = std::make_unique<Weather>(this, zoneId, weatherData);
2882 info.DefaultWeather->ReGenerate();
2883 info.DefaultWeather->UpdateWeather();
2884 }
2885
2886 return info.DefaultWeather.get();
2887}
ZoneDynamicInfoMap _zoneDynamicInfo
Definition Map.h:604
WeatherData const * GetWeatherData(uint32 zone_id)
Definition WeatherMgr.cpp:39
Definition Weather.h:40
Definition Map.h:133
std::unique_ptr< Weather > DefaultWeather
Definition Map.h:137

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
231{ return m_parentMap; }

References m_parentMap.

Referenced by GridTerrainLoader::LoadMap().

◆ GetPet()

Pet * Map::GetPet ( ObjectGuid const &  guid)
2368{
2369 return dynamic_cast<Pet*>(_objectsStore.Find<Creature>(guid));
2370}
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
518 {
519 if (auto const& it = _zonePlayerCountMap.find(zoneId); it != _zonePlayerCountMap.end())
520 return it->second;
521
522 return 0;
523 };

References _zonePlayerCountMap.

Referenced by debug_commandscript::HandleDebugZoneStatsCommand().

◆ GetPlayers()

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

References m_mapRefMgr.

Referenced by AddToMap(), boss_hadronox::boss_hadronoxAI::AnyPlayerValid(), MotionTransport::BuildUpdate(), StaticTransport::BuildUpdate(), InstanceMap::CannotEnter(), boss_professor_putricide::boss_professor_putricideAI::ChangePhase(), boss_gothik::boss_gothikAI::CheckGroupSplitted(), boss_volazj::CheckPhaseMinions(), boss_skadi_grauf::boss_skadi_graufAI::CheckPlayers(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::ChromieWhisper(), brann_bronzebeard::brann_bronzebeardAI::DoAction(), npc_arthas::npc_arthasAI::DoAction(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::DoCheckDedicatedInsanity(), boss_algalon_the_observer::boss_algalon_the_observerAI::DoCheckHeraldOfTheTitans(), DoForAllPlayers(), instance_violet_hold::instance_violet_hold_InstanceMapScript::DoNeedCleanup(), 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::boss_thorimAI::GetArenaPlayer(), spell_teron_gorefiend_shadowy_construct::HandleEffectApply(), spell_valkyr_touch_aura::HandleEffectPeriodic(), spell_yogg_saron_brain_link_aura::HandleOnEffectApply(), WorldSession::HandleSetRaidDifficultyOpcode(), boss_ichoron::boss_ichoronAI::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::boss_yoggsaronAI::JustDied(), boss_ahune::JustDied(), boss_four_horsemen::boss_four_horsemenAI::JustDied(), boss_devourer_of_souls::boss_devourer_of_soulsAI::JustEngagedWith(), boss_lady_deathwhisper::boss_lady_deathwhisperAI::JustSummoned(), boss_gothik::boss_gothikAI::JustSummoned(), LogEncounterFinished(), WorldSession::LogoutPlayer(), npc_image_of_medivh::npc_image_of_medivhAI::NextStep(), PlayDirectSoundToMap(), SmartScript::ProcessAction(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::RemoveBackPack(), RemoveFromMap(), boss_krystallus::boss_krystallusAI::RemoveStonedEffect(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::ReplaceMoiraIfSaved(), boss_volazj::ResetPlayersPhaseMask(), boss_yoggsaron_constrictor_tentacle::boss_yoggsaron_constrictor_tentacleAI::SelectConstrictTarget(), boss_yoggsaron_corruptor_tentacle::boss_yoggsaron_corruptor_tentacleAI::SelectCorruptionTarget(), boss_gluth::boss_gluthAI::SelectPlayerInRoom(), boss_thorim_arena_npcs::boss_thorim_arena_npcsAI::SelectT(), spell_gen_rallying_cry_of_the_dragonslayer::SelectTarget(), ScriptedAI::SelectTargetFromPlayerList(), CreatureTextMgr::SendChatPacket(), CreatureTextMgr::SendNonChatPacket(), SendPacketToPlayers(), npc_highlord_darion_mograine::npc_highlord_darion_mograineAI::SendUpdateWorldState(), SendZoneMessage(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::SetData(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::SetData(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::SetData(), instance_ulduar::instance_ulduar_InstanceMapScript::SetData(), GameObject::SetLootRecipient(), Creature::SetLootRecipient(), boss_hodir::boss_hodirAI::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::instance_halls_of_reflection_InstanceMapScript::Update(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::Update(), instance_vault_of_archavon::instance_vault_of_archavon_InstanceMapScript::Update(), boss_chromaggus::boss_chromaggusAI::UpdateAI(), npc_highlord_darion_mograine::npc_highlord_darion_mograineAI::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::npc_hor_lich_kingAI::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_heigan::boss_heiganAI::UpdateAI(), boss_sapphiron::boss_sapphironAI::UpdateAI(), boss_malygos::boss_malygosAI::UpdateAI(), npc_scion_of_eternity::npc_scion_of_eternityAI::UpdateAI(), boss_keristrasza::UpdateAI(), boss_freya::boss_freyaAI::UpdateAI(), boss_vezax::boss_vezaxAI::UpdateAI(), boss_hodir::boss_hodirAI::UpdateAI(), boss_ignis::boss_ignisAI::UpdateAI(), boss_mimiron::boss_mimironAI::UpdateAI(), npc_ulduar_leviathan_mkii::npc_ulduar_leviathan_mkiiAI::UpdateAI(), npc_ulduar_flames_initial::npc_ulduar_flames_initialAI::UpdateAI(), UpdateEncounterState(), npc_grimstone::npc_grimstoneAI::UpdateEscortAI(), npc_varian_wrynn::npc_varian_wrynnAI::UpdateWorldState(), and npc_thrall_bfu::npc_thrall_bfuAI::UpdateWorldState().

◆ GetPlayersCountExceptGMs()

◆ GetSpawnMode()

◆ GetTransport()

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

◆ GetTransportForPos()

Transport * Map::GetTransportForPos ( uint32  phase,
float  x,
float  y,
float  z,
WorldObject worldobject = nullptr 
)
1119{
1120 G3D::Vector3 v(x, y, z + 2.0f);
1121 G3D::Ray r(v, G3D::Vector3(0, 0, -1));
1122 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1123 if ((*itr)->IsInWorld() && (*itr)->GetExactDistSq(x, y, z) < 75.0f * 75.0f && (*itr)->m_model)
1124 {
1125 float dist = 30.0f;
1126 bool hit = (*itr)->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
1127 if (hit)
1128 return *itr;
1129 }
1130
1131 if (worldobject)
1132 if (GameObject* staticTrans = worldobject->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_TRANSPORT, 75.0f))
1133 if (staticTrans->m_model)
1134 {
1135 float dist = 10.0f;
1136 bool hit = staticTrans->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
1137 if (hit)
1138 if (GetHeight(phase, x, y, z, true, 30.0f) < (v.z - dist + 1.0f))
1139 return staticTrans->ToTransport();
1140 }
1141
1142 return nullptr;
1143}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1582
phase
Definition boss_skadi.cpp:99
GameObject * FindNearestGameObjectOfType(GameobjectTypes type, float range) const
Definition Object.cpp:2468

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
1525{
1526 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1527 return gmap->getLiquidLevel(x, y);
1528
1529 return INVALID_HEIGHT;
1530}

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
1098{
1099 // we need ground level (including grid height version) for proper return water level in point
1100 float ground_z = GetHeight(phasemask, x, y, z + Z_OFFSET_FIND_HEIGHT, true, 50.0f);
1101 if (ground)
1102 *ground = ground_z;
1103
1104 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phasemask, x, y, ground_z, collisionHeight, {});
1105 switch (liquidData.Status)
1106 {
1108 return std::max<float>(liquidData.Level, ground_z);
1110 return ground_z;
1111 default:
1112 return liquidData.Level;
1113 }
1114
1116}
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:1297

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
1290{
1291 areaid = zoneid = GetAreaId(phaseMask, x, y, z);
1292 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
1293 if (area->zone)
1294 zoneid = area->zone;
1295}

References GetAreaId(), and sAreaTableStore.

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

◆ GetZoneId()

uint32 Map::GetZoneId ( uint32  phaseMask,
float  x,
float  y,
float  z 
) const
1280{
1281 uint32 areaId = GetAreaId(phaseMask, x, y, z);
1282 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
1283 if (area->zone)
1284 return area->zone;
1285
1286 return areaId;
1287}

References GetAreaId(), and sAreaTableStore.

Referenced by MapMgr::GetZoneId().

◆ GetZoneWideVisibleWorldObjectsForZone()

ZoneWideVisibleWorldObjectsSet const * Map::GetZoneWideVisibleWorldObjectsForZone ( uint32  zoneId) const
672{
673 ZoneWideVisibleWorldObjectsMap::const_iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
674 if (itr == _zoneWideVisibleWorldObjectsMap.end())
675 return nullptr;
676
677 return &itr->second;
678}

References _zoneWideVisibleWorldObjectsMap.

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

◆ HandleDelayedVisibility()

void Map::HandleDelayedVisibility ( )
681{
683 return;
684 for (std::unordered_set<Unit*>::iterator itr = i_objectsForDelayedVisibility.begin(); itr != i_objectsForDelayedVisibility.end(); ++itr)
685 (*itr)->ExecuteDelayedUnitRelocationEvent();
687}
std::unordered_set< Unit * > i_objectsForDelayedVisibility
Definition Map.h:236

References i_objectsForDelayedVisibility.

Referenced by Update().

◆ HasEnoughWater() [1/2]

bool Map::HasEnoughWater ( WorldObject const *  searcher,
float  x,
float  y,
float  z 
) const
1607{
1608 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(
1609 searcher->GetPhaseMask(), x, y, z, searcher->GetCollisionHeight(), MAP_ALL_LIQUIDS);
1610
1611 if ((liquidData.Status & MAP_LIQUID_STATUS_SWIMMING) == 0)
1612 return false;
1613
1614 float minHeightInWater = searcher->GetMinHeightInWater();
1615 return liquidData.Level > INVALID_HEIGHT &&
1616 liquidData.Level > liquidData.DepthLevel &&
1617 liquidData.Level - liquidData.DepthLevel >= minHeightInWater;
1618}
#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 )
294{
295 //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
296}

◆ InitializeObject() [2/3]

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

◆ InitializeObject() [3/3]

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

Referenced by AddToMap().

◆ InitVisibilityDistance()

void Map::InitVisibilityDistance ( )
virtual

Reimplemented in InstanceMap, BattlegroundMap, and MapInstanced.

97{
98 //init visibility for continents
100
101 switch (GetId())
102 {
103 case MAP_EBON_HOLD: // Scarlet Enclave (DK starting zone)
104 m_VisibleDistance = 125.0f;
105 break;
106 case MAP_SCOTT_TEST: // (box map)
107 m_VisibleDistance = 200.0f;
108 break;
109 }
110}
@ MAP_EBON_HOLD
Definition AreaDefines.h:258
@ MAP_SCOTT_TEST
Definition AreaDefines.h:187
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 ( const GameObjectModel model)
inline
392{ _dynamicTree.insert(model); }
void insert(const GameObjectModel &)
Definition DynamicTree.cpp:117

References _dynamicTree, and DynamicMapTree::insert().

Referenced by GameObject::AddToWorld(), GameObject::UpdateModel(), and GameObject::UpdateModelPosition().

◆ Instanceable()

◆ Is25ManRaid()

◆ IsBattleArena()

◆ IsBattleground()

bool Map::IsBattleground ( ) const
inline
301{ return i_mapEntry && i_mapEntry->IsBattleground(); }
bool IsBattleground() const
Definition DBCStructure.h:1356

References i_mapEntry, and MapEntry::IsBattleground().

Referenced by SpellMgr::GetSpellIdForDifficulty(), and AuraEffect::HandleAuraDummy().

◆ IsBattlegroundOrArena()

◆ isCellMarked()

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

References marked_cells.

◆ IsDungeon()

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

References i_mapEntry, and MapEntry::IsDungeon().

Referenced by Group::_cancelHomebindIfInstance(), Group::_homebindIfInstance(), InstanceSaveMgr::_ResetOrWarnAll(), InstanceMap::AddPlayerToMap(), GameObject::AddToSkillupList(), Spell::CheckCast(), TransportMgr::CreateTransport(), Spell::DoAllEffectOnTarget(), ScriptedAI::DoTeleportAll(), CreatureAI::DoZoneInCombat(), Spell::EffectTeleportUnits(), 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
215 {
217 }
bool IsGridCreated(GridCoord const &gridCoord) const
Definition Map.cpp:209

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

◆ IsGridCreated() [2/2]

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

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
210 {
212 }

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

◆ IsGridLoaded() [2/2]

bool Map::IsGridLoaded ( GridCoord const &  gridCoord) const

◆ 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(), BattleExperienceEvent::Execute(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::GetData(), spell_freezing_circle::HandleDamage(), 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(), 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(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::Update(), npc_time_rift::UpdateAI(), boss_loken::UpdateAI(), UpdateEncounterState(), 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
1533{
1534 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_PVP_LOS))
1535 {
1537 {
1538 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1539 }
1540 }
1541
1542 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD))
1543 {
1544 if (IsWorldMap())
1545 {
1546 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1547 }
1548 }
1549
1550 if ((checks & LINEOFSIGHT_CHECK_VMAP) && !VMAP::VMapFactory::createOrGetVMapMgr()->isInLineOfSight(GetId(), x1, y1, z1, x2, y2, z2, ignoreFlags))
1551 {
1552 return false;
1553 }
1554
1555 if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT_ALL))
1556 {
1557 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1558 if (!(checks & LINEOFSIGHT_CHECK_GOBJECT_M2))
1559 {
1560 ignoreFlags = VMAP::ModelIgnoreFlags::M2;
1561 }
1562
1563 if (!_dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask, ignoreFlags))
1564 {
1565 return false;
1566 }
1567 }
1568
1569 return true;
1570}
@ LINEOFSIGHT_CHECK_GOBJECT_M2
Definition Map.h:106
@ LINEOFSIGHT_CHECK_VMAP
Definition Map.h:104
@ LINEOFSIGHT_CHECK_GOBJECT_ALL
Definition Map.h:108
@ CONFIG_CHECK_GOBJECT_LOS
Definition WorldConfig.h:114
@ CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD
Definition WorldConfig.h:136
@ CONFIG_VMAP_BLIZZLIKE_PVP_LOS
Definition WorldConfig.h:135
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:304
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
Definition Map.cpp:1532

References _dynamicTree, CONFIG_CHECK_GOBJECT_LOS, CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD, CONFIG_VMAP_BLIZZLIKE_PVP_LOS, VMAP::VMapFactory::createOrGetVMapMgr(), GetId(), IsBattlegroundOrArena(), isInLineOfSight(), DynamicMapTree::isInLineOfSight(), IsWorldMap(), LINEOFSIGHT_CHECK_GOBJECT_ALL, LINEOFSIGHT_CHECK_GOBJECT_M2, LINEOFSIGHT_CHECK_VMAP, VMAP::M2, VMAP::Nothing, and sWorld.

Referenced by RandomMovementGenerator< T >::_setRandomLocation(), isInLineOfSight(), 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
1595{
1596 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phaseMask, x, y, pZ, collisionHeight, {});
1597 return (liquidData.Status & MAP_LIQUID_STATUS_SWIMMING) != 0;
1598}

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
296{ return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); }
bool IsNonRaidDungeon() const
Definition DBCStructure.h:1353

References i_mapEntry, and MapEntry::IsNonRaidDungeon().

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

◆ 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
291{ return GetDifficulty() == REGULAR_DIFFICULTY; }
@ REGULAR_DIFFICULTY
Definition DBCEnums.h:267

References GetDifficulty(), and REGULAR_DIFFICULTY.

◆ IsUnderWater()

bool Map::IsUnderWater ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight 
) const
1601{
1602 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phaseMask, x, y, z, collisionHeight, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN);
1603 return liquidData.Status == LIQUID_MAP_UNDER_WATER;
1604}
#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
304{ return i_mapEntry && i_mapEntry->IsWorldMap(); }
bool IsWorldMap() const
Definition DBCStructure.h:1359

References i_mapEntry, and MapEntry::IsWorldMap().

Referenced by isInLineOfSight().

◆ LoadAllGrids()

void Map::LoadAllGrids ( )
220{
221 for (uint32 cellX = 0; cellX < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellX++)
222 for (uint32 cellY = 0; cellY < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellY++)
224}
#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:214

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 ( )
3102{
3104 stmt->SetData(0, GetId());
3105 stmt->SetData(1, GetInstanceId());
3106
3107 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3108 // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
3109 PreparedQueryResult result = CharacterDatabase.Query(stmt);
3110 if (!result)
3111 return;
3112
3113 do
3114 {
3115 Field* fields = result->Fetch();
3116 CorpseType type = CorpseType(fields[13].Get<uint8>());
3117 uint32 guid = fields[16].Get<uint32>();
3118 if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
3119 {
3120 LOG_ERROR("maps", "Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
3121 continue;
3122 }
3123
3124 Corpse* corpse = new Corpse(type);
3125
3126 if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
3127 {
3128 delete corpse;
3129 continue;
3130 }
3131
3132 AddCorpse(corpse);
3133
3134 corpse->UpdatePositionData();
3135 } while (result->NextRow());
3136}
@ CHAR_SEL_CORPSES
Definition CharacterDatabase.h:246
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 
)
227{
229 return;
230
231 float const x = center.GetPositionX();
232 float const y = center.GetPositionY();
233
234 CellCoord cellCoord(Acore::ComputeCellCoord(x, y));
235 if (!cellCoord.IsCoordValid())
236 return;
237
238 if (radius > SIZE_OF_GRIDS)
239 radius = SIZE_OF_GRIDS;
240
241 CellArea area = Cell::CalculateCellArea(x, y, radius);
242 if (!area)
243 return;
244
245 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
246 {
247 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
248 {
249 CellCoord cellCoord(x, y);
250 Cell cell(cellCoord);
251 EnsureGridLoaded(cell);
252 }
253 }
254}
#define SIZE_OF_GRIDS
Definition MapDefines.h:26
bool IsGridsFullyLoaded() const
Definition MapGridManager.cpp:126
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(), and Unit::ExecuteDelayedUnitRelocationEvent().

◆ LoadRespawnTimes()

void Map::LoadRespawnTimes ( )
2461{
2463 stmt->SetData(0, GetId());
2464 stmt->SetData(1, GetInstanceId());
2465 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2466 {
2467 do
2468 {
2469 Field* fields = result->Fetch();
2470 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
2471 uint32 respawnTime = fields[1].Get<uint32>();
2472
2473 _creatureRespawnTimes[lowguid] = time_t(respawnTime);
2474 } while (result->NextRow());
2475 }
2476
2477 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GO_RESPAWNS);
2478 stmt->SetData(0, GetId());
2479 stmt->SetData(1, GetInstanceId());
2480 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2481 {
2482 do
2483 {
2484 Field* fields = result->Fetch();
2485 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
2486 uint32 respawnTime = fields[1].Get<uint32>();
2487
2488 _goRespawnTimes[lowguid] = time_t(respawnTime);
2489 } while (result->NextRow());
2490 }
2491}
@ CHAR_SEL_CREATURE_RESPAWNS
Definition CharacterDatabase.h:252
@ CHAR_SEL_GO_RESPAWNS
Definition CharacterDatabase.h:257

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

Referenced by MapMgr::CreateBaseMap().

◆ LogEncounterFinished()

void Map::LogEncounterFinished ( EncounterCreditType  type,
uint32  creditEntry 
)
2580{
2581 if (!IsRaid() || !GetEntry() || GetEntry()->Expansion() < 2) // only for wotlk raids, because logs take up tons of mysql memory
2582 return;
2583 InstanceMap* map = ToInstanceMap();
2584 if (!map)
2585 return;
2586 std::string playersInfo;
2587 char buffer[16384], buffer2[255];
2588 Map::PlayerList const& pl = map->GetPlayers();
2589 for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
2590 if (Player* p = itr->GetSource())
2591 {
2592 std::string auraStr;
2593 const Unit::AuraApplicationMap& a = p->GetAppliedAuras();
2594 for (auto iterator = a.begin(); iterator != a.end(); ++iterator)
2595 {
2596 snprintf(buffer2, 255, "%u(%u) ", iterator->first, iterator->second->GetEffectMask());
2597 auraStr += buffer2;
2598 }
2599
2600 snprintf(buffer, 16384, "%s (%s, acc: %u, ip: %s, guild: %u), xyz: (%.1f, %.1f, %.1f), auras: %s\n",
2601 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());
2602 playersInfo += buffer;
2603 }
2604 CleanStringForMysqlQuery(playersInfo);
2605 CharacterDatabase.Execute("INSERT INTO log_encounter VALUES(NOW(), {}, {}, {}, {}, '{}')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo);
2606}
void CleanStringForMysqlQuery(std::string &str)
Definition Common.cpp:61
LinkedListHead::Iterator< GridReference< MapGridType > > iterator
Definition GridRefMgr.h:30
Definition Map.h:646
Definition MapRefMgr.h:26
InstanceMap * ToInstanceMap()
Definition Map.h:377
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:659

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

Referenced by UpdateEncounterState().

◆ markCell()

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

References marked_cells.

Referenced by MarkNearbyCellsOf().

◆ MarkNearbyCellsOf()

void Map::MarkNearbyCellsOf ( WorldObject obj)
397{
398 // Check for valid position
399 if (!obj->IsPositionValid())
400 return;
401
402 // Update mobs/objects in ALL visible cells around object!
404 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
405 {
406 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
407 {
408 // marked cells are those that have been visited
409 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
410 markCell(cell_id);
411 }
412 }
413}
void markCell(uint32 pCellId)
Definition Map.h:318
float GetGridActivationRange() const
Definition Object.cpp:1656
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 ( )
909{
910 for (std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr)
911 {
912 Creature* c = *itr;
913 if (c->FindMap() != this)
914 continue;
915
917 {
919 continue;
920 }
921
923 if (!c->IsInWorld())
924 continue;
925
926 Cell const& old_cell = c->GetCurrentCell();
927 Cell new_cell(c->GetPositionX(), c->GetPositionY());
928 if (c->IsFarVisible())
929 {
930 // Removes via GetCurrentCell, added back in AddToGrid
932 }
933
934 c->RemoveFromGrid();
935 if (old_cell.DiffGrid(new_cell))
936 EnsureGridLoaded(new_cell);
937 AddToGrid(c, new_cell);
938 }
939 _creaturesToMove.clear();
940}
void RemoveFromGrid()
Definition Object.h:370
void RemoveWorldObjectFromFarVisibleMap(WorldObject *obj)
Definition Map.cpp:640
Map * FindMap() const
Definition Object.h:622

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 ( )
978{
979 for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr)
980 {
981 DynamicObject* dynObj = *itr;
982 if (dynObj->FindMap() != this)
983 continue;
984
986 {
988 continue;
989 }
990
992 if (!dynObj->IsInWorld())
993 continue;
994
995 Cell const& old_cell = dynObj->GetCurrentCell();
996 Cell new_cell(dynObj->GetPositionX(), dynObj->GetPositionY());
997
998 dynObj->RemoveFromGrid();
999 if (old_cell.DiffGrid(new_cell))
1000 EnsureGridLoaded(new_cell);
1001 AddToGrid(dynObj, new_cell);
1002 }
1003 _dynamicObjectsToMove.clear();
1004}

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 ( )
943{
944 for (std::vector<GameObject*>::iterator itr = _gameObjectsToMove.begin(); itr != _gameObjectsToMove.end(); ++itr)
945 {
946 GameObject* go = *itr;
947 if (go->FindMap() != this)
948 continue;
949
951 {
953 continue;
954 }
955
957 if (!go->IsInWorld())
958 continue;
959
960 Cell const& old_cell = go->GetCurrentCell();
961 Cell new_cell(go->GetPositionX(), go->GetPositionY());
962
963 if (go->IsFarVisible())
964 {
965 // Removes via GetCurrentCell, added back in AddToGrid
967 }
968
969 go->RemoveFromGrid();
970 if (old_cell.DiffGrid(new_cell))
971 EnsureGridLoaded(new_cell);
972 AddToGrid(go, new_cell);
973 }
974 _gameObjectsToMove.clear();
975}

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 ( )
88{
89 // Instances load all grids by default (both base map and child maps)
90 if (GetInstanceId())
92
93 sScriptMgr->OnCreateMap(this);
94}
void LoadAllGrids()
Definition Map.cpp:219

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

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

◆ PlayDirectSoundToMap()

void Map::PlayDirectSoundToMap ( uint32  soundId,
uint32  zoneId = 0 
)
2849{
2850 Map::PlayerList const& players = GetPlayers();
2851 if (!players.IsEmpty())
2852 {
2854 data << uint32(soundId);
2855
2856 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2857 if (Player* player = itr->GetSource())
2858 if (!zoneId || player->GetZoneId() == zoneId)
2859 player->SendDirectMessage(&data);
2860 }
2861}
@ 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 
)
785{
786 Cell old_cell(player->GetPositionX(), player->GetPositionY());
787 Cell new_cell(x, y);
788
789 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
790 {
791 player->RemoveFromGrid();
792
793 if (old_cell.DiffGrid(new_cell))
794 EnsureGridLoaded(new_cell);
795
796 AddToGrid(player, new_cell);
797 }
798
799 player->Relocate(x, y, z, o);
800 if (player->IsVehicle())
802 player->UpdatePositionData();
803 player->UpdateObjectVisibility(false);
804}

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().

◆ RemoveAllObjectsInRemoveList()

void Map::RemoveAllObjectsInRemoveList ( )
1794{
1795 while (!i_objectsToRemove.empty())
1796 {
1797 std::unordered_set<WorldObject*>::iterator itr = i_objectsToRemove.begin();
1798 WorldObject* obj = *itr;
1799 i_objectsToRemove.erase(itr);
1800
1801 switch (obj->GetTypeId())
1802 {
1803 case TYPEID_CORPSE:
1804 {
1805 Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
1806 if (!corpse)
1807 LOG_ERROR("maps", "Tried to delete corpse/bones {} that is not in map.", obj->GetGUID().ToString());
1808 else
1809 RemoveFromMap(corpse, true);
1810 break;
1811 }
1813 RemoveFromMap((DynamicObject*)obj, true);
1814 break;
1815 case TYPEID_GAMEOBJECT:
1816 if (Transport* transport = obj->ToGameObject()->ToTransport())
1817 RemoveFromMap(transport, true);
1818 else
1819 RemoveFromMap(obj->ToGameObject(), true);
1820 break;
1821 case TYPEID_UNIT:
1822 // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call
1823 // make sure that like sources auras/etc removed before destructor start
1825 RemoveFromMap(obj->ToCreature(), true);
1826 break;
1827 default:
1828 LOG_ERROR("maps", "Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->GetTypeId());
1829 break;
1830 }
1831 }
1832}
@ TYPEID_DYNAMICOBJECT
Definition ObjectGuid.h:38
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ TYPEID_CORPSE
Definition ObjectGuid.h:39
void RemoveFromMap(T *, bool)
Definition Map.cpp:727
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:15786
Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:179

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.

1016{
1017 if (HavePlayers())
1018 {
1019 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1020 {
1021 Player* player = itr->GetSource();
1022 if (!player->IsBeingTeleportedFar())
1023 {
1024 // this is happening for bg
1025 LOG_ERROR("maps", "Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->GetName(), GetId());
1026 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
1027 }
1028 }
1029 }
1030}
float m_homebindZ
Definition Player.h:2378
bool IsBeingTeleportedFar() const
Definition Player.h:2092
uint32 m_homebindMapId
Definition Player.h:2374
float m_homebindY
Definition Player.h:2377
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1350
float m_homebindX
Definition Player.h:2376
std::string const & GetName() const
Definition Object.h:525

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)
2653{
2654 ASSERT(corpse);
2655 GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
2656
2657 corpse->DestroyForVisiblePlayers();
2658 if (corpse->IsInGrid())
2659 RemoveFromMap(corpse, false);
2660 else
2661 {
2662 corpse->RemoveFromWorld();
2663 corpse->ResetMap();
2664 }
2665
2666 _corpsesByGrid[gridCoord.GetId()].erase(corpse);
2667 if (corpse->GetType() != CORPSE_BONES)
2668 _corpsesByPlayer.erase(corpse->GetOwnerGUID());
2669 else
2670 _corpseBones.erase(corpse);
2671}
void RemoveFromWorld() override
Definition Corpse.cpp:52
bool IsInGrid() const
Definition Object.h:361
virtual void ResetMap()
Definition Object.cpp:2138
void DestroyForVisiblePlayers()
Definition Object.cpp:2947

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)
2416{
2417 _creatureRespawnTimes.erase(spawnId);
2418
2420 stmt->SetData(0, spawnId);
2421 stmt->SetData(1, GetId());
2422 stmt->SetData(2, GetInstanceId());
2423 CharacterDatabase.Execute(stmt);
2424}
@ CHAR_DEL_CREATURE_RESPAWN
Definition CharacterDatabase.h:254

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

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

◆ RemoveDynamicObjectFromMoveList()

void Map::RemoveDynamicObjectFromMoveList ( DynamicObject go)
private

◆ RemoveFromMap() [1/2]

template<class T >
void Map::RemoveFromMap ( T *  obj,
bool  remove 
)
728{
729 obj->RemoveFromWorld();
730
731 obj->RemoveFromGrid();
732
733 obj->ResetMap();
734
735 if (remove)
736 {
738 DeleteFromWorld(obj);
739 }
740}
void RemoveObjectFromMapUpdateList(WorldObject *obj)
Definition Map.cpp:605
void DeleteFromWorld(T *)
Definition Map.cpp:166

References DeleteFromWorld(), and RemoveObjectFromMapUpdateList().

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

◆ RemoveFromMap() [2/2]

template<>
void Map::RemoveFromMap ( Transport obj,
bool  remove 
)
744{
745 obj->RemoveFromWorld();
746
747 Map::PlayerList const& players = GetPlayers();
748 if (!players.IsEmpty())
749 {
750 UpdateData data;
751 obj->BuildOutOfRangeUpdateBlock(&data);
752 WorldPacket packet;
753 data.BuildPacket(packet);
754 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
755 if (itr->GetSource()->GetTransport() != obj)
756 itr->GetSource()->SendDirectMessage(&packet);
757 }
758
760 {
761 TransportsContainer::iterator itr = _transports.find(obj);
762 if (itr == _transports.end())
763 return;
764 if (itr == _transportsUpdateIter)
766 _transports.erase(itr);
767 }
768 else
769 _transports.erase(obj);
770
771 obj->ResetMap();
772
774
775 if (remove)
776 {
777 // if option set then object already saved at this moment
778 if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
779 obj->SaveRespawnTime();
780 DeleteFromWorld(obj);
781 }
782}
@ CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY
Definition WorldConfig.h:52
void RemoveFromWorld() override
Definition GameObject.cpp:168
void SaveRespawnTime() override
Definition GameObject.h:243
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
Definition Object.cpp:258

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 ( const GameObjectModel model)
inline
391{ _dynamicTree.remove(model); }
void remove(const GameObjectModel &)
Definition DynamicTree.cpp:122

References _dynamicTree, and DynamicMapTree::remove().

Referenced by GameObject::RemoveFromWorld(), GameObject::UpdateModel(), and GameObject::UpdateModelPosition().

◆ RemoveGORespawnTime()

void Map::RemoveGORespawnTime ( ObjectGuid::LowType  dbGuid)
2450{
2451 _goRespawnTimes.erase(spawnId);
2452
2454 stmt->SetData(0, spawnId);
2455 stmt->SetData(1, GetId());
2456 stmt->SetData(2, GetInstanceId());
2457 CharacterDatabase.Execute(stmt);
2458}
@ CHAR_DEL_GO_RESPAWN
Definition CharacterDatabase.h:259

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

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

◆ RemoveObjectFromMapUpdateList()

void Map::RemoveObjectFromMapUpdateList ( WorldObject obj)

◆ RemoveOldCorpses()

void Map::RemoveOldCorpses ( )
2727{
2728 time_t now = GameTime::GetGameTime().count();
2729
2730 std::vector<ObjectGuid> corpses;
2731 corpses.reserve(_corpsesByPlayer.size());
2732
2733 for (auto const& p : _corpsesByPlayer)
2734 if (p.second->IsExpired(now))
2735 corpses.push_back(p.first);
2736
2737 for (ObjectGuid const& ownerGuid : corpses)
2738 ConvertCorpseToBones(ownerGuid);
2739
2740 std::vector<Corpse*> expiredBones;
2741 for (Corpse* bones : _corpseBones)
2742 if (bones->IsExpired(now))
2743 expiredBones.push_back(bones);
2744
2745 for (Corpse* bones : expiredBones)
2746 {
2747 RemoveCorpse(bones);
2748 delete bones;
2749 }
2750}
Seconds GetGameTime()
Definition GameTime.cpp:38

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.

702{
704
705 player->getHostileRefMgr().deleteReferences(true); // pussywizard: multithreading crashfix
706
707 player->RemoveFromWorld();
708 SendRemoveTransports(player);
709
710 if (player->IsInGrid())
711 player->RemoveFromGrid();
712 else
713 ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map
714
715 sScriptMgr->OnPlayerLeaveMap(this, player);
716 if (remove)
717 {
718 DeleteFromWorld(player);
719 }
720}
#define MAP_INVALID_ZONE
Definition Map.cpp:48
void deleteReferences(bool removeFromMap=false)
Definition HostileRefMgr.cpp:125
void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone)
Definition Map.cpp:415
void SendRemoveTransports(Player *player)
Definition Map.cpp:1690
void RemoveFromWorld() override
Definition Player.cpp:1710
HostileRefMgr & getHostileRefMgr()
Definition Unit.h:940
uint32 GetZoneId() const
Definition Object.cpp:3063

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

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

◆ RemoveUpdateObject()

void Map::RemoveUpdateObject ( Object obj)
inline
492 {
493 _updateObjects.erase(obj);
494 }

References _updateObjects.

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

◆ RemoveWorldObjectFromFarVisibleMap()

void Map::RemoveWorldObjectFromFarVisibleMap ( WorldObject obj)
641{
642 if (Creature* creature = obj->ToCreature())
643 {
644 Cell curr_cell = creature->GetCurrentCell();
645 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
646 grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
647 }
648 else if (GameObject* go = obj->ToGameObject())
649 {
650 Cell curr_cell = go->GetCurrentCell();
651 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
652 grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
653 }
654}
void RemoveFarVisibleObject(uint16 const x, uint16 const y, SPECIFIC_OBJECT *obj)
Definition MapGrid.h:63

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 
)
663{
664 ZoneWideVisibleWorldObjectsMap::iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
665 if (itr == _zoneWideVisibleWorldObjectsMap.end())
666 return;
667
668 itr->second.erase(obj);
669}

References _zoneWideVisibleWorldObjectsMap.

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

◆ resetMarkedCells()

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

References marked_cells.

Referenced by Update().

◆ SaveCreatureRespawnTime()

void Map::SaveCreatureRespawnTime ( ObjectGuid::LowType  dbGuid,
time_t &  respawnTime 
)
2393{
2394 if (!respawnTime)
2395 {
2396 // Delete only
2398 return;
2399 }
2400
2401 time_t now = GameTime::GetGameTime().count();
2402 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
2403 respawnTime = now + YEAR;
2404
2405 _creatureRespawnTimes[spawnId] = respawnTime;
2406
2408 stmt->SetData(0, spawnId);
2409 stmt->SetData(1, uint32(respawnTime));
2410 stmt->SetData(2, GetId());
2411 stmt->SetData(3, GetInstanceId());
2412 CharacterDatabase.Execute(stmt);
2413}
@ CHAR_REP_CREATURE_RESPAWN
Definition CharacterDatabase.h:253
constexpr auto YEAR
Definition Common.h:52
time_t GetInstanceResetPeriod() const
Definition Map.h:428
void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2415

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

Referenced by Creature::SaveRespawnTime().

◆ SaveGORespawnTime()

void Map::SaveGORespawnTime ( ObjectGuid::LowType  dbGuid,
time_t &  respawnTime 
)
2427{
2428 if (!respawnTime)
2429 {
2430 // Delete only
2431 RemoveGORespawnTime(spawnId);
2432 return;
2433 }
2434
2435 time_t now = GameTime::GetGameTime().count();
2436 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
2437 respawnTime = now + YEAR;
2438
2439 _goRespawnTimes[spawnId] = respawnTime;
2440
2442 stmt->SetData(0, spawnId);
2443 stmt->SetData(1, uint32(respawnTime));
2444 stmt->SetData(2, GetId());
2445 stmt->SetData(3, GetInstanceId());
2446 CharacterDatabase.Execute(stmt);
2447}
@ CHAR_REP_GO_RESPAWN
Definition CharacterDatabase.h:258
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2449

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

Referenced by GameObject::SaveRespawnTime().

◆ ScheduleCreatureRespawn()

void Map::ScheduleCreatureRespawn ( ObjectGuid  creatureGuid,
Milliseconds  respawnTimer,
Position  pos = Position() 
)
2753{
2754 Events.AddEventAtOffset([this, creatureGuid, pos]()
2755 {
2756 if (Creature* creature = GetCreature(creatureGuid))
2757 creature->Respawn();
2758 else
2759 SummonCreature(creatureGuid.GetEntry(), pos);
2760 }, respawnTimer);
2761}
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:2165
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2357
uint32 GetEntry() const
Definition ObjectGuid.h:144

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:120
bool IsItem() const
Definition Object.h:225
Definition Map.h:82
ObjectGuid targetGUID
Definition Map.h:84
ObjectGuid ownerGUID
Definition Map.h:85
ObjectGuid sourceGUID
Definition Map.h:83
ScriptInfo const * script
Definition Map.h:86

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:421
@ CHAT_TYPE_TEXT_EMOTE
Definition CreatureData.h:423
@ CHAT_TYPE_BOSS_EMOTE
Definition CreatureData.h:424
@ CHAT_TYPE_WHISPER
Definition CreatureData.h:425
@ CHAT_TYPE_YELL
Definition CreatureData.h:422
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:85
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition ObjectMgr.cpp:83
@ SF_CASTSPELL_SOURCE_TO_SOURCE
Definition ObjectMgr.h:174
@ SF_CASTSPELL_SOURCE_TO_TARGET
Definition ObjectMgr.h:173
@ SF_CASTSPELL_TRIGGERED
Definition ObjectMgr.h:178
@ SF_CASTSPELL_TARGET_TO_SOURCE
Definition ObjectMgr.h:176
@ SF_REMOVEAURA_REVERSE
Definition ObjectMgr.h:170
@ SF_PLAYSOUND_DISTANCE_SOUND
Definition ObjectMgr.h:182
@ SF_TALK_USE_PLAYER
Definition ObjectMgr.h:158
@ SF_TELEPORT_USE_CREATURE
Definition ObjectMgr.h:164
@ SF_KILLCREDIT_REWARD_GROUP
Definition ObjectMgr.h:167
@ SF_PLAYSOUND_TARGET_PLAYER
Definition ObjectMgr.h:181
@ SF_CASTSPELL_TARGET_TO_TARGET
Definition ObjectMgr.h:175
@ SF_EMOTE_USE_STATE
Definition ObjectMgr.h:161
@ SF_CASTSPELL_SEARCH_CREATURE
Definition ObjectMgr.h:177
@ SF_PLAYSOUND_DISTANCE_RADIUS
Definition ObjectMgr.h:183
@ SF_ORIENTATION_FACE_TARGET
Definition ObjectMgr.h:186
@ SCRIPT_COMMAND_EMOTE
Definition ObjectMgr.h:93
@ SCRIPT_COMMAND_CREATE_ITEM
Definition ObjectMgr.h:109
@ SCRIPT_COMMAND_DESPAWN_SELF
Definition ObjectMgr.h:110
@ SCRIPT_COMMAND_CAST_SPELL
Definition ObjectMgr.h:107
@ SCRIPT_COMMAND_RESPAWN_GAMEOBJECT
Definition ObjectMgr.h:101
@ SCRIPT_COMMAND_QUEST_EXPLORED
Definition ObjectMgr.h:99
@ SCRIPT_COMMAND_ACTIVATE_OBJECT
Definition ObjectMgr.h:105
@ SCRIPT_COMMAND_TALK
Definition ObjectMgr.h:92
@ SCRIPT_COMMAND_EQUIP
Definition ObjectMgr.h:118
@ SCRIPT_COMMAND_FIELD_SET
Definition ObjectMgr.h:94
@ SCRIPT_COMMAND_PLAYMOVIE
Definition ObjectMgr.h:121
@ SCRIPT_COMMAND_CALLSCRIPT_TO_UNIT
Definition ObjectMgr.h:113
@ SCRIPT_COMMAND_TELEPORT_TO
Definition ObjectMgr.h:98
@ SCRIPT_COMMAND_MOVE_TO
Definition ObjectMgr.h:95
@ SCRIPT_COMMAND_FLAG_SET
Definition ObjectMgr.h:96
@ SCRIPT_COMMAND_TEMP_SUMMON_CREATURE
Definition ObjectMgr.h:102
@ SCRIPT_COMMAND_MOVEMENT
Definition ObjectMgr.h:122
@ SCRIPT_COMMAND_KILL_CREDIT
Definition ObjectMgr.h:100
@ SCRIPT_COMMAND_KILL
Definition ObjectMgr.h:114
@ SCRIPT_COMMAND_LOAD_PATH
Definition ObjectMgr.h:112
@ SCRIPT_COMMAND_ORIENTATION
Definition ObjectMgr.h:117
@ SCRIPT_COMMAND_PLAY_SOUND
Definition ObjectMgr.h:108
@ SCRIPT_COMMAND_MODEL
Definition ObjectMgr.h:119
@ SCRIPT_COMMAND_CLOSE_GOSSIP
Definition ObjectMgr.h:120
@ SCRIPT_COMMAND_REMOVE_AURA
Definition ObjectMgr.h:106
@ SCRIPT_COMMAND_FLAG_REMOVE
Definition ObjectMgr.h:97
std::map< uint32, ScriptMap > ScriptMapMap
Definition ObjectMgr.h:386
ScriptsType
Definition ObjectMgr.h:145
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition Object.h:48
std::vector< ItemPosCount > ItemPosCountVec
Definition Player.h:766
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:887
@ GAMEOBJECT_TYPE_TRAP
Definition SharedDefines.h:1577
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition SharedDefines.h:1588
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition SharedDefines.h:3444
@ UNIT_NPC_EMOTESTATE
Definition UpdateFields.h:140
@ OBJECT_FIELD_ENTRY
Definition UpdateFields.h:27
#define sWaypointMgr
Definition WaypointMgr.h:79
bool isSpawned() const
Definition GameObject.h:189
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2434
void SetRespawnTime(int32 respawn)
Definition GameObject.cpp:1284
void Use(Unit *user)
Definition GameObject.cpp:1460
static T * Find(ObjectGuid guid)
Definition ObjectAccessor.cpp:53
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:2367
Creature * _GetScriptCreature(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:186
Corpse * GetCorpse(ObjectGuid const &guid)
Definition Map.cpp:2352
Creature * _GetScriptCreatureSourceOrTarget(Object *source, Object *target, const ScriptInfo *scriptInfo, bool bReverse=false) const
Definition MapScripts.cpp:120
WorldObject * _GetScriptWorldObject(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:201
Player * _GetScriptPlayerSourceOrTarget(Object *source, Object *target, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:98
void _ScriptProcessDoor(Object *source, Object *target, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:217
Transport * GetTransport(ObjectGuid const &guid)
Definition Map.cpp:2372
Player * _GetScriptPlayer(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:171
Unit * _GetScriptUnit(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:153
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:901
void MovePoint(uint32 id, const Position &pos, ForcedMovement forcedMovement=FORCED_MOVEMENT_NONE, float speed=0.f, bool generatePath=true, bool forceDestination=true)
Definition MotionMaster.h:228
Definition Object.h:104
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:1927
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition PlayerQuest.cpp:1818
void SendMovieStart(uint32 MovieId)
Definition Player.cpp:5727
void FailQuest(uint32 quest_id)
Definition PlayerQuest.cpp:886
PlayerMenu * PlayerTalkClass
Definition Player.h:2243
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:12781
void SetFacingToObject(WorldObject *object, Milliseconds timed=0ms)
Definition Unit.cpp:20290
void SetFacingTo(float ori)
Definition Unit.cpp:20280
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:21015
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:21020
MotionMaster * GetMotionMaster()
Definition Unit.h:1713
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:21025
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:1194
void NearTeleportTo(Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
Definition Unit.cpp:19738
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition Unit.cpp:21030
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1354
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1278
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2408
Player * GetPlayer(Map const *, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:220
Definition ChatCommandTags.h:253
float Orientation
Definition ObjectMgr.h:250
uint32 Flags
Definition ObjectMgr.h:207
struct ScriptInfo::@267::@287 CallScript
uint32 FieldID
Definition ObjectMgr.h:219
struct ScriptInfo::@267::@291 Model
struct ScriptInfo::@267::@278 RespawnGameobject
struct ScriptInfo::@267::@273 MoveTo
uint32 QuestID
Definition ObjectMgr.h:255
float SearchRadius
Definition ObjectMgr.h:304
struct ScriptInfo::@267::@284 CreateItem
struct ScriptInfo::@267::@276 QuestExplored
int32 TextID
Definition ObjectMgr.h:208
uint32 MovementType
Definition ObjectMgr.h:376
uint32 MovementDistance
Definition ObjectMgr.h:377
struct ScriptInfo::@267::@293 Movement
struct ScriptInfo::@267::@282 CastSpell
float DestX
Definition ObjectMgr.h:229
uint32 ItemEntry
Definition ObjectMgr.h:316
uint32 ChatType
Definition ObjectMgr.h:206
uint32 SoundID
Definition ObjectMgr.h:309
uint32 CheckIfExists
Definition ObjectMgr.h:275
struct ScriptInfo::@267::@271 Emote
struct ScriptInfo::@267::@272 FieldSet
uint32 ScriptID
Definition ObjectMgr.h:334
uint32 ModelID
Definition ObjectMgr.h:364
struct ScriptInfo::@267::@285 DespawnSelf
struct ScriptInfo::@267::@277 KillCredit
uint32 FieldValue
Definition ObjectMgr.h:220
float PosY
Definition ObjectMgr.h:278
struct ScriptInfo::@267::@288 Kill
struct ScriptInfo::@267::@274 FlagToggle
float DestY
Definition ObjectMgr.h:230
uint32 PathID
Definition ObjectMgr.h:327
uint32 MapID
Definition ObjectMgr.h:243
uint32 IsRepeatable
Definition ObjectMgr.h:328
struct ScriptInfo::@267::@292 PlayMovie
int32 Path
Definition ObjectMgr.h:378
int32 RemoveCorpse
Definition ObjectMgr.h:342
float PosZ
Definition ObjectMgr.h:279
struct ScriptInfo::@267::@279 TempSummonCreature
struct ScriptInfo::@267::@270 Talk
uint32 ScriptType
Definition ObjectMgr.h:335
uint32 DespawnDelay
Definition ObjectMgr.h:268
float PosX
Definition ObjectMgr.h:277
int32 Radius
Definition ObjectMgr.h:311
struct ScriptInfo::@267::@286 LoadPath
uint32 TravelTime
Definition ObjectMgr.h:226
uint32 Distance
Definition ObjectMgr.h:256
struct ScriptInfo::@267::@275 TeleportTo
uint32 SpellID
Definition ObjectMgr.h:294
struct ScriptInfo::@267::@281 RemoveAura
float DestZ
Definition ObjectMgr.h:231
struct ScriptInfo::@267::@283 Playsound
uint32 MovieID
Definition ObjectMgr.h:371
struct ScriptInfo::@267::@290 Equip
uint32 EquipmentID
Definition ObjectMgr.h:359
uint32 CreatureEntry
Definition ObjectMgr.h:261
uint32 Amount
Definition ObjectMgr.h:317
uint32 EmoteID
Definition ObjectMgr.h:213

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:385

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(), Spell::EffectDummy(), Spell::EffectScriptEffect(), Spell::EffectSendEvent(), WaypointMovementGenerator< Creature >::OnArrived(), ScriptsProcess(), and GameObject::Use().

◆ SendInitSelf()

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

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)
1672{
1673 if (_transports.empty())
1674 return;
1675
1676 // Hack to send out transports
1677 UpdateData transData;
1678 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1679 if (*itr != player->GetTransport())
1680 (*itr)->BuildCreateUpdateBlockForPlayer(&transData, player);
1681
1682 if (!transData.HasData())
1683 return;
1684
1685 WorldPacket packet;
1686 transData.BuildPacket(packet);
1687 player->SendDirectMessage(&packet);
1688}
bool HasData() const
Definition UpdateData.h:60

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

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

◆ SendObjectUpdates()

void Map::SendObjectUpdates ( )
private
1710{
1711 UpdateDataMapType update_players;
1712
1713 while (!_updateObjects.empty())
1714 {
1715 Object* obj = *_updateObjects.begin();
1716 ASSERT(obj->IsInWorld());
1717
1718 _updateObjects.erase(_updateObjects.begin());
1719 obj->BuildUpdate(update_players);
1720 }
1721
1722 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
1723 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
1724 {
1725 iter->second.BuildPacket(packet);
1726 iter->first->SendDirectMessage(&packet);
1727 packet.clear(); // clean the string
1728 }
1729}
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition Object.h:99
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)
1691{
1692 if (_transports.empty())
1693 return;
1694
1695 // Hack to send out transports
1696 UpdateData transData;
1697 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1698 if (*itr != player->GetTransport())
1699 (*itr)->BuildOutOfRangeUpdateBlock(&transData);
1700
1701 if (!transData.HasData())
1702 return;
1703
1704 WorldPacket packet;
1705 transData.BuildPacket(packet);
1706 player->SendDirectMessage(&packet);
1707}

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

Referenced by RemovePlayerFromMap().

◆ SendToPlayers()

void Map::SendToPlayers ( WorldPacket const *  data) const
1844{
1845 for (MapRefMgr::const_iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1846 itr->GetSource()->SendDirectMessage(data);
1847}

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
2793{
2794 ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
2795 if (itr == _zoneDynamicInfo.end())
2796 return;
2797
2798 if (uint32 music = itr->second.MusicId)
2799 player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
2800
2801 SendZoneWeather(itr->second, player);
2802
2803 if (uint32 overrideLight = itr->second.OverrideLightId)
2804 {
2805 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4);
2806 data << uint32(_defaultLight);
2807 data << uint32(overrideLight);
2808 data << uint32(itr->second.LightFadeInTime);
2809 player->SendDirectMessage(&data);
2810 }
2811}
void SendZoneWeather(uint32 zoneId, Player *player) const
Definition Map.cpp:2813
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)

2765{
2766 bool foundPlayerToSend = false;
2767
2768 for (MapReference const& ref : GetPlayers())
2769 {
2770 Player* player = ref.GetSource();
2771 if (player->IsInWorld() &&
2772 player->GetZoneId() == zone &&
2773 player->GetSession() != self &&
2774 (teamId == TEAM_NEUTRAL || player->GetTeamId() == teamId))
2775 {
2776 player->SendDirectMessage(packet);
2777 foundPlayerToSend = true;
2778 }
2779 }
2780
2781 return foundPlayerToSend;
2782}
@ TEAM_NEUTRAL
Definition SharedDefines.h:773
Definition MapReference.h:25
TeamId GetTeamId(bool original=false) const
Definition Player.h:2108
WorldSession * GetSession() const
Definition Player.h:1998

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)

2786{
2787 WorldPacket data;
2788 ChatHandler::BuildChatPacket(data, CHAT_MSG_SYSTEM, LANG_UNIVERSAL, nullptr, nullptr, text);
2789 SendZoneMessage(zoneId, &data, self, teamId);
2790}
@ CHAT_MSG_SYSTEM
Definition SharedDefines.h:3402
@ LANG_UNIVERSAL
Definition SharedDefines.h:746
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:265
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:2764

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
2814{
2815 ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
2816 if (itr == _zoneDynamicInfo.end())
2817 return;
2818
2819 SendZoneWeather(itr->second, player);
2820}

References _zoneDynamicInfo, and SendZoneWeather().

Referenced by SendZoneDynamicInfo(), and SendZoneWeather().

◆ SendZoneWeather() [2/2]

void Map::SendZoneWeather ( ZoneDynamicInfo const &  zoneDynamicInfo,
Player player 
) const
2823{
2824 if (WeatherState weatherId = zoneDynamicInfo.WeatherId)
2825 {
2826 WorldPackets::Misc::Weather weather(weatherId, zoneDynamicInfo.WeatherGrade);
2827 player->SendDirectMessage(weather.Write());
2828 }
2829 else if (zoneDynamicInfo.DefaultWeather)
2830 zoneDynamicInfo.DefaultWeather->SendWeatherUpdateToPlayer(player);
2831 else
2833}
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 
)

◆ SetZoneWeather()

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

◆ 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 
)
2166{
2167 uint32 mask = UNIT_MASK_SUMMON;
2168 if (properties)
2169 {
2170 switch (properties->Category)
2171 {
2173 mask = UNIT_MASK_GUARDIAN;
2174 break;
2176 mask = UNIT_MASK_PUPPET;
2177 break;
2179 mask = UNIT_MASK_MINION;
2180 break;
2184 {
2185 switch (properties->Type)
2186 {
2187 case SUMMON_TYPE_MINION:
2190 mask = UNIT_MASK_GUARDIAN;
2191 break;
2192 case SUMMON_TYPE_TOTEM:
2194 mask = UNIT_MASK_TOTEM;
2195 break;
2198 mask = UNIT_MASK_SUMMON;
2199 break;
2201 case SUMMON_TYPE_JEEVES:
2202 mask = UNIT_MASK_MINION;
2203 break;
2204 default:
2205 if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
2206 mask = UNIT_MASK_GUARDIAN;
2207 break;
2208 }
2209 break;
2210 }
2211 default:
2212 return nullptr;
2213 }
2214 }
2215
2217 if (summoner)
2218 phase = summoner->GetPhaseMask();
2219
2220 TempSummon* summon = nullptr;
2221 switch (mask)
2222 {
2223 case UNIT_MASK_SUMMON:
2224 summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2225 break;
2226 case UNIT_MASK_GUARDIAN:
2227 summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2228 break;
2229 case UNIT_MASK_PUPPET:
2230 summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2231 break;
2232 case UNIT_MASK_TOTEM:
2233 summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2234 break;
2235 case UNIT_MASK_MINION:
2236 summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2237 break;
2238 default:
2239 return nullptr;
2240 }
2241
2242 EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
2243 if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
2244 {
2245 delete summon;
2246 return nullptr;
2247 }
2248
2249 summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
2250
2251 summon->SetHomePosition(pos);
2252
2253 summon->InitStats(duration);
2254
2255 summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
2256
2257 bool summonerHasTransport = summoner && summoner->GetTransport();
2258 bool summonerIsVehicle = summoner && summoner->IsUnit() && summoner->ToUnit()->IsVehicle();
2259 bool checkTransport = summon->GetOwnerGUID().IsPlayer() || (summonerHasTransport && !summonerIsVehicle);
2260 if (!AddToMap(summon->ToCreature(), checkTransport))
2261 {
2262 delete summon;
2263 return nullptr;
2264 }
2265
2266 summon->InitSummon();
2267
2268 // call MoveInLineOfSight for nearby creatures
2269 Acore::AIRelocationNotifier notifier(*summon);
2270 Cell::VisitObjects(summon, notifier, GetVisibilityRange());
2271
2272 return summon;
2273}
@ PHASEMASK_NORMAL
Definition Object.h:62
@ SUMMON_TYPE_VEHICLE2
Definition SharedDefines.h:3554
@ SUMMON_TYPE_LIGHTWELL
Definition SharedDefines.h:3555
@ SUMMON_TYPE_MINION
Definition SharedDefines.h:3547
@ SUMMON_TYPE_GUARDIAN
Definition SharedDefines.h:3546
@ SUMMON_TYPE_JEEVES
Definition SharedDefines.h:3556
@ SUMMON_TYPE_TOTEM
Definition SharedDefines.h:3548
@ SUMMON_TYPE_VEHICLE
Definition SharedDefines.h:3553
@ SUMMON_TYPE_MINIPET
Definition SharedDefines.h:3549
@ SUMMON_TYPE_GUARDIAN2
Definition SharedDefines.h:3550
@ SUMMON_CATEGORY_PET
Definition SharedDefines.h:3535
@ SUMMON_CATEGORY_VEHICLE
Definition SharedDefines.h:3537
@ SUMMON_CATEGORY_ALLY
Definition SharedDefines.h:3534
@ SUMMON_CATEGORY_PUPPET
Definition SharedDefines.h:3536
@ SUMMON_CATEGORY_WILD
Definition SharedDefines.h:3533
@ SUMMON_CATEGORY_UNK
Definition SharedDefines.h:3538
@ UNIT_MASK_PUPPET
Definition UnitDefines.h:162
@ UNIT_MASK_TOTEM
Definition UnitDefines.h:159
@ UNIT_MASK_SUMMON
Definition UnitDefines.h:156
@ UNIT_MASK_GUARDIAN
Definition UnitDefines.h:158
@ UNIT_MASK_MINION
Definition UnitDefines.h:157
@ UNIT_CREATED_BY_SPELL
Definition UpdateFields.h:138
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:339
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData *data=nullptr)
Definition Creature.cpp:1138
Definition TemporarySummon.h:96
float GetVisibilityRange() const
Definition Map.h:195
Definition TemporarySummon.h:77
bool IsPlayer() const
Definition ObjectGuid.h:168
Definition TemporarySummon.h:115
Definition TemporarySummon.h:40
virtual void InitSummon()
Definition TemporarySummon.cpp:252
virtual void InitStats(uint32 lifetime)
Definition TemporarySummon.cpp:200
void SetVisibleBySummonerOnly(bool visibleBySummonerOnly)
Definition TemporarySummon.h:61
Definition Totem.h:51
ObjectGuid GetOwnerGUID() const
Definition Unit.h:698
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:21198
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_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::instance_blackrock_depths_InstanceMapScript::ReplaceMoiraIfSaved(), boss_ossirian::Reset(), ScheduleCreatureRespawn(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::ScheduleNextPortal(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetBossState(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::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::SetData(), instance_violet_hold::instance_violet_hold_InstanceMapScript::SetData(), instance_ulduar::instance_ulduar_InstanceMapScript::SpawnLeviathanEncounterVehicles(), instance_zulfarrak::instance_zulfarrak_InstanceMapScript::SpawnPyramidWave(), SummonCreatureGroup(), Spell::SummonGuardian(), instance_zulaman::instance_zulaman_InstanceMapScript::SummonHostage(), instance_molten_core::instance_molten_core_InstanceMapScript::SummonMajordomoExecutus(), WorldState::SummonMouth(), WorldState::SummonPallid(), instance_blackrock_spire::instance_blackrock_spireMapScript::SummonSolakarWave(), instance_blackwing_lair::instance_blackwing_lair_InstanceMapScript::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(), boss_the_lich_king::boss_the_lich_kingAI::UpdateAI(), npc_brann_bronzebeard_algalon::npc_brann_bronzebeard_algalonAI::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.
2283{
2284 std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetId(), SUMMONER_TYPE_MAP, group);
2285 if (!data)
2286 return;
2287
2288 for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2289 if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, nullptr, itr->time))
2290 if (list)
2291 list->push_back(summon);
2292}
@ SUMMONER_TYPE_MAP
Definition TemporarySummon.h:27

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 
)
2307{
2308 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
2309 if (!goinfo)
2310 {
2311 LOG_ERROR("sql.sql", "Gameobject template {} not found in database!", entry);
2312 return nullptr;
2313 }
2314
2315 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
2316 if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
2317 {
2318 delete go;
2319 return nullptr;
2320 }
2321
2322 // Xinef: if gameobject is temporary, set custom spellid
2323 if (respawnTime)
2324 go->SetSpellId(1);
2325
2326 go->SetRespawnTime(respawnTime);
2327 go->SetSpawnedByDefault(false);
2328 AddToMap(go, checkTransport);
2329 return go;
2330}
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:254
void SetSpawnedByDefault(bool b)
Definition GameObject.h:196
void SetSpellId(uint32 id)
Definition GameObject.h:176
Definition Transport.h:115
Definition GameObjectData.h:31

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

Referenced by instance_sunken_temple::instance_sunken_temple_InstanceMapScript::OnGameObjectCreate(), SummonGameObject(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::Update(), and npc_arthas::npc_arthasAI::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 
)
2333{
2334 return SummonGameObject(entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), rotation0, rotation1, rotation2, rotation3, respawnTime, checkTransport);
2335}
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:2306

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

◆ ToBattlegroundMap() [1/2]

◆ ToBattlegroundMap() [2/2]

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

References IsBattlegroundOrArena().

◆ ToInstanceMap() [1/2]

◆ ToInstanceMap() [2/2]

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

References IsDungeon().

◆ ToMapInstanced() [1/2]

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

References Instanceable().

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

◆ ToMapInstanced() [2/2]

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

References Instanceable().

◆ UnloadAll()

void Map::UnloadAll ( )
virtual

Reimplemented in InstanceMap, and MapInstanced.

1033{
1034 // clear all delayed moves, useless anyway do this moves before map unload.
1035 _creaturesToMove.clear();
1036 _gameObjectsToMove.clear();
1037
1039 {
1040 MapGridType& grid(*i->GetSource());
1041 ++i;
1042 UnloadGrid(grid); // deletes the grid and removes it from the GridRefMgr
1043 }
1044
1045 // pussywizard: crashfix, some npc can be left on transport (not a default passenger)
1046 if (!AllTransportsEmpty())
1048
1049 for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
1050 {
1051 Transport* transport = *itr;
1052 ++itr;
1053
1054 RemoveFromMap<Transport>(transport, true);
1055 }
1056
1057 _transports.clear();
1058
1059 for (auto& cellCorpsePair : _corpsesByGrid)
1060 {
1061 for (Corpse* corpse : cellCorpsePair.second)
1062 {
1063 corpse->RemoveFromWorld();
1064 corpse->ResetMap();
1065 delete corpse;
1066 }
1067 }
1068
1069 _corpsesByGrid.clear();
1070 _corpsesByPlayer.clear();
1071 _corpseBones.clear();
1072}
Definition GridRefMgr.h:28
iterator end()
Definition GridRefMgr.h:36
void AllTransportsRemovePassengers()
Definition Map.cpp:2617
bool UnloadGrid(MapGridType &grid)
Definition Map.cpp:1006
bool AllTransportsEmpty() const
Definition Map.cpp:2608

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)
1007{
1008 _mapGridManager.UnloadGrid(grid.GetX(), grid.GetY());
1009
1010 ASSERT(i_objectsToRemove.empty());
1011 LOG_DEBUG("maps", "Unloading grid[{}, {}] for map {} finished", grid.GetX(), grid.GetY(), GetId());
1012 return true;
1013}
void UnloadGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:38
uint16 GetY() const
Definition MapGrid.h:43
uint16 GetX() const
Definition MapGrid.h:42

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 necessary scripts

Reimplemented in InstanceMap, and MapInstanced.

433{
434 if (t_diff)
435 _dynamicTree.update(t_diff);
436
437 // Update world sessions and players
439 {
440 Player* player = m_mapRefIter->GetSource();
441 if (player && player->IsInWorld())
442 {
443 // Update session
444 WorldSession* session = player->GetSession();
445 MapSessionFilter updater(session);
446 session->Update(s_diff, updater);
447
448 // update players at tick
449 if (!t_diff)
450 player->Update(s_diff);
451 }
452 }
453
454 Events.Update(t_diff);
455
456 if (!t_diff)
457 {
459 return;
460 }
461
464
465 // Update players
467 {
468 Player* player = m_mapRefIter->GetSource();
469
470 if (!player || !player->IsInWorld())
471 continue;
472
473 player->Update(s_diff);
474
476 {
477 MarkNearbyCellsOf(player);
478
479 // If player is using far sight, update viewpoint
480 if (WorldObject* viewPoint = player->GetViewpoint())
481 {
482 if (Creature* viewCreature = viewPoint->ToCreature())
483 MarkNearbyCellsOf(viewCreature);
484 else if (DynamicObject* viewObject = viewPoint->ToDynObject())
485 MarkNearbyCellsOf(viewObject);
486 }
487 }
488 }
489
491
493
495 if (!m_scriptSchedule.empty())
496 {
497 i_scriptLock = true;
499 i_scriptLock = false;
500 }
501
505
507
508 UpdateWeather(t_diff);
509 UpdateExpiredCorpses(t_diff);
510
511 sScriptMgr->OnMapUpdate(this, t_diff);
512
513 METRIC_VALUE("map_creatures", uint64(GetObjectsStore().Size<Creature>()),
514 METRIC_TAG("map_id", std::to_string(GetId())),
515 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
516
517 METRIC_VALUE("map_gameobjects", uint64(GetObjectsStore().Size<GameObject>()),
518 METRIC_TAG("map_id", std::to_string(GetId())),
519 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
520}
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
void update(uint32 diff)
Definition DynamicTree.cpp:142
Definition WorldSession.h:283
void HandleDelayedVisibility()
Definition Map.cpp:680
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:348
void MoveAllGameObjectsInMoveList()
Definition Map.cpp:942
void UpdateNonPlayerObjects(uint32 const diff)
Definition Map.cpp:522
void MarkNearbyCellsOf(WorldObject *obj)
Definition Map.cpp:396
void resetMarkedCells()
Definition Map.h:316
void UpdateWeather(uint32 const diff)
Definition Map.cpp:2835
void MoveAllDynamicObjectsInMoveList()
Definition Map.cpp:977
void MoveAllCreaturesInMoveList()
Definition Map.cpp:908
MapRefMgr::iterator m_mapRefIter
Definition Map.h:564
void SendObjectUpdates()
Definition Map.cpp:1709
void UpdateExpiredCorpses(uint32 const diff)
Definition Map.cpp:1660
DynamicObject * ToDynObject()
Definition Object.h:222
void Update(uint32 time) override
Definition PlayerUpdates.cpp:53
WorldObject * GetViewpoint() const
Definition Player.cpp:13259
FROM * GetSource() const
Definition Reference.h:97
Player session in the World.
Definition WorldSession.h:369
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update)
Definition WorldSession.cpp:327
bool Passed()
Definition Timer.h:161
void Update(time_t diff)
Definition Timer.h:152

References _dynamicTree, _updatableObjectListRecheckTimer, MapRefMgr::begin(), MapRefMgr::end(), 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(), resetMarkedCells(), ScriptsProcess(), SendObjectUpdates(), sScriptMgr, Object::ToCreature(), Object::ToDynObject(), IntervalTimer::Update(), DynamicMapTree::update(), WorldSession::Update(), Player::Update(), UpdateExpiredCorpses(), UpdateNonPlayerObjects(), and UpdateWeather().

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

◆ UpdateEncounterState()

void Map::UpdateEncounterState ( EncounterCreditType  type,
uint32  creditEntry,
Unit source 
)
2515{
2516 Difficulty difficulty_fixed = (IsSharedDifficultyMap(GetId()) ? Difficulty(GetDifficulty() % 2) : GetDifficulty());
2517 DungeonEncounterList const* encounters;
2518 // 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.
2519 if ((GetId() == 631 || GetId() == 724) && IsHeroic())
2520 {
2521 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), !Is25ManRaid() ? RAID_DIFFICULTY_10MAN_NORMAL : RAID_DIFFICULTY_25MAN_NORMAL);
2522 }
2523 else
2524 {
2525 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), difficulty_fixed);
2526 }
2527
2528 if (!encounters)
2529 {
2530 return;
2531 }
2532
2533 uint32 dungeonId = 0;
2534 bool updated = false;
2535
2536 for (DungeonEncounterList::const_iterator itr = encounters->begin(); itr != encounters->end(); ++itr)
2537 {
2538 DungeonEncounter const* encounter = *itr;
2539 if (encounter->creditType == type && encounter->creditEntry == creditEntry)
2540 {
2541 if (source)
2542 if (InstanceScript* instanceScript = source->GetInstanceScript())
2543 {
2544 uint32 prevMask = instanceScript->GetCompletedEncounterMask();
2545 instanceScript->SetCompletedEncountersMask((1 << encounter->dbcEntry->encounterIndex) | instanceScript->GetCompletedEncounterMask(), true);
2546 if (prevMask != instanceScript->GetCompletedEncounterMask())
2547 updated = true;
2548 }
2549
2550 if (encounter->lastEncounterDungeon)
2551 {
2552 dungeonId = encounter->lastEncounterDungeon;
2553 break;
2554 }
2555 }
2556 }
2557
2558 // pussywizard:
2559 LogEncounterFinished(type, creditEntry);
2560
2561 sScriptMgr->OnAfterUpdateEncounterState(this, type, creditEntry, source, difficulty_fixed, encounters, dungeonId, updated);
2562
2563 if (dungeonId)
2564 {
2565 Map::PlayerList const& players = GetPlayers();
2566 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
2567 {
2568 if (Player* player = i->GetSource())
2569 if (Group* grp = player->GetGroup())
2570 if (grp->isLFGGroup())
2571 {
2572 sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, this);
2573 return;
2574 }
2575 }
2576 }
2577}
@ 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:641
std::list< DungeonEncounter const * > DungeonEncounterList
Definition ObjectMgr.h:711
Definition Group.h:169
Definition InstanceScript.h:143
bool Is25ManRaid() const
Definition Map.h:300
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry)
Definition Map.cpp:2579
bool IsHeroic() const
Definition Map.h:299
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1221
uint32 encounterIndex
Definition DBCStructure.h:871
Definition ObjectMgr.h:701
DungeonEncounterEntry const * dbcEntry
Definition ObjectMgr.h:705
EncounterCreditType creditType
Definition ObjectMgr.h:706
uint32 lastEncounterDungeon
Definition ObjectMgr.h:708
uint32 creditEntry
Definition ObjectMgr.h:707

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::boss_majordomoAI::SummonedCreatureDies(), and npc_grimstone::npc_grimstoneAI::WaypointReached().

◆ UpdateExpiredCorpses()

void Map::UpdateExpiredCorpses ( uint32 const  diff)
1661{
1664 return;
1665
1667
1669}
void RemoveOldCorpses()
Definition Map.cpp:2726
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)
2387{
2388 if (m_mapRefIter == player->GetMapRef())
2390}
MapReference const * nocheck_prev() const
Definition MapReference.h:49
MapReference & GetMapRef()
Definition Player.h:2495

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

Referenced by Player::ResetMap().

◆ UpdateNonPlayerObjects()

void Map::UpdateNonPlayerObjects ( uint32 const  diff)
private
523{
527
529 {
530 for (uint32 i = 0; i < _updatableObjectList.size();)
531 {
533 if (!obj->IsInWorld())
534 {
535 ++i;
536 continue;
537 }
538
539 obj->Update(diff);
540
541 if (!obj->IsUpdateNeeded())
542 {
544 // Intentional no iteration here, obj is swapped with last element in
545 // _updatableObjectList so next loop will update that object at the same index
546 }
547 else
548 ++i;
549 }
551 }
552 else
553 {
554 for (uint32 i = 0; i < _updatableObjectList.size(); ++i)
555 {
557 if (!obj->IsInWorld())
558 continue;
559
560 obj->Update(diff);
561 }
562 }
563}
void _AddObjectToUpdateList(WorldObject *obj)
Definition Map.cpp:579
virtual bool IsUpdateNeeded()
Definition Object.cpp:3139
virtual void Update(uint32 diff)
Definition Object.cpp:1051

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

Referenced by Update().

◆ UpdatePlayerZoneStats()

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

References _zonePlayerCountMap, and MAP_INVALID_ZONE.

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

◆ UpdateWeather()

void Map::UpdateWeather ( uint32 const  diff)
2836{
2839 return;
2840
2841 for (auto&& zoneInfo : _zoneDynamicInfo)
2842 if (zoneInfo.second.DefaultWeather && !zoneInfo.second.DefaultWeather->Update(_weatherUpdateTimer.GetInterval()))
2843 zoneInfo.second.DefaultWeather.reset();
2844
2846}
virtual void Update(const uint32, const uint32, bool thread=true)
Definition Map.cpp:432

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

Referenced by Update().

◆ Visit()

template<class T , class CONTAINER >
void Map::Visit ( const Cell cell,
TypeContainerVisitor< T, CONTAINER > &  visitor 
)
inline
701{
702 uint32 const grid_x = cell.GridX();
703 uint32 const grid_y = cell.GridY();
704
705 // If grid is not loaded, nothing to visit.
706 if (!IsGridLoaded(GridCoord(grid_x, grid_y)))
707 return;
708
709 GetMapGrid(grid_x, grid_y)->VisitCell(cell.CellX(), cell.CellY(), visitor);
710}
void VisitCell(uint16 const x, uint16 const y, TypeContainerVisitor< T, TT > &visitor)
Definition MapGrid.h:86

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

CreatureBySpawnIdContainer Map::_creatureBySpawnIdStore
private

◆ _creatureRespawnTimes

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

◆ _creaturesToMove

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

◆ _defaultLight

uint32 Map::_defaultLight
private

◆ _dynamicObjectsToMove

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

◆ _dynamicTree

◆ _gameobjectBySpawnIdStore

GameObjectBySpawnIdContainer Map::_gameobjectBySpawnIdStore
private

◆ _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

◆ _mapGridManager

◆ _objectsStore

◆ _pendingAddUpdatableObjectList

◆ _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(), and ~Map().

◆ 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

◆ MMapLock

std::shared_mutex Map::MMapLock
protected

Referenced by GetMMapLock().


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