Skip to content

Commit

Permalink
Fix for crash during air battle (#12772)
Browse files Browse the repository at this point in the history
Problem: 'oldUnits' is stateful and may already contain units.
We then "double add" a unit in the following code block

(RemoveUnitsHistoryChange.java:71)

```
    final Collection<Unit> allUnloadedUnits = new HashSet<>();
    for (Unit u : killedUnits) {
      oldUnits.add(u);
```

To resolve this issue, the 'oldUnits' and 'killedUnits' is converted
into a set, which removes duplicate units. (This 'fix' is not very deep,
arguably this is a hack. Why is the duplicate unit being added in the first
place?)

Resolves: #12770
  • Loading branch information
DanVanAtta authored Jul 25, 2024
1 parent d9e67ea commit 8f856ad
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public class RemoveUnitsHistoryChange implements HistoryChange {
String messageTemplate;

/** Units that were killed */
Collection<Unit> oldUnits = new ArrayList<>();
Collection<Unit> oldUnits = new HashSet<>();

/** The units that were created after a transformation */
Collection<Unit> newUnits = new ArrayList<>();
Collection<Unit> newUnits = new HashSet<>();

/**
* @param messageTemplate ${units} and ${territory} will be replaced in this template
Expand Down

0 comments on commit 8f856ad

Please sign in to comment.