Updates Serialization (#292)

- [X] Removes all save strategies
- [X] Removes duplicate file writer that won't be used
- [X] Removes persistence (it will become a duplicate system)
- [X] Add a save position variable to skip serializing a clean item/mobile
- [X] Update Guilds/Accounts to be IEntity types
    - Because guilds are abstract, this may make serialization tricky.
- [X] Update the generalized IEntity writing
- [X] Update the load/save to write to buffers then to files in background


Bumps release version
This commit is contained in:
Kamron Batman 2020-10-31 17:38:29 -07:00 • committed by GitHub
parent a8d486a969
commit 1ca8655fc1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 1148 additions and 4351 deletions

View file

@ -69,12 +69,9 @@ namespace Server.Accounting
}
}
public static void Save(bool message)
public static void Save()
{
if (!Directory.Exists("Saves/Accounts"))
{
Directory.CreateDirectory("Saves/Accounts");
}
AssemblyHandler.EnsureDirectory("Saves/Accounts");
var filePath = Path.Combine("Saves/Accounts", "accounts.xml");

View file

@ -405,7 +405,7 @@ namespace Server.Engines.Plants
GrowAll();
}
private static void EventSink_WorldSave(bool message)
private static void EventSink_WorldSave()
{
GrowAll();
}

View file

@ -26,7 +26,7 @@ namespace Server.Guilds
"",
0,
GuildDisplayType.All,
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(BaseGuild.List.Values)),
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(World.Guilds.Values)),
1063136 + (int)GuildDisplayType.All
)
{
@ -44,7 +44,7 @@ namespace Server.Guilds
filter,
startNumber,
display,
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(BaseGuild.List.Values)),
Utility.CastListCovariant<BaseGuild, Guild>(new List<BaseGuild>(World.Guilds.Values)),
1063136 + (int)display
)
{

View file

@ -101,7 +101,7 @@ namespace Server.Items
}
else
{
throw new Exception(World.LoadingType);
throw new Exception("Invalid beverage type");
}
break;
@ -380,7 +380,7 @@ namespace Server.Items
}
else
{
throw new Exception(World.LoadingType);
throw new Exception("Invalid beverage type");
}
break;
@ -550,7 +550,7 @@ namespace Server.Items
}
else
{
throw new Exception(World.LoadingType);
throw new Exception("Invalid beverage type");
}
break;
@ -1106,7 +1106,7 @@ namespace Server.Items
writer.Write(m_Quantity);
}
protected bool CheckType(string name) => World.LoadingType == $"Server.Items.{name}";
protected bool CheckType(string name) => GetType().FullName == $"Server.Items.{name}";
public override void Deserialize(IGenericReader reader)
{

View file

@ -106,7 +106,7 @@ namespace Server.Misc
Console.WriteLine("WARNING: Automatic backup FAILED: {0}", e);
}
World.Save(true, permitBackgroundWrite);
World.Save();
}
private static void Backup()

View file

@ -575,7 +575,7 @@ namespace Server.Guilds
protected override void OnTick()
{
foreach (var g in BaseGuild.List.Values)
foreach (var g in World.Guilds.Values)
{
(g as Guild)?.CheckExpiredWars();
}
@ -632,7 +632,7 @@ namespace Server.Guilds
PendingWars = new List<WarDeclaration>();
}
public Guild(uint id) : base(id) // serialization ctor
public Guild(Serial serial) : base(serial)
{
}
@ -815,7 +815,6 @@ namespace Server.Guilds
public static void Configure()
{
EventSink.CreateGuild += EventSink_CreateGuild;
EventSink.GuildGumpRequest += EventSink_GuildGumpRequest;
CommandSystem.Register("GuildProps", AccessLevel.Counselor, GuildProps_OnCommand);
@ -885,7 +884,7 @@ namespace Server.Guilds
{
m_Leader = null;
List.Remove(Serial);
World.RemoveGuild(this);
foreach (var m in Members)
{
@ -945,7 +944,7 @@ namespace Server.Guilds
else
{
var g = uint.TryParse(arg, out var id)
? Find(id) as Guild
? World.FindGuild(id) as Guild
: FindByAbbrev(arg) as Guild ?? FindByName(arg) as Guild;
if (g != null)
@ -977,11 +976,6 @@ namespace Server.Guilds
}
}
public static void EventSink_CreateGuild(CreateGuildEventArgs args)
{
args.Guild = new Guild(args.Id);
}
public static Guild GetAllianceLeader(Guild g)
{
var alliance = g.Alliance;
@ -1234,6 +1228,11 @@ namespace Server.Guilds
writer.Write(Website);
}
public override void Delete()
{
World.RemoveGuild(this);
}
public override void Deserialize(IGenericReader reader)
{
var version = reader.ReadInt();

View file

@ -1986,7 +1986,7 @@ namespace Server.Multis
EventSink.WorldSave += EventSink_WorldSave;
}
private static void EventSink_WorldSave(bool message)
private static void EventSink_WorldSave()
{
new UpdateAllTimer().Start();
}