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:
parent
9b6aa1deed
commit
3097eb4fa7
6 changed files with 14 additions and 11 deletions
|
|
@ -949,14 +949,18 @@ public static class Utility
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool InUpdateRange(Point3D p1, Point3D p2) => InRange(p1, p2, 18);
|
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(int amount, int sides, int bonus)
|
||||||
public static int Dice(uint amount, uint sides, int bonus)
|
|
||||||
{
|
{
|
||||||
|
if (amount <= 0 || sides <= 0)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
var total = 0;
|
var total = 0;
|
||||||
|
|
||||||
for (var i = 0; i < amount; ++i)
|
for (var i = 0; i < amount; ++i)
|
||||||
{
|
{
|
||||||
total += (int)RandomSources.Source.Next(1, sides);
|
total += RandomSources.Source.Next(1, sides);
|
||||||
}
|
}
|
||||||
|
|
||||||
return total + bonus;
|
return total + bonus;
|
||||||
|
|
|
||||||
|
|
@ -119,8 +119,6 @@ public partial class Runebook : Item, ISecurable, ICraftable
|
||||||
|
|
||||||
private void Deserialize(IGenericReader reader, int version)
|
private void Deserialize(IGenericReader reader, int version)
|
||||||
{
|
{
|
||||||
base.Deserialize(reader);
|
|
||||||
|
|
||||||
_quality = (BookQuality)reader.ReadByte();
|
_quality = (BookQuality)reader.ReadByte();
|
||||||
Timer.DelayCall(crafter => _crafter = crafter?.RawName, reader.ReadEntity<Mobile>());
|
Timer.DelayCall(crafter => _crafter = crafter?.RawName, reader.ReadEntity<Mobile>());
|
||||||
_level = (SecureLevel)reader.ReadInt();
|
_level = (SecureLevel)reader.ReadInt();
|
||||||
|
|
|
||||||
|
|
@ -2106,7 +2106,7 @@ namespace Server.Items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual double GetAosDamage(Mobile attacker, int bonus, uint dice, uint sides)
|
public virtual double GetAosDamage(Mobile attacker, int bonus, int dice, int sides)
|
||||||
{
|
{
|
||||||
var damage = Utility.Dice(dice, sides, bonus) * 100;
|
var damage = Utility.Dice(dice, sides, bonus) * 100;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
"type": "System.DateTime",
|
"type": "System.DateTime",
|
||||||
"rule": "PrimitiveTypeMigrationRule",
|
"rule": "PrimitiveTypeMigrationRule",
|
||||||
"ruleArguments": [
|
"ruleArguments": [
|
||||||
""
|
"DeltaTime"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -43,8 +43,9 @@ namespace Server.Mobiles
|
||||||
|
|
||||||
public override string CorpseName => "a sheep corpse";
|
public override string CorpseName => "a sheep corpse";
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[DeltaDateTime]
|
||||||
[SerializableProperty(0)]
|
[SerializableProperty(0)]
|
||||||
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public DateTime NextWoolTime
|
public DateTime NextWoolTime
|
||||||
{
|
{
|
||||||
get => _nextWoolTime;
|
get => _nextWoolTime;
|
||||||
|
|
|
||||||
|
|
@ -192,7 +192,7 @@ namespace Server.Spells
|
||||||
(m as BaseCreature)?.OnHarmfulSpell(Caster);
|
(m as BaseCreature)?.OnHarmfulSpell(Caster);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int GetNewAosDamage(int bonus, uint dice, uint sides, Mobile singleTarget)
|
public virtual int GetNewAosDamage(int bonus, int dice, int sides, Mobile singleTarget)
|
||||||
{
|
{
|
||||||
if (singleTarget != null)
|
if (singleTarget != null)
|
||||||
{
|
{
|
||||||
|
|
@ -208,10 +208,10 @@ namespace Server.Spells
|
||||||
return GetNewAosDamage(bonus, dice, sides, false);
|
return GetNewAosDamage(bonus, dice, sides, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual int GetNewAosDamage(int bonus, uint dice, uint sides, bool playerVsPlayer) =>
|
public virtual int GetNewAosDamage(int bonus, int dice, int sides, bool playerVsPlayer) =>
|
||||||
GetNewAosDamage(bonus, dice, sides, playerVsPlayer, 1.0);
|
GetNewAosDamage(bonus, dice, sides, playerVsPlayer, 1.0);
|
||||||
|
|
||||||
public virtual int GetNewAosDamage(int bonus, uint dice, uint sides, bool playerVsPlayer, double scalar)
|
public virtual int GetNewAosDamage(int bonus, int dice, int sides, bool playerVsPlayer, double scalar)
|
||||||
{
|
{
|
||||||
var damage = Utility.Dice(dice, sides, bonus) * 100;
|
var damage = Utility.Dice(dice, sides, bonus) * 100;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue