Cleanup/Housekeeping (#242)
This commit is contained in:
parent
90ede0659f
commit
741e8d8300
228 changed files with 6292 additions and 2690 deletions
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: BaseRandomSource.cs *
|
||||
* *
|
||||
|
|
@ -42,8 +42,15 @@ namespace Server.Random
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public int Next(int count)
|
||||
{
|
||||
if (count == 0) throw new ArgumentOutOfRangeException(nameof(count), count, "count must not be 0");
|
||||
if (count == 1 || count == -1) return 0;
|
||||
if (count == 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count), count, "count must not be 0");
|
||||
}
|
||||
|
||||
if (count == 1 || count == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var negative = count < 0;
|
||||
|
||||
|
|
@ -66,8 +73,15 @@ namespace Server.Random
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public uint Next(uint count)
|
||||
{
|
||||
if (count == 0) throw new ArgumentOutOfRangeException(nameof(count), count, "count must not be 0");
|
||||
if (count == 1) return 0;
|
||||
if (count == 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count), count, "count must not be 0");
|
||||
}
|
||||
|
||||
if (count == 1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var bits = Log2(count);
|
||||
|
||||
|
|
@ -86,8 +100,15 @@ namespace Server.Random
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public long Next(long count)
|
||||
{
|
||||
if (count == 0) throw new ArgumentOutOfRangeException(nameof(count), count, "count must not be 0");
|
||||
if (count == 1 || count == -1) return 0;
|
||||
if (count == 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException(nameof(count), count, "count must not be 0");
|
||||
}
|
||||
|
||||
if (count == 1 || count == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
var negative = count < 0;
|
||||
|
||||
|
|
@ -143,7 +164,9 @@ namespace Server.Random
|
|||
exponent -= 64;
|
||||
|
||||
if (exponent < -1074)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
shift = BitOperations.LeadingZeroCount(significand);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: IRandomSource.cs *
|
||||
* *
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: RandomSources.cs *
|
||||
* *
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: SecureRandom.cs *
|
||||
* *
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright (C) 2019-2020 - ModernUO Development Team *
|
||||
* Copyright 2019-2020 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: Xoshiro256PlusPlus.cs *
|
||||
* *
|
||||
|
|
@ -75,7 +75,10 @@ namespace Server.Random
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public override unsafe void NextBytes(Span<byte> b)
|
||||
{
|
||||
if (b.Length == 0) return;
|
||||
if (b.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var s0 = _s0;
|
||||
var s1 = _s1;
|
||||
|
|
@ -150,6 +153,7 @@ namespace Server.Random
|
|||
ulong s3 = 0;
|
||||
|
||||
for (var i = 0; i < jumps.Length; i++)
|
||||
{
|
||||
for (var b = 0; b < 64; b++)
|
||||
{
|
||||
if ((jumps[i] & (1ul << b)) != 0)
|
||||
|
|
@ -162,6 +166,7 @@ namespace Server.Random
|
|||
|
||||
NextULong();
|
||||
}
|
||||
}
|
||||
|
||||
_s0 = s0;
|
||||
_s1 = s1;
|
||||
|
|
@ -202,7 +207,10 @@ namespace Server.Random
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void FillArray(ulong[] arr)
|
||||
{
|
||||
for (var i = 0; i < arr.Length; i++) arr[i] = Next();
|
||||
for (var i = 0; i < arr.Length; i++)
|
||||
{
|
||||
arr[i] = Next();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue