diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a8f1aec02ec9..7098e395cf35 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -859,6 +859,7 @@ set(wesnoth-main_SRC resources.cpp save_blocker.cpp save_index.cpp + saved_game.cpp savegame.cpp scripting/debug_lua.cpp scripting/lua.cpp diff --git a/src/SConscript b/src/SConscript index 25488961ac45..3c8dc79481ff 100644 --- a/src/SConscript +++ b/src/SConscript @@ -492,6 +492,7 @@ wesnoth_sources = Split(""" resources.cpp save_blocker.cpp save_index.cpp + saved_game.cpp savegame.cpp scripting/debug_lua.cpp scripting/lua.cpp diff --git a/src/editor/map/context_manager.cpp b/src/editor/map/context_manager.cpp index 0959139a0ff2..ef44282211da 100644 --- a/src/editor/map/context_manager.cpp +++ b/src/editor/map/context_manager.cpp @@ -85,8 +85,8 @@ class map_context_refresher context_manager_.gui().replace_overlay_map(&context_manager_.get_map_context().get_overlays()); - resources::classification = &context_manager_.get_map_context().get_game_state().classification(); - resources::mp_settings = &context_manager_.get_map_context().get_game_state().mp_settings(); + resources::classification = &context_manager_.get_map_context().get_classification(); + resources::mp_settings = &context_manager_.get_map_context().get_mp_settings(); context_manager_.gui().init_flags(); diff --git a/src/editor/map/map_context.cpp b/src/editor/map/map_context.cpp index 0adc97c50a28..b96003422997 100644 --- a/src/editor/map/map_context.cpp +++ b/src/editor/map/map_context.cpp @@ -63,7 +63,8 @@ map_context::map_context(const editor_map& map, const display& disp, bool pure_m , units_() , teams_() , tod_manager_(new tod_manager(schedule)) - , state_() + , mp_settings_() + , game_classification_() , music_tracks_() { } @@ -94,7 +95,8 @@ map_context::map_context(const config& game_config, const std::string& filename, , units_() , teams_() , tod_manager_(new tod_manager(game_config.find_child("editor_times", "id", "default"))) - , state_() + , mp_settings_() + , game_classification_() , music_tracks_() { /* diff --git a/src/editor/map/map_context.hpp b/src/editor/map/map_context.hpp index f30746c4d240..a439b162eb03 100644 --- a/src/editor/map/map_context.hpp +++ b/src/editor/map/map_context.hpp @@ -157,9 +157,12 @@ class map_context : public display_context, private boost::noncopyable tod_manager* get_time_manager() { return tod_manager_.get(); } - - game_state& get_game_state() { - return state_; + + mp_game_settings & get_mp_settings() { + return mp_settings_; + } + game_classification& get_classification() { + return game_classification_; } /** @@ -475,7 +478,8 @@ class map_context : public display_context, private boost::noncopyable unit_map units_; std::vector teams_; boost::scoped_ptr tod_manager_; - game_state state_; + mp_game_settings mp_settings_; + game_classification game_classification_; typedef std::map music_map; music_map music_tracks_; diff --git a/src/game_controller.cpp b/src/game_controller.cpp index 5db00e04d3d1..439c1212024a 100644 --- a/src/game_controller.cpp +++ b/src/game_controller.cpp @@ -643,7 +643,7 @@ bool game_controller::load_game() void game_controller::set_tutorial() { - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::TUTORIAL; state_.carryover_sides_start["next_scenario"] = "tutorial"; state_.classification().campaign_define = "TUTORIAL"; @@ -658,7 +658,7 @@ void game_controller::mark_completed_campaigns(std::vector &campaigns) bool game_controller::new_campaign() { - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::SCENARIO; std::vector campaigns; @@ -881,7 +881,7 @@ bool game_controller::play_multiplayer() { int res; - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::MULTIPLAYER; //Print Gui only if the user hasn't specified any server @@ -1002,7 +1002,7 @@ bool game_controller::play_multiplayer_commandline() DBG_MP << "starting multiplayer game from the commandline" << std::endl; // These are all the relevant lines taken literally from play_multiplayer() above - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::MULTIPLAYER; resources::config_manager-> diff --git a/src/game_controller.hpp b/src/game_controller.hpp index 63037d959621..baef02fa7580 100644 --- a/src/game_controller.hpp +++ b/src/game_controller.hpp @@ -16,7 +16,7 @@ #include "commandline_options.hpp" #include "editor/editor_main.hpp" -#include "gamestatus.hpp" +#include "saved_game.hpp" #include "game_config_manager.hpp" #include "game_display.hpp" #include "game_preferences.hpp" @@ -110,7 +110,7 @@ class game_controller std::string screenshot_map_, screenshot_filename_; - game_state state_; + saved_game state_; std::string multiplayer_server_; bool jump_to_multiplayer_; diff --git a/src/game_preferences.hpp b/src/game_preferences.hpp index 18a9fa69e1d6..7c5985d8bb0b 100644 --- a/src/game_preferences.hpp +++ b/src/game_preferences.hpp @@ -16,7 +16,6 @@ class game_board; class gamemap; -class game_state; class team; class unit_map; diff --git a/src/gamestatus.cpp b/src/gamestatus.cpp index 65a4e7b6090d..8ef7eefc60d9 100644 --- a/src/gamestatus.cpp +++ b/src/gamestatus.cpp @@ -598,74 +598,6 @@ config game_classification::to_config() const return cfg; } -game_state::game_state() : - replay_data(), - snapshot(), - carryover_sides(), - carryover_sides_start(carryover_info().to_config()), - replay_start_(), - classification_(), - mp_settings_() - {} - -game_state::game_state(const config& cfg, bool show_replay) : - replay_data(), - snapshot(), - carryover_sides(), - carryover_sides_start(), - replay_start_(), - classification_(cfg), - mp_settings_(cfg) -{ - log_scope("read_game"); - - if(cfg.has_child("carryover_sides")){ - carryover_sides = cfg.child("carryover_sides"); - } - if(cfg.has_child("carryover_sides_start")){ - carryover_sides_start = cfg.child("carryover_sides_start"); - } - - if(show_replay){ - //If replay_start and replay_data couldn't be loaded - if(!load_replay(cfg)){ - //TODO: notify user of failure - ERR_NG<<"Could not load as replay " << std::endl; - } - } else { - if(const config& snapshot = cfg.child("snapshot")){ - this->snapshot = snapshot; - load_replay(cfg); - } else if(carryover_sides_start.empty() && !carryover_sides.empty()){ - //if we are loading a start of scenario save and don't have carryover_sides_start, use carryover_sides - carryover_sides_start = carryover_sides; - } - //TODO: check if loading fails completely - } - - LOG_NG << "scenario: '" << carryover_sides_start["next_scenario"] << "'\n"; - - if (const config &stats = cfg.child("statistics")) { - statistics::fresh_stats(); - statistics::read_stats(stats); - } - -} - -bool game_state::load_replay(const config& cfg){ - bool replay_loaded = false; - - if(const config& replay_start = cfg.child("replay_start")){ - replay_start_ = replay_start; - if(const config& replay = cfg.child("replay")){ - this->replay_data = replay; - replay_loaded = true; - } - } - - return replay_loaded; -} - void convert_old_saves(config& cfg){ if(!cfg.has_child("snapshot")){ return; @@ -771,33 +703,3 @@ void convert_old_saves(config& cfg){ //1.12-1.13 end LOG_RG<<"cfg after conversion "<~game_state(); - new (this) game_state(state) ; - } - return *this ; -} - - -void game_state::write_config(config_writer& out) const -{ - out.write(classification_.to_config()); - if (classification_.campaign_type == game_classification::MULTIPLAYER) { - out.write_child(lexical_cast(game_classification::MULTIPLAYER), mp_settings_.to_config()); - } -} - diff --git a/src/gamestatus.hpp b/src/gamestatus.hpp index 4f124f2393ee..6466d5944e02 100644 --- a/src/gamestatus.hpp +++ b/src/gamestatus.hpp @@ -163,56 +163,4 @@ class game_classification : public savegame::savegame_config }; MAKE_ENUM_STREAM_OPS2(game_classification, CAMPAIGN_TYPE) -class game_state -{ -public: - game_state(); - game_state(const game_state& state); - explicit game_state(const config& cfg, bool show_replay = false); - - ~game_state(){} - game_state& operator=(const game_state& state); - - //write the config information into a stream (file) - void write_config(config_writer& out) const; - - game_classification& classification() { return classification_; } - const game_classification& classification() const { return classification_; } - - /** Multiplayer parameters for this game */ - mp_game_settings& mp_settings() { return mp_settings_; } - const mp_game_settings& mp_settings() const { return mp_settings_; } - - bool load_replay(const config& cfg); - - config& replay_start() { return replay_start_; } - - /** - * If the game is saved mid-level, we have a series of replay steps - * to take the game up to the position it was saved at. - */ - config replay_data; - - /** - * Snapshot of the game's current contents. - * - * i.e. unless the player selects to view a replay, the game's settings are - * read in from this object. - */ - config snapshot; - - /** The carryover information for all sides*/ - config carryover_sides; - - /** The carryover information for all sides as it was before the scenario started*/ - config carryover_sides_start; - -private: - /** First turn snapshot for replays, contains starting position */ - config replay_start_; - - game_classification classification_; - mp_game_settings mp_settings_; -}; - #endif diff --git a/src/mp_game_utils.cpp b/src/mp_game_utils.cpp index 220db75626cd..8747ef783d12 100644 --- a/src/mp_game_utils.cpp +++ b/src/mp_game_utils.cpp @@ -17,7 +17,7 @@ #include "config.hpp" #include "dialogs.hpp" #include "formula_string_utils.hpp" -#include "gamestatus.hpp" +#include "saved_game.hpp" #include "game_config_manager.hpp" #include "gettext.hpp" #include "log.hpp" @@ -45,7 +45,7 @@ static lg::log_domain log_network("network"); namespace mp { config initial_level_config(game_display& disp, const mp_game_settings& params, - game_state& state) + saved_game& state) { config level; @@ -161,7 +161,7 @@ config initial_level_config(game_display& disp, const mp_game_settings& params, return level; } -void level_to_gamestate(config& level, game_state& state) +void level_to_gamestate(config& level, saved_game& state) { // Any replay data is only temporary and should be removed from // the level data in case we want to save the game later. @@ -259,9 +259,9 @@ void level_to_gamestate(config& level, game_state& state) } } if (sides.get_variables().empty()) { - LOG_NG << "No variables were found for the game_state." << std::endl; + LOG_NG << "No variables were found for the saved_game." << std::endl; } else { - LOG_NG << "Variables found and loaded into game_state:" << std::endl; + LOG_NG << "Variables found and loaded into saved_game:" << std::endl; LOG_NG << sides.get_variables(); } diff --git a/src/mp_game_utils.hpp b/src/mp_game_utils.hpp index 66b9186b7d35..302311eba1a6 100644 --- a/src/mp_game_utils.hpp +++ b/src/mp_game_utils.hpp @@ -19,14 +19,14 @@ #include "network.hpp" class config; -class game_state; +class saved_game; namespace mp { config initial_level_config(game_display& disp, const mp_game_settings& params, - game_state& state); + saved_game& state); -void level_to_gamestate(config& level, game_state& state); +void level_to_gamestate(config& level, saved_game& state); void check_response(network::connection res, const config& data); diff --git a/src/multiplayer.cpp b/src/multiplayer.cpp index 9a9481f4ce35..87d74e6d0444 100644 --- a/src/multiplayer.cpp +++ b/src/multiplayer.cpp @@ -427,7 +427,7 @@ static server_type open_connection(game_display& disp, const std::string& origin // of those screen functions. static void enter_wait_mode(game_display& disp, const config& game_config, - game_state& state, bool observe) + saved_game& state, bool observe) { DBG_MP << "entering wait mode" << std::endl; @@ -470,10 +470,10 @@ static void enter_wait_mode(game_display& disp, const config& game_config, } static void enter_create_mode(game_display& disp, const config& game_config, - game_state& state, bool local_players_only = false); + saved_game& state, bool local_players_only = false); static bool enter_connect_mode(game_display& disp, const config& game_config, - game_state& state, const mp_game_settings& params, + saved_game& state, const mp_game_settings& params, bool local_players_only = false) { DBG_MP << "entering connect mode" << std::endl; @@ -521,11 +521,11 @@ static bool enter_connect_mode(game_display& disp, const config& game_config, } static bool enter_configure_mode(game_display& disp, const config& game_config, - game_state& state, const mp_game_settings& params, + saved_game& state, const mp_game_settings& params, bool local_players_only = false); static void enter_create_mode(game_display& disp, const config& game_config, - game_state& state, bool local_players_only) + saved_game& state, bool local_players_only) { DBG_MP << "entering create mode" << std::endl; @@ -575,7 +575,7 @@ static void enter_create_mode(game_display& disp, const config& game_config, } static bool enter_configure_mode(game_display& disp, const config& game_config, - game_state& state, const mp_game_settings& params, bool local_players_only) + saved_game& state, const mp_game_settings& params, bool local_players_only) { DBG_MP << "entering configure mode" << std::endl; @@ -632,7 +632,7 @@ static void do_preferences_dialog(game_display& disp, const config& game_config) } static void enter_lobby_mode(game_display& disp, const config& game_config, - game_state& state) + saved_game& state) { DBG_MP << "entering lobby mode" << std::endl; @@ -738,7 +738,7 @@ static void enter_lobby_mode(game_display& disp, const config& game_config, namespace mp { void start_local_game(game_display& disp, const config& game_config, - game_state& state) + saved_game& state) { DBG_MP << "starting local game" << std::endl; gamechat.clear_history(); @@ -749,7 +749,7 @@ void start_local_game(game_display& disp, const config& game_config, } void start_local_game_commandline(game_display& disp, const config& game_config, - game_state& state, const commandline_options& cmdline_opts) + saved_game& state, const commandline_options& cmdline_opts) { DBG_MP << "starting local MP game from commandline" << std::endl; @@ -870,14 +870,14 @@ void start_local_game_commandline(game_display& disp, const config& game_config, unsigned int repeat = (cmdline_opts.multiplayer_repeat) ? *cmdline_opts.multiplayer_repeat : 1; for(unsigned int i = 0; i < repeat; i++){ - game_state state_copy(state); + saved_game state_copy(state); play_game(disp, state_copy, game_config, IO_SERVER, false, false); } recorder.clear(); } void start_client(game_display& disp, const config& game_config, - game_state& state, const std::string& host) + saved_game& state, const std::string& host) { DBG_MP << "starting client" << std::endl; const network::manager net_manager(1,1); @@ -919,7 +919,7 @@ mp::ui::result goto_mp_connect(game_display& disp, connect_engine& engine, return res; } -mp::ui::result goto_mp_wait(game_state& state, game_display& disp, +mp::ui::result goto_mp_wait(saved_game& state, game_display& disp, const config& game_config, bool observe) { mp::ui::result res; diff --git a/src/multiplayer.hpp b/src/multiplayer.hpp index b33b3ed92493..0cb29fda4f1c 100644 --- a/src/multiplayer.hpp +++ b/src/multiplayer.hpp @@ -37,7 +37,7 @@ const size_t max_login_size = 20; * @param game_config The global, top-level WML configuration for the game */ void start_local_game(game_display& disp, const config& game_config, - game_state& state); + saved_game& state); /** Starts a multiplayer game in single-user mode. * @@ -45,7 +45,7 @@ void start_local_game(game_display& disp, const config& game_config, * cmdline_opts The commandline options */ void start_local_game_commandline(game_display& disp, const config& game_config, - game_state& state, const commandline_options& cmdline_opts); + saved_game& state, const commandline_options& cmdline_opts); /** Starts a multiplayer game in client mode. * @@ -54,7 +54,7 @@ void start_local_game_commandline(game_display& disp, const config& game_config, * @param host The host to connect to. */ void start_client(game_display& disp, const config& game_config, - game_state& state, const std::string& host); + saved_game& state, const std::string& host); /** * Opens mp::connect screen and sets game state according to the @@ -67,7 +67,7 @@ mp::ui::result goto_mp_connect(game_display& disp, connect_engine& engine, * Opens mp::wait screen and sets game state according to the * changes made. */ -mp::ui::result goto_mp_wait(game_state& state, game_display& disp, +mp::ui::result goto_mp_wait(saved_game& state, game_display& disp, const config& game_config, bool observe); } diff --git a/src/multiplayer_connect_engine.cpp b/src/multiplayer_connect_engine.cpp index 77a168fb6d50..57ea8ae0f28a 100644 --- a/src/multiplayer_connect_engine.cpp +++ b/src/multiplayer_connect_engine.cpp @@ -68,7 +68,7 @@ const std::string attributes_to_trim[] = { namespace mp { -connect_engine::connect_engine(game_display& disp, game_state& state, +connect_engine::connect_engine(game_display& disp, saved_game& state, const mp_game_settings& params, const bool local_players_only, const bool first_scenario) : level_(), diff --git a/src/multiplayer_connect_engine.hpp b/src/multiplayer_connect_engine.hpp index 6666b5c2ed09..cd958ee97814 100644 --- a/src/multiplayer_connect_engine.hpp +++ b/src/multiplayer_connect_engine.hpp @@ -17,9 +17,9 @@ #include "commandline_options.hpp" #include "config.hpp" #include "flg_manager.hpp" -#include "gamestatus.hpp" +#include "saved_game.hpp" #include "multiplayer_ui.hpp" - +#include "saved_game.hpp" #include namespace mp { @@ -43,7 +43,7 @@ typedef std::pair controller_option; class connect_engine { public: - connect_engine(game_display& disp, game_state& state, + connect_engine(game_display& disp, saved_game& state, const mp_game_settings& params, const bool local_players_only, const bool first_scenario); ~connect_engine(); @@ -107,7 +107,7 @@ class connect_engine friend class side_engine; config level_; - game_state& state_; + saved_game& state_; const mp_game_settings& params_; diff --git a/src/multiplayer_create.cpp b/src/multiplayer_create.cpp index 43536aeae7c7..5187094b4bbf 100644 --- a/src/multiplayer_create.cpp +++ b/src/multiplayer_create.cpp @@ -55,7 +55,7 @@ const SDL_Rect null_rect = {0, 0, 0, 0}; namespace mp { -create::create(game_display& disp, const config& cfg, game_state& state, +create::create(game_display& disp, const config& cfg, saved_game& state, chat& c, config& gamelist) : ui(disp, _("Create Game"), cfg, c, gamelist), tooltip_manager_(disp.video()), diff --git a/src/multiplayer_create.hpp b/src/multiplayer_create.hpp index 72f4c9fec5b5..55f6f7d2a048 100644 --- a/src/multiplayer_create.hpp +++ b/src/multiplayer_create.hpp @@ -30,7 +30,7 @@ namespace mp { class create : public mp::ui { public: - create(game_display& disp, const config& game_config, game_state& state, + create(game_display& disp, const config& game_config, saved_game& state, chat& c, config& gamelist); ~create(); diff --git a/src/multiplayer_create_engine.cpp b/src/multiplayer_create_engine.cpp index 8909211bd25c..6119b07e3650 100644 --- a/src/multiplayer_create_engine.cpp +++ b/src/multiplayer_create_engine.cpp @@ -22,6 +22,7 @@ #include "generators/map_create.hpp" #include "map_exception.hpp" #include "minimap.hpp" +#include "saved_game.hpp" #include "wml_separators.hpp" #include "wml_exception.hpp" @@ -324,7 +325,7 @@ int campaign::max_players() const return max_players_; } -create_engine::create_engine(game_display& disp, game_state& state) : +create_engine::create_engine(game_display& disp, saved_game& state) : current_level_type_(), current_level_index_(0), current_era_index_(0), @@ -349,7 +350,7 @@ create_engine::create_engine(game_display& disp, game_state& state) : DBG_MP << "restoring game config\n"; // Restore game config for multiplayer. - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::MULTIPLAYER; resources::config_manager-> load_game_config_for_game(state_.classification()); diff --git a/src/multiplayer_create_engine.hpp b/src/multiplayer_create_engine.hpp index 0dd44278b92c..814a37fb2ad2 100644 --- a/src/multiplayer_create_engine.hpp +++ b/src/multiplayer_create_engine.hpp @@ -25,7 +25,7 @@ #include #include -class game_state; +class saved_game; namespace mp { @@ -157,7 +157,7 @@ class campaign : public level class create_engine { public: - create_engine(game_display& disp, game_state& state); + create_engine(game_display& disp, saved_game& state); ~create_engine(); enum MP_EXTRA { ERA, MOD }; @@ -267,7 +267,7 @@ class create_engine std::vector eras_; std::vector mods_; - game_state& state_; + saved_game& state_; mp_game_settings parameters_; depcheck::manager dependency_manager_; diff --git a/src/multiplayer_wait.cpp b/src/multiplayer_wait.cpp index 0a81c6fada83..e7166c2ce6ad 100644 --- a/src/multiplayer_wait.cpp +++ b/src/multiplayer_wait.cpp @@ -25,6 +25,7 @@ #include "mp_game_utils.hpp" #include "multiplayer_wait.hpp" #include "statistics.hpp" +#include "saved_game.hpp" #include "sound.hpp" #include "wml_exception.hpp" #include "wml_separators.hpp" @@ -182,7 +183,7 @@ handler_vector wait::leader_preview_pane::handler_members() { } -wait::wait(game_display& disp, const config& cfg, game_state& state, +wait::wait(game_display& disp, const config& cfg, saved_game& state, mp::chat& c, config& gamelist, const bool first_scenario) : ui(disp, _("Game Lobby"), cfg, c, gamelist), cancel_button_(disp.video(), first_scenario ? _("Cancel") : _("Quit")), @@ -201,7 +202,7 @@ wait::~wait() { try { if (get_result() == QUIT) { - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::MULTIPLAYER; resources::config_manager-> @@ -228,7 +229,7 @@ void wait::join_game(bool observe) } if (first_scenario_) { - state_ = game_state(); + state_ = saved_game(); state_.classification().campaign_type = game_classification::MULTIPLAYER; const config* campaign = &resources::config_manager-> @@ -387,7 +388,7 @@ void wait::start_game() level_to_gamestate(level_, state_); } else { - state_ = game_state(level_); + state_ = saved_game(level_); // When we observe and don't have the addon installed we still need // the old way, no clue why however. Code is a copy paste of diff --git a/src/multiplayer_wait.hpp b/src/multiplayer_wait.hpp index 4fb04034f909..fe39ba24310a 100644 --- a/src/multiplayer_wait.hpp +++ b/src/multiplayer_wait.hpp @@ -26,7 +26,7 @@ namespace mp { class wait : public ui { public: - wait(game_display& disp, const config& cfg, game_state& state, chat& c, + wait(game_display& disp, const config& cfg, saved_game& state, chat& c, config& gamelist, const bool first_scenario = true); ~wait(); virtual void process_event(); @@ -74,7 +74,7 @@ class wait : public ui gui::menu game_menu_; config level_; - game_state& state_; + saved_game& state_; const bool first_scenario_; bool stop_updates_; diff --git a/src/play_controller.cpp b/src/play_controller.cpp index a5dd3f7ad897..54d3decdcfc7 100644 --- a/src/play_controller.cpp +++ b/src/play_controller.cpp @@ -38,6 +38,7 @@ #include "pathfind/teleport.hpp" #include "resources.hpp" #include "savegame.hpp" +#include "saved_game.hpp" #include "sound.hpp" #include "unit_id.hpp" #include "save_blocker.hpp" @@ -94,7 +95,7 @@ static void clear_resources() -play_controller::play_controller(const config& level, game_state& state_of_game, +play_controller::play_controller(const config& level, saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video, bool skip_replay) : controller_base(ticks, game_config, video), diff --git a/src/play_controller.hpp b/src/play_controller.hpp index bc12b9f3e363..1dfdebe2f072 100644 --- a/src/play_controller.hpp +++ b/src/play_controller.hpp @@ -31,7 +31,7 @@ #include class game_display; -class game_state; +class saved_game; class game_data; class team; @@ -72,7 +72,7 @@ namespace wb { class play_controller : public controller_base, public events::observer, public savegame::savegame_config { public: - play_controller(const config& level, game_state& state_of_game, + play_controller(const config& level, saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video, bool skip_replay); virtual ~play_controller(); @@ -239,7 +239,7 @@ class play_controller : public controller_base, public events::observer, public boost::scoped_ptr gui_; const statistics::scenario_context statistics_context_; const config& level_; - game_state& gamestate_; + saved_game& gamestate_; game_data gamedata_; /// undo_stack_ is never NULL. It is implemented as a pointer so that /// undo_list can be an incomplete type at this point (which reduces the diff --git a/src/playcampaign.cpp b/src/playcampaign.cpp index f7a74ba1ac25..a847224f8d4b 100644 --- a/src/playcampaign.cpp +++ b/src/playcampaign.cpp @@ -40,6 +40,7 @@ #include "gettext.hpp" #include "resources.hpp" #include "savegame.hpp" +#include "saved_game.hpp" #include "sound.hpp" #include "wml_exception.hpp" #include "unit_id.hpp" @@ -55,7 +56,7 @@ static lg::log_domain log_engine("engine"); static lg::log_domain log_enginerefac("enginerefac"); #define LOG_RG LOG_STREAM(info, log_enginerefac) -static void team_init(config& level, game_state& gamestate){ +static void team_init(config& level, saved_game& gamestate){ //if we are at the start of a new scenario, initialize carryover_sides if(gamestate.snapshot.child_or_empty("variables")["turn_number"].to_int(-1)<1){ gamestate.carryover_sides = gamestate.carryover_sides_start; @@ -72,7 +73,7 @@ static void team_init(config& level, game_state& gamestate){ } } -static void store_carryover(game_state& gamestate, playsingle_controller& playcontroller, display& disp, const end_level_data& end_level, const LEVEL_RESULT res){ +static void store_carryover(saved_game& gamestate, playsingle_controller& playcontroller, display& disp, const end_level_data& end_level, const LEVEL_RESULT res){ bool has_next_scenario = !resources::gamedata->next_scenario().empty() && resources::gamedata->next_scenario() != "null"; //explain me: when could this be the case?? @@ -184,7 +185,7 @@ static void generate_map(config const*& scenario) scenario = &new_scenario; } -LEVEL_RESULT play_replay(display& disp, game_state& gamestate, const config& game_config, +LEVEL_RESULT play_replay(display& disp, saved_game& gamestate, const config& game_config, CVideo& video, bool is_unit_test) { const std::string campaign_type_str = lexical_cast (gamestate.classification().campaign_type); @@ -245,7 +246,7 @@ LEVEL_RESULT play_replay(display& disp, game_state& gamestate, const config& gam } static LEVEL_RESULT playsingle_scenario(const config& game_config, - const config* level, display& disp, game_state& state_of_game, + const config* level, display& disp, saved_game& state_of_game, const config::const_child_itors &story, bool skip_replay, end_level_data &end_level) { @@ -289,7 +290,7 @@ static LEVEL_RESULT playsingle_scenario(const config& game_config, static LEVEL_RESULT playmp_scenario(const config& game_config, - const config* level, display& disp, game_state& state_of_game, + const config* level, display& disp, saved_game& state_of_game, const config::const_child_itors &story, bool skip_replay, bool blindfold_replay, io_type_t& io_type, end_level_data &end_level) { @@ -338,7 +339,7 @@ static LEVEL_RESULT playmp_scenario(const config& game_config, return res; } -LEVEL_RESULT play_game(game_display& disp, game_state& gamestate, +LEVEL_RESULT play_game(game_display& disp, saved_game& gamestate, const config& game_config, io_type_t io_type, bool skip_replay, bool network_game, bool blindfold_replay, bool is_unit_test) { @@ -541,7 +542,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& gamestate, } starting_pos = gamestate.replay_start(); - gamestate = game_state(starting_pos); + gamestate = saved_game(starting_pos); // Retain carryover_sides_start, as the config from the server // doesn't contain it. gamestate.carryover_sides_start = sides.to_config(); diff --git a/src/playcampaign.hpp b/src/playcampaign.hpp index d3c7bbb22b57..aad503f9da80 100644 --- a/src/playcampaign.hpp +++ b/src/playcampaign.hpp @@ -22,7 +22,7 @@ class display; class game_display; -class game_state; +class saved_game; class config; class CVideo; @@ -32,7 +32,7 @@ enum io_type_t { IO_CLIENT }; -LEVEL_RESULT play_game(game_display& disp, game_state& state, +LEVEL_RESULT play_game(game_display& disp, saved_game& state, const config& game_config, io_type_t io_type=IO_NONE, bool skip_replay = false, @@ -40,7 +40,7 @@ LEVEL_RESULT play_game(game_display& disp, game_state& state, bool blindfold_replay = false, bool is_unit_test = false); -LEVEL_RESULT play_replay(display& disp, game_state& state, +LEVEL_RESULT play_replay(display& disp, saved_game& state, const config& game_config, CVideo& video, bool is_unit_test = false); diff --git a/src/playmp_controller.cpp b/src/playmp_controller.cpp index eb9572c86977..c31ecd277a7d 100644 --- a/src/playmp_controller.cpp +++ b/src/playmp_controller.cpp @@ -37,7 +37,7 @@ static lg::log_domain log_engine("engine"); unsigned int playmp_controller::replay_last_turn_ = 0; playmp_controller::playmp_controller(const config& level, - game_state& state_of_game, const int ticks, const config& game_config, CVideo& video, + saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video, bool skip_replay, bool blindfold_replay_, bool is_host) : playsingle_controller(level, state_of_game, ticks, game_config, video, skip_replay || blindfold_replay_), //this || means that if blindfold is enabled, quick replays will be on. diff --git a/src/playmp_controller.hpp b/src/playmp_controller.hpp index 2e79b71cb557..954a6cb8b4c9 100644 --- a/src/playmp_controller.hpp +++ b/src/playmp_controller.hpp @@ -23,7 +23,7 @@ class turn_info; class playmp_controller : public playsingle_controller, public events::pump_monitor { public: - playmp_controller(const config& level, game_state& state_of_game, + playmp_controller(const config& level, saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video, bool skip_replay, bool blindfold_replay, bool is_host); virtual ~playmp_controller(); diff --git a/src/playsingle_controller.cpp b/src/playsingle_controller.cpp index 7edd5b84ce15..e18cea28e103 100644 --- a/src/playsingle_controller.cpp +++ b/src/playsingle_controller.cpp @@ -63,7 +63,7 @@ static lg::log_domain log_enginerefac("enginerefac"); #define LOG_RG LOG_STREAM(info, log_enginerefac) playsingle_controller::playsingle_controller(const config& level, - game_state& state_of_game, const int ticks, + saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video, bool skip_replay) : play_controller(level, state_of_game, ticks, game_config, video, skip_replay), cursor_setter(cursor::NORMAL), @@ -593,7 +593,7 @@ LEVEL_RESULT playsingle_controller::play_scenario( // Loading a new game is effectively a quit. // if ( game::load_game_exception::game != "" ) { - gamestate_ = game_state(); + gamestate_ = saved_game(); } throw; } catch(network::error& e) { @@ -902,7 +902,7 @@ void playsingle_controller::linger() } catch(const game::load_game_exception &) { // Loading a new game is effectively a quit. if ( game::load_game_exception::game != "" ) { - gamestate_ = game_state(); + gamestate_ = saved_game(); } throw; } diff --git a/src/playsingle_controller.hpp b/src/playsingle_controller.hpp index 8f8f76bfa64b..045b42c8dbae 100644 --- a/src/playsingle_controller.hpp +++ b/src/playsingle_controller.hpp @@ -20,10 +20,11 @@ #include "playturn_network_adapter.hpp" #include "playturn.hpp" #include "replay.hpp" +#include "saved_game.hpp" struct set_completion { - set_completion(game_state& state, const std::string& completion) : + set_completion(saved_game& state, const std::string& completion) : state_(state), completion_(completion) { } @@ -32,14 +33,14 @@ struct set_completion state_.classification().completion = completion_; } private: - game_state& state_; + saved_game& state_; const std::string completion_; }; class playsingle_controller : public play_controller { public: - playsingle_controller(const config& level, game_state& state_of_game, + playsingle_controller(const config& level, saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video, bool skip_replay); virtual ~playsingle_controller(); diff --git a/src/replay_controller.cpp b/src/replay_controller.cpp index 72d0e5e4ede6..8ae347c857af 100644 --- a/src/replay_controller.cpp +++ b/src/replay_controller.cpp @@ -29,6 +29,7 @@ #include "random_new_deterministic.hpp" #include "resources.hpp" #include "savegame.hpp" +#include "saved_game.hpp" #include "synced_context.hpp" #include @@ -45,7 +46,7 @@ static lg::log_domain log_replay("replay"); possible_end_play_signal play_replay_level_main_loop(replay_controller & replaycontroller, bool & is_unit_test); LEVEL_RESULT play_replay_level(const config& game_config, - CVideo& video, game_state& state_of_game, bool is_unit_test) + CVideo& video, saved_game& state_of_game, bool is_unit_test) { const int ticks = SDL_GetTicks(); @@ -108,7 +109,7 @@ possible_end_play_signal replay_controller::try_run_to_completion() { } replay_controller::replay_controller(const config& level, - game_state& state_of_game, const int ticks, + saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video) : play_controller(level, state_of_game, ticks, game_config, video, false), gamestate_start_(gamestate_), diff --git a/src/replay_controller.hpp b/src/replay_controller.hpp index dd8b4bd7fd2c..fcbf912a363a 100644 --- a/src/replay_controller.hpp +++ b/src/replay_controller.hpp @@ -18,6 +18,7 @@ #include "game_end_exceptions.hpp" #include "gamestatus.hpp" +#include "saved_game.hpp" #include "play_controller.hpp" #include @@ -27,7 +28,7 @@ class video; class replay_controller : public play_controller { public: - replay_controller(const config& level, game_state& state_of_game, + replay_controller(const config& level, saved_game& state_of_game, const int ticks, const config& game_config, CVideo& video); virtual ~replay_controller(); @@ -86,7 +87,7 @@ class replay_controller : public play_controller play_turn_button() && play_side_button(); } - game_state gamestate_start_; + saved_game gamestate_start_; game_board gameboard_start_; tod_manager tod_manager_start_; @@ -99,6 +100,6 @@ class replay_controller : public play_controller LEVEL_RESULT play_replay_level(const config& terrain_config, CVideo& video, - game_state& state_of_game, bool is_unit_test = false); + saved_game& state_of_game, bool is_unit_test = false); #endif diff --git a/src/saved_game.cpp b/src/saved_game.cpp new file mode 100644 index 000000000000..6f803258e8c0 --- /dev/null +++ b/src/saved_game.cpp @@ -0,0 +1,213 @@ + + +#include "saved_game.hpp" +#include "gamestatus.hpp" +#include "carryover.hpp" +#include "log.hpp" +#include "statistics.hpp" +#include "serialization/binary_or_text.hpp" +#include "util.hpp" + +#include + +static lg::log_domain log_engine("engine"); +#define ERR_NG LOG_STREAM(err, log_engine) +#define WRN_NG LOG_STREAM(warn, log_engine) +#define LOG_NG LOG_STREAM(info, log_engine) +#define DBG_NG LOG_STREAM(debug, log_engine) + +static lg::log_domain log_enginerefac("enginerefac"); +#define LOG_RG LOG_STREAM(info, log_enginerefac) + +saved_game::saved_game() : + replay_data(), + snapshot(), + carryover_sides(), + carryover_sides_start(carryover_info().to_config()), + replay_start_(), + classification_(), + mp_settings_() + {} + +saved_game::saved_game(const config& cfg, bool show_replay) : + replay_data(), + snapshot(), + carryover_sides(), + carryover_sides_start(), + replay_start_(), + classification_(cfg), + mp_settings_(cfg) +{ + log_scope("read_game"); + + if(cfg.has_child("carryover_sides")){ + carryover_sides = cfg.child("carryover_sides"); + } + if(cfg.has_child("carryover_sides_start")){ + carryover_sides_start = cfg.child("carryover_sides_start"); + } + + if(show_replay){ + //If replay_start and replay_data couldn't be loaded + if(!load_replay(cfg)){ + //TODO: notify user of failure + ERR_NG<<"Could not load as replay " << std::endl; + } + } else { + if(const config& snapshot = cfg.child("snapshot")){ + this->snapshot = snapshot; + load_replay(cfg); + } else if(carryover_sides_start.empty() && !carryover_sides.empty()){ + //if we are loading a start of scenario save and don't have carryover_sides_start, use carryover_sides + carryover_sides_start = carryover_sides; + } + //TODO: check if loading fails completely + } + + LOG_NG << "scenario: '" << carryover_sides_start["next_scenario"] << "'\n"; + + if (const config &stats = cfg.child("statistics")) { + statistics::fresh_stats(); + statistics::read_stats(stats); + } + +} + +bool saved_game::load_replay(const config& cfg){ + bool replay_loaded = false; + + if(const config& replay_start = cfg.child("replay_start")){ + replay_start_ = replay_start; + if(const config& replay = cfg.child("replay")){ + this->replay_data = replay; + replay_loaded = true; + } + } + + return replay_loaded; +} + +static void convert_old_saves(config& cfg){ + if(!cfg.has_child("snapshot")){ + return; + } + + const config& snapshot = cfg.child("snapshot"); + const config& replay_start = cfg.child("replay_start"); + const config& replay = cfg.child("replay"); + + if(!cfg.has_child("carryover_sides") && !cfg.has_child("carryover_sides_start")){ + config carryover; + //copy rng and menu items from toplevel to new carryover_sides + carryover["random_seed"] = cfg["random_seed"]; + carryover["random_calls"] = cfg["random_calls"]; + BOOST_FOREACH(const config& menu_item, cfg.child_range("menu_item")){ + carryover.add_child("menu_item", menu_item); + } + carryover["difficulty"] = cfg["difficulty"]; + carryover["random_mode"] = cfg["random_mode"]; + //the scenario to be played is always stored as next_scenario in carryover_sides_start + carryover["next_scenario"] = cfg["scenario"]; + + config carryover_start = carryover; + + //copy sides from either snapshot or replay_start to new carryover_sides + if(!snapshot.empty()){ + BOOST_FOREACH(const config& side, snapshot.child_range("side")){ + carryover.add_child("side", side); + } + //for compatibility with old savegames that use player instead of side + BOOST_FOREACH(const config& side, snapshot.child_range("player")){ + carryover.add_child("side", side); + } + //save the sides from replay_start in carryover_sides_start + BOOST_FOREACH(const config& side, replay_start.child_range("side")){ + carryover_start.add_child("side", side); + } + //for compatibility with old savegames that use player instead of side + BOOST_FOREACH(const config& side, replay_start.child_range("player")){ + carryover_start.add_child("side", side); + } + } else if (!replay_start.empty()){ + BOOST_FOREACH(const config& side, replay_start.child_range("side")){ + carryover.add_child("side", side); + carryover_start.add_child("side", side); + } + //for compatibility with old savegames that use player instead of side + BOOST_FOREACH(const config& side, replay_start.child_range("player")){ + carryover.add_child("side", side); + carryover_start.add_child("side", side); + } + } + + //get variables according to old hierarchy and copy them to new carryover_sides + if(!snapshot.empty()){ + if(const config& variables = snapshot.child("variables")){ + carryover.add_child("variables", variables); + carryover_start.add_child("variables", replay_start.child_or_empty("variables")); + } else if (const config& variables = cfg.child("variables")){ + carryover.add_child("variables", variables); + carryover_start.add_child("variables", variables); + } + } else if (!replay_start.empty()){ + if(const config& variables = replay_start.child("variables")){ + carryover.add_child("variables", variables); + carryover_start.add_child("variables", variables); + } + } else { + carryover.add_child("variables", cfg.child("variables")); + carryover_start.add_child("variables", cfg.child("variables")); + } + + cfg.add_child("carryover_sides", carryover); + cfg.add_child("carryover_sides_start", carryover_start); + } + + //if replay and snapshot are empty we've got a start of scenario save and don't want replay_start either + if(replay.empty() && snapshot.empty()){ + LOG_RG<<"removing replay_start \n"; + cfg.remove_child("replay_start", 0); + } + + //remove empty replay or snapshot so type of save can be detected more easily + if(replay.empty()){ + LOG_RG<<"removing replay \n"; + cfg.remove_child("replay", 0); + } + + if(snapshot.empty()){ + LOG_RG<<"removing snapshot \n"; + cfg.remove_child("snapshot", 0); + } + + LOG_RG<<"cfg after conversion "<~saved_game(); + new (this) saved_game(state) ; + } + return *this ; +} + + +void saved_game::write_config(config_writer& out) const +{ + out.write(classification_.to_config()); + if (classification_.campaign_type == game_classification::MULTIPLAYER) { + out.write_child(lexical_cast(game_classification::MULTIPLAYER), mp_settings_.to_config()); + } +} diff --git a/src/saved_game.hpp b/src/saved_game.hpp new file mode 100644 index 000000000000..81653dd6fbb3 --- /dev/null +++ b/src/saved_game.hpp @@ -0,0 +1,64 @@ + +#ifndef SAVED_GAME_HPP_INCLUDED +#define SAVED_GAME_HPP_INCLUDED + +#include "config.hpp" +#include "gamestatus.hpp" //game_classification + +class config_writer; + + +class saved_game +{ +public: + saved_game(); + saved_game(const saved_game& state); + explicit saved_game(const config& cfg, bool show_replay = false); + + ~saved_game(){} + saved_game& operator=(const saved_game& state); + + //write the config information into a stream (file) + void write_config(config_writer& out) const; + + game_classification& classification() { return classification_; } + const game_classification& classification() const { return classification_; } + + /** Multiplayer parameters for this game */ + mp_game_settings& mp_settings() { return mp_settings_; } + const mp_game_settings& mp_settings() const { return mp_settings_; } + + bool load_replay(const config& cfg); + + config& replay_start() { return replay_start_; } + + /** + * If the game is saved mid-level, we have a series of replay steps + * to take the game up to the position it was saved at. + */ + config replay_data; + + /** + * Snapshot of the game's current contents. + * + * i.e. unless the player selects to view a replay, the game's settings are + * read in from this object. + */ + config snapshot; + + /** The carryover information for all sides*/ + config carryover_sides; + + /** The carryover information for all sides as it was before the scenario started*/ + config carryover_sides_start; + +private: + /** First turn snapshot for replays, contains starting position */ + config replay_start_; + + game_classification classification_; + mp_game_settings mp_settings_; +}; + + +#endif diff --git a/src/savegame.cpp b/src/savegame.cpp index efab69283769..89575def4db5 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -82,7 +82,7 @@ void clean_saves(const std::string& label) } } -loadgame::loadgame(display& gui, const config& game_config, game_state& gamestate) +loadgame::loadgame(display& gui, const config& game_config, saved_game& gamestate) : game_config_(game_config) , gui_(gui) , gamestate_(gamestate) @@ -293,7 +293,7 @@ void loadgame::check_version_compatibility() void loadgame::set_gamestate() { - gamestate_ = game_state(load_config_, show_replay_); + gamestate_ = saved_game(load_config_, show_replay_); // Get the status of the random in the snapshot. // For a replay we need to restore the start only, the replaying gets at @@ -325,7 +325,7 @@ void loadgame::load_multiplayer_game() read_save_file(filename_, load_config_, &error_log); copy_era(load_config_); - gamestate_ = game_state(load_config_); + gamestate_ = saved_game(load_config_); } if(!error_log.empty()) { @@ -398,7 +398,7 @@ void loadgame::copy_era(config &cfg) snapshot.add_child("era", era); } -savegame::savegame(game_state& gamestate, const compression::format compress_saves, const std::string& title) +savegame::savegame(saved_game& gamestate, const compression::format compress_saves, const std::string& title) : gamestate_(gamestate) , snapshot_() , filename_() @@ -618,7 +618,7 @@ scoped_ostream savegame::open_save_game(const std::string &label) } } -scenariostart_savegame::scenariostart_savegame(game_state &gamestate, const compression::format compress_saves) +scenariostart_savegame::scenariostart_savegame(saved_game &gamestate, const compression::format compress_saves) : savegame(gamestate, compress_saves) { set_filename(gamestate.classification().label); @@ -630,7 +630,7 @@ void scenariostart_savegame::write_game(config_writer &out){ out.write_child("carryover_sides_start", gamestate().carryover_sides_start); } -replay_savegame::replay_savegame(game_state &gamestate, const compression::format compress_saves) +replay_savegame::replay_savegame(saved_game &gamestate, const compression::format compress_saves) : savegame(gamestate, compress_saves, _("Save Replay")) {} @@ -654,7 +654,7 @@ void replay_savegame::write_game(config_writer &out) { out.write_child("replay", gamestate().replay_data); } -autosave_savegame::autosave_savegame(game_state &gamestate, +autosave_savegame::autosave_savegame(saved_game &gamestate, game_display& gui, const config& snapshot_cfg, const compression::format compress_saves) : ingame_savegame(gamestate, gui, snapshot_cfg, compress_saves) { @@ -682,7 +682,7 @@ void autosave_savegame::create_filename() set_filename(filename); } -oos_savegame::oos_savegame(game_state& gamestate, game_display& gui, const config& snapshot_cfg) +oos_savegame::oos_savegame(saved_game& gamestate, game_display& gui, const config& snapshot_cfg) : ingame_savegame(gamestate, gui, snapshot_cfg, preferences::save_compression_format()) {} @@ -705,7 +705,7 @@ int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, co return res; } -ingame_savegame::ingame_savegame(game_state &gamestate, +ingame_savegame::ingame_savegame(saved_game &gamestate, game_display& gui, const config& snapshot_cfg, const compression::format compress_saves) : savegame(gamestate, compress_saves, _("Save Game")), gui_(gui) diff --git a/src/savegame.hpp b/src/savegame.hpp index 52816400629c..85e29533a5ed 100644 --- a/src/savegame.hpp +++ b/src/savegame.hpp @@ -18,6 +18,7 @@ #include "filesystem.hpp" #include "gamestatus.hpp" +#include "saved_game.hpp" #include "show_dialog.hpp" #include "serialization/compression.hpp" class config_writer; @@ -38,7 +39,7 @@ void clean_saves(const std::string& label); class loadgame { public: - loadgame(display& gui, const config& game_config, game_state& gamestate); + loadgame(display& gui, const config& game_config, saved_game& gamestate); virtual ~loadgame() {} /** Load a game without providing any information. */ @@ -74,7 +75,7 @@ class loadgame const config& game_config_; display& gui_; - game_state& gamestate_; /** Primary output information. */ + saved_game& gamestate_; /** Primary output information. */ std::string filename_; /** Name of the savefile to be loaded. */ std::string difficulty_; /** The difficulty the save is meant to be loaded with. */ config load_config_; /** Config information of the savefile to be loaded. */ @@ -93,7 +94,7 @@ class savegame protected: /** The only constructor of savegame. The title parameter is only necessary if you intend to do interactive saves. */ - savegame(game_state& gamestate, const compression::format compress_saves, const std::string& title = "Save"); + savegame(saved_game& gamestate, const compression::format compress_saves, const std::string& title = "Save"); public: virtual ~savegame() {} @@ -130,7 +131,7 @@ class savegame void set_error_message(const std::string& error_message) { error_message_ = error_message; } const std::string& title() { return title_; } - game_state& gamestate() { return gamestate_; } + saved_game& gamestate() { return gamestate_; } config& snapshot() { return snapshot_; } /** If there needs to be some data fiddling before saving the game, this is the place to go. */ @@ -161,7 +162,7 @@ class savegame scoped_ostream open_save_game(const std::string &label); friend class save_info; - game_state& gamestate_; + saved_game& gamestate_; /** Gamestate information at the time of saving. Note that this object is needed here, since even if it is empty the code relies on it to be there. */ @@ -183,7 +184,7 @@ class savegame class ingame_savegame : public savegame { public: - ingame_savegame(game_state& gamestate, + ingame_savegame(saved_game& gamestate, game_display& gui, const config& snapshot_cfg, const compression::format compress_saves); private: @@ -201,7 +202,7 @@ class ingame_savegame : public savegame class replay_savegame : public savegame { public: - replay_savegame(game_state& gamestate, const compression::format compress_saves); + replay_savegame(saved_game& gamestate, const compression::format compress_saves); private: /** Create a filename for automatic saves */ @@ -214,7 +215,7 @@ class replay_savegame : public savegame class autosave_savegame : public ingame_savegame { public: - autosave_savegame(game_state &gamestate, + autosave_savegame(saved_game &gamestate, game_display& gui, const config& snapshot_cfg, const compression::format compress_saves); void autosave(const bool disable_autosave, const int autosave_max, const int infinite_autosaves); @@ -226,7 +227,7 @@ class autosave_savegame : public ingame_savegame class oos_savegame : public ingame_savegame { public: - oos_savegame(game_state& gamestate, game_display& gui, const config& snapshot_cfg); + oos_savegame(saved_game& gamestate, game_display& gui, const config& snapshot_cfg); private: /** Display the save game dialog. */ @@ -237,7 +238,7 @@ class oos_savegame : public ingame_savegame class scenariostart_savegame : public savegame { public: - scenariostart_savegame(game_state& gamestate, const compression::format compress_saves); + scenariostart_savegame(saved_game& gamestate, const compression::format compress_saves); private: void write_game(config_writer &out); diff --git a/src/tests/utils/play_scenario.cpp b/src/tests/utils/play_scenario.cpp index 0402440cad31..49e27304aea3 100644 --- a/src/tests/utils/play_scenario.cpp +++ b/src/tests/utils/play_scenario.cpp @@ -19,7 +19,7 @@ #include "tests/utils/fake_display.hpp" #include "game_display.hpp" -#include "gamestatus.hpp" +#include "saved_game.hpp" #include "playcampaign.hpp" #include "unit.hpp" #include "unit_map.hpp" @@ -68,7 +68,7 @@ namespace test_utils { } class end_position_collector : public event_node { - game_state state_; + saved_game state_; unit_map units_; public: @@ -85,7 +85,7 @@ namespace test_utils { units_ = game_display::get_singleton()->get_units(); } - game_state& get_state() + saved_game& get_state() { return state_; } @@ -108,7 +108,7 @@ namespace test_utils { source_.type_key(current_time_++, SDLK_EXCLAIM); source_.type_key(current_time_++, SDLK_RETURN); - game_state& state = end->get_state(); + saved_game& state = end->get_state(); state.classification().campaign_type = game_classification::TEST; state.carryover_sides_start["next_scenario"] = id_; play_game(get_fake_display(1024, 768), state, game_config_);