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