Skip to content

Commit 04c125e

Browse files
committed
Skip executable path when parsing command line (Fixes #2858)
1 parent 95a9b68 commit 04c125e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Client/core/CCore.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,22 @@ void CCore::ParseCommandLine(std::map<std::string, std::string>& options, const
14671467
}
14681468

14691469
const char* szCmdLine = GetCommandLine();
1470-
char szCmdLineCopy[512];
1470+
1471+
// Skip the leading game executable path (starts and ends with a quotation mark).
1472+
if (szCmdLine[0] == '"')
1473+
{
1474+
if (const char* afterPath = strchr(szCmdLine + 1, '"'); afterPath != nullptr)
1475+
{
1476+
++afterPath;
1477+
1478+
while (*afterPath && isspace(*afterPath))
1479+
++afterPath;
1480+
1481+
szCmdLine = afterPath;
1482+
}
1483+
}
1484+
1485+
char szCmdLineCopy[512];
14711486
STRNCPY(szCmdLineCopy, szCmdLine, sizeof(szCmdLineCopy));
14721487

14731488
char* pCmdLineEnd = szCmdLineCopy + strlen(szCmdLineCopy);

0 commit comments

Comments
 (0)