fix: issues with proton installations (#2711)

This commit is contained in:
Andreas Maerten 2024-02-13 00:16:10 +01:00 committed by GitHub
parent ec7735cb3a
commit 1b260f788b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 10 deletions

View File

@ -1,7 +1,6 @@
#pragma once
#include "logger.hpp"
#include "memory/module.hpp"
#include "util/is_proton.hpp"
namespace big
{
@ -22,8 +21,7 @@ namespace big
m_console_handle(nullptr),
m_file(file)
{
auto module = memory::module("ntdll.dll");
if (const auto env_no_color = std::getenv("NO_COLOR"); module.get_export("wine_get_version") || (env_no_color && strlen(env_no_color)))
if (is_proton())
{
LOG(VERBOSE) << "Using simple logger.";
m_console_logger = &logger::format_console_simple;
@ -183,4 +181,4 @@ namespace big
m_file_out << "[" << timestamp << "]"
<< "[" << get_level_string(level) << "/" << file << ":" << location.line() << "] " << msg->Message() << std::flush;
}
}
}

View File

@ -35,6 +35,7 @@
#include "services/vehicle/xml_vehicles_service.hpp"
#include "services/xml_maps/xml_map_service.hpp"
#include "thread_pool.hpp"
#include "util/is_proton.hpp"
#include "version.hpp"
namespace big
@ -158,10 +159,18 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
LOG(INFO) << "Yim's Menu Initializing";
LOGF(INFO, "Git Info\n\tBranch:\t{}\n\tHash:\t{}\n\tDate:\t{}", version::GIT_BRANCH, version::GIT_SHA1, version::GIT_DATE);
auto display_version = ReadRegistryKeySZ(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "DisplayVersion");
auto current_build = ReadRegistryKeySZ(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuild");
auto UBR = ReadRegistryKeyDWORD(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR");
LOG(INFO) << GetWindowsVersion() << " Version " << display_version << " (OS Build " << current_build << "." << UBR << ")";
// more tech debt, YAY!
if (is_proton())
{
LOG(INFO) << "Running on proton!";
}
else
{
auto display_version = ReadRegistryKeySZ(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "DisplayVersion");
auto current_build = ReadRegistryKeySZ(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuild");
auto UBR = ReadRegistryKeyDWORD(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", "UBR");
LOG(INFO) << GetWindowsVersion() << " Version " << display_version << " (OS Build " << current_build << "." << UBR << ")";
}
#ifndef NDEBUG
LOG(WARNING) << "Debug Build. Switch to RelWithDebInfo or Release Build for a more stable experience";
@ -343,4 +352,4 @@ BOOL APIENTRY DllMain(HMODULE hmod, DWORD reason, PVOID)
}
return true;
}
}

13
src/util/is_proton.hpp Normal file
View File

@ -0,0 +1,13 @@
#pragma once
#include "memory/module.hpp"
namespace big
{
inline bool is_proton()
{
static auto module = memory::module("ntdll.dll");
const auto env_no_color = std::getenv("NO_COLOR");
return module.get_export("wine_get_version") || (env_no_color && strlen(env_no_color));
}
}