From d5c8ad836fe2bdc4ed919f2b3d3bc62c38571e91 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 9 Nov 2014 17:21:59 +0000 Subject: [PATCH] Fixed non-Skyrim BSA-loading plugins not marked. This goes way back. --- src/backend/metadata.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/backend/metadata.cpp b/src/backend/metadata.cpp index de893686..dfe28bbf 100644 --- a/src/backend/metadata.cpp +++ b/src/backend/metadata.cpp @@ -908,9 +908,23 @@ namespace loot { } bool Plugin::LoadsBSA(const Game& game) const { - if (game.Id() != Game::tes5 || IsRegexPlugin()) + if (IsRegexPlugin()) return false; - return boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 3) + "bsa")); + if (game.Id() == Game::tes5) { + // Skyrim plugins only load BSAs that exactly match their basename. + return boost::filesystem::exists(game.DataPath() / (name.substr(0, name.length() - 3) + "bsa")); + } + else { + //Oblivion, FO3 and FNV .esp files can load BSAs which begin with the plugin basename. + if (boost::iends_with(name, ".esp")) { + string basename = name.substr(0, name.length() - 4); + for (boost::filesystem::directory_iterator it(game.DataPath()); it != boost::filesystem::directory_iterator(); ++it) { + if (it->path().extension().string() == ".bsa" && boost::istarts_with(it->path().filename().string(), basename)) + return true; + } + } + return false; + } } bool operator == (const File& lhs, const Plugin& rhs) {