298 time_t now = time(
NULL);
299 time_t today = (now /
DAY) *
DAY;
306 typedef std::pair<
uint32 , time_t> ResetTimeMapDiffType;
307 typedef std::map<uint32, ResetTimeMapDiffType> InstResetTimeMapDiffType;
308 InstResetTimeMapDiffType instResetTime;
311 typedef std::multimap<uint32 , uint32 > ResetTimeMapDiffInstances;
312 typedef std::pair<ResetTimeMapDiffInstances::const_iterator, ResetTimeMapDiffInstances::const_iterator> ResetTimeMapDiffInstancesBounds;
313 ResetTimeMapDiffInstances mapDiffResetInstances;
320 Field* fields = result->Fetch();
322 uint32 instanceId = fields[0].
GetUInt32();
326 if (
sMapMgr->GetNextInstanceId() == instanceId)
327 sMapMgr->SetNextInstanceId(instanceId + 1);
330 sMapMgr->RegisterInstanceId(instanceId);
332 if (time_t resettime = time_t(fields[3].GetUInt32()))
335 uint32 difficulty = fields[2].
GetUInt8();
337 instResetTime[instanceId] = ResetTimeMapDiffType(
MAKE_PAIR32(mapid, difficulty), resettime);
338 mapDiffResetInstances.insert(ResetTimeMapDiffInstances::value_type(
MAKE_PAIR32(mapid, difficulty), instanceId));
341 while (result->NextRow());
348 Field* fields = result2->Fetch();
350 time_t resettime = time_t(fields[0].GetUInt32() + 2 *
HOUR);
351 InstResetTimeMapDiffType::iterator itr = instResetTime.find(instance);
352 if (itr != instResetTime.end() && itr->second.second != resettime)
355 itr->second.second = resettime;
358 while (result->NextRow());
362 for (InstResetTimeMapDiffType::iterator itr = instResetTime.begin(); itr != instResetTime.end(); ++itr)
363 if (itr->second.second > now)
374 Field* fields = result->Fetch();
382 TC_LOG_ERROR(
"misc",
"InstanceSaveManager::LoadResetTimes: invalid mapid(%u)/difficulty(%u) pair in instance_reset!", mapid, difficulty);
388 uint64 newresettime = (oldresettime /
DAY) *
DAY + diff;
389 if (oldresettime != newresettime)
393 }
while (result->NextRow());
400 uint32 mapid = mapDifficultyPair.first;
402 for (
auto& difficultyPair : mapDifficultyPair.second)
418 t = today + period + diff;
427 t += ((today - t) / period + 1) * period + diff;
435 for (type = 1; type < 4; ++type)
441 ResetTimeMapDiffInstancesBounds range = mapDiffResetInstances.equal_range(
MAKE_PAIR32(mapid, difficulty));
442 for (; range.first != range.second; ++range.first)
Difficulty
Definition: DBCEnums.h:402
MapDifficultyEntry const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition: DBCStores.cpp:724
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: QueryResult.h:107
void ScheduleReset(bool add, time_t time, InstResetEvent event)
Definition: InstanceSaveMgr.cpp:465
MapDifficultyMap sMapDifficultyMap
Definition: DBCStores.cpp:115
Class used to access individual fields of database query result.
Definition: Field.h:56
time_t GetResetTimeFor(uint32 mapid, Difficulty d) const
Definition: InstanceSaveMgr.h:184
static InstanceSaveManager * instance()
Definition: InstanceSaveMgr.cpp:41
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 RaidDuration
Definition: DBCStructure.h:891
uint64_t uint64
Definition: g3dmath.h:170
#define sWorld
Definition: World.h:887
uint8 GetUInt8() const
Definition: Field.h:70
void DirectPExecute(Format &&sql, Args &&...args)
Definition: DatabaseWorkerPool.h:134
uint16 PAIR32_LOPART(uint32 x)
Definition: ObjectDefines.h:64
#define UI64FMTD
Definition: Define.h:137
Definition: CharacterDatabase.h:293
uint32_t uint32
Definition: Define.h:150
uint64_t uint64
Definition: Define.h:149
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint16 GetUInt16() const
Definition: Field.h:108
PreparedStatement * GetPreparedStatement(PreparedStatementIndex index)
Definition: DatabaseWorkerPool.h:263
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: DBCStructure.h:885
void InitializeResetTimeFor(uint32 mapid, Difficulty d, time_t t)
Definition: InstanceSaveMgr.h:192
#define sMapMgr
Definition: MapManager.h:194
uint32 GetUInt32() const
Definition: Field.h:146
uint8_t uint8
Definition: Define.h:152
CharacterDatabaseWorkerPool CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32_t uint32
Definition: g3dmath.h:168
uint16 PAIR32_HIPART(uint32 x)
Definition: ObjectDefines.h:59
uint32 MAKE_PAIR32(uint16 l, uint16 h)
Definition: ObjectDefines.h:54
static uint16 ResetTimeDelay[]
Definition: InstanceSaveMgr.h:228