mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-19 23:17:24 -05:00
* Pre-patch preparations
* Update magic values
* Check formatting characters directly rather than string compare
"Brown".StartsWith("\u000e")
>true
what
let's be paranoid here, because .NET Core behaves differently from .NET framework.
* Update FileHashRevision.cs
Postbox with the massive decrease in size; likely the same mutation caused the other massive decreases.
* Dump item names
* Update flag definitions
* Update item info
* Add feathers to bug list
Might remove later.
* Update RecipeList.cs
* Update ItemRemakeUtil.cs
* Update stack details
* Update offsets
* Update MainSaveOffsets17.cs
* Update GameLists.cs
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
namespace NHSE.Core
|
|
{
|
|
/// <summary>
|
|
/// Xorshift128 RNG Implementation (xor128)
|
|
/// <see href="https://en.wikipedia.org/wiki/Xorshift#Example_implementation"/>
|
|
/// </summary>
|
|
internal ref struct XorShift128
|
|
{
|
|
private uint a, b, c, d;
|
|
private const int Mersenne = 0x6C078965;
|
|
|
|
/// <summary>
|
|
/// Initialize the generator from a seed.
|
|
/// </summary>
|
|
/// <param name="seed">Ticks, usually.</param>
|
|
public XorShift128(uint seed)
|
|
{
|
|
// Unrolled Mersenne Twister initialization loop
|
|
a = (Mersenne * (seed ^ (seed >> 30))) + 1;
|
|
b = (Mersenne * ( a ^ ( a >> 30))) + 2;
|
|
c = (Mersenne * ( b ^ ( b >> 30))) + 3;
|
|
d = (Mersenne * ( c ^ ( c >> 30))) + 4;
|
|
}
|
|
|
|
public uint GetU32()
|
|
{
|
|
uint t = a;
|
|
a = b;
|
|
b = c;
|
|
c = d;
|
|
t ^= t << 11;
|
|
t ^= t >> 8;
|
|
return d = t ^ d ^ (d >> 19);
|
|
}
|
|
|
|
public ulong GetU64() => ((ulong)GetU32() << 32) | GetU32();
|
|
}
|
|
}
|