diff options
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/game_bethesda/src/games/ttw/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp | 27 | ||||
| -rw-r--r-- | libs/nak/src/deps/tools.rs | 21 |
3 files changed, 39 insertions, 16 deletions
diff --git a/libs/game_bethesda/src/games/ttw/CMakeLists.txt b/libs/game_bethesda/src/games/ttw/CMakeLists.txt index 27149ec..828b67f 100644 --- a/libs/game_bethesda/src/games/ttw/CMakeLists.txt +++ b/libs/game_bethesda/src/games/ttw/CMakeLists.txt @@ -17,4 +17,11 @@ add_library(game_ttw SHARED 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() + 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 3ffa5a1..cfd8ca8 100644 --- a/libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp +++ b/libs/game_bethesda/src/games/ttw/gamefalloutttw.cpp @@ -15,6 +15,11 @@ #include <gamebryosavegameinfo.h> #include <gamebryounmanagedmods.h> +#ifdef HAS_NAK_FFI +#include <nak_ffi.h> +#include "scopeguard.h" +#endif + #include <QCoreApplication> #include <QDir> #include <QFileInfo> @@ -80,8 +85,26 @@ QString GameFalloutTTW::identifyGamePath() const QString path = "Software\\Bethesda Softworks\\FalloutNV"; result = findInRegistry(HKEY_LOCAL_MACHINE, path.toStdWString().c_str(), L"Installed Path"); -#else - result = GameGamebryo::identifyGamePath(); +#elif defined(HAS_NAK_FFI) + // 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; + } + } + } #endif // EPIC Game Store if (result.isEmpty()) { diff --git a/libs/nak/src/deps/tools.rs b/libs/nak/src/deps/tools.rs index 0e3e356..03dbe9a 100644 --- a/libs/nak/src/deps/tools.rs +++ b/libs/nak/src/deps/tools.rs @@ -105,19 +105,12 @@ pub fn ensure_winetricks() -> Result<PathBuf, Box<dyn Error>> { const CABEXTRACT_URL: &str = "https://github.com/SulfurNitride/NaK/releases/download/Cabextract/cabextract-linux-x86_64.zip"; -/// Ensures cabextract is available (either system or downloaded). +/// Ensures cabextract is available in our bin directory. +/// +/// Always downloads to ~/.local/share/fluorine/bin/ because winetricks runs +/// inside pressure-vessel where system binaries under /usr are not visible. pub fn ensure_cabextract() -> Result<PathBuf, Box<dyn Error>> { - // First check if system has cabextract - if Command::new("which") - .arg("cabextract") - .output() - .map(|o| o.status.success()) - .unwrap_or(false) - { - return Ok(PathBuf::from("cabextract")); - } - - // Check if we already downloaded it + // Check if we already downloaded it to our bin dir let bin_dir = get_nak_bin_path(); let cabextract_path = bin_dir.join("cabextract"); @@ -125,8 +118,8 @@ pub fn ensure_cabextract() -> Result<PathBuf, Box<dyn Error>> { return Ok(cabextract_path); } - // Download cabextract zip - log_warning("System cabextract not found, downloading..."); + // Download cabextract zip — system copy is unusable inside pressure-vessel + log_info("Downloading cabextract for use inside container..."); fs::create_dir_all(&bin_dir)?; let response = ureq::get(CABEXTRACT_URL).call().map_err(|e| { |
