From 0e79a3d3c4f61254b02aaff606819abbf4c960db Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Tue, 23 Feb 2021 09:35:07 -0800 Subject: [PATCH] fix(core): Fixes guild serialization (#517) --- Projects/Server/Guild.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Projects/Server/Guild.cs b/Projects/Server/Guild.cs index a93d0b745..daa22153f 100644 --- a/Projects/Server/Guild.cs +++ b/Projects/Server/Guild.cs @@ -14,13 +14,30 @@ namespace Server.Guilds protected BaseGuild(Serial serial) { Serial = serial; - World.AddGuild(this); + + var ourType = GetType(); + TypeRef = World.GuildTypes.IndexOf(ourType); + + if (TypeRef == -1) + { + World.GuildTypes.Add(ourType); + TypeRef = World.GuildTypes.Count - 1; + } } protected BaseGuild() { Serial = World.NewGuild; World.AddGuild(this); + + var ourType = GetType(); + TypeRef = World.GuildTypes.IndexOf(ourType); + + if (TypeRef == -1) + { + World.GuildTypes.Add(ourType); + TypeRef = World.GuildTypes.Count - 1; + } } public abstract string Abbreviation { get; set; } @@ -36,7 +53,7 @@ namespace Server.Guilds BufferWriter ISerializable.SaveBuffer { get; set; } - public int TypeRef => 0; + public int TypeRef { get; } public abstract void Serialize(IGenericWriter writer); public abstract void Deserialize(IGenericReader reader);