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, uint8 reqLiquidType=MAP_ALL_LIQUIDS)
 
LiquidData const GetLiquidData (uint32 phaseMask, float x, float y, float z, float collisionHeight, uint8 ReqLiquidType)
 
bool GetAreaInfo (uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
 
uint32 GetAreaId (uint32 phaseMask, float x, float y, float z) const
 
uint32 GetZoneId (uint32 phaseMask, float x, float y, float z) const
 
void GetZoneAndAreaId (uint32 phaseMask, uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
 
float GetWaterLevel (float x, float y) const
 
bool IsInWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
 
bool IsUnderWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
 
bool HasEnoughWater (WorldObject const *searcher, float x, float y, float z) const
 
bool HasEnoughWater (WorldObject const *searcher, LiquidData const &liquidData) const
 
void MoveAllCreaturesInMoveList ()
 
void MoveAllGameObjectsInMoveList ()
 
void MoveAllDynamicObjectsInMoveList ()
 
void RemoveAllObjectsInRemoveList ()
 
virtual void RemoveAllPlayers ()
 
uint32 GetInstanceId () const
 
uint8 GetSpawnMode () const
 
virtual EnterState CannotEnter (Player *, bool)
 
const char * GetMapName () const
 
Difficulty GetDifficulty () const
 
bool IsRegularDifficulty () const
 
MapDifficulty const * GetMapDifficulty () const
 
bool Instanceable () const
 
bool IsDungeon () const
 
bool IsNonRaidDungeon () const
 
bool IsRaid () const
 
bool IsRaidOrHeroicDungeon () const
 
bool IsHeroic () const
 
bool Is25ManRaid () const
 
bool IsBattleground () const
 
bool IsBattleArena () const
 
bool IsBattlegroundOrArena () const
 
bool IsWorldMap () const
 
bool GetEntrancePos (int32 &mapid, float &x, float &y)
 
void AddObjectToRemoveList (WorldObject *obj)
 
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 ()
 
void SendInitTransports (Player *player)
 
void SendRemoveTransports (Player *player)
 
void SendZoneDynamicInfo (Player *player)
 
void SendInitSelf (Player *player)
 
void UpdateExpiredCorpses (uint32 const diff)
 
void PlayDirectSoundToMap (uint32 soundId, uint32 zoneId=0)
 
void SetZoneMusic (uint32 zoneId, uint32 musicId)
 
void SetZoneWeather (uint32 zoneId, WeatherState weatherId, float weatherGrade)
 
void SetZoneOverrideLight (uint32 zoneId, uint32 lightId, Milliseconds fadeInTime)
 
void UpdateEncounterState (EncounterCreditType type, uint32 creditEntry, Unit *source)
 
void LogEncounterFinished (EncounterCreditType type, uint32 creditEntry)
 
void DoForAllPlayers (std::function< void(Player *)> exec)
 
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
 
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
 
TaskScheduler _creatureRespawnScheduler
 
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
 
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 
267 {
268 CAN_ENTER = 0,
269 CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
270 CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
271 CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
272 CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
273 CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
274 CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
275 CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
276 CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
277 CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
278 CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
280 };
@ CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE
Definition Map.h:274
@ CANNOT_ENTER_TOO_MANY_INSTANCES
Definition Map.h:276
@ CANNOT_ENTER_MAX_PLAYERS
Definition Map.h:277
@ CANNOT_ENTER_ZONE_IN_COMBAT
Definition Map.h:278
@ CAN_ENTER
Definition Map.h:268
@ CANNOT_ENTER_ALREADY_IN_MAP
Definition Map.h:269
@ CANNOT_ENTER_UNSPECIFIED_REASON
Definition Map.h:279
@ CANNOT_ENTER_NO_ENTRY
Definition Map.h:270
@ CANNOT_ENTER_DIFFICULTY_UNAVAILABLE
Definition Map.h:272
@ CANNOT_ENTER_INSTANCE_BIND_MISMATCH
Definition Map.h:275
@ CANNOT_ENTER_UNINSTANCED_DUNGEON
Definition Map.h:271
@ CANNOT_ENTER_NOT_IN_RAID
Definition Map.h:273

Constructor & Destructor Documentation

◆ Map()

Map::Map ( uint32  id,
uint32  InstanceId,
uint8  SpawnMode,
Map _parent = nullptr 
)
64 :
65 _mapGridManager(this), i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
68{
69 m_parentMap = (_parent ? _parent : this);
70
71 _zonePlayerCountMap.clear();
73
74 //lets initialize visibility distance for map
76
78}
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:89
#define DEFAULT_VISIBILITY_DISTANCE
Definition ObjectDefines.h:39
MapEntry const * i_mapEntry
Definition Map.h:537
uint8 i_spawnMode
Definition Map.h:538
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition Map.h:584
TransportsContainer::iterator _transportsUpdateIter
Definition Map.h:549
uint32 m_unloadTimer
Definition Map.h:540
uint32 _defaultLight
Definition Map.h:587
Map * m_parentMap
Definition Map.h:563
IntervalTimer _updatableObjectListRecheckTimer
Definition Map.h:613
bool i_scriptLock
Definition Map.h:567
IntervalTimer _corpseUpdateTimer
Definition Map.h:589
time_t _instanceResetPeriod
Definition Map.h:543
float m_VisibleDistance
Definition Map.h:541
MapGridManager _mapGridManager
Definition Map.h:536
virtual void InitVisibilityDistance()
Definition Map.cpp:90
TransportsContainer _transports
Definition Map.h:548
uint32 i_InstanceId
Definition Map.h:539
void SetInterval(time_t interval)
Definition Timer.h:179

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

◆ ~Map()

Map::~Map ( )
override
53{
54 // UnloadAll must be called before deleting the map
55
56 sScriptMgr->OnDestroyMap(this);
57
58 if (!m_scriptSchedule.empty())
59 sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
60
62}
#define sScriptMgr
Definition ScriptMgr.h:728
static MMapMgr * createOrGetMMapMgr()
Definition MMapFactory.cpp:27
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
Definition MMapMgr.cpp:279
ScriptScheduleMap m_scriptSchedule
Definition Map.h:571
uint32 GetId() const
Definition Map.h:226

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

Member Function Documentation

◆ _AddObjectToUpdateList()

void Map::_AddObjectToUpdateList ( WorldObject obj)
private
574{
575 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
576 ASSERT(mapUpdatableObject && mapUpdatableObject->GetUpdateState() == UpdatableMapObject::UpdateState::PendingAdd);
577
579 mapUpdatableObject->SetMapUpdateListOffset(_updatableObjectList.size());
580 _updatableObjectList.push_back(obj);
581}
#define ASSERT
Definition Errors.h:68
UpdatableObjectList _updatableObjectList
Definition Map.h:611
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:43
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:167
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:1072

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

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
585{
586 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
587 ASSERT(mapUpdatableObject && mapUpdatableObject->GetUpdateState() == UpdatableMapObject::UpdateState::Updating);
588
589 if (obj != _updatableObjectList.back())
590 {
591 dynamic_cast<UpdatableMapObject*>(_updatableObjectList.back())->SetMapUpdateListOffset(mapUpdatableObject->GetMapUpdateListOffset());
592 std::swap(_updatableObjectList[mapUpdatableObject->GetMapUpdateListOffset()], _updatableObjectList.back());
593 }
594
595 _updatableObjectList.pop_back();
597}
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)
2648{
2649 corpse->SetMap(this);
2650
2651 GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
2652 _corpsesByGrid[gridCoord.GetId()].insert(corpse);
2653 if (corpse->GetType() != CORPSE_BONES)
2654 _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
2655 else
2656 _corpseBones.insert(corpse);
2657}
@ 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:606
std::unordered_set< Corpse * > _corpseBones
Definition Map.h:607
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByGrid
Definition Map.h:605
virtual void SetMap(Map *map)
Definition Object.cpp:2090
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
866{
868 _creaturesToMove.push_back(c);
870}
@ 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:517
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
892{
893 if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
894 _dynamicObjectsToMove.push_back(dynObj);
895 dynObj->_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE;
896}
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition Map.h:519

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

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

Referenced by GameObjectRelocation().

◆ AddObjectToPendingUpdateList()

void Map::AddObjectToPendingUpdateList ( WorldObject obj)
560{
561 if (!obj->CanBeAddedToMapUpdateList())
562 return;
563
564 UpdatableMapObject* mapUpdatableObject = dynamic_cast<UpdatableMapObject*>(obj);
566 return;
567
570}
PendingAddUpdatableObjectList _pendingAddUpdatableObjectList
Definition Map.h:612
bool CanBeAddedToMapUpdateList()
Definition Object.cpp:3122

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)
1791{
1792 ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
1793
1794 obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
1795
1796 i_objectsToRemove.insert(obj);
1797 //LOG_DEBUG("maps", "Object ({}) added to removing list.", obj->GetGUID().ToString());
1798}
std::unordered_set< WorldObject * > i_objectsToRemove
Definition Map.h:568
uint32 GetInstanceId() const
Definition Map.h:263
uint32 GetMapId() const
Definition Position.h:280
uint32 GetInstanceId() const
Definition Object.h:510
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition Object.cpp:1117

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.

251{
252 CellCoord cellCoord = Acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
253 if (!cellCoord.IsCoordValid())
254 {
255 LOG_ERROR("maps", "Map::Add: Player ({}) has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
256 player->GetGUID().ToString(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
257 return false;
258 }
259
260 Cell cell(cellCoord);
262 AddToGrid(player, cell);
263
264 // Check if we are adding to correct map
265 ASSERT (player->GetMap() == this);
266 player->SetMap(this);
267 player->AddToWorld();
268
269 SendInitTransports(player);
270 SendInitSelf(player);
271 SendZoneDynamicInfo(player);
272
273 player->UpdateObjectVisibility(false);
274
275 if (player->IsAlive())
276 ConvertCorpseToBones(player->GetGUID());
277
278 sScriptMgr->OnPlayerEnterMap(this, player);
279 return true;
280}
#define MAX_VISIBILITY_DISTANCE
Definition ObjectDefines.h:30
void LoadGridsInRange(Position const &center, float radius)
Definition Map.cpp:220
void SendZoneDynamicInfo(Player *player)
Definition Map.cpp:2770
void SendInitSelf(Player *player)
Definition Map.cpp:1632
void AddToGrid(T *object, Cell const &cell)
Definition Map.cpp:108
void SendInitTransports(Player *player)
Definition Map.cpp:1678
Corpse * ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia=false)
Definition Map.cpp:2680
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition PlayerUpdates.cpp:1608
void AddToWorld() override
Definition Player.cpp:1713
void SetMap(Map *map) override
Definition Player.cpp:14701
bool IsAlive() const
Definition Unit.h:1710
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(), SendZoneDynamicInfo(), 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 
)
147{
148 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
149 // Corpses are a special object type - they can be added to grid via a call to AddToMap
150 // or loaded through ObjectGridLoader.
151 // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
152 // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
153 // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
154 // to avoid failing an assertion in GridObject::AddToGrid
155 if (grid->IsObjectDataLoaded())
156 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
157}
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:193

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 
)
118{
119 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
120 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
121 if (obj->IsFarVisible())
122 grid->AddFarVisibleObject(cell.CellX(), cell.CellY(), obj);
123
124 obj->SetCurrentCell(cell);
125}
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 
)
140{
141 MapGridType* grid = GetMapGrid(cell.GridX(), cell.GridY());
142 grid->AddGridObject(cell.CellX(), cell.CellY(), obj);
143}

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

References _updateObjects.

Referenced by WorldObject::AddToObjectUpdate().

◆ AddWorldObjectToFarVisibleMap()

void Map::AddWorldObjectToFarVisibleMap ( WorldObject obj)
613{
614 if (Creature* creature = obj->ToCreature())
615 {
616 if (!creature->IsInGrid())
617 return;
618
619 Cell curr_cell = creature->GetCurrentCell();
620 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
621 grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
622 }
623 else if (GameObject* go = obj->ToGameObject())
624 {
625 if (!go->IsInGrid())
626 return;
627
628 Cell curr_cell = go->GetCurrentCell();
629 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
630 grid->AddFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
631 }
632}
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::SetVisibilityDistanceOverride().

◆ AddWorldObjectToZoneWideVisibleMap()

void Map::AddWorldObjectToZoneWideVisibleMap ( uint32  zoneId,
WorldObject obj 
)
652{
653 _zoneWideVisibleWorldObjectsMap[zoneId].insert(obj);
654}
ZoneWideVisibleWorldObjectsMap _zoneWideVisibleWorldObjectsMap
Definition Map.h:614

References _zoneWideVisibleWorldObjectsMap.

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

◆ AfterPlayerUnlinkFromMap()

void Map::AfterPlayerUnlinkFromMap ( )
virtual

◆ AllTransportsEmpty()

bool Map::AllTransportsEmpty ( ) const
2616{
2617 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2618 if (!(*itr)->GetPassengers().empty())
2619 return false;
2620
2621 return true;
2622}

References _transports.

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

◆ AllTransportsRemovePassengers()

void Map::AllTransportsRemovePassengers ( )
2625{
2626 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2627 while (!(*itr)->GetPassengers().empty())
2628 (*itr)->RemovePassenger(*((*itr)->GetPassengers().begin()), true);
2629}

References _transports.

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

◆ ApplyDynamicModeRespawnScaling()

uint32 Map::ApplyDynamicModeRespawnScaling ( WorldObject const *  obj,
uint32  respawnDelay 
) const
1739{
1740 ASSERT(obj->GetMap() == this);
1741
1742 float rate = sWorld->getFloatConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICRATE_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICRATE_CREATURE);
1743
1744 if (rate == 1.0f)
1745 return respawnDelay;
1746
1747 // No instanced maps (dungeons, battlegrounds, arenas etc.)
1748 if (obj->GetMap()->Instanceable())
1749 return respawnDelay;
1750
1751 // No quest givers or world bosses
1752 if (Creature const* creature = obj->ToCreature())
1753 if (creature->IsQuestGiver() || creature->isWorldBoss()
1754 || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RARE)
1755 || (creature->GetCreatureTemplate()->rank == CREATURE_ELITE_RAREELITE))
1756 return respawnDelay;
1757
1758 auto it = _zonePlayerCountMap.find(obj->GetZoneId());
1759 if (it == _zonePlayerCountMap.end())
1760 return respawnDelay;
1761 uint32 const playerCount = it->second;
1762 if (!playerCount)
1763 return respawnDelay;
1764 double const adjustFactor = rate / playerCount;
1765 if (adjustFactor >= 1.0) // nothing to do here
1766 return respawnDelay;
1767 uint32 const timeMinimum = sWorld->getIntConfig(obj->IsGameObject() ? CONFIG_RESPAWN_DYNAMICMINIMUM_GAMEOBJECT : CONFIG_RESPAWN_DYNAMICMINIMUM_CREATURE);
1768 if (respawnDelay <= timeMinimum)
1769 return respawnDelay;
1770
1771 return std::max<uint32>(std::ceil(respawnDelay * adjustFactor), timeMinimum);
1772}
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:317

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

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
2934{
2935 return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
2936}
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:2893

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
2939{
2940 if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
2941 {
2942 return false;
2943 }
2944
2945 Unit const* unit = source->ToUnit();
2946 // if it's not an unit (Object) then we do not have to continue
2947 // with walkable checks
2948 if (!unit)
2949 {
2950 return true;
2951 }
2952
2953 /*
2954 * Walkable checks
2955 */
2956 bool isWaterNext = HasEnoughWater(unit, destX, destY, destZ);
2957 Creature const* creature = unit->ToCreature();
2958 bool cannotEnterWater = isWaterNext && (creature && !creature->CanEnterWater());
2959 bool cannotWalkOrFly = !isWaterNext && !source->ToPlayer() && !unit->CanFly() && (creature && !creature->CanWalk());
2960 if (cannotEnterWater || cannotWalkOrFly ||
2961 (failOnSlopes && !PathGenerator::IsWalkableClimb(startX, startY, startZ, destX, destY, destZ, source->GetCollisionHeight())))
2962 {
2963 return false;
2964 }
2965
2966 return true;
2967}
bool CanWalk() const
Definition Creature.h:79
bool CanEnterWater() const override
Definition Creature.cpp:3287
bool HasEnoughWater(WorldObject const *searcher, float x, float y, float z) const
Definition Map.cpp:1613
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:2976
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.

2894{
2895 G3D::Vector3 prevPath = path->GetStartPosition();
2896 for (auto& vector : path->GetPath())
2897 {
2898 float x = vector.x;
2899 float y = vector.y;
2900 float z = vector.z;
2901
2902 if (!CanReachPositionAndGetValidCoords(source, prevPath.x, prevPath.y, prevPath.z, x, y, z, failOnCollision, failOnSlopes))
2903 {
2904 destX = x;
2905 destY = y;
2906 destZ = z;
2907 return false;
2908 }
2909
2910 prevPath = vector;
2911 }
2912
2913 destX = prevPath.x;
2914 destY = prevPath.y;
2915 destZ = prevPath.z;
2916
2917 return true;
2918}
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
171 {
172 if (!m_unloadTimer)
173 return false;
174
175 if (m_unloadTimer <= diff)
176 return true;
177
178 m_unloadTimer -= diff;
179 return false;
180 }

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
2977{
2978 // Prevent invalid coordinates here, position is unchanged
2979 if (!Acore::IsValidMapCoord(startX, startY, startZ) || !Acore::IsValidMapCoord(destX, destY, destZ))
2980 {
2981 LOG_FATAL("maps", "Map::CheckCollisionAndGetValidCoords invalid coordinates startX: {}, startY: {}, startZ: {}, destX: {}, destY: {}, destZ: {}", startX, startY, startZ, destX, destY, destZ);
2982 return false;
2983 }
2984
2985 bool isWaterNext = IsInWater(source->GetPhaseMask(), destX, destY, destZ, source->GetCollisionHeight());
2986
2987 PathGenerator path(source);
2988
2989 // Use a detour raycast to get our first collision point
2990 path.SetUseRaycast(true);
2991 bool result = path.CalculatePath(startX, startY, startZ, destX, destY, destZ, false);
2992
2993 Unit const* unit = source->ToUnit();
2994 bool notOnGround = path.GetPathType() & PATHFIND_NOT_USING_PATH
2995 || isWaterNext || (unit && unit->IsFlying());
2996
2997 // Check for valid path types before we proceed
2998 if (!result || (!notOnGround && path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END)))
2999 {
3000 return false;
3001 }
3002
3003 G3D::Vector3 endPos = path.GetPath().back();
3004 destX = endPos.x;
3005 destY = endPos.y;
3006 destZ = endPos.z;
3007
3008 // collision check
3009 bool collided = false;
3010
3011 // check static LOS
3012 float halfHeight = source->GetCollisionHeight() * 0.5f;
3013
3014 // Unit is not on the ground, check for potential collision via vmaps
3015 if (notOnGround)
3016 {
3017 bool col = VMAP::VMapFactory::createOrGetVMapMgr()->GetObjectHitPos(source->GetMapId(),
3018 startX, startY, startZ + halfHeight,
3019 destX, destY, destZ + halfHeight,
3020 destX, destY, destZ, -CONTACT_DISTANCE);
3021
3022 destZ -= halfHeight;
3023
3024 // Collided with static LOS object, move back to collision point
3025 if (col)
3026 {
3027 collided = true;
3028 }
3029 }
3030
3031 // check dynamic collision
3032 bool col = source->GetMap()->GetObjectHitPos(source->GetPhaseMask(),
3033 startX, startY, startZ + halfHeight,
3034 destX, destY, destZ + halfHeight,
3035 destX, destY, destZ, -CONTACT_DISTANCE);
3036
3037 destZ -= halfHeight;
3038
3039 // Collided with a gameobject, move back to collision point
3040 if (col)
3041 {
3042 collided = true;
3043 }
3044
3045 float groundZ = VMAP_INVALID_HEIGHT_VALUE;
3046 source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
3047
3048 // position has no ground under it (or is too far away)
3049 if (groundZ <= INVALID_HEIGHT && unit && !unit->CanFly())
3050 {
3051 // fall back to gridHeight if any
3052 float gridHeight = GetGridHeight(destX, destY);
3053 if (gridHeight > INVALID_HEIGHT)
3054 {
3055 destZ = gridHeight + unit->GetHoverHeight();
3056 }
3057 else
3058 {
3059 return false;
3060 }
3061 }
3062
3063 return !failOnCollision || !collided;
3064}
#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:1601
float GetGridHeight(float x, float y) const
Definition Map.cpp:1178
Definition PathGenerator.h:59
float GetCollisionHeight() const override
Return collision height sent to client.
Definition Unit.cpp:20966
float GetHoverHeight() const
Definition Unit.h:1633
bool IsFlying() const
Definition Unit.h:1630
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
390{ 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 
)
2681{
2682 Corpse* corpse = GetCorpseByPlayer(ownerGuid);
2683 if (!corpse)
2684 return nullptr;
2685
2686 RemoveCorpse(corpse);
2687
2688 // remove corpse from DB
2689 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
2690 corpse->DeleteFromDB(trans);
2691 CharacterDatabase.CommitTransaction(trans);
2692
2693 Corpse* bones = NULL;
2694
2695 // create the bones only if the map and the grid is loaded at the corpse's location
2696 // ignore bones creating option in case insignia
2697 if ((insignia ||
2699 IsGridLoaded(corpse->GetPositionX(), corpse->GetPositionY()))
2700 {
2701 // Create bones, don't change Corpse
2702 bones = new Corpse();
2703 bones->Create(corpse->GetGUID().GetCounter());
2704
2705 for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
2706 bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
2707
2708 bones->SetCellCoord(corpse->GetCellCoord());
2709 bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
2710 bones->SetPhaseMask(corpse->GetPhaseMask(), false);
2711
2713 bones->SetGuidValue(CORPSE_FIELD_OWNER, corpse->GetOwnerGUID());
2714
2715 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
2716 if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
2717 bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
2718
2719 AddCorpse(bones);
2720
2721 bones->UpdatePositionData();
2722
2723 // add bones in grid store if grid loaded where corpse placed
2724 AddToMap(bones);
2725 }
2726
2727 // all references to the corpse should be removed at this point
2728 delete corpse;
2729
2730 return bones;
2731}
@ 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:690
@ 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:300
void AddCorpse(Corpse *corpse)
Definition Map.cpp:2647
bool IsGridLoaded(GridCoord const &gridCoord) const
Definition Map.cpp:198
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition Map.h:362
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:300
void RemoveCorpse(Corpse *corpse)
Definition Map.cpp:2659
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:2866
uint32 GetPhaseMask() const
Definition Object.h:513
void UpdatePositionData()
Definition Object.cpp:1140
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 
)
803{
804 Cell old_cell = creature->GetCurrentCell();
805 Cell new_cell(x, y);
806
807 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
808 {
809 if (old_cell.DiffGrid(new_cell))
810 EnsureGridLoaded(new_cell);
811
812 AddCreatureToMoveList(creature);
813 }
814 else
816
817 creature->Relocate(x, y, z, o);
818 if (creature->IsVehicle())
819 creature->GetVehicleKit()->RelocatePassengers();
820 creature->UpdatePositionData();
821 creature->UpdateObjectVisibility(false);
822}
void AddCreatureToMoveList(Creature *c)
Definition Map.cpp:865
void RemoveCreatureFromMoveList(Creature *c)
Definition Map.cpp:872
Cell const & GetCurrentCell() const
Definition Object.h:419
bool IsVehicle() const
Definition Unit.h:752
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition Unit.cpp:19227
Vehicle * GetVehicleKit() const
Definition Unit.h:1841
void RelocatePassengers()
Definition Vehicle.cpp:514
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.

1775{
1777 {
1778 Transport* transport = *_transportsUpdateIter;
1780
1781 if (!transport->IsInWorld())
1782 continue;
1783
1784 transport->DelayedUpdate(t_diff);
1785 }
1786
1788}
void RemoveAllObjectsInRemoveList()
Definition Map.cpp:1800
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 ( )
3104{
3105 // DELETE FROM corpse WHERE mapId = ? AND instanceId = ?
3107 stmt->SetData(0, GetId());
3108 stmt->SetData(1, GetInstanceId());
3109 CharacterDatabase.Execute(stmt);
3110}
@ 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)
168{
170
171 RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway
172 delete player;
173}
void RemoveUpdateObject(Object *obj)
Definition Map.h:481
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
161{
162 // Note: In case resurrectable corpse and pet its removed from global lists in own destructor
163 delete obj;
164}

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

◆ DeleteRespawnTimes()

void Map::DeleteRespawnTimes ( )
2501{
2502 _creatureRespawnTimes.clear();
2503 _goRespawnTimes.clear();
2504
2506}
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
Definition Map.cpp:2508
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition Map.h:581
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition Map.h:582

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

Referenced by InstanceMap::UnloadAll().

◆ DeleteRespawnTimesInDB()

void Map::DeleteRespawnTimesInDB ( uint16  mapId,
uint32  instanceId 
)
static
2509{
2511 stmt->SetData(0, mapId);
2512 stmt->SetData(1, instanceId);
2513 CharacterDatabase.Execute(stmt);
2514
2515 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
2516 stmt->SetData(0, mapId);
2517 stmt->SetData(1, instanceId);
2518 CharacterDatabase.Execute(stmt);
2519}
@ 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)
2877{
2878 for (auto const& it : GetPlayers())
2879 {
2880 if (Player* player = it.GetSource())
2881 {
2882 exec(player);
2883 }
2884 }
2885}

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 
)
846{
847 Cell old_cell = dynObj->GetCurrentCell();
848 Cell new_cell(x, y);
849
850 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
851 {
852 if (old_cell.DiffGrid(new_cell))
853 EnsureGridLoaded(new_cell);
854
856 }
857 else
859
860 dynObj->Relocate(x, y, z, o);
861 dynObj->SetPositionDataUpdate();
862 dynObj->UpdateObjectVisibility(false);
863}
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
Definition Map.cpp:898
void AddDynamicObjectToMoveList(DynamicObject *go)
Definition Map.cpp:891

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)
176{
177 _mapGridManager.CreateGrid(gridCoord.x_coord, gridCoord.y_coord);
178}
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
181{
182 EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
183
184 if (_mapGridManager.LoadGrid(cell.GridX(), cell.GridY()))
185 {
186 Balance();
187 return true;
188 }
189
190 return false;
191}
bool LoadGrid(uint16 const x, uint16 const y)
Definition MapGridManager.cpp:22
void Balance()
Definition Map.h:387

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 
)
825{
826 Cell old_cell = go->GetCurrentCell();
827 Cell new_cell(x, y);
828
829 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
830 {
831 if (old_cell.DiffGrid(new_cell))
832 EnsureGridLoaded(new_cell);
833
835 }
836 else
838
839 go->Relocate(x, y, z, o);
842 go->UpdateObjectVisibility(false);
843}
void UpdateModelPosition()
Definition GameObject.cpp:2891
void AddGameObjectToMoveList(GameObject *go)
Definition Map.cpp:878
void RemoveGameObjectFromMoveList(GameObject *go)
Definition Map.cpp:885
void SetPositionDataUpdate()
Definition Object.cpp:1131
virtual void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false)
Definition Object.cpp:2939

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
465{ 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
1249{
1250 uint32 mogpFlags;
1251 int32 adtId, rootId, groupId;
1252 float vmapZ = z;
1253 bool hasVmapArea = GetAreaInfo(phaseMask, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
1254
1255 uint32 gridAreaId = 0;
1256 float gridMapHeight = INVALID_HEIGHT;
1257 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1258 {
1259 gridAreaId = gmap->getArea(x, y);
1260 gridMapHeight = gmap->getHeight(x, y);
1261 }
1262
1263 uint16 areaId = 0;
1264
1265 // floor is the height we are closer to (but only if above)
1266 if (hasVmapArea && G3D::fuzzyGe(z, vmapZ - GROUND_HEIGHT_TOLERANCE) && (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapZ > gridMapHeight))
1267 {
1268 // wmo found
1269 if (WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId))
1270 areaId = wmoEntry->areaId;
1271
1272 if (!areaId)
1273 areaId = gridAreaId;
1274 }
1275 else
1276 areaId = gridAreaId;
1277
1278 if (!areaId)
1279 areaId = i_mapEntry->linked_zone;
1280
1281 return areaId;
1282}
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:160
bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition Map.cpp:1199
GridTerrainData * GetGridTerrainData(GridCoord const &gridCoord)
Definition Map.cpp:1077
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
1200{
1201 float vmap_z = z;
1202 float dynamic_z = z;
1203 float check_z = z;
1205 uint32 vflags;
1206 int32 vadtId;
1207 int32 vrootId;
1208 int32 vgroupId;
1209 uint32 dflags;
1210 int32 dadtId;
1211 int32 drootId;
1212 int32 dgroupId;
1213
1214 bool hasVmapAreaInfo = vmgr->GetAreaInfo(GetId(), x, y, vmap_z, vflags, vadtId, vrootId, vgroupId);
1215 bool hasDynamicAreaInfo = _dynamicTree.GetAreaInfo(x, y, dynamic_z, phaseMask, dflags, dadtId, drootId, dgroupId);
1216 auto useVmap = [&]() { check_z = vmap_z; flags = vflags; adtId = vadtId; rootId = vrootId; groupId = vgroupId; };
1217 auto useDyn = [&]() { check_z = dynamic_z; flags = dflags; adtId = dadtId; rootId = drootId; groupId = dgroupId; };
1218
1219 if (hasVmapAreaInfo)
1220 {
1221 if (hasDynamicAreaInfo && dynamic_z > vmap_z)
1222 useDyn();
1223 else
1224 useVmap();
1225 }
1226 else if (hasDynamicAreaInfo)
1227 {
1228 useDyn();
1229 }
1230
1231 if (hasVmapAreaInfo || hasDynamicAreaInfo)
1232 {
1233 // check if there's terrain between player height and object height
1234 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1235 {
1236 float mapHeight = gmap->getHeight(x, y);
1237 // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
1238 if (z + 2.0f > mapHeight && mapHeight > check_z)
1239 return false;
1240 }
1241
1242 return true;
1243 }
1244
1245 return false;
1246}
bool GetAreaInfo(float x, float y, float &z, uint32 phasemask, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition DynamicTree.cpp:311
Definition IVMapMgr.h:78
virtual bool GetAreaInfo(uint32 pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const =0

References _dynamicTree, VMAP::VMapFactory::createOrGetVMapMgr(), DynamicMapTree::GetAreaInfo(), VMAP::IVMapMgr::GetAreaInfo(), GetGridTerrainData(), and GetId().

Referenced by GetAreaId().

◆ GetCorpse()

Corpse * Map::GetCorpse ( ObjectGuid const  guid)
2360{
2361 return _objectsStore.Find<Corpse>(guid);
2362}
MapStoredObjectTypesContainer _objectsStore
Definition Map.h:602
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
363 {
364 auto itr = _corpsesByPlayer.find(ownerGuid);
365 if (itr != _corpsesByPlayer.end())
366 return itr->second;
367
368 return nullptr;
369 }

References _corpsesByPlayer.

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

◆ GetCorpsesInGrid()

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

References _corpsesByGrid.

Referenced by GridObjectLoader::LoadAllCellsInGrid().

◆ GetCreatedCellsInGridCount()

uint32 Map::GetCreatedCellsInGridCount ( uint16 const  x,
uint16 const  y 
)
3132{
3134}
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 ( )
3137{
3139}
uint32 GetCreatedCellsInMapCount()
Definition MapGridManager.cpp:107

References _mapGridManager, and MapGridManager::GetCreatedCellsInMapCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreatedGridsCount()

uint32 Map::GetCreatedGridsCount ( )
3122{
3124}
uint32 GetCreatedGridsCount()
Definition MapGridManager.cpp:88

References _mapGridManager, and MapGridManager::GetCreatedGridsCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetCreature()

Creature * Map::GetCreature ( ObjectGuid const  guid)
2365{
2366 return _objectsStore.Find<Creature>(guid);
2367}

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
402 {
403 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
404 if (itr != _creatureRespawnTimes.end())
405 return itr->second;
406
407 return time_t(0);
408 }

References _creatureRespawnTimes.

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

◆ GetDebugInfo()

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

Reimplemented in InstanceMap.

3113{
3114 std::stringstream sstr;
3115 sstr << std::boolalpha
3116 << "Id: " << GetId() << " InstanceId: " << GetInstanceId() << " Difficulty: " << std::to_string(GetDifficulty())
3117 << " HasPlayers: " << HavePlayers();
3118 return sstr.str();
3119}
bool HavePlayers() const
Definition Map.h:317
Difficulty GetDifficulty() const
Definition Map.h:287

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

Referenced by InstanceMap::GetDebugInfo().

◆ GetDifficulty()

◆ GetDynamicMapTree()

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

References _dynamicTree.

Referenced by BattlegroundRV::CheckPositionForUnit().

◆ GetDynamicObject()

DynamicObject * Map::GetDynamicObject ( ObjectGuid const  guid)
2389{
2390 return _objectsStore.Find<DynamicObject>(guid);
2391}
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
304 {
305 if (!i_mapEntry)
306 return false;
307 return i_mapEntry->GetEntrancePos(mapid, x, y);
308 }
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,
uint8  reqLiquidType = MAP_ALL_LIQUIDS 
)
1389{
1390 GridTerrainData* gmap = GetGridTerrainData(x, y);
1391
1393 VMAP::AreaAndLiquidData vmapData;
1394 // VMAP::AreaAndLiquidData dynData;
1395 VMAP::AreaAndLiquidData* wmoData = nullptr;
1396 vmgr->GetAreaAndLiquidData(GetId(), x, y, z, reqLiquidType, vmapData);
1397 // _dynamicTree.GetAreaAndLiquidData(x, y, z, phaseMask, reqLiquidType, dynData);
1398
1399 uint32 gridAreaId = 0;
1400 float gridMapHeight = INVALID_HEIGHT;
1401 if (gmap)
1402 {
1403 gridAreaId = gmap->getArea(x, y);
1404 gridMapHeight = gmap->getHeight(x, y);
1405 }
1406
1407 bool useGridLiquid = true;
1408
1409 // floor is the height we are closer to (but only if above)
1411 if (gridMapHeight > INVALID_HEIGHT && G3D::fuzzyGe(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE))
1412 data.floorZ = gridMapHeight;
1413
1414 if (vmapData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
1415 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapData.floorZ > gridMapHeight))
1416 {
1417 data.floorZ = vmapData.floorZ;
1418 wmoData = &vmapData;
1419 }
1420
1421 // NOTE: Objects will not detect a case when a wmo providing area/liquid despawns from under them
1422 // but this is fine as these kind of objects are not meant to be spawned and despawned a lot
1423 // example: Lich King platform
1424 /*
1425 if (dynData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, dynData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
1426 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > gridMapHeight) &&
1427 (G3D::fuzzyLt(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > vmapData.floorZ))
1428 {
1429 data.floorZ = dynData.floorZ;
1430 wmoData = &dynData;
1431 }
1432 */
1433
1434 if (wmoData)
1435 {
1436 if (wmoData->areaInfo)
1437 {
1438 // wmo found
1439 WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId);
1440 data.outdoors = (wmoData->areaInfo->mogpFlags & 0x8) != 0;
1441 if (wmoEntry)
1442 {
1443 data.areaId = wmoEntry->areaId;
1444 if (wmoEntry->Flags & 4)
1445 data.outdoors = true;
1446 else if (wmoEntry->Flags & 2)
1447 data.outdoors = false;
1448 }
1449
1450 if (!data.areaId)
1451 data.areaId = gridAreaId;
1452
1453 useGridLiquid = !IsInWMOInterior(wmoData->areaInfo->mogpFlags);
1454 }
1455 }
1456 else
1457 {
1458 data.outdoors = true;
1459 data.areaId = gridAreaId;
1460 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId))
1461 data.outdoors = (areaEntry->flags & (AREA_FLAG_INSIDE | AREA_FLAG_OUTSIDE)) != AREA_FLAG_INSIDE;
1462 }
1463
1464 if (!data.areaId)
1466
1467 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId);
1468
1469 // liquid processing
1470 if (wmoData && wmoData->liquidInfo && wmoData->liquidInfo->level > wmoData->floorZ)
1471 {
1472 uint32 liquidType = wmoData->liquidInfo->type;
1473 if (GetId() == MAP_OUTLAND && liquidType == 2) // gotta love blizzard hacks
1474 liquidType = 15;
1475
1476 uint32 liquidFlagType = 0;
1477 if (LiquidTypeEntry const* liquidData = sLiquidTypeStore.LookupEntry(liquidType))
1478 liquidFlagType = liquidData->Type;
1479
1480 if (liquidType && liquidType < 21 && areaEntry)
1481 {
1482 uint32 overrideLiquid = areaEntry->LiquidTypeOverride[liquidFlagType];
1483 if (!overrideLiquid && areaEntry->zone)
1484 {
1485 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->zone);
1486 if (zoneEntry)
1487 overrideLiquid = zoneEntry->LiquidTypeOverride[liquidFlagType];
1488 }
1489
1490 if (LiquidTypeEntry const* overrideData = sLiquidTypeStore.LookupEntry(overrideLiquid))
1491 {
1492 liquidType = overrideLiquid;
1493 liquidFlagType = overrideData->Type;
1494 }
1495 }
1496
1497 data.liquidInfo.Level = wmoData->liquidInfo->level;
1498 data.liquidInfo.DepthLevel = wmoData->floorZ;
1499 data.liquidInfo.Entry = liquidType;
1500 data.liquidInfo.Flags = 1 << liquidFlagType;
1501
1502 // Get position delta
1503 float delta = wmoData->liquidInfo->level - z;
1504
1505 if (delta > collisionHeight)
1507 else if (delta > 0.0f)
1509 else if (delta > -0.1f)
1511 else
1513 }
1514
1515 // look up liquid data from grid map
1516 if (gmap && useGridLiquid)
1517 {
1518 LiquidData const& gridLiquidData = gmap->GetLiquidData(x, y, z, collisionHeight, reqLiquidType);
1519 if (gridLiquidData.Status != LIQUID_MAP_NO_WATER && (!wmoData || gridLiquidData.Level > wmoData->floorZ))
1520 {
1521 uint32 liquidEntry = gridLiquidData.Entry;
1522 if (GetId() == MAP_OUTLAND && liquidEntry == 2)
1523 liquidEntry = 15;
1524
1525 data.liquidInfo = gridLiquidData;
1526 data.liquidInfo.Entry = liquidEntry;
1527 }
1528 }
1529}
@ 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:1194
float getHeight(float x, float y) const
Definition GridTerrainData.h:249
uint16 getArea(float x, float y) const
Definition GridTerrainData.cpp:214
LiquidData const GetLiquidData(float x, float y, float z, float collisionHeight, uint8 ReqLiquidType) const
Definition GridTerrainData.cpp:530
virtual void GetAreaAndLiquidData(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData &data) const =0
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:95
uint32 areaId
Definition Map.h:94
LiquidData liquidInfo
Definition Map.h:97
bool outdoors
Definition Map.h:96
Definition IVMapMgr.h:52
Optional< AreaInfo > areaInfo
Definition IVMapMgr.h:72
Optional< LiquidInfo > liquidInfo
Definition IVMapMgr.h:73
float floorZ
Definition IVMapMgr.h:71
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)
2370{
2371 return _objectsStore.Find<GameObject>(guid);
2372}

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::HandleMovementOpcodes(), 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(), instance_halls_of_lightning::instance_halls_of_lightning_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_gundrak::instance_gundrak_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
394 {
395 return _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
396 }
float getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const
Definition DynamicTree.cpp:294

References _dynamicTree, and DynamicMapTree::getHeight().

◆ GetGORespawnTime()

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

References _goRespawnTimes.

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

◆ GetGridHeight()

float Map::GetGridHeight ( float  x,
float  y 
) const
1179{
1180 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1181 return gmap->getHeight(x, y);
1182
1183 return INVALID_HEIGHT;
1184}

References GetGridTerrainData(), and INVALID_HEIGHT.

Referenced by CheckCollisionAndGetValidCoords(), and GetHeight().

◆ GetGridTerrainData() [1/2]

GridTerrainData * Map::GetGridTerrainData ( float  x,
float  y 
)
1088{
1089 GridCoord const gridCoord = Acore::ComputeGridCoord(x, y);
1090 return GetGridTerrainData(gridCoord);
1091}

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

◆ GetGridTerrainData() [2/2]

GridTerrainData * Map::GetGridTerrainData ( GridCoord const &  gridCoord)
1078{
1079 if (!MapGridManager::IsValidGridCoordinates(gridCoord.x_coord, gridCoord.y_coord))
1080 return nullptr;
1081
1082 // ensure GridMap is created
1083 EnsureGridCreated(gridCoord);
1084 return _mapGridManager.GetGrid(gridCoord.x_coord, gridCoord.y_coord)->GetTerrainData();
1085}
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)
1071{
1072 // ensure GridMap is created
1073 EnsureGridCreated(gridCoord);
1074 return _mapGridManager.GetGrid(gridCoord.x_coord, gridCoord.y_coord)->GetTerrainDataSharedPtr();
1075}
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
593 {
594 auto itr = _guidGenerators.find(high);
595 if (itr == _guidGenerators.end())
596 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
597
598 return *itr->second;
599 }
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition Map.h:601
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
1142{
1143 // find raw .map surface under Z coordinates
1144 float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
1145 float gridHeight = GetGridHeight(x, y);
1146 if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
1147 mapHeight = gridHeight;
1148
1149 float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
1150 if (checkVMap)
1151 {
1153 vmapHeight = vmgr->getHeight(GetId(), x, y, z, maxSearchDist); // look from a bit higher pos to find the floor
1154 }
1155
1156 // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT
1157 // vmapheight set for any under Z value or <= INVALID_HEIGHT
1158 if (vmapHeight > INVALID_HEIGHT)
1159 {
1160 if (mapHeight > INVALID_HEIGHT)
1161 {
1162 // we have mapheight and vmapheight and must select more appropriate
1163
1164 // we are already under the surface or vmap height above map heigt
1165 // or if the distance of the vmap height is less the land height distance
1166 if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
1167 return vmapHeight;
1168 else
1169 return mapHeight; // better use .map surface height
1170 }
1171 else
1172 return vmapHeight; // we have only vmapHeight (if have)
1173 }
1174
1175 return mapHeight; // explicitly use map data
1176}
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
1594{
1595 float h1, h2;
1596 h1 = GetHeight(x, y, z, vmap, maxSearchDist);
1597 h2 = _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
1598 return std::max<float>(h1, h2);
1599}
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.cpp:1141

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

◆ GetId()

uint32 Map::GetId ( ) const
inline
226{ 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
2632{
2633 ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
2634 switch (linkedGuid.GetHigh())
2635 {
2636 case HighGuid::Unit:
2637 return GetCreatureRespawnTime(linkedGuid.GetCounter());
2639 return GetGORespawnTime(linkedGuid.GetCounter());
2640 default:
2641 break;
2642 }
2643
2644 return time_t(0);
2645}
#define sObjectMgr
Definition ObjectMgr.h:1650
time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:401
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition Map.h:410
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,
uint8  ReqLiquidType 
)
1303{
1304 LiquidData liquidData;
1305
1307 float liquid_level = INVALID_HEIGHT;
1308 float ground_level = INVALID_HEIGHT;
1309 uint32 liquid_type = 0;
1310 uint32 mogpFlags = 0;
1311 bool useGridLiquid = true;
1312 if (vmgr->GetLiquidLevel(GetId(), x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type, mogpFlags))
1313 {
1314 useGridLiquid = !IsInWMOInterior(mogpFlags);
1315 LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: {} ground: {} type: {}", liquid_level, ground_level, liquid_type);
1316 // Check water level and ground level
1317 if (liquid_level > ground_level && G3D::fuzzyGe(z, ground_level - GROUND_HEIGHT_TOLERANCE))
1318 {
1319 // hardcoded in client like this
1320 if (GetId() == MAP_OUTLAND && liquid_type == 2)
1321 liquid_type = 15;
1322
1323 uint32 liquidFlagType = 0;
1324 if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(liquid_type))
1325 liquidFlagType = liq->Type;
1326
1327 if (liquid_type && liquid_type < 21)
1328 {
1329 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseMask, x, y, z)))
1330 {
1331 uint32 overrideLiquid = area->LiquidTypeOverride[liquidFlagType];
1332 if (!overrideLiquid && area->zone)
1333 {
1334 area = sAreaTableStore.LookupEntry(area->zone);
1335 if (area)
1336 overrideLiquid = area->LiquidTypeOverride[liquidFlagType];
1337 }
1338
1339 if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
1340 {
1341 liquid_type = overrideLiquid;
1342 liquidFlagType = liq->Type;
1343 }
1344 }
1345 }
1346
1347 liquidData.Level = liquid_level;
1348 liquidData.DepthLevel = ground_level;
1349 liquidData.Entry = liquid_type;
1350 liquidData.Flags = 1 << liquidFlagType;
1351 }
1352
1353 float delta = liquid_level - z;
1354
1355 // Get position delta
1356 if (delta > collisionHeight)
1357 liquidData.Status = LIQUID_MAP_UNDER_WATER;
1358 else if (delta > 0.0f)
1359 liquidData.Status = LIQUID_MAP_IN_WATER;
1360 else if (delta > -0.1f)
1361 liquidData.Status = LIQUID_MAP_WATER_WALK;
1362 else
1363 liquidData.Status = LIQUID_MAP_ABOVE_WATER;
1364 }
1365
1366 if (useGridLiquid)
1367 {
1368 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1369 {
1370 LiquidData const& map_data = gmap->GetLiquidData(x, y, z, collisionHeight, ReqLiquidType);
1371 // Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
1372 if (map_data.Status != LIQUID_MAP_NO_WATER && (map_data.Level > ground_level))
1373 {
1374 // hardcoded in client like this
1375 uint32 liquidEntry = map_data.Entry;
1376 if (GetId() == MAP_OUTLAND && liquidEntry == 2)
1377 liquidEntry = 15;
1378
1379 liquidData = map_data;
1380 liquidData.Entry = liquidEntry;
1381 }
1382 }
1383 }
1384
1385 return liquidData;
1386}
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
uint32 GetAreaId(uint32 phaseMask, float x, float y, float z) const
Definition Map.cpp:1248
virtual bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type, uint32 &mogpFlags) const =0

References VMAP::VMapFactory::createOrGetVMapMgr(), LiquidData::DepthLevel, LiquidData::Entry, LiquidData::Flags, GetAreaId(), GetGridTerrainData(), GetId(), VMAP::IVMapMgr::GetLiquidLevel(), GROUND_HEIGHT_TOLERANCE, INVALID_HEIGHT, IsInWMOInterior(), LiquidData::Level, LIQUID_MAP_ABOVE_WATER, LIQUID_MAP_IN_WATER, LIQUID_MAP_NO_WATER, LIQUID_MAP_UNDER_WATER, LIQUID_MAP_WATER_WALK, 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 ( )
3127{
3129}
uint32 GetLoadedGridsCount()
Definition MapGridManager.cpp:93

References _mapGridManager, and MapGridManager::GetLoadedGridsCount().

Referenced by debug_commandscript::HandleDebugMapDataCommand().

◆ GetMapDifficulty()

MapDifficulty const * Map::GetMapDifficulty ( ) const
2260{
2262}
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
1187{
1188 if (GridTerrainData const* grid = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1189 return grid->getMinHeight(x, y);
1190
1191 return MIN_HEIGHT;
1192}
#define MIN_HEIGHT
Definition GridTerrainData.h:29

References GetGridTerrainData(), and MIN_HEIGHT.

Referenced by WorldSession::HandleMovementOpcodes().

◆ GetMMapLock()

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

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 
)
1580{
1581 G3D::Vector3 startPos(x1, y1, z1);
1582 G3D::Vector3 dstPos(x2, y2, z2);
1583
1584 G3D::Vector3 resultPos;
1585 bool result = _dynamicTree.GetObjectHitPos(phasemask, startPos, dstPos, resultPos, modifyDist);
1586
1587 rx = resultPos.x;
1588 ry = resultPos.y;
1589 rz = resultPos.z;
1590 return result;
1591}
bool GetObjectHitPos(uint32 phasemask, const G3D::Vector3 &pPos1, const G3D::Vector3 &pPos2, G3D::Vector3 &pResultHitPos, float pModifyDist) const
Definition DynamicTree.cpp:230

References _dynamicTree, and DynamicMapTree::GetObjectHitPos().

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

◆ GetObjectsStore()

◆ GetParent()

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

References m_parentMap.

Referenced by GridTerrainLoader::LoadMap().

◆ GetPet()

Pet * Map::GetPet ( ObjectGuid const  guid)
2375{
2376 return dynamic_cast<Pet*>(_objectsStore.Find<Creature>(guid));
2377}
Definition Pet.h:41

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

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

◆ GetPlayers()

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

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(), 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(), SetZoneMusic(), SetZoneOverrideLight(), SetZoneWeather(), 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_arthas::npc_arthasAI::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 
)
1115{
1116 G3D::Vector3 v(x, y, z + 2.0f);
1117 G3D::Ray r(v, G3D::Vector3(0, 0, -1));
1118 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1119 if ((*itr)->IsInWorld() && (*itr)->GetExactDistSq(x, y, z) < 75.0f * 75.0f && (*itr)->m_model)
1120 {
1121 float dist = 30.0f;
1122 bool hit = (*itr)->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
1123 if (hit)
1124 return *itr;
1125 }
1126
1127 if (worldobject)
1128 if (GameObject* staticTrans = worldobject->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_TRANSPORT, 75.0f))
1129 if (staticTrans->m_model)
1130 {
1131 float dist = 10.0f;
1132 bool hit = staticTrans->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
1133 if (hit)
1134 if (GetHeight(phase, x, y, z, true, 30.0f) < (v.z - dist + 1.0f))
1135 return staticTrans->ToTransport();
1136 }
1137
1138 return nullptr;
1139}
@ GAMEOBJECT_TYPE_TRANSPORT
Definition SharedDefines.h:1582
phase
Definition boss_skadi.cpp:103
GameObject * FindNearestGameObjectOfType(GameobjectTypes type, float range) const
Definition Object.cpp:2443

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
1532{
1533 if (GridTerrainData* gmap = const_cast<Map*>(this)->GetGridTerrainData(x, y))
1534 return gmap->getLiquidLevel(x, y);
1535
1536 return INVALID_HEIGHT;
1537}

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
1094{
1095 // we need ground level (including grid height version) for proper return water level in point
1096 float ground_z = GetHeight(phasemask, x, y, z + Z_OFFSET_FIND_HEIGHT, true, 50.0f);
1097 if (ground)
1098 *ground = ground_z;
1099
1100 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phasemask, x, y, ground_z, collisionHeight, MAP_ALL_LIQUIDS);
1101 switch (liquidData.Status)
1102 {
1104 return std::max<float>(liquidData.Level, ground_z);
1106 return ground_z;
1107 default:
1108 return liquidData.Level;
1109 }
1110
1112}
#define MAP_ALL_LIQUIDS
Definition GridTerrainData.h:40
constexpr float Z_OFFSET_FIND_HEIGHT
Definition SharedDefines.h:27
LiquidData const GetLiquidData(uint32 phaseMask, float x, float y, float z, float collisionHeight, uint8 ReqLiquidType)
Definition Map.cpp:1302

References GetHeight(), GetLiquidData(), LiquidData::Level, LIQUID_MAP_ABOVE_WATER, LIQUID_MAP_NO_WATER, MAP_ALL_LIQUIDS, 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
1295{
1296 areaid = zoneid = GetAreaId(phaseMask, x, y, z);
1297 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
1298 if (area->zone)
1299 zoneid = area->zone;
1300}

References GetAreaId(), and sAreaTableStore.

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

◆ GetZoneId()

uint32 Map::GetZoneId ( uint32  phaseMask,
float  x,
float  y,
float  z 
) const
1285{
1286 uint32 areaId = GetAreaId(phaseMask, x, y, z);
1287 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
1288 if (area->zone)
1289 return area->zone;
1290
1291 return areaId;
1292}

References GetAreaId(), and sAreaTableStore.

Referenced by MapMgr::GetZoneId().

◆ GetZoneWideVisibleWorldObjectsForZone()

ZoneWideVisibleWorldObjectsSet const * Map::GetZoneWideVisibleWorldObjectsForZone ( uint32  zoneId) const
666{
667 ZoneWideVisibleWorldObjectsMap::const_iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
668 if (itr == _zoneWideVisibleWorldObjectsMap.end())
669 return nullptr;
670
671 return &itr->second;
672}

References _zoneWideVisibleWorldObjectsMap.

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

◆ HandleDelayedVisibility()

void Map::HandleDelayedVisibility ( )
675{
677 return;
678 for (std::unordered_set<Unit*>::iterator itr = i_objectsForDelayedVisibility.begin(); itr != i_objectsForDelayedVisibility.end(); ++itr)
679 (*itr)->ExecuteDelayedUnitRelocationEvent();
681}
std::unordered_set< Unit * > i_objectsForDelayedVisibility
Definition Map.h:233

References i_objectsForDelayedVisibility.

Referenced by Update().

◆ HasEnoughWater() [1/2]

bool Map::HasEnoughWater ( WorldObject const *  searcher,
float  x,
float  y,
float  z 
) const
1614{
1615 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(
1616 searcher->GetPhaseMask(), x, y, z, searcher->GetCollisionHeight(), MAP_ALL_LIQUIDS);
1617
1618 if ((liquidData.Status & MAP_LIQUID_STATUS_SWIMMING) == 0)
1619 return false;
1620
1621 float minHeightInWater = searcher->GetMinHeightInWater();
1622 return liquidData.Level > INVALID_HEIGHT &&
1623 liquidData.Level > liquidData.DepthLevel &&
1624 liquidData.Level - liquidData.DepthLevel >= minHeightInWater;
1625}
#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 )
289{
290 //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
291}

◆ InitializeObject() [2/3]

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

◆ InitializeObject() [3/3]

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

Referenced by AddToMap().

◆ InitVisibilityDistance()

void Map::InitVisibilityDistance ( )
virtual

Reimplemented in InstanceMap, BattlegroundMap, and MapInstanced.

91{
92 //init visibility for continents
94
95 switch (GetId())
96 {
97 case MAP_EBON_HOLD: // Scarlet Enclave (DK starting zone)
98 m_VisibleDistance = 125.0f;
99 break;
100 case MAP_SCOTT_TEST: // (box map)
101 m_VisibleDistance = 200.0f;
102 break;
103 }
104}
@ MAP_EBON_HOLD
Definition AreaDefines.h:258
@ MAP_SCOTT_TEST
Definition AreaDefines.h:187
static float GetMaxVisibleDistanceOnContinents()
Definition World.h:214

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
389{ _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()

bool Map::Is25ManRaid ( ) const
inline

◆ IsBattleArena()

◆ IsBattleground()

bool Map::IsBattleground ( ) const
inline
298{ 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
314{ return marked_cells.test(pCellId); }
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition Map.h:565

References marked_cells.

◆ IsDungeon()

bool Map::IsDungeon ( ) const
inline
292{ 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(), Acore::XP::Gain(), 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
212 {
214 }
bool IsGridCreated(GridCoord const &gridCoord) const
Definition Map.cpp:203

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

◆ IsGridCreated() [2/2]

bool Map::IsGridCreated ( GridCoord const &  gridCoord) const
204{
205 return _mapGridManager.IsGridCreated(gridCoord.x_coord, gridCoord.y_coord);
206}
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
207 {
209 }

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_orb_carrier::npc_orb_carrierAI::DoAction(), npc_molten_golem::npc_molten_golemAI::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_loken::boss_lokenAI::JustEngagedWith(), boss_krystallus::boss_krystallusAI::JustEngagedWith(), npc_tirion_fordring_tft::npc_tirion_fordringAI::JustReachedHome(), npc_frost_tomb::npc_frost_tomb(), instance_trial_of_the_crusader::instance_trial_of_the_crusader_InstanceMapScript::OnPlayerEnter(), at_shattered_halls_execution::OnTrigger(), 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_gundrak::instance_gundrak_InstanceMapScript::SetBossState(), 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(), boss_skadi_grauf::boss_skadi_graufAI::SpawnFlameTriggers(), boss_skadi_grauf::boss_skadi_graufAI::SpellHitTarget(), boss_ionar::boss_ionarAI::Split(), 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(), npc_stormforged_lieutenant::npc_stormforged_lieutenantAI::UpdateAI(), boss_ionar::boss_ionarAI::UpdateAI(), boss_loken::boss_lokenAI::UpdateAI(), boss_volkhan::boss_volkhanAI::UpdateAI(), npc_molten_golem::npc_molten_golemAI::UpdateAI(), npc_hol_monument::npc_hol_monumentAI::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
1540{
1541 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_PVP_LOS))
1542 {
1544 {
1545 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1546 }
1547 }
1548
1549 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD))
1550 {
1551 if (IsWorldMap())
1552 {
1553 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1554 }
1555 }
1556
1557 if ((checks & LINEOFSIGHT_CHECK_VMAP) && !VMAP::VMapFactory::createOrGetVMapMgr()->isInLineOfSight(GetId(), x1, y1, z1, x2, y2, z2, ignoreFlags))
1558 {
1559 return false;
1560 }
1561
1562 if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT_ALL))
1563 {
1564 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
1565 if (!(checks & LINEOFSIGHT_CHECK_GOBJECT_M2))
1566 {
1567 ignoreFlags = VMAP::ModelIgnoreFlags::M2;
1568 }
1569
1570 if (!_dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask, ignoreFlags))
1571 {
1572 return false;
1573 }
1574 }
1575
1576 return true;
1577}
@ LINEOFSIGHT_CHECK_GOBJECT_M2
Definition Map.h:104
@ LINEOFSIGHT_CHECK_VMAP
Definition Map.h:102
@ LINEOFSIGHT_CHECK_GOBJECT_ALL
Definition Map.h:106
@ 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:276
bool IsWorldMap() const
Definition Map.h:301
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:1539

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

◆ IsNonRaidDungeon()

bool Map::IsNonRaidDungeon ( ) const
inline
293{ 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
288{ 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
1608{
1609 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phaseMask, x, y, z, collisionHeight, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN);
1610 return liquidData.Status == LIQUID_MAP_UNDER_WATER;
1611}
#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::HandleMovementOpcodes().

◆ IsWorldMap()

bool Map::IsWorldMap ( ) const
inline
301{ 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 ( )
214{
215 for (uint32 cellX = 0; cellX < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellX++)
216 for (uint32 cellY = 0; cellY < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellY++)
218}
#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:208

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 ( )
3067{
3069 stmt->SetData(0, GetId());
3070 stmt->SetData(1, GetInstanceId());
3071
3072 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
3073 // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
3074 PreparedQueryResult result = CharacterDatabase.Query(stmt);
3075 if (!result)
3076 return;
3077
3078 do
3079 {
3080 Field* fields = result->Fetch();
3081 CorpseType type = CorpseType(fields[13].Get<uint8>());
3082 uint32 guid = fields[16].Get<uint32>();
3083 if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
3084 {
3085 LOG_ERROR("maps", "Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
3086 continue;
3087 }
3088
3089 Corpse* corpse = new Corpse(type);
3090
3091 if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
3092 {
3093 delete corpse;
3094 continue;
3095 }
3096
3097 AddCorpse(corpse);
3098
3099 corpse->UpdatePositionData();
3100 } while (result->NextRow());
3101}
@ 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 
)
221{
223 return;
224
225 float const x = center.GetPositionX();
226 float const y = center.GetPositionY();
227
228 CellCoord cellCoord(Acore::ComputeCellCoord(x, y));
229 if (!cellCoord.IsCoordValid())
230 return;
231
232 if (radius > SIZE_OF_GRIDS)
233 radius = SIZE_OF_GRIDS;
234
235 CellArea area = Cell::CalculateCellArea(x, y, radius);
236 if (!area)
237 return;
238
239 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
240 {
241 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
242 {
243 CellCoord cellCoord(x, y);
244 Cell cell(cellCoord);
245 EnsureGridLoaded(cell);
246 }
247 }
248}
#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 ( )
2468{
2470 stmt->SetData(0, GetId());
2471 stmt->SetData(1, GetInstanceId());
2472 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2473 {
2474 do
2475 {
2476 Field* fields = result->Fetch();
2477 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
2478 uint32 respawnTime = fields[1].Get<uint32>();
2479
2480 _creatureRespawnTimes[lowguid] = time_t(respawnTime);
2481 } while (result->NextRow());
2482 }
2483
2484 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GO_RESPAWNS);
2485 stmt->SetData(0, GetId());
2486 stmt->SetData(1, GetInstanceId());
2487 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
2488 {
2489 do
2490 {
2491 Field* fields = result->Fetch();
2492 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
2493 uint32 respawnTime = fields[1].Get<uint32>();
2494
2495 _goRespawnTimes[lowguid] = time_t(respawnTime);
2496 } while (result->NextRow());
2497 }
2498}
@ 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 
)
2587{
2588 if (!IsRaid() || !GetEntry() || GetEntry()->Expansion() < 2) // only for wotlk raids, because logs take up tons of mysql memory
2589 return;
2590 InstanceMap* map = ToInstanceMap();
2591 if (!map)
2592 return;
2593 std::string playersInfo;
2594 char buffer[16384], buffer2[255];
2595 Map::PlayerList const& pl = map->GetPlayers();
2596 for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
2597 if (Player* p = itr->GetSource())
2598 {
2599 std::string auraStr;
2600 const Unit::AuraApplicationMap& a = p->GetAppliedAuras();
2601 for (auto iterator = a.begin(); iterator != a.end(); ++iterator)
2602 {
2603 snprintf(buffer2, 255, "%u(%u) ", iterator->first, iterator->second->GetEffectMask());
2604 auraStr += buffer2;
2605 }
2606
2607 snprintf(buffer, 16384, "%s (%s, acc: %u, ip: %s, guild: %u), xyz: (%.1f, %.1f, %.1f), auras: %s\n",
2608 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());
2609 playersInfo += buffer;
2610 }
2611 CleanStringForMysqlQuery(playersInfo);
2612 CharacterDatabase.Execute("INSERT INTO log_encounter VALUES(NOW(), {}, {}, {}, {}, '{}')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo);
2613}
void CleanStringForMysqlQuery(std::string &str)
Definition Common.cpp:61
LinkedListHead::Iterator< GridReference< MapGridType > > iterator
Definition GridRefMgr.h:30
Definition Map.h:627
Definition MapRefMgr.h:26
InstanceMap * ToInstanceMap()
Definition Map.h:374
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:629

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

Referenced by UpdateEncounterState().

◆ markCell()

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

References marked_cells.

Referenced by MarkNearbyCellsOf().

◆ MarkNearbyCellsOf()

void Map::MarkNearbyCellsOf ( WorldObject obj)
392{
393 // Check for valid position
394 if (!obj->IsPositionValid())
395 return;
396
397 // Update mobs/objects in ALL visible cells around object!
399 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
400 {
401 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
402 {
403 // marked cells are those that have been visited
404 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
405 markCell(cell_id);
406 }
407 }
408}
void markCell(uint32 pCellId)
Definition Map.h:315
float GetGridActivationRange() const
Definition Object.cpp:1628
bool IsPositionValid() const
Definition Position.cpp:176

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 ( )
905{
906 for (std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr)
907 {
908 Creature* c = *itr;
909 if (c->FindMap() != this)
910 continue;
911
913 {
915 continue;
916 }
917
919 if (!c->IsInWorld())
920 continue;
921
922 Cell const& old_cell = c->GetCurrentCell();
923 Cell new_cell(c->GetPositionX(), c->GetPositionY());
924 if (c->IsFarVisible())
925 {
926 // Removes via GetCurrentCell, added back in AddToGrid
928 }
929
930 c->RemoveFromGrid();
931 if (old_cell.DiffGrid(new_cell))
932 EnsureGridLoaded(new_cell);
933 AddToGrid(c, new_cell);
934 }
935 _creaturesToMove.clear();
936}
void RemoveFromGrid()
Definition Object.h:370
void RemoveWorldObjectFromFarVisibleMap(WorldObject *obj)
Definition Map.cpp:634
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 ( )
974{
975 for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr)
976 {
977 DynamicObject* dynObj = *itr;
978 if (dynObj->FindMap() != this)
979 continue;
980
982 {
984 continue;
985 }
986
988 if (!dynObj->IsInWorld())
989 continue;
990
991 Cell const& old_cell = dynObj->GetCurrentCell();
992 Cell new_cell(dynObj->GetPositionX(), dynObj->GetPositionY());
993
994 dynObj->RemoveFromGrid();
995 if (old_cell.DiffGrid(new_cell))
996 EnsureGridLoaded(new_cell);
997 AddToGrid(dynObj, new_cell);
998 }
999 _dynamicObjectsToMove.clear();
1000}

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

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 ( )
82{
83 // Instances load all grids by default (both base map and child maps)
84 if (GetInstanceId())
86
87 sScriptMgr->OnCreateMap(this);
88}
void LoadAllGrids()
Definition Map.cpp:213

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

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

◆ PlayDirectSoundToMap()

void Map::PlayDirectSoundToMap ( uint32  soundId,
uint32  zoneId = 0 
)
2797{
2798 Map::PlayerList const& players = GetPlayers();
2799 if (!players.IsEmpty())
2800 {
2802 data << uint32(soundId);
2803
2804 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2805 if (Player* player = itr->GetSource())
2806 if (!zoneId || player->GetZoneId() == zoneId)
2807 player->SendDirectMessage(&data);
2808 }
2809}
@ 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 
)
781{
782 Cell old_cell(player->GetPositionX(), player->GetPositionY());
783 Cell new_cell(x, y);
784
785 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
786 {
787 player->RemoveFromGrid();
788
789 if (old_cell.DiffGrid(new_cell))
790 EnsureGridLoaded(new_cell);
791
792 AddToGrid(player, new_cell);
793 }
794
795 player->Relocate(x, y, z, o);
796 if (player->IsVehicle())
798 player->UpdatePositionData();
799 player->UpdateObjectVisibility(false);
800}

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 ( )
1801{
1802 while (!i_objectsToRemove.empty())
1803 {
1804 std::unordered_set<WorldObject*>::iterator itr = i_objectsToRemove.begin();
1805 WorldObject* obj = *itr;
1806 i_objectsToRemove.erase(itr);
1807
1808 switch (obj->GetTypeId())
1809 {
1810 case TYPEID_CORPSE:
1811 {
1812 Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
1813 if (!corpse)
1814 LOG_ERROR("maps", "Tried to delete corpse/bones {} that is not in map.", obj->GetGUID().ToString());
1815 else
1816 RemoveFromMap(corpse, true);
1817 break;
1818 }
1820 RemoveFromMap((DynamicObject*)obj, true);
1821 break;
1822 case TYPEID_GAMEOBJECT:
1823 if (Transport* transport = obj->ToGameObject()->ToTransport())
1824 RemoveFromMap(transport, true);
1825 else
1826 RemoveFromMap(obj->ToGameObject(), true);
1827 break;
1828 case TYPEID_UNIT:
1829 // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call
1830 // make sure that like sources auras/etc removed before destructor start
1832 RemoveFromMap(obj->ToCreature(), true);
1833 break;
1834 default:
1835 LOG_ERROR("maps", "Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->GetTypeId());
1836 break;
1837 }
1838 }
1839}
@ 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:721
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition Unit.cpp:15858
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.

1012{
1013 if (HavePlayers())
1014 {
1015 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1016 {
1017 Player* player = itr->GetSource();
1018 if (!player->IsBeingTeleportedFar())
1019 {
1020 // this is happening for bg
1021 LOG_ERROR("maps", "Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->GetName(), GetId());
1022 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
1023 }
1024 }
1025 }
1026}
float m_homebindZ
Definition Player.h:2384
bool IsBeingTeleportedFar() const
Definition Player.h:2099
uint32 m_homebindMapId
Definition Player.h:2380
float m_homebindY
Definition Player.h:2383
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1345
float m_homebindX
Definition Player.h:2382
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)
2660{
2661 ASSERT(corpse);
2662 GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
2663
2664 corpse->DestroyForVisiblePlayers();
2665 if (corpse->IsInGrid())
2666 RemoveFromMap(corpse, false);
2667 else
2668 {
2669 corpse->RemoveFromWorld();
2670 corpse->ResetMap();
2671 }
2672
2673 _corpsesByGrid[gridCoord.GetId()].erase(corpse);
2674 if (corpse->GetType() != CORPSE_BONES)
2675 _corpsesByPlayer.erase(corpse->GetOwnerGUID());
2676 else
2677 _corpseBones.erase(corpse);
2678}
void RemoveFromWorld() override
Definition Corpse.cpp:52
bool IsInGrid() const
Definition Object.h:361
virtual void ResetMap()
Definition Object.cpp:2113
void DestroyForVisiblePlayers()
Definition Object.cpp:2922

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)
2423{
2424 _creatureRespawnTimes.erase(spawnId);
2425
2427 stmt->SetData(0, spawnId);
2428 stmt->SetData(1, GetId());
2429 stmt->SetData(2, GetInstanceId());
2430 CharacterDatabase.Execute(stmt);
2431}
@ 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 
)
722{
723 obj->RemoveFromWorld();
724
725 obj->RemoveFromGrid();
726 if (obj->IsFarVisible())
728
729 obj->ResetMap();
730
731 if (remove)
732 {
734 DeleteFromWorld(obj);
735 }
736}
void RemoveObjectFromMapUpdateList(WorldObject *obj)
Definition Map.cpp:599
void DeleteFromWorld(T *)
Definition Map.cpp:160

References DeleteFromWorld(), RemoveObjectFromMapUpdateList(), and RemoveWorldObjectFromFarVisibleMap().

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

◆ RemoveFromMap() [2/2]

template<>
void Map::RemoveFromMap ( Transport obj,
bool  remove 
)
740{
741 obj->RemoveFromWorld();
742
743 Map::PlayerList const& players = GetPlayers();
744 if (!players.IsEmpty())
745 {
746 UpdateData data;
747 obj->BuildOutOfRangeUpdateBlock(&data);
748 WorldPacket packet;
749 data.BuildPacket(packet);
750 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
751 if (itr->GetSource()->GetTransport() != obj)
752 itr->GetSource()->SendDirectMessage(&packet);
753 }
754
756 {
757 TransportsContainer::iterator itr = _transports.find(obj);
758 if (itr == _transports.end())
759 return;
760 if (itr == _transportsUpdateIter)
762 _transports.erase(itr);
763 }
764 else
765 _transports.erase(obj);
766
767 obj->ResetMap();
768
770
771 if (remove)
772 {
773 // if option set then object already saved at this moment
774 if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
775 obj->SaveRespawnTime();
776 DeleteFromWorld(obj);
777 }
778}
@ 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
388{ _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)
2457{
2458 _goRespawnTimes.erase(spawnId);
2459
2461 stmt->SetData(0, spawnId);
2462 stmt->SetData(1, GetId());
2463 stmt->SetData(2, GetInstanceId());
2464 CharacterDatabase.Execute(stmt);
2465}
@ 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 ( )
2734{
2735 time_t now = GameTime::GetGameTime().count();
2736
2737 std::vector<ObjectGuid> corpses;
2738 corpses.reserve(_corpsesByPlayer.size());
2739
2740 for (auto const& p : _corpsesByPlayer)
2741 if (p.second->IsExpired(now))
2742 corpses.push_back(p.first);
2743
2744 for (ObjectGuid const& ownerGuid : corpses)
2745 ConvertCorpseToBones(ownerGuid);
2746
2747 std::vector<Corpse*> expiredBones;
2748 for (Corpse* bones : _corpseBones)
2749 if (bones->IsExpired(now))
2750 expiredBones.push_back(bones);
2751
2752 for (Corpse* bones : expiredBones)
2753 {
2754 RemoveCorpse(bones);
2755 delete bones;
2756 }
2757}
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.

696{
697 // Before leaving map, update zone/area for stats
698 player->UpdateZone(MAP_INVALID_ZONE, 0);
699 player->getHostileRefMgr().deleteReferences(true); // pussywizard: multithreading crashfix
700
701 player->RemoveFromWorld();
702 SendRemoveTransports(player);
703
704 if (player->IsInGrid())
705 player->RemoveFromGrid();
706 else
707 ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map
708
709 sScriptMgr->OnPlayerLeaveMap(this, player);
710 if (remove)
711 {
712 DeleteFromWorld(player);
713 }
714}
#define MAP_INVALID_ZONE
Definition Map.cpp:47
void deleteReferences(bool removeFromMap=false)
Definition HostileRefMgr.cpp:125
void SendRemoveTransports(Player *player)
Definition Map.cpp:1697
void UpdateZone(uint32 newZone, uint32 newArea, bool force=false)
Definition PlayerUpdates.cpp:1252
void RemoveFromWorld() override
Definition Player.cpp:1725
HostileRefMgr & getHostileRefMgr()
Definition Unit.h:904

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

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

◆ RemoveUpdateObject()

void Map::RemoveUpdateObject ( Object obj)
inline
482 {
483 _updateObjects.erase(obj);
484 }

References _updateObjects.

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

◆ RemoveWorldObjectFromFarVisibleMap()

void Map::RemoveWorldObjectFromFarVisibleMap ( WorldObject obj)
635{
636 if (Creature* creature = obj->ToCreature())
637 {
638 Cell curr_cell = creature->GetCurrentCell();
639 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
640 grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), creature);
641 }
642 else if (GameObject* go = obj->ToGameObject())
643 {
644 Cell curr_cell = go->GetCurrentCell();
645 MapGridType* grid = GetMapGrid(curr_cell.GridX(), curr_cell.GridY());
646 grid->RemoveFarVisibleObject(curr_cell.CellX(), curr_cell.CellY(), go);
647 }
648}
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(), RemoveFromMap(), and WorldObject::SetVisibilityDistanceOverride().

◆ RemoveWorldObjectFromZoneWideVisibleMap()

void Map::RemoveWorldObjectFromZoneWideVisibleMap ( uint32  zoneId,
WorldObject obj 
)
657{
658 ZoneWideVisibleWorldObjectsMap::iterator itr = _zoneWideVisibleWorldObjectsMap.find(zoneId);
659 if (itr == _zoneWideVisibleWorldObjectsMap.end())
660 return;
661
662 itr->second.erase(obj);
663}

References _zoneWideVisibleWorldObjectsMap.

Referenced by WorldObject::ProcessPositionDataChanged(), WorldObject::RemoveFromWorld(), and WorldObject::SetVisibilityDistanceOverride().

◆ resetMarkedCells()

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

References marked_cells.

Referenced by Update().

◆ SaveCreatureRespawnTime()

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

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 
)
2434{
2435 if (!respawnTime)
2436 {
2437 // Delete only
2438 RemoveGORespawnTime(spawnId);
2439 return;
2440 }
2441
2442 time_t now = GameTime::GetGameTime().count();
2443 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
2444 respawnTime = now + YEAR;
2445
2446 _goRespawnTimes[spawnId] = respawnTime;
2447
2449 stmt->SetData(0, spawnId);
2450 stmt->SetData(1, uint32(respawnTime));
2451 stmt->SetData(2, GetId());
2452 stmt->SetData(3, GetInstanceId());
2453 CharacterDatabase.Execute(stmt);
2454}
@ CHAR_REP_GO_RESPAWN
Definition CharacterDatabase.h:258
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition Map.cpp:2456

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() 
)
2760{
2761 _creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid, pos](TaskContext)
2762 {
2763 if (Creature* creature = GetCreature(creatureGuid))
2764 creature->Respawn();
2765 else
2766 SummonCreature(creatureGuid.GetEntry(), pos);
2767 });
2768}
TaskScheduler _creatureRespawnScheduler
Definition Map.h:430
Creature * GetCreature(ObjectGuid const guid)
Definition Map.cpp:2364
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:2140
uint32 GetEntry() const
Definition ObjectGuid.h:144
Definition TaskScheduler.h:421
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition TaskScheduler.h:232

References _creatureRespawnScheduler, GetCreature(), ObjectGuid::GetEntry(), TaskScheduler::Schedule(), 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:80
ObjectGuid targetGUID
Definition Map.h:82
ObjectGuid ownerGUID
Definition Map.h:83
ObjectGuid sourceGUID
Definition Map.h:81
ScriptInfo const * script
Definition Map.h:84

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);
445 unit->MonsterMoveWithSpeed(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, speed);
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(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()->MovementExpired();
884 cSource->GetMotionMaster()->MoveIdle();
885
886 switch (step.script->Movement.MovementType)
887 {
889 cSource->GetMotionMaster()->MoveRandom((float)step.script->Movement.MovementDistance);
890 break;
892 cSource->GetMotionMaster()->MovePath(step.script->Movement.Path, false);
893 break;
894 }
895 }
896 break;
897
898 default:
899 LOG_ERROR("maps.script", "Unknown script command {}.", step.script->GetDebugInfo());
900 break;
901 }
902
903 m_scriptSchedule.erase(iter);
904 iter = m_scriptSchedule.begin();
905 sScriptMgr->DecreaseScheduledScriptCount();
906 }
907}
@ 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
@ 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
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:767
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition ScriptedCreature.cpp:895
@ 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:78
bool isSpawned() const
Definition GameObject.h:189
void SetLootState(LootState s, Unit *unit=nullptr)
Definition GameObject.cpp:2423
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
Corpse * GetCorpse(ObjectGuid const guid)
Definition Map.cpp:2359
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
Creature * _GetScriptCreature(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:186
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
Pet * GetPet(ObjectGuid const guid)
Definition Map.cpp:2374
void _ScriptProcessDoor(Object *source, Object *target, const ScriptInfo *scriptInfo) const
Definition MapScripts.cpp:217
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
Transport * GetTransport(ObjectGuid const guid)
Definition Map.cpp:2379
void MovePath(uint32 path_id, bool repeatable)
Move the unit following a specific path. Doesn't work with UNIT_FLAG_DISABLE_MOVE.
Definition MotionMaster.cpp:887
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:5744
void FailQuest(uint32 quest_id)
Definition PlayerQuest.cpp:886
PlayerMenu * PlayerTalkClass
Definition Player.h:2250
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition Player.cpp:12758
void SetFacingTo(float ori)
Definition Unit.cpp:20369
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:20999
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition Unit.cpp:21004
MotionMaster * GetMotionMaster()
Definition Unit.h:1676
void SetFacingToObject(WorldObject *object)
Definition Unit.cpp:20379
void MonsterMoveWithSpeed(float x, float y, float z, float speed)
Definition Unit.cpp:531
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition Unit.cpp:21009
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:19809
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition Unit.cpp:21014
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition Object.cpp:1326
float GetDistance(WorldObject const *obj) const
Definition Object.cpp:1250
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition Object.cpp:2383
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, 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(), 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, Unit::MonsterMoveWithSpeed(), ScriptInfo::Movement, ScriptInfo::MovementDistance, ScriptInfo::MovementType, 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)
1633{
1634 LOG_DEBUG("maps", "Creating player data for himself {}", player->GetGUID().ToString());
1635
1636 WorldPacket packet;
1637 UpdateData data;
1638
1639 // attach to player data current transport data
1640 if (Transport* transport = player->GetTransport())
1641 transport->BuildCreateUpdateBlockForPlayer(&data, player);
1642
1643 // build data for self presence in world at own client (one time for map)
1644 player->BuildCreateUpdateBlockForPlayer(&data, player);
1645
1646 // build and send self update packet before sending to player his own auras
1647 data.BuildPacket(packet);
1648 player->SendDirectMessage(&packet);
1649
1650 // send to player his own auras (this is needed here for timely initialization of some fields on client)
1651 player->GetAurasForTarget(player, true);
1652
1653 // clean buffers for further work
1654 packet.clear();
1655 data.Clear();
1656
1657 // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map
1658 if (Transport* transport = player->GetTransport())
1659 for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
1660 if (player != (*itr) && player->HaveAtClient(*itr))
1661 (*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
1662
1663 data.BuildPacket(packet);
1664 player->SendDirectMessage(&packet);
1665}
void clear()
Definition ByteBuffer.h:122
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5728
bool HaveAtClient(WorldObject const *u) const
Definition Player.cpp:11448
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) override
Definition Player.cpp:3842
void GetAurasForTarget(Unit *target, bool force=false)
Definition Player.cpp:12087
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)
1679{
1680 if (_transports.empty())
1681 return;
1682
1683 // Hack to send out transports
1684 UpdateData transData;
1685 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1686 if (*itr != player->GetTransport())
1687 (*itr)->BuildCreateUpdateBlockForPlayer(&transData, player);
1688
1689 if (!transData.HasData())
1690 return;
1691
1692 WorldPacket packet;
1693 transData.BuildPacket(packet);
1694 player->GetSession()->SendPacket(&packet);
1695}
WorldSession * GetSession() const
Definition Player.h:2005
bool HasData() const
Definition UpdateData.h:60
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:251

References _transports, UpdateData::BuildPacket(), Player::GetSession(), WorldObject::GetTransport(), UpdateData::HasData(), and WorldSession::SendPacket().

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

◆ SendObjectUpdates()

void Map::SendObjectUpdates ( )
private
1717{
1718 UpdateDataMapType update_players;
1719
1720 while (!_updateObjects.empty())
1721 {
1722 Object* obj = *_updateObjects.begin();
1723 ASSERT(obj->IsInWorld());
1724
1725 _updateObjects.erase(_updateObjects.begin());
1726 obj->BuildUpdate(update_players);
1727 }
1728
1729 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
1730 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
1731 {
1732 iter->second.BuildPacket(packet);
1733 iter->first->GetSession()->SendPacket(&packet);
1734 packet.clear(); // clean the string
1735 }
1736}
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)
1698{
1699 if (_transports.empty())
1700 return;
1701
1702 // Hack to send out transports
1703 UpdateData transData;
1704 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
1705 if (*itr != player->GetTransport())
1706 (*itr)->BuildOutOfRangeUpdateBlock(&transData);
1707
1708 if (!transData.HasData())
1709 return;
1710
1711 WorldPacket packet;
1712 transData.BuildPacket(packet);
1713 player->GetSession()->SendPacket(&packet);
1714}

References _transports, UpdateData::BuildPacket(), Player::GetSession(), WorldObject::GetTransport(), UpdateData::HasData(), and WorldSession::SendPacket().

Referenced by RemovePlayerFromMap().

◆ SendToPlayers()

void Map::SendToPlayers ( WorldPacket const *  data) const
1851{
1852 for (MapRefMgr::const_iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1853 itr->GetSource()->GetSession()->SendPacket(data);
1854}

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

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

◆ SendZoneDynamicInfo()

void Map::SendZoneDynamicInfo ( Player player)
2771{
2772 uint32 zoneId = player->GetZoneId();
2773 ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
2774 if (itr == _zoneDynamicInfo.end())
2775 return;
2776
2777 if (uint32 music = itr->second.MusicId)
2778 player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
2779
2780 if (WeatherState weatherId = itr->second.WeatherId)
2781 {
2782 WorldPackets::Misc::Weather weather(weatherId, itr->second.WeatherGrade);
2783 player->SendDirectMessage(weather.Write());
2784 }
2785
2786 if (uint32 overrideLight = itr->second.OverrideLightId)
2787 {
2788 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 1);
2789 data << uint32(_defaultLight);
2790 data << uint32(overrideLight);
2791 data << uint32(itr->second.LightFadeInTime);
2792 player->SendDirectMessage(&data);
2793 }
2794}
ZoneDynamicInfoMap _zoneDynamicInfo
Definition Map.h:586
uint32 GetZoneId() const
Definition Object.cpp:3038
Definition MiscPackets.h:58
Definition MiscPackets.h:32
@ SMSG_OVERRIDE_LIGHT
Definition Opcodes.h:1072
WeatherState
Definition Weather.h:45

References _defaultLight, _zoneDynamicInfo, WorldObject::GetZoneId(), Player::SendDirectMessage(), SMSG_OVERRIDE_LIGHT, and WorldPackets::Misc::Weather::Write().

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

◆ SetVisibilityRange()

◆ SetZoneMusic()

void Map::SetZoneMusic ( uint32  zoneId,
uint32  musicId 
)

◆ SetZoneOverrideLight()

void Map::SetZoneOverrideLight ( uint32  zoneId,
uint32  lightId,
Milliseconds  fadeInTime 
)
2853{
2854 if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
2855 _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
2856
2857 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
2858 info.OverrideLightId = lightId;
2859 info.LightFadeInTime = static_cast<uint32>(fadeInTime.count());
2860 Map::PlayerList const& players = GetPlayers();
2861
2862 if (!players.IsEmpty())
2863 {
2864 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4);
2865 data << uint32(_defaultLight);
2866 data << uint32(lightId);
2867 data << uint32(static_cast<uint32>(fadeInTime.count()));
2868
2869 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2870 if (Player* player = itr->GetSource())
2871 if (player->GetZoneId() == zoneId)
2872 player->SendDirectMessage(&data);
2873 }
2874}
uint32 LightFadeInTime
Definition Map.h:138
uint32 OverrideLightId
Definition Map.h:137

References _defaultLight, _zoneDynamicInfo, MapRefMgr::begin(), MapRefMgr::end(), GetPlayers(), LinkedListHead::IsEmpty(), ZoneDynamicInfo::LightFadeInTime, ZoneDynamicInfo::OverrideLightId, and SMSG_OVERRIDE_LIGHT.

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

◆ SetZoneWeather()

void Map::SetZoneWeather ( uint32  zoneId,
WeatherState  weatherId,
float  weatherGrade 
)
2832{
2833 if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
2834 _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
2835
2836 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
2837 info.WeatherId = weatherId;
2838 info.WeatherGrade = weatherGrade;
2839 Map::PlayerList const& players = GetPlayers();
2840
2841 if (!players.IsEmpty())
2842 {
2843 WorldPackets::Misc::Weather weather(weatherId, weatherGrade);
2844
2845 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
2846 if (Player* player = itr->GetSource())
2847 if (player->GetZoneId() == zoneId)
2848 player->SendDirectMessage(weather.Write());
2849 }
2850}
WeatherState WeatherId
Definition Map.h:135
float WeatherGrade
Definition Map.h:136

References _zoneDynamicInfo, MapRefMgr::begin(), MapRefMgr::end(), GetPlayers(), LinkedListHead::IsEmpty(), ZoneDynamicInfo::WeatherGrade, ZoneDynamicInfo::WeatherId, and WorldPackets::Misc::Weather::Write().

Referenced by boss_the_lich_king::boss_the_lich_kingAI::DoAction(), boss_akilzon::SetWeather(), boss_the_lich_king::boss_the_lich_kingAI::SpellHitTarget(), and npc_tirion_fordring_tft::npc_tirion_fordringAI::UpdateAI().

◆ 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 
)
2141{
2142 uint32 mask = UNIT_MASK_SUMMON;
2143 if (properties)
2144 {
2145 switch (properties->Category)
2146 {
2148 mask = UNIT_MASK_GUARDIAN;
2149 break;
2151 mask = UNIT_MASK_PUPPET;
2152 break;
2154 mask = UNIT_MASK_MINION;
2155 break;
2159 {
2160 switch (properties->Type)
2161 {
2162 case SUMMON_TYPE_MINION:
2165 mask = UNIT_MASK_GUARDIAN;
2166 break;
2167 case SUMMON_TYPE_TOTEM:
2169 mask = UNIT_MASK_TOTEM;
2170 break;
2173 mask = UNIT_MASK_SUMMON;
2174 break;
2176 case SUMMON_TYPE_JEEVES:
2177 mask = UNIT_MASK_MINION;
2178 break;
2179 default:
2180 if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
2181 mask = UNIT_MASK_GUARDIAN;
2182 break;
2183 }
2184 break;
2185 }
2186 default:
2187 return nullptr;
2188 }
2189 }
2190
2192 if (summoner)
2193 phase = summoner->GetPhaseMask();
2194
2195 TempSummon* summon = nullptr;
2196 switch (mask)
2197 {
2198 case UNIT_MASK_SUMMON:
2199 summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2200 break;
2201 case UNIT_MASK_GUARDIAN:
2202 summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2203 break;
2204 case UNIT_MASK_PUPPET:
2205 summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2206 break;
2207 case UNIT_MASK_TOTEM:
2208 summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2209 break;
2210 case UNIT_MASK_MINION:
2211 summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2212 break;
2213 default:
2214 return nullptr;
2215 }
2216
2217 EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
2218 if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
2219 {
2220 delete summon;
2221 return nullptr;
2222 }
2223
2224 summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
2225
2226 summon->SetHomePosition(pos);
2227
2228 summon->InitStats(duration);
2229
2230 summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
2231
2232 bool summonerHasTransport = summoner && summoner->GetTransport();
2233 bool summonerIsVehicle = summoner && summoner->IsUnit() && summoner->ToUnit()->IsVehicle();
2234 bool checkTransport = summon->GetOwnerGUID().IsPlayer() || (summonerHasTransport && !summonerIsVehicle);
2235 if (!AddToMap(summon->ToCreature(), checkTransport))
2236 {
2237 delete summon;
2238 return nullptr;
2239 }
2240
2241 summon->InitSummon();
2242
2243 // call MoveInLineOfSight for nearby creatures
2244 Acore::AIRelocationNotifier notifier(*summon);
2245 Cell::VisitObjects(summon, notifier, GetVisibilityRange());
2246
2247 return summon;
2248}
@ 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:341
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:1136
Definition TemporarySummon.h:96
float GetVisibilityRange() const
Definition Map.h:192
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:668
void SetUInt32Value(uint16 index, uint32 value)
Definition Unit.cpp:21182
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_gundrak::instance_gundrak_InstanceMapScript::SetBossState(), 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.
2258{
2259 std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetId(), SUMMONER_TYPE_MAP, group);
2260 if (!data)
2261 return;
2262
2263 for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2264 if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, nullptr, itr->time))
2265 if (list)
2266 list->push_back(summon);
2267}
@ 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 
)
2282{
2283 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
2284 if (!goinfo)
2285 {
2286 LOG_ERROR("sql.sql", "Gameobject template {} not found in database!", entry);
2287 return nullptr;
2288 }
2289
2290 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
2291 if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
2292 {
2293 delete go;
2294 return nullptr;
2295 }
2296
2297 // Xinef: if gameobject is temporary, set custom spellid
2298 if (respawnTime)
2299 go->SetSpellId(1);
2300
2301 go->SetRespawnTime(respawnTime);
2302 go->SetSpawnedByDefault(false);
2303 AddToMap(go, checkTransport);
2304 return go;
2305}
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(), and instance_sunken_temple::instance_sunken_temple_InstanceMapScript::Update().

◆ 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 
)
2308{
2309 return SummonGameObject(entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), rotation0, rotation1, rotation2, rotation3, respawnTime, checkTransport);
2310}
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:2281

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

◆ ToBattlegroundMap() [1/2]

◆ ToBattlegroundMap() [2/2]

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

References IsBattlegroundOrArena().

◆ ToInstanceMap() [1/2]

◆ ToInstanceMap() [2/2]

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

References IsDungeon().

◆ ToMapInstanced() [1/2]

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

References Instanceable().

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

◆ ToMapInstanced() [2/2]

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

References Instanceable().

◆ UnloadAll()

void Map::UnloadAll ( )
virtual

Reimplemented in InstanceMap, and MapInstanced.

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

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)
1003{
1004 _mapGridManager.UnloadGrid(grid.GetX(), grid.GetY());
1005
1006 ASSERT(i_objectsToRemove.empty());
1007 LOG_DEBUG("maps", "Unloading grid[{}, {}] for map {} finished", grid.GetX(), grid.GetY(), GetId());
1008 return true;
1009}
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.

428{
429 if (t_diff)
430 _dynamicTree.update(t_diff);
431
432 // Update world sessions and players
434 {
435 Player* player = m_mapRefIter->GetSource();
436 if (player && player->IsInWorld())
437 {
438 // Update session
439 WorldSession* session = player->GetSession();
440 MapSessionFilter updater(session);
441 session->Update(s_diff, updater);
442
443 // update players at tick
444 if (!t_diff)
445 player->Update(s_diff);
446 }
447 }
448
450
451 if (!t_diff)
452 {
454 return;
455 }
456
459
460 // Update players
462 {
463 Player* player = m_mapRefIter->GetSource();
464
465 if (!player || !player->IsInWorld())
466 continue;
467
468 player->Update(s_diff);
469
471 {
472 MarkNearbyCellsOf(player);
473
474 // If player is using far sight, update viewpoint
475 if (WorldObject* viewPoint = player->GetViewpoint())
476 {
477 if (Creature* viewCreature = viewPoint->ToCreature())
478 MarkNearbyCellsOf(viewCreature);
479 else if (DynamicObject* viewObject = viewPoint->ToDynObject())
480 MarkNearbyCellsOf(viewObject);
481 }
482 }
483 }
484
486
488
490 if (!m_scriptSchedule.empty())
491 {
492 i_scriptLock = true;
494 i_scriptLock = false;
495 }
496
500
502
503 UpdateExpiredCorpses(t_diff);
504
505 sScriptMgr->OnMapUpdate(this, t_diff);
506
507 METRIC_VALUE("map_creatures", uint64(GetObjectsStore().Size<Creature>()),
508 METRIC_TAG("map_id", std::to_string(GetId())),
509 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
510
511 METRIC_VALUE("map_gameobjects", uint64(GetObjectsStore().Size<GameObject>()),
512 METRIC_TAG("map_id", std::to_string(GetId())),
513 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
514}
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:274
void HandleDelayedVisibility()
Definition Map.cpp:674
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:345
void MoveAllGameObjectsInMoveList()
Definition Map.cpp:938
void UpdateNonPlayerObjects(uint32 const diff)
Definition Map.cpp:516
void MarkNearbyCellsOf(WorldObject *obj)
Definition Map.cpp:391
void resetMarkedCells()
Definition Map.h:313
void MoveAllDynamicObjectsInMoveList()
Definition Map.cpp:973
void MoveAllCreaturesInMoveList()
Definition Map.cpp:904
MapRefMgr::iterator m_mapRefIter
Definition Map.h:546
void SendObjectUpdates()
Definition Map.cpp:1716
void UpdateExpiredCorpses(uint32 const diff)
Definition Map.cpp:1667
DynamicObject * ToDynObject()
Definition Object.h:222
void Update(uint32 time) override
Definition PlayerUpdates.cpp:53
WorldObject * GetViewpoint() const
Definition Player.cpp:13236
FROM * GetSource() const
Definition Reference.h:97
TaskScheduler & Update(success_t const &callback=EmptyCallback)
Definition TaskScheduler.cpp:27
Player session in the World.
Definition WorldSession.h:360
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update)
Definition WorldSession.cpp:326
bool Passed()
Definition Timer.h:161
void Update(time_t diff)
Definition Timer.h:152

References _creatureRespawnScheduler, _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(), TaskScheduler::Update(), IntervalTimer::Update(), DynamicMapTree::update(), WorldSession::Update(), Player::Update(), UpdateExpiredCorpses(), and UpdateNonPlayerObjects().

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

◆ UpdateEncounterState()

void Map::UpdateEncounterState ( EncounterCreditType  type,
uint32  creditEntry,
Unit source 
)
2522{
2523 Difficulty difficulty_fixed = (IsSharedDifficultyMap(GetId()) ? Difficulty(GetDifficulty() % 2) : GetDifficulty());
2524 DungeonEncounterList const* encounters;
2525 // 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.
2526 if ((GetId() == 631 || GetId() == 724) && IsHeroic())
2527 {
2528 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), !Is25ManRaid() ? RAID_DIFFICULTY_10MAN_NORMAL : RAID_DIFFICULTY_25MAN_NORMAL);
2529 }
2530 else
2531 {
2532 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), difficulty_fixed);
2533 }
2534
2535 if (!encounters)
2536 {
2537 return;
2538 }
2539
2540 uint32 dungeonId = 0;
2541 bool updated = false;
2542
2543 for (DungeonEncounterList::const_iterator itr = encounters->begin(); itr != encounters->end(); ++itr)
2544 {
2545 DungeonEncounter const* encounter = *itr;
2546 if (encounter->creditType == type && encounter->creditEntry == creditEntry)
2547 {
2548 if (source)
2549 if (InstanceScript* instanceScript = source->GetInstanceScript())
2550 {
2551 uint32 prevMask = instanceScript->GetCompletedEncounterMask();
2552 instanceScript->SetCompletedEncountersMask((1 << encounter->dbcEntry->encounterIndex) | instanceScript->GetCompletedEncounterMask(), true);
2553 if (prevMask != instanceScript->GetCompletedEncounterMask())
2554 updated = true;
2555 }
2556
2557 if (encounter->lastEncounterDungeon)
2558 {
2559 dungeonId = encounter->lastEncounterDungeon;
2560 break;
2561 }
2562 }
2563 }
2564
2565 // pussywizard:
2566 LogEncounterFinished(type, creditEntry);
2567
2568 sScriptMgr->OnAfterUpdateEncounterState(this, type, creditEntry, source, difficulty_fixed, encounters, dungeonId, updated);
2569
2570 if (dungeonId)
2571 {
2572 Map::PlayerList const& players = GetPlayers();
2573 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
2574 {
2575 if (Player* player = i->GetSource())
2576 if (Group* grp = player->GetGroup())
2577 if (grp->isLFGGroup())
2578 {
2579 sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, this);
2580 return;
2581 }
2582 }
2583 }
2584}
@ 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:297
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry)
Definition Map.cpp:2586
bool IsHeroic() const
Definition Map.h:296
InstanceScript * GetInstanceScript() const
Definition Object.cpp:1197
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)
1668{
1671 return;
1672
1674
1676}
void RemoveOldCorpses()
Definition Map.cpp:2733
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)
2394{
2395 if (m_mapRefIter == player->GetMapRef())
2397}
MapReference const * nocheck_prev() const
Definition MapReference.h:49
MapReference & GetMapRef()
Definition Player.h:2501

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

Referenced by Player::ResetMap().

◆ UpdateNonPlayerObjects()

void Map::UpdateNonPlayerObjects ( uint32 const  diff)
private
517{
521
523 {
524 for (uint32 i = 0; i < _updatableObjectList.size();)
525 {
527 if (!obj->IsInWorld())
528 {
529 ++i;
530 continue;
531 }
532
533 obj->Update(diff);
534
535 if (!obj->IsUpdateNeeded())
536 {
538 // Intentional no iteration here, obj is swapped with last element in
539 // _updatableObjectList so next loop will update that object at the same index
540 }
541 else
542 ++i;
543 }
545 }
546 else
547 {
548 for (uint32 i = 0; i < _updatableObjectList.size(); ++i)
549 {
551 if (!obj->IsInWorld())
552 continue;
553
554 obj->Update(diff);
555 }
556 }
557}
void _AddObjectToUpdateList(WorldObject *obj)
Definition Map.cpp:573
virtual bool IsUpdateNeeded()
Definition Object.cpp:3114
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 
)
411{
412 // Nothing to do if no change
413 if (oldZone == newZone)
414 return;
415
416 if (oldZone != MAP_INVALID_ZONE)
417 {
418 uint32& oldZoneCount = _zonePlayerCountMap[oldZone];
419 if (!oldZoneCount)
420 LOG_ERROR("maps", "A player left zone {} (went to {}) - but there were no players in the zone!", oldZone, newZone);
421 else
422 --oldZoneCount;
423 }
424 ++_zonePlayerCountMap[newZone];
425}

References _zonePlayerCountMap, LOG_ERROR, and MAP_INVALID_ZONE.

Referenced by Player::UpdateZone().

◆ Visit()

template<class T , class CONTAINER >
void Map::Visit ( const Cell cell,
TypeContainerVisitor< T, CONTAINER > &  visitor 
)
inline
682{
683 uint32 const grid_x = cell.GridX();
684 uint32 const grid_y = cell.GridY();
685
686 // If grid is not loaded, nothing to visit.
687 if (!IsGridLoaded(GridCoord(grid_x, grid_y)))
688 return;
689
690 GetMapGrid(grid_x, grid_y)->VisitCell(cell.CellX(), cell.CellY(), visitor);
691}
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

◆ _creatureRespawnScheduler

TaskScheduler Map::_creatureRespawnScheduler

Referenced by ScheduleCreatureRespawn(), and Update().

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

◆ _zoneDynamicInfo

◆ _zonePlayerCountMap

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

◆ _zoneWideVisibleWorldObjectsMap

◆ CreatureGroupHolder

◆ CustomData

DataMap Map::CustomData

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