Core/Quests: Reset seasonal quests based on saved completion time and intended holiday start time

Port From (https://github.com/TrinityCore/TrinityCore/commit/49ad0d2d495a9f817ad2820f8e616f3a6564b480)
This commit is contained in:
hondacrx
2022-07-04 01:15:52 -04:00
parent 3a402854aa
commit c7123ad860
8 changed files with 69 additions and 27 deletions
+16 -1
View File
@@ -1100,7 +1100,7 @@ namespace Game
RunSmartAIScripts(event_id, true);
// check for seasonal quest reset.
Global.WorldMgr.ResetEventSeasonalQuests(event_id);
Global.WorldMgr.ResetEventSeasonalQuests(event_id, GetLastStartTime(event_id));
}
void UpdateEventNPCFlags(ushort event_id)
@@ -1676,6 +1676,21 @@ namespace Game
}
}
long GetLastStartTime(ushort event_id)
{
if (event_id >= mGameEvent.Length)
return 0;
if (mGameEvent[event_id].state != GameEventState.Normal)
return 0;
DateTime now = GameTime.GetSystemTime();
DateTime eventInitialStart = Time.UnixTimeToDateTime(mGameEvent[event_id].start);
TimeSpan occurence = TimeSpan.FromMinutes(mGameEvent[event_id].occurence);
TimeSpan durationSinceLastStart = TimeSpan.FromTicks((now - eventInitialStart).Ticks % occurence.Ticks);
return Time.DateTimeToUnixTime(now - durationSinceLastStart);
}
public bool IsHolidayActive(HolidayIds id)
{
if (id == HolidayIds.None)