From ec16bd6c374f20c71894526666d5ddf8a3b5e5e1 Mon Sep 17 00:00:00 2001 From: Taylor Richards Date: Wed, 5 Apr 2017 23:38:39 -0400 Subject: [PATCH] exit properly when help or version cmdline options are specified --- src/network/stand_gui.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/network/stand_gui.cpp b/src/network/stand_gui.cpp index 3c511a1..eef24dd 100644 --- a/src/network/stand_gui.cpp +++ b/src/network/stand_gui.cpp @@ -76,6 +76,10 @@ bool StandaloneApp::OnInit() wxMessageBox(err, "Error!", wxOK|wxICON_ERROR|wxCENTRE|wxSTAY_ON_TOP); return false; + } catch (const bool retval) { + std_client->Close(); + + return retval; } std_client->Show(true); @@ -1114,6 +1118,7 @@ bool Standalone::startFreeSpace(int argc, wxCmdLineArgsArray &argv) { wxString epath = wxFileName(wxStandardPaths::Get().GetExecutablePath()).GetPath(true); bool cmd_port = false; + bool shutdown_cmd = false; epath.Append( wxT("fs") ); @@ -1140,6 +1145,12 @@ bool Standalone::startFreeSpace(int argc, wxCmdLineArgsArray &argv) cmd_port = true; } + // if we have help or version options, exit after game exec + if ( arg.Contains( wxT("-help") ) || arg.Contains( wxT("-version") ) + || arg.IsSameAs( wxT("-h") ) || arg.IsSameAs( wxT("-v") ) ) { + shutdown_cmd = true; + } + epath.Append( wxT(" ") ); epath.Append(arg); } @@ -1198,6 +1209,11 @@ bool Standalone::startFreeSpace(int argc, wxCmdLineArgsArray &argv) // start game executable fspid = wxExecute(epath, wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER | wxEXEC_HIDE_CONSOLE); + // throw shutdown if we should exit (such as help or version cmdline options) + if (shutdown_cmd) { + throw shutdown_cmd; + } + return (fspid > 0); } -- 2.39.2