summaryrefslogtreecommitdiff
path: root/src/profile.cpp
diff options
context:
space:
mode:
authorMikaël Capelle <capelle.mikael@gmail.com>2021-01-18 23:02:15 +0100
committerMikaël Capelle <capelle.mikael@gmail.com>2021-01-18 23:02:15 +0100
commit8a49f2232e546e022a6f435b8a0d466911b0b58c (patch)
tree9500713e291f2c560fd45e5e6519da60ae1369e7 /src/profile.cpp
parent58e72e89c35bd90b7a7a8574cf45c5a61afdf71f (diff)
Clamp priority to the correct value, taking backups into account.
Diffstat (limited to 'src/profile.cpp')
-rw-r--r--src/profile.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/profile.cpp b/src/profile.cpp
index 029265e2..b77a8295 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -650,14 +650,22 @@ void Profile::setModPriority(unsigned int index, int &newPriority)
return;
}
- for (std::map<int, unsigned int>::iterator iter = m_ModIndexByPriority.begin(); iter != m_ModIndexByPriority.end(); iter++) {
- if (newPriority < oldPriority && iter->first >= newPriority && iter->first < oldPriority) {
- m_ModStatus.at(iter->second).m_Priority += 1;
+ // we need to put the mod before backups
+ auto it = std::find_if(m_ModIndexByPriority.begin(), m_ModIndexByPriority.end(), [](auto&& p) {
+ return ModInfo::getByIndex(p.second)->isBackup();
+ });
+ if (it != m_ModIndexByPriority.end() && it->first <= newPriority) {
+ newPriority = it->first - 1;
+ }
+
+ for (auto& [priority, index] : m_ModIndexByPriority) {
+ if (newPriority < oldPriority && priority >= newPriority && priority < oldPriority) {
+ m_ModStatus.at(index).m_Priority += 1;
}
- else if (newPriority > oldPriority && iter->first <= newPriority && iter->first > oldPriority) {
- m_ModStatus.at(iter->second).m_Priority -= 1;
+ else if (newPriority > oldPriority && priority <= newPriority && priority > oldPriority) {
+ m_ModStatus.at(index).m_Priority -= 1;
}
- lastPriority = std::max(lastPriority, iter->first);
+ lastPriority = std::max(lastPriority, priority);
}
newPriority = std::min(newPriority, lastPriority);