Skip to content

Commit

Permalink
fixup carryover_on_defeat
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gfgtdf committed Jun 1, 2014
1 parent d7ba99a commit 064dcc3
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/game_end_exceptions.cpp
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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);
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/game_end_exceptions.hpp
Expand Up @@ -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. > */
};

/**
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/play_controller.cpp
Expand Up @@ -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);
}

Expand Down
12 changes: 8 additions & 4 deletions src/playcampaign.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/playsingle_controller.cpp
Expand Up @@ -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_);
}

Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 064dcc3

Please sign in to comment.