Skip to content

Commit

Permalink
Fix for Concurrent Modification exceptions in Precognition
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Jul 18, 2024
1 parent 587df46 commit d0ac9a0
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions megamek/src/megamek/common/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -1650,17 +1650,29 @@ public Hashtable<Coords, Collection<SpecialHexDisplay>> getSpecialHexDisplayTabl
}

public void setSpecialHexDisplayTable(Hashtable<Coords, Collection<SpecialHexDisplay>> shd) {
Hashtable<Coords, Collection<SpecialHexDisplay>> temp = new Hashtable<>();
for (Map.Entry<Coords, Collection<SpecialHexDisplay>> e: specialHexes.entrySet()) {
for (SpecialHexDisplay special: e.getValue()) {
if (special.getType() == SpecialHexDisplay.Type.ARTILLERY_MISS) {
if (!shd.containsKey(e.getKey())) {
shd.put(e.getKey(), new LinkedList<>());
if (!temp.containsKey(e.getKey())) {
temp.put(e.getKey(), new LinkedList<>());
}
shd.get(e.getKey()).add(special);
temp.get(e.getKey()).add(special);
}
}
}
// Swap new Hashtable in for old
specialHexes = shd;

// Add miss instances back
for (Map.Entry<Coords, Collection<SpecialHexDisplay>> e: temp.entrySet()) {
for(SpecialHexDisplay miss: e.getValue()) {
if (!specialHexes.containsKey(e.getKey())) {
specialHexes.put(e.getKey(), new LinkedList<>());
}
specialHexes.get(e.getKey()).add(miss);
}
}
}

public void setType(int t) {
Expand Down

0 comments on commit d0ac9a0

Please sign in to comment.