Skip to content

Commit

Permalink
Fix Microsoft Store install detection
Browse files Browse the repository at this point in the history
For future compatibility / correctness with other games that it's not
currently used on.
  • Loading branch information
Ortham committed Jul 30, 2023
1 parent 60cc8d8 commit 3b41f57
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/api/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,32 @@ 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<std::filesystem::path> GetAdditionalDataPaths(
const GameType gameType,
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,
Expand Down

0 comments on commit 3b41f57

Please sign in to comment.