Skip to content

Commit

Permalink
Improve robustness of "-$" command line key when it's used incorrectly (
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Feb 12, 2024
1 parent e66e812 commit 5e8c166
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/xrGame/Level_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,17 @@ bool CLevel::net_start6()
{
if (strstr(Core.Params, "-$"))
{
string256 buf, cmd, param;
sscanf(strstr(Core.Params, "-$") + 2, "%[^ ] %[^ ] ", cmd, param);
strconcat(sizeof(buf), buf, cmd, " ", param);
Console->Execute(buf);
string256 buf{}, cmd{}, param{};
const int result = sscanf(strstr(Core.Params, "-$") + 2, "%[^ ] %[^ ] ", cmd, param);
if (result == 2)
{
strconcat(buf, cmd, " ", param);
Console->Execute(buf);
}
else
{
Log("! The key '-$' is not being used correctly. Correct format: -$ <command> <param>");
}
}
}
else
Expand Down

0 comments on commit 5e8c166

Please sign in to comment.