本文整理汇总了C++中game_state::clear_start_hero_data方法的典型用法代码示例。如果您正苦于以下问题:C++ game_state::clear_start_hero_data方法的具体用法?C++ game_state::clear_start_hero_data怎么用?C++ game_state::clear_start_hero_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类game_state
的用法示例。
在下文中一共展示了game_state::clear_start_hero_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: play_replay
void play_replay(display& disp, game_state& gamestate, const config& game_config,
hero_map& heros, hero_map& heros_start, card_map& cards, CVideo& video)
{
std::string type = gamestate.classification().campaign_type;
if(type.empty())
type = "scenario";
// 'starting_pos' will contain the position we start the game from.
config starting_pos;
if (gamestate.starting_pos.empty()){
// Backwards compatibility code for 1.2 and 1.2.1
const config &scenario = game_config.find_child(type,"id",gamestate.classification().scenario);
assert(scenario);
gamestate.starting_pos = scenario;
}
starting_pos = gamestate.starting_pos;
//for replays, use the variables specified in starting_pos
if (const config &vars = starting_pos.child("variables")) {
gamestate.set_variables(vars);
}
try {
// Preserve old label eg. replay
if (gamestate.classification().label.empty())
gamestate.classification().label = starting_pos["name"].str();
//if (gamestate.abbrev.empty())
// gamestate.abbrev = (*scenario)["abbrev"];
play_replay_level(game_config, &starting_pos, video, gamestate, heros, heros_start, cards);
gamestate.snapshot = config();
recorder.clear();
gamestate.replay_data.clear();
gamestate.start_scenario_ss.str("");
// gamestate.start_hero_ss.str("");
gamestate.clear_start_hero_data();
} catch(game::load_game_failed& e) {
gui2::show_error_message(disp.video(), _("The game could not be loaded: ") + e.message);
} catch(game::game_error& e) {
gui2::show_error_message(disp.video(), _("Error while playing the game: ") + e.message);
} catch(incorrect_map_format_error& e) {
gui2::show_error_message(disp.video(), std::string(_("The game map could not be loaded: ")) + e.message);
} catch(twml_exception& e) {
e.show(disp);
}
}
示例2: play_game
//.........这里部分代码省略.........
gui2::show_error_message(disp.video(), _("The game could not be loaded: ") + e.message);
return QUIT;
} catch(game::game_error& e) {
gui2::show_error_message(disp.video(), _("Error while playing the game: ") + e.message);
return QUIT;
} catch(incorrect_map_format_error& e) {
gui2::show_error_message(disp.video(), std::string(_("The game map could not be loaded: ")) + e.message);
return QUIT;
} catch(config::error& e) {
std::cerr << "caught config::error...\n";
gui2::show_error_message(disp.video(), _("Error while reading the WML: ") + e.message);
return QUIT;
} catch(twml_exception& e) {
e.show(disp);
return QUIT;
}
// Save-management options fire on game end.
// This means: (a) we have a victory, or
// or (b) we're multiplayer live, in which
// case defeat is also game end. Someday,
// if MP campaigns ever work again, we might
// need to change this test.
if (res == VICTORY || (io_type != IO_NONE && res == DEFEAT)) {
if (preferences::delete_saves()) {
savegame::manager::clean_saves(gamestate.classification().label);
}
}
recorder.clear();
gamestate.replay_data.clear();
gamestate.start_scenario_ss.str("");
gamestate.clear_start_hero_data();
// On DEFEAT, QUIT, or OBSERVER_END, we're done now
if (res != VICTORY) {
if (res != OBSERVER_END || gamestate.classification().next_scenario.empty()) {
gamestate.snapshot = config();
return res;
}
const int dlg_res = gui2::show_message(disp.video(), _("Game Over"),
_("This scenario has ended. Do you want to continue the campaign?"),
gui2::tmessage::yes_no_buttons);
if (dlg_res == gui2::twindow::CANCEL) {
gamestate.snapshot = config();
return res;
}
}
// Continue without saving is like a victory,
// but the save game dialog isn't displayed
if (!end_level.prescenario_save) {
save_game_after_scenario = false;
}
// Switch to the next scenario.
gamestate.classification().scenario = gamestate.classification().next_scenario;
gamestate.rng().rotate_random();
// gamestate.rng().seed_random(rand(), 0);
scenario = NULL;
if (io_type == IO_NONE) {
scenario = &load_campagin_scenario(gamestate.classification().campaign, gamestate.classification().scenario, type);