#include "global.hpp"
#include "filesystem.hpp"
#include "game_config.hpp"
#include "game_errors.hpp"
#include "gamestatus.hpp"
#include "gettext.hpp"
#include "language.hpp"
#include "log.hpp"
#include "game_preferences.hpp"
#include "statistics.hpp"
#include "util.hpp"
#include "wesconfig.h"
#include "serialization/binary_or_text.hpp"
#include "serialization/binary_wml.hpp"
#include "serialization/parser.hpp"
#include "serialization/string_utils.hpp"
#include "wml_exception.hpp"
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <sstream>
#include <sys/time.h>
#include <time.h>
Go to the source code of this file.
Classes | |
struct | save_info_less_time |
A structure for comparing to save_info objects based on their modified time. More... | |
Defines | |
#define | DBG_NG lg::debug(lg::engine) |
#define | LOG_NG lg::info(lg::engine) |
#define | WRN_NG lg::warn(lg::engine) |
#define | ERR_NG lg::err(lg::engine) |
Functions | |
void | replace_underbar2space (std::string &name) |
static void | replace_space2underbar (std::string &name) |
static void | extract_summary_from_config (config &cfg_save, config &cfg_summary) |
static void | extract_summary_data_from_save (const game_state &gamestate, config &out) |
static void | parse_times (const config &cfg, std::vector< time_of_day > &normal_times) |
static player_info | read_player (const config *cfg) |
static void | write_player (const player_info &player, config &cfg) |
static void | write_player (config_writer &out, const player_info &player) |
void | write_game (const game_state &gamestate, config &cfg, WRITE_GAME_MODE mode) |
void | write_game (config_writer &out, const game_state &gamestate, WRITE_GAME_MODE mode) |
std::vector< save_info > | get_saves_list (const std::string *dir, const std::string *filter) |
Get a list of available saves. | |
bool | save_game_exists (const std::string &name) |
Returns true iff there is already a savegame with that name. | |
void | delete_game (const std::string &name) |
Delete a savegame. | |
void | read_save_file (const std::string &name, config &cfg, std::string *error_log) |
static void | copy_era (config &cfg) |
void | load_game (const std::string &name, game_state &gamestate, std::string *error_log) |
Load/Save games. | |
void | load_game_summary (const std::string &name, config &cfg_summary, std::string *error_log) |
scoped_ostream | open_save_game (const std::string &label) |
Throws game::save_game_failed. | |
void | finish_save_game (config_writer &out, const game_state &gamestate, const std::string &label) |
void | save_game (const game_state &gamestate) |
Throws gamestatus::save_game_failed. | |
static config & | save_index () |
config & | save_summary (const std::string &save) |
void | write_save_index () |
static void | clear_wmi (std::map< std::string, wml_menu_item * > &gs_wmi) |
Variables | |
bool | save_index_loaded = false |
config | save_index_cfg |
Definition in file gamestatus.cpp.
#define DBG_NG lg::debug(lg::engine) |
Definition at line 45 of file gamestatus.cpp.
#define ERR_NG lg::err(lg::engine) |
Definition at line 48 of file gamestatus.cpp.
#define LOG_NG lg::info(lg::engine) |
Definition at line 46 of file gamestatus.cpp.
#define WRN_NG lg::warn(lg::engine) |
Definition at line 47 of file gamestatus.cpp.
static void clear_wmi | ( | std::map< std::string, wml_menu_item * > & | gs_wmi | ) | [static] |
Definition at line 1163 of file gamestatus.cpp.
Referenced by game_state::operator=(), game_state::set_menu_items(), and game_state::~game_state().
static void copy_era | ( | config & | cfg | ) | [static] |
Definition at line 802 of file gamestatus.cpp.
References config::add_child(), config::child(), and game_state::snapshot.
Referenced by load_game().
void delete_game | ( | const std::string & | name | ) |
Delete a savegame.
Definition at line 764 of file gamestatus.cpp.
References get_saves_dir(), and replace_space2underbar().
Referenced by clean_saves(), and remove_old_auto_saves().
void extract_summary_data_from_save | ( | const game_state & | gamestate, | |
config & | out | |||
) | [static] |
Definition at line 928 of file gamestatus.cpp.
References game_state::campaign, game_state::campaign_type, config::child(), game_state::difficulty, config::empty(), config::find_child(), config::get_children(), game_state::label, game_state::players, game_state::replay_data, game_state::scenario, game_state::snapshot, game_state::starting_pos, utils::string_bool(), units, and game_state::version.
Referenced by finish_save_game().
Definition at line 1006 of file gamestatus.cpp.
References config::child(), config::find_child(), config::get_children(), game_state::players, game_state::snapshot, utils::string_bool(), and units.
Referenced by load_game_summary().
void finish_save_game | ( | config_writer & | out, | |
const game_state & | gamestate, | |||
const std::string & | label | |||
) |
Definition at line 846 of file gamestatus.cpp.
References _, extract_summary_data_from_save(), file_create_time(), get_saves_dir(), config_writer::good(), save_summary(), str_cast(), io_exception::what(), and write_save_index().
Referenced by replay::save_game(), and save_game().
std::vector<save_info> get_saves_list | ( | const std::string * | dir, | |
const std::string * | filter | |||
) |
Get a list of available saves.
Definition at line 727 of file gamestatus.cpp.
References file_create_time(), get_files_in_dir(), get_saves_dir(), and replace_underbar2space().
Referenced by clean_saves(), dialogs::load_game_dialog(), and remove_old_auto_saves().
void load_game | ( | const std::string & | name, | |
game_state & | gamestate, | |||
std::string * | error_log | |||
) |
Load/Save games.
Definition at line 813 of file gamestatus.cpp.
References cfg, copy_era(), game_state::game_state(), log_scope, and read_save_file().
void load_game_summary | ( | const std::string & | name, | |
config & | cfg_summary, | |||
std::string * | error_log | |||
) |
Definition at line 824 of file gamestatus.cpp.
References cfg, extract_summary_from_config(), log_scope, and read_save_file().
scoped_ostream open_save_game | ( | const std::string & | label | ) |
Throws game::save_game_failed.
Definition at line 834 of file gamestatus.cpp.
References get_saves_dir(), ostream_file(), replace_space2underbar(), and io_exception::what().
Referenced by replay::save_game(), and save_game().
static void parse_times | ( | const config & | cfg, | |
std::vector< time_of_day > & | normal_times | |||
) | [static] |
Definition at line 165 of file gamestatus.cpp.
References dummy_cfg, config::get_children(), and time_of_day::time_of_day().
Referenced by gamestatus::gamestatus().
static player_info read_player | ( | const config * | cfg | ) | [static] |
Definition at line 419 of file gamestatus.cpp.
References player_info::available_units, player_info::can_recruit, config::get_children(), player_info::gold, player_info::gold_add, player_info::name, utils::split(), utils::string_bool(), and units.
Referenced by game_state::load_recall_list().
void read_save_file | ( | const std::string & | name, | |
config & | cfg, | |||
std::string * | error_log | |||
) |
Definition at line 773 of file gamestatus.cpp.
References config::clear(), detect_format_and_read(), config::empty(), lg::err, get_saves_dir(), is_gzip_file(), istream_file(), config::error::message, read_gz(), and replace_space2underbar().
Referenced by load_game(), and load_game_summary().
static void replace_space2underbar | ( | std::string & | name | ) | [static] |
Definition at line 115 of file gamestatus.cpp.
Referenced by delete_game(), open_save_game(), read_save_file(), and save_game_exists().
void replace_underbar2space | ( | std::string & | name | ) |
Definition at line 112 of file gamestatus.cpp.
Referenced by get_saves_list(), and dialogs::show_objectives().
void save_game | ( | const game_state & | gamestate | ) |
Throws gamestatus::save_game_failed.
Definition at line 868 of file gamestatus.cpp.
References preferences::compress_saves(), finish_save_game(), game_state::label, open_save_game(), PACKAGE, and write_game().
Referenced by play_game().
bool save_game_exists | ( | const std::string & | name | ) |
Returns true iff there is already a savegame with that name.
Definition at line 752 of file gamestatus.cpp.
References preferences::compress_saves(), file_exists(), get_saves_dir(), and replace_space2underbar().
Referenced by play_controller::expand_autosaves(), and dialogs::get_save_name().
static config& save_index | ( | ) | [static] |
Definition at line 886 of file gamestatus.cpp.
References config::clear(), detect_format_and_read(), get_save_index_file(), istream_file(), save_index_cfg, save_index_loaded, stream, and io_exception::what().
Referenced by save_summary(), and write_save_index().
config& save_summary | ( | const std::string & | save | ) |
Definition at line 905 of file gamestatus.cpp.
References config::add_child(), cfg, config::find_child(), and save_index().
Referenced by finish_save_game(), and dialogs::load_game_dialog().
void write_game | ( | config_writer & | out, | |
const game_state & | gamestate, | |||
WRITE_GAME_MODE | mode | |||
) |
Definition at line 647 of file gamestatus.cpp.
References game_state::abbrev, game_state::campaign, game_state::campaign_define, game_state::campaign_type, game_state::campaign_xtra_defines, config::child(), config_writer::close_child(), game_state::completion, game_state::difficulty, simple_rng::get_random_calls(), simple_rng::get_random_seed(), game_state::get_variables(), game_state::history, utils::join(), game_state::label, log_scope, game_state::next_scenario, config_writer::open_child(), game_state::players, game_state::replay_data, game_state::rng(), game_state::scenario, game_state::snapshot, game_state::starting_pos, game_config::version, game_state::wml_menu_items, config_writer::write_child(), WRITE_FULL_GAME, config_writer::write_key_val(), write_player(), and statistics::write_stats().
void write_game | ( | const game_state & | gamestate, | |
config & | cfg, | |||
WRITE_GAME_MODE | mode | |||
) |
Definition at line 585 of file gamestatus.cpp.
References game_state::abbrev, config::add_child(), game_state::campaign, game_state::campaign_define, game_state::campaign_type, game_state::campaign_xtra_defines, config::child(), game_state::completion, game_state::difficulty, simple_rng::get_random_calls(), simple_rng::get_random_seed(), game_state::get_variables(), game_state::history, utils::join(), game_state::label, lexical_cast(), log_scope, game_state::next_scenario, game_state::players, game_state::replay_data, game_state::rng(), game_state::scenario, game_state::snapshot, game_state::starting_pos, game_config::version, game_state::wml_menu_items, WRITE_FULL_GAME, write_player(), and statistics::write_stats().
Referenced by play_game(), replay::save_game(), save_game(), and events::menu_handler::write_game_snapshot().
static void write_player | ( | config_writer & | out, | |
const player_info & | player | |||
) | [static] |
Definition at line 554 of file gamestatus.cpp.
References player_info::available_units, buf, player_info::can_recruit, DBG_NG, player_info::gold, player_info::name, config_writer::write_child(), and config_writer::write_key_val().
static void write_player | ( | const player_info & | player, | |
config & | cfg | |||
) | [static] |
Definition at line 523 of file gamestatus.cpp.
References config::add_child(), player_info::available_units, buf, player_info::can_recruit, DBG_NG, player_info::gold, player_info::gold_add, and player_info::name.
Referenced by write_game().
void write_save_index | ( | ) |
Definition at line 917 of file gamestatus.cpp.
References get_save_index_file(), log_scope, ostream_file(), save_index(), stream, io_exception::what(), and write_compressed().
Referenced by finish_save_game(), and dialogs::load_game_dialog().
config save_index_cfg [static] |
bool save_index_loaded = false [static] |
Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth | Gna! | Forum | Wiki | CIA | devdocs |