aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.HLE/HOS/Services/Time
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2019-07-14 21:04:38 +0200
committergdkchan <gab.dark.100@gmail.com>2019-07-14 16:04:38 -0300
commit4ad3936afd4ca393a05b330e3848958e9598e910 (patch)
treee0b3bc963230d3ea3d6cc57b5bc6caeba9233479 /Ryujinx.HLE/HOS/Services/Time
parent4926f6523d3130879e108403979ab68f1212f544 (diff)
Refactoring result codes (#731)
* refactoring result codes - Add a main enum who can handle some orphalin result codes and the default `ResultCode.Success` one. - Add sub-enum by services when it's needed. - Remove some empty line. - Recast all service calls to ResultCode. - Remove some unneeded static declaration. - Delete unused `NvHelper` class. * NvResult is back * Fix
Diffstat (limited to 'Ryujinx.HLE/HOS/Services/Time')
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/IStaticService.cs29
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs12
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs16
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs40
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/ITimeZoneServiceTypes.cs2
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/ResultCode.cs17
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/TimeError.cs12
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs56
-rw-r--r--Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs47
9 files changed, 116 insertions, 115 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs
index f45b6c25..420e6912 100644
--- a/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/IStaticService.cs
@@ -17,52 +17,52 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(0)]
// GetStandardUserSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
- public long GetStandardUserSystemClock(ServiceCtx context)
+ public ResultCode GetStandardUserSystemClock(ServiceCtx context)
{
MakeObject(context, new ISystemClock(SystemClockType.User));
- return 0;
+ return ResultCode.Success;
}
[Command(1)]
// GetStandardNetworkSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
- public long GetStandardNetworkSystemClock(ServiceCtx context)
+ public ResultCode GetStandardNetworkSystemClock(ServiceCtx context)
{
MakeObject(context, new ISystemClock(SystemClockType.Network));
- return 0;
+ return ResultCode.Success;
}
[Command(2)]
// GetStandardSteadyClock() -> object<nn::timesrv::detail::service::ISteadyClock>
- public long GetStandardSteadyClock(ServiceCtx context)
+ public ResultCode GetStandardSteadyClock(ServiceCtx context)
{
MakeObject(context, new ISteadyClock());
- return 0;
+ return ResultCode.Success;
}
[Command(3)]
// GetTimeZoneService() -> object<nn::timesrv::detail::service::ITimeZoneService>
- public long GetTimeZoneService(ServiceCtx context)
+ public ResultCode GetTimeZoneService(ServiceCtx context)
{
MakeObject(context, new ITimeZoneService());
- return 0;
+ return ResultCode.Success;
}
[Command(4)]
// GetStandardLocalSystemClock() -> object<nn::timesrv::detail::service::ISystemClock>
- public long GetStandardLocalSystemClock(ServiceCtx context)
+ public ResultCode GetStandardLocalSystemClock(ServiceCtx context)
{
MakeObject(context, new ISystemClock(SystemClockType.Local));
- return 0;
+ return ResultCode.Success;
}
[Command(20)] // 6.0.0+
// GetSharedMemoryNativeHandle() -> handle<copy>
- public long GetSharedMemoryNativeHandle(ServiceCtx context)
+ public ResultCode GetSharedMemoryNativeHandle(ServiceCtx context)
{
if (_timeSharedMemoryNativeHandle == 0)
{
@@ -74,20 +74,19 @@ namespace Ryujinx.HLE.HOS.Services.Time
context.Response.HandleDesc = IpcHandleDesc.MakeCopy(_timeSharedMemoryNativeHandle);
- return 0;
+ return ResultCode.Success;
}
[Command(300)] // 4.0.0+
// CalculateMonotonicSystemClockBaseTimePoint(nn::time::SystemClockContext) -> u64
- public long CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context)
+ public ResultCode CalculateMonotonicSystemClockBaseTimePoint(ServiceCtx context)
{
long timeOffset = (long)(DateTime.UtcNow - StartupDate).TotalSeconds;
long systemClockContextEpoch = context.RequestData.ReadInt64();
context.ResponseData.Write(timeOffset + systemClockContextEpoch);
- return 0;
+ return ResultCode.Success;
}
-
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs
index 4964e616..ccf19d7d 100644
--- a/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/ISteadyClock.cs
@@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(0)]
// GetCurrentTimePoint() -> nn::time::SteadyClockTimePoint
- public long GetCurrentTimePoint(ServiceCtx context)
+ public ResultCode GetCurrentTimePoint(ServiceCtx context)
{
context.ResponseData.Write((long)(System.Diagnostics.Process.GetCurrentProcess().StartTime - DateTime.Now).TotalSeconds);
@@ -22,25 +22,25 @@ namespace Ryujinx.HLE.HOS.Services.Time
context.ResponseData.Write((byte)0);
}
- return 0;
+ return ResultCode.Success;
}
[Command(1)]
// GetTestOffset() -> nn::TimeSpanType
- public long GetTestOffset(ServiceCtx context)
+ public ResultCode GetTestOffset(ServiceCtx context)
{
context.ResponseData.Write(_testOffset);
- return 0;
+ return ResultCode.Success;
}
[Command(2)]
// SetTestOffset(nn::TimeSpanType)
- public long SetTestOffset(ServiceCtx context)
+ public ResultCode SetTestOffset(ServiceCtx context)
{
_testOffset = context.RequestData.ReadUInt64();
- return 0;
+ return ResultCode.Success;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs b/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs
index a9e5fc75..0ed34d17 100644
--- a/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/ISystemClock.cs
@@ -30,7 +30,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(0)]
// GetCurrentTime() -> nn::time::PosixTime
- public long GetCurrentTime(ServiceCtx context)
+ public ResultCode GetCurrentTime(ServiceCtx context)
{
DateTime currentTime = DateTime.Now;
@@ -42,12 +42,12 @@ namespace Ryujinx.HLE.HOS.Services.Time
context.ResponseData.Write((long)((currentTime - Epoch).TotalSeconds) + _timeOffset);
- return 0;
+ return ResultCode.Success;
}
[Command(1)]
// SetCurrentTime(nn::time::PosixTime)
- public long SetCurrentTime(ServiceCtx context)
+ public ResultCode SetCurrentTime(ServiceCtx context)
{
DateTime currentTime = DateTime.Now;
@@ -59,12 +59,12 @@ namespace Ryujinx.HLE.HOS.Services.Time
_timeOffset = (context.RequestData.ReadInt64() - (long)(currentTime - Epoch).TotalSeconds);
- return 0;
+ return ResultCode.Success;
}
[Command(2)]
// GetSystemClockContext() -> nn::time::SystemClockContext
- public long GetSystemClockContext(ServiceCtx context)
+ public ResultCode GetSystemClockContext(ServiceCtx context)
{
context.ResponseData.Write((long)(_systemClockContextEpoch - Epoch).TotalSeconds);
@@ -77,12 +77,12 @@ namespace Ryujinx.HLE.HOS.Services.Time
context.ResponseData.Write(_systemClockContextEnding[i]);
}
- return 0;
+ return ResultCode.Success;
}
[Command(3)]
// SetSystemClockContext(nn::time::SystemClockContext)
- public long SetSystemClockContext(ServiceCtx context)
+ public ResultCode SetSystemClockContext(ServiceCtx context)
{
long newSystemClockEpoch = context.RequestData.ReadInt64();
long newSystemClockTimePoint = context.RequestData.ReadInt64();
@@ -91,7 +91,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
_systemClockTimePoint = newSystemClockTimePoint;
_systemClockContextEnding = context.RequestData.ReadBytes(0x10);
- return 0;
+ return ResultCode.Success;
}
}
} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs
index 56651716..74182428 100644
--- a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneService.cs
@@ -5,8 +5,6 @@ using Ryujinx.HLE.HOS.Services.Time.TimeZone;
using System;
using System.Text;
-using static Ryujinx.HLE.HOS.ErrorCode;
-
namespace Ryujinx.HLE.HOS.Services.Time
{
class ITimeZoneService : IpcService
@@ -15,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(0)]
// GetDeviceLocationName() -> nn::time::LocationName
- public long GetDeviceLocationName(ServiceCtx context)
+ public ResultCode GetDeviceLocationName(ServiceCtx context)
{
char[] tzName = TimeZoneManager.Instance.GetDeviceLocationName().ToCharArray();
@@ -23,7 +21,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
if (padding < 0)
{
- return MakeError(ErrorModule.Time, TimeError.LocationNameTooLong);
+ return ResultCode.LocationNameTooLong;
}
context.ResponseData.Write(tzName);
@@ -33,12 +31,12 @@ namespace Ryujinx.HLE.HOS.Services.Time
context.ResponseData.Write((byte)0);
}
- return 0;
+ return ResultCode.Success;
}
[Command(1)]
// SetDeviceLocationName(nn::time::LocationName)
- public long SetDeviceLocationName(ServiceCtx context)
+ public ResultCode SetDeviceLocationName(ServiceCtx context)
{
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
@@ -47,23 +45,23 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(2)]
// GetTotalLocationNameCount() -> u32
- public long GetTotalLocationNameCount(ServiceCtx context)
+ public ResultCode GetTotalLocationNameCount(ServiceCtx context)
{
context.ResponseData.Write(TimeZoneManager.Instance.GetTotalLocationNameCount());
- return 0;
+ return ResultCode.Success;
}
[Command(3)]
// LoadLocationNameList(u32 index) -> (u32 outCount, buffer<nn::time::LocationName, 6>)
- public long LoadLocationNameList(ServiceCtx context)
+ public ResultCode LoadLocationNameList(ServiceCtx context)
{
// TODO: fix logic to use index
uint index = context.RequestData.ReadUInt32();
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferSize = context.Request.ReceiveBuff[0].Size;
- uint errorCode = TimeZoneManager.Instance.LoadLocationNameList(index, out string[] locationNameArray, (uint)bufferSize / 0x24);
+ ResultCode errorCode = TimeZoneManager.Instance.LoadLocationNameList(index, out string[] locationNameArray, (uint)bufferSize / 0x24);
if (errorCode == 0)
{
@@ -75,7 +73,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
if (padding < 0)
{
- return MakeError(ErrorModule.Time, TimeError.LocationNameTooLong);
+ return ResultCode.LocationNameTooLong;
}
context.Memory.WriteBytes(bufferPosition + offset, Encoding.ASCII.GetBytes(locationName));
@@ -92,7 +90,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(4)]
// LoadTimeZoneRule(nn::time::LocationName locationName) -> buffer<nn::time::TimeZoneRule, 0x16>
- public long LoadTimeZoneRule(ServiceCtx context)
+ public ResultCode LoadTimeZoneRule(ServiceCtx context)
{
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferSize = context.Request.ReceiveBuff[0].Size;
@@ -108,7 +106,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
- long resultCode = TimeZoneManager.Instance.LoadTimeZoneRules(out TimeZoneRule rules, locationName);
+ ResultCode resultCode = TimeZoneManager.Instance.LoadTimeZoneRules(out TimeZoneRule rules, locationName);
// Write TimeZoneRule if success
if (resultCode == 0)
@@ -121,7 +119,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(100)]
// ToCalendarTime(nn::time::PosixTime time, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo)
- public long ToCalendarTime(ServiceCtx context)
+ public ResultCode ToCalendarTime(ServiceCtx context)
{
long posixTime = context.RequestData.ReadInt64();
long bufferPosition = context.Request.SendBuff[0].Position;
@@ -137,7 +135,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
TimeZoneRule rules = MemoryHelper.Read<TimeZoneRule>(context.Memory, bufferPosition);
- long resultCode = TimeZoneManager.ToCalendarTime(rules, posixTime, out CalendarInfo calendar);
+ ResultCode resultCode = TimeZoneManager.ToCalendarTime(rules, posixTime, out CalendarInfo calendar);
if (resultCode == 0)
{
@@ -149,11 +147,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(101)]
// ToCalendarTimeWithMyRule(nn::time::PosixTime) -> (nn::time::CalendarTime, nn::time::sf::CalendarAdditionalInfo)
- public long ToCalendarTimeWithMyRule(ServiceCtx context)
+ public ResultCode ToCalendarTimeWithMyRule(ServiceCtx context)
{
long posixTime = context.RequestData.ReadInt64();
- long resultCode = TimeZoneManager.Instance.ToCalendarTimeWithMyRules(posixTime, out CalendarInfo calendar);
+ ResultCode resultCode = TimeZoneManager.Instance.ToCalendarTimeWithMyRules(posixTime, out CalendarInfo calendar);
if (resultCode == 0)
{
@@ -165,7 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(201)]
// ToPosixTime(nn::time::CalendarTime calendarTime, buffer<nn::time::TimeZoneRule, 0x15> rules) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>)
- public long ToPosixTime(ServiceCtx context)
+ public ResultCode ToPosixTime(ServiceCtx context)
{
long inBufferPosition = context.Request.SendBuff[0].Position;
long inBufferSize = context.Request.SendBuff[0].Size;
@@ -182,7 +180,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
TimeZoneRule rules = MemoryHelper.Read<TimeZoneRule>(context.Memory, inBufferPosition);
- long resultCode = TimeZoneManager.ToPosixTime(rules, calendarTime, out long posixTime);
+ ResultCode resultCode = TimeZoneManager.ToPosixTime(rules, calendarTime, out long posixTime);
if (resultCode == 0)
{
@@ -198,11 +196,11 @@ namespace Ryujinx.HLE.HOS.Services.Time
[Command(202)]
// ToPosixTimeWithMyRule(nn::time::CalendarTime calendarTime) -> (u32 outCount, buffer<nn::time::PosixTime, 0xa>)
- public long ToPosixTimeWithMyRule(ServiceCtx context)
+ public ResultCode ToPosixTimeWithMyRule(ServiceCtx context)
{
CalendarTime calendarTime = context.RequestData.ReadStruct<CalendarTime>();
- long resultCode = TimeZoneManager.Instance.ToPosixTimeWithMyRules(calendarTime, out long posixTime);
+ ResultCode resultCode = TimeZoneManager.Instance.ToPosixTimeWithMyRules(calendarTime, out long posixTime);
if (resultCode == 0)
{
diff --git a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneServiceTypes.cs b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneServiceTypes.cs
index e50bd5d6..9a83b82b 100644
--- a/Ryujinx.HLE/HOS/Services/Time/ITimeZoneServiceTypes.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/ITimeZoneServiceTypes.cs
@@ -125,4 +125,4 @@ namespace Ryujinx.HLE.HOS.Services.Time
public CalendarTime Time;
public CalendarAdditionalInfo AdditionalInfo;
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs b/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs
new file mode 100644
index 00000000..5868a458
--- /dev/null
+++ b/Ryujinx.HLE/HOS/Services/Time/ResultCode.cs
@@ -0,0 +1,17 @@
+namespace Ryujinx.HLE.HOS.Services.Time
+{
+ public enum ResultCode
+ {
+ ModuleId = 116,
+ ErrorCodeShift = 9,
+
+ Success = 0,
+
+ TimeNotFound = (200 << ErrorCodeShift) | ModuleId,
+ Overflow = (201 << ErrorCodeShift) | ModuleId,
+ LocationNameTooLong = (801 << ErrorCodeShift) | ModuleId,
+ OutOfRange = (902 << ErrorCodeShift) | ModuleId,
+ TimeZoneConversionFailed = (903 << ErrorCodeShift) | ModuleId,
+ TimeZoneNotFound = (989 << ErrorCodeShift) | ModuleId
+ }
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeError.cs b/Ryujinx.HLE/HOS/Services/Time/TimeError.cs
deleted file mode 100644
index 20b2375c..00000000
--- a/Ryujinx.HLE/HOS/Services/Time/TimeError.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace Ryujinx.HLE.HOS.Services.Time
-{
- static class TimeError
- {
- public const int TimeNotFound = 200;
- public const int Overflow = 201;
- public const int LocationNameTooLong = 801;
- public const int OutOfRange = 902;
- public const int TimeZoneConversionFailed = 903;
- public const int TimeZoneNotFound = 989;
- }
-}
diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs
index 8039dc89..4898b2b9 100644
--- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZone.cs
@@ -1237,7 +1237,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
}
}
- private static int CreateCalendarTime(long time, int gmtOffset, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo)
+ private static ResultCode CreateCalendarTime(long time, int gmtOffset, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo)
{
long year = EpochYear;
long timeDays = time / SecondsPerDay;
@@ -1263,7 +1263,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (IncrementOverflow64(ref newYear, delta))
{
- return TimeError.OutOfRange;
+ return ResultCode.OutOfRange;
}
long leapDays = GetLeapDays(newYear - 1) - GetLeapDays(year - 1);
@@ -1290,7 +1290,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
if (IncrementOverflow64(ref year, -1))
{
- return TimeError.OutOfRange;
+ return ResultCode.OutOfRange;
}
dayOfYear += YearLengths[IsLeap((int)year)];
@@ -1302,7 +1302,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (IncrementOverflow64(ref year, 1))
{
- return TimeError.OutOfRange;
+ return ResultCode.OutOfRange;
}
}
@@ -1340,7 +1340,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return 0;
}
- private static int ToCalendarTimeInternal(TimeZoneRule rules, long time, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo)
+ private static ResultCode ToCalendarTimeInternal(TimeZoneRule rules, long time, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo)
{
calendarTime = new CalendarTimeInternal();
calendarAdditionalInfo = new CalendarAdditionalInfo()
@@ -1348,7 +1348,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
TimezoneName = new char[8]
};
- int result;
+ ResultCode result;
if ((rules.GoAhead && time < rules.Ats[0]) || (rules.GoBack && time > rules.Ats[rules.TimeCount - 1]))
{
@@ -1382,7 +1382,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (newTime < rules.Ats[0] && newTime > rules.Ats[rules.TimeCount - 1])
{
- return TimeError.TimeNotFound;
+ return ResultCode.TimeNotFound;
}
result = ToCalendarTimeInternal(rules, newTime, out calendarTime, out calendarAdditionalInfo);
@@ -1400,7 +1400,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
calendarTime.Year += years;
}
- return 0;
+ return ResultCode.Success;
}
int ttiIndex;
@@ -1453,7 +1453,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return result;
}
- private static int ToPosixTimeInternal(TimeZoneRule rules, CalendarTimeInternal calendarTime, out long posixTime)
+ private static ResultCode ToPosixTimeInternal(TimeZoneRule rules, CalendarTimeInternal calendarTime, out long posixTime)
{
posixTime = 0;
@@ -1462,7 +1462,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (NormalizeOverflow32(ref hour, ref minute, MinutesPerHour))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
calendarTime.Minute = (sbyte)minute;
@@ -1470,7 +1470,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
int day = calendarTime.Day;
if (NormalizeOverflow32(ref day, ref hour, HoursPerDays))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
calendarTime.Day = (sbyte)day;
@@ -1481,21 +1481,21 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (NormalizeOverflow64(ref year, ref month, MonthsPerYear))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
calendarTime.Month = (sbyte)month;
if (IncrementOverflow64(ref year, YearBase))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
while (day <= 0)
{
if (IncrementOverflow64(ref year, -1))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
long li = year;
@@ -1521,7 +1521,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (IncrementOverflow64(ref year, 1))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
}
@@ -1542,7 +1542,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
calendarTime.Month = 0;
if (IncrementOverflow64(ref year, 1))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
}
}
@@ -1551,7 +1551,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (IncrementOverflow64(ref year, -YearBase))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
calendarTime.Year = year;
@@ -1567,7 +1567,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
int second = calendarTime.Second;
if (IncrementOverflow32(ref second, 1 - SecondsPerMinute))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
savedSeconds = second;
@@ -1597,7 +1597,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
int direction;
- int result = ToCalendarTimeInternal(rules, pivot, out CalendarTimeInternal candidateCalendarTime, out _);
+ ResultCode result = ToCalendarTimeInternal(rules, pivot, out CalendarTimeInternal candidateCalendarTime, out _);
if (result != 0)
{
if (pivot > 0)
@@ -1620,7 +1620,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if ((timeResult < pivot) != (savedSeconds < 0))
{
- return TimeError.Overflow;
+ return ResultCode.Overflow;
}
posixTime = timeResult;
@@ -1632,7 +1632,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
if (pivot == long.MaxValue)
{
- return TimeError.TimeNotFound;
+ return ResultCode.TimeNotFound;
}
pivot += 1;
@@ -1642,7 +1642,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
if (pivot == long.MinValue)
{
- return TimeError.TimeNotFound;
+ return ResultCode.TimeNotFound;
}
pivot -= 1;
@@ -1651,7 +1651,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (low > high)
{
- return TimeError.TimeNotFound;
+ return ResultCode.TimeNotFound;
}
if (direction > 0)
@@ -1665,12 +1665,12 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
}
}
- return 0;
+ return ResultCode.Success;
}
- internal static int ToCalendarTime(TimeZoneRule rules, long time, out CalendarInfo calendar)
+ internal static ResultCode ToCalendarTime(TimeZoneRule rules, long time, out CalendarInfo calendar)
{
- int result = ToCalendarTimeInternal(rules, time, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo);
+ ResultCode result = ToCalendarTimeInternal(rules, time, out CalendarTimeInternal calendarTime, out CalendarAdditionalInfo calendarAdditionalInfo);
calendar = new CalendarInfo()
{
@@ -1689,7 +1689,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return result;
}
- internal static int ToPosixTime(TimeZoneRule rules, CalendarTime calendarTime, out long posixTime)
+ internal static ResultCode ToPosixTime(TimeZoneRule rules, CalendarTime calendarTime, out long posixTime)
{
CalendarTimeInternal calendarTimeInternal = new CalendarTimeInternal()
{
@@ -1704,4 +1704,4 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return ToPosixTimeInternal(rules, calendarTimeInternal, out posixTime);
}
}
-}
+} \ No newline at end of file
diff --git a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs
index b3dc4c34..cf27639b 100644
--- a/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs
+++ b/Ryujinx.HLE/HOS/Services/Time/TimeZone/TimeZoneManager.cs
@@ -10,7 +10,6 @@ using TimeZoneConverter.Posix;
using TimeZoneConverter;
using static Ryujinx.HLE.HOS.Services.Time.TimeZoneRule;
-using static Ryujinx.HLE.HOS.ErrorCode;
namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
@@ -138,9 +137,9 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return _deviceLocationName;
}
- public uint SetDeviceLocationName(string locationName)
+ public ResultCode SetDeviceLocationName(string locationName)
{
- uint resultCode = LoadTimeZoneRules(out TimeZoneRule rules, locationName);
+ ResultCode resultCode = LoadTimeZoneRules(out TimeZoneRule rules, locationName);
if (resultCode == 0)
{
@@ -151,7 +150,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return resultCode;
}
- public uint LoadLocationNameList(uint index, out string[] outLocationNameArray, uint maxLength)
+ public ResultCode LoadLocationNameList(uint index, out string[] outLocationNameArray, uint maxLength)
{
List<string> locationNameList = new List<string>();
@@ -169,7 +168,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
outLocationNameArray = new string[0];
- return MakeError(ErrorModule.Time, TimeError.LocationNameTooLong);
+ return ResultCode.LocationNameTooLong;
}
locationNameList.Add(locationName);
@@ -177,7 +176,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
outLocationNameArray = locationNameList.ToArray();
- return 0;
+ return ResultCode.Success;
}
public uint GetTotalLocationNameCount()
@@ -195,7 +194,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
return !string.IsNullOrEmpty(GetTimeZoneBinaryTitleContentPath());
}
- internal uint LoadTimeZoneRules(out TimeZoneRule outRules, string locationName)
+ internal ResultCode LoadTimeZoneRules(out TimeZoneRule outRules, string locationName)
{
outRules = new TimeZoneRule
{
@@ -207,7 +206,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (!IsLocationNameValid(locationName))
{
- return MakeError(ErrorModule.Time, TimeError.TimeZoneNotFound);
+ return ResultCode.TimeZoneNotFound;
}
if (!HasTimeZoneBinaryTitle())
@@ -222,7 +221,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (!TimeZone.ParsePosixName(posixRule, out outRules))
{
- return MakeError(ErrorModule.Time, TimeError.TimeZoneConversionFailed);
+ return ResultCode.TimeZoneConversionFailed;
}
return 0;
@@ -231,7 +230,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
{
Logger.PrintWarning(LogClass.ServiceTime, $"Timezone not found for string: {locationName})");
- return MakeError(ErrorModule.Time, TimeError.TimeZoneNotFound);
+ return ResultCode.TimeZoneNotFound;
}
}
else
@@ -244,7 +243,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
if (!TimeZone.LoadTimeZoneRules(out outRules, tzIfStream))
{
- return MakeError(ErrorModule.Time, TimeError.TimeZoneConversionFailed);
+ return ResultCode.TimeZoneConversionFailed;
}
}
@@ -252,38 +251,38 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
}
}
- internal uint ToCalendarTimeWithMyRules(long time, out CalendarInfo calendar)
+ internal ResultCode ToCalendarTimeWithMyRules(long time, out CalendarInfo calendar)
{
return ToCalendarTime(_myRules, time, out calendar);
}
- internal static uint ToCalendarTime(TimeZoneRule rules, long time, out CalendarInfo calendar)
+ internal static ResultCode ToCalendarTime(TimeZoneRule rules, long time, out CalendarInfo calendar)
{
- int error = TimeZone.ToCalendarTime(rules, time, out calendar);
+ ResultCode error = TimeZone.ToCalendarTime(rules, time, out calendar);
- if (error != 0)
+ if (error != ResultCode.Success)
{
- return MakeError(ErrorModule.Time, error);
+ return error;
}
- return 0;
+ return ResultCode.Success;
}
- internal uint ToPosixTimeWithMyRules(CalendarTime calendarTime, out long posixTime)
+ internal ResultCode ToPosixTimeWithMyRules(CalendarTime calendarTime, out long posixTime)
{
return ToPosixTime(_myRules, calendarTime, out posixTime);
}
- internal static uint ToPosixTime(TimeZoneRule rules, CalendarTime calendarTime, out long posixTime)
+ internal static ResultCode ToPosixTime(TimeZoneRule rules, CalendarTime calendarTime, out long posixTime)
{
- int error = TimeZone.ToPosixTime(rules, calendarTime, out posixTime);
+ ResultCode error = TimeZone.ToPosixTime(rules, calendarTime, out posixTime);
- if (error != 0)
+ if (error != ResultCode.Success)
{
- return MakeError(ErrorModule.Time, error);
+ return error;
}
- return 0;
+ return ResultCode.Success;
}
}
-}
+} \ No newline at end of file