Skip to content

Commit

Permalink
Prevent crash of replay started from start-of-scenario save
Browse files Browse the repository at this point in the history
Start-of-scenario saves in 1.11 do not contain the [replay_start] tag
any more because its contents are identical to the starting situation.
As a result, the tag needs to be created during the start-up sequence
of a scenario.  Whether this is necessary was previously decided by
checking whether the scenario snapshot was empty.  This works when the
scenario is started by finishing the previous scenario.  However, when
the start-of-scenario savegame is loaded, the snapshot is not empty.
Thus, we need to check whether the snapshot is empty OR whether the
turn number in it is less than 1.
  • Loading branch information
mattsc committed Oct 9, 2013
1 parent 389a155 commit ef0ffef
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/playsingle_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
}

//before first turn, save a snapshot as replay_start
if(gamestate_.snapshot.empty()){
if(gamestate_.snapshot.child_or_empty("variables")["turn_number"].to_int(-1)<1){
gamestate_.replay_start() = to_config();
gamestate_.write_snapshot(gamestate_.replay_start(), gui_.get());
}
Expand Down

1 comment on commit ef0ffef

@mattsc
Copy link
Member Author

@mattsc mattsc commented on ef0ffef Oct 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forgot to say that this fixes bug #20564.

Please sign in to comment.