fix(Core/Calendar): Correct calculation of reset time (#14834)

This commit is contained in:
Kitzunu
2023-02-01 10:18:13 +01:00
committed by GitHub
parent 439c394784
commit b94d5b94ae

View File

@@ -3130,20 +3130,9 @@ void World::InitCalendarOldEventsDeletionTime()
Seconds currentDeletionTime = Seconds(getWorldState(WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME));
Seconds nextDeletionTime = currentDeletionTime > 0s ? currentDeletionTime : Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR)));
// If the reset time saved in the worldstate is before now it means the server was offline when the reset was supposed to occur.
// In this case we set the reset time in the past and next world update will do the reset and schedule next one in the future.
if (currentDeletionTime < GameTime::GetGameTime())
{
_nextCalendarOldEventsDeletionTime = nextDeletionTime - 1_days;
}
else
{
_nextCalendarOldEventsDeletionTime = nextDeletionTime;
}
if (currentDeletionTime == 0s)
{
sWorld->setWorldState(WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME, _nextCalendarOldEventsDeletionTime.count());
sWorld->setWorldState(WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME, nextDeletionTime.count());
}
}
@@ -3254,7 +3243,7 @@ void World::CalendarDeleteOldEvents()
{
LOG_INFO("server.worldserver", "Calendar deletion of old events.");
_nextCalendarOldEventsDeletionTime += 1_days;
_nextCalendarOldEventsDeletionTime = Seconds(Acore::Time::GetNextTimeWithDayAndHour(-1, getIntConfig(CONFIG_CALENDAR_DELETE_OLD_EVENTS_HOUR)));
sWorld->setWorldState(WS_DAILY_CALENDAR_DELETION_OLD_EVENTS_TIME, _nextCalendarOldEventsDeletionTime.count());
sCalendarMgr->DeleteOldEvents();
}