Refactor archive file extension detail to Game

This commit is contained in:
Oliver Hamlet
2016-04-03 09:59:12 +01:00
parent 8e44d8254c
commit 89a8f7bbcd
4 changed files with 18 additions and 5 deletions
+7
View File
@@ -191,4 +191,11 @@ namespace loot {
return LoadOrderHandler::IsPluginActive(pluginName);
}
}
std::string Game::getArchiveFileExtension() const {
if (Id() == Game::fo4)
return ".ba2";
else
return ".bsa";
}
}
+2
View File
@@ -51,6 +51,8 @@ namespace loot {
// Check if the plugin is active by using the cached value if
// available, and otherwise asking the load order handler.
bool IsPluginActive(const std::string& pluginName) const;
std::string getArchiveFileExtension() const;
private:
bool _pluginsFullyLoaded;
};
+1 -5
View File
@@ -92,11 +92,7 @@ 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";
const string archiveExtension = game.getArchiveFileExtension();
if (game.Id() == Game::tes5 || game.Id() == Game::fo4) {
// Skyrim and Fallout 4 plugins only load archives that exactly match their basename.
+8
View File
@@ -100,6 +100,14 @@ namespace loot {
EXPECT_THROW(game.Init(true, localPath), error);
}
TEST_P(GameTest, getArchiveFileExtensionShouldReturnDotBa2ForFallout4AndDotBsaForOtherGames) {
Game game(GetParam());
if (game.Id() == Game::fo4)
EXPECT_EQ(".ba2", game.getArchiveFileExtension());
else
EXPECT_EQ(".bsa", game.getArchiveFileExtension());
}
#ifndef _WIN32
// Testing on Windows will find real game installs in the Registry, so cannot
// test autodetection fully unless on Linux.