#include <saved_game.hpp>
Public Member Functions | |
saved_game () | |
saved_game (const saved_game &state) | |
saved_game (config cfg) | |
~saved_game () | |
saved_game & | operator= (saved_game other) |
void | swap (saved_game &other) |
void | set_data (config &cfg) |
destroys the passed config. More... | |
void | write_config (config_writer &out) const |
writes the config information into a stream (file) More... | |
void | write_general_info (config_writer &out) const |
void | write_carryover (config_writer &out) const |
void | write_starting_pos (config_writer &out) const |
config | to_config () const |
game_classification & | classification () |
const game_classification & | classification () const |
mp_game_settings & | mp_settings () |
Multiplayer parameters for this game. More... | |
const mp_game_settings & | mp_settings () const |
void | set_carryover_sides_start (config carryover_sides_start) |
void | expand_scenario () |
copies the content of a [scenario] with the correct id attribute from the game config into this object. More... | |
void | expand_carryover () |
merges [carryover_sides_start] into [scenario] and saves the rest into [carryover_sides] Removes [carryover_sides_start] afterwards More... | |
void | expand_mp_events () |
adds [event]s from [era] and [modification] into this scenario does NOT expand [option]s because variables are persitent anyway to we don't need it should be called after expand_scenario() but before expand_carryover() More... | |
void | load_mod (const std::string &type, const std::string &id) |
helper for expand_mp_events(); More... | |
void | expand_mp_options () |
adds values of [option]s into [carryover_sides_start][variables] so that they are applied in the next level. More... | |
void | expand_random_scenario () |
takes care of generate_map=, generate_scenario=, map= attributes This should be called before expanding carryover or mp_events because this might completely replace starting_pos_. More... | |
bool | valid () |
config & | set_snapshot (config snapshot) |
void | set_scenario (config scenario) |
void | remove_snapshot () |
bool | is_mid_game_save () |
void | convert_to_start_save () |
converts a normal savegame form the end of a scenaio to a start-of-scenario savefile for the next scenaio, The saved_game must contain a [snapshot] made during the linger mode of the last scenaio. More... | |
void | set_random_seed () |
sets the random seed if that didn't already happen. More... | |
const config & | get_replay_starting_pos () |
std::string | get_scenario_id () |
config & | get_starting_pos () |
const config & | get_starting_pos () const |
config & | replay_start () |
const config & | replay_start () const |
bool | not_corrupt () const |
void | update_label () |
sets classification().label to the correct value. More... | |
void | cancel_orders () |
void | unify_controllers () |
void | set_defaults () |
does some post loading stuff must be used before passing the data to connect_engine More... | |
replay_recorder_base & | get_replay () |
const replay_recorder_base & | get_replay () const |
Private Types | |
enum | STARTING_POS_TYPE { STARTINGPOS_NONE, STARTINGPOS_SNAPSHOT, STARTINGPOS_SCENARIO, STARTINGPOS_INVALID } |
Private Attributes | |
bool | has_carryover_expanded_ |
config | carryover_ |
depends on has_carryover_expanded_: if true: The carryover information for all sides from the previous scenario that aren't used in this scenario (to be carried over to the next scenario). More... | |
config | replay_start_ |
snapshot made before the start event. More... | |
game_classification | classification_ |
some general information of the game that doesn't change during the game More... | |
mp_game_settings | mp_settings_ |
STARTING_POS_TYPE | starting_pos_type_ |
config | starting_pos_ |
The starting pos where the (non replay) game will be started from. More... | |
replay_recorder_base | replay_data_ |
Definition at line 25 of file saved_game.hpp.
|
private |
Definition at line 27 of file saved_game.hpp.
saved_game::saved_game | ( | ) |
Definition at line 74 of file saved_game.cpp.
saved_game::saved_game | ( | const saved_game & | state | ) |
Definition at line 101 of file saved_game.cpp.
|
explicit |
Definition at line 87 of file saved_game.cpp.
References set_data().
|
inline |
Definition at line 42 of file saved_game.hpp.
void saved_game::cancel_orders | ( | ) |
Definition at line 567 of file saved_game.cpp.
References config::child_range(), and starting_pos_.
Referenced by game_launcher::load_game(), and mp::create::process_event_impl().
|
inline |
Definition at line 54 of file saved_game.hpp.
References classification_.
Referenced by mp::add_multiplayer_classification(), savegame::loadgame::check_version_compatibility(), mp::configure::configure(), ng::configure_engine::configure_engine(), ng::connect_engine::connect_engine(), ng::create_engine::create_engine(), savegame::autosave_savegame::create_filename(), sp::enter_create_mode(), play_controller::hotkey_handler::expand_autosaves(), expand_mp_options(), expand_scenario(), ng::configure_engine::fog_game_default(), ng::configure_engine::force_lock_settings(), play_controller::get_classification(), ng::create_engine::init_all_levels(), ng::create_engine::init_extras(), mp::wait::join_game(), game_launcher::launch_game(), mp::level_to_gamestate(), savegame::loadgame::load_game(), game_launcher::load_game(), savegame::loadgame::load_multiplayer_game(), game_launcher::new_campaign(), play_controller::play_controller(), campaign_controller::play_game(), game_launcher::play_multiplayer(), game_launcher::play_multiplayer_commandline(), game_launcher::play_render_image_mode(), playsingle_controller::play_scenario_init(), game_launcher::play_test(), ng::create_engine::prepare_for_campaign(), ng::create_engine::prepare_for_era_and_mods(), ng::create_engine::prepare_for_saved_game(), ng::create_engine::prepare_for_scenario(), savegame::scenariostart_savegame::scenariostart_savegame(), set_defaults(), ng::configure_engine::set_oos_debug(), game_launcher::set_tutorial(), campaign_controller::show_carryover_message(), ng::side_engine::side_engine(), mp::start_client(), mp::start_local_game_commandline(), game_launcher::unit_test(), update_label(), ng::configure_engine::village_gold_default(), and mp::wait::~wait().
|
inline |
Definition at line 55 of file saved_game.hpp.
References classification_.
void saved_game::convert_to_start_save | ( | ) |
converts a normal savegame form the end of a scenaio to a start-of-scenario savefile for the next scenaio, The saved_game must contain a [snapshot] made during the linger mode of the last scenaio.
Definition at line 497 of file saved_game.cpp.
References carryover_, has_carryover_expanded_, carryover_info::merge_old_carryover(), remove_snapshot(), replay_data_, replay_start_, carryover_info::rng(), rand_rng::mt_rng::rotate_random(), starting_pos_, starting_pos_type_, STARTINGPOS_SNAPSHOT, and carryover_info::to_config().
Referenced by campaign_controller::play_game().
void saved_game::expand_carryover | ( | ) |
merges [carryover_sides_start] into [scenario] and saves the rest into [carryover_sides] Removes [carryover_sides_start] afterwards
Definition at line 428 of file saved_game.cpp.
References carryover_, expand_scenario(), get_starting_pos(), has_carryover_expanded_, starting_pos_type_, STARTINGPOS_SCENARIO, carryover_info::to_config(), carryover_info::transfer_all_to(), and carryover_info::transfer_to().
Referenced by get_replay_starting_pos(), and campaign_controller::play_game().
void saved_game::expand_mp_events | ( | ) |
adds [event]s from [era] and [modification] into this scenario does NOT expand [option]s because variables are persitent anyway to we don't need it should be called after expand_scenario() but before expand_carryover()
Definition at line 321 of file saved_game.cpp.
References mp_game_settings::active_mods, game_classification::campaign, config::child_range(), classification_, config::clear_children(), expand_scenario(), load_mod(), mp_game_settings::mp_era, mp_settings_, starting_pos_, starting_pos_type_, and STARTINGPOS_SCENARIO.
Referenced by mp::initial_level_config(), campaign_controller::play_game(), and mp::start_local_game_commandline().
void saved_game::expand_mp_options | ( | ) |
adds values of [option]s into [carryover_sides_start][variables] so that they are applied in the next level.
Note that since [variabels] are persistent we only use this once at the beginning of a campaign but calling it multiple times is no harm eigher
Definition at line 356 of file saved_game.cpp.
References mp_game_settings::active_mods, carryover_, config::child_or_add(), config::child_range(), classification(), config::find_child(), get_scenario_id(), has_carryover_expanded_, LOG_NG, mp_game_settings::mp_era, mp_settings(), mp_settings_, preferences::options(), starting_pos_type_, and STARTINGPOS_SCENARIO.
Referenced by mp::initial_level_config(), campaign_controller::play_game(), and mp::start_local_game_commandline().
void saved_game::expand_random_scenario | ( | ) |
takes care of generate_map=, generate_scenario=, map= attributes This should be called before expanding carryover or mp_events because this might completely replace starting_pos_.
Definition at line 387 of file saved_game.cpp.
References config::add_child(), config::child(), config::child_range(), expand_scenario(), LOG_NG, random_generate_map(), random_generate_scenario(), filesystem::read_map(), set_defaults(), starting_pos_, starting_pos_type_, STARTINGPOS_SCENARIO, update_label(), and cursor::WAIT.
Referenced by mp::initial_level_config(), campaign_controller::play_game(), ng::create_engine::prepare_for_new_level(), and mp::start_local_game_commandline().
void saved_game::expand_scenario | ( | ) |
copies the content of a [scenario] with the correct id attribute from the game config into this object.
reloads the game config from disk if necessary.
Definition at line 204 of file saved_game.cpp.
References carryover_, classification(), config::find_child(), game_config_manager::game_config(), game_config_manager::get(), has_carryover_expanded_, mp_game_settings::hash, config::hash(), game_config_manager::load_game_config_for_game(), mp_settings_, set_defaults(), starting_pos_, starting_pos_type_, STARTINGPOS_INVALID, STARTINGPOS_NONE, STARTINGPOS_SCENARIO, mp_game_settings::update_addon_requirements(), and update_label().
Referenced by expand_carryover(), expand_mp_events(), expand_random_scenario(), get_replay_starting_pos(), campaign_controller::play_game(), ng::create_engine::prepare_for_new_level(), and ng::create_engine::prepare_for_saved_game().
|
inline |
Definition at line 116 of file saved_game.hpp.
References replay_data_.
Referenced by campaign_controller::play_game(), play_controller::reset_gamestate(), play_controller::to_config(), savegame::ingame_savegame::write_game(), and savegame::replay_savegame::write_game().
|
inline |
Definition at line 117 of file saved_game.hpp.
References replay_data_.
const config & saved_game::get_replay_starting_pos | ( | ) |
Definition at line 478 of file saved_game.cpp.
References config::child(), config::empty(), expand_carryover(), expand_scenario(), has_carryover_expanded_, replay_start_, starting_pos_, starting_pos_type_, and STARTINGPOS_SCENARIO.
Referenced by campaign_controller::playsingle_scenario().
std::string saved_game::get_scenario_id | ( | ) |
Definition at line 533 of file saved_game.cpp.
References carryover_, has_carryover_expanded_, starting_pos_, starting_pos_type_, STARTINGPOS_SCENARIO, and STARTINGPOS_SNAPSHOT.
Referenced by mp::add_multiplayer_classification(), mp::configure::configure(), sp::enter_create_mode(), expand_mp_options(), and campaign_controller::play_game().
config & saved_game::get_starting_pos | ( | ) |
Definition at line 472 of file saved_game.cpp.
References starting_pos_.
Referenced by mp::add_multiplayer_classification(), ng::configure_engine::configure_engine(), savegame::autosave_savegame::create_filename(), enter_configure_mode(), expand_carryover(), ng::configure_engine::force_lock_settings(), mp::initial_level_config(), ng::configure_engine::num_turns_default(), campaign_controller::play_game(), campaign_controller::playmp_scenario(), campaign_controller::playsingle_scenario(), ng::configure_engine::random_start_time_default(), mp::start_local_game_commandline(), ng::configure_engine::write_parameters(), and ng::configure_engine::xp_modifier_default().
|
inline |
Definition at line 103 of file saved_game.hpp.
References starting_pos_.
|
inline |
Definition at line 88 of file saved_game.hpp.
References starting_pos_type_, and STARTINGPOS_SNAPSHOT.
Referenced by game_launcher::load_game().
void saved_game::load_mod | ( | const std::string & | type, |
const std::string & | id | ||
) |
helper for expand_mp_events();
Definition at line 281 of file saved_game.cpp.
References config::add_child(), carryover_, config::child_or_empty(), config::child_range(), ERR_NG, game_config_manager::get(), mp_settings_, starting_pos_, and mp_game_settings::update_addon_requirements().
Referenced by expand_mp_events().
|
inline |
Multiplayer parameters for this game.
Definition at line 58 of file saved_game.hpp.
References mp_settings_.
Referenced by ng::create_engine::active_mods(), playmp_controller::after_human_turn(), ng::connect_engine::connect_engine(), ng::create_engine::create_engine(), sp::enter_connect_mode(), enter_connect_mode(), expand_mp_options(), play_controller::get_mp_settings(), ng::create_engine::get_parameters(), play_controller::init(), ng::create_engine::init_active_mods(), mp::initial_level_config(), mp::level_to_gamestate(), game_launcher::new_campaign(), play_controller::play_controller(), campaign_controller::play_game(), playmp_controller::play_human_turn(), game_launcher::play_test(), gui2::tcampaign_settings::post_show(), gui2::tcampaign_settings::pre_show(), ng::create_engine::prepare_for_other(), ng::create_engine::prepare_for_saved_game(), game_launcher::set_tutorial(), ng::connect_engine::start_game(), play_controller::start_game(), mp::start_local_game_commandline(), ng::create_engine::toggle_current_mod(), and ng::configure_engine::write_parameters().
|
inline |
Definition at line 59 of file saved_game.hpp.
References mp_settings_.
bool saved_game::not_corrupt | ( | ) | const |
Definition at line 553 of file saved_game.cpp.
Referenced by write_carryover().
saved_game & saved_game::operator= | ( | saved_game | other | ) |
Definition at line 594 of file saved_game.cpp.
References swap().
void saved_game::remove_snapshot | ( | ) |
Definition at line 466 of file saved_game.cpp.
References starting_pos_, starting_pos_type_, and STARTINGPOS_NONE.
Referenced by convert_to_start_save(), and playsingle_controller::play_scenario().
|
inline |
Definition at line 104 of file saved_game.hpp.
References replay_start_.
Referenced by playsingle_controller::enable_replay(), playsingle_controller::play_scenario_init(), and set_data().
|
inline |
Definition at line 105 of file saved_game.hpp.
References replay_start_.
Definition at line 113 of file saved_game.cpp.
References carryover_, has_carryover_expanded_, and config::swap().
Referenced by sp::enter_create_mode(), game_launcher::play_test(), ng::create_engine::prepare_for_campaign(), ng::create_engine::prepare_for_scenario(), game_launcher::set_tutorial(), mp::start_local_game_commandline(), and game_launcher::unit_test().
destroys the passed config.
Definition at line 612 of file saved_game.cpp.
References replay_recorder_base::append_config(), carryover_, config::child(), config::child_or_empty(), config::child_range(), classification_, config::clear(), statistics::fresh_stats(), has_carryover_expanded_, LOG_NG, log_scope, mp_settings_, statistics::read_stats(), replay_data_, replay_start(), replay_start_, replay_recorder_base::set_to_end(), starting_pos_, starting_pos_type_, STARTINGPOS_NONE, STARTINGPOS_SCENARIO, STARTINGPOS_SNAPSHOT, and config::swap().
Referenced by savegame::loadgame::load_multiplayer_game(), saved_game(), and savegame::loadgame::set_gamestate().
void saved_game::set_defaults | ( | ) |
does some post loading stuff must be used before passing the data to connect_engine
Definition at line 167 of file saved_game.cpp.
References config::child_range(), classification(), config::attribute_value::empty(), ERR_NG, config::get(), game_classification::get_tagname(), starting_pos_, starting_pos_type_, and STARTINGPOS_SCENARIO.
Referenced by expand_random_scenario(), expand_scenario(), and mp::initial_level_config().
void saved_game::set_random_seed | ( | ) |
sets the random seed if that didn't already happen.
Definition at line 119 of file saved_game.cpp.
References carryover_, and has_carryover_expanded_.
Referenced by mp::initial_level_config().
Definition at line 458 of file saved_game.cpp.
References has_carryover_expanded_, starting_pos_, starting_pos_type_, STARTINGPOS_SCENARIO, config::swap(), and update_label().
Referenced by ng::create_engine::prepare_for_other(), and ng::configure_engine::set_scenario().
Definition at line 451 of file saved_game.cpp.
References starting_pos_, starting_pos_type_, STARTINGPOS_SNAPSHOT, and config::swap().
Referenced by playsingle_controller::play_scenario(), campaign_controller::playsingle_scenario(), and play_controller::update_savegame_snapshot().
void saved_game::swap | ( | saved_game & | other | ) |
Definition at line 600 of file saved_game.cpp.
References carryover_, classification_, has_carryover_expanded_, mp_settings_, replay_data_, replay_start_, starting_pos_, starting_pos_type_, replay_recorder_base::swap(), swap(), and config::swap().
Referenced by operator=().
config saved_game::to_config | ( | ) | const |
Definition at line 510 of file saved_game.cpp.
References config::add_child(), carryover_, classification_, config::empty(), has_carryover_expanded_, mp_settings_, replay_data_, replay_start_, starting_pos_, starting_pos_type_, STARTINGPOS_SCENARIO, STARTINGPOS_SNAPSHOT, mp_game_settings::to_config(), game_classification::to_config(), and replay_recorder_base::write().
Referenced by ng::configure_engine::configure_engine(), and mp::initial_level_config().
void saved_game::unify_controllers | ( | ) |
Definition at line 583 of file saved_game.cpp.
References config::child_range(), and starting_pos_.
Referenced by game_launcher::load_game().
void saved_game::update_label | ( | ) |
sets classification().label to the correct value.
Definition at line 558 of file saved_game.cpp.
References game_classification::abbrev, classification(), game_classification::label, and starting_pos_.
Referenced by expand_random_scenario(), expand_scenario(), campaign_controller::play_game(), and set_scenario().
bool saved_game::valid | ( | ) |
Definition at line 446 of file saved_game.cpp.
References starting_pos_type_, and STARTINGPOS_INVALID.
Referenced by sp::enter_create_mode(), and campaign_controller::play_game().
void saved_game::write_carryover | ( | config_writer & | out | ) | const |
Definition at line 154 of file saved_game.cpp.
References carryover_, has_carryover_expanded_, not_corrupt(), and config_writer::write_child().
Referenced by write_config(), savegame::ingame_savegame::write_game(), savegame::replay_savegame::write_game(), and savegame::scenariostart_savegame::write_game().
void saved_game::write_config | ( | config_writer & | out | ) | const |
writes the config information into a stream (file)
Definition at line 129 of file saved_game.cpp.
References config_writer::close_child(), config::empty(), config_writer::open_child(), replay_data_, replay_start_, replay_recorder_base::write(), write_carryover(), config_writer::write_child(), write_general_info(), and write_starting_pos().
void saved_game::write_general_info | ( | config_writer & | out | ) | const |
Definition at line 161 of file saved_game.cpp.
References classification_, mp_settings_, mp_game_settings::to_config(), game_classification::to_config(), config_writer::write(), and config_writer::write_child().
Referenced by write_config().
void saved_game::write_starting_pos | ( | config_writer & | out | ) | const |
Definition at line 143 of file saved_game.cpp.
References starting_pos_, starting_pos_type_, STARTINGPOS_SCENARIO, STARTINGPOS_SNAPSHOT, and config_writer::write_child().
Referenced by write_config().
|
private |
depends on has_carryover_expanded_: if true: The carryover information for all sides from the previous scenario that aren't used in this scenario (to be carried over to the next scenario).
if false: The carryover information for all sides from the previous scenario.
Definition at line 126 of file saved_game.hpp.
Referenced by convert_to_start_save(), expand_carryover(), expand_mp_options(), expand_scenario(), get_scenario_id(), load_mod(), set_carryover_sides_start(), set_data(), set_random_seed(), swap(), to_config(), and write_carryover().
|
private |
some general information of the game that doesn't change during the game
Definition at line 130 of file saved_game.hpp.
Referenced by classification(), expand_mp_events(), set_data(), swap(), to_config(), and write_general_info().
|
private |
Definition at line 120 of file saved_game.hpp.
Referenced by convert_to_start_save(), expand_carryover(), expand_mp_options(), expand_scenario(), get_replay_starting_pos(), get_scenario_id(), set_carryover_sides_start(), set_data(), set_random_seed(), set_scenario(), swap(), to_config(), and write_carryover().
|
private |
Definition at line 131 of file saved_game.hpp.
Referenced by expand_mp_events(), expand_mp_options(), expand_scenario(), load_mod(), mp_settings(), set_data(), swap(), to_config(), and write_general_info().
|
private |
Definition at line 140 of file saved_game.hpp.
Referenced by convert_to_start_save(), get_replay(), set_data(), swap(), to_config(), and write_config().
|
private |
snapshot made before the start event.
To be used as a starting pos for replays
Definition at line 128 of file saved_game.hpp.
Referenced by convert_to_start_save(), get_replay_starting_pos(), replay_start(), set_data(), swap(), to_config(), and write_config().
|
private |
The starting pos where the (non replay) game will be started from.
This can eigher be a [scenario] for a fresh game or a [snapshot] if this is a reloaded game
Definition at line 138 of file saved_game.hpp.
Referenced by cancel_orders(), convert_to_start_save(), expand_mp_events(), expand_random_scenario(), expand_scenario(), get_replay_starting_pos(), get_scenario_id(), get_starting_pos(), load_mod(), remove_snapshot(), set_data(), set_defaults(), set_scenario(), set_snapshot(), swap(), to_config(), unify_controllers(), update_label(), and write_starting_pos().
|
private |
Definition at line 133 of file saved_game.hpp.
Referenced by convert_to_start_save(), expand_carryover(), expand_mp_events(), expand_mp_options(), expand_random_scenario(), expand_scenario(), get_replay_starting_pos(), get_scenario_id(), is_mid_game_save(), remove_snapshot(), set_data(), set_defaults(), set_scenario(), set_snapshot(), swap(), to_config(), valid(), and write_starting_pos().