TrinityCore
Loading...
Searching...
No Matches
Map.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITY_MAP_H
19#define TRINITY_MAP_H
20
21#include "Define.h"
22
23#include "Cell.h"
24#include "DynamicTree.h"
25#include "GridDefines.h"
26#include "GridRefManager.h"
27#include "MapDefines.h"
28#include "MapRefManager.h"
29#include "MPSCQueue.h"
30#include "ObjectGuid.h"
31#include "Optional.h"
32#include "SharedDefines.h"
33#include "SpawnData.h"
34#include "Timer.h"
35#include "Transaction.h"
36#include "UniqueTrackablePtr.h"
37#include <bitset>
38#include <list>
39#include <memory>
40#include <mutex>
41
42class Battleground;
43class BattlegroundMap;
44class CreatureGroup;
45class GameObjectModel;
46class Group;
47class InstanceMap;
48class InstanceSave;
49class InstanceScript;
50class MapInstanced;
51class Object;
52class Player;
53class TempSummon;
54class Transport;
55class Unit;
56class Weather;
57class WorldObject;
58class WorldPacket;
59class WorldSession;
61struct MapEntry;
62struct Position;
63struct ScriptAction;
64struct ScriptInfo;
66enum Difficulty : uint8;
67enum WeatherState : uint32;
68
69namespace Trinity { struct ObjectUpdater; }
70namespace VMAP { enum class ModelIgnoreFlags : uint32; }
71namespace G3D { class Plane; }
72
74{
77 TRANSFER_ABORT_MAX_PLAYERS = 2, // Transfer Aborted: instance is full
78 TRANSFER_ABORT_NOT_FOUND = 3, // Transfer Aborted: instance not found
79 TRANSFER_ABORT_TOO_MANY_INSTANCES = 4, // You have entered too many instances recently.
81 TRANSFER_ABORT_ZONE_IN_COMBAT = 6, // Unable to zone in while an encounter is in progress.
82 TRANSFER_ABORT_INSUF_EXPAN_LVL = 7, // You must have <TBC, WotLK> expansion installed to access this area.
83 TRANSFER_ABORT_DIFFICULTY = 8, // <Normal, Heroic, Epic> difficulty mode is not available for %s.
84 TRANSFER_ABORT_UNIQUE_MESSAGE = 9, // Until you've escaped TLK's grasp, you cannot leave this place!
85 TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES = 10, // Additional instances cannot be launched, please try again later.
86 TRANSFER_ABORT_NEED_GROUP = 11, // Transfer Aborted: you must be in a raid group to enter this instance
87 TRANSFER_ABORT_NEED_SERVER = 12, // Transfer Aborted: instance not found
88 TRANSFER_ABORT_TIMEOUT = 13, // Transfer Aborted: instance not found
89 TRANSFER_ABORT_BUSY = 14, // Transfer Aborted: instance not found
90 TRANSFER_ABORT_REALM_ONLY = 15, // All players on party must be from the same realm.
91 TRANSFER_ABORT_MAP_NOT_ALLOWED = 16 // Map can't be entered at this time.
92};
93
101
104{
105 char asChar[4];
107};
108
109// ******************************************
110// Map file format defines
111// ******************************************
126
127#define MAP_AREA_NO_AREA 0x0001
128
135
136#define MAP_HEIGHT_NO_HEIGHT 0x0001
137#define MAP_HEIGHT_AS_INT16 0x0002
138#define MAP_HEIGHT_AS_INT8 0x0004
139#define MAP_HEIGHT_HAS_FLIGHT_BOUNDS 0x0008
140
148
149#define MAP_LIQUID_NO_TYPE 0x0001
150#define MAP_LIQUID_NO_HEIGHT 0x0002
151
164
165#define MAP_LIQUID_TYPE_NO_WATER 0x00
166#define MAP_LIQUID_TYPE_WATER 0x01
167#define MAP_LIQUID_TYPE_OCEAN 0x02
168#define MAP_LIQUID_TYPE_MAGMA 0x04
169#define MAP_LIQUID_TYPE_SLIME 0x08
170
171#define MAP_ALL_LIQUIDS (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_SLIME)
172
173#define MAP_LIQUID_TYPE_DARK_WATER 0x10
174
176{
178 union{
179 float* m_V9;
182 };
183 union{
184 float* m_V8;
187 };
188 G3D::Plane* _minHeightPlanes;
189 // Height level data
192
193 // Area data
195
196 // Liquid data
208
210
211 bool loadAreaData(FILE* in, uint32 offset, uint32 size);
212 bool loadHeightData(FILE* in, uint32 offset, uint32 size);
213 bool loadLiquidData(FILE* in, uint32 offset, uint32 size);
214 bool loadHolesData(FILE* in, uint32 offset, uint32 size);
215 bool isHole(int row, int col) const;
216
217 // Get height functions and pointers
218 typedef float (GridMap::*GetHeightPtr) (float x, float y) const;
219 GetHeightPtr _gridGetHeight;
220 float getHeightFromFloat(float x, float y) const;
221 float getHeightFromUint16(float x, float y) const;
222 float getHeightFromUint8(float x, float y) const;
223 float getHeightFromFlat(float x, float y) const;
224
225public:
226 GridMap();
227 ~GridMap();
228 bool loadData(char const* filename);
229 void unloadData();
230
231 uint16 getArea(float x, float y) const;
232 inline float getHeight(float x, float y) const {return (this->*_gridGetHeight)(x, y);}
233 float getMinHeight(float x, float y) const;
234 float getLiquidLevel(float x, float y) const;
235 ZLiquidStatus GetLiquidStatus(float x, float y, float z, Optional<uint8> ReqLiquidType, LiquidData* data = 0, float collisionHeight = 2.03128f); // DEFAULT_COLLISION_HEIGHT in Object.h
236};
237
238#pragma pack(push, 1)
239
258
259#pragma pack(pop)
260
261#define MAX_HEIGHT 100000.0f // can be use for find ground height at surface
262#define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE
263#define MAX_FALL_DISTANCE 250000.0f // "unlimited fall" to find VMap ground if it is available, just larger than MAX_HEIGHT - INVALID_HEIGHT
264#define DEFAULT_HEIGHT_SEARCH 50.0f // default search distance to find height at nearby locations
265#define MIN_UNLOAD_DELAY 1 // immediate unload
266#define MAP_INVALID_ZONE 0xFFFFFFFF
267
268struct RespawnInfo; // forward declaration
270{
271 bool operator()(RespawnInfo const* a, RespawnInfo const* b) const;
272};
273using ZoneDynamicInfoMap = std::unordered_map<uint32 /*zoneId*/, ZoneDynamicInfo>;
275using RespawnInfoMap = std::unordered_map<ObjectGuid::LowType, RespawnInfo*>;
286inline bool CompareRespawnInfo::operator()(RespawnInfo const* a, RespawnInfo const* b) const
287{
288 if (a == b)
289 return false;
290 if (a->respawnTime != b->respawnTime)
291 return (a->respawnTime > b->respawnTime);
292 if (a->spawnId != b->spawnId)
293 return a->spawnId < b->spawnId;
294 ASSERT(a->type != b->type, "Duplicate respawn entry for spawnId (%u,%u) found!", a->type, a->spawnId);
295 return a->type < b->type;
296}
297
300
302{
303 friend class MapReference;
304 public:
305 Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent = nullptr);
306 virtual ~Map();
307
308 MapEntry const* GetEntry() const { return i_mapEntry; }
309
310 // currently unused for normal maps
311 bool CanUnload(uint32 diff)
312 {
313 if (!m_unloadTimer)
314 return false;
315
316 if (m_unloadTimer <= diff)
317 return true;
318
319 m_unloadTimer -= diff;
320 return false;
321 }
322
323 virtual bool AddPlayerToMap(Player*);
324 virtual void RemovePlayerFromMap(Player*, bool);
325
326 template<class T> bool AddToMap(T *);
327 template<class T> void RemoveFromMap(T *, bool);
328
330 virtual void Update(uint32);
331
332 float GetVisibilityRange() const { return m_VisibleDistance; }
333 //function for setting up visibility distance for maps on per-type/per-Id basis
334 virtual void InitVisibilityDistance();
335
336 void PlayerRelocation(Player*, float x, float y, float z, float orientation);
337 void CreatureRelocation(Creature* creature, float x, float y, float z, float ang, bool respawnRelocationOnFail = true);
338 void GameObjectRelocation(GameObject* go, float x, float y, float z, float orientation, bool respawnRelocationOnFail = true);
339 void DynamicObjectRelocation(DynamicObject* go, float x, float y, float z, float orientation);
340
341 template<class T, class CONTAINER>
342 void Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor);
343
344 bool IsRemovalGrid(float x, float y) const
345 {
347 return !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL;
348 }
349 bool IsRemovalGrid(Position const& pos) const { return IsRemovalGrid(pos.GetPositionX(), pos.GetPositionY()); }
350
351 bool IsGridLoaded(uint32 gridId) const { return IsGridLoaded(GridCoord(gridId % MAX_NUMBER_OF_GRIDS, gridId / MAX_NUMBER_OF_GRIDS)); }
352 bool IsGridLoaded(float x, float y) const { return IsGridLoaded(Trinity::ComputeGridCoord(x, y)); }
353 bool IsGridLoaded(Position const& pos) const { return IsGridLoaded(pos.GetPositionX(), pos.GetPositionY()); }
354
355 bool GetUnloadLock(GridCoord const& p) const { return getNGrid(p.x_coord, p.y_coord)->getUnloadLock(); }
356 void SetUnloadLock(GridCoord const& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on); }
357 void LoadGrid(float x, float y);
358 void LoadAllCells();
359 bool UnloadGrid(NGridType& ngrid, bool pForce);
360 void GridMarkNoUnload(uint32 x, uint32 y);
361 void GridUnmarkNoUnload(uint32 x, uint32 y);
362 virtual void UnloadAll();
363
364 void ResetGridExpiry(NGridType &grid, float factor = 1) const
365 {
366 grid.ResetTimeTracker(time_t(float(i_gridExpiry)*factor));
367 }
368
369 time_t GetGridExpiry(void) const { return i_gridExpiry; }
370 uint32 GetId() const;
371
372 static bool ExistMap(uint32 mapid, int gx, int gy);
373 static bool ExistVMap(uint32 mapid, int gx, int gy);
374
375 static void InitStateMachine();
376 static void DeleteStateMachine();
377
378 Map const* GetParent() const { return m_parentMap; }
379
380 void GetFullTerrainStatusForPosition(uint32 phaseMask, float x, float y, float z, PositionFullTerrainStatus& data, Optional<uint8> reqLiquidType = {}, float collisionHeight = 2.03128f) const; // DEFAULT_COLLISION_HEIGHT in Object.h
381 ZLiquidStatus GetLiquidStatus(uint32 phaseMask, float x, float y, float z, Optional<uint8> ReqLiquidType, LiquidData* data = nullptr, float collisionHeight = 2.03128f) const; // DEFAULT_COLLISION_HEIGHT in Object.h
382
383 bool GetAreaInfo(uint32 phaseMask, float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId) const;
384 uint32 GetAreaId(uint32 phaseMask, float x, float y, float z) const;
385 uint32 GetAreaId(uint32 phaseMask, Position const& pos) const { return GetAreaId(phaseMask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
386 uint32 GetZoneId(uint32 phaseMask, float x, float y, float z) const;
387 uint32 GetZoneId(uint32 phaseMask, Position const& pos) const { return GetZoneId(phaseMask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
388 void GetZoneAndAreaId(uint32 phaseMask, uint32& zoneid, uint32& areaid, float x, float y, float z) const;
389 void GetZoneAndAreaId(uint32 phaseMask, uint32& zoneid, uint32& areaid, Position const& pos) const { GetZoneAndAreaId(phaseMask, zoneid, areaid, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); }
390
391 float GetWaterLevel(float x, float y) const;
392 bool IsInWater(uint32 phaseMask, float x, float y, float z, LiquidData* data = nullptr) const;
393 bool IsUnderWater(uint32 phaseMask, float x, float y, float z) const;
394
395 void MoveAllCreaturesInMoveList();
396 void MoveAllGameObjectsInMoveList();
397 void MoveAllDynamicObjectsInMoveList();
398 void RemoveAllObjectsInRemoveList();
399 virtual void RemoveAllPlayers();
400
401 // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader
402 bool CreatureRespawnRelocation(Creature* c, bool diffGridOnly);
403 bool GameObjectRespawnRelocation(GameObject* go, bool diffGridOnly);
404
405 // assert print helper
406 bool CheckGridIntegrity(Creature* c, bool moved) const;
407
408 uint32 GetInstanceId() const { return i_InstanceId; }
409 uint8 GetSpawnMode() const { return (i_spawnMode); }
410
411 Trinity::unique_weak_ptr<Map> GetWeakPtr() const { return m_weakRef; }
412 void SetWeakPtr(Trinity::unique_weak_ptr<Map> weakRef) { m_weakRef = std::move(weakRef); }
413
415 {
416 CAN_ENTER = 0,
417 CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
418 CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
419 CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
420 CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
421 CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
422 CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
423 CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
424 CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
425 CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
426 CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
427 CANNOT_ENTER_UNSPECIFIED_REASON
428 };
429 virtual EnterState CannotEnter(Player* /*player*/) { return CAN_ENTER; }
430 char const* GetMapName() const;
431
432 // have meaning only for instanced map (that have set real difficulty)
433 Difficulty GetDifficultyID() const { return Difficulty(GetSpawnMode()); }
434 MapDifficultyEntry const* GetMapDifficulty() const;
435
436 bool Instanceable() const;
437 bool IsWorldMap() const;
438 bool IsDungeon() const;
439 bool IsNonRaidDungeon() const;
440 bool IsRaid() const;
441 bool IsRaidOrHeroicDungeon() const;
442 bool IsHeroic() const;
443 bool Is25ManRaid() const;
444 bool IsBattleground() const;
445 bool IsBattleArena() const;
446 bool IsBattlegroundOrArena() const;
447 bool GetEntrancePos(int32& mapid, float& x, float& y) const;
448
449 void AddObjectToRemoveList(WorldObject* obj);
450 void AddObjectToSwitchList(WorldObject* obj, bool on);
451 virtual void DelayedUpdate(uint32 diff);
452
453 void resetMarkedCells() { marked_cells.reset(); }
454 bool isCellMarked(uint32 pCellId) { return marked_cells.test(pCellId); }
455 void markCell(uint32 pCellId) { marked_cells.set(pCellId); }
456
457 bool HavePlayers() const { return !m_mapRefManager.isEmpty(); }
458 uint32 GetPlayersCountExceptGMs() const;
459 bool ActiveObjectsNearGrid(NGridType const& ngrid) const;
460
461 void AddWorldObject(WorldObject* obj) { i_worldObjects.insert(obj); }
462 void RemoveWorldObject(WorldObject* obj) { i_worldObjects.erase(obj); }
463
464 void SendToPlayers(WorldPacket const* data) const;
465 bool SendZoneMessage(uint32 zone, WorldPacket const* packet, WorldSession const* self = nullptr, uint32 team = 0) const;
466
468 PlayerList const& GetPlayers() const { return m_mapRefManager; }
469
470 //per-map script storage
471 void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo>> const& scripts, uint32 id, Object* source, Object* target);
472 void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
473
474 // must called with AddToWorld
475 void AddToActive(WorldObject* obj);
476
477 // must called with RemoveFromWorld
478 void RemoveFromActive(WorldObject* obj);
479
480 template<class T> void SwitchGridContainers(T* obj, bool on);
481 std::unordered_map<ObjectGuid::LowType /*leaderSpawnId*/, CreatureGroup*> CreatureGroupHolder;
482
483 void UpdateIteratorBack(Player* player);
484
485 TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = nullptr, uint32 duration = 0, WorldObject* summoner = nullptr, uint32 spellId = 0, uint32 vehId = 0, ObjectGuid privateObjectOwner = ObjectGuid::Empty);
486 void SummonCreatureGroup(uint8 group, std::list<TempSummon*>* list = nullptr);
487 Player* GetPlayer(ObjectGuid const& guid);
488 Corpse* GetCorpse(ObjectGuid const& guid);
489 Creature* GetCreature(ObjectGuid const& guid);
490 GameObject* GetGameObject(ObjectGuid const& guid);
491 Creature* GetCreatureBySpawnId(ObjectGuid::LowType spawnId) const;
492 GameObject* GetGameObjectBySpawnId(ObjectGuid::LowType spawnId) const;
494 {
495 switch (type)
496 {
498 return reinterpret_cast<WorldObject*>(GetCreatureBySpawnId(spawnId));
500 return reinterpret_cast<WorldObject*>(GetGameObjectBySpawnId(spawnId));
501 default:
502 return nullptr;
503 }
504 }
505 Transport* GetTransport(ObjectGuid const& guid);
506 DynamicObject* GetDynamicObject(ObjectGuid const& guid);
507 Pet* GetPet(ObjectGuid const& guid);
508
510
511 typedef std::unordered_multimap<ObjectGuid::LowType, Creature*> CreatureBySpawnIdContainer;
512 CreatureBySpawnIdContainer& GetCreatureBySpawnIdStore() { return _creatureBySpawnIdStore; }
513 CreatureBySpawnIdContainer const& GetCreatureBySpawnIdStore() const { return _creatureBySpawnIdStore; }
514
515 typedef std::unordered_multimap<ObjectGuid::LowType, GameObject*> GameObjectBySpawnIdContainer;
516 GameObjectBySpawnIdContainer& GetGameObjectBySpawnIdStore() { return _gameobjectBySpawnIdStore; }
517 GameObjectBySpawnIdContainer const& GetGameObjectBySpawnIdStore() const { return _gameobjectBySpawnIdStore; }
518
519 std::unordered_set<Corpse*> const* GetCorpsesInCell(uint32 cellId) const
520 {
521 auto itr = _corpsesByCell.find(cellId);
522 if (itr != _corpsesByCell.end())
523 return &itr->second;
524
525 return nullptr;
526 }
527
528 Corpse* GetCorpseByPlayer(ObjectGuid const& ownerGuid) const
529 {
530 auto itr = _corpsesByPlayer.find(ownerGuid);
531 if (itr != _corpsesByPlayer.end())
532 return itr->second;
533
534 return nullptr;
535 }
536
537 MapInstanced* ToMapInstanced() { if (Instanceable()) return reinterpret_cast<MapInstanced*>(this); return nullptr; }
538 MapInstanced const* ToMapInstanced() const { if (Instanceable()) return reinterpret_cast<MapInstanced const*>(this); return nullptr; }
539
540 InstanceMap* ToInstanceMap() { if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return nullptr; }
541 InstanceMap const* ToInstanceMap() const { if (IsDungeon()) return reinterpret_cast<InstanceMap const*>(this); return nullptr; }
542
543 BattlegroundMap* ToBattlegroundMap() { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap*>(this); else return nullptr; }
544 BattlegroundMap const* ToBattlegroundMap() const { if (IsBattlegroundOrArena()) return reinterpret_cast<BattlegroundMap const*>(this); return nullptr; }
545
546 float GetWaterOrGroundLevel(uint32 phasemask, float x, float y, float z, float* ground = nullptr, bool swim = false, float collisionHeight = 2.03128f) const; // DEFAULT_COLLISION_HEIGHT in Object.h
547 float GetMinHeight(float x, float y) const;
548 float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
549 float GetGridHeight(float x, float y) const;
550 float GetHeight(Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return GetHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); }
551 float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return std::max<float>(GetHeight(x, y, z, vmap, maxSearchDist), GetGameObjectFloor(phasemask, x, y, z, maxSearchDist)); }
552 float GetHeight(uint32 phasemask, Position const& pos, bool vmap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const { return GetHeight(phasemask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), vmap, maxSearchDist); }
553 bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2, uint32 phasemask, LineOfSightChecks checks, VMAP::ModelIgnoreFlags ignoreFlags) const;
554 void Balance() { _dynamicTree.balance(); }
555 void RemoveGameObjectModel(GameObjectModel const& model) { _dynamicTree.remove(model); }
556 void InsertGameObjectModel(GameObjectModel const& model) { _dynamicTree.insert(model); }
557 bool ContainsGameObjectModel(GameObjectModel const& model) const { return _dynamicTree.contains(model);}
558 float GetGameObjectFloor(uint32 phasemask, float x, float y, float z, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const
559 {
560 return _dynamicTree.getHeight(x, y, z, maxSearchDist, phasemask);
561 }
562 bool getObjectHitPos(uint32 phasemask, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist);
563
564 /*
565 RESPAWN TIMES
566 */
567 time_t GetLinkedRespawnTime(ObjectGuid guid) const;
569 {
570 auto const& map = GetRespawnMapForType(type);
571 auto it = map.find(spawnId);
572 return (it == map.end()) ? 0 : it->second->respawnTime;
573 }
574 time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const { return GetRespawnTime(SPAWN_TYPE_CREATURE, spawnId); }
575 time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const { return GetRespawnTime(SPAWN_TYPE_GAMEOBJECT, spawnId); }
576
577 void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone);
578
579 void SaveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 entry, time_t respawnTime, uint32 gridId, CharacterDatabaseTransaction dbTrans = nullptr, bool startup = false);
580 void SaveRespawnInfoDB(RespawnInfo const& info, CharacterDatabaseTransaction dbTrans = nullptr);
581 void LoadRespawnTimes();
582 void DeleteRespawnTimes() { UnloadAllRespawnInfos(); DeleteRespawnTimesInDB(GetId(), GetInstanceId()); }
583 static void DeleteRespawnTimesInDB(uint16 mapId, uint32 instanceId);
584
585 void LoadCorpseData();
586 void DeleteCorpseData();
587 void AddCorpse(Corpse* corpse);
588 void RemoveCorpse(Corpse* corpse);
589 Corpse* ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia = false);
590 void RemoveOldCorpses();
591
592 void SendInitTransports(Player* player);
593 void SendRemoveTransports(Player* player);
594 void SendZoneDynamicInfo(uint32 zoneId, Player* player) const;
595 void SendZoneWeather(uint32 zoneId, Player* player) const;
596 void SendZoneWeather(ZoneDynamicInfo const& zoneDynamicInfo, Player* player) const;
597 void SendZoneText(uint32 zoneId, const char* text, WorldSession const* self = nullptr, uint32 team = 0) const;
598
599 void SetZoneMusic(uint32 zoneId, uint32 musicId);
600 Weather* GetOrGenerateZoneDefaultWeather(uint32 zoneId);
601 void SetZoneWeather(uint32 zoneId, WeatherState weatherId, float intensity);
602 void SetZoneOverrideLight(uint32 zoneId, uint32 areaLightId, uint32 overrideLightId, Milliseconds transitionTime);
603
604 void UpdateAreaDependentAuras();
605
606 template<HighGuid high>
608 {
609 static_assert(ObjectGuidTraits<high>::SequenceSource.HasFlag(ObjectGuidSequenceSource::Map), "Only map specific guid can be generated in Map context");
610 return GetGuidSequenceGenerator(high).Generate();
611 }
612
613 template<HighGuid high>
615 {
616 static_assert(ObjectGuidTraits<high>::SequenceSource.HasFlag(ObjectGuidSequenceSource::Map), "Only map specific guid can be generated in Map context");
617 return GetGuidSequenceGenerator(high).GetNextAfterMaxUsed();
618 }
619
621 {
622 _updateObjects.insert(obj);
623 }
624
626 {
627 _updateObjects.erase(obj);
628 }
629
631 {
632 return m_activeNonPlayers.size();
633 }
634
635 virtual std::string GetDebugInfo() const;
636
637 private:
638 void LoadMapAndVMap(int gx, int gy);
639 void LoadVMap(int gx, int gy);
640 void LoadMap(int gx, int gy, bool reload = false);
641 void LoadMMap(int gx, int gy);
642 GridMap* GetGrid(float x, float y);
643
644 void SetTimer(uint32 t) { i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t; }
645
646 void SendInitSelf(Player* player);
647
648 bool CreatureCellRelocation(Creature* creature, Cell new_cell);
649 bool GameObjectCellRelocation(GameObject* go, Cell new_cell);
650 bool DynamicObjectCellRelocation(DynamicObject* go, Cell new_cell);
651
652 template<class T> void InitializeObject(T* obj);
653 void AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang);
654 void RemoveCreatureFromMoveList(Creature* c);
655 void AddGameObjectToMoveList(GameObject* go, float x, float y, float z, float ang);
656 void RemoveGameObjectFromMoveList(GameObject* go);
657 void AddDynamicObjectToMoveList(DynamicObject* go, float x, float y, float z, float ang);
658 void RemoveDynamicObjectFromMoveList(DynamicObject* go);
659
661 std::vector<Creature*> _creaturesToMove;
662
664 std::vector<GameObject*> _gameObjectsToMove;
665
667 std::vector<DynamicObject*> _dynamicObjectsToMove;
668
669 bool IsGridLoaded(GridCoord const&) const;
670 void EnsureGridCreated(GridCoord const&);
671 void EnsureGridCreated_i(GridCoord const&);
672 bool EnsureGridLoaded(Cell const&);
673 void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object);
674
675 void buildNGridLinkage(NGridType* pNGridType) { pNGridType->link(this); }
676
678 {
679 ASSERT(x < MAX_NUMBER_OF_GRIDS && y < MAX_NUMBER_OF_GRIDS, "x = %u, y = %u", x, y);
680 return i_grids[x][y];
681 }
682
683 void setNGrid(NGridType* grid, uint32 x, uint32 y);
684 void ScriptsProcess();
685
686 void SendObjectUpdates();
687
688 protected:
689 void SetUnloadReferenceLock(GridCoord const& p, bool on) { getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on); }
690
691 std::mutex _mapLock;
692 std::mutex _gridLock;
693
701
704
706
707 typedef std::set<WorldObject*> ActiveNonPlayers;
709 ActiveNonPlayers::iterator m_activeNonPlayersIter;
710
711 // Objects that must update even in inactive grids without activating them
712 typedef std::set<Transport*> TransportsContainer;
714 TransportsContainer::iterator _transportsUpdateIter;
715
716 private:
717 Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo) const;
718 Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo, bool bReverse = false) const;
719 GameObject* _GetScriptGameObjectSourceOrTarget(Object* source, Object* target, ScriptInfo const* scriptInfo, bool bReverse = false) const;
720 Unit* _GetScriptUnit(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
721 Player* _GetScriptPlayer(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
722 Creature* _GetScriptCreature(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
723 WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, ScriptInfo const* scriptInfo) const;
724 void _ScriptProcessDoor(Object* source, Object* target, ScriptInfo const* scriptInfo) const;
725 GameObject* _FindGameObject(WorldObject* pWorldObject, ObjectGuid::LowType guid) const;
726
728
729 //used for fast base_map (e.g. MapInstanced class object) search for
730 //InstanceMaps and BattlegroundMaps...
732
735 std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
736
737 //these functions used to process player/mob aggro reactions and
738 //visibility calculations. Highly optimized for massive calculations
739 void ProcessRelocationNotifies(const uint32 diff);
740
742 std::set<WorldObject*> i_objectsToRemove;
743 std::map<WorldObject*, bool> i_objectsToSwitch;
744 std::set<WorldObject*> i_worldObjects;
745
746 typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap;
748
749 public:
750 void ProcessRespawns();
751 void ApplyDynamicModeRespawnScaling(WorldObject const* obj, ObjectGuid::LowType spawnId, uint32& respawnDelay, uint32 mode) const;
752
753 private:
754 // if return value is true, we can respawn
755 // if return value is false, reschedule the respawn to new value of info->respawnTime iff nonzero, delete otherwise
756 // if return value is false and info->respawnTime is nonzero, it is guaranteed to be greater than time(NULL)
757 bool CheckRespawn(RespawnInfo* info);
758 void DoRespawn(SpawnObjectType type, ObjectGuid::LowType spawnId, uint32 gridId);
759 bool AddRespawnInfo(RespawnInfo const& info);
760 void UnloadAllRespawnInfos();
761 RespawnInfo* GetRespawnInfo(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
762 void Respawn(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr);
763 void DeleteRespawnInfo(RespawnInfo* info, CharacterDatabaseTransaction dbTrans = nullptr);
764 void DeleteRespawnInfoFromDB(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr);
765
766 public:
767 void GetRespawnInfo(std::vector<RespawnInfo const*>& respawnData, SpawnObjectTypeMask types) const;
769 {
770 if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
771 Respawn(info, dbTrans);
772 }
773 void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans = nullptr, bool alwaysDeleteFromDB = false)
774 {
775 if (RespawnInfo* info = GetRespawnInfo(type, spawnId))
776 DeleteRespawnInfo(info, dbTrans);
777 // Some callers might need to make sure the database doesn't contain any respawn time
778 else if (alwaysDeleteFromDB)
779 DeleteRespawnInfoFromDB(type, spawnId, dbTrans);
780 }
781 size_t DespawnAll(SpawnObjectType type, ObjectGuid::LowType spawnId);
782
783 bool ShouldBeSpawnedOnGridLoad(SpawnObjectType type, ObjectGuid::LowType spawnId) const;
784 template <typename T> bool ShouldBeSpawnedOnGridLoad(ObjectGuid::LowType spawnId) const { return ShouldBeSpawnedOnGridLoad(SpawnData::TypeFor<T>, spawnId); }
785
786 SpawnGroupTemplateData const* GetSpawnGroupData(uint32 groupId) const;
787
788 bool IsSpawnGroupActive(uint32 groupId) const;
789
790 // Enable the spawn group, which causes all creatures in it to respawn (unless they have a respawn timer)
791 // The force flag can be used to force spawning additional copies even if old copies are still around from a previous spawn
792 bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn = false, bool force = false, std::vector<WorldObject*>* spawnedObjects = nullptr);
793
794 // Despawn all creatures in the spawn group if spawned, optionally delete their respawn timer, and disable the group
795 bool SpawnGroupDespawn(uint32 groupId, bool deleteRespawnTimes = false, size_t* count = nullptr);
796
797 // Disable the spawn group, which prevents any creatures in the group from respawning until re-enabled
798 // This will not affect any already-present creatures in the group
799 void SetSpawnGroupInactive(uint32 groupId) { SetSpawnGroupActive(groupId, false); }
800
801 typedef std::function<void(Map*)> FarSpellCallback;
802 void AddFarSpellCallback(FarSpellCallback&& callback);
803
804 private:
805 // Type specific code for add/remove to/from grid
806 template<class T>
807 void AddToGrid(T* object, Cell const& cell);
808
809 template<class T>
810 void DeleteFromWorld(T*);
811
813 {
814 m_activeNonPlayers.insert(obj);
815 }
816
818 {
819 // Map::Update for active object in proccess
820 if (m_activeNonPlayersIter != m_activeNonPlayers.end())
821 {
822 ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
823 if (itr == m_activeNonPlayers.end())
824 return;
825 if (itr == m_activeNonPlayersIter)
826 ++m_activeNonPlayersIter;
827 m_activeNonPlayers.erase(itr);
828 }
829 else
830 m_activeNonPlayers.erase(obj);
831 }
832
833 std::unique_ptr<RespawnListContainer> _respawnTimes;
837 {
838 switch (type)
839 {
840 default:
841 ABORT();
843 return _creatureRespawnTimesBySpawnId;
845 return _gameObjectRespawnTimesBySpawnId;
846 }
847 }
849 {
850 switch (type)
851 {
852 default:
853 ABORT();
855 return _creatureRespawnTimesBySpawnId;
857 return _gameObjectRespawnTimesBySpawnId;
858 }
859 }
860
861 void SetSpawnGroupActive(uint32 groupId, bool state);
862 std::unordered_set<uint32> _toggledSpawnGroupIds;
863
865 std::unordered_map<uint32, uint32> _zonePlayerCountMap;
866
869
870 ObjectGuidGenerator& GetGuidSequenceGenerator(HighGuid high);
871
872 std::map<HighGuid, std::unique_ptr<ObjectGuidGenerator>> _guidGenerators;
876 std::unordered_map<uint32/*cellId*/, std::unordered_set<Corpse*>> _corpsesByCell;
877 std::unordered_map<ObjectGuid, Corpse*> _corpsesByPlayer;
878 std::unordered_set<Corpse*> _corpseBones;
879
880 std::unordered_set<Object*> _updateObjects;
881
883};
884
894
896{
897 public:
898 InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent, TeamId InstanceTeam);
899 ~InstanceMap();
900 bool AddPlayerToMap(Player*) override;
901 void RemovePlayerFromMap(Player*, bool) override;
902 void Update(uint32) override;
903 void CreateInstanceData(bool load);
904 bool Reset(uint8 method);
905 uint32 GetScriptId() const { return i_script_id; }
906 std::string const& GetScriptName() const;
907 InstanceScript* GetInstanceScript() { return i_data; }
908 InstanceScript const* GetInstanceScript() const { return i_data; }
909 void PermBindAllPlayers();
910 void UnloadAll() override;
911 EnterState CannotEnter(Player* player) override;
912 void SendResetWarnings(uint32 timeLeft) const;
913 void SetResetSchedule(bool on);
914
915 /* this checks if any players have a permanent bind (included reactivatable expired binds) to the instance ID
916 it needs a DB query, so use sparingly */
917 bool HasPermBoundPlayers() const;
918 uint32 GetMaxPlayers() const;
919 uint32 GetMaxResetDelay() const;
920 TeamId GetTeamIdInInstance() const { return i_script_team; }
921 Team GetTeamInInstance() const { return i_script_team == TEAM_ALLIANCE ? ALLIANCE : HORDE; }
922
923 virtual void InitVisibilityDistance() override;
924
925 std::string GetDebugInfo() const override;
926 private:
932};
933
935{
936 public:
937 BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent, uint8 spawnMode);
939
940 bool AddPlayerToMap(Player*) override;
941 void RemovePlayerFromMap(Player*, bool) override;
942 EnterState CannotEnter(Player* player) override;
943 void SetUnload();
944 //void UnloadAll(bool pForce);
945 void RemoveAllPlayers() override;
946
947 virtual void InitVisibilityDistance() override;
948 Battleground* GetBG() { return m_bg; }
949 void SetBG(Battleground* bg) { m_bg = bg; }
950 private:
952};
953
954template<class T, class CONTAINER>
955inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
956{
957 const uint32 x = cell.GridX();
958 const uint32 y = cell.GridY();
959 const uint32 cell_x = cell.CellX();
960 const uint32 cell_y = cell.CellY();
961
962 if (!cell.NoCreate())
963 EnsureGridLoaded(cell);
964
965 NGridType* grid = getNGrid(x, y);
966 if (grid && grid->isGridObjectDataLoaded())
967 grid->VisitGrid(cell_x, cell_y, visitor);
968}
969#endif
Difficulty
Definition DBCEnums.h:279
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint16_t uint16
Definition Define.h:134
uint32_t uint32
Definition Define.h:133
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::string GetDebugInfo()
Definition Errors.cpp:155
#define ABORT
Definition Errors.h:74
#define ASSERT
Definition Errors.h:68
#define MIN_GRID_DELAY
Definition GridDefines.h:43
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
#define MAX_NUMBER_OF_GRIDS
Definition GridDefines.h:36
std::conditional_t< IntrusiveLink !=nullptr, Trinity::Impl::MPSCQueueIntrusive< T, IntrusiveLink >, Trinity::Impl::MPSCQueueNonIntrusive< T > > MPSCQueue
Definition MPSCQueue.h:167
ZLiquidStatus
Definition MapDefines.h:74
#define DEFAULT_HEIGHT_SEARCH
Definition Map.h:264
std::unordered_map< ObjectGuid::LowType, RespawnInfo * > RespawnInfoMap
Definition Map.h:275
InstanceResetMethod
Definition Map.h:886
@ INSTANCE_RESET_GROUP_DISBAND
Definition Map.h:890
@ INSTANCE_RESET_GROUP_JOIN
Definition Map.h:891
@ INSTANCE_RESET_CHANGE_DIFFICULTY
Definition Map.h:888
@ INSTANCE_RESET_RESPAWN_DELAY
Definition Map.h:892
@ INSTANCE_RESET_GLOBAL
Definition Map.h:889
@ INSTANCE_RESET_ALL
Definition Map.h:887
std::unordered_map< uint32, ZoneDynamicInfo > ZoneDynamicInfoMap
Definition Map.h:273
TypeUnorderedMapContainer< AllMapStoredObjectTypes, ObjectGuid > MapStoredObjectTypesContainer
Definition Map.h:299
TransferAbortReason
Definition Map.h:74
@ TRANSFER_ABORT_TOO_MANY_INSTANCES
Definition Map.h:79
@ TRANSFER_ABORT_DIFFICULTY
Definition Map.h:83
@ TRANSFER_ABORT_UNIQUE_MESSAGE
Definition Map.h:84
@ TRANSFER_ABORT_MAP_NOT_ALLOWED
Definition Map.h:91
@ TRANSFER_ABORT_INSUF_EXPAN_LVL
Definition Map.h:82
@ TRANSFER_ABORT_TOO_MANY_REALM_INSTANCES
Definition Map.h:85
@ TRANSFER_ABORT_MAX_PLAYERS
Definition Map.h:77
@ TRANSFER_ABORT_TIMEOUT
Definition Map.h:88
@ TRANSFER_ABORT_ZONE_IN_COMBAT
Definition Map.h:81
@ TRANSFER_ABORT_NONE
Definition Map.h:75
@ TRANSFER_ABORT_LOGGING_OUT
Definition Map.h:80
@ TRANSFER_ABORT_NOT_FOUND
Definition Map.h:78
@ TRANSFER_ABORT_NEED_GROUP
Definition Map.h:86
@ TRANSFER_ABORT_BUSY
Definition Map.h:89
@ TRANSFER_ABORT_NEED_SERVER
Definition Map.h:87
@ TRANSFER_ABORT_REALM_ONLY
Definition Map.h:90
@ TRANSFER_ABORT_ERROR
Definition Map.h:76
@ GRID_STATE_REMOVAL
Definition NGrid.h:61
HighGuid
Definition ObjectGuid.h:63
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
TeamId
@ TEAM_ALLIANCE
@ ALLIANCE
@ HORDE
LineOfSightChecks
SpawnObjectTypeMask
Definition SpawnData.h:38
SpawnObjectType
Definition SpawnData.h:30
@ SPAWN_TYPE_GAMEOBJECT
Definition SpawnData.h:32
@ SPAWN_TYPE_CREATURE
Definition SpawnData.h:31
bool isHole(int holes, int i, int j)
Definition adt.cpp:34
Battleground * GetBG()
Definition Map.h:948
Battleground * m_bg
Definition Map.h:951
void SetBG(Battleground *bg)
Definition Map.h:949
Definition Map.h:176
uint8 * m_uint8_V8
Definition Map.h:186
float _liquidLevel
Definition Map.h:197
uint16 * m_uint16_V8
Definition Map.h:185
uint16 * _liquidEntry
Definition Map.h:198
uint8 _liquidGlobalFlags
Definition Map.h:203
uint8 _liquidOffY
Definition Map.h:205
uint16 _liquidGlobalEntry
Definition Map.h:202
uint8 _liquidOffX
Definition Map.h:204
uint8 * m_uint8_V9
Definition Map.h:181
float * _liquidMap
Definition Map.h:200
uint32 _flags
Definition Map.h:177
uint8 _liquidHeight
Definition Map.h:207
uint16 * _areaMap
Definition Map.h:194
float _gridIntHeightMultiplier
Definition Map.h:191
uint8 _liquidWidth
Definition Map.h:206
uint8 * _liquidFlags
Definition Map.h:199
float * m_V9
Definition Map.h:179
G3D::Plane * _minHeightPlanes
Definition Map.h:188
uint16 _gridArea
Definition Map.h:201
uint16 * m_uint16_V9
Definition Map.h:180
float getHeight(float x, float y) const
Definition Map.h:232
float _gridHeight
Definition Map.h:190
GetHeightPtr _gridGetHeight
Definition Map.h:219
uint16 * _holes
Definition Map.h:209
float * m_V8
Definition Map.h:184
Definition Group.h:165
bool m_resetAfterUnload
Definition Map.h:927
InstanceScript const * GetInstanceScript() const
Definition Map.h:908
bool m_unloadWhenEmpty
Definition Map.h:928
TeamId GetTeamIdInInstance() const
Definition Map.h:920
TeamId i_script_team
Definition Map.h:931
uint32 GetScriptId() const
Definition Map.h:905
Team GetTeamInInstance() const
Definition Map.h:921
InstanceScript * i_data
Definition Map.h:929
uint32 i_script_id
Definition Map.h:930
InstanceScript * GetInstanceScript()
Definition Map.h:907
Definition Map.h:302
MapEntry const * i_mapEntry
Definition Map.h:694
uint8 i_spawnMode
Definition Map.h:695
uint32 GetZoneId(uint32 phaseMask, Position const &pos) const
Definition Map.h:387
bool _creatureToMoveLock
Definition Map.h:660
float GetHeight(uint32 phasemask, float x, float y, float z, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.h:551
std::map< WorldObject *, bool > i_objectsToSwitch
Definition Map.h:743
WorldObject * GetWorldObjectBySpawnId(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.h:493
std::unordered_map< uint32, uint32 > _zonePlayerCountMap
Definition Map.h:865
std::vector< Creature * > _creaturesToMove
Definition Map.h:661
void GetZoneAndAreaId(uint32 phaseMask, uint32 &zoneid, uint32 &areaid, Position const &pos) const
Definition Map.h:389
CreatureBySpawnIdContainer const & GetCreatureBySpawnIdStore() const
Definition Map.h:513
bool IsRemovalGrid(Position const &pos) const
Definition Map.h:349
void SetSpawnGroupInactive(uint32 groupId)
Definition Map.h:799
std::unordered_set< Corpse * > const * GetCorpsesInCell(uint32 cellId) const
Definition Map.h:519
std::unordered_multimap< ObjectGuid::LowType, Creature * > CreatureBySpawnIdContainer
Definition Map.h:511
std::unordered_map< ObjectGuid, Corpse * > _corpsesByPlayer
Definition Map.h:877
void SetWeakPtr(Trinity::unique_weak_ptr< Map > weakRef)
Definition Map.h:412
bool ShouldBeSpawnedOnGridLoad(ObjectGuid::LowType spawnId) const
Definition Map.h:784
MapStoredObjectTypesContainer & GetObjectsStore()
Definition Map.h:509
TransportsContainer::iterator _transportsUpdateIter
Definition Map.h:714
InstanceMap const * ToInstanceMap() const
Definition Map.h:541
void RemoveFromActiveHelper(WorldObject *obj)
Definition Map.h:817
std::function< void(Map *)> FarSpellCallback
Definition Map.h:801
bool GetUnloadLock(GridCoord const &p) const
Definition Map.h:355
void RemoveGameObjectModel(GameObjectModel const &model)
Definition Map.h:555
void DeleteRespawnTimes()
Definition Map.h:582
void RemoveUpdateObject(Object *obj)
Definition Map.h:625
RespawnInfoMap _gameObjectRespawnTimesBySpawnId
Definition Map.h:835
uint32 m_unloadTimer
Definition Map.h:698
bool IsGridLoaded(Position const &pos) const
Definition Map.h:353
MapRefManager PlayerList
Definition Map.h:467
uint8 GetSpawnMode() const
Definition Map.h:409
void SetTimer(uint32 t)
Definition Map.h:644
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition Map.h:735
BattlegroundMap const * ToBattlegroundMap() const
Definition Map.h:544
bool CanUnload(uint32 diff)
Definition Map.h:311
IntervalTimer _weatherUpdateTimer
Definition Map.h:868
Map * m_parentMap
Definition Map.h:731
void RemoveRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr, bool alwaysDeleteFromDB=false)
Definition Map.h:773
bool _dynamicObjectsToMoveLock
Definition Map.h:666
NGridType * getNGrid(uint32 x, uint32 y) const
Definition Map.h:677
void AddToActiveHelper(WorldObject *obj)
Definition Map.h:812
bool _gameObjectsToMoveLock
Definition Map.h:663
bool ContainsGameObjectModel(GameObjectModel const &model) const
Definition Map.h:557
Map const * GetParent() const
Definition Map.h:378
float GetHeight(uint32 phasemask, Position const &pos, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.h:552
uint32 _respawnCheckTimer
Definition Map.h:864
bool HavePlayers() const
Definition Map.h:457
bool IsRemovalGrid(float x, float y) const
Definition Map.h:344
MapInstanced const * ToMapInstanced() const
Definition Map.h:538
std::unordered_map< uint32, std::unordered_set< Corpse * > > _corpsesByCell
Definition Map.h:876
MapRefManager m_mapRefManager
Definition Map.h:702
void resetMarkedCells()
Definition Map.h:453
RespawnInfoMap const & GetRespawnMapForType(SpawnObjectType type) const
Definition Map.h:848
void Visit(Cell const &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
Definition Map.h:955
ScriptScheduleMap m_scriptSchedule
Definition Map.h:747
ObjectGuid::LowType GetMaxLowGuid()
Definition Map.h:614
void AddWorldObject(WorldObject *obj)
Definition Map.h:461
void ResetGridExpiry(NGridType &grid, float factor=1) const
Definition Map.h:364
DynamicMapTree _dynamicTree
Definition Map.h:700
void Respawn(SpawnObjectType type, ObjectGuid::LowType spawnId, CharacterDatabaseTransaction dbTrans=nullptr)
Definition Map.h:768
std::vector< GameObject * > _gameObjectsToMove
Definition Map.h:664
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:607
uint32 GetAreaId(uint32 phaseMask, Position const &pos) const
Definition Map.h:385
std::unordered_map< ObjectGuid::LowType, CreatureGroup * > CreatureGroupHolder
Definition Map.h:481
time_t i_gridExpiry
Definition Map.h:727
int32 m_VisibilityNotifyPeriod
Definition Map.h:705
std::unordered_set< Corpse * > _corpseBones
Definition Map.h:878
MPSCQueue< FarSpellCallback > _farSpellCallbacks
Definition Map.h:882
time_t GetGORespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:575
bool i_scriptLock
Definition Map.h:741
RespawnInfoMap & GetRespawnMapForType(SpawnObjectType type)
Definition Map.h:836
std::unordered_set< uint32 > _toggledSpawnGroupIds
Definition Map.h:862
bool isCellMarked(uint32 pCellId)
Definition Map.h:454
time_t GetCreatureRespawnTime(ObjectGuid::LowType spawnId) const
Definition Map.h:574
BattlegroundMap * ToBattlegroundMap()
Definition Map.h:543
Trinity::unique_weak_ptr< Map > m_weakRef
Definition Map.h:697
MapRefManager::iterator m_mapRefIter
Definition Map.h:703
std::multimap< time_t, ScriptAction > ScriptScheduleMap
Definition Map.h:746
std::unique_ptr< RespawnListContainer > _respawnTimes
Definition Map.h:833
virtual EnterState CannotEnter(Player *)
Definition Map.h:429
time_t GetRespawnTime(SpawnObjectType type, ObjectGuid::LowType spawnId) const
Definition Map.h:568
void SetUnloadReferenceLock(GridCoord const &p, bool on)
Definition Map.h:689
void Balance()
Definition Map.h:554
ZoneDynamicInfoMap _zoneDynamicInfo
Definition Map.h:867
void RemoveWorldObject(WorldObject *obj)
Definition Map.h:462
float GetGameObjectFloor(uint32 phasemask, float x, float y, float z, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.h:558
std::set< WorldObject * > i_worldObjects
Definition Map.h:744
Difficulty GetDifficultyID() const
Definition Map.h:433
ActiveNonPlayers m_activeNonPlayers
Definition Map.h:708
GameObjectBySpawnIdContainer & GetGameObjectBySpawnIdStore()
Definition Map.h:516
void InsertGameObjectModel(GameObjectModel const &model)
Definition Map.h:556
void SetUnloadLock(GridCoord const &p, bool on)
Definition Map.h:356
std::set< Transport * > TransportsContainer
Definition Map.h:712
std::unordered_set< Object * > _updateObjects
Definition Map.h:880
void buildNGridLinkage(NGridType *pNGridType)
Definition Map.h:675
MapEntry const * GetEntry() const
Definition Map.h:308
Trinity::unique_weak_ptr< Map > GetWeakPtr() const
Definition Map.h:411
std::set< WorldObject * > i_objectsToRemove
Definition Map.h:742
MapStoredObjectTypesContainer _objectsStore
Definition Map.h:873
bool IsGridLoaded(float x, float y) const
Definition Map.h:352
friend class MapReference
Definition Map.h:303
float m_VisibleDistance
Definition Map.h:699
float GetVisibilityRange() const
Definition Map.h:332
InstanceMap * ToInstanceMap()
Definition Map.h:540
Corpse * GetCorpseByPlayer(ObjectGuid const &ownerGuid) const
Definition Map.h:528
bool IsGridLoaded(uint32 gridId) const
Definition Map.h:351
std::set< WorldObject * > ActiveNonPlayers
Definition Map.h:707
void markCell(uint32 pCellId)
Definition Map.h:455
std::mutex _mapLock
Definition Map.h:691
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
Definition Map.h:512
time_t GetGridExpiry(void) const
Definition Map.h:369
bool EnsureGridLoaded(Cell const &)
Definition Map.cpp:533
std::vector< DynamicObject * > _dynamicObjectsToMove
Definition Map.h:667
uint32 GetInstanceId() const
Definition Map.h:408
TransportsContainer _transports
Definition Map.h:713
PlayerList const & GetPlayers() const
Definition Map.h:468
GameObjectBySpawnIdContainer const & GetGameObjectBySpawnIdStore() const
Definition Map.h:517
void AddUpdateObject(Object *obj)
Definition Map.h:620
MapInstanced * ToMapInstanced()
Definition Map.h:537
RespawnInfoMap _creatureRespawnTimesBySpawnId
Definition Map.h:834
CreatureBySpawnIdContainer _creatureBySpawnIdStore
Definition Map.h:874
uint32 i_InstanceId
Definition Map.h:696
EnterState
Definition Map.h:415
@ CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE
Definition Map.h:422
@ CANNOT_ENTER_TOO_MANY_INSTANCES
Definition Map.h:424
@ CANNOT_ENTER_MAX_PLAYERS
Definition Map.h:425
@ CANNOT_ENTER_ZONE_IN_COMBAT
Definition Map.h:426
@ CANNOT_ENTER_NO_ENTRY
Definition Map.h:418
@ CANNOT_ENTER_DIFFICULTY_UNAVAILABLE
Definition Map.h:420
@ CANNOT_ENTER_INSTANCE_BIND_MISMATCH
Definition Map.h:423
@ CANNOT_ENTER_UNINSTANCED_DUNGEON
Definition Map.h:419
@ CANNOT_ENTER_NOT_IN_RAID
Definition Map.h:421
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition Map.h:709
std::unordered_multimap< ObjectGuid::LowType, GameObject * > GameObjectBySpawnIdContainer
Definition Map.h:515
std::map< HighGuid, std::unique_ptr< ObjectGuidGenerator > > _guidGenerators
Definition Map.h:872
float GetHeight(Position const &pos, bool vmap=true, float maxSearchDist=DEFAULT_HEIGHT_SEARCH) const
Definition Map.h:550
std::mutex _gridLock
Definition Map.h:692
GameObjectBySpawnIdContainer _gameobjectBySpawnIdStore
Definition Map.h:875
size_t GetActiveNonPlayersCount() const
Definition Map.h:630
Definition NGrid.h:73
bool isGridObjectDataLoaded() const
Definition NGrid.h:103
void ResetTimeTracker(time_t interval)
Definition NGrid.h:113
void VisitGrid(const uint32 x, const uint32 y, TypeContainerVisitor< T, TypeMapContainer< TT > > &visitor)
Definition NGrid.h:149
void link(GridRefManager< NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES > > *pTo)
Definition NGrid.h:99
static ObjectGuid const Empty
Definition ObjectGuid.h:140
uint32 LowType
Definition ObjectGuid.h:142
Definition Pet.h:40
Trinity::unique_trackable_ptr companion class, replicating what std::weak_ptr is to std::shared_ptr.
Definition Unit.h:783
Weather for one zone.
Definition Weather.h:67
Player session in the World.
WeatherState
Definition Weather.h:47
GridCoord ComputeGridCoord(float x, float y)
Definition Cell.h:47
uint32 GridX() const
Definition Cell.h:72
bool NoCreate() const
Definition Cell.h:74
uint32 GridY() const
Definition Cell.h:73
uint32 CellX() const
Definition Cell.h:70
uint32 CellY() const
Definition Cell.h:71
bool operator()(RespawnInfo const *a, RespawnInfo const *b) const
Definition Map.h:286
uint32 x_coord
uint32 y_coord
float GetPositionZ() const
Definition Position.h:81
float GetPositionX() const
Definition Position.h:79
float GetPositionY() const
Definition Position.h:80
uint32 gridId
Definition Map.h:284
ObjectGuid::LowType spawnId
Definition Map.h:281
time_t respawnTime
Definition Map.h:283
virtual ~RespawnInfo()
uint32 entry
Definition Map.h:282
SpawnObjectType type
Definition Map.h:280
ObjectGuid targetGUID
Definition Map.h:97
ObjectGuid ownerGUID
Definition Map.h:98
ObjectGuid sourceGUID
Definition Map.h:96
ScriptInfo const * script
‍owner of source if source is item
Definition Map.h:99
ZoneDynamicInfo()
Definition Map.cpp:71
std::vector< LightOverride > LightOverrides
Definition Map.h:256
uint32 MusicId
Definition Map.h:244
WeatherState WeatherId
Definition Map.h:247
std::unique_ptr< Weather > DefaultWeather
Definition Map.h:246
float Intensity
Definition Map.h:248
uint32 fourcc
Definition Map.h:131
uint16 gridArea
Definition Map.h:133
uint16 flags
Definition Map.h:132
u_map_magic mapMagic
Definition Map.h:114
uint32 holesSize
Definition Map.h:124
uint32 liquidMapSize
Definition Map.h:122
uint32 areaMapOffset
Definition Map.h:117
uint32 heightMapSize
Definition Map.h:120
uint32 heightMapOffset
Definition Map.h:119
u_map_magic buildMagic
Definition Map.h:116
uint32 holesOffset
Definition Map.h:123
uint32 versionMagic
Definition Map.h:115
uint32 liquidMapOffset
Definition Map.h:121
uint32 areaMapSize
Definition Map.h:118
float gridMaxHeight
Definition Map.h:146
uint32 flags
Definition Map.h:144
float gridHeight
Definition Map.h:145
uint32 fourcc
Definition Map.h:143
uint8 offsetX
Definition Map.h:158
uint32 fourcc
Definition Map.h:154
uint8 liquidFlags
Definition Map.h:156
uint8 width
Definition Map.h:160
uint8 height
Definition Map.h:161
uint8 flags
Definition Map.h:155
uint16 liquidType
Definition Map.h:157
uint8 offsetY
Definition Map.h:159
float liquidLevel
Definition Map.h:162
Represents a map magic value of 4 bytes (used in versions)
Definition Map.h:104
char asChar[4]
Definition Map.h:105
uint32 asUInt
‍Non-null terminated string
Definition Map.h:106