fix: Fixes Dice Infinite loop and deserialization of some items (#1360)

### Summary
- Fixes deserialization issues with some items.
- Changes Utility.Dice to prevent long iteration by passing `(uint)-1`
This commit is contained in:
Kamron Batman 2023-03-05 18:29:48 -08:00 committed by GitHub
parent 9b6aa1deed
commit 3097eb4fa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 14 additions and 11 deletions

View file

@ -949,14 +949,18 @@ public static class Utility
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool InUpdateRange(Point3D p1, Point3D p2) => InRange(p1, p2, 18);
// 4d6+8 would be: Utility.Dice( 4, 6, 8 )
public static int Dice(uint amount, uint sides, int bonus)
public static int Dice(int amount, int sides, int bonus)
{
if (amount <= 0 || sides <= 0)
{
return 0;
}
var total = 0;
for (var i = 0; i < amount; ++i)
{
total += (int)RandomSources.Source.Next(1, sides);
total += RandomSources.Source.Next(1, sides);
}
return total + bonus;