Skip to content

Commit

Permalink
add game_state::to_config
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeck88 committed Jun 24, 2014
1 parent 15352a2 commit d583b3e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
16 changes: 16 additions & 0 deletions src/game_state.cpp
Expand Up @@ -189,3 +189,19 @@ void game_state::init(const int ticks, const config & replay_start)

pathfind_manager_.reset(new pathfind::manager(level_));
}

config game_state::to_config() const
{
config cfg;

board_.write_config(cfg);

cfg.merge_with(tod_manager_.to_config());

//write out the current state of the map
cfg.merge_with(pathfind_manager_->to_config());

gamedata_.write_snapshot(cfg);

return cfg;
}
2 changes: 2 additions & 0 deletions src/game_state.hpp
Expand Up @@ -41,6 +41,8 @@ struct game_state {
void place_sides_in_preferred_locations();

void init(int ticks, const config & replay_start);

config to_config() const;
};

#endif
10 changes: 1 addition & 9 deletions src/play_controller.cpp
Expand Up @@ -618,9 +618,7 @@ config play_controller::to_config() const
cfg["init_side_done"] = init_side_done_;
cfg.merge_attributes(level_);

gamestate_.board_.write_config(cfg);

cfg.merge_with(gamestate_.tod_manager_.to_config());
cfg.merge_with(gamestate_.to_config());

if(linger_) {
config endlevel;
Expand All @@ -633,9 +631,6 @@ config play_controller::to_config() const
cfg.add_child("terrain_graphics", tg);
}

//write out the current state of the map
cfg.merge_with(gamestate_.pathfind_manager_->to_config());

config display;
gui_->write(display);
cfg.add_child("display", display);
Expand All @@ -656,9 +651,6 @@ config play_controller::to_config() const
//TODO: move id_manager handling to play_controller
cfg["next_underlying_unit_id"] = str_cast(n_unit::id_manager::instance().get_save_id());


gamestate_.gamedata_.write_snapshot(cfg);

cfg.merge_attributes(saved_game_.classification().to_config());
return cfg;
}
Expand Down

0 comments on commit d583b3e

Please sign in to comment.