From 0c53ff4cd44125bef6e108e5374c7c88f118395f Mon Sep 17 00:00:00 2001 From: Tixx <83774803+WiserTixx@users.noreply.github.com> Date: Sat, 5 Oct 2024 18:34:39 +0200 Subject: [PATCH] Pass game arguments to beamng on windows --- src/GameStart.cpp | 9 ++++++++- src/Options.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/GameStart.cpp b/src/GameStart.cpp index ab5645e..844e20b 100644 --- a/src/GameStart.cpp +++ b/src/GameStart.cpp @@ -84,7 +84,14 @@ void StartGame(std::string Dir) { std::string BaseDir = Dir; //+"\\Bin64"; // Dir += R"(\Bin64\BeamNG.drive.x64.exe)"; Dir += "\\BeamNG.drive.exe"; - bSuccess = CreateProcessA(Dir.c_str(), nullptr, nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi); + std::string gameArgs = ""; + + for (int i = 0; i < options.game_arguments_length; i++) { + gameArgs += " "; + gameArgs += options.game_arguments[i]; + } + + bSuccess = CreateProcessA(nullptr, (LPSTR)(Dir + gameArgs).c_str(), nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi); if (bSuccess) { info("Game Launched!"); GamePID = pi.dwProcessId; diff --git a/src/Options.cpp b/src/Options.cpp index caa0db8..8dfa788 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -68,7 +68,7 @@ void InitOptions(int argc, char *argv[], Options &options) { options.no_download = true; options.no_launch = true; options.no_update = true; - } else if (argument == "--") { + } else if (argument == "--game") { options.game_arguments = &argv[i + 1]; options.game_arguments_length = argc - i - 1; break;