Skip to content

Commit

Permalink
Fix duplicated heroes without corrupting save.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byak0 committed Sep 23, 2022
1 parent 00d5efd commit c20e42a
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions source/EnhancedBattleTest/src/SinglePlayer/BattleStarter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit c20e42a

Please sign in to comment.