mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-08-16 08:16:20 +00:00
Get error code when the game fails to launch on windows (#179)
This PR logs the error `CreateProcessA` returns when failing on windows. This can help with figuring out why the launcher `Failed to Launch the game!` --- By creating this pull request, I understand that code that is AI generated or otherwise automatically generated may be rejected without further discussion. I declare that I fully understand all code I pushed into this PR, and wrote all this code myself and own the rights to this code.
This commit is contained in:
commit
e216b6ec06
@ -90,6 +90,8 @@ void StartGame(std::string Dir) {
|
|||||||
gameArgs += options.game_arguments[i];
|
gameArgs += options.game_arguments[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debug("BeamNG executable path: " + Dir);
|
||||||
|
|
||||||
bSuccess = CreateProcessA(nullptr, (LPSTR)(Dir + gameArgs).c_str(), nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi);
|
bSuccess = CreateProcessA(nullptr, (LPSTR)(Dir + gameArgs).c_str(), nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi);
|
||||||
if (bSuccess) {
|
if (bSuccess) {
|
||||||
info("Game Launched!");
|
info("Game Launched!");
|
||||||
@ -97,7 +99,19 @@ void StartGame(std::string Dir) {
|
|||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||||
error("Game Closed! launcher closing soon");
|
error("Game Closed! launcher closing soon");
|
||||||
} else {
|
} else {
|
||||||
error("Failed to Launch the game! launcher closing soon");
|
std::string err = "";
|
||||||
|
|
||||||
|
DWORD dw = GetLastError();
|
||||||
|
LPVOID lpErrorMsgBuffer;
|
||||||
|
|
||||||
|
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dw,
|
||||||
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpErrorMsgBuffer, 0, nullptr) == 0) {
|
||||||
|
err = "Unknown error code: " + std::to_string(dw);
|
||||||
|
} else {
|
||||||
|
err = "Error " + std::to_string(dw) + ": " + (char*)lpErrorMsgBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
error("Failed to Launch the game! launcher closing soon. " + err);
|
||||||
}
|
}
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(5));
|
std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
exit(2);
|
exit(2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user