mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
Update BeamNG.cpp
As requested: - Changed 'string' variables that referred to paths to 'filesystem'. - Added error log for when a valid 'GameDir' isn't found. Also readded error log for when 'libraryfolders.vdf' is missing for better contextualization for the 'basic_string::_M_replace_aux' error (the code doesn't reach the GameDir segment when that file is not found).
This commit is contained in:
parent
89327b8e20
commit
63aee03969
@ -180,34 +180,44 @@ void LegitimacyCheck() {
|
|||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
struct passwd* pw = getpwuid(getuid());
|
struct passwd* pw = getpwuid(getuid());
|
||||||
std::string homeDir = pw->pw_dir;
|
std::filesystem::path homeDir = pw->pw_dir;
|
||||||
|
|
||||||
// Right now only steam is supported
|
// Right now only steam is supported
|
||||||
std::vector<std::string> steamappsCommonPaths = {
|
std::vector<std::filesystem::path> steamappsCommonPaths = {
|
||||||
"/.steam/root/steamapps/", // default
|
".steam/root/steamapps", // default
|
||||||
"/.var/app/com.valvesoftware.Steam/.steam/root/steamapps/", // flatpak
|
".var/app/com.valvesoftware.Steam/.steam/root/steamapps", // flatpak
|
||||||
"/snap/steam/common/.local/share/Steam/steamapps/" //snap
|
"snap/steam/common/.local/share/Steam/steamapps" // snap
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string libraryFoldersPath;
|
std::filesystem::path libraryFoldersPath;
|
||||||
bool libraryFoldersFound = false;
|
bool libraryFoldersFound = false;
|
||||||
for (const std::string& path : steamappsCommonPaths) {
|
|
||||||
std::string fullPath = homeDir + path + "/libraryfolders.vdf";
|
|
||||||
|
|
||||||
|
for (const auto& path : steamappsCommonPaths) {
|
||||||
|
std::filesystem::path fullPath = homeDir / path / "libraryfolders.vdf";
|
||||||
if (std::filesystem::exists(fullPath)) {
|
if (std::filesystem::exists(fullPath)) {
|
||||||
libraryFoldersPath = fullPath;
|
libraryFoldersPath = fullPath;
|
||||||
libraryFoldersFound = true;
|
libraryFoldersFound = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!libraryFoldersFound) {
|
||||||
|
error("Did not find a valid path to a libraryfolders.vdf file.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
std::ifstream libraryFolders(libraryFoldersPath);
|
std::ifstream libraryFolders(libraryFoldersPath);
|
||||||
auto root = tyti::vdf::read(libraryFolders);
|
auto root = tyti::vdf::read(libraryFolders);
|
||||||
|
|
||||||
for (auto folderInfo : root.childs) {
|
for (auto folderInfo : root.childs) {
|
||||||
if (std::filesystem::exists(folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/")) {
|
if (std::filesystem::exists(folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/")) {
|
||||||
GameDir = folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/";
|
GameDir = folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (GameDir.empty()) {
|
||||||
|
error("The game directory was not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
std::string CheckVer(const std::string& dir) {
|
std::string CheckVer(const std::string& dir) {
|
||||||
@ -228,4 +238,4 @@ std::string CheckVer(const std::string& dir) {
|
|||||||
temp += a;
|
temp += a;
|
||||||
}
|
}
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user