mirror of
https://github.com/GreemDev/Ryujinx
synced 2024-11-21 17:40:52 +01:00
misc: Convert UIntUtils.CreateRandom into an extension on Random.
This commit is contained in:
parent
cb31d79164
commit
a989d28e03
5 changed files with 14 additions and 12 deletions
|
@ -5,14 +5,16 @@ namespace Ryujinx.Common.Utilities
|
||||||
{
|
{
|
||||||
public static class UInt128Utils
|
public static class UInt128Utils
|
||||||
{
|
{
|
||||||
public static UInt128 FromHex(string hex)
|
public static UInt128 FromHex(string hex) =>
|
||||||
{
|
new(
|
||||||
return new UInt128(ulong.Parse(hex.AsSpan(0, 16), NumberStyles.HexNumber), ulong.Parse(hex.AsSpan(16), NumberStyles.HexNumber));
|
ulong.Parse(hex.AsSpan(0, 16), NumberStyles.HexNumber),
|
||||||
}
|
ulong.Parse(hex.AsSpan(16), NumberStyles.HexNumber)
|
||||||
|
);
|
||||||
|
|
||||||
public static UInt128 CreateRandom()
|
public static Int128 NextInt128(this Random rand) =>
|
||||||
{
|
new((ulong)rand.NextInt64(), (ulong)rand.NextInt64());
|
||||||
return new UInt128((ulong)Random.Shared.NextInt64(), (ulong)Random.Shared.NextInt64());
|
|
||||||
}
|
public static UInt128 NextUInt128(this Random rand) =>
|
||||||
|
new((ulong)rand.NextInt64(), (ulong)rand.NextInt64());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,7 +63,7 @@ namespace Ryujinx.HLE.HOS.Services.Mii
|
||||||
|
|
||||||
public CreateId MakeCreateId()
|
public CreateId MakeCreateId()
|
||||||
{
|
{
|
||||||
UInt128 value = UInt128Utils.CreateRandom();
|
UInt128 value = Random.Shared.NextUInt128();
|
||||||
|
|
||||||
// Ensure the random ID generated is valid as a create id.
|
// Ensure the random ID generated is valid as a create id.
|
||||||
value &= ~new UInt128(0xC0, 0);
|
value &= ~new UInt128(0xC0, 0);
|
||||||
|
|
|
@ -78,7 +78,7 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
|
||||||
|
|
||||||
NetworkProfileData networkProfile = new()
|
NetworkProfileData networkProfile = new()
|
||||||
{
|
{
|
||||||
Uuid = UInt128Utils.CreateRandom(),
|
Uuid = Random.Shared.NextUInt128(),
|
||||||
};
|
};
|
||||||
|
|
||||||
networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress);
|
networkProfile.IpSettingData.IpAddressSetting = new IpAddressSetting(interfaceProperties, unicastAddress);
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
||||||
|
|
||||||
public SteadyClockCore()
|
public SteadyClockCore()
|
||||||
{
|
{
|
||||||
_clockSourceId = UInt128Utils.CreateRandom();
|
_clockSourceId = Random.Shared.NextUInt128();
|
||||||
_isRtcResetDetected = false;
|
_isRtcResetDetected = false;
|
||||||
_isInitialized = false;
|
_isInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.Clock
|
||||||
return new SteadyClockTimePoint
|
return new SteadyClockTimePoint
|
||||||
{
|
{
|
||||||
TimePoint = 0,
|
TimePoint = 0,
|
||||||
ClockSourceId = UInt128Utils.CreateRandom(),
|
ClockSourceId = Random.Shared.NextUInt128(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue