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

#include "Map.h"

Inheritance diagram for Map:
GridRefMgr< NGridType > 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
 
- Public Types inherited from GridRefMgr< NGridType >
typedef LinkedListHead::Iterator< GridReference< NGridType > > iterator
 
- Public Types inherited from RefMgr< TO, FROM >
typedef LinkedListHead::Iterator< Reference< TO, FROM > > iterator
 
- Public Types inherited from LinkedListHead
typedef Iterator< LinkedListElementiterator
 

Public Member Functions

 Map (uint32 id, uint32 InstanceId, uint8 SpawnMode, Map *_parent=nullptr)
 
 ~Map () override
 
MapEntry const * GetEntry () const
 
bool CanUnload (uint32 diff)
 
virtual bool AddPlayerToMap (Player *)
 
virtual void RemovePlayerFromMap (Player *, bool)
 
virtual void AfterPlayerUnlinkFromMap ()
 
template<class T >
bool AddToMap (T *, bool checkTransport=false)
 
template<class T >
void RemoveFromMap (T *, bool)
 
void VisitNearbyCellsOf (WorldObject *obj, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &worldVisitor, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &largeGridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &largeWorldVisitor)
 
void VisitNearbyCellsOfPlayer (Player *player, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &worldVisitor, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &largeGridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &largeWorldVisitor)
 
virtual void Update (const uint32, const uint32, bool thread=true)
 
float GetVisibilityRange () const
 
void SetVisibilityRange (float range)
 
virtual void InitVisibilityDistance ()
 
void PlayerRelocation (Player *, float x, float y, float z, float o)
 
void CreatureRelocation (Creature *creature, float x, float y, float z, float o)
 
void GameObjectRelocation (GameObject *go, float x, float y, float z, float o)
 
void DynamicObjectRelocation (DynamicObject *go, float x, float y, float z, float o)
 
template<class T , class CONTAINER >
void Visit (const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
 
bool IsRemovalGrid (float x, float y) const
 
bool IsGridLoaded (float x, float y) const
 
void LoadGrid (float x, float y)
 
void LoadAllCells ()
 
bool UnloadGrid (NGridType &ngrid)
 
virtual void UnloadAll ()
 
uint32 GetId () const
 
Map const * GetParent () const
 
std::shared_mutex & GetMMapLock () const
 
void HandleDelayedVisibility ()
 
float GetHeight (float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
float GetGridHeight (float x, float y) const
 
float GetMinHeight (float x, float y) const
 
TransportGetTransportForPos (uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
 
void GetFullTerrainStatusForPosition (uint32 phaseMask, float x, float y, float z, float collisionHeight, PositionFullTerrainStatus &data, uint8 reqLiquidType=MAP_ALL_LIQUIDS)
 
LiquidData const GetLiquidData (uint32 phaseMask, float x, float y, float z, float collisionHeight, uint8 ReqLiquidType)
 
bool GetAreaInfo (uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
 
uint32 GetAreaId (uint32 phaseMask, float x, float y, float z) const
 
uint32 GetZoneId (uint32 phaseMask, float x, float y, float z) const
 
void GetZoneAndAreaId (uint32 phaseMask, uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
 
float GetWaterLevel (float x, float y) const
 
bool IsInWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
 
bool IsUnderWater (uint32 phaseMask, float x, float y, float z, float collisionHeight) const
 
bool HasEnoughWater (WorldObject const *searcher, float x, float y, float z) const
 
bool HasEnoughWater (WorldObject const *searcher, LiquidData const &liquidData) const
 
void MoveAllCreaturesInMoveList ()
 
void MoveAllGameObjectsInMoveList ()
 
void MoveAllDynamicObjectsInMoveList ()
 
void RemoveAllObjectsInRemoveList ()
 
virtual void RemoveAllPlayers ()
 
uint32 GetInstanceId () const
 
uint8 GetSpawnMode () const
 
virtual EnterState CannotEnter (Player *, bool)
 
const char * GetMapName () const
 
Difficulty GetDifficulty () const
 
bool IsRegularDifficulty () const
 
MapDifficulty const * GetMapDifficulty () const
 
bool Instanceable () const
 
bool IsDungeon () const
 
bool IsNonRaidDungeon () const
 
bool IsRaid () const
 
bool IsRaidOrHeroicDungeon () const
 
bool IsHeroic () const
 
bool Is25ManRaid () const
 
bool IsBattleground () const
 
bool IsBattleArena () const
 
bool IsBattlegroundOrArena () const
 
bool IsWorldMap () const
 
bool GetEntrancePos (int32 &mapid, float &x, float &y)
 
void AddObjectToRemoveList (WorldObject *obj)
 
void AddObjectToSwitchList (WorldObject *obj, bool on)
 
virtual void DelayedUpdate (const uint32 diff)
 
void resetMarkedCells ()
 
bool isCellMarked (uint32 pCellId)
 
void markCell (uint32 pCellId)
 
void resetMarkedCellsLarge ()
 
bool isCellMarkedLarge (uint32 pCellId)
 
void markCellLarge (uint32 pCellId)
 
bool HavePlayers () const
 
uint32 GetPlayersCountExceptGMs () const
 
void AddWorldObject (WorldObject *obj)
 
void RemoveWorldObject (WorldObject *obj)
 
void SendToPlayers (WorldPacket const *data) const
 
PlayerList const & GetPlayers () const
 
void ScriptsStart (std::map< uint32, std::multimap< uint32, ScriptInfo > > const &scripts, uint32 id, Object *source, Object *target)
 Put scripts in the execution queue. More...
 
void ScriptCommandStart (ScriptInfo const &script, uint32 delay, Object *source, Object *target)
 
template<class T >
void AddToActive (T *obj)
 
template<class T >
void RemoveFromActive (T *obj)
 
template<class T >
void SwitchGridContainers (T *obj, bool on)
 
void UpdateIteratorBack (Player *player)
 
TempSummonSummonCreature (uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, uint32 duration=0, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, bool visibleBySummonerOnly=false)
 
GameObjectSummonGameObject (uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime, bool checkTransport=true)
 
GameObjectSummonGameObject (uint32 entry, Position const &pos, float rotation0=0.0f, float rotation1=0.0f, float rotation2=0.0f, float rotation3=0.0f, uint32 respawnTime=100, bool checkTransport=true)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=nullptr)
 
CorpseGetCorpse (ObjectGuid const guid)
 
CreatureGetCreature (ObjectGuid const guid)
 
GameObjectGetGameObject (ObjectGuid const guid)
 
TransportGetTransport (ObjectGuid const guid)
 
DynamicObjectGetDynamicObject (ObjectGuid const guid)
 
PetGetPet (ObjectGuid const guid)
 
MapStoredObjectTypesContainerGetObjectsStore ()
 
CreatureBySpawnIdContainerGetCreatureBySpawnIdStore ()
 
GameObjectBySpawnIdContainerGetGameObjectBySpawnIdStore ()
 
std::unordered_set< Corpse * > const * GetCorpsesInCell (uint32 cellId) const
 
CorpseGetCorpseByPlayer (ObjectGuid const &ownerGuid) const
 
MapInstancedToMapInstanced ()
 
MapInstanced const * ToMapInstanced () const
 
InstanceMapToInstanceMap ()
 
InstanceMap const * ToInstanceMap () const
 
BattlegroundMapToBattlegroundMap ()
 
BattlegroundMap const * ToBattlegroundMap () const
 
float GetWaterOrGroundLevel (uint32 phasemask, float x, float y, float z, float *ground=nullptr, bool swim=false, float collisionHeight=DEFAULT_COLLISION_HEIGHT) const
 
float GetHeight (uint32 phasemask, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
bool isInLineOfSight (float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, PathGenerator *path, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 Check if a given source can reach a specific point following a path and normalize the coords. Use this method for long paths, otherwise use the overloaded method with the start coords when you need to do a quick check on small segments. More...
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 validate the new destination and set reachable coords Check if a given unit can reach a specific point on a segment and set the correct dest coords NOTE: use this method with small segments. More...
 
bool CanReachPositionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true, bool failOnSlopes=true) const
 
bool CheckCollisionAndGetValidCoords (WorldObject const *source, float startX, float startY, float startZ, float &destX, float &destY, float &destZ, bool failOnCollision=true) const
 validate the new destination and set coords Check if a given unit can face collisions in a specific segment More...
 
void Balance ()
 
void RemoveGameObjectModel (const GameObjectModel &model)
 
void InsertGameObjectModel (const GameObjectModel &model)
 
bool ContainsGameObjectModel (const GameObjectModel &model) const
 
DynamicMapTree const & GetDynamicMapTree () const
 
bool GetObjectHitPos (uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float &rx, float &ry, float &rz, float modifyDist)
 
float GetGameObjectFloor (uint32 phasemask, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
time_t GetLinkedRespawnTime (ObjectGuid guid) const
 
time_t GetCreatureRespawnTime (ObjectGuid::LowType dbGuid) const
 
time_t GetGORespawnTime (ObjectGuid::LowType dbGuid) const
 
void SaveCreatureRespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
 
void RemoveCreatureRespawnTime (ObjectGuid::LowType dbGuid)
 
void SaveGORespawnTime (ObjectGuid::LowType dbGuid, time_t &respawnTime)
 
void RemoveGORespawnTime (ObjectGuid::LowType dbGuid)
 
void LoadRespawnTimes ()
 
void DeleteRespawnTimes ()
 
time_t GetInstanceResetPeriod () const
 
void ScheduleCreatureRespawn (ObjectGuid, Milliseconds)
 
void LoadCorpseData ()
 
void DeleteCorpseData ()
 
void AddCorpse (Corpse *corpse)
 
void RemoveCorpse (Corpse *corpse)
 
CorpseConvertCorpseToBones (ObjectGuid const ownerGuid, bool insignia=false)
 
void RemoveOldCorpses ()
 
void SendInitTransports (Player *player)
 
void SendRemoveTransports (Player *player)
 
void SendZoneDynamicInfo (Player *player)
 
void SendInitSelf (Player *player)
 
void PlayDirectSoundToMap (uint32 soundId, uint32 zoneId=0)
 
void SetZoneMusic (uint32 zoneId, uint32 musicId)
 
void SetZoneWeather (uint32 zoneId, WeatherState weatherId, float weatherGrade)
 
void SetZoneOverrideLight (uint32 zoneId, uint32 lightId, Milliseconds fadeInTime)
 
void UpdateEncounterState (EncounterCreditType type, uint32 creditEntry, Unit *source)
 
void LogEncounterFinished (EncounterCreditType type, uint32 creditEntry)
 
void DoForAllPlayers (std::function< void(Player *)> exec)
 
GridMapGetGrid (float x, float y)
 
void EnsureGridCreated (const GridCoord &)
 
bool AllTransportsEmpty () const
 
void AllTransportsRemovePassengers ()
 
TransportsContainer const & GetAllTransports () const
 
template<HighGuid high>
ObjectGuid::LowType GenerateLowGuid ()
 
void AddUpdateObject (Object *obj)
 
void RemoveUpdateObject (Object *obj)
 
std::size_t GetActiveNonPlayersCount () const
 
virtual std::string GetDebugInfo () const
 
template<>
void AddToGrid (Creature *obj, Cell const &cell)
 
template<>
void AddToGrid (GameObject *obj, Cell const &cell)
 
template<>
void AddToGrid (DynamicObject *obj, Cell const &cell)
 
template<>
void AddToGrid (Corpse *obj, Cell const &cell)
 
template<>
void SwitchGridContainers (Creature *obj, bool on)
 
template<>
void SwitchGridContainers (GameObject *obj, bool on)
 
template<>
void DeleteFromWorld (Player *player)
 
template<>
void InitializeObject (Creature *)
 
template<>
void InitializeObject (GameObject *)
 
template<>
bool AddToMap (MotionTransport *obj, bool)
 
template<>
void RemoveFromMap (MotionTransport *obj, bool remove)
 
template<>
void AddToActive (Creature *c)
 
template<>
void AddToActive (DynamicObject *d)
 
template<>
void AddToActive (GameObject *d)
 
template<>
void RemoveFromActive (Creature *c)
 
template<>
void RemoveFromActive (DynamicObject *obj)
 
template<>
void RemoveFromActive (GameObject *obj)
 
- Public Member Functions inherited from GridRefMgr< NGridType >
GridReference< NGridType > * getFirst ()
 
GridReference< NGridType > * getLast ()
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
- Public Member Functions inherited from RefMgr< TO, FROM >
 RefMgr ()=default
 
virtual ~RefMgr ()
 
Reference< TO, FROM > * getFirst ()
 
Reference< TO, FROM > const * getFirst () const
 
Reference< TO, FROM > * getLast ()
 
Reference< TO, FROM > const * getLast () const
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
void clearReferences ()
 
- Public Member Functions inherited from LinkedListHead
 LinkedListHead ()
 
bool IsEmpty () const
 
LinkedListElementgetFirst ()
 
LinkedListElement const * getFirst () const
 
LinkedListElementgetLast ()
 
LinkedListElement const * getLast () const
 
void insertFirst (LinkedListElement *pElem)
 
void insertLast (LinkedListElement *pElem)
 
uint32 getSize () const
 
void incSize ()
 
void decSize ()
 

Static Public Member Functions

static bool ExistMap (uint32 mapid, int gx, int gy)
 
static bool ExistVMap (uint32 mapid, int gx, int gy)
 
static void DeleteRespawnTimesInDB (uint16 mapId, uint32 instanceId)
 

Public Attributes

std::unordered_set< Unit * > i_objectsForDelayedVisibility
 
CreatureGroupHolderType CreatureGroupHolder
 
TaskScheduler _creatureRespawnScheduler
 
DataMap CustomData
 

Protected Types

typedef std::set< WorldObject * > ActiveNonPlayers
 

Protected Attributes

std::mutex Lock
 
std::mutex GridLock
 
std::shared_mutex MMapLock
 
MapEntry const * i_mapEntry
 
uint8 i_spawnMode
 
uint32 i_InstanceId
 
uint32 m_unloadTimer
 
float m_VisibleDistance
 
DynamicMapTree _dynamicTree
 
time_t _instanceResetPeriod
 
MapRefMgr m_mapRefMgr
 
MapRefMgr::iterator m_mapRefIter
 
ActiveNonPlayers m_activeNonPlayers
 
ActiveNonPlayers::iterator m_activeNonPlayersIter
 
TransportsContainer _transports
 
TransportsContainer::iterator _transportsUpdateIter
 

Private Types

typedef std::multimap< time_t, ScriptActionScriptScheduleMap
 

Private Member Functions

void LoadMapAndVMap (int gx, int gy)
 
void LoadVMap (int gx, int gy)
 
void LoadMap (int gx, int gy, bool reload=false)
 
void LoadMMap (int gx, int gy)
 
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 IsGridLoaded (const GridCoord &) const
 
void EnsureGridCreated_i (const GridCoord &)
 
void buildNGridLinkage (NGridType *pNGridType)
 
NGridTypegetNGrid (uint32 x, uint32 y) const
 
bool EnsureGridLoaded (Cell const &)
 
bool isGridObjectDataLoaded (uint32 x, uint32 y) const
 
void setGridObjectDataLoaded (bool pLoaded, uint32 x, uint32 y)
 
void setNGrid (NGridType *grid, uint32 x, uint32 y)
 
void ScriptsProcess ()
 Process queued scripts. More...
 
void UpdateActiveCells (const float &x, const float &y, const uint32 t_diff)
 
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 AddToGrid (T *object, Cell const &cell)
 
template<class T >
void DeleteFromWorld (T *)
 
void AddToActiveHelper (WorldObject *obj)
 
void RemoveFromActiveHelper (WorldObject *obj)
 
template<HighGuid high>
ObjectGuidGeneratorBaseGetGuidSequenceGenerator ()
 

Private Attributes

std::vector< Creature * > _creaturesToMove
 
std::vector< GameObject * > _gameObjectsToMove
 
std::vector< DynamicObject * > _dynamicObjectsToMove
 
Mapm_parentMap
 
NGridTypei_grids [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
GridMapGridMaps [MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
 
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAPmarked_cells
 
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAPmarked_cells_large
 
bool i_scriptLock
 
std::unordered_set< WorldObject * > i_objectsToRemove
 
std::map< WorldObject *, bool > i_objectsToSwitch
 
std::unordered_set< WorldObject * > i_worldObjects
 
ScriptScheduleMap m_scriptSchedule
 
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
 
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
 
ZoneDynamicInfoMap _zoneDynamicInfo
 
uint32 _defaultLight
 
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
 
MapStoredObjectTypesContainer _objectsStore
 
CreatureBySpawnIdContainer _creatureBySpawnIdStore
 
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
 
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
 
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
 
std::unordered_set< Corpse * > _corpseBones
 
std::unordered_set< Object * > _updateObjects
 

Friends

class MapReference
 

Detailed Description

Member Typedef Documentation

◆ ActiveNonPlayers

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

◆ CreatureBySpawnIdContainer

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

◆ GameObjectBySpawnIdContainer

◆ PlayerList

◆ ScriptScheduleMap

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

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 
421 {
422 CAN_ENTER = 0,
423 CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
424 CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
425 CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
426 CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
427 CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
428 CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
429 CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
430 CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
431 CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
432 CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
434 };
@ CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE
Definition: Map.h:428
@ CANNOT_ENTER_TOO_MANY_INSTANCES
Definition: Map.h:430
@ CANNOT_ENTER_MAX_PLAYERS
Definition: Map.h:431
@ CANNOT_ENTER_ZONE_IN_COMBAT
Definition: Map.h:432
@ CAN_ENTER
Definition: Map.h:422
@ CANNOT_ENTER_ALREADY_IN_MAP
Definition: Map.h:423
@ CANNOT_ENTER_UNSPECIFIED_REASON
Definition: Map.h:433
@ CANNOT_ENTER_NO_ENTRY
Definition: Map.h:424
@ CANNOT_ENTER_DIFFICULTY_UNAVAILABLE
Definition: Map.h:426
@ CANNOT_ENTER_INSTANCE_BIND_MISMATCH
Definition: Map.h:429
@ CANNOT_ENTER_UNINSTANCED_DUNGEON
Definition: Map.h:425
@ CANNOT_ENTER_NOT_IN_RAID
Definition: Map.h:427

Constructor & Destructor Documentation

◆ Map()

Map::Map ( uint32  id,
uint32  InstanceId,
uint8  SpawnMode,
Map _parent = nullptr 
)
238 :
239 i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
243{
244 m_parentMap = (_parent ? _parent : this);
245 for (unsigned int idx = 0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
246 {
247 for (unsigned int j = 0; j < MAX_NUMBER_OF_GRIDS; ++j)
248 {
249 //z code
250 GridMaps[idx][j] = nullptr;
251 setNGrid(nullptr, idx, j);
252 }
253 }
254
255 //lets initialize visibility distance for map
257
258 sScriptMgr->OnCreateMap(this);
259}
#define MAX_NUMBER_OF_GRIDS
Definition: MapDefines.h:24
#define DEFAULT_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:40
uint32 GetDefaultMapLight(uint32 mapId)
Definition: DBCStores.cpp:880
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
#define sScriptMgr
Definition: ScriptMgr.h:709
MapEntry const * i_mapEntry
Definition: Map.h:706
uint8 i_spawnMode
Definition: Map.h:707
TransportsContainer::iterator _transportsUpdateIter
Definition: Map.h:723
uint32 m_unloadTimer
Definition: Map.h:709
uint32 _defaultLight
Definition: Map.h:784
Map * m_parentMap
Definition: Map.h:737
bool i_scriptLock
Definition: Map.h:744
time_t _instanceResetPeriod
Definition: Map.h:712
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:718
float m_VisibleDistance
Definition: Map.h:710
virtual void InitVisibilityDistance()
Definition: Map.cpp:261
TransportsContainer _transports
Definition: Map.h:722
uint32 i_InstanceId
Definition: Map.h:708
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition: Map.h:719
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:740
void setNGrid(NGridType *grid, uint32 x, uint32 y)
Definition: Map.cpp:2605

References GridMaps, InitVisibilityDistance(), m_parentMap, MAX_NUMBER_OF_GRIDS, setNGrid(), and sScriptMgr.

◆ ~Map()

Map::~Map ( )
override
66{
67 // UnloadAll must be called before deleting the map
68
69 sScriptMgr->OnDestroyMap(this);
70
71 while (!i_worldObjects.empty())
72 {
73 WorldObject* obj = *i_worldObjects.begin();
74 ASSERT(obj->IsWorldObject());
75 LOG_DEBUG("maps", "Map::~Map: WorldObject TypeId is not a corpse! ({})", static_cast<uint8>(obj->GetTypeId()));
76 //ASSERT(obj->IsCorpse());
77 obj->RemoveFromWorld();
78 obj->ResetMap();
79 }
80
81 if (!m_scriptSchedule.empty())
82 sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
83
84 //MMAP::MMapFactory::createOrGetMMapMgr()->unloadMap(GetId());
86}
#define ASSERT
Definition: Errors.h:68
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
std::uint8_t uint8
Definition: Define.h:109
static MMapMgr * createOrGetMMapMgr()
Definition: MMapFactory.cpp:27
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
Definition: MMapMgr.cpp:279
TypeID GetTypeId() const
Definition: Object.h:127
Definition: Object.h:410
virtual void ResetMap()
Definition: Object.cpp:2142
bool IsWorldObject() const
Definition: Object.cpp:1083
void RemoveFromWorld() override
Definition: Object.cpp:1193
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:750
uint32 GetId() const
Definition: Map.h:377
std::unordered_set< WorldObject * > i_worldObjects
Definition: Map.h:747

References ASSERT, MMAP::MMapFactory::createOrGetMMapMgr(), GetId(), Object::GetTypeId(), i_InstanceId, i_worldObjects, WorldObject::IsWorldObject(), LOG_DEBUG, m_scriptSchedule, WorldObject::RemoveFromWorld(), WorldObject::ResetMap(), sScriptMgr, and MMAP::MMapMgr::unloadMapInstance().

Member Function Documentation

◆ _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:157
Definition: Creature.h:43
Creature * ToCreature()
Definition: Object.h:205
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
std::string ToString() const
Definition: ObjectGuid.cpp:47
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}
uint32 GetEntry() const
Definition: Object.h:115

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:201
Definition: Player.h:1081

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:208
Unit * ToUnit()
Definition: Object.h:209
Definition: Unit.h:630

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}

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

Referenced by ScriptsProcess().

◆ _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
@ GAMEOBJECT_TYPE_BUTTON
Definition: SharedDefines.h:1561
@ GAMEOBJECT_TYPE_DOOR
Definition: SharedDefines.h:1560
@ SCRIPT_COMMAND_CLOSE_DOOR
Definition: ObjectMgr.h:104
@ SCRIPT_COMMAND_OPEN_DOOR
Definition: ObjectMgr.h:103
@ GO_STATE_READY
Definition: GameObjectData.h:690
@ TYPEMASK_GAMEOBJECT
Definition: ObjectGuid.h:51
Definition: GameObject.h:120
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
Definition: GameObject.cpp:1431
GOState GetGoState() const
Definition: GameObject.h:205
GameobjectTypes GetGoType() const
Definition: GameObject.h:203
bool isType(uint16 mask) const
Definition: Object.h:128
GameObject * ToGameObject()
Definition: Object.h:213
uint32 LowType
Definition: ObjectGuid.h:122
ScriptCommands command
Definition: ObjectMgr.h:194
uint32 ResetDelay
Definition: ObjectMgr.h:287
struct ScriptInfo::@265::@278 ToggleDoor
uint32 GOGuid
Definition: ObjectMgr.h:267
GameObject * _FindGameObject(WorldObject *pWorldObject, ObjectGuid::LowType guid) const
Definition: MapScripts.cpp:267

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)
3601{
3602 corpse->SetMap(this);
3603
3604 _corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse);
3605 if (corpse->GetType() != CORPSE_BONES)
3606 _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
3607 else
3608 _corpseBones.insert(corpse);
3609}
@ CORPSE_BONES
Definition: Corpse.h:28
ObjectGuid GetOwnerGUID() const
Definition: Corpse.h:68
CellCoord const & GetCellCoord() const
Definition: Corpse.h:74
CorpseType GetType() const
Definition: Corpse.h:72
virtual void SetMap(Map *map)
Definition: Object.cpp:2116
uint32 GetId() const
Definition: GridDefines.h:147
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:801
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:800
std::unordered_set< Corpse * > _corpseBones
Definition: Map.h:802

References _corpseBones, _corpsesByCell, _corpsesByPlayer, CORPSE_BONES, Corpse::GetCellCoord(), CoordPair< LIMIT >::GetId(), Corpse::GetOwnerGUID(), Corpse::GetType(), and WorldObject::SetMap().

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

◆ AddCreatureToMoveList()

void Map::AddCreatureToMoveList ( Creature c)
private
1089{
1091 _creaturesToMove.push_back(c);
1093}
@ MAP_OBJECT_CELL_MOVE_ACTIVE
Definition: Object.h:388
@ MAP_OBJECT_CELL_MOVE_NONE
Definition: Object.h:387
MapObjectCellMoveState _moveState
Definition: Object.h:406
std::vector< Creature * > _creaturesToMove
Definition: Map.h:675

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
1115{
1116 if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1117 _dynamicObjectsToMove.push_back(dynObj);
1118 dynObj->_moveState = MAP_OBJECT_CELL_MOVE_ACTIVE;
1119}
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition: Map.h:677

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
1102{
1104 _gameObjectsToMove.push_back(go);
1106}
std::vector< GameObject * > _gameObjectsToMove
Definition: Map.h:676

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

Referenced by GameObjectRelocation().

◆ AddObjectToRemoveList()

void Map::AddObjectToRemoveList ( WorldObject obj)
2655{
2656 ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
2657
2658 obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
2659
2660 i_objectsToRemove.insert(obj);
2661 //LOG_DEBUG("maps", "Object ({}) added to removing list.", obj->GetGUID().ToString());
2662}
uint32 GetInstanceId() const
Definition: Object.h:448
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition: Object.cpp:1142
uint32 GetMapId() const
Definition: Position.h:275
std::unordered_set< WorldObject * > i_objectsToRemove
Definition: Map.h:745
uint32 GetInstanceId() const
Definition: Map.h:417

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

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

◆ AddObjectToSwitchList()

void Map::AddObjectToSwitchList ( WorldObject obj,
bool  on 
)
2665{
2666 ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
2667 // i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses
2668 // the contained objects only if IsCreature() , so we can return in all other cases
2669 if (!obj->IsCreature() && !obj->IsGameObject())
2670 return;
2671
2672 std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj);
2673 if (itr == i_objectsToSwitch.end())
2674 i_objectsToSwitch.insert(itr, std::make_pair(obj, on));
2675 else if (itr->second != on)
2676 i_objectsToSwitch.erase(itr);
2677 else
2678 ABORT();
2679}
#define ABORT
Definition: Errors.h:76
bool IsGameObject() const
Definition: Object.h:212
bool IsCreature() const
Definition: Object.h:204
std::map< WorldObject *, bool > i_objectsToSwitch
Definition: Map.h:746

References ABORT, ASSERT, GetId(), WorldObject::GetInstanceId(), GetInstanceId(), WorldLocation::GetMapId(), i_objectsToSwitch, Object::IsCreature(), and Object::IsGameObject().

Referenced by WorldObject::SetWorldObject().

◆ AddPlayerToMap()

bool Map::AddPlayerToMap ( Player player)
virtual

Reimplemented in InstanceMap, and BattlegroundMap.

508{
509 CellCoord cellCoord = Acore::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
510 if (!cellCoord.IsCoordValid())
511 {
512 LOG_ERROR("maps", "Map::Add: Player ({}) has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
513 player->GetGUID().ToString(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
514 return false;
515 }
516
517 Cell cell(cellCoord);
518 EnsureGridLoaded(cell);
519 AddToGrid(player, cell);
520
521 // Check if we are adding to correct map
522 ASSERT (player->GetMap() == this);
523 player->SetMap(this);
524 player->AddToWorld();
525
526 SendInitTransports(player);
527 SendInitSelf(player);
528 SendZoneDynamicInfo(player);
529
530 player->m_clientGUIDs.clear();
531 player->UpdateObjectVisibility(false);
532
533 if (player->IsAlive())
534 ConvertCorpseToBones(player->GetGUID());
535
536 sScriptMgr->OnPlayerEnterMap(this, player);
537 return true;
538}
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:190
Map * GetMap() const
Definition: Object.h:536
float GetPositionX() const
Definition: Position.h:116
float GetPositionY() const
Definition: Position.h:117
GuidUnorderedSet m_clientGUIDs
Definition: Player.h:2381
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition: PlayerUpdates.cpp:1571
void AddToWorld() override
Definition: Player.cpp:1702
void SetMap(Map *map) override
Definition: Player.cpp:14707
bool IsAlive() const
Definition: Unit.h:1654
Definition: Cell.h:45
bool IsCoordValid() const
Definition: GridDefines.h:135
uint32 x_coord
Definition: GridDefines.h:152
uint32 y_coord
Definition: GridDefines.h:153
void SendZoneDynamicInfo(Player *player)
Definition: Map.cpp:3721
void SendInitSelf(Player *player)
Definition: Map.cpp:2532
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:279
void SendInitTransports(Player *player)
Definition: Map.cpp:2567
bool EnsureGridLoaded(Cell const &)
Definition: Map.cpp:470
Corpse * ConvertCorpseToBones(ObjectGuid const ownerGuid, bool insignia=false)
Definition: Map.cpp:3631

References AddToGrid(), Player::AddToWorld(), ASSERT, Acore::ComputeCellCoord(), ConvertCorpseToBones(), EnsureGridLoaded(), Object::GetGUID(), WorldObject::GetMap(), Position::GetPositionX(), Position::GetPositionY(), Unit::IsAlive(), CoordPair< LIMIT >::IsCoordValid(), LOG_ERROR, Player::m_clientGUIDs, 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().

◆ AddToActive() [1/4]

template<>
void Map::AddToActive ( Creature c)
2771{
2773}
void AddToActiveHelper(WorldObject *obj)
Definition: Map.h:759

References AddToActiveHelper().

◆ AddToActive() [2/4]

template<>
void Map::AddToActive ( DynamicObject d)
2777{
2779}

References AddToActiveHelper().

◆ AddToActive() [3/4]

template<>
void Map::AddToActive ( GameObject d)
2783{
2785}

References AddToActiveHelper().

◆ AddToActive() [4/4]

template<class T >
void Map::AddToActive ( T *  obj)
2765{
2766 AddToActiveHelper(obj);
2767}

References AddToActiveHelper().

Referenced by AddObjectHelper(), AddToMap(), and WorldObject::setActive().

◆ AddToActiveHelper()

void Map::AddToActiveHelper ( WorldObject obj)
inlineprivate
760 {
761 m_activeNonPlayers.insert(obj);
762 }

References m_activeNonPlayers.

Referenced by AddToActive().

◆ AddToGrid() [1/5]

template<>
void Map::AddToGrid ( Corpse obj,
Cell const &  cell 
)
323{
324 NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
325 // Corpses are a special object type - they can be added to grid via a call to AddToMap
326 // or loaded through ObjectGridLoader.
327 // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
328 // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
329 // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
330 // to avoid failing an assertion in GridObject::AddToGrid
331 if (grid->isGridObjectDataLoaded())
332 {
333 if (obj->IsWorldObject())
334 grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
335 else
336 grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
337 }
338}
void AddWorldObject(SPECIFIC_OBJECT *obj)
Definition: Grid.h:57
void AddGridObject(SPECIFIC_OBJECT *obj)
Definition: Grid.h:101
Definition: NGrid.h:36
bool isGridObjectDataLoaded() const
Definition: NGrid.h:64
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:44
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:684

References Grid< ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddGridObject(), Grid< ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddWorldObject(), Cell::CellX(), Cell::CellY(), NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetGridType(), getNGrid(), Cell::GridX(), Cell::GridY(), NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::isGridObjectDataLoaded(), and WorldObject::IsWorldObject().

◆ AddToGrid() [2/5]

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

◆ AddToGrid() [3/5]

◆ AddToGrid() [4/5]

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

◆ AddToGrid() [5/5]

template<class T >
void Map::AddToGrid ( T *  object,
Cell const &  cell 
)
private
280{
281 NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
282 if (obj->IsWorldObject())
283 grid->GetGridType(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj);
284 else
285 grid->GetGridType(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj);
286}

References Cell::CellX(), Cell::CellY(), NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetGridType(), getNGrid(), Cell::GridX(), and Cell::GridY().

Referenced by AddPlayerToMap(), AddToMap(), MoveAllCreaturesInMoveList(), MoveAllDynamicObjectsInMoveList(), MoveAllGameObjectsInMoveList(), and PlayerRelocation().

◆ AddToMap() [1/2]

template<>
bool Map::AddToMap ( MotionTransport obj,
bool   
)
616{
617 //TODO: Needs clean up. An object should not be added to map twice.
618 if (obj->IsInWorld())
619 return true;
620
622 if (!cellCoord.IsCoordValid())
623 {
624 LOG_ERROR("maps", "Map::Add: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
625 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
626 return false; //Should delete object
627 }
628
629 Cell cell(cellCoord);
630 if (obj->isActiveObject())
631 EnsureGridLoaded(cell);
632
633 obj->AddToWorld();
634
635 if (obj->isActiveObject())
636 AddToActive(obj);
637
638 _transports.insert(obj);
639
640 // Broadcast creation to players
641 if (!GetPlayers().IsEmpty())
642 {
643 for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
644 {
645 if (itr->GetSource()->GetTransport() != obj)
646 {
647 UpdateData data;
648 obj->BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
649 WorldPacket packet;
650 data.BuildPacket(packet);
651 itr->GetSource()->SendDirectMessage(&packet);
652 }
653 }
654 }
655
656 return true;
657}
bool IsEmpty() const
Definition: LinkedList.h:97
Definition: LinkedList.h:139
void AddToWorld() override
Definition: GameObject.cpp:140
bool IsInWorld() const
Definition: Object.h:107
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target)
Definition: Object.cpp:189
bool isActiveObject() const
Definition: Object.h:579
Definition: UpdateData.h:52
bool BuildPacket(WorldPacket &packet)
Definition: UpdateData.cpp:48
iterator begin()
Definition: GridRefMgr.h:35
void AddToActive(T *obj)
Definition: Map.cpp:2764
PlayerList const & GetPlayers() const
Definition: Map.h:484
iterator end()
Definition: MapRefMgr.h:37
Definition: WorldPacket.h:26

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

◆ AddToMap() [2/2]

template<class T >
bool Map::AddToMap ( T *  obj,
bool  checkTransport = false 
)
559{
560 //TODO: Needs clean up. An object should not be added to map twice.
561 if (obj->IsInWorld())
562 {
563 ASSERT(obj->IsInGrid());
564 obj->UpdateObjectVisibility(true);
565 return true;
566 }
567
568 CellCoord cellCoord = Acore::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
569 //It will create many problems (including crashes) if an object is not added to grid after creation
570 //The correct way to fix it is to make AddToMap return false and delete the object if it is not added to grid
571 //But now AddToMap is used in too many places, I will just see how many ASSERT failures it will cause
572 ASSERT(cellCoord.IsCoordValid());
573 if (!cellCoord.IsCoordValid())
574 {
575 LOG_ERROR("maps", "Map::AddToMap: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
576 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
577 return false; //Should delete object
578 }
579
580 Cell cell(cellCoord);
581 if (obj->isActiveObject())
582 EnsureGridLoaded(cell);
583 else
584 EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
585
586 AddToGrid(obj, cell);
587
588 //Must already be set before AddToMap. Usually during obj->Create.
589 //obj->SetMap(this);
590 obj->AddToWorld();
591
592 if (checkTransport)
593 if (!(obj->IsGameObject() && obj->ToGameObject()->IsTransport())) // dont add transport to transport ;d
594 if (Transport* transport = GetTransportForPos(obj->GetPhaseMask(), obj->GetPositionX(), obj->GetPositionY(), obj->GetPositionZ(), obj))
595 transport->AddPassenger(obj, true);
596
597 InitializeObject(obj);
598
599 if (obj->isActiveObject())
600 AddToActive(obj);
601
602 //something, such as vehicle, needs to be update immediately
603 //also, trigger needs to cast spell, if not update, cannot see visual
604 obj->UpdateObjectVisibility(true);
605
606 // 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
607 // Initialize vehicle, this is done only for summoned npcs, DB creatures are handled by grid loaders
608 if (obj->IsCreature())
609 if (Vehicle* vehicle = obj->ToCreature()->GetVehicleKit())
610 vehicle->Reset();
611 return true;
612}
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:168
Definition: Transport.h:29
Definition: Vehicle.h:28
void InitializeObject(T *obj)
Definition: Map.cpp:541
Transport * GetTransportForPos(uint32 phase, float x, float y, float z, WorldObject *worldobject=nullptr)
Definition: Map.cpp:2016
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:435

References AddToActive(), 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(), 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(), PoolGroup< T >::Spawn1Object(), Battlefield::SpawnCreature(), Battlefield::SpawnGameObject(), SummonCreature(), SummonGameObject(), WorldObject::SummonGameObject(), Player::SummonPet(), and GameObject::Update().

◆ AddUpdateObject()

void Map::AddUpdateObject ( Object obj)
inline
643 {
644 _updateObjects.insert(obj);
645 }
std::unordered_set< Object * > _updateObjects
Definition: Map.h:804

References _updateObjects.

Referenced by WorldObject::AddToObjectUpdate().

◆ AddWorldObject()

void Map::AddWorldObject ( WorldObject obj)
inline
478{ i_worldObjects.insert(obj); }

References i_worldObjects.

Referenced by WorldObject::SetMap(), and SwitchGridContainers().

◆ AfterPlayerUnlinkFromMap()

void Map::AfterPlayerUnlinkFromMap ( )
virtual

◆ AllTransportsEmpty()

bool Map::AllTransportsEmpty ( ) const
3569{
3570 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
3571 if (!(*itr)->GetPassengers().empty())
3572 return false;
3573
3574 return true;
3575}

References _transports.

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

◆ AllTransportsRemovePassengers()

void Map::AllTransportsRemovePassengers ( )
3578{
3579 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
3580 while (!(*itr)->GetPassengers().empty())
3581 (*itr)->RemovePassenger(*((*itr)->GetPassengers().begin()), true);
3582}

References _transports.

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

◆ Balance()

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

References _dynamicTree, and DynamicMapTree::balance().

Referenced by EnsureGridLoaded().

◆ buildNGridLinkage()

void Map::buildNGridLinkage ( NGridType pNGridType)
inlineprivate
682{ pNGridType->link(this); }
void link(GridRefMgr< NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES > > *pTo)
Definition: NGrid.h:60

References NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::link().

Referenced by EnsureGridCreated_i().

◆ 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
3885{
3886 return CanReachPositionAndGetValidCoords(source, source->GetPositionX(), source->GetPositionY(), source->GetPositionZ(), destX, destY, destZ, failOnCollision, failOnSlopes);
3887}
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:3844

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
3890{
3891 if (!CheckCollisionAndGetValidCoords(source, startX, startY, startZ, destX, destY, destZ, failOnCollision))
3892 {
3893 return false;
3894 }
3895
3896 Unit const* unit = source->ToUnit();
3897 // if it's not an unit (Object) then we do not have to continue
3898 // with walkable checks
3899 if (!unit)
3900 {
3901 return true;
3902 }
3903
3904 /*
3905 * Walkable checks
3906 */
3907 bool isWaterNext = HasEnoughWater(unit, destX, destY, destZ);
3908 Creature const* creature = unit->ToCreature();
3909 bool cannotEnterWater = isWaterNext && (creature && !creature->CanEnterWater());
3910 bool cannotWalkOrFly = !isWaterNext && !source->ToPlayer() && !unit->CanFly() && (creature && !creature->CanWalk());
3911 if (cannotEnterWater || cannotWalkOrFly ||
3912 (failOnSlopes && !PathGenerator::IsWalkableClimb(startX, startY, startZ, destX, destY, destZ, source->GetCollisionHeight())))
3913 {
3914 return false;
3915 }
3916
3917 return true;
3918}
bool CanWalk() const
Definition: Creature.h:78
bool CanEnterWater() const override
Definition: Creature.cpp:3271
virtual bool CanFly() const =0
bool HasEnoughWater(WorldObject const *searcher, float x, float y, float z) const
Definition: Map.cpp:2515
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:3927
bool IsWalkableClimb(float const *v1, float const *v2) const
Definition: PathGenerator.cpp:951

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.

3845{
3846 G3D::Vector3 prevPath = path->GetStartPosition();
3847 for (auto& vector : path->GetPath())
3848 {
3849 float x = vector.x;
3850 float y = vector.y;
3851 float z = vector.z;
3852
3853 if (!CanReachPositionAndGetValidCoords(source, prevPath.x, prevPath.y, prevPath.z, x, y, z, failOnCollision, failOnSlopes))
3854 {
3855 destX = x;
3856 destY = y;
3857 destZ = z;
3858 return false;
3859 }
3860
3861 prevPath = vector;
3862 }
3863
3864 destX = prevPath.x;
3865 destY = prevPath.y;
3866 destZ = prevPath.z;
3867
3868 return true;
3869}
Movement::PointsArray const & GetPath() const
Definition: PathGenerator.h:90
G3D::Vector3 const & GetStartPosition() const
Definition: PathGenerator.h:86

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

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

◆ CanUnload()

bool Map::CanUnload ( uint32  diff)
inline
321 {
322 if (!m_unloadTimer)
323 return false;
324
325 if (m_unloadTimer <= diff)
326 return true;
327
328 m_unloadTimer -= diff;
329 return false;
330 }

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
3928{
3929 // Prevent invalid coordinates here, position is unchanged
3930 if (!Acore::IsValidMapCoord(startX, startY, startZ) || !Acore::IsValidMapCoord(destX, destY, destZ))
3931 {
3932 LOG_FATAL("maps", "Map::CheckCollisionAndGetValidCoords invalid coordinates startX: {}, startY: {}, startZ: {}, destX: {}, destY: {}, destZ: {}", startX, startY, startZ, destX, destY, destZ);
3933 return false;
3934 }
3935
3936 bool isWaterNext = IsInWater(source->GetPhaseMask(), destX, destY, destZ, source->GetCollisionHeight());
3937
3938 PathGenerator path(source);
3939
3940 // Use a detour raycast to get our first collision point
3941 path.SetUseRaycast(true);
3942 bool result = path.CalculatePath(startX, startY, startZ, destX, destY, destZ, false);
3943
3944 Unit const* unit = source->ToUnit();
3945 bool notOnGround = path.GetPathType() & PATHFIND_NOT_USING_PATH
3946 || isWaterNext || (unit && unit->IsFlying());
3947
3948 // Check for valid path types before we proceed
3949 if (!result || (!notOnGround && path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END)))
3950 {
3951 return false;
3952 }
3953
3954 G3D::Vector3 endPos = path.GetPath().back();
3955 destX = endPos.x;
3956 destY = endPos.y;
3957 destZ = endPos.z;
3958
3959 // collision check
3960 bool collided = false;
3961
3962 // check static LOS
3963 float halfHeight = source->GetCollisionHeight() * 0.5f;
3964
3965 // Unit is not on the ground, check for potential collision via vmaps
3966 if (notOnGround)
3967 {
3968 bool col = VMAP::VMapFactory::createOrGetVMapMgr()->GetObjectHitPos(source->GetMapId(),
3969 startX, startY, startZ + halfHeight,
3970 destX, destY, destZ + halfHeight,
3971 destX, destY, destZ, -CONTACT_DISTANCE);
3972
3973 destZ -= halfHeight;
3974
3975 // Collided with static LOS object, move back to collision point
3976 if (col)
3977 {
3978 collided = true;
3979 }
3980 }
3981
3982 // check dynamic collision
3983 bool col = source->GetMap()->GetObjectHitPos(source->GetPhaseMask(),
3984 startX, startY, startZ + halfHeight,
3985 destX, destY, destZ + halfHeight,
3986 destX, destY, destZ, -CONTACT_DISTANCE);
3987
3988 destZ -= halfHeight;
3989
3990 // Collided with a gameobject, move back to collision point
3991 if (col)
3992 {
3993 collided = true;
3994 }
3995
3996 float groundZ = VMAP_INVALID_HEIGHT_VALUE;
3997 source->UpdateAllowedPositionZ(destX, destY, destZ, &groundZ);
3998
3999 // position has no ground under it (or is too far away)
4000 if (groundZ <= INVALID_HEIGHT && unit && !unit->CanFly())
4001 {
4002 // fall back to gridHeight if any
4003 float gridHeight = GetGridHeight(destX, destY);
4004 if (gridHeight > INVALID_HEIGHT)
4005 {
4006 destZ = gridHeight + unit->GetHoverHeight();
4007 }
4008 else
4009 {
4010 return false;
4011 }
4012 }
4013
4014 return !failOnCollision || !collided;
4015}
#define LOG_FATAL(filterType__,...)
Definition: Log.h:153
#define VMAP_INVALID_HEIGHT_VALUE
Definition: IVMapMgr.h:49
#define INVALID_HEIGHT
Definition: Map.h:163
#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 IsValidMapCoord(float c)
Definition: GridDefines.h:215
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
float GetHoverHeight() const
Definition: Unit.h:1583
bool IsFlying() const
Definition: Unit.h:1580
bool IsInWater(uint32 phaseMask, float x, float y, float z, float collisionHeight) const
Definition: Map.cpp:2503
float GetGridHeight(float x, float y) const
Definition: Map.cpp:2080
Definition: PathGenerator.h:59

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
560{ 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 
)
3632{
3633 Corpse* corpse = GetCorpseByPlayer(ownerGuid);
3634 if (!corpse)
3635 return nullptr;
3636
3637 RemoveCorpse(corpse);
3638
3639 // remove corpse from DB
3640 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
3641 corpse->DeleteFromDB(trans);
3642 CharacterDatabase.CommitTransaction(trans);
3643
3644 Corpse* bones = NULL;
3645
3646 // create the bones only if the map and the grid is loaded at the corpse's location
3647 // ignore bones creating option in case insignia
3648 if ((insignia ||
3650 !IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
3651 {
3652 // Create bones, don't change Corpse
3653 bones = new Corpse();
3654 bones->Create(corpse->GetGUID().GetCounter());
3655
3656 for (uint8 i = OBJECT_FIELD_TYPE + 1; i < CORPSE_END; ++i) // don't overwrite guid and object type
3657 bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
3658
3659 bones->SetCellCoord(corpse->GetCellCoord());
3660 bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
3661 bones->SetPhaseMask(corpse->GetPhaseMask(), false);
3662
3664 bones->SetGuidValue(CORPSE_FIELD_OWNER, corpse->GetOwnerGUID());
3665
3666 for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
3667 if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
3668 bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
3669
3670 AddCorpse(bones);
3671
3672 bones->UpdatePositionData();
3673
3674 // add bones in grid store if grid loaded where corpse placed
3675 AddToMap(bones);
3676 }
3677
3678 // all references to the corpse should be removed at this point
3679 delete corpse;
3680
3681 return bones;
3682}
@ CONFIG_DEATH_BONES_BG_OR_ARENA
Definition: IWorld.h:106
@ CONFIG_DEATH_BONES_WORLD
Definition: IWorld.h:105
@ EQUIPMENT_SLOT_END
Definition: Player.h:699
@ CORPSE_FLAG_BONES
Definition: Corpse.h:40
@ CORPSE_FLAG_UNK2
Definition: Corpse.h:42
@ 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
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:69
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sWorld
Definition: World.h:443
Definition: Corpse.h:49
bool Create(ObjectGuid::LowType guidlow)
Definition: Corpse.cpp:61
void SetCellCoord(CellCoord const &cellCoord)
Definition: Corpse.h:75
void DeleteFromDB(CharacterDatabaseTransaction trans)
Definition: Corpse.cpp:119
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:305
void SetGuidValue(uint16 index, ObjectGuid value)
Definition: Object.cpp:723
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:650
virtual void SetPhaseMask(uint32 newPhaseMask, bool update)
Definition: Object.cpp:2886
uint32 GetPhaseMask() const
Definition: Object.h:451
void UpdatePositionData()
Definition: Object.cpp:1165
LowType GetCounter() const
Definition: ObjectGuid.h:145
float GetPositionZ() const
Definition: Position.h:118
float GetOrientation() const
Definition: Position.h:119
void Relocate(float x, float y)
Definition: Position.h:72
bool IsBattlegroundOrArena() const
Definition: Map.h:454
void AddCorpse(Corpse *corpse)
Definition: Map.cpp:3600
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:361
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition: Map.h:532
bool AddToMap(T *, bool checkTransport=false)
Definition: Map.cpp:558
void RemoveCorpse(Corpse *corpse)
Definition: Map.cpp:3611

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(), IsRemovalGrid(), 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 
)
1026{
1027 Cell old_cell = creature->GetCurrentCell();
1028 Cell new_cell(x, y);
1029
1030 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
1031 {
1032 if (old_cell.DiffGrid(new_cell))
1033 EnsureGridLoaded(new_cell);
1034
1035 AddCreatureToMoveList(creature);
1036 }
1037 else
1039
1040 creature->Relocate(x, y, z, o);
1041 if (creature->IsVehicle())
1042 creature->GetVehicleKit()->RelocatePassengers();
1043 creature->UpdatePositionData();
1044 creature->UpdateObjectVisibility(false);
1045}
Cell const & GetCurrentCell() const
Definition: Object.h:402
bool IsVehicle() const
Definition: Unit.h:757
void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false) override
Definition: Unit.cpp:19130
Vehicle * GetVehicleKit() const
Definition: Unit.h:1785
void RelocatePassengers()
Definition: Vehicle.cpp:513
bool DiffGrid(const Cell &cell) const
Definition: Cell.h:63
bool DiffCell(const Cell &cell) const
Definition: Cell.h:57
void AddCreatureToMoveList(Creature *c)
Definition: Map.cpp:1088
void RemoveCreatureFromMoveList(Creature *c)
Definition: Map.cpp:1095

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.

2639{
2641 {
2644
2645 if (!transport->IsInWorld())
2646 continue;
2647
2648 transport->DelayedUpdate(t_diff);
2649 }
2650
2652}
Definition: Transport.h:48
void DelayedUpdate(uint32 diff)
Definition: Transport.cpp:240
void RemoveAllObjectsInRemoveList()
Definition: Map.cpp:2681

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

Referenced by MapInstanced::DelayedUpdate().

◆ DeleteCorpseData()

void Map::DeleteCorpseData ( )
4055{
4056 // DELETE FROM corpse WHERE mapId = ? AND instanceId = ?
4058 stmt->SetData(0, GetId());
4059 stmt->SetData(1, GetInstanceId());
4060 CharacterDatabase.Execute(stmt);
4061}
@ CHAR_DEL_CORPSES_FROM_MAP
Definition: CharacterDatabase.h:247
Definition: PreparedStatement.h:157
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77

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)
428{
430
431 RemoveUpdateObject(player); //TODO: I do not know why we need this, it should be removed in ~Object anyway
432 delete player;
433}
void RemoveObject(T *object)
Definition: ObjectAccessor.h:95
void RemoveUpdateObject(Object *obj)
Definition: Map.h:647

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

◆ DeleteFromWorld() [2/2]

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

Referenced by RemoveFromMap(), and RemovePlayerFromMap().

◆ DeleteRespawnTimes()

void Map::DeleteRespawnTimes ( )
3454{
3455 _creatureRespawnTimes.clear();
3456 _goRespawnTimes.clear();
3457
3459}
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
Definition: Map.cpp:3461
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition: Map.h:780
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition: Map.h:781

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

Referenced by InstanceMap::UnloadAll().

◆ DeleteRespawnTimesInDB()

void Map::DeleteRespawnTimesInDB ( uint16  mapId,
uint32  instanceId 
)
static
3462{
3464 stmt->SetData(0, mapId);
3465 stmt->SetData(1, instanceId);
3466 CharacterDatabase.Execute(stmt);
3467
3468 stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_GO_RESPAWN_BY_INSTANCE);
3469 stmt->SetData(0, mapId);
3470 stmt->SetData(1, instanceId);
3471 CharacterDatabase.Execute(stmt);
3472}
@ CHAR_DEL_CREATURE_RESPAWN_BY_INSTANCE
Definition: CharacterDatabase.h:253
@ CHAR_DEL_GO_RESPAWN_BY_INSTANCE
Definition: CharacterDatabase.h:258

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)
3828{
3829 for (auto const& it : GetPlayers())
3830 {
3831 if (Player* player = it.GetSource())
3832 {
3833 exec(player);
3834 }
3835 }
3836}

References GetPlayers().

Referenced by Battleground::_ProcessProgress(), 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 
)
1069{
1070 Cell old_cell = dynObj->GetCurrentCell();
1071 Cell new_cell(x, y);
1072
1073 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
1074 {
1075 if (old_cell.DiffGrid(new_cell))
1076 EnsureGridLoaded(new_cell);
1077
1079 }
1080 else
1082
1083 dynObj->Relocate(x, y, z, o);
1084 dynObj->SetPositionDataUpdate();
1085 dynObj->UpdateObjectVisibility(false);
1086}
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
Definition: Map.cpp:1121
void AddDynamicObjectToMoveList(DynamicObject *go)
Definition: Map.cpp:1114

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 ( const GridCoord p)
436{
437 if (getNGrid(p.x_coord, p.y_coord)) // pussywizard
438 return;
439 std::lock_guard<std::mutex> guard(GridLock);
441}
std::mutex GridLock
Definition: Map.h:703
void EnsureGridCreated_i(const GridCoord &)
Definition: Map.cpp:445

References EnsureGridCreated_i(), getNGrid(), GridLock, CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by AddToMap(), EnsureGridLoaded(), GetGrid(), and LoadMap().

◆ EnsureGridCreated_i()

void Map::EnsureGridCreated_i ( const GridCoord p)
private
446{
447 if (!getNGrid(p.x_coord, p.y_coord))
448 {
449 // pussywizard: moved setNGrid to the end of the function
451
452 // build a linkage between this map and NGridType
453 buildNGridLinkage(ngt); // pussywizard: getNGrid(x, y) changed to: ngt
454
455 //z coord
456 int gx = (MAX_NUMBER_OF_GRIDS - 1) - p.x_coord;
457 int gy = (MAX_NUMBER_OF_GRIDS - 1) - p.y_coord;
458
459 if (!GridMaps[gx][gy])
460 {
461 LoadMapAndVMap(gx, gy);
462 }
463
464 // pussywizard: moved here
465 setNGrid(ngt, p.x_coord, p.y_coord);
466 }
467}
NGrid< MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes > NGridType
Definition: GridDefines.h:77
void LoadMapAndVMap(int gx, int gy)
Definition: Map.cpp:228
void buildNGridLinkage(NGridType *pNGridType)
Definition: Map.h:682

References buildNGridLinkage(), getNGrid(), GridMaps, LoadMapAndVMap(), MAX_NUMBER_OF_GRIDS, setNGrid(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by EnsureGridCreated().

◆ EnsureGridLoaded()

bool Map::EnsureGridLoaded ( Cell const &  cell)
private
471{
472 EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
473 NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
474
475 ASSERT(grid);
476 if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY()))
477 {
478 //if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY()))
479 //{
480 LOG_DEBUG("maps", "Loading grid[{}, {}] for map {} instance {}", cell.GridX(), cell.GridY(), GetId(), i_InstanceId);
481
482 setGridObjectDataLoaded(true, cell.GridX(), cell.GridY());
483
484 ObjectGridLoader loader(*grid, this, cell);
485 loader.LoadN();
486
487 Balance();
488 return true;
489 //}
490 }
491
492 return false;
493}
Definition: ObjectGridLoader.h:28
void Balance()
Definition: Map.h:557
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
Definition: Map.h:692
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
Definition: Map.h:691

References ASSERT, Balance(), EnsureGridCreated(), GetId(), getNGrid(), Cell::GridX(), Cell::GridY(), i_InstanceId, isGridObjectDataLoaded(), ObjectGridLoader::LoadN(), LOG_DEBUG, and setGridObjectDataLoaded().

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

◆ ExistMap()

bool Map::ExistMap ( uint32  mapid,
int  gx,
int  gy 
)
static
89{
90 int len = sWorld->GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
91 char* tmp = new char[len];
92 snprintf(tmp, len, (char*)(sWorld->GetDataPath() + "maps/%03u%02u%02u.map").c_str(), mapid, gx, gy);
93
94 bool ret = false;
95 FILE* pf = fopen(tmp, "rb");
96
97 if (!pf)
98 LOG_ERROR("maps", "Map file '{}': does not exist!", tmp);
99 else
100 {
101 map_fileheader header;
102 if (fread(&header, sizeof(header), 1, pf) == 1)
103 {
104 if (header.mapMagic != MapMagic.asUInt || header.versionMagic != MapVersionMagic)
105 {
106 LOG_ERROR("maps", "Map file '{}' is from an incompatible map version (%.*u v{}), %.*s v{} is expected. Please pull your source, recompile tools and recreate maps using the updated mapextractor, then replace your old map files with new files.",
107 tmp, 4, header.mapMagic, header.versionMagic, 4, MapMagic.asChar, MapVersionMagic);
108 }
109
110 else
111 ret = true;
112 }
113 fclose(pf);
114 }
115 delete [] tmp;
116 return ret;
117}
uint32 MapVersionMagic
Definition: Map.cpp:54
u_map_magic MapMagic
Definition: Map.cpp:53
char asChar[4]
Definition: Map.cpp:49
uint32 asUInt
Definition: Map.cpp:50
Definition: Map.h:88
uint32 mapMagic
Definition: Map.h:89
uint32 versionMagic
Definition: Map.h:90

References u_map_magic::asChar, u_map_magic::asUInt, LOG_ERROR, MapMagic, map_fileheader::mapMagic, MapVersionMagic, sWorld, and map_fileheader::versionMagic.

Referenced by MapMgr::ExistMapAndVMap(), and misc_commandscript::HandleGPSCommand().

◆ ExistVMap()

bool Map::ExistVMap ( uint32  mapid,
int  gx,
int  gy 
)
static
120{
122 {
123 if (vmgr->isMapLoadingEnabled())
124 {
125 VMAP::LoadResult result = vmgr->existsMap((sWorld->GetDataPath() + "vmaps").c_str(), mapid, gx, gy);
126 std::string name = vmgr->getDirFileName(mapid, gx, gy);
127 switch (result)
128 {
130 break;
132 LOG_ERROR("maps", "VMap file '{}' does not exist", (sWorld->GetDataPath() + "vmaps/" + name));
133 LOG_ERROR("maps", "Please place VMAP files (*.vmtree and *.vmtile) in the vmap directory ({}), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath() + "vmaps/"));
134 return false;
136 LOG_ERROR("maps", "VMap file '{}' couldn't be loaded", (sWorld->GetDataPath() + "vmaps/" + name));
137 LOG_ERROR("maps", "This is because the version of the VMap file and the version of this module are different, please re-extract the maps with the tools compiled with this module.");
138 return false;
139 }
140 }
141 }
142
143 return true;
144}
LoadResult
Definition: IVMapMgr.h:42
Definition: IVMapMgr.h:78

References VMAP::VMapFactory::createOrGetVMapMgr(), VMAP::FileNotFound, LOG_ERROR, VMAP::Success, sWorld, and VMAP::VersionMismatch.

Referenced by MapMgr::ExistMapAndVMap(), and misc_commandscript::HandleGPSCommand().

◆ GameObjectRelocation()

void Map::GameObjectRelocation ( GameObject go,
float  x,
float  y,
float  z,
float  o 
)
1048{
1049 Cell old_cell = go->GetCurrentCell();
1050 Cell new_cell(x, y);
1051
1052 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
1053 {
1054 if (old_cell.DiffGrid(new_cell))
1055 EnsureGridLoaded(new_cell);
1056
1058 }
1059 else
1061
1062 go->Relocate(x, y, z, o);
1063 go->UpdateModelPosition();
1065 go->UpdateObjectVisibility(false);
1066}
void UpdateModelPosition()
Definition: GameObject.cpp:2912
void SetPositionDataUpdate()
Definition: Object.cpp:1156
virtual void UpdateObjectVisibility(bool forced=true, bool fromUpdate=false)
Definition: Object.cpp:2982
void AddGameObjectToMoveList(GameObject *go)
Definition: Map.cpp:1101
void RemoveGameObjectFromMoveList(GameObject *go)
Definition: Map.cpp:1108

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(), MotionTransport::UpdatePassengerPositions(), and StaticTransport::UpdatePosition().

◆ GenerateLowGuid()

◆ GetActiveNonPlayersCount()

std::size_t Map::GetActiveNonPlayersCount ( ) const
inline
653 {
654 return m_activeNonPlayers.size();
655 }

References m_activeNonPlayers.

Referenced by debug_commandscript::HandleDebugObjectCountMap().

◆ GetAllTransports()

TransportsContainer const & Map::GetAllTransports ( ) const
inline
631{ 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
2151{
2152 uint32 mogpFlags;
2153 int32 adtId, rootId, groupId;
2154 float vmapZ = z;
2155 bool hasVmapArea = GetAreaInfo(phaseMask, x, y, vmapZ, mogpFlags, adtId, rootId, groupId);
2156
2157 uint32 gridAreaId = 0;
2158 float gridMapHeight = INVALID_HEIGHT;
2159 if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2160 {
2161 gridAreaId = gmap->getArea(x, y);
2162 gridMapHeight = gmap->getHeight(x, y);
2163 }
2164
2165 uint16 areaId = 0;
2166
2167 // floor is the height we are closer to (but only if above)
2168 if (hasVmapArea && G3D::fuzzyGe(z, vmapZ - GROUND_HEIGHT_TOLERANCE) && (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapZ > gridMapHeight))
2169 {
2170 // wmo found
2171 if (WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId))
2172 areaId = wmoEntry->areaId;
2173
2174 if (!areaId)
2175 areaId = gridAreaId;
2176 }
2177 else
2178 areaId = gridAreaId;
2179
2180 if (!areaId)
2181 areaId = i_mapEntry->linked_zone;
2182
2183 return areaId;
2184}
std::uint32_t uint32
Definition: Define.h:107
std::uint16_t uint16
Definition: Define.h:108
float const GROUND_HEIGHT_TOLERANCE
Definition: SharedDefines.h:26
WMOAreaTableEntry const * GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
Definition: DBCStores.cpp:694
Definition: Map.h:200
Definition: Map.h:311
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:1980
bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition: Map.cpp:2101
uint32 linked_zone
Definition: DBCStructure.h:1332
Definition: DBCStructure.h:2130

References GetAreaInfo(), GetGrid(), 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
2102{
2103 float vmap_z = z;
2104 float dynamic_z = z;
2105 float check_z = z;
2107 uint32 vflags;
2108 int32 vadtId;
2109 int32 vrootId;
2110 int32 vgroupId;
2111 uint32 dflags;
2112 int32 dadtId;
2113 int32 drootId;
2114 int32 dgroupId;
2115
2116 bool hasVmapAreaInfo = vmgr->GetAreaInfo(GetId(), x, y, vmap_z, vflags, vadtId, vrootId, vgroupId);
2117 bool hasDynamicAreaInfo = _dynamicTree.GetAreaInfo(x, y, dynamic_z, phaseMask, dflags, dadtId, drootId, dgroupId);
2118 auto useVmap = [&]() { check_z = vmap_z; flags = vflags; adtId = vadtId; rootId = vrootId; groupId = vgroupId; };
2119 auto useDyn = [&]() { check_z = dynamic_z; flags = dflags; adtId = dadtId; rootId = drootId; groupId = dgroupId; };
2120
2121 if (hasVmapAreaInfo)
2122 {
2123 if (hasDynamicAreaInfo && dynamic_z > vmap_z)
2124 useDyn();
2125 else
2126 useVmap();
2127 }
2128 else if (hasDynamicAreaInfo)
2129 {
2130 useDyn();
2131 }
2132
2133 if (hasVmapAreaInfo || hasDynamicAreaInfo)
2134 {
2135 // check if there's terrain between player height and object height
2136 if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2137 {
2138 float mapHeight = gmap->getHeight(x, y);
2139 // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
2140 if (z + 2.0f > mapHeight && mapHeight > check_z)
2141 return false;
2142 }
2143
2144 return true;
2145 }
2146
2147 return false;
2148}
bool GetAreaInfo(float x, float y, float &z, uint32 phasemask, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition: DynamicTree.cpp:311
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(), GetGrid(), and GetId().

Referenced by GetAreaId().

◆ GetCorpse()

Corpse * Map::GetCorpse ( ObjectGuid const  guid)
3313{
3314 return _objectsStore.Find<Corpse>(guid);
3315}
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:144
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:797

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

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

◆ GetCorpseByPlayer()

Corpse * Map::GetCorpseByPlayer ( ObjectGuid const &  ownerGuid) const
inline
533 {
534 auto itr = _corpsesByPlayer.find(ownerGuid);
535 if (itr != _corpsesByPlayer.end())
536 return itr->second;
537
538 return nullptr;
539 }

References _corpsesByPlayer.

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

◆ GetCorpsesInCell()

std::unordered_set< Corpse * > const * Map::GetCorpsesInCell ( uint32  cellId) const
inline
524 {
525 auto itr = _corpsesByCell.find(cellId);
526 if (itr != _corpsesByCell.end())
527 return &itr->second;
528
529 return nullptr;
530 }

References _corpsesByCell.

Referenced by ObjectWorldLoader::Visit().

◆ GetCreature()

Creature * Map::GetCreature ( ObjectGuid const  guid)
3318{
3319 return _objectsStore.Find<Creature>(guid);
3320}

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(), 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(), BattlegroundEY::EventTeamCapturedPoint(), Battleground::GetBGCreature(), boss_erekem::boss_erekemAI::GetChainHealTargetGUID(), Battlefield::GetCreature(), InstanceScript::GetCreature(), ObjectAccessor::GetCreature(), npc_ranshalla::npc_ranshallaAI::GetSpeakerByEntry(), SmartScript::GetTargets(), 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(), 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(), instance_molten_core::instance_molten_core_InstanceMapScript::OnGameObjectCreate(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate(), instance_naxxramas::instance_naxxramas_InstanceMapScript::OnGameObjectRemove(), instance_ruby_sanctum::instance_ruby_sanctum_InstanceMapScript::OnPlayerEnter(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::OnPlayerEnter(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::OnPlayerEnter(), instance_vault_of_archavon::instance_vault_of_archavon_InstanceMapScript::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(), BattlegroundAV::PopulateNode(), BattlegroundIC::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(), boss_tyrannus::boss_tyrannusAI::Reset(), 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_naxxramas::instance_naxxramas_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_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(), 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(), 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_naxxramas::instance_naxxramas_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(), boss_faerlina::boss_faerlinaAI::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(), npc_ichor_globule::npc_ichor_globuleAI::UpdateAI(), and Player::UpdateTriggerVisibility().

◆ GetCreatureBySpawnIdStore()

◆ GetCreatureRespawnTime()

time_t Map::GetCreatureRespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
572 {
573 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
574 if (itr != _creatureRespawnTimes.end())
575 return itr->second;
576
577 return time_t(0);
578 }

References _creatureRespawnTimes.

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

◆ GetDebugInfo()

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

Reimplemented in InstanceMap.

4064{
4065 std::stringstream sstr;
4066 sstr << std::boolalpha
4067 << "Id: " << GetId() << " InstanceId: " << GetInstanceId() << " Difficulty: " << std::to_string(GetDifficulty())
4068 << " HasPlayers: " << HavePlayers();
4069 return sstr.str();
4070}
bool HavePlayers() const
Definition: Map.h:475
Difficulty GetDifficulty() const
Definition: Map.h:441

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

Referenced by InstanceMap::GetDebugInfo().

◆ GetDifficulty()

◆ GetDynamicMapTree()

DynamicMapTree const & Map::GetDynamicMapTree ( ) const
inline

◆ GetDynamicObject()

DynamicObject * Map::GetDynamicObject ( ObjectGuid const  guid)
3342{
3343 return _objectsStore.Find<DynamicObject>(guid);
3344}
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
458 {
459 if (!i_mapEntry)
460 return false;
461 return i_mapEntry->GetEntrancePos(mapid, x, y);
462 }
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
Definition: DBCStructure.h:1359

References MapEntry::GetEntrancePos(), and i_mapEntry.

◆ GetEntry()

◆ GetFullTerrainStatusForPosition()

void Map::GetFullTerrainStatusForPosition ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight,
PositionFullTerrainStatus data,
uint8  reqLiquidType = MAP_ALL_LIQUIDS 
)
2291{
2292 GridMap* gmap = GetGrid(x, y);
2293
2295 VMAP::AreaAndLiquidData vmapData;
2296 // VMAP::AreaAndLiquidData dynData;
2297 VMAP::AreaAndLiquidData* wmoData = nullptr;
2298 vmgr->GetAreaAndLiquidData(GetId(), x, y, z, reqLiquidType, vmapData);
2299 // _dynamicTree.GetAreaAndLiquidData(x, y, z, phaseMask, reqLiquidType, dynData);
2300
2301 uint32 gridAreaId = 0;
2302 float gridMapHeight = INVALID_HEIGHT;
2303 if (gmap)
2304 {
2305 gridAreaId = gmap->getArea(x, y);
2306 gridMapHeight = gmap->getHeight(x, y);
2307 }
2308
2309 bool useGridLiquid = true;
2310
2311 // floor is the height we are closer to (but only if above)
2313 if (gridMapHeight > INVALID_HEIGHT && G3D::fuzzyGe(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE))
2314 data.floorZ = gridMapHeight;
2315
2316 if (vmapData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
2317 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || vmapData.floorZ > gridMapHeight))
2318 {
2319 data.floorZ = vmapData.floorZ;
2320 wmoData = &vmapData;
2321 }
2322
2323 // NOTE: Objects will not detect a case when a wmo providing area/liquid despawns from under them
2324 // but this is fine as these kind of objects are not meant to be spawned and despawned a lot
2325 // example: Lich King platform
2326 /*
2327 if (dynData.floorZ > VMAP_INVALID_HEIGHT && G3D::fuzzyGe(z, dynData.floorZ - GROUND_HEIGHT_TOLERANCE) &&
2328 (G3D::fuzzyLt(z, gridMapHeight - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > gridMapHeight) &&
2329 (G3D::fuzzyLt(z, vmapData.floorZ - GROUND_HEIGHT_TOLERANCE) || dynData.floorZ > vmapData.floorZ))
2330 {
2331 data.floorZ = dynData.floorZ;
2332 wmoData = &dynData;
2333 }
2334 */
2335
2336 if (wmoData)
2337 {
2338 if (wmoData->areaInfo)
2339 {
2340 // wmo found
2341 WMOAreaTableEntry const* wmoEntry = GetWMOAreaTableEntryByTripple(wmoData->areaInfo->rootId, wmoData->areaInfo->adtId, wmoData->areaInfo->groupId);
2342 data.outdoors = (wmoData->areaInfo->mogpFlags & 0x8) != 0;
2343 if (wmoEntry)
2344 {
2345 data.areaId = wmoEntry->areaId;
2346 if (wmoEntry->Flags & 4)
2347 data.outdoors = true;
2348 else if (wmoEntry->Flags & 2)
2349 data.outdoors = false;
2350 }
2351
2352 if (!data.areaId)
2353 data.areaId = gridAreaId;
2354
2355 useGridLiquid = !IsInWMOInterior(wmoData->areaInfo->mogpFlags);
2356 }
2357 }
2358 else
2359 {
2360 data.outdoors = true;
2361 data.areaId = gridAreaId;
2362 if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId))
2363 data.outdoors = (areaEntry->flags & (AREA_FLAG_INSIDE | AREA_FLAG_OUTSIDE)) != AREA_FLAG_INSIDE;
2364 }
2365
2366 if (!data.areaId)
2368
2369 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(data.areaId);
2370
2371 // liquid processing
2372 if (wmoData && wmoData->liquidInfo && wmoData->liquidInfo->level > wmoData->floorZ)
2373 {
2374 uint32 liquidType = wmoData->liquidInfo->type;
2375 if (GetId() == 530 && liquidType == 2) // gotta love blizzard hacks
2376 liquidType = 15;
2377
2378 uint32 liquidFlagType = 0;
2379 if (LiquidTypeEntry const* liquidData = sLiquidTypeStore.LookupEntry(liquidType))
2380 liquidFlagType = liquidData->Type;
2381
2382 if (liquidType && liquidType < 21 && areaEntry)
2383 {
2384 uint32 overrideLiquid = areaEntry->LiquidTypeOverride[liquidFlagType];
2385 if (!overrideLiquid && areaEntry->zone)
2386 {
2387 AreaTableEntry const* zoneEntry = sAreaTableStore.LookupEntry(areaEntry->zone);
2388 if (zoneEntry)
2389 overrideLiquid = zoneEntry->LiquidTypeOverride[liquidFlagType];
2390 }
2391
2392 if (LiquidTypeEntry const* overrideData = sLiquidTypeStore.LookupEntry(overrideLiquid))
2393 {
2394 liquidType = overrideLiquid;
2395 liquidFlagType = overrideData->Type;
2396 }
2397 }
2398
2399 data.liquidInfo.Level = wmoData->liquidInfo->level;
2400 data.liquidInfo.DepthLevel = wmoData->floorZ;
2401 data.liquidInfo.Entry = liquidType;
2402 data.liquidInfo.Flags = 1 << liquidFlagType;
2403
2404 // Get position delta
2405 float delta = wmoData->liquidInfo->level - z;
2406
2407 if (delta > collisionHeight)
2409 else if (delta > 0.0f)
2411 else if (delta > -0.1f)
2413 else
2415 }
2416
2417 // look up liquid data from grid map
2418 if (gmap && useGridLiquid)
2419 {
2420 LiquidData const& gridLiquidData = gmap->GetLiquidData(x, y, z, collisionHeight, reqLiquidType);
2421 if (gridLiquidData.Status != LIQUID_MAP_NO_WATER && (!wmoData || gridLiquidData.Level > wmoData->floorZ))
2422 {
2423 uint32 liquidEntry = gridLiquidData.Entry;
2424 if (GetId() == 530 && liquidEntry == 2)
2425 liquidEntry = 15;
2426
2427 data.liquidInfo = gridLiquidData;
2428 data.liquidInfo.Entry = liquidEntry;
2429 }
2430 }
2431}
#define VMAP_INVALID_HEIGHT
Definition: IVMapMgr.h:48
@ AREA_FLAG_OUTSIDE
Definition: DBCEnums.h:260
@ AREA_FLAG_INSIDE
Definition: DBCEnums.h:259
@ LIQUID_MAP_UNDER_WATER
Definition: Map.h:146
@ LIQUID_MAP_NO_WATER
Definition: Map.h:142
@ LIQUID_MAP_IN_WATER
Definition: Map.h:145
@ LIQUID_MAP_ABOVE_WATER
Definition: Map.h:143
@ LIQUID_MAP_WATER_WALK
Definition: Map.h:144
static bool IsInWMOInterior(uint32 mogpFlags)
Definition: Map.cpp:2096
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
DBCStorage< LiquidTypeEntry > sLiquidTypeStore(LiquidTypefmt)
Definition: IVMapMgr.h:52
Optional< AreaInfo > areaInfo
Definition: IVMapMgr.h:72
Optional< LiquidInfo > liquidInfo
Definition: IVMapMgr.h:73
float floorZ
Definition: IVMapMgr.h:71
virtual void GetAreaAndLiquidData(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, AreaAndLiquidData &data) const =0
Definition: Map.h:169
float Level
Definition: Map.h:174
uint32 Flags
Definition: Map.h:173
uint32 Entry
Definition: Map.h:172
LiquidStatus Status
Definition: Map.h:176
float DepthLevel
Definition: Map.h:175
float floorZ
Definition: Map.h:183
uint32 areaId
Definition: Map.h:182
LiquidData liquidInfo
Definition: Map.h:185
bool outdoors
Definition: Map.h:184
uint16 getArea(float x, float y) const
Definition: Map.cpp:1556
LiquidData const GetLiquidData(float x, float y, float z, float collisionHeight, uint8 ReqLiquidType) const
Definition: Map.cpp:1893
float getHeight(float x, float y) const
Definition: Map.h:258
Definition: DBCStructure.h:518
uint32 zone
Definition: DBCStructure.h:521
uint32 LiquidTypeOverride[4]
Definition: DBCStructure.h:529
Definition: DBCStructure.h:1282
uint32 Flags
Definition: DBCStructure.h:2140
uint32 areaId
Definition: DBCStructure.h:2141

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, GridMap::getArea(), VMAP::IVMapMgr::GetAreaAndLiquidData(), GetGrid(), GridMap::getHeight(), GetId(), GridMap::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, 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)
3323{
3324 return _objectsStore.Find<GameObject>(guid);
3325}

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

Referenced by boss_sjonnir::boss_sjonnirAI::ActivatePipe(), Spell::CheckCast(), Player::CheckDuelDistance(), Spell::CheckEffectTarget(), 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::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_faerlina::boss_faerlinaAI::JustDied(), boss_four_horsemen::boss_four_horsemenAI::JustDied(), boss_gothik::boss_gothikAI::JustDied(), boss_kelthuzad::boss_kelthuzadAI::JustDied(), boss_noth::boss_nothAI::JustDied(), boss_thaddius::boss_thaddiusAI::JustDied(), boss_shade_of_aran::JustEngagedWith(), boss_sjonnir::boss_sjonnirAI::JustEngagedWith(), boss_kologarn::boss_kologarnAI::JustEngagedWith(), boss_thaddius_summon::boss_thaddius_summonAI::JustEngagedWith(), boss_faerlina::boss_faerlinaAI::JustEngagedWith(), boss_four_horsemen::boss_four_horsemenAI::JustEngagedWith(), boss_gothik::boss_gothikAI::JustEngagedWith(), boss_heigan::boss_heiganAI::JustEngagedWith(), boss_kelthuzad::boss_kelthuzadAI::JustEngagedWith(), boss_loatheb::boss_loathebAI::JustEngagedWith(), boss_maexxna::boss_maexxnaAI::JustEngagedWith(), boss_noth::boss_nothAI::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_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_faerlina::boss_faerlinaAI::Reset(), boss_four_horsemen::boss_four_horsemenAI::Reset(), boss_gothik::boss_gothikAI::Reset(), boss_heigan::boss_heiganAI::Reset(), boss_kelthuzad::boss_kelthuzadAI::Reset(), boss_loatheb::boss_loathebAI::Reset(), boss_maexxna::boss_maexxnaAI::Reset(), boss_noth::boss_nothAI::Reset(), boss_thaddius::boss_thaddiusAI::Reset(), boss_sjonnir::boss_sjonnirAI::Reset(), boss_kologarn::boss_kologarnAI::Reset(), boss_palehoof::boss_palehoofAI::Reset(), ScriptsProcess(), Player::SendLoot(), Player::SendQuestGiverStatusMultiple(), Acore::VisibleNotifier::SendToSelf(), instance_molten_core::instance_molten_core_InstanceMapScript::SetBossState(), instance_naxxramas::instance_naxxramas_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_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_naxxramas::instance_naxxramas_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_gothik::boss_gothikAI::UpdateAI(), boss_kelthuzad::boss_kelthuzadAI::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(), Player::UpdateTriggerVisibility(), 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
564 {
565 return _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
566 }
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
581 {
582 std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid);
583 if (itr != _goRespawnTimes.end())
584 return itr->second;
585
586 return time_t(0);
587 }

References _goRespawnTimes.

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

◆ GetGrid()

GridMap * Map::GetGrid ( float  x,
float  y 
)
1981{
1982 // half opt method
1983 int gx = (int)(32 - x / SIZE_OF_GRIDS); //grid x
1984 int gy = (int)(32 - y / SIZE_OF_GRIDS); //grid y
1985
1986 // ensure GridMap is loaded
1987 EnsureGridCreated(GridCoord(63 - gx, 63 - gy));
1988
1989 return GridMaps[gx][gy];
1990}
#define SIZE_OF_GRIDS
Definition: MapDefines.h:25

References EnsureGridCreated(), GridMaps, and SIZE_OF_GRIDS.

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

◆ GetGridHeight()

float Map::GetGridHeight ( float  x,
float  y 
) const
2081{
2082 if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2083 return gmap->getHeight(x, y);
2084
2086}

References GetGrid(), and VMAP_INVALID_HEIGHT_VALUE.

Referenced by CheckCollisionAndGetValidCoords(), and GetHeight().

◆ GetGuidSequenceGenerator()

template<HighGuid high>
ObjectGuidGeneratorBase & Map::GetGuidSequenceGenerator ( )
inlineprivate
788 {
789 auto itr = _guidGenerators.find(high);
790 if (itr == _guidGenerators.end())
791 itr = _guidGenerators.insert(std::make_pair(high, std::unique_ptr<ObjectGuidGenerator<high>>(new ObjectGuidGenerator<high>()))).first;
792
793 return *itr->second;
794 }
Definition: ObjectGuid.h:297
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition: Map.h:796

References _guidGenerators.

◆ GetHeight() [1/2]

float Map::GetHeight ( float  x,
float  y,
float  z,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
2044{
2045 // find raw .map surface under Z coordinates
2046 float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
2047 float gridHeight = GetGridHeight(x, y);
2048 if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
2049 mapHeight = gridHeight;
2050
2051 float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
2052 if (checkVMap)
2053 {
2055 vmapHeight = vmgr->getHeight(GetId(), x, y, z, maxSearchDist); // look from a bit higher pos to find the floor
2056 }
2057
2058 // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT
2059 // vmapheight set for any under Z value or <= INVALID_HEIGHT
2060 if (vmapHeight > INVALID_HEIGHT)
2061 {
2062 if (mapHeight > INVALID_HEIGHT)
2063 {
2064 // we have mapheight and vmapheight and must select more appropriate
2065
2066 // we are already under the surface or vmap height above map heigt
2067 // or if the distance of the vmap height is less the land height distance
2068 if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
2069 return vmapHeight;
2070 else
2071 return mapHeight; // better use .map surface height
2072 }
2073 else
2074 return vmapHeight; // we have only vmapHeight (if have)
2075 }
2076
2077 return mapHeight; // explicitly use map data
2078}
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
2496{
2497 float h1, h2;
2498 h1 = GetHeight(x, y, z, vmap, maxSearchDist);
2499 h2 = _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
2500 return std::max<float>(h1, h2);
2501}
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2043

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

◆ GetId()

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

References i_mapEntry, and MapEntry::MapID.

Referenced by Group::_cancelHomebindIfInstance(), AddObjectToRemoveList(), AddObjectToSwitchList(), InstanceMap::AddPlayerToMap(), WorldState::BuffAdalsSongOfBattle(), WorldState::BuffMagtheridonTeam(), spell_gen_consumption::CalculateDamage(), MapUpdateRequest::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(), EnsureGridLoaded(), anonymous_namespace{AllMapScript.cpp}::ForeachMaps(), 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(), LoadCorpseData(), LoadMap(), LoadMMap(), ObjectGridLoader::LoadN(), LoadRespawnTimes(), LoadVMap(), LogEncounterFinished(), AchievementCriteriaData::Meets(), MotionMaster::MoveFall(), lfg::LFGPlayerScript::OnMapChanged(), InstanceMap::PermBindAllPlayers(), RemoveAllPlayers(), RemoveCreatureRespawnTime(), RemoveGORespawnTime(), InstanceMap::Reset(), Player::RewardReputation(), SaveCreatureRespawnTime(), SaveGORespawnTime(), InstanceMap::SendResetWarnings(), World::SetInitialWorldSettings(), WorldObject::SetMap(), Player::SetMover(), SummonCreatureGroup(), MotionTransport::TeleportTransport(), UnloadGrid(), Update(), UpdateEncounterState(), ObjectGridLoader::Visit(), and ~Map().

◆ GetInstanceId()

◆ GetInstanceResetPeriod()

time_t Map::GetInstanceResetPeriod ( ) const
inline

◆ GetLinkedRespawnTime()

time_t Map::GetLinkedRespawnTime ( ObjectGuid  guid) const
3585{
3586 ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
3587 switch (linkedGuid.GetHigh())
3588 {
3589 case HighGuid::Unit:
3590 return GetCreatureRespawnTime(linkedGuid.GetCounter());
3591 case HighGuid::GameObject:
3592 return GetGORespawnTime(linkedGuid.GetCounter());
3593 default:
3594 break;
3595 }
3596
3597 return time_t(0);
3598}
#define sObjectMgr
Definition: ObjectMgr.h:1635
Definition: ObjectGuid.h:118
HighGuid GetHigh() const
Definition: ObjectGuid.h:143
time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const
Definition: Map.h:571
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition: Map.h:580

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

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

◆ GetLiquidData()

LiquidData const Map::GetLiquidData ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight,
uint8  ReqLiquidType 
)
2205{
2206 LiquidData liquidData;
2207
2209 float liquid_level = INVALID_HEIGHT;
2210 float ground_level = INVALID_HEIGHT;
2211 uint32 liquid_type = 0;
2212 uint32 mogpFlags = 0;
2213 bool useGridLiquid = true;
2214 if (vmgr->GetLiquidLevel(GetId(), x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type, mogpFlags))
2215 {
2216 useGridLiquid = !IsInWMOInterior(mogpFlags);
2217 LOG_DEBUG("maps", "GetLiquidStatus(): vmap liquid level: {} ground: {} type: {}", liquid_level, ground_level, liquid_type);
2218 // Check water level and ground level
2219 if (liquid_level > ground_level && G3D::fuzzyGe(z, ground_level - GROUND_HEIGHT_TOLERANCE))
2220 {
2221 // hardcoded in client like this
2222 if (GetId() == 530 && liquid_type == 2)
2223 liquid_type = 15;
2224
2225 uint32 liquidFlagType = 0;
2226 if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(liquid_type))
2227 liquidFlagType = liq->Type;
2228
2229 if (liquid_type && liquid_type < 21)
2230 {
2231 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(phaseMask, x, y, z)))
2232 {
2233 uint32 overrideLiquid = area->LiquidTypeOverride[liquidFlagType];
2234 if (!overrideLiquid && area->zone)
2235 {
2236 area = sAreaTableStore.LookupEntry(area->zone);
2237 if (area)
2238 overrideLiquid = area->LiquidTypeOverride[liquidFlagType];
2239 }
2240
2241 if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
2242 {
2243 liquid_type = overrideLiquid;
2244 liquidFlagType = liq->Type;
2245 }
2246 }
2247 }
2248
2249 liquidData.Level = liquid_level;
2250 liquidData.DepthLevel = ground_level;
2251 liquidData.Entry = liquid_type;
2252 liquidData.Flags = 1 << liquidFlagType;
2253 }
2254
2255 float delta = liquid_level - z;
2256
2257 // Get position delta
2258 if (delta > collisionHeight)
2259 liquidData.Status = LIQUID_MAP_UNDER_WATER;
2260 else if (delta > 0.0f)
2261 liquidData.Status = LIQUID_MAP_IN_WATER;
2262 else if (delta > -0.1f)
2263 liquidData.Status = LIQUID_MAP_WATER_WALK;
2264 else
2265 liquidData.Status = LIQUID_MAP_ABOVE_WATER;
2266 }
2267
2268 if (useGridLiquid)
2269 {
2270 if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2271 {
2272 LiquidData const& map_data = gmap->GetLiquidData(x, y, z, collisionHeight, ReqLiquidType);
2273 // Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
2274 if (map_data.Status != LIQUID_MAP_NO_WATER && (map_data.Level > ground_level))
2275 {
2276 // hardcoded in client like this
2277 uint32 liquidEntry = map_data.Entry;
2278 if (GetId() == 530 && liquidEntry == 2)
2279 liquidEntry = 15;
2280
2281 liquidData = map_data;
2282 liquidData.Entry = liquidEntry;
2283 }
2284 }
2285 }
2286
2287 return liquidData;
2288}
virtual bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type, uint32 &mogpFlags) const =0
uint32 GetAreaId(uint32 phaseMask, float x, float y, float z) const
Definition: Map.cpp:2150

References VMAP::VMapFactory::createOrGetVMapMgr(), LiquidData::DepthLevel, LiquidData::Entry, LiquidData::Flags, GetAreaId(), GetGrid(), 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, sAreaTableStore, sLiquidTypeStore, and LiquidData::Status.

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

◆ GetMapDifficulty()

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

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

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

◆ GetMapName()

char const * Map::GetMapName ( ) const
2528{
2529 return i_mapEntry ? i_mapEntry->name[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0";
2530}
char const * name[16]
Definition: DBCStructure.h:1330

References i_mapEntry, MapEntry::name, and sWorld.

Referenced by InstanceMap::CannotEnter(), debug_commandscript::HandleDebugObjectCountMap(), go_commandscript::HandleGoZoneXYCommand(), LoadMMap(), LoadVMap(), LogCommandUsage(), and InstanceMap::PermBindAllPlayers().

◆ GetMinHeight()

float Map::GetMinHeight ( float  x,
float  y 
) const
2089{
2090 if (GridMap const* grid = const_cast<Map*>(this)->GetGrid(x, y))
2091 return grid->getMinHeight(x, y);
2092
2093 return -500.0f;
2094}

References GetGrid().

Referenced by WorldSession::HandleMovementOpcodes().

◆ GetMMapLock()

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

References MMapLock.

◆ getNGrid()

NGridType * Map::getNGrid ( uint32  x,
uint32  y 
) const
inlineprivate
685 {
687 return i_grids[x][y];
688 }
NGridType * i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:739

References ASSERT, i_grids, and MAX_NUMBER_OF_GRIDS.

Referenced by AddToGrid(), EnsureGridCreated(), EnsureGridCreated_i(), EnsureGridLoaded(), IsGridLoaded(), isGridObjectDataLoaded(), IsRemovalGrid(), setGridObjectDataLoaded(), SwitchGridContainers(), and Visit().

◆ 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 
)
2482{
2483 G3D::Vector3 startPos(x1, y1, z1);
2484 G3D::Vector3 dstPos(x2, y2, z2);
2485
2486 G3D::Vector3 resultPos;
2487 bool result = _dynamicTree.GetObjectHitPos(phasemask, startPos, dstPos, resultPos, modifyDist);
2488
2489 rx = resultPos.x;
2490 ry = resultPos.y;
2491 rz = resultPos.z;
2492 return result;
2493}
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
382{ return m_parentMap; }

References m_parentMap.

◆ GetPet()

Pet * Map::GetPet ( ObjectGuid const  guid)
3328{
3329 return _objectsStore.Find<Pet>(guid);
3330}
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
484{ return m_mapRefMgr; }
MapRefMgr m_mapRefMgr
Definition: Map.h:714

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(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::GetCreatureEntry(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::GetCreatureEntry(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::GetGameObjectEntry(), 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(), instance_trial_of_the_champion::instance_trial_of_the_champion_InstanceMapScript::OnCreatureCreate(), instance_forge_of_souls::instance_forge_of_souls_InstanceScript::OnCreatureCreate(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::OnCreatureCreate(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::OnCreatureCreate(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnCreatureCreate(), instance_nexus::instance_nexus_InstanceMapScript::OnCreatureCreate(), instance_shattered_halls::instance_shattered_halls_InstanceMapScript::OnCreatureCreate(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate(), 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(), npc_singularity::Reset(), 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_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(), npc_demonic_vapor::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)
3333{
3334 if (guid.GetHigh() != HighGuid::Mo_Transport && guid.GetHigh() != HighGuid::Transport)
3335 return nullptr;
3336
3337 GameObject* go = GetGameObject(guid);
3338 return go ? go->ToTransport() : nullptr;
3339}
Transport * ToTransport()
Definition: GameObject.h:321
GameObject * GetGameObject(ObjectGuid const guid)
Definition: Map.cpp:3322

References GetGameObject(), ObjectGuid::GetHigh(), and GameObject::ToTransport().

Referenced by ObjectAccessor::GetTransport(), WorldSession::HandleMovementOpcodes(), npc_gunship::npc_gunshipAI::JustDied(), npc_gunship_boarding_addAI::MovementInform(), ScriptsProcess(), npc_high_overlord_saurfang_igb::npc_high_overlord_saurfang_igbAI::UpdateAI(), and npc_muradin_bronzebeard_igb::npc_muradin_bronzebeard_igbAI::UpdateAI().

◆ GetTransportForPos()

Transport * Map::GetTransportForPos ( uint32  phase,
float  x,
float  y,
float  z,
WorldObject worldobject = nullptr 
)
2017{
2018 G3D::Vector3 v(x, y, z + 2.0f);
2019 G3D::Ray r(v, G3D::Vector3(0, 0, -1));
2020 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2021 if ((*itr)->IsInWorld() && (*itr)->GetExactDistSq(x, y, z) < 75.0f * 75.0f && (*itr)->m_model)
2022 {
2023 float dist = 30.0f;
2024 bool hit = (*itr)->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
2025 if (hit)
2026 return *itr;
2027 }
2028
2029 if (worldobject)
2030 if (GameObject* staticTrans = worldobject->FindNearestGameObjectOfType(GAMEOBJECT_TYPE_TRANSPORT, 75.0f))
2031 if (staticTrans->m_model)
2032 {
2033 float dist = 10.0f;
2034 bool hit = staticTrans->m_model->intersectRay(r, dist, false, phase, VMAP::ModelIgnoreFlags::Nothing);
2035 if (hit)
2036 if (GetHeight(phase, x, y, z, true, 30.0f) < (v.z - dist + 1.0f))
2037 return staticTrans->ToTransport();
2038 }
2039
2040 return nullptr;
2041}
phase
Definition: boss_skadi.cpp:103
@ GAMEOBJECT_TYPE_TRANSPORT
Definition: SharedDefines.h:1571
GameObject * FindNearestGameObjectOfType(GameobjectTypes type, float range) const
Definition: Object.cpp:2475

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

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

◆ GetVisibilityRange()

◆ GetWaterLevel()

float Map::GetWaterLevel ( float  x,
float  y 
) const
2434{
2435 if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2436 return gmap->getLiquidLevel(x, y);
2437 else
2438 return 0;
2439}

References GetGrid().

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
1993{
1994 if (const_cast<Map*>(this)->GetGrid(x, y))
1995 {
1996 // we need ground level (including grid height version) for proper return water level in point
1997 float ground_z = GetHeight(phasemask, x, y, z + Z_OFFSET_FIND_HEIGHT, true, 50.0f);
1998 if (ground)
1999 *ground = ground_z;
2000
2001 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phasemask, x, y, ground_z, collisionHeight, MAP_ALL_LIQUIDS);
2002 switch (liquidData.Status)
2003 {
2005 return std::max<float>(liquidData.Level, ground_z);
2007 return ground_z;
2008 default:
2009 return liquidData.Level;
2010 }
2011 }
2012
2014}
constexpr float Z_OFFSET_FIND_HEIGHT
Definition: SharedDefines.h:27
#define MAP_ALL_LIQUIDS
Definition: Map.h:158
LiquidData const GetLiquidData(uint32 phaseMask, float x, float y, float z, float collisionHeight, uint8 ReqLiquidType)
Definition: Map.cpp:2204

References GetGrid(), 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
2197{
2198 areaid = zoneid = GetAreaId(phaseMask, x, y, z);
2199 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
2200 if (area->zone)
2201 zoneid = area->zone;
2202}

References GetAreaId(), and sAreaTableStore.

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

◆ GetZoneId()

uint32 Map::GetZoneId ( uint32  phaseMask,
float  x,
float  y,
float  z 
) const
2187{
2188 uint32 areaId = GetAreaId(phaseMask, x, y, z);
2189 if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
2190 if (area->zone)
2191 return area->zone;
2192
2193 return areaId;
2194}

References GetAreaId(), and sAreaTableStore.

Referenced by MapMgr::GetZoneId().

◆ HandleDelayedVisibility()

void Map::HandleDelayedVisibility ( )
894{
896 return;
897 for (std::unordered_set<Unit*>::iterator itr = i_objectsForDelayedVisibility.begin(); itr != i_objectsForDelayedVisibility.end(); ++itr)
898 (*itr)->ExecuteDelayedUnitRelocationEvent();
900}
std::unordered_set< Unit * > i_objectsForDelayedVisibility
Definition: Map.h:387

References i_objectsForDelayedVisibility.

Referenced by Update().

◆ HasEnoughWater() [1/2]

bool Map::HasEnoughWater ( WorldObject const *  searcher,
float  x,
float  y,
float  z 
) const
2516{
2517 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(searcher->GetPhaseMask(), x, y, z, searcher->GetCollisionHeight(), MAP_ALL_LIQUIDS);
2518 return (liquidData.Status & MAP_LIQUID_STATUS_SWIMMING) != 0 && HasEnoughWater(searcher, liquidData);
2519}
#define MAP_LIQUID_STATUS_SWIMMING
Definition: Map.h:149

References WorldObject::GetCollisionHeight(), GetLiquidData(), WorldObject::GetPhaseMask(), HasEnoughWater(), MAP_ALL_LIQUIDS, MAP_LIQUID_STATUS_SWIMMING, and LiquidData::Status.

Referenced by CanReachPositionAndGetValidCoords(), and HasEnoughWater().

◆ HasEnoughWater() [2/2]

bool Map::HasEnoughWater ( WorldObject const *  searcher,
LiquidData const &  liquidData 
) const
2522{
2523 float minHeightInWater = searcher->GetMinHeightInWater();
2524 return liquidData.Level > INVALID_HEIGHT && liquidData.Level > liquidData.DepthLevel && liquidData.Level - liquidData.DepthLevel >= minHeightInWater;
2525}

References LiquidData::DepthLevel, WorldObject::GetMinHeightInWater(), INVALID_HEIGHT, and LiquidData::Level.

◆ HavePlayers()

◆ InitializeObject() [1/3]

template<>
void Map::InitializeObject ( Creature )
547{
548 //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
549}

◆ InitializeObject() [2/3]

template<>
void Map::InitializeObject ( GameObject )
553{
554 //obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
555}

◆ InitializeObject() [3/3]

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

Referenced by AddToMap().

◆ InitVisibilityDistance()

void Map::InitVisibilityDistance ( )
virtual

Reimplemented in InstanceMap, BattlegroundMap, and MapInstanced.

262{
263 //init visibility for continents
265
266 switch (GetId())
267 {
268 case 609: // Scarlet Enclave (DK starting zone)
269 m_VisibleDistance = 125.0f;
270 break;
271 case 25: // Scott Test (box map)
272 m_VisibleDistance = 200.0f;
273 break;
274 }
275}
static float GetMaxVisibleDistanceOnContinents()
Definition: World.h:315

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

Referenced by Map().

◆ InsertGameObjectModel()

void Map::InsertGameObjectModel ( const GameObjectModel model)
inline
559{ _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
451{ return IsRaid() && i_spawnMode & RAID_DIFFICULTY_MASK_25MAN; } // since 25man difficulties are 1 and 3, we can check them like that
#define RAID_DIFFICULTY_MASK_25MAN
Definition: DBCEnums.h:279
bool IsRaid() const
Definition: Map.h:448

References i_spawnMode, IsRaid(), and RAID_DIFFICULTY_MASK_25MAN.

Referenced by boss_thorim::boss_thorimAI::DamageTaken(), boss_yoggsaron_sara::boss_yoggsaron_saraAI::DoAction(), spell_archavon_rock_shards::HandleScript(), instance_ulduar::instance_ulduar_InstanceMapScript::instance_ulduar_InstanceMapScript(), spell_the_lich_king_vile_spirits_aura::Load(), AchievementCriteriaData::Meets(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnGameObjectCreate(), AreaTrigger_at_celestial_planetarium_enterance::OnTrigger(), npc_frostwing_vrykul::npc_frostwing_vrykulAI::Reset(), npc_gunship::npc_gunshipAI::SetGUID(), instance_ulduar::instance_ulduar_InstanceMapScript::SpawnLeviathanEncounterVehicles(), boss_prince_valanar_icc::boss_prince_valanarAI::UpdateAI(), npc_icc_valkyr_herald::npc_icc_valkyr_heraldAI::UpdateAI(), boss_grobbulus_poison_cloud::boss_grobbulus_poison_cloudAI::UpdateAI(), boss_freya::boss_freyaAI::UpdateAI(), boss_freya_lifebinder::boss_freya_lifebinderAI::UpdateAI(), boss_freya_nature_bomb::boss_freya_nature_bombAI::UpdateAI(), boss_vezax::boss_vezaxAI::UpdateAI(), boss_kologarn_eyebeam::boss_kologarn_eyebeamAI::UpdateAI(), boss_yoggsaron_sara::boss_yoggsaron_saraAI::UpdateAI(), and UpdateEncounterState().

◆ IsBattleArena()

◆ IsBattleground()

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

References i_mapEntry, and MapEntry::IsBattleground().

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

◆ IsBattlegroundOrArena()

◆ isCellMarked()

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

References marked_cells.

Referenced by VisitNearbyCellsOf().

◆ isCellMarkedLarge()

bool Map::isCellMarkedLarge ( uint32  pCellId)
inline
472{ return marked_cells_large.test(pCellId); }
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells_large
Definition: Map.h:742

References marked_cells_large.

Referenced by VisitNearbyCellsOf(), and VisitNearbyCellsOfPlayer().

◆ IsDungeon()

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

References i_mapEntry, and MapEntry::IsDungeon().

Referenced by Group::_cancelHomebindIfInstance(), InstanceSaveMgr::_ResetOrWarnAll(), InstanceMap::AddPlayerToMap(), GameObject::AddToSkillupList(), Spell::CheckCast(), MapInstanced::CreateInstance(), 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(), and AchievementMgr::UpdateAchievementCriteria().

◆ IsGridLoaded() [1/2]

bool Map::IsGridLoaded ( const GridCoord p) const
private

◆ IsGridLoaded() [2/2]

bool Map::IsGridLoaded ( float  x,
float  y 
) const
inline
368 {
370 }
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:185
bool IsGridLoaded(float x, float y) const
Definition: Map.h:367

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

Referenced by ObjectMgr::AddGOData(), GameEventMgr::GameEventSpawn(), IsGridLoaded(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::SetData(), PoolGroup< T >::Spawn1Object(), SwitchGridContainers(), and Visit().

◆ isGridObjectDataLoaded()

bool Map::isGridObjectDataLoaded ( uint32  x,
uint32  y 
) const
inlineprivate

◆ 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::FillInitialWorldStates(), 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
2442{
2443 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_PVP_LOS))
2444 {
2446 {
2447 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
2448 }
2449 }
2450
2451 if (!sWorld->getBoolConfig(CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD))
2452 {
2453 if (IsWorldMap())
2454 {
2455 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
2456 }
2457 }
2458
2459 if ((checks & LINEOFSIGHT_CHECK_VMAP) && !VMAP::VMapFactory::createOrGetVMapMgr()->isInLineOfSight(GetId(), x1, y1, z1, x2, y2, z2, ignoreFlags))
2460 {
2461 return false;
2462 }
2463
2464 if (sWorld->getBoolConfig(CONFIG_CHECK_GOBJECT_LOS) && (checks & LINEOFSIGHT_CHECK_GOBJECT_ALL))
2465 {
2466 ignoreFlags = VMAP::ModelIgnoreFlags::Nothing;
2467 if (!(checks & LINEOFSIGHT_CHECK_GOBJECT_M2))
2468 {
2469 ignoreFlags = VMAP::ModelIgnoreFlags::M2;
2470 }
2471
2472 if (!_dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask, ignoreFlags))
2473 {
2474 return false;
2475 }
2476 }
2477
2478 return true;
2479}
@ LINEOFSIGHT_CHECK_GOBJECT_M2
Definition: Map.h:192
@ LINEOFSIGHT_CHECK_VMAP
Definition: Map.h:190
@ LINEOFSIGHT_CHECK_GOBJECT_ALL
Definition: Map.h:194
@ CONFIG_CHECK_GOBJECT_LOS
Definition: IWorld.h:155
@ CONFIG_VMAP_BLIZZLIKE_LOS_OPEN_WORLD
Definition: IWorld.h:177
@ CONFIG_VMAP_BLIZZLIKE_PVP_LOS
Definition: IWorld.h:176
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:455
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:2441

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

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

References GetDifficulty(), and REGULAR_DIFFICULTY.

◆ IsRemovalGrid()

bool Map::IsRemovalGrid ( float  x,
float  y 
) const
inline

◆ IsUnderWater()

bool Map::IsUnderWater ( uint32  phaseMask,
float  x,
float  y,
float  z,
float  collisionHeight 
) const
2510{
2511 LiquidData const& liquidData = const_cast<Map*>(this)->GetLiquidData(phaseMask, x, y, z, collisionHeight, MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN);
2512 return liquidData.Status == LIQUID_MAP_UNDER_WATER;
2513}
#define MAP_LIQUID_TYPE_WATER
Definition: Map.h:153
#define MAP_LIQUID_TYPE_OCEAN
Definition: Map.h:154

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
455{ return i_mapEntry && i_mapEntry->IsWorldMap(); }
bool IsWorldMap() const
Definition: DBCStructure.h:1357

References i_mapEntry, and MapEntry::IsWorldMap().

Referenced by isInLineOfSight().

◆ LoadAllCells()

void Map::LoadAllCells ( )
501{
502 for (uint32 cellX = 0; cellX < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellX++)
503 for (uint32 cellY = 0; cellY < TOTAL_NUMBER_OF_CELLS_PER_MAP; cellY++)
505}
#define TOTAL_NUMBER_OF_CELLS_PER_MAP
Definition: GridDefines.h:48
#define CENTER_GRID_CELL_ID
Definition: GridDefines.h:45
#define SIZE_OF_GRID_CELL
Definition: GridDefines.h:43
void LoadGrid(float x, float y)
Definition: Map.cpp:495

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

Referenced by World::SetInitialWorldSettings().

◆ LoadCorpseData()

void Map::LoadCorpseData ( )
4018{
4020 stmt->SetData(0, GetId());
4021 stmt->SetData(1, GetInstanceId());
4022
4023 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
4024 // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, guildId, flags, dynFlags, time, corpseType, instanceId, phaseMask, guid FROM corpse WHERE mapId = ? AND instanceId = ?
4025 PreparedQueryResult result = CharacterDatabase.Query(stmt);
4026 if (!result)
4027 return;
4028
4029 do
4030 {
4031 Field* fields = result->Fetch();
4032 CorpseType type = CorpseType(fields[13].Get<uint8>());
4033 uint32 guid = fields[16].Get<uint32>();
4034 if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
4035 {
4036 LOG_ERROR("maps", "Corpse (guid: {}) have wrong corpse type ({}), not loading.", guid, type);
4037 continue;
4038 }
4039
4040 Corpse* corpse = new Corpse(type);
4041
4042 if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
4043 {
4044 delete corpse;
4045 continue;
4046 }
4047
4048 AddCorpse(corpse);
4049
4050 corpse->UpdatePositionData();
4051 } while (result->NextRow());
4052}
CorpseType
Definition: Corpse.h:27
#define MAX_CORPSE_TYPE
Definition: Corpse.h:32
@ CHAR_SEL_CORPSES
Definition: CharacterDatabase.h:244
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:45
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
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field *fields)
Definition: Corpse.cpp:131

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(), and MapInstanced::CreateInstance().

◆ LoadGrid()

void Map::LoadGrid ( float  x,
float  y 
)
496{
497 EnsureGridLoaded(Cell(x, y));
498}

References EnsureGridLoaded().

Referenced by at_zulgurub_entrance_speech::_OnTrigger(), at_zulgurub_bridge_speech::_OnTrigger(), at_zulgurub_temple_speech::_OnTrigger(), at_zulgurub_bloodfire_pit_speech::_OnTrigger(), at_zulgurub_edge_of_madness_speech::_OnTrigger(), CinematicMgr::BeginCinematic(), instance_stratholme::instance_stratholme_InstanceMapScript::CheckZiggurats(), instance_the_black_morass::instance_the_black_morass_InstanceMapScript::CleanupInstance(), MotionTransport::DelayedTeleportTransport(), boss_nightbane::DoAction(), npc_thrall_warchief::npc_thrall_warchiefAI::DoAction(), npc_crok_scourgebane::npc_crok_scourgebaneAI::DoAction(), instance_culling_of_stratholme::instance_culling_of_stratholme_InstanceMapScript::EnsureGridLoaded(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::EnsureGridLoaded(), WorldSession::HandleMoveWorldportAck(), boss_kelidan_the_breaker::JustDied(), boss_kurinnaxx::JustDied(), LoadAllCells(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::OnCreatureCreate(), instance_ulduar::instance_ulduar_InstanceMapScript::OnGameObjectCreate(), instance_ruby_sanctum::instance_ruby_sanctum_InstanceMapScript::OnPlayerEnter(), instance_pit_of_saron::instance_pit_of_saron_InstanceScript::OnPlayerEnter(), instance_stratholme::instance_stratholme_InstanceMapScript::OnPlayerEnter(), instance_sunwell_plateau::instance_sunwell_plateau_InstanceMapScript::OnPlayerEnter(), instance_ruins_of_ahnqiraj::instance_ruins_of_ahnqiraj_InstanceMapScript::OnPlayerEnter(), instance_ulduar::instance_ulduar_InstanceMapScript::OnPlayerEnter(), at_sindragosa_lair::OnTrigger(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::OnUnitDeath(), FlightPathMovementGenerator::PreloadEndGrid(), instance_naxxramas::instance_naxxramas_InstanceMapScript::SetBossState(), instance_icecrown_citadel::instance_icecrown_citadel_InstanceMapScript::SetBossState(), instance_stratholme::instance_stratholme_InstanceMapScript::SetData(), instance_sunken_temple::instance_sunken_temple_InstanceMapScript::SetData(), instance_dire_maul::instance_dire_maul_InstanceMapScript::SetData(), instance_wailing_caverns::instance_wailing_caverns_InstanceMapScript::SetData(), instance_halls_of_reflection::instance_halls_of_reflection_InstanceMapScript::SetData(), instance_ulduar::instance_ulduar_InstanceMapScript::SetData(), instance_shattered_halls::instance_shattered_halls_InstanceMapScript::SetData(), Vehicle::TeleportVehicle(), instance_stratholme::instance_stratholme_InstanceMapScript::Update(), instance_old_hillsbrad::instance_old_hillsbrad_InstanceMapScript::Update(), instance_naxxramas::instance_naxxramas_InstanceMapScript::Update(), MotionTransport::UpdatePosition(), and StaticTransport::UpdatePosition().

◆ LoadMap()

void Map::LoadMap ( int  gx,
int  gy,
bool  reload = false 
)
private
185{
186 if (i_InstanceId != 0)
187 {
188 if (GridMaps[gx][gy])
189 return;
190
191 // load grid map for base map
192 m_parentMap->EnsureGridCreated(GridCoord(63 - gx, 63 - gy));
193
194 GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
195 return;
196 }
197
198 if (GridMaps[gx][gy] && !reload)
199 return;
200
201 //map already load, delete it before reloading (Is it necessary? Do we really need the ability the reload maps during runtime?)
202 if (GridMaps[gx][gy])
203 {
204 LOG_DEBUG("maps", "Unloading previously loaded map {} before reloading.", GetId());
205 sScriptMgr->OnUnloadGridMap(this, GridMaps[gx][gy], gx, gy);
206
207 delete (GridMaps[gx][gy]);
208 GridMaps[gx][gy] = nullptr;
209 }
210
211 // map file name
212 char* tmp = nullptr;
213 int len = sWorld->GetDataPath().length() + strlen("maps/%03u%02u%02u.map") + 1;
214 tmp = new char[len];
215 snprintf(tmp, len, (char*)(sWorld->GetDataPath() + "maps/%03u%02u%02u.map").c_str(), GetId(), gx, gy);
216 LOG_DEBUG("maps", "Loading map {}", tmp);
217 // loading data
218 GridMaps[gx][gy] = new GridMap();
219 if (!GridMaps[gx][gy]->loadData(tmp))
220 {
221 LOG_ERROR("maps", "Error loading map file: \n {}\n", tmp);
222 }
223 delete [] tmp;
224
225 sScriptMgr->OnLoadGridMap(this, GridMaps[gx][gy], gx, gy);
226}

References EnsureGridCreated(), GetId(), GridMaps, i_InstanceId, LOG_DEBUG, LOG_ERROR, m_parentMap, sScriptMgr, and sWorld.

Referenced by LoadMapAndVMap().

◆ LoadMapAndVMap()

void Map::LoadMapAndVMap ( int  gx,
int  gy 
)
private
229{
230 LoadMap(gx, gy);
231 if (i_InstanceId == 0)
232 {
233 LoadVMap(gx, gy); // Only load the data for the base map
234 LoadMMap(gx, gy);
235 }
236}
void LoadMMap(int gx, int gy)
Definition: Map.cpp:146
void LoadMap(int gx, int gy, bool reload=false)
Definition: Map.cpp:184
void LoadVMap(int gx, int gy)
Definition: Map.cpp:166

References i_InstanceId, LoadMap(), LoadMMap(), and LoadVMap().

Referenced by EnsureGridCreated_i().

◆ LoadMMap()

void Map::LoadMMap ( int  gx,
int  gy 
)
private
147{
148 if (!DisableMgr::IsPathfindingEnabled(this)) // pussywizard
149 return;
150
151 int mmapLoadResult = MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(GetId(), gx, gy);
152 switch (mmapLoadResult)
153 {
155 LOG_DEBUG("maps", "MMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
156 break;
158 LOG_DEBUG("maps", "Could not load MMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
159 break;
161 LOG_DEBUG("maps", "Ignored MMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
162 break;
163 }
164}
@ MMAP_LOAD_RESULT_ERROR
Definition: IMMAPMgr.h:26
@ MMAP_LOAD_RESULT_IGNORED
Definition: IMMAPMgr.h:28
@ MMAP_LOAD_RESULT_OK
Definition: IMMAPMgr.h:27
bool IsPathfindingEnabled(const Map *map)
Definition: DisableMgr.cpp:412
bool loadMap(uint32 mapId, int32 x, int32 y)
Definition: MMapMgr.cpp:128
const char * GetMapName() const
Definition: Map.cpp:2527

References MMAP::MMapFactory::createOrGetMMapMgr(), GetId(), GetMapName(), DisableMgr::IsPathfindingEnabled(), MMAP::MMapMgr::loadMap(), LOG_DEBUG, MMAP::MMAP_LOAD_RESULT_ERROR, MMAP::MMAP_LOAD_RESULT_IGNORED, and MMAP::MMAP_LOAD_RESULT_OK.

Referenced by LoadMapAndVMap().

◆ LoadRespawnTimes()

void Map::LoadRespawnTimes ( )
3421{
3423 stmt->SetData(0, GetId());
3424 stmt->SetData(1, GetInstanceId());
3425 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
3426 {
3427 do
3428 {
3429 Field* fields = result->Fetch();
3430 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
3431 uint32 respawnTime = fields[1].Get<uint32>();
3432
3433 _creatureRespawnTimes[lowguid] = time_t(respawnTime);
3434 } while (result->NextRow());
3435 }
3436
3437 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GO_RESPAWNS);
3438 stmt->SetData(0, GetId());
3439 stmt->SetData(1, GetInstanceId());
3440 if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
3441 {
3442 do
3443 {
3444 Field* fields = result->Fetch();
3445 ObjectGuid::LowType lowguid = fields[0].Get<uint32>();
3446 uint32 respawnTime = fields[1].Get<uint32>();
3447
3448 _goRespawnTimes[lowguid] = time_t(respawnTime);
3449 } while (result->NextRow());
3450 }
3451}
@ CHAR_SEL_CREATURE_RESPAWNS
Definition: CharacterDatabase.h:250
@ CHAR_SEL_GO_RESPAWNS
Definition: CharacterDatabase.h:255

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

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

◆ LoadVMap()

void Map::LoadVMap ( int  gx,
int  gy 
)
private
167{
168 // x and y are swapped !!
169 int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapMgr()->loadMap((sWorld->GetDataPath() + "vmaps").c_str(), GetId(), gx, gy);
170 switch (vmapLoadResult)
171 {
173 LOG_DEBUG("maps", "VMAP loaded name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
174 break;
176 LOG_DEBUG("maps", "Could not load VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
177 break;
179 LOG_DEBUG("maps", "Ignored VMAP name:{}, id:{}, x:{}, y:{} (vmap rep.: x:{}, y:{})", GetMapName(), GetId(), gx, gy, gx, gy);
180 break;
181 }
182}
@ VMAP_LOAD_RESULT_ERROR
Definition: IVMapMgr.h:36
@ VMAP_LOAD_RESULT_OK
Definition: IVMapMgr.h:37
@ VMAP_LOAD_RESULT_IGNORED
Definition: IVMapMgr.h:38
int loadMap(const char *pBasePath, unsigned int mapId, int x, int y) override
Definition: VMapMgr2.cpp:98

References VMAP::VMapFactory::createOrGetVMapMgr(), GetId(), GetMapName(), VMAP::VMapMgr2::loadMap(), LOG_DEBUG, sWorld, VMAP::VMAP_LOAD_RESULT_ERROR, VMAP::VMAP_LOAD_RESULT_IGNORED, and VMAP::VMAP_LOAD_RESULT_OK.

Referenced by LoadMapAndVMap().

◆ LogEncounterFinished()

void Map::LogEncounterFinished ( EncounterCreditType  type,
uint32  creditEntry 
)
3540{
3541 if (!IsRaid() || !GetEntry() || GetEntry()->Expansion() < 2) // only for wotlk raids, because logs take up tons of mysql memory
3542 return;
3543 InstanceMap* map = ToInstanceMap();
3544 if (!map)
3545 return;
3546 std::string playersInfo;
3547 char buffer[16384], buffer2[255];
3548 Map::PlayerList const& pl = map->GetPlayers();
3549 for (Map::PlayerList::const_iterator itr = pl.begin(); itr != pl.end(); ++itr)
3550 if (Player* p = itr->GetSource())
3551 {
3552 std::string auraStr;
3553 const Unit::AuraApplicationMap& a = p->GetAppliedAuras();
3554 for (auto iterator = a.begin(); iterator != a.end(); ++iterator)
3555 {
3556 snprintf(buffer2, 255, "%u(%u) ", iterator->first, iterator->second->GetEffectMask());
3557 auraStr += buffer2;
3558 }
3559
3560 snprintf(buffer, 16384, "%s (%s, acc: %u, ip: %s, guild: %u), xyz: (%.1f, %.1f, %.1f), auras: %s\n",
3561 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());
3562 playersInfo += buffer;
3563 }
3564 CleanStringForMysqlQuery(playersInfo);
3565 CharacterDatabase.Execute("INSERT INTO log_encounter VALUES(NOW(), {}, {}, {}, {}, '{}')", GetId(), (uint32)GetDifficulty(), type, creditEntry, playersInfo);
3566}
void CleanStringForMysqlQuery(std::string &str)
Definition: Common.cpp:54
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition: Unit.h:639
LinkedListHead::Iterator< GridReference< NGridType > > iterator
Definition: GridRefMgr.h:30
MapEntry const * GetEntry() const
Definition: Map.h:317
InstanceMap * ToInstanceMap()
Definition: Map.h:544
Definition: Map.h:817
Definition: MapRefMgr.h:26

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

Referenced by UpdateEncounterState().

◆ markCell()

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

References marked_cells.

Referenced by VisitNearbyCellsOf().

◆ markCellLarge()

void Map::markCellLarge ( uint32  pCellId)
inline
473{ marked_cells_large.set(pCellId); }

References marked_cells_large.

Referenced by VisitNearbyCellsOf(), and VisitNearbyCellsOfPlayer().

◆ MoveAllCreaturesInMoveList()

void Map::MoveAllCreaturesInMoveList ( )
1128{
1129 for (std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr)
1130 {
1131 Creature* c = *itr;
1132 if (c->FindMap() != this)
1133 continue;
1134
1136 {
1138 continue;
1139 }
1140
1142 if (!c->IsInWorld())
1143 continue;
1144
1145 Cell const& old_cell = c->GetCurrentCell();
1146 Cell new_cell(c->GetPositionX(), c->GetPositionY());
1147
1148 c->RemoveFromGrid();
1149 if (old_cell.DiffGrid(new_cell))
1150 EnsureGridLoaded(new_cell);
1151 AddToGrid(c, new_cell);
1152 }
1153 _creaturesToMove.clear();
1154}
void RemoveFromGrid()
Definition: Object.h:356
Map * FindMap() const
Definition: Object.h:537

References _creaturesToMove, 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().

◆ MoveAllDynamicObjectsInMoveList()

void Map::MoveAllDynamicObjectsInMoveList ( )
1186{
1187 for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr)
1188 {
1189 DynamicObject* dynObj = *itr;
1190 if (dynObj->FindMap() != this)
1191 continue;
1192
1194 {
1196 continue;
1197 }
1198
1200 if (!dynObj->IsInWorld())
1201 continue;
1202
1203 Cell const& old_cell = dynObj->GetCurrentCell();
1204 Cell new_cell(dynObj->GetPositionX(), dynObj->GetPositionY());
1205
1206 dynObj->RemoveFromGrid();
1207 if (old_cell.DiffGrid(new_cell))
1208 EnsureGridLoaded(new_cell);
1209 AddToGrid(dynObj, new_cell);
1210 }
1211 _dynamicObjectsToMove.clear();
1212}

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 ( )
1157{
1158 for (std::vector<GameObject*>::iterator itr = _gameObjectsToMove.begin(); itr != _gameObjectsToMove.end(); ++itr)
1159 {
1160 GameObject* go = *itr;
1161 if (go->FindMap() != this)
1162 continue;
1163
1165 {
1167 continue;
1168 }
1169
1171 if (!go->IsInWorld())
1172 continue;
1173
1174 Cell const& old_cell = go->GetCurrentCell();
1175 Cell new_cell(go->GetPositionX(), go->GetPositionY());
1176
1177 go->RemoveFromGrid();
1178 if (old_cell.DiffGrid(new_cell))
1179 EnsureGridLoaded(new_cell);
1180 AddToGrid(go, new_cell);
1181 }
1182 _gameObjectsToMove.clear();
1183}

References _gameObjectsToMove, 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().

◆ PlayDirectSoundToMap()

void Map::PlayDirectSoundToMap ( uint32  soundId,
uint32  zoneId = 0 
)
3748{
3749 Map::PlayerList const& players = GetPlayers();
3750 if (!players.IsEmpty())
3751 {
3753 data << uint32(soundId);
3754
3755 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3756 if (Player* player = itr->GetSource())
3757 if (!zoneId || player->GetZoneId() == zoneId)
3758 player->SendDirectMessage(&data);
3759 }
3760}
@ SMSG_PLAY_SOUND
Definition: Opcodes.h:752

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

Referenced by instance_naxxramas::instance_naxxramas_InstanceMapScript::Update().

◆ PlayerRelocation()

void Map::PlayerRelocation ( Player player,
float  x,
float  y,
float  z,
float  o 
)
1004{
1005 Cell old_cell(player->GetPositionX(), player->GetPositionY());
1006 Cell new_cell(x, y);
1007
1008 if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
1009 {
1010 player->RemoveFromGrid();
1011
1012 if (old_cell.DiffGrid(new_cell))
1013 EnsureGridLoaded(new_cell);
1014
1015 AddToGrid(player, new_cell);
1016 }
1017
1018 player->Relocate(x, y, z, o);
1019 if (player->IsVehicle())
1020 player->GetVehicleKit()->RelocatePassengers();
1021 player->UpdatePositionData();
1022 player->UpdateObjectVisibility(false);
1023}

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 ( )
2682{
2683 while (!i_objectsToSwitch.empty())
2684 {
2685 std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.begin();
2686 WorldObject* obj = itr->first;
2687 bool on = itr->second;
2688 i_objectsToSwitch.erase(itr);
2689
2690 if (!obj->IsPermanentWorldObject())
2691 {
2692 switch (obj->GetTypeId())
2693 {
2694 case TYPEID_UNIT:
2695 SwitchGridContainers<Creature>(obj->ToCreature(), on);
2696 break;
2697 case TYPEID_GAMEOBJECT:
2698 SwitchGridContainers<GameObject>(obj->ToGameObject(), on);
2699 break;
2700 default:
2701 break;
2702 }
2703 }
2704 }
2705
2706 //LOG_DEBUG("maps", "Object remover 1 check.");
2707 while (!i_objectsToRemove.empty())
2708 {
2709 std::unordered_set<WorldObject*>::iterator itr = i_objectsToRemove.begin();
2710 WorldObject* obj = *itr;
2711 i_objectsToRemove.erase(itr);
2712
2713 switch (obj->GetTypeId())
2714 {
2715 case TYPEID_CORPSE:
2716 {
2717 Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
2718 if (!corpse)
2719 LOG_ERROR("maps", "Tried to delete corpse/bones {} that is not in map.", obj->GetGUID().ToString());
2720 else
2721 RemoveFromMap(corpse, true);
2722 break;
2723 }
2725 RemoveFromMap((DynamicObject*)obj, true);
2726 break;
2727 case TYPEID_GAMEOBJECT:
2728 if (MotionTransport* transport = obj->ToGameObject()->ToMotionTransport())
2729 RemoveFromMap(transport, true);
2730 else
2731 RemoveFromMap(obj->ToGameObject(), true);
2732 break;
2733 case TYPEID_UNIT:
2734 // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call
2735 // make sure that like sources auras/etc removed before destructor start
2737 RemoveFromMap(obj->ToCreature(), true);
2738 break;
2739 default:
2740 LOG_ERROR("maps", "Non-grid object (TypeId: {}) is in grid object remove list, ignored.", obj->GetTypeId());
2741 break;
2742 }
2743 }
2744
2745 //LOG_DEBUG("maps", "Object remover 2 check.");
2746}
@ TYPEID_DYNAMICOBJECT
Definition: ObjectGuid.h:38
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ TYPEID_CORPSE
Definition: ObjectGuid.h:39
Corpse * GetCorpse(WorldObject const &u, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:179
MotionTransport * ToMotionTransport()
Definition: GameObject.h:327
bool IsPermanentWorldObject() const
Definition: Object.h:585
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Unit.cpp:15771
void RemoveFromMap(T *, bool)
Definition: Map.cpp:942

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

Referenced by DelayedUpdate(), and UnloadGrid().

◆ RemoveAllPlayers()

void Map::RemoveAllPlayers ( )
virtual

Reimplemented in BattlegroundMap.

1262{
1263 if (HavePlayers())
1264 {
1265 for (MapRefMgr::iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
1266 {
1267 Player* player = itr->GetSource();
1268 if (!player->IsBeingTeleportedFar())
1269 {
1270 // this is happening for bg
1271 LOG_ERROR("maps", "Map::UnloadAll: player {} is still in map {} during unload, this should not happen!", player->GetName(), GetId());
1272 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
1273 }
1274 }
1275 }
1276}
std::string const & GetName() const
Definition: Object.h:463
float m_homebindZ
Definition: Player.h:2373
bool IsBeingTeleportedFar() const
Definition: Player.h:2092
uint32 m_homebindMapId
Definition: Player.h:2369
float m_homebindY
Definition: Player.h:2372
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition: Player.cpp:1334
float m_homebindX
Definition: Player.h:2371

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)
3612{
3613 ASSERT(corpse);
3614
3615 corpse->DestroyForNearbyPlayers();
3616 if (corpse->IsInGrid())
3617 RemoveFromMap(corpse, false);
3618 else
3619 {
3620 corpse->RemoveFromWorld();
3621 corpse->ResetMap();
3622 }
3623
3624 _corpsesByCell[corpse->GetCellCoord().GetId()].erase(corpse);
3625 if (corpse->GetType() != CORPSE_BONES)
3626 _corpsesByPlayer.erase(corpse->GetOwnerGUID());
3627 else
3628 _corpseBones.erase(corpse);
3629}
void RemoveFromWorld() override
Definition: Corpse.cpp:52
bool IsInGrid() const
Definition: Object.h:354
void DestroyForNearbyPlayers()
Definition: Object.cpp:2955

References _corpseBones, _corpsesByCell, _corpsesByPlayer, ASSERT, CORPSE_BONES, WorldObject::DestroyForNearbyPlayers(), Corpse::GetCellCoord(), CoordPair< LIMIT >::GetId(), Corpse::GetOwnerGUID(), 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)
3376{
3377 _creatureRespawnTimes.erase(spawnId);
3378
3380 stmt->SetData(0, spawnId);
3381 stmt->SetData(1, GetId());
3382 stmt->SetData(2, GetInstanceId());
3383 CharacterDatabase.Execute(stmt);
3384}
@ CHAR_DEL_CREATURE_RESPAWN
Definition: CharacterDatabase.h:252

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
1122{
1123 if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_ACTIVE)
1124 dynObj->_moveState = MAP_OBJECT_CELL_MOVE_INACTIVE;
1125}

References MovableMapObject::_moveState, MAP_OBJECT_CELL_MOVE_ACTIVE, and MAP_OBJECT_CELL_MOVE_INACTIVE.

Referenced by DynamicObjectRelocation().

◆ RemoveFromActive() [1/4]

template<>
void Map::RemoveFromActive ( Creature c)
2795{
2797}
void RemoveFromActiveHelper(WorldObject *obj)
Definition: Map.h:764

References RemoveFromActiveHelper().

◆ RemoveFromActive() [2/4]

template<>
void Map::RemoveFromActive ( DynamicObject obj)
2801{
2803}

References RemoveFromActiveHelper().

◆ RemoveFromActive() [3/4]

template<>
void Map::RemoveFromActive ( GameObject obj)
2807{
2809}

References RemoveFromActiveHelper().

◆ RemoveFromActive() [4/4]

template<class T >
void Map::RemoveFromActive ( T *  obj)
2789{
2791}

References RemoveFromActiveHelper().

Referenced by RemoveFromMap(), and WorldObject::setActive().

◆ RemoveFromActiveHelper()

void Map::RemoveFromActiveHelper ( WorldObject obj)
inlineprivate
765 {
766 // Map::Update for active object in proccess
768 {
769 ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
770 if (itr == m_activeNonPlayers.end())
771 return;
772 if (itr == m_activeNonPlayersIter)
774 m_activeNonPlayers.erase(itr);
775 }
776 else
777 m_activeNonPlayers.erase(obj);
778 }

References m_activeNonPlayers, and m_activeNonPlayersIter.

Referenced by RemoveFromActive().

◆ RemoveFromMap() [1/2]

template<>
void Map::RemoveFromMap ( MotionTransport obj,
bool  remove 
)
963{
964 obj->RemoveFromWorld();
965 if (obj->isActiveObject())
966 RemoveFromActive(obj);
967
968 Map::PlayerList const& players = GetPlayers();
969 if (!players.IsEmpty())
970 {
971 UpdateData data;
972 obj->BuildOutOfRangeUpdateBlock(&data);
973 WorldPacket packet;
974 data.BuildPacket(packet);
975 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
976 if (itr->GetSource()->GetTransport() != obj)
977 itr->GetSource()->SendDirectMessage(&packet);
978 }
979
981 {
982 TransportsContainer::iterator itr = _transports.find(obj);
983 if (itr == _transports.end())
984 return;
985 if (itr == _transportsUpdateIter)
987 _transports.erase(itr);
988 }
989 else
990 _transports.erase(obj);
991
992 obj->ResetMap();
993
994 if (remove)
995 {
996 // if option set then object already saved at this moment
997 if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
998 obj->SaveRespawnTime();
999 DeleteFromWorld(obj);
1000 }
1001}
@ CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY
Definition: IWorld.h:93
void RemoveFromWorld() override
Definition: GameObject.cpp:168
void SaveRespawnTime() override
Definition: GameObject.h:244
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
Definition: Object.cpp:269
void RemoveFromActive(T *obj)
Definition: Map.cpp:2788
void DeleteFromWorld(T *)
Definition: Map.cpp:420

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

◆ RemoveFromMap() [2/2]

template<class T >
void Map::RemoveFromMap ( T *  obj,
bool  remove 
)
943{
944 bool inWorld = obj->IsInWorld() && obj->GetTypeId() >= TYPEID_UNIT && obj->GetTypeId() <= TYPEID_GAMEOBJECT;
945 obj->RemoveFromWorld();
946
947 if (obj->isActiveObject())
948 RemoveFromActive(obj);
949
950 if (!inWorld) // pussywizard: if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
951 obj->DestroyForNearbyPlayers(); // pussywizard: previous player->UpdateObjectVisibility()
952
953 obj->RemoveFromGrid();
954
955 obj->ResetMap();
956
957 if (remove)
958 DeleteFromWorld(obj);
959}

References DeleteFromWorld(), RemoveFromActive(), TYPEID_GAMEOBJECT, and TYPEID_UNIT.

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

◆ RemoveGameObjectFromMoveList()

void Map::RemoveGameObjectFromMoveList ( GameObject go)
private

◆ RemoveGameObjectModel()

void Map::RemoveGameObjectModel ( const GameObjectModel model)
inline
558{ _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)
3410{
3411 _goRespawnTimes.erase(spawnId);
3412
3414 stmt->SetData(0, spawnId);
3415 stmt->SetData(1, GetId());
3416 stmt->SetData(2, GetInstanceId());
3417 CharacterDatabase.Execute(stmt);
3418}
@ CHAR_DEL_GO_RESPAWN
Definition: CharacterDatabase.h:257

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

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

◆ RemoveOldCorpses()

void Map::RemoveOldCorpses ( )
3685{
3686 time_t now = GameTime::GetGameTime().count();
3687
3688 std::vector<ObjectGuid> corpses;
3689 corpses.reserve(_corpsesByPlayer.size());
3690
3691 for (auto const& p : _corpsesByPlayer)
3692 if (p.second->IsExpired(now))
3693 corpses.push_back(p.first);
3694
3695 for (ObjectGuid const& ownerGuid : corpses)
3696 ConvertCorpseToBones(ownerGuid);
3697
3698 std::vector<Corpse*> expiredBones;
3699 for (Corpse* bones : _corpseBones)
3700 if (bones->IsExpired(now))
3701 expiredBones.push_back(bones);
3702
3703 for (Corpse* bones : expiredBones)
3704 {
3705 RemoveCorpse(bones);
3706 delete bones;
3707 }
3708}
Seconds GetGameTime()
Definition: GameTime.cpp:38

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

Referenced by World::Update().

◆ RemovePlayerFromMap()

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

Reimplemented in InstanceMap, and BattlegroundMap.

915{
916 player->getHostileRefMgr().deleteReferences(true); // pussywizard: multithreading crashfix
917
918 bool inWorld = player->IsInWorld();
919 player->RemoveFromWorld();
920 SendRemoveTransports(player);
921
922 if (!inWorld) // pussywizard: if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
923 player->DestroyForNearbyPlayers(); // pussywizard: previous player->UpdateObjectVisibility(true)
924
925 if (player->IsInGrid())
926 player->RemoveFromGrid();
927 else
928 ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map
929
930 sScriptMgr->OnPlayerLeaveMap(this, player);
931 if (remove)
932 {
933 DeleteFromWorld(player);
934 }
935}
void deleteReferences(bool removeFromMap=false)
Definition: HostileRefMgr.cpp:125
void RemoveFromWorld() override
Definition: Player.cpp:1714
HostileRefMgr & getHostileRefMgr()
Definition: Unit.h:907
void SendRemoveTransports(Player *player)
Definition: Map.cpp:2580

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

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

◆ RemoveUpdateObject()

void Map::RemoveUpdateObject ( Object obj)
inline
648 {
649 _updateObjects.erase(obj);
650 }

References _updateObjects.

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

◆ RemoveWorldObject()

void Map::RemoveWorldObject ( WorldObject obj)
inline
479{ i_worldObjects.erase(obj); }

References i_worldObjects.

Referenced by WorldObject::ResetMap(), and SwitchGridContainers().

◆ resetMarkedCells()

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

References marked_cells.

Referenced by Update().

◆ resetMarkedCellsLarge()

void Map::resetMarkedCellsLarge ( )
inline
471{ marked_cells_large.reset(); }

References marked_cells_large.

Referenced by Update().

◆ SaveCreatureRespawnTime()

void Map::SaveCreatureRespawnTime ( ObjectGuid::LowType  dbGuid,
time_t &  respawnTime 
)
3353{
3354 if (!respawnTime)
3355 {
3356 // Delete only
3358 return;
3359 }
3360
3361 time_t now = GameTime::GetGameTime().count();
3362 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
3363 respawnTime = now + YEAR;
3364
3365 _creatureRespawnTimes[spawnId] = respawnTime;
3366
3368 stmt->SetData(0, spawnId);
3369 stmt->SetData(1, uint32(respawnTime));
3370 stmt->SetData(2, GetId());
3371 stmt->SetData(3, GetInstanceId());
3372 CharacterDatabase.Execute(stmt);
3373}
constexpr auto YEAR
Definition: Common.h:52
@ CHAR_REP_CREATURE_RESPAWN
Definition: CharacterDatabase.h:251
time_t GetInstanceResetPeriod() const
Definition: Map.h:595
void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3375

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 
)
3387{
3388 if (!respawnTime)
3389 {
3390 // Delete only
3391 RemoveGORespawnTime(spawnId);
3392 return;
3393 }
3394
3395 time_t now = GameTime::GetGameTime().count();
3396 if (GetInstanceResetPeriod() > 0 && respawnTime - now + 5 >= GetInstanceResetPeriod())
3397 respawnTime = now + YEAR;
3398
3399 _goRespawnTimes[spawnId] = respawnTime;
3400
3402 stmt->SetData(0, spawnId);
3403 stmt->SetData(1, uint32(respawnTime));
3404 stmt->SetData(2, GetId());
3405 stmt->SetData(3, GetInstanceId());
3406 CharacterDatabase.Execute(stmt);
3407}
@ CHAR_REP_GO_RESPAWN
Definition: CharacterDatabase.h:256
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3409

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 
)
3711{
3712 _creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid](TaskContext)
3713 {
3714 if (Creature* creature = GetCreature(creatureGuid))
3715 {
3716 creature->Respawn();
3717 }
3718 });
3719}
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
Definition: TaskScheduler.h:232
Definition: TaskScheduler.h:421
TaskScheduler _creatureRespawnScheduler
Definition: Map.h:597
Creature * GetCreature(ObjectGuid const guid)
Definition: Map.cpp:3317

References _creatureRespawnScheduler, GetCreature(), and TaskScheduler::Schedule().

Referenced by 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
bool IsItem() const
Definition: Object.h:224
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
Definition: Map.h:77
ObjectGuid targetGUID
Definition: Map.h:79
ObjectGuid ownerGUID
Definition: Map.h:80
ObjectGuid sourceGUID
Definition: Map.h:78
ScriptInfo const * script
Definition: Map.h:81
void ScriptsProcess()
Process queued scripts.
Definition: MapScripts.cpp:277

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:
299 case HighGuid::Vehicle:
300 source = GetCreature(step.sourceGUID);
301 break;
302 case HighGuid::Pet:
303 source = GetPet(step.sourceGUID);
304 break;
305 case HighGuid::Player:
307 break;
308 case HighGuid::Transport:
309 case HighGuid::GameObject:
310 source = GetGameObject(step.sourceGUID);
311 break;
312 case HighGuid::Corpse:
313 source = GetCorpse(step.sourceGUID);
314 break;
315 case HighGuid::Mo_Transport:
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:
331 case HighGuid::Vehicle:
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;
340 case HighGuid::Transport:
341 case HighGuid::GameObject:
342 target = GetGameObject(step.targetGUID);
343 break;
344 case HighGuid::Corpse:
345 target = GetCorpse(step.targetGUID);
346 break;
347 case HighGuid::Mo_Transport:
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))
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) ?
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}
@ GAMEOBJECT_TYPE_TRAP
Definition: SharedDefines.h:1566
@ GAMEOBJECT_TYPE_FISHINGNODE
Definition: SharedDefines.h:1577
@ CHAT_MSG_RAID_BOSS_WHISPER
Definition: SharedDefines.h:3194
@ 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
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition: ObjectMgr.cpp:83
Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition: ScriptedCreature.cpp:850
std::vector< ItemPosCount > ItemPosCountVec
Definition: Player.h:776
InventoryResult
Definition: Item.h:46
@ EQUIP_ERR_OK
Definition: Item.h:47
@ NULL_BAG
Definition: Item.h:40
@ NULL_SLOT
Definition: Item.h:41
@ GO_READY
Definition: GameObject.h:111
@ TEMPSUMMON_TIMED_OR_DEAD_DESPAWN
Definition: Object.h:46
@ UNIT_NPC_EMOTESTATE
Definition: UpdateFields.h:140
@ OBJECT_FIELD_ENTRY
Definition: UpdateFields.h:27
@ 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
@ WAYPOINT_MOTION_TYPE
Definition: MotionMaster.h:41
@ RANDOM_MOTION_TYPE
Definition: MotionMaster.h:40
#define sWaypointMgr
Definition: WaypointMgr.h:78
Player * GetPlayer(Map const *, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:220
void SendCloseGossip()
Definition: GossipDef.cpp:239
bool isSpawned() const
Definition: GameObject.h:189
void SetLootState(LootState s, Unit *unit=nullptr)
Definition: GameObject.cpp:2444
void SetRespawnTime(int32 respawn)
Definition: GameObject.cpp:1305
void Use(Unit *user)
Definition: GameObject.cpp:1481
Definition: Object.h:103
bool IsPlayer() const
Definition: Object.h:200
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool useBoundingRadius=true) const
Definition: Object.cpp:1332
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1256
Creature * SummonTrigger(float x, float y, float z, float ang, uint32 dur, bool setLevel=false, CreatureAI *(*GetAI)(Creature *)=nullptr)
Definition: Object.cpp:2415
void KilledMonsterCredit(uint32 entry, ObjectGuid guid=ObjectGuid::Empty)
Definition: PlayerQuest.cpp:1926
void GroupEventHappens(uint32 questId, WorldObject const *pEventObject)
Definition: PlayerQuest.cpp:1817
void SendMovieStart(uint32 MovieId)
Definition: Player.cpp:5739
void FailQuest(uint32 quest_id)
Definition: PlayerQuest.cpp:885
PlayerMenu * PlayerTalkClass
Definition: Player.h:2239
void RewardPlayerAndGroupAtEvent(uint32 creature_id, WorldObject *pRewardSource)
Definition: Player.cpp:12769
void SetFacingTo(float ori)
Definition: Unit.cpp:20527
virtual void Say(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:21139
virtual void Yell(std::string_view text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:21144
MotionMaster * GetMotionMaster()
Definition: Unit.h:1620
void SetFacingToObject(WorldObject *object)
Definition: Unit.cpp:20537
void MonsterMoveWithSpeed(float x, float y, float z, float speed)
Definition: Unit.cpp:529
virtual void TextEmote(std::string_view text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:21149
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:1167
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:4909
void NearTeleportTo(Position &pos, bool casting=false, bool vehicleTeleport=false, bool withPet=false, bool removeTransport=false)
Definition: Unit.cpp:19979
virtual void Whisper(std::string_view text, Language language, Player *target, bool isBossWhisper=false)
Definition: Unit.cpp:21154
static T * Find(ObjectGuid guid)
Definition: ObjectAccessor.cpp:53
float Orientation
Definition: ObjectMgr.h:250
uint32 Flags
Definition: ObjectMgr.h:207
struct ScriptInfo::@265::@273 TeleportTo
struct ScriptInfo::@265::@279 RemoveAura
struct ScriptInfo::@265::@274 QuestExplored
uint32 FieldID
Definition: ObjectMgr.h:219
struct ScriptInfo::@265::@289 Model
struct ScriptInfo::@265::@282 CreateItem
uint32 QuestID
Definition: ObjectMgr.h:255
float SearchRadius
Definition: ObjectMgr.h:304
struct ScriptInfo::@265::@281 Playsound
struct ScriptInfo::@265::@271 MoveTo
int32 TextID
Definition: ObjectMgr.h:208
struct ScriptInfo::@265::@285 CallScript
uint32 MovementType
Definition: ObjectMgr.h:376
uint32 MovementDistance
Definition: ObjectMgr.h:377
float DestX
Definition: ObjectMgr.h:229
struct ScriptInfo::@265::@286 Kill
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::@265::@272 FlagToggle
uint32 ScriptID
Definition: ObjectMgr.h:334
uint32 ModelID
Definition: ObjectMgr.h:364
struct ScriptInfo::@265::@277 TempSummonCreature
struct ScriptInfo::@265::@275 KillCredit
uint32 FieldValue
Definition: ObjectMgr.h:220
float PosY
Definition: ObjectMgr.h:278
float DestY
Definition: ObjectMgr.h:230
uint32 PathID
Definition: ObjectMgr.h:327
uint32 MapID
Definition: ObjectMgr.h:243
struct ScriptInfo::@265::@276 RespawnGameobject
struct ScriptInfo::@265::@291 Movement
uint32 IsRepeatable
Definition: ObjectMgr.h:328
int32 Path
Definition: ObjectMgr.h:378
int32 RemoveCorpse
Definition: ObjectMgr.h:342
float PosZ
Definition: ObjectMgr.h:279
uint32 ScriptType
Definition: ObjectMgr.h:335
struct ScriptInfo::@265::@268 Talk
uint32 DespawnDelay
Definition: ObjectMgr.h:268
float PosX
Definition: ObjectMgr.h:277
int32 Radius
Definition: ObjectMgr.h:311
struct ScriptInfo::@265::@284 LoadPath
uint32 TravelTime
Definition: ObjectMgr.h:226
uint32 Distance
Definition: ObjectMgr.h:256
struct ScriptInfo::@265::@290 PlayMovie
struct ScriptInfo::@265::@288 Equip
uint32 SpellID
Definition: ObjectMgr.h:294
struct ScriptInfo::@265::@270 FieldSet
struct ScriptInfo::@265::@280 CastSpell
float DestZ
Definition: ObjectMgr.h:231
uint32 MovieID
Definition: ObjectMgr.h:371
struct ScriptInfo::@265::@269 Emote
uint32 EquipmentID
Definition: ObjectMgr.h:359
uint32 CreatureEntry
Definition: ObjectMgr.h:261
uint32 Amount
Definition: ObjectMgr.h:317
uint32 EmoteID
Definition: ObjectMgr.h:213
struct ScriptInfo::@265::@283 DespawnSelf
Corpse * GetCorpse(ObjectGuid const guid)
Definition: Map.cpp:3312
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:3327
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:3332
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:852

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, 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_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(), ScriptInfo::ItemEntry, ScriptInfo::Kill, ScriptInfo::KillCredit, ScriptInfo::LoadPath, LOG_ERROR, m_scriptSchedule, ScriptInfo::MapID, 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, 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(), ScriptInfo::TravelTime, UNIT_NPC_EMOTESTATE, 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)
2533{
2534 LOG_DEBUG("maps", "Creating player data for himself {}", player->GetGUID().ToString());
2535
2536 WorldPacket packet;
2537 UpdateData data;
2538
2539 // attach to player data current transport data
2540 if (Transport* transport = player->GetTransport())
2541 transport->BuildCreateUpdateBlockForPlayer(&data, player);
2542
2543 // build data for self presence in world at own client (one time for map)
2544 player->BuildCreateUpdateBlockForPlayer(&data, player);
2545
2546 // build and send self update packet before sending to player his own auras
2547 data.BuildPacket(packet);
2548 player->SendDirectMessage(&packet);
2549
2550 // send to player his own auras (this is needed here for timely initialization of some fields on client)
2551 player->GetAurasForTarget(player, true);
2552
2553 // clean buffers for further work
2554 packet.clear();
2555 data.Clear();
2556
2557 // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map
2558 if (Transport* transport = player->GetTransport())
2559 for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
2560 if (player != (*itr) && player->HaveAtClient(*itr))
2561 (*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
2562
2563 data.BuildPacket(packet);
2564 player->SendDirectMessage(&packet);
2565}
Transport * GetTransport() const
Definition: Object.h:604
void Clear()
Definition: UpdateData.cpp:71
void SendDirectMessage(WorldPacket const *data) const
Definition: Player.cpp:5723
bool HaveAtClient(WorldObject const *u) const
Definition: Player.cpp:11444
void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) override
Definition: Player.cpp:3830
void GetAurasForTarget(Unit *target, bool force=false)
Definition: Player.cpp:12092
void clear()
Definition: ByteBuffer.h:122

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)
2568{
2569 // Hack to send out transports
2570 UpdateData transData;
2571 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2572 if (*itr != player->GetTransport())
2573 (*itr)->BuildCreateUpdateBlockForPlayer(&transData, player);
2574
2575 WorldPacket packet;
2576 transData.BuildPacket(packet);
2577 player->GetSession()->SendPacket(&packet);
2578}
WorldSession * GetSession() const
Definition: Player.h:1998
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

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

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

◆ SendObjectUpdates()

void Map::SendObjectUpdates ( )
private
2616{
2617 UpdateDataMapType update_players;
2618 UpdatePlayerSet player_set;
2619
2620 while (!_updateObjects.empty())
2621 {
2622 Object* obj = *_updateObjects.begin();
2623 ASSERT(obj->IsInWorld());
2624
2625 _updateObjects.erase(_updateObjects.begin());
2626 obj->BuildUpdate(update_players, player_set);
2627 }
2628
2629 WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
2630 for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
2631 {
2632 iter->second.BuildPacket(packet);
2633 iter->first->GetSession()->SendPacket(&packet);
2634 packet.clear(); // clean the string
2635 }
2636}
GuidUnorderedSet UpdatePlayerSet
Definition: Object.h:98
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition: Object.h:97
virtual void BuildUpdate(UpdateDataMapType &, UpdatePlayerSet &)
Definition: Object.h:191

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

Referenced by Update().

◆ SendRemoveTransports()

void Map::SendRemoveTransports ( Player player)
2581{
2582 // Hack to send out transports
2583 UpdateData transData;
2584 for (TransportsContainer::const_iterator itr = _transports.begin(); itr != _transports.end(); ++itr)
2585 if (*itr != player->GetTransport())
2586 (*itr)->BuildOutOfRangeUpdateBlock(&transData);
2587
2588 // pussywizard: remove static transports from client
2589 for (GuidUnorderedSet::const_iterator it = player->m_clientGUIDs.begin(); it != player->m_clientGUIDs.end(); )
2590 {
2591 if ((*it).IsTransport())
2592 {
2593 transData.AddOutOfRangeGUID(*it);
2594 it = player->m_clientGUIDs.erase(it);
2595 }
2596 else
2597 ++it;
2598 }
2599
2600 WorldPacket packet;
2601 transData.BuildPacket(packet);
2602 player->GetSession()->SendPacket(&packet);
2603}
void AddOutOfRangeGUID(ObjectGuid guid)
Definition: UpdateData.cpp:31

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

Referenced by RemovePlayerFromMap().

◆ SendToPlayers()

void Map::SendToPlayers ( WorldPacket const *  data) const
2758{
2759 for (MapRefMgr::const_iterator itr = m_mapRefMgr.begin(); itr != m_mapRefMgr.end(); ++itr)
2760 itr->GetSource()->GetSession()->SendPacket(data);
2761}

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

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

◆ SendZoneDynamicInfo()

void Map::SendZoneDynamicInfo ( Player player)
3722{
3723 uint32 zoneId = player->GetZoneId();
3724 ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
3725 if (itr == _zoneDynamicInfo.end())
3726 return;
3727
3728 if (uint32 music = itr->second.MusicId)
3729 player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
3730
3731 if (WeatherState weatherId = itr->second.WeatherId)
3732 {
3733 WorldPackets::Misc::Weather weather(weatherId, itr->second.WeatherGrade);
3734 player->SendDirectMessage(weather.Write());
3735 }
3736
3737 if (uint32 overrideLight = itr->second.OverrideLightId)
3738 {
3739 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 1);
3740 data << uint32(_defaultLight);
3741 data << uint32(overrideLight);
3742 data << uint32(itr->second.LightFadeInTime);
3743 player->SendDirectMessage(&data);
3744 }
3745}
@ SMSG_OVERRIDE_LIGHT
Definition: Opcodes.h:1072
WeatherState
Definition: Weather.h:45
uint32 GetZoneId() const
Definition: Object.cpp:3157
ZoneDynamicInfoMap _zoneDynamicInfo
Definition: Map.h:783
Definition: MiscPackets.h:32
Definition: MiscPackets.h:58

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

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

◆ setGridObjectDataLoaded()

void Map::setGridObjectDataLoaded ( bool  pLoaded,
uint32  x,
uint32  y 
)
inlineprivate
692{ getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); }
void setGridObjectDataLoaded(bool pLoaded)
Definition: NGrid.h:65

References getNGrid(), and NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::setGridObjectDataLoaded().

Referenced by EnsureGridLoaded().

◆ setNGrid()

void Map::setNGrid ( NGridType grid,
uint32  x,
uint32  y 
)
inlineprivate
2606{
2608 {
2609 LOG_ERROR("maps", "map::setNGrid() Invalid grid coordinates found: {}, {}!", x, y);
2610 ABORT();
2611 }
2612 i_grids[x][y] = grid;
2613}

References ABORT, i_grids, LOG_ERROR, and MAX_NUMBER_OF_GRIDS.

Referenced by EnsureGridCreated_i(), Map(), and UnloadGrid().

◆ SetVisibilityRange()

◆ SetZoneMusic()

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

◆ SetZoneOverrideLight()

void Map::SetZoneOverrideLight ( uint32  zoneId,
uint32  lightId,
Milliseconds  fadeInTime 
)
3804{
3805 if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
3806 _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
3807
3808 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
3809 info.OverrideLightId = lightId;
3810 info.LightFadeInTime = static_cast<uint32>(fadeInTime.count());
3811 Map::PlayerList const& players = GetPlayers();
3812
3813 if (!players.IsEmpty())
3814 {
3815 WorldPacket data(SMSG_OVERRIDE_LIGHT, 4 + 4 + 4);
3816 data << uint32(_defaultLight);
3817 data << uint32(lightId);
3818 data << uint32(static_cast<uint32>(fadeInTime.count()));
3819
3820 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3821 if (Player* player = itr->GetSource())
3822 if (player->GetZoneId() == zoneId)
3823 player->SendDirectMessage(&data);
3824 }
3825}
uint32 LightFadeInTime
Definition: Map.h:291
uint32 OverrideLightId
Definition: Map.h:290

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 
)
3783{
3784 if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
3785 _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
3786
3787 ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
3788 info.WeatherId = weatherId;
3789 info.WeatherGrade = weatherGrade;
3790 Map::PlayerList const& players = GetPlayers();
3791
3792 if (!players.IsEmpty())
3793 {
3794 WorldPackets::Misc::Weather weather(weatherId, weatherGrade);
3795
3796 for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3797 if (Player* player = itr->GetSource())
3798 if (player->GetZoneId() == zoneId)
3799 player->SendDirectMessage(weather.Write());
3800 }
3801}
WeatherState WeatherId
Definition: Map.h:288
float WeatherGrade
Definition: Map.h:289

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 
)
2175{
2176 uint32 mask = UNIT_MASK_SUMMON;
2177 if (properties)
2178 {
2179 switch (properties->Category)
2180 {
2182 mask = UNIT_MASK_GUARDIAN;
2183 break;
2185 mask = UNIT_MASK_PUPPET;
2186 break;
2188 mask = UNIT_MASK_MINION;
2189 break;
2193 {
2194 switch (properties->Type)
2195 {
2196 case SUMMON_TYPE_MINION:
2199 mask = UNIT_MASK_GUARDIAN;
2200 break;
2201 case SUMMON_TYPE_TOTEM:
2203 mask = UNIT_MASK_TOTEM;
2204 break;
2207 mask = UNIT_MASK_SUMMON;
2208 break;
2210 case SUMMON_TYPE_JEEVES:
2211 mask = UNIT_MASK_MINION;
2212 break;
2213 default:
2214 if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
2215 mask = UNIT_MASK_GUARDIAN;
2216 break;
2217 }
2218 break;
2219 }
2220 default:
2221 return nullptr;
2222 }
2223 }
2224
2226 if (summoner)
2227 phase = summoner->GetPhaseMask();
2228
2229 TempSummon* summon = nullptr;
2230 switch (mask)
2231 {
2232 case UNIT_MASK_SUMMON:
2233 summon = new TempSummon(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
2234 break;
2235 case UNIT_MASK_GUARDIAN:
2236 summon = new Guardian(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
2237 break;
2238 case UNIT_MASK_PUPPET:
2239 summon = new Puppet(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2240 break;
2241 case UNIT_MASK_TOTEM:
2242 summon = new Totem(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty);
2243 break;
2244 case UNIT_MASK_MINION:
2245 summon = new Minion(properties, summoner ? summoner->GetGUID() : ObjectGuid::Empty, false);
2246 break;
2247 default:
2248 return nullptr;
2249 }
2250
2251 EnsureGridLoaded(Cell(pos.GetPositionX(), pos.GetPositionY()));
2252 if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, phase, entry, vehId, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation()))
2253 {
2254 delete summon;
2255 return nullptr;
2256 }
2257
2258 summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
2259
2260 summon->SetHomePosition(pos);
2261
2262 summon->InitStats(duration);
2263
2264 summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
2265
2266 bool summonerHasTransport = summoner && summoner->GetTransport();
2267 bool summonerIsVehicle = summoner && summoner->IsUnit() && summoner->ToUnit()->IsVehicle();
2268 bool checkTransport = summon->GetOwnerGUID().IsPlayer() || (summonerHasTransport && !summonerIsVehicle);
2269 if (!AddToMap(summon->ToCreature(), checkTransport))
2270 {
2271 delete summon;
2272 return nullptr;
2273 }
2274
2275 summon->InitSummon();
2276
2277 //ObjectAccessor::UpdateObjectVisibility(summon);
2278
2279 return summon;
2280}
@ SUMMON_TYPE_VEHICLE2
Definition: SharedDefines.h:3304
@ SUMMON_TYPE_LIGHTWELL
Definition: SharedDefines.h:3305
@ SUMMON_TYPE_MINION
Definition: SharedDefines.h:3297
@ SUMMON_TYPE_GUARDIAN
Definition: SharedDefines.h:3296
@ SUMMON_TYPE_JEEVES
Definition: SharedDefines.h:3306
@ SUMMON_TYPE_TOTEM
Definition: SharedDefines.h:3298
@ SUMMON_TYPE_VEHICLE
Definition: SharedDefines.h:3303
@ SUMMON_TYPE_MINIPET
Definition: SharedDefines.h:3299
@ SUMMON_TYPE_GUARDIAN2
Definition: SharedDefines.h:3300
@ SUMMON_CATEGORY_PET
Definition: SharedDefines.h:3285
@ SUMMON_CATEGORY_VEHICLE
Definition: SharedDefines.h:3287
@ SUMMON_CATEGORY_ALLY
Definition: SharedDefines.h:3284
@ SUMMON_CATEGORY_PUPPET
Definition: SharedDefines.h:3286
@ SUMMON_CATEGORY_WILD
Definition: SharedDefines.h:3283
@ SUMMON_CATEGORY_UNK
Definition: SharedDefines.h:3288
@ PHASEMASK_NORMAL
Definition: Object.h:60
@ UNIT_CREATED_BY_SPELL
Definition: UpdateFields.h:138
@ UNIT_MASK_PUPPET
Definition: UnitDefines.h:141
@ UNIT_MASK_TOTEM
Definition: UnitDefines.h:138
@ UNIT_MASK_SUMMON
Definition: UnitDefines.h:135
@ UNIT_MASK_GUARDIAN
Definition: UnitDefines.h:137
@ UNIT_MASK_MINION
Definition: UnitDefines.h:136
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:336
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:1126
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:60
Definition: TemporarySummon.h:76
Definition: TemporarySummon.h:95
Definition: TemporarySummon.h:114
bool IsPlayer() const
Definition: ObjectGuid.h:168
Definition: Totem.h:51
ObjectGuid GetOwnerGUID() const
Definition: Unit.h:678
void SetUInt32Value(uint16 index, uint32 value)
Definition: Unit.cpp:21316

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(), 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, and UNIT_MASK_TOTEM.

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_stratholme::instance_stratholme_InstanceMapScript::ProcessSlaughterEvent(), instance_blackrock_depths::instance_blackrock_depths_InstanceMapScript::ReplaceMoiraIfSaved(), boss_ossirian::Reset(), 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(), 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(), 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.
2290{
2291 std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetId(), SUMMONER_TYPE_MAP, group);
2292 if (!data)
2293 return;
2294
2295 for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2296 if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, nullptr, itr->time))
2297 if (list)
2298 list->push_back(summon);
2299}
@ SUMMONER_TYPE_MAP
Definition: TemporarySummon.h:27
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:2174

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

Referenced by at_ancient_leaf::OnTrigger().

◆ 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 
)
2314{
2315 GameObjectTemplate const* goinfo = sObjectMgr->GetGameObjectTemplate(entry);
2316 if (!goinfo)
2317 {
2318 LOG_ERROR("sql.sql", "Gameobject template {} not found in database!", entry);
2319 return nullptr;
2320 }
2321
2322 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
2323 if (!go->Create(GenerateLowGuid<HighGuid::GameObject>(), entry, this, PHASEMASK_NORMAL, x, y, z, ang, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, GO_STATE_READY))
2324 {
2325 delete go;
2326 return nullptr;
2327 }
2328
2329 // Xinef: if gameobject is temporary, set custom spellid
2330 if (respawnTime)
2331 go->SetSpellId(1);
2332
2333 go->SetRespawnTime(respawnTime);
2334 go->SetSpawnedByDefault(false);
2335 AddToMap(go, checkTransport);
2336 return go;
2337}
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: GameObjectData.h:31
Definition: Transport.h:112

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 
)
2340{
2341 return SummonGameObject(entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), rotation0, rotation1, rotation2, rotation3, respawnTime, checkTransport);
2342}
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:2313

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

◆ SwitchGridContainers() [1/3]

template<>
void Map::SwitchGridContainers ( Creature obj,
bool  on 
)
347{
350 if (!p.IsCoordValid())
351 {
352 LOG_ERROR("maps", "Map::SwitchGridContainers: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
353 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
354 return;
355 }
356
357 Cell cell(p);
358 if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
359 return;
360
361 LOG_DEBUG("maps", "Switch object {} from grid[{}, {}] {}", obj->GetGUID().ToString(), cell.GridX(), cell.GridY(), on);
362 NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY());
363 ASSERT(ngrid);
364
365 GridType& grid = ngrid->GetGridType(cell.CellX(), cell.CellY());
366
367 obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add
368
369 if (on)
370 {
371 grid.AddWorldObject(obj);
372 AddWorldObject(obj);
373 }
374 else
375 {
376 grid.AddGridObject(obj);
378 }
379
380 obj->m_isTempWorldObject = on;
381}
bool m_isTempWorldObject
Definition: Creature.h:373
Definition: Grid.h:46
void AddWorldObject(WorldObject *obj)
Definition: Map.h:478
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:479

References Grid< ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddGridObject(), Grid< ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddWorldObject(), AddWorldObject(), ASSERT, Cell::CellX(), Cell::CellY(), Acore::ComputeCellCoord(), Cell::data, NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetGridType(), Object::GetGUID(), getNGrid(), Position::GetPositionX(), Position::GetPositionY(), Cell::grid_x, Cell::grid_y, Cell::GridX(), Cell::GridY(), CoordPair< LIMIT >::IsCoordValid(), IsGridLoaded(), WorldObject::IsPermanentWorldObject(), LOG_DEBUG, LOG_ERROR, Creature::m_isTempWorldObject, Cell::Part, GridObject< T >::RemoveFromGrid(), RemoveWorldObject(), ObjectGuid::ToString(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

◆ SwitchGridContainers() [2/3]

template<>
void Map::SwitchGridContainers ( GameObject obj,
bool  on 
)
385{
388 if (!p.IsCoordValid())
389 {
390 LOG_ERROR("maps", "Map::SwitchGridContainers: Object {} has invalid coordinates X:{} Y:{} grid cell [{}:{}]",
391 obj->GetGUID().ToString(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
392 return;
393 }
394
395 Cell cell(p);
396 if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
397 return;
398
399 //LOG_DEBUG(LOG_FILTER_MAPS, "Switch object {} from grid[{}, {}] {}", obj->GetGUID().ToString(), cell.data.Part.grid_x, cell.data.Part.grid_y, on);
400 NGridType* ngrid = getNGrid(cell.GridX(), cell.GridY());
401 ASSERT(ngrid);
402
403 GridType& grid = ngrid->GetGridType(cell.CellX(), cell.CellY());
404
405 obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add
406
407 if (on)
408 {
409 grid.AddWorldObject(obj);
410 AddWorldObject(obj);
411 }
412 else
413 {
414 grid.AddGridObject(obj);
416 }
417}

References Grid< ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddGridObject(), Grid< ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::AddWorldObject(), AddWorldObject(), ASSERT, Cell::CellX(), Cell::CellY(), Acore::ComputeCellCoord(), Cell::data, NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::GetGridType(), Object::GetGUID(), getNGrid(), Position::GetPositionX(), Position::GetPositionY(), Cell::grid_x, Cell::grid_y, Cell::GridX(), Cell::GridY(), CoordPair< LIMIT >::IsCoordValid(), IsGridLoaded(), WorldObject::IsPermanentWorldObject(), LOG_ERROR, Cell::Part, GridObject< T >::RemoveFromGrid(), RemoveWorldObject(), ObjectGuid::ToString(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

◆ SwitchGridContainers() [3/3]

template<class T >
void Map::SwitchGridContainers ( T *  obj,
bool  on 
)
342{
343}

◆ ToBattlegroundMap() [1/2]

◆ ToBattlegroundMap() [2/2]

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

References IsBattlegroundOrArena().

◆ ToInstanceMap() [1/2]

◆ ToInstanceMap() [2/2]

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

References IsDungeon().

◆ ToMapInstanced() [1/2]

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

References Instanceable().

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

◆ ToMapInstanced() [2/2]

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

References Instanceable().

◆ UnloadAll()

void Map::UnloadAll ( )
virtual

Reimplemented in InstanceMap, and MapInstanced.

1279{
1280 // clear all delayed moves, useless anyway do this moves before map unload.
1281 _creaturesToMove.clear();
1282 _gameObjectsToMove.clear();
1283
1285 {
1286 NGridType& grid(*i->GetSource());
1287 ++i;
1288 UnloadGrid(grid); // deletes the grid and removes it from the GridRefMgr
1289 }
1290
1291 // pussywizard: crashfix, some npc can be left on transport (not a default passenger)
1292 if (!AllTransportsEmpty())
1294
1295 for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
1296 {
1297 MotionTransport* transport = *itr;
1298 ++itr;
1299
1300 transport->RemoveFromWorld();
1301 delete transport;
1302 }
1303
1304 _transports.clear();
1305
1306 for (auto& cellCorpsePair : _corpsesByCell)
1307 {
1308 for (Corpse* corpse : cellCorpsePair.second)
1309 {
1310 corpse->RemoveFromWorld();
1311 corpse->ResetMap();
1312 delete corpse;
1313 }
1314 }
1315
1316 _corpsesByCell.clear();
1317 _corpsesByPlayer.clear();
1318 _corpseBones.clear();
1319}
Definition: GridRefMgr.h:28
iterator end()
Definition: GridRefMgr.h:36
bool UnloadGrid(NGridType &ngrid)
Definition: Map.cpp:1214
void AllTransportsRemovePassengers()
Definition: Map.cpp:3577
bool AllTransportsEmpty() const
Definition: Map.cpp:3568

References _corpseBones, _corpsesByCell, _corpsesByPlayer, _creaturesToMove, _gameObjectsToMove, _transports, AllTransportsEmpty(), AllTransportsRemovePassengers(), GridRefMgr< OBJECT >::end(), Corpse::RemoveFromWorld(), GameObject::RemoveFromWorld(), WorldObject::ResetMap(), and UnloadGrid().

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

◆ UnloadGrid()

bool Map::UnloadGrid ( NGridType ngrid)
1215{
1216 // pussywizard: UnloadGrid only done when whole map is unloaded, no need to worry about moving npcs between grids, etc.
1217
1218 const uint32 x = ngrid.getX();
1219 const uint32 y = ngrid.getY();
1220
1221 {
1222 ObjectGridCleaner worker;
1224 ngrid.VisitAllGrids(visitor);
1225 }
1226
1228
1229 {
1230 ObjectGridUnloader worker;
1232 ngrid.VisitAllGrids(visitor);
1233 }
1234
1235 ASSERT(i_objectsToRemove.empty());
1236
1237 delete &ngrid;
1238 setNGrid(nullptr, x, y);
1239
1240 int gx = (MAX_NUMBER_OF_GRIDS - 1) - x;
1241 int gy = (MAX_NUMBER_OF_GRIDS - 1) - y;
1242
1243 if (i_InstanceId == 0)
1244 {
1245 if (GridMaps[gx][gy])
1246 {
1247 GridMaps[gx][gy]->unloadData();
1248 delete GridMaps[gx][gy];
1249 }
1250 // x and y are swapped
1253 }
1254
1255 GridMaps[gx][gy] = nullptr;
1256
1257 LOG_DEBUG("maps", "Unloading grid[{}, {}] for map {} finished", x, y, GetId());
1258 return true;
1259}
bool unloadMap(uint32 mapId, int32 x, int32 y)
Definition: MMapMgr.cpp:204
void unloadMap(unsigned int mapId, int x, int y) override
Definition: VMapMgr2.cpp:160
Definition: TypeContainerVisitor.h:84
int32 getX() const
Definition: NGrid.h:57
int32 getY() const
Definition: NGrid.h:58
void VisitAllGrids(TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition: NGrid.h:91
Definition: ObjectGridLoader.h:56
Definition: ObjectGridLoader.h:63
void unloadData()
Definition: Map.cpp:1412

References ASSERT, MMAP::MMapFactory::createOrGetMMapMgr(), VMAP::VMapFactory::createOrGetVMapMgr(), GetId(), NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::getX(), NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::getY(), GridMaps, i_InstanceId, i_objectsToRemove, LOG_DEBUG, MAX_NUMBER_OF_GRIDS, RemoveAllObjectsInRemoveList(), setNGrid(), GridMap::unloadData(), MMAP::MMapMgr::unloadMap(), VMAP::VMapMgr2::unloadMap(), and NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::VisitAllGrids().

Referenced by UnloadAll().

◆ Update()

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

update worldsessions for existing players

update active cells around players and active objects

  • Process necessary scripts

Reimplemented in InstanceMap, and MapInstanced.

740{
741 if (t_diff)
742 _dynamicTree.update(t_diff);
743
746 {
747 Player* player = m_mapRefIter->GetSource();
748 if (player && player->IsInWorld())
749 {
750 //player->Update(t_diff);
751 WorldSession* session = player->GetSession();
752 MapSessionFilter updater(session);
753 session->Update(s_diff, updater);
754 }
755 }
756
758
759 if (!t_diff)
760 {
762 {
763 Player* player = m_mapRefIter->GetSource();
764
765 if (!player || !player->IsInWorld())
766 continue;
767
768 // update players at tick
769 player->Update(s_diff);
770 }
771
773 return;
774 }
775
779
780 Acore::ObjectUpdater updater(t_diff, false);
781
782 // for creature
784 // for pets
786
787 // for large creatures
788 Acore::ObjectUpdater largeObjectUpdater(t_diff, true);
789 TypeContainerVisitor<Acore::ObjectUpdater, GridTypeMapContainer > grid_large_object_update(largeObjectUpdater);
790 TypeContainerVisitor<Acore::ObjectUpdater, WorldTypeMapContainer > world_large_object_update(largeObjectUpdater);
791
792 // pussywizard: container for far creatures in combat with players
793 std::vector<Creature*> updateList;
794 updateList.reserve(10);
795
796 // non-player active objects, increasing iterator in the loop in case of object removal
798 {
801
802 if (!obj || !obj->IsInWorld())
803 continue;
804
805 VisitNearbyCellsOf(obj, grid_object_update, world_object_update, grid_large_object_update, world_large_object_update);
806 }
807
808 // the player iterator is stored in the map object
809 // to make sure calls to Map::Remove don't invalidate it
811 {
812 Player* player = m_mapRefIter->GetSource();
813
814 if (!player || !player->IsInWorld())
815 continue;
816
817 // update players at tick
818 player->Update(s_diff);
819
820 VisitNearbyCellsOfPlayer(player, grid_object_update, world_object_update, grid_large_object_update, world_large_object_update);
821
822 // If player is using far sight, visit that object too
823 if (WorldObject* viewPoint = player->GetViewpoint())
824 {
825 if (Creature* viewCreature = viewPoint->ToCreature())
826 {
827 VisitNearbyCellsOf(viewCreature, grid_object_update, world_object_update, grid_large_object_update, world_large_object_update);
828 }
829 else if (DynamicObject* viewObject = viewPoint->ToDynObject())
830 {
831 VisitNearbyCellsOf(viewObject, grid_object_update, world_object_update, grid_large_object_update, world_large_object_update);
832 }
833 }
834
835 // handle updates for creatures in combat with player and are more than X yards away
836 if (player->IsInCombat())
837 {
838 updateList.clear();
839 float rangeSq = player->GetGridActivationRange() - 1.0f;
840 rangeSq = rangeSq * rangeSq;
841 HostileReference* ref = player->getHostileRefMgr().getFirst();
842 while (ref)
843 {
844 if (Unit* unit = ref->GetSource()->GetOwner())
845 if (Creature* cre = unit->ToCreature())
846 if (cre->FindMap() == player->FindMap() && cre->GetExactDist2dSq(player) > rangeSq)
847 updateList.push_back(cre);
848 ref = ref->next();
849 }
850 for (std::vector<Creature*>::const_iterator itr = updateList.begin(); itr != updateList.end(); ++itr)
851 VisitNearbyCellsOf(*itr, grid_object_update, world_object_update, grid_large_object_update, world_large_object_update);
852 }
853 }
854
855 for (_transportsUpdateIter = _transports.begin(); _transportsUpdateIter != _transports.end();) // pussywizard: transports updated after VisitNearbyCellsOf, grids around are loaded, everything ok
856 {
859
860 if (!transport->IsInWorld())
861 continue;
862
863 transport->Update(t_diff);
864 }
865
867
869 if (!m_scriptSchedule.empty())
870 {
871 i_scriptLock = true;
873 i_scriptLock = false;
874 }
875
879
881
882 sScriptMgr->OnMapUpdate(this, t_diff);
883
884 METRIC_VALUE("map_creatures", uint64(GetObjectsStore().Size<Creature>()),
885 METRIC_TAG("map_id", std::to_string(GetId())),
886 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
887
888 METRIC_VALUE("map_gameobjects", uint64(GetObjectsStore().Size<GameObject>()),
889 METRIC_TAG("map_id", std::to_string(GetId())),
890 METRIC_TAG("map_instanceid", std::to_string(GetInstanceId())));
891}
#define METRIC_VALUE(category, value,...)
Definition: Metric.h:193
#define METRIC_TAG(name, value)
Definition: Metric.h:159
std::uint64_t uint64
Definition: Define.h:106
void update(uint32 diff)
Definition: DynamicTree.cpp:142
FROM * GetSource() const
Definition: Reference.h:97
TaskScheduler & Update(success_t const &callback=EmptyCallback)
Definition: TaskScheduler.cpp:27
HostileReference * getFirst()
Definition: HostileRefMgr.h:59
Definition: ThreatMgr.h:48
HostileReference * next()
Definition: ThreatMgr.h:115
Unit * GetOwner() const
Definition: ThreatMgr.h:236
DynamicObject * ToDynObject()
Definition: Object.h:221
float GetGridActivationRange() const
Definition: Object.cpp:1634
void Update(uint32 time) override
Definition: PlayerUpdates.cpp:53
WorldObject * GetViewpoint() const
Definition: Player.cpp:13247
void Update(uint32 diff) override
Definition: Transport.cpp:138
bool IsInCombat() const
Definition: Unit.h:884
Definition: GridNotifiers.h:158
void HandleDelayedVisibility()
Definition: Map.cpp:893
MapStoredObjectTypesContainer & GetObjectsStore()
Definition: Map.h:515
void MoveAllGameObjectsInMoveList()
Definition: Map.cpp:1156
void VisitNearbyCellsOfPlayer(Player *player, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &worldVisitor, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &largeGridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &largeWorldVisitor)
Definition: Map.cpp:664
void resetMarkedCellsLarge()
Definition: Map.h:471
void resetMarkedCells()
Definition: Map.h:468
void MoveAllDynamicObjectsInMoveList()
Definition: Map.cpp:1185
void VisitNearbyCellsOf(WorldObject *obj, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &worldVisitor, TypeContainerVisitor< Acore::ObjectUpdater, GridTypeMapContainer > &largeGridVisitor, TypeContainerVisitor< Acore::ObjectUpdater, WorldTypeMapContainer > &largeWorldVisitor)
Definition: Map.cpp:699
void MoveAllCreaturesInMoveList()
Definition: Map.cpp:1127
MapRefMgr::iterator m_mapRefIter
Definition: Map.h:715
void SendObjectUpdates()
Definition: Map.cpp:2615
Definition: WorldSession.h:244
Player session in the World.
Definition: WorldSession.h:330
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update)
Definition: WorldSession.cpp:289

References _creatureRespawnScheduler, _dynamicTree, _transports, _transportsUpdateIter, MapRefMgr::begin(), MapRefMgr::end(), WorldObject::FindMap(), HostileRefMgr::getFirst(), WorldObject::GetGridActivationRange(), Unit::getHostileRefMgr(), GetId(), GetInstanceId(), GetObjectsStore(), ThreatMgr::GetOwner(), Player::GetSession(), Reference< TO, FROM >::GetSource(), Player::GetViewpoint(), HandleDelayedVisibility(), i_scriptLock, Unit::IsInCombat(), Object::IsInWorld(), m_activeNonPlayers, m_activeNonPlayersIter, m_mapRefIter, m_mapRefMgr, m_scriptSchedule, METRIC_TAG, METRIC_VALUE, MoveAllCreaturesInMoveList(), MoveAllDynamicObjectsInMoveList(), MoveAllGameObjectsInMoveList(), HostileReference::next(), resetMarkedCells(), resetMarkedCellsLarge(), ScriptsProcess(), SendObjectUpdates(), sScriptMgr, Object::ToCreature(), Object::ToDynObject(), TaskScheduler::Update(), DynamicMapTree::update(), MotionTransport::Update(), WorldSession::Update(), Player::Update(), VisitNearbyCellsOf(), and VisitNearbyCellsOfPlayer().

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

◆ UpdateActiveCells()

void Map::UpdateActiveCells ( const float &  x,
const float &  y,
const uint32  t_diff 
)
private

◆ UpdateEncounterState()

void Map::UpdateEncounterState ( EncounterCreditType  type,
uint32  creditEntry,
Unit source 
)
3475{
3476 Difficulty difficulty_fixed = (IsSharedDifficultyMap(GetId()) ? Difficulty(GetDifficulty() % 2) : GetDifficulty());
3477 DungeonEncounterList const* encounters;
3478 // 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.
3479 if ((GetId() == 631 || GetId() == 724) && IsHeroic())
3480 {
3481 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), !Is25ManRaid() ? RAID_DIFFICULTY_10MAN_NORMAL : RAID_DIFFICULTY_25MAN_NORMAL);
3482 }
3483 else
3484 {
3485 encounters = sObjectMgr->GetDungeonEncounterList(GetId(), difficulty_fixed);
3486 }
3487
3488 if (!encounters)
3489 {
3490 return;
3491 }
3492
3493 uint32 dungeonId = 0;
3494 bool updated = false;
3495
3496 for (DungeonEncounterList::const_iterator itr = encounters->begin(); itr != encounters->end(); ++itr)
3497 {
3498 DungeonEncounter const* encounter = *itr;
3499 if (encounter->creditType == type && encounter->creditEntry == creditEntry)
3500 {
3501 if (source)
3502 if (InstanceScript* instanceScript = source->GetInstanceScript())
3503 {
3504 uint32 prevMask = instanceScript->GetCompletedEncounterMask();
3505 instanceScript->SetCompletedEncountersMask((1 << encounter->dbcEntry->encounterIndex) | instanceScript->GetCompletedEncounterMask(), true);
3506 if (prevMask != instanceScript->GetCompletedEncounterMask())
3507 updated = true;
3508 }
3509
3510 if (encounter->lastEncounterDungeon)
3511 {
3512 dungeonId = encounter->lastEncounterDungeon;
3513 break;
3514 }
3515 }
3516 }
3517
3518 // pussywizard:
3519 LogEncounterFinished(type, creditEntry);
3520
3521 sScriptMgr->OnAfterUpdateEncounterState(this, type, creditEntry, source, difficulty_fixed, encounters, dungeonId, updated);
3522
3523 if (dungeonId)
3524 {
3525 Map::PlayerList const& players = GetPlayers();
3526 for (Map::PlayerList::const_iterator i = players.begin(); i != players.end(); ++i)
3527 {
3528 if (Player* player = i->GetSource())
3529 if (Group* grp = player->GetGroup())
3530 if (grp->isLFGGroup())
3531 {
3532 sLFGMgr->FinishDungeon(grp->GetGUID(), dungeonId, this);
3533 return;
3534 }
3535 }
3536 }
3537}
@ RAID_DIFFICULTY_10MAN_NORMAL
Definition: DBCEnums.h:273
@ RAID_DIFFICULTY_25MAN_NORMAL
Definition: DBCEnums.h:274
std::list< DungeonEncounter const * > DungeonEncounterList
Definition: ObjectMgr.h:712
#define sLFGMgr
Definition: LFGMgr.h:641
bool IsSharedDifficultyMap(uint32 mapid)
Definition: DBCStores.cpp:829
InstanceScript * GetInstanceScript() const
Definition: Object.cpp:1203
Definition: ObjectMgr.h:702
DungeonEncounterEntry const * dbcEntry
Definition: ObjectMgr.h:706
EncounterCreditType creditType
Definition: ObjectMgr.h:707
uint32 lastEncounterDungeon
Definition: ObjectMgr.h:709
uint32 creditEntry
Definition: ObjectMgr.h:708
Definition: Group.h:169
Definition: InstanceScript.h:142
bool Is25ManRaid() const
Definition: Map.h:451
void LogEncounterFinished(EncounterCreditType type, uint32 creditEntry)
Definition: Map.cpp:3539
bool IsHeroic() const
Definition: Map.h:450
uint32 encounterIndex
Definition: DBCStructure.h:870

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

◆ UpdateIteratorBack()

void Map::UpdateIteratorBack ( Player player)
3347{
3348 if (m_mapRefIter == player->GetMapRef())
3350}
MapReference & GetMapRef()
Definition: Player.h:2491
MapReference const * nocheck_prev() const
Definition: MapReference.h:49

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

Referenced by Player::ResetMap().

◆ Visit()

template<class T , class CONTAINER >
void Map::Visit ( const Cell cell,
TypeContainerVisitor< T, CONTAINER > &  visitor 
)
inline
872{
873 const uint32 x = cell.GridX();
874 const uint32 y = cell.GridY();
875 const uint32 cell_x = cell.CellX();
876 const uint32 cell_y = cell.CellY();
877
878 if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y)))
879 {
880 EnsureGridLoaded(cell);
881 getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
882 }
883}
uint32 GridX() const
Definition: Cell.h:71
bool NoCreate() const
Definition: Cell.h:73
uint32 GridY() const
Definition: Cell.h:72
uint32 CellX() const
Definition: Cell.h:69
uint32 CellY() const
Definition: Cell.h:70
void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition: NGrid.h:100

References Cell::CellX(), Cell::CellY(), EnsureGridLoaded(), getNGrid(), Cell::GridX(), Cell::GridY(), IsGridLoaded(), Cell::NoCreate(), and NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES >::VisitGrid().

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

◆ VisitNearbyCellsOf()

703{
704 // Check for valid position
705 if (!obj->IsPositionValid())
706 return;
707
708 // Update mobs/objects in ALL visible cells around object!
710
711 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
712 {
713 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
714 {
715 // marked cells are those that have been visited
716 // don't visit the same cell twice
717 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
718 if (isCellMarked(cell_id))
719 continue;
720
721 markCell(cell_id);
722 CellCoord pair(x, y);
723 Cell cell(pair);
724 //cell.SetNoCreate(); // in mmaps this is missing
725
726 Visit(cell, gridVisitor);
727 Visit(cell, worldVisitor);
728
729 if (!isCellMarkedLarge(cell_id))
730 {
731 markCellLarge(cell_id);
732 Visit(cell, largeGridVisitor);
733 Visit(cell, largeWorldVisitor);
734 }
735 }
736 }
737}
bool IsPositionValid() const
Definition: Position.cpp:176
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:46
bool isCellMarkedLarge(uint32 pCellId)
Definition: Map.h:472
bool isCellMarked(uint32 pCellId)
Definition: Map.h:469
void Visit(const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
Definition: Map.h:871
void markCell(uint32 pCellId)
Definition: Map.h:470
void markCellLarge(uint32 pCellId)
Definition: Map.h:473

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

Referenced by Update(), and VisitNearbyCellsOfPlayer().

◆ VisitNearbyCellsOfPlayer()

668{
669 // check for valid position
670 if (!player->IsPositionValid())
671 return;
672
673 // check normal grid activation range of the player
674 VisitNearbyCellsOf(player, gridVisitor, worldVisitor, largeGridVisitor, largeWorldVisitor);
675
676 // check maximum visibility distance for large creatures
678
679 for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
680 {
681 for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
682 {
683 // marked cells are those that have been visited
684 // don't visit the same cell twice
685 uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
686 if (isCellMarkedLarge(cell_id))
687 continue;
688
689 markCellLarge(cell_id);
690 CellCoord pair(x, y);
691 Cell cell(pair);
692
693 Visit(cell, largeGridVisitor);
694 Visit(cell, largeWorldVisitor);
695 }
696 }
697}
#define MAX_VISIBILITY_DISTANCE
Definition: ObjectDefines.h:31

References Cell::CalculateCellArea(), Position::GetPositionX(), Position::GetPositionY(), CellArea::high_bound, isCellMarkedLarge(), Position::IsPositionValid(), CellArea::low_bound, markCellLarge(), MAX_VISIBILITY_DISTANCE, TOTAL_NUMBER_OF_CELLS_PER_MAP, Visit(), VisitNearbyCellsOf(), CoordPair< LIMIT >::x_coord, and CoordPair< LIMIT >::y_coord.

Referenced by Update().

Friends And Related Function Documentation

◆ MapReference

friend class MapReference
friend

Member Data Documentation

◆ _corpseBones

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

◆ _corpsesByCell

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

◆ _corpsesByPlayer

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

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

◆ _objectsStore

◆ _transports

◆ _transportsUpdateIter

TransportsContainer::iterator Map::_transportsUpdateIter
protected

◆ _updateObjects

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

◆ _zoneDynamicInfo

◆ CreatureGroupHolder

◆ CustomData

DataMap Map::CustomData

◆ GridLock

std::mutex Map::GridLock
protected

Referenced by EnsureGridCreated().

◆ GridMaps

◆ i_grids

Referenced by getNGrid(), and setNGrid().

◆ i_InstanceId

uint32 Map::i_InstanceId
protected

◆ i_mapEntry

◆ i_objectsForDelayedVisibility

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

◆ i_objectsToRemove

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

◆ i_objectsToSwitch

std::map<WorldObject*, bool> Map::i_objectsToSwitch
private

◆ i_scriptLock

bool Map::i_scriptLock
private

◆ i_spawnMode

uint8 Map::i_spawnMode
protected

◆ i_worldObjects

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

◆ Lock

std::mutex Map::Lock
protected

◆ m_activeNonPlayers

ActiveNonPlayers Map::m_activeNonPlayers
protected

◆ m_activeNonPlayersIter

ActiveNonPlayers::iterator Map::m_activeNonPlayersIter
protected

Referenced by RemoveFromActiveHelper(), and Update().

◆ 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(), LoadMap(), 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

◆ marked_cells_large

◆ MMapLock

std::shared_mutex Map::MMapLock
protected

Referenced by GetMMapLock().