all launch types can reset story

This commit is contained in:
2025-01-15 19:13:06 -06:00
committed by Celtic Minstrel
parent 897047a566
commit 5d1532afda
3 changed files with 26 additions and 5 deletions

View File

@@ -83,7 +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;
bool scen_arg_start = false;
boost::optional<short> scen_arg_town, scen_arg_town_entrance;
boost::optional<location> scen_arg_out_sec, scen_arg_loc;
@@ -313,7 +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_start)["--start"]("Put the party at the starting location of the scenario.");
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.");
@@ -386,6 +386,7 @@ static void process_args(int argc, char* argv[]) {
}
static void handle_scenario_args() {
bool resetting = false;
if(scen_arg_path){
fs::path path = *scen_arg_path;
@@ -402,8 +403,13 @@ static void handle_scenario_args() {
start_new_game(true);
}
if(univ.party.is_in_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
if(univ.scenario.scen_name == scenario.scen_name){
// The party is already in the correct scenario.
// Ask whether to clear SDFs or not
if(cChoiceDlog("reset-story",{"reset","keep"}).show() == "reset"){
resetting = true;
handle_victory(true);
}
}else{
// The party is in a different scenario.
// TODO maybe the player should be warned before they're removed from it?
@@ -483,6 +489,11 @@ static void handle_scenario_args() {
std::cerr << "--x and --y are required when loading a scenario outdoors" << std::endl;
exit(1);
}
}else if(scen_arg_start){
// If restarting the scenario completely, this isn't needed:
if(!resetting){
debug_return_to_start();
}
}
}