Skip to content

Commit

Permalink
small playcampaign refactor
Browse files Browse the repository at this point in the history
we move state_of_game.expand_carryover(); out of playmp/singel scenario to remove code dublication

we move gamestate.get_starting_pos().child_range("story"); after expand_random_scenario because expand_random_scenario might invalidate the returnvalue of child_range("story").
  • Loading branch information
gfgtdf committed Jun 15, 2014
1 parent 699fbae commit c1c7688
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/playcampaign.cpp
Expand Up @@ -184,8 +184,6 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config,
{
const int ticks = SDL_GetTicks();

state_of_game.expand_carryover();

LOG_NG << "creating objects... " << (SDL_GetTicks() - ticks) << "\n";
playsingle_controller playcontroller(state_of_game.get_starting_pos(), state_of_game, ticks, game_config, disp.video(), skip_replay);
LOG_NG << "created objects... " << (SDL_GetTicks() - playcontroller.get_ticks()) << "\n";
Expand Down Expand Up @@ -227,7 +225,6 @@ static LEVEL_RESULT playmp_scenario(const config& game_config,
bool blindfold_replay, io_type_t& io_type, end_level_data &end_level)
{
const int ticks = SDL_GetTicks();
state_of_game.expand_carryover();

playmp_controller playcontroller(state_of_game.get_starting_pos(), state_of_game, ticks,
game_config, disp.video(), skip_replay, blindfold_replay, io_type == IO_SERVER);
Expand Down Expand Up @@ -280,7 +277,6 @@ LEVEL_RESULT play_game(game_display& disp, saved_game& gamestate,

while(gamestate.valid()) {
config& starting_pos = gamestate.get_starting_pos();
config::const_child_itors story = starting_pos.child_range("story");


bool save_game_after_scenario = true;
Expand All @@ -307,6 +303,10 @@ LEVEL_RESULT play_game(game_display& disp, saved_game& gamestate,

sound::empty_playlist();

state_of_game.expand_carryover();

config::const_child_itors story = gamestate.get_starting_pos().child_range("story");

switch (io_type){
case IO_NONE:
#if !defined(ALWAYS_USE_MP_CONTROLLER)
Expand Down

0 comments on commit c1c7688

Please sign in to comment.