Permalink
Browse files

Prevent crash of replay started from start-of-scenario save

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...
1 parent 389a155 commit ef0ffef5b02282954c2f9b7871a6417bd079adde @mattsc mattsc committed Oct 9, 2013
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/playsingle_controller.cpp
@@ -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());
}

1 comment on commit ef0ffef

Member

mattsc commented on ef0ffef Oct 9, 2013

I forgot to say that this fixes bug #20564.

Please sign in to comment.