From c40af681bfedfa53c65a7f8fb9260f612e45ac3b Mon Sep 17 00:00:00 2001 From: Tixx <83774803+WiserTixx@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:39:38 +0200 Subject: [PATCH 1/3] Strip bom encoding --- src/Security/BeamNG.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Security/BeamNG.cpp b/src/Security/BeamNG.cpp index 58167b7..19f5524 100644 --- a/src/Security/BeamNG.cpp +++ b/src/Security/BeamNG.cpp @@ -177,6 +177,10 @@ void LegitimacyCheck() { std::string contents((std::istreambuf_iterator(beamngIni)), std::istreambuf_iterator()); beamngIni.close(); + if (contents.size() >= 3 && (unsigned char)contents[0] == 0xEF && (unsigned char)contents[1] == 0xBB && (unsigned char)contents[2] == 0xBF) { + contents = contents.substr(3); + } + auto ini = Utils::ParseINI(contents); if (ini.empty()) lowExit(3); From 1209ff88e2a3529e5465e6eeb9c3140e18efc0ef Mon Sep 17 00:00:00 2001 From: Tixx <83774803+WiserTixx@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:39:57 +0200 Subject: [PATCH 2/3] Support unicode in windows terminal --- src/Logger.cpp | 12 ++++++------ src/Startup.cpp | 2 ++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Logger.cpp b/src/Logger.cpp index 33215fb..36188dd 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -57,36 +57,36 @@ void addToLog(const std::wstring& Line) { } void info(const std::string& toPrint) { std::string Print = getDate() + "[INFO] " + toPrint + "\n"; - std::cout << Print; + std::wcout << Utils::ToWString(Print); addToLog(Print); } void debug(const std::string& toPrint) { std::string Print = getDate() + "[DEBUG] " + toPrint + "\n"; if (options.verbose) { - std::cout << Print; + std::wcout << Utils::ToWString(Print); } addToLog(Print); } void warn(const std::string& toPrint) { std::string Print = getDate() + "[WARN] " + toPrint + "\n"; - std::cout << Print; + std::wcout << Utils::ToWString(Print); addToLog(Print); } void error(const std::string& toPrint) { std::string Print = getDate() + "[ERROR] " + toPrint + "\n"; - std::cout << Print; + std::wcout << Utils::ToWString(Print); addToLog(Print); } void fatal(const std::string& toPrint) { std::string Print = getDate() + "[FATAL] " + toPrint + "\n"; - std::cout << Print; + std::wcout << Utils::ToWString(Print); addToLog(Print); std::this_thread::sleep_for(std::chrono::seconds(5)); std::exit(1); } void except(const std::string& toPrint) { std::string Print = getDate() + "[EXCEP] " + toPrint + "\n"; - std::cout << Print; + std::wcout << Utils::ToWString(Print); addToLog(Print); } diff --git a/src/Startup.cpp b/src/Startup.cpp index ec6a592..2ccb89b 100644 --- a/src/Startup.cpp +++ b/src/Startup.cpp @@ -269,6 +269,8 @@ void LinuxPatch() { void InitLauncher() { SetConsoleTitleA(("BeamMP Launcher v" + std::string(GetVer()) + GetPatch()).c_str()); + SetConsoleOutputCP(CP_UTF8); + _setmode(_fileno(stdout), _O_U8TEXT); debug("Launcher Version : " + GetVer() + GetPatch()); CheckName(); LinuxPatch(); From a669557726647fa49b7971dde1ffd7c34c5b4aaa Mon Sep 17 00:00:00 2001 From: Tixx <83774803+WiserTixx@users.noreply.github.com> Date: Sun, 21 Sep 2025 21:54:24 +0200 Subject: [PATCH 3/3] Make logger stdout cross platform again --- include/Utils.h | 2 ++ src/Logger.cpp | 12 ++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/Utils.h b/include/Utils.h index 28f0986..f329038 100644 --- a/include/Utils.h +++ b/include/Utils.h @@ -21,12 +21,14 @@ #define beammp_fs_string std::wstring #define beammp_fs_char wchar_t #define beammp_wide(str) L##str +#define beammp_stdout std::wcout #define WIN32_LEAN_AND_MEAN #include #else #define beammp_fs_string std::string #define beammp_fs_char char #define beammp_wide(str) str +#define beammp_stdout std::cout #endif namespace Utils { diff --git a/src/Logger.cpp b/src/Logger.cpp index 36188dd..771d07d 100644 --- a/src/Logger.cpp +++ b/src/Logger.cpp @@ -57,36 +57,36 @@ void addToLog(const std::wstring& Line) { } void info(const std::string& toPrint) { std::string Print = getDate() + "[INFO] " + toPrint + "\n"; - std::wcout << Utils::ToWString(Print); + beammp_stdout << Utils::ToWString(Print); addToLog(Print); } void debug(const std::string& toPrint) { std::string Print = getDate() + "[DEBUG] " + toPrint + "\n"; if (options.verbose) { - std::wcout << Utils::ToWString(Print); + beammp_stdout << Utils::ToWString(Print); } addToLog(Print); } void warn(const std::string& toPrint) { std::string Print = getDate() + "[WARN] " + toPrint + "\n"; - std::wcout << Utils::ToWString(Print); + beammp_stdout << Utils::ToWString(Print); addToLog(Print); } void error(const std::string& toPrint) { std::string Print = getDate() + "[ERROR] " + toPrint + "\n"; - std::wcout << Utils::ToWString(Print); + beammp_stdout << Utils::ToWString(Print); addToLog(Print); } void fatal(const std::string& toPrint) { std::string Print = getDate() + "[FATAL] " + toPrint + "\n"; - std::wcout << Utils::ToWString(Print); + beammp_stdout << Utils::ToWString(Print); addToLog(Print); std::this_thread::sleep_for(std::chrono::seconds(5)); std::exit(1); } void except(const std::string& toPrint) { std::string Print = getDate() + "[EXCEP] " + toPrint + "\n"; - std::wcout << Utils::ToWString(Print); + beammp_stdout << Utils::ToWString(Print); addToLog(Print); }