fix(core): Fixes several serialization issues (#355)

- [X] Fixes an issue where a buffer smaller than 8 bytes would not double with enough space in some cases.
- [X] Fixes an issue with dupe copying the savebuffer reference (ugh).
- [X] Streamlines the IGenericWriter API to use better generics.
- [X] Streamlines the IGenericReader API to use better generics.
- [X] Forces `tidying` of a List/HashSet to be done externally since Writers/Readers should not have side effects.
- [X] Fixes an issue where Tidying a list didn't TrimExcess, causing memory leaks.
- [X] Reverted the meaning of `World.Running` to specifically refer to any world state post world loading.
  - NOTE: Do not use this if you want to block on world saves. Instead use checks against `WorldState.Saving` states.
- [X] Fixes an issue with serializing negative DateTime deltas.
- [X] Fixes a potential issue with serializing non-UTC DateTime.

Bumps release version
This commit is contained in:
Kamron Batman 2020-12-23 07:11:41 -08:00 • committed by GitHub
parent 0888ab9b86
commit 4ddb3de026
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
162 changed files with 652 additions and 1045 deletions

View file

@ -2567,20 +2567,13 @@ namespace Server
AddNameProperties(list);
}
public BufferWriter SaveBuffer { get; set; }
BufferWriter ISerializable.SaveBuffer { get; set; }
[CommandProperty(AccessLevel.Counselor)]
public Serial Serial { get; }
public int TypeRef { get; }
public void Serialize()
{
SaveBuffer ??= new BufferWriter(true);
SaveBuffer.Reset();
Serialize(SaveBuffer);
}
public virtual void Serialize(IGenericWriter writer)
{
// The item is clean, so let's skip
@ -2628,7 +2621,8 @@ namespace Server
writer.Write(CreationTime);
writer.Write(Stabled, true);
Stabled.Tidy();
writer.Write(Stabled);
writer.Write(CantWalk);
@ -6393,7 +6387,7 @@ namespace Server
case 25:
case 24:
{
Corpse = reader.ReadItem() as Container;
Corpse = reader.ReadEntity<Container>();
goto case 23;
}
@ -6406,7 +6400,7 @@ namespace Server
case 22: // Just removed followers
case 21:
{
Stabled = reader.ReadStrongMobileList();
Stabled = reader.ReadEntityList<Mobile>();
goto case 20;
}
@ -6461,13 +6455,13 @@ namespace Server
}
case 13:
{
GuildFealty = reader.ReadMobile();
GuildFealty = reader.ReadEntity<Mobile>();
goto case 12;
}
case 12:
{
m_Guild = reader.ReadGuild();
m_Guild = reader.ReadEntity<BaseGuild>();
goto case 11;
}
@ -6491,7 +6485,7 @@ namespace Server
}
case 8:
{
m_Holding = reader.ReadItem();
m_Holding = reader.ReadEntity<Item>();
goto case 7;
}
@ -6599,7 +6593,7 @@ namespace Server
Skills = new Skills(this, reader);
Items = reader.ReadStrongItemList();
Items = reader.ReadEntityList<Item>();
m_Player = reader.ReadBool();
m_Title = reader.ReadString();