Skip to content

Commit

Permalink
remove game_state::write_snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
gfgtdf committed Jun 6, 2014
1 parent 1ae3c92 commit b401f76
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 27 deletions.
16 changes: 1 addition & 15 deletions src/gamestatus.cpp
Expand Up @@ -460,7 +460,7 @@ void game_data::clear_variable(const std::string& varname)
}
}

void game_data::write_snapshot(config& cfg){
void game_data::write_snapshot(config& cfg) const {
cfg["scenario"] = scenario_;
cfg["next_scenario"] = next_scenario_;

Expand Down Expand Up @@ -763,20 +763,6 @@ void convert_old_saves(config& cfg){
LOG_RG<<"cfg after conversion "<<cfg<<"\n";
}

void game_state::write_snapshot(config& cfg) const
{
log_scope("write_game");
cfg.merge_attributes(classification_.to_config());

//TODO: move id_manager handling to play_controller
cfg["next_underlying_unit_id"] = str_cast(n_unit::id_manager::instance().get_save_id());

if(resources::gamedata != NULL){
resources::gamedata->write_snapshot(cfg);
}

}

void extract_summary_from_config(config& cfg_save, config& cfg_summary)
{
const config &cfg_snapshot = cfg_save.child("snapshot");
Expand Down
4 changes: 1 addition & 3 deletions src/gamestatus.hpp
Expand Up @@ -106,7 +106,7 @@ class game_data : public variable_set {
/** the last location where a select event fired. */
map_location last_selected;

void write_snapshot(config& cfg);
void write_snapshot(config& cfg) const ;
void write_config(config_writer& out);

const std::string& next_scenario() const { return next_scenario_; }
Expand Down Expand Up @@ -173,8 +173,6 @@ class game_state
~game_state(){}
game_state& operator=(const game_state& state);

//write the gamestate into a config object
void write_snapshot(config& cfg) const;
//write the config information into a stream (file)
void write_config(config_writer& out) const;

Expand Down
8 changes: 8 additions & 0 deletions src/play_controller.cpp
Expand Up @@ -779,6 +779,14 @@ config play_controller::to_config() const
gui_->labels().write(cfg);
sound::write_music_play_list(cfg);
}

//TODO: move id_manager handling to play_controller
cfg["next_underlying_unit_id"] = str_cast(n_unit::id_manager::instance().get_save_id());


gamedata_.write_snapshot(cfg);

cfg.merge_attributes(gamestate_.classification().to_config());
return cfg;
}

Expand Down
1 change: 0 additions & 1 deletion src/playsingle_controller.cpp
Expand Up @@ -383,7 +383,6 @@ LEVEL_RESULT playsingle_controller::play_scenario(
// At the beginning of the scenario, save a snapshot as replay_start
if(gamestate_.snapshot.child_or_empty("variables")["turn_number"].to_int(-1)<1){
gamestate_.replay_start() = to_config();
gamestate_.write_snapshot(gamestate_.replay_start());
}
fire_preload();

Expand Down
5 changes: 0 additions & 5 deletions src/savegame.cpp
Expand Up @@ -1082,11 +1082,6 @@ void ingame_savegame::create_filename()
set_filename(stream.str());
}

void ingame_savegame::before_save()
{
savegame::before_save();
gamestate().write_snapshot(snapshot());
}

void ingame_savegame::write_game(config_writer &out) {
log_scope("write_game");
Expand Down
4 changes: 1 addition & 3 deletions src/savegame.hpp
Expand Up @@ -186,7 +186,7 @@ class savegame
config& snapshot() { return snapshot_; }

/** If there needs to be some data fiddling before saving the game, this is the place to go. */
virtual void before_save();
void before_save();

/** Writing the savegame config to a file. */
virtual void write_game(config_writer &out);
Expand Down Expand Up @@ -242,8 +242,6 @@ class ingame_savegame : public savegame
/** Create a filename for automatic saves */
virtual void create_filename();

/** Builds the snapshot config. */
virtual void before_save();

void write_game(config_writer &out);

Expand Down

0 comments on commit b401f76

Please sign in to comment.