Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
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");
}
Ejemplo n.º 3
0
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);
	}
}
Ejemplo n.º 4
0
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");
	}
}
Ejemplo n.º 5
0
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");
	}
}
Ejemplo n.º 6
0
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");
}
Ejemplo n.º 7
0
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);
	}
}
Ejemplo n.º 8
0
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);
}
Ejemplo n.º 9
0
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);
	}
}
Ejemplo n.º 10
0
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);

}