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