Fixed GameDir localization issues.

I couldn't launch the game without this.
This commit is contained in:
Winos 2024-12-05 03:56:13 -03:00
parent 811fe41afb
commit ec1a09bbcb

View File

@ -182,7 +182,24 @@ void LegitimacyCheck() {
struct passwd* pw = getpwuid(getuid());
std::string homeDir = pw->pw_dir;
// Right now only steam is supported
std::ifstream libraryFolders(homeDir + "/.steam/root/steamapps/libraryfolders.vdf");
std::vector<std::string> steamappsCommonPaths = {
homeDir + "/.steam/root/steamapps/", // default
homeDir + "/.var/app/com.valvesoftware.Steam/.steam/root/steamapps/", // flatpak
};
std::string libraryFoldersPath;
bool libraryFoldersFound = false;
for (const std::string& path : steamappsCommonPaths) {
std::string fullPath = path + "/libraryfolders.vdf";
if (std::filesystem::exists(fullPath)) {
libraryFoldersPath = fullPath;
libraryFoldersFound = true;
break;
}
}
if (!libraryFoldersFound) {
throw std::runtime_error("Failed to find libraryfolders.vdf");
}
std::ifstream libraryFolders(libraryFoldersPath);
auto root = tyti::vdf::read(libraryFolders);
for (auto folderInfo : root.childs) {
@ -191,6 +208,13 @@ void LegitimacyCheck() {
break;
}
}
if (GameDir.empty()) {
// Check if user is using Snap, which can't be located from libraryFolders...
const std::string snapPath =
homeDir + "/snap/steam/common/.local/share/Steam/steamapps/common/BeamNG.drive/";
if (std::filesystem::exists(snapPath)) GameDir = snapPath;
}
#endif
}
std::string CheckVer(const std::string& dir) {