本文整理汇总了C++中saved_game::set_carryover_sides_start方法的典型用法代码示例。如果您正苦于以下问题:C++ saved_game::set_carryover_sides_start方法的具体用法?C++ saved_game::set_carryover_sides_start怎么用?C++ saved_game::set_carryover_sides_start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类saved_game
的用法示例。
在下文中一共展示了saved_game::set_carryover_sides_start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}
示例2: enter_create_mode
bool enter_create_mode(game_display& disp, const config& game_config,
saved_game& state, jump_to_campaign_info jump_to_campaign, bool local_players_only) {
bool configure_canceled = false;
do {
ng::create_engine create_eng(disp, state);
create_eng.set_current_level_type(ng::level::TYPE::SP_CAMPAIGN);
std::vector<ng::create_engine::level_ptr> campaigns(
create_eng.get_levels_by_type_unfiltered(ng::level::TYPE::SP_CAMPAIGN));
if (campaigns.empty()) {
gui2::show_error_message(disp.video(),
_("No campaigns are available.\n"));
return false;
}
bool use_deterministic_mode = false;
// No campaign selected from command line
if (jump_to_campaign.campaign_id_.empty() == true)
{
gui2::tcampaign_selection dlg(create_eng);
try {
dlg.show(disp.video());
} catch(twml_exception& e) {
e.show(disp);
return false;
}
if(dlg.get_retval() != gui2::twindow::OK) {
return false;
}
use_deterministic_mode = dlg.get_deterministic();
}
else
{
// don't reset the campaign_id_ so we can know
// if we should quit the game or return to the main menu
// checking for valid campaign name
bool not_found = true;
for(size_t i = 0; i < campaigns.size(); ++i)
{
if (campaigns[i]->data()["id"] == jump_to_campaign.campaign_id_)
{
create_eng.set_current_level(i);
not_found = false;
break;
}
}
// didn't find any campaign with that id
if (not_found)
{
//TODO: use ERR_NG or similar
std::cerr<<"No such campaign id to jump to: ["<<jump_to_campaign.campaign_id_<<"]\n";
return false;
}
}
std::string random_mode = use_deterministic_mode ? "deterministic" : "";
state.classification().random_mode = random_mode;
std::string selected_difficulty = create_eng.select_campaign_difficulty(jump_to_campaign.difficulty_);
if (selected_difficulty == "FAIL") return false;
if (selected_difficulty == "CANCEL") {
if (jump_to_campaign.campaign_id_.empty() == false)
{
jump_to_campaign.campaign_id_ = "";
}
// canceled difficulty dialog, relaunch the campaign selection dialog
return enter_create_mode(disp, game_config, state, jump_to_campaign, local_players_only);
}
create_eng.prepare_for_era_and_mods();
create_eng.prepare_for_campaign(selected_difficulty);
if(!jump_to_campaign.scenario_id_.empty()) {
state.set_carryover_sides_start(
config_of("next_scenario", jump_to_campaign.scenario_id_)
);
}
create_eng.prepare_for_new_level();
create_eng.get_parameters();
if(!state.valid())
{
//TODO: use ERR_NG or similar
std::cerr << "Cannot load scenario with id=" << state.get_scenario_id() << "\n";
return false;
}
configure_canceled = !enter_configure_mode(disp, game_config_manager::get()->game_config(), state, local_players_only);
//.........这里部分代码省略.........
示例3: enter_create_mode
bool enter_create_mode(CVideo& video, const config& game_config, saved_game& state, jump_to_campaign_info jump_to_campaign, bool local_players_only)
{
bool configure_canceled = false;
do {
ng::create_engine create_eng(video, state);
create_eng.set_current_level_type(ng::level::TYPE::SP_CAMPAIGN);
const std::vector<ng::create_engine::level_ptr> campaigns =
create_eng.get_levels_by_type_unfiltered(ng::level::TYPE::SP_CAMPAIGN);
if(campaigns.empty()) {
gui2::show_error_message(video, _("No campaigns are available."));
return false;
}
std::string random_mode = "";
// No campaign selected from command line
if(jump_to_campaign.campaign_id_.empty()) {
gui2::tcampaign_selection dlg(create_eng);
try {
dlg.show(video);
} catch(twml_exception& e) {
e.show(video);
return false;
}
if(dlg.get_retval() != gui2::twindow::OK) {
return false;
}
if(dlg.get_deterministic()) {
random_mode = "deterministic";
}
} else {
// Don't reset the campaign_id_ so we can know
// if we should quit the game or return to the main menu
// Checking for valid campaign name
const auto campaign = std::find_if(campaigns.begin(), campaigns.end(), [&jump_to_campaign](ng::create_engine::level_ptr level) {
return level->data()["id"] == jump_to_campaign.campaign_id_;
});
// Didn't find a campaign with that id
if(campaign == campaigns.end()) {
ERR_NG << "No such campaign id to jump to: [" << jump_to_campaign.campaign_id_ << "]" << std::endl;
return false;
}
create_eng.set_current_level(campaign - campaigns.begin());
}
state.classification().random_mode = random_mode;
const std::string selected_difficulty = create_eng.select_campaign_difficulty(jump_to_campaign.difficulty_);
if(selected_difficulty == "FAIL") return false;
if(selected_difficulty == "CANCEL") {
if(!jump_to_campaign.campaign_id_.empty()) {
jump_to_campaign.campaign_id_ = "";
}
// Canceled difficulty dialog, relaunch the campaign selection dialog
return enter_create_mode(video, game_config, state, jump_to_campaign, local_players_only);
}
create_eng.prepare_for_era_and_mods();
create_eng.prepare_for_campaign(selected_difficulty);
if(!jump_to_campaign.scenario_id_.empty()) {
state.set_carryover_sides_start(
config_of("next_scenario", jump_to_campaign.scenario_id_)
);
}
if(!state.valid()) {
ERR_NG << "Cannot load scenario with id=" << state.get_scenario_id() << std::endl;
return false;
}
configure_canceled = !enter_configure_mode(video, game_config_manager::get()->game_config(), state, create_eng, local_players_only);
} while (configure_canceled);
return true;
}