void replay_savegame::write_game(config_writer &out) { savegame::write_game(out); gamestate().write_carryover(out); out.write_child("replay_start", gamestate().replay_start()); out.write_child("replay", gamestate().replay_data); }
static void write_battle_result_map(config_writer &out, const stats::battle_result_map& m) { for(stats::battle_result_map::const_iterator i = m.begin(); i != m.end(); ++i) { out.open_child("sequence"); write_str_int_map(out, i->second); out.write_key_val("_num", i->first); out.close_child("sequence"); } }
void ingame_savegame::write_game(config_writer &out) { log_scope("write_game"); savegame::write_game(out); gamestate().write_carryover(out); out.write_child("snapshot",snapshot()); out.write_child("replay_start", gamestate().replay_start()); out.write_child("replay", gamestate().replay_data); }
void write_stats(config_writer &out) { out.write_key_val("mid_scenario", mid_scenario ? "yes" : "no"); for(std::vector<scenario_stats>::const_iterator i = master_stats.begin(); i != master_stats.end(); ++i) { out.open_child("scenario"); i->write(out); out.close_child("scenario"); } }
void replay_savegame::write_game(config_writer &out) { savegame::write_game(out); gamestate().write_carryover(out); out.write_child("replay_start", gamestate().replay_start()); out.open_child("replay"); gamestate().get_replay().write(out); out.close_child("replay"); }
void savegame::write_game(config_writer &out) { log_scope("write_game"); out.write_key_val("version", game_config::version); gamestate_.write_general_info(out); out.open_child("statistics"); statistics::write_stats(out); out.close_child("statistics"); }
void ingame_savegame::write_game(config_writer &out) { log_scope("write_game"); savegame::write_game(out); gamestate().write_carryover(out); out.write_child("snapshot",gamestate().get_starting_pos()); out.write_child("replay_start", gamestate().replay_start()); out.open_child("replay"); gamestate().get_replay().write(out); out.close_child("replay"); }
void savegame::write_game(config_writer &out) { log_scope("write_game"); out.write_key_val("version", game_config::version); out.write_key_val("next_underlying_unit_id", lexical_cast<std::string>(n_unit::id_manager::instance().get_save_id())); gamestate_.write_general_info(out); out.open_child("statistics"); statistics::write_stats(out); out.close_child("statistics"); }
static void write_str_int_map(config_writer &out, const stats::str_int_map& m) { for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { char buf[50]; snprintf(buf,sizeof(buf),"%d",i->second); out.write_key_val(i->first, buf); } }
void savegame::finish_save_game(const config_writer &out) { try { if(!out.good()) { throw game::save_game_failed(_("Could not write to file")); } save_index_manager.remove(gamestate_.classification().label); } catch(filesystem::io_exception& e) { throw game::save_game_failed(e.what()); } }
void game_data::write_config(config_writer& out){ out.write_key_val("scenario", scenario_); out.write_key_val("next_scenario", next_scenario_); out.write_key_val("random_seed", lexical_cast<std::string>(rng_.get_random_seed())); out.write_key_val("random_calls", lexical_cast<std::string>(rng_.get_random_calls())); out.write_child("variables", variables_); config cfg; wml_menu_items_.to_config(cfg); out.write_child("menu_item", cfg); }
void savegame::finish_save_game(const config_writer &out) { std::string name = gamestate_.classification().label; replace_space2underbar(name); std::string fname(get_saves_dir() + "/" + name); try { if(!out.good()) { throw game::save_game_failed(_("Could not write to file")); } config& summary = save_index::save_summary(gamestate_.classification().label); extract_summary_data_from_save(summary); const int mod_time = static_cast<int>(file_create_time(fname)); summary["mod_time"] = str_cast(mod_time); save_index::write_save_index(); } catch(io_exception& e) { throw game::save_game_failed(e.what()); } }
void stats::write(config_writer &out) const { out.open_child("recruits"); write_str_int_map(out, recruits); out.close_child("recruits"); out.open_child("recalls"); write_str_int_map(out, recalls); out.close_child("recalls"); out.open_child("advances"); write_str_int_map(out, advanced_to); out.close_child("advances"); out.open_child("deaths"); write_str_int_map(out, deaths); out.close_child("deaths"); out.open_child("killed"); write_str_int_map(out, killed); out.close_child("killed"); out.open_child("attacks"); write_battle_result_map(out, attacks); out.close_child("attacks"); out.open_child("defends"); write_battle_result_map(out, defends); out.close_child("defends"); out.write_key_val("recruit_cost", recruit_cost); out.write_key_val("recall_cost", recall_cost); out.write_key_val("damage_inflicted", damage_inflicted); out.write_key_val("damage_taken", damage_taken); out.write_key_val("expected_damage_inflicted", expected_damage_inflicted); out.write_key_val("expected_damage_taken", expected_damage_taken); out.write_key_val("turn_damage_inflicted", turn_damage_inflicted); out.write_key_val("turn_damage_taken", turn_damage_taken); out.write_key_val("turn_expected_damage_inflicted", turn_expected_damage_inflicted); out.write_key_val("turn_expected_damage_taken", turn_expected_damage_taken); out.write_key_val("save_id", save_id); }
static void write_str_int_map(config_writer &out, const stats::str_int_map& m) { for(stats::str_int_map::const_iterator i = m.begin(); i != m.end(); ++i) { out.write_key_val(i->first, i->second); } }
void stats::write(config_writer &out) const { out.open_child("recruits"); write_str_int_map(out, recruits); out.close_child("recruits"); out.open_child("recalls"); write_str_int_map(out, recalls); out.close_child("recalls"); out.open_child("advances"); write_str_int_map(out, advanced_to); out.close_child("advances"); out.open_child("deaths"); write_str_int_map(out, deaths); out.close_child("deaths"); out.open_child("killed"); write_str_int_map(out, killed); out.close_child("killed"); out.open_child("attacks"); write_battle_result_map(out, attacks); out.close_child("attacks"); out.open_child("defends"); write_battle_result_map(out, defends); out.close_child("defends"); std::ostringstream ss; ss << recruit_cost; out.write_key_val("recruit_cost", ss.str()); ss.str(std::string()); ss << recall_cost; out.write_key_val("recall_cost", ss.str()); ss.str(std::string()); ss << damage_inflicted; out.write_key_val("damage_inflicted", ss.str()); ss.str(std::string()); ss << damage_taken; out.write_key_val("damage_taken", ss.str()); ss.str(std::string()); ss << expected_damage_inflicted; out.write_key_val("expected_damage_inflicted", ss.str()); ss.str(std::string()); ss << expected_damage_taken; out.write_key_val("expected_damage_taken", ss.str()); ss.str(std::string()); ss << turn_damage_inflicted; out.write_key_val("turn_damage_inflicted", ss.str()); ss.str(std::string()); ss << turn_damage_taken; out.write_key_val("turn_damage_taken", ss.str()); ss.str(std::string()); ss << turn_expected_damage_inflicted; out.write_key_val("turn_expected_damage_inflicted", ss.str()); ss.str(std::string()); ss << turn_expected_damage_taken; out.write_key_val("turn_expected_damage_taken", ss.str()); out.write_key_val("save_id", save_id); }
void savegame::write_game(config_writer &out) const { config cfg = gamestate_.classification().to_config(); BOOST_FOREACH (const config::attribute& i, cfg.attribute_range()) { out.write_key_val(i.first, i.second); } int duration = gamestate_.duration(time(NULL)); out.write_key_val("duration", lexical_cast<std::string>(duration)); out.write_key_val("random_seed", lexical_cast<std::string>(gamestate_.rng().get_random_seed())); out.write_key_val("random_calls", lexical_cast<std::string>(gamestate_.rng().get_random_calls())); // update newest rpg to variables gamestate_.rpg_2_variable(); out.write_child("variables", gamestate_.get_variables()); for (std::map<std::string, wml_menu_item *>::const_iterator j=gamestate_.wml_menu_items.begin(); j!=gamestate_.wml_menu_items.end(); ++j) { out.open_child("menu_item"); out.write_key_val("id", j->first); out.write_key_val("image", j->second->image); out.write_key_val("description", j->second->description); out.write_key_val("needs_select", (j->second->needs_select) ? "yes" : "no"); if(!j->second->show_if.empty()) out.write_child("show_if", j->second->show_if); if(!j->second->filter_location.empty()) out.write_child("filter_location", j->second->filter_location); if(!j->second->command.empty()) out.write_child("command", j->second->command); out.close_child("menu_item"); } out.write_child("snapshot", snapshot_); /* out.open_child("statistics"); statistics::write_stats(out); out.close_child("statistics"); */ if (!gamestate_.replay_data_dbg.child("replay12")) { out.write_child("replay12", gamestate_.replay_data_dbg); } }