From 064dcc3d4eaa65ff1dcb08e928651f7d5d72da10 Mon Sep 17 00:00:00 2001 From: gfgtdf Date: Sun, 1 Jun 2014 03:55:20 +0200 Subject: [PATCH] fixup carryover_on_defeat we need to save the preceed_to_next_scenario value for linger saves. We don't really need it for the next scenario in the carryover though. --- src/game_end_exceptions.cpp | 4 +++- src/game_end_exceptions.hpp | 2 +- src/play_controller.cpp | 2 +- src/playcampaign.cpp | 12 ++++++++---- src/playsingle_controller.cpp | 4 ++-- 5 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/game_end_exceptions.cpp b/src/game_end_exceptions.cpp index bf35ef13edf..053cc5e2158 100644 --- a/src/game_end_exceptions.cpp +++ b/src/game_end_exceptions.cpp @@ -24,7 +24,6 @@ transient_end_level::transient_end_level() , custom_endlevel_music() , reveal_map(true) , disabled(false) - , proceed_to_next_level(false) {} end_level_data::end_level_data() @@ -33,6 +32,7 @@ end_level_data::end_level_data() , gold_bonus(true) , carryover_percentage(game_config::gold_carryover_percentage) , carryover_add(false) + , proceed_to_next_level(false) , transient() , next_scenario_settings() , next_scenario_append() @@ -46,6 +46,7 @@ void end_level_data::write(config& cfg) const cfg["bonus"] = gold_bonus; cfg["carryover_percentage"] = carryover_percentage; cfg["carryover_add"] = carryover_add; + cfg["proceed_to_next_level"] = proceed_to_next_level; if (!next_scenario_settings.empty()) { cfg.add_child("next_scenario_settings", next_scenario_settings); } @@ -62,6 +63,7 @@ void end_level_data::read(const config& cfg) gold_bonus = cfg["bonus"].to_bool(true); carryover_percentage = cfg["carryover_percentage"].to_int(game_config::gold_carryover_percentage); carryover_add = cfg["carryover_add"].to_bool(false); + proceed_to_next_level = cfg["proceed_to_next_level"].to_bool(true); const config & next_scenario_settings_cfg = cfg.child_or_empty("next_scenario_settings"); if (!next_scenario_settings_cfg.empty()) { next_scenario_settings = next_scenario_settings_cfg; diff --git a/src/game_end_exceptions.hpp b/src/game_end_exceptions.hpp index f2421c7ac9d..b04df79f821 100644 --- a/src/game_end_exceptions.hpp +++ b/src/game_end_exceptions.hpp @@ -91,7 +91,6 @@ struct transient_end_level{ std::string custom_endlevel_music; /**< Custom short music played at the end. */ bool reveal_map; /**< Should we reveal map when game is ended? (Multiplayer only) */ bool disabled; /**< Limits execution of tag [endlevel] to a single time > */ - bool proceed_to_next_level; /**< whether to proceed to the next scenario, equals (res == VICTORY) in sp. > */ }; /** @@ -107,6 +106,7 @@ struct end_level_data bool gold_bonus; /**< Should early-finish bonus be applied? */ int carryover_percentage; /**< How much gold is carried over to next scenario. */ bool carryover_add; /**< Add or replace next scenario's minimum starting gold. */ + bool proceed_to_next_level; /**< whether to proceed to the next scenario, equals (res == VICTORY) in sp. We need to save this in saves during linger mode. > */ transient_end_level transient; config next_scenario_settings; diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 5dd2b15451d..70eabc63268 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -1490,7 +1490,7 @@ void play_controller::check_victory() DBG_NG << "throwing end level exception..." << std::endl; //Also proceed to the next scenario when another player survived. - end_level_data_.transient.proceed_to_next_level = found_player || found_network_player; + end_level_data_.proceed_to_next_level = found_player || found_network_player; throw end_level_exception(found_player ? VICTORY : DEFEAT); } diff --git a/src/playcampaign.cpp b/src/playcampaign.cpp index b9f9634fa90..f8247101dc1 100644 --- a/src/playcampaign.cpp +++ b/src/playcampaign.cpp @@ -133,7 +133,7 @@ static void store_carryover(game_state& gamestate, playsingle_controller& playco } } - if (persistent_teams > 0 && ((has_next_scenario && end_level.transient.proceed_to_next_level)|| + if (persistent_teams > 0 && ((has_next_scenario && end_level.proceed_to_next_level)|| gamestate.classification().campaign_type == game_classification::TEST)) { gamemap map = playcontroller.get_map_const(); @@ -301,7 +301,11 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config, if (res != QUIT) { - store_carryover(state_of_game, playcontroller, disp, end_level, res); + //if we are loading from linger mode then we already did this. + if(res != SKIP_TO_LINGER) + { + store_carryover(state_of_game, playcontroller, disp, end_level, res); + } if(!disp.video().faked()) { try { @@ -344,7 +348,7 @@ static LEVEL_RESULT playmp_scenario(const config& game_config, if (res != QUIT) { - if(res != OBSERVER_END) + if(res != OBSERVER_END && res != SKIP_TO_LINGER) { //We need to call this before linger because it also prints the defeated/victory message. //(we want to see that message before entering the linger mode) @@ -532,7 +536,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate, //if(res == QUIT || ((res != VICTORY) && gamestate.carryover_sides_start["next_scenario"].empty())) //If there is no next scenario we're done now. - if(res == QUIT || !end_level.transient.proceed_to_next_level || gamestate.carryover_sides_start["next_scenario"].empty()) + if(res == QUIT || !end_level.proceed_to_next_level || gamestate.carryover_sides_start["next_scenario"].empty()) { gamestate.snapshot = config(); return res; diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index 10acc669604..4e558ca8011 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -164,7 +164,7 @@ void playsingle_controller::check_end_level() } return; } - get_end_level_data().transient.proceed_to_next_level = (level_result_ == VICTORY); + get_end_level_data().proceed_to_next_level = (level_result_ == VICTORY); throw end_level_exception(level_result_); } @@ -992,7 +992,7 @@ void playsingle_controller::check_time_over(){ check_victory(); - get_end_level_data().transient.proceed_to_next_level = false; + get_end_level_data().proceed_to_next_level = false; throw end_level_exception(DEFEAT); } }