TrinityCore
Loading...
Searching...
No Matches
Map.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_MAP_H
19#define TRINITY_MAP_H
20
21#include "Define.h"
22
23#include "Cell.h"
24#include "DatabaseEnvFwd.h"
25#include "DynamicTree.h"
26#include "GridDefines.h"
27#include "GridRefManager.h"
29#include "MapDefines.h"
30#include "MapReference.h"
31#include "MapRefManager.h"
32#include "MPSCQueue.h"
33#include "ObjectGuid.h"
36#include "SharedDefines.h"
37#include "SpawnData.h"
38#include "Timer.h"
39#include "UniqueTrackablePtr.h"
40#include "WorldStateDefines.h"
41#include <bitset>
42#include <list>
43#include <map>
44#include <memory>
45#include <set>
46#include <unordered_set>
47
48class BaseEntity;
49class Battleground;
50class BattlegroundMap;
52class CreatureGroup;
53class GameObjectModel;
54class Group;
55class InstanceLock;
56class InstanceMap;
57class InstanceScript;
59class Object;
60class PhaseShift;
61class Player;
62class SpawnedPoolData;
63class TempSummon;
64class TerrainInfo;
65class Unit;
66class Weather;
67class WorldObject;
68class WorldPacket;
71struct MapEntry;
72struct Position;
73struct ScriptAction;
74struct ScriptInfo;
79class Transport;
80enum Difficulty : int16;
81enum WeatherState : uint32;
82enum class ItemContext : uint8;
83
84namespace Trinity { struct ObjectUpdater; }
85namespace Vignettes { struct VignetteData; }
86namespace VMAP { enum class ModelIgnoreFlags : uint32; }
87namespace MMAP { class DynamicTileBuilder; }
88
90{
93 TRANSFER_ABORT_MAX_PLAYERS = 2, // Transfer Aborted: instance is full
94 TRANSFER_ABORT_NOT_FOUND = 3, // Transfer Aborted: instance not found
95 TRANSFER_ABORT_TOO_MANY_INSTANCES = 4, // You have entered too many instances recently.
96 TRANSFER_ABORT_ZONE_IN_COMBAT = 6, // Unable to zone in while an encounter is in progress.
97 TRANSFER_ABORT_INSUF_EXPAN_LVL = 7, // You must have <TBC, WotLK> expansion installed to access this area.
98 TRANSFER_ABORT_DIFFICULTY = 8, // <Normal, Heroic, Epic> difficulty mode is not available for %s.
99 TRANSFER_ABORT_UNIQUE_MESSAGE = 9, // Until you've escaped TLK's grasp, you cannot leave this place!
100 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 10, // Additional instances cannot be launched, please try again later.
101 TRANSFER_ABORT_NEED_GROUP = 11, // Transfer Aborted: you must be in a raid group to enter this instance
102 TRANSFER_ABORT_NOT_FOUND_2 = 12, // Transfer Aborted: instance not found
103 TRANSFER_ABORT_NOT_FOUND_3 = 13, // Transfer Aborted: instance not found
104 TRANSFER_ABORT_NOT_FOUND_4 = 14, // Transfer Aborted: instance not found
105 TRANSFER_ABORT_REALM_ONLY = 15, // All players in the party must be from the same realm to enter %s.
106 TRANSFER_ABORT_MAP_NOT_ALLOWED = 16, // Map cannot be entered at this time.
107 TRANSFER_ABORT_LOCKED_TO_DIFFERENT_INSTANCE = 18, // You are already locked to %s
108 TRANSFER_ABORT_ALREADY_COMPLETED_ENCOUNTER = 19, // You are ineligible to participate in at least one encounter in this instance because you are already locked to an instance in which it has been defeated.
109 TRANSFER_ABORT_DIFFICULTY_NOT_FOUND = 22, // client writes to console "Unable to resolve requested difficultyID %u to actual difficulty for map %d"
110 TRANSFER_ABORT_XREALM_ZONE_DOWN = 24, // Transfer Aborted: cross-realm zone is down
111 TRANSFER_ABORT_SOLO_PLAYER_SWITCH_DIFFICULTY = 26, // This instance is already in progress. You may only switch difficulties from inside the instance.
112 TRANSFER_ABORT_NOT_CROSS_FACTION_COMPATIBLE = 33, // This instance isn't available for cross-faction groups
113};
114
116{
117 TransferAbortParams(TransferAbortReason reason, uint8 arg = 0, int32 mapDifficultyXConditionId = 0)
118 : Reason(reason), Arg(arg), MapDifficultyXConditionId(mapDifficultyXConditionId)
119 {
120 }
121
125
126 operator bool() const { return Reason != TRANSFER_ABORT_NONE; }
127};
128
136
155
156#define MIN_UNLOAD_DELAY 1 // immediate unload
157#define MAP_INVALID_ZONE 0xFFFFFFFF
158
159struct RespawnInfo; // forward declaration
161{
162 bool operator()(RespawnInfo const* a, RespawnInfo const* b) const;
163};
164using ZoneDynamicInfoMap = std::unordered_map<uint32 /*zoneId*/, ZoneDynamicInfo>;
166using RespawnInfoMap = std::unordered_map<ObjectGuid::LowType, RespawnInfo*>;
177inline bool CompareRespawnInfo::operator()(RespawnInfo const* a, RespawnInfo const* b) const
178{
179 if (a == b)
180 return false;
181 if (a->respawnTime != b->respawnTime)
182 return (a->respawnTime > b->respawnTime);
183 if (a->spawnId != b->spawnId)
184 return a->spawnId < b->spawnId;
185 ASSERT(a->type != b->type, "Duplicate respawn entry for spawnId (%u," UI64FMTD ") found!", a->type, a->spawnId);
186 return a->type < b->type;
187}
188
189template <typename ObjectType>
191{
192 using Container = std::unordered_map<ObjectGuid, ObjectType*>;
194 using ValueType = ObjectType*;
195
196 static bool Insert(Container& container, ValueType object)
197 {
198 auto [itr, isNew] = container.try_emplace(object->GetGUID(), object);
199 ASSERT(isNew || itr->second == object, "Object with certain key already in but objects are different!");
200 return true;
201 }
202
203 static bool Remove(Container& container, ValueType object)
204 {
205 container.erase(object->GetGUID());
206 return true;
207 }
208
209 static std::size_t Size(Container const& container)
210 {
211 return container.size();
212 }
213
214 static ValueType Find(Container const& container, KeyType const& key)
215 {
216 auto itr = container.find(key);
217 return itr != container.end() ? itr->second : nullptr;
218 }
219};
220
223
225{
226 friend class MapReference;
227 public:
228 Map(uint32 id, time_t, uint32 InstanceId, Difficulty SpawnMode);
229 virtual ~Map();
230
231 MapEntry const* GetEntry() const { return i_mapEntry; }
232
233 // currently unused for normal maps
234 bool CanUnload(uint32 diff)
235 {
236 if (!m_unloadTimer)
237 return false;
238
239 if (m_unloadTimer <= diff)
240 return true;
241
242 m_unloadTimer -= diff;
243 return false;
244 }
245
246 virtual bool AddPlayerToMap(Player* player, bool initPlayer = true);
247 virtual void RemovePlayerFromMap(Player*, bool);
248
249 template<class T> bool AddToMap(T *);
250 template<class T> void RemoveFromMap(T *, bool);
251
253 virtual void Update(uint32);
254
255 float GetVisibilityRange() const { return m_VisibleDistance; }
256 //function for setting up visibility distance for maps on per-type/per-Id basis
257 virtual void InitVisibilityDistance();
258
259 void PlayerRelocation(Player*, float x, float y, float z, float orientation);
260 void CreatureRelocation(Creature* creature, float x, float y, float z, float ang, bool respawnRelocationOnFail = true);
261 void GameObjectRelocation(GameObject* go, float x, float y, float z, float orientation, bool respawnRelocationOnFail = true);
262 void DynamicObjectRelocation(DynamicObject* go, float x, float y, float z, float orientation);
263 void AreaTriggerRelocation(AreaTrigger* at, float x, float y, float z, float orientation);
264
265 template<class T, class CONTAINER>
266 void Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor);
267
268 bool IsRemovalGrid(float x, float y) const
269 {
271 return !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL;
272 }
273 bool IsRemovalGrid(Position const& pos) const { return IsRemovalGrid(pos.GetPositionX(), pos.GetPositionY()); }
274
275 bool IsGridLoaded(uint32 gridId) const { return IsGridLoaded(GridCoord(gridId % MAX_NUMBER_OF_GRIDS, gridId / MAX_NUMBER_OF_GRIDS)); }
276 bool IsGridLoaded(float x, float y) const { return IsGridLoaded(Trinity::ComputeGridCoord(x, y)); }
277 bool IsGridLoaded(Position const& pos) const { return IsGridLoaded(pos.GetPositionX(), pos.GetPositionY()); }
278
279 bool GetUnloadLock(GridCoord const& p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
280 void SetUnloadLock(GridCoord const& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
281 void LoadGrid(float x, float y);
282 void LoadGridForActiveObject(float x, float y, WorldObject const* object);
283 void LoadAllCells();
284 bool UnloadGrid(NGridType& ngrid, bool pForce);
285 void GridMarkNoUnload(uint32 x, uint32 y);
286 void GridUnmarkNoUnload(uint32 x, uint32 y);
287 void UnloadAll();
288
289 void ResetGridExpiry(NGridType &grid, float factor = 1) const
290 {
291 grid.ResetTimeTracker(time_t(float(i_gridExpiry)*factor));
292 }
293
294 time_t GetGridExpiry() const { return i_gridExpiry; }
295
296 static void InitStateMachine();
297 static void DeleteStateMachine();
298
299 TerrainInfo* GetTerrain() const { return m_terrain.get(); }
300
301 // custom PathGenerator include and exclude filter flags
302 // these modify what kind of terrain types are available in current instance
303 // for example this can be used to mark offmesh connections as enabled/disabled
304 uint16 GetForceEnabledNavMeshFilterFlags() const { return m_forceEnabledNavMeshFilterFlags; }
305 void SetForceEnabledNavMeshFilterFlag(uint16 flag) { m_forceEnabledNavMeshFilterFlags |= flag; }
306 void RemoveForceEnabledNavMeshFilterFlag(uint16 flag) { m_forceEnabledNavMeshFilterFlags &= ~flag; }
307
308 uint16 GetForceDisabledNavMeshFilterFlags() const { return m_forceDisabledNavMeshFilterFlags; }
309 void SetForceDisabledNavMeshFilterFlag(uint16 flag) { m_forceDisabledNavMeshFilterFlags |= flag; }
310 void RemoveForceDisabledNavMeshFilterFlag(uint16 flag) { m_forceDisabledNavMeshFilterFlags &= ~flag; }
311
312 void GetFullTerrainStatusForPosition(PhaseShift const& phaseShift, float x, float y, float z, PositionFullTerrainStatus& data, Optional<map_liquidHeaderTypeFlags> reqLiquidType = {}, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
313 ZLiquidStatus GetLiquidStatus(PhaseShift const& phaseShift, float x, float y, float z, Optional<map_liquidHeaderTypeFlags> ReqLiquidType = {}, LiquidData* data = nullptr, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
314
315 uint32 GetAreaId(PhaseShift const& phaseShift, float x, float y, float z);
316 uint32 GetAreaId(PhaseShift const& phaseShift, Position const& pos) { return GetAreaId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
317 uint32 GetZoneId(PhaseShift const& phaseShift, float x, float y, float z);
318 uint32 GetZoneId(PhaseShift const& phaseShift, Position const& pos) { return GetZoneId(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
319 void GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, float x, float y, float z);
320 void GetZoneAndAreaId(PhaseShift const& phaseShift, uint32& zoneid, uint32& areaid, Position const& pos) { GetZoneAndAreaId(phaseShift, zoneid, areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
321
322 float GetMinHeight(PhaseShift const& phaseShift, float x, float y);
323 float GetGridHeight(PhaseShift const& phaseShift, float x, float y);
324 float GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH);
325 float GetStaticHeight(PhaseShift const& phaseShift, Position const& pos, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) { return GetStaticHeight(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), checkVMap, maxSearchDist); }
326 float GetHeight(PhaseShift const& phaseShift, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) { return std::max<float>(GetStaticHeight(phaseShift, x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phaseShift, x, y, z, maxSearchDist)); }
327 float GetHeight(PhaseShift const& phaseShift, Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) { return GetHeight(phaseShift, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); }
328
329 float GetWaterLevel(PhaseShift const& phaseShift, float x, float y);
330 bool IsInWater(PhaseShift const& phaseShift, float x, float y, float z, LiquidData* data = nullptr);
331 bool IsUnderWater(PhaseShift const& phaseShift, float x, float y, float z);
332
333 float GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
334
335 void MoveAllCreaturesInMoveList();
336 void MoveAllGameObjectsInMoveList();
337 void MoveAllDynamicObjectsInMoveList();
338 void MoveAllAreaTriggersInMoveList();
339 void RemoveAllObjectsInRemoveList();
340 virtual void RemoveAllPlayers();
341
342 // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader
343 bool CreatureRespawnRelocation(Creature* c, bool diffGridOnly);
344 bool GameObjectRespawnRelocation(GameObject* go, bool diffGridOnly);
345
346 // assert print helper
347 template <typename T>
348 static bool CheckGridIntegrity(T* object, bool moved, char const* objType);
349
350 uint32 GetInstanceId() const { return i_InstanceId; }
351
352 Trinity::unique_weak_ptr<Map> GetWeakPtr() const { return m_weakRef; }
353 void SetWeakPtr(Trinity::unique_weak_ptr<Map> weakRef) { m_weakRef = std::move(weakRef); }
354
355 static TransferAbortParams PlayerCannotEnter(uint32 mapid, Player* player);
356 virtual TransferAbortParams CannotEnter(Player* /*player*/) { return { TRANSFER_ABORT_NONE }; }
357 char const* GetMapName() const;
358
359 // have meaning only for instanced map (that have set real difficulty)
360 Difficulty GetDifficultyID() const { return Difficulty(i_spawnMode); }
361 MapDifficultyEntry const* GetMapDifficulty() const;
362
363 uint32 GetId() const;
364 bool Instanceable() const;
365 bool IsDungeon() const;
366 bool IsNonRaidDungeon() const;
367 bool IsRaid() const;
368 bool IsLFR() const;
369 bool IsNormal() const;
370 bool IsHeroic() const;
371 bool IsMythic() const;
372 bool IsMythicPlus() const;
373 bool IsHeroicOrHigher() const;
374 bool Is25ManRaid() const;
375 bool IsTimewalking() const;
376 bool IsBattleground() const;
377 bool IsBattleArena() const;
378 bool IsBattlegroundOrArena() const;
379 bool IsScenario() const;
380 bool IsGarrison() const;
381 // Currently, this means that every entity added to this map will be marked as active
382 bool IsAlwaysActive() const;
383 bool GetEntrancePos(int32& mapid, float& x, float& y);
384
385 void AddObjectToRemoveList(WorldObject* obj);
386 void AddObjectToSwitchList(WorldObject* obj, bool on);
387 virtual void DelayedUpdate(uint32 diff);
388
389 void resetMarkedCells() { marked_cells.reset(); }
390 bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
391 void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
392
393 bool HavePlayers() const { return !m_mapRefManager.empty(); }
394 uint32 GetPlayersCountExceptGMs() const;
395 bool ActiveObjectsNearGrid(NGridType const& ngrid) const;
396
397 void AddWorldObject(WorldObject* obj);
398 void RemoveWorldObject(WorldObject* obj);
399
400 void SendToPlayers(WorldPacket const* data) const;
401
403 PlayerList const& GetPlayers() const { return m_mapRefManager; }
404
405 template <typename T>
406 void DoOnPlayers(T&& fn)
407 {
408 for (MapReference const& ref : GetPlayers())
409 if (Player* player = ref.GetSource())
410 fn(player);
411 }
412
413 //per-map script storage
414 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo>> const& scripts, uint32 id, Object* source, Object* target);
415 void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
416
417 // must called with AddToWorld
418 void AddToActive(WorldObject* obj);
419
420 // must called with RemoveFromWorld
421 void RemoveFromActive(WorldObject* obj);
422
423 template<class T> void SwitchGridContainers(T* obj, bool on);
424 std::unordered_map<ObjectGuid::LowType /*leaderSpawnId*/, CreatureGroup*> CreatureGroupHolder;
425
426 void UpdateIteratorBack(Player* player);
427
428 TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, Milliseconds duration = 0ms, WorldObject* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty, SmoothPhasingInfo const* smoothPhasingInfo = nullptr);
429 void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
430 AreaTrigger* GetAreaTrigger(ObjectGuid const& guid);
431 SceneObject* GetSceneObject(ObjectGuid const& guid);
432 Conversation* GetConversation(ObjectGuid const& guid);
433 Player* GetPlayer(ObjectGuid const& guid);
434 Corpse* GetCorpse(ObjectGuid const& guid);
435 Creature* GetCreature(ObjectGuid const& guid);
436 DynamicObject* GetDynamicObject(ObjectGuid const& guid);
437 GameObject* GetGameObject(ObjectGuid const& guid);
438 Pet* GetPet(ObjectGuid const& guid);
439 Transport* GetTransport(ObjectGuid const& guid);
440 Creature* GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const;
441 GameObject* GetGameObjectBySpawnId(ObjectGuid::LowType spawnId) const;
442 AreaTrigger* GetAreaTriggerBySpawnId(ObjectGuid::LowType spawnId) const;
444 {
445 switch (type)
446 {
448 return reinterpret_cast<WorldObject*>(GetCreatureBySpawnId(spawnId));
450 return reinterpret_cast<WorldObject*>(GetGameObjectBySpawnId(spawnId));
452 return reinterpret_cast<WorldObject*>(GetAreaTriggerBySpawnId(spawnId));
453 default:
454 return nullptr;
455 }
456 }
457
459
460 typedef std::unordered_multimap<ObjectGuid::LowType, Creature*> CreatureBySpawnIdContainer;
461 CreatureBySpawnIdContainer& GetCreatureBySpawnIdStore() { return _creatureBySpawnIdStore; }
462 CreatureBySpawnIdContainer const& GetCreatureBySpawnIdStore() const { return _creatureBySpawnIdStore; }
463
464 typedef std::unordered_multimap<ObjectGuid::LowType, GameObject*> GameObjectBySpawnIdContainer;
465 GameObjectBySpawnIdContainer& GetGameObjectBySpawnIdStore() { return _gameobjectBySpawnIdStore; }
466 GameObjectBySpawnIdContainer const& GetGameObjectBySpawnIdStore() const { return _gameobjectBySpawnIdStore; }
467
468 typedef std::unordered_multimap<ObjectGuid::LowType, AreaTrigger*> AreaTriggerBySpawnIdContainer;
469 AreaTriggerBySpawnIdContainer& GetAreaTriggerBySpawnIdStore() { return _areaTriggerBySpawnIdStore; }
470 AreaTriggerBySpawnIdContainer const& GetAreaTriggerBySpawnIdStore() const { return _areaTriggerBySpawnIdStore; }
471
472 std::unordered_set<Corpse*> const* GetCorpsesInCell(uint32 cellId) const
473 {
474 auto itr = _corpsesByCell.find(cellId);
475 if (itr != _corpsesByCell.end())
476 return &itr->second;
477
478 return nullptr;
479 }
480
481 Corpse* GetCorpseByPlayer(ObjectGuid const& ownerGuid) const
482 {
483 auto itr = _corpsesByPlayer.find(ownerGuid);
484 if (itr != _corpsesByPlayer.end())
485 return itr->second;
486
487 return nullptr;
488 }
489
490 InstanceMap* ToInstanceMap() { return IsDungeon() ? reinterpret_cast<InstanceMap*>(this) : nullptr; }
491 InstanceMap const* ToInstanceMap() const { return IsDungeon() ? reinterpret_cast<InstanceMap const*>(this) : nullptr; }
492
493 BattlegroundMap* ToBattlegroundMap() { return IsBattlegroundOrArena() ? reinterpret_cast<BattlegroundMap*>(this) : nullptr; }
494 BattlegroundMap const* ToBattlegroundMap() const { return IsBattlegroundOrArena() ? reinterpret_cast<BattlegroundMap const*>(this) : nullptr; }
495
496 bool isInLineOfSight(PhaseShift const& phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const;
497 void Balance() { _dynamicTree.balance(); }
498 void RemoveGameObjectModel(GameObjectModel const& model) { _dynamicTree.remove(model); }
499 void InsertGameObjectModel(GameObjectModel const& model) { _dynamicTree.insert(model); }
500 bool ContainsGameObjectModel(GameObjectModel const& model) const { return _dynamicTree.contains(model);}
501 std::span<GameObjectModel const* const> GetGameObjectModelsInGrid(uint32 gx, uint32 gy) const { return _dynamicTree.getModelsInGrid(gx, gy); }
502 float GetGameObjectFloor(PhaseShift const& phaseShift, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const
503 {
504 return _dynamicTree.getHeight(x, y, z, maxSearchDist, phaseShift);
505 }
506 bool getObjectHitPos(PhaseShift const& phaseShift, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist);
507
508 void RequestRebuildNavMeshOnGameObjectModelChange(GameObjectModel const& model, PhaseShift const& phaseShift);
509
510 virtual ObjectGuid::LowType GetOwnerGuildId(uint32 /*team*/ = TEAM_OTHER) const { return UI64LIT(0); }
511 /*
512 RESPAWN TIMES
513 */
514 time_t GetLinkedRespawnTime(ObjectGuid guid) const;
516 {
517 if (auto map = GetRespawnMapForType(type))
518 {
519 auto it = map->find(spawnId);
520 return (it == map->end()) ? 0 : it->second->respawnTime;
521 }
522 return 0;
523 }
524 time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const { return GetRespawnTime(SPAWN_TYPE_CREATURE, spawnId); }
525 time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const { return GetRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId); }
526
527 void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone);
528
529 void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, CharacterDatabaseTransaction dbTrans = nullptr, bool startup = false);
530 void SaveRespawnInfoDB(RespawnInfo const& info, CharacterDatabaseTransaction dbTrans = nullptr);
531 void LoadRespawnTimes();
532 void DeleteRespawnTimes() { UnloadAllRespawnInfos(); DeleteRespawnTimesInDB(); }
533 void DeleteRespawnTimesInDB();
534
535 void LoadCorpseData();
536 void DeleteCorpseData();
537 void AddCorpse(Corpse* corpse);
538 void RemoveCorpse(Corpse* corpse);
539 Corpse* ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia = false);
540 void RemoveOldCorpses();
541
542 void SendInitTransports(Player* player);
543 void SendRemoveTransports(Player* player);
544 void SendUpdateTransportVisibility(Player* player);
545 void SendZoneDynamicInfo(uint32 zoneId, Player* player) const;
546 void SendZoneWeather(uint32 zoneId, Player* player) const;
547 void SendZoneWeather(ZoneDynamicInfo const& zoneDynamicInfo, Player* player) const;
548
549 void SetZoneMusic(uint32 zoneId, uint32 musicId);
550 Weather* GetOrGenerateZoneDefaultWeather(uint32 zoneId);
551 WeatherState GetZoneWeather(uint32 zoneId) const;
552 void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float intensity);
553 void SetZoneOverrideLight(uint32 zoneId, uint32 areaLightId, uint32 overrideLightId, Milliseconds transitionTime);
554
555 void UpdateAreaDependentAuras();
556
557 template<HighGuid high>
559 {
560 static_assert(ObjectGuidTraits<high>::SequenceSource.HasFlag(ObjectGuidSequenceSource::Map), "Only map specific guid can be generated in Map context");
561 return GetGuidSequenceGenerator(high).Generate();
562 }
563
564 template<HighGuid high>
566 {
567 static_assert(ObjectGuidTraits<high>::SequenceSource.HasFlag(ObjectGuidSequenceSource::Map), "Only map specific guid can be retrieved in Map context");
568 return GetGuidSequenceGenerator(high).GetNextAfterMaxUsed();
569 }
570
572 {
573 _updateObjects.insert(obj);
574 }
575
577 {
578 _updateObjects.erase(obj);
579 }
580
582 {
583 return m_activeNonPlayers.size();
584 }
585
586 virtual std::string GetDebugInfo() const;
587
588 private:
589
590 void SetTimer(uint32 t) { i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t; }
591
592 void SendInitSelf(Player* player);
593
594 template <typename T>
595 bool MapObjectCellRelocation(T* object, Cell new_cell, char const* objType);
596
597 bool CreatureCellRelocation(Creature* creature, Cell new_cell);
598 bool GameObjectCellRelocation(GameObject* go, Cell new_cell);
599 bool DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell);
600 bool AreaTriggerCellRelocation(AreaTrigger* at, Cell new_cell);
601
602 template<class T> void InitializeObject(T* obj);
603 void AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang);
604 void RemoveCreatureFromMoveList(Creature* c);
605 void AddGameObjectToMoveList(GameObject* go, float x, float y, float z, float ang);
606 void RemoveGameObjectFromMoveList(GameObject* go);
607 void AddDynamicObjectToMoveList(DynamicObject* go, float x, float y, float z, float ang);
608 void RemoveDynamicObjectFromMoveList(DynamicObject* go);
609 void AddAreaTriggerToMoveList(AreaTrigger* at, float x, float y, float z, float ang);
610 void RemoveAreaTriggerFromMoveList(AreaTrigger* at);
611
613 std::vector<Creature*> _creaturesToMove;
614
616 std::vector<GameObject*> _gameObjectsToMove;
617
619 std::vector<DynamicObject*> _dynamicObjectsToMove;
620
622 std::vector<AreaTrigger*> _areaTriggersToMove;
623
624 bool IsGridLoaded(GridCoord const&) const;
625 void EnsureGridCreated(GridCoord const&);
626 bool EnsureGridLoaded(Cell const&);
627 void EnsureGridLoadedForActiveObject(Cell const&, WorldObject const* object);
628
629 void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
630
632 {
633 ASSERT(x < MAX_NUMBER_OF_GRIDS && y < MAX_NUMBER_OF_GRIDS, "x = %u, y = %u", x, y);
634 return i_grids[x][y];
635 }
636
637 bool isGridObjectDataLoaded(uint32 x, uint32 y) const { return getNGrid(x, y)->isGridObjectDataLoaded(); }
638 void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y) { getNGrid(x, y)->setGridObjectDataLoaded(pLoaded); }
639
640 void setNGrid(NGridType* grid, uint32 x, uint32 y);
641 void ScriptsProcess();
642
643 void SendObjectUpdates();
644
645 protected:
646 virtual void LoadGridObjects(NGridType* grid, Cell const& cell);
647
655 std::shared_ptr<MMAP::DynamicTileBuilder> m_mmapTileRebuilder;
656
659
661
662 typedef std::set<WorldObject*> ActiveNonPlayers;
664 ActiveNonPlayers::iterator m_activeNonPlayersIter;
665
666 // Objects that must update even in inactive grids without activating them
667 typedef std::set<Transport*> TransportsContainer;
669 TransportsContainer::iterator _transportsUpdateIter;
670
671 private:
672 Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo) const;
673 Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo, bool bReverse = false) const;
674 GameObject* _GetScriptGameObjectSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo, bool bReverse = false) const;
675 Unit* _GetScriptUnit(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
676 Player* _GetScriptPlayer(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
677 Creature* _GetScriptCreature(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
678 WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
679 void _ScriptProcessDoor(Object* source, Object* target, ScriptInfo const* scriptInfo) const;
680 GameObject* _FindGameObject(WorldObject* pWorldObject, ObjectGuid::LowType guid) const;
681
683
684 std::shared_ptr<TerrainInfo> m_terrain;
687
689 std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
690
691 //these functions used to process player/mob aggro reactions and
692 //visibility calculations. Highly optimized for massive calculations
693 void ProcessRelocationNotifies(const uint32 diff);
694
696 std::set<WorldObject*> i_objectsToRemove;
697 std::map<WorldObject*, bool> i_objectsToSwitch;
698 std::set<WorldObject*> i_worldObjects;
699
700 typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap;
702
703 public:
704 void ProcessRespawns();
705 void ApplyDynamicModeRespawnScaling(WorldObject const* obj, ObjectGuid::LowType spawnId, uint32& respawnDelay, uint32 mode) const;
706
707 private:
708 // if return value is true, we can respawn
709 // if return value is false, reschedule the respawn to new value of info->respawnTime iff nonzero, delete otherwise
710 // if return value is false and info->respawnTime is nonzero, it is guaranteed to be greater than time(NULL)
711 bool CheckRespawn(RespawnInfo* info);
712 void DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gridId);
713 bool AddRespawnInfo(RespawnInfo const& info);
714 void UnloadAllRespawnInfos();
715 RespawnInfo* GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
716 void Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr);
717 void DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr);
718 void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr);
719
720 public:
721 void GetRespawnInfo(std::vector<RespawnInfo const*>& respawnData, SpawnObjectTypeMask types) const;
723 {
724 if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
725 Respawn(info, dbTrans);
726 }
727 void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr, bool alwaysDeleteFromDB = false)
728 {
729 if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
730 DeleteRespawnInfo(info, dbTrans);
731 // Some callers might need to make sure the database doesn't contain any respawn time
732 else if (alwaysDeleteFromDB)
733 DeleteRespawnInfoFromDB(type, spawnId, dbTrans);
734 }
735 size_t DespawnAll(SpawnObjectType type, ObjectGuid::LowType spawnId);
736
737 bool ShouldBeSpawnedOnGridLoad(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
738 template <typename T> bool ShouldBeSpawnedOnGridLoad(ObjectGuid::LowType spawnId) const { return ShouldBeSpawnedOnGridLoad(SpawnData::TypeFor<T>, spawnId); }
739
740 SpawnGroupTemplateData const* GetSpawnGroupData(uint32 groupId) const;
741
742 bool IsSpawnGroupActive(uint32 groupId) const;
743
744 // Enable the spawn group, which causes all creatures in it to respawn (unless they have a respawn timer)
745 // The force flag can be used to force spawning additional copies even if old copies are still around from a previous spawn
746 bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn = false, bool force = false, std::vector<WorldObject*>* spawnedObjects = nullptr);
747
748 // Despawn all creatures in the spawn group if spawned, optionally delete their respawn timer, and disable the group
749 bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes = false, size_t* count = nullptr);
750
751 // Disable the spawn group, which prevents any creatures in the group from respawning until re-enabled
752 // This will not affect any already-present creatures in the group
753 void SetSpawnGroupInactive(uint32 groupId) { SetSpawnGroupActive(groupId, false); }
754
755 SpawnedPoolData& GetPoolData() { return *_poolData; }
756 SpawnedPoolData const& GetPoolData() const { return *_poolData; }
757
758 typedef std::function<void(Map*)> FarSpellCallback;
759 void AddFarSpellCallback(FarSpellCallback&& callback);
760
761 void InitSpawnGroupState();
762 void UpdateSpawnGroupConditions();
763
764 private:
765 // Type specific code for add/remove to/from grid
766 template<class T>
767 void AddToGrid(T* object, Cell const& cell);
768
769 template<class T>
770 void DeleteFromWorld(T*);
771
772 std::unique_ptr<RespawnListContainer> _respawnTimes;
776 {
777 switch (type)
778 {
779 default:
780 ABORT();
782 return &_creatureRespawnTimesBySpawnId;
784 return &_gameObjectRespawnTimesBySpawnId;
786 return nullptr;
787 }
788 }
790 {
791 switch (type)
792 {
793 default:
794 ABORT();
796 return &_creatureRespawnTimesBySpawnId;
798 return &_gameObjectRespawnTimesBySpawnId;
800 return nullptr;
801 }
802 }
803
804 void SetSpawnGroupActive(uint32 groupId, bool state);
805 std::unordered_set<uint32> _toggledSpawnGroupIds;
806
808 std::unordered_map<uint32, uint32> _zonePlayerCountMap;
809
812
813 ObjectGuidGenerator& GetGuidSequenceGenerator(HighGuid high);
814
815 std::map<HighGuid, ObjectGuidGenerator> _guidGenerators;
816 std::unique_ptr<SpawnedPoolData> _poolData;
821 std::unordered_map<uint32/*cellId*/, std::unordered_set<Corpse*>> _corpsesByCell;
822 std::unordered_map<ObjectGuid, Corpse*> _corpsesByPlayer;
823 std::unordered_set<Corpse*> _corpseBones;
824
825 std::unordered_set<BaseEntity*> _updateObjects;
826
828
829 /*********************************************************/
830 /*** Phasing ***/
831 /*********************************************************/
832 public:
833 MultiPersonalPhaseTracker& GetMultiPersonalPhaseTracker() { return _multiPersonalPhaseTracker; }
834 void UpdatePersonalPhasesForPlayer(Player const* player);
835
836 private:
838
839 /*********************************************************/
840 /*** WorldStates ***/
841 /*********************************************************/
842 public:
843 int32 GetWorldStateValue(int32 worldStateId) const;
844 void SetWorldStateValue(int32 worldStateId, int32 value, bool hidden);
845 WorldStateValueContainer const& GetWorldStateValues() const { return _worldStateValues; }
846
847 private:
849
850 /*********************************************************/
851 /*** Vignettes ***/
852 /*********************************************************/
853 public:
854 void AddInfiniteAOIVignette(Vignettes::VignetteData* vignette);
855 void RemoveInfiniteAOIVignette(Vignettes::VignetteData* vignette);
856 std::vector<Vignettes::VignetteData*> const& GetInfiniteAOIVignettes() const { return _infiniteAOIVignettes; }
857
858 private:
859 std::vector<Vignettes::VignetteData*> _infiniteAOIVignettes;
861};
862
864{
865 Manual,
867 Expire
868};
869
871{
872 Success,
873 NotEmpty,
875};
876
878{
879 public:
880 InstanceMap(uint32 id, time_t, uint32 InstanceId, Difficulty SpawnMode, TeamId InstanceTeam, InstanceLock* instanceLock,
881 Optional<uint32> lfgDungeonsId);
882 ~InstanceMap();
883 bool AddPlayerToMap(Player* player, bool initPlayer = true) override;
884 void RemovePlayerFromMap(Player*, bool) override;
885 void Update(uint32) override;
886 void CreateInstanceData();
888 uint32 GetScriptId() const { return i_script_id; }
889 std::string const& GetScriptName() const;
890 InstanceScript* GetInstanceScript() { return i_data; }
891 InstanceScript const* GetInstanceScript() const { return i_data; }
892 InstanceScenario* GetInstanceScenario() { return i_scenario.get(); }
893 InstanceScenario const* GetInstanceScenario() const { return i_scenario.get(); }
894 void SetInstanceScenario(InstanceScenario* scenario);
895 InstanceLock const* GetInstanceLock() const { return i_instanceLock; }
896 void UpdateInstanceLock(UpdateBossStateSaveDataEvent const& updateSaveDataEvent);
897 void UpdateInstanceLock(UpdateAdditionalSaveDataEvent const& updateSaveDataEvent);
898 void CreateInstanceLockForPlayer(Player* player);
899 TransferAbortParams CannotEnter(Player* player) override;
900
901 uint32 GetMaxPlayers() const;
902 TeamId GetTeamIdInInstance() const;
903 Team GetTeamInInstance() const { return GetTeamIdInInstance() == TEAM_ALLIANCE ? ALLIANCE : HORDE; }
904 Optional<uint32> GetLfgDungeonsId() const { return i_lfgDungeonsId; }
905
906 virtual void InitVisibilityDistance() override;
907
908 Group* GetOwningGroup() const { return i_owningGroupRef.getTarget(); }
909 void TrySetOwningGroup(Group* group);
910
911 std::string GetDebugInfo() const override;
912 private:
916 std::unique_ptr<InstanceScenario> i_scenario;
920};
921
923{
924 public:
925 BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Difficulty spawnMode);
927
928 bool AddPlayerToMap(Player* player, bool initPlayer = true) override;
929 void RemovePlayerFromMap(Player*, bool) override;
930 TransferAbortParams CannotEnter(Player* player) override;
931 void SetUnload();
932 //void UnloadAll(bool pForce);
933 void RemoveAllPlayers() override;
934 void Update(uint32 diff) override;
935
936 virtual void InitVisibilityDistance() override;
937 Battleground* GetBG() const { return m_bg; }
938 void SetBG(Battleground* bg) { m_bg = bg; }
939
940 uint32 GetScriptId() const { return _scriptId; }
941 std::string const& GetScriptName() const;
942 BattlegroundScript* GetBattlegroundScript() { return _battlegroundScript.get(); }
943 BattlegroundScript const* GetBattlegroundScript() const { return _battlegroundScript.get(); }
944
945 void InitScriptData();
946 private:
948 std::unique_ptr<BattlegroundScript> _battlegroundScript;
950};
951
952template<class T, class CONTAINER>
953inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
954{
955 const uint32 x = cell.GridX();
956 const uint32 y = cell.GridY();
957 const uint32 cell_x = cell.CellX();
958 const uint32 cell_y = cell.CellY();
959
960 if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y)))
961 {
962 EnsureGridLoaded(cell);
963 getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
964 }
965}
966#endif
ItemContext
Definition DBCEnums.h:1315
Difficulty
Definition DBCEnums.h:932
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
#define UI64FMTD
Definition Define.h:138
#define TC_GAME_API
Definition Define.h:129
uint8_t uint8
Definition Define.h:156
int16_t int16
Definition Define.h:151
int32_t int32
Definition Define.h:150
#define UI64LIT(N)
Definition Define.h:139
uint16_t uint16
Definition Define.h:155
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::string GetDebugInfo()
Definition Errors.cpp:170
#define ABORT
Definition Errors.h:87
#define ASSERT
Definition Errors.h:80
#define DEFAULT_HEIGHT_SEARCH
Definition GridDefines.h:63
#define MIN_GRID_DELAY
Definition GridDefines.h:45
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
#define MAX_NUMBER_OF_GRIDS
Definition GridDefines.h:38
std::conditional_t< IntrusiveLink !=nullptr, Trinity::Impl::MPSCQueueIntrusive< T, IntrusiveLink >, Trinity::Impl::MPSCQueueNonIntrusive< T > > MPSCQueue
Definition MPSCQueue.h:173
ZLiquidStatus
Definition MapDefines.h:133
InstanceResetMethod
Definition Map.h:864
std::unordered_map< ObjectGuid::LowType, RespawnInfo * > RespawnInfoMap
Definition Map.h:166
InstanceResetResult
Definition Map.h:871
std::unordered_map< uint32, ZoneDynamicInfo > ZoneDynamicInfoMap
Definition Map.h:164
TypeListContainer< MapStoredObjectsUnorderedMap, Creature, GameObject, DynamicObject, Pet, Corpse, AreaTrigger, SceneObject, Conversation > MapStoredObjectTypesContainer
Definition Map.h:222
TransferAbortReason
Definition Map.h:90
@ TRANSFER_ABORT_TOO_MANY_INSTANCES
Definition Map.h:95
@ TRANSFER_ABORT_NOT_CROSS_FACTION_COMPATIBLE
Definition Map.h:112
@ TRANSFER_ABORT_XREALM_ZONE_DOWN
Definition Map.h:110
@ TRANSFER_ABORT_NOT_FOUND_2
Definition Map.h:102
@ TRANSFER_ABORT_DIFFICULTY
Definition Map.h:98
@ TRANSFER_ABORT_UNIQUE_MESSAGE
Definition Map.h:99
@ TRANSFER_ABORT_MAP_NOT_ALLOWED
Definition Map.h:106
@ TRANSFER_ABORT_INSUF_EXPAN_LVL
Definition Map.h:97
@ TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
Definition Map.h:100
@ TRANSFER_ABORT_MAX_PLAYERS
Definition Map.h:93
@ TRANSFER_ABORT_NOT_FOUND_4
Definition Map.h:104
@ TRANSFER_ABORT_ZONE_IN_COMBAT
Definition Map.h:96
@ TRANSFER_ABORT_DIFFICULTY_NOT_FOUND
Definition Map.h:109
@ TRANSFER_ABORT_NONE
Definition Map.h:91
@ TRANSFER_ABORT_ALREADY_COMPLETED_ENCOUNTER
Definition Map.h:108
@ TRANSFER_ABORT_SOLO_PLAYER_SWITCH_DIFFICULTY
Definition Map.h:111
@ TRANSFER_ABORT_NOT_FOUND
Definition Map.h:94
@ TRANSFER_ABORT_LOCKED_TO_DIFFERENT_INSTANCE
Definition Map.h:107
@ TRANSFER_ABORT_NEED_GROUP
Definition Map.h:101
@ TRANSFER_ABORT_NOT_FOUND_3
Definition Map.h:103
@ TRANSFER_ABORT_REALM_ONLY
Definition Map.h:105
@ TRANSFER_ABORT_ERROR
Definition Map.h:92
@ GRID_STATE_REMOVAL
Definition NGrid.h:59
HighGuid
Definition ObjectGuid.h:109
static void SummonCreatureGroup(uint32 summonerId, SummonerType summonerType, uint8 group, std::list< TempSummon * > *summoned, SummonCreature summonCreature)
Definition Object.cpp:1319
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
@ TEAM_ALLIANCE
@ TEAM_OTHER
@ ALLIANCE
@ HORDE
LineOfSightChecks
SpawnObjectTypeMask
Definition SpawnData.h:44
SpawnObjectType
Definition SpawnData.h:35
@ SPAWN_TYPE_GAMEOBJECT
Definition SpawnData.h:37
@ SPAWN_TYPE_AREATRIGGER
Definition SpawnData.h:38
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:36
std::unordered_map< int32, int32 > WorldStateValueContainer
BattlegroundScript const * GetBattlegroundScript() const
Definition Map.h:943
std::unique_ptr< BattlegroundScript > _battlegroundScript
Definition Map.h:948
Battleground * GetBG() const
Definition Map.h:937
uint32 GetScriptId() const
Definition Map.h:940
Battleground * m_bg
Definition Map.h:947
void SetBG(Battleground *bg)
Definition Map.h:938
BattlegroundScript * GetBattlegroundScript()
Definition Map.h:942
uint32 _scriptId
Definition Map.h:949
Definition Group.h:205
Optional< SystemTimePoint > i_instanceExpireEvent
Definition Map.h:913
InstanceLock * i_instanceLock
Definition Map.h:917
InstanceScript const * GetInstanceScript() const
Definition Map.h:891
InstanceScenario * GetInstanceScenario()
Definition Map.h:892
std::unique_ptr< InstanceScenario > i_scenario
Definition Map.h:916
Optional< uint32 > i_lfgDungeonsId
Definition Map.h:919
uint32 GetScriptId() const
Definition Map.h:888
Team GetTeamInInstance() const
Definition Map.h:903
InstanceLock const * GetInstanceLock() const
Definition Map.h:895
GroupInstanceReference i_owningGroupRef
Definition Map.h:918
Optional< uint32 > GetLfgDungeonsId() const
Definition Map.h:904
InstanceScript * i_data
Definition Map.h:914
InstanceScenario const * GetInstanceScenario() const
Definition Map.h:893
uint32 i_script_id
Definition Map.h:915
Group * GetOwningGroup() const
Definition Map.h:908
InstanceScript * GetInstanceScript()
Definition Map.h:890
Definition Map.h:225
MapEntry const * i_mapEntry
Definition Map.h:648
bool _creatureToMoveLock
Definition Map.h:612
std::map< WorldObject *, bool > i_objectsToSwitch
Definition Map.h:697
WorldObject * GetWorldObjectBySpawnId(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.h:443
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition Map.h:808
std::vector< Creature * > _creaturesToMove
Definition Map.h:613
uint16 m_forceDisabledNavMeshFilterFlags
Definition Map.h:686
CreatureBySpawnIdContainer const & GetCreatureBySpawnIdStore() const
Definition Map.h:462
bool IsRemovalGrid(Position const &pos) const
Definition Map.h:273
RespawnInfoMap const * GetRespawnMapForType(SpawnObjectType type) const
Definition Map.h:789
float GetStaticHeight(PhaseShift const &phaseShift, Position const &pos, bool checkVMap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition Map.h:325
void SetSpawnGroupInactive(uint32 groupId)
Definition Map.h:753
std::unordered_set< Corpse * > const * GetCorpsesInCell(uint32 cellId) const
Definition Map.h:472
std::unordered_multimap< ObjectGuid::LowType, Creature * > CreatureBySpawnIdContainer
Definition Map.h:460
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition Map.h:822
void SetWeakPtr(Trinity::unique_weak_ptr< Map > weakRef)
Definition Map.h:353
bool ShouldBeSpawnedOnGridLoad(ObjectGuid::LowType spawnId) const
Definition Map.h:738
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:458
TransportsContainer::iterator _transportsUpdateIter
Definition Map.h:669
void RemoveForceEnabledNavMeshFilterFlag(uint16 flag)
Definition Map.h:306
std::map< HighGuid, ObjectGuidGenerator > _guidGenerators
Definition Map.h:815
InstanceMap const * ToInstanceMap() const
Definition Map.h:491
uint32 GetAreaId(PhaseShift const &phaseShift, Position const &pos)
Definition Map.h:316
void GetZoneAndAreaId(PhaseShift const &phaseShift, uint32 &zoneid, uint32 &areaid, Position const &pos)
Definition Map.h:320
std::function< void(Map *)> FarSpellCallback
Definition Map.h:758
PeriodicTimer _vignetteUpdateTimer
Definition Map.h:860
std::shared_ptr< MMAP::DynamicTileBuilder > m_mmapTileRebuilder
Definition Map.h:655
bool GetUnloadLock(GridCoord const &p) const
Definition Map.h:279
void RemoveGameObjectModel(GameObjectModel const &model)
Definition Map.h:498
RespawnInfoMap * GetRespawnMapForType(SpawnObjectType type)
Definition Map.h:775
virtual TransferAbortParams CannotEnter(Player *)
Definition Map.h:356
void DeleteRespawnTimes()
Definition Map.h:532
RespawnInfoMap _gameObjectRespawnTimesBySpawnId
Definition Map.h:774
uint16 GetForceDisabledNavMeshFilterFlags() const
Definition Map.h:308
uint32 m_unloadTimer
Definition Map.h:652
bool IsGridLoaded(Position const &pos) const
Definition Map.h:277
MapRefManager PlayerList
Definition Map.h:402
AreaTriggerBySpawnIdContainer & GetAreaTriggerBySpawnIdStore()
Definition Map.h:469
void RemoveUpdateObject(BaseEntity *obj)
Definition Map.h:576
void SetTimer(uint32 t)
Definition Map.h:590
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition Map.h:689
uint32 GetZoneId(PhaseShift const &phaseShift, Position const &pos)
Definition Map.h:318
SpawnedPoolData const & GetPoolData() const
Definition Map.h:756
virtual ObjectGuid::LowType GetOwnerGuildId(uint32=TEAM_OTHER) const
Definition Map.h:510
BattlegroundMap const * ToBattlegroundMap() const
Definition Map.h:494
bool CanUnload(uint32 diff)
Definition Map.h:234
std::span< GameObjectModel const *const > GetGameObjectModelsInGrid(uint32 gx, uint32 gy) const
Definition Map.h:501
WorldStateValueContainer _worldStateValues
Definition Map.h:848
IntervalTimer _weatherUpdateTimer
Definition Map.h:811
std::unordered_set< BaseEntity * > _updateObjects
Definition Map.h:825
void RemoveForceDisabledNavMeshFilterFlag(uint16 flag)
Definition Map.h:310
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr, bool alwaysDeleteFromDB=false)
Definition Map.h:727
bool _dynamicObjectsToMoveLock
Definition Map.h:618
NGridType * getNGrid(uint32 x, uint32 y) const
Definition Map.h:631
std::shared_ptr< TerrainInfo > m_terrain
Definition Map.h:684
bool _gameObjectsToMoveLock
Definition Map.h:615
bool ContainsGameObjectModel(GameObjectModel const &model) const
Definition Map.h:500
void SetForceEnabledNavMeshFilterFlag(uint16 flag)
Definition Map.h:305
uint32 _respawnCheckTimer
Definition Map.h:807
WorldStateValueContainer const & GetWorldStateValues() const
Definition Map.h:845
bool HavePlayers() const
Definition Map.h:393
bool IsRemovalGrid(float x, float y) const
Definition Map.h:268
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition Map.h:821
MapRefManager m_mapRefManager
Definition Map.h:657
void resetMarkedCells()
Definition Map.h:389
void Visit(Cell const &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
Definition Map.h:953
ScriptScheduleMap m_scriptSchedule
Definition Map.h:701
ObjectGuid::LowType GetMaxLowGuid()
Definition Map.h:565
void ResetGridExpiry(NGridType &grid, float factor=1) const
Definition Map.h:289
DynamicMapTree _dynamicTree
Definition Map.h:654
void Respawn(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
Definition Map.h:722
std::vector< GameObject * > _gameObjectsToMove
Definition Map.h:616
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:558
std::unordered_map< ObjectGuid::LowType, CreatureGroup * > CreatureGroupHolder
Definition Map.h:424
void DoOnPlayers(T &&fn)
Definition Map.h:406
AreaTriggerBySpawnIdContainer _areaTriggerBySpawnIdStore
Definition Map.h:820
time_t i_gridExpiry
Definition Map.h:682
int32 m_VisibilityNotifyPeriod
Definition Map.h:660
std::unordered_set< Corpse * > _corpseBones
Definition Map.h:823
MPSCQueue< FarSpellCallback > _farSpellCallbacks
Definition Map.h:827
Difficulty i_spawnMode
Definition Map.h:649
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:525
bool i_scriptLock
Definition Map.h:695
uint16 GetForceEnabledNavMeshFilterFlags() const
Definition Map.h:304
std::unordered_set< uint32 > _toggledSpawnGroupIds
Definition Map.h:805
bool isCellMarked(uint32 pCellId)
Definition Map.h:390
uint16 m_forceEnabledNavMeshFilterFlags
Definition Map.h:685
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:524
MultiPersonalPhaseTracker & GetMultiPersonalPhaseTracker()
Definition Map.h:833
BattlegroundMap * ToBattlegroundMap()
Definition Map.h:493
Trinity::unique_weak_ptr< Map > m_weakRef
Definition Map.h:651
MultiPersonalPhaseTracker _multiPersonalPhaseTracker
Definition Map.h:837
MapRefManager::iterator m_mapRefIter
Definition Map.h:658
std::multimap< time_t, ScriptAction > ScriptScheduleMap
Definition Map.h:700
std::unique_ptr< RespawnListContainer > _respawnTimes
Definition Map.h:772
void AddUpdateObject(BaseEntity *obj)
Definition Map.h:571
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.h:515
void Balance()
Definition Map.h:497
ZoneDynamicInfoMap _zoneDynamicInfo
Definition Map.h:810
bool _areaTriggersToMoveLock
Definition Map.h:621
std::vector< Vignettes::VignetteData * > _infiniteAOIVignettes
Definition Map.h:859
std::vector< AreaTrigger * > _areaTriggersToMove
Definition Map.h:622
std::set< WorldObject * > i_worldObjects
Definition Map.h:698
Difficulty GetDifficultyID() const
Definition Map.h:360
ActiveNonPlayers m_activeNonPlayers
Definition Map.h:663
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:465
void InsertGameObjectModel(GameObjectModel const &model)
Definition Map.h:499
void SetUnloadLock(GridCoord const &p, bool on)
Definition Map.h:280
std::set< Transport * > TransportsContainer
Definition Map.h:667
void buildNGridLinkage(NGridType *pNGridType)
Definition Map.h:629
MapEntry const * GetEntry() const
Definition Map.h:231
Trinity::unique_weak_ptr< Map > GetWeakPtr() const
Definition Map.h:352
std::set< WorldObject * > i_objectsToRemove
Definition Map.h:696
MapStoredObjectTypesContainer _objectsStore
Definition Map.h:817
bool IsGridLoaded(float x, float y) const
Definition Map.h:276
std::unordered_multimap< ObjectGuid::LowType, AreaTrigger * > AreaTriggerBySpawnIdContainer
Definition Map.h:468
friend class MapReference
Definition Map.h:226
float m_VisibleDistance
Definition Map.h:653
float GetVisibilityRange() const
Definition Map.h:255
float GetHeight(PhaseShift const &phaseShift, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition Map.h:326
InstanceMap * ToInstanceMap()
Definition Map.h:490
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition Map.h:481
bool IsGridLoaded(uint32 gridId) const
Definition Map.h:275
std::set< WorldObject * > ActiveNonPlayers
Definition Map.h:662
void markCell(uint32 pCellId)
Definition Map.h:391
float GetHeight(PhaseShift const &phaseShift, Position const &pos, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH)
Definition Map.h:327
void SetForceDisabledNavMeshFilterFlag(uint16 flag)
Definition Map.h:309
AreaTriggerBySpawnIdContainer const & GetAreaTriggerBySpawnIdStore() const
Definition Map.h:470
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:461
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
Definition Map.h:638
bool EnsureGridLoaded(Cell const &)
Definition Map.cpp:322
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition Map.h:619
uint32 GetInstanceId() const
Definition Map.h:350
TransportsContainer _transports
Definition Map.h:668
PlayerList const & GetPlayers() const
Definition Map.h:403
GameObjectBySpawnIdContainer const & GetGameObjectBySpawnIdStore() const
Definition Map.h:466
SpawnedPoolData & GetPoolData()
Definition Map.h:755
RespawnInfoMap _creatureRespawnTimesBySpawnId
Definition Map.h:773
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition Map.h:818
uint32 i_InstanceId
Definition Map.h:650
std::vector< Vignettes::VignetteData * > const & GetInfiniteAOIVignettes() const
Definition Map.h:856
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition Map.h:664
time_t GetGridExpiry() const
Definition Map.h:294
std::unordered_multimap< ObjectGuid::LowType, GameObject * > GameObjectBySpawnIdContainer
Definition Map.h:464
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
Definition Map.h:637
TerrainInfo * GetTerrain() const
Definition Map.h:299
float GetGameObjectFloor(PhaseShift const &phaseShift, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.h:502
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
Definition Map.h:819
std::unique_ptr< SpawnedPoolData > _poolData
Definition Map.h:816
size_t GetActiveNonPlayersCount() const
Definition Map.h:581
Definition NGrid.h:70
void VisitGrid(uint32 x, uint32 y, TypeContainerVisitor< VISITOR, WORLD_OBJECT_CONTAINER > &visitor)
Definition NGrid.h:153
void ResetTimeTracker(time_t interval)
Definition NGrid.h:109
void link(GridRefManager< NGrid > *pTo)
Definition NGrid.h:96
static ObjectGuid const Empty
Definition ObjectGuid.h:314
uint64 LowType
Definition ObjectGuid.h:321
Definition Pet.h:40
Trinity::unique_trackable_ptr companion class, replicating what std::weak_ptr is to std::shared_ptr.
Definition Unit.h:635
Weather for one zone.
Definition Weather.h:66
WeatherState
Definition Weather.h:46
GridCoord ComputeGridCoord(float x, float y)
Definition Cell.h:47
uint32 GridX() const
Definition Cell.h:73
bool NoCreate() const
Definition Cell.h:75
uint32 GridY() const
Definition Cell.h:74
uint32 CellX() const
Definition Cell.h:71
uint32 CellY() const
Definition Cell.h:72
bool operator()(RespawnInfo const *a, RespawnInfo const *b) const
Definition Map.h:177
uint32 x_coord
uint32 y_coord
static std::size_t Size(Container const &container)
Definition Map.h:209
std::unordered_map< ObjectGuid, ObjectType * > Container
Definition Map.h:192
ObjectType * ValueType
Definition Map.h:194
static bool Insert(Container &container, ValueType object)
Definition Map.h:196
static bool Remove(Container &container, ValueType object)
Definition Map.h:203
static ValueType Find(Container const &container, KeyType const &key)
Definition Map.h:214
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
constexpr float GetPositionZ() const
Definition Position.h:89
uint32 gridId
Definition Map.h:175
ObjectGuid::LowType spawnId
Definition Map.h:172
time_t respawnTime
Definition Map.h:174
virtual ~RespawnInfo()
uint32 entry
Definition Map.h:173
SpawnObjectType type
Definition Map.h:171
ObjectGuid targetGUID
Definition Map.h:132
ObjectGuid ownerGUID
Definition Map.h:133
ObjectGuid sourceGUID
Definition Map.h:131
ScriptInfo const * script
‍owner of source if source is item
Definition Map.h:134
int32 MapDifficultyXConditionId
Definition Map.h:124
TransferAbortReason Reason
Definition Map.h:122
TransferAbortParams(TransferAbortReason reason, uint8 arg=0, int32 mapDifficultyXConditionId=0)
Definition Map.h:117
ZoneDynamicInfo()
Definition Map.cpp:76
std::vector< LightOverride > LightOverrides
Definition Map.h:153
uint32 MusicId
Definition Map.h:141
WeatherState WeatherId
Definition Map.h:144
std::unique_ptr< Weather > DefaultWeather
Definition Map.h:143
float Intensity
Definition Map.h:145