diff --git a/source/GameInterface.Tests/Serialization/SerializerTests/HeroSerializationTest.cs b/source/GameInterface.Tests/Serialization/SerializerTests/HeroSerializationTest.cs index fb8e11e98..da2f64f54 100644 --- a/source/GameInterface.Tests/Serialization/SerializerTests/HeroSerializationTest.cs +++ b/source/GameInterface.Tests/Serialization/SerializerTests/HeroSerializationTest.cs @@ -23,6 +23,8 @@ using Xunit.Abstractions; using Common.Serialization; using TaleWorlds.CampaignSystem.Actions; +using Common.Util; +using TaleWorlds.CampaignSystem.Roster; namespace GameInterface.Tests.Serialization.SerializerTests { @@ -81,6 +83,7 @@ public void Hero_Full_Serialization() var objectManager = container.Resolve(); HeroFactory.RandomHeroWithData heroData = HeroFactory.CreateRandomHero(objectManager); Hero hero = heroData.Hero; + // Setup serialization var factory = container.Resolve(); @@ -347,6 +350,11 @@ private void CreateParty() HeroParty = (MobileParty)FormatterServices.GetUninitializedObject(typeof(MobileParty)); HeroParty.StringId = "My Party"; HeroParty.SetCustomName(new TextObject("My Party")); + + HeroParty.Party = ObjectHelper.SkipConstructor(); + HeroParty.Party.MemberRoster = new TroopRoster(); + HeroParty.Party.PrisonRoster = new TroopRoster(); + objectManager.AddExisting(HeroParty.StringId, HeroParty); PartyBelongedToAsPrisoner = (PartyBase)FormatterServices.GetUninitializedObject(typeof(PartyBase)); @@ -357,6 +365,7 @@ private void CreateCharacterObject() CharacterObject = (CharacterObject)FormatterServices.GetUninitializedObject(typeof(CharacterObject)); CharacterObject.StringId = "My CharacterObject"; CharacterObject._basicName = new TextObject("My CharacterObject"); + CharacterObject.UpgradeTargets = new CharacterObject[0]; objectManager.AddExisting(CharacterObject.StringId, CharacterObject); } diff --git a/source/GameInterface/Serialization/External/TroopRosterBinaryPackage.cs b/source/GameInterface/Serialization/External/TroopRosterBinaryPackage.cs index 14a3ef0fc..e6215441d 100644 --- a/source/GameInterface/Serialization/External/TroopRosterBinaryPackage.cs +++ b/source/GameInterface/Serialization/External/TroopRosterBinaryPackage.cs @@ -4,6 +4,7 @@ using System.Reflection; using TaleWorlds.CampaignSystem.Party; using TaleWorlds.CampaignSystem.Roster; +using TaleWorlds.Library; namespace GameInterface.Serialization.External { @@ -37,6 +38,9 @@ protected override void UnpackInternal() { Object.NumberChangedCallback = Object.OwnerParty.MemberRosterNumberChanged; } + + Object._troopRosterElements = new MBList(); + Object.VersionNo = -1; } } }