From 3de4056df4ea5d0afbcea388ad8d681daea1aac3 Mon Sep 17 00:00:00 2001 From: SulfurNitride Date: Wed, 8 Apr 2026 03:30:04 -0500 Subject: Remove NaK/Rust dependency, port remaining functionality to native C++ Replace NaK Rust crate and nak_ffi with native C++ implementations: - Game detection (Steam, Heroic, Bottles), VDF parser, icon extraction - Prefix symlinks, SLR manager, Steam path detection - Known games database Add FUSE VFS optimizations: zero-copy reads via fuse_reply_data, default_permissions mount option, FUSE_CAP_ASYNC_DIO, FUSE_CAP_EXPIRE_ONLY, lookup cache parent index, cached mode bits, increased I/O buffer sizes. Update build system, prefix setup, and various fixes. Co-Authored-By: Claude Opus 4.6 (1M context) --- libs/game_bethesda/src/gamebryo/CMakeLists.txt | 6 +-- libs/game_bethesda/src/gamebryo/gamegamebryo.cpp | 43 ++++++++-------------- libs/game_bethesda/src/games/ttw/CMakeLists.txt | 6 +-- .../game_bethesda/src/games/ttw/gamefalloutttw.cpp | 31 ++++++---------- 4 files changed, 30 insertions(+), 56 deletions(-) (limited to 'libs/game_bethesda') diff --git a/libs/game_bethesda/src/gamebryo/CMakeLists.txt b/libs/game_bethesda/src/gamebryo/CMakeLists.txt index bbc47ae..9e5970b 100644 --- a/libs/game_bethesda/src/gamebryo/CMakeLists.txt +++ b/libs/game_bethesda/src/gamebryo/CMakeLists.txt @@ -58,11 +58,7 @@ target_link_libraries(game_gamebryo $,lz4::lz4,PkgConfig::LZ4> ) -# NaK FFI for game detection (replaces Windows registry) -if(TARGET mo2::nak_ffi) - target_link_libraries(game_gamebryo PRIVATE mo2::nak_ffi) - target_compile_definitions(game_gamebryo PRIVATE HAS_NAK_FFI) -endif() +# Game detection symbols are in libuibase.so (already linked via mo2::uibase). target_include_directories(game_gamebryo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/libs/game_bethesda/src/gamebryo/gamegamebryo.cpp b/libs/game_bethesda/src/gamebryo/gamegamebryo.cpp index 2fd45cd..9d29dcf 100644 --- a/libs/game_bethesda/src/gamebryo/gamegamebryo.cpp +++ b/libs/game_bethesda/src/gamebryo/gamegamebryo.cpp @@ -39,8 +39,9 @@ #include #endif -#ifdef HAS_NAK_FFI -#include +#ifndef _WIN32 +#include "gamedetection.h" +#include "steamdetection.h" #endif #include @@ -230,12 +231,9 @@ QFileInfo GameGamebryo::findInGameFolder(const QString& relativePath) const QString GameGamebryo::identifyGamePath() const { -#ifdef HAS_NAK_FFI - // Use NaK to detect game installations on Linux - NakGameList gameList = nak_detect_all_games(); - ON_BLOCK_EXIT([&]() { - nak_game_list_free(gameList); - }); +#ifndef _WIN32 + // Detect game installations on Linux. + const GameScanResult scanResult = detectAllGames(); QString shortName = gameShortName(); QString fullName = gameName(); @@ -258,17 +256,14 @@ QString GameGamebryo::identifyGamePath() const return anyToken; }; - for (size_t i = 0; i < gameList.count; ++i) { - const NakGame& game = gameList.games[i]; - QString detectedName = QString::fromUtf8(game.name); - QString detectedPath = QString::fromUtf8(game.install_path); - if (detectedName.compare(fullName, Qt::CaseInsensitive) == 0 || - detectedName.compare(shortName, Qt::CaseInsensitive) == 0 || - detectedName.contains(fullName, Qt::CaseInsensitive) || - detectedName.contains(shortName, Qt::CaseInsensitive) || - tokensMatch(detectedName, fullName) || tokensMatch(detectedName, shortName)) { - if (looksValid(QDir(detectedPath))) { - return detectedPath; + for (const DetectedGame& game : scanResult.games) { + if (game.name.compare(fullName, Qt::CaseInsensitive) == 0 || + game.name.compare(shortName, Qt::CaseInsensitive) == 0 || + game.name.contains(fullName, Qt::CaseInsensitive) || + game.name.contains(shortName, Qt::CaseInsensitive) || + tokensMatch(game.name, fullName) || tokensMatch(game.name, shortName)) { + if (looksValid(QDir(game.install_path))) { + return game.install_path; } } } @@ -857,14 +852,8 @@ QString GameGamebryo::parseEpicGamesLocation(const QStringList& manifests) QString GameGamebryo::parseSteamLocation(const QString& appid, const QString& directoryName) { -#ifdef HAS_NAK_FFI - // Use NaK to find Steam path - char* steamPathC = nak_find_steam_path(); - QString steamLocation; - if (steamPathC) { - steamLocation = QString::fromUtf8(steamPathC); - nak_string_free(steamPathC); - } +#ifndef _WIN32 + QString steamLocation = findSteamPath(); #elif defined(_WIN32) QString path = "Software\\Valve\\Steam"; QString steamLocation = diff --git a/libs/game_bethesda/src/games/ttw/CMakeLists.txt b/libs/game_bethesda/src/games/ttw/CMakeLists.txt index 828b67f..8a2b8b4 100644 --- a/libs/game_bethesda/src/games/ttw/CMakeLists.txt +++ b/libs/game_bethesda/src/games/ttw/CMakeLists.txt @@ -18,10 +18,6 @@ mo2_configure_plugin(game_ttw NO_SOURCES WARNINGS 4) mo2_default_source_group() target_link_libraries(game_ttw PRIVATE game_gamebryo) -# NaK FFI for TTW game detection (TTW uses FalloutNV as base game) -if(TARGET mo2::nak_ffi) - target_link_libraries(game_ttw PRIVATE mo2::nak_ffi) - target_compile_definitions(game_ttw PRIVATE HAS_NAK_FFI) -endif() +# Game detection symbols are in libuibase.so (already linked via game_gamebryo → mo2::uibase). mo2_install_plugin(game_ttw) diff --git a/libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp b/libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp index cfd8ca8..e09ddf0 100644 --- a/libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp +++ b/libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp @@ -15,9 +15,8 @@ #include #include -#ifdef HAS_NAK_FFI -#include -#include "scopeguard.h" +#ifndef _WIN32 +#include "gamedetection.h" #endif #include @@ -85,23 +84,17 @@ QString GameFalloutTTW::identifyGamePath() const QString path = "Software\\Bethesda Softworks\\FalloutNV"; result = findInRegistry(HKEY_LOCAL_MACHINE, path.toStdWString().c_str(), L"Installed Path"); -#elif defined(HAS_NAK_FFI) +#else // TTW uses FalloutNV as its base game, so look for Fallout New Vegas - // (the base class would try matching "TTW" which NaK doesn't know about) - NakGameList gameList = nak_detect_all_games(); - ON_BLOCK_EXIT([&]() { - nak_game_list_free(gameList); - }); - - for (size_t i = 0; i < gameList.count; ++i) { - const NakGame& game = gameList.games[i]; - QString detectedName = QString::fromUtf8(game.name); - if (detectedName.contains("Fallout", Qt::CaseInsensitive) && - detectedName.contains("Vegas", Qt::CaseInsensitive)) { - QString detectedPath = QString::fromUtf8(game.install_path); - if (looksValid(QDir(detectedPath))) { - result = detectedPath; - break; + { + const GameScanResult scanResult = detectAllGames(); + for (const DetectedGame& game : scanResult.games) { + if (game.name.contains("Fallout", Qt::CaseInsensitive) && + game.name.contains("Vegas", Qt::CaseInsensitive)) { + if (looksValid(QDir(game.install_path))) { + result = game.install_path; + break; + } } } } -- cgit v1.3.1