diff --git a/Projects/Server/Server.csproj b/Projects/Server/Server.csproj index ee06c9fec..5983ad7a1 100755 --- a/Projects/Server/Server.csproj +++ b/Projects/Server/Server.csproj @@ -38,7 +38,7 @@ - + diff --git a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs index 6170f2929..d13a1bda1 100644 --- a/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs +++ b/Projects/UOContent/Engines/Factions/Mobiles/Guards/GuardAI.cs @@ -624,7 +624,7 @@ namespace Server.Factions { spell = new RecallSpell( m_Guard, - new RunebookEntry(m_Guard.Home, m_Guard.Map, "Guard's Home") + new RunebookEntry(null, m_Guard.Home, m_Guard.Map, "Guard's Home") ); } else if (IsAllowed(GuardAI.Bless)) diff --git a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs index 8fb451267..856aa774c 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Runebook.cs @@ -129,7 +129,9 @@ public partial class Runebook : Item, ISecurable, ICraftable for (var i = 0; i < count; ++i) { - Entries.Add(new RunebookEntry(reader)); + var entry = new RunebookEntry(this); + entry.Deserialize(reader); + Entries.Add(entry); } _description = reader.ReadString(); @@ -285,7 +287,7 @@ public partial class Runebook : Item, ISecurable, ICraftable { var entry = Entries[i]; - book.Entries.Add(new RunebookEntry(entry.Location, entry.Map, entry.Description, entry.House)); + book.Entries.Add(new RunebookEntry(this, entry.Location, entry.Map, entry.Description, entry.House)); } } @@ -326,7 +328,7 @@ public partial class Runebook : Item, ISecurable, ICraftable if (rune.Marked && rune.TargetMap != null) { - Entries.Add(new RunebookEntry(rune.Target, rune.TargetMap, rune.Description, rune.House)); + Entries.Add(new RunebookEntry(this, rune.Target, rune.TargetMap, rune.Description, rune.House)); rune.Delete(); @@ -370,60 +372,67 @@ public partial class Runebook : Item, ISecurable, ICraftable } } -[ManualDirtyChecking] -public class RunebookEntry +[SerializationGenerator(2)] +public partial class RunebookEntry { - public RunebookEntry(Point3D loc, Map map, string description, BaseHouse house = null) + [CanBeNull] + [DirtyTrackingEntity] + private Runebook _runebook; + + [SerializableField(0)] + private BaseHouse _house; + + [SerializableFieldSaveFlag(0)] + public bool ShouldSerializeHouse() => _house?.Deleted == false; + + [SerializableField(1)] + private Point3D _location; + + [SerializableFieldSaveFlag(1)] + public bool ShouldSerializeLocation() => _house?.Deleted != false; + + [SerializableField(2)] + private Map _map; + + [SerializableFieldSaveFlag(2)] + public bool ShouldSerializeMap() => _house?.Deleted != false; + + [SerializableField(3)] + private string _description; + + [SerializableFieldSaveFlag(3)] + public bool ShouldSerializeDesc() => _house?.Deleted != false; + + public RunebookEntry(Runebook runebook) : this(runebook, new Point3D(), null, null) { - Location = loc; - Map = map; - Description = description; - House = house; } - public RunebookEntry(IGenericReader reader) + public RunebookEntry(Runebook runebook, Point3D loc, Map map, string description, BaseHouse house = null) + { + _runebook = runebook; + _house = house; + _location = loc; + _map = map; + _description = description; + } + + private void Deserialize(IGenericReader reader, int version) { - var version = reader.ReadByte(); switch (version) { case 1: { - House = reader.ReadEntity(); + _house = reader.ReadEntity(); goto case 0; } case 0: { - Location = reader.ReadPoint3D(); - Map = reader.ReadMap(); - Description = reader.ReadString(); + _location = reader.ReadPoint3D(); + _map = reader.ReadMap(); + _description = reader.ReadString(); break; } } } - - public void Serialize(IGenericWriter writer) - { - if (House?.Deleted == false) - { - writer.Write((byte)1); // version - writer.Write(House); - } - else - { - writer.Write((byte)0); // version - } - - writer.Write(Location); - writer.Write(Map); - writer.Write(Description); - } - - public BaseHouse House { get; } - - public Point3D Location { get; } - - public Map Map { get; } - - public string Description { get; } } diff --git a/Projects/UOContent/Migrations/Server.Items.Runebook.v4.json b/Projects/UOContent/Migrations/Server.Items.Runebook.v4.json index 1104edda0..b0240733e 100644 --- a/Projects/UOContent/Migrations/Server.Items.Runebook.v4.json +++ b/Projects/UOContent/Migrations/Server.Items.Runebook.v4.json @@ -26,8 +26,8 @@ "rule": "ListMigrationRule", "ruleArguments": [ "Server.Items.RunebookEntry", - "SerializationMethodSignatureMigrationRule", - "" + "RawSerializableMigrationRule", + "DeserializationRequiresParent" ] }, { diff --git a/Projects/UOContent/Migrations/Server.Items.RunebookEntry.v2.json b/Projects/UOContent/Migrations/Server.Items.RunebookEntry.v2.json index 59e090936..861bdde09 100644 --- a/Projects/UOContent/Migrations/Server.Items.RunebookEntry.v2.json +++ b/Projects/UOContent/Migrations/Server.Items.RunebookEntry.v2.json @@ -5,11 +5,13 @@ { "name": "House", "type": "Server.Multis.BaseHouse", + "usesSaveFlag": true, "rule": "SerializableInterfaceMigrationRule" }, { "name": "Location", "type": "Server.Point3D", + "usesSaveFlag": true, "rule": "PrimitiveUOTypeMigrationRule", "ruleArguments": [ "Point3D" @@ -18,6 +20,7 @@ { "name": "Map", "type": "Server.Map", + "usesSaveFlag": true, "rule": "PrimitiveUOTypeMigrationRule", "ruleArguments": [ "Map" @@ -26,6 +29,7 @@ { "name": "Description", "type": "string", + "usesSaveFlag": true, "rule": "PrimitiveTypeMigrationRule", "ruleArguments": [ "" diff --git a/Projects/UOContent/Migrations/Server.Mobiles.BaseMount.v1.json b/Projects/UOContent/Migrations/Server.Mobiles.BaseMount.v1.json deleted file mode 100644 index 4e5aa4da6..000000000 --- a/Projects/UOContent/Migrations/Server.Mobiles.BaseMount.v1.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "version": 1, - "type": "Server.Mobiles.BaseMount", - "properties": [ - { - "name": "NextMountAbility", - "type": "System.DateTime", - "rule": "PrimitiveTypeMigrationRule", - "ruleArguments": [ - "" - ] - }, - { - "name": "Rider", - "type": "Server.Mobile", - "rule": "SerializableInterfaceMigrationRule" - }, - { - "name": "InternalItem", - "type": "Server.Item", - "rule": "SerializableInterfaceMigrationRule" - } - ] -} \ No newline at end of file diff --git a/Projects/UOContent/Migrations/Server.Mobiles.SkeletalMount.v1.json b/Projects/UOContent/Migrations/Server.Mobiles.SkeletalMount.v1.json deleted file mode 100644 index f1da97ad9..000000000 --- a/Projects/UOContent/Migrations/Server.Mobiles.SkeletalMount.v1.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "version": 1, - "type": "Server.Mobiles.SkeletalMount" -} \ No newline at end of file diff --git a/Projects/UOContent/UOContent.csproj b/Projects/UOContent/UOContent.csproj index 2d570e7de..5854f9e76 100755 --- a/Projects/UOContent/UOContent.csproj +++ b/Projects/UOContent/UOContent.csproj @@ -39,7 +39,7 @@ - +