diff --git a/src/backend/game/game.cpp b/src/backend/game/game.cpp index c4c8299c..1052a3c7 100644 --- a/src/backend/game/game.cpp +++ b/src/backend/game/game.cpp @@ -195,11 +195,4 @@ namespace loot { return LoadOrderHandler::IsPluginActive(pluginName); } } - - std::string Game::getArchiveFileExtension() const { - if (Id() == Game::fo4) - return ".ba2"; - else - return ".bsa"; - } } diff --git a/src/backend/game/game.h b/src/backend/game/game.h index 1daf9d4e..f5229058 100644 --- a/src/backend/game/game.h +++ b/src/backend/game/game.h @@ -51,8 +51,6 @@ 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; }; diff --git a/src/backend/game/game_settings.cpp b/src/backend/game/game_settings.cpp index 12001ede..7fa51054 100644 --- a/src/backend/game/game_settings.cpp +++ b/src/backend/game/game_settings.cpp @@ -191,6 +191,13 @@ namespace loot { return LootPaths::getLootDataPath() / _lootFolderName / "userlist.yaml"; } + std::string GameSettings::GetArchiveFileExtension() const { + if (_id == GameSettings::fo4) + return ".ba2"; + else + return ".bsa"; + } + GameSettings& GameSettings::SetName(const std::string& name) { BOOST_LOG_TRIVIAL(trace) << "Setting \"" << _name << "\" name to: " << name; _name = name; diff --git a/src/backend/game/game_settings.h b/src/backend/game/game_settings.h index 2d14310e..bd611a54 100644 --- a/src/backend/game/game_settings.h +++ b/src/backend/game/game_settings.h @@ -59,6 +59,8 @@ namespace loot { boost::filesystem::path MasterlistPath() const; boost::filesystem::path UserlistPath() const; + std::string GetArchiveFileExtension() const; + GameSettings& SetName(const std::string& name); GameSettings& SetMaster(const std::string& masterFile); GameSettings& SetRegistryKey(const std::string& registry); diff --git a/src/backend/plugin/plugin.cpp b/src/backend/plugin/plugin.cpp index 0e26e239..f96cfeb5 100644 --- a/src/backend/plugin/plugin.cpp +++ b/src/backend/plugin/plugin.cpp @@ -92,7 +92,7 @@ namespace loot { _isActive = game.LoadOrderHandler::IsPluginActive(Name()); // Get whether the plugin loads an archive (BSA/BA2) or not. - const string archiveExtension = game.getArchiveFileExtension(); + const string archiveExtension = game.GetArchiveFileExtension(); if (game.Id() == Game::tes5) { // Skyrim plugins only load BSAs that exactly match their basename. diff --git a/src/tests/backend/game/game_settings_test.h b/src/tests/backend/game/game_settings_test.h index 69c7a780..7ac48483 100644 --- a/src/tests/backend/game/game_settings_test.h +++ b/src/tests/backend/game/game_settings_test.h @@ -131,6 +131,16 @@ namespace loot { EXPECT_FALSE(game1 == game2); } + TEST_P(GameSettingsTest, getArchiveFileExtensionShouldReturnDotBa2IfGameIdIsFallout4) { + GameSettings game(GameSettings::fo4); + EXPECT_EQ(".ba2", game.GetArchiveFileExtension()); + } + + TEST_P(GameSettingsTest, getArchiveFileExtensionShouldReturnDotBsaIfGameIdIsNotFallout4) { + GameSettings game; + EXPECT_EQ(".bsa", game.GetArchiveFileExtension()); + } + TEST_P(GameSettingsTest, setNameShouldStoreGivenValue) { GameSettings game; game.SetName("name"); diff --git a/src/tests/backend/game/game_test.h b/src/tests/backend/game/game_test.h index 9ed91892..9df12557 100644 --- a/src/tests/backend/game/game_test.h +++ b/src/tests/backend/game/game_test.h @@ -100,14 +100,6 @@ 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. diff --git a/src/tests/backend/plugin/plugin_test.h b/src/tests/backend/plugin/plugin_test.h index bf3a2826..6d052aa0 100644 --- a/src/tests/backend/plugin/plugin_test.h +++ b/src/tests/backend/plugin/plugin_test.h @@ -35,8 +35,8 @@ namespace loot { PluginTest() : emptyFile("EmptyFile.esm"), nonPluginFile("NotAPlugin.esm"), - blankArchive("Blank" + Game(GetParam()).getArchiveFileExtension()), - blankSuffixArchive("Blank - Different - suffix" + Game(GetParam()).getArchiveFileExtension()) {} + blankArchive("Blank" + Game(GetParam()).GetArchiveFileExtension()), + blankSuffixArchive("Blank - Different - suffix" + Game(GetParam()).GetArchiveFileExtension()) {} inline void SetUp() { BaseGameTest::SetUp();