Also fix #2852 when using "Back to turn" in a networked MP game.

This commit is contained in:
josteph 2019-03-22 21:55:52 +00:00 committed by jostephd
parent d3c1cc43e7
commit 301aa1da79
3 changed files with 10 additions and 5 deletions

View file

@ -313,7 +313,8 @@ void playsingle_controller::hotkey_handler::load_autosave(const std::string& fil
return;
}
std::shared_ptr<config> res(new config(savegame.child_or_empty("snapshot")));
throw reset_gamestate_exception(res, true);
std::shared_ptr<config> stats(new config(savegame.child_or_empty("statistics")));
throw reset_gamestate_exception(res, stats, true);
}
else
{

View file

@ -203,8 +203,11 @@ void playsingle_controller::play_scenario_main_loop()
for(std::size_t i = 0; i < local_players.size(); ++i) {
local_players[i] = gamestate().board_.teams()[i].is_local();
}
if(!ex.start_replay) {
// TODO: is this also needed when start_replay is true?
if(ex.start_replay) {
// MP "Back to turn"
statistics::read_stats(*ex.stats_);
} else {
// SP replay
statistics::reset_current_scenario();
}
reset_gamestate(*ex.level, (*ex.level)["replay_pos"]);
@ -671,7 +674,7 @@ void playsingle_controller::reset_replay()
{
if(replay_controller_ && replay_controller_->allow_reset_replay()) {
replay_controller_->stop_replay();
throw reset_gamestate_exception(replay_controller_->get_reset_state(), false);
throw reset_gamestate_exception(replay_controller_->get_reset_state(), {}, false);
}
else {
ERR_NG << "received invalid reset replay\n";

View file

@ -28,8 +28,9 @@
struct reset_gamestate_exception : public std::exception
{
reset_gamestate_exception(std::shared_ptr<config> l, bool s = true) : level(l), start_replay(s) {}
reset_gamestate_exception(std::shared_ptr<config> l, std::shared_ptr<config> stats, bool s = true) : level(l), stats_(stats), start_replay(s) {}
std::shared_ptr<config> level;
std::shared_ptr<config> stats_;
bool start_replay;
};