fix: add is_veh_enabled func

This commit is contained in:
goaaats 2021-12-23 15:57:26 +01:00
parent ca1f5baee4
commit 78efd885b7
No known key found for this signature in database
GPG key ID: F18F057873895461

View file

@ -35,6 +35,25 @@ bool is_running_on_linux()
return pwine_get_version != nullptr || pwine_get_host_version != nullptr; return pwine_get_version != nullptr || pwine_get_host_version != nullptr;
} }
bool is_veh_enabled()
{
size_t required_size;
getenv_s(&required_size, nullptr, 0, "DALAMUD_NO_VEH");
if (required_size > 0)
{
if (char* is_no_veh = static_cast<char*>(malloc(required_size * sizeof(char))))
{
getenv_s(&required_size, is_no_veh, required_size, "DALAMUD_NO_VEH");
auto result = _stricmp(is_no_veh, "true");
free(is_no_veh);
if (result == 0)
return false;
}
}
return true;
}
DllExport DWORD WINAPI Initialize(LPVOID lpParam) DllExport DWORD WINAPI Initialize(LPVOID lpParam)
{ {
#ifndef NDEBUG #ifndef NDEBUG
@ -74,8 +93,7 @@ DllExport DWORD WINAPI Initialize(LPVOID lpParam)
// ============================== VEH ======================================== // // ============================== VEH ======================================== //
printf("Initializing VEH... "); printf("Initializing VEH... ");
GetEnvironmentVariableW(L"DALAMUD_NO_VEH", nullptr, 0); if(is_running_on_linux() || !is_veh_enabled())
if(is_running_on_linux() || GetLastError() != ERROR_ENVVAR_NOT_FOUND)
{ {
printf("VEH was disabled manually!\n"); printf("VEH was disabled manually!\n");
} }