69namespace Trinity {
struct ObjectUpdater; }
71namespace G3D {
class Plane; }
106#define MAP_AREA_NO_AREA 0x0001
115#define MAP_HEIGHT_NO_HEIGHT 0x0001
116#define MAP_HEIGHT_AS_INT16 0x0002
117#define MAP_HEIGHT_AS_INT8 0x0004
118#define MAP_HEIGHT_HAS_FLIGHT_BOUNDS 0x0008
128#define MAP_LIQUID_NO_TYPE 0x0001
129#define MAP_LIQUID_NO_HEIGHT 0x0002
144#define MAP_LIQUID_TYPE_NO_WATER 0x00
145#define MAP_LIQUID_TYPE_WATER 0x01
146#define MAP_LIQUID_TYPE_OCEAN 0x02
147#define MAP_LIQUID_TYPE_MAGMA 0x04
148#define MAP_LIQUID_TYPE_SLIME 0x08
150#define MAP_ALL_LIQUIDS (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)
152#define MAP_LIQUID_TYPE_DARK_WATER 0x10
190 bool loadAreaData(FILE* in,
uint32 offset,
uint32 size);
191 bool loadHeightData(FILE* in,
uint32 offset,
uint32 size);
192 bool loadLiquidData(FILE* in,
uint32 offset,
uint32 size);
193 bool loadHolesData(FILE* in,
uint32 offset,
uint32 size);
194 bool isHole(
int row,
int col)
const;
197 typedef float (
GridMap::*GetHeightPtr) (float x, float y) const;
199 float getHeightFromFloat(
float x,
float y)
const;
200 float getHeightFromUint16(
float x,
float y)
const;
201 float getHeightFromUint8(
float x,
float y)
const;
202 float getHeightFromFlat(
float x,
float y)
const;
207 bool loadData(
char const* filename);
210 uint16 getArea(
float x,
float y)
const;
211 inline float getHeight(
float x,
float y)
const {
return (this->*_gridGetHeight)(x, y);}
212 float getMinHeight(
float x,
float y)
const;
213 float getLiquidLevel(
float x,
float y)
const;
240#define MAX_HEIGHT 100000.0f
241#define INVALID_HEIGHT -100000.0f
242#define MAX_FALL_DISTANCE 250000.0f
243#define DEFAULT_HEIGHT_SEARCH 50.0f
244#define MIN_UNLOAD_DELAY 1
245#define MAP_INVALID_ZONE 0xFFFFFFFF
295 if (m_unloadTimer <= diff)
298 m_unloadTimer -= diff;
302 virtual bool AddPlayerToMap(
Player*);
303 virtual void RemovePlayerFromMap(
Player*,
bool);
305 template<
class T>
bool AddToMap(T *);
306 template<
class T>
void RemoveFromMap(T *,
bool);
309 virtual void Update(
uint32);
313 virtual void InitVisibilityDistance();
315 void PlayerRelocation(
Player*,
float x,
float y,
float z,
float orientation);
316 void CreatureRelocation(
Creature* creature,
float x,
float y,
float z,
float ang,
bool respawnRelocationOnFail =
true);
317 void GameObjectRelocation(
GameObject* go,
float x,
float y,
float z,
float orientation,
bool respawnRelocationOnFail =
true);
318 void DynamicObjectRelocation(
DynamicObject* go,
float x,
float y,
float z,
float orientation);
320 template<
class T,
class CONTAINER>
336 void LoadGrid(
float x,
float y);
338 bool UnloadGrid(
NGridType& ngrid,
bool pForce);
341 virtual void UnloadAll();
351 static bool ExistMap(
uint32 mapid,
int gx,
int gy);
352 static bool ExistVMap(
uint32 mapid,
int gx,
int gy);
354 static void InitStateMachine();
355 static void DeleteStateMachine();
362 bool GetAreaInfo(
uint32 phaseMask,
float x,
float y,
float z,
uint32& mogpflags,
int32& adtId,
int32& rootId,
int32& groupId)
const;
363 uint32 GetAreaId(
uint32 phaseMask,
float x,
float y,
float z)
const;
365 uint32 GetZoneId(
uint32 phaseMask,
float x,
float y,
float z)
const;
367 void GetZoneAndAreaId(
uint32 phaseMask,
uint32& zoneid,
uint32& areaid,
float x,
float y,
float z)
const;
370 float GetWaterLevel(
float x,
float y)
const;
371 bool IsInWater(
uint32 phaseMask,
float x,
float y,
float z,
LiquidData* data =
nullptr)
const;
372 bool IsUnderWater(
uint32 phaseMask,
float x,
float y,
float z)
const;
374 void MoveAllCreaturesInMoveList();
375 void MoveAllGameObjectsInMoveList();
376 void MoveAllDynamicObjectsInMoveList();
377 void RemoveAllObjectsInRemoveList();
378 virtual void RemoveAllPlayers();
381 bool CreatureRespawnRelocation(
Creature* c,
bool diffGridOnly);
382 bool GameObjectRespawnRelocation(
GameObject* go,
bool diffGridOnly);
385 bool CheckGridIntegrity(
Creature* c,
bool moved)
const;
396 CANNOT_ENTER_ALREADY_IN_MAP = 1,
406 CANNOT_ENTER_UNSPECIFIED_REASON
409 char const* GetMapName()
const;
413 bool IsRegularDifficulty()
const;
416 bool Instanceable()
const;
417 bool IsWorldMap()
const;
418 bool IsDungeon()
const;
419 bool IsNonRaidDungeon()
const;
421 bool IsRaidOrHeroicDungeon()
const;
422 bool IsHeroic()
const;
423 bool Is25ManRaid()
const;
424 bool IsBattleground()
const;
425 bool IsBattleArena()
const;
426 bool IsBattlegroundOrArena()
const;
427 bool GetEntrancePos(
int32& mapid,
float& x,
float& y)
const;
430 void AddObjectToSwitchList(
WorldObject* obj,
bool on);
431 virtual void DelayedUpdate(
uint32 diff);
438 uint32 GetPlayersCountExceptGMs()
const;
439 bool ActiveObjectsNearGrid(
NGridType const& ngrid)
const;
451 void ScriptsStart(std::map<
uint32, std::multimap<uint32, ScriptInfo>>
const& scripts,
uint32 id,
Object* source,
Object* target);
460 template<
class T>
void SwitchGridContainers(T* obj,
bool on);
463 void UpdateIteratorBack(
Player* player);
466 void SummonCreatureGroup(
uint8 group, std::list<TempSummon*>* list =
nullptr);
478 return reinterpret_cast<WorldObject*
>(GetCreatureBySpawnId(spawnId));
480 return reinterpret_cast<WorldObject*
>(GetGameObjectBySpawnId(spawnId));
501 auto itr = _corpsesByCell.find(cellId);
502 if (itr != _corpsesByCell.end())
510 auto itr = _corpsesByPlayer.find(ownerGuid);
511 if (itr != _corpsesByPlayer.end())
526 float GetWaterOrGroundLevel(
uint32 phasemask,
float x,
float y,
float z,
float* ground =
nullptr,
bool swim =
false,
float collisionHeight = 2.03128f)
const;
527 float GetMinHeight(
float x,
float y)
const;
528 float GetHeight(
float x,
float y,
float z,
bool checkVMap =
true,
float maxSearchDist =
DEFAULT_HEIGHT_SEARCH)
const;
529 float GetGridHeight(
float x,
float y)
const;
531 float GetHeight(
uint32 phasemask,
float x,
float y,
float z,
bool vmap =
true,
float maxSearchDist =
DEFAULT_HEIGHT_SEARCH)
const {
return std::max<float>(
GetHeight(x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phasemask, x, y, z, maxSearchDist)); }
540 return _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
542 bool getObjectHitPos(
uint32 phasemask,
float x1,
float y1,
float z1,
float x2,
float y2,
float z2,
float& rx,
float &ry,
float& rz,
float modifyDist);
547 time_t GetLinkedRespawnTime(
ObjectGuid guid)
const;
550 auto const& map = GetRespawnMapForType(type);
551 auto it = map.find(spawnId);
552 return (it == map.end()) ? 0 : it->second->respawnTime;
557 void UpdatePlayerZoneStats(
uint32 oldZone,
uint32 newZone);
561 void LoadRespawnTimes();
562 void DeleteRespawnTimes() { UnloadAllRespawnInfos(); DeleteRespawnTimesInDB(GetId(), GetInstanceId()); }
563 static void DeleteRespawnTimesInDB(
uint16 mapId,
uint32 instanceId);
565 void LoadCorpseData();
566 void DeleteCorpseData();
567 void AddCorpse(
Corpse* corpse);
568 void RemoveCorpse(
Corpse* corpse);
569 Corpse* ConvertCorpseToBones(
ObjectGuid const& ownerGuid,
bool insignia =
false);
570 void RemoveOldCorpses();
572 void SendInitTransports(
Player* player);
573 void SendRemoveTransports(
Player* player);
574 void SendZoneDynamicInfo(
uint32 zoneId,
Player* player)
const;
575 void SendZoneWeather(
uint32 zoneId,
Player* player)
const;
584 void UpdateAreaDependentAuras();
586 template<HighGu
id high>
590 return GetGuidSequenceGenerator(high).Generate();
593 template<HighGu
id high>
597 return GetGuidSequenceGenerator(high).GetNextAfterMaxUsed();
602 _updateObjects.insert(obj);
607 _updateObjects.erase(obj);
612 return m_activeNonPlayers.size();
618 void LoadMapAndVMap(
int gx,
int gy);
619 void LoadVMap(
int gx,
int gy);
620 void LoadMap(
int gx,
int gy,
bool reload =
false);
621 void LoadMMap(
int gx,
int gy);
622 GridMap* GetGrid(
float x,
float y);
626 void SendInitSelf(
Player* player);
628 bool CreatureCellRelocation(
Creature* creature,
Cell new_cell);
632 template<
class T>
void InitializeObject(T* obj);
633 void AddCreatureToMoveList(
Creature* c,
float x,
float y,
float z,
float ang);
634 void RemoveCreatureFromMoveList(
Creature* c);
635 void AddGameObjectToMoveList(
GameObject* go,
float x,
float y,
float z,
float ang);
636 void RemoveGameObjectFromMoveList(
GameObject* go);
637 void AddDynamicObjectToMoveList(
DynamicObject* go,
float x,
float y,
float z,
float ang);
649 bool IsGridLoaded(
GridCoord const&)
const;
650 void EnsureGridCreated(
GridCoord const&);
651 void EnsureGridCreated_i(
GridCoord const&);
652 bool EnsureGridLoaded(
Cell const&);
653 void EnsureGridLoadedForActiveObject(
Cell const&,
WorldObject*
object);
660 return i_grids[x][y];
664 void ScriptsProcess();
666 void SendObjectUpdates();
715 std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP>
marked_cells;
719 void ProcessRelocationNotifies(
const uint32 diff);
730 void ProcessRespawns();
740 void UnloadAllRespawnInfos();
747 void GetRespawnInfo(std::vector<RespawnInfo const*>& respawnData,
SpawnObjectTypeMask types)
const;
750 if (
RespawnInfo* info = GetRespawnInfo(type, spawnId))
751 Respawn(info, dbTrans);
755 if (
RespawnInfo* info = GetRespawnInfo(type, spawnId))
756 DeleteRespawnInfo(info, dbTrans);
758 else if (alwaysDeleteFromDB)
759 DeleteRespawnInfoFromDB(type, spawnId, dbTrans);
768 bool IsSpawnGroupActive(
uint32 groupId)
const;
772 bool SpawnGroupSpawn(
uint32 groupId,
bool ignoreRespawn =
false,
bool force =
false, std::vector<WorldObject*>* spawnedObjects =
nullptr);
775 bool SpawnGroupDespawn(
uint32 groupId,
bool deleteRespawnTimes =
false,
size_t* count =
nullptr);
787 void AddToGrid(T*
object,
Cell const& cell);
790 void DeleteFromWorld(T*);
794 m_activeNonPlayers.insert(obj);
800 if (m_activeNonPlayersIter != m_activeNonPlayers.end())
802 ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
803 if (itr == m_activeNonPlayers.end())
805 if (itr == m_activeNonPlayersIter)
806 ++m_activeNonPlayersIter;
807 m_activeNonPlayers.erase(itr);
810 m_activeNonPlayers.erase(obj);
823 return _creatureRespawnTimesBySpawnId;
825 return _gameObjectRespawnTimesBySpawnId;
835 return _creatureRespawnTimesBySpawnId;
837 return _gameObjectRespawnTimesBySpawnId;
841 void SetSpawnGroupActive(
uint32 groupId,
bool state);
880 bool AddPlayerToMap(
Player*)
override;
881 void RemovePlayerFromMap(
Player*,
bool)
override;
882 void Update(
uint32)
override;
883 void CreateInstanceData(
bool load);
884 bool Reset(
uint8 method);
886 std::string
const& GetScriptName()
const;
889 void PermBindAllPlayers();
890 void UnloadAll()
override;
891 EnterState CannotEnter(
Player* player)
override;
892 void SendResetWarnings(
uint32 timeLeft)
const;
893 void SetResetSchedule(
bool on);
897 bool HasPermBoundPlayers()
const;
898 uint32 GetMaxPlayers()
const;
899 uint32 GetMaxResetDelay()
const;
903 virtual void InitVisibilityDistance()
override;
920 bool AddPlayerToMap(
Player*)
override;
921 void RemovePlayerFromMap(
Player*,
bool)
override;
925 void RemoveAllPlayers()
override;
927 virtual void InitVisibilityDistance()
override;
934template<
class T,
class CONTAINER>
947 grid->
VisitGrid(cell_x, cell_y, visitor);
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
std::string GetDebugInfo()
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
#define MAX_NUMBER_OF_GRIDS
std::conditional_t< IntrusiveLink !=nullptr, Trinity::Impl::MPSCQueueIntrusive< T, IntrusiveLink >, Trinity::Impl::MPSCQueueNonIntrusive< T > > MPSCQueue
#define DEFAULT_HEIGHT_SEARCH
std::unordered_map< ObjectGuid::LowType, RespawnInfo * > RespawnInfoMap
@ INSTANCE_RESET_GROUP_DISBAND
@ INSTANCE_RESET_GROUP_JOIN
@ INSTANCE_RESET_CHANGE_DIFFICULTY
@ INSTANCE_RESET_RESPAWN_DELAY
std::unordered_map< uint32, ZoneDynamicInfo > ZoneDynamicInfoMap
TypeUnorderedMapContainer< AllMapStoredObjectTypes, ObjectGuid > MapStoredObjectTypesContainer
std::optional< T > Optional
Optional helper class to wrap optional values within.
bool isHole(int holes, int i, int j)
void SetBG(Battleground *bg)
uint16 _liquidGlobalEntry
float _gridIntHeightMultiplier
G3D::Plane * _minHeightPlanes
float getHeight(float x, float y) const
GetHeightPtr _gridGetHeight
InstanceScript const * GetInstanceScript() const
TeamId GetTeamIdInInstance() const
uint32 GetScriptId() const
Team GetTeamInInstance() const
InstanceScript * GetInstanceScript()
MapEntry const * i_mapEntry
uint32 GetZoneId(uint32 phaseMask, Position const &pos) const
float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
std::map< WorldObject *, bool > i_objectsToSwitch
WorldObject * GetWorldObjectBySpawnId(SpawnObjectType type, ObjectGuid::LowType spawnId) const
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
std::vector< Creature * > _creaturesToMove
void GetZoneAndAreaId(uint32 phaseMask, uint32 &zoneid, uint32 &areaid, Position const &pos) const
CreatureBySpawnIdContainer const & GetCreatureBySpawnIdStore() const
bool IsRemovalGrid(Position const &pos) const
void SetSpawnGroupInactive(uint32 groupId)
std::unordered_set< Corpse * > const * GetCorpsesInCell(uint32 cellId) const
std::unordered_multimap< ObjectGuid::LowType, Creature * > CreatureBySpawnIdContainer
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
void SetWeakPtr(Trinity::unique_weak_ptr< Map > weakRef)
bool ShouldBeSpawnedOnGridLoad(ObjectGuid::LowType spawnId) const
MapStoredObjectTypesContainer & GetObjectsStore()
TransportsContainer::iterator _transportsUpdateIter
InstanceMap const * ToInstanceMap() const
void RemoveFromActiveHelper(WorldObject *obj)
std::function< void(Map *)> FarSpellCallback
bool GetUnloadLock(GridCoord const &p) const
void RemoveGameObjectModel(GameObjectModel const &model)
void DeleteRespawnTimes()
void RemoveUpdateObject(Object *obj)
RespawnInfoMap _gameObjectRespawnTimesBySpawnId
bool IsGridLoaded(Position const &pos) const
uint8 GetSpawnMode() const
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
BattlegroundMap const * ToBattlegroundMap() const
bool CanUnload(uint32 diff)
IntervalTimer _weatherUpdateTimer
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr, bool alwaysDeleteFromDB=false)
bool _dynamicObjectsToMoveLock
NGridType * getNGrid(uint32 x, uint32 y) const
void AddToActiveHelper(WorldObject *obj)
bool _gameObjectsToMoveLock
bool ContainsGameObjectModel(GameObjectModel const &model) const
Map const * GetParent() const
float GetHeight(uint32 phasemask, Position const &pos, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
uint32 _respawnCheckTimer
bool IsRemovalGrid(float x, float y) const
MapInstanced const * ToMapInstanced() const
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
MapRefManager m_mapRefManager
RespawnInfoMap const & GetRespawnMapForType(SpawnObjectType type) const
void Visit(Cell const &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
ScriptScheduleMap m_scriptSchedule
ObjectGuid::LowType GetMaxLowGuid()
void AddWorldObject(WorldObject *obj)
void ResetGridExpiry(NGridType &grid, float factor=1) const
DynamicMapTree _dynamicTree
void Respawn(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
std::vector< GameObject * > _gameObjectsToMove
ObjectGuid::LowType GenerateLowGuid()
uint32 GetAreaId(uint32 phaseMask, Position const &pos) const
std::unordered_map< ObjectGuid::LowType, CreatureGroup * > CreatureGroupHolder
int32 m_VisibilityNotifyPeriod
std::unordered_set< Corpse * > _corpseBones
MPSCQueue< FarSpellCallback > _farSpellCallbacks
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
RespawnInfoMap & GetRespawnMapForType(SpawnObjectType type)
std::unordered_set< uint32 > _toggledSpawnGroupIds
bool isCellMarked(uint32 pCellId)
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
BattlegroundMap * ToBattlegroundMap()
Trinity::unique_weak_ptr< Map > m_weakRef
MapRefManager::iterator m_mapRefIter
std::multimap< time_t, ScriptAction > ScriptScheduleMap
std::unique_ptr< RespawnListContainer > _respawnTimes
virtual EnterState CannotEnter(Player *)
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
void SetUnloadReferenceLock(GridCoord const &p, bool on)
ZoneDynamicInfoMap _zoneDynamicInfo
void RemoveWorldObject(WorldObject *obj)
float GetGameObjectFloor(uint32 phasemask, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
std::set< WorldObject * > i_worldObjects
ActiveNonPlayers m_activeNonPlayers
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
void InsertGameObjectModel(GameObjectModel const &model)
void SetUnloadLock(GridCoord const &p, bool on)
std::set< Transport * > TransportsContainer
std::unordered_set< Object * > _updateObjects
void buildNGridLinkage(NGridType *pNGridType)
MapEntry const * GetEntry() const
Trinity::unique_weak_ptr< Map > GetWeakPtr() const
std::set< WorldObject * > i_objectsToRemove
MapStoredObjectTypesContainer _objectsStore
bool IsGridLoaded(float x, float y) const
friend class MapReference
float GetVisibilityRange() const
InstanceMap * ToInstanceMap()
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
bool IsGridLoaded(uint32 gridId) const
Difficulty GetDifficulty() const
std::set< WorldObject * > ActiveNonPlayers
void markCell(uint32 pCellId)
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
time_t GetGridExpiry(void) const
bool EnsureGridLoaded(Cell const &)
std::vector< DynamicObject * > _dynamicObjectsToMove
uint32 GetInstanceId() const
TransportsContainer _transports
PlayerList const & GetPlayers() const
GameObjectBySpawnIdContainer const & GetGameObjectBySpawnIdStore() const
void AddUpdateObject(Object *obj)
MapInstanced * ToMapInstanced()
RespawnInfoMap _creatureRespawnTimesBySpawnId
CreatureBySpawnIdContainer _creatureBySpawnIdStore
@ CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE
@ CANNOT_ENTER_TOO_MANY_INSTANCES
@ CANNOT_ENTER_MAX_PLAYERS
@ CANNOT_ENTER_ZONE_IN_COMBAT
@ CANNOT_ENTER_DIFFICULTY_UNAVAILABLE
@ CANNOT_ENTER_INSTANCE_BIND_MISMATCH
@ CANNOT_ENTER_UNINSTANCED_DUNGEON
@ CANNOT_ENTER_NOT_IN_RAID
ActiveNonPlayers::iterator m_activeNonPlayersIter
std::unordered_multimap< ObjectGuid::LowType, GameObject * > GameObjectBySpawnIdContainer
std::map< HighGuid, std::unique_ptr< ObjectGuidGenerator > > _guidGenerators
float GetHeight(Position const &pos, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
size_t GetActiveNonPlayersCount() const
bool isGridObjectDataLoaded() const
void ResetTimeTracker(time_t interval)
void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
void link(GridRefManager< NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES > > *pTo)
static ObjectGuid const Empty
Trinity::unique_trackable_ptr companion class, replicating what std::weak_ptr is to std::shared_ptr.
Player session in the World.
GridCoord ComputeGridCoord(float x, float y)
bool operator()(RespawnInfo const *a, RespawnInfo const *b) const
float GetPositionZ() const
float GetPositionX() const
float GetPositionY() const
ObjectGuid::LowType spawnId
ScriptInfo const * script
owner of source if source is item
uint32 TransitionMilliseconds
std::vector< LightOverride > LightOverrides
std::unique_ptr< Weather > DefaultWeather
Represents a map magic value of 4 bytes (used in versions)
uint32 asUInt
Non-null terminated string