Solved a concurrent modification bug, a second before publish

This commit is contained in:
Yair Morgenstern 2020-04-21 20:34:02 +03:00
parent 700b1afb34
commit 0321aed309

View File

@ -255,7 +255,9 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
unit.removeFromTile()
unit.putInTile(destination)
for (payload in origin.getUnits().filter { it.isTransported }) { // bring along the payloads
// The .toList() here is because we have a sequence that's running on the units in the tile,
// then if we move one of the units we'll get a ConcurrentModificationException, se we save them all to a list
for (payload in origin.getUnits().filter { it.isTransported }.toList()) { // bring along the payloads
if (unit.canTransport(payload)) {
payload.removeFromTile()
payload.putInTile(destination)