Fix Fallout 4 archive detection

This commit is contained in:
Oliver Hamlet
2016-03-31 19:33:15 +01:00
parent cd4fb5e810
commit 644879f5fe
+8 -2
View File
@@ -92,15 +92,21 @@ namespace loot {
_isActive = game.IsPluginActive(Name());
// Get whether the plugin loads an archive (BSA/BA2) or not.
string archiveExtension;
if (game.Id() == Game::fo4)
archiveExtension = ".ba2";
else
archiveExtension = ".bsa";
if (game.Id() == Game::tes5 || game.Id() == Game::fo4) {
// Skyrim and Fallout 4 plugins only load archives that exactly match their basename.
_loadsArchive = boost::filesystem::exists(game.DataPath() / (Name().substr(0, Name().length() - 3) + "bsa"));
_loadsArchive = boost::filesystem::exists(game.DataPath() / (Name().substr(0, Name().length() - 4) + archiveExtension));
}
else if (game.Id() != Game::tes4 || boost::iends_with(Name(), ".esp")) {
//Oblivion .esp files and FO3, FNV plugins can load BSAs which begin with the plugin basename.
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)) {
if (boost::iequals(it->path().extension().string(), archiveExtension) && boost::istarts_with(it->path().filename().string(), basename)) {
_loadsArchive = true;
break;
}