From bed77a0f081a541b00ede5446dbcbd55bf943277 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 25 Mar 2017 12:20:41 +0000 Subject: [PATCH] Remove Game dependence from ApiDatabase --- src/api/api_database.cpp | 24 ++--- src/api/api_database.h | 15 ++- src/api/game/game.cpp | 2 +- src/api/game/game_cache.h | 2 - src/api/metadata/condition_evaluator.cpp | 93 +++++++++++-------- src/api/metadata/condition_evaluator.h | 26 ++++-- src/api/metadata/condition_grammar.h | 5 +- src/api/metadata/conditional_metadata.cpp | 4 +- src/api/metadata_list.cpp | 10 +- src/api/metadata_list.h | 5 +- .../metadata/condition_evaluator_test.h | 2 +- .../metadata/condition_grammar_test.h | 13 +-- src/tests/api/internals/metadata_list_test.h | 3 +- 13 files changed, 111 insertions(+), 93 deletions(-) diff --git a/src/api/api_database.cpp b/src/api/api_database.cpp index 525549ca..9472bdf3 100644 --- a/src/api/api_database.cpp +++ b/src/api/api_database.cpp @@ -36,7 +36,12 @@ #include "api/plugin/plugin_sorter.h" namespace loot { -ApiDatabase::ApiDatabase(Game& game) : game_(game) {} +ApiDatabase::ApiDatabase(const GameType gameType, + const boost::filesystem::path& dataPath, + std::shared_ptr gameCache, + std::shared_ptr loadOrderHandler) : + gameCache_(gameCache), + conditionEvaluator_(gameType, dataPath, gameCache, loadOrderHandler) {} /////////////////////////////////// // Database Loading Functions @@ -69,14 +74,14 @@ void ApiDatabase::LoadLists(const std::string& masterlistPath, void ApiDatabase::EvalLists() { // Clear caches before evaluating conditions. - game_.GetCache()->ClearCachedConditions(); + gameCache_->ClearCachedConditions(); Masterlist temp = masterlist_; MetadataList userTemp = userlist_; // Refresh active plugins before evaluating conditions. - temp.EvalAllConditions(game_); - userTemp.EvalAllConditions(game_); + temp.EvalAllConditions(conditionEvaluator_); + userTemp.EvalAllConditions(conditionEvaluator_); masterlist_ = temp; userlist_ = userTemp; @@ -146,10 +151,9 @@ std::vector ApiDatabase::GetGeneralMessages(bool evaluateConditions) co if (evaluateConditions) { // Evaluate conditions from scratch. - game_.GetCache()->ClearCachedConditions(); - ConditionEvaluator evaluator(&game_); + gameCache_->ClearCachedConditions(); for (auto it = std::begin(masterlistMessages); it != std::end(masterlistMessages);) { - if (!evaluator.evaluate(it->GetCondition())) + if (!conditionEvaluator_.evaluate(it->GetCondition())) it = masterlistMessages.erase(it); else ++it; @@ -169,8 +173,7 @@ PluginMetadata ApiDatabase::GetPluginMetadata(const std::string& plugin, } if (evaluateConditions) { - ConditionEvaluator evaluator(&game_); - return evaluator.evaluateAll(metadata); + return conditionEvaluator_.evaluateAll(metadata); } return metadata; @@ -181,8 +184,7 @@ PluginMetadata ApiDatabase::GetPluginUserMetadata(const std::string& plugin, PluginMetadata metadata = userlist_.FindPlugin(plugin); if (evaluateConditions) { - ConditionEvaluator evaluator(&game_); - return evaluator.evaluateAll(metadata); + return conditionEvaluator_.evaluateAll(metadata); } return metadata; diff --git a/src/api/api_database.h b/src/api/api_database.h index ee9a3510..9764a4a6 100644 --- a/src/api/api_database.h +++ b/src/api/api_database.h @@ -29,12 +29,20 @@ #include #include -#include "api/game/game.h" +#include "api/game/game_cache.h" +#include "api/game/load_order_handler.h" +#include "api/metadata/condition_evaluator.h" +#include "api/metadata_list.h" +#include "api/masterlist.h" #include "loot/database_interface.h" +#include "loot/enum/game_type.h" namespace loot { struct ApiDatabase : public DatabaseInterface { - ApiDatabase(Game& game); + ApiDatabase(const GameType gameType, + const boost::filesystem::path& dataPath, + std::shared_ptr gameCache, + std::shared_ptr loadOrderHandler); void LoadLists(const std::string& masterlist_path, const std::string& userlist_path = ""); @@ -74,7 +82,8 @@ struct ApiDatabase : public DatabaseInterface { void DiscardAllUserMetadata(); private: - Game& game_; + std::shared_ptr gameCache_; + ConditionEvaluator conditionEvaluator_; Masterlist masterlist_; MetadataList userlist_; }; diff --git a/src/api/game/game.cpp b/src/api/game/game.cpp index af61fdd0..9b8c02cc 100644 --- a/src/api/game/game.cpp +++ b/src/api/game/game.cpp @@ -70,7 +70,7 @@ Game::Game(const GameType gameType, loadOrderHandler_->Init(type_, gamePath_, localDataPath_); - database_ = std::make_shared(*this); + database_ = std::make_shared(Type(), DataPath(), GetCache(), GetLoadOrderHandler()); } GameType Game::Type() const { diff --git a/src/api/game/game_cache.h b/src/api/game/game_cache.h index 44cf1fde..ae1ddace 100644 --- a/src/api/game/game_cache.h +++ b/src/api/game/game_cache.h @@ -29,8 +29,6 @@ #include #include -#include "api/masterlist.h" -#include "api/metadata_list.h" #include "api/plugin/plugin.h" namespace loot { diff --git a/src/api/metadata/condition_evaluator.cpp b/src/api/metadata/condition_evaluator.cpp index 2de48c01..402954bd 100644 --- a/src/api/metadata/condition_evaluator.cpp +++ b/src/api/metadata/condition_evaluator.cpp @@ -35,10 +35,18 @@ using boost::format; namespace loot { -ConditionEvaluator::ConditionEvaluator(Game * game) : game_(game) {} +ConditionEvaluator::ConditionEvaluator() : gameType_(GameType::tes4), gameCache_(nullptr), loadOrderHandler_(nullptr) {} +ConditionEvaluator::ConditionEvaluator(const GameType gameType, + const boost::filesystem::path& dataPath, + std::shared_ptr gameCache, + std::shared_ptr loadOrderHandler) : + gameType_(gameType), + dataPath_(dataPath), + gameCache_(gameCache), + loadOrderHandler_(loadOrderHandler) {} -bool ConditionEvaluator::evaluate(const std::string& condition) { - if (game_ == nullptr) { +bool ConditionEvaluator::evaluate(const std::string& condition) const { + if (shouldParseOnly()) { // Still check that the syntax is valid. parseCondition(condition); return false; @@ -49,19 +57,19 @@ bool ConditionEvaluator::evaluate(const std::string& condition) { BOOST_LOG_TRIVIAL(trace) << "Evaluating condition: " << condition; - auto cachedValue = game_->GetCache()->GetCachedCondition(condition); + auto cachedValue = gameCache_->GetCachedCondition(condition); if (cachedValue.second) return cachedValue.first; bool result = parseCondition(condition); - game_->GetCache()->CacheCondition(condition, result); + gameCache_->CacheCondition(condition, result); return result; } -bool ConditionEvaluator::evaluate(const PluginCleaningData& cleaningData, const std::string& pluginName) { - if (game_ == nullptr || pluginName.empty()) +bool ConditionEvaluator::evaluate(const PluginCleaningData& cleaningData, const std::string& pluginName) const { + if (shouldParseOnly() || pluginName.empty()) return false; // First need to get plugin's CRC. @@ -69,23 +77,23 @@ bool ConditionEvaluator::evaluate(const PluginCleaningData& cleaningData, const // Get the CRC from the game plugin cache if possible. try { - crc = game_->GetPlugin(pluginName)->GetCRC(); + crc = gameCache_->GetPlugin(pluginName)->GetCRC(); } catch (...) {} // Otherwise calculate it from the file. if (crc == 0) { - if (boost::filesystem::exists(game_->DataPath() / pluginName)) { - crc = GetCrc32(game_->DataPath() / pluginName); - } else if (boost::filesystem::exists(game_->DataPath() / (pluginName + ".ghost"))) { - crc = GetCrc32(game_->DataPath() / (pluginName + ".ghost")); + if (boost::filesystem::exists(dataPath_ / pluginName)) { + crc = GetCrc32(dataPath_ / pluginName); + } else if (boost::filesystem::exists(dataPath_ / (pluginName + ".ghost"))) { + crc = GetCrc32(dataPath_ / (pluginName + ".ghost")); } } return cleaningData.GetCRC() == crc; } -PluginMetadata ConditionEvaluator::evaluateAll(const PluginMetadata& pluginMetadata) { - if (game_ == nullptr) +PluginMetadata ConditionEvaluator::evaluateAll(const PluginMetadata& pluginMetadata) const { + if (shouldParseOnly()) return pluginMetadata; PluginMetadata evaluatedMetadata(pluginMetadata.GetName()); @@ -151,7 +159,7 @@ PluginMetadata ConditionEvaluator::evaluateAll(const PluginMetadata& pluginMetad bool ConditionEvaluator::fileExists(const std::string& filePath) const { validatePath(filePath); - if (game_ == nullptr) + if (shouldParseOnly()) return false; if (filePath == "LOOT") @@ -161,23 +169,23 @@ bool ConditionEvaluator::fileExists(const std::string& filePath) const { // for plugins. try { // GetPlugin throws if it can't find an entry. - game_->GetPlugin(filePath); + gameCache_->GetPlugin(filePath); return true; } catch (...) { // Not a loaded plugin, check the filesystem. if (boost::iends_with(filePath, ".esp") || boost::iends_with(filePath, ".esm")) - return boost::filesystem::exists(game_->DataPath() / filePath) - || boost::filesystem::exists(game_->DataPath() / (filePath + ".ghost")); + return boost::filesystem::exists(dataPath_ / filePath) + || boost::filesystem::exists(dataPath_ / (filePath + ".ghost")); else - return boost::filesystem::exists(game_->DataPath() / filePath); + return boost::filesystem::exists(dataPath_ / filePath); } } bool ConditionEvaluator::regexMatchExists(const std::string& regexString) const { auto pathRegex = splitRegex(regexString); - if (game_ == nullptr) + if (shouldParseOnly()) return false; return isRegexMatchInDataDirectory(pathRegex, @@ -187,7 +195,7 @@ bool ConditionEvaluator::regexMatchExists(const std::string& regexString) const bool ConditionEvaluator::regexMatchesExist(const std::string& regexString) const { auto pathRegex = splitRegex(regexString); - if (game_ == nullptr) + if (shouldParseOnly()) return false; return areRegexMatchesInDataDirectory(pathRegex, @@ -197,43 +205,43 @@ bool ConditionEvaluator::regexMatchesExist(const std::string& regexString) const bool ConditionEvaluator::isPluginActive(const std::string& pluginName) const { validatePath(pluginName); - if (game_ == nullptr) + if (shouldParseOnly()) return false; if (pluginName == "LOOT") return false; - return game_->IsPluginActive(pluginName); + return loadOrderHandler_->IsPluginActive(pluginName); } bool ConditionEvaluator::isPluginMatchingRegexActive(const std::string& regexString) const { auto pathRegex = splitRegex(regexString); - if (game_ == nullptr) + if (shouldParseOnly()) return false; return isRegexMatchInDataDirectory(pathRegex, [&](const std::string& filename) { - return game_->IsPluginActive(filename); + return loadOrderHandler_->IsPluginActive(filename); }); } bool ConditionEvaluator::arePluginsActive(const std::string& regexString) const { auto pathRegex = splitRegex(regexString); - if (game_ == nullptr) + if (shouldParseOnly()) return false; return areRegexMatchesInDataDirectory(pathRegex, [&](const std::string& filename) { - return game_->IsPluginActive(filename); + return loadOrderHandler_->IsPluginActive(filename); }); } -bool ConditionEvaluator::checksumMatches(const std::string& filePath, const uint32_t checksum) { +bool ConditionEvaluator::checksumMatches(const std::string& filePath, const uint32_t checksum) const { validatePath(filePath); - if (game_ == nullptr) + if (shouldParseOnly()) return false; uint32_t realChecksum = 0; @@ -243,14 +251,14 @@ bool ConditionEvaluator::checksumMatches(const std::string& filePath, const uint // CRC could be for a plugin or a file. // Get the CRC from the game plugin cache if possible. try { - realChecksum = game_->GetPlugin(filePath)->GetCRC(); + realChecksum = gameCache_->GetPlugin(filePath)->GetCRC(); } catch (...) {} if (realChecksum == 0) { - if (boost::filesystem::exists(game_->DataPath() / filePath)) - realChecksum = GetCrc32(game_->DataPath() / filePath); - else if ((boost::iends_with(filePath, ".esp") || boost::iends_with(filePath, ".esm")) && boost::filesystem::exists(game_->DataPath() / (filePath + ".ghost"))) - realChecksum = GetCrc32(game_->DataPath() / (filePath + ".ghost")); + if (boost::filesystem::exists(dataPath_ / filePath)) + realChecksum = GetCrc32(dataPath_ / filePath); + else if ((boost::iends_with(filePath, ".esp") || boost::iends_with(filePath, ".esm")) && boost::filesystem::exists(dataPath_ / (filePath + ".ghost"))) + realChecksum = GetCrc32(dataPath_ / (filePath + ".ghost")); } } @@ -339,7 +347,7 @@ std::pair ConditionEvaluator::splitRegex(co } bool ConditionEvaluator::isGameSubdirectory(const boost::filesystem::path& path) const { - boost::filesystem::path parentPath = game_->DataPath() / path; + boost::filesystem::path parentPath = dataPath_ / path; return boost::filesystem::exists(parentPath) && boost::filesystem::is_directory(parentPath); } @@ -353,7 +361,7 @@ bool ConditionEvaluator::isRegexMatchInDataDirectory(const std::pairDataPath() / pathRegex.first), + return std::any_of(boost::filesystem::directory_iterator(dataPath_ / pathRegex.first), boost::filesystem::directory_iterator(), [&](const boost::filesystem::directory_entry& entry) { const std::string filename = entry.path().filename().string(); @@ -376,7 +384,7 @@ bool ConditionEvaluator::areRegexMatchesInDataDirectory(const std::pairGetPlugin(filePath)->GetVersion()); + return Version(gameCache_->GetPlugin(filePath)->GetVersion()); } catch (...) { // The file wasn't in the plugin cache, load it as a plugin // if it appears to be valid, otherwise treat it as a non // plugin file. - if (Plugin::IsValid(filePath, game_->Type(), game_->DataPath())) - return Version(Plugin(game_->Type(), game_->DataPath(), game_->GetLoadOrderHandler(), filePath, true).GetVersion()); + if (Plugin::IsValid(filePath, gameType_, dataPath_)) + return Version(Plugin(gameType_, dataPath_, loadOrderHandler_, filePath, true).GetVersion()); - return Version(game_->DataPath() / filePath); + return Version(dataPath_ / filePath); } } } +bool ConditionEvaluator::shouldParseOnly() const { + return gameCache_ == nullptr || loadOrderHandler_ == nullptr; +} } diff --git a/src/api/metadata/condition_evaluator.h b/src/api/metadata/condition_evaluator.h index 8b000f2c..87e612d9 100644 --- a/src/api/metadata/condition_evaluator.h +++ b/src/api/metadata/condition_evaluator.h @@ -30,7 +30,8 @@ #include -#include "api/game/game.h" +#include "api/game/game_cache.h" +#include "api/game/load_order_handler.h" #include "api/helpers/version.h" #include "loot/metadata/plugin_cleaning_data.h" #include "loot/metadata/plugin_metadata.h" @@ -38,11 +39,15 @@ namespace loot { class ConditionEvaluator { public: - ConditionEvaluator(Game * game); + ConditionEvaluator(); + ConditionEvaluator(const GameType gameType, + const boost::filesystem::path& dataPath, + std::shared_ptr gameCache, + std::shared_ptr loadOrderHandler); - bool evaluate(const std::string& condition); - bool evaluate(const PluginCleaningData& cleaningData, const std::string& pluginName); - PluginMetadata evaluateAll(const PluginMetadata& pluginMetadata); + bool evaluate(const std::string& condition) const; + bool evaluate(const PluginCleaningData& cleaningData, const std::string& pluginName) const; + PluginMetadata evaluateAll(const PluginMetadata& pluginMetadata) const; bool fileExists(const std::string& filePath) const; bool regexMatchExists(const std::string& regexString) const; @@ -53,7 +58,7 @@ public: bool arePluginsActive(const std::string& regexString) const; bool checksumMatches(const std::string& filePath, - const uint32_t checksum); + const uint32_t checksum) const; bool compareVersions(const std::string& filePath, const std::string& testVersion, @@ -74,11 +79,16 @@ private: bool areRegexMatchesInDataDirectory(const std::pair& pathRegex, const std::function condition) const; - bool parseCondition(const std::string& condition); + bool parseCondition(const std::string& condition) const; Version getVersion(const std::string& filePath) const; - Game * game_; + bool shouldParseOnly() const; + + const GameType gameType_; + const boost::filesystem::path dataPath_; + const std::shared_ptr gameCache_; + const std::shared_ptr loadOrderHandler_; }; } diff --git a/src/api/metadata/condition_grammar.h b/src/api/metadata/condition_grammar.h index 8859f583..6ba556be 100644 --- a/src/api/metadata/condition_grammar.h +++ b/src/api/metadata/condition_grammar.h @@ -55,8 +55,7 @@ namespace loot { template class ConditionGrammar : public boost::spirit::qi::grammar < Iterator, bool(), Skipper > { public: - ConditionGrammar() : ConditionGrammar(nullptr) {} - ConditionGrammar(ConditionEvaluator& evaluator) : ConditionGrammar::base_type(expression_, "condition grammar"), evaluator_(evaluator) { + ConditionGrammar(const ConditionEvaluator& evaluator) : ConditionGrammar::base_type(expression_, "condition grammar"), evaluator_(evaluator) { using boost::spirit::unicode::char_; using boost::spirit::unicode::string; namespace phoenix = boost::phoenix; @@ -203,7 +202,7 @@ private: boost::spirit::qi::rule quotedStr_, filePath_, comparator_; boost::spirit::qi::rule invalidPathChars_; - ConditionEvaluator& evaluator_; + const ConditionEvaluator& evaluator_; }; } #endif diff --git a/src/api/metadata/conditional_metadata.cpp b/src/api/metadata/conditional_metadata.cpp index d36cc285..62d8db66 100644 --- a/src/api/metadata/conditional_metadata.cpp +++ b/src/api/metadata/conditional_metadata.cpp @@ -47,8 +47,6 @@ std::string ConditionalMetadata::GetCondition() const { void ConditionalMetadata::ParseCondition() const { BOOST_LOG_TRIVIAL(trace) << "Testing condition syntax: " << condition_; - ConditionEvaluator evaluator(nullptr); - - evaluator.evaluate(condition_); + ConditionEvaluator().evaluate(condition_); } } diff --git a/src/api/metadata_list.cpp b/src/api/metadata_list.cpp index e305c26d..5212f4dd 100644 --- a/src/api/metadata_list.cpp +++ b/src/api/metadata_list.cpp @@ -152,16 +152,14 @@ void MetadataList::AppendMessage(const Message& message) { messages_.push_back(message); } -void MetadataList::EvalAllConditions(Game& game) { - ConditionEvaluator evaluator(&game); - +void MetadataList::EvalAllConditions(const ConditionEvaluator& conditionEvaluator) { if (unevaluatedPlugins_.empty()) unevaluatedPlugins_.swap(plugins_); else plugins_.clear(); for (const auto& plugin : unevaluatedPlugins_) { - plugins_.insert(evaluator.evaluateAll(plugin)); + plugins_.insert(conditionEvaluator.evaluateAll(plugin)); } if (unevaluatedRegexPlugins_.empty()) @@ -170,7 +168,7 @@ void MetadataList::EvalAllConditions(Game& game) { regexPlugins_ = unevaluatedRegexPlugins_; for (auto& plugin : regexPlugins_) { - plugin = evaluator.evaluateAll(plugin); + plugin = conditionEvaluator.evaluateAll(plugin); } if (unevaluatedMessages_.empty()) @@ -179,7 +177,7 @@ void MetadataList::EvalAllConditions(Game& game) { messages_.clear(); for (const auto& message : unevaluatedMessages_) { - if (evaluator.evaluate(message.GetCondition())) + if (conditionEvaluator.evaluate(message.GetCondition())) messages_.push_back(message); } } diff --git a/src/api/metadata_list.h b/src/api/metadata_list.h index d6cfa684..e05f9a32 100644 --- a/src/api/metadata_list.h +++ b/src/api/metadata_list.h @@ -31,11 +31,10 @@ #include +#include "api/metadata/condition_evaluator.h" #include "loot/metadata/plugin_metadata.h" namespace loot { -class Game; - class MetadataList { public: void Load(const boost::filesystem::path& filepath); @@ -57,7 +56,7 @@ public: void AppendMessage(const Message& message); // Eval plugin conditions. - void EvalAllConditions(Game& game); + void EvalAllConditions(const ConditionEvaluator& conditionEvaluator); protected: std::set bashTags_; diff --git a/src/tests/api/internals/metadata/condition_evaluator_test.h b/src/tests/api/internals/metadata/condition_evaluator_test.h index bab169da..3201feb4 100644 --- a/src/tests/api/internals/metadata/condition_evaluator_test.h +++ b/src/tests/api/internals/metadata/condition_evaluator_test.h @@ -39,7 +39,7 @@ protected: MessageContent("info"), })), game_(GetParam(), dataPath.parent_path(), localPath), - evaluator_(&game_) {} + evaluator_(game_.Type(), game_.DataPath(), game_.GetCache(), game_.GetLoadOrderHandler()) {} const std::vector info_; diff --git a/src/tests/api/internals/metadata/condition_grammar_test.h b/src/tests/api/internals/metadata/condition_grammar_test.h index 6bba3532..6fb07847 100644 --- a/src/tests/api/internals/metadata/condition_grammar_test.h +++ b/src/tests/api/internals/metadata/condition_grammar_test.h @@ -38,7 +38,7 @@ protected: ConditionGrammarTest() : resourcePath(dataPath / "resource" / "detail" / "resource.txt"), game_(GetParam(), dataPath.parent_path(), localPath), - evaluator_(&game_), + evaluator_(game_.Type(), game_.DataPath(), game_.GetCache(), game_.GetLoadOrderHandler()), result_(false), success_(false) {} @@ -103,7 +103,7 @@ INSTANTIATE_TEST_CASE_P(, GameType::tes5se)); TEST_P(ConditionGrammarTest, parsingInvalidSyntaxShouldThrow) { - ConditionEvaluator evaluator(nullptr); + ConditionEvaluator evaluator; Grammar grammar(evaluator); std::string condition("file(foo)"); @@ -126,7 +126,7 @@ TEST_P(ConditionGrammarTest, evaluatingInvalidSyntaxShouldThrow) { } TEST_P(ConditionGrammarTest, parsingAnEmptyConditionShouldThrow) { - ConditionEvaluator evaluator(nullptr); + ConditionEvaluator evaluator; Grammar grammar(evaluator); std::string condition(""); @@ -573,7 +573,6 @@ TEST_P(ConditionGrammarTest, aVersionGreaterThanOrEqualToConditionForAPluginWith } TEST_P(ConditionGrammarTest, anActiveConditionWithAPluginThatIsActiveShouldEvaluateToTrue) { - Grammar grammar(evaluator_); std::string condition("active(\"" + blankEsm + "\")"); @@ -587,7 +586,6 @@ TEST_P(ConditionGrammarTest, anActiveConditionWithAPluginThatIsActiveShouldEvalu } TEST_P(ConditionGrammarTest, anActiveConditionWithAPluginThatIsNotActiveShouldEvaluateToFalse) { - Grammar grammar(evaluator_); std::string condition("active(\"" + blankEsp + "\")"); @@ -601,7 +599,6 @@ TEST_P(ConditionGrammarTest, anActiveConditionWithAPluginThatIsNotActiveShouldEv } TEST_P(ConditionGrammarTest, anActiveConditionWithARegexMatchingAnActivePluginShouldEvaluateToTrue) { - Grammar grammar(evaluator_); std::string condition("active(\"Blank\\.esm\")"); @@ -615,7 +612,6 @@ TEST_P(ConditionGrammarTest, anActiveConditionWithARegexMatchingAnActivePluginSh } TEST_P(ConditionGrammarTest, anActiveConditionWithARegexMatchingNoActivePluginsShouldEvaluateToFalse) { - Grammar grammar(evaluator_); std::string condition("active(\"Blank\\.esp\")"); @@ -629,7 +625,6 @@ TEST_P(ConditionGrammarTest, anActiveConditionWithARegexMatchingNoActivePluginsS } TEST_P(ConditionGrammarTest, aManyActiveConditionWithARegexMatchingMoreThanOnePluginThatIsActiveShouldEvaluateToTrue) { - Grammar grammar(evaluator_); std::string condition("many_active(\"Blank( - Different Master Dependent)?\\.es(m|p)\")"); @@ -643,7 +638,6 @@ TEST_P(ConditionGrammarTest, aManyActiveConditionWithARegexMatchingMoreThanOnePl } TEST_P(ConditionGrammarTest, aManyActiveConditionWithARegexMatchingOnlyOnePluginThatIsActiveShouldEvaluateToFalse) { - Grammar grammar(evaluator_); std::string condition("many_active(\"Blank\\.esm\")"); @@ -657,7 +651,6 @@ TEST_P(ConditionGrammarTest, aManyActiveConditionWithARegexMatchingOnlyOnePlugin } TEST_P(ConditionGrammarTest, aManyActiveConditionWithARegexMatchingNoPluginsThatAreActiveShouldEvaluateToFalse) { - Grammar grammar(evaluator_); std::string condition("many_active(\"Blank\\.esp\")"); diff --git a/src/tests/api/internals/metadata_list_test.h b/src/tests/api/internals/metadata_list_test.h index 2848d9e0..6d6f41ba 100644 --- a/src/tests/api/internals/metadata_list_test.h +++ b/src/tests/api/internals/metadata_list_test.h @@ -285,6 +285,7 @@ TEST_P(MetadataListTest, erasePluginShouldRemoveStoredMetadataForTheGivenPlugin) TEST_P(MetadataListTest, evalAllConditionsShouldEvaluateTheConditionsForThePluginsStoredInTeMetadataList) { Game game(GetParam(), dataPath.parent_path(), localPath); + ConditionEvaluator evaluator(game.Type(), game.DataPath(), game.GetCache(), game.GetLoadOrderHandler()); MetadataList metadataList; ASSERT_NO_THROW(metadataList.Load(metadataPath)); @@ -299,7 +300,7 @@ TEST_P(MetadataListTest, evalAllConditionsShouldEvaluateTheConditionsForThePlugi ASSERT_EQ(blankEsp, plugin.GetName()); ASSERT_FALSE(plugin.HasNameOnly()); - EXPECT_NO_THROW(metadataList.EvalAllConditions(game)); + EXPECT_NO_THROW(metadataList.EvalAllConditions(evaluator)); plugin = metadataList.FindPlugin(PluginMetadata(blankEsm)); EXPECT_EQ(std::vector({