mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 22:37:02 +00:00
[10384] Fixed reset time calculation for some cases.
Most real fix suggested by Schmoozerd and Toinan67 and some my code style part coding ;)
This commit is contained in:
parent
0649b508e4
commit
920a36b3fd
5 changed files with 22 additions and 12 deletions
|
|
@ -126,6 +126,19 @@ bool InstanceSave::UnloadIfEmpty()
|
|||
|
||||
//== InstanceResetScheduler functions ======================
|
||||
|
||||
uint32 InstanceResetScheduler::GetMaxResetTimFor(MapDifficulty const* mapDiff)
|
||||
{
|
||||
if (!mapDiff || !mapDiff->resetTime)
|
||||
return 0;
|
||||
|
||||
uint32 delay = uint32(mapDiff->resetTime / DAY * sWorld.getConfig(CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME)) * DAY;
|
||||
|
||||
if (delay < DAY) // the reset_delay must be at least one day
|
||||
delay = DAY;
|
||||
|
||||
return delay;
|
||||
}
|
||||
|
||||
void InstanceResetScheduler::LoadResetTimes()
|
||||
{
|
||||
time_t now = time(NULL);
|
||||
|
|
@ -229,11 +242,7 @@ void InstanceResetScheduler::LoadResetTimes()
|
|||
if (!mapDiff->resetTime)
|
||||
continue;
|
||||
|
||||
// the reset_delay must be at least one day
|
||||
uint32 period = uint32(mapDiff->resetTime / DAY * sWorld.getConfig(CONFIG_FLOAT_RATE_INSTANCE_RESET_TIME)) * DAY;
|
||||
if (period < DAY)
|
||||
period = DAY;
|
||||
|
||||
uint32 period = GetMaxResetTimFor(mapDiff);
|
||||
time_t t = GetResetTimeFor(mapid,difficulty);
|
||||
if(!t)
|
||||
{
|
||||
|
|
@ -637,7 +646,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b
|
|||
|
||||
// calculate the next reset time
|
||||
uint32 diff = sWorld.getConfig(CONFIG_UINT32_INSTANCE_RESET_TIME_HOUR) * HOUR;
|
||||
uint32 period = mapDiff->resetTime * DAY;
|
||||
uint32 period = InstanceResetScheduler::GetMaxResetTimFor(mapDiff);
|
||||
time_t next_reset = ((now + timeLeft + MINUTE) / DAY * DAY) + period + diff;
|
||||
// update it in the DB
|
||||
CharacterDatabase.PExecute("UPDATE instance_reset SET resettime = '"UI64FMTD"' WHERE mapid = '%d' AND difficulty = '%d'", (uint64)next_reset, mapid, difficulty);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue