From 897047a566c045acd20acc0eedd3b9a9560b051c Mon Sep 17 00:00:00 2001 From: Nat Quayle Nelson Date: Tue, 14 Jan 2025 20:07:57 -0600 Subject: [PATCH] use the exe-args format for child process --- src/scenedit/scen.main.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 21225b7d5..c08e4ff1c 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -136,42 +137,48 @@ void launch_scenario(eLaunchType type) { return; } - std::ostringstream command_stream; - command_stream << game_binary << " --scenario \"" << last_load_file << "\" "; + std::vector args; + args.push_back("--scenario"); + args.push_back(last_load_file); if(type == eLaunchType::LOC){ if(editing_town){ - command_stream << "--town " << cur_town; + args.push_back("--town"); + args.push_back(boost::lexical_cast(cur_town)); }else{ - command_stream << "--out-sec (" << cur_out.x << "," << cur_out.y << ")"; + location out_sec = {cur_out.x, cur_out.y}; + args.push_back("--out-sec"); + args.push_back(boost::lexical_cast(out_sec)); } - command_stream << " --loc (" << cen_x << "," << cen_y << ")"; + location loc = {cen_x, cen_y}; + args.push_back("--loc"); + args.push_back(boost::lexical_cast(loc)); }else if(type == eLaunchType::ENTRANCE){ - command_stream << "--town " << cur_town; + args.push_back("--town"); + args.push_back(boost::lexical_cast(cur_town)); + std::ostringstream prompt; prompt << "Launch in " << scenario.towns[cur_town]->name << " at which entrance?"; std::vector choices = {"North", "East", "South", "West"}; cStringChoice dlog(choices, prompt.str()); size_t choice = dlog.show(0); if(dlog->accepted()){ - command_stream << " --entrance " << choice; + args.push_back("--entrance"); + args.push_back(boost::lexical_cast(choice)); }else{ // Cancel return; } }else if(type == eLaunchType::START){ - command_stream << "--restart"; + args.push_back("--restart"); } // allow specifying a debug party path as an editor preference std::string default_party = get_string_pref("DefaultPartyPath"); if(!(get_bool_pref("ForceDefaultParty", false) || default_party.empty())){ - command_stream << " \"" << default_party << "\""; + args.push_back(default_party); } - LOG(command_stream.str()); - - - bp::child ch(command_stream.str(), bp::std_out > stdout); + bp::child ch(game_binary, args=args, bp::std_out > stdout); ch.detach(); }