From 3b41f5705e10de82e1c31e68f6a905f29d141d0c Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 30 Jul 2023 12:06:07 +0100 Subject: [PATCH] Fix Microsoft Store install detection For future compatibility / correctness with other games that it's not currently used on. --- src/api/game/game.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index 1f0d0b58..24a5aad9 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -71,8 +71,23 @@ constexpr const char* MS_FO4_VAULT_TEC_DATA_PATH = constexpr const char* MS_FO4_WASTELAND_DATA_PATH = "../../Fallout 4- Wasteland Workshop (PC)/Content/Data"; -bool IsMicrosoftStoreGame(const std::filesystem::path& gamePath) { - return std::filesystem::exists(gamePath / "appxmanifest.xml"); +bool IsMicrosoftStoreInstall(const GameType gameType, + const std::filesystem::path& gamePath) { + switch (gameType) { + case GameType::tes3: + case GameType::tes4: + case GameType::fo3: + case GameType::fonv: + // tes3, tes4, fo3 and fonv install paths are localised, with the + // appxmanifest.xml file sitting in the parent directory. + return std::filesystem::exists(gamePath.parent_path() / + "appxmanifest.xml"); + case GameType::tes5se: + case GameType::fo4: + return std::filesystem::exists(gamePath / "appxmanifest.xml"); + default: + return false; + } } std::vector GetAdditionalDataPaths( @@ -80,7 +95,8 @@ std::vector GetAdditionalDataPaths( const std::filesystem::path& dataPath) { const auto gamePath = dataPath.parent_path(); - if (gameType == GameType::fo4 && IsMicrosoftStoreGame(gamePath)) { + if (gameType == GameType::fo4 && + IsMicrosoftStoreInstall(gameType, gamePath)) { // All DLC directories are listed before the main data path because DLC // plugins in those directories override any in the main data path. return {gamePath / MS_FO4_AUTOMATRON_DATA_PATH,