ModernUO/Projects/Server
Kamron Batman 312e3873f1
fix(core): Fixes encoded int. Adds dirty checking opt-out (#619)
### Additions
- Automatically opts-out `Item/Mobile/Guild/Accounts` from dirty checking with a new property `UseDirtyChecking`
- Codegen now enables `UseDirtyChecking` via getter. This requires that the property is `virtual` for derived types.

### Fixes
- Fixes `EncodedInt` being broken
- Fixes issues with new custom serializable types that are not derived from Item/Mobile/etc.
- Removes double dirty checking.

### Example of a brand new serializable type that isn't an Item/Mobile/etc.
User created code:
```cs
using System;

namespace Server.Items
{
    [Serializable(0)]
    public partial class NewTestEntityObject : ISerializable
    {
        [EncodedInt]
        [SerializableField(0)]
        private int _someProperty;

        public NewTestEntityObject()
        {
            SetTypeRef(GetType());
            // Add to serial tracking like World.Item
            /*
            Serial = World.NewEntity;
            World.AddEntity(this);
            */
        }

        [AfterDeserialization]
        private void AfterDeserialization()
        {
            Console.WriteLine("This ran!");
        }

        public int TypeRef { get; }
        public Serial Serial { get; }
        public void Delete()
        {
        }

        public bool Deleted { get; set; }
        public void SetTypeRef(Type type)
        {
            // Type tracking for persistence goes here
            /*
            TypeRef = World.NewEntityTypes.IndexOf(type);
            if (TypeRef == -1)
            {
                World.NewEntityTypes.Add(type);
                TypeRef = World.NewEntityTypes.Count - 1;
            }
            */
        }
    }
}
```

Generated code:
```cs
namespace Server.Items
{
    public partial class NewTestEntityObject
    {
#pragma warning disable 0414
        private const int _version = 0;
#pragma warning restore 0414

        public int SomeProperty
        {
            get => _someProperty;
            set
            {
                if (value != _someProperty)
                {
                    _someProperty = value;
                    ((ISerializable)this).MarkDirty();
                }
            }
        }

        long ISerializable.SavePosition { get; set; } = -1;
        BufferWriter ISerializable.SaveBuffer { get; set; }
        bool ISerializable.UseDirtyChecking => true;

        public NewTestEntityObject(Serial serial)
        {
            Serial = serial;
            SetTypeRef(typeof(NewTestEntityObject));
        }

        public void Serialize(IGenericWriter writer)
        {

            writer.WriteEncodedInt(_version);

            writer.WriteEncodedInt(SomeProperty);
        }

        public void Deserialize(IGenericReader reader)
        {
            var version = reader.ReadEncodedInt();

            SomeProperty = reader.ReadEncodedInt();

            Timer.DelayCall(AfterDeserialization);
        }
    }
}
```
2021-05-26 19:25:05 -07:00
..
Buffers fix(core): Updates to serialization (#590) 2021-05-09 00:10:39 -07:00
Collections fix(core): Fixes nullables being disabled (#466) 2021-02-05 14:09:57 -08:00
Comparers Splits up mobile (#296) 2020-10-31 23:30:51 -07:00
Configuration feat(logging): Adds support for Serilog (#573) 2021-04-19 23:43:54 -07:00
ContextMenus fix(core): Removes some uses of Linq (#421) 2021-01-18 21:05:11 -08:00
Diagnostics fix(core): Tightens the network stack (#479) 2021-02-07 23:30:56 -08:00
Events fix(core): Fixes flow for saves, adds logging and configurations (#513) 2021-02-20 19:32:08 -08:00
Exceptions fix(core): Changes invalid gump response to write to network errors. (#510) 2021-02-15 08:31:53 -08:00
Geometry chore: Code cleanup (#399) 2021-01-10 09:14:03 -08:00
Gumps fix(core): Changes invalid gump response to write to network errors. (#510) 2021-02-15 08:31:53 -08:00
Items fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
Json feat: Source generated Serialization/Deserialization (#550) 2021-05-23 21:06:23 -07:00
Logging feat(logging): Adds support for Serilog (#573) 2021-04-19 23:43:54 -07:00
Maps chore(logging): Logging cleanup (#580) 2021-04-23 18:57:42 -07:00
Menus Updates menu packets (#320) 2020-11-17 21:47:00 -08:00
Mobiles fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
Network Fixes awaiting seed for < v6 clients (#589) 2021-05-05 11:47:54 -07:00
Random fix(core): Changes random source to use debut assert (#603) 2021-05-15 20:15:22 -07:00
Regions feat(logging): Adds support for Serilog (#573) 2021-04-19 23:43:54 -07:00
Serialization fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
Targeting fix(core): Caches DateTime.NowUtc (#548) 2021-03-13 01:32:04 -08:00
Text fix(core): Updates to serialization (#590) 2021-05-09 00:10:39 -07:00
TileMatrix chore(logging): Logging cleanup (#580) 2021-04-23 18:57:42 -07:00
Timer fix(core): Handles a rare NPE with LoginTimer (#508) 2021-02-11 23:47:02 -08:00
Utilities fix(core): Updates to serialization (#590) 2021-05-09 00:10:39 -07:00
World fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
AssemblyHandler.cs fix(content): Fixes duplicate alias type (#588) 2021-04-30 00:59:53 -07:00
Attributes.cs fix(core): Fixes some properties that cannot be modified ingame (#604) 2021-05-15 23:47:33 -07:00
CityInfo.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00
ClientVersion.cs fix(core): Updates slice with range selectors (#583) 2021-04-23 20:57:24 -07:00
Commands.cs fix(core): Updates slice with range selectors (#583) 2021-04-23 20:57:24 -07:00
Effects.cs fix(core): Cleans up uninitialized packets (#397) 2021-01-09 14:10:29 -08:00
EventLoopTasks.cs fix(core): Core cleanup, adds event loop synchronization, and fixes gumps (#429) 2021-01-25 21:06:46 -08:00
ExpansionInfo.cs fix(core): Fixes map issues at New Haven (#509) 2021-02-14 16:06:49 -08:00
Guild.cs fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
HuePicker.cs fix(core): Converts remaining player packets (#374) 2020-12-30 16:09:51 -08:00
IAccount.cs fix(core): Updates expansion and map configurations (fixes map issues) (#570) 2021-04-14 01:45:18 -07:00
IEntity.cs fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
Interfaces.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00
KeywordList.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00
Main.cs fix(core): Cleans up serialization (#606) 2021-05-16 13:45:32 -07:00
MultiData.cs fix(core): Moves map definitions and cleans up loading maps, regions, and tiles (#431) 2021-01-25 11:05:52 -08:00
MUO.ico Adds MUO Logo (#52) 2019-09-12 13:13:13 -07:00
NativeReader.cs fix(core): Fixes map issues at New Haven (#509) 2021-02-14 16:06:49 -08:00
ObjectPropertyList.cs fix(core): Fixes OPL packets (#395) 2021-01-08 23:55:23 -08:00
Party.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00
Poison.cs C# 9 Cleanup (#325) 2020-11-27 00:29:21 -08:00
Prompt.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00
Race.cs fix(core): Optimizes strings / .NET 5 compatibility changes (#354) 2020-12-20 23:21:55 -08:00
Sector.cs fix(core): Adds SkipLocalsInitAttribute support, optimizes broadcasted packets (#363) 2020-12-26 12:46:06 -08:00
SecureTrade.cs fix(core): Converts mobile status packets (#368) 2020-12-28 01:13:02 -08:00
Serial.cs fix(core): Reverts change to Serial.IsValid (#596) 2021-05-12 09:59:03 -07:00
Server.csproj feat: Source generated Serialization/Deserialization (#550) 2021-05-23 21:06:23 -07:00
Skills.cs fix(core): Fixes some properties that cannot be modified ingame (#604) 2021-05-15 23:47:33 -07:00
TileData.cs fix(core): Cleans up serialization (#606) 2021-05-16 13:45:32 -07:00
TileList.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00
VirtueInfo.cs Cleanup/Housekeeping (#242) 2020-09-12 15:31:21 -07:00