From 4963c278fe849562b1059fe70f95b0cd74a48f70 Mon Sep 17 00:00:00 2001 From: Chris Bessent Date: Sun, 26 Jan 2020 18:26:03 -0700 Subject: Don't allow foreign mods or overwrite for overriding overwrite --- src/editexecutablesdialog.cpp | 6 +++++- src/modinfo.cpp | 16 ++++++++++++++++ src/modinfo.h | 7 +++++++ 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/editexecutablesdialog.cpp b/src/editexecutablesdialog.cpp index 1c804a7c..52615c23 100644 --- a/src/editexecutablesdialog.cpp +++ b/src/editexecutablesdialog.cpp @@ -73,7 +73,11 @@ EditExecutablesDialog::EditExecutablesDialog(OrganizerCore& oc, int sel, QWidget loadForcedLibraries(); for (auto&& m : m_organizerCore.modList()->allMods()) { - if (ModInfo::isRegularName(m)) { + auto mod = ModInfo::getByName(m); + if (!mod->hasAnyOfTheseFlags({ ModInfo::FLAG_FOREIGN, + ModInfo::FLAG_BACKUP, + ModInfo::FLAG_OVERWRITE, + ModInfo::FLAG_SEPARATOR })) { ui->mods->addItem(m); } } diff --git a/src/modinfo.cpp b/src/modinfo.cpp index 6e048bfb..d971f150 100644 --- a/src/modinfo.cpp +++ b/src/modinfo.cpp @@ -491,6 +491,22 @@ bool ModInfo::hasFlag(ModInfo::EFlag flag) const return std::find(flags.begin(), flags.end(), flag) != flags.end(); } +bool ModInfo::hasAnyOfTheseFlags(std::vector flags) const +{ + std::vector modFlags = getFlags(); + for (auto modFlag : modFlags) + { + for (auto flag : flags) + { + if (modFlag == flag) + { + return true; + } + } + } + return false; +} + bool ModInfo::hasContent(ModInfo::EContent content) const { std::vector contents = getContents(); diff --git a/src/modinfo.h b/src/modinfo.h index a27822b0..34b1ecdf 100644 --- a/src/modinfo.h +++ b/src/modinfo.h @@ -541,6 +541,13 @@ public: */ bool hasFlag(EFlag flag) const; + /** + * @brief test if any of the provided flags are set for this mod + * @param flags the flags to test + * @return true if any of the flags are set, false otherwise + */ + bool hasAnyOfTheseFlags(std::vector flags) const; + /** * @brief test if the mods contains the specified content * @param content the content to test -- cgit v1.3.1