Skip to content

Commit

Permalink
Fix FIXABLE status for ModDataChecker. (#2080)
Browse files Browse the repository at this point in the history
* Fix FIXABLE status for ModDataChecker.
* Fix issue with registerFeature() without games.
  • Loading branch information
Holt59 authored Jul 28, 2024
1 parent 2395c13 commit f11925a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/game_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MOBase::IFileTree>
Expand Down Expand Up @@ -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();
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/gamefeaturesproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ bool GameFeaturesProxy::registerFeature(MOBase::IPluginGame* game,
bool GameFeaturesProxy::registerFeature(std::shared_ptr<MOBase::GameFeature> feature,
int priority, bool replace)
{
return registerFeature({}, feature, priority, replace);
return registerFeature(QStringList(), feature, priority, replace);
}

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

0 comments on commit f11925a

Please sign in to comment.