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