ModernUO/Projects/UOContent/Accounting
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
..
Security fix(core): Fixes issues with deserialization due to bad checking of dirty tracking (#618) 2021-05-26 13:47:04 -07:00
AccessRestrictions.cs fix(core): Fixes issues with deserialization due to bad checking of dirty tracking (#618) 2021-05-26 13:47:04 -07:00
Account.cs fix(core): Fixes encoded int. Adds dirty checking opt-out (#619) 2021-05-26 19:25:05 -07:00
AccountAttackLimiter.cs fix(core): Caches DateTime.NowUtc (#548) 2021-03-13 01:32:04 -08:00
AccountComment.cs fix(core): Caches DateTime.NowUtc (#548) 2021-03-13 01:32:04 -08:00
AccountHandler.cs fix(core): Fixes issues with deserialization due to bad checking of dirty tracking (#618) 2021-05-26 13:47:04 -07:00
Accounts.cs chore(logging): Migrate some logs to ILogger (#582) 2021-04-22 08:45:49 -07:00
AccountTag.cs fix(serialization): Updates serialization flow & fixes serializing accounts (#521) 2021-02-24 22:14:15 -08:00
Firewall.cs fix(network): Converts House Design Detailed Packet (#538) 2021-03-03 02:09:15 -08:00
IPasswordProtection.cs Formats UO Content (#201) 2020-08-27 18:30:38 -07:00
IPLimiter.cs feat(spawners): Adds Respawn, EditSpawner, and SpawnProps commands (#532) 2021-02-28 22:49:52 -08:00