From f11925ab88cd5881c7e5dd35c40744d95b3eab2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mika=C3=ABl=20Capelle?= Date: Sun, 28 Jul 2024 14:39:20 +0200 Subject: [PATCH] Fix FIXABLE status for ModDataChecker. (#2080) * Fix FIXABLE status for ModDataChecker. * Fix issue with registerFeature() without games. --- src/game_features.cpp | 18 +++++++++++++----- src/gamefeaturesproxy.cpp | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/game_features.cpp b/src/game_features.cpp index bc083bc80..9505c8dcb 100644 --- a/src/game_features.cpp +++ b/src/game_features.cpp @@ -45,20 +45,29 @@ class GameFeatures::CombinedModDataChecker : public ModDataChecker { m_fixer = nullptr; - for (auto& modDataChecker : m_modDataCheckers) { + // go through the available mod-data checker, if any returns valid, we also + // return valid, otherwise, return the first one that is fixable + for (const auto& modDataChecker : m_modDataCheckers) { auto check = modDataChecker->dataLooksValid(fileTree); switch (check) { case CheckReturn::FIXABLE: - m_fixer = modDataChecker; - [[fallthrough]]; + // only update fixer if there is not one with higher priority + if (!m_fixer) { + m_fixer = modDataChecker; + } + break; case CheckReturn::VALID: + // clear fixer if one were found before and return VALID, not mandatory + // but cleaner + m_fixer = nullptr; return CheckReturn::VALID; case CheckReturn::INVALID: break; } } - return CheckReturn::INVALID; + + return m_fixer ? CheckReturn::FIXABLE : CheckReturn::INVALID; } std::shared_ptr @@ -100,7 +109,6 @@ class GameFeatures::CombinedModDataContent : public ModDataContent std::make_move_iterator(contents.end())); // increase offset for next mod data content - offset += contents.size(); } } diff --git a/src/gamefeaturesproxy.cpp b/src/gamefeaturesproxy.cpp index 3adac3539..1c833a2fe 100644 --- a/src/gamefeaturesproxy.cpp +++ b/src/gamefeaturesproxy.cpp @@ -28,7 +28,7 @@ bool GameFeaturesProxy::registerFeature(MOBase::IPluginGame* game, bool GameFeaturesProxy::registerFeature(std::shared_ptr feature, int priority, bool replace) { - return registerFeature({}, feature, priority, replace); + return registerFeature(QStringList(), feature, priority, replace); } bool GameFeaturesProxy::unregisterFeature(std::shared_ptr feature)