mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
Refactor archive file extension detail to Game
This commit is contained in:
@@ -191,4 +191,11 @@ namespace loot {
|
||||
return LoadOrderHandler::IsPluginActive(pluginName);
|
||||
}
|
||||
}
|
||||
|
||||
std::string Game::getArchiveFileExtension() const {
|
||||
if (Id() == Game::fo4)
|
||||
return ".ba2";
|
||||
else
|
||||
return ".bsa";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user