Fix merge

This commit is contained in:
Tixx committed 2025-06-08 13:34:15 +02:00
1 parent 06c741edc5
commit 6c740e2562
6 files changed
+59 -19

No files matched your search

+8 -9
View File
@@ -6,7 +6,6 @@
#if defined(_WIN32)
#include <shlobj.h>
#include <windows.h>
#elif defined(__linux__)
#include "vdf_parser.hpp"
#include <pwd.h>
@@ -32,14 +31,14 @@ std::wstring QueryKey(HKEY hKey, int ID);
std::wstring GetGamePath() {
static std::filesystem::path Path;
if (!Path.empty())
return Path.string();
return Path.wstring();
if (options.user_path) {
if (std::filesystem::exists(options.user_path)) {
Path = options.user_path;
debug("Using custom user folder path: " + Path.string());
debug(L"Using custom user folder path: " + Path.wstring());
} else
warn("Invalid or non-existent path (" + std::string(options.user_path) + ") specified using --user-path, skipping");
warn(L"Invalid or non-existent path (" + Utils::ToWString(options.user_path) + L") specified using --user-path, skipping");
}
if (const auto startupIniPath = std::filesystem::path(GetGameDir()) / "startup.ini"; exists(startupIniPath)) {
@@ -58,16 +57,16 @@ std::wstring GetGamePath() {
} else
debug("Successfully parsed startup.ini");
std::string userPath;
std::wstring userPath;
if (ini.contains("filesystem") && ini["filesystem"].contains("UserPath"))
userPath = ini["filesystem"]["UserPath"];
userPath = Utils::ToWString(ini["filesystem"]["UserPath"]);
if (!userPath.empty())
if (userPath = Utils::ExpandEnvVars(userPath); std::filesystem::exists(userPath)) {
Path = userPath;
debug("Using custom user folder path from startup.ini: " + Path.string());
debug(L"Using custom user folder path from startup.ini: " + Path.wstring());
} else
warn("Found custom user folder path (" + userPath + ") in startup.ini but it doesn't exist, skipping");
warn(L"Found custom user folder path (" + userPath + L") in startup.ini but it doesn't exist, skipping");
}
if (Path.empty()) {
@@ -129,7 +128,7 @@ void StartGame(std::wstring Dir) {
gameArgs += Utils::ToWString(options.game_arguments[i]);
}
debug("BeamNG executable path: " + Dir);
debug(L"BeamNG executable path: " + Dir);
bSuccess = CreateProcessW(nullptr, (wchar_t*)(Dir + gameArgs).c_str(), nullptr, nullptr, TRUE, 0, nullptr, BaseDir.c_str(), &si, &pi);
if (bSuccess) {
+1
View File
@@ -12,6 +12,7 @@
#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#include <shellapi.h>
#elif defined(__linux__)
#include <cstring>
#include <errno.h>
+3 -3
View File
@@ -525,7 +525,7 @@ void NewSyncResources(SOCKET Sock, const std::string& Mods, const std::vector<Mo
CheckForDir();
std::string FName = ModInfoIter->FileName;
do {
debug("Loading file '" + FName + "' to '" + PathToSaveTo.string() + "'");
debug(L"Loading file '" + Utils::ToWString(FName) + L"' to '" + PathToSaveTo.wstring() + L"'");
TCPSend("f" + ModInfoIter->FileName, Sock);
std::string Data = TCPRcv(Sock);
@@ -562,8 +562,8 @@ void NewSyncResources(SOCKET Sock, const std::string& Mods, const std::vector<Mo
Terminate = true;
}
if (GetSha256HashReallyFast(PathToSaveTo) != ModInfoIter->Hash) {
error("Failed to write or download the entire file '" + PathToSaveTo + "' correctly (hash mismatch)");
if (Utils::GetSha256HashReallyFast(PathToSaveTo) != ModInfoIter->Hash) {
error(L"Failed to write or download the entire file '" + PathToSaveTo.wstring() + L"' correctly (hash mismatch)");
Terminate = true;
}
} while (fs::file_size(PathToSaveTo) != ModInfoIter->FileSize && !Terminate);
-1
View File
@@ -7,7 +7,6 @@
#include <filesystem>
#if defined(_WIN32)
#include <windows.h>
#elif defined(__linux__)
#include "vdf_parser.hpp"
#include <pwd.h>
-1
View File
@@ -12,7 +12,6 @@
#include <nlohmann/json.hpp>
#include <string>
#if defined(_WIN32)
#include <windows.h>
#elif defined(__linux__)
#include <unistd.h>
#endif