fix: Codegens BaseMulti, Container, and VirtualCheck (#1624)
This commit is contained in:
parent
4ebdc75bdf
commit
e21ff0eb28
9 changed files with 192 additions and 298 deletions
|
|
@ -15,17 +15,15 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
using ModernUO.Serialization;
|
||||||
|
|
||||||
namespace Server.Items;
|
namespace Server.Items;
|
||||||
|
|
||||||
|
[SerializationGenerator(0, false)]
|
||||||
public abstract partial class BaseMulti : Item
|
public abstract partial class BaseMulti : Item
|
||||||
{
|
{
|
||||||
public BaseMulti(int itemID) : base(itemID) => Movable = false;
|
public BaseMulti(int itemID) : base(itemID) => Movable = false;
|
||||||
|
|
||||||
public BaseMulti(Serial serial) : base(serial)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public override int ItemID
|
public override int ItemID
|
||||||
{
|
{
|
||||||
|
|
@ -156,26 +154,4 @@ public abstract partial class BaseMulti : Item
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
|
||||||
{
|
|
||||||
base.Serialize(writer);
|
|
||||||
|
|
||||||
writer.Write(1); // version
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Deserialize(IGenericReader reader)
|
|
||||||
{
|
|
||||||
base.Deserialize(reader);
|
|
||||||
|
|
||||||
var version = reader.ReadInt();
|
|
||||||
|
|
||||||
if (version == 0)
|
|
||||||
{
|
|
||||||
if (ItemID >= 0x4000)
|
|
||||||
{
|
|
||||||
ItemID -= 0x4000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using Server.Collections;
|
using Server.Collections;
|
||||||
using Server.Logging;
|
using Server.Logging;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
using ModernUO.Serialization;
|
||||||
|
|
||||||
namespace Server.Items;
|
namespace Server.Items;
|
||||||
|
|
||||||
|
|
@ -13,47 +14,38 @@ public delegate int CheckItemGroup(Item a, Item b);
|
||||||
|
|
||||||
public delegate void ContainerSnoopHandler(Container cont, Mobile from);
|
public delegate void ContainerSnoopHandler(Container cont, Mobile from);
|
||||||
|
|
||||||
|
[SerializationGenerator(0, false)]
|
||||||
public partial class Container : Item
|
public partial class Container : Item
|
||||||
{
|
{
|
||||||
private ContainerData m_ContainerData;
|
private ContainerData m_ContainerData;
|
||||||
|
|
||||||
private int m_DropSound;
|
|
||||||
private int m_GumpID;
|
|
||||||
|
|
||||||
internal List<Item> m_Items;
|
internal List<Item> m_Items;
|
||||||
private int m_MaxItems;
|
|
||||||
private int m_TotalGold;
|
private int m_TotalGold;
|
||||||
|
|
||||||
private int m_TotalItems;
|
private int m_TotalItems;
|
||||||
private int m_TotalWeight;
|
private int m_TotalWeight;
|
||||||
private int _version;
|
private int _version;
|
||||||
|
|
||||||
|
[SerializableField(3)]
|
||||||
|
[SerializedCommandProperty(AccessLevel.GameMaster)]
|
||||||
|
private bool _liftOverride;
|
||||||
|
|
||||||
|
[SerializableFieldSaveFlag(3)]
|
||||||
|
private bool ShouldSerializeLiftOverride() => _liftOverride;
|
||||||
|
|
||||||
public Container(int itemID) : base(itemID)
|
public Container(int itemID) : base(itemID)
|
||||||
{
|
{
|
||||||
m_GumpID = -1;
|
_gumpID = -1;
|
||||||
m_DropSound = -1;
|
_dropSound = -1;
|
||||||
m_MaxItems = -1;
|
_maxItems = -1;
|
||||||
|
|
||||||
UpdateContainerData();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Container(Serial serial) : base(serial)
|
|
||||||
{
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ContainerSnoopHandler SnoopHandler { get; set; }
|
public static ContainerSnoopHandler SnoopHandler { get; set; }
|
||||||
|
|
||||||
public ContainerData ContainerData
|
public ContainerData ContainerData
|
||||||
{
|
{
|
||||||
get
|
get => m_ContainerData ?? UpdateContainerData();
|
||||||
{
|
|
||||||
if (m_ContainerData == null)
|
|
||||||
{
|
|
||||||
UpdateContainerData();
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_ContainerData;
|
|
||||||
}
|
|
||||||
set => m_ContainerData = value;
|
set => m_ContainerData = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -69,52 +61,62 @@ public partial class Container : Item
|
||||||
|
|
||||||
if (ItemID != oldID)
|
if (ItemID != oldID)
|
||||||
{
|
{
|
||||||
UpdateContainerData();
|
m_ContainerData = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[EncodedInt]
|
||||||
public int GumpID
|
[SerializableProperty(0)]
|
||||||
{
|
|
||||||
get => m_GumpID == -1 ? DefaultGumpID : m_GumpID;
|
|
||||||
set => m_GumpID = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
|
||||||
public int DropSound
|
|
||||||
{
|
|
||||||
get => m_DropSound == -1 ? DefaultDropSound : m_DropSound;
|
|
||||||
set => m_DropSound = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public int MaxItems
|
public int MaxItems
|
||||||
{
|
{
|
||||||
get => m_MaxItems == -1 ? DefaultMaxItems : m_MaxItems;
|
get => _maxItems == -1 ? DefaultMaxItems : _maxItems;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_MaxItems = value;
|
_maxItems = value;
|
||||||
InvalidateProperties();
|
InvalidateProperties();
|
||||||
|
this.MarkDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SerializableFieldSaveFlag(0)]
|
||||||
|
private bool ShouldSerializeMaxItems() => _maxItems != -1;
|
||||||
|
|
||||||
|
[EncodedInt]
|
||||||
|
[SerializableProperty(1)]
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public virtual int MaxWeight
|
public int GumpID
|
||||||
{
|
{
|
||||||
get
|
get => _gumpID == -1 ? DefaultGumpID : _gumpID;
|
||||||
|
set
|
||||||
{
|
{
|
||||||
if (Parent is Container container && container.MaxWeight == 0)
|
_gumpID = value;
|
||||||
{
|
this.MarkDirty();
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefaultMaxWeight;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[SerializableFieldSaveFlag(1)]
|
||||||
|
private bool ShouldSerializeGumpId() => _gumpID != -1;
|
||||||
|
|
||||||
|
[EncodedInt]
|
||||||
|
[SerializableProperty(2)]
|
||||||
[CommandProperty(AccessLevel.GameMaster)]
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
public bool LiftOverride { get; set; }
|
public int DropSound
|
||||||
|
{
|
||||||
|
get => _dropSound == -1 ? DefaultDropSound : _dropSound;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_dropSound = value;
|
||||||
|
this.MarkDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SerializableFieldSaveFlag(2)]
|
||||||
|
private bool ShouldSerializeDropSound() => _dropSound != -1;
|
||||||
|
|
||||||
|
[CommandProperty(AccessLevel.GameMaster)]
|
||||||
|
public virtual int MaxWeight => Parent is Container { MaxWeight: 0 } ? 0 : DefaultMaxWeight;
|
||||||
|
|
||||||
public virtual Rectangle2D Bounds => ContainerData.Bounds;
|
public virtual Rectangle2D Bounds => ContainerData.Bounds;
|
||||||
|
|
||||||
|
|
@ -139,10 +141,7 @@ public partial class Container : Item
|
||||||
|
|
||||||
public virtual bool IsPublicContainer => false;
|
public virtual bool IsPublicContainer => false;
|
||||||
|
|
||||||
public virtual void UpdateContainerData()
|
public virtual ContainerData UpdateContainerData() => ContainerData = ContainerData.GetData(ItemID);
|
||||||
{
|
|
||||||
ContainerData = ContainerData.GetData(ItemID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual int GetDroppedSound(Item item)
|
public virtual int GetDroppedSound(Item item)
|
||||||
{
|
{
|
||||||
|
|
@ -283,118 +282,9 @@ public partial class Container : Item
|
||||||
|
|
||||||
private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0;
|
private static bool GetSaveFlag(SaveFlag flags, SaveFlag toGet) => (flags & toGet) != 0;
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
[AfterDeserialization]
|
||||||
|
private void AfterDeserialization()
|
||||||
{
|
{
|
||||||
base.Serialize(writer);
|
|
||||||
|
|
||||||
writer.Write(2); // version
|
|
||||||
|
|
||||||
var flags = SaveFlag.None;
|
|
||||||
|
|
||||||
SetSaveFlag(ref flags, SaveFlag.MaxItems, m_MaxItems != -1);
|
|
||||||
SetSaveFlag(ref flags, SaveFlag.GumpID, m_GumpID != -1);
|
|
||||||
SetSaveFlag(ref flags, SaveFlag.DropSound, m_DropSound != -1);
|
|
||||||
SetSaveFlag(ref flags, SaveFlag.LiftOverride, LiftOverride);
|
|
||||||
|
|
||||||
writer.Write((byte)flags);
|
|
||||||
|
|
||||||
if (GetSaveFlag(flags, SaveFlag.MaxItems))
|
|
||||||
{
|
|
||||||
writer.WriteEncodedInt(m_MaxItems);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetSaveFlag(flags, SaveFlag.GumpID))
|
|
||||||
{
|
|
||||||
writer.WriteEncodedInt(m_GumpID);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetSaveFlag(flags, SaveFlag.DropSound))
|
|
||||||
{
|
|
||||||
writer.WriteEncodedInt(m_DropSound);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Deserialize(IGenericReader reader)
|
|
||||||
{
|
|
||||||
base.Deserialize(reader);
|
|
||||||
|
|
||||||
var version = reader.ReadInt();
|
|
||||||
|
|
||||||
switch (version)
|
|
||||||
{
|
|
||||||
case 2:
|
|
||||||
{
|
|
||||||
var flags = (SaveFlag)reader.ReadByte();
|
|
||||||
|
|
||||||
if (GetSaveFlag(flags, SaveFlag.MaxItems))
|
|
||||||
{
|
|
||||||
m_MaxItems = reader.ReadEncodedInt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_MaxItems = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetSaveFlag(flags, SaveFlag.GumpID))
|
|
||||||
{
|
|
||||||
m_GumpID = reader.ReadEncodedInt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_GumpID = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetSaveFlag(flags, SaveFlag.DropSound))
|
|
||||||
{
|
|
||||||
m_DropSound = reader.ReadEncodedInt();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_DropSound = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
LiftOverride = GetSaveFlag(flags, SaveFlag.LiftOverride);
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 1:
|
|
||||||
{
|
|
||||||
m_MaxItems = reader.ReadInt();
|
|
||||||
goto case 0;
|
|
||||||
}
|
|
||||||
case 0:
|
|
||||||
{
|
|
||||||
if (version < 1)
|
|
||||||
{
|
|
||||||
m_MaxItems = GlobalMaxItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_GumpID = reader.ReadInt();
|
|
||||||
m_DropSound = reader.ReadInt();
|
|
||||||
|
|
||||||
if (m_GumpID == DefaultGumpID)
|
|
||||||
{
|
|
||||||
m_GumpID = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_DropSound == DefaultDropSound)
|
|
||||||
{
|
|
||||||
m_DropSound = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_MaxItems == DefaultMaxItems)
|
|
||||||
{
|
|
||||||
m_MaxItems = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// m_Bounds = new Rectangle2D( reader.ReadPoint2D(), reader.ReadPoint2D() );
|
|
||||||
reader.ReadPoint2D();
|
|
||||||
reader.ReadPoint2D();
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateContainerData();
|
UpdateContainerData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -416,18 +306,24 @@ public partial class Container : Item
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case TotalType.Gold:
|
case TotalType.Gold:
|
||||||
m_TotalGold += delta;
|
{
|
||||||
break;
|
m_TotalGold += delta;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TotalType.Items:
|
case TotalType.Items:
|
||||||
m_TotalItems += delta;
|
{
|
||||||
InvalidateProperties();
|
m_TotalItems += delta;
|
||||||
break;
|
InvalidateProperties();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case TotalType.Weight:
|
case TotalType.Weight:
|
||||||
m_TotalWeight += delta;
|
{
|
||||||
InvalidateProperties();
|
m_TotalWeight += delta;
|
||||||
break;
|
InvalidateProperties();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1630,16 +1526,6 @@ public partial class Container : Item
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
|
||||||
private enum SaveFlag : byte
|
|
||||||
{
|
|
||||||
None = 0x00000000,
|
|
||||||
MaxItems = 0x00000001,
|
|
||||||
GumpID = 0x00000002,
|
|
||||||
DropSound = 0x00000004,
|
|
||||||
LiftOverride = 0x00000008
|
|
||||||
}
|
|
||||||
|
|
||||||
private struct ItemStackEntry
|
private struct ItemStackEntry
|
||||||
{
|
{
|
||||||
public readonly Item m_StackItem;
|
public readonly Item m_StackItem;
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,14 @@
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
|
using ModernUO.Serialization;
|
||||||
using Server.Gumps;
|
using Server.Gumps;
|
||||||
using Server.Network;
|
using Server.Network;
|
||||||
|
|
||||||
namespace Server.Items;
|
namespace Server.Items;
|
||||||
|
|
||||||
public sealed class VirtualCheck : Item
|
[SerializationGenerator(0, false)]
|
||||||
|
public sealed partial class VirtualCheck : Item
|
||||||
{
|
{
|
||||||
public static bool UseEditGump { get; private set; }
|
public static bool UseEditGump { get; private set; }
|
||||||
|
|
||||||
|
|
@ -27,9 +29,9 @@ public sealed class VirtualCheck : Item
|
||||||
UseEditGump = ServerConfiguration.GetSetting("virtualChecks.useEditGump", Core.TOL);
|
UseEditGump = ServerConfiguration.GetSetting("virtualChecks.useEditGump", Core.TOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int m_Gold;
|
private int _gold;
|
||||||
|
|
||||||
private int m_Plat;
|
private int _plat;
|
||||||
|
|
||||||
public VirtualCheck(int plat = 0, int gold = 0) : base(0x14F0)
|
public VirtualCheck(int plat = 0, int gold = 0) : base(0x14F0)
|
||||||
{
|
{
|
||||||
|
|
@ -39,11 +41,6 @@ public sealed class VirtualCheck : Item
|
||||||
Movable = false;
|
Movable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualCheck(Serial serial)
|
|
||||||
: base(serial)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool IsVirtualItem => true;
|
public override bool IsVirtualItem => true;
|
||||||
|
|
||||||
public override bool DisplayWeight => false;
|
public override bool DisplayWeight => false;
|
||||||
|
|
@ -58,10 +55,10 @@ public sealed class VirtualCheck : Item
|
||||||
[CommandProperty(AccessLevel.Administrator)]
|
[CommandProperty(AccessLevel.Administrator)]
|
||||||
public int Plat
|
public int Plat
|
||||||
{
|
{
|
||||||
get => m_Plat;
|
get => _plat;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_Plat = value;
|
_plat = value;
|
||||||
InvalidateProperties();
|
InvalidateProperties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -69,10 +66,10 @@ public sealed class VirtualCheck : Item
|
||||||
[CommandProperty(AccessLevel.Administrator)]
|
[CommandProperty(AccessLevel.Administrator)]
|
||||||
public int Gold
|
public int Gold
|
||||||
{
|
{
|
||||||
get => m_Gold;
|
get => _gold;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
m_Gold = value;
|
_gold = value;
|
||||||
InvalidateProperties();
|
InvalidateProperties();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -159,11 +156,8 @@ public sealed class VirtualCheck : Item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Serialize(IGenericWriter writer)
|
[AfterDeserialization(false)]
|
||||||
{
|
private void AfterDeserialization()
|
||||||
}
|
|
||||||
|
|
||||||
public override void Deserialize(IGenericReader reader)
|
|
||||||
{
|
{
|
||||||
Delete();
|
Delete();
|
||||||
}
|
}
|
||||||
|
|
@ -179,15 +173,15 @@ public sealed class VirtualCheck : Item
|
||||||
AllGold
|
AllGold
|
||||||
}
|
}
|
||||||
|
|
||||||
private int m_Plat, m_Gold;
|
private int _plat, _gold;
|
||||||
|
|
||||||
public EditGump(Mobile user, VirtualCheck check) : base(50, 50)
|
public EditGump(Mobile user, VirtualCheck check) : base(50, 50)
|
||||||
{
|
{
|
||||||
User = user;
|
User = user;
|
||||||
Check = check;
|
Check = check;
|
||||||
|
|
||||||
m_Plat = Check.Plat;
|
_plat = Check.Plat;
|
||||||
m_Gold = Check.Gold;
|
_gold = Check.Gold;
|
||||||
|
|
||||||
Closable = true;
|
Closable = true;
|
||||||
Disposable = true;
|
Disposable = true;
|
||||||
|
|
@ -289,7 +283,7 @@ public sealed class VirtualCheck : Item
|
||||||
|
|
||||||
AddBackground(210, 60, 175, 20, 9300);
|
AddBackground(210, 60, 175, 20, 9300);
|
||||||
AddBackground(215, 45, 165, 30, 9350);
|
AddBackground(215, 45, 165, 30, 9350);
|
||||||
AddTextEntry(225, 50, 145, 20, 0, 0, m_Plat.ToString(), User.Account.TotalPlat.ToString().Length);
|
AddTextEntry(225, 50, 145, 20, 0, 0, _plat.ToString(), User.Account.TotalPlat.ToString().Length);
|
||||||
|
|
||||||
// Gold Row
|
// Gold Row
|
||||||
AddBackground(15, 100, 175, 20, 9300);
|
AddBackground(15, 100, 175, 20, 9300);
|
||||||
|
|
@ -301,7 +295,7 @@ public sealed class VirtualCheck : Item
|
||||||
|
|
||||||
AddBackground(210, 100, 175, 20, 9300);
|
AddBackground(210, 100, 175, 20, 9300);
|
||||||
AddBackground(215, 85, 165, 30, 9350);
|
AddBackground(215, 85, 165, 30, 9350);
|
||||||
AddTextEntry(225, 90, 145, 20, 0, 1, m_Gold.ToString(), User.Account.TotalGold.ToString().Length);
|
AddTextEntry(225, 90, 145, 20, 0, 1, _gold.ToString(), User.Account.TotalGold.ToString().Length);
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
AddButton(20, 128, 12006, 12007, (int)Buttons.Close);
|
AddButton(20, 128, 12006, 12007, (int)Buttons.Close);
|
||||||
|
|
@ -317,29 +311,28 @@ public sealed class VirtualCheck : Item
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool refresh = false, updated = false;
|
var refresh = false;
|
||||||
|
var updated = false;
|
||||||
|
|
||||||
switch ((Buttons)info.ButtonID)
|
switch ((Buttons)info.ButtonID)
|
||||||
{
|
{
|
||||||
case Buttons.Close:
|
|
||||||
break;
|
|
||||||
case Buttons.Clear:
|
case Buttons.Clear:
|
||||||
{
|
{
|
||||||
m_Plat = m_Gold = 0;
|
_plat = _gold = 0;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case Buttons.Accept:
|
case Buttons.Accept:
|
||||||
{
|
{
|
||||||
var platText = info.GetTextEntry(0).Text;
|
var platText = info.GetTextEntry(0).Text;
|
||||||
var goldText = info.GetTextEntry(1).Text;
|
var goldText = info.GetTextEntry(1).Text;
|
||||||
|
|
||||||
if (!int.TryParse(platText, out m_Plat))
|
if (!int.TryParse(platText, out _plat))
|
||||||
{
|
{
|
||||||
User.SendMessage("That is not a valid amount of platinum.");
|
User.SendMessage("That is not a valid amount of platinum.");
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
else if (!int.TryParse(goldText, out m_Gold))
|
else if (!int.TryParse(goldText, out _gold))
|
||||||
{
|
{
|
||||||
User.SendMessage("That is not a valid amount of gold.");
|
User.SendMessage("That is not a valid amount of gold.");
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
|
@ -349,34 +342,34 @@ public sealed class VirtualCheck : Item
|
||||||
var totalPlat = User.Account.TotalPlat;
|
var totalPlat = User.Account.TotalPlat;
|
||||||
var totalGold = User.Account.TotalGold;
|
var totalGold = User.Account.TotalGold;
|
||||||
|
|
||||||
if (totalPlat < m_Plat || totalGold < m_Gold)
|
if (totalPlat < _plat || totalGold < _gold)
|
||||||
{
|
{
|
||||||
m_Plat = User.Account.TotalPlat;
|
_plat = User.Account.TotalPlat;
|
||||||
m_Gold = User.Account.TotalGold;
|
_gold = User.Account.TotalGold;
|
||||||
User.SendMessage("You do not have that much currency.");
|
User.SendMessage("You do not have that much currency.");
|
||||||
refresh = true;
|
refresh = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Check.Plat = m_Plat;
|
Check.Plat = _plat;
|
||||||
Check.Gold = m_Gold;
|
Check.Gold = _gold;
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case Buttons.AllPlat:
|
case Buttons.AllPlat:
|
||||||
{
|
{
|
||||||
m_Plat = User.Account.TotalPlat;
|
_plat = User.Account.TotalPlat;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case Buttons.AllGold:
|
case Buttons.AllGold:
|
||||||
{
|
{
|
||||||
m_Gold = User.Account.TotalGold;
|
_gold = User.Account.TotalGold;
|
||||||
refresh = true;
|
refresh = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (updated)
|
if (updated)
|
||||||
|
|
|
||||||
|
|
@ -54,46 +54,63 @@ public static class JsonUtilities
|
||||||
switch(je.ValueKind)
|
switch(je.ValueKind)
|
||||||
{
|
{
|
||||||
case JsonValueKind.Object:
|
case JsonValueKind.Object:
|
||||||
writer.WriteStartObject();
|
|
||||||
|
|
||||||
// TODO: This is slow, can make it faster?
|
|
||||||
foreach (JsonProperty x in je.EnumerateObject().OrderBy(prop => prop.Name))
|
|
||||||
{
|
{
|
||||||
writer.WritePropertyName(x.Name);
|
writer.WriteStartObject();
|
||||||
WriteJsonElementSorted(x.Value, writer);
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.WriteEndObject();
|
// TODO: This is slow, can make it faster?
|
||||||
break;
|
foreach (JsonProperty x in je.EnumerateObject().OrderBy(prop => prop.Name))
|
||||||
|
{
|
||||||
|
writer.WritePropertyName(x.Name);
|
||||||
|
WriteJsonElementSorted(x.Value, writer);
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.WriteEndObject();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JsonValueKind.Array:
|
case JsonValueKind.Array:
|
||||||
writer.WriteStartArray();
|
|
||||||
foreach(JsonElement x in je.EnumerateArray())
|
|
||||||
{
|
{
|
||||||
WriteJsonElementSorted(x, writer);
|
writer.WriteStartArray();
|
||||||
|
foreach(JsonElement x in je.EnumerateArray())
|
||||||
|
{
|
||||||
|
WriteJsonElementSorted(x, writer);
|
||||||
|
}
|
||||||
|
writer.WriteEndArray();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
writer.WriteEndArray();
|
|
||||||
break;
|
|
||||||
case JsonValueKind.Number:
|
case JsonValueKind.Number:
|
||||||
writer.WriteNumberValue(je.GetDouble());
|
{
|
||||||
break;
|
writer.WriteNumberValue(je.GetDouble());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JsonValueKind.String:
|
case JsonValueKind.String:
|
||||||
// Escape the string
|
{
|
||||||
writer.WriteStringValue(je.GetString());
|
// Escape the string
|
||||||
break;
|
writer.WriteStringValue(je.GetString());
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JsonValueKind.Null:
|
case JsonValueKind.Null:
|
||||||
writer.WriteNullValue();
|
{
|
||||||
break;
|
writer.WriteNullValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JsonValueKind.True:
|
case JsonValueKind.True:
|
||||||
writer.WriteBooleanValue(true);
|
{
|
||||||
break;
|
writer.WriteBooleanValue(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JsonValueKind.False:
|
case JsonValueKind.False:
|
||||||
writer.WriteBooleanValue(false);
|
{
|
||||||
break;
|
writer.WriteBooleanValue(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case JsonValueKind.Undefined: // Don't write anything
|
case JsonValueKind.Undefined: // Don't write anything
|
||||||
break;
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException($"Kind: {je.ValueKind}");
|
{
|
||||||
|
throw new NotImplementedException($"Kind: {je.ValueKind}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,33 +61,49 @@ public static class Movement
|
||||||
switch (d & Direction.Mask)
|
switch (d & Direction.Mask)
|
||||||
{
|
{
|
||||||
case Direction.North:
|
case Direction.North:
|
||||||
--y;
|
{
|
||||||
break;
|
--y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.South:
|
case Direction.South:
|
||||||
++y;
|
{
|
||||||
break;
|
++y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.West:
|
case Direction.West:
|
||||||
--x;
|
{
|
||||||
break;
|
--x;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.East:
|
case Direction.East:
|
||||||
++x;
|
{
|
||||||
break;
|
++x;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.Right:
|
case Direction.Right:
|
||||||
++x;
|
{
|
||||||
--y;
|
++x;
|
||||||
break;
|
--y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.Left:
|
case Direction.Left:
|
||||||
--x;
|
{
|
||||||
++y;
|
--x;
|
||||||
break;
|
++y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.Down:
|
case Direction.Down:
|
||||||
++x;
|
{
|
||||||
++y;
|
++x;
|
||||||
break;
|
++y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Direction.Up:
|
case Direction.Up:
|
||||||
--x;
|
{
|
||||||
--y;
|
--x;
|
||||||
break;
|
--y;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,10 @@ public class GenericEntityPersistence<T> : Persistence, IGenericEntityPersistenc
|
||||||
{
|
{
|
||||||
switch (World.WorldState)
|
switch (World.WorldState)
|
||||||
{
|
{
|
||||||
default: return null;
|
default:
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
case WorldState.Loading:
|
case WorldState.Loading:
|
||||||
case WorldState.Saving:
|
case WorldState.Saving:
|
||||||
case WorldState.WritingSave:
|
case WorldState.WritingSave:
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,10 @@ public interface IGenericWriter
|
||||||
{
|
{
|
||||||
switch (sizeof(T))
|
switch (sizeof(T))
|
||||||
{
|
{
|
||||||
default: throw new ArgumentException($"Argument of type {typeof(T)} is not a normal enum");
|
default:
|
||||||
|
{
|
||||||
|
throw new ArgumentException($"Argument of type {typeof(T)} is not a normal enum");
|
||||||
|
}
|
||||||
case 1:
|
case 1:
|
||||||
{
|
{
|
||||||
Write(*(byte*)&value);
|
Write(*(byte*)&value);
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
<PackageReference Include="Zlib.Bindings" Version="1.11.0" />
|
<PackageReference Include="Zlib.Bindings" Version="1.11.0" />
|
||||||
|
|
||||||
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.9.1" />
|
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.9.1" />
|
||||||
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.9.1" />
|
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.9.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="Migrations/*.v*.json" />
|
<AdditionalFiles Include="Migrations/*.v*.json" />
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@
|
||||||
<PackageReference Include="Zstd.Binaries" Version="1.6.0" />
|
<PackageReference Include="Zstd.Binaries" Version="1.6.0" />
|
||||||
|
|
||||||
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.9.1" />
|
<PackageReference Include="ModernUO.Serialization.Annotations" Version="2.9.1" />
|
||||||
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.9.1" />
|
<PackageReference Include="ModernUO.Serialization.Generator" Version="2.9.2" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<AdditionalFiles Include="Migrations/*.v*.json" />
|
<AdditionalFiles Include="Migrations/*.v*.json" />
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue