The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Types | Private Attributes | List of all members
saved_game Class Reference

#include <saved_game.hpp>

Public Member Functions

 saved_game ()
 
 saved_game (const saved_game &state)
 
 saved_game (config cfg)
 
 ~saved_game ()
 
saved_gameoperator= (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_classificationclassification ()
 
const game_classificationclassification () const
 
mp_game_settingsmp_settings ()
 Multiplayer parameters for this game. More...
 
const mp_game_settingsmp_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 ()
 
configset_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 configget_replay_starting_pos ()
 
std::string get_scenario_id ()
 
configget_starting_pos ()
 
const configget_starting_pos () const
 
configreplay_start ()
 
const configreplay_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_baseget_replay ()
 
const replay_recorder_baseget_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_
 

Detailed Description

Definition at line 25 of file saved_game.hpp.

Member Enumeration Documentation

Enumerator
STARTINGPOS_NONE 

There is no scenario stating pos data (start-of-scenario).

STARTINGPOS_SNAPSHOT 

We have a [snapshot] (mid-game-savefile).

STARTINGPOS_SCENARIO 

We have a [scenario] (start-of-scenario) savefile.

STARTINGPOS_INVALID 

We failed to get a starting pos in expand_scenario.

Definition at line 27 of file saved_game.hpp.

Constructor & Destructor Documentation

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.

saved_game::saved_game ( config  cfg)
explicit

Definition at line 87 of file saved_game.cpp.

References set_data().

saved_game::~saved_game ( )
inline

Definition at line 42 of file saved_game.hpp.

Member Function Documentation

void saved_game::cancel_orders ( )
game_classification& saved_game::classification ( )
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().

const game_classification& saved_game::classification ( ) const
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 ( )
replay_recorder_base& saved_game::get_replay ( )
inline
const replay_recorder_base& saved_game::get_replay ( ) const
inline

Definition at line 117 of file saved_game.hpp.

References replay_data_.

const config & saved_game::get_replay_starting_pos ( )
Returns
the starting pos for replays. Usualy this is [replay_start] but it can also be a [scenario] if no [replay_start] is present

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 ( )
Returns
the id of the currently played scenario or the id of the next scenario if this is a between-scenaios-save (also called start-of-scenario-save).

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 ( )
const config& saved_game::get_starting_pos ( ) const
inline

Definition at line 103 of file saved_game.hpp.

References starting_pos_.

bool saved_game::is_mid_game_save ( )
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 
)
mp_game_settings& saved_game::mp_settings ( )
inline
const mp_game_settings& saved_game::mp_settings ( ) const
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 ( )
config& saved_game::replay_start ( )
inline
const config& saved_game::replay_start ( ) const
inline

Definition at line 105 of file saved_game.hpp.

References replay_start_.

void saved_game::set_carryover_sides_start ( config  carryover_sides_start)
void saved_game::set_data ( config cfg)
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().

void saved_game::set_scenario ( config  scenario)
config & saved_game::set_snapshot ( config  snapshot)
void saved_game::swap ( saved_game other)
config saved_game::to_config ( ) const
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 ( )
bool saved_game::valid ( )
void saved_game::write_carryover ( config_writer out) const
void saved_game::write_config ( config_writer out) const
void saved_game::write_general_info ( config_writer out) const
void saved_game::write_starting_pos ( config_writer out) const

Member Data Documentation

config saved_game::carryover_
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().

game_classification saved_game::classification_
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().

bool saved_game::has_carryover_expanded_
private
mp_game_settings saved_game::mp_settings_
private
replay_recorder_base saved_game::replay_data_
private
config saved_game::replay_start_
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().

config saved_game::starting_pos_
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().

STARTING_POS_TYPE saved_game::starting_pos_type_
private

The documentation for this class was generated from the following files: