Skip to content

Commit

Permalink
store it_is_a_new_turn_ in savefiles
Browse files Browse the repository at this point in the history
this is intended to fix a case where turn X events are not fired when
reloading init_side_done=no saves when it is the first players turn.
  • Loading branch information
gfgtdf committed Mar 1, 2015
1 parent 560a4c9 commit bf37365
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/play_controller.cpp
Expand Up @@ -138,7 +138,7 @@ play_controller::play_controller(const config& level, saved_game& state_of_game,
, start_turn_(gamestate_.tod_manager_.turn()) // gamestate_.tod_manager_ constructed above
, skip_replay_(skip_replay)
, linger_(false)
, it_is_a_new_turn_(true)
, it_is_a_new_turn_(level["it_is_a_new_turn"].to_bool(true))
, init_side_done_(level["init_side_done"].to_bool(false))
, ticks_(ticks)
, victory_when_enemies_defeated_(true)
Expand Down Expand Up @@ -318,10 +318,6 @@ void play_controller::fire_start(bool execute){
}
init_side_done_ = false;

} else {
// FIXME: calculate it_is_a_new_turn_ correctly instead of setting it to false when reloading a game.
// it could cause missed turn events in case init_side_done_ == false.
it_is_a_new_turn_ = false;
}
gamestate_.gamedata_.set_phase(game_data::PLAY);
}
Expand Down Expand Up @@ -454,6 +450,7 @@ config play_controller::to_config() const

cfg.merge_attributes(level_);
cfg["init_side_done"] = init_side_done_;
cfg["it_is_a_new_turn"] = it_is_a_new_turn_;

gamestate_.write(cfg);

Expand Down
2 changes: 0 additions & 2 deletions src/replay_controller.cpp
Expand Up @@ -382,8 +382,6 @@ void replay_controller::reset_replay()
fire_start(true);
sync.do_final_checkup();
}
// Since we did not fire the start event, it_is_a_new_turn_ has the wrong value.
it_is_a_new_turn_ = true;
update_gui();

reset_replay_ui();
Expand Down

0 comments on commit bf37365

Please sign in to comment.