本文整理汇总了C++中saved_game::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ saved_game::clear方法的具体用法?C++ saved_game::clear怎么用?C++ saved_game::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saved_game
的用法示例。
在下文中一共展示了saved_game::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start_local_game_commandline
void start_local_game_commandline(const config& game_config, saved_game& state, const commandline_options& cmdline_opts)
{
DBG_MP << "starting local MP game from commandline" << std::endl;
// The setup is done equivalently to lobby MP games using as much of existing
// code as possible. This means that some things are set up that are not
// needed in commandline mode, but they are required by the functions called.
preferences::set_message_private(false);
DBG_MP << "entering create mode" << std::endl;
// Set the default parameters
state.clear(); // This creates these parameters with default values defined in mp_game_settings.cpp
mp_game_settings& parameters = state.mp_settings();
// Hardcoded default values
parameters.mp_era = "era_default";
parameters.name = "multiplayer_The_Freelands";
// Default values for which at getter function exists
parameters.num_turns = settings::get_turns("");
parameters.village_gold = settings::get_village_gold("");
parameters.village_support = settings::get_village_support("");
parameters.xp_modifier = settings::get_xp_modifier("");
// Do not use map settings if --ignore-map-settings commandline option is set
if(cmdline_opts.multiplayer_ignore_map_settings) {
DBG_MP << "ignoring map settings" << std::endl;
parameters.use_map_settings = false;
} else {
parameters.use_map_settings = true;
}
// None of the other parameters need to be set, as their creation values above are good enough for CL mode.
// In particular, we do not want to use the preferences values.
state.classification().campaign_type = game_classification::CAMPAIGN_TYPE::MULTIPLAYER;
// [era] define.
if(cmdline_opts.multiplayer_era) {
parameters.mp_era = *cmdline_opts.multiplayer_era;
}
if(const config& cfg_era = game_config.find_child("era", "id", parameters.mp_era)) {
state.classification().era_define = cfg_era["define"].str();
} else {
std::cerr << "Could not find era '" << parameters.mp_era << "'\n";
return;
}
// [multiplayer] define.
if(cmdline_opts.multiplayer_scenario) {
parameters.name = *cmdline_opts.multiplayer_scenario;
}
if(const config& cfg_multiplayer = game_config.find_child("multiplayer", "id", parameters.name)) {
state.classification().scenario_define = cfg_multiplayer["define"].str();
} else {
std::cerr << "Could not find [multiplayer] '" << parameters.name << "'\n";
return;
}
game_config_manager::get()->load_game_config_for_game(state.classification());
state.set_carryover_sides_start(
config {"next_scenario", parameters.name}
);
state.expand_random_scenario();
state.expand_mp_events();
state.expand_mp_options();
// Should number of turns be determined from scenario data?
if(parameters.use_map_settings && state.get_starting_pos()["turns"]) {
DBG_MP << "setting turns from scenario data: " << state.get_starting_pos()["turns"] << std::endl;
parameters.num_turns = state.get_starting_pos()["turns"];
}
DBG_MP << "entering connect mode" << std::endl;
statistics::fresh_stats();
{
ng::connect_engine_ptr connect_engine(new ng::connect_engine(state, true, nullptr));
// Update the parameters to reflect game start conditions
connect_engine->start_game_commandline(cmdline_opts);
}
if(resources::recorder && cmdline_opts.multiplayer_label) {
std::string label = *cmdline_opts.multiplayer_label;
resources::recorder->add_log_data("ai_log","ai_label",label);
}
unsigned int repeat = (cmdline_opts.multiplayer_repeat) ? *cmdline_opts.multiplayer_repeat : 1;
for(unsigned int i = 0; i < repeat; i++){
saved_game state_copy(state);
campaign_controller controller(state_copy, game_config, game_config_manager::get()->terrain_types());
controller.play_game();
}
}