Address comments
This commit is contained in:
parent
792a0b3e6d
commit
7efb073ac9
4 changed files with 338 additions and 330 deletions
|
@ -61,6 +61,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
public long SetDeviceLocationName(ServiceCtx context)
|
||||
{
|
||||
string locationName = Encoding.ASCII.GetString(context.RequestData.ReadBytes(0x24)).TrimEnd('\0');
|
||||
|
||||
return TimeZoneManager.Instance.SetDeviceLocationName(locationName);
|
||||
}
|
||||
|
||||
|
@ -97,6 +98,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
|
||||
context.Memory.WriteBytes(bufferPosition + offset, Encoding.ASCII.GetBytes(locationName));
|
||||
MemoryHelper.FillWithZeros(context.Memory, bufferPosition + offset + locationName.Length, padding);
|
||||
|
||||
offset += 0x24;
|
||||
}
|
||||
|
||||
|
@ -116,6 +118,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
// TODO: find error code here
|
||||
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
|
@ -144,6 +147,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
// TODO: find error code here
|
||||
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{bufferSize:x} (expected 0x4000)");
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
|
@ -186,6 +190,7 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
{
|
||||
// TODO: find error code here
|
||||
Logger.PrintError(LogClass.ServiceTime, $"TimeZoneRule buffer size is 0x{inBufferSize:x} (expected 0x4000)");
|
||||
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
|
@ -218,6 +223,8 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
long outBufferSize = context.Request.RecvListBuff[0].Size;
|
||||
|
||||
context.Memory.WriteInt64(outBufferPosition, posixTime);
|
||||
|
||||
// There could be only one result on one calendar as leap seconds aren't supported.
|
||||
context.ResponseData.Write(1);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,24 +5,24 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
[StructLayout(LayoutKind.Sequential, Size = 0x10, Pack = 4)]
|
||||
public struct TimeTypeInfo
|
||||
{
|
||||
public int gmtOffset;
|
||||
public int GmtOffset;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool isDaySavingTime;
|
||||
public bool IsDaySavingTime;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
char[] padding1;
|
||||
char[] Padding1;
|
||||
|
||||
public int abbreviationListIndex;
|
||||
public int AbbreviationListIndex;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool isStandardTimeDaylight;
|
||||
public bool IsStandardTimeDaylight;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool isGMT;
|
||||
public bool IsGMT;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
|
||||
char[] padding2;
|
||||
char[] Padding2;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 0x4000, CharSet = CharSet.Ansi)]
|
||||
|
@ -35,94 +35,94 @@ namespace Ryujinx.HLE.HOS.Services.Time
|
|||
public const int TzNameMax = 255;
|
||||
public const int TzCharsArraySize = 2 * (TzNameMax + 1);
|
||||
|
||||
public int timeCount;
|
||||
public int typeCount;
|
||||
public int charCount;
|
||||
public int TimeCount;
|
||||
public int TypeCount;
|
||||
public int CharCount;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool goBack;
|
||||
public bool GoBack;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool goAhead;
|
||||
public bool GoAhead;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
|
||||
public long[] ats;
|
||||
public long[] Ats;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTimes)]
|
||||
public byte[] types;
|
||||
public byte[] Types;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzMaxTypes)]
|
||||
public TimeTypeInfo[] ttis;
|
||||
public TimeTypeInfo[] Ttis;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = TzCharsArraySize)]
|
||||
public char[] chars;
|
||||
public char[] Chars;
|
||||
|
||||
public int defaultType;
|
||||
public int DefaultType;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x2C)]
|
||||
public struct TzifHeader
|
||||
{
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public char[] magic;
|
||||
public char[] Magic;
|
||||
|
||||
public char version;
|
||||
public char Version;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 15)]
|
||||
public byte[] reserved;
|
||||
public byte[] Reserved;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] ttisGMTCount;
|
||||
public byte[] TtisGMTCount;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] ttisSTDCount;
|
||||
public byte[] TtisSTDCount;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] leapCount;
|
||||
public byte[] LeapCount;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] timeCount;
|
||||
public byte[] TimeCount;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] typeCount;
|
||||
public byte[] TypeCount;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 4)]
|
||||
public byte[] charCount;
|
||||
public byte[] CharCount;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x8)]
|
||||
public struct CalendarTime
|
||||
{
|
||||
public short year;
|
||||
public sbyte month;
|
||||
public sbyte day;
|
||||
public sbyte hour;
|
||||
public sbyte minute;
|
||||
public sbyte second;
|
||||
public short Year;
|
||||
public sbyte Month;
|
||||
public sbyte Day;
|
||||
public sbyte Hour;
|
||||
public sbyte Minute;
|
||||
public sbyte Second;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x18, CharSet = CharSet.Ansi)]
|
||||
public struct CalendarAdditionalInfo
|
||||
{
|
||||
public uint dayOfWeek;
|
||||
public uint dayOfYear;
|
||||
public uint DayOfWeek;
|
||||
public uint DayOfYear;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
|
||||
public char[] timezoneName;
|
||||
public char[] TimezoneName;
|
||||
|
||||
[MarshalAs(UnmanagedType.I1)]
|
||||
public bool isDaySavingTime;
|
||||
public bool IsDaySavingTime;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 3)]
|
||||
char[] padding;
|
||||
char[] Padding;
|
||||
|
||||
public int gmtOffset;
|
||||
public int GmtOffset;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 0x4, Size = 0x20, CharSet = CharSet.Ansi)]
|
||||
public struct CalendarInfo
|
||||
{
|
||||
public CalendarTime time;
|
||||
public CalendarAdditionalInfo additionalInfo;
|
||||
public CalendarTime Time;
|
||||
public CalendarAdditionalInfo AdditionalInfo;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -18,11 +18,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
{
|
||||
private const long TimeZoneBinaryTitleId = 0x010000000000080E;
|
||||
|
||||
private static TimeZoneManager instance = null;
|
||||
private static TimeZoneManager instance;
|
||||
|
||||
private static object instanceLock = new object();
|
||||
|
||||
|
||||
private Switch _device;
|
||||
private TimeZoneRule _myRules;
|
||||
private string _deviceLocationName;
|
||||
|
@ -35,10 +34,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
// Empty rules (UTC)
|
||||
_myRules = new TimeZoneRule
|
||||
{
|
||||
ats = new long[TzMaxTimes],
|
||||
types = new byte[TzMaxTimes],
|
||||
ttis = new TimeTypeInfo[TzMaxTypes],
|
||||
chars = new char[TzCharsArraySize]
|
||||
Ats = new long[TzMaxTimes],
|
||||
Types = new byte[TzMaxTimes],
|
||||
Ttis = new TimeTypeInfo[TzMaxTypes],
|
||||
Chars = new char[TzCharsArraySize]
|
||||
};
|
||||
|
||||
_deviceLocationName = "UTC";
|
||||
|
@ -57,8 +56,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
{
|
||||
using (IStorage ncaFileStream = new LocalStorage(_device.FileSystem.SwitchPathToSystemPath(GetTimeZoneBinaryTitleContentPath()), FileAccess.Read, FileMode.Open))
|
||||
{
|
||||
Nca nca = new Nca(_device.System.KeySet, ncaFileStream);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
|
||||
Nca nca = new Nca(_device.System.KeySet, ncaFileStream);
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
|
||||
Stream binaryListStream = romfs.OpenFile("binaryList.txt", OpenMode.Read).AsStream();
|
||||
|
||||
StreamReader reader = new StreamReader(binaryListStream);
|
||||
|
@ -155,6 +154,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
if (locationName.Length > 0x24)
|
||||
{
|
||||
outLocationNameArray = new string[0];
|
||||
|
||||
return MakeError(ErrorModule.Time, TimeError.LocationNameTooLong);
|
||||
}
|
||||
|
||||
|
@ -162,6 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
}
|
||||
|
||||
outLocationNameArray = locationNameList.ToArray();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -184,10 +185,10 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
{
|
||||
outRules = new TimeZoneRule
|
||||
{
|
||||
ats = new long[TzMaxTimes],
|
||||
types = new byte[TzMaxTimes],
|
||||
ttis = new TimeTypeInfo[TzMaxTypes],
|
||||
chars = new char[TzCharsArraySize]
|
||||
Ats = new long[TzMaxTimes],
|
||||
Types = new byte[TzMaxTimes],
|
||||
Ttis = new TimeTypeInfo[TzMaxTypes],
|
||||
Chars = new char[TzCharsArraySize]
|
||||
};
|
||||
|
||||
if (!IsLocationNameValid(locationName))
|
||||
|
@ -202,8 +203,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
Logger.PrintWarning(LogClass.ServiceTime, "TimeZoneBinary system archive not found! Time conversions will not be accurate!");
|
||||
try
|
||||
{
|
||||
TimeZoneInfo info = TZConvert.GetTimeZoneInfo(locationName);
|
||||
string posixRule = PosixTimeZone.FromTimeZoneInfo(info);
|
||||
TimeZoneInfo info = TZConvert.GetTimeZoneInfo(locationName);
|
||||
string posixRule = PosixTimeZone.FromTimeZoneInfo(info);
|
||||
|
||||
if (!TimeZone.ParsePosixName(posixRule, out outRules))
|
||||
{
|
||||
|
@ -225,8 +226,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
|
|||
{
|
||||
Nca nca = new Nca(_device.System.KeySet, ncaFileStream);
|
||||
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
|
||||
Stream tzIfStream = romfs.OpenFile($"zoneinfo/{locationName}", OpenMode.Read).AsStream();
|
||||
IFileSystem romfs = nca.OpenFileSystem(NcaSectionType.Data, _device.System.FsIntegrityCheckLevel);
|
||||
Stream tzIfStream = romfs.OpenFile($"zoneinfo/{locationName}", OpenMode.Read).AsStream();
|
||||
|
||||
if (!TimeZone.LoadTimeZoneRules(out outRules, tzIfStream))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue