fix: Fixes negative random numbers (#1600)

This commit is contained in:
Kamron Batman 2023-11-18 10:22:40 -08:00 committed by GitHub
parent dba3ec2db5
commit b5c984e5de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -1236,13 +1236,13 @@ public static class Utility
public static int Random(int from, int count) => BuiltInRng.Next(from, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int Random(int count) => BuiltInRng.Next(count);
public static int Random(int count) => count < 0 ? -BuiltInRng.Next(-count) : BuiltInRng.Next(count);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long Random(long from, long count) => BuiltInRng.Next(from, count);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static long Random(long count) => BuiltInRng.Next(count);
public static long Random(long count) => count < 0 ? -BuiltInRng.Next(-count) : BuiltInRng.Next(count);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void RandomBytes(Span<byte> buffer) => BuiltInRng.NextBytes(buffer);

View file

@ -19,8 +19,8 @@ namespace Server.Mobiles
Skills.MagicResist.Base = Utility.Random(15, 6);
Skills.Poisoning.Base = Utility.Random(31, 20);
Fame = Utility.Random(0, 1249);
Karma = Utility.Random(0, -624);
Fame = Utility.Random(1249);
Karma = -Utility.Random(624);
}
public override string CorpseName => "a jwilson corpse";

View file

@ -17,8 +17,8 @@ namespace Server.Mobiles
Skills.Tactics.Base = 6;
Skills.MagicResist.Base = 5;
Fame = Utility.Random(0, 1249);
Karma = Utility.Random(0, -624);
Fame = Utility.Random(1249);
Karma = -Utility.Random(624);
Tamable = true;
ControlSlots = 1;