From 0801553556548a2d7dda4b64a52d2ddc7c38c362 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Sun, 31 Mar 2024 22:05:20 +0200 Subject: [PATCH] Fix commandLine for CreateProcessW Remove unnecessary ternary (binary is never iw4x-sp.exe) --- src/Components/Modules/QuickPatch.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index ef455f9a..ca8dfc9d 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -244,12 +244,12 @@ namespace Components return; } - auto workingDir = std::filesystem::current_path().string(); - const std::string binary = *Game::sys_exitCmdLine; - const std::string command = binary == "iw4x-sp.exe" ? "iw4x-sp" : "iw4x"; + const std::filesystem::path workingDir = std::filesystem::current_path(); + const std::wstring binary = Utils::String::Convert(*Game::sys_exitCmdLine); + const std::wstring commandLine = std::format(L"\"{}\" iw4x --pass \"{}\"", (workingDir / binary).wstring(), Utils::GetLaunchParameters()); - SetEnvironmentVariableA("MW2_INSTALL", workingDir.data()); - Utils::Library::LaunchProcess(Utils::String::Convert(binary), std::format(L"{} --pass \"{}\"", Utils::String::Convert(command), Utils::GetLaunchParameters()), workingDir); + SetEnvironmentVariableA("MW2_INSTALL", workingDir.string().data()); + Utils::Library::LaunchProcess(binary, commandLine, workingDir); } __declspec(naked) void QuickPatch::SND_GetAliasOffset_Stub()