18#ifndef _INSTANCESAVEMGR_H
19#define _INSTANCESAVEMGR_H
24#include <unordered_map>
75 time_t GetResetTimeForDB();
84 std::lock_guard<std::mutex> lock(_playerListLock);
85 m_playerList.push_back(player);
90 _playerListLock.lock();
91 m_playerList.remove(player);
92 bool isStillValid = UnloadIfEmpty();
93 _playerListLock.unlock();
105 m_groupList.remove(group);
106 bool isStillValid = UnloadIfEmpty();
125 bool UnloadIfEmpty();
129 m_toDelete = toDelete;
175 : type(t), difficulty(d), mapid(_mapid), instanceId(_instanceid) { }
180 void LoadInstances();
182 void LoadResetTimes();
185 ResetTimeByMapDifficultyMap::const_iterator itr = m_resetTimeByMapDifficulty.find(
MAKE_PAIR32(mapid, d));
186 return itr != m_resetTimeByMapDifficulty.end() ? itr->second : 0;
188 time_t GetSubsequentResetTime(
uint32 mapid,
Difficulty difficulty, time_t resetTime)
const;
193 m_resetTimeByMapDifficulty[
MAKE_PAIR32(mapid, d)] = t;
201 return m_resetTimeByMapDifficulty;
203 void ScheduleReset(
bool add, time_t time, InstResetEvent event);
209 bool canReset,
bool load =
false);
210 void RemoveInstanceSave(
uint32 InstanceId);
211 void UnloadInstanceSave(
uint32 InstanceId);
212 static void DeleteInstanceFromDB(
uint32 instanceid);
218 uint32 GetNumBoundPlayersTotal()
const;
219 uint32 GetNumBoundGroupsTotal()
const;
222 static uint16 ResetTimeDelay[];
225 void _ResetOrWarnAll(
uint32 mapid,
Difficulty difficulty,
bool warn, time_t resetTime);
227 void _ResetSave(InstanceSaveHashMap::iterator &itr);
237#define sInstanceSaveMgr InstanceSaveManager::instance()
@ DUNGEON_DIFFICULTY_NORMAL
std::unordered_map< uint32, time_t > ResetTimeByMapDifficultyMap
uint32 MAKE_PAIR32(uint16 l, uint16 h)
static void SaveToDB(QuestPool const &pool, CharacterDatabaseTransaction trans)
std::multimap< time_t, InstResetEvent > ResetTimeQueue
std::unordered_map< uint32, InstanceSave * > InstanceSaveHashMap
InstanceSaveHashMap m_instanceSaveById
ResetTimeByMapDifficultyMap const & GetResetTimeMap() const
ResetTimeByMapDifficultyMap m_resetTimeByMapDifficulty
uint32 GetNumInstanceSaves() const
time_t GetResetTimeFor(uint32 mapid, Difficulty d) const
void InitializeResetTimeFor(uint32 mapid, Difficulty d, time_t t)
ResetTimeQueue m_resetTimeQueue
void AddPlayer(Player *player)
bool RemovePlayer(Player *player)
uint8 GetPlayerCount() const
bool RemoveGroup(Group *group)
uint8 GetGroupCount() const
void SetCanReset(bool canReset)
void SetResetTime(time_t resetTime)
uint32 GetInstanceId() const
std::list< Group * > GroupListType
Difficulty GetDifficulty() const
void AddGroup(Group *group)
PlayerListType m_playerList
std::list< Player * > PlayerListType
GroupListType m_groupList
time_t GetResetTime() const
void SetToDelete(bool toDelete)
std::mutex _playerListLock
bool operator==(InstResetEvent const &e) const
InstResetEvent(uint8 t, uint32 _mapid, Difficulty d, uint16 _instanceid)