Created
September 11, 2014 13:23
-
-
Save peterix/9410f4063c00e27d1905 to your computer and use it in GitHub Desktop.
Making code readable, exposing problems.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* Before */ | |
| const QMap<QuickModRef, QPair<QuickModVersionRef, bool>> quickmods = | |
| m_instance->getFullVersion()->quickmods; | |
| QList<QuickModRef> mods; | |
| for (auto it = quickmods.cbegin(); it != quickmods.cend(); ++it) | |
| { | |
| const QuickModVersionRef version = it.value().first; | |
| QuickModPtr mod = version.isValid() ? version.findMod() | |
| : MMC->quickmodslist()->mods(it.key()).first(); | |
| QuickModVersionPtr ptr = version.findVersion(); | |
| if (!ptr || !MMC->quickmodSettings()->isModMarkedAsExists(mod, version) || hasResolveError || | |
| (ptr->needsDeploy() && !MMC->quickmodSettings()->isModMarkedAsInstalled(mod->uid(), version, m_instance))) | |
| { | |
| mods.append(mod->uid()); | |
| } | |
| } | |
| /* After */ | |
| auto iter = m_instance->installedMods()->iterateQuickMods(); | |
| QList<QuickModRef> mods; | |
| while (iter->isValid()) | |
| { | |
| auto version = iter->version(); | |
| QuickModVersionPtr ptr = version.findVersion(); | |
| // FIXME: unify the refs and don't do this silly stuff. | |
| QuickModPtr mod; | |
| if(version.isValid()) | |
| { | |
| mod = version.findMod(); | |
| } | |
| else | |
| { | |
| // FIXME: this is not respecting user preferences... | |
| mod = MMC->quickmodslist()->mods(iter->uid()).first(); | |
| } | |
| bool processMod = false; | |
| processMod |= !ptr; | |
| processMod |= !MMC->quickmodSettings()->isModMarkedAsExists(mod, version); | |
| processMod |= hasResolveError; | |
| processMod |= ptr->needsDeploy() && !MMC->quickmodSettings()->isModMarkedAsInstalled(mod->uid(), version, m_instance); | |
| if(processMod) | |
| { | |
| mods.append(mod->uid()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment