Merge branch 'master' of git://github.com/wesnoth/wesnoth
This commit is contained in:
commit
148d42ea88
38 changed files with 285 additions and 260 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -84,8 +84,8 @@ public:
|
|||
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();
|
||||
|
||||
|
|
|
@ -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_()
|
||||
{
|
||||
/*
|
||||
|
|
|
@ -157,9 +157,12 @@ public:
|
|||
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 @@ private:
|
|||
unit_map units_;
|
||||
std::vector<team> teams_;
|
||||
boost::scoped_ptr<tod_manager> tod_manager_;
|
||||
game_state state_;
|
||||
mp_game_settings mp_settings_;
|
||||
game_classification game_classification_;
|
||||
|
||||
typedef std::map<std::string, sound::music_track> music_map;
|
||||
music_map music_tracks_;
|
||||
|
|
|
@ -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<config> &campaigns)
|
|||
|
||||
bool game_controller::new_campaign()
|
||||
{
|
||||
state_ = game_state();
|
||||
state_ = saved_game();
|
||||
state_.classification().campaign_type = game_classification::SCENARIO;
|
||||
|
||||
std::vector<config> 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->
|
||||
|
|
|
@ -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 @@ private:
|
|||
|
||||
std::string screenshot_map_, screenshot_filename_;
|
||||
|
||||
game_state state_;
|
||||
saved_game state_;
|
||||
|
||||
std::string multiplayer_server_;
|
||||
bool jump_to_multiplayer_;
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
class game_board;
|
||||
class gamemap;
|
||||
class game_state;
|
||||
class team;
|
||||
class unit_map;
|
||||
|
||||
|
|
|
@ -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 "<<cfg<<"\n";
|
||||
}
|
||||
|
||||
game_state::game_state(const game_state& state) :
|
||||
replay_data(state.replay_data),
|
||||
snapshot(state.snapshot),
|
||||
carryover_sides(state.carryover_sides),
|
||||
carryover_sides_start(state.carryover_sides_start),
|
||||
replay_start_(state.replay_start_),
|
||||
classification_(state.classification_),
|
||||
mp_settings_(state.mp_settings_)
|
||||
{}
|
||||
|
||||
game_state& game_state::operator=(const game_state& state)
|
||||
{
|
||||
// Use copy constructor to make sure we are coherent
|
||||
if (this != &state) {
|
||||
this->~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<std::string>(game_classification::MULTIPLAYER), mp_settings_.to_config());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,56 +163,4 @@ public:
|
|||
};
|
||||
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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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_(),
|
||||
|
|
|
@ -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 <boost/scoped_ptr.hpp>
|
||||
|
||||
namespace mp {
|
||||
|
@ -43,7 +43,7 @@ typedef std::pair<mp::controller, std::string> 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 @@ private:
|
|||
friend class side_engine;
|
||||
|
||||
config level_;
|
||||
game_state& state_;
|
||||
saved_game& state_;
|
||||
|
||||
const mp_game_settings& params_;
|
||||
|
||||
|
|
|
@ -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()),
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
class game_state;
|
||||
class saved_game;
|
||||
|
||||
namespace mp {
|
||||
|
||||
|
@ -157,7 +157,7 @@ private:
|
|||
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 @@ private:
|
|||
std::vector<extras_metadata_ptr> eras_;
|
||||
std::vector<extras_metadata_ptr> mods_;
|
||||
|
||||
game_state& state_;
|
||||
saved_game& state_;
|
||||
mp_game_settings parameters_;
|
||||
|
||||
depcheck::manager dependency_manager_;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ private:
|
|||
gui::menu game_menu_;
|
||||
|
||||
config level_;
|
||||
game_state& state_;
|
||||
saved_game& state_;
|
||||
|
||||
const bool first_scenario_;
|
||||
bool stop_updates_;
|
||||
|
|
|
@ -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"
|
||||
|
@ -93,7 +94,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),
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
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 @@ protected:
|
|||
boost::scoped_ptr<game_display> 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
|
||||
|
|
|
@ -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<std::string> (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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "random_new_deterministic.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "savegame.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "synced_context.hpp"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
@ -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_),
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "game_end_exceptions.hpp"
|
||||
#include "gamestatus.hpp"
|
||||
#include "saved_game.hpp"
|
||||
#include "play_controller.hpp"
|
||||
|
||||
#include <vector>
|
||||
|
@ -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 @@ private:
|
|||
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 @@ private:
|
|||
|
||||
|
||||
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
|
||||
|
|
92
src/saved_game.cpp
Normal file
92
src/saved_game.cpp
Normal file
|
@ -0,0 +1,92 @@
|
|||
|
||||
|
||||
#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 <boost/foreach.hpp>
|
||||
|
||||
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)
|
||||
: replay_data()
|
||||
, snapshot()
|
||||
, carryover_sides()
|
||||
, carryover_sides_start()
|
||||
, replay_start_()
|
||||
, classification_(cfg)
|
||||
, mp_settings_(cfg)
|
||||
{
|
||||
log_scope("read_game");
|
||||
|
||||
carryover_sides = cfg.child_or_empty("carryover_sides");
|
||||
carryover_sides_start = cfg.child_or_empty("carryover_sides_start");
|
||||
replay_start_ = cfg.child_or_empty("replay_start");
|
||||
replay_data = cfg.child_or_empty("replay");
|
||||
snapshot = cfg.child_or_empty("snapshot");
|
||||
|
||||
if(snapshot.empty() && carryover_sides_start.empty() && !carryover_sides.empty())
|
||||
{
|
||||
//Explain me: when could this happen?
|
||||
//if we are loading a start of scenario save and don't have carryover_sides_start, use carryover_sides
|
||||
carryover_sides_start = carryover_sides;
|
||||
}
|
||||
|
||||
LOG_NG << "scenario: '" << carryover_sides_start["next_scenario"].str() << "'\n";
|
||||
|
||||
if (const config &stats = cfg.child("statistics")) {
|
||||
statistics::fresh_stats();
|
||||
statistics::read_stats(stats);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
saved_game::saved_game(const saved_game& state) :
|
||||
replay_data(state.replay_data),
|
||||
snapshot(state.snapshot),
|
||||
carryover_sides(state.carryover_sides),
|
||||
carryover_sides_start(state.carryover_sides_start),
|
||||
replay_start_(state.replay_start_),
|
||||
classification_(state.classification_),
|
||||
mp_settings_(state.mp_settings_)
|
||||
{}
|
||||
|
||||
saved_game& saved_game::operator=(const saved_game& state)
|
||||
{
|
||||
// Use copy constructor to make sure we are coherent
|
||||
if (this != &state) {
|
||||
this->~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<std::string>(game_classification::MULTIPLAYER), mp_settings_.to_config());
|
||||
}
|
||||
}
|
62
src/saved_game.hpp
Normal file
62
src/saved_game.hpp
Normal file
|
@ -0,0 +1,62 @@
|
|||
|
||||
#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);
|
||||
|
||||
~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_; }
|
||||
|
||||
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
|
|
@ -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,11 @@ void loadgame::check_version_compatibility()
|
|||
|
||||
void loadgame::set_gamestate()
|
||||
{
|
||||
gamestate_ = game_state(load_config_, show_replay_);
|
||||
gamestate_ = saved_game(load_config_);
|
||||
#if 0
|
||||
//we dont need this code since we always restore our random from [snapshot] or [replay_start] (execpt for start of scenario saves where we dont have those)
|
||||
//also the random_seed isn't stored at toplevel anymore.
|
||||
|
||||
|
||||
// Get the status of the random in the snapshot.
|
||||
// For a replay we need to restore the start only, the replaying gets at
|
||||
|
@ -308,6 +312,7 @@ void loadgame::set_gamestate()
|
|||
carryover_info sides(gamestate_.carryover_sides_start);
|
||||
sides.rng().seed_random(seed, calls);
|
||||
gamestate_.carryover_sides_start = sides.to_config();
|
||||
#endif
|
||||
}
|
||||
|
||||
void loadgame::load_multiplayer_game()
|
||||
|
@ -325,7 +330,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 +403,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 +623,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 +635,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 +659,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 +687,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 +710,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)
|
||||
|
|
|
@ -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 @@ private:
|
|||
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 @@ protected:
|
|||
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 @@ private:
|
|||
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 @@ private:
|
|||
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 @@ protected:
|
|||
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 @@ private:
|
|||
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 @@ private:
|
|||
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 @@ private:
|
|||
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);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "multiplayer_connect.hpp"
|
||||
#include "multiplayer_ui.hpp"
|
||||
#include "hotkey/hotkey_manager.hpp"
|
||||
#include "saved_game.hpp"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
@ -39,7 +40,7 @@ public:
|
|||
|
||||
class test_mp_connect_engine : public mp::connect_engine {
|
||||
public:
|
||||
test_mp_connect_engine(game_display& disp, game_state& gamestate,
|
||||
test_mp_connect_engine(game_display& disp, saved_game& gamestate,
|
||||
const mp_game_settings& params) :
|
||||
mp::connect_engine(disp, gamestate, params, true, true)
|
||||
{}
|
||||
|
@ -52,7 +53,7 @@ namespace {
|
|||
|
||||
boost::scoped_ptr<game_display> disp;
|
||||
boost::scoped_ptr<mp_game_settings> params;
|
||||
boost::scoped_ptr<game_state> state;
|
||||
boost::scoped_ptr<saved_game> state;
|
||||
|
||||
}
|
||||
|
||||
|
@ -74,7 +75,7 @@ struct mp_connect_fixture {
|
|||
false));
|
||||
config_manager->init_game_config(game_config_manager::NO_FORCE_RELOAD);
|
||||
|
||||
state.reset(new game_state());
|
||||
state.reset(new saved_game());
|
||||
state->classification().campaign_type = game_classification::MULTIPLAYER;
|
||||
config_manager->load_game_config_for_game(state->classification());
|
||||
|
||||
|
|
|
@ -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_);
|
||||
|
|
Loading…
Add table
Reference in a new issue