diff --git a/src/game_events.cpp b/src/game_events.cpp index 8bad982468a..48d02f096a9 100644 --- a/src/game_events.cpp +++ b/src/game_events.cpp @@ -2180,7 +2180,7 @@ bool event_handler::handle_event_command(const queued_event& event_info, const std::string next_scenario = cfg["next_scenario"]; if(next_scenario.empty() == false) { - state_of_game->scenario = next_scenario; + state_of_game->next_scenario = next_scenario; } const std::string result = cfg["result"].base_str(); //do not translate diff --git a/src/gamestatus.cpp b/src/gamestatus.cpp index 27897bde91a..12da5845a56 100644 --- a/src/gamestatus.cpp +++ b/src/gamestatus.cpp @@ -429,6 +429,7 @@ game_state::game_state(const game_data& data, const config& cfg) label = cfg["label"]; version = cfg["version"]; scenario = cfg["scenario"]; + next_scenario = cfg["next_scenario"]; completion = cfg["completion"]; campaign = cfg["campaign"]; @@ -454,6 +455,7 @@ game_state::game_state(const game_data& data, const config& cfg) } std::cerr << "scenario: '" << scenario << "'\n"; + std::cerr << "next_scenario: '" << next_scenario << "'\n"; difficulty = cfg["difficulty"]; if(difficulty.empty()) @@ -559,6 +561,7 @@ void write_game(const game_state& gamestate, config& cfg, WRITE_GAME_MODE mode) cfg["version"] = game_config::version; cfg["scenario"] = gamestate.scenario; + cfg["next_scenario"] = gamestate.next_scenario; cfg["completion"] = gamestate.completion; @@ -616,6 +619,7 @@ void write_game(config_writer &out, const game_state& gamestate, WRITE_GAME_MODE out.write_key_val("label", gamestate.label); out.write_key_val("version", game_config::version); out.write_key_val("scenario", gamestate.scenario); + out.write_key_val("next_scenario", gamestate.next_scenario); out.write_key_val("completion", gamestate.completion); out.write_key_val("campaign", gamestate.campaign); out.write_key_val("campaign_type", gamestate.campaign_type); diff --git a/src/gamestatus.hpp b/src/gamestatus.hpp index b2216604442..752843b7601 100644 --- a/src/gamestatus.hpp +++ b/src/gamestatus.hpp @@ -110,6 +110,7 @@ public: std::string campaign; //!< the campaign being played std::string abbrev; //!< the campaign abbreviation std::string scenario; //!< the scenario being played + std::string next_scenario; //!< the scenario coming next (for campaigns) std::string completion; //!< running. victory, or defeat //! Information about campaign players who carry resources diff --git a/src/playcampaign.cpp b/src/playcampaign.cpp index 39ca7f18c8d..eb5aaa005c6 100644 --- a/src/playcampaign.cpp +++ b/src/playcampaign.cpp @@ -314,8 +314,7 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_ } const config::child_list& story = scenario->get_children("story"); - const std::string current_scenario = gamestate.scenario; - const std::string next_scenario = (*scenario)["next_scenario"]; + gamestate.next_scenario = (*scenario)["next_scenario"]; bool save_game_after_scenario = true; @@ -403,9 +402,6 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_ // if MP campaigns ever work again, we might // need to change this test. if(res == VICTORY || io_type != IO_NONE) { - const std::string orig_scenario = gamestate.scenario; - gamestate.scenario = current_scenario; - if (preferences::delete_saves()) clean_saves(gamestate.label); @@ -419,8 +415,6 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_ gui::show_error_message(disp, _("The replay could not be saved")); } } - - gamestate.scenario = orig_scenario; } recorder.clear(); @@ -432,10 +426,10 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_ { // In case we are the host and there is a next scenario, notify // the other players so they can leave linger mode. - if (!next_scenario.empty() && io_type == IO_SERVER) + if (!gamestate.next_scenario.empty() && io_type == IO_SERVER) notify_next_scenario(IO_SERVER); - if (res != OBSERVER_END || next_scenario.empty()) + if (res != OBSERVER_END || gamestate.next_scenario.empty()) return res; const int dlg_res = gui::dialog(disp,"Game Over", @@ -450,12 +444,11 @@ LEVEL_RESULT play_game(display& disp, game_state& gamestate, const config& game_ if(res == LEVEL_CONTINUE_NO_SAVE) save_game_after_scenario = false; - // If the scenario hasn't been set in-level, set it now. - if(gamestate.scenario == current_scenario) - gamestate.scenario = next_scenario; + // Switch to the next scenario. + gamestate.scenario = gamestate.next_scenario; if(io_type == IO_CLIENT) { - if (!next_scenario.empty()){ + if (!gamestate.next_scenario.empty()){ //notifies the clients that this player advanced to the next scenario notify_next_scenario(IO_CLIENT); diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index ec0fdf0550c..76909740305 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -331,12 +331,8 @@ LEVEL_RESULT playsingle_controller::play_scenario(const std::vector& st if (first_human_team_ != -1) log.victory(status_.turn(), teams_[first_human_team_].gold()); - if(gamestate_.scenario == (level_)["id"]) { - gamestate_.scenario = (level_)["next_scenario"]; - } - - const bool has_next_scenario = !gamestate_.scenario.empty() && - gamestate_.scenario != "null"; + const bool has_next_scenario = !gamestate_.next_scenario.empty() && + gamestate_.next_scenario != "null"; // Save current_player name to reuse it when setting next_scenario side info std::vector::iterator i;