From 849f33f2da34a7d81fee0b1d377472ea7b37745f Mon Sep 17 00:00:00 2001 From: asvitkine Date: Sat, 22 Jul 2023 07:15:59 -0400 Subject: [PATCH] Fix battle calc current player selection in history mode. (#11803) This is a corrected version of the change done in https://github.com/triplea-game/triplea/pull/10759. --- .../java/games/strategy/engine/history/History.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/game-app/game-core/src/main/java/games/strategy/engine/history/History.java b/game-app/game-core/src/main/java/games/strategy/engine/history/History.java index a36383065a7..a89c9b79923 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/history/History.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/history/History.java @@ -179,9 +179,13 @@ public synchronized void removeAllHistoryAfterNode(final HistoryNode removeAfter if (node instanceof Step) { player = ((Step) node).getPlayerId(); } - int nodeChangeIndex = getNextChange(node); - if (seekingEnabled && nodeChangeIndex > nextChangeIndex) { - break; + if (node.isLeaf()) { + // Don't do this logic on non-leaf nodes as getNextChange() will return + // the next change after this non-leaf, skipping all the child nodes. + int nodeChangeIndex = getNextChange(node); + if (seekingEnabled && nodeChangeIndex > nextChangeIndex) { + break; + } } } return player;