diff --git a/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java b/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java index 02aa4608d66..33a0310ec1f 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/data/GameData.java @@ -358,6 +358,15 @@ public void setHistory(final History history) { public void resetHistory() { gameHistory = new History(this); + GameStep step = getSequence().getStep(); + // Put the history in a round and step, so that child nodes can be added without errors. + gameHistory + .getHistoryWriter() + .startNextStep( + step.getName(), + step.getDelegate().getName(), + step.getPlayerId(), + step.getDisplayName()); } /** Not to be called by mere mortals. */ diff --git a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java index a1271205860..0f397947144 100644 --- a/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java +++ b/game-app/game-core/src/main/java/games/strategy/engine/framework/GameDataManager.java @@ -227,7 +227,7 @@ public static void saveGameUncompressed( // write to temporary file first in case of error try (ObjectOutputStream outStream = new ObjectOutputStream(sink)) { outStream.writeObject(engineVersion); - try (GameData.Unlocker ignored = data.acquireReadLock()) { + try (GameData.Unlocker ignored = data.acquireWriteLock()) { final var history = data.getHistory(); if (!options.withHistory) { data.resetHistory();