Skip to content

Commit f11925a

Browse files
authored
Fix FIXABLE status for ModDataChecker. (#2080)
* Fix FIXABLE status for ModDataChecker. * Fix issue with registerFeature() without games.
1 parent 2395c13 commit f11925a

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/game_features.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,29 @@ class GameFeatures::CombinedModDataChecker : public ModDataChecker
4545
{
4646
m_fixer = nullptr;
4747

48-
for (auto& modDataChecker : m_modDataCheckers) {
48+
// go through the available mod-data checker, if any returns valid, we also
49+
// return valid, otherwise, return the first one that is fixable
50+
for (const auto& modDataChecker : m_modDataCheckers) {
4951
auto check = modDataChecker->dataLooksValid(fileTree);
5052

5153
switch (check) {
5254
case CheckReturn::FIXABLE:
53-
m_fixer = modDataChecker;
54-
[[fallthrough]];
55+
// only update fixer if there is not one with higher priority
56+
if (!m_fixer) {
57+
m_fixer = modDataChecker;
58+
}
59+
break;
5560
case CheckReturn::VALID:
61+
// clear fixer if one were found before and return VALID, not mandatory
62+
// but cleaner
63+
m_fixer = nullptr;
5664
return CheckReturn::VALID;
5765
case CheckReturn::INVALID:
5866
break;
5967
}
6068
}
61-
return CheckReturn::INVALID;
69+
70+
return m_fixer ? CheckReturn::FIXABLE : CheckReturn::INVALID;
6271
}
6372

6473
std::shared_ptr<MOBase::IFileTree>
@@ -100,7 +109,6 @@ class GameFeatures::CombinedModDataContent : public ModDataContent
100109
std::make_move_iterator(contents.end()));
101110

102111
// increase offset for next mod data content
103-
104112
offset += contents.size();
105113
}
106114
}

src/gamefeaturesproxy.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ bool GameFeaturesProxy::registerFeature(MOBase::IPluginGame* game,
2828
bool GameFeaturesProxy::registerFeature(std::shared_ptr<MOBase::GameFeature> feature,
2929
int priority, bool replace)
3030
{
31-
return registerFeature({}, feature, priority, replace);
31+
return registerFeature(QStringList(), feature, priority, replace);
3232
}
3333

3434
bool GameFeaturesProxy::unregisterFeature(std::shared_ptr<MOBase::GameFeature> feature)

0 commit comments

Comments
 (0)