From c162b61056d9b285855db682d0c19758d08b3d17 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Mon, 1 Sep 2014 15:37:03 +0100 Subject: [PATCH] Fixed regex plugins not getting saved. Or equality-compared. --- src/backend/game.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/backend/game.cpp b/src/backend/game.cpp index 83780ce2..d8e08e39 100644 --- a/src/backend/game.cpp +++ b/src/backend/game.cpp @@ -126,7 +126,7 @@ namespace loot { YAML::Emitter yout; yout.SetIndent(2); yout << YAML::BeginMap - << YAML::Key << "plugins" << YAML::Value << plugins + << YAML::Key << "plugins" << YAML::Value << Plugins() << YAML::Key << "globals" << YAML::Value << messages << YAML::EndMap; @@ -141,7 +141,7 @@ namespace loot { } bool MetadataList::operator == (const MetadataList& rhs) const { - if (this->plugins.size() != rhs.plugins.size() || this->messages.size() != rhs.messages.size()) { + if (this->plugins.size() != rhs.plugins.size() || this->messages.size() != rhs.messages.size() || this->regexPlugins.size() != rhs.regexPlugins.size()) { BOOST_LOG_TRIVIAL(info) << "Metadata edited for some plugin, new and old userlists differ in size."; return false; } @@ -159,6 +159,19 @@ namespace loot { return false; } } + for (const auto& rhsPlugin : rhs.regexPlugins) { + const auto it = find(regexPlugins.begin(), regexPlugins.end(), rhsPlugin); + + if (it == this->regexPlugins.end()) { + BOOST_LOG_TRIVIAL(info) << "Metadata added for plugin: " << it->Name(); + return false; + } + + if (!it->DiffMetadata(rhsPlugin).HasNameOnly()) { + BOOST_LOG_TRIVIAL(info) << "Metadata edited for plugin: " << it->Name(); + return false; + } + } // Messages are compared exactly by the '==' operator, so there's no need to do a more // fine-grained check. for (const auto& rhsMessage : rhs.messages) {