Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "Not in a step" exception with battle calc. #10689

Merged
merged 2 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down