removed level_cfg_, map_ and tod_manager_ members from game_savegame
This commit is contained in:
parent
1a03263159
commit
54a7365dd7
5 changed files with 37 additions and 44 deletions
|
@ -309,7 +309,7 @@ void play_controller::status_table(){
|
|||
void play_controller::save_game(){
|
||||
if(save_blocker::try_block()) {
|
||||
save_blocker::save_unblocker unblocker;
|
||||
game_savegame save(gamestate_, level_, *gui_, tod_manager_, map_, to_config(), preferences::compress_saves());
|
||||
game_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
save.save_game_interactive((*gui_).video(), "", gui::OK_CANCEL);
|
||||
} else {
|
||||
save_blocker::on_unblock(this,&play_controller::save_game);
|
||||
|
@ -540,6 +540,9 @@ void play_controller::do_init_side(const unsigned int team_index){
|
|||
config play_controller::to_config() const
|
||||
{
|
||||
config cfg;
|
||||
|
||||
cfg.merge_attributes(level_);
|
||||
|
||||
std::stringstream buf;
|
||||
|
||||
for(std::vector<team>::const_iterator t = teams_.begin(); t != teams_.end(); ++t) {
|
||||
|
@ -570,6 +573,19 @@ config play_controller::to_config() const
|
|||
}
|
||||
}
|
||||
|
||||
cfg.merge_with(tod_manager_.to_config());
|
||||
|
||||
// Write terrain_graphics data in snapshot, too
|
||||
const config::child_list& terrains = level_.get_children("terrain_graphics");
|
||||
for(config::child_list::const_iterator tg = terrains.begin();
|
||||
tg != terrains.end(); ++tg) {
|
||||
|
||||
cfg.add_child("terrain_graphics", **tg);
|
||||
}
|
||||
|
||||
//write out the current state of the map
|
||||
cfg["map_data"] = map_.write();
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
|
|
|
@ -544,7 +544,7 @@ void playmp_controller::process_oos(const std::string& err_msg){
|
|||
temp_buf << " \n";
|
||||
}
|
||||
|
||||
oos_savegame save(gamestate_, level_, *gui_, tod_manager_, map_, to_config(), preferences::compress_saves());
|
||||
oos_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
save.save_game_interactive((*gui_).video(), temp_buf.str(), gui::YES_NO);
|
||||
}
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ LEVEL_RESULT playsingle_controller::play_scenario(
|
|||
disconnect = true;
|
||||
}
|
||||
|
||||
game_savegame save(gamestate_, level_, *gui_, tod_manager_, map_, to_config(), preferences::compress_saves());
|
||||
game_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
save.save_game_interactive((*gui_).video(), _("A network disconnection has occurred, and the game\ncannot continue. Do you want to save the game?"), gui::YES_NO);
|
||||
if(disconnect) {
|
||||
throw network::error();
|
||||
|
@ -633,7 +633,7 @@ void playsingle_controller::before_human_turn(bool save)
|
|||
gui_->draw(true,true);
|
||||
|
||||
if (save) {
|
||||
autosave_savegame save(gamestate_, level_, *gui_, tod_manager_, map_, to_config(), preferences::compress_saves());
|
||||
autosave_savegame save(gamestate_, *gui_, to_config(), preferences::compress_saves());
|
||||
save.autosave(game_config::disable_autosave, preferences::autosavemax(), preferences::INFINITE_AUTO_SAVES);
|
||||
}
|
||||
|
||||
|
|
|
@ -934,10 +934,9 @@ void replay_savegame::create_filename()
|
|||
set_filename(stream.str());
|
||||
}
|
||||
|
||||
autosave_savegame::autosave_savegame(game_state &gamestate, const config& level_cfg,
|
||||
game_display& gui, const tod_manager& tod_mng,
|
||||
const gamemap& map, const config& snapshot_cfg, const bool compress_saves)
|
||||
: game_savegame(gamestate, level_cfg, gui, tod_mng, map, snapshot_cfg, compress_saves)
|
||||
autosave_savegame::autosave_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves)
|
||||
: game_savegame(gamestate, gui, snapshot_cfg, compress_saves)
|
||||
{
|
||||
set_error_message(_("Could not auto save the game. Please save the game manually."));
|
||||
}
|
||||
|
@ -958,15 +957,14 @@ void autosave_savegame::create_filename()
|
|||
if (gamestate().classification().label.empty())
|
||||
filename = _("Auto-Save");
|
||||
else
|
||||
filename = gamestate().classification().label + "-" + _("Auto-Save") + lexical_cast<std::string>(tod_manager_.turn());
|
||||
filename = gamestate().classification().label + "-" + _("Auto-Save") + snapshot()["turn_at"];
|
||||
|
||||
set_filename(filename);
|
||||
}
|
||||
|
||||
oos_savegame::oos_savegame(game_state &gamestate, const config& level_cfg,
|
||||
game_display& gui, const tod_manager& tod_mng,
|
||||
const gamemap& map, const config& snapshot_cfg, const bool compress_saves)
|
||||
: game_savegame(gamestate, level_cfg, gui, tod_mng, map, snapshot_cfg, compress_saves)
|
||||
oos_savegame::oos_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves)
|
||||
: game_savegame(gamestate, gui, snapshot_cfg, compress_saves)
|
||||
{}
|
||||
|
||||
int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, const gui::DIALOG_TYPE /*dialog_type*/)
|
||||
|
@ -990,12 +988,10 @@ int oos_savegame::show_save_dialog(CVideo& video, const std::string& message, co
|
|||
return res;
|
||||
}
|
||||
|
||||
game_savegame::game_savegame(game_state &gamestate, const config& level_cfg,
|
||||
game_display& gui, const tod_manager& tod_mng,
|
||||
const gamemap& map, const config& snapshot_cfg, const bool compress_saves)
|
||||
game_savegame::game_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves)
|
||||
: savegame(gamestate, compress_saves, _("Save Game")),
|
||||
level_cfg_(level_cfg), gui_(gui),
|
||||
tod_manager_(tod_mng), map_(map)
|
||||
gui_(gui)
|
||||
{
|
||||
snapshot().merge_with(snapshot_cfg);
|
||||
}
|
||||
|
@ -1006,7 +1002,7 @@ void game_savegame::create_filename()
|
|||
|
||||
const std::string ellipsed_name = font::make_text_ellipsis(gamestate().classification().label,
|
||||
font::SIZE_NORMAL, 200);
|
||||
stream << ellipsed_name << " " << _("Turn") << " " << tod_manager_.turn();
|
||||
stream << ellipsed_name << " " << _("Turn") << " " << snapshot()["turn_at"];
|
||||
set_filename(stream.str());
|
||||
}
|
||||
|
||||
|
@ -1018,7 +1014,6 @@ void game_savegame::before_save()
|
|||
|
||||
void game_savegame::write_game_snapshot()
|
||||
{
|
||||
snapshot().merge_attributes(level_cfg_);
|
||||
|
||||
snapshot()["snapshot"] = "yes";
|
||||
|
||||
|
@ -1026,24 +1021,12 @@ void game_savegame::write_game_snapshot()
|
|||
buf << gui_.playing_team();
|
||||
snapshot()["playing_team"] = buf.str();
|
||||
|
||||
snapshot().merge_with(tod_manager_.to_config());
|
||||
game_events::write_events(snapshot());
|
||||
|
||||
// Write terrain_graphics data in snapshot, too
|
||||
const config::child_list& terrains = level_cfg_.get_children("terrain_graphics");
|
||||
for(config::child_list::const_iterator tg = terrains.begin();
|
||||
tg != terrains.end(); ++tg) {
|
||||
|
||||
snapshot().add_child("terrain_graphics", **tg);
|
||||
}
|
||||
|
||||
sound::write_music_play_list(snapshot());
|
||||
|
||||
gamestate().write_snapshot(snapshot());
|
||||
|
||||
//write out the current state of the map
|
||||
snapshot()["map_data"] = map_.write();
|
||||
|
||||
gui_.labels().write(snapshot());
|
||||
}
|
||||
|
||||
|
|
|
@ -229,9 +229,8 @@ private:
|
|||
class game_savegame : public savegame
|
||||
{
|
||||
public:
|
||||
game_savegame(game_state& gamestate, const config& level_cfg,
|
||||
game_display& gui, const tod_manager& tod_mng,
|
||||
const gamemap& map, const config& snapshot_cfg, const bool compress_saves);
|
||||
game_savegame(game_state& gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves);
|
||||
|
||||
private:
|
||||
/** Create a filename for automatic saves */
|
||||
|
@ -244,10 +243,7 @@ private:
|
|||
void write_game_snapshot();
|
||||
|
||||
protected:
|
||||
const config& level_cfg_;
|
||||
game_display& gui_;
|
||||
const tod_manager& tod_manager_;
|
||||
const gamemap& map_;
|
||||
};
|
||||
|
||||
/** Class for replay saves (either manually or automatically). */
|
||||
|
@ -265,9 +261,8 @@ private:
|
|||
class autosave_savegame : public game_savegame
|
||||
{
|
||||
public:
|
||||
autosave_savegame(game_state &gamestate, const config& level_cfg,
|
||||
game_display& gui, const tod_manager& tod_mng,
|
||||
const gamemap& map, const config& snapshot_cfg, const bool compress_saves);
|
||||
autosave_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves);
|
||||
|
||||
void autosave(const bool disable_autosave, const int autosave_max, const int infinite_autosaves);
|
||||
private:
|
||||
|
@ -278,9 +273,8 @@ private:
|
|||
class oos_savegame : public game_savegame
|
||||
{
|
||||
public:
|
||||
oos_savegame(game_state &gamestate, const config& level_cfg,
|
||||
game_display& gui, const tod_manager& tod_mng,
|
||||
const gamemap& map, const config& snapshot_cfg, const bool compress_saves);
|
||||
oos_savegame(game_state &gamestate,
|
||||
game_display& gui, const config& snapshot_cfg, const bool compress_saves);
|
||||
|
||||
private:
|
||||
/** Display the save game dialog. */
|
||||
|
|
Loading…
Add table
Reference in a new issue