mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-04-06 15:56:26 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
386f471362 | ||
|
|
6c3bfda23b | ||
|
|
5737e27bf3 | ||
|
|
1860c0aef1 | ||
|
|
9d20b678f9 | ||
|
|
be7594039e |
@@ -122,10 +122,10 @@ std::filesystem::path GetGamePath() {
|
|||||||
struct passwd* pw = getpwuid(getuid());
|
struct passwd* pw = getpwuid(getuid());
|
||||||
std::string homeDir = pw->pw_dir;
|
std::string homeDir = pw->pw_dir;
|
||||||
|
|
||||||
std::string Path = homeDir + "/.local/share/BeamNG.drive/";
|
std::string Path = homeDir + "/.local/share/BeamNG/BeamNG.drive/";
|
||||||
std::string Ver = CheckVer(GetGameDir());
|
std::string Ver = CheckVer(GetGameDir());
|
||||||
Ver = Ver.substr(0, Ver.find('.', Ver.find('.') + 1));
|
Ver = Ver.substr(0, Ver.find('.', Ver.find('.') + 1));
|
||||||
Path += Ver + "/";
|
Path += "current/";
|
||||||
return Path;
|
return Path;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
|
#include <shlobj_core.h>
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
#include "vdf_parser.hpp"
|
#include "vdf_parser.hpp"
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
@@ -162,24 +163,43 @@ void FileList(std::vector<std::string>& a, const std::string& Path) {
|
|||||||
}
|
}
|
||||||
void LegitimacyCheck() {
|
void LegitimacyCheck() {
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
std::wstring Result;
|
wchar_t* appDataPath = new wchar_t[MAX_PATH];
|
||||||
std::string K3 = R"(Software\BeamNG\BeamNG.drive)";
|
HRESULT result = SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, appDataPath);
|
||||||
HKEY hKey;
|
|
||||||
LONG dwRegOPenKey = OpenKey(HKEY_CURRENT_USER, K3.c_str(), &hKey);
|
if (!SUCCEEDED(result)) {
|
||||||
if (dwRegOPenKey == ERROR_SUCCESS) {
|
fatal("Cannot get Local Appdata directory");
|
||||||
Result = QueryKey(hKey, 3);
|
|
||||||
if (Result.empty()) {
|
|
||||||
debug("Failed to QUERY key HKEY_CURRENT_USER\\Software\\BeamNG\\BeamNG.drive");
|
|
||||||
lowExit(3);
|
|
||||||
}
|
|
||||||
GameDir = Result;
|
|
||||||
} else {
|
|
||||||
debug("Failed to OPEN key HKEY_CURRENT_USER\\Software\\BeamNG\\BeamNG.drive");
|
|
||||||
lowExit(4);
|
|
||||||
}
|
}
|
||||||
K3.clear();
|
|
||||||
Result.clear();
|
auto BeamNGAppdataPath = std::filesystem::path(appDataPath) / "BeamNG";
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
if (const auto beamngIniPath = BeamNGAppdataPath / "BeamNG.Drive.ini"; exists(beamngIniPath)) {
|
||||||
|
if (std::ifstream beamngIni(beamngIniPath); beamngIni.is_open()) {
|
||||||
|
std::string contents((std::istreambuf_iterator(beamngIni)), std::istreambuf_iterator<char>());
|
||||||
|
beamngIni.close();
|
||||||
|
|
||||||
|
auto ini = Utils::ParseINI(contents);
|
||||||
|
if (ini.empty())
|
||||||
|
lowExit(3);
|
||||||
|
else
|
||||||
|
debug("Successfully parsed BeamNG.Drive.ini");
|
||||||
|
|
||||||
|
if (ini.contains("installPath")) {
|
||||||
|
std::wstring installPath = Utils::ToWString(std::get<std::string>(ini["installPath"]));
|
||||||
|
installPath.erase(0, installPath.find_first_not_of(L" \t"));
|
||||||
|
|
||||||
|
if (installPath = std::filesystem::path(Utils::ExpandEnvVars(installPath)); std::filesystem::exists(installPath)) {
|
||||||
|
GameDir = installPath;
|
||||||
|
debug(L"GameDir from BeamNG.Drive.ini: " + installPath);
|
||||||
|
} else {
|
||||||
|
lowExit(4);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lowExit(5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] appDataPath;
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
struct passwd* pw = getpwuid(getuid());
|
struct passwd* pw = getpwuid(getuid());
|
||||||
std::filesystem::path homeDir = pw->pw_dir;
|
std::filesystem::path homeDir = pw->pw_dir;
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ std::string GetVer() {
|
|||||||
return "2.6";
|
return "2.6";
|
||||||
}
|
}
|
||||||
std::string GetPatch() {
|
std::string GetPatch() {
|
||||||
return ".0";
|
return ".2";
|
||||||
}
|
}
|
||||||
|
|
||||||
beammp_fs_string GetEP(const beammp_fs_char* P) {
|
beammp_fs_string GetEP(const beammp_fs_char* P) {
|
||||||
@@ -215,7 +215,7 @@ void CheckForUpdates(const std::string& CV) {
|
|||||||
"https://backend.beammp.com/builds/launcher?download=true"
|
"https://backend.beammp.com/builds/launcher?download=true"
|
||||||
"&pk="
|
"&pk="
|
||||||
+ PublicKey + "&branch=" + Branch,
|
+ PublicKey + "&branch=" + Branch,
|
||||||
beammp_wide("new_") + BP, LatestHash);
|
GetBP() / (beammp_wide("new_") + GetEN()), LatestHash);
|
||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
fs::remove(Back, ec);
|
fs::remove(Back, ec);
|
||||||
if (ec == std::errc::permission_denied) {
|
if (ec == std::errc::permission_denied) {
|
||||||
@@ -224,7 +224,7 @@ void CheckForUpdates(const std::string& CV) {
|
|||||||
} else {
|
} else {
|
||||||
fs::rename(BP, Back);
|
fs::rename(BP, Back);
|
||||||
}
|
}
|
||||||
fs::rename(beammp_wide("new_") + BP, BP);
|
fs::rename(GetBP() / (beammp_wide("new_") + GetEN()), BP);
|
||||||
URelaunch();
|
URelaunch();
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user