launch from start: restart scenario if already in it

This commit is contained in:
2025-01-14 19:55:50 -06:00
committed by Celtic Minstrel
parent 80aa0341a1
commit 832ceffe8e
4 changed files with 9 additions and 5 deletions

View File

@@ -1229,7 +1229,7 @@ void handle_get_items(bool& did_something, bool& need_redraw, bool& need_reprint
need_reprint = true;
}
void handle_victory(bool record) {
void handle_victory(bool force, bool record) {
if(record && recording){
record_action("handle_victory", "");
}
@@ -1243,7 +1243,7 @@ void handle_victory(bool record) {
draw_startup(0);
menu_activate();
univ.party.scen_name = ""; // should be harmless...
if(cChoiceDlog("congrats-save",{"cancel","save"}).show() == "save"){
if(!force && cChoiceDlog("congrats-save",{"cancel","save"}).show() == "save"){
// TODO: Wait, this shouldn't be a "save as" action, should it? It should save without asking for a location.
fs::path file = nav_put_or_temp_party();
if(!file.empty()) save_party(file, univ);

View File

@@ -87,7 +87,7 @@ void debug_stealth_detect_life_firewalk();
void debug_fly();
void debug_ghost_mode();
void debug_return_to_start();
void handle_victory(bool record = false);
void handle_victory(bool force = false, bool record = false);
void debug_increase_age();
void debug_towns_forget();
void debug_heal_plus_extra();

View File

@@ -83,6 +83,7 @@ std::string scenario_temp_dir_name = "scenario";
extern fs::path tempDir;
std::vector<fs::path> extra_scen_dirs;
boost::optional<std::string> scen_arg_path;
bool scen_arg_restart = false;
boost::optional<short> scen_arg_town, scen_arg_town_entrance;
boost::optional<location> scen_arg_out_sec, scen_arg_loc;
@@ -312,6 +313,7 @@ static void process_args(int argc, char* argv[]) {
// Loading and entering a scenario has to happen after other initialization steps,
// so we just save these options for later.
cli |= clara::Opt(scen_arg_path, "scen-path")["--scenario"]("Launch a scenario, with the default party if no party is loaded.");
cli |= clara::Opt(scen_arg_restart)["--restart"]("Restart of the scenario if the party is already in it. (SDFs will be cleared.)");
cli |= clara::Opt(scen_arg_town, "town")["--town"]("Put the party in a town.");
cli |= clara::Opt(cParseEntrance(scen_arg_town_entrance), "entrance")["--entrance"]("Put the party at a town entrance point.");
cli |= clara::Opt(cParseLocation(scen_arg_out_sec), "x,y")["--out-sec"]("Put the party in an outdoor section.");
@@ -400,8 +402,8 @@ static void handle_scenario_args() {
start_new_game(true);
}
if(univ.party.is_in_scenario()){
if(univ.scenario.scen_name == scenario.scen_name){
// The party is already in the correct scenario
if(univ.scenario.scen_name == scenario.scen_name && !scen_arg_restart){
// The party is already in the correct scenario and doesn't need to restart
}else{
// The party is in a different scenario.
// TODO maybe the player should be warned before they're removed from it?

View File

@@ -158,6 +158,8 @@ void launch_scenario(eLaunchType type) {
// Cancel
return;
}
}else if(type == eLaunchType::START){
command_stream << "--restart";
}
// allow specifying a debug party path as an editor preference