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