Skip to content

Commit

Permalink
Prevent error when trying to customize party with no banner,
Browse files Browse the repository at this point in the history
or when customizing same banner multiple times.
  • Loading branch information
Byak0 committed Sep 21, 2022
1 parent 91b9a39 commit 00d5efd
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions source/EnhancedBattleTest/src/SinglePlayer/BattleStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,23 @@ private static MissionInitializerRecord CreateMissionInitializerRecord(BattleCon
private static PartyBase CreateParty(TeamConfig teamConfig, bool isPlayerSide, int index = 0)
{
PartyBase party = MobileParty.CreateParty("EnhancedBattleTestParty",
new EnhancedBattleTestPartyComponent(GetPartyName(isPlayerSide, index), teamConfig)).Party;
new EnhancedBattleTestPartyComponent(GetPartyName(isPlayerSide, index), teamConfig)).Party;
TryOverridePartyBanner(party, teamConfig);
return party;
}

private static void TryOverridePartyBanner(PartyBase party, TeamConfig config)
{
if (config.CustomBanner)
if (config.CustomBanner && party.Banner != null && !_bannerSave.ContainsKey(party.Banner))
{
_bannerSave.Add(party.Banner, party.Banner.Serialize());
party.Banner.Deserialize(config.BannerKey);
party.Banner.Deserialize(config.BannerKey);
}
}

private static void TryRecoverPartyBanner(PartyBase party)
{
if (_bannerSave.IsEmpty()) return;
if (_bannerSave.TryGetValue(party.Banner, out var bannerValue))
if (party.Banner != null && _bannerSave.TryGetValue(party.Banner, out var bannerValue))
{
party.Banner.Deserialize(bannerValue);
_bannerSave.Remove(party.Banner);
Expand Down Expand Up @@ -450,7 +449,7 @@ public static void RecoverHeroes()
case MemberState.Prisoner:
if (pair.Value.Key.MobileParty.PrisonRoster.Contains(pair.Key.CharacterObject))
continue;
pair.Value.Key.AddPrisoner(pair.Key.CharacterObject, 1);
pair.Value.Key.AddPrisoner(pair.Key.CharacterObject, 1);
break;
case MemberState.Original:
if (pair.Value.Key.MobileParty.MemberRoster.Contains(pair.Key.CharacterObject))
Expand Down

0 comments on commit 00d5efd

Please sign in to comment.