The Battle for Wesnoth  1.19.5+dev
Public Member Functions | Static 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= (const saved_game &other)=delete
 
saved_gameoperator= (saved_game &&other)
 
void swap (saved_game &other)
 
void set_data (config &cfg)
 destroys the passed config. More...
 
void clear ()
 
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_point (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_non_scenario (const std::string &type, const std::string &id, size_t pos)
 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_point_. More...
 
void check_require_scenario ()
 Add addon_id information if needed. More...
 
bool valid () const
 
configset_snapshot (config snapshot)
 
void set_scenario (config scenario)
 
void remove_snapshot ()
 
bool is_mid_game_save () const
 
bool is_start_of_scenario () const
 
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_point ()
 
std::string get_scenario_id () const
 
configget_starting_point ()
 
const configget_starting_point () 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
 
statistics_record::campaign_stats_tstatistics ()
 
const statistics_record::campaign_stats_tstatistics () const
 
bool skip_story () const
 Whether to play [story] tags. More...
 
void set_skip_story (bool skip_story)
 

Static Public Member Functions

static void post_scenario_generation (const config &old_scenario, config &generated_scenario)
 copies attributes & tags from the 'outer' [scenario] to the scenario that is generated by scenario_generation= More...
 
static void expand_map_file (config &scenario)
 reads scenario["map_file"] More...
 

Private Types

enum class  starting_point { NONE , SNAPSHOT , SCENARIO , 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_point starting_point_type_
 
config starting_point_
 The starting pos where the (non replay) game will be started from. More...
 
replay_recorder_base replay_data_
 
statistics_record::campaign_stats_t statistics_
 
bool skip_story_
 

Detailed Description

Definition at line 25 of file saved_game.hpp.

Member Enumeration Documentation

◆ starting_point

enum saved_game::starting_point
strongprivate
Enumerator
NONE 

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

SNAPSHOT 

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

SCENARIO 

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

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() [1/3]

saved_game::saved_game ( )

Definition at line 121 of file saved_game.cpp.

◆ saved_game() [2/3]

saved_game::saved_game ( const saved_game state)

Definition at line 150 of file saved_game.cpp.

◆ saved_game() [3/3]

saved_game::saved_game ( config  cfg)
explicit

Definition at line 135 of file saved_game.cpp.

References set_data().

◆ ~saved_game()

saved_game::~saved_game ( )
inline

Definition at line 42 of file saved_game.hpp.

Member Function Documentation

◆ cancel_orders()

void saved_game::cancel_orders ( )

◆ check_require_scenario()

void saved_game::check_require_scenario ( )

◆ classification() [1/2]

game_classification& saved_game::classification ( )
inline

Definition at line 56 of file saved_game.hpp.

References classification_.

Referenced by ng::create_engine::active_mods(), mp::add_multiplayer_classification(), play_controller::check_next_scenario_is_known(), savegame::loadgame::check_version_compatibility(), ng::connect_engine::connect_engine(), ng::create_engine::create_engine(), savegame::ingame_savegame::create_initial_filename(), savegame::replay_savegame::create_initial_filename(), savegame::autosave_savegame::create_initial_filename(), savegame::scenariostart_savegame::create_initial_filename(), playsingle_controller::do_end_level(), expand_mp_options(), expand_scenario(), gui2::dialogs::mp_join_game::fetch_game_config(), ng::configure_engine::fog_game_default(), ng::configure_engine::force_lock_settings(), play_controller::get_classification(), ng::create_engine::get_parameters(), ng::create_engine::init_active_mods(), ng::create_engine::init_all_levels(), ng::create_engine::init_extras(), mp::initial_level_config(), game_launcher::launch_game(), mp::level_to_gamestate(), game_launcher::load_game(), savegame::loadgame::load_game(), game_launcher::new_campaign(), play_controller::play_controller(), campaign_controller::play_game(), game_launcher::play_render_image_mode(), playsingle_controller::play_scenario_init(), game_launcher::play_test(), gui2::dialogs::mp_create_game::post_show(), 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(), play_controller::reveal_map_default(), sp::select_campaign(), ng::create_engine::set_current_level(), set_defaults(), ng::configure_engine::set_oos_debug(), game_launcher::set_test(), gui2::dialogs::mp_join_game::show_flg_select(), ng::side_engine::side_engine(), game_launcher::single_unit_test(), mp::start_local_game_commandline(), ng::create_engine::toggle_mod(), gui2::dialogs::mp_create_game::update_details(), update_label(), and ng::configure_engine::village_gold_default().

◆ classification() [2/2]

const game_classification& saved_game::classification ( ) const
inline

Definition at line 57 of file saved_game.hpp.

References classification_.

◆ clear()

void saved_game::clear ( )

◆ convert_to_start_save()

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 636 of file saved_game.cpp.

References carryover_, config::clear(), has_carryover_expanded_, carryover_info::merge_old_carryover(), remove_snapshot(), replay_data_, replay_start_, carryover_info::rng(), randomness::mt_rng::rotate_random(), SNAPSHOT, starting_point_, starting_point_type_, and carryover_info::to_config().

Referenced by campaign_controller::play_game().

◆ expand_carryover()

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 566 of file saved_game.cpp.

References carryover_, expand_scenario(), get_starting_point(), has_carryover_expanded_, statistics_record::campaign_stats_t::new_scenario(), SCENARIO, starting_point_type_, statistics(), carryover_info::to_config(), carryover_info::transfer_all_to(), and carryover_info::transfer_to().

Referenced by get_replay_starting_point(), and campaign_controller::play_game().

◆ expand_map_file()

void saved_game::expand_map_file ( config scenario)
static

◆ expand_mp_events()

void saved_game::expand_mp_events ( )

◆ expand_mp_options()

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 427 of file saved_game.cpp.

References game_classification::active_mods, carryover_, config::child_or_add(), config::child_range(), classification(), classification_, game_classification::era_id, ERR_NG, get_scenario_id(), has_carryover_expanded_, LOG_NG, mp_settings(), SCENARIO, and starting_point_type_.

Referenced by mp::initial_level_config(), campaign_controller::play_game(), and mp::start_local_game_commandline().

◆ expand_random_scenario()

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_point_.

Definition at line 505 of file saved_game.cpp.

References carryover_, config::child_or_empty(), expand_map_file(), expand_scenario(), LOG_NG, config::mandatory_child(), post_scenario_generation(), random_generate_map(), random_generate_scenario(), SCENARIO, set_defaults(), starting_point_, starting_point_type_, 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().

◆ expand_scenario()

void saved_game::expand_scenario ( )

◆ get_replay() [1/2]

replay_recorder_base& saved_game::get_replay ( )
inline

◆ get_replay() [2/2]

const replay_recorder_base& saved_game::get_replay ( ) const
inline

Definition at line 141 of file saved_game.hpp.

References replay_data_.

◆ get_replay_starting_point()

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

Definition at line 617 of file saved_game.cpp.

References config::empty(), expand_carryover(), expand_scenario(), has_carryover_expanded_, replay_start_, SCENARIO, starting_point_, and starting_point_type_.

Referenced by playsingle_controller::enable_replay(), and campaign_controller::playsingle_scenario().

◆ get_scenario_id()

std::string saved_game::get_scenario_id ( ) const

◆ get_starting_point() [1/2]

config & saved_game::get_starting_point ( )

◆ get_starting_point() [2/2]

const config& saved_game::get_starting_point ( ) const
inline

Definition at line 127 of file saved_game.hpp.

References starting_point_.

◆ is_mid_game_save()

bool saved_game::is_mid_game_save ( ) const
inline

◆ is_start_of_scenario()

bool saved_game::is_start_of_scenario ( ) const
inline

Definition at line 110 of file saved_game.hpp.

References has_carryover_expanded_.

Referenced by game_launcher::load_game().

◆ load_non_scenario()

void saved_game::load_non_scenario ( const std::string &  type,
const std::string &  id,
size_t  pos 
)

◆ mp_settings() [1/2]

mp_game_settings& saved_game::mp_settings ( )
inline

◆ mp_settings() [2/2]

const mp_game_settings& saved_game::mp_settings ( ) const
inline

Definition at line 61 of file saved_game.hpp.

References mp_settings_.

◆ not_corrupt()

bool saved_game::not_corrupt ( ) const

Definition at line 697 of file saved_game.cpp.

Referenced by write_carryover().

◆ operator=() [1/2]

saved_game& saved_game::operator= ( const saved_game other)
delete

◆ operator=() [2/2]

saved_game & saved_game::operator= ( saved_game &&  other)

Definition at line 740 of file saved_game.cpp.

References swap().

◆ post_scenario_generation()

void saved_game::post_scenario_generation ( const config old_scenario,
config generated_scenario 
)
static

copies attributes & tags from the 'outer' [scenario] to the scenario that is generated by scenario_generation=

Definition at line 539 of file saved_game.cpp.

References config::add_child(), and config::child_range().

Referenced by expand_random_scenario(), and ng::create_engine::init_generated_level_data().

◆ remove_snapshot()

void saved_game::remove_snapshot ( )

◆ replay_start() [1/2]

config& saved_game::replay_start ( )
inline

Definition at line 128 of file saved_game.hpp.

References replay_start_.

Referenced by playsingle_controller::play_scenario_init(), and set_data().

◆ replay_start() [2/2]

const config& saved_game::replay_start ( ) const
inline

Definition at line 129 of file saved_game.hpp.

References replay_start_.

◆ set_carryover_sides_start()

void saved_game::set_carryover_sides_start ( config  carryover_sides_start)

◆ set_data()

void saved_game::set_data ( config cfg)

◆ set_defaults()

void saved_game::set_defaults ( )

◆ set_random_seed()

void saved_game::set_random_seed ( )

sets the random seed if that didn't already happen.

Definition at line 170 of file saved_game.cpp.

References carryover_, randomness::generator, randomness::rng::get_random_int(), and has_carryover_expanded_.

Referenced by mp::initial_level_config().

◆ set_scenario()

void saved_game::set_scenario ( config  scenario)

◆ set_skip_story()

void saved_game::set_skip_story ( bool  skip_story)
inline

Definition at line 147 of file saved_game.hpp.

References skip_story(), and skip_story_.

Referenced by game_launcher::goto_campaign().

◆ set_snapshot()

config & saved_game::set_snapshot ( config  snapshot)
Returns
the snapshot in the savefile (get_starting_point)

Definition at line 588 of file saved_game.cpp.

References SNAPSHOT, starting_point_, starting_point_type_, and config::swap().

Referenced by campaign_controller::playsingle_scenario(), and play_controller::update_savegame_snapshot().

◆ skip_story()

bool saved_game::skip_story ( ) const
inline

Whether to play [story] tags.

Definition at line 146 of file saved_game.hpp.

References skip_story_.

Referenced by set_skip_story().

◆ statistics() [1/2]

statistics_record::campaign_stats_t& saved_game::statistics ( )
inline

◆ statistics() [2/2]

const statistics_record::campaign_stats_t& saved_game::statistics ( ) const
inline

Definition at line 144 of file saved_game.hpp.

References statistics_.

◆ swap()

void saved_game::swap ( saved_game other)

◆ to_config()

config saved_game::to_config ( ) const

◆ unify_controllers()

void saved_game::unify_controllers ( )

Definition at line 733 of file saved_game.cpp.

References config::child_range(), and starting_point_.

Referenced by game_launcher::load_game().

◆ update_label()

void saved_game::update_label ( )

◆ valid()

bool saved_game::valid ( ) const

◆ write_carryover()

void saved_game::write_carryover ( config_writer out) const

◆ write_config()

void saved_game::write_config ( config_writer out) const

◆ write_general_info()

void saved_game::write_general_info ( config_writer out) const

◆ write_starting_point()

void saved_game::write_starting_point ( config_writer out) const

Member Data Documentation

◆ carryover_

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 156 of file saved_game.hpp.

Referenced by clear(), convert_to_start_save(), expand_carryover(), expand_mp_options(), expand_random_scenario(), expand_scenario(), get_scenario_id(), load_non_scenario(), set_carryover_sides_start(), set_data(), set_random_seed(), swap(), to_config(), and write_carryover().

◆ classification_

game_classification saved_game::classification_
private

some general information of the game that doesn't change during the game

Definition at line 160 of file saved_game.hpp.

Referenced by classification(), clear(), expand_mp_events(), expand_mp_options(), set_data(), set_defaults(), swap(), to_config(), and write_general_info().

◆ has_carryover_expanded_

bool saved_game::has_carryover_expanded_
private

◆ mp_settings_

mp_game_settings saved_game::mp_settings_
private

◆ replay_data_

replay_recorder_base saved_game::replay_data_
private

◆ replay_start_

config saved_game::replay_start_
private

snapshot made before the start event.

To be used as a starting pos for replays

Definition at line 158 of file saved_game.hpp.

Referenced by clear(), convert_to_start_save(), get_replay_starting_point(), get_scenario_id(), replay_start(), set_data(), swap(), to_config(), and write_config().

◆ skip_story_

bool saved_game::skip_story_
private

Definition at line 174 of file saved_game.hpp.

Referenced by set_skip_story(), and skip_story().

◆ starting_point_

config saved_game::starting_point_
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 168 of file saved_game.hpp.

Referenced by cancel_orders(), check_require_scenario(), clear(), convert_to_start_save(), expand_mp_events(), expand_random_scenario(), expand_scenario(), get_replay_starting_point(), get_scenario_id(), get_starting_point(), load_non_scenario(), remove_snapshot(), set_data(), set_defaults(), set_scenario(), set_snapshot(), swap(), to_config(), unify_controllers(), update_label(), and write_starting_point().

◆ starting_point_type_

starting_point saved_game::starting_point_type_
private

◆ statistics_

statistics_record::campaign_stats_t saved_game::statistics_
private

Definition at line 172 of file saved_game.hpp.

Referenced by clear(), set_data(), statistics(), and to_config().


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