From c20e42a197e294ce48ce29e9f4d2a6f17f9367a2 Mon Sep 17 00:00:00 2001 From: Lkoinw Date: Fri, 23 Sep 2022 20:43:26 +0200 Subject: [PATCH] Fix duplicated heroes without corrupting save. --- .../src/SinglePlayer/BattleStarter.cs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/EnhancedBattleTest/src/SinglePlayer/BattleStarter.cs b/source/EnhancedBattleTest/src/SinglePlayer/BattleStarter.cs index 831901c..b202899 100644 --- a/source/EnhancedBattleTest/src/SinglePlayer/BattleStarter.cs +++ b/source/EnhancedBattleTest/src/SinglePlayer/BattleStarter.cs @@ -440,20 +440,25 @@ public static void RecoverHeroes() switch (pair.Value.Value) { case MemberState.Leader: - if (!pair.Value.Key.MobileParty.MemberRoster.Contains(pair.Key.CharacterObject)) - { - pair.Value.Key.AddElementToMemberRoster(pair.Key.CharacterObject, 1); - } + if (pair.Key.PartyBelongedTo?.Party == pair.Value.Key) + continue; + if (pair.Value.Key.MobileParty.MemberRoster.Contains(pair.Key.CharacterObject)) + pair.Value.Key.AddElementToMemberRoster(pair.Key.CharacterObject, -1); + pair.Value.Key.AddElementToMemberRoster(pair.Key.CharacterObject, 1, true); pair.Value.Key.MobileParty.ChangePartyLeader(pair.Key); break; case MemberState.Prisoner: - if (pair.Value.Key.MobileParty.PrisonRoster.Contains(pair.Key.CharacterObject)) + if (pair.Key.PartyBelongedToAsPrisoner == pair.Value.Key) continue; - pair.Value.Key.AddPrisoner(pair.Key.CharacterObject, 1); + if (pair.Value.Key.MobileParty.PrisonRoster.Contains(pair.Key.CharacterObject)) + 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)) + if (pair.Key.PartyBelongedTo?.Party == pair.Value.Key) continue; + if (pair.Value.Key.MobileParty.MemberRoster.Contains(pair.Key.CharacterObject)) + pair.Value.Key.AddElementToMemberRoster(pair.Key.CharacterObject, -1); pair.Value.Key.AddElementToMemberRoster(pair.Key.CharacterObject, 1); break; }