From d583b3e4015df554c8143c36ed5d549ad485f3c4 Mon Sep 17 00:00:00 2001 From: Chris Beck Date: Tue, 24 Jun 2014 17:18:53 -0400 Subject: [PATCH] add game_state::to_config --- src/game_state.cpp | 16 ++++++++++++++++ src/game_state.hpp | 2 ++ src/play_controller.cpp | 10 +--------- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/game_state.cpp b/src/game_state.cpp index 496af272887b..49caef17bb3d 100644 --- a/src/game_state.cpp +++ b/src/game_state.cpp @@ -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; +} diff --git a/src/game_state.hpp b/src/game_state.hpp index dc3b205ddacb..25928837256b 100644 --- a/src/game_state.hpp +++ b/src/game_state.hpp @@ -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 diff --git a/src/play_controller.cpp b/src/play_controller.cpp index 31d36efe3d83..1256ccace5ad 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -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; @@ -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); @@ -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; }