mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 15:36:10 +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);
|
||||
#elif defined(__linux__)
|
||||
struct passwd* pw = getpwuid(getuid());
|
||||
std::string homeDir = pw->pw_dir;
|
||||
std::filesystem::path homeDir = pw->pw_dir;
|
||||
|
||||
// Right now only steam is supported
|
||||
std::vector<std::string> steamappsCommonPaths = {
|
||||
"/.steam/root/steamapps/", // default
|
||||
"/.var/app/com.valvesoftware.Steam/.steam/root/steamapps/", // flatpak
|
||||
"/snap/steam/common/.local/share/Steam/steamapps/" //snap
|
||||
std::vector<std::filesystem::path> steamappsCommonPaths = {
|
||||
".steam/root/steamapps", // default
|
||||
".var/app/com.valvesoftware.Steam/.steam/root/steamapps", // flatpak
|
||||
"snap/steam/common/.local/share/Steam/steamapps" // snap
|
||||
};
|
||||
|
||||
std::string libraryFoldersPath;
|
||||
std::filesystem::path libraryFoldersPath;
|
||||
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)) {
|
||||
libraryFoldersPath = fullPath;
|
||||
libraryFoldersFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!libraryFoldersFound) {
|
||||
error("Did not find a valid path to a libraryfolders.vdf file.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::ifstream libraryFolders(libraryFoldersPath);
|
||||
auto root = tyti::vdf::read(libraryFolders);
|
||||
|
||||
for (auto folderInfo : root.childs) {
|
||||
if (std::filesystem::exists(folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/")) {
|
||||
GameDir = folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/";
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GameDir.empty()) {
|
||||
error("The game directory was not found.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
std::string CheckVer(const std::string& dir) {
|
||||
@ -228,4 +238,4 @@ std::string CheckVer(const std::string& dir) {
|
||||
temp += a;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user