TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MapInstanced.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITY_MAP_INSTANCED_H
20 #define TRINITY_MAP_INSTANCED_H
21 
22 #include "Map.h"
23 #include "InstanceSaveMgr.h"
24 #include "DBCEnums.h"
25 
26 class GarrisonMap;
27 
29 {
30  friend class MapManager;
31  public:
32  typedef std::unordered_map< uint32, Map*> InstancedMaps;
33 
34  MapInstanced(uint32 id, time_t expiry);
36 
37  // functions overwrite Map versions
38  void Update(const uint32) override;
39  void DelayedUpdate(const uint32 diff) override;
40  //void RelocationNotify();
41  void UnloadAll() override;
42  EnterState CannotEnter(Player* /*player*/) override;
43 
44  Map* CreateInstanceForPlayer(const uint32 mapId, Player* player, uint32 loginInstanceId=0);
45  Map* FindInstanceMap(uint32 instanceId) const
46  {
47  InstancedMaps::const_iterator i = m_InstancedMaps.find(instanceId);
48  return(i == m_InstancedMaps.end() ? nullptr : i->second);
49  }
50  bool DestroyInstance(InstancedMaps::iterator &itr);
51 
53  {
54  ++GridMapReference[p.x_coord][p.y_coord];
56  }
57 
59  {
60  --GridMapReference[p.x_coord][p.y_coord];
61  if (!GridMapReference[p.x_coord][p.y_coord])
63  }
64 
65  InstancedMaps &GetInstancedMaps() { return m_InstancedMaps; }
66  virtual void InitVisibilityDistance() override;
67 
68  private:
69  InstanceMap* CreateInstance(uint32 InstanceId, InstanceSave* save, Difficulty difficulty);
70  BattlegroundMap* CreateBattleground(uint32 InstanceId, Battleground* bg);
71  GarrisonMap* CreateGarrison(uint32 instanceId, Player* owner);
72 
73  InstancedMaps m_InstancedMaps;
74 
76 };
77 #endif
Definition: MapInstanced.h:28
Difficulty
Definition: DBCEnums.h:402
Map * FindInstanceMap(uint32 instanceId) const
Definition: MapInstanced.h:45
virtual void InitVisibilityDistance()
Definition: Map.cpp:253
InstancedMaps & GetInstancedMaps()
Definition: MapInstanced.h:65
#define MAX_NUMBER_OF_GRIDS
Definition: GridDefines.h:37
void SetUnloadReferenceLock(const GridCoord &p, bool on)
Definition: Map.h:634
Definition: GarrisonMap.h:26
uint32 y_coord
Definition: GridDefines.h:156
uint32 x_coord
Definition: GridDefines.h:155
void RemoveGridMapReference(GridCoord const &p)
Definition: MapInstanced.h:58
std::unordered_map< uint32, Map * > InstancedMaps
Definition: MapInstanced.h:32
Definition: Map.h:758
Definition: Map.h:790
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: GridDefines.h:89
Definition: Map.h:259
virtual void Update(const uint32)
Definition: Map.cpp:682
Definition: InstanceSaveMgr.h:44
virtual void UnloadAll()
Definition: Map.cpp:1614
Definition: MapManager.h:31
#define TC_GAME_API
Definition: Define.h:134
virtual void DelayedUpdate(const uint32 diff)
Definition: Map.cpp:2774
Definition: Battleground.h:235
InstancedMaps m_InstancedMaps
Definition: MapInstanced.h:73
virtual EnterState CannotEnter(Player *)
Definition: Map.h:386
CoordPair< MAX_NUMBER_OF_GRIDS > GridCoord
Definition: GridDefines.h:171
~MapInstanced()
Definition: MapInstanced.h:35
void AddGridMapReference(const GridCoord &p)
Definition: MapInstanced.h:52