diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-21 20:01:43 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-21 20:01:43 +0100 |
| commit | 60085ae4b662cfd5a3f3d4da78994a275904af96 (patch) | |
| tree | 7e4087f8a20b4627b222d26900cb1a8fad17922a | |
| parent | 49461f00864df6e00479704fad7d7e15bc104c1e (diff) | |
Use actual priority of overwrite instead of INT_MAX, and remove useless checks.
| -rw-r--r-- | src/profile.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/profile.cpp b/src/profile.cpp index acda465b..6b8d0709 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -232,20 +232,18 @@ void Profile::doWriteModlist() for (auto iter = m_ModIndexByPriority.crbegin(); iter != m_ModIndexByPriority.crend(); iter++) { // the priority order was inverted on load so it has to be inverted again - unsigned int index = iter->second; - if (index != UINT_MAX) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(index); - if (!modInfo->isFixedPriority()) { - if (modInfo->isForeign()) { - file->write("*"); - } else if (m_ModStatus[index].m_Enabled) { - file->write("+"); - } else { - file->write("-"); - } - file->write(modInfo->name().toUtf8()); - file->write("\r\n"); + const auto index = iter->second; + ModInfo::Ptr modInfo = ModInfo::getByIndex(index); + if (!modInfo->isFixedPriority()) { + if (modInfo->isForeign()) { + file->write("*"); + } else if (m_ModStatus[index].m_Enabled) { + file->write("+"); + } else { + file->write("-"); } + file->write(modInfo->name().toUtf8()); + file->write("\r\n"); } } @@ -587,13 +585,10 @@ void Profile::updateIndices() std::vector<std::tuple<QString, QString, int> > Profile::getActiveMods() { std::vector<std::tuple<QString, QString, int> > result; - for (std::map<int, unsigned int>::const_iterator iter = m_ModIndexByPriority.begin(); iter != m_ModIndexByPriority.end(); iter++ ) { - if ((iter->second != UINT_MAX) && m_ModStatus[iter->second].m_Enabled) { - ModInfo::Ptr modInfo = ModInfo::getByIndex(iter->second); - if (modInfo->hasFlag(ModInfo::FLAG_OVERWRITE)) - result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), std::numeric_limits<int>::max())); - else - result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), m_ModStatus[iter->second].m_Priority)); + for (const auto& [priority, index] : m_ModIndexByPriority) { + if (m_ModStatus[index].m_Enabled) { + ModInfo::Ptr modInfo = ModInfo::getByIndex(index); + result.push_back(std::make_tuple(modInfo->internalName(), modInfo->absolutePath(), m_ModStatus[index].m_Priority)); } } |
