TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Map Class Reference

#include <Map.h>

Public Types

enum  EnterState {
  CAN_ENTER = 0, CANNOT_ENTER_ALREADY_IN_MAP = 1, CANNOT_ENTER_NO_ENTRY, CANNOT_ENTER_UNINSTANCED_DUNGEON,
  CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, CANNOT_ENTER_NOT_IN_RAID, CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, CANNOT_ENTER_INSTANCE_BIND_MISMATCH,
  CANNOT_ENTER_TOO_MANY_INSTANCES, CANNOT_ENTER_MAX_PLAYERS, CANNOT_ENTER_ZONE_IN_COMBAT, CANNOT_ENTER_UNSPECIFIED_REASON
}
 
typedef MapRefManager PlayerList
 
typedef
std::unordered_multimap
< ObjectGuid::LowType,
Creature * > 
CreatureBySpawnIdContainer
 
typedef
std::unordered_multimap
< ObjectGuid::LowType,
GameObject * > 
GameObjectBySpawnIdContainer
 
- Public Types inherited from GridRefManager< NGridType >
typedef
LinkedListHead::Iterator
< GridReference< NGridType > > 
iterator
 
- Public Types inherited from RefManager< GridRefManager< NGridType >, NGridType >
typedef
LinkedListHead::Iterator
< Reference< GridRefManager
< NGridType >, NGridType > > 
iterator
 
- Public Types inherited from LinkedListHead
typedef Iterator
< LinkedListElement
iterator
 

Public Member Functions

 Map (uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map *_parent=NULL)
 
virtual ~Map ()
 
MapEntry constGetEntry () const
 
bool CanUnload (uint32 diff)
 
virtual bool AddPlayerToMap (Player *player, bool initPlayer=true)
 
virtual void RemovePlayerFromMap (Player *, bool)
 
template<class T >
bool AddToMap (T *)
 
template<class T >
void RemoveFromMap (T *, bool)
 
void VisitNearbyCellsOf (WorldObject *obj, TypeContainerVisitor< Trinity::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Trinity::ObjectUpdater, WorldTypeMapContainer > &worldVisitor)
 
virtual void Update (const uint32)
 
float GetVisibilityRange () const
 
virtual void InitVisibilityDistance ()
 
void PlayerRelocation (Player *, float x, float y, float z, float orientation)
 
void CreatureRelocation (Creature *creature, float x, float y, float z, float ang, bool respawnRelocationOnFail=true)
 
void GameObjectRelocation (GameObject *go, float x, float y, float z, float orientation, bool respawnRelocationOnFail=true)
 
void DynamicObjectRelocation (DynamicObject *go, float x, float y, float z, float orientation)
 
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
 
bool GetUnloadLock (const GridCoord &p) const
 
void SetUnloadLock (const GridCoord &p, bool on)
 
void LoadGrid (float x, float y)
 
bool UnloadGrid (NGridType &ngrid, bool pForce)
 
virtual void UnloadAll ()
 
void ResetGridExpiry (NGridType &grid, float factor=1) const
 
time_t GetGridExpiry (void) const
 
uint32 GetId (void) const
 
Map constGetParent () const
 
float GetHeight (float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
 
float GetMinHeight (float x, float y) const
 
ZLiquidStatus getLiquidStatus (float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
 
uint32 GetAreaId (float x, float y, float z, bool *isOutdoors) const
 
bool GetAreaInfo (float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
 
uint32 GetAreaId (float x, float y, float z) const
 
uint32 GetZoneId (float x, float y, float z) const
 
void GetZoneAndAreaId (uint32 &zoneid, uint32 &areaid, float x, float y, float z) const
 
bool IsOutdoors (float x, float y, float z) const
 
uint8 GetTerrainType (float x, float y) const
 
float GetWaterLevel (float x, float y) const
 
bool IsInWater (float x, float y, float z, LiquidData *data=nullptr) const
 
bool IsUnderWater (float x, float y, float z) const
 
void MoveAllCreaturesInMoveList ()
 
void MoveAllGameObjectsInMoveList ()
 
void MoveAllDynamicObjectsInMoveList ()
 
void RemoveAllObjectsInRemoveList ()
 
virtual void RemoveAllPlayers ()
 
bool CreatureRespawnRelocation (Creature *c, bool diffGridOnly)
 
bool GameObjectRespawnRelocation (GameObject *go, bool diffGridOnly)
 
bool CheckGridIntegrity (Creature *c, bool moved) const
 
uint32 GetInstanceId () const
 
uint8 GetSpawnMode () const
 
virtual EnterState CannotEnter (Player *)
 
const char * GetMapName () const
 
Difficulty GetDifficultyID () const
 
MapDifficultyEntry constGetMapDifficulty () const
 
uint32 GetDifficultyLootBonusTreeMod () 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 IsGarrison () 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 UpdateObjectVisibility (WorldObject *obj, Cell cell, CellCoord cellpair)
 
void UpdateObjectsVisibilityFor (Player *player, Cell cell, CellCoord cellpair)
 
void resetMarkedCells ()
 
bool isCellMarked (uint32 pCellId)
 
void markCell (uint32 pCellId)
 
bool HavePlayers () const
 
uint32 GetPlayersCountExceptGMs () const
 
bool ActiveObjectsNearGrid (NGridType const &ngrid) const
 
void AddWorldObject (WorldObject *obj)
 
void RemoveWorldObject (WorldObject *obj)
 
void SendToPlayers (WorldPacket const *data) const
 
PlayerList constGetPlayers () 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)
 
template<class NOTIFIER >
void VisitAll (const float &x, const float &y, float radius, NOTIFIER &notifier)
 
template<class NOTIFIER >
void VisitFirstFound (const float &x, const float &y, float radius, NOTIFIER &notifier)
 
template<class NOTIFIER >
void VisitWorld (const float &x, const float &y, float radius, NOTIFIER &notifier)
 
template<class NOTIFIER >
void VisitGrid (const float &x, const float &y, float radius, NOTIFIER &notifier)
 
void UpdateIteratorBack (Player *player)
 
TempSummonSummonCreature (uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=NULL, uint32 duration=0, Unit *summoner=NULL, uint32 spellId=0, uint32 vehId=0)
 
void SummonCreatureGroup (uint8 group, std::list< TempSummon * > *list=NULL)
 
AreaTriggerGetAreaTrigger (ObjectGuid const &guid)
 
CorpseGetCorpse (ObjectGuid const &guid)
 
CreatureGetCreature (ObjectGuid const &guid)
 
DynamicObjectGetDynamicObject (ObjectGuid const &guid)
 
GameObjectGetGameObject (ObjectGuid const &guid)
 
PetGetPet (ObjectGuid const &guid)
 
TransportGetTransport (ObjectGuid const &guid)
 
MapStoredObjectTypesContainerGetObjectsStore ()
 
CreatureBySpawnIdContainerGetCreatureBySpawnIdStore ()
 
GameObjectBySpawnIdContainerGetGameObjectBySpawnIdStore ()
 
std::unordered_set< Corpse * >
const
GetCorpsesInCell (uint32 cellId) const
 
CorpseGetCorpseByPlayer (ObjectGuid const &ownerGuid) const
 
MapInstancedToMapInstanced ()
 
MapInstanced constToMapInstanced () const
 
InstanceMapToInstanceMap ()
 
InstanceMap constToInstanceMap () const
 
BattlegroundMapToBattlegroundMap ()
 
BattlegroundMap constToBattlegroundMap () const
 
float GetWaterOrGroundLevel (float x, float y, float z, float *ground=NULL, bool swim=false) 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) const
 
void Balance ()
 
void RemoveGameObjectModel (const GameObjectModel &model)
 
void InsertGameObjectModel (const GameObjectModel &model)
 
bool ContainsGameObjectModel (const GameObjectModel &model) 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)
 
virtual ObjectGuid::LowType GetOwnerGuildId (uint32=TEAM_OTHER) 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 ()
 
void LoadCorpseData ()
 
void DeleteCorpseData ()
 
void AddCorpse (Corpse *corpse)
 
void RemoveCorpse (Corpse *corpse)
 
CorpseConvertCorpseToBones (ObjectGuid const &ownerGuid, bool insignia=false)
 
void RemoveOldCorpses ()
 
void SendInitTransports (Player *player)
 
void SendRemoveTransports (Player *player)
 
void SendUpdateTransportVisibility (Player *player, std::set< uint32 > const &previousPhases)
 
void SendZoneDynamicInfo (Player *player)
 
void SetZoneMusic (uint32 zoneId, uint32 musicId)
 
void SetZoneWeather (uint32 zoneId, WeatherState weatherId, float weatherGrade)
 
void SetZoneOverrideLight (uint32 zoneId, uint32 lightId, uint32 fadeInTime)
 
void UpdateAreaDependentAuras ()
 
template<HighGuid high>
ObjectGuid::LowType GenerateLowGuid ()
 
void AddUpdateObject (Object *obj)
 
void RemoveUpdateObject (Object *obj)
 
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 DeleteFromWorld (Transport *transport)
 
template<>
void InitializeObject (Creature *obj)
 
template<>
void InitializeObject (GameObject *obj)
 
template<>
bool AddToMap (Transport *obj)
 
template<>
void RemoveFromMap (Transport *obj, bool remove)
 
template<>
void AddToActive (Creature *c)
 
template<>
void AddToActive (DynamicObject *d)
 
template<>
void RemoveFromActive (Creature *c)
 
template<>
void RemoveFromActive (DynamicObject *obj)
 
- Public Member Functions inherited from GridRefManager< NGridType >
GridReference< NGridType > * getFirst ()
 
GridReference< NGridType > * getLast ()
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
- Public Member Functions inherited from RefManager< GridRefManager< NGridType >, NGridType >
 RefManager ()
 
virtual ~RefManager ()
 
Reference< GridRefManager
< NGridType >, NGridType > * 
getFirst ()
 
Reference< GridRefManager
< NGridType >, NGridType >
const
getFirst () const
 
Reference< GridRefManager
< NGridType >, NGridType > * 
getLast ()
 
Reference< GridRefManager
< NGridType >, NGridType >
const
getLast () const
 
iterator begin ()
 
iterator end ()
 
iterator rbegin ()
 
iterator rend ()
 
void clearReferences ()
 
- Public Member Functions inherited from LinkedListHead
 LinkedListHead ()
 
virtual ~LinkedListHead ()
 
bool isEmpty () const
 
LinkedListElementgetFirst ()
 
LinkedListElement constgetFirst () const
 
LinkedListElementgetLast ()
 
LinkedListElement constgetLast () 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 InitStateMachine ()
 
static void DeleteStateMachine ()
 
static void DeleteRespawnTimesInDB (uint16 mapId, uint32 instanceId)
 

Public Attributes

CreatureGroupHolderType CreatureGroupHolder
 

Protected Types

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

Protected Member Functions

void SetUnloadReferenceLock (const GridCoord &p, bool on)
 
virtual void LoadGridObjects (NGridType *grid, Cell const &cell)
 

Protected Attributes

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

Private Types

typedef std::multimap< time_t,
ScriptAction
ScriptScheduleMap
 

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)
 
GridMapGetGrid (float x, float y)
 
void SetTimer (uint32 t)
 
void SendInitSelf (Player *player)
 
bool CreatureCellRelocation (Creature *creature, Cell new_cell)
 
bool GameObjectCellRelocation (GameObject *go, Cell new_cell)
 
bool DynamicObjectCellRelocation (DynamicObject *go, Cell new_cell)
 
template<class T >
void InitializeObject (T *obj)
 
void AddCreatureToMoveList (Creature *c, float x, float y, float z, float ang)
 
void RemoveCreatureFromMoveList (Creature *c)
 
void AddGameObjectToMoveList (GameObject *go, float x, float y, float z, float ang)
 
void RemoveGameObjectFromMoveList (GameObject *go)
 
void AddDynamicObjectToMoveList (DynamicObject *go, float x, float y, float z, float ang)
 
void RemoveDynamicObjectFromMoveList (DynamicObject *go)
 
bool IsGridLoaded (const GridCoord &) const
 
void EnsureGridCreated (const GridCoord &)
 
void EnsureGridCreated_i (const GridCoord &)
 
bool EnsureGridLoaded (Cell const &)
 
void EnsureGridLoadedForActiveObject (Cell const &, WorldObject *object)
 
void buildNGridLinkage (NGridType *pNGridType)
 
NGridTypegetNGrid (uint32 x, uint32 y) const
 
bool isGridObjectDataLoaded (uint32 x, uint32 y) const
 
void setGridObjectDataLoaded (bool pLoaded, uint32 x, uint32 y)
 
void setNGrid (NGridType *grid, uint32 x, uint32 y)
 
void ScriptsProcess ()
 Process queued scripts. More...
 
void 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
 
void ProcessRelocationNotifies (const uint32 diff)
 
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

bool _creatureToMoveLock
 
std::vector< Creature * > _creaturesToMove
 
bool _gameObjectsToMoveLock
 
std::vector< GameObject * > _gameObjectsToMove
 
bool _dynamicObjectsToMoveLock
 
std::vector< DynamicObject * > _dynamicObjectsToMove
 
time_t i_gridExpiry
 
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_MAP
marked_cells
 
bool i_scriptLock
 
std::set< WorldObject * > i_objectsToRemove
 
std::map< WorldObject *, booli_objectsToSwitch
 
std::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
 

Member Typedef Documentation

typedef std::set<WorldObject*> Map::ActiveNonPlayers
protected
typedef std::unordered_multimap<ObjectGuid::LowType, Creature*> Map::CreatureBySpawnIdContainer
typedef std::multimap<time_t, ScriptAction> Map::ScriptScheduleMap
private
typedef std::set<Transport*> Map::TransportsContainer
protected

Member Enumeration Documentation

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 
372  {
373  CAN_ENTER = 0,
374  CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
375  CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
376  CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
377  CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
378  CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
379  CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
380  CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
381  CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
382  CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
383  CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
385  };
Definition: Map.h:378
Definition: Map.h:375
Definition: Map.h:373
Definition: Map.h:382

Constructor & Destructor Documentation

Map::Map ( uint32  id,
time_t  expiry,
uint32  InstanceId,
uint8  SpawnMode,
Map _parent = NULL 
)
227  :
229 i_mapEntry(sMapStore.LookupEntry(id)), i_spawnMode(SpawnMode), i_InstanceId(InstanceId),
233 i_gridExpiry(expiry),
235 {
236  m_parentMap = (_parent ? _parent : this);
237  for (unsigned int idx=0; idx < MAX_NUMBER_OF_GRIDS; ++idx)
238  {
239  for (unsigned int j=0; j < MAX_NUMBER_OF_GRIDS; ++j)
240  {
241  //z code
242  GridMaps[idx][j] =NULL;
243  setNGrid(NULL, idx, j);
244  }
245  }
246 
247  //lets initialize visibility distance for map
249 
250  sScriptMgr->OnCreateMap(this);
251 }
virtual void InitVisibilityDistance()
Definition: Map.cpp:253
MapEntry const * i_mapEntry
Definition: Map.h:640
float m_VisibleDistance
Definition: Map.h:644
time_t i_gridExpiry
Definition: Map.h:671
TransportsContainer _transports
Definition: Map.h:658
Map * m_parentMap
Definition: Map.h:675
#define DEFAULT_VISIBILITY_NOTIFY_PERIOD
Definition: NGrid.h:30
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
arena_t NULL
Definition: jemalloc_internal.h:624
TransportsContainer::iterator _transportsUpdateIter
Definition: Map.h:659
uint8 i_spawnMode
Definition: Map.h:641
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:653
bool i_scriptLock
Definition: Map.h:685
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:678
bool _gameObjectsToMoveLock
Definition: Map.h:603
void setNGrid(NGridType *grid, uint32 x, uint32 y)
Definition: Map.cpp:2743
uint32 m_unloadTimer
Definition: Map.h:643
uint32 GetDefaultMapLight(uint32 mapId)
Definition: DBCStores.cpp:830
bool _dynamicObjectsToMoveLock
Definition: Map.h:606
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition: Map.h:654
int32 m_VisibilityNotifyPeriod
Definition: Map.h:650
DBCStorage< MapEntry > sMapStore(Mapfmt)
uint32 i_InstanceId
Definition: Map.h:642
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 _defaultLight
Definition: Map.h:725
bool _creatureToMoveLock
Definition: Map.h:600
#define DEFAULT_VISIBILITY_DISTANCE
Definition: Object.h:40

+ Here is the call graph for this function:

Map::~Map ( )
virtual
59 {
60  // UnloadAll must be called before deleting the map
61 
62  sScriptMgr->OnDestroyMap(this);
63 
64  while (!i_worldObjects.empty())
65  {
66  WorldObject* obj = *i_worldObjects.begin();
67  ASSERT(obj->IsWorldObject());
68  //ASSERT(obj->GetTypeId() == TYPEID_CORPSE);
69  obj->RemoveFromWorld();
70  obj->ResetMap();
71  }
72 
73  if (!m_scriptSchedule.empty())
74  sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
75 
77 }
virtual void ResetMap()
Definition: Object.cpp:2187
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:691
bool IsWorldObject() const
Definition: Object.cpp:1462
Definition: Object.h:423
uint32 GetId(void) const
Definition: Map.h:325
virtual void RemoveFromWorld() override
Definition: Object.cpp:1515
std::set< WorldObject * > i_worldObjects
Definition: Map.h:688
bool unloadMapInstance(uint32 mapId, uint32 instanceId)
Definition: MMapManager.cpp:372
uint32 i_InstanceId
Definition: Map.h:642
#define ASSERT
Definition: Errors.h:55
static MMapManager * createOrGetMMapManager()
Definition: MMapFactory.cpp:28
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the call graph for this function:

Member Function Documentation

GameObject * Map::_FindGameObject ( WorldObject pWorldObject,
ObjectGuid::LowType  guid 
) const
inlineprivate
283 {
284  auto bounds = searchObject->GetMap()->GetGameObjectBySpawnIdStore().equal_range(guid);
285  if (bounds.first == bounds.second)
286  return nullptr;
287 
288  return bounds.first->second;
289 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Map::_GetScriptCreature ( Object obj,
bool  isSource,
const ScriptInfo scriptInfo 
) const
inlineprivate
193 {
194  Creature* creature = NULL;
195  if (!obj)
196  TC_LOG_ERROR("scripts", "%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
197  else
198  {
199  creature = obj->ToCreature();
200  if (!creature)
201  {
202  TC_LOG_ERROR("scripts", "%s %s object is not a creature (TypeId: %u, Entry: %u, %s).", scriptInfo->GetDebugInfo().c_str(),
203  isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString().c_str());
204  }
205  }
206  return creature;
207 }
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Creature * ToCreature()
Definition: Object.h:194
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Map::_GetScriptCreatureSourceOrTarget ( Object source,
Object target,
const ScriptInfo scriptInfo,
bool  bReverse = false 
) const
inlineprivate
123 {
124  Creature* creature = NULL;
125  if (!source && !target)
126  TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
127  else
128  {
129  if (bReverse)
130  {
131  // Check target first, then source.
132  if (target)
133  creature = target->ToCreature();
134  if (!creature && source)
135  creature = source->ToCreature();
136  }
137  else
138  {
139  // Check source first, then target.
140  if (source)
141  creature = source->ToCreature();
142  if (!creature && target)
143  creature = target->ToCreature();
144  }
145 
146  if (!creature)
147  TC_LOG_ERROR("scripts", "%s neither source nor target are creatures (source: TypeId: %u, Entry: %u, %s; target: TypeId: %u, Entry: %u, %s), skipping.",
148  scriptInfo->GetDebugInfo().c_str(),
149  source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, (source ? source->GetGUID() : ObjectGuid::Empty).ToString().c_str(),
150  target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, (target ? target->GetGUID() : ObjectGuid::Empty).ToString().c_str());
151  }
152  return creature;
153 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Creature.h:467
TypeID GetTypeId() const
Definition: Object.h:113
string ToString(int i)
Definition: strutil.h:491
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Creature * ToCreature()
Definition: Object.h:194
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Map::_GetScriptPlayer ( Object obj,
bool  isSource,
const ScriptInfo scriptInfo 
) const
inlineprivate
176 {
177  Player* player = NULL;
178  if (!obj)
179  TC_LOG_ERROR("scripts", "%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
180  else
181  {
182  player = obj->ToPlayer();
183  if (!player)
184  {
185  TC_LOG_ERROR("scripts", "%s %s object is not a player (TypeId: %u, Entry: %u, %s).",
186  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString().c_str());
187  }
188  }
189  return player;
190 }
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Player * Map::_GetScriptPlayerSourceOrTarget ( Object source,
Object target,
const ScriptInfo scriptInfo 
) const
inlineprivate
101 {
102  Player* player = NULL;
103  if (!source && !target)
104  TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", scriptInfo->GetDebugInfo().c_str());
105  else
106  {
107  // Check target first, then source.
108  if (target)
109  player = target->ToPlayer();
110  if (!player && source)
111  player = source->ToPlayer();
112 
113  if (!player)
114  TC_LOG_ERROR("scripts", "%s neither source nor target object is player (source: TypeId: %u, Entry: %u, %s; target: TypeId: %u, Entry: %u, %s), skipping.",
115  scriptInfo->GetDebugInfo().c_str(),
116  source ? source->GetTypeId() : 0, source ? source->GetEntry() : 0, (source ? source->GetGUID() : ObjectGuid::Empty).ToString().c_str(),
117  target ? target->GetTypeId() : 0, target ? target->GetEntry() : 0, (target ? target->GetGUID() : ObjectGuid::Empty).ToString().c_str());
118  }
119  return player;
120 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
arena_t NULL
Definition: jemalloc_internal.h:624
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
string ToString(int i)
Definition: strutil.h:491
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Unit * Map::_GetScriptUnit ( Object obj,
bool  isSource,
const ScriptInfo scriptInfo 
) const
inlineprivate
156 {
157  Unit* unit = NULL;
158  if (!obj)
159  TC_LOG_ERROR("scripts", "%s %s object is NULL.", scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
160  else if (!obj->isType(TYPEMASK_UNIT))
161  {
162  TC_LOG_ERROR("scripts", "%s %s object is not unit (TypeId: %u, Entry: %u, %s), skipping.",
163  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString().c_str());
164  }
165  else
166  {
167  unit = obj->ToUnit();
168  if (!unit)
169  TC_LOG_ERROR("scripts", "%s %s object could not be cast to unit.",
170  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
171  }
172  return unit;
173 }
bool isType(uint16 mask) const
Definition: Object.h:114
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: ObjectGuid.h:49
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Unit.h:1305
std::string ToString() const
Definition: ObjectGuid.cpp:99
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

WorldObject * Map::_GetScriptWorldObject ( Object obj,
bool  isSource,
const ScriptInfo scriptInfo 
) const
inlineprivate
210 {
211  WorldObject* pWorldObject = NULL;
212  if (!obj)
213  TC_LOG_ERROR("scripts", "%s %s object is NULL.",
214  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target");
215  else
216  {
217  pWorldObject = dynamic_cast<WorldObject*>(obj);
218  if (!pWorldObject)
219  {
220  TC_LOG_ERROR("scripts", "%s %s object is not a world object (TypeId: %u, Entry: %u, %s).",
221  scriptInfo->GetDebugInfo().c_str(), isSource ? "source" : "target", obj->GetTypeId(), obj->GetEntry(), obj->GetGUID().ToString().c_str());
222  }
223  }
224  return pWorldObject;
225 }
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Object.h:423
TypeID GetTypeId() const
Definition: Object.h:113
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::_ScriptProcessDoor ( Object source,
Object target,
const ScriptInfo scriptInfo 
) const
inlineprivate
228 {
229  bool bOpen = false;
230  ObjectGuid::LowType guid = scriptInfo->ToggleDoor.GOGuid;
231  int32 nTimeToToggle = std::max(15, int32(scriptInfo->ToggleDoor.ResetDelay));
232  switch (scriptInfo->command)
233  {
234  case SCRIPT_COMMAND_OPEN_DOOR: bOpen = true; break;
235  case SCRIPT_COMMAND_CLOSE_DOOR: break;
236  default:
237  TC_LOG_ERROR("scripts", "%s unknown command for _ScriptProcessDoor.", scriptInfo->GetDebugInfo().c_str());
238  return;
239  }
240  if (!guid)
241  TC_LOG_ERROR("scripts", "%s door guid is not specified.", scriptInfo->GetDebugInfo().c_str());
242  else if (!source)
243  TC_LOG_ERROR("scripts", "%s source object is NULL.", scriptInfo->GetDebugInfo().c_str());
244  else if (!source->isType(TYPEMASK_UNIT))
245  {
246  TC_LOG_ERROR("scripts", "%s source object is not unit (TypeId: %u, Entry: %u, %s), skipping.", scriptInfo->GetDebugInfo().c_str(),
247  source->GetTypeId(), source->GetEntry(), source->GetGUID().ToString().c_str());
248  }
249  else
250  {
251  WorldObject* wSource = dynamic_cast <WorldObject*> (source);
252  if (!wSource)
253  {
254  TC_LOG_ERROR("scripts", "%s source object could not be cast to world object (TypeId: %u, Entry: %u, %s), skipping.",
255  scriptInfo->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUID().ToString().c_str());
256  }
257  else
258  {
259  GameObject* pDoor = _FindGameObject(wSource, guid);
260  if (!pDoor)
261  TC_LOG_ERROR("scripts", "%s gameobject was not found (guid: " UI64FMTD ").", scriptInfo->GetDebugInfo().c_str(), guid);
262  else if (pDoor->GetGoType() != GAMEOBJECT_TYPE_DOOR)
263  {
264  TC_LOG_ERROR("scripts", "%s gameobject is not a door (GoType: %u, Entry: %u, %s).",
265  scriptInfo->GetDebugInfo().c_str(), pDoor->GetGoType(), pDoor->GetEntry(), pDoor->GetGUID().ToString().c_str());
266  }
267  else if (bOpen == (pDoor->GetGoState() == GO_STATE_READY))
268  {
269  pDoor->UseDoorOrButton(nTimeToToggle);
270 
271  if (target && target->isType(TYPEMASK_GAMEOBJECT))
272  {
273  GameObject* goTarget = target->ToGameObject();
274  if (goTarget && goTarget->GetGoType() == GAMEOBJECT_TYPE_BUTTON)
275  goTarget->UseDoorOrButton(nTimeToToggle);
276  }
277  }
278  }
279  }
280 }
Definition: ObjectMgr.h:97
GOState GetGoState() const
Definition: GameObject.h:966
GameObject * _FindGameObject(WorldObject *pWorldObject, ObjectGuid::LowType guid) const
Definition: MapScripts.cpp:282
ScriptCommands command
Definition: ObjectMgr.h:187
bool isType(uint16 mask) const
Definition: Object.h:114
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
Definition: Object.h:423
uint64 LowType
Definition: ObjectGuid.h:199
GameObject * ToGameObject()
Definition: Object.h:200
T max(const T &x, const T &y)
Definition: g3dmath.h:320
Definition: ObjectGuid.h:49
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:51
Definition: SharedDefines.h:2066
struct ScriptInfo::@280::@293 ToggleDoor
#define UI64FMTD
Definition: Define.h:137
int32_t int32
Definition: Define.h:146
Definition: GameObject.h:880
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=NULL)
Definition: GameObject.cpp:1182
Definition: GameObject.h:823
ObjectGuid const & GetGUID() const
Definition: Object.h:105
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Definition: ObjectMgr.h:98
int32_t int32
Definition: g3dmath.h:167
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: SharedDefines.h:2065

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::ActiveObjectsNearGrid ( NGridType const ngrid) const
2921 {
2922  CellCoord cell_min(ngrid.getX() * MAX_NUMBER_OF_CELLS, ngrid.getY() * MAX_NUMBER_OF_CELLS);
2923  CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
2924 
2925  //we must find visible range in cells so we unload only non-visible cells...
2926  float viewDist = GetVisibilityRange();
2927  int cell_range = (int)ceilf(viewDist / SIZE_OF_GRID_CELL) + 1;
2928 
2929  cell_min.dec_x(cell_range);
2930  cell_min.dec_y(cell_range);
2931  cell_max.inc_x(cell_range);
2932  cell_max.inc_y(cell_range);
2933 
2934  for (MapRefManager::const_iterator iter = m_mapRefManager.begin(); iter != m_mapRefManager.end(); ++iter)
2935  {
2936  Player* player = iter->GetSource();
2937 
2938  CellCoord p = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
2939  if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
2940  (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
2941  return true;
2942  }
2943 
2944  for (ActiveNonPlayers::const_iterator iter = m_activeNonPlayers.begin(); iter != m_activeNonPlayers.end(); ++iter)
2945  {
2946  WorldObject* obj = *iter;
2947 
2949  if ((cell_min.x_coord <= p.x_coord && p.x_coord <= cell_max.x_coord) &&
2950  (cell_min.y_coord <= p.y_coord && p.y_coord <= cell_max.y_coord))
2951  return true;
2952  }
2953 
2954  return false;
2955 }
#define SIZE_OF_GRID_CELL
Definition: GridDefines.h:47
#define MAX_NUMBER_OF_CELLS
Definition: GridDefines.h:35
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
Definition: Object.h:423
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
iterator begin()
Definition: MapRefManager.h:37
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:653
float GetPositionY() const
Definition: Position.h:105
Definition: LinkedList.h:141
float GetVisibilityRange() const
Definition: Map.h:290
float GetPositionX() const
Definition: Position.h:104
MapRefManager m_mapRefManager
Definition: Map.h:647
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::AddCorpse ( Corpse corpse)
3770 {
3771  corpse->SetMap(this);
3772 
3773  _corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse);
3774  if (corpse->GetType() != CORPSE_BONES)
3775  _corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
3776  else
3777  _corpseBones.insert(corpse);
3778 }
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:742
ObjectGuid GetOwnerGUID() const
Definition: Corpse.h:67
CellCoord const & GetCellCoord() const
Definition: Corpse.h:73
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:741
virtual void SetMap(Map *map)
Definition: Object.cpp:2169
CorpseType GetType() const
Definition: Corpse.h:71
std::unordered_set< Corpse * > _corpseBones
Definition: Map.h:743
uint32 GetId() const
Definition: GridDefines.h:150
Definition: Corpse.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::AddCreatureToMoveList ( Creature c,
float  x,
float  y,
float  z,
float  ang 
)
private
1085 {
1086  if (_creatureToMoveLock) //can this happen?
1087  return;
1088 
1089  if (c->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1090  _creaturesToMove.push_back(c);
1091  c->SetNewCellPosition(x, y, z, ang);
1092 }
Definition: Object.h:393
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
std::vector< Creature * > _creaturesToMove
Definition: Map.h:601
bool _creatureToMoveLock
Definition: Map.h:600

+ Here is the caller graph for this function:

void Map::AddDynamicObjectToMoveList ( DynamicObject go,
float  x,
float  y,
float  z,
float  ang 
)
private
1123 {
1124  if (_dynamicObjectsToMoveLock) //can this happen?
1125  return;
1126 
1127  if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1128  _dynamicObjectsToMove.push_back(dynObj);
1129  dynObj->SetNewCellPosition(x, y, z, ang);
1130 }
Definition: Object.h:393
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition: Map.h:607
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
bool _dynamicObjectsToMoveLock
Definition: Map.h:606
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

void Map::AddGameObjectToMoveList ( GameObject go,
float  x,
float  y,
float  z,
float  ang 
)
private
1104 {
1105  if (_gameObjectsToMoveLock) //can this happen?
1106  return;
1107 
1108  if (go->_moveState == MAP_OBJECT_CELL_MOVE_NONE)
1109  _gameObjectsToMove.push_back(go);
1110  go->SetNewCellPosition(x, y, z, ang);
1111 }
std::vector< GameObject * > _gameObjectsToMove
Definition: Map.h:604
Definition: Object.h:393
bool _gameObjectsToMoveLock
Definition: Map.h:603
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

void Map::AddObjectToRemoveList ( WorldObject obj)
2805 {
2806  ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
2807 
2808  obj->CleanupsBeforeDelete(false); // remove or simplify at least cross referenced links
2809 
2810  i_objectsToRemove.insert(obj);
2811  //TC_LOG_DEBUG("maps", "Object (GUID: %u TypeId: %u) added to removing list.", obj->GetGUIDLow(), obj->GetTypeId());
2812 }
std::set< WorldObject * > i_objectsToRemove
Definition: Map.h:686
virtual void CleanupsBeforeDelete(bool finalCleanup=true)
Definition: Object.cpp:1506
uint32 GetId(void) const
Definition: Map.h:325
uint32 GetInstanceId() const
Definition: Object.h:451
uint32 GetMapId() const
Definition: Position.h:254
#define ASSERT
Definition: Errors.h:55
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::AddObjectToSwitchList ( WorldObject obj,
bool  on 
)
2815 {
2816  ASSERT(obj->GetMapId() == GetId() && obj->GetInstanceId() == GetInstanceId());
2817  // i_objectsToSwitch is iterated only in Map::RemoveAllObjectsInRemoveList() and it uses
2818  // the contained objects only if GetTypeId() == TYPEID_UNIT , so we can return in all other cases
2819  if (obj->GetTypeId() != TYPEID_UNIT && obj->GetTypeId() != TYPEID_GAMEOBJECT)
2820  return;
2821 
2822  std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.find(obj);
2823  if (itr == i_objectsToSwitch.end())
2824  i_objectsToSwitch.insert(itr, std::make_pair(obj, on));
2825  else if (itr->second != on)
2826  i_objectsToSwitch.erase(itr);
2827  else
2828  ABORT();
2829 }
std::map< WorldObject *, bool > i_objectsToSwitch
Definition: Map.h:687
Definition: ObjectGuid.h:32
uint32 GetId(void) const
Definition: Map.h:325
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:34
uint32 GetInstanceId() const
Definition: Object.h:451
uint32 GetMapId() const
Definition: Position.h:254
#define ABORT
Definition: Errors.h:56
#define ASSERT
Definition: Errors.h:55
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented in BattlegroundMap, InstanceMap, and GarrisonMap.

514 {
515  CellCoord cellCoord = Trinity::ComputeCellCoord(player->GetPositionX(), player->GetPositionY());
516  if (!cellCoord.IsCoordValid())
517  {
518  TC_LOG_ERROR("maps", "Map::Add: Player (%s) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", player->GetGUID().ToString().c_str(), player->GetPositionX(), player->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
519  return false;
520  }
521 
522  Cell cell(cellCoord);
523  EnsureGridLoadedForActiveObject(cell, player);
524  AddToGrid(player, cell);
525 
526  // Check if we are adding to correct map
527  ASSERT (player->GetMap() == this);
528  player->SetMap(this);
529  player->AddToWorld();
530 
531  if (initPlayer)
532  SendInitSelf(player);
533 
534  SendInitTransports(player);
535  SendZoneDynamicInfo(player);
536 
537  if (initPlayer)
538  player->m_clientGUIDs.clear();
539 
540  player->UpdateObjectVisibility(false);
541  player->SendUpdatePhasing();
542 
543  if (player->IsAlive())
544  ConvertCorpseToBones(player->GetGUID());
545 
546  sScriptMgr->OnPlayerEnterMap(this, player);
547  return true;
548 }
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:262
void SendInitTransports(Player *player)
Definition: Map.cpp:2697
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
void SendZoneDynamicInfo(Player *player)
Definition: Map.cpp:3879
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
Corpse * ConvertCorpseToBones(ObjectGuid const &ownerGuid, bool insignia=false)
Definition: Map.cpp:3800
bool IsCoordValid() const
Definition: GridDefines.h:138
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
Definition: Map.cpp:465
Definition: Cell.h:49
#define ASSERT
Definition: Errors.h:55
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void SendInitSelf(Player *player)
Definition: Map.cpp:2671

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
void Map::AddToActive ( T *  obj)
2959 {
2960  AddToActiveHelper(obj);
2961 }
void AddToActiveHelper(WorldObject *obj)
Definition: Map.h:700

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<>
void Map::AddToActive ( Creature c)
2965 {
2966  AddToActiveHelper(c);
2967 
2968  // also not allow unloading spawn grid to prevent creating creature clone at load
2969  if (!c->IsPet() && c->GetSpawnId())
2970  {
2971  float x, y, z;
2972  c->GetRespawnPosition(x, y, z);
2974  if (getNGrid(p.x_coord, p.y_coord))
2976  else
2977  {
2979  TC_LOG_ERROR("maps", "Active creature (%s Entry: %u) added to grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
2980  c->GetGUID().ToString().c_str(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
2981  }
2982  }
2983 }
void AddToActiveHelper(WorldObject *obj)
Definition: Map.h:700
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:188
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GridDefines.h:89
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition: Creature.cpp:2355
void incUnloadActiveLock()
Definition: NGrid.h:117
bool IsPet() const
Definition: Unit.h:1403
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

template<>
void Map::AddToActive ( DynamicObject d)
2987 {
2988  AddToActiveHelper(d);
2989 }
void AddToActiveHelper(WorldObject *obj)
Definition: Map.h:700

+ Here is the call graph for this function:

void Map::AddToActiveHelper ( WorldObject obj)
inlineprivate
701  {
702  m_activeNonPlayers.insert(obj);
703  }
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:653

+ Here is the caller graph for this function:

template<>
void Map::AddToGrid ( Creature obj,
Cell const cell 
)
273 {
274  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
275  if (obj->IsWorldObject())
276  grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
277  else
278  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
279 
280  obj->SetCurrentCell(cell);
281 }
Definition: NGrid.h:77
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
bool IsWorldObject() const
Definition: Object.cpp:1462
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86
void AddWorldObject(WorldObject *obj)
Definition: Map.h:427

+ Here is the call graph for this function:

template<>
void Map::AddToGrid ( GameObject obj,
Cell const cell 
)
285 {
286  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
287  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
288 
289  obj->SetCurrentCell(cell);
290 }
Definition: NGrid.h:77
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86

+ Here is the call graph for this function:

template<>
void Map::AddToGrid ( DynamicObject obj,
Cell const cell 
)
294 {
295  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
296  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
297 
298  obj->SetCurrentCell(cell);
299 }
Definition: NGrid.h:77
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86

+ Here is the call graph for this function:

template<>
void Map::AddToGrid ( Corpse obj,
Cell const cell 
)
303 {
304  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
305  // Corpses are a special object type - they can be added to grid via a call to AddToMap
306  // or loaded through ObjectGridLoader.
307  // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell
308  // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded
309  // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader)
310  // to avoid failing an assertion in GridObject::AddToGrid
311  if (grid->isGridObjectDataLoaded())
312  {
313  if (obj->IsWorldObject())
314  grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj);
315  else
316  grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj);
317  }
318 }
Definition: NGrid.h:77
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
bool IsWorldObject() const
Definition: Object.cpp:1462
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86
void AddWorldObject(WorldObject *obj)
Definition: Map.h:427
bool isGridObjectDataLoaded() const
Definition: NGrid.h:109

+ Here is the call graph for this function:

template<class T >
void Map::AddToGrid ( T *  object,
Cell const cell 
)
private
263 {
264  NGridType* grid = getNGrid(cell.GridX(), cell.GridY());
265  if (obj->IsWorldObject())
266  grid->GetGridType(cell.CellX(), cell.CellY()).template AddWorldObject<T>(obj);
267  else
268  grid->GetGridType(cell.CellX(), cell.CellY()).template AddGridObject<T>(obj);
269 }
Definition: NGrid.h:77
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class T >
bool Map::AddToMap ( T *  obj)
Todo:
Needs clean up. An object should not be added to map twice.
567 {
569  if (obj->IsInWorld())
570  {
571  ASSERT(obj->IsInGrid());
572  obj->UpdateObjectVisibility(true);
573  return true;
574  }
575 
576  CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
577  //It will create many problems (including crashes) if an object is not added to grid after creation
578  //The correct way to fix it is to make AddToMap return false and delete the object if it is not added to grid
579  //But now AddToMap is used in too many places, I will just see how many ASSERT failures it will cause
580  ASSERT(cellCoord.IsCoordValid());
581  if (!cellCoord.IsCoordValid())
582  {
583  TC_LOG_ERROR("maps", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
584  return false; //Should delete object
585  }
586 
587  Cell cell(cellCoord);
588  if (obj->isActiveObject())
590  else
591  EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
592  AddToGrid(obj, cell);
593  TC_LOG_DEBUG("maps", "Object %s enters grid[%u, %u]", obj->GetGUID().ToString().c_str(), cell.GridX(), cell.GridY());
594 
595  //Must already be set before AddToMap. Usually during obj->Create.
596  //obj->SetMap(this);
597  obj->AddToWorld();
598 
599  InitializeObject(obj);
600 
601  if (obj->isActiveObject())
602  AddToActive(obj);
603 
604  obj->RebuildTerrainSwaps();
605 
606  //something, such as vehicle, needs to be update immediately
607  //also, trigger needs to cast spell, if not update, cannot see visual
608  obj->UpdateObjectVisibility(true);
609  return true;
610 }
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:262
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
void InitializeObject(T *obj)
Definition: Map.cpp:551
bool IsCoordValid() const
Definition: GridDefines.h:138
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
Definition: Map.cpp:465
Definition: Cell.h:49
void AddToActive(T *obj)
Definition: Map.cpp:2958
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<>
bool Map::AddToMap ( Transport obj)
614 {
615  //TODO: Needs clean up. An object should not be added to map twice.
616  if (obj->IsInWorld())
617  return true;
618 
619  CellCoord cellCoord = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
620  if (!cellCoord.IsCoordValid())
621  {
622  TC_LOG_ERROR("maps", "Map::Add: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), cellCoord.x_coord, cellCoord.y_coord);
623  return false; //Should delete object
624  }
625 
626  obj->AddToWorld();
627  _transports.insert(obj);
628 
629  // Broadcast creation to players
630  if (!GetPlayers().isEmpty())
631  {
632  for (Map::PlayerList::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
633  {
634  if (itr->GetSource()->GetTransport() != obj)
635  {
636  UpdateData data(GetId());
637  obj->BuildCreateUpdateBlockForPlayer(&data, itr->GetSource());
638  WorldPacket packet;
639  data.BuildPacket(&packet);
640  itr->GetSource()->SendDirectMessage(&packet);
641  }
642  }
643  }
644 
645  return true;
646 }
TransportsContainer _transports
Definition: Map.h:658
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
void AddToWorld() override
Definition: GameObject.cpp:125
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
Definition: UpdateData.h:59
uint32 GetId(void) const
Definition: Map.h:325
float GetPositionY() const
Definition: Position.h:105
Definition: LinkedList.h:141
bool isEmpty() const
Definition: LinkedList.h:102
bool IsCoordValid() const
Definition: GridDefines.h:138
iterator begin()
Definition: GridRefManager.h:36
virtual void BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) const
Definition: Object.cpp:167
PlayerList const & GetPlayers() const
Definition: Map.h:433
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool IsInWorld() const
Definition: Object.h:100
float GetPositionX() const
Definition: Position.h:104
Definition: WorldPacket.h:26
std::string ToString() const
Definition: ObjectGuid.cpp:99
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

void Map::AddUpdateObject ( Object obj)
inline
568  {
569  _updateObjects.insert(obj);
570  }
std::unordered_set< Object * > _updateObjects
Definition: Map.h:745

+ Here is the caller graph for this function:

void Map::AddWorldObject ( WorldObject obj)
inline
427 { i_worldObjects.insert(obj); }
std::set< WorldObject * > i_worldObjects
Definition: Map.h:688

+ Here is the caller graph for this function:

void Map::Balance ( )
inline
504 { _dynamicTree.balance(); }
void balance()
Definition: DynamicTree.cpp:132
DynamicMapTree _dynamicTree
Definition: Map.h:645

+ Here is the caller graph for this function:

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual EnterState Map::CannotEnter ( Player )
inlinevirtual

Reimplemented in BattlegroundMap, InstanceMap, and MapInstanced.

386 { return CAN_ENTER; }
Definition: Map.h:373

+ Here is the caller graph for this function:

bool Map::CanUnload ( uint32  diff)
inline
270  {
271  if (!m_unloadTimer)
272  return false;
273 
274  if (m_unloadTimer <= diff)
275  return true;
276 
277  m_unloadTimer -= diff;
278  return false;
279  }
uint32 m_unloadTimer
Definition: Map.h:643
bool Map::CheckGridIntegrity ( Creature c,
bool  moved 
) const
2628 {
2629  Cell const& cur_cell = c->GetCurrentCell();
2630  Cell xy_cell(c->GetPositionX(), c->GetPositionY());
2631  if (xy_cell != cur_cell)
2632  {
2633  TC_LOG_DEBUG("maps", "Creature (%s) X: %f Y: %f (%s) is in grid[%u, %u]cell[%u, %u] instead of grid[%u, %u]cell[%u, %u]",
2634  c->GetGUID().ToString().c_str(),
2635  c->GetPositionX(), c->GetPositionY(), (moved ? "final" : "original"),
2636  cur_cell.GridX(), cur_cell.GridY(), cur_cell.CellX(), cur_cell.CellY(),
2637  xy_cell.GridX(), xy_cell.GridY(), xy_cell.CellX(), xy_cell.CellY());
2638  return true; // not crash at error, just output error in debug mode
2639  }
2640 
2641  return true;
2642 }
uint32 CellY() const
Definition: Cell.h:75
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
float GetPositionY() const
Definition: Position.h:105
uint32 CellX() const
Definition: Cell.h:74
uint32 GridY() const
Definition: Cell.h:77
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 GridX() const
Definition: Cell.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::ContainsGameObjectModel ( const GameObjectModel model) const
inline
507 { return _dynamicTree.contains(model);}
bool contains(const GameObjectModel &) const
Definition: DynamicTree.cpp:127
DynamicMapTree _dynamicTree
Definition: Map.h:645
Corpse * Map::ConvertCorpseToBones ( ObjectGuid const ownerGuid,
bool  insignia = false 
)
3801 {
3802  Corpse* corpse = GetCorpseByPlayer(ownerGuid);
3803  if (!corpse)
3804  return nullptr;
3805 
3806  RemoveCorpse(corpse);
3807 
3808  // remove corpse from DB
3810  corpse->DeleteFromDB(trans);
3812 
3813  Corpse* bones = NULL;
3814 
3815  // create the bones only if the map and the grid is loaded at the corpse's location
3816  // ignore bones creating option in case insignia
3817  if ((insignia ||
3819  !IsRemovalGrid(corpse->GetPositionX(), corpse->GetPositionY()))
3820  {
3821  // Create bones, don't change Corpse
3822  bones = new Corpse();
3823  bones->Create(corpse->GetGUID().GetCounter(), this);
3824 
3825  for (uint8 i = OBJECT_FIELD_GUID + 4; i < CORPSE_END; ++i) // don't overwrite guid
3826  bones->SetUInt32Value(i, corpse->GetUInt32Value(i));
3827 
3828  bones->SetCellCoord(corpse->GetCellCoord());
3829  bones->Relocate(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetOrientation());
3830 
3834 
3835  for (uint8 i = 0; i < EQUIPMENT_SLOT_END; ++i)
3836  if (corpse->GetUInt32Value(CORPSE_FIELD_ITEM + i))
3837  bones->SetUInt32Value(CORPSE_FIELD_ITEM + i, 0);
3838 
3839  bones->CopyPhaseFrom(corpse);
3840 
3841  AddCorpse(bones);
3842 
3843  // add bones in grid store if grid loaded where corpse placed
3844  AddToMap(bones);
3845  }
3846 
3847  // all references to the corpse should be removed at this point
3848  delete corpse;
3849 
3850  return bones;
3851 }
bool IsBattlegroundOrArena() const
Definition: Map.h:403
Definition: Corpse.h:49
uint32 GetUInt32Value(uint16 index) const
Definition: Object.cpp:300
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void RemoveCorpse(Corpse *corpse)
Definition: Map.cpp:3780
void SetCellCoord(CellCoord const &cellCoord)
Definition: Corpse.h:74
Definition: UpdateFields.h:364
CellCoord const & GetCellCoord() const
Definition: Corpse.h:73
SQLTransaction BeginTransaction()
Begins an automanaged transaction pointer that will automatically rollback if not commited...
Definition: DatabaseWorkerPool.h:221
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
void SetGuidValue(uint16 index, ObjectGuid const &value)
Definition: Object.cpp:1120
#define sWorld
Definition: World.h:887
void DeleteFromDB(SQLTransaction &trans)
Definition: Corpse.cpp:131
Definition: World.h:130
void CommitTransaction(SQLTransaction transaction)
Definition: DatabaseWorkerPool.cpp:179
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition: Map.h:483
float GetOrientation() const
Definition: Position.h:107
void Relocate(float x, float y)
Definition: Position.h:67
float GetPositionY() const
Definition: Position.h:105
bool AddToMap(T *)
Definition: Map.cpp:566
float GetPositionZ() const
Definition: Position.h:106
bool Create(ObjectGuid::LowType guidlow, Map *map)
Definition: Corpse.cpp:62
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Definition: UpdateFields.h:358
Definition: UpdateFields.h:361
Definition: Corpse.h:43
Definition: UpdateFields.h:27
uint8_t uint8
Definition: Define.h:152
Definition: UpdateFields.h:26
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: UpdateFields.h:355
Definition: World.h:131
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:302
float GetPositionX() const
Definition: Position.h:104
void AddCorpse(Corpse *corpse)
Definition: Map.cpp:3769
Definition: Corpse.h:41
LowType GetCounter() const
Definition: ObjectGuid.h:221
std::shared_ptr< Transaction > SQLTransaction
Definition: Transaction.h:58

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::CreatureCellRelocation ( Creature creature,
Cell  new_cell 
)
private
1281 {
1282  Cell const& old_cell = c->GetCurrentCell();
1283  if (!old_cell.DiffGrid(new_cell)) // in same grid
1284  {
1285  // if in same cell then none do
1286  if (old_cell.DiffCell(new_cell))
1287  {
1288  #ifdef TRINITY_DEBUG
1289  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
1290  #endif
1291 
1292  c->RemoveFromGrid();
1293  AddToGrid(c, new_cell);
1294  }
1295  else
1296  {
1297  #ifdef TRINITY_DEBUG
1298  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
1299  #endif
1300  }
1301 
1302  return true;
1303  }
1304 
1305  // in diff. grids but active creature
1306  if (c->isActiveObject())
1307  {
1308  EnsureGridLoadedForActiveObject(new_cell, c);
1309 
1310  #ifdef TRINITY_DEBUG
1311  TC_LOG_DEBUG("maps", "Active creature (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1312  #endif
1313 
1314  c->RemoveFromGrid();
1315  AddToGrid(c, new_cell);
1316 
1317  return true;
1318  }
1319 
1320  // in diff. loaded grid normal creature
1321  if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
1322  {
1323  #ifdef TRINITY_DEBUG
1324  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1325  #endif
1326 
1327  c->RemoveFromGrid();
1328  EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
1329  AddToGrid(c, new_cell);
1330 
1331  return true;
1332  }
1333 
1334  // fail to move: normal creature attempt move to unloaded grid
1335  #ifdef TRINITY_DEBUG
1336  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1337  #endif
1338  return false;
1339 }
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:262
uint32 CellY() const
Definition: Cell.h:75
bool DiffCell(const Cell &cell) const
Definition: Cell.h:62
bool DiffGrid(const Cell &cell) const
Definition: Cell.h:68
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
uint32 CellX() const
Definition: Cell.h:74
uint32 GridY() const
Definition: Cell.h:77
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
Definition: Map.cpp:465
Definition: Cell.h:49
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
uint32 GridX() const
Definition: Cell.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::CreatureRelocation ( Creature creature,
float  x,
float  y,
float  z,
float  ang,
bool  respawnRelocationOnFail = true 
)

If hovering, always increase our server-side Z position Client automatically projects correct position based on Z coord sent in monster move and UNIT_FIELD_HOVERHEIGHT sent in object updates

983 {
984  ASSERT(CheckGridIntegrity(creature, false));
985 
986  Cell old_cell = creature->GetCurrentCell();
987  Cell new_cell(x, y);
988 
989  if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
990  return;
991 
996  z += creature->GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
997 
998  // delay creature move for grid/cell to grid/cell moves
999  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1000  {
1001  #ifdef TRINITY_DEBUG
1002  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", creature->GetGUID().ToString().c_str(), creature->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1003  #endif
1004  AddCreatureToMoveList(creature, x, y, z, ang);
1005  // in diffcell/diffgrid case notifiers called at finishing move creature in Map::MoveAllCreaturesInMoveList
1006  }
1007  else
1008  {
1009  creature->Relocate(x, y, z, ang);
1010  if (creature->IsVehicle())
1011  creature->GetVehicleKit()->RelocatePassengers();
1012  creature->UpdateObjectVisibility(false);
1013  RemoveCreatureFromMoveList(creature);
1014  }
1015 
1016  ASSERT(CheckGridIntegrity(creature, true));
1017 }
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
Definition: Vehicle.cpp:520
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
bool IsVehicle() const
Definition: Unit.h:1406
void AddCreatureToMoveList(Creature *c, float x, float y, float z, float ang)
Definition: Map.cpp:1084
uint32 CellY() const
Definition: Cell.h:75
bool DiffCell(const Cell &cell) const
Definition: Cell.h:62
void RemoveCreatureFromMoveList(Creature *c)
Definition: Map.cpp:1094
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
bool DiffGrid(const Cell &cell) const
Definition: Cell.h:68
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: UpdateFields.h:160
void Relocate(float x, float y)
Definition: Position.h:67
Definition: Unit.h:804
G3D::int16 z
Definition: Vector3int16.h:46
uint32 CellX() const
Definition: Cell.h:74
float GetFloatValue(uint16 index) const
Definition: Object.cpp:312
G3D::int16 y
Definition: Vector2int16.h:38
uint32 GridY() const
Definition: Cell.h:77
bool CheckGridIntegrity(Creature *c, bool moved) const
Definition: Map.cpp:2627
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
uint32 GetEntry() const
Definition: Object.h:107
G3D::int16 x
Definition: Vector2int16.h:37
std::string ToString() const
Definition: ObjectGuid.cpp:99
uint32 GridX() const
Definition: Cell.h:76
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::CreatureRespawnRelocation ( Creature c,
bool  diffGridOnly 
)
1464 {
1465  float resp_x, resp_y, resp_z, resp_o;
1466  c->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
1467  Cell resp_cell(resp_x, resp_y);
1468 
1469  //creature will be unloaded with grid
1470  if (diffGridOnly && !c->GetCurrentCell().DiffGrid(resp_cell))
1471  return true;
1472 
1473  c->CombatStop();
1474  c->GetMotionMaster()->Clear();
1475 
1476  #ifdef TRINITY_DEBUG
1477  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", c->GetGUID().ToString().c_str(), c->GetEntry(), c->GetCurrentCell().GridX(), c->GetCurrentCell().GridY(), c->GetCurrentCell().CellX(), c->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
1478  #endif
1479 
1480  // teleport it to respawn point (like normal respawn if player see)
1481  if (CreatureCellRelocation(c, resp_cell))
1482  {
1483  c->Relocate(resp_x, resp_y, resp_z, resp_o);
1484  c->GetMotionMaster()->Initialize(); // prevent possible problems with default move generators
1485  //CreatureRelocationNotify(c, resp_cell, resp_cell.GetCellCoord());
1486  c->UpdateObjectVisibility(false);
1487  return true;
1488  }
1489 
1490  return false;
1491 }
void Clear(bool reset=true)
Definition: MotionMaster.h:138
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Relocate(float x, float y)
Definition: Position.h:67
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition: Creature.cpp:2355
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool CreatureCellRelocation(Creature *creature, Cell new_cell)
Definition: Map.cpp:1280
uint32 GetEntry() const
Definition: Object.h:107
void Initialize()
Definition: MotionMaster.cpp:39
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::DelayedUpdate ( const uint32  diff)
virtual

Reimplemented in MapInstanced.

2775 {
2777  {
2778  Transport* transport = *_transportsUpdateIter;
2780 
2781  if (!transport->IsInWorld())
2782  continue;
2783 
2784  transport->DelayedUpdate(t_diff);
2785  }
2786 
2788 
2789  // Don't unload grids if it's battleground, since we may have manually added GOs, creatures, those doesn't load from DB at grid re-load !
2790  // This isn't really bother us, since as soon as we have instanced BG-s, the whole map unloads as the BG gets ended
2791  if (!IsBattlegroundOrArena())
2792  {
2794  {
2795  NGridType *grid = i->GetSource();
2796  GridInfo* info = i->GetSource()->getGridInfoRef();
2797  ++i; // The update might delete the map and we need the next map before the iterator gets invalid
2798  ASSERT(grid->GetGridState() >= 0 && grid->GetGridState() < MAX_GRID_STATE);
2799  si_GridStates[grid->GetGridState()]->Update(*this, *grid, *info, t_diff);
2800  }
2801  }
2802 }
Definition: NGrid.h:77
bool IsBattlegroundOrArena() const
Definition: Map.h:403
Definition: NGrid.h:32
grid_state_t GetGridState(void) const
Definition: NGrid.h:100
TransportsContainer _transports
Definition: Map.h:658
GridState * si_GridStates[MAX_GRID_STATE]
Definition: Map.cpp:52
TransportsContainer::iterator _transportsUpdateIter
Definition: Map.h:659
Definition: Transport.h:28
void RemoveAllObjectsInRemoveList()
Definition: Map.cpp:2831
Definition: GridReference.h:25
Definition: NGrid.h:67
#define ASSERT
Definition: Errors.h:55
iterator end()
Definition: GridRefManager.h:37
bool IsInWorld() const
Definition: Object.h:100
void DelayedUpdate(uint32 diff)
Definition: Transport.cpp:229
virtual void Update(Map &, NGridType &, GridInfo &, uint32 t_diff) const =0

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::DeleteCorpseData ( )
3761 {
3762  // DELETE cp, c FROM corpse_phases cp INNER JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?
3764  stmt->setUInt32(0, GetId());
3765  stmt->setUInt32(1, GetInstanceId());
3766  CharacterDatabase.Execute(stmt);
3767 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:283
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<>
void Map::DeleteFromWorld ( Player player)
Todo:
I do not know why we need this, it should be removed in ~Object anyway
420 {
422  RemoveUpdateObject(player);
423  delete player;
424 }
void RemoveUpdateObject(Object *obj)
Definition: Map.h:572
void RemoveObject(T *object)
Definition: ObjectAccessor.h:104

+ Here is the call graph for this function:

template<>
void Map::DeleteFromWorld ( Transport transport)
428 {
429  ObjectAccessor::RemoveObject(transport);
430  delete transport;
431 }
void RemoveObject(T *object)
Definition: ObjectAccessor.h:104

+ Here is the call graph for this function:

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

+ Here is the caller graph for this function:

void Map::DeleteRespawnTimes ( )
3664 {
3665  _creatureRespawnTimes.clear();
3666  _goRespawnTimes.clear();
3667 
3669 }
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition: Map.h:721
uint32 GetId(void) const
Definition: Map.h:325
static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId)
Definition: Map.cpp:3671
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition: Map.h:722
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::DeleteRespawnTimesInDB ( uint16  mapId,
uint32  instanceId 
)
static
3672 {
3674  stmt->setUInt16(0, mapId);
3675  stmt->setUInt32(1, instanceId);
3676  CharacterDatabase.Execute(stmt);
3677 
3679  stmt->setUInt16(0, mapId);
3680  stmt->setUInt32(1, instanceId);
3681  CharacterDatabase.Execute(stmt);
3682 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: CharacterDatabase.h:292
Definition: PreparedStatement.h:74
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
Definition: CharacterDatabase.h:298
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::DeleteStateMachine ( )
static
220 {
225 }
GridState * si_GridStates[MAX_GRID_STATE]
Definition: Map.cpp:52
Definition: NGrid.h:64
Definition: NGrid.h:65
Definition: NGrid.h:63
Definition: NGrid.h:66

+ Here is the caller graph for this function:

bool Map::DynamicObjectCellRelocation ( DynamicObject go,
Cell  new_cell 
)
private
1403 {
1404  Cell const& old_cell = go->GetCurrentCell();
1405  if (!old_cell.DiffGrid(new_cell)) // in same grid
1406  {
1407  // if in same cell then none do
1408  if (old_cell.DiffCell(new_cell))
1409  {
1410  #ifdef TRINITY_DEBUG
1411  TC_LOG_DEBUG("maps", "DynamicObject (%s) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
1412  #endif
1413 
1414  go->RemoveFromGrid();
1415  AddToGrid(go, new_cell);
1416  }
1417  else
1418  {
1419  #ifdef TRINITY_DEBUG
1420  TC_LOG_DEBUG("maps", "DynamicObject (%s) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
1421  #endif
1422  }
1423 
1424  return true;
1425  }
1426 
1427  // in diff. grids but active GameObject
1428  if (go->isActiveObject())
1429  {
1430  EnsureGridLoadedForActiveObject(new_cell, go);
1431 
1432  #ifdef TRINITY_DEBUG
1433  TC_LOG_DEBUG("maps", "Active DynamicObject (%s) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1434  #endif
1435 
1436  go->RemoveFromGrid();
1437  AddToGrid(go, new_cell);
1438 
1439  return true;
1440  }
1441 
1442  // in diff. loaded grid normal GameObject
1443  if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
1444  {
1445  #ifdef TRINITY_DEBUG
1446  TC_LOG_DEBUG("maps", "DynamicObject (%s) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1447  #endif
1448 
1449  go->RemoveFromGrid();
1450  EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
1451  AddToGrid(go, new_cell);
1452 
1453  return true;
1454  }
1455 
1456  // fail to move: normal GameObject attempt move to unloaded grid
1457  #ifdef TRINITY_DEBUG
1458  TC_LOG_DEBUG("maps", "DynamicObject (%s) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1459  #endif
1460  return false;
1461 }
void RemoveFromGrid()
Definition: Object.h:362
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:262
uint32 CellY() const
Definition: Cell.h:75
bool DiffCell(const Cell &cell) const
Definition: Cell.h:62
bool DiffGrid(const Cell &cell) const
Definition: Cell.h:68
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
uint32 CellX() const
Definition: Cell.h:74
bool isActiveObject() const
Definition: Object.h:581
uint32 GridY() const
Definition: Cell.h:77
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
Definition: Map.cpp:465
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
std::string ToString() const
Definition: ObjectGuid.cpp:99
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
uint32 GridX() const
Definition: Cell.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::DynamicObjectRelocation ( DynamicObject go,
float  x,
float  y,
float  z,
float  orientation 
)
1053 {
1054  Cell integrity_check(dynObj->GetPositionX(), dynObj->GetPositionY());
1055  Cell old_cell = dynObj->GetCurrentCell();
1056 
1057  ASSERT(integrity_check == old_cell);
1058  Cell new_cell(x, y);
1059 
1060  if (!getNGrid(new_cell.GridX(), new_cell.GridY()))
1061  return;
1062 
1063  // delay creature move for grid/cell to grid/cell moves
1064  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1065  {
1066 #ifdef TRINITY_DEBUG
1067  TC_LOG_DEBUG("maps", "GameObject (%s) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", dynObj->GetGUID().ToString().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1068 #endif
1069  AddDynamicObjectToMoveList(dynObj, x, y, z, orientation);
1070  // in diffcell/diffgrid case notifiers called at finishing move dynObj in Map::MoveAllGameObjectsInMoveList
1071  }
1072  else
1073  {
1074  dynObj->Relocate(x, y, z, orientation);
1075  dynObj->UpdateObjectVisibility(false);
1077  }
1078 
1079  old_cell = dynObj->GetCurrentCell();
1080  integrity_check = Cell(dynObj->GetPositionX(), dynObj->GetPositionY());
1081  ASSERT(integrity_check == old_cell);
1082 }
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
#define ASSERT
Definition: Errors.h:55
void RemoveDynamicObjectFromMoveList(DynamicObject *go)
Definition: Map.cpp:1132
G3D::int16 x
Definition: Vector2int16.h:37
void AddDynamicObjectToMoveList(DynamicObject *go, float x, float y, float z, float ang)
Definition: Map.cpp:1122

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::EnsureGridCreated ( const GridCoord p)
private
434 {
435  std::lock_guard<std::mutex> lock(_gridLock);
437 }
void EnsureGridCreated_i(const GridCoord &)
Definition: Map.cpp:441
std::mutex _gridLock
Definition: Map.h:638

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::EnsureGridCreated_i ( const GridCoord p)
private
442 {
443  if (!getNGrid(p.x_coord, p.y_coord))
444  {
445  TC_LOG_DEBUG("maps", "Creating grid[%u, %u] for map %u instance %u", p.x_coord, p.y_coord, GetId(), i_InstanceId);
446 
448  p.x_coord, p.y_coord);
449 
450  // build a linkage between this map and NGridType
452 
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  LoadMapAndVMap(gx, gy);
461  }
462 }
time_t i_gridExpiry
Definition: Map.h:671
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
Definition: World.h:104
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 y_coord
Definition: GridDefines.h:156
#define sWorld
Definition: World.h:887
uint32 x_coord
Definition: GridDefines.h:155
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:678
uint32 GetId(void) const
Definition: Map.h:325
void setNGrid(NGridType *grid, uint32 x, uint32 y)
Definition: Map.cpp:2743
Definition: NGrid.h:65
void LoadMapAndVMap(int gx, int gy)
Definition: Map.cpp:200
void SetGridState(grid_state_t s)
Definition: NGrid.h:101
void buildNGridLinkage(NGridType *pNGridType)
Definition: Map.h:615
uint32 i_InstanceId
Definition: Map.h:642
NGrid< MAX_NUMBER_OF_CELLS, Player, AllWorldObjectTypes, AllGridObjectTypes > NGridType
Definition: GridDefines.h:83

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::EnsureGridLoaded ( Cell const cell)
private
482 {
483  EnsureGridCreated(GridCoord(cell.GridX(), cell.GridY()));
484  NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
485 
486  ASSERT(grid != NULL);
487  if (!isGridObjectDataLoaded(cell.GridX(), cell.GridY()))
488  {
489  TC_LOG_DEBUG("maps", "Loading grid[%u, %u] for map %u instance %u", cell.GridX(), cell.GridY(), GetId(), i_InstanceId);
490 
491  setGridObjectDataLoaded(true, cell.GridX(), cell.GridY());
492 
493  LoadGridObjects(grid, cell);
494 
495  Balance();
496  return true;
497  }
498 
499  return false;
500 }
Definition: NGrid.h:77
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 GetId(void) const
Definition: Map.h:325
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
Definition: Map.h:623
virtual void LoadGridObjects(NGridType *grid, Cell const &cell)
Definition: Map.cpp:502
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
void Balance()
Definition: Map.h:504
uint32 i_InstanceId
Definition: Map.h:642
#define ASSERT
Definition: Errors.h:55
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
Definition: Map.h:624
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::EnsureGridLoadedForActiveObject ( Cell const cell,
WorldObject object 
)
private
466 {
467  EnsureGridLoaded(cell);
468  NGridType *grid = getNGrid(cell.GridX(), cell.GridY());
469  ASSERT(grid != NULL);
470 
471  // refresh grid state & timer
472  if (grid->GetGridState() != GRID_STATE_ACTIVE)
473  {
474  TC_LOG_DEBUG("maps", "Active object %s triggers loading of grid [%u, %u] on map %u", object->GetGUID().ToString().c_str(), cell.GridX(), cell.GridY(), GetId());
475  ResetGridExpiry(*grid, 0.1f);
477  }
478 }
Definition: NGrid.h:77
bool EnsureGridLoaded(Cell const &)
Definition: Map.cpp:481
grid_state_t GetGridState(void) const
Definition: NGrid.h:100
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: NGrid.h:64
uint32 GetId(void) const
Definition: Map.h:325
void SetGridState(grid_state_t s)
Definition: NGrid.h:101
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
void ResetGridExpiry(NGridType &grid, float factor=1) const
Definition: Map.h:319
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::ExistMap ( uint32  mapid,
int  gx,
int  gy 
)
static
80 {
81  std::string fileName = Trinity::StringFormat("%smaps/%04u_%02u_%02u.map", sWorld->GetDataPath().c_str(), mapid, gx, gy);
82 
83  bool ret = false;
84  FILE* file = fopen(fileName.c_str(), "rb");
85  if (!file)
86  {
87  TC_LOG_ERROR("maps", "Map file '%s' does not exist!", fileName.c_str());
88  TC_LOG_ERROR("maps", "Please place MAP-files (*.map) in the appropriate directory (%s), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath()+"maps/").c_str());
89  }
90  else
91  {
92  map_fileheader header;
93  if (fread(&header, sizeof(header), 1, file) == 1)
94  {
96  TC_LOG_ERROR("maps", "Map file '%s' is from an incompatible map version (%.*s %.*s), %.*s %.*s is expected. Please recreate using the mapextractor.",
97  fileName.c_str(), 4, header.mapMagic.asChar, 4, header.versionMagic.asChar, 4, MapMagic.asChar, 4, MapVersionMagic.asChar);
98  else
99  ret = true;
100  }
101  fclose(file);
102  }
103 
104  return ret;
105 }
u_map_magic MapMagic
Definition: Map.cpp:42
#define sWorld
Definition: World.h:887
u_map_magic MapVersionMagic
Definition: Map.cpp:43
char asChar[4]
Definition: Map.h:72
uint32 asUInt
Non-null terminated string
Definition: Map.h:73
Definition: Map.h:79
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
u_map_magic mapMagic
Definition: Map.h:81
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
u_map_magic versionMagic
Definition: Map.h:82

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::ExistVMap ( uint32  mapid,
int  gx,
int  gy 
)
static
108 {
110  {
111  if (vmgr->isMapLoadingEnabled())
112  {
113  bool exists = vmgr->existsMap((sWorld->GetDataPath()+ "vmaps").c_str(), mapid, gx, gy);
114  if (!exists)
115  {
116  std::string name = vmgr->getDirFileName(mapid, gx, gy);
117  TC_LOG_ERROR("maps", "VMap file '%s' does not exist", (sWorld->GetDataPath()+"vmaps/"+name).c_str());
118  TC_LOG_ERROR("maps", "Please place VMAP-files (*.vmtree and *.vmtile) in the vmap-directory (%s), or correct the DataDir setting in your worldserver.conf file.", (sWorld->GetDataPath()+"vmaps/").c_str());
119  return false;
120  }
121  }
122  }
123 
124  return true;
125 }
#define sWorld
Definition: World.h:887
Definition: IVMapManager.h:45
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::GameObjectCellRelocation ( GameObject go,
Cell  new_cell 
)
private
1342 {
1343  Cell const& old_cell = go->GetCurrentCell();
1344  if (!old_cell.DiffGrid(new_cell)) // in same grid
1345  {
1346  // if in same cell then none do
1347  if (old_cell.DiffCell(new_cell))
1348  {
1349  #ifdef TRINITY_DEBUG
1350  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved in grid[%u, %u] from cell[%u, %u] to cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.CellX(), new_cell.CellY());
1351  #endif
1352 
1353  go->RemoveFromGrid();
1354  AddToGrid(go, new_cell);
1355  }
1356  else
1357  {
1358  #ifdef TRINITY_DEBUG
1359  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved in same grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY());
1360  #endif
1361  }
1362 
1363  return true;
1364  }
1365 
1366  // in diff. grids but active GameObject
1367  if (go->isActiveObject())
1368  {
1369  EnsureGridLoadedForActiveObject(new_cell, go);
1370 
1371  #ifdef TRINITY_DEBUG
1372  TC_LOG_DEBUG("maps", "Active GameObject (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1373  #endif
1374 
1375  go->RemoveFromGrid();
1376  AddToGrid(go, new_cell);
1377 
1378  return true;
1379  }
1380 
1381  // in diff. loaded grid normal GameObject
1382  if (IsGridLoaded(GridCoord(new_cell.GridX(), new_cell.GridY())))
1383  {
1384  #ifdef TRINITY_DEBUG
1385  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1386  #endif
1387 
1388  go->RemoveFromGrid();
1389  EnsureGridCreated(GridCoord(new_cell.GridX(), new_cell.GridY()));
1390  AddToGrid(go, new_cell);
1391 
1392  return true;
1393  }
1394 
1395  // fail to move: normal GameObject attempt move to unloaded grid
1396  #ifdef TRINITY_DEBUG
1397  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) attempted to move from grid[%u, %u]cell[%u, %u] to unloaded grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1398  #endif
1399  return false;
1400 }
void RemoveFromGrid()
Definition: Object.h:362
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:262
uint32 CellY() const
Definition: Cell.h:75
bool DiffCell(const Cell &cell) const
Definition: Cell.h:62
bool DiffGrid(const Cell &cell) const
Definition: Cell.h:68
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
uint32 CellX() const
Definition: Cell.h:74
bool isActiveObject() const
Definition: Object.h:581
uint32 GridY() const
Definition: Cell.h:77
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
Definition: Map.cpp:465
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
std::string ToString() const
Definition: ObjectGuid.cpp:99
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
uint32 GridX() const
Definition: Cell.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::GameObjectRelocation ( GameObject go,
float  x,
float  y,
float  z,
float  orientation,
bool  respawnRelocationOnFail = true 
)
1020 {
1021  Cell integrity_check(go->GetPositionX(), go->GetPositionY());
1022  Cell old_cell = go->GetCurrentCell();
1023 
1024  ASSERT(integrity_check == old_cell);
1025  Cell new_cell(x, y);
1026 
1027  if (!respawnRelocationOnFail && !getNGrid(new_cell.GridX(), new_cell.GridY()))
1028  return;
1029 
1030  // delay creature move for grid/cell to grid/cell moves
1031  if (old_cell.DiffCell(new_cell) || old_cell.DiffGrid(new_cell))
1032  {
1033 #ifdef TRINITY_DEBUG
1034  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) added to moving list from grid[%u, %u]cell[%u, %u] to grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
1035 #endif
1036  AddGameObjectToMoveList(go, x, y, z, orientation);
1037  // in diffcell/diffgrid case notifiers called at finishing move go in Map::MoveAllGameObjectsInMoveList
1038  }
1039  else
1040  {
1041  go->Relocate(x, y, z, orientation);
1042  go->UpdateModelPosition();
1043  go->UpdateObjectVisibility(false);
1045  }
1046 
1047  old_cell = go->GetCurrentCell();
1048  integrity_check = Cell(go->GetPositionX(), go->GetPositionY());
1049  ASSERT(integrity_check == old_cell);
1050 }
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void Relocate(float x, float y)
Definition: Position.h:67
void RemoveGameObjectFromMoveList(GameObject *go)
Definition: Map.cpp:1113
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
void UpdateModelPosition()
Definition: GameObject.cpp:2425
void AddGameObjectToMoveList(GameObject *go, float x, float y, float z, float ang)
Definition: Map.cpp:1103
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3001
#define ASSERT
Definition: Errors.h:55
uint32 GetEntry() const
Definition: Object.h:107
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::GameObjectRespawnRelocation ( GameObject go,
bool  diffGridOnly 
)
1494 {
1495  float resp_x, resp_y, resp_z, resp_o;
1496  go->GetRespawnPosition(resp_x, resp_y, resp_z, &resp_o);
1497  Cell resp_cell(resp_x, resp_y);
1498 
1499  //GameObject will be unloaded with grid
1500  if (diffGridOnly && !go->GetCurrentCell().DiffGrid(resp_cell))
1501  return true;
1502 
1503  #ifdef TRINITY_DEBUG
1504  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) moved from grid[%u, %u]cell[%u, %u] to respawn grid[%u, %u]cell[%u, %u].", go->GetGUID().ToString().c_str(), go->GetEntry(), go->GetCurrentCell().GridX(), go->GetCurrentCell().GridY(), go->GetCurrentCell().CellX(), go->GetCurrentCell().CellY(), resp_cell.GridX(), resp_cell.GridY(), resp_cell.CellX(), resp_cell.CellY());
1505  #endif
1506 
1507  // teleport it to respawn point (like normal respawn if player see)
1508  if (GameObjectCellRelocation(go, resp_cell))
1509  {
1510  go->Relocate(resp_x, resp_y, resp_z, resp_o);
1511  go->UpdateObjectVisibility(false);
1512  return true;
1513  }
1514 
1515  return false;
1516 }
bool GameObjectCellRelocation(GameObject *go, Cell new_cell)
Definition: Map.cpp:1341
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void GetRespawnPosition(float &x, float &y, float &z, float *ori=NULL) const
Definition: GameObject.cpp:2386
void Relocate(float x, float y)
Definition: Position.h:67
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3001
uint32 GetEntry() const
Definition: Object.h:107
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<HighGuid high>
ObjectGuid::LowType Map::GenerateLowGuid ( )
inline
562  {
563  static_assert(ObjectGuidTraits<high>::MapSpecific, "Only map specific guid can be generated in Map context");
564  return GetGuidSequenceGenerator<high>().Generate();
565  }
Definition: ObjectGuid.h:114

+ Here is the caller graph for this function:

uint32 Map::GetAreaId ( float  x,
float  y,
float  z,
bool isOutdoors 
) const
2427 {
2428  uint32 mogpFlags;
2429  int32 adtId, rootId, groupId;
2430  WMOAreaTableEntry const* wmoEntry = nullptr;
2431  AreaTableEntry const* atEntry = nullptr;
2432  bool haveAreaInfo = false;
2433 
2434  if (GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId))
2435  {
2436  haveAreaInfo = true;
2437  wmoEntry = GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
2438  if (wmoEntry)
2439  atEntry = sAreaTableStore.LookupEntry(wmoEntry->AreaTableID);
2440  }
2441 
2442  uint32 areaId = 0;
2443 
2444  if (atEntry)
2445  areaId = atEntry->ID;
2446  else
2447  {
2448  if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2449  areaId = gmap->getArea(x, y);
2450 
2451  // this used while not all *.map files generated (instances)
2452  if (!areaId)
2453  areaId = i_mapEntry->AreaTableID;
2454  }
2455 
2456  if (isOutdoors)
2457  {
2458  if (haveAreaInfo)
2459  *isOutdoors = IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
2460  else
2461  *isOutdoors = true;
2462  }
2463  return areaId;
2464 }
bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition: Map.cpp:2407
Definition: DBCStructure.h:37
MapEntry const * i_mapEntry
Definition: Map.h:640
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:2284
Definition: Map.h:159
WMOAreaTableEntry const * GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
Definition: DBCStores.cpp:579
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
uint32 AreaTableID
Definition: DBCStructure.h:1395
Definition: DBCStructure.h:1383
G3D::int16 z
Definition: Vector3int16.h:46
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
bool IsOutdoorWMO(uint32 mogpFlags, int32, int32, int32, WMOAreaTableEntry const *wmoEntry, AreaTableEntry const *atEntry)
Definition: Map.cpp:2364
uint32 ID
Definition: DBCStructure.h:39
G3D::int16 x
Definition: Vector2int16.h:37
uint32 AreaTableID
Definition: DBCStructure.h:839

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Map::GetAreaId ( float  x,
float  y,
float  z 
) const
2467 {
2468  return GetAreaId(x, y, z, nullptr);
2469 }
uint32 GetAreaId(float x, float y, float z, bool *isOutdoors) const
Definition: Map.cpp:2426
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

bool Map::GetAreaInfo ( float  x,
float  y,
float  z,
uint32 mogpflags,
int32 adtId,
int32 rootId,
int32 groupId 
) const
2408 {
2409  float vmap_z = z;
2411  if (vmgr->getAreaInfo(GetId(), x, y, vmap_z, flags, adtId, rootId, groupId))
2412  {
2413  // check if there's terrain between player height and object height
2414  if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2415  {
2416  float _mapheight = gmap->getHeight(x, y);
2417  // z + 2.0f condition taken from GetHeight(), not sure if it's such a great choice...
2418  if (z + 2.0f > _mapheight && _mapheight > vmap_z)
2419  return false;
2420  }
2421  return true;
2422  }
2423  return false;
2424 }
Definition: Map.h:159
uint32 GetId(void) const
Definition: Map.h:325
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: IVMapManager.h:45
virtual bool getAreaInfo(unsigned int pMapId, float x, float y, float &z, uint32 &flags, int32 &adtId, int32 &rootId, int32 &groupId) const =0
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
uint8 flags
Definition: DisableMgr.cpp:44
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

AreaTrigger * Map::GetAreaTrigger ( ObjectGuid const guid)
3526 {
3527  return _objectsStore.Find<AreaTrigger>(guid);
3528 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:131
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738
Definition: AreaTrigger.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Corpse * Map::GetCorpse ( ObjectGuid const guid)
3531 {
3532  return _objectsStore.Find<Corpse>(guid);
3533 }
Definition: Corpse.h:49
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:131
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Corpse* Map::GetCorpseByPlayer ( ObjectGuid const ownerGuid) const
inline
484  {
485  auto itr = _corpsesByPlayer.find(ownerGuid);
486  if (itr != _corpsesByPlayer.end())
487  return itr->second;
488 
489  return nullptr;
490  }
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:742

+ Here is the caller graph for this function:

std::unordered_set<Corpse*> const* Map::GetCorpsesInCell ( uint32  cellId) const
inline
475  {
476  auto itr = _corpsesByCell.find(cellId);
477  if (itr != _corpsesByCell.end())
478  return &itr->second;
479 
480  return nullptr;
481  }
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:741

+ Here is the caller graph for this function:

Creature * Map::GetCreature ( ObjectGuid const guid)
3536 {
3537  return _objectsStore.Find<Creature>(guid);
3538 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:131
Definition: Creature.h:467
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738

+ Here is the call graph for this function:

CreatureBySpawnIdContainer& Map::GetCreatureBySpawnIdStore ( )
inline
469 { return _creatureBySpawnIdStore; }
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition: Map.h:739

+ Here is the caller graph for this function:

time_t Map::GetCreatureRespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
516  {
517  std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _creatureRespawnTimes.find(dbGuid);
518  if (itr != _creatureRespawnTimes.end())
519  return itr->second;
520 
521  return time_t(0);
522  }
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition: Map.h:721
uint64 LowType
Definition: ObjectGuid.h:199

+ Here is the caller graph for this function:

Difficulty Map::GetDifficultyID ( ) const
inline
390 { return Difficulty(GetSpawnMode()); }
Difficulty
Definition: DBCEnums.h:402
uint8 GetSpawnMode() const
Definition: Map.h:369

+ Here is the caller graph for this function:

uint32 Map::GetDifficultyLootBonusTreeMod ( ) const
3409 {
3410  if (MapDifficultyEntry const* mapDifficulty = GetMapDifficulty())
3411  if (mapDifficulty->ItemBonusTreeModID)
3412  return mapDifficulty->ItemBonusTreeModID;
3413 
3414  if (DifficultyEntry const* difficulty = sDifficultyStore.LookupEntry(GetDifficultyID()))
3415  return difficulty->ItemBonusTreeModID;
3416 
3417  return 0;
3418 }
Difficulty GetDifficultyID() const
Definition: Map.h:390
Definition: DBCStructure.h:885
DBCStorage< DifficultyEntry > sDifficultyStore(DifficultyFmt)
MapDifficultyEntry const * GetMapDifficulty() const
Definition: Map.cpp:3403
Definition: DBCStructure.h:338

+ Here is the call graph for this function:

DynamicObject * Map::GetDynamicObject ( ObjectGuid const guid)
3541 {
3542  return _objectsStore.Find<DynamicObject>(guid);
3543 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:131
Definition: DynamicObject.h:35
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::GetEntrancePos ( int32 mapid,
float &  x,
float &  y 
)
inline
406  {
407  if (!i_mapEntry)
408  return false;
409  return i_mapEntry->GetEntrancePos(mapid, x, y);
410  }
MapEntry const * i_mapEntry
Definition: Map.h:640
bool GetEntrancePos(int32 &mapid, float &x, float &y) const
Definition: DBCStructure.h:866
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
MapEntry const* Map::GetEntry ( ) const
inline
266 { return i_mapEntry; }
MapEntry const * i_mapEntry
Definition: Map.h:640

+ Here is the caller graph for this function:

GameObject * Map::GetGameObject ( ObjectGuid const guid)
3546 {
3547  return _objectsStore.Find<GameObject>(guid);
3548 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:131
Definition: GameObject.h:880
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738

+ Here is the call graph for this function:

GameObjectBySpawnIdContainer& Map::GetGameObjectBySpawnIdStore ( )
inline
472 { return _gameobjectBySpawnIdStore; }
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
Definition: Map.h:740

+ Here is the caller graph for this function:

time_t Map::GetGORespawnTime ( ObjectGuid::LowType  dbGuid) const
inline
525  {
526  std::unordered_map<ObjectGuid::LowType /*dbGUID*/, time_t>::const_iterator itr = _goRespawnTimes.find(dbGuid);
527  if (itr != _goRespawnTimes.end())
528  return itr->second;
529 
530  return time_t(0);
531  }
uint64 LowType
Definition: ObjectGuid.h:199
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition: Map.h:722

+ Here is the caller graph for this function:

GridMap * Map::GetGrid ( float  x,
float  y 
)
inlineprivate
2285 {
2286  // half opt method
2287  int gx=(int)(CENTER_GRID_ID - x/SIZE_OF_GRIDS); //grid x
2288  int gy=(int)(CENTER_GRID_ID - y/SIZE_OF_GRIDS); //grid y
2289 
2290  // ensure GridMap is loaded
2292 
2293  return GridMaps[gx][gy];
2294 }
#define SIZE_OF_GRIDS
Definition: GridDefines.h:39
#define CENTER_GRID_ID
Definition: GridDefines.h:40
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:678
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

time_t Map::GetGridExpiry ( void  ) const
inline
324 { return i_gridExpiry; }
time_t i_gridExpiry
Definition: Map.h:671

+ Here is the caller graph for this function:

template<HighGuid high>
ObjectGuidGeneratorBase& Map::GetGuidSequenceGenerator ( )
inlineprivate
729  {
730  auto itr = _guidGenerators.find(high);
731  if (itr == _guidGenerators.end())
732  itr = _guidGenerators.insert(std::make_pair(high, Trinity::make_unique<ObjectGuidGenerator<high>>())).first;
733 
734  return *itr->second;
735  }
std::map< HighGuid, std::unique_ptr< ObjectGuidGeneratorBase > > _guidGenerators
Definition: Map.h:737
Definition: ObjectGuid.h:372
std::unique_ptr< T > make_unique(Args &&...args)
std::make_unique implementation (TODO: remove this once C++14 is supported)
Definition: Common.h:176

+ Here is the call graph for this function:

float Map::GetHeight ( float  x,
float  y,
float  z,
bool  checkVMap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
2315 {
2316  // find raw .map surface under Z coordinates
2317  float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
2318  if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2319  {
2320  float gridHeight = gmap->getHeight(x, y);
2321  // look from a bit higher pos to find the floor, ignore under surface case
2322  if (z + 2.0f > gridHeight)
2323  mapHeight = gridHeight;
2324  }
2325 
2326  float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
2327  if (checkVMap)
2328  {
2330  if (vmgr->isHeightCalcEnabled())
2331  vmapHeight = vmgr->getHeight(GetId(), x, y, z + 2.0f, maxSearchDist); // look from a bit higher pos to find the floor
2332  }
2333 
2334  // mapHeight set for any above raw ground Z or <= INVALID_HEIGHT
2335  // vmapheight set for any under Z value or <= INVALID_HEIGHT
2336  if (vmapHeight > INVALID_HEIGHT)
2337  {
2338  if (mapHeight > INVALID_HEIGHT)
2339  {
2340  // we have mapheight and vmapheight and must select more appropriate
2341 
2342  // we are already under the surface or vmap height above map heigt
2343  // or if the distance of the vmap height is less the land height distance
2344  if (z < mapHeight || vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
2345  return vmapHeight;
2346  else
2347  return mapHeight; // better use .map surface height
2348  }
2349  else
2350  return vmapHeight; // we have only vmapHeight (if have)
2351  }
2352 
2353  return mapHeight; // explicitly use map data
2354 }
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:2284
Definition: Map.h:159
uint32 GetId(void) const
Definition: Map.h:325
G3D::int16 z
Definition: Vector3int16.h:46
#define VMAP_INVALID_HEIGHT_VALUE
Definition: IVMapManager.h:42
G3D::int16 y
Definition: Vector2int16.h:38
Definition: IVMapManager.h:45
bool isHeightCalcEnabled() const
Definition: IVMapManager.h:87
virtual float getHeight(unsigned int pMapId, float x, float y, float z, float maxSearchDist)=0
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
G3D::int16 x
Definition: Vector2int16.h:37
#define INVALID_HEIGHT
Definition: Map.h:248

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Map::GetHeight ( uint32  phasemask,
float  x,
float  y,
float  z,
bool  vmap = true,
float  maxSearchDist = DEFAULT_HEIGHT_SEARCH 
) const
2611 {
2612  return std::max<float>(GetHeight(x, y, z, vmap, maxSearchDist), _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask));
2613 }
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
DynamicMapTree _dynamicTree
Definition: Map.h:645
G3D::int16 x
Definition: Vector2int16.h:37
float getHeight(float x, float y, float z, float maxSearchDist, uint32 phasemask) const
Definition: DynamicTree.cpp:249

+ Here is the call graph for this function:

uint32 Map::GetId ( void  ) const
inline
325 { return i_mapEntry->ID; }
MapEntry const * i_mapEntry
Definition: Map.h:640
uint32 ID
Definition: DBCStructure.h:832
uint32 Map::GetInstanceId ( ) const
inline
368 { return i_InstanceId; }
uint32 i_InstanceId
Definition: Map.h:642

+ Here is the caller graph for this function:

time_t Map::GetLinkedRespawnTime ( ObjectGuid  guid) const
3685 {
3686  ObjectGuid linkedGuid = sObjectMgr->GetLinkedRespawnGuid(guid);
3687  switch (linkedGuid.GetHigh())
3688  {
3689  case HighGuid::Creature:
3690  return GetCreatureRespawnTime(linkedGuid.GetCounter());
3691  case HighGuid::GameObject:
3692  return GetGORespawnTime(linkedGuid.GetCounter());
3693  default:
3694  break;
3695  }
3696 
3697  return time_t(0);
3698 }
#define sObjectMgr
Definition: ObjectMgr.h:1567
time_t GetGORespawnTime(ObjectGuid::LowType dbGuid) const
Definition: Map.h:524
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
Definition: ObjectGuid.h:189
time_t GetCreatureRespawnTime(ObjectGuid::LowType dbGuid) const
Definition: Map.h:515
LowType GetCounter() const
Definition: ObjectGuid.h:221

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ZLiquidStatus Map::getLiquidStatus ( float  x,
float  y,
float  z,
uint8  ReqLiquidType,
LiquidData data = nullptr 
) const
2498 {
2501  float liquid_level = INVALID_HEIGHT;
2502  float ground_level = INVALID_HEIGHT;
2503  uint32 liquid_type = 0;
2504  if (vmgr->GetLiquidLevel(GetId(), x, y, z, ReqLiquidType, liquid_level, ground_level, liquid_type))
2505  {
2506  TC_LOG_DEBUG("maps", "getLiquidStatus(): vmap liquid level: %f ground: %f type: %u", liquid_level, ground_level, liquid_type);
2507  // Check water level and ground level
2508  if (liquid_level > ground_level && z > ground_level - 2)
2509  {
2510  // All ok in water -> store data
2511  if (data)
2512  {
2513  // hardcoded in client like this
2514  if (GetId() == 530 && liquid_type == 2)
2515  liquid_type = 15;
2516 
2517  uint32 liquidFlagType = 0;
2518  if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(liquid_type))
2519  liquidFlagType = liq->Type;
2520 
2521  if (liquid_type && liquid_type < 21)
2522  {
2523  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(GetAreaId(x, y, z)))
2524  {
2525  uint32 overrideLiquid = area->LiquidTypeID[liquidFlagType];
2526  if (!overrideLiquid && area->ParentAreaID)
2527  {
2528  area = sAreaTableStore.LookupEntry(area->ParentAreaID);
2529  if (area)
2530  overrideLiquid = area->LiquidTypeID[liquidFlagType];
2531  }
2532 
2533  if (LiquidTypeEntry const* liq = sLiquidTypeStore.LookupEntry(overrideLiquid))
2534  {
2535  liquid_type = overrideLiquid;
2536  liquidFlagType = liq->Type;
2537  }
2538  }
2539  }
2540 
2541  data->level = liquid_level;
2542  data->depth_level = ground_level;
2543 
2544  data->entry = liquid_type;
2545  data->type_flags = 1 << liquidFlagType;
2546  }
2547 
2548  float delta = liquid_level - z;
2549 
2550  // Get position delta
2551  if (delta > 2.0f) // Under water
2552  return LIQUID_MAP_UNDER_WATER;
2553  if (delta > 0.0f) // In water
2554  return LIQUID_MAP_IN_WATER;
2555  if (delta > -0.1f) // Walk on water
2556  return LIQUID_MAP_WATER_WALK;
2557  result = LIQUID_MAP_ABOVE_WATER;
2558  }
2559  }
2560 
2561  if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2562  {
2563  LiquidData map_data;
2564  ZLiquidStatus map_result = gmap->getLiquidStatus(x, y, z, ReqLiquidType, &map_data);
2565  // Not override LIQUID_MAP_ABOVE_WATER with LIQUID_MAP_NO_WATER:
2566  if (map_result != LIQUID_MAP_NO_WATER && (map_data.level > ground_level))
2567  {
2568  if (data)
2569  {
2570  // hardcoded in client like this
2571  if (GetId() == 530 && map_data.entry == 2)
2572  map_data.entry = 15;
2573 
2574  *data = map_data;
2575  }
2576  return map_result;
2577  }
2578  }
2579  return result;
2580 }
uint32 GetAreaId(float x, float y, float z, bool *isOutdoors) const
Definition: Map.cpp:2426
Definition: DBCStructure.h:37
DBCStorage< LiquidTypeEntry > sLiquidTypeStore(LiquidTypefmt)
Definition: Map.h:136
float depth_level
Definition: Map.h:156
Definition: Map.h:159
Definition: Map.h:151
Definition: Map.h:134
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
uint32 GetId(void) const
Definition: Map.h:325
virtual bool GetLiquidLevel(uint32 pMapId, float x, float y, float z, uint8 ReqLiquidType, float &level, float &floor, uint32 &type) const =0
Definition: DBCStructure.h:789
G3D::int16 z
Definition: Vector3int16.h:46
float level
Definition: Map.h:155
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: IVMapManager.h:45
ZLiquidStatus
Definition: Map.h:131
Definition: Map.h:135
uint32 type_flags
Definition: Map.h:153
uint32 entry
Definition: Map.h:154
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Map.h:137
#define INVALID_HEIGHT
Definition: Map.h:248
Definition: Map.h:133

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MapDifficultyEntry const * Map::GetMapDifficulty ( ) const
3404 {
3406 }
MapDifficultyEntry const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition: DBCStores.cpp:724
Difficulty GetDifficultyID() const
Definition: Map.h:390
uint32 GetId(void) const
Definition: Map.h:325

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

char const * Map::GetMapName ( ) const
2645 {
2646  return i_mapEntry ? i_mapEntry->MapName_lang : "UNNAMEDMAP\x0";
2647 }
MapEntry const * i_mapEntry
Definition: Map.h:640
char * MapName_lang
Definition: DBCStructure.h:838

+ Here is the caller graph for this function:

float Map::GetMinHeight ( float  x,
float  y 
) const
2357 {
2358  if (GridMap const* grid = const_cast<Map*>(this)->GetGrid(x, y))
2359  return grid->getMinHeight(x, y);
2360 
2361  return -500.0f;
2362 }
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:2284
Definition: Map.h:159
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

NGridType* Map::getNGrid ( uint32  x,
uint32  y 
) const
inlineprivate
618  {
620  return i_grids[x][y];
621  }
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
G3D::int16 y
Definition: Vector2int16.h:38
NGridType * i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:677
#define ASSERT
Definition: Errors.h:55
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

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 
)
2597 {
2598  G3D::Vector3 startPos(x1, y1, z1);
2599  G3D::Vector3 dstPos(x2, y2, z2);
2600 
2601  G3D::Vector3 resultPos;
2602  bool result = _dynamicTree.getObjectHitPos(phasemask, startPos, dstPos, resultPos, modifyDist);
2603 
2604  rx = resultPos.x;
2605  ry = resultPos.y;
2606  rz = resultPos.z;
2607  return result;
2608 }
float x
Definition: Vector3.h:62
float y
Definition: Vector3.h:62
Definition: Vector3.h:58
DynamicMapTree _dynamicTree
Definition: Map.h:645
float z
Definition: Vector3.h:62
bool getObjectHitPos(uint32 phasemask, const G3D::Vector3 &pPos1, const G3D::Vector3 &pPos2, G3D::Vector3 &pResultHitPos, float pModifyDist) const
Definition: DynamicTree.cpp:193

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

MapStoredObjectTypesContainer& Map::GetObjectsStore ( )
inline
466 { return _objectsStore; }
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738

+ Here is the caller graph for this function:

virtual ObjectGuid::LowType Map::GetOwnerGuildId ( uint32  = TEAM_OTHER) const
inlinevirtual
510 { return UI64LIT(0); }
#define UI64LIT(N)
Definition: Define.h:138
Map const* Map::GetParent ( ) const
inline
333 { return m_parentMap; }
Map * m_parentMap
Definition: Map.h:675

+ Here is the caller graph for this function:

Pet * Map::GetPet ( ObjectGuid const guid)
3551 {
3552  return _objectsStore.Find<Pet>(guid);
3553 }
SPECIFIC_TYPE * Find(KEY_TYPE const &handle)
Definition: TypeContainer.h:131
MapStoredObjectTypesContainer _objectsStore
Definition: Map.h:738
Definition: Pet.h:46

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PlayerList const& Map::GetPlayers ( ) const
inline
433 { return m_mapRefManager; }
MapRefManager m_mapRefManager
Definition: Map.h:647
uint32 Map::GetPlayersCountExceptGMs ( ) const
2906 {
2907  uint32 count = 0;
2909  if (!itr->GetSource()->IsGameMaster())
2910  ++count;
2911  return count;
2912 }
iterator begin()
Definition: MapRefManager.h:37
uint32_t uint32
Definition: Define.h:150
Definition: LinkedList.h:141
MapRefManager m_mapRefManager
Definition: Map.h:647
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint8 Map::GetSpawnMode ( ) const
inline
369 { return (i_spawnMode); }
uint8 i_spawnMode
Definition: Map.h:641

+ Here is the caller graph for this function:

uint8 Map::GetTerrainType ( float  x,
float  y 
) const
2490 {
2491  if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2492  return gmap->getTerrainType(x, y);
2493  else
2494  return 0;
2495 }
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:2284
Definition: Map.h:159
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

Transport * Map::GetTransport ( ObjectGuid const guid)
3556 {
3557  if (!guid.IsMOTransport())
3558  return NULL;
3559 
3560  GameObject* go = GetGameObject(guid);
3561  return go ? go->ToTransport() : NULL;
3562 }
arena_t NULL
Definition: jemalloc_internal.h:624
Transport * ToTransport()
Definition: GameObject.h:1073
Definition: GameObject.h:880
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::GetUnloadLock ( const GridCoord p) const
inline
313 { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
bool getUnloadLock() const
Definition: NGrid.h:114
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
float Map::GetVisibilityRange ( ) const
inline
290 { return m_VisibleDistance; }
float m_VisibleDistance
Definition: Map.h:644

+ Here is the caller graph for this function:

float Map::GetWaterLevel ( float  x,
float  y 
) const
2583 {
2584  if (GridMap* gmap = const_cast<Map*>(this)->GetGrid(x, y))
2585  return gmap->getLiquidLevel(x, y);
2586  else
2587  return 0;
2588 }
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:2284
Definition: Map.h:159
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

float Map::GetWaterOrGroundLevel ( float  x,
float  y,
float  z,
float *  ground = NULL,
bool  swim = false 
) const
2297 {
2298  if (const_cast<Map*>(this)->GetGrid(x, y))
2299  {
2300  // we need ground level (including grid height version) for proper return water level in point
2301  float ground_z = GetHeight(PHASEMASK_NORMAL, x, y, z, true, 50.0f);
2302  if (ground)
2303  *ground = ground_z;
2304 
2305  LiquidData liquid_status;
2306 
2307  ZLiquidStatus res = getLiquidStatus(x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status);
2308  return res ? liquid_status.level : ground_z;
2309  }
2310 
2312 }
GridMap * GetGrid(float x, float y)
Definition: Map.cpp:2284
Definition: Map.h:151
float GetHeight(float x, float y, float z, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition: Map.cpp:2314
Definition: Object.h:66
G3D::int16 z
Definition: Vector3int16.h:46
#define MAP_ALL_LIQUIDS
Definition: Map.h:146
float level
Definition: Map.h:155
#define VMAP_INVALID_HEIGHT_VALUE
Definition: IVMapManager.h:42
G3D::int16 y
Definition: Vector2int16.h:38
ZLiquidStatus
Definition: Map.h:131
G3D::int16 x
Definition: Vector2int16.h:37
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::GetZoneAndAreaId ( uint32 zoneid,
uint32 areaid,
float  x,
float  y,
float  z 
) const
2482 {
2483  areaid = zoneid = GetAreaId(x, y, z);
2484  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaid))
2485  if (area->ParentAreaID)
2486  zoneid = area->ParentAreaID;
2487 }
uint32 GetAreaId(float x, float y, float z, bool *isOutdoors) const
Definition: Map.cpp:2426
Definition: DBCStructure.h:37
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint32 Map::GetZoneId ( float  x,
float  y,
float  z 
) const
2472 {
2473  uint32 areaId = GetAreaId(x, y, z);
2474  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId))
2475  if (area->ParentAreaID)
2476  return area->ParentAreaID;
2477 
2478  return areaId;
2479 }
uint32 GetAreaId(float x, float y, float z, bool *isOutdoors) const
Definition: Map.cpp:2426
Definition: DBCStructure.h:37
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
G3D::int16 z
Definition: Vector3int16.h:46
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::HavePlayers ( ) const
inline
423 { return !m_mapRefManager.isEmpty(); }
bool isEmpty() const
Definition: LinkedList.h:102
MapRefManager m_mapRefManager
Definition: Map.h:647

+ Here is the caller graph for this function:

template<>
void Map::InitializeObject ( Creature obj)
555 {
556  obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
557 }
Definition: Object.h:393
template<>
void Map::InitializeObject ( GameObject obj)
561 {
562  obj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
563 }
Definition: Object.h:393
template<class T >
void Map::InitializeObject ( T *  obj)
private
551 { }

+ Here is the caller graph for this function:

void Map::InitStateMachine ( )
static
212 {
217 }
GridState * si_GridStates[MAX_GRID_STATE]
Definition: Map.cpp:52
Definition: GridStates.h:52
Definition: GridStates.h:34
Definition: GridStates.h:40
Definition: NGrid.h:64
Definition: NGrid.h:65
Definition: NGrid.h:63
Definition: NGrid.h:66
Definition: GridStates.h:46

+ Here is the caller graph for this function:

void Map::InitVisibilityDistance ( )
virtual

Reimplemented in BattlegroundMap, InstanceMap, MapInstanced, and GarrisonMap.

254 {
255  //init visibility for continents
258 }
float m_VisibleDistance
Definition: Map.h:644
static float GetMaxVisibleDistanceOnContinents()
Definition: World.h:729
static int32 GetVisibilityNotifyPeriodOnContinents()
Definition: World.h:733
int32 m_VisibilityNotifyPeriod
Definition: Map.h:650

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::InsertGameObjectModel ( const GameObjectModel model)
inline
506 { _dynamicTree.insert(model); }
DynamicMapTree _dynamicTree
Definition: Map.h:645
void insert(const GameObjectModel &)
Definition: DynamicTree.cpp:117

+ Here is the caller graph for this function:

bool Map::Instanceable ( ) const
inline
394 { return i_mapEntry && i_mapEntry->Instanceable(); }
MapEntry const * i_mapEntry
Definition: Map.h:640
bool Instanceable() const
Definition: DBCStructure.h:859

+ Here is the caller graph for this function:

bool Map::Is25ManRaid ( ) const
inline
400 { return IsRaid() && (i_spawnMode == DIFFICULTY_25_N || i_spawnMode == DIFFICULTY_25_HC); } // since 25man difficulties are 1 and 3, we can check them like that
bool IsRaid() const
Definition: Map.h:397
uint8 i_spawnMode
Definition: Map.h:641
Definition: DBCEnums.h:408
Definition: DBCEnums.h:410

+ Here is the caller graph for this function:

bool Map::IsBattleArena ( ) const
inline
402 { return i_mapEntry && i_mapEntry->IsBattleArena(); }
bool IsBattleArena() const
Definition: DBCStructure.h:862
MapEntry const * i_mapEntry
Definition: Map.h:640
bool Map::IsBattleground ( ) const
inline
401 { return i_mapEntry && i_mapEntry->IsBattleground(); }
MapEntry const * i_mapEntry
Definition: Map.h:640
bool IsBattleground() const
Definition: DBCStructure.h:861

+ Here is the caller graph for this function:

bool Map::IsBattlegroundOrArena ( ) const
inline
MapEntry const * i_mapEntry
Definition: Map.h:640
bool IsBattlegroundOrArena() const
Definition: DBCStructure.h:863

+ Here is the caller graph for this function:

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

+ Here is the caller graph for this function:

bool Map::IsDungeon ( ) const
inline
395 { return i_mapEntry && i_mapEntry->IsDungeon(); }
MapEntry const * i_mapEntry
Definition: Map.h:640
bool IsDungeon() const
Definition: DBCStructure.h:857

+ Here is the caller graph for this function:

bool Map::IsGarrison ( ) const
inline
404 { return i_mapEntry && i_mapEntry->IsGarrison(); }
bool IsGarrison() const
Definition: DBCStructure.h:882
MapEntry const * i_mapEntry
Definition: Map.h:640

+ Here is the caller graph for this function:

bool Map::IsGridLoaded ( float  x,
float  y 
) const
inline
309  {
311  }
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:188
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::IsGridLoaded ( const GridCoord p) const
private
649 {
651 }
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
Definition: Map.h:623

+ Here is the call graph for this function:

bool Map::isGridObjectDataLoaded ( uint32  x,
uint32  y 
) const
inlineprivate
623 { return getNGrid(x, y)->isGridObjectDataLoaded(); }
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
bool isGridObjectDataLoaded() const
Definition: NGrid.h:109

+ Here is the caller graph for this function:

bool Map::IsHeroic ( ) const
3421 {
3422  if (DifficultyEntry const* difficulty = sDifficultyStore.LookupEntry(i_spawnMode))
3423  return difficulty->Flags & DIFFICULTY_FLAG_HEROIC;
3424  return false;
3425 }
uint8 i_spawnMode
Definition: Map.h:641
DBCStorage< DifficultyEntry > sDifficultyStore(DifficultyFmt)
Definition: DBCEnums.h:431
Definition: DBCStructure.h:338

+ Here is the caller graph for this function:

bool Map::isInLineOfSight ( float  x1,
float  y1,
float  z1,
float  x2,
float  y2,
float  z2,
uint32  phasemask 
) const
2591 {
2592  return VMAP::VMapFactory::createOrGetVMapManager()->isInLineOfSight(GetId(), x1, y1, z1, x2, y2, z2)
2593  && _dynamicTree.isInLineOfSight(x1, y1, z1, x2, y2, z2, phasemask);
2594 }
uint32 GetId(void) const
Definition: Map.h:325
virtual bool isInLineOfSight(unsigned int pMapId, float x1, float y1, float z1, float x2, float y2, float z2)=0
DynamicMapTree _dynamicTree
Definition: Map.h:645
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask) const
Definition: DynamicTree.cpp:233

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::IsInWater ( float  x,
float  y,
float  z,
LiquidData data = nullptr 
) const
2616 {
2617  LiquidData liquid_status;
2618  LiquidData* liquid_ptr = data ? data : &liquid_status;
2619  return (getLiquidStatus(x, y, pZ, MAP_ALL_LIQUIDS, liquid_ptr) & (LIQUID_MAP_IN_WATER | LIQUID_MAP_UNDER_WATER)) != 0;
2620 }
Definition: Map.h:136
Definition: Map.h:151
#define MAP_ALL_LIQUIDS
Definition: Map.h:146
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Map.h:137
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::IsNonRaidDungeon ( ) const
inline
396 { return i_mapEntry && i_mapEntry->IsNonRaidDungeon(); }
MapEntry const * i_mapEntry
Definition: Map.h:640
bool IsNonRaidDungeon() const
Definition: DBCStructure.h:858
bool Map::IsOutdoors ( float  x,
float  y,
float  z 
) const
2389 {
2390  uint32 mogpFlags;
2391  int32 adtId, rootId, groupId;
2392 
2393  // no wmo found? -> outside by default
2394  if (!GetAreaInfo(x, y, z, mogpFlags, adtId, rootId, groupId))
2395  return true;
2396 
2397  AreaTableEntry const* atEntry = nullptr;
2398  WMOAreaTableEntry const* wmoEntry= GetWMOAreaTableEntryByTripple(rootId, adtId, groupId);
2399  if (wmoEntry)
2400  {
2401  TC_LOG_DEBUG("maps", "Got WMOAreaTableEntry! flag %u, areaid %u", wmoEntry->Flags, wmoEntry->AreaTableID);
2402  atEntry = sAreaTableStore.LookupEntry(wmoEntry->AreaTableID);
2403  }
2404  return IsOutdoorWMO(mogpFlags, adtId, rootId, groupId, wmoEntry, atEntry);
2405 }
bool GetAreaInfo(float x, float y, float z, uint32 &mogpflags, int32 &adtId, int32 &rootId, int32 &groupId) const
Definition: Map.cpp:2407
Definition: DBCStructure.h:37
WMOAreaTableEntry const * GetWMOAreaTableEntryByTripple(int32 rootid, int32 adtid, int32 groupid)
Definition: DBCStores.cpp:579
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 Flags
Definition: DBCStructure.h:1394
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
uint32 AreaTableID
Definition: DBCStructure.h:1395
Definition: DBCStructure.h:1383
G3D::int16 z
Definition: Vector3int16.h:46
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
bool IsOutdoorWMO(uint32 mogpFlags, int32, int32, int32, WMOAreaTableEntry const *wmoEntry, AreaTableEntry const *atEntry)
Definition: Map.cpp:2364
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::IsRaid ( ) const
inline
397 { return i_mapEntry && i_mapEntry->IsRaid(); }
MapEntry const * i_mapEntry
Definition: Map.h:640
bool IsRaid() const
Definition: DBCStructure.h:860

+ Here is the caller graph for this function:

bool Map::IsRaidOrHeroicDungeon ( ) const
inline
398 { return IsRaid() || IsHeroic(); }
bool IsRaid() const
Definition: Map.h:397
bool IsHeroic() const
Definition: Map.cpp:3420

+ Here is the caller graph for this function:

bool Map::IsRemovalGrid ( float  x,
float  y 
) const
inline
303  {
306  }
grid_state_t GetGridState(void) const
Definition: NGrid.h:100
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:188
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
Definition: NGrid.h:66
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GridDefines.h:89
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::IsUnderWater ( float  x,
float  y,
float  z 
) const
2623 {
2625 }
#define MAP_LIQUID_TYPE_WATER
Definition: Map.h:141
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37
Definition: Map.h:137
ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData *data=nullptr) const
Definition: Map.cpp:2497
#define MAP_LIQUID_TYPE_OCEAN
Definition: Map.h:142

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadCorpseData ( )
3701 {
3702  std::unordered_map<ObjectGuid::LowType, std::unordered_set<uint32>> phases;
3703 
3705  stmt->setUInt32(0, GetId());
3706  stmt->setUInt32(1, GetInstanceId());
3707 
3708  // 0 1
3709  // SELECT OwnerGuid, PhaseId FROM corpse_phases cp LEFT JOIN corpse c ON cp.OwnerGuid = c.guid WHERE c.mapId = ? AND c.instanceId = ?
3710  PreparedQueryResult phaseResult = CharacterDatabase.Query(stmt);
3711  if (phaseResult)
3712  {
3713  do
3714  {
3715  Field* fields = phaseResult->Fetch();
3716  ObjectGuid::LowType guid = fields[0].GetUInt64();
3717  uint32 phaseId = fields[1].GetUInt32();
3718 
3719  phases[guid].insert(phaseId);
3720 
3721  } while (phaseResult->NextRow());
3722  }
3723 
3725  stmt->setUInt32(0, GetId());
3726  stmt->setUInt32(1, GetInstanceId());
3727 
3728  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
3729  // SELECT posX, posY, posZ, orientation, mapId, displayId, itemCache, bytes1, bytes2, flags, dynFlags, time, corpseType, instanceId, guid FROM corpse WHERE mapId = ? AND instanceId = ?
3731  if (!result)
3732  return;
3733 
3734  do
3735  {
3736  Field* fields = result->Fetch();
3737  CorpseType type = CorpseType(fields[12].GetUInt8());
3738  ObjectGuid::LowType guid = fields[14].GetUInt64();
3739  if (type >= MAX_CORPSE_TYPE || type == CORPSE_BONES)
3740  {
3741  TC_LOG_ERROR("misc", "Corpse (guid: " UI64FMTD ") have wrong corpse type (%u), not loading.", guid, type);
3742  continue;
3743  }
3744 
3745  Corpse* corpse = new Corpse(type);
3746  if (!corpse->LoadCorpseFromDB(GenerateLowGuid<HighGuid::Corpse>(), fields))
3747  {
3748  delete corpse;
3749  continue;
3750  }
3751 
3752  for (auto phaseId : phases[guid])
3753  corpse->SetInPhase(phaseId, false, true);
3754 
3755  AddCorpse(corpse);
3756 
3757  } while (result->NextRow());
3758 }
Definition: Corpse.h:49
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
Class used to access individual fields of database query result.
Definition: Field.h:56
CorpseType
Definition: Corpse.h:27
uint64 LowType
Definition: ObjectGuid.h:199
bool LoadCorpseFromDB(ObjectGuid::LowType guid, Field *fields)
Definition: Corpse.cpp:147
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
virtual bool SetInPhase(uint32 id, bool update, bool apply)
Definition: Object.cpp:2879
Definition: CharacterDatabase.h:280
#define UI64FMTD
Definition: Define.h:137
uint32_t uint32
Definition: Define.h:150
#define MAX_CORPSE_TYPE
Definition: Corpse.h:33
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void AddCorpse(Corpse *corpse)
Definition: Map.cpp:3769
uint32 GetInstanceId() const
Definition: Map.h:368
Definition: CharacterDatabase.h:284
Definition: Corpse.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadGrid ( float  x,
float  y 
)
509 {
511 }
bool EnsureGridLoaded(Cell const &)
Definition: Map.cpp:481
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadGridObjects ( NGridType grid,
Cell const cell 
)
protectedvirtual

Reimplemented in GarrisonMap.

503 {
504  ObjectGridLoader loader(*grid, this, cell);
505  loader.LoadN();
506 }
Definition: ObjectGridLoader.h:30

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadMap ( int  gx,
int  gy,
bool  reload = false 
)
private
161 {
162  if (i_InstanceId != 0)
163  {
164  if (GridMaps[gx][gy])
165  return;
166 
167  // load grid map for base map
168  if (!m_parentMap->GridMaps[gx][gy])
170 
171  ((MapInstanced*)(m_parentMap))->AddGridMapReference(GridCoord(gx, gy));
172  GridMaps[gx][gy] = m_parentMap->GridMaps[gx][gy];
173  return;
174  }
175 
176  if (GridMaps[gx][gy] && !reload)
177  return;
178 
179  //map already load, delete it before reloading (Is it necessary? Do we really need the ability the reload maps during runtime?)
180  if (GridMaps[gx][gy])
181  {
182  TC_LOG_DEBUG("maps", "Unloading previously loaded map %u before reloading.", GetId());
183  sScriptMgr->OnUnloadGridMap(this, GridMaps[gx][gy], gx, gy);
184 
185  delete (GridMaps[gx][gy]);
186  GridMaps[gx][gy]=NULL;
187  }
188 
189  // map file name
190  std::string fileName = Trinity::StringFormat("%smaps/%04u_%02u_%02u.map", sWorld->GetDataPath().c_str(), GetId(), gx, gy);
191  TC_LOG_DEBUG("maps", "Loading map %s", fileName.c_str());
192  // loading data
193  GridMaps[gx][gy] = new GridMap();
194  if (!GridMaps[gx][gy]->loadData(fileName.c_str()))
195  TC_LOG_ERROR("maps", "Error loading map file: %s", fileName.c_str());
196 
197  sScriptMgr->OnLoadGridMap(this, GridMaps[gx][gy], gx, gy);
198 }
Definition: MapInstanced.h:28
Map * m_parentMap
Definition: Map.h:675
Definition: Map.h:159
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:678
uint32 GetId(void) const
Definition: Map.h:325
void EnsureGridCreated(const GridCoord &)
Definition: Map.cpp:433
std::string StringFormat(Format &&fmt, Args &&...args)
Default TC string format function.
Definition: StringFormat.h:28
uint32 i_InstanceId
Definition: Map.h:642
#define sScriptMgr
Definition: ScriptMgr.h:837
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadMapAndVMap ( int  gx,
int  gy 
)
private
201 {
202  LoadMap(gx, gy);
203  // Only load the data for the base map
204  if (i_InstanceId == 0)
205  {
206  LoadVMap(gx, gy);
207  LoadMMap(gx, gy);
208  }
209 }
void LoadVMap(int gx, int gy)
Definition: Map.cpp:140
void LoadMap(int gx, int gy, bool reload=false)
Definition: Map.cpp:160
void LoadMMap(int gx, int gy)
Definition: Map.cpp:127
uint32 i_InstanceId
Definition: Map.h:642

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadMMap ( int  gx,
int  gy 
)
private
128 {
130  return;
131 
132  bool mmapLoadResult = MMAP::MMapFactory::createOrGetMMapManager()->loadMap((sWorld->GetDataPath() + "mmaps").c_str(), GetId(), gx, gy);
133 
134  if (mmapLoadResult)
135  TC_LOG_DEBUG("maps", "MMAP loaded name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
136  else
137  TC_LOG_ERROR("maps", "Could not load MMAP name:%s, id:%d, x:%d, y:%d (mmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
138 }
bool IsPathfindingEnabled(uint32 mapId)
Definition: DisableMgr.cpp:380
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
uint32 GetId(void) const
Definition: Map.h:325
bool loadMap(const std::string &basePath, uint32 mapId, int32 x, int32 y)
Definition: MMapManager.cpp:124
static MMapManager * createOrGetMMapManager()
Definition: MMapFactory.cpp:28
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
const char * GetMapName() const
Definition: Map.cpp:2644

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadRespawnTimes ( )
3631 {
3633  stmt->setUInt16(0, GetId());
3634  stmt->setUInt32(1, GetInstanceId());
3635  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
3636  {
3637  do
3638  {
3639  Field* fields = result->Fetch();
3640  ObjectGuid::LowType loguid = fields[0].GetUInt64();
3641  uint32 respawnTime = fields[1].GetUInt32();
3642 
3643  _creatureRespawnTimes[loguid] = time_t(respawnTime);
3644  } while (result->NextRow());
3645  }
3646 
3648  stmt->setUInt16(0, GetId());
3649  stmt->setUInt32(1, GetInstanceId());
3650  if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
3651  {
3652  do
3653  {
3654  Field* fields = result->Fetch();
3655  ObjectGuid::LowType loguid = fields[0].GetUInt64();
3656  uint32 respawnTime = fields[1].GetUInt32();
3657 
3658  _goRespawnTimes[loguid] = time_t(respawnTime);
3659  } while (result->NextRow());
3660  }
3661 }
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
uint64 GetUInt64() const
Definition: Field.h:184
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition: Map.h:721
Class used to access individual fields of database query result.
Definition: Field.h:56
uint64 LowType
Definition: ObjectGuid.h:199
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
Definition: CharacterDatabase.h:295
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
uint32_t uint32
Definition: Define.h:150
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition: Map.h:722
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 GetUInt32() const
Definition: Field.h:146
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
Definition: CharacterDatabase.h:289
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::LoadVMap ( int  gx,
int  gy 
)
private
141 {
142  if (!VMAP::VMapFactory::createOrGetVMapManager()->isMapLoadingEnabled())
143  return;
144  // x and y are swapped !!
145  int vmapLoadResult = VMAP::VMapFactory::createOrGetVMapManager()->loadMap((sWorld->GetDataPath()+ "vmaps").c_str(), GetId(), gx, gy);
146  switch (vmapLoadResult)
147  {
149  TC_LOG_DEBUG("maps", "VMAP loaded name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
150  break;
152  TC_LOG_ERROR("maps", "Could not load VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
153  break;
155  TC_LOG_DEBUG("maps", "Ignored VMAP name:%s, id:%d, x:%d, y:%d (vmap rep.: x:%d, y:%d)", GetMapName(), GetId(), gx, gy, gx, gy);
156  break;
157  }
158 }
Definition: IVMapManager.h:38
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define sWorld
Definition: World.h:887
Definition: IVMapManager.h:36
uint32 GetId(void) const
Definition: Map.h:325
virtual int loadMap(const char *pBasePath, unsigned int pMapId, int x, int y)=0
Definition: IVMapManager.h:37
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
const char * GetMapName() const
Definition: Map.cpp:2644

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::markCell ( uint32  pCellId)
inline
421 { marked_cells.set(pCellId); }
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition: Map.h:679

+ Here is the caller graph for this function:

void Map::MoveAllCreaturesInMoveList ( )
Todo:
pets will disappear if this is outside CreatureRespawnRelocation
1142 {
1143  _creatureToMoveLock = true;
1144  for (std::vector<Creature*>::iterator itr = _creaturesToMove.begin(); itr != _creaturesToMove.end(); ++itr)
1145  {
1146  Creature* c = *itr;
1147  if (c->FindMap() != this) //pet is teleported to another map
1148  continue;
1149 
1150  if (c->_moveState != MAP_OBJECT_CELL_MOVE_ACTIVE)
1151  {
1152  c->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
1153  continue;
1154  }
1155 
1156  c->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
1157  if (!c->IsInWorld())
1158  continue;
1159 
1160  // do move or do move to respawn or remove creature if previous all fail
1161  if (CreatureCellRelocation(c, Cell(c->_newPosition.m_positionX, c->_newPosition.m_positionY)))
1162  {
1163  // update pos
1164  c->Relocate(c->_newPosition);
1165  if (c->IsVehicle())
1167  //CreatureRelocationNotify(c, new_cell, new_cell.cellCoord());
1168  c->UpdateObjectVisibility(false);
1169  }
1170  else
1171  {
1172  // if creature can't be move in new cell/grid (not loaded) move it to repawn cell/grid
1173  // creature coordinates will be updated and notifiers send
1174  if (!CreatureRespawnRelocation(c, false))
1175  {
1176  // ... or unload (if respawn grid also not loaded)
1177  #ifdef TRINITY_DEBUG
1178  TC_LOG_DEBUG("maps", "Creature (%s Entry: %u) cannot be move to unloaded respawn grid.", c->GetGUID().ToString().c_str(), c->GetEntry());
1179  #endif
1180  //AddObjectToRemoveList(Pet*) should only be called in Pet::Remove
1181  //This may happen when a player just logs in and a pet moves to a nearby unloaded cell
1182  //To avoid this, we can load nearby cells when player log in
1183  //But this check is always needed to ensure safety
1185  //need to check why pet is frequently relocated to an unloaded cell
1186  if (c->IsPet())
1187  ((Pet*)c)->Remove(PET_SAVE_NOT_IN_SLOT, true);
1188  else
1190  }
1191  }
1192  }
1193  _creaturesToMove.clear();
1194  _creatureToMoveLock = false;
1195 }
bool Remove(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:104
void RelocatePassengers()
Relocate passengers. Must be called after m_base::Relocate.
Definition: Vehicle.cpp:520
bool IsVehicle() const
Definition: Unit.h:1406
bool CreatureRespawnRelocation(Creature *c, bool diffGridOnly)
Definition: Map.cpp:1463
float m_positionY
Definition: Position.h:53
void UpdateObjectVisibility(bool forced=true) override
Definition: Unit.cpp:14630
float m_positionX
Definition: Position.h:52
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:2804
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
Definition: Object.h:393
void Relocate(float x, float y)
Definition: Position.h:67
Map * FindMap() const
Definition: Object.h:544
Definition: Object.h:394
bool IsPet() const
Definition: Unit.h:1403
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
bool CreatureCellRelocation(Creature *creature, Cell new_cell)
Definition: Map.cpp:1280
Definition: PetDefines.h:38
uint32 GetEntry() const
Definition: Object.h:107
bool IsInWorld() const
Definition: Object.h:100
std::vector< Creature * > _creaturesToMove
Definition: Map.h:601
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: Pet.h:46
Vehicle * GetVehicleKit() const
Definition: Unit.h:2165
bool _creatureToMoveLock
Definition: Map.h:600

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::MoveAllDynamicObjectsInMoveList ( )
1243 {
1245  for (std::vector<DynamicObject*>::iterator itr = _dynamicObjectsToMove.begin(); itr != _dynamicObjectsToMove.end(); ++itr)
1246  {
1247  DynamicObject* dynObj = *itr;
1248  if (dynObj->FindMap() != this) //transport is teleported to another map
1249  continue;
1250 
1251  if (dynObj->_moveState != MAP_OBJECT_CELL_MOVE_ACTIVE)
1252  {
1253  dynObj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
1254  continue;
1255  }
1256 
1257  dynObj->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
1258  if (!dynObj->IsInWorld())
1259  continue;
1260 
1261  // do move or do move to respawn or remove creature if previous all fail
1262  if (DynamicObjectCellRelocation(dynObj, Cell(dynObj->_newPosition.m_positionX, dynObj->_newPosition.m_positionY)))
1263  {
1264  // update pos
1265  dynObj->Relocate(dynObj->_newPosition);
1266  dynObj->UpdateObjectVisibility(false);
1267  }
1268  else
1269  {
1270 #ifdef TRINITY_DEBUG
1271  TC_LOG_DEBUG("maps", "DynamicObject (%s) cannot be moved to unloaded grid.", dynObj->GetGUID().ToString().c_str());
1272 #endif
1273  }
1274  }
1275 
1276  _dynamicObjectsToMove.clear();
1277  _dynamicObjectsToMoveLock = false;
1278 }
float m_positionY
Definition: Position.h:53
float m_positionX
Definition: Position.h:52
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool DynamicObjectCellRelocation(DynamicObject *go, Cell new_cell)
Definition: Map.cpp:1402
Definition: Object.h:393
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition: Map.h:607
Definition: DynamicObject.h:35
void Relocate(float x, float y)
Definition: Position.h:67
Map * FindMap() const
Definition: Object.h:544
Definition: Object.h:394
bool _dynamicObjectsToMoveLock
Definition: Map.h:606
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3001
bool IsInWorld() const
Definition: Object.h:100
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

void Map::MoveAllGameObjectsInMoveList ( )
1198 {
1199  _gameObjectsToMoveLock = true;
1200  for (std::vector<GameObject*>::iterator itr = _gameObjectsToMove.begin(); itr != _gameObjectsToMove.end(); ++itr)
1201  {
1202  GameObject* go = *itr;
1203  if (go->FindMap() != this) //transport is teleported to another map
1204  continue;
1205 
1206  if (go->_moveState != MAP_OBJECT_CELL_MOVE_ACTIVE)
1207  {
1208  go->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
1209  continue;
1210  }
1211 
1212  go->_moveState = MAP_OBJECT_CELL_MOVE_NONE;
1213  if (!go->IsInWorld())
1214  continue;
1215 
1216  // do move or do move to respawn or remove creature if previous all fail
1217  if (GameObjectCellRelocation(go, Cell(go->_newPosition.m_positionX, go->_newPosition.m_positionY)))
1218  {
1219  // update pos
1220  go->Relocate(go->_newPosition);
1221  go->UpdateModelPosition();
1222  go->UpdateObjectVisibility(false);
1223  }
1224  else
1225  {
1226  // if GameObject can't be move in new cell/grid (not loaded) move it to repawn cell/grid
1227  // GameObject coordinates will be updated and notifiers send
1228  if (!GameObjectRespawnRelocation(go, false))
1229  {
1230  // ... or unload (if respawn grid also not loaded)
1231 #ifdef TRINITY_DEBUG
1232  TC_LOG_DEBUG("maps", "GameObject (%s Entry: %u) cannot be move to unloaded respawn grid.", go->GetGUID().ToString().c_str(), go->GetEntry());
1233 #endif
1235  }
1236  }
1237  }
1238  _gameObjectsToMove.clear();
1239  _gameObjectsToMoveLock = false;
1240 }
std::vector< GameObject * > _gameObjectsToMove
Definition: Map.h:604
float m_positionY
Definition: Position.h:53
bool GameObjectCellRelocation(GameObject *go, Cell new_cell)
Definition: Map.cpp:1341
float m_positionX
Definition: Position.h:52
void AddObjectToRemoveList(WorldObject *obj)
Definition: Map.cpp:2804
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Object.h:393
bool _gameObjectsToMoveLock
Definition: Map.h:603
void Relocate(float x, float y)
Definition: Position.h:67
Map * FindMap() const
Definition: Object.h:544
Definition: GameObject.h:880
void UpdateModelPosition()
Definition: GameObject.cpp:2425
Definition: Object.h:394
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
virtual void UpdateObjectVisibility(bool forced=true)
Definition: Object.cpp:3001
uint32 GetEntry() const
Definition: Object.h:107
bool IsInWorld() const
Definition: Object.h:100
bool GameObjectRespawnRelocation(GameObject *go, bool diffGridOnly)
Definition: Map.cpp:1493
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::PlayerRelocation ( Player player,
float  x,
float  y,
float  z,
float  orientation 
)

If hovering, always increase our server-side Z position Client automatically projects correct position based on Z coord sent in monster move and UNIT_FIELD_HOVERHEIGHT sent in object updates

951 {
952  ASSERT(player);
953 
954  Cell old_cell(player->GetPositionX(), player->GetPositionY());
955  Cell new_cell(x, y);
956 
960  if (player->HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
961  z += player->GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
962 
963  player->Relocate(x, y, z, orientation);
964  if (player->IsVehicle())
965  player->GetVehicleKit()->RelocatePassengers();
966 
967  if (old_cell.DiffGrid(new_cell) || old_cell.DiffCell(new_cell))
968  {
969  TC_LOG_DEBUG("maps", "Player %s relocation grid[%u, %u]cell[%u, %u]->grid[%u, %u]cell[%u, %u]", player->GetName().c_str(), old_cell.GridX(), old_cell.GridY(), old_cell.CellX(), old_cell.CellY(), new_cell.GridX(), new_cell.GridY(), new_cell.CellX(), new_cell.CellY());
970 
971  player->RemoveFromGrid();
972 
973  if (old_cell.DiffGrid(new_cell))
974  EnsureGridLoadedForActiveObject(new_cell, player);
975 
976  AddToGrid(player, new_cell);
977  }
978 
979  player->UpdateObjectVisibility(false);
980 }
void AddToGrid(T *object, Cell const &cell)
Definition: Map.cpp:262
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: UpdateFields.h:160
Definition: Unit.h:804
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
void EnsureGridLoadedForActiveObject(Cell const &, WorldObject *object)
Definition: Map.cpp:465
Definition: Cell.h:49
#define ASSERT
Definition: Errors.h:55
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::ProcessRelocationNotifies ( const uint32  diff)
private
796 {
798  {
799  NGridType *grid = i->GetSource();
800 
801  if (grid->GetGridState() != GRID_STATE_ACTIVE)
802  continue;
803 
804  grid->getGridInfoRef()->getRelocationTimer().TUpdate(diff);
805  if (!grid->getGridInfoRef()->getRelocationTimer().TPassed())
806  continue;
807 
808  uint32 gx = grid->getX(), gy = grid->getY();
809 
810  CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
811  CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
812 
813  for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x)
814  {
815  for (uint32 y = cell_min.y_coord; y < cell_max.y_coord; ++y)
816  {
817  uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
818  if (!isCellMarked(cell_id))
819  continue;
820 
821  CellCoord pair(x, y);
822  Cell cell(pair);
823  cell.SetNoCreate();
824 
825  Trinity::DelayedUnitRelocation cell_relocation(cell, pair, *this, MAX_VISIBILITY_DISTANCE);
828  Visit(cell, grid_object_relocation);
829  Visit(cell, world_object_relocation);
830  }
831  }
832  }
833 
834  ResetNotifier reset;
838  {
839  NGridType *grid = i->GetSource();
840 
841  if (grid->GetGridState() != GRID_STATE_ACTIVE)
842  continue;
843 
844  if (!grid->getGridInfoRef()->getRelocationTimer().TPassed())
845  continue;
846 
848 
849  uint32 gx = grid->getX(), gy = grid->getY();
850 
851  CellCoord cell_min(gx*MAX_NUMBER_OF_CELLS, gy*MAX_NUMBER_OF_CELLS);
852  CellCoord cell_max(cell_min.x_coord + MAX_NUMBER_OF_CELLS, cell_min.y_coord+MAX_NUMBER_OF_CELLS);
853 
854  for (uint32 x = cell_min.x_coord; x < cell_max.x_coord; ++x)
855  {
856  for (uint32 y = cell_min.y_coord; y < cell_max.y_coord; ++y)
857  {
858  uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
859  if (!isCellMarked(cell_id))
860  continue;
861 
862  CellCoord pair(x, y);
863  Cell cell(pair);
864  cell.SetNoCreate();
865  Visit(cell, grid_notifier);
866  Visit(cell, world_notifier);
867  }
868  }
869  }
870 }
Definition: NGrid.h:77
Definition: TypeContainerVisitor.h:32
bool isCellMarked(uint32 pCellId)
Definition: Map.h:420
grid_state_t GetGridState(void) const
Definition: NGrid.h:100
void TUpdate(int32 diff)
Definition: Timer.h:193
#define MAX_NUMBER_OF_CELLS
Definition: GridDefines.h:35
#define TOTAL_NUMBER_OF_CELLS_PER_MAP
Definition: GridDefines.h:52
Definition: NGrid.h:64
Definition: Map.cpp:783
Definition: GridReference.h:25
uint32_t uint32
Definition: Define.h:150
Definition: GridNotifiers.h:84
G3D::int16 y
Definition: Vector2int16.h:38
GridInfo * getGridInfoRef()
Definition: NGrid.h:112
void TReset(int32 diff, int32 period)
Definition: Timer.h:195
#define MAX_VISIBILITY_DISTANCE
Definition: Object.h:38
int32 getY() const
Definition: NGrid.h:103
Definition: Cell.h:49
void Visit(const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
Definition: Map.h:811
int32 m_VisibilityNotifyPeriod
Definition: Map.h:650
int32 getX() const
Definition: NGrid.h:102
PeriodicTimer & getRelocationTimer()
Definition: NGrid.h:51
iterator end()
Definition: GridRefManager.h:37
G3D::int16 x
Definition: Vector2int16.h:37
bool TPassed() const
Definition: Timer.h:194

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::RemoveAllObjectsInRemoveList ( )
2832 {
2833  while (!i_objectsToSwitch.empty())
2834  {
2835  std::map<WorldObject*, bool>::iterator itr = i_objectsToSwitch.begin();
2836  WorldObject* obj = itr->first;
2837  bool on = itr->second;
2838  i_objectsToSwitch.erase(itr);
2839 
2840  if (!obj->IsPermanentWorldObject())
2841  {
2842  switch (obj->GetTypeId())
2843  {
2844  case TYPEID_UNIT:
2845  SwitchGridContainers<Creature>(obj->ToCreature(), on);
2846  break;
2847  case TYPEID_GAMEOBJECT:
2848  SwitchGridContainers<GameObject>(obj->ToGameObject(), on);
2849  break;
2850  default:
2851  break;
2852  }
2853  }
2854  }
2855 
2856  //TC_LOG_DEBUG("maps", "Object remover 1 check.");
2857  while (!i_objectsToRemove.empty())
2858  {
2859  std::set<WorldObject*>::iterator itr = i_objectsToRemove.begin();
2860  WorldObject* obj = *itr;
2861 
2862  switch (obj->GetTypeId())
2863  {
2864  case TYPEID_CORPSE:
2865  {
2866  Corpse* corpse = ObjectAccessor::GetCorpse(*obj, obj->GetGUID());
2867  if (!corpse)
2868  TC_LOG_ERROR("maps", "Tried to delete corpse/bones %s that is not in map.", obj->GetGUID().ToString().c_str());
2869  else
2870  RemoveFromMap(corpse, true);
2871  break;
2872  }
2873  case TYPEID_DYNAMICOBJECT:
2874  RemoveFromMap(obj->ToDynObject(), true);
2875  break;
2876  case TYPEID_AREATRIGGER:
2877  RemoveFromMap((AreaTrigger*)obj, true);
2878  break;
2879  case TYPEID_GAMEOBJECT:
2880  {
2881  GameObject* go = obj->ToGameObject();
2882  if (Transport* transport = go->ToTransport())
2883  RemoveFromMap(transport, true);
2884  else
2885  RemoveFromMap(go, true);
2886  break;
2887  }
2888  case TYPEID_UNIT:
2889  // in case triggered sequence some spell can continue casting after prev CleanupsBeforeDelete call
2890  // make sure that like sources auras/etc removed before destructor start
2891  obj->ToCreature()->CleanupsBeforeDelete();
2892  RemoveFromMap(obj->ToCreature(), true);
2893  break;
2894  default:
2895  TC_LOG_ERROR("maps", "Non-grid object (TypeId: %u) is in grid object remove list, ignored.", obj->GetTypeId());
2896  break;
2897  }
2898 
2899  i_objectsToRemove.erase(itr);
2900  }
2901 
2902  //TC_LOG_DEBUG("maps", "Object remover 2 check.");
2903 }
void CleanupsBeforeDelete(bool finalCleanup=true) override
Definition: Unit.cpp:11802
Definition: Corpse.h:49
std::set< WorldObject * > i_objectsToRemove
Definition: Map.h:686
Definition: ObjectGuid.h:36
void RemoveFromMap(T *, bool)
Definition: Map.cpp:890
std::map< WorldObject *, bool > i_objectsToSwitch
Definition: Map.h:687
Definition: ObjectGuid.h:32
Definition: Transport.h:28
Definition: Object.h:423
DynamicObject * ToDynObject()
Definition: Object.h:206
GameObject * ToGameObject()
Definition: Object.h:200
TypeID GetTypeId() const
Definition: Object.h:113
Definition: ObjectGuid.h:37
Definition: ObjectGuid.h:34
TC_GAME_API Corpse * GetCorpse(WorldObject const &u, ObjectGuid const &guid)
Definition: ObjectAccessor.cpp:138
Transport * ToTransport()
Definition: GameObject.h:1073
Definition: GameObject.h:880
ObjectGuid const & GetGUID() const
Definition: Object.h:105
Creature * ToCreature()
Definition: Object.h:194
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectGuid.h:35
std::string ToString() const
Definition: ObjectGuid.cpp:99
bool IsPermanentWorldObject() const
Definition: Object.h:584
Definition: AreaTrigger.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::RemoveAllPlayers ( )
virtual

Reimplemented in BattlegroundMap.

1598 {
1599  if (HavePlayers())
1600  {
1601  for (MapRefManager::iterator itr = m_mapRefManager.begin(); itr != m_mapRefManager.end(); ++itr)
1602  {
1603  Player* player = itr->GetSource();
1604  if (!player->IsBeingTeleportedFar())
1605  {
1606  // this is happening for bg
1607  TC_LOG_ERROR("maps", "Map::UnloadAll: player %s is still in map %u during unload, this should not happen!", player->GetName().c_str(), GetId());
1608  player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
1609  }
1610  }
1611  }
1612 }
iterator begin()
Definition: MapRefManager.h:37
uint32 GetId(void) const
Definition: Map.h:325
bool HavePlayers() const
Definition: Map.h:423
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
MapRefManager m_mapRefManager
Definition: Map.h:647
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

void Map::RemoveCorpse ( Corpse corpse)
3781 {
3782  ASSERT(corpse);
3783 
3784  corpse->DestroyForNearbyPlayers();
3785  if (corpse->IsInGrid())
3786  RemoveFromMap(corpse, false);
3787  else
3788  {
3789  corpse->RemoveFromWorld();
3790  corpse->ResetMap();
3791  }
3792 
3793  _corpsesByCell[corpse->GetCellCoord().GetId()].erase(corpse);
3794  if (corpse->GetType() != CORPSE_BONES)
3795  _corpsesByPlayer.erase(corpse->GetOwnerGUID());
3796  else
3797  _corpseBones.erase(corpse);
3798 }
virtual void ResetMap()
Definition: Object.cpp:2187
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:742
ObjectGuid GetOwnerGUID() const
Definition: Corpse.h:67
CellCoord const & GetCellCoord() const
Definition: Corpse.h:73
void RemoveFromWorld() override
Definition: Corpse.cpp:53
void RemoveFromMap(T *, bool)
Definition: Map.cpp:890
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:741
bool IsInGrid() const
Definition: Object.h:360
CorpseType GetType() const
Definition: Corpse.h:71
std::unordered_set< Corpse * > _corpseBones
Definition: Map.h:743
#define ASSERT
Definition: Errors.h:55
void DestroyForNearbyPlayers()
Definition: Object.cpp:2974
uint32 GetId() const
Definition: GridDefines.h:150
Definition: Corpse.h:29

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::RemoveCreatureFromMoveList ( Creature c)
private
1095 {
1096  if (_creatureToMoveLock) //can this happen?
1097  return;
1098 
1099  if (c->_moveState == MAP_OBJECT_CELL_MOVE_ACTIVE)
1100  c->_moveState = MAP_OBJECT_CELL_MOVE_INACTIVE;
1101 }
Definition: Object.h:394
Definition: Object.h:395
bool _creatureToMoveLock
Definition: Map.h:600

+ Here is the caller graph for this function:

void Map::RemoveCreatureRespawnTime ( ObjectGuid::LowType  dbGuid)
3590 {
3591  _creatureRespawnTimes.erase(dbGuid);
3592 
3594  stmt->setUInt64(0, dbGuid);
3595  stmt->setUInt16(1, GetId());
3596  stmt->setUInt32(2, GetInstanceId());
3597  CharacterDatabase.Execute(stmt);
3598 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition: Map.h:721
Definition: CharacterDatabase.h:291
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::RemoveDynamicObjectFromMoveList ( DynamicObject go)
private
1133 {
1134  if (_dynamicObjectsToMoveLock) //can this happen?
1135  return;
1136 
1137  if (dynObj->_moveState == MAP_OBJECT_CELL_MOVE_ACTIVE)
1138  dynObj->_moveState = MAP_OBJECT_CELL_MOVE_INACTIVE;
1139 }
Definition: Object.h:394
bool _dynamicObjectsToMoveLock
Definition: Map.h:606
Definition: Object.h:395

+ Here is the caller graph for this function:

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

+ Here is the caller graph for this function:

template<>
void Map::RemoveFromActive ( Creature c)
2996 {
2998 
2999  // also allow unloading spawn grid
3000  if (!c->IsPet() && c->GetSpawnId())
3001  {
3002  float x, y, z;
3003  c->GetRespawnPosition(x, y, z);
3005  if (getNGrid(p.x_coord, p.y_coord))
3007  else
3008  {
3010  TC_LOG_ERROR("maps", "Active creature (%s Entry: %u) removed from grid[%u, %u] but spawn grid[%u, %u] was not loaded.",
3011  c->GetGUID().ToString().c_str(), c->GetEntry(), p.x_coord, p.y_coord, p2.x_coord, p2.y_coord);
3012  }
3013  }
3014 }
void decUnloadActiveLock()
Definition: NGrid.h:118
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:188
ObjectGuid::LowType GetSpawnId() const
Definition: Creature.h:487
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
void RemoveFromActiveHelper(WorldObject *obj)
Definition: Map.h:705
float GetPositionY() const
Definition: Position.h:105
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GridDefines.h:89
void GetRespawnPosition(float &x, float &y, float &z, float *ori=nullptr, float *dist=nullptr) const
Definition: Creature.cpp:2355
bool IsPet() const
Definition: Unit.h:1403
ObjectGuid const & GetGUID() const
Definition: Object.h:105
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99

+ Here is the call graph for this function:

template<>
void Map::RemoveFromActive ( DynamicObject obj)
3018 {
3020 }
void RemoveFromActiveHelper(WorldObject *obj)
Definition: Map.h:705

+ Here is the call graph for this function:

void Map::RemoveFromActiveHelper ( WorldObject obj)
inlineprivate
706  {
707  // Map::Update for active object in proccess
709  {
710  ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
711  if (itr == m_activeNonPlayers.end())
712  return;
713  if (itr == m_activeNonPlayersIter)
715  m_activeNonPlayers.erase(itr);
716  }
717  else
718  m_activeNonPlayers.erase(obj);
719  }
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:653
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition: Map.h:654

+ Here is the caller graph for this function:

template<class T >
void Map::RemoveFromMap ( T *  obj,
bool  remove 
)
891 {
892  obj->RemoveFromWorld();
893  if (obj->isActiveObject())
894  RemoveFromActive(obj);
895 
896  obj->UpdateObjectVisibility(true);
897  obj->RemoveFromGrid();
898 
899  obj->ResetMap();
900 
901  if (remove)
902  {
903  // if option set then object already saved at this moment
904  if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
905  obj->SaveRespawnTime();
906  DeleteFromWorld(obj);
907  }
908 }
void RemoveFromActive(T *obj)
Definition: Map.cpp:2992
#define sWorld
Definition: World.h:887
void DeleteFromWorld(T *)
Definition: Map.cpp:412

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<>
void Map::RemoveFromMap ( Transport obj,
bool  remove 
)
912 {
913  obj->RemoveFromWorld();
914 
915  Map::PlayerList const& players = GetPlayers();
916  if (!players.isEmpty())
917  {
918  UpdateData data(GetId());
919  obj->BuildOutOfRangeUpdateBlock(&data);
920  WorldPacket packet;
921  data.BuildPacket(&packet);
922  for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
923  if (itr->GetSource()->GetTransport() != obj)
924  itr->GetSource()->SendDirectMessage(&packet);
925  }
926 
927  if (_transportsUpdateIter != _transports.end())
928  {
929  TransportsContainer::iterator itr = _transports.find(obj);
930  if (itr == _transports.end())
931  return;
932  if (itr == _transportsUpdateIter)
934  _transports.erase(itr);
935  }
936  else
937  _transports.erase(obj);
938 
939  obj->ResetMap();
940 
941  if (remove)
942  {
943  // if option set then object already saved at this moment
944  if (!sWorld->getBoolConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATELY))
945  obj->SaveRespawnTime();
946  DeleteFromWorld(obj);
947  }
948 }
virtual void ResetMap()
Definition: Object.cpp:2187
TransportsContainer _transports
Definition: Map.h:658
TransportsContainer::iterator _transportsUpdateIter
Definition: Map.h:659
#define sWorld
Definition: World.h:887
iterator begin()
Definition: MapRefManager.h:37
Definition: UpdateData.h:59
void RemoveFromWorld() override
Definition: GameObject.cpp:152
uint32 GetId(void) const
Definition: Map.h:325
void DeleteFromWorld(T *)
Definition: Map.cpp:412
Definition: LinkedList.h:141
bool isEmpty() const
Definition: LinkedList.h:102
PlayerList const & GetPlayers() const
Definition: Map.h:433
Definition: MapRefManager.h:26
void SaveRespawnTime() override
Definition: GameObject.cpp:1014
void BuildOutOfRangeUpdateBlock(UpdateData *data) const
Definition: Object.cpp:278
Definition: WorldPacket.h:26
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

void Map::RemoveGameObjectFromMoveList ( GameObject go)
private
1114 {
1115  if (_gameObjectsToMoveLock) //can this happen?
1116  return;
1117 
1118  if (go->_moveState == MAP_OBJECT_CELL_MOVE_ACTIVE)
1119  go->_moveState = MAP_OBJECT_CELL_MOVE_INACTIVE;
1120 }
bool _gameObjectsToMoveLock
Definition: Map.h:603
Definition: Object.h:394
Definition: Object.h:395

+ Here is the caller graph for this function:

void Map::RemoveGameObjectModel ( const GameObjectModel model)
inline
505 { _dynamicTree.remove(model); }
void remove(const GameObjectModel &)
Definition: DynamicTree.cpp:122
DynamicMapTree _dynamicTree
Definition: Map.h:645

+ Here is the caller graph for this function:

void Map::RemoveGORespawnTime ( ObjectGuid::LowType  dbGuid)
3620 {
3621  _goRespawnTimes.erase(dbGuid);
3622 
3624  stmt->setUInt64(0, dbGuid);
3625  stmt->setUInt16(1, GetId());
3626  stmt->setUInt32(2, GetInstanceId());
3627  CharacterDatabase.Execute(stmt);
3628 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
Definition: CharacterDatabase.h:297
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition: Map.h:722
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32 GetInstanceId() const
Definition: Map.h:368

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::RemoveOldCorpses ( )
3854 {
3855  time_t now = time(nullptr);
3856 
3857  std::vector<ObjectGuid> corpses;
3858  corpses.reserve(_corpsesByPlayer.size());
3859 
3860  for (auto const& p : _corpsesByPlayer)
3861  if (p.second->IsExpired(now))
3862  corpses.push_back(p.first);
3863 
3864  for (ObjectGuid const& ownerGuid : corpses)
3865  ConvertCorpseToBones(ownerGuid);
3866 
3867  std::vector<Corpse*> expiredBones;
3868  for (Corpse* bones : _corpseBones)
3869  if (bones->IsExpired(now))
3870  expiredBones.push_back(bones);
3871 
3872  for (Corpse* bones : expiredBones)
3873  {
3874  RemoveCorpse(bones);
3875  delete bones;
3876  }
3877 }
Definition: Corpse.h:49
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:742
void RemoveCorpse(Corpse *corpse)
Definition: Map.cpp:3780
Corpse * ConvertCorpseToBones(ObjectGuid const &ownerGuid, bool insignia=false)
Definition: Map.cpp:3800
std::unordered_set< Corpse * > _corpseBones
Definition: Map.h:743
Definition: ObjectGuid.h:189

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented in BattlegroundMap, and InstanceMap.

873 {
874  sScriptMgr->OnPlayerLeaveMap(this, player);
875 
876  player->RemoveFromWorld();
877  SendRemoveTransports(player);
878 
879  player->UpdateObjectVisibility(true);
880  if (player->IsInGrid())
881  player->RemoveFromGrid();
882  else
883  ASSERT(remove); //maybe deleted in logoutplayer when player is not in a map
884 
885  if (remove)
886  DeleteFromWorld(player);
887 }
void SendRemoveTransports(Player *player)
Definition: Map.cpp:2710
void DeleteFromWorld(T *)
Definition: Map.cpp:412
#define ASSERT
Definition: Errors.h:55
#define sScriptMgr
Definition: ScriptMgr.h:837

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::RemoveUpdateObject ( Object obj)
inline
573  {
574  _updateObjects.erase(obj);
575  }
std::unordered_set< Object * > _updateObjects
Definition: Map.h:745

+ Here is the caller graph for this function:

void Map::RemoveWorldObject ( WorldObject obj)
inline
428 { i_worldObjects.erase(obj); }
std::set< WorldObject * > i_worldObjects
Definition: Map.h:688

+ Here is the caller graph for this function:

void Map::ResetGridExpiry ( NGridType grid,
float  factor = 1 
) const
inline
320  {
321  grid.ResetTimeTracker(time_t(float(i_gridExpiry)*factor));
322  }
time_t i_gridExpiry
Definition: Map.h:671
void ResetTimeTracker(time_t interval)
Definition: NGrid.h:119

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::resetMarkedCells ( )
inline
419 { marked_cells.reset(); }
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition: Map.h:679

+ Here is the caller graph for this function:

void Map::SaveCreatureRespawnTime ( ObjectGuid::LowType  dbGuid,
time_t  respawnTime 
)
3571 {
3572  if (!respawnTime)
3573  {
3574  // Delete only
3575  RemoveCreatureRespawnTime(dbGuid);
3576  return;
3577  }
3578 
3579  _creatureRespawnTimes[dbGuid] = respawnTime;
3580 
3582  stmt->setUInt64(0, dbGuid);
3583  stmt->setUInt32(1, uint32(respawnTime));
3584  stmt->setUInt16(2, GetId());
3585  stmt->setUInt32(3, GetInstanceId());
3586  CharacterDatabase.Execute(stmt);
3587 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
std::unordered_map< ObjectGuid::LowType, time_t > _creatureRespawnTimes
Definition: Map.h:721
Definition: CharacterDatabase.h:290
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32_t uint32
Definition: g3dmath.h:168
uint32 GetInstanceId() const
Definition: Map.h:368
void RemoveCreatureRespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3589

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SaveGORespawnTime ( ObjectGuid::LowType  dbGuid,
time_t  respawnTime 
)
3601 {
3602  if (!respawnTime)
3603  {
3604  // Delete only
3605  RemoveGORespawnTime(dbGuid);
3606  return;
3607  }
3608 
3609  _goRespawnTimes[dbGuid] = respawnTime;
3610 
3612  stmt->setUInt64(0, dbGuid);
3613  stmt->setUInt32(1, uint32(respawnTime));
3614  stmt->setUInt16(2, GetId());
3615  stmt->setUInt32(3, GetInstanceId());
3616  CharacterDatabase.Execute(stmt);
3617 }
void Execute(const char *sql)
Definition: DatabaseWorkerPool.h:87
Definition: PreparedStatement.h:74
uint32 GetId(void) const
Definition: Map.h:325
void setUInt16(const uint8 index, const uint16 value)
Definition: PreparedStatement.cpp:106
Definition: CharacterDatabase.h:296
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
std::unordered_map< ObjectGuid::LowType, time_t > _goRespawnTimes
Definition: Map.h:722
void setUInt32(const uint8 index, const uint32 value)
Definition: PreparedStatement.cpp:115
void setUInt64(const uint8 index, const uint64 value)
Definition: PreparedStatement.cpp:124
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
uint32_t uint32
Definition: g3dmath.h:168
uint32 GetInstanceId() const
Definition: Map.h:368
void RemoveGORespawnTime(ObjectGuid::LowType dbGuid)
Definition: Map.cpp:3619

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::ScriptCommandStart ( ScriptInfo const script,
uint32  delay,
Object source,
Object target 
)
  • If effects should be immediate, launch the script execution
72 {
73  // NOTE: script record _must_ exist until command executed
74 
75  // prepare static data
76  ObjectGuid sourceGUID = source ? source->GetGUID() : ObjectGuid::Empty;
77  ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty;
78  ObjectGuid ownerGUID = (source && source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : ObjectGuid::Empty;
79 
80  ScriptAction sa;
81  sa.sourceGUID = sourceGUID;
82  sa.targetGUID = targetGUID;
83  sa.ownerGUID = ownerGUID;
84 
85  sa.script = &script;
86  m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + delay), sa));
87 
88  sScriptMgr->IncreaseScheduledScriptsCount();
89 
91  if (delay == 0 && !i_scriptLock)
92  {
93  i_scriptLock = true;
95  i_scriptLock = false;
96  }
97 }
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:691
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
ScriptInfo const * script
owner of source if source is item
Definition: Map.h:66
ObjectGuid ownerGUID
Definition: Map.h:65
#define sWorld
Definition: World.h:887
bool i_scriptLock
Definition: Map.h:685
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Item.h:259
ObjectGuid targetGUID
Definition: Map.h:64
ObjectGuid sourceGUID
Definition: Map.h:63
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: ObjectGuid.h:189
Definition: Map.h:61
void ScriptsProcess()
Process queued scripts.
Definition: MapScripts.cpp:292
Definition: ObjectGuid.h:30

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::ScriptsProcess ( )
private

Process queued scripts.

  • Process overdue queued scripts
Todo:
Allow gameobjects to be targets and casters
293 {
294  if (m_scriptSchedule.empty())
295  return;
296 
298  ScriptScheduleMap::iterator iter = m_scriptSchedule.begin();
299  // ok as multimap is a *sorted* associative container
300  while (!m_scriptSchedule.empty() && (iter->first <= sWorld->GetGameTime()))
301  {
302  ScriptAction const& step = iter->second;
303 
304  Object* source = NULL;
305  if (!step.sourceGUID.IsEmpty())
306  {
307  switch (step.sourceGUID.GetHigh())
308  {
309  case HighGuid::Item: // as well as HIGHGUID_CONTAINER
310  if (Player* player = HashMapHolder<Player>::Find(step.ownerGUID))
311  source = player->GetItemByGuid(step.sourceGUID);
312  break;
313  case HighGuid::Creature:
314  case HighGuid::Vehicle:
315  source = GetCreature(step.sourceGUID);
316  break;
317  case HighGuid::Pet:
318  source = GetPet(step.sourceGUID);
319  break;
320  case HighGuid::Player:
322  break;
324  source = GetGameObject(step.sourceGUID);
325  break;
326  case HighGuid::Corpse:
327  source = GetCorpse(step.sourceGUID);
328  break;
329  case HighGuid::Transport:
330  source = GetTransport(step.sourceGUID);
331  break;
332  default:
333  TC_LOG_ERROR("scripts", "%s source with unsupported high guid %s.",
334  step.script->GetDebugInfo().c_str(), step.sourceGUID.ToString().c_str());
335  break;
336  }
337  }
338 
339  WorldObject* target = NULL;
340  if (!step.targetGUID.IsEmpty())
341  {
342  switch (step.targetGUID.GetHigh())
343  {
344  case HighGuid::Creature:
345  case HighGuid::Vehicle:
346  target = GetCreature(step.targetGUID);
347  break;
348  case HighGuid::Pet:
349  target = GetPet(step.targetGUID);
350  break;
351  case HighGuid::Player:
353  break;
355  target = GetGameObject(step.targetGUID);
356  break;
357  case HighGuid::Corpse:
358  target = GetCorpse(step.targetGUID);
359  break;
360  case HighGuid::Transport:
361  target = GetTransport(step.targetGUID);
362  break;
363  default:
364  TC_LOG_ERROR("scripts", "%s target with unsupported high guid %s.",
365  step.script->GetDebugInfo().c_str(), step.targetGUID.ToString().c_str());
366  break;
367  }
368  }
369 
370  switch (step.script->command)
371  {
372  case SCRIPT_COMMAND_TALK:
373  {
374  if (step.script->Talk.ChatType > CHAT_TYPE_BOSS_WHISPER)
375  {
376  TC_LOG_ERROR("scripts", "%s invalid chat type (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->Talk.ChatType);
377  break;
378  }
379 
380  if (step.script->Talk.Flags & SF_TALK_USE_PLAYER)
381  source = _GetScriptPlayerSourceOrTarget(source, target, step.script);
382  else
383  source = _GetScriptCreatureSourceOrTarget(source, target, step.script);
384 
385  if (source)
386  {
387  Unit* sourceUnit = source->ToUnit();
388  if (!sourceUnit)
389  {
390  TC_LOG_ERROR("scripts", "%s source object (%s) is not an unit, skipping.", step.script->GetDebugInfo().c_str(), source->GetGUID().ToString().c_str());
391  break;
392  }
393 
394  switch (step.script->Talk.ChatType)
395  {
396  case CHAT_TYPE_SAY:
397  sourceUnit->Say(step.script->Talk.TextID, target);
398  break;
399  case CHAT_TYPE_YELL:
400  sourceUnit->Yell(step.script->Talk.TextID, target);
401  break;
404  sourceUnit->TextEmote(step.script->Talk.TextID, target, step.script->Talk.ChatType == CHAT_TYPE_BOSS_EMOTE);
405  break;
406  case CHAT_TYPE_WHISPER:
408  {
409  Player* receiver = target ? target->ToPlayer() : nullptr;
410  if (!receiver)
411  TC_LOG_ERROR("scripts", "%s attempt to whisper to non-player unit, skipping.", step.script->GetDebugInfo().c_str());
412  else
413  sourceUnit->Whisper(step.script->Talk.TextID, receiver, step.script->Talk.ChatType == CHAT_TYPE_BOSS_WHISPER);
414  break;
415  }
416  default:
417  break; // must be already checked at load
418  }
419  }
420  break;
421  }
422 
424  // Source or target must be Creature.
425  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
426  {
427  if (step.script->Emote.Flags & SF_EMOTE_USE_STATE)
428  cSource->SetUInt32Value(UNIT_NPC_EMOTESTATE, step.script->Emote.EmoteID);
429  else
430  cSource->HandleEmoteCommand(step.script->Emote.EmoteID);
431  }
432  break;
433 
435  // Source or target must be Creature.
436  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
437  {
438  // Validate field number.
439  if (step.script->FieldSet.FieldID <= OBJECT_FIELD_ENTRY || step.script->FieldSet.FieldID >= cSource->GetValuesCount())
440  TC_LOG_ERROR("scripts", "%s wrong field %u (max count: %u) in object (TypeId: %u, %s) specified, skipping.",
441  step.script->GetDebugInfo().c_str(), step.script->FieldSet.FieldID,
442  cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetGUID().ToString().c_str());
443  else
444  cSource->SetUInt32Value(step.script->FieldSet.FieldID, step.script->FieldSet.FieldValue);
445  }
446  break;
447 
449  // Source or target must be Creature.
450  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
451  {
452  Unit* unit = (Unit*)cSource;
453  if (step.script->MoveTo.TravelTime != 0)
454  {
455  float speed = unit->GetDistance(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ) / ((float)step.script->MoveTo.TravelTime * 0.001f);
456  unit->MonsterMoveWithSpeed(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, speed);
457  }
458  else
459  unit->NearTeleportTo(step.script->MoveTo.DestX, step.script->MoveTo.DestY, step.script->MoveTo.DestZ, unit->GetOrientation());
460  }
461  break;
462 
464  // Source or target must be Creature.
465  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
466  {
467  // Validate field number.
468  if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
469  {
470  TC_LOG_ERROR("scripts", "%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, %s) specified, skipping.",
471  step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID,
472  cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUID().ToString().c_str());
473  }
474  else
475  cSource->SetFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
476  }
477  break;
478 
480  // Source or target must be Creature.
481  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
482  {
483  // Validate field number.
484  if (step.script->FlagToggle.FieldID <= OBJECT_FIELD_ENTRY || step.script->FlagToggle.FieldID >= cSource->GetValuesCount())
485  {
486  TC_LOG_ERROR("scripts", "%s wrong field %u (max count: %u) in object (TypeId: %u, Entry: %u, %s) specified, skipping.",
487  step.script->GetDebugInfo().c_str(), step.script->FlagToggle.FieldID,
488  cSource->GetValuesCount(), cSource->GetTypeId(), cSource->GetEntry(), cSource->GetGUID().ToString().c_str());
489  }
490  else
491  cSource->RemoveFlag(step.script->FlagToggle.FieldID, step.script->FlagToggle.FieldValue);
492  }
493  break;
494 
496  if (step.script->TeleportTo.Flags & SF_TELEPORT_USE_CREATURE)
497  {
498  // Source or target must be Creature.
499  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true))
500  cSource->NearTeleportTo(step.script->TeleportTo.DestX, step.script->TeleportTo.DestY, step.script->TeleportTo.DestZ, step.script->TeleportTo.Orientation);
501  }
502  else
503  {
504  // Source or target must be Player.
505  if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
506  player->TeleportTo(step.script->TeleportTo.MapID, step.script->TeleportTo.DestX, step.script->TeleportTo.DestY, step.script->TeleportTo.DestZ, step.script->TeleportTo.Orientation);
507  }
508  break;
509 
511  {
512  if (!source)
513  {
514  TC_LOG_ERROR("scripts", "%s source object is NULL.", step.script->GetDebugInfo().c_str());
515  break;
516  }
517  if (!target)
518  {
519  TC_LOG_ERROR("scripts", "%s target object is NULL.", step.script->GetDebugInfo().c_str());
520  break;
521  }
522 
523  // when script called for item spell casting then target == (unit or GO) and source is player
524  WorldObject* worldObject;
525  Player* player = target->ToPlayer();
526  if (player)
527  {
528  if (source->GetTypeId() != TYPEID_UNIT && source->GetTypeId() != TYPEID_GAMEOBJECT && source->GetTypeId() != TYPEID_PLAYER)
529  {
530  TC_LOG_ERROR("scripts", "%s source is not unit, gameobject or player (TypeId: %u, Entry: %u, %s), skipping.",
531  step.script->GetDebugInfo().c_str(), source->GetTypeId(), source->GetEntry(), source->GetGUID().ToString().c_str());
532  break;
533  }
534  worldObject = dynamic_cast<WorldObject*>(source);
535  }
536  else
537  {
538  player = source->ToPlayer();
539  if (player)
540  {
541  if (target->GetTypeId() != TYPEID_UNIT && target->GetTypeId() != TYPEID_GAMEOBJECT && target->GetTypeId() != TYPEID_PLAYER)
542  {
543  TC_LOG_ERROR("scripts", "%s target is not unit, gameobject or player (TypeId: %u, Entry: %u, %s), skipping.",
544  step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUID().ToString().c_str());
545  break;
546  }
547  worldObject = dynamic_cast<WorldObject*>(target);
548  }
549  else
550  {
551  TC_LOG_ERROR("scripts", "%s neither source nor target is player (Entry: %u, GUID: %s; target: Entry: %u, GUID: %s), skipping.",
552  step.script->GetDebugInfo().c_str(), source->GetEntry(), source->GetGUID().ToString().c_str(),
553  target->GetEntry(), target->GetGUID().ToString().c_str());
554  break;
555  }
556  }
557 
558  // quest id and flags checked at script loading
559  if ((worldObject->GetTypeId() != TYPEID_UNIT || ((Unit*)worldObject)->IsAlive()) &&
560  (step.script->QuestExplored.Distance == 0 || worldObject->IsWithinDistInMap(player, float(step.script->QuestExplored.Distance))))
561  player->AreaExploredOrEventHappens(step.script->QuestExplored.QuestID);
562  else
563  player->FailQuest(step.script->QuestExplored.QuestID);
564 
565  break;
566  }
567 
569  // Source or target must be Player.
570  if (Player* player = _GetScriptPlayerSourceOrTarget(source, target, step.script))
571  {
572  if (step.script->KillCredit.Flags & SF_KILLCREDIT_REWARD_GROUP)
573  player->RewardPlayerAndGroupAtEvent(step.script->KillCredit.CreatureEntry, player);
574  else
575  player->KilledMonsterCredit(step.script->KillCredit.CreatureEntry);
576  }
577  break;
578 
580  if (!step.script->RespawnGameobject.GOGuid)
581  {
582  TC_LOG_ERROR("scripts", "%s gameobject guid (datalong) is not specified.", step.script->GetDebugInfo().c_str());
583  break;
584  }
585 
586  // Source or target must be WorldObject.
587  if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
588  {
589  GameObject* pGO = _FindGameObject(pSummoner, step.script->RespawnGameobject.GOGuid);
590  if (!pGO)
591  {
592  TC_LOG_ERROR("scripts", "%s gameobject was not found (guid: %u).", step.script->GetDebugInfo().c_str(), step.script->RespawnGameobject.GOGuid);
593  break;
594  }
595 
596  if (pGO->GetGoType() == GAMEOBJECT_TYPE_FISHINGNODE ||
597  pGO->GetGoType() == GAMEOBJECT_TYPE_DOOR ||
598  pGO->GetGoType() == GAMEOBJECT_TYPE_BUTTON ||
600  {
601  TC_LOG_ERROR("scripts", "%s can not be used with gameobject of type %u (guid: %u).",
602  step.script->GetDebugInfo().c_str(), uint32(pGO->GetGoType()), step.script->RespawnGameobject.GOGuid);
603  break;
604  }
605 
606  // Check that GO is not spawned
607  if (!pGO->isSpawned())
608  {
609  int32 nTimeToDespawn = std::max(5, int32(step.script->RespawnGameobject.DespawnDelay));
610  pGO->SetLootState(GO_READY);
611  pGO->SetRespawnTime(nTimeToDespawn);
612 
613  pGO->GetMap()->AddToMap(pGO);
614  }
615  }
616  break;
617 
619  {
620  // Source must be WorldObject.
621  if (WorldObject* pSummoner = _GetScriptWorldObject(source, true, step.script))
622  {
623  if (!step.script->TempSummonCreature.CreatureEntry)
624  TC_LOG_ERROR("scripts", "%s creature entry (datalong) is not specified.", step.script->GetDebugInfo().c_str());
625  else
626  {
627  float x = step.script->TempSummonCreature.PosX;
628  float y = step.script->TempSummonCreature.PosY;
629  float z = step.script->TempSummonCreature.PosZ;
630  float o = step.script->TempSummonCreature.Orientation;
631 
632  if (!pSummoner->SummonCreature(step.script->TempSummonCreature.CreatureEntry, x, y, z, o, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, step.script->TempSummonCreature.DespawnDelay))
633  TC_LOG_ERROR("scripts", "%s creature was not spawned (entry: %u).", step.script->GetDebugInfo().c_str(), step.script->TempSummonCreature.CreatureEntry);
634  }
635  }
636  break;
637  }
638 
641  _ScriptProcessDoor(source, target, step.script);
642  break;
643 
645  // Source must be Unit.
646  if (Unit* unit = _GetScriptUnit(source, true, step.script))
647  {
648  // Target must be GameObject.
649  if (!target)
650  {
651  TC_LOG_ERROR("scripts", "%s target object is NULL.", step.script->GetDebugInfo().c_str());
652  break;
653  }
654 
655  if (target->GetTypeId() != TYPEID_GAMEOBJECT)
656  {
657  TC_LOG_ERROR("scripts", "%s target object is not gameobject (TypeId: %u, Entry: %u, %s), skipping.",
658  step.script->GetDebugInfo().c_str(), target->GetTypeId(), target->GetEntry(), target->GetGUID().ToString().c_str());
659  break;
660  }
661 
662  if (GameObject* pGO = target->ToGameObject())
663  pGO->Use(unit);
664  }
665  break;
666 
668  {
669  // Source (datalong2 != 0) or target (datalong2 == 0) must be Unit.
670  bool bReverse = step.script->RemoveAura.Flags & SF_REMOVEAURA_REVERSE;
671  if (Unit* unit = _GetScriptUnit(bReverse ? source : target, bReverse, step.script))
672  unit->RemoveAurasDueToSpell(step.script->RemoveAura.SpellID);
673  break;
674  }
675 
677  {
679  if (!source && !target)
680  {
681  TC_LOG_ERROR("scripts", "%s source and target objects are NULL.", step.script->GetDebugInfo().c_str());
682  break;
683  }
684 
685  Unit* uSource = NULL;
686  Unit* uTarget = NULL;
687  // source/target cast spell at target/source (script->datalong2: 0: s->t 1: s->s 2: t->t 3: t->s
688  switch (step.script->CastSpell.Flags)
689  {
690  case SF_CASTSPELL_SOURCE_TO_TARGET: // source -> target
691  uSource = source ? source->ToUnit() : NULL;
692  uTarget = target ? target->ToUnit() : NULL;
693  break;
694  case SF_CASTSPELL_SOURCE_TO_SOURCE: // source -> source
695  uSource = source ? source->ToUnit() : NULL;
696  uTarget = uSource;
697  break;
698  case SF_CASTSPELL_TARGET_TO_TARGET: // target -> target
699  uSource = target ? target->ToUnit() : NULL;
700  uTarget = uSource;
701  break;
702  case SF_CASTSPELL_TARGET_TO_SOURCE: // target -> source
703  uSource = target ? target->ToUnit() : NULL;
704  uTarget = source ? source->ToUnit() : NULL;
705  break;
706  case SF_CASTSPELL_SEARCH_CREATURE: // source -> creature with entry
707  uSource = source ? source->ToUnit() : NULL;
708  uTarget = uSource ? GetClosestCreatureWithEntry(uSource, abs(step.script->CastSpell.CreatureEntry), step.script->CastSpell.SearchRadius) : NULL;
709  break;
710  }
711 
712  if (!uSource || !uSource->isType(TYPEMASK_UNIT))
713  {
714  TC_LOG_ERROR("scripts", "%s no source unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
715  break;
716  }
717 
718  if (!uTarget || !uTarget->isType(TYPEMASK_UNIT))
719  {
720  TC_LOG_ERROR("scripts", "%s no target unit found for spell %u", step.script->GetDebugInfo().c_str(), step.script->CastSpell.SpellID);
721  break;
722  }
723 
724  bool triggered = (step.script->CastSpell.Flags != 4) ?
725  step.script->CastSpell.CreatureEntry & SF_CASTSPELL_TRIGGERED :
726  step.script->CastSpell.CreatureEntry < 0;
727  uSource->CastSpell(uTarget, step.script->CastSpell.SpellID, triggered);
728  break;
729  }
730 
732  // Source must be WorldObject.
733  if (WorldObject* object = _GetScriptWorldObject(source, true, step.script))
734  {
735  // PlaySound.Flags bitmask: 0/1=anyone/target
736  Player* player = NULL;
737  if (step.script->PlaySound.Flags & SF_PLAYSOUND_TARGET_PLAYER)
738  {
739  // Target must be Player.
740  player = _GetScriptPlayer(target, false, step.script);
741  if (!target)
742  break;
743  }
744 
745  // PlaySound.Flags bitmask: 0/2=without/with distance dependent
746  if (step.script->PlaySound.Flags & SF_PLAYSOUND_DISTANCE_SOUND)
747  object->PlayDistanceSound(step.script->PlaySound.SoundID, player);
748  else
749  object->PlayDirectSound(step.script->PlaySound.SoundID, player);
750  }
751  break;
752 
754  // Target or source must be Player.
755  if (Player* pReceiver = _GetScriptPlayerSourceOrTarget(source, target, step.script))
756  {
757  ItemPosCountVec dest;
758  InventoryResult msg = pReceiver->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, step.script->CreateItem.ItemEntry, step.script->CreateItem.Amount);
759  if (msg == EQUIP_ERR_OK)
760  {
761  if (Item* item = pReceiver->StoreNewItem(dest, step.script->CreateItem.ItemEntry, true))
762  pReceiver->SendNewItem(item, step.script->CreateItem.Amount, false, true);
763  }
764  else
765  pReceiver->SendEquipError(msg, NULL, NULL, step.script->CreateItem.ItemEntry);
766  }
767  break;
768 
770  // Target or source must be Creature.
771  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script, true))
772  cSource->DespawnOrUnsummon(step.script->DespawnSelf.DespawnDelay);
773  break;
774 
776  // Source must be Unit.
777  if (Unit* unit = _GetScriptUnit(source, true, step.script))
778  {
779  if (!sWaypointMgr->GetPath(step.script->LoadPath.PathID))
780  TC_LOG_ERROR("scripts", "%s source object has an invalid path (%u), skipping.", step.script->GetDebugInfo().c_str(), step.script->LoadPath.PathID);
781  else
782  unit->GetMotionMaster()->MovePath(step.script->LoadPath.PathID, step.script->LoadPath.IsRepeatable != 0);
783  }
784  break;
785 
787  {
788  if (!step.script->CallScript.CreatureEntry)
789  {
790  TC_LOG_ERROR("scripts", "%s creature entry is not specified, skipping.", step.script->GetDebugInfo().c_str());
791  break;
792  }
793  if (!step.script->CallScript.ScriptID)
794  {
795  TC_LOG_ERROR("scripts", "%s script id is not specified, skipping.", step.script->GetDebugInfo().c_str());
796  break;
797  }
798 
799  Creature* cTarget = NULL;
800  auto creatureBounds = _creatureBySpawnIdStore.equal_range(step.script->CallScript.CreatureEntry);
801  if (creatureBounds.first != creatureBounds.second)
802  {
803  // Prefer alive (last respawned) creature
804  auto creatureItr = std::find_if(creatureBounds.first, creatureBounds.second, [](Map::CreatureBySpawnIdContainer::value_type const& pair)
805  {
806  return pair.second->IsAlive();
807  });
808 
809  cTarget = creatureItr != creatureBounds.second ? creatureItr->second : creatureBounds.first->second;
810  }
811 
812  if (!cTarget)
813  {
814  TC_LOG_ERROR("scripts", "%s target was not found (entry: %u)", step.script->GetDebugInfo().c_str(), step.script->CallScript.CreatureEntry);
815  break;
816  }
817 
818  //Lets choose our ScriptMap map
819  ScriptMapMap* datamap = GetScriptsMapByType(ScriptsType(step.script->CallScript.ScriptType));
820  //if no scriptmap present...
821  if (!datamap)
822  {
823  TC_LOG_ERROR("scripts", "%s unknown scriptmap (%u) specified, skipping.", step.script->GetDebugInfo().c_str(), step.script->CallScript.ScriptType);
824  break;
825  }
826 
827  // Insert script into schedule but do not start it
828  ScriptsStart(*datamap, step.script->CallScript.ScriptID, cTarget, NULL);
829  break;
830  }
831 
832  case SCRIPT_COMMAND_KILL:
833  // Source or target must be Creature.
834  if (Creature* cSource = _GetScriptCreatureSourceOrTarget(source, target, step.script))
835  {
836  if (cSource->isDead())
837  {
838  TC_LOG_ERROR("scripts", "%s creature is already dead (Entry: %u, %s)",
839  step.script->GetDebugInfo().c_str(), cSource->GetEntry(), cSource->GetGUID().ToString().c_str());
840  }
841  else
842  {
843  cSource->setDeathState(JUST_DIED);
844  if (step.script->Kill.RemoveCorpse == 1)
845  cSource->RemoveCorpse();
846  }
847  }
848  break;
849 
851  // Source must be Unit.
852  if (Unit* sourceUnit = _GetScriptUnit(source, true, step.script))
853  {
855  {
856  // Target must be Unit.
857  Unit* targetUnit = _GetScriptUnit(target, false, step.script);
858  if (!targetUnit)
859  break;
860 
861  sourceUnit->SetFacingToObject(targetUnit);
862  }
863  else
864  sourceUnit->SetFacingTo(step.script->Orientation.Orientation);
865  }
866  break;
867 
869  // Source must be Creature.
870  if (Creature* cSource = _GetScriptCreature(source, true, step.script))
871  cSource->LoadEquipment(step.script->Equip.EquipmentID);
872  break;
873 
875  // Source must be Creature.
876  if (Creature* cSource = _GetScriptCreature(source, true, step.script))
877  cSource->SetDisplayId(step.script->Model.ModelID);
878  break;
879 
881  // Source must be Player.
882  if (Player* player = _GetScriptPlayer(source, true, step.script))
883  player->PlayerTalkClass->SendCloseGossip();
884  break;
885 
887  // Source must be Player.
888  if (Player* player = _GetScriptPlayer(source, true, step.script))
889  player->SendMovieStart(step.script->PlayMovie.MovieID);
890  break;
891 
893  // Source must be Creature.
894  if (Creature* cSource = _GetScriptCreature(source, true, step.script))
895  cSource->PlayOneShotAnimKitId(step.script->PlayAnimKit.AnimKitID);
896  break;
897 
898  default:
899  TC_LOG_ERROR("scripts", "Unknown script command %s.", step.script->GetDebugInfo().c_str());
900  break;
901  }
902 
903  m_scriptSchedule.erase(iter);
904  iter = m_scriptSchedule.begin();
905  sScriptMgr->DecreaseScheduledScriptCount();
906  }
907 }
Definition: Object.h:95
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
Definition: ObjectMgr.h:115
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:691
Definition: ObjectMgr.h:97
Definition: ObjectMgr.h:161
Definition: ObjectMgr.h:108
Definition: ObjectMgr.h:96
Definition: UpdateFields.h:136
Definition: Creature.h:341
Definition: ObjectMgr.h:95
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:33
struct ScriptInfo::@280::@297 CreateItem
GameObject * _FindGameObject(WorldObject *pWorldObject, ObjectGuid::LowType guid) const
Definition: MapScripts.cpp:282
Definition: ObjectMgr.h:94
Definition: Creature.h:343
Definition: ObjectMgr.h:89
Map * GetMap() const
Definition: Object.h:543
Definition: Unit.h:379
Definition: ObjectMgr.h:170
virtual void TextEmote(std::string const &text, WorldObject const *target=nullptr, bool isBossEmote=false)
Definition: Unit.cpp:16403
float Orientation
Definition: ObjectMgr.h:243
void _ScriptProcessDoor(Object *source, Object *target, const ScriptInfo *scriptInfo) const
Definition: MapScripts.cpp:227
struct ScriptInfo::@280::@286 MoveTo
Player * _GetScriptPlayer(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition: MapScripts.cpp:175
TC_GAME_API Creature * GetClosestCreatureWithEntry(WorldObject *source, uint32 entry, float maxSearchRange, bool alive)
Definition: ScriptedCreature.cpp:611
ScriptCommands command
Definition: ObjectMgr.h:187
Definition: Unit.h:542
ScriptsType
Definition: ObjectMgr.h:138
Definition: ObjectMgr.h:103
Definition: ObjectMgr.h:106
bool isType(uint16 mask) const
Definition: Object.h:114
struct ScriptInfo::@280::@304 Model
ScriptInfo const * script
owner of source if source is item
Definition: Map.h:66
Definition: ObjectMgr.h:167
MotionMaster * GetMotionMaster()
Definition: Unit.h:2101
struct ScriptInfo::@280::@285 FieldSet
std::map< uint32, ScriptMap > ScriptMapMap
Definition: ObjectMgr.h:376
ObjectGuid ownerGUID
Definition: Map.h:65
Definition: ObjectMgr.h:101
Definition: ObjectGuid.h:32
std::string GetDebugInfo() const
Definition: ObjectMgr.cpp:126
Definition: ObjectMgr.h:90
arena_t NULL
Definition: jemalloc_internal.h:624
struct ScriptInfo::@280::@284 Emote
Definition: Creature.h:345
struct ScriptInfo::@280::@299 LoadPath
Pet * GetPet(ObjectGuid const &guid)
Definition: Map.cpp:3550
Definition: Object.h:423
Definition: ObjectMgr.h:113
Definition: Creature.h:467
void SetRespawnTime(int32 respawn)
Definition: GameObject.h:945
#define sWorld
Definition: World.h:887
struct ScriptInfo::@280::@300 CallScript
Definition: SharedDefines.h:2082
Corpse * GetCorpse(ObjectGuid const &guid)
Definition: Map.cpp:3530
GameObject * ToGameObject()
Definition: Object.h:200
Definition: Creature.h:340
T max(const T &x, const T &y)
Definition: g3dmath.h:320
struct ScriptInfo::@280::@301 Kill
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true) const
Definition: Object.cpp:1663
Definition: ObjectMgr.h:87
Player * ToPlayer()
Definition: Object.h:191
Definition: ObjectGuid.h:49
Definition: ObjectMgr.h:91
Definition: ObjectMgr.h:107
struct ScriptInfo::@280::@291 RespawnGameobject
struct ScriptInfo::@280::@283 Talk
TypeID GetTypeId() const
Definition: Object.h:113
void SetLootState(LootState s, Unit *unit=NULL)
Definition: GameObject.cpp:2112
Definition: UpdateFields.h:29
Definition: Item.h:48
void SetFacingToObject(WorldObject const *object)
Definition: Unit.cpp:15787
float GetOrientation() const
Definition: Position.h:107
#define sWaypointMgr
Definition: WaypointManager.h:75
Definition: Unit.h:378
Definition: ObjectMgr.h:86
struct ScriptInfo::@280::@305 PlayMovie
Definition: SharedDefines.h:2066
float GetDistance(WorldObject const *obj) const
Definition: Object.cpp:1594
Definition: ObjectMgr.h:102
struct ScriptInfo::@280::@306 PlayAnimKit
Definition: ObjectMgr.h:175
Definition: ObjectMgr.h:169
struct ScriptInfo::@280::@294 RemoveAura
void NearTeleportTo(float x, float y, float z, float orientation, bool casting=false)
Definition: Unit.cpp:15407
Creature * _GetScriptCreature(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition: MapScripts.cpp:192
G3D::int16 z
Definition: Vector3int16.h:46
Definition: Item.h:259
bool AddToMap(T *)
Definition: Map.cpp:566
Unit * _GetScriptUnit(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition: MapScripts.cpp:155
Definition: ObjectGuid.h:34
int32_t int32
Definition: Define.h:146
ObjectGuid targetGUID
Definition: Map.h:64
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition: Map.h:739
G3D::int16 y
Definition: Vector2int16.h:38
struct ScriptInfo::@280::@295 CastSpell
Definition: GameObject.h:880
void SetFacingTo(float ori)
Definition: Unit.cpp:15777
WorldObject * _GetScriptWorldObject(Object *obj, bool isSource, const ScriptInfo *scriptInfo) const
Definition: MapScripts.cpp:209
ScriptMapMap * GetScriptsMapByType(ScriptsType type)
Definition: ObjectMgr.cpp:68
struct ScriptInfo::@280::@298 DespawnSelf
Definition: ObjectMgr.h:92
Definition: ObjectMgr.h:152
Definition: ObjectMgr.h:176
ObjectGuid sourceGUID
Definition: Map.h:63
void Use(Unit *user)
Definition: GameObject.cpp:1232
Player * _GetScriptPlayerSourceOrTarget(Object *source, Object *target, const ScriptInfo *scriptInfo) const
Definition: MapScripts.cpp:100
Definition: ObjectMgr.h:172
Definition: ObjectMgr.h:112
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition: Unit.cpp:3586
virtual void Whisper(std::string const &text, Language language, Player *target, bool isBossWhisper=false)
Definition: Unit.cpp:16408
virtual void Yell(std::string const &text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:16398
Definition: Creature.h:342
ObjectGuid const & GetGUID() const
Definition: Object.h:105
struct ScriptInfo::@280::@292 TempSummonCreature
bool isSpawned() const
Definition: GameObject.h:951
virtual void Say(std::string const &text, Language language, WorldObject const *target=nullptr)
Definition: Unit.cpp:16393
Definition: ObjectGuid.h:33
GameobjectTypes GetGoType() const
Definition: GameObject.h:964
Definition: ObjectMgr.h:100
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535
SPECIFIC_TYPE * Find(ContainerUnorderedMap< SPECIFIC_TYPE, KEY_TYPE > const &elements, KEY_TYPE const &handle, SPECIFIC_TYPE *)
Definition: TypeContainerFunctions.h:74
void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath=false, bool forceDestination=false)
Definition: Unit.cpp:426
Definition: ObjectMgr.h:164
Definition: ObjectMgr.h:171
Definition: ObjectMgr.h:98
Definition: ObjectMgr.h:116
struct ScriptInfo::@280::@303 Equip
void MovePath(uint32 path_id, bool repeatable)
Definition: MotionMaster.cpp:618
Definition: ObjectMgr.h:99
HighGuid GetHigh() const
Definition: ObjectGuid.h:217
int32_t int32
Definition: g3dmath.h:167
Definition: ObjectAccessor.h:45
#define sScriptMgr
Definition: ScriptMgr.h:837
uint32 GetEntry() const
Definition: Object.h:107
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ObjectMgr.h:155
struct ScriptInfo::@280::@290 KillCredit
uint32_t uint32
Definition: g3dmath.h:168
G3D::int16 x
Definition: Vector2int16.h:37
struct ScriptInfo::@280::@288 TeleportTo
Definition: ObjectMgr.h:179
InventoryResult
Definition: Item.h:46
Transport * GetTransport(ObjectGuid const &guid)
Definition: Map.cpp:3555
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545
struct ScriptInfo::@280::@296 PlaySound
Definition: ObjectMgr.h:158
Creature * _GetScriptCreatureSourceOrTarget(Object *source, Object *target, const ScriptInfo *scriptInfo, bool bReverse=false) const
Definition: MapScripts.cpp:122
Definition: ObjectMgr.h:104
Definition: Map.h:61
Definition: Unit.h:1305
struct ScriptInfo::@280::@287 FlagToggle
Definition: ObjectMgr.h:93
Definition: GameObject.h:869
void CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=NULL, AuraEffect const *triggeredByAura=NULL, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:869
Definition: SharedDefines.h:2071
Definition: ObjectMgr.h:114
std::string ToString() const
Definition: ObjectGuid.cpp:99
Definition: ObjectMgr.h:168
struct ScriptInfo::@280::@289 QuestExplored
Unit * ToUnit()
Definition: Object.h:197
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: ObjectMgr.h:111
Definition: SharedDefines.h:2065
Definition: ObjectMgr.h:88
Definition: Creature.h:344
Definition: Object.h:54

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
34 {
36  ScriptMapMap::const_iterator s = scripts.find(id);
37  if (s == scripts.end())
38  return;
39 
40  // prepare static data
41  ObjectGuid sourceGUID = source ? source->GetGUID() : ObjectGuid::Empty; //some script commands doesn't have source
42  ObjectGuid targetGUID = target ? target->GetGUID() : ObjectGuid::Empty;
43  ObjectGuid ownerGUID = (source && source->GetTypeId() == TYPEID_ITEM) ? ((Item*)source)->GetOwnerGUID() : ObjectGuid::Empty;
44 
46  ScriptMap const* s2 = &(s->second);
47  bool immedScript = false;
48  for (ScriptMap::const_iterator iter = s2->begin(); iter != s2->end(); ++iter)
49  {
50  ScriptAction sa;
51  sa.sourceGUID = sourceGUID;
52  sa.targetGUID = targetGUID;
53  sa.ownerGUID = ownerGUID;
54 
55  sa.script = &iter->second;
56  m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + iter->first), sa));
57  if (iter->first == 0)
58  immedScript = true;
59 
60  sScriptMgr->IncreaseScheduledScriptsCount();
61  }
63  if (/*start &&*/ immedScript && !i_scriptLock)
64  {
65  i_scriptLock = true;
67  i_scriptLock = false;
68  }
69 }
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:691
std::multimap< uint32, ScriptInfo > ScriptMap
Definition: ObjectMgr.h:375
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
ScriptInfo const * script
owner of source if source is item
Definition: Map.h:66
ObjectGuid ownerGUID
Definition: Map.h:65
#define sWorld
Definition: World.h:887
bool i_scriptLock
Definition: Map.h:685
TypeID GetTypeId() const
Definition: Object.h:113
Definition: Item.h:259
ObjectGuid targetGUID
Definition: Map.h:64
ObjectGuid sourceGUID
Definition: Map.h:63
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define sScriptMgr
Definition: ScriptMgr.h:837
Definition: ObjectGuid.h:189
Definition: Map.h:61
void ScriptsProcess()
Process queued scripts.
Definition: MapScripts.cpp:292
Definition: ObjectGuid.h:30

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SendInitSelf ( Player player)
private
2672 {
2673  TC_LOG_DEBUG("maps", "Creating player data for himself %s", player->GetGUID().ToString().c_str());
2674 
2675  UpdateData data(player->GetMapId());
2676 
2677  // attach to player data current transport data
2678  if (Transport* transport = player->GetTransport())
2679  {
2680  transport->BuildCreateUpdateBlockForPlayer(&data, player);
2681  }
2682 
2683  // build data for self presence in world at own client (one time for map)
2684  player->BuildCreateUpdateBlockForPlayer(&data, player);
2685 
2686  // build other passengers at transport also (they always visible and marked as visible and will not send at visibility update at add to map
2687  if (Transport* transport = player->GetTransport())
2688  for (Transport::PassengerSet::const_iterator itr = transport->GetPassengers().begin(); itr != transport->GetPassengers().end(); ++itr)
2689  if (player != (*itr) && player->HaveAtClient(*itr))
2690  (*itr)->BuildCreateUpdateBlockForPlayer(&data, player);
2691 
2692  WorldPacket packet;
2693  data.BuildPacket(&packet);
2694  player->GetSession()->SendPacket(&packet);
2695 }
Definition: Transport.h:28
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: UpdateData.h:59
Transport * GetTransport() const
Definition: Object.h:602
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SendInitTransports ( Player player)
2698 {
2699  // Hack to send out transports
2700  UpdateData transData(player->GetMapId());
2701  for (TransportsContainer::const_iterator i = _transports.begin(); i != _transports.end(); ++i)
2702  if (*i != player->GetTransport() && player->IsInPhase(*i))
2703  (*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
2704 
2705  WorldPacket packet;
2706  transData.BuildPacket(&packet);
2707  player->GetSession()->SendPacket(&packet);
2708 }
TransportsContainer _transports
Definition: Map.h:658
Definition: UpdateData.h:59
Definition: WorldPacket.h:26

+ Here is the caller graph for this function:

void Map::SendObjectUpdates ( )
private
2754 {
2755  UpdateDataMapType update_players;
2756 
2757  while (!_updateObjects.empty())
2758  {
2759  Object* obj = *_updateObjects.begin();
2760  ASSERT(obj->IsInWorld());
2761  _updateObjects.erase(_updateObjects.begin());
2762  obj->BuildUpdate(update_players);
2763  }
2764 
2765  WorldPacket packet; // here we allocate a std::vector with a size of 0x10000
2766  for (UpdateDataMapType::iterator iter = update_players.begin(); iter != update_players.end(); ++iter)
2767  {
2768  iter->second.BuildPacket(&packet);
2769  iter->first->GetSession()->SendPacket(&packet);
2770  packet.clear(); // clean the string
2771  }
2772 }
Definition: Object.h:95
virtual void BuildUpdate(UpdateDataMapType &)
Definition: Object.h:182
std::unordered_map< Player *, UpdateData > UpdateDataMapType
Definition: Object.h:91
std::unordered_set< Object * > _updateObjects
Definition: Map.h:745
#define ASSERT
Definition: Errors.h:55
bool IsInWorld() const
Definition: Object.h:100
void clear()
Definition: ByteBuffer.h:134
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SendRemoveTransports ( Player player)
2711 {
2712  // Hack to send out transports
2713  UpdateData transData(player->GetMapId());
2714  for (TransportsContainer::const_iterator i = _transports.begin(); i != _transports.end(); ++i)
2715  if (*i != player->GetTransport())
2716  (*i)->BuildOutOfRangeUpdateBlock(&transData);
2717 
2718  WorldPacket packet;
2719  transData.BuildPacket(&packet);
2720  player->GetSession()->SendPacket(&packet);
2721 }
TransportsContainer _transports
Definition: Map.h:658
Definition: UpdateData.h:59
Definition: WorldPacket.h:26

+ Here is the caller graph for this function:

void Map::SendToPlayers ( WorldPacket const data) const
2915 {
2917  itr->GetSource()->GetSession()->SendPacket(data);
2918 }
iterator begin()
Definition: MapRefManager.h:37
Definition: LinkedList.h:141
MapRefManager m_mapRefManager
Definition: Map.h:647
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SendUpdateTransportVisibility ( Player player,
std::set< uint32 > const previousPhases 
)
2724 {
2725  // Hack to send out transports
2726  UpdateData transData(player->GetMapId());
2727  for (TransportsContainer::const_iterator i = _transports.begin(); i != _transports.end(); ++i)
2728  {
2729  if (*i == player->GetTransport())
2730  continue;
2731 
2732  if (player->IsInPhase(*i) && !Trinity::Containers::Intersects(previousPhases.begin(), previousPhases.end(), (*i)->GetPhases().begin(), (*i)->GetPhases().end()))
2733  (*i)->BuildCreateUpdateBlockForPlayer(&transData, player);
2734  else if (!player->IsInPhase(*i))
2735  (*i)->BuildOutOfRangeUpdateBlock(&transData);
2736  }
2737 
2738  WorldPacket packet;
2739  transData.BuildPacket(&packet);
2740  player->GetSession()->SendPacket(&packet);
2741 }
TransportsContainer _transports
Definition: Map.h:658
Definition: UpdateData.h:59
bool Intersects(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
Definition: Containers.h:133
Definition: WorldPacket.h:26

+ Here is the call graph for this function:

void Map::SendZoneDynamicInfo ( Player player)
3880 {
3881  uint32 zoneId = GetZoneId(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ());
3882  ZoneDynamicInfoMap::const_iterator itr = _zoneDynamicInfo.find(zoneId);
3883  if (itr == _zoneDynamicInfo.end())
3884  return;
3885 
3886  if (uint32 music = itr->second.MusicId)
3887  player->SendDirectMessage(WorldPackets::Misc::PlayMusic(music).Write());
3888 
3889  if (WeatherState weatherId = itr->second.WeatherId)
3890  {
3891  WorldPackets::Misc::Weather weather(weatherId, itr->second.WeatherGrade);
3892  player->SendDirectMessage(weather.Write());
3893  }
3894 
3895  if (uint32 overrideLightId = itr->second.OverrideLightId)
3896  {
3897  WorldPackets::Misc::OverrideLight overrideLight;
3898  overrideLight.AreaLightID = _defaultLight;
3899  overrideLight.OverrideLightID = overrideLightId;
3900  overrideLight.TransitionMilliseconds = itr->second.LightFadeInTime;
3901  player->SendDirectMessage(overrideLight.Write());
3902  }
3903 }
Definition: MiscPackets.h:501
Definition: MiscPackets.h:815
int32 OverrideLightID
Definition: MiscPackets.h:824
int32 TransitionMilliseconds
Definition: MiscPackets.h:823
int32 AreaLightID
Definition: MiscPackets.h:822
WorldPacket const * Write() override
Definition: MiscPackets.cpp:621
Definition: MiscPackets.h:400
ZoneDynamicInfoMap _zoneDynamicInfo
Definition: Map.h:724
uint32_t uint32
Definition: Define.h:150
uint32 GetZoneId(float x, float y, float z) const
Definition: Map.cpp:2471
WeatherState
Definition: Weather.h:46
uint32 _defaultLight
Definition: Map.h:725

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::setGridObjectDataLoaded ( bool  pLoaded,
uint32  x,
uint32  y 
)
inlineprivate
624 { getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); }
void setGridObjectDataLoaded(bool pLoaded)
Definition: NGrid.h:110
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

void Map::setNGrid ( NGridType grid,
uint32  x,
uint32  y 
)
inlineprivate
2744 {
2746  {
2747  TC_LOG_ERROR("maps", "map::setNGrid() Invalid grid coordinates found: %d, %d!", x, y);
2748  ABORT();
2749  }
2750  i_grids[x][y] = grid;
2751 }
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
G3D::int16 y
Definition: Vector2int16.h:38
#define ABORT
Definition: Errors.h:56
NGridType * i_grids[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:677
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the caller graph for this function:

void Map::SetTimer ( uint32  t)
inlineprivate
#define MIN_GRID_DELAY
Definition: GridDefines.h:44
time_t i_gridExpiry
Definition: Map.h:671
void Map::SetUnloadLock ( const GridCoord p,
bool  on 
)
inline
void setUnloadExplicitLock(bool on)
Definition: NGrid.h:115
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
void Map::SetUnloadReferenceLock ( const GridCoord p,
bool  on 
)
inlineprotected
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
void setUnloadReferenceLock(bool on)
Definition: NGrid.h:116

+ Here is the caller graph for this function:

void Map::SetZoneMusic ( uint32  zoneId,
uint32  musicId 
)
3906 {
3907  if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
3908  _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
3909 
3910  _zoneDynamicInfo[zoneId].MusicId = musicId;
3911 
3912  Map::PlayerList const& players = GetPlayers();
3913  if (!players.isEmpty())
3914  {
3915  for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3916  if (Player* player = itr->GetSource())
3917  if (player->GetZoneId() == zoneId)
3918  player->SendDirectMessage(WorldPackets::Misc::PlayMusic(musicId).Write());
3919  }
3920 }
WorldPacket const * Write() override
Definition: MiscPackets.cpp:362
Definition: Map.h:234
Definition: MiscPackets.h:501
iterator begin()
Definition: MapRefManager.h:37
ZoneDynamicInfoMap _zoneDynamicInfo
Definition: Map.h:724
Definition: LinkedList.h:141
bool isEmpty() const
Definition: LinkedList.h:102
PlayerList const & GetPlayers() const
Definition: Map.h:433
Definition: MapRefManager.h:26
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SetZoneOverrideLight ( uint32  zoneId,
uint32  lightId,
uint32  fadeInTime 
)
3944 {
3945  if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
3946  _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
3947 
3948  ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
3949  info.OverrideLightId = lightId;
3950  info.LightFadeInTime = fadeInTime;
3951  Map::PlayerList const& players = GetPlayers();
3952 
3953  if (!players.isEmpty())
3954  {
3955  WorldPackets::Misc::OverrideLight overrideLight;
3956  overrideLight.AreaLightID = _defaultLight;
3957  overrideLight.OverrideLightID = lightId;
3958  overrideLight.TransitionMilliseconds = fadeInTime;
3959  overrideLight.Write();
3960 
3961  for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3962  if (Player* player = itr->GetSource())
3963  if (player->GetZoneId() == zoneId)
3964  player->SendDirectMessage(overrideLight.GetRawPacket());
3965  }
3966 }
Definition: Map.h:234
Definition: MiscPackets.h:815
int32 OverrideLightID
Definition: MiscPackets.h:824
int32 TransitionMilliseconds
Definition: MiscPackets.h:823
iterator begin()
Definition: MapRefManager.h:37
int32 AreaLightID
Definition: MiscPackets.h:822
WorldPacket const * Write() override
Definition: MiscPackets.cpp:621
uint32 LightFadeInTime
Definition: Map.h:242
ZoneDynamicInfoMap _zoneDynamicInfo
Definition: Map.h:724
WorldPacket const * GetRawPacket() const
Definition: Packet.h:38
Definition: LinkedList.h:141
bool isEmpty() const
Definition: LinkedList.h:102
PlayerList const & GetPlayers() const
Definition: Map.h:433
Definition: MapRefManager.h:26
uint32 OverrideLightId
Definition: Map.h:241
iterator end()
Definition: MapRefManager.h:38
uint32 _defaultLight
Definition: Map.h:725

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::SetZoneWeather ( uint32  zoneId,
WeatherState  weatherId,
float  weatherGrade 
)
3923 {
3924  if (_zoneDynamicInfo.find(zoneId) == _zoneDynamicInfo.end())
3925  _zoneDynamicInfo.insert(ZoneDynamicInfoMap::value_type(zoneId, ZoneDynamicInfo()));
3926 
3927  ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
3928  info.WeatherId = weatherId;
3929  info.WeatherGrade = weatherGrade;
3930  Map::PlayerList const& players = GetPlayers();
3931 
3932  if (!players.isEmpty())
3933  {
3934  WorldPackets::Misc::Weather weather(weatherId, weatherGrade);
3935 
3936  for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3937  if (Player* player = itr->GetSource())
3938  if (player->GetZoneId() == zoneId)
3939  player->SendDirectMessage(weather.Write());
3940  }
3941 }
float WeatherGrade
Definition: Map.h:240
Definition: Map.h:234
iterator begin()
Definition: MapRefManager.h:37
Definition: MiscPackets.h:400
ZoneDynamicInfoMap _zoneDynamicInfo
Definition: Map.h:724
Definition: LinkedList.h:141
bool isEmpty() const
Definition: LinkedList.h:102
PlayerList const & GetPlayers() const
Definition: Map.h:433
Definition: MapRefManager.h:26
WeatherState WeatherId
Definition: Map.h:239
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TempSummon * Map::SummonCreature ( uint32  entry,
Position const pos,
SummonPropertiesEntry const properties = NULL,
uint32  duration = 0,
Unit summoner = NULL,
uint32  spellId = 0,
uint32  vehId = 0 
)
2220 {
2221  uint32 mask = UNIT_MASK_SUMMON;
2222  if (properties)
2223  {
2224  switch (properties->Category)
2225  {
2226  case SUMMON_CATEGORY_PET:
2227  mask = UNIT_MASK_GUARDIAN;
2228  break;
2230  mask = UNIT_MASK_PUPPET;
2231  break;
2233  mask = UNIT_MASK_MINION;
2234  break;
2235  case SUMMON_CATEGORY_WILD:
2236  case SUMMON_CATEGORY_ALLY:
2237  case SUMMON_CATEGORY_UNK:
2238  {
2239  switch (properties->Type)
2240  {
2241  case SUMMON_TYPE_MINION:
2242  case SUMMON_TYPE_GUARDIAN:
2243  case SUMMON_TYPE_GUARDIAN2:
2244  mask = UNIT_MASK_GUARDIAN;
2245  break;
2246  case SUMMON_TYPE_TOTEM:
2247  case SUMMON_TYPE_LIGHTWELL:
2248  mask = UNIT_MASK_TOTEM;
2249  break;
2250  case SUMMON_TYPE_VEHICLE:
2251  case SUMMON_TYPE_VEHICLE2:
2252  mask = UNIT_MASK_SUMMON;
2253  break;
2254  case SUMMON_TYPE_MINIPET:
2255  mask = UNIT_MASK_MINION;
2256  break;
2257  default:
2258  if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
2259  mask = UNIT_MASK_GUARDIAN;
2260  break;
2261  }
2262  break;
2263  }
2264  default:
2265  return NULL;
2266  }
2267  }
2268 
2269  TempSummon* summon = NULL;
2270  switch (mask)
2271  {
2272  case UNIT_MASK_SUMMON:
2273  summon = new TempSummon(properties, summoner, false);
2274  break;
2275  case UNIT_MASK_GUARDIAN:
2276  summon = new Guardian(properties, summoner, false);
2277  break;
2278  case UNIT_MASK_PUPPET:
2279  summon = new Puppet(properties, summoner);
2280  break;
2281  case UNIT_MASK_TOTEM:
2282  summon = new Totem(properties, summoner);
2283  break;
2284  case UNIT_MASK_MINION:
2285  summon = new Minion(properties, summoner, false);
2286  break;
2287  }
2288 
2289  if (!summon->Create(GenerateLowGuid<HighGuid::Creature>(), this, 0, entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), nullptr, vehId))
2290  {
2291  delete summon;
2292  return NULL;
2293  }
2294 
2295  // Set the summon to the summoner's phase
2296  summon->CopyPhaseFrom(summoner);
2297 
2298  summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
2299 
2300  summon->SetHomePosition(pos);
2301 
2302  summon->InitStats(duration);
2303  AddToMap(summon->ToCreature());
2304  summon->InitSummon();
2305 
2306  //ObjectAccessor::UpdateObjectVisibility(summon);
2307 
2308  return summon;
2309 }
Definition: TemporarySummon.h:83
Definition: TemporarySummon.h:40
Definition: SharedDefines.h:4404
Definition: SharedDefines.h:4400
Definition: Unit.h:860
Definition: SharedDefines.h:4406
Definition: TemporarySummon.h:107
Definition: SharedDefines.h:4385
Definition: UpdateFields.h:134
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const *data=nullptr, uint32 vehId=0)
Definition: Creature.cpp:834
arena_t NULL
Definition: jemalloc_internal.h:624
void SetUInt32Value(uint16 index, uint32 value)
Definition: Object.cpp:996
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:670
void CopyPhaseFrom(WorldObject *obj, bool update=false)
Definition: Object.cpp:2915
Definition: SharedDefines.h:4387
Definition: Unit.h:859
Definition: Totem.h:38
Definition: TemporarySummon.h:66
Definition: SharedDefines.h:4398
bool AddToMap(T *)
Definition: Map.cpp:566
Definition: SharedDefines.h:4401
uint32_t uint32
Definition: Define.h:150
Definition: SharedDefines.h:4386
Definition: Unit.h:858
Definition: SharedDefines.h:4384
Definition: SharedDefines.h:4389
virtual void InitSummon()
Definition: TemporarySummon.cpp:220
Creature * ToCreature()
Definition: Object.h:194
Definition: SharedDefines.h:4405
Definition: SharedDefines.h:4397
Definition: Unit.h:861
virtual void InitStats(uint32 lifetime)
Definition: TemporarySummon.cpp:176
Definition: SharedDefines.h:4388
Definition: Unit.h:864
Definition: SharedDefines.h:4399

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Summons group of creatures.

Parameters
groupId of group to summon.
listList to store pointers to summoned creatures.
2319 {
2320  std::vector<TempSummonData> const* data = sObjectMgr->GetSummonGroup(GetId(), SUMMONER_TYPE_MAP, group);
2321  if (!data)
2322  return;
2323 
2324  for (std::vector<TempSummonData>::const_iterator itr = data->begin(); itr != data->end(); ++itr)
2325  if (TempSummon* summon = SummonCreature(itr->entry, itr->pos, NULL, itr->time))
2326  if (list)
2327  list->push_back(summon);
2328 }
Definition: TemporarySummon.h:40
Definition: TemporarySummon.h:28
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=NULL, uint32 duration=0, Unit *summoner=NULL, uint32 spellId=0, uint32 vehId=0)
Definition: Object.cpp:2219
arena_t NULL
Definition: jemalloc_internal.h:624
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 GetId(void) const
Definition: Map.h:325

+ Here is the call graph for this function:

template<>
void Map::SwitchGridContainers ( Creature obj,
bool  on 
)
325 {
328  if (!p.IsCoordValid())
329  {
330  TC_LOG_ERROR("maps", "Map::SwitchGridContainers: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
331  return;
332  }
333 
334  Cell cell(p);
335  if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
336  return;
337 
338  if (sLog->ShouldLog("maps", LOG_LEVEL_DEBUG))
339  {
340  // Extract bitfield values
341  uint32 const grid_x = cell.data.Part.grid_x;
342  uint32 const grid_y = cell.data.Part.grid_y;
343 
344  TC_LOG_DEBUG("maps", "Switch object %s from grid[%u, %u] %u", obj->GetGUID().ToString().c_str(), grid_x, grid_y, on);
345  }
346 
347  NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY());
348  ASSERT(ngrid != NULL);
349 
350  GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY());
351 
352  obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add
353 
354  if (on)
355  {
356  grid.AddWorldObject(obj);
357  AddWorldObject(obj);
358  }
359  else
360  {
361  grid.AddGridObject(obj);
362  RemoveWorldObject(obj);
363  }
364 
365  obj->m_isTempWorldObject = on;
366 }
Definition: NGrid.h:77
void RemoveFromGrid()
Definition: Object.h:362
Definition: Appender.h:35
bool m_isTempWorldObject
Definition: Creature.h:706
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
arena_t NULL
Definition: jemalloc_internal.h:624
#define sLog
Definition: Log.h:154
Definition: Grid.h:46
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:428
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86
void AddGridObject(SPECIFIC_OBJECT *obj)
Definition: Grid.h:112
float GetPositionY() const
Definition: Position.h:105
uint32_t uint32
Definition: Define.h:150
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void AddWorldObject(WorldObject *obj)
Definition: Map.h:427
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
bool IsPermanentWorldObject() const
Definition: Object.h:584
void AddWorldObject(SPECIFIC_OBJECT *obj)
Definition: Grid.h:59

+ Here is the call graph for this function:

template<>
void Map::SwitchGridContainers ( GameObject obj,
bool  on 
)
370 {
373  if (!p.IsCoordValid())
374  {
375  TC_LOG_ERROR("maps", "Map::SwitchGridContainers: Object %s has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUID().ToString().c_str(), obj->GetPositionX(), obj->GetPositionY(), p.x_coord, p.y_coord);
376  return;
377  }
378 
379  Cell cell(p);
380  if (!IsGridLoaded(GridCoord(cell.data.Part.grid_x, cell.data.Part.grid_y)))
381  return;
382 
383  if (sLog->ShouldLog("maps", LOG_LEVEL_DEBUG))
384  {
385  // Extract bitfield values
386  uint32 const grid_x = cell.data.Part.grid_x;
387  uint32 const grid_y = cell.data.Part.grid_y;
388 
389  TC_LOG_DEBUG("maps", "Switch object %s from grid[%u, %u] %u", obj->GetGUID().ToString().c_str(), grid_x, grid_y, on);
390  }
391 
392  NGridType *ngrid = getNGrid(cell.GridX(), cell.GridY());
393  ASSERT(ngrid != NULL);
394 
395  GridType &grid = ngrid->GetGridType(cell.CellX(), cell.CellY());
396 
397  obj->RemoveFromGrid(); //This step is not really necessary but we want to do ASSERT in remove/add
398 
399  if (on)
400  {
401  grid.AddWorldObject(obj);
402  AddWorldObject(obj);
403  }
404  else
405  {
406  grid.AddGridObject(obj);
407  RemoveWorldObject(obj);
408  }
409 }
Definition: NGrid.h:77
void RemoveFromGrid()
Definition: Object.h:362
Definition: Appender.h:35
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
arena_t NULL
Definition: jemalloc_internal.h:624
#define sLog
Definition: Log.h:154
Definition: Grid.h:46
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:428
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
GridType & GetGridType(const uint32 x, const uint32 y)
Definition: NGrid.h:86
void AddGridObject(SPECIFIC_OBJECT *obj)
Definition: Grid.h:112
float GetPositionY() const
Definition: Position.h:105
uint32_t uint32
Definition: Define.h:150
Definition: Cell.h:49
ObjectGuid const & GetGUID() const
Definition: Object.h:105
#define ASSERT
Definition: Errors.h:55
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
void AddWorldObject(WorldObject *obj)
Definition: Map.h:427
float GetPositionX() const
Definition: Position.h:104
std::string ToString() const
Definition: ObjectGuid.cpp:99
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
bool IsPermanentWorldObject() const
Definition: Object.h:584
void AddWorldObject(SPECIFIC_OBJECT *obj)
Definition: Grid.h:59

+ Here is the call graph for this function:

template<class T >
void Map::SwitchGridContainers ( T *  obj,
bool  on 
)
321 { }
BattlegroundMap* Map::ToBattlegroundMap ( )
inline
498 { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap*>(this); else return NULL; }
bool IsBattlegroundOrArena() const
Definition: Map.h:403
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Map.h:790

+ Here is the caller graph for this function:

BattlegroundMap const* Map::ToBattlegroundMap ( ) const
inline
499 { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return NULL; }
bool IsBattlegroundOrArena() const
Definition: Map.h:403
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: Map.h:790
#define const
Definition: zconf.h:217
InstanceMap* Map::ToInstanceMap ( )
inline
495 { if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsDungeon() const
Definition: Map.h:395
Definition: Map.h:758

+ Here is the caller graph for this function:

InstanceMap const* Map::ToInstanceMap ( ) const
inline
496 { if (IsDungeon()) return reinterpret_cast<InstanceMap const*>(this); return NULL; }
arena_t NULL
Definition: jemalloc_internal.h:624
bool IsDungeon() const
Definition: Map.h:395
Definition: Map.h:758
#define const
Definition: zconf.h:217
MapInstanced* Map::ToMapInstanced ( )
inline
492 { if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); return NULL; }
Definition: MapInstanced.h:28
arena_t NULL
Definition: jemalloc_internal.h:624
bool Instanceable() const
Definition: Map.h:394

+ Here is the caller graph for this function:

MapInstanced const* Map::ToMapInstanced ( ) const
inline
493 { if (Instanceable()) return reinterpret_cast<MapInstanced const*>(this); return NULL; }
Definition: MapInstanced.h:28
arena_t NULL
Definition: jemalloc_internal.h:624
bool Instanceable() const
Definition: Map.h:394
#define const
Definition: zconf.h:217
void Map::UnloadAll ( )
virtual

Reimplemented in InstanceMap, and MapInstanced.

1615 {
1616  // clear all delayed moves, useless anyway do this moves before map unload.
1617  _creaturesToMove.clear();
1618  _gameObjectsToMove.clear();
1619 
1621  {
1622  NGridType &grid(*i->GetSource());
1623  ++i;
1624  UnloadGrid(grid, true); // deletes the grid and removes it from the GridRefManager
1625  }
1626 
1627  for (TransportsContainer::iterator itr = _transports.begin(); itr != _transports.end();)
1628  {
1629  Transport* transport = *itr;
1630  ++itr;
1631 
1632  RemoveFromMap<Transport>(transport, true);
1633  }
1634 
1635  for (auto& cellCorpsePair : _corpsesByCell)
1636  {
1637  for (Corpse* corpse : cellCorpsePair.second)
1638  {
1639  corpse->RemoveFromWorld();
1640  corpse->ResetMap();
1641  delete corpse;
1642  }
1643  }
1644 
1645  _corpsesByCell.clear();
1646  _corpsesByPlayer.clear();
1647  _corpseBones.clear();
1648 }
Definition: NGrid.h:77
virtual void ResetMap()
Definition: Object.cpp:2187
std::vector< GameObject * > _gameObjectsToMove
Definition: Map.h:604
Definition: Corpse.h:49
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition: Map.h:742
TransportsContainer _transports
Definition: Map.h:658
void RemoveFromWorld() override
Definition: Corpse.cpp:53
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition: Map.h:741
Definition: Transport.h:28
Definition: GridReference.h:25
std::unordered_set< Corpse * > _corpseBones
Definition: Map.h:743
bool UnloadGrid(NGridType &ngrid, bool pForce)
Definition: Map.cpp:1518
iterator end()
Definition: GridRefManager.h:37
std::vector< Creature * > _creaturesToMove
Definition: Map.h:601

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Map::UnloadGrid ( NGridType ngrid,
bool  pForce 
)
1519 {
1520  const uint32 x = ngrid.getX();
1521  const uint32 y = ngrid.getY();
1522 
1523  {
1524  if (!unloadAll)
1525  {
1526  //pets, possessed creatures (must be active), transport passengers
1527  if (ngrid.GetWorldObjectCountInNGrid<Creature>())
1528  return false;
1529 
1530  if (ActiveObjectsNearGrid(ngrid))
1531  return false;
1532  }
1533 
1534  TC_LOG_DEBUG("maps", "Unloading grid[%u, %u] for map %u", x, y, GetId());
1535 
1536  if (!unloadAll)
1537  {
1538  // Finish creature moves, remove and delete all creatures with delayed remove before moving to respawn grids
1539  // Must know real mob position before move
1542 
1543  // move creatures to respawn grids if this is diff.grid or to remove list
1544  ObjectGridEvacuator worker;
1546  ngrid.VisitAllGrids(visitor);
1547 
1548  // Finish creature moves, remove and delete all creatures with delayed remove before unload
1551  }
1552 
1553  {
1554  ObjectGridCleaner worker;
1556  ngrid.VisitAllGrids(visitor);
1557  }
1558 
1560 
1561  {
1562  ObjectGridUnloader worker;
1564  ngrid.VisitAllGrids(visitor);
1565  }
1566 
1567  ASSERT(i_objectsToRemove.empty());
1568 
1569  delete &ngrid;
1570  setNGrid(NULL, x, y);
1571  }
1572  int gx = (MAX_NUMBER_OF_GRIDS - 1) - x;
1573  int gy = (MAX_NUMBER_OF_GRIDS - 1) - y;
1574 
1575  // delete grid map, but don't delete if it is from parent map (and thus only reference)
1576  //+++if (GridMaps[gx][gy]) don't check for GridMaps[gx][gy], we might have to unload vmaps
1577  {
1578  if (i_InstanceId == 0)
1579  {
1580  if (GridMaps[gx][gy])
1581  {
1582  GridMaps[gx][gy]->unloadData();
1583  delete GridMaps[gx][gy];
1584  }
1587  }
1588  else
1589  ((MapInstanced*)m_parentMap)->RemoveGridMapReference(GridCoord(gx, gy));
1590 
1591  GridMaps[gx][gy] = NULL;
1592  }
1593  TC_LOG_DEBUG("maps", "Unloading grid[%u, %u] for map %u finished", x, y, GetId());
1594  return true;
1595 }
Definition: MapInstanced.h:28
virtual void unloadMap(unsigned int pMapId, int x, int y)=0
std::set< WorldObject * > i_objectsToRemove
Definition: Map.h:686
Definition: TypeContainerVisitor.h:32
Map * m_parentMap
Definition: Map.h:675
void unloadData()
Definition: Map.cpp:1734
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
arena_t NULL
Definition: jemalloc_internal.h:624
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: Creature.h:467
bool ActiveObjectsNearGrid(NGridType const &ngrid) const
Definition: Map.cpp:2920
void RemoveAllObjectsInRemoveList()
Definition: Map.cpp:2831
bool unloadMap(uint32 mapId, int32 x, int32 y)
Definition: MMapManager.cpp:289
GridMap * GridMaps[MAX_NUMBER_OF_GRIDS][MAX_NUMBER_OF_GRIDS]
Definition: Map.h:678
uint32 GetWorldObjectCountInNGrid() const
Definition: NGrid.h:174
uint32 GetId(void) const
Definition: Map.h:325
void setNGrid(NGridType *grid, uint32 x, uint32 y)
Definition: Map.cpp:2743
void VisitAllGrids(TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition: NGrid.h:146
Definition: ObjectGridLoader.h:76
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: ObjectGridLoader.h:67
int32 getY() const
Definition: NGrid.h:103
int32 getX() const
Definition: NGrid.h:102
Definition: ObjectGridLoader.h:83
void MoveAllGameObjectsInMoveList()
Definition: Map.cpp:1197
void MoveAllCreaturesInMoveList()
Definition: Map.cpp:1141
uint32 i_InstanceId
Definition: Map.h:642
static IVMapManager * createOrGetVMapManager()
Definition: VMapFactory.cpp:28
#define ASSERT
Definition: Errors.h:55
static MMapManager * createOrGetMMapManager()
Definition: MMapFactory.cpp:28
G3D::int16 x
Definition: Vector2int16.h:37
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::Update ( const uint32  t_diff)
virtual

update worldsessions for existing players

update active cells around players and active objects

  • Process necessary scripts

Reimplemented in InstanceMap, and MapInstanced.

683 {
684  _dynamicTree.update(t_diff);
687  {
688  Player* player = m_mapRefIter->GetSource();
689  if (player && player->IsInWorld())
690  {
691  //player->Update(t_diff);
692  WorldSession* session = player->GetSession();
693  MapSessionFilter updater(session);
694  session->Update(t_diff, updater);
695  }
696  }
699 
700  Trinity::ObjectUpdater updater(t_diff);
701  // for creature
703  // for pets
705 
706  // the player iterator is stored in the map object
707  // to make sure calls to Map::Remove don't invalidate it
709  {
710  Player* player = m_mapRefIter->GetSource();
711 
712  if (!player || !player->IsInWorld())
713  continue;
714 
715  // update players at tick
716  player->Update(t_diff);
717 
718  VisitNearbyCellsOf(player, grid_object_update, world_object_update);
719 
720  // Handle updates for creatures in combat with player and are more than 60 yards away
721  if (player->IsInCombat())
722  {
723  std::vector<Creature*> updateList;
724  HostileReference* ref = player->getHostileRefManager().getFirst();
725 
726  while (ref)
727  {
728  if (Unit* unit = ref->GetSource()->GetOwner())
729  if (unit->ToCreature() && unit->GetMapId() == player->GetMapId() && !unit->IsWithinDistInMap(player, GetVisibilityRange(), false))
730  updateList.push_back(unit->ToCreature());
731 
732  ref = ref->next();
733  }
734 
735  // Process deferred update list for player
736  for (Creature* c : updateList)
737  VisitNearbyCellsOf(c, grid_object_update, world_object_update);
738  }
739  }
740 
741  // non-player active objects, increasing iterator in the loop in case of object removal
743  {
746 
747  if (!obj || !obj->IsInWorld())
748  continue;
749 
750  VisitNearbyCellsOf(obj, grid_object_update, world_object_update);
751  }
752 
754  {
757 
758  if (!obj->IsInWorld())
759  continue;
760 
761  obj->Update(t_diff);
762  }
763 
765 
767  if (!m_scriptSchedule.empty())
768  {
769  i_scriptLock = true;
770  ScriptsProcess();
771  i_scriptLock = false;
772  }
773 
776 
777  if (!m_mapRefManager.isEmpty() || !m_activeNonPlayers.empty())
779 
780  sScriptMgr->OnMapUpdate(this, t_diff);
781 }
ScriptScheduleMap m_scriptSchedule
Definition: Map.h:691
Definition: TypeContainerVisitor.h:32
Definition: GridNotifiers.h:162
TransportsContainer _transports
Definition: Map.h:658
void VisitNearbyCellsOf(WorldObject *obj, TypeContainerVisitor< Trinity::ObjectUpdater, GridTypeMapContainer > &gridVisitor, TypeContainerVisitor< Trinity::ObjectUpdater, WorldTypeMapContainer > &worldVisitor)
Definition: Map.cpp:653
virtual void Update(uint32)
Definition: Object.h:430
TransportsContainer::iterator _transportsUpdateIter
Definition: Map.h:659
Definition: Object.h:423
Definition: Creature.h:467
void update(uint32 diff)
Definition: DynamicTree.cpp:142
iterator begin()
Definition: MapRefManager.h:37
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:653
bool i_scriptLock
Definition: Map.h:685
void SendObjectUpdates()
Definition: Map.cpp:2753
void resetMarkedCells()
Definition: Map.h:419
bool Update(uint32 diff, PacketFilter &updater)
Update the WorldSession (triggered by World update)
Definition: WorldSession.cpp:327
HostileReference * next()
Definition: ThreatManager.h:116
Definition: ThreatManager.h:49
bool isEmpty() const
Definition: LinkedList.h:102
float GetVisibilityRange() const
Definition: Map.h:290
DynamicMapTree _dynamicTree
Definition: Map.h:645
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition: Map.h:654
FROM * GetSource() const
Definition: Reference.h:96
void MoveAllGameObjectsInMoveList()
Definition: Map.cpp:1197
void MoveAllCreaturesInMoveList()
Definition: Map.cpp:1141
Unit * GetOwner() const
Definition: ThreatManager.h:228
#define sScriptMgr
Definition: ScriptMgr.h:837
Player session in the World.
Definition: WorldSession.h:882
bool IsInWorld() const
Definition: Object.h:100
MapRefManager::iterator m_mapRefIter
Definition: Map.h:648
Definition: Unit.h:1305
MapRefManager m_mapRefManager
Definition: Map.h:647
void ScriptsProcess()
Process queued scripts.
Definition: MapScripts.cpp:292
Definition: WorldSession.h:854
iterator end()
Definition: MapRefManager.h:38
void ProcessRelocationNotifies(const uint32 diff)
Definition: Map.cpp:795

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::UpdateActiveCells ( const float &  x,
const float &  y,
const uint32  t_diff 
)
private
void Map::UpdateAreaDependentAuras ( )
3969 {
3970  Map::PlayerList const& players = GetPlayers();
3971  for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
3972  if (Player* player = itr->GetSource())
3973  if (player->IsInWorld())
3974  {
3975  player->UpdateAreaDependentAuras(player->GetAreaId());
3976  player->UpdateZoneDependentAuras(player->GetZoneId());
3977  }
3978 }
iterator begin()
Definition: MapRefManager.h:37
Definition: LinkedList.h:141
PlayerList const & GetPlayers() const
Definition: Map.h:433
Definition: MapRefManager.h:26
iterator end()
Definition: MapRefManager.h:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Map::UpdateIteratorBack ( Player player)
3565 {
3566  if (m_mapRefIter == player->GetMapRef())
3568 }
MapRefManager::iterator m_mapRefIter
Definition: Map.h:648
MapReference const * nocheck_prev() const
Definition: MapReference.h:50

+ Here is the call graph for this function:

void Map::UpdateObjectsVisibilityFor ( Player player,
Cell  cell,
CellCoord  cellpair 
)
2658 {
2659  Trinity::VisibleNotifier notifier(*player);
2660 
2661  cell.SetNoCreate();
2664  cell.Visit(cellpair, world_notifier, *this, *player, player->GetSightRange());
2665  cell.Visit(cellpair, grid_notifier, *this, *player, player->GetSightRange());
2666 
2667  // send data
2668  notifier.SendToSelf();
2669 }
Definition: TypeContainerVisitor.h:32
void SetNoCreate()
Definition: Cell.h:79
Definition: GridNotifiers.h:43
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition: CellImpl.h:122

+ Here is the call graph for this function:

void Map::UpdateObjectVisibility ( WorldObject obj,
Cell  cell,
CellCoord  cellpair 
)
2650 {
2651  cell.SetNoCreate();
2652  Trinity::VisibleChangesNotifier notifier(*obj);
2654  cell.Visit(cellpair, player_notifier, *this, *obj, obj->GetVisibilityRange());
2655 }
Definition: TypeContainerVisitor.h:32
float GetVisibilityRange() const
Definition: Object.cpp:1912
void SetNoCreate()
Definition: Cell.h:79
Definition: GridNotifiers.h:55
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition: CellImpl.h:122

+ Here is the call graph for this function:

template<class T , class CONTAINER >
void Map::Visit ( const Cell cell,
TypeContainerVisitor< T, CONTAINER > &  visitor 
)
inline
812 {
813  const uint32 x = cell.GridX();
814  const uint32 y = cell.GridY();
815  const uint32 cell_x = cell.CellX();
816  const uint32 cell_y = cell.CellY();
817 
818  if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y)))
819  {
820  EnsureGridLoaded(cell);
821  getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
822  }
823 }
bool EnsureGridLoaded(Cell const &)
Definition: Map.cpp:481
uint32 CellY() const
Definition: Cell.h:75
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:617
bool IsGridLoaded(float x, float y) const
Definition: Map.h:308
void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition: NGrid.h:155
uint32 CellX() const
Definition: Cell.h:74
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
uint32 GridY() const
Definition: Cell.h:77
bool NoCreate() const
Definition: Cell.h:78
G3D::int16 x
Definition: Vector2int16.h:37
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
uint32 GridX() const
Definition: Cell.h:76

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class NOTIFIER >
void Map::VisitAll ( const float &  x,
const float &  y,
float  radius,
NOTIFIER &  notifier 
)
inline
827 {
829  Cell cell(p);
830  cell.SetNoCreate();
831 
832  TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
833  cell.Visit(p, world_object_notifier, *this, radius, x, y);
834  TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
835  cell.Visit(p, grid_object_notifier, *this, radius, x, y);
836 }
Definition: TypeContainerVisitor.h:32
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class NOTIFIER >
void Map::VisitFirstFound ( const float &  x,
const float &  y,
float  radius,
NOTIFIER &  notifier 
)
inline
841 {
843  Cell cell(p);
844  cell.SetNoCreate();
845 
846  TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
847  cell.Visit(p, world_object_notifier, *this, radius, x, y);
848  if (!notifier.i_object)
849  {
850  TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
851  cell.Visit(p, grid_object_notifier, *this, radius, x, y);
852  }
853 }
Definition: TypeContainerVisitor.h:32
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class NOTIFIER >
void Map::VisitGrid ( const float &  x,
const float &  y,
float  radius,
NOTIFIER &  notifier 
)
inline
868 {
870  Cell cell(p);
871  cell.SetNoCreate();
872 
873  TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
874  cell.Visit(p, grid_object_notifier, *this, radius, x, y);
875 }
Definition: TypeContainerVisitor.h:32
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

void Map::VisitNearbyCellsOf ( WorldObject obj,
TypeContainerVisitor< Trinity::ObjectUpdater, GridTypeMapContainer > &  gridVisitor,
TypeContainerVisitor< Trinity::ObjectUpdater, WorldTypeMapContainer > &  worldVisitor 
)
654 {
655  // Check for valid position
656  if (!obj->IsPositionValid())
657  return;
658 
659  // Update mobs/objects in ALL visible cells around object!
661 
662  for (uint32 x = area.low_bound.x_coord; x <= area.high_bound.x_coord; ++x)
663  {
664  for (uint32 y = area.low_bound.y_coord; y <= area.high_bound.y_coord; ++y)
665  {
666  // marked cells are those that have been visited
667  // don't visit the same cell twice
668  uint32 cell_id = (y * TOTAL_NUMBER_OF_CELLS_PER_MAP) + x;
669  if (isCellMarked(cell_id))
670  continue;
671 
672  markCell(cell_id);
673  CellCoord pair(x, y);
674  Cell cell(pair);
675  cell.SetNoCreate();
676  Visit(cell, gridVisitor);
677  Visit(cell, worldVisitor);
678  }
679  }
680 }
float GetGridActivationRange() const
Definition: Object.cpp:1902
bool isCellMarked(uint32 pCellId)
Definition: Map.h:420
uint32 y_coord
Definition: GridDefines.h:156
static CellArea CalculateCellArea(float x, float y, float radius)
Definition: CellImpl.h:49
uint32 x_coord
Definition: GridDefines.h:155
#define TOTAL_NUMBER_OF_CELLS_PER_MAP
Definition: GridDefines.h:52
void markCell(uint32 pCellId)
Definition: Map.h:421
Definition: Cell.h:32
float GetPositionY() const
Definition: Position.h:105
CellCoord low_bound
Definition: Cell.h:45
uint32_t uint32
Definition: Define.h:150
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
void Visit(const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
Definition: Map.h:811
CellCoord high_bound
Definition: Cell.h:46
bool IsPositionValid() const
Definition: Position.cpp:40
G3D::int16 x
Definition: Vector2int16.h:37
float GetPositionX() const
Definition: Position.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class NOTIFIER >
void Map::VisitWorld ( const float &  x,
const float &  y,
float  radius,
NOTIFIER &  notifier 
)
inline
857 {
859  Cell cell(p);
860  cell.SetNoCreate();
861 
862  TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
863  cell.Visit(p, world_object_notifier, *this, radius, x, y);
864 }
Definition: TypeContainerVisitor.h:32
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:193
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Cell.h:49
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

Friends And Related Function Documentation

friend class MapReference
friend

Member Data Documentation

std::unordered_set<Corpse*> Map::_corpseBones
private
std::unordered_map<uint32, std::unordered_set<Corpse*> > Map::_corpsesByCell
private
std::unordered_map<ObjectGuid, Corpse*> Map::_corpsesByPlayer
private
CreatureBySpawnIdContainer Map::_creatureBySpawnIdStore
private
std::unordered_map<ObjectGuid::LowType , time_t> Map::_creatureRespawnTimes
private
std::vector<Creature*> Map::_creaturesToMove
private
bool Map::_creatureToMoveLock
private
uint32 Map::_defaultLight
private
std::vector<DynamicObject*> Map::_dynamicObjectsToMove
private
bool Map::_dynamicObjectsToMoveLock
private
DynamicMapTree Map::_dynamicTree
protected
GameObjectBySpawnIdContainer Map::_gameobjectBySpawnIdStore
private
std::vector<GameObject*> Map::_gameObjectsToMove
private
bool Map::_gameObjectsToMoveLock
private
std::unordered_map<ObjectGuid::LowType , time_t> Map::_goRespawnTimes
private
std::mutex Map::_gridLock
protected
std::map<HighGuid, std::unique_ptr<ObjectGuidGeneratorBase> > Map::_guidGenerators
private
std::mutex Map::_mapLock
protected
MapStoredObjectTypesContainer Map::_objectsStore
private
TransportsContainer Map::_transports
protected
TransportsContainer::iterator Map::_transportsUpdateIter
protected
std::unordered_set<Object*> Map::_updateObjects
private
ZoneDynamicInfoMap Map::_zoneDynamicInfo
private
CreatureGroupHolderType Map::CreatureGroupHolder
time_t Map::i_gridExpiry
private
uint32 Map::i_InstanceId
protected
MapEntry const* Map::i_mapEntry
protected
std::set<WorldObject*> Map::i_objectsToRemove
private
std::map<WorldObject*, bool> Map::i_objectsToSwitch
private
bool Map::i_scriptLock
private
uint8 Map::i_spawnMode
protected
std::set<WorldObject*> Map::i_worldObjects
private
ActiveNonPlayers Map::m_activeNonPlayers
protected
ActiveNonPlayers::iterator Map::m_activeNonPlayersIter
protected
MapRefManager::iterator Map::m_mapRefIter
protected
MapRefManager Map::m_mapRefManager
protected
Map* Map::m_parentMap
private
ScriptScheduleMap Map::m_scriptSchedule
private
uint32 Map::m_unloadTimer
protected
int32 Map::m_VisibilityNotifyPeriod
protected
float Map::m_VisibleDistance
protected
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> Map::marked_cells
private

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