Fix bug with Auth (#478)

This commit is contained in:
Edo 2022-09-06 14:06:29 +02:00 committed by GitHub
parent 7a5e3f3df4
commit c890b4c8a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -104,12 +104,25 @@ namespace Utils
return address; return address;
} }
void SetLegacyEnvironment()
{
wchar_t binaryPath[512];
GetModuleFileNameW(GetModuleHandleW(nullptr), binaryPath, sizeof(binaryPath) / sizeof(wchar_t));
auto* exeBaseName = std::wcsrchr(binaryPath, L'\\');
exeBaseName[0] = L'\0';
// Make the game work without the xlabs launcher
SetCurrentDirectoryW(binaryPath);
}
void SetEnvironment() void SetEnvironment()
{ {
wchar_t* buffer{}; wchar_t* buffer{};
std::size_t size{}; std::size_t size{};
if (_wdupenv_s(&buffer, &size, L"XLABS_MW2_INSTALL") != 0 || buffer == nullptr) if (_wdupenv_s(&buffer, &size, L"XLABS_MW2_INSTALL") != 0 || buffer == nullptr)
{ {
SetLegacyEnvironment();
return; return;
} }