19 #ifndef _INSTANCESAVEMGR_H
20 #define _INSTANCESAVEMGR_H
25 #include <unordered_map>
76 time_t GetResetTimeForDB();
85 std::lock_guard<std::mutex> lock(_playerListLock);
86 m_playerList.push_back(player);
91 _playerListLock.lock();
92 m_playerList.remove(player);
93 bool isStillValid = UnloadIfEmpty();
94 _playerListLock.unlock();
106 m_groupList.remove(group);
107 bool isStillValid = UnloadIfEmpty();
126 m_toDelete = toDelete;
132 bool UnloadIfEmpty();
176 : type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) { }
181 void LoadInstances();
183 void LoadResetTimes();
186 ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(
MAKE_PAIR64(mapid, d));
187 return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
189 time_t GetSubsequentResetTime(uint32 mapid,
Difficulty difficulty, time_t resetTime)
const;
194 m_resetTimeByMapDifficulty[
MAKE_PAIR64(mapid, d)] = t;
200 ResetTimeByMapDifficultyMap::iterator itr = m_resetTimeByMapDifficulty.find(
MAKE_PAIR64(mapid, d));
201 ASSERT(itr != m_resetTimeByMapDifficulty.end());
207 return m_resetTimeByMapDifficulty;
209 void ScheduleReset(
bool add, time_t time, InstResetEvent event);
210 void ForceGlobalReset(uint32 mapId,
Difficulty difficulty);
215 bool canReset,
bool load =
false);
216 void RemoveInstanceSave(uint32 InstanceId);
217 void UnloadInstanceSave(uint32 InstanceId);
218 static void DeleteInstanceFromDB(uint32 instanceid);
224 uint32 GetNumBoundPlayersTotal()
const;
225 uint32 GetNumBoundGroupsTotal()
const;
231 void _ResetOrWarnAll(uint32 mapid,
Difficulty difficulty,
bool warn, time_t resetTime);
232 void _ResetInstance(uint32 mapid, uint32 instanceId);
233 void _ResetSave(InstanceSaveHashMap::iterator &itr);
243 #define sInstanceSaveMgr InstanceSaveManager::instance()
uint8 type
Definition: InstanceSaveMgr.h:169
Difficulty
Definition: DBCEnums.h:402
InstResetEvent(uint8 t, uint32 _mapid, Difficulty d, uint32 _instanceid)
Definition: InstanceSaveMgr.h:175
PlayerListType m_playerList
Definition: InstanceSaveMgr.h:136
uint32 instanceId
Definition: InstanceSaveMgr.h:172
uint32 GetNumInstanceSaves() const
Definition: InstanceSaveMgr.h:223
std::unordered_map< uint64, time_t > ResetTimeByMapDifficultyMap
Definition: InstanceSaveMgr.h:148
ResetTimeByMapDifficultyMap m_resetTimeByMapDifficulty
Definition: InstanceSaveMgr.h:239
Definition: InstanceSaveMgr.h:167
time_t GetResetTimeFor(uint32 mapid, Difficulty d) const
Definition: InstanceSaveMgr.h:184
Definition: DBCStructure.h:830
#define false
Definition: CascPort.h:18
void SetResetTime(time_t resetTime)
Definition: InstanceSaveMgr.h:75
ResetTimeByMapDifficultyMap const & GetResetTimeMap() const
Definition: InstanceSaveMgr.h:205
friend class InstanceSave
Definition: InstanceSaveMgr.h:152
Difficulty m_difficulty
Definition: InstanceSaveMgr.h:141
uint64 MAKE_PAIR64(uint32 l, uint32 h)
Definition: ObjectDefines.h:34
uint32 mapid
Definition: InstanceSaveMgr.h:171
void SetCanReset(bool canReset)
Definition: InstanceSaveMgr.h:117
void AddGroup(Group *group)
Definition: InstanceSaveMgr.h:103
ResetTimeQueue m_resetTimeQueue
Definition: InstanceSaveMgr.h:240
void SetResetTimeFor(uint32 mapid, Difficulty d, time_t t)
Definition: InstanceSaveMgr.h:198
InstanceSaveHashMap m_instanceSaveById
Definition: InstanceSaveMgr.h:237
bool m_canReset
Definition: InstanceSaveMgr.h:142
uint32 GetGroupCount() const
Definition: InstanceSaveMgr.h:59
uint32 m_instanceid
Definition: InstanceSaveMgr.h:139
std::unordered_map< uint32, InstanceSave * > InstanceSaveHashMap
Definition: InstanceSaveMgr.h:159
std::mutex _playerListLock
Definition: InstanceSaveMgr.h:145
bool operator==(const CoordPair< LIMIT > &p1, const CoordPair< LIMIT > &p2)
Definition: GridDefines.h:160
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
uint16_t uint16
Definition: Define.h:151
InstResetEvent()
Definition: InstanceSaveMgr.h:174
std::list< Group * > GroupListType
Definition: InstanceSaveMgr.h:130
std::list< Player * > PlayerListType
Definition: InstanceSaveMgr.h:129
Definition: InstanceSaveMgr.h:44
std::multimap< time_t, InstResetEvent > ResetTimeQueue
Definition: InstanceSaveMgr.h:179
uint32 m_mapid
Definition: InstanceSaveMgr.h:140
uint32 GetMapId() const
Definition: InstanceSaveMgr.h:65
bool m_toDelete
Definition: InstanceSaveMgr.h:143
uint32 GetPlayerCount() const
Definition: InstanceSaveMgr.h:58
void SetToDelete(bool toDelete)
Definition: InstanceSaveMgr.h:124
Definition: InstanceSaveMgr.h:150
Difficulty GetDifficultyID() const
Definition: InstanceSaveMgr.h:121
void InitializeResetTimeFor(uint32 mapid, Difficulty d, time_t t)
Definition: InstanceSaveMgr.h:192
#define TC_GAME_API
Definition: Define.h:134
bool lock_instLists
Definition: InstanceSaveMgr.h:235
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
InstanceSaveManager()
Definition: InstanceSaveMgr.h:155
bool RemovePlayer(Player *player)
Definition: InstanceSaveMgr.h:89
bool CanReset() const
Definition: InstanceSaveMgr.h:116
uint32_t uint32
Definition: g3dmath.h:168
time_t m_resetTime
Definition: InstanceSaveMgr.h:138
void AddPlayer(Player *player)
Definition: InstanceSaveMgr.h:83
bool RemoveGroup(Group *group)
Definition: InstanceSaveMgr.h:104
GroupListType m_groupList
Definition: InstanceSaveMgr.h:137
uint32 GetInstanceId() const
Definition: InstanceSaveMgr.h:64
void Update(uint32 diff)
Definition: WeatherMgr.cpp:150
time_t GetResetTime() const
Definition: InstanceSaveMgr.h:74
Definition: DBCEnums.h:405