From b5c984e5de191ed6ae9b4e43ec720fe9d9bc4eea Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 18 Nov 2023 10:22:40 -0800 Subject: [PATCH] fix: Fixes negative random numbers (#1600) --- Projects/Server/Utilities/Utility.cs | 4 ++-- Projects/UOContent/Mobiles/Animals/Slimes/Jwilson.cs | 4 ++-- .../Mobiles/Animals/Town Critters/(UO 3D Only) Parrot.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Projects/Server/Utilities/Utility.cs b/Projects/Server/Utilities/Utility.cs index 3e3d7a5d8..de595be33 100644 --- a/Projects/Server/Utilities/Utility.cs +++ b/Projects/Server/Utilities/Utility.cs @@ -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 buffer) => BuiltInRng.NextBytes(buffer); diff --git a/Projects/UOContent/Mobiles/Animals/Slimes/Jwilson.cs b/Projects/UOContent/Mobiles/Animals/Slimes/Jwilson.cs index bde5b9857..1cefdd89e 100644 --- a/Projects/UOContent/Mobiles/Animals/Slimes/Jwilson.cs +++ b/Projects/UOContent/Mobiles/Animals/Slimes/Jwilson.cs @@ -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"; diff --git a/Projects/UOContent/Mobiles/Animals/Town Critters/(UO 3D Only) Parrot.cs b/Projects/UOContent/Mobiles/Animals/Town Critters/(UO 3D Only) Parrot.cs index 618790d11..5b0e6543c 100644 --- a/Projects/UOContent/Mobiles/Animals/Town Critters/(UO 3D Only) Parrot.cs +++ b/Projects/UOContent/Mobiles/Animals/Town Critters/(UO 3D Only) Parrot.cs @@ -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;