From 5a2bf60e00365cbec63672d951bf14c88901be82 Mon Sep 17 00:00:00 2001 From: Thog Date: Tue, 1 Oct 2019 00:56:58 +0200 Subject: [PATCH] Fix two critical flaws in TimeZone logic The first one was the month range being different fron Nintendo one (0-11 instead of 1-12) The other flaw was a bad incrementation order during days & months computation. --- Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs | 4 +++- Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs | 6 ++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs b/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs index 58b1f1ec9b..b3352f20dd 100644 --- a/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs +++ b/Ryujinx.HLE/HOS/Services/Time/ITimeServiceManager.cs @@ -68,7 +68,9 @@ namespace Ryujinx.HLE.HOS.Services.Time TimeSpanType testOffset = context.RequestData.ReadStruct(); bool isRtcResetDetected = context.RequestData.ReadBoolean(); - return _timeManager.SetupStandardSteadyClock(context.Thread, clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected); + _timeManager.SetupStandardSteadyClock(context.Thread, clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected); + + return ResultCode.Success; } [Command(11)] diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs index f4c4bd6976..b32a979578 100644 --- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs +++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs @@ -1357,10 +1357,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone int[] ip = MonthsLengths[IsLeap((int)year)]; - while (dayOfYear >= ip[calendarTime.Month]) + for (calendarTime.Month = 0; dayOfYear >= ip[calendarTime.Month]; ++calendarTime.Month) { - calendarTime.Month += 1; - dayOfYear -= ip[calendarTime.Month]; } @@ -1709,7 +1707,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone Time = new CalendarTime() { Year = (short)calendarTime.Year, - Month = calendarTime.Month, + Month = (sbyte)(calendarTime.Month + 1), Day = calendarTime.Day, Hour = calendarTime.Hour, Minute = calendarTime.Minute,