OregonCore  revision fb2a440-git
Your Favourite TBC server
Map.h
Go to the documentation of this file.
1 /*
2  * This file is part of the OregonCore 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 OREGON_MAP_H
19 #define OREGON_MAP_H
20 
21 #include "Platform/Define.h"
23 #include "ace/RW_Thread_Mutex.h"
24 #include "ace/Thread_Mutex.h"
25 
26 #include "DBCStructure.h"
27 #include "GridDefines.h"
28 #include "Cell.h"
29 #include "Timer.h"
30 #include "SharedDefines.h"
32 #include "MapRefManager.h"
33 
34 #include "DynamicTree.h"
35 #include "GameObjectModel.h"
36 
37 #include <bitset>
38 #include <list>
39 #include <set>
40 
41 class Unit;
42 class WorldPacket;
43 class InstanceData;
44 class Group;
45 class InstanceSave;
46 class Object;
47 class WorldObject;
48 class TempSummon;
49 class Player;
50 class CreatureGroup;
51 struct ScriptInfo;
52 struct ScriptAction;
53 struct Position;
54 class Battleground;
55 class InstanceMap;
56 namespace Oregon { struct ObjectUpdater; }
57 
59 {
62  uint64 ownerGUID; // owner of source if source is item
63  ScriptInfo const* script; // pointer to static script data
64 };
65 
66 //******************************************
67 // Map file format defines
68 //******************************************
69 static const uint32 MAP_MAGIC = 0x5350414D; // SPAM
70 static const uint32 MAP_VERSION_MAGIC = 0x332E3176; // 3.1v
71 static const uint32 MAP_AREA_MAGIC = 0x41455241; // AERA
72 static const uint32 MAP_HEIGHT_MAGIC = 0x5447484D; // TGHM
73 static const uint32 MAP_LIQUID_MAGIC = 0x51494C4D; // QILM
74 
76 {
88 };
89 
90 #define MAP_AREA_NO_AREA 0x0001
91 
93 {
97 };
98 
99 #define MAP_HEIGHT_NO_HEIGHT 0x0001
100 #define MAP_HEIGHT_AS_INT16 0x0002
101 #define MAP_HEIGHT_AS_INT8 0x0004
102 
104 {
107  float gridHeight;
109 };
110 
111 #define MAP_LIQUID_NO_TYPE 0x0001
112 #define MAP_LIQUID_NO_HEIGHT 0x0002
113 
115 {
123  float liquidLevel;
124 };
125 
127 {
128  LIQUID_MAP_NO_WATER = 0x00000000,
130  LIQUID_MAP_WATER_WALK = 0x00000002,
131  LIQUID_MAP_IN_WATER = 0x00000004,
133 };
134 
135 // defined in DBC and left shifted for flag usage
136 #define MAP_LIQUID_TYPE_NO_WATER 0x00
137 #define MAP_LIQUID_TYPE_MAGMA 0x01
138 #define MAP_LIQUID_TYPE_OCEAN 0x02
139 #define MAP_LIQUID_TYPE_SLIME 0x04
140 #define MAP_LIQUID_TYPE_WATER 0x08
141 
142 #define MAP_ALL_LIQUIDS (MAP_LIQUID_TYPE_WATER | MAP_LIQUID_TYPE_MAGMA | MAP_LIQUID_TYPE_OCEAN | MAP_LIQUID_TYPE_SLIME)
143 
144 #define MAP_LIQUID_TYPE_DARK_WATER 0x10
145 #define MAP_LIQUID_TYPE_WMO_WATER 0x20
146 
148 {
151  float level;
152  float depth_level;
153 };
154 
155 class GridMap
156 {
158  // Area data
161  // Height level data
164  union
165  {
166  float* m_V9;
169  };
170  union
171  {
172  float* m_V8;
175  };
176  // Liquid data
185  float* _liquidMap;
186 
187  bool loadAreaData(FILE* in, uint32 offset, uint32 size);
188  bool loadHeightData(FILE* in, uint32 offset, uint32 size);
189  bool loadLiquidData(FILE* in, uint32 offset, uint32 size);
190 
191  // Get height functions and pointers
192  typedef float (GridMap::*pGetHeightPtr) (float x, float y) const;
193  pGetHeightPtr m_gridGetHeight;
194  float getHeightFromFloat(float x, float y) const;
195  float getHeightFromUint16(float x, float y) const;
196  float getHeightFromUint8(float x, float y) const;
197  float getHeightFromFlat(float x, float y) const;
198 
199  public:
200  GridMap();
201  ~GridMap();
202  bool loadData(const char* filename);
203  void unloadData();
204 
205  uint16 getArea(float x, float y);
206  inline float getHeight(float x, float y)
207  {
208  return (this->*m_gridGetHeight)(x, y);
209  }
210  float getLiquidLevel(float x, float y);
211  uint8 getTerrainType(float x, float y);
212  ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0);
213 };
214 
216 {
217  CreatureMover() : x(0), y(0), z(0), ang(0) {}
218  CreatureMover(float _x, float _y, float _z, float _ang) : x(_x), y(_y), z(_z), ang(_ang) {}
219 
220  float x, y, z, ang;
221 };
222 
223 // GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
224 #if defined(__GNUC__)
225 #pragma pack(1)
226 #else
227 #pragma pack(push,1)
228 #endif
229 
231 {
237  float startLocX;
238  float startLocY;
239  float startLocZ;
240  float startLocO;
243 };
244 
246 {
248 };
249 
250 #if defined(__GNUC__)
251 #pragma pack()
252 #else
253 #pragma pack(pop)
254 #endif
255 
256 typedef UNORDERED_MAP<Creature*, CreatureMover> CreatureMoveList;
257 
258 #define MAX_HEIGHT 100000.0f // can be use for find ground height at surface
259 #define INVALID_HEIGHT -100000.0f // for check, must be equal to VMAP_INVALID_HEIGHT, real value for unknown height is VMAP_INVALID_HEIGHT_VALUE
260 #define MAX_FALL_DISTANCE 250000.0f // "unlimited fall" to find VMap ground if it is available, just larger than MAX_HEIGHT - INVALID_HEIGHT
261 #define DEFAULT_HEIGHT_SEARCH 50.0f // default search distance to find height at nearby locations
262 #define MIN_UNLOAD_DELAY 1 // immediate unload
263 
264 typedef std::map<uint32/*leaderDBGUID*/, CreatureGroup*> CreatureGroupHolderType;
265 
266 class Map : public GridRefManager<NGridType>, public Oregon::ObjectLevelLockable<Map, ACE_Thread_Mutex>
267 {
268  friend class MapReference;
269  public:
270  Map(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent = NULL);
271  ~Map() override;
272 
273  // currently unused for normal maps
274  bool CanUnload(uint32 diff)
275  {
276  if (!m_unloadTimer) return false;
277  if (m_unloadTimer <= diff) return true;
278  m_unloadTimer -= diff;
279  return false;
280  }
281 
282  virtual bool AddPlayerToMap(Player*);
283  virtual void RemovePlayerFromMap(Player*, bool);
284 
285  template<class T> bool AddToMap(T*);
286  template<class T> void RemoveFromMap(T*, bool);
287 
289  virtual void Update(const uint32&);
290 
291  float GetVisibilityRange() const { return m_VisibleDistance; }
292 
293  //function for setting up visibility distance for maps on per-type/per-Id basis
294  virtual void InitVisibilityDistance();
295 
296  void PlayerRelocation(Player*, float x, float y, float z, float orientation);
297  void CreatureRelocation(Creature* creature, float x, float y, float z, float ang, bool respawnRelocationOnFail = true);
298 
299  template<class T, class CONTAINER> void Visit(const Cell& cell, TypeContainerVisitor<T, CONTAINER>& visitor);
300 
301  bool IsRemovalGrid(float x, float y) const
302  {
304  return !getNGrid(p.x_coord, p.y_coord) || getNGrid(p.x_coord, p.y_coord)->GetGridState() == GRID_STATE_REMOVAL;
305  }
306 
307  bool IsGridLoaded(float x, float y) const
308  {
309  return IsGridLoaded(Oregon::ComputeGridCoord(x, y));
310  }
311 
312  bool GetUnloadLock(const GridCoord& p) const
313  {
314  return getNGrid(p.x_coord, p.y_coord)->getUnloadLock();
315  }
316  void SetUnloadLock(const GridCoord& p, bool on)
317  {
318  getNGrid(p.x_coord, p.y_coord)->setUnloadExplicitLock(on);
319  }
320  void LoadGrid(float x, float y);
321  bool UnloadGrid(NGridType& ngrid, bool pForce);
322  virtual void UnloadAll();
323 
324  void ResetGridExpiry(NGridType& grid, float factor = 1) const
325  {
326  grid.ResetTimeTracker(time_t(float(i_gridExpiry)*factor));
327  }
328 
329  time_t GetGridExpiry(void) const
330  {
331  return i_gridExpiry;
332  }
333  uint32 GetId(void) const
334  {
335  return i_mapEntry->MapID;
336  }
337 
338  static bool ExistMap(uint32 mapid, int gx, int gy);
339  static bool ExistVMap(uint32 mapid, int gx, int gy);
340 
341  static void InitStateMachine();
342  static void DeleteStateMachine();
343 
344  Map const* GetParent() const
345  {
346  return m_parentMap;
347  }
348 
349  InstanceMap* ToInstanceMap() { if (IsDungeon()) return reinterpret_cast<InstanceMap*>(this); else return NULL; }
350  InstanceMap const* ToInstanceMap() const { if (IsDungeon()) return reinterpret_cast<InstanceMap const*>(this); return NULL; }
351 
352  float GetWaterOrGroundLevel(float x, float y, float z, float* ground = NULL, bool swim = false) const;
353  float GetHeight(float x, float y, float z, bool checkVMap = true, float maxSearchDist = DEFAULT_HEIGHT_SEARCH) const;
354 
355  ZLiquidStatus getLiquidStatus(float x, float y, float z, uint8 ReqLiquidType, LiquidData* data = 0) const;
356 
357  uint16 GetAreaFlag(float x, float y, float z, bool* isOutdoors = 0) const;
358  bool GetAreaInfo(float x, float y, float z, uint32& mogpflags, int32& adtId, int32& rootId, int32& groupId) const;
359 
360  bool IsOutdoors(float x, float y, float z) const;
361 
362  uint8 GetTerrainType(float x, float y) const;
363  float GetWaterLevel(float x, float y) const;
364  bool IsInWater(float x, float y, float z, LiquidData* data = nullptr) const;
365  bool IsUnderWater(float x, float y, float z) const;
366  bool IsSwimmable(float x, float y, float z, LiquidData* data = nullptr) const;
367 
368  static uint32 GetAreaId(uint16 areaflag, uint32 map_id);
369  static uint32 GetZoneId(uint16 areaflag, uint32 map_id);
370 
371  uint32 GetAreaId(float x, float y, float z) const
372  {
373  return GetAreaId(GetAreaFlag(x, y, z), GetId());
374  }
375 
376  uint32 GetZoneId(float x, float y, float z) const
377  {
378  return GetZoneId(GetAreaFlag(x, y, z), GetId());
379  }
380 
381  void MoveAllCreaturesInMoveList();
382  void RemoveAllObjectsInRemoveList();
383  virtual void RemoveAllPlayers();
384 
385  bool CreatureRespawnRelocation(Creature* c); // used only in MoveAllCreaturesInMoveList and ObjectGridUnloader
386 
387  // assert print helper
388  bool CheckGridIntegrity(Creature* c, bool moved) const;
389 
391  {
392  return i_InstanceId;
393  }
395  {
396  return (i_spawnMode);
397  }
398 
400  {
401  CAN_ENTER = 0,
402  CANNOT_ENTER_ALREADY_IN_MAP = 1, // Player is already in the map
403  CANNOT_ENTER_NO_ENTRY, // No map entry was found for the target map ID
404  CANNOT_ENTER_UNINSTANCED_DUNGEON, // No instance template was found for dungeon map
405  CANNOT_ENTER_DIFFICULTY_UNAVAILABLE, // Requested instance difficulty is not available for target map
406  CANNOT_ENTER_NOT_IN_RAID, // Target instance is a raid instance and the player is not in a raid group
407  CANNOT_ENTER_CORPSE_IN_DIFFERENT_INSTANCE, // Player is dead and their corpse is not in target instance
408  CANNOT_ENTER_INSTANCE_BIND_MISMATCH, // Player's permanent instance save is not compatible with their group's current instance bind
409  CANNOT_ENTER_TOO_MANY_INSTANCES, // Player has entered too many instances recently
410  CANNOT_ENTER_MAX_PLAYERS, // Target map already has the maximum number of players allowed
411  CANNOT_ENTER_ZONE_IN_COMBAT, // A boss encounter is currently in progress on the target map
412  CANNOT_ENTER_UNSPECIFIED_REASON
413  };
414  virtual EnterState CannotEnter(Player* /*player*/) { return CAN_ENTER; }
415 
416  const char* GetMapName() const;
417 
418  // have meaning only for instanced map (that have set real difficulty)
419  DungeonDifficulty GetDifficulty() const { return DungeonDifficulty(GetSpawnMode()); }
420  bool IsRegularDifficulty() const { return GetDifficulty() == DIFFICULTY_NORMAL; }
421 
422  bool Instanceable() const
423  {
424  return i_mapEntry && i_mapEntry->Instanceable();
425  }
426  // NOTE: this duplicate of Instanceable(), but Instanceable() can be changed when BG also will be instanceable
427  bool IsDungeon() const
428  {
429  return i_mapEntry && i_mapEntry->IsDungeon();
430  }
431  bool IsRaid() const
432  {
433  return i_mapEntry && i_mapEntry->IsRaid();
434  }
435  bool IsHeroic() const
436  {
437  return i_spawnMode == DIFFICULTY_HEROIC;
438  }
439  bool IsBattleground() const
440  {
441  return i_mapEntry && i_mapEntry->IsBattleground();
442  }
443  bool IsBattleArena() const
444  {
445  return i_mapEntry && i_mapEntry->IsBattleArena();
446  }
448  {
449  return i_mapEntry && i_mapEntry->IsBattlegroundOrArena();
450  }
451 
452  void AddObjectToRemoveList(WorldObject* obj);
453  void AddObjectToSwitchList(WorldObject* obj, bool on);
454  virtual void DelayedUpdate(const uint32 diff);
455 
456  void UpdateObjectVisibility(WorldObject* obj, Cell cell, CellCoord cellpair);
457  void UpdateObjectsVisibilityFor(Player* player, Cell cell, CellCoord cellpair);
458 
460  {
461  marked_cells.reset();
462  }
463  bool isCellMarked(uint32 pCellId)
464  {
465  return marked_cells.test(pCellId);
466  }
467  void markCell(uint32 pCellId)
468  {
469  marked_cells.set(pCellId);
470  }
471 
472  bool HavePlayers() const
473  {
474  return !m_mapRefManager.isEmpty();
475  }
476  uint32 GetPlayersCountExceptGMs() const;
477  bool ActiveObjectsNearGrid(NGridType const& ngrid) const;
478 
480  {
481  i_worldObjects.insert(obj);
482  }
484  {
485  i_worldObjects.erase(obj);
486  }
487 
488  void SendToPlayers(WorldPacket const* data) const;
489 
491  PlayerList const& GetPlayers() const
492  {
493  return m_mapRefManager;
494  }
495 
496  //per-map script storage
497  void ScriptsStart(std::map<uint32, std::multimap<uint32, ScriptInfo> > const& scripts, uint32 id, Object* source, Object* target);
498  void ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* source, Object* target);
499 
500  // must called with AddToWorld
501  template<class T>
502  void AddToActive(T* obj)
503  {
504  AddToActiveHelper(obj);
505  }
506 
507  void AddToActive(Creature* obj);
508 
509  // must called with RemoveFromWorld
510  template<class T>
511  void RemoveFromActive(T* obj)
512  {
513  RemoveFromActiveHelper(obj);
514  }
515 
516  void RemoveFromActive(Creature* obj);
517 
518  void SwitchGridContainers(Creature* creature, bool toWorldContainer);
519  template<class NOTIFIER> void VisitAll(const float& x, const float& y, float radius, NOTIFIER& notifier);
520  template<class NOTIFIER> void VisitWorld(const float& x, const float& y, float radius, NOTIFIER& notifier);
521  template<class NOTIFIER> void VisitGrid(const float& x, const float& y, float radius, NOTIFIER& notifier);
523 
524  void UpdateIteratorBack(Player* player);
525 
526  TempSummon* SummonCreature(uint32 entry, const Position& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, TempSummonType spwType = TEMPSUMMON_MANUAL_DESPAWN);
527  Creature* GetCreature(uint64 guid);
528  GameObject* GetGameObject(uint64 guid);
529  DynamicObject* GetDynamicObject(uint64 guid);
530 
531  bool isInLineOfSight(float x1, float y1, float z1, float x2, float y2, float z2) const;
532  void Balance() { m_dyn_tree.balance(); }
533  void Remove(const GameObjectModel& mdl) { m_dyn_tree.remove(mdl); }
534  void Insert(const GameObjectModel& mdl) { m_dyn_tree.insert(mdl); }
535  bool Contains(const GameObjectModel& mdl) const { return m_dyn_tree.contains(mdl);}
536  bool getObjectHitPos(float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist);
537  private:
538  void LoadMapAndVMap(int gx, int gy);
539  void LoadVMap(int gx, int gy);
540  void LoadMMap(int gx, int gy);
541  void LoadMap(int gx, int gy, bool reload = false);
542  GridMap* GetGrid(float x, float y);
543 
544  void SetTimer(uint32 t)
545  {
546  i_gridExpiry = t < MIN_GRID_DELAY ? MIN_GRID_DELAY : t;
547  }
548 
549  void SendInitSelf(Player* player);
550 
551  void SendInitTransports(Player* player);
552  void SendRemoveTransports(Player* player);
553 
554  bool CreatureCellRelocation(Creature* creature, Cell new_cell);
555 
556  void AddCreatureToMoveList(Creature* c, float x, float y, float z, float ang);
558 
559  bool IsGridLoaded(const GridCoord &) const;
560  void EnsureGridCreated(const GridCoord&);
561  bool EnsureGridLoaded(Cell const&);
562  void EnsureGridLoadedForActiveObject(Cell const&, WorldObject* object);
563 
564  void buildNGridLinkage(NGridType* pNGridType)
565  {
566  pNGridType->link(this);
567  }
568 
569  template<class T> void AddType(T* obj);
570  template<class T> void RemoveType(T* obj, bool);
571 
573  {
576  return i_grids[x][y];
577  }
578 
580  {
581  return getNGrid(x, y)->isGridObjectDataLoaded();
582  }
583  void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
584  {
585  getNGrid(x, y)->setGridObjectDataLoaded(pLoaded);
586  }
587 
588  void setNGrid(NGridType* grid, uint32 x, uint32 y);
589  void ScriptsProcess();
590 
591  protected:
592  void SetUnloadReferenceLock(const GridCoord& p, bool on)
593  {
594  getNGrid(p.x_coord, p.y_coord)->setUnloadReferenceLock(on);
595  }
596 
598 
604 
607 
609 
610  typedef std::set<WorldObject*> ActiveNonPlayers;
611  ActiveNonPlayers m_activeNonPlayers;
612  ActiveNonPlayers::iterator m_activeNonPlayersIter;
613 
614  private:
615  Player* _GetScriptPlayerSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo) const;
616  Creature* _GetScriptCreatureSourceOrTarget(Object* source, Object* target, const ScriptInfo* scriptInfo, bool bReverse = false) const;
617  Unit* _GetScriptUnit(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
618  Player* _GetScriptPlayer(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
619  Creature* _GetScriptCreature(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
620  WorldObject* _GetScriptWorldObject(Object* obj, bool isSource, const ScriptInfo* scriptInfo) const;
621  void _ScriptProcessDoor(Object* source, Object* target, const ScriptInfo* scriptInfo) const;
622  GameObject* _FindGameObject(WorldObject* pWorldObject, uint32 guid) const;
623 
625  time_t i_gridExpiry;
626 
627  //used for fast base_map (e.g. MapInstanced class object) search for
628  //InstanceMaps and BattlegroundMaps...
630 
633  std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP* TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
634 
635  //these functions used to process player/mob aggro reactions and
636  //visibility calculations. Highly optimized for massive calculations
637  void ProcessRelocationNotifies(const uint32& diff);
638 
640  std::set<WorldObject*> i_objectsToRemove;
641  std::map<WorldObject*, bool> i_objectsToSwitch;
642  std::set<WorldObject*> i_worldObjects;
643  std::multimap<time_t, ScriptAction> m_scriptSchedule;
644 
645  // Type specific code for add/remove to/from grid
646  template<class T>
647  void AddToGrid(T* object, Cell const& cell);
648 
649  template<class T>
650  void DeleteFromWorld(T*);
651 
652  template<class T>
653  void AddToActiveHelper(T* obj)
654  {
655  m_activeNonPlayers.insert(obj);
656  }
657 
658  template<class T>
660  {
661  // Map::Update for active object in proccess
662  if (m_activeNonPlayersIter != m_activeNonPlayers.end())
663  {
664  ActiveNonPlayers::iterator itr = m_activeNonPlayers.find(obj);
665  if (itr == m_activeNonPlayers.end())
666  return;
667  if (itr == m_activeNonPlayersIter)
668  ++m_activeNonPlayersIter;
669  m_activeNonPlayers.erase(itr);
670  }
671  else
672  m_activeNonPlayers.erase(obj);
673  }
674 };
675 
677 {
684 };
685 
686 class InstanceMap : public Map
687 {
688  public:
689  InstanceMap(uint32 id, time_t, uint32 InstanceId, uint8 SpawnMode, Map* _parent);
690  ~InstanceMap() override;
691  bool AddPlayerToMap(Player*) override;
692  void RemovePlayerFromMap(Player*, bool) override;
693  void Update(const uint32&) override;
694  void CreateInstanceData(bool load);
695  bool Reset(uint8 method);
697  {
698  return i_script_id;
699  }
701  {
702  return i_data;
703  }
704  void PermBindAllPlayers(Player* player);
705  time_t GetResetTime();
706  void UnloadAll() override;
707  EnterState CannotEnter(Player* player) override;
708  void SendResetWarnings(uint32 timeLeft) const;
709  void SetResetSchedule(bool on);
710 
711  void InitVisibilityDistance() override;
712  private:
717 };
718 
719 class BattlegroundMap : public Map
720 {
721  public:
722  BattlegroundMap(uint32 id, time_t, uint32 InstanceId, Map* _parent);
723  ~BattlegroundMap() override;
724 
725  bool AddPlayerToMap(Player*) override;
726  void RemovePlayerFromMap(Player*, bool) override;
727  EnterState CannotEnter(Player* player) override;
728  void SetUnload();
729  void RemoveAllPlayers() override;
730 
731  void InitVisibilityDistance() override;
733  {
734  return m_bg;
735  }
736  void SetBG(Battleground* bg)
737  {
738  m_bg = bg;
739  }
740  private:
742 };
743 
744 /*inline
745 uint64
746 Map::CalculateGridMask(const uint32 &y) const
747 {
748  uint64 mask = 1;
749  mask <<= y;
750  return mask;
751 }
752 */
753 
754 template<class T, class CONTAINER>
755 inline void Map::Visit(Cell const& cell, TypeContainerVisitor<T, CONTAINER>& visitor)
756 {
757  const uint32 x = cell.GridX();
758  const uint32 y = cell.GridY();
759  const uint32 cell_x = cell.CellX();
760  const uint32 cell_y = cell.CellY();
761 
762  if (!cell.NoCreate() || IsGridLoaded(GridCoord(x, y)))
763  {
764  EnsureGridLoaded(cell);
765  getNGrid(x, y)->VisitGrid(cell_x, cell_y, visitor);
766  }
767 }
768 
769 template<class NOTIFIER>
770 inline void Map::VisitAll(float const& x, float const& y, float radius, NOTIFIER& notifier)
771 {
773  Cell cell(p);
774  cell.SetNoCreate();
775 
776  TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
777  cell.Visit(p, world_object_notifier, *this, radius, x, y);
778  TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
779  cell.Visit(p, grid_object_notifier, *this, radius, x, y);
780 }
781 
782 template<class NOTIFIER>
783 inline void Map::VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
784 {
786  Cell cell(p);
787  cell.SetNoCreate();
788 
789  TypeContainerVisitor<NOTIFIER, WorldTypeMapContainer> world_object_notifier(notifier);
790  cell.Visit(p, world_object_notifier, *this, radius, x, y);
791 }
792 
793 template<class NOTIFIER>
794 inline void Map::VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
795 {
797  Cell cell(p);
798  cell.SetNoCreate();
799 
800  TypeContainerVisitor<NOTIFIER, GridTypeMapContainer > grid_object_notifier(notifier);
801  cell.Visit(p, grid_object_notifier, *this, radius, x, y);
802 }
803 #endif
804 
void SetTimer(uint32 t)
Definition: Map.h:544
float * m_V9
Definition: Map.h:166
std::multimap< time_t, ScriptAction > m_scriptSchedule
Definition: Map.h:643
despawns when UnSummon() is called
Definition: Object.h:130
Definition: NGrid.h:75
bool IsBattlegroundOrArena() const
Definition: Map.h:447
#define MIN_GRID_DELAY
Definition: GridDefines.h:40
DungeonDifficulty GetDifficulty() const
Definition: Map.h:419
uint8 offsetY
Definition: Map.h:120
uint8 GetSpawnMode() const
Definition: Map.h:394
bool IsBattleground() const
Definition: Map.h:439
uint8 height
Definition: Map.h:122
std::set< WorldObject * > i_objectsToRemove
Definition: Map.h:640
uint32 fourcc
Definition: Map.h:105
float depth_level
Definition: Map.h:152
uint32 reset_delay
Definition: Map.h:235
UNORDERED_MAP< Creature *, CreatureMover > CreatureMoveList
Definition: Map.h:256
MapEntry const * i_mapEntry
Definition: Map.h:599
bool isCellMarked(uint32 pCellId)
Definition: Map.h:463
uint16 flags
Definition: Map.h:117
uint32 areaMapSize
Definition: Map.h:81
float m_VisibleDistance
Definition: Map.h:603
#define DEFAULT_HEIGHT_SEARCH
Definition: Map.h:261
uint8 m_liquid_offY
Definition: Map.h:179
time_t i_gridExpiry
Definition: Map.h:625
uint32 CellY() const
Definition: Cell.h:72
bool IsRaid() const
Definition: Map.h:431
void RemoveFromActiveHelper(T *obj)
Definition: Map.h:659
Map * m_parentMap
Definition: Map.h:629
Definition: Map.h:155
float gridMaxHeight
Definition: Map.h:108
uint8 offsetX
Definition: Map.h:119
ScriptInfo const * script
Definition: Map.h:63
MapRefManager PlayerList
Definition: Map.h:490
NGridType * getNGrid(uint32 x, uint32 y) const
Definition: Map.h:572
void ResetTimeTracker(time_t interval)
Definition: NGrid.h:118
Battleground * GetBG()
Definition: Map.h:732
std::map< WorldObject *, bool > i_objectsToSwitch
Definition: Map.h:641
void SetBG(Battleground *bg)
Definition: Map.h:736
uint32 flags
Definition: Map.h:106
void Remove(const GameObjectModel &mdl)
Definition: Map.h:533
uint32 fourcc
Definition: Map.h:116
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:33
ZLiquidStatus
Definition: Map.h:126
ACE_INT32 int32
Definition: Define.h:67
uint32 m_flags
Definition: Map.h:157
bool IsDungeon() const
Definition: Map.h:427
uint32 areaMapOffset
Definition: Map.h:80
void AddToActiveHelper(T *obj)
Definition: Map.h:653
void SetUnloadReferenceLock(const GridCoord &p, bool on)
Definition: Map.h:592
void SetNoCreate()
Definition: Cell.h:76
void RemoveWorldObject(WorldObject *obj)
Definition: Map.h:483
uint32 y_coord
Definition: GridDefines.h:142
bool IsGridLoaded(float x, float y) const
Definition: Map.h:307
void RemoveFromActive(T *obj)
Definition: Map.h:511
uint32 x_coord
Definition: GridDefines.h:141
uint16 gridArea
Definition: Map.h:96
DungeonDifficulty
Battleground * m_bg
Definition: Map.h:741
uint8 i_spawnMode
Definition: Map.h:600
uint32 i_script_id
Definition: Map.h:716
ActiveNonPlayers m_activeNonPlayers
Definition: Map.h:611
bool i_scriptLock
Definition: Map.h:639
uint16 liquidType
Definition: Map.h:118
CreatureMoveList i_creaturesToMove
Definition: Map.h:557
uint8 width
Definition: Map.h:121
bool CanUnload(uint32 diff)
Definition: Map.h:274
float getHeight(float x, float y)
Definition: Map.h:206
DynamicMapTree m_dyn_tree
Definition: Map.h:624
pGetHeightPtr m_gridGetHeight
Definition: Map.h:193
float liquidLevel
Definition: Map.h:123
uint8 * m_uint8_V8
Definition: Map.h:174
float z
Definition: Map.h:220
uint32 GetId(void) const
Definition: Map.h:333
float * m_V8
Definition: Map.h:172
bool isGridObjectDataLoaded(uint32 x, uint32 y) const
Definition: Map.h:579
ACE_UINT8 uint8
Definition: Define.h:73
uint32 heightMapOffset
Definition: Map.h:82
void markCell(uint32 pCellId)
Definition: Map.h:467
LevelRequirementVsMode
Definition: Map.h:245
bool m_resetAfterUnload
Definition: Map.h:713
void Insert(const GameObjectModel &mdl)
Definition: Map.h:534
uint8 * m_uint8_V9
Definition: Map.h:168
void resetMarkedCells()
Definition: Map.h:459
uint32 m_unloadTimer
Definition: Map.h:602
InstanceData * GetInstanceData()
Definition: Map.h:700
uint64 sourceGUID
Definition: Map.h:60
bool IsHeroic() const
Definition: Map.h:435
float startLocY
Definition: Map.h:238
uint32 holesOffset
Definition: Map.h:86
std::set< WorldObject * > ActiveNonPlayers
Definition: Map.h:610
CreatureMover()
Definition: Map.h:217
float m_gridIntHeightMultiplier
Definition: Map.h:163
uint32 CellX() const
Definition: Cell.h:71
bool allowMount
Definition: Map.h:242
float level
Definition: Map.h:151
CreatureGroupHolderType CreatureGroupHolder
Definition: Map.h:522
float m_liquidLevel
Definition: Map.h:182
InstanceMap * ToInstanceMap()
Definition: Map.h:349
bool IsRegularDifficulty() const
Definition: Map.h:420
TempSummonType
uint32 GetScriptId()
Definition: Map.h:696
uint64 targetGUID
Definition: Map.h:61
uint16 * m_area_map
Definition: Map.h:160
uint32 GridY() const
Definition: Cell.h:74
void SetUnloadLock(const GridCoord &p, bool on)
Definition: Map.h:316
uint32 type_flags
Definition: Map.h:149
bool HavePlayers() const
Definition: Map.h:472
uint32 liquidMapOffset
Definition: Map.h:84
uint8 m_liquid_offX
Definition: Map.h:178
void VisitAll(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition: Map.h:266
uint16 * m_uint16_V8
Definition: Map.h:173
std::set< WorldObject * > i_worldObjects
Definition: Map.h:642
uint32 entry
Definition: Map.h:150
uint32 liquidMapSize
Definition: Map.h:85
void Balance()
Definition: Map.h:532
float GetVisibilityRange() const
Definition: Map.h:291
uint16 flags
Definition: Map.h:95
CellCoord ComputeCellCoord(float x, float y)
Definition: GridDefines.h:167
uint16 m_liquidType
Definition: Map.h:177
float startLocO
Definition: Map.h:240
uint32 GetZoneId(float x, float y, float z) const
Definition: Map.h:376
uint16 m_gridArea
Definition: Map.h:159
InstanceData * i_data
Definition: Map.h:715
uint32 parent
Definition: Map.h:233
float gridHeight
Definition: Map.h:107
void buildNGridLinkage(NGridType *pNGridType)
Definition: Map.h:564
std::bitset< TOTAL_NUMBER_OF_CELLS_PER_MAP *TOTAL_NUMBER_OF_CELLS_PER_MAP > marked_cells
Definition: Map.h:633
uint32 heightMapSize
Definition: Map.h:83
float startLocZ
Definition: Map.h:239
ACE_UINT64 uint64
Definition: Define.h:70
PlayerList const & GetPlayers() const
Definition: Map.h:491
Definition: Cell.h:46
ActiveNonPlayers::iterator m_activeNonPlayersIter
Definition: Map.h:612
void Visit(const Cell &cell, TypeContainerVisitor< T, CONTAINER > &visitor)
int32 m_VisibilityNotifyPeriod
Definition: Map.h:608
uint16 * m_uint16_V9
Definition: Map.h:167
float startLocX
Definition: Map.h:237
uint32 map
Definition: Map.h:232
uint32 fourcc
Definition: Map.h:94
void AddToActive(T *obj)
Definition: Map.h:502
std::map< uint32, CreatureGroup * > CreatureGroupHolderType
Definition: Map.h:264
InstanceMap const * ToInstanceMap() const
Definition: Map.h:350
uint32 maxPlayers
Definition: Map.h:234
uint32 i_InstanceId
Definition: Map.h:601
InstanceResetMethod
Definition: Map.h:676
uint32 GetAreaId(float x, float y, float z) const
Definition: Map.h:371
void link(GridRefManager< NGrid< N, ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES > > *pTo)
Definition: NGrid.h:104
bool NoCreate() const
Definition: Cell.h:75
bool Contains(const GameObjectModel &mdl) const
Definition: Map.h:535
#define ASSERT
Definition: Errors.h:29
CreatureMover(float _x, float _y, float _z, float _ang)
Definition: Map.h:218
bool Instanceable() const
Definition: Map.h:422
uint32 mapMagic
Definition: Map.h:77
bool IsBattleArena() const
Definition: Map.h:443
void VisitWorld(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition: Map.h:783
float m_gridHeight
Definition: Map.h:162
EnterState
Definition: Map.h:399
bool GetUnloadLock(const GridCoord &p) const
Definition: Map.h:312
void setGridObjectDataLoaded(bool pLoaded, uint32 x, uint32 y)
Definition: Map.h:583
void AddWorldObject(WorldObject *obj)
Definition: Map.h:479
ACE_UINT16 uint16
Definition: Define.h:72
uint64 ownerGUID
Definition: Map.h:62
bool IsRemovalGrid(float x, float y) const
Definition: Map.h:301
MapRefManager::iterator m_mapRefIter
Definition: Map.h:606
void VisitGrid(const float &x, const float &y, float radius, NOTIFIER &notifier)
Definition: Map.h:794
uint32 access_id
Definition: Map.h:236
virtual EnterState CannotEnter(Player *)
Definition: Map.h:414
ACE_UINT32 uint32
Definition: Define.h:71
time_t GetGridExpiry(void) const
Definition: Map.h:329
Definition: Unit.h:908
void ResetGridExpiry(NGridType &grid, float factor=1) const
Definition: Map.h:324
bool m_unloadWhenEmpty
Definition: Map.h:714
Map const * GetParent() const
Definition: Map.h:344
uint8 m_liquid_width
Definition: Map.h:180
MapRefManager m_mapRefManager
Definition: Map.h:605
Definition: Player.h:922
uint32 GetInstanceId() const
Definition: Map.h:390
void Visit(CellCoord const &, TypeContainerVisitor< T, CONTAINER > &visitor, Map &, WorldObject const &, float) const
Definition: CellImpl.h:121
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:145
uint32 holesSize
Definition: Map.h:87
uint32 buildMagic
Definition: Map.h:79
uint32 script_id
Definition: Map.h:241
uint32 GridX() const
Definition: Cell.h:73
Definition: Group.h:154
uint32 versionMagic
Definition: Map.h:78
uint8 m_liquid_height
Definition: Map.h:181
Oregon::ObjectLevelLockable< Map, ACE_Thread_Mutex >::Lock Guard
Definition: Map.h:597
uint8 * _liquidFlags
Definition: Map.h:184
uint16 * _liquidEntry
Definition: Map.h:183
float * _liquidMap
Definition: Map.h:185
GridCoord ComputeGridCoord(float x, float y)
Definition: GridDefines.h:162