diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index e5a7001db..ffc39c197 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "modernuoschemagenerator": { - "version": "2.1.4", + "version": "2.2.2", "commands": [ "ModernUOSchemaGenerator" ] diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index bfc63eaa8..898aba93c 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -26,7 +26,7 @@ jobs: - name: Setup .NET 6 uses: actions/setup-dotnet@v1 with: - dotnet-version: 6.0.300 + dotnet-version: 6.0.400 - name: Build run: ./publish.cmd - name: Test diff --git a/Directory.Build.props b/Directory.Build.props index 5b23e4a72..ae71adb36 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -59,7 +59,7 @@ - 3.5.107 + 3.5.109 all diff --git a/Projects/Server.Tests/Server.Tests.csproj b/Projects/Server.Tests/Server.Tests.csproj index db30edf70..dbb87dc7a 100644 --- a/Projects/Server.Tests/Server.Tests.csproj +++ b/Projects/Server.Tests/Server.Tests.csproj @@ -3,9 +3,9 @@ false - - - + + + diff --git a/Projects/Server/Migrations/Server.SkillMod.v0.json b/Projects/Server/Migrations/Server.SkillMod.v0.json index 174c434c2..e7a65a546 100644 --- a/Projects/Server/Migrations/Server.SkillMod.v0.json +++ b/Projects/Server/Migrations/Server.SkillMod.v0.json @@ -23,14 +23,6 @@ "" ] }, - { - "name": "Absolute", - "type": "bool", - "rule": "PrimitiveTypeMigrationRule", - "ruleArguments": [ - "" - ] - }, { "name": "Value", "type": "double", diff --git a/Projects/Server/Mobiles/Mods/ResistanceMod.cs b/Projects/Server/Mobiles/Mods/ResistanceMod.cs index 8b14cc1a5..67d254692 100644 --- a/Projects/Server/Mobiles/Mods/ResistanceMod.cs +++ b/Projects/Server/Mobiles/Mods/ResistanceMod.cs @@ -20,12 +20,6 @@ namespace Server; [SerializationGenerator(0)] public partial class ResistanceMod : MobileMod { - // Field 0 - private int _offset; - - // Field 1 - private ResistanceType _type; - public ResistanceMod(Mobile owner) : base(owner) { } @@ -36,7 +30,7 @@ public partial class ResistanceMod : MobileMod _offset = offset; } - [SerializableField(0)] + [SerializableProperty(0)] public ResistanceType Type { get => _type; @@ -52,7 +46,7 @@ public partial class ResistanceMod : MobileMod } } - [SerializableField(1)] + [SerializableProperty(1)] public int Offset { get => _offset; diff --git a/Projects/Server/Mobiles/Mods/SkillMod.cs b/Projects/Server/Mobiles/Mods/SkillMod.cs index 680d92b88..57312e3ae 100644 --- a/Projects/Server/Mobiles/Mods/SkillMod.cs +++ b/Projects/Server/Mobiles/Mods/SkillMod.cs @@ -21,11 +21,6 @@ namespace Server; [SerializationGenerator(0)] public abstract partial class SkillMod : MobileMod { - private bool _obeyCap; - private bool _relative; - private SkillName _skill; - private double _value; - public SkillMod(Mobile owner) : base(owner) { } @@ -37,7 +32,7 @@ public abstract partial class SkillMod : MobileMod _value = value; } - [SerializableField(0)] + [SerializableProperty(0)] public bool ObeyCap { get => _obeyCap; @@ -51,7 +46,7 @@ public abstract partial class SkillMod : MobileMod } } - [SerializableField(1)] + [SerializableProperty(1)] public SkillName Skill { get => _skill; @@ -71,7 +66,7 @@ public abstract partial class SkillMod : MobileMod } } - [SerializableField(2)] + [SerializableProperty(2)] public bool Relative { get => _relative; @@ -88,24 +83,13 @@ public abstract partial class SkillMod : MobileMod } } - [SerializableField(3)] public bool Absolute { - get => !_relative; - set - { - if (_relative == value) - { - _relative = !value; - - var sk = Owner?.Skills[_skill]; - sk?.Update(); - MarkDirty(); - } - } + get => !Relative; + set => Relative = !value; } - [SerializableField(4)] + [SerializableProperty(3)] public double Value { get => _value; diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj index 0e310043d..d3e1e4d18 100755 --- a/Projects/Server/Server.csproj +++ b/Projects/Server/Server.csproj @@ -40,8 +40,8 @@ - - + + diff --git a/Projects/UOContent.Tests/UOContent.Tests.csproj b/Projects/UOContent.Tests/UOContent.Tests.csproj index 195cec9a4..4f2cd601f 100644 --- a/Projects/UOContent.Tests/UOContent.Tests.csproj +++ b/Projects/UOContent.Tests/UOContent.Tests.csproj @@ -3,9 +3,9 @@ false - - - + + + diff --git a/Projects/UOContent/Accounting/Account.Migrations.cs b/Projects/UOContent/Accounting/Account.Migrations.cs index e53d5c75f..dd9148b01 100644 --- a/Projects/UOContent/Accounting/Account.Migrations.cs +++ b/Projects/UOContent/Accounting/Account.Migrations.cs @@ -18,7 +18,7 @@ namespace Server.Accounting _lastLogin = content.LastLogin; _totalGold = content.TotalGold; _totalPlat = content.TotalPlat; - _rawMobiles = content.Mobiles; + _mobiles = content.Mobiles; _comments = content.Comments; _tags = content.Tags; _loginIPs = content.LoginIPs; @@ -47,10 +47,10 @@ namespace Server.Accounting _totalPlat = reader.ReadInt(); var length = reader.ReadInt(); - _rawMobiles = new Mobile[length]; + _mobiles = new Mobile[length]; for (int i = 0; i < length; i++) { - _rawMobiles[i] = reader.ReadEntity(); + _mobiles[i] = reader.ReadEntity(); } length = reader.ReadInt(); diff --git a/Projects/UOContent/Accounting/Account.cs b/Projects/UOContent/Accounting/Account.cs index b2048f924..1d5a961bc 100644 --- a/Projects/UOContent/Accounting/Account.cs +++ b/Projects/UOContent/Accounting/Account.cs @@ -56,12 +56,9 @@ namespace Server.Accounting [SerializableFieldAttr("[CommandProperty(AccessLevel.Administrator)]")] public int _totalPlat; - [SerializableField(8, "private", "private")] - private Mobile[] _rawMobiles; + private Mobile[] _mobiles; - private List _comments; - - [SerializableField(9)] + [SerializableProperty(9)] public List Comments { get => _comments ??= new List(); @@ -72,9 +69,7 @@ namespace Server.Accounting } } - private List _tags; - - [SerializableField(10)] + [SerializableProperty(10)] public List Tags { get => _tags ??= new List(); @@ -95,20 +90,18 @@ namespace Server.Accounting [SerializableField(12)] private string[] _ipRestrictions; - private TimeSpan _totalGameTime; - /// /// Gets the total game time of this account, also considering the game time of characters /// that have been deleted. /// - [SerializableField(13)] + [SerializableProperty(13)] public TimeSpan TotalGameTime { get { - for (var i = 0; i < _rawMobiles.Length; i++) + for (var i = 0; i < _mobiles.Length; i++) { - if (_rawMobiles[i] is PlayerMobile m && m.NetState != null) + if (_mobiles[i] is PlayerMobile m && m.NetState != null) { return _totalGameTime + (Core.Now - m.SessionStart); } @@ -140,7 +133,7 @@ namespace Server.Accounting _lastLogin = Core.Now; _totalGameTime = TimeSpan.Zero; - _rawMobiles = new Mobile[7]; + _mobiles = new Mobile[7]; _ipRestrictions = Array.Empty(); _loginIPs = Array.Empty(); @@ -188,26 +181,26 @@ namespace Server.Accounting _totalGold = Utility.GetXMLInt32(Utility.GetText(node["totalGold"], "0"), 0); _totalPlat = Utility.GetXMLInt32(Utility.GetText(node["totalPlat"], "0"), 0); - _rawMobiles = LoadMobiles(node); + _mobiles = LoadMobiles(node); _comments = LoadComments(node); _tags = LoadTags(node); _loginIPs = LoadAddressList(node); _ipRestrictions = LoadAccessCheck(node); - for (var i = 0; i < _rawMobiles.Length; ++i) + for (var i = 0; i < _mobiles.Length; ++i) { - if (_rawMobiles[i] != null) + if (_mobiles[i] != null) { - _rawMobiles[i].Account = this; + _mobiles[i].Account = this; } } var totalGameTime = Utility.GetXMLTimeSpan(Utility.GetText(node["totalGameTime"], null), TimeSpan.Zero); if (totalGameTime == TimeSpan.Zero) { - for (var i = 0; i < _rawMobiles.Length; i++) + for (var i = 0; i < _mobiles.Length; i++) { - if (_rawMobiles[i] is PlayerMobile m) + if (_mobiles[i] is PlayerMobile m) { totalGameTime += m.GameTime; } @@ -333,19 +326,19 @@ namespace Server.Accounting _tags = null; } - for (var i = 0; i < _rawMobiles.Length; ++i) + for (var i = 0; i < _mobiles.Length; ++i) { - if (_rawMobiles[i] != null) + if (_mobiles[i] != null) { - _rawMobiles[i].Account = this; + _mobiles[i].Account = this; } } if (_totalGameTime == TimeSpan.Zero) { - for (var i = 0; i < _rawMobiles.Length; i++) + for (var i = 0; i < _mobiles.Length; i++) { - if (_rawMobiles[i] is PlayerMobile m) + if (_mobiles[i] is PlayerMobile m) { _totalGameTime += m.GameTime; } @@ -382,7 +375,7 @@ namespace Server.Accounting m.Delete(); m.Account = null; - _rawMobiles[i] = null; + _mobiles[i] = null; } if (_loginIPs.Length != 0 && AccountHandler.IPTable.ContainsKey(_loginIPs[0])) @@ -453,7 +446,7 @@ namespace Server.Accounting /// /// Gets the maximum amount of characters that this account can hold. /// - public int Length => _rawMobiles.Length; + public int Length => _mobiles.Length; /// /// Gets or sets the character at a specified index for this account. Out of bound index values are handled; null returned @@ -463,9 +456,9 @@ namespace Server.Accounting { get { - if (index >= 0 && index < _rawMobiles.Length) + if (index >= 0 && index < _mobiles.Length) { - var m = _rawMobiles[index]; + var m = _mobiles[index]; if (m?.Deleted != true) { @@ -475,7 +468,7 @@ namespace Server.Accounting // This is the only place that clears a mobile for garbage collection // outside of an entire account deletion. m.Account = null; - _rawMobiles[index] = null; + _mobiles[index] = null; this.MarkDirty(); } @@ -483,19 +476,19 @@ namespace Server.Accounting } set { - if (index >= 0 && index < _rawMobiles.Length) + if (index >= 0 && index < _mobiles.Length) { - if (_rawMobiles[index] != null) + if (_mobiles[index] != null) { - _rawMobiles[index].Account = null; + _mobiles[index].Account = null; } - _rawMobiles[index] = value; + _mobiles[index] = value; this.MarkDirty(); - if (_rawMobiles[index] != null) + if (_mobiles[index] != null) { - _rawMobiles[index].Account = this; + _mobiles[index].Account = this; } } } @@ -826,9 +819,9 @@ namespace Server.Accounting { Young = false; - for (var i = 0; i < _rawMobiles.Length; i++) + for (var i = 0; i < _mobiles.Length; i++) { - if (_rawMobiles[i] is PlayerMobile { Young: true } m) + if (_mobiles[i] is PlayerMobile { Young: true } m) { m.Young = false; @@ -1186,8 +1179,9 @@ namespace Server.Accounting } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Enumerator GetEnumerator() => new(_rawMobiles); + public Enumerator GetEnumerator() => new(_mobiles); + [SerializableProperty(8, useField: nameof(_mobiles))] public Enumerator Mobiles { [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Projects/UOContent/Items/Addons/BaseAddon.cs b/Projects/UOContent/Items/Addons/BaseAddon.cs index f7fbd61c7..cdd80f1ed 100644 --- a/Projects/UOContent/Items/Addons/BaseAddon.cs +++ b/Projects/UOContent/Items/Addons/BaseAddon.cs @@ -24,9 +24,6 @@ namespace Server.Items [SerializationGenerator(3, false)] public abstract partial class BaseAddon : Item, IChoppable, IAddon { - [SerializableField(1, "private", "private")] - private CraftResource _rawResource; - public BaseAddon() : base(1) { Movable = false; @@ -66,16 +63,17 @@ namespace Server.Items } } + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource { - get => _rawResource; + get => _resource; set { - if (_rawResource != value) + if (_resource != value) { - RawResource = value; - Hue = CraftResources.GetHue(_rawResource); + _resource = value; + Hue = CraftResources.GetHue(_resource); InvalidateProperties(); this.MarkDirty(); @@ -285,7 +283,7 @@ namespace Server.Items if (version == 2) { - _rawResource = (CraftResource)reader.ReadEncodedInt(); + _resource = (CraftResource)reader.ReadEncodedInt(); } } } diff --git a/Projects/UOContent/Items/Addons/BaseAddonContainer.cs b/Projects/UOContent/Items/Addons/BaseAddonContainer.cs index 3cf06af23..71c69c05c 100644 --- a/Projects/UOContent/Items/Addons/BaseAddonContainer.cs +++ b/Projects/UOContent/Items/Addons/BaseAddonContainer.cs @@ -10,9 +10,6 @@ namespace Server.Items [SerializableField(0, setter: "private")] private List _components; - [SerializableField(1, "private", "private")] - private CraftResource _rawResource; - public BaseAddonContainer(int itemID) : base(itemID) { AddonComponent.ApplyLightTo(this); @@ -44,16 +41,17 @@ namespace Server.Items } } + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource { - get => _rawResource; + get => _resource; set { - if (_rawResource != value) + if (_resource != value) { - RawResource = value; - Hue = CraftResources.GetHue(_rawResource); + _resource = value; + Hue = CraftResources.GetHue(_resource); InvalidateProperties(); this.MarkDirty(); @@ -172,9 +170,9 @@ namespace Server.Items { base.GetProperties(list); - if (!CraftResources.IsStandard(_rawResource)) + if (!CraftResources.IsStandard(_resource)) { - list.Add(CraftResources.GetLocalizationNumber(_rawResource)); + list.Add(CraftResources.GetLocalizationNumber(_resource)); } } @@ -205,7 +203,7 @@ namespace Server.Items private void Deserialize(IGenericReader reader, int version) { _components = reader.ReadEntityList(); - _rawResource = version == 1 ? reader.ReadEnum() : (CraftResource)reader.ReadInt(); + _resource = version == 1 ? reader.ReadEnum() : (CraftResource)reader.ReadInt(); } [AfterDeserialization] diff --git a/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs b/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs index 1fd8c3072..bf2dda6e7 100644 --- a/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs +++ b/Projects/UOContent/Items/Addons/FlourMillEastAddon.cs @@ -27,8 +27,6 @@ namespace Server.Items new[] { 0x1924, 0x1924, 0x1928 } }; - private int _flour; - [Constructible] public FlourMillEastAddon() { @@ -40,10 +38,10 @@ namespace Server.Items public override BaseAddonDeed Deed => new FlourMillEastDeed(); [CommandProperty(AccessLevel.GameMaster)] - public bool HasFlour => _flour > 0; + public bool HasFlour => _curFlour > 0; [CommandProperty(AccessLevel.GameMaster)] - public bool IsFull => _flour >= MaxFlour; + public bool IsFull => _curFlour >= MaxFlour; [CommandProperty(AccessLevel.GameMaster)] public bool IsWorking { get; private set; } @@ -51,14 +49,14 @@ namespace Server.Items [CommandProperty(AccessLevel.GameMaster)] public int MaxFlour => 2; - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurFlour { - get => _flour; + get => _curFlour; set { - _flour = Math.Clamp(value, 0, MaxFlour); + _curFlour = Math.Clamp(value, 0, MaxFlour); UpdateStage(); this.MarkDirty(); } @@ -86,7 +84,7 @@ namespace Server.Items if (from.PlaceInBackpack(flour)) { - _flour = 0; + _curFlour = 0; } else { diff --git a/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs b/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs index cfd7c7c72..0695fe143 100644 --- a/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs +++ b/Projects/UOContent/Items/Addons/FlourMillSouthAddon.cs @@ -14,8 +14,6 @@ namespace Server.Items new[] { 0x1930, 0x1930, 0x1934 } }; - private int _flour; - [Constructible] public FlourMillSouthAddon() { @@ -27,10 +25,10 @@ namespace Server.Items public override BaseAddonDeed Deed => new FlourMillSouthDeed(); [CommandProperty(AccessLevel.GameMaster)] - public bool HasFlour => _flour > 0; + public bool HasFlour => _curFlour > 0; [CommandProperty(AccessLevel.GameMaster)] - public bool IsFull => _flour >= MaxFlour; + public bool IsFull => _curFlour >= MaxFlour; [CommandProperty(AccessLevel.GameMaster)] public bool IsWorking { get; private set; } @@ -38,14 +36,14 @@ namespace Server.Items [CommandProperty(AccessLevel.GameMaster)] public int MaxFlour => 2; - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurFlour { - get => _flour; + get => _curFlour; set { - _flour = Math.Max(0, Math.Min(value, MaxFlour)); + _curFlour = Math.Max(0, Math.Min(value, MaxFlour)); UpdateStage(); } } @@ -74,7 +72,7 @@ namespace Server.Items if (from.PlaceInBackpack(flour)) { - _flour = 0; + _curFlour = 0; } else { diff --git a/Projects/UOContent/Items/Addons/SHTeleporter.cs b/Projects/UOContent/Items/Addons/SHTeleporter.cs index a8ac56dd6..28ec63ddc 100644 --- a/Projects/UOContent/Items/Addons/SHTeleporter.cs +++ b/Projects/UOContent/Items/Addons/SHTeleporter.cs @@ -11,13 +11,6 @@ namespace Server.Items [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private Point3D _teleOffset; - //The extra custom processing done in the property setters causes deserialisation to fail. - //These hidden private members will auto generate properties with no processing which we can point to. - [SerializableField(0, getter: "private", setter: "private")] - private bool _rawActive; - [SerializableField(1, getter: "private", setter: "private")] - private SHTeleComponent _rawTeleDest; - [Constructible] public SHTeleComponent(int itemID = 0x1775) : this(itemID, new Point3D(0, 0, 0)) { @@ -29,17 +22,18 @@ namespace Server.Items Movable = false; Hue = 1; - _rawActive = true; - TeleOffset = offset; + _active = true; + _teleOffset = offset; } + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public bool Active { - get => RawActive; + get => _active; set { - RawActive = value; + _active = value; if (Addon is SHTeleporter sourceAddon) { @@ -48,13 +42,14 @@ namespace Server.Items } } + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public SHTeleComponent TeleDest { - get => RawTeleDest; + get => _teleDest; set { - RawTeleDest = value; + _teleDest = value; if (Addon is SHTeleporter sourceAddon) { @@ -74,15 +69,15 @@ namespace Server.Items public override void OnDoubleClick(Mobile m) { - if (!_rawActive || _rawTeleDest?.Deleted != false || _rawTeleDest.Map == Map.Internal) + if (!_active || _teleDest?.Deleted != false || _teleDest.Map == Map.Internal) { return; } if (m.InRange(this, 3)) { - var map = _rawTeleDest.Map; - var p = _rawTeleDest.TelePoint; + var map = _teleDest.Map; + var p = _teleDest.TelePoint; BaseCreature.TeleportPets(m, p, map); diff --git a/Projects/UOContent/Items/Aquarium/AquariumState.cs b/Projects/UOContent/Items/Aquarium/AquariumState.cs index ed38e98f7..47dc21a98 100644 --- a/Projects/UOContent/Items/Aquarium/AquariumState.cs +++ b/Projects/UOContent/Items/Aquarium/AquariumState.cs @@ -28,11 +28,9 @@ namespace Server.Items [DirtyTrackingEntity] private Aquarium _aquarium; - private int _state; - public AquariumState(Aquarium parent) => _aquarium = parent; - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int State { diff --git a/Projects/UOContent/Items/Armor/BaseArmor.Migrations.cs b/Projects/UOContent/Items/Armor/BaseArmor.Migrations.cs index de8904f0c..528bf6704 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.Migrations.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.Migrations.cs @@ -20,7 +20,7 @@ public partial class BaseArmor Timer.StartTimer(() => _crafter = crafter?.RawName); _quality = content.Quality ?? ArmorQuality.Regular; _durability = content.Durability ?? ArmorDurabilityLevel.Regular; - _rawResource = content.RawResource ?? DefaultResource; + _resource = content.RawResource ?? DefaultResource; _armorBase = content.BaseArmorRating ?? -1; _strBonus = content.StrBonus ?? -1; _dexBonus = content.DexBonus ?? -1; @@ -107,12 +107,12 @@ public partial class BaseArmor if (GetSaveFlag(flags, OldSaveFlag.Protection)) { - _protection = (ArmorProtectionLevel)reader.ReadEncodedInt(); + _protectionLevel = (ArmorProtectionLevel)reader.ReadEncodedInt(); } if (GetSaveFlag(flags, OldSaveFlag.Resource)) { - _rawResource = (CraftResource)reader.ReadEncodedInt(); + _resource = (CraftResource)reader.ReadEncodedInt(); } if (GetSaveFlag(flags, OldSaveFlag.BaseArmor)) diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index 4aa3191e7..d97167c57 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -94,9 +94,6 @@ namespace Server.Items [SerializableFieldSaveFlag(8)] private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0; - // Field 9 - private int _hitPoints; - [InvalidateProperties] [SerializableField(10)] [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] @@ -105,21 +102,8 @@ namespace Server.Items [SerializableFieldSaveFlag(10)] private bool ShouldSerializeCrafter() => _crafter != null; - // Field 11 - private ArmorQuality _quality = ArmorQuality.Regular; - - // Field 12 - private ArmorDurabilityLevel _durability = ArmorDurabilityLevel.Regular; - - // Field 13 - private ArmorProtectionLevel _protection = ArmorProtectionLevel.Regular; - - // Field 14 - [SerializableField(14, "private", "private")] - private CraftResource _rawResource; - [SerializableFieldSaveFlag(14)] - private bool ShouldSerializeResource() => _rawResource != DefaultResource; + private bool ShouldSerializeResource() => _resource != DefaultResource; // Field 15 private int _armorBase = -1; @@ -168,8 +152,8 @@ namespace Server.Items { _crafter = null; - _rawResource = DefaultResource; - Hue = CraftResources.GetHue(_rawResource); + _resource = DefaultResource; + Hue = CraftResources.GetHue(_resource); _hitPoints = _maxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); @@ -206,7 +190,7 @@ namespace Server.Items public virtual int OldDexReq => 0; public virtual int OldIntReq => 0; - [SerializableField(11)] + [SerializableProperty(11)] [CommandProperty(AccessLevel.GameMaster)] public ArmorQuality Quality { @@ -228,7 +212,7 @@ namespace Server.Items [SerializableFieldSaveFlag(11)] private bool ShouldSerializeArmorQuality() => _quality != ArmorQuality.Regular; - [SerializableField(12)] + [SerializableProperty(12)] [CommandProperty(AccessLevel.GameMaster)] public ArmorDurabilityLevel Durability { @@ -250,16 +234,16 @@ namespace Server.Items [SerializableFieldSaveFlag(12)] private bool ShouldSerializeDurability() => _durability != ArmorDurabilityLevel.Regular; - [SerializableField(13)] + [SerializableProperty(13)] [CommandProperty(AccessLevel.GameMaster)] public ArmorProtectionLevel ProtectionLevel { - get => _protection; + get => _protectionLevel; set { - if (_protection != value) + if (_protectionLevel != value) { - _protection = value; + _protectionLevel = value; Invalidate(); InvalidateProperties(); @@ -271,23 +255,24 @@ namespace Server.Items } [SerializableFieldSaveFlag(13)] - private bool ShouldSerializeProtectionLevel() => _protection != ArmorProtectionLevel.Regular; + private bool ShouldSerializeProtectionLevel() => _protectionLevel != ArmorProtectionLevel.Regular; + [SerializableProperty(14)] [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource { - get => _rawResource; + get => _resource; set { - if (_rawResource != value) + if (_resource != value) { UnscaleDurability(); - RawResource = value; + _resource = value; if (CraftItem.RetainsColor(GetType())) { - Hue = CraftResources.GetHue(_rawResource); + Hue = CraftResources.GetHue(_resource); } Invalidate(); @@ -302,7 +287,7 @@ namespace Server.Items private CraftResource ResourceDefaultValue() => DefaultResource; [EncodedInt] - [SerializableField(15)] + [SerializableProperty(15, useField: nameof(_armorBase))] [CommandProperty(AccessLevel.GameMaster)] public int BaseArmorRating { @@ -329,12 +314,12 @@ namespace Server.Items { var ar = BaseArmorRating; - if (_protection != ArmorProtectionLevel.Regular) + if (_protectionLevel != ArmorProtectionLevel.Regular) { - ar += 10 + 5 * (int)_protection; + ar += 10 + 5 * (int)_protectionLevel; } - ar += _rawResource switch + ar += _resource switch { CraftResource.DullCopper => 2, CraftResource.ShadowIron => 4, @@ -358,7 +343,7 @@ namespace Server.Items public double ArmorRatingScaled => ArmorRating * ArmorScalar; [EncodedInt] - [SerializableField(16)] + [SerializableProperty(16, useField: nameof(_strBonus))] [CommandProperty(AccessLevel.GameMaster)] public int StrBonus { @@ -378,7 +363,7 @@ namespace Server.Items private int StrBonusDefaultValue() => -1; [EncodedInt] - [SerializableField(17)] + [SerializableProperty(17, useField: nameof(_dexBonus))] [CommandProperty(AccessLevel.GameMaster)] public int DexBonus { @@ -398,7 +383,7 @@ namespace Server.Items private int DexBonusDefaultValue() => -1; [EncodedInt] - [SerializableField(18)] + [SerializableProperty(18, useField: nameof(_intBonus))] [CommandProperty(AccessLevel.GameMaster)] public int IntBonus { @@ -418,7 +403,7 @@ namespace Server.Items private int IntBonusDefaultValue() => -1; [EncodedInt] - [SerializableField(19)] + [SerializableProperty(19, useField: nameof(_strReq))] [CommandProperty(AccessLevel.GameMaster)] public int StrRequirement { @@ -438,7 +423,7 @@ namespace Server.Items private int StrReqDefaultValue() => -1; [EncodedInt] - [SerializableField(20)] + [SerializableProperty(20, useField: nameof(_dexReq))] [CommandProperty(AccessLevel.GameMaster)] public int DexRequirement { @@ -458,7 +443,7 @@ namespace Server.Items private int DexReqDefaultValue() => -1; [EncodedInt] - [SerializableField(21)] + [SerializableProperty(21, useField: nameof(_intReq))] [CommandProperty(AccessLevel.GameMaster)] public int IntRequirement { @@ -477,7 +462,7 @@ namespace Server.Items [SerializableFieldDefault(21)] private int IntReqDefaultValue() => -1; - [SerializableField(22)] + [SerializableProperty(22, useField: nameof(_meditate))] [CommandProperty(AccessLevel.GameMaster)] public AMA MeditationAllowance { @@ -675,7 +660,7 @@ namespace Server.Items { try { - var res = CraftResources.GetInfo(_rawResource).ResourceTypes[0].CreateInstance(); + var res = CraftResources.GetInfo(_resource).ResourceTypes[0].CreateInstance(); ScissorHelper(from, res, PlayerConstructed ? item.Resources[0].Amount / 2 : 1); return true; @@ -693,7 +678,7 @@ namespace Server.Items public virtual bool CanFortify => true; [EncodedInt] - [SerializableField(9)] + [SerializableProperty(9)] [CommandProperty(AccessLevel.GameMaster)] public int HitPoints { @@ -864,11 +849,11 @@ namespace Server.Items } public CraftAttributeInfo GetResourceAttrs() => - CraftResources.GetInfo(_rawResource)?.AttributeInfo ?? CraftAttributeInfo.Blank; + CraftResources.GetInfo(_resource)?.AttributeInfo ?? CraftAttributeInfo.Blank; public int GetProtOffset() { - return _protection switch + return _protectionLevel switch { ArmorProtectionLevel.Guarding => 1, ArmorProtectionLevel.Hardening => 2, @@ -896,7 +881,7 @@ namespace Server.Items { bonus += ArmorAttributes.DurabilityBonus; - var resInfo = CraftResources.GetInfo(_rawResource); + var resInfo = CraftResources.GetInfo(_resource); CraftAttributeInfo attrInfo = null; if (resInfo != null) @@ -969,7 +954,7 @@ namespace Server.Items var v = ArmorAttributes.LowerStatReq; - var info = CraftResources.GetInfo(_rawResource); + var info = CraftResources.GetInfo(_resource); var attrInfo = info?.AttributeInfo; @@ -1028,9 +1013,9 @@ namespace Server.Items SkillBonuses.AddTo(m); } - if (_rawResource == CraftResource.None) + if (_resource == CraftResource.None) { - _rawResource = DefaultResource; + _resource = DefaultResource; } var strBonus = ComputeStatBonus(StatType.Str); @@ -1208,7 +1193,7 @@ namespace Server.Items public override void AddNameProperty(IPropertyList list) { - var oreType = _rawResource switch + var oreType = _resource switch { CraftResource.DullCopper => 1053108, CraftResource.ShadowIron => 1053107, @@ -1276,7 +1261,7 @@ namespace Server.Items return Attributes.SpellChanneling != 0; } - public virtual int GetLuckBonus() => CraftResources.GetInfo(_rawResource)?.AttributeInfo?.ArmorLuck ?? 0; + public virtual int GetLuckBonus() => CraftResources.GetInfo(_resource)?.AttributeInfo?.ArmorLuck ?? 0; public override void GetProperties(IPropertyList list) { @@ -1497,13 +1482,13 @@ namespace Server.Items attrs.Add(new EquipInfoAttribute(1038000 + (int)_durability)); } - if (_protection > ArmorProtectionLevel.Regular && _protection <= ArmorProtectionLevel.Invulnerability) + if (_protectionLevel > ArmorProtectionLevel.Regular && _protectionLevel <= ArmorProtectionLevel.Invulnerability) { - attrs.Add(new EquipInfoAttribute(1038005 + (int)_protection)); + attrs.Add(new EquipInfoAttribute(1038005 + (int)_protectionLevel)); } } - else if (_durability != ArmorDurabilityLevel.Regular || _protection > ArmorProtectionLevel.Regular && - _protection <= ArmorProtectionLevel.Invulnerability) + else if (_durability != ArmorDurabilityLevel.Regular || _protectionLevel > ArmorProtectionLevel.Regular && + _protectionLevel <= ArmorProtectionLevel.Invulnerability) { attrs.Add(new EquipInfoAttribute(1038000)); // Unidentified } diff --git a/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs b/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs index fc8028be6..36fb38c6e 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeafGloves.cs @@ -6,9 +6,6 @@ namespace Server.Items [SerializationGenerator(1)] public partial class LeafGloves : BaseArmor, IArcaneEquip { - private int _maxArcaneCharges; - private int _curArcaneCharges; - [Constructible] public LeafGloves() : base(0x2FC6) => Weight = 2.0; @@ -33,7 +30,7 @@ namespace Server.Items public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All; [EncodedInt] - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurArcaneCharges { @@ -47,7 +44,7 @@ namespace Server.Items } [EncodedInt] - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public int MaxArcaneCharges { diff --git a/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs b/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs index ef8005160..cab91adcc 100644 --- a/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs +++ b/Projects/UOContent/Items/Armor/Leather/LeatherGloves.cs @@ -6,9 +6,6 @@ namespace Server.Items [SerializationGenerator(2, false)] public partial class LeatherGloves : BaseArmor, IArcaneEquip { - private int _maxArcaneCharges; - private int _curArcaneCharges; - [Constructible] public LeatherGloves() : base(0x13C6) => Weight = 1.0; @@ -32,7 +29,7 @@ namespace Server.Items public override ArmorMeditationAllowance DefMedAllowance => ArmorMeditationAllowance.All; [EncodedInt] - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurArcaneCharges { @@ -46,7 +43,7 @@ namespace Server.Items } [EncodedInt] - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public int MaxArcaneCharges { diff --git a/Projects/UOContent/Items/Clothing/BaseClothing.Migrations.cs b/Projects/UOContent/Items/Clothing/BaseClothing.Migrations.cs index fe0902747..da962c73f 100644 --- a/Projects/UOContent/Items/Clothing/BaseClothing.Migrations.cs +++ b/Projects/UOContent/Items/Clothing/BaseClothing.Migrations.cs @@ -4,7 +4,7 @@ public partial class BaseClothing { private void MigrateFrom(V6Content content) { - _rawResource = content.RawResource ?? DefaultResource; + _resource = content.RawResource ?? DefaultResource; _attributes = content.Attributes ?? AttributesDefaultValue(); _clothingAttributes = content.ClothingAttributes ?? ClothingAttributesDefaultValue(); _skillBonuses = content.SkillBonuses ?? SkillBonusesDefaultValue(); @@ -24,11 +24,11 @@ public partial class BaseClothing if (GetSaveFlag(flags, OldSaveFlag.Resource)) { - _rawResource = (CraftResource)reader.ReadEncodedInt(); + _resource = (CraftResource)reader.ReadEncodedInt(); } else { - _rawResource = DefaultResource; + _resource = DefaultResource; } Attributes = new AosAttributes(this); diff --git a/Projects/UOContent/Items/Clothing/BaseClothing.cs b/Projects/UOContent/Items/Clothing/BaseClothing.cs index 11dd69859..a6a785871 100644 --- a/Projects/UOContent/Items/Clothing/BaseClothing.cs +++ b/Projects/UOContent/Items/Clothing/BaseClothing.cs @@ -26,11 +26,8 @@ namespace Server.Items [SerializationGenerator(7, false)] public abstract partial class BaseClothing : Item, IDyable, IScissorable, IFactionItem, ICraftable, IWearableDurability { - [SerializableField(0, "private", "private")] - private CraftResource _rawResource; - [SerializableFieldSaveFlag(0)] - private bool ShouldSerializeResource() => _rawResource != DefaultResource; + private bool ShouldSerializeResource() => _resource != DefaultResource; [SerializableField(1, setter: "private")] [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster, canModify: true)]")] @@ -81,9 +78,6 @@ namespace Server.Items [SerializableFieldSaveFlag(5)] private bool ShouldSerializeMaxHitPoints() => _maxHitPoints != 0; - // Field 6 - private int _hitPoints; - [SerializableField(7)] [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private bool _playerConstructed; @@ -117,7 +111,7 @@ namespace Server.Items Layer = layer; Hue = hue; - _rawResource = DefaultResource; + _resource = DefaultResource; _hitPoints = _maxHitPoints = Utility.RandomMinMax(InitMinHits, InitMaxHits); @@ -127,20 +121,21 @@ namespace Server.Items Resistances = new AosElementAttributes(this); } + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource { - get => _rawResource; + get => _resource; set { - RawResource = value; - Hue = CraftResources.GetHue(_rawResource); + _resource = value; + Hue = CraftResources.GetHue(_resource); InvalidateProperties(); this.MarkDirty(); } } - [SerializableField(10)] + [SerializableProperty(10, useField: nameof(_strReq))] [CommandProperty(AccessLevel.GameMaster)] public int StrRequirement { @@ -278,7 +273,7 @@ namespace Server.Items { try { - var info = CraftResources.GetInfo(_rawResource); + var info = CraftResources.GetInfo(_resource); Type resourceType = null; if (info?.ResourceTypes.Length > 0) @@ -308,7 +303,7 @@ namespace Server.Items public virtual bool CanFortify => true; [EncodedInt] - [SerializableField(6)] + [SerializableProperty(6)] [CommandProperty(AccessLevel.GameMaster)] public int HitPoints { @@ -664,7 +659,7 @@ namespace Server.Items public override void AddNameProperty(IPropertyList list) { - var oreType = _rawResource switch + var oreType = _resource switch { CraftResource.DullCopper => 1053108, CraftResource.ShadowIron => 1053107, diff --git a/Projects/UOContent/Items/Clothing/Cloaks.cs b/Projects/UOContent/Items/Clothing/Cloaks.cs index d5356dde2..cf9753120 100644 --- a/Projects/UOContent/Items/Clothing/Cloaks.cs +++ b/Projects/UOContent/Items/Clothing/Cloaks.cs @@ -15,14 +15,11 @@ namespace Server.Items [SerializationGenerator(2, false)] public partial class Cloak : BaseCloak, IArcaneEquip { - private int _maxArcaneCharges; - private int _curArcaneCharges; - [Constructible] public Cloak(int hue = 0) : base(0x1515, hue) => Weight = 5.0; [EncodedInt] - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurArcaneCharges { @@ -37,7 +34,7 @@ namespace Server.Items } [EncodedInt] - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public int MaxArcaneCharges { diff --git a/Projects/UOContent/Items/Clothing/OuterTorso.cs b/Projects/UOContent/Items/Clothing/OuterTorso.cs index edd737c2f..15aec7f89 100644 --- a/Projects/UOContent/Items/Clothing/OuterTorso.cs +++ b/Projects/UOContent/Items/Clothing/OuterTorso.cs @@ -309,14 +309,11 @@ namespace Server.Items [SerializationGenerator(2, false)] public partial class Robe : BaseOuterTorso, IArcaneEquip { - private int _curArcaneCharges; - private int _maxArcaneCharges; - [Constructible] public Robe(int hue = 0) : base(0x1F03, hue) => Weight = 3.0; [EncodedInt] - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurArcaneCharges { @@ -331,7 +328,7 @@ namespace Server.Items } [EncodedInt] - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public int MaxArcaneCharges { diff --git a/Projects/UOContent/Items/Clothing/Shoes.cs b/Projects/UOContent/Items/Clothing/Shoes.cs index 0615335d9..8e6cb3d7a 100644 --- a/Projects/UOContent/Items/Clothing/Shoes.cs +++ b/Projects/UOContent/Items/Clothing/Shoes.cs @@ -43,16 +43,13 @@ namespace Server.Items [SerializationGenerator(2, false)] public partial class ThighBoots : BaseShoes, IArcaneEquip { - private int _maxArcaneCharges; - private int _curArcaneCharges; - [Constructible] public ThighBoots(int hue = 0) : base(0x1711, hue) => Weight = 4.0; public override CraftResource DefaultResource => CraftResource.RegularLeather; [EncodedInt] - [SerializableField(0)] + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public int CurArcaneCharges { @@ -67,7 +64,7 @@ namespace Server.Items } [EncodedInt] - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public int MaxArcaneCharges { diff --git a/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainer.cs b/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainer.cs index 9f035a477..dae84dcc8 100644 --- a/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainer.cs +++ b/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainer.cs @@ -6,9 +6,6 @@ namespace Server.Items; [SerializationGenerator(2, false)] public abstract partial class FillableContainer : LockableContainer { - [SerializableField(0)] - protected FillableContentType _rawContentType; - [TimerDrift] [SerializableField(1)] private Timer _respawnTimer; @@ -35,19 +32,20 @@ public abstract partial class FillableContainer : LockableContainer [CommandProperty(AccessLevel.GameMaster)] public DateTime NextRespawnTime => _respawnTimer?.Next ?? DateTime.MinValue; + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public FillableContentType ContentType { - get => _rawContentType; + get => _contentType; set { - if (_rawContentType == value) + if (_contentType == value) { return; } ClearContents(); - _rawContentType = value; + _contentType = value; Respawn(); } } @@ -77,14 +75,15 @@ public abstract partial class FillableContainer : LockableContainer public virtual void AcquireContent() { - if (_rawContentType != FillableContentType.None) + if (_contentType != FillableContentType.None) { return; } - RawContentType = FillableContent.Acquire(GetWorldLocation(), Map); + // Don't trigger serialization code + _contentType = FillableContent.Acquire(GetWorldLocation(), Map); - if (_rawContentType != FillableContentType.None) + if (_contentType != FillableContentType.None) { Respawn(); } @@ -118,7 +117,7 @@ public abstract partial class FillableContainer : LockableContainer public void CheckRespawn() { var canSpawn = - _rawContentType != FillableContentType.None && + _contentType != FillableContentType.None && !Deleted && !Movable && Parent == null && !IsLockedDown && !IsSecure && ( GetItemsCount() <= SpawnThreshold || @@ -147,14 +146,14 @@ public abstract partial class FillableContainer : LockableContainer _respawnTimer?.Stop(); _respawnTimer = null; - if (_rawContentType == FillableContentType.None || Deleted) + if (_contentType == FillableContentType.None || Deleted) { return; } GenerateContent(); - var level = FillableContent.Lookup(_rawContentType).Level; + var level = FillableContent.Lookup(_contentType).Level; if (IsLockable) { @@ -199,12 +198,12 @@ public abstract partial class FillableContainer : LockableContainer public virtual void GenerateContent() { - if (_rawContentType == FillableContentType.None || Deleted) + if (_contentType == FillableContentType.None || Deleted) { return; } - var content = FillableContent.Lookup(_rawContentType); + var content = FillableContent.Lookup(_contentType); var toSpawn = GetSpawnCount(); @@ -238,7 +237,7 @@ public abstract partial class FillableContainer : LockableContainer private void Deserialize(IGenericReader reader, int version) { - _rawContentType = (FillableContentType)reader.ReadInt(); + _contentType = (FillableContentType)reader.ReadInt(); var respawnTimerNext = reader.ReadDeltaTime(); DeserializeRespawnTimer(respawnTimerNext == DateTime.MinValue ? TimeSpan.MinValue : respawnTimerNext - Core.Now); } diff --git a/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainers.cs b/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainers.cs index 0c3afc853..459638fc4 100644 --- a/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainers.cs +++ b/Projects/UOContent/Items/Containers/Fillable Containers/FillableContainers.cs @@ -16,13 +16,12 @@ public partial class LibraryBookcase : FillableContainer public override void AcquireContent() { - if (_rawContentType != FillableContentType.None) + if (ContentType != FillableContentType.None) { return; } - RawContentType = FillableContentType.Library; - Respawn(); + ContentType = FillableContentType.Library; } } diff --git a/Projects/UOContent/Items/Containers/LockableContainer.cs b/Projects/UOContent/Items/Containers/LockableContainer.cs index a65670256..c878a7f13 100644 --- a/Projects/UOContent/Items/Containers/LockableContainer.cs +++ b/Projects/UOContent/Items/Containers/LockableContainer.cs @@ -12,7 +12,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, public override bool TrapOnOpen => !_trapOnLockpick; - public override bool DisplaysContent => !_rawLocked; + public override bool DisplaysContent => !_locked; public int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, @@ -72,18 +72,16 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private int _lockLevel; - [SerializableField(6, getter: "private", setter: "private")] - private bool _rawLocked; - + [SerializableProperty(6)] [CommandProperty(AccessLevel.GameMaster)] public virtual bool Locked { - get => _rawLocked; + get => _locked; set { - _rawLocked = value; + _locked = value; - if (_rawLocked) + if (_locked) { Picker = null; } @@ -104,11 +102,11 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, } } - public override bool CheckContentDisplay(Mobile from) => !_rawLocked && base.CheckContentDisplay(from); + public override bool CheckContentDisplay(Mobile from) => !_locked && base.CheckContentDisplay(from); public override bool TryDropItem(Mobile from, Item dropped, bool sendFullMessage) { - if (from.AccessLevel < AccessLevel.GameMaster && _rawLocked) + if (from.AccessLevel < AccessLevel.GameMaster && _locked) { from.SendLocalizedMessage(501747); // It appears to be locked. return false; @@ -119,7 +117,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, public override bool OnDragDropInto(Mobile from, Item item, Point3D p) { - if (from.AccessLevel < AccessLevel.GameMaster && _rawLocked) + if (from.AccessLevel < AccessLevel.GameMaster && _locked) { from.SendLocalizedMessage(501747); // It appears to be locked. return false; @@ -130,7 +128,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, public override bool CheckLift(Mobile from, Item item, ref LRReason reject) => base.CheckLift(from, item, ref reject) && - (item == this || from.AccessLevel >= AccessLevel.GameMaster || !_rawLocked); + (item == this || from.AccessLevel >= AccessLevel.GameMaster || !_locked); public override bool CheckItemUse(Mobile from, Item item) { @@ -139,7 +137,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, return false; } - if (item != this && from.AccessLevel < AccessLevel.GameMaster && _rawLocked) + if (item != this && from.AccessLevel < AccessLevel.GameMaster && _locked) { from.LocalOverheadMessage(MessageType.Regular, 0x3B2, 1019045); // I can't reach that. return false; @@ -150,7 +148,7 @@ public abstract partial class LockableContainer : TrappableContainer, ILockable, public virtual bool CheckLocked(Mobile from) { - if (!_rawLocked) + if (!_locked) { return false; } diff --git a/Projects/UOContent/Items/Containers/MarkContainer.cs b/Projects/UOContent/Items/Containers/MarkContainer.cs index 59846b477..67d9a3f89 100644 --- a/Projects/UOContent/Items/Containers/MarkContainer.cs +++ b/Projects/UOContent/Items/Containers/MarkContainer.cs @@ -6,9 +6,6 @@ namespace Server.Items; [SerializationGenerator(0, false)] public partial class MarkContainer : LockableContainer { - [SerializableField(0, getter: "private", setter: "private")] - private bool _rawAutoLock; - [TimerDrift] [SerializableField(1, getter: "private", setter: "private")] private InternalTimer _relockTimer; @@ -16,7 +13,7 @@ public partial class MarkContainer : LockableContainer [DeserializeTimerField(1)] private void DeserializeRelockTimer(TimeSpan delay) { - if (!Locked && _rawAutoLock) + if (!Locked && _autoLock) { _relockTimer = new InternalTimer(this, delay); } @@ -44,7 +41,7 @@ public partial class MarkContainer : LockableContainer Hue = 1102; } - _rawAutoLock = locked; + _autoLock = locked; Locked = locked; if (locked) @@ -53,15 +50,16 @@ public partial class MarkContainer : LockableContainer } } + [SerializableProperty(0)] [CommandProperty(AccessLevel.GameMaster)] public bool AutoLock { - get => _rawAutoLock; + get => _autoLock; set { - _rawAutoLock = value; + _autoLock = value; - if (!_rawAutoLock) + if (!_autoLock) { StopTimer(); } @@ -93,7 +91,7 @@ public partial class MarkContainer : LockableContainer { base.Locked = value; - if (_rawAutoLock) + if (_autoLock) { StopTimer(); diff --git a/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs b/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs index 78a13404e..4b70f57c5 100644 --- a/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs +++ b/Projects/UOContent/Items/Deeds/DragonBardingDeed.cs @@ -20,20 +20,18 @@ public partial class DragonBardingDeed : Item, ICraftable [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private bool _exceptional; - [SerializableField(2, "private", "private")] - private CraftResource _rawResource; - public DragonBardingDeed() : base(0x14F0) => Weight = 1.0; public override int LabelNumber => _exceptional ? 1053181 : 1053012; // dragon barding deed + [SerializableProperty(2)] [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource { - get => _rawResource; + get => _resource; set { - _rawResource = value; + _resource = value; Hue = CraftResources.GetHue(value); InvalidateProperties(); } @@ -134,6 +132,6 @@ public partial class DragonBardingDeed : Item, ICraftable reader.ReadInt(); } - _rawResource = (CraftResource)reader.ReadInt(); + _resource = (CraftResource)reader.ReadInt(); } } diff --git a/Projects/UOContent/Items/Food/Beverage.cs b/Projects/UOContent/Items/Food/Beverage.cs index 305440fcb..e74eb03b4 100644 --- a/Projects/UOContent/Items/Food/Beverage.cs +++ b/Projects/UOContent/Items/Food/Beverage.cs @@ -227,23 +227,17 @@ public abstract partial class BaseBeverage : Item, IHasQuantity [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private Mobile _poisoner; - [SerializableField(2, getter: "private", setter: "private")] - private BeverageType _rawContent; - - [SerializableField(3, getter: "private", setter: "private")] - private int _rawQuantity; - public BaseBeverage() => ItemID = ComputeItemID(); public BaseBeverage(BeverageType type) { - _rawContent = type; - _rawQuantity = MaxQuantity; + _content = type; + _quantity = MaxQuantity; ItemID = ComputeItemID(); } public override int LabelNumber => - IsEmpty || BaseLabelNumber == 0 ? EmptyLabelNumber : BaseLabelNumber + (int)_rawContent; + IsEmpty || BaseLabelNumber == 0 ? EmptyLabelNumber : BaseLabelNumber + (int)_content; public virtual bool ShowQuantity => MaxQuantity > 1; public virtual bool Fillable => true; @@ -255,21 +249,22 @@ public abstract partial class BaseBeverage : Item, IHasQuantity public abstract int MaxQuantity { get; } [CommandProperty(AccessLevel.GameMaster)] - public bool IsEmpty => _rawQuantity <= 0; + public bool IsEmpty => _quantity <= 0; [CommandProperty(AccessLevel.GameMaster)] - public bool ContainsAlcohol => !IsEmpty && _rawContent is not BeverageType.Milk and not BeverageType.Water; + public bool ContainsAlcohol => !IsEmpty && _content is not BeverageType.Milk and not BeverageType.Water; [CommandProperty(AccessLevel.GameMaster)] - public bool IsFull => _rawQuantity >= MaxQuantity; + public bool IsFull => _quantity >= MaxQuantity; + [SerializableProperty(2)] [CommandProperty(AccessLevel.GameMaster)] public BeverageType Content { - get => _rawContent; + get => _content; set { - RawContent = value; + _content = value; InvalidateProperties(); @@ -286,13 +281,14 @@ public abstract partial class BaseBeverage : Item, IHasQuantity } } + [SerializableProperty(3)] [CommandProperty(AccessLevel.GameMaster)] public int Quantity { - get => _rawQuantity; + get => _quantity; set { - RawQuantity = Math.Clamp(value, 0, MaxQuantity); + _quantity = Math.Clamp(value, 0, MaxQuantity); InvalidateProperties(); @@ -313,7 +309,7 @@ public abstract partial class BaseBeverage : Item, IHasQuantity public virtual int GetQuantityDescription() { - return (_rawQuantity * 100 / MaxQuantity) switch + return (_quantity * 100 / MaxQuantity) switch { <= 0 => 1042975, <= 33 => 1042974, @@ -715,8 +711,8 @@ public abstract partial class BaseBeverage : Item, IHasQuantity { _poison = reader.ReadPoison(); _poisoner = reader.ReadEntity(); - _rawContent = (BeverageType)reader.ReadInt(); - _rawQuantity = reader.ReadInt(); + _content = (BeverageType)reader.ReadInt(); + _quantity = reader.ReadInt(); } public static void Initialize() diff --git a/Projects/UOContent/Items/Food/Cooking.cs b/Projects/UOContent/Items/Food/Cooking.cs index e665c490f..73a68a4fb 100644 --- a/Projects/UOContent/Items/Food/Cooking.cs +++ b/Projects/UOContent/Items/Food/Cooking.cs @@ -58,8 +58,6 @@ public partial class WoodenBowl : Item [SerializationGenerator(0, false)] public partial class SackFlour : Item, IHasQuantity { - private int _quantity; - [Constructible] public SackFlour() : base(0x1039) { @@ -68,7 +66,7 @@ public partial class SackFlour : Item, IHasQuantity } [CommandProperty(AccessLevel.GameMaster)] - [SerializableField(0)] + [SerializableProperty(0)] public int Quantity { get => _quantity; diff --git a/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs b/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs index 827b135cf..be72fe621 100644 --- a/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs +++ b/Projects/UOContent/Items/Games/Mahjong/MahjongGame.cs @@ -32,12 +32,6 @@ public partial class MahjongGame : Item, ISecurable [SerializableField(5, setter: "private")] private MahjongPlayers _players; - // Field 6 - private bool _showScores; - - // Field 7 - private bool _spectatorVision; - private DateTime _lastReset; [Constructible] @@ -56,7 +50,7 @@ public partial class MahjongGame : Item, ISecurable } [CommandProperty(AccessLevel.GameMaster)] - [SerializableField(6)] + [SerializableProperty(6)] public bool ShowScores { get => _showScores; @@ -81,7 +75,7 @@ public partial class MahjongGame : Item, ISecurable } [CommandProperty(AccessLevel.GameMaster)] - [SerializableField(7)] + [SerializableProperty(7)] public bool SpectatorVision { get => _spectatorVision; diff --git a/Projects/UOContent/Items/Jewels/BaseJewel.cs b/Projects/UOContent/Items/Jewels/BaseJewel.cs index c15c2d6e0..fdda15757 100644 --- a/Projects/UOContent/Items/Jewels/BaseJewel.cs +++ b/Projects/UOContent/Items/Jewels/BaseJewel.cs @@ -27,12 +27,6 @@ public abstract partial class BaseJewel : Item, ICraftable [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private int _maxHitPoints; - // Field 1 - private int _hitPoints; - - [SerializableField(2, "private", "private")] - private CraftResource _rawResource; - [SerializableField(3)] [InvalidateProperties] [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] @@ -55,8 +49,8 @@ public abstract partial class BaseJewel : Item, ICraftable _attributes = new AosAttributes(this); _resistances = new AosElementAttributes(this); _skillBonuses = new AosSkillBonuses(this); - _rawResource = CraftResource.Iron; - Hue = CraftResources.GetHue(_rawResource); + _resource = CraftResource.Iron; + Hue = CraftResources.GetHue(_resource); _gemType = GemType.None; Layer = layer; @@ -65,7 +59,7 @@ public abstract partial class BaseJewel : Item, ICraftable } [EncodedInt] - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public int HitPoints { @@ -91,14 +85,15 @@ public abstract partial class BaseJewel : Item, ICraftable } } + [SerializableProperty(2)] [CommandProperty(AccessLevel.GameMaster)] public CraftResource Resource { - get => _rawResource; + get => _resource; set { - _rawResource = value; - Hue = CraftResources.GetHue(_rawResource); + _resource = value; + Hue = CraftResources.GetHue(_resource); } } @@ -395,7 +390,7 @@ public abstract partial class BaseJewel : Item, ICraftable { _maxHitPoints = reader.ReadEncodedInt(); _hitPoints = reader.ReadEncodedInt(); - _rawResource = (CraftResource)reader.ReadEncodedInt(); + _resource = (CraftResource)reader.ReadEncodedInt(); _gemType = (GemType)reader.ReadEncodedInt(); _attributes = new AosAttributes(this); _attributes.Deserialize(reader); diff --git a/Projects/UOContent/Items/Lights/BaseLight.cs b/Projects/UOContent/Items/Lights/BaseLight.cs index 7aa6742d4..3e8ec5c56 100644 --- a/Projects/UOContent/Items/Lights/BaseLight.cs +++ b/Projects/UOContent/Items/Lights/BaseLight.cs @@ -12,12 +12,6 @@ public abstract partial class BaseLight : Item [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private bool _burntOut; - // Field 1 - private bool _burning; - - // Field 2 - private TimeSpan _duration = TimeSpan.Zero; - [SerializableField(3)] [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private bool _protected; @@ -49,7 +43,7 @@ public abstract partial class BaseLight : Item public virtual int UnlitSound => 0x3be; public virtual int BurntOutSound => 0x4b8; - [SerializableField(1)] + [SerializableProperty(1)] [CommandProperty(AccessLevel.GameMaster)] public bool Burning { @@ -65,7 +59,7 @@ public abstract partial class BaseLight : Item } } - [SerializableField(2)] + [SerializableProperty(2)] [CommandProperty(AccessLevel.GameMaster)] public TimeSpan Duration { diff --git a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs index 2cf95b183..f81879b89 100644 --- a/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs +++ b/Projects/UOContent/Items/Skill Items/Tailor Items/Dyetubs/DyeTub.cs @@ -23,8 +23,6 @@ namespace Server.Items [SerializableFieldAttr("[CommandProperty(AccessLevel.GameMaster)]")] private bool _redyable; - private int _dyedHue; - [Constructible] public DyeTub() : base(0xFAB) { @@ -44,7 +42,7 @@ namespace Server.Items public virtual bool AllowDyables => true; - [SerializableField(2)] + [SerializableProperty(2)] [CommandProperty(AccessLevel.GameMaster)] public int DyedHue { diff --git a/Projects/UOContent/Migrations/Server.Accounting.Account.v4.json b/Projects/UOContent/Migrations/Server.Accounting.Account.v4.json index 887b06c08..07d1336c7 100644 --- a/Projects/UOContent/Migrations/Server.Accounting.Account.v4.json +++ b/Projects/UOContent/Migrations/Server.Accounting.Account.v4.json @@ -61,7 +61,7 @@ ] }, { - "name": "RawMobiles", + "name": "Mobiles", "type": "Server.Mobile[]", "rule": "ArrayMigrationRule", "ruleArguments": [ diff --git a/Projects/UOContent/Migrations/Server.Items.BaseAddon.v3.json b/Projects/UOContent/Migrations/Server.Items.BaseAddon.v3.json index a80bc2afc..edb8610a0 100644 --- a/Projects/UOContent/Migrations/Server.Items.BaseAddon.v3.json +++ b/Projects/UOContent/Migrations/Server.Items.BaseAddon.v3.json @@ -13,7 +13,7 @@ ] }, { - "name": "RawResource", + "name": "Resource", "type": "Server.Items.CraftResource", "rule": "EnumMigrationRule" } diff --git a/Projects/UOContent/Migrations/Server.Items.BaseAddonContainer.v2.json b/Projects/UOContent/Migrations/Server.Items.BaseAddonContainer.v2.json index 76a123257..9a9c284b3 100644 --- a/Projects/UOContent/Migrations/Server.Items.BaseAddonContainer.v2.json +++ b/Projects/UOContent/Migrations/Server.Items.BaseAddonContainer.v2.json @@ -13,7 +13,7 @@ ] }, { - "name": "RawResource", + "name": "Resource", "type": "Server.Items.CraftResource", "rule": "EnumMigrationRule" } diff --git a/Projects/UOContent/Migrations/Server.Items.BaseArmor.v9.json b/Projects/UOContent/Migrations/Server.Items.BaseArmor.v9.json index 2ea3ab105..4350bc6d6 100644 --- a/Projects/UOContent/Migrations/Server.Items.BaseArmor.v9.json +++ b/Projects/UOContent/Migrations/Server.Items.BaseArmor.v9.json @@ -120,7 +120,7 @@ "rule": "EnumMigrationRule" }, { - "name": "RawResource", + "name": "Resource", "type": "Server.Items.CraftResource", "usesSaveFlag": true, "rule": "EnumMigrationRule" diff --git a/Projects/UOContent/Migrations/Server.Items.BaseBeverage.v2.json b/Projects/UOContent/Migrations/Server.Items.BaseBeverage.v2.json index d47ccdf8d..ff0ae46f8 100644 --- a/Projects/UOContent/Migrations/Server.Items.BaseBeverage.v2.json +++ b/Projects/UOContent/Migrations/Server.Items.BaseBeverage.v2.json @@ -16,12 +16,12 @@ "rule": "SerializableInterfaceMigrationRule" }, { - "name": "RawContent", + "name": "Content", "type": "Server.Items.BeverageType", "rule": "EnumMigrationRule" }, { - "name": "RawQuantity", + "name": "Quantity", "type": "int", "rule": "PrimitiveTypeMigrationRule", "ruleArguments": [ diff --git a/Projects/UOContent/Migrations/Server.Items.BaseClothing.v7.json b/Projects/UOContent/Migrations/Server.Items.BaseClothing.v7.json index 0ea558c62..0e479af4b 100644 --- a/Projects/UOContent/Migrations/Server.Items.BaseClothing.v7.json +++ b/Projects/UOContent/Migrations/Server.Items.BaseClothing.v7.json @@ -3,7 +3,7 @@ "type": "Server.Items.BaseClothing", "properties": [ { - "name": "RawResource", + "name": "Resource", "type": "Server.Items.CraftResource", "usesSaveFlag": true, "rule": "EnumMigrationRule" diff --git a/Projects/UOContent/Migrations/Server.Items.BaseJewel.v4.json b/Projects/UOContent/Migrations/Server.Items.BaseJewel.v4.json index 6573d187d..8c9ae23a0 100644 --- a/Projects/UOContent/Migrations/Server.Items.BaseJewel.v4.json +++ b/Projects/UOContent/Migrations/Server.Items.BaseJewel.v4.json @@ -19,7 +19,7 @@ ] }, { - "name": "RawResource", + "name": "Resource", "type": "Server.Items.CraftResource", "rule": "EnumMigrationRule" }, diff --git a/Projects/UOContent/Migrations/Server.Items.DragonBardingDeed.v2.json b/Projects/UOContent/Migrations/Server.Items.DragonBardingDeed.v2.json index a6a26d015..b11c91682 100644 --- a/Projects/UOContent/Migrations/Server.Items.DragonBardingDeed.v2.json +++ b/Projects/UOContent/Migrations/Server.Items.DragonBardingDeed.v2.json @@ -19,7 +19,7 @@ ] }, { - "name": "RawResource", + "name": "Resource", "type": "Server.Items.CraftResource", "rule": "EnumMigrationRule" } diff --git a/Projects/UOContent/Migrations/Server.Items.FillableContainer.v2.json b/Projects/UOContent/Migrations/Server.Items.FillableContainer.v2.json index bb0c8c156..55f5d2a49 100644 --- a/Projects/UOContent/Migrations/Server.Items.FillableContainer.v2.json +++ b/Projects/UOContent/Migrations/Server.Items.FillableContainer.v2.json @@ -3,7 +3,7 @@ "type": "Server.Items.FillableContainer", "properties": [ { - "name": "RawContentType", + "name": "ContentType", "type": "Server.Items.FillableContentType", "rule": "EnumMigrationRule" }, diff --git a/Projects/UOContent/Migrations/Server.Items.LockableContainer.v0.json b/Projects/UOContent/Migrations/Server.Items.LockableContainer.v0.json index e9d8da768..56fbeedb0 100644 --- a/Projects/UOContent/Migrations/Server.Items.LockableContainer.v0.json +++ b/Projects/UOContent/Migrations/Server.Items.LockableContainer.v0.json @@ -51,7 +51,7 @@ ] }, { - "name": "RawLocked", + "name": "Locked", "type": "bool", "rule": "PrimitiveTypeMigrationRule", "ruleArguments": [ diff --git a/Projects/UOContent/Migrations/Server.Items.MarkContainer.v0.json b/Projects/UOContent/Migrations/Server.Items.MarkContainer.v0.json index 489250da4..f1b9197d5 100644 --- a/Projects/UOContent/Migrations/Server.Items.MarkContainer.v0.json +++ b/Projects/UOContent/Migrations/Server.Items.MarkContainer.v0.json @@ -3,7 +3,7 @@ "type": "Server.Items.MarkContainer", "properties": [ { - "name": "RawAutoLock", + "name": "AutoLock", "type": "bool", "rule": "PrimitiveTypeMigrationRule", "ruleArguments": [ diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj index bd101f145..72638cdb6 100755 --- a/Projects/UOContent/UOContent.csproj +++ b/Projects/UOContent/UOContent.csproj @@ -45,8 +45,8 @@ - - + + diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9820ec29a..476a53911 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -18,7 +18,7 @@ jobs: displayName: 'Install .NET 6' inputs: packageType: sdk - version: 6.0.300 + version: 6.0.400 - task: NuGetAuthenticate@0 - script: ./publish.cmd Release win displayName: 'Build' @@ -59,7 +59,7 @@ jobs: displayName: 'Install .NET 6' inputs: packageType: sdk - version: 6.0.300 + version: 6.0.400 - task: NuGetAuthenticate@0 - script: ./publish.cmd Release $(os) displayName: 'Build'