Skip to content

Commit

Permalink
use config::child_or_add
Browse files Browse the repository at this point in the history
Note: This commit is a squash of two cherry-picked commits
from master, they were adjacent and the second was a fixup
of the first. The first commit in master was
28ffcc5
  • Loading branch information
gfgtdf authored and cbeck88 committed May 31, 2014
1 parent fe3395c commit c3d599d
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/playcampaign.cpp
Expand Up @@ -271,15 +271,10 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
LOG_NG << "created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) << "\n";

LEVEL_RESULT res = playcontroller.play_scenario(story, skip_replay);
end_level = playcontroller.get_end_level_data_const();

if (state_of_game.carryover_sides.has_child("end_level_data")) {
config& cfg_end_level = state_of_game.carryover_sides.child("end_level_data");
end_level.write(cfg_end_level);
} else {
config& cfg_end_level = state_of_game.carryover_sides.add_child("end_level_data");
end_level.write(cfg_end_level);
}
end_level = playcontroller.get_end_level_data_const();
config& cfg_end_level = state_of_game.carryover_sides.child_or_add("end_level_data");
end_level.write(cfg_end_level);

if (res == DEFEAT) {
if (resources::persist != NULL)
Expand Down Expand Up @@ -324,15 +319,10 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
playmp_controller playcontroller(init_level, state_of_game, ticks, num_turns,
game_config, disp.video(), skip_replay, blindfold_replay, io_type == IO_SERVER);
LEVEL_RESULT res = playcontroller.play_scenario(story, skip_replay);
end_level = playcontroller.get_end_level_data_const();

if (state_of_game.carryover_sides.has_child("end_level_data")) {
config& cfg_end_level = state_of_game.carryover_sides.child("end_level_data");
end_level.write(cfg_end_level);
} else {
config& cfg_end_level = state_of_game.carryover_sides.add_child("end_level_data");
end_level.write(cfg_end_level);
}
end_level = playcontroller.get_end_level_data_const();
config& cfg_end_level = state_of_game.carryover_sides.child_or_add("end_level_data");
end_level.write(cfg_end_level);

//Check if the player started as mp client and changed to host
if (io_type == IO_CLIENT && playcontroller.is_host())
Expand Down

0 comments on commit c3d599d

Please sign in to comment.