Skip to content

Commit 375e958

Browse files
committed
hammer: Fix game launching and dump error if game failed to start
1 parent b6969c3 commit 375e958

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

hammer/runcommands.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -439,16 +439,24 @@ bool RunCommands(CCommandArray& Commands, LPCTSTR pszOrigDocName, CWnd *parent)
439439
char szDir[MAX_PATH];
440440
V_strcpy_safe(szDir, szNewRun);
441441
// dimhotepus: Strip quotes around dir.
442-
RemoveQuotes(szDir, ssize(szDir));
442+
RemoveQuotes(szDir, V_strlen(szDir));
443443
V_StripFilename(szDir);
444444

445445
mychdir(szDir);
446446

447447
// YWB Force asynchronous operation so that engine doesn't hang on
448448
// exit??? Seems to work.
449449
// spawnv doesn't like quotes
450-
RemoveQuotes(szNewRun, ssize(szNewRun));
451-
_spawnv(/*cmd.bNoWait ?*/ _P_NOWAIT /*: P_WAIT*/, szNewRun, ppParms);
450+
RemoveQuotes(szNewRun, V_strlen(szNewRun));
451+
intptr_t rc = _spawnv(/*cmd.bNoWait ?*/ _P_NOWAIT /*: P_WAIT*/, szNewRun, ppParms);
452+
if (rc == -1)
453+
{
454+
const int err = errno;
455+
CString str;
456+
str.Format("The command failed:\r\n \"%s\"\r\n", std::generic_category().message(err).c_str());
457+
procWnd.Append(str);
458+
procWnd.SetForegroundWindow();
459+
}
452460
}
453461
}
454462
else

0 commit comments

Comments
 (0)