Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TroopRoster Null Data Fix #1029

Merged
merged 2 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -81,6 +83,7 @@ public void Hero_Full_Serialization()
var objectManager = container.Resolve<IObjectManager>();
HeroFactory.RandomHeroWithData heroData = HeroFactory.CreateRandomHero(objectManager);
Hero hero = heroData.Hero;


// Setup serialization
var factory = container.Resolve<IBinaryPackageFactory>();
Expand Down Expand Up @@ -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<PartyBase>();
HeroParty.Party.MemberRoster = new TroopRoster();
HeroParty.Party.PrisonRoster = new TroopRoster();

objectManager.AddExisting(HeroParty.StringId, HeroParty);

PartyBelongedToAsPrisoner = (PartyBase)FormatterServices.GetUninitializedObject(typeof(PartyBase));
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Roster;
using TaleWorlds.Library;

namespace GameInterface.Serialization.External
{
Expand Down Expand Up @@ -37,6 +38,9 @@ protected override void UnpackInternal()
{
Object.NumberChangedCallback = Object.OwnerParty.MemberRosterNumberChanged;
}

Object._troopRosterElements = new MBList<TroopRosterElement>();
Object.VersionNo = -1;
}
}
}