summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAL <26797547+Al12rs@users.noreply.github.com>2020-10-31 16:24:43 +0100
committerAL <26797547+Al12rs@users.noreply.github.com>2020-10-31 16:24:43 +0100
commit89d3311aca63ed5d0aa2345f630eb10003bdd9cb (patch)
tree121fe0026bf98f421d0c4c70b87a1d3a97e3676c /src
parent6f77c479077e250923fb98bbc56a11ed18987756 (diff)
Prefer early return in case of error.
Diffstat (limited to 'src')
-rw-r--r--src/modinfodialogconflicts.cpp96
1 files changed, 47 insertions, 49 deletions
diff --git a/src/modinfodialogconflicts.cpp b/src/modinfodialogconflicts.cpp
index 9dd98751..79ce6ade 100644
--- a/src/modinfodialogconflicts.cpp
+++ b/src/modinfodialogconflicts.cpp
@@ -927,72 +927,70 @@ std::optional<ConflictItem> AdvancedConflictsTab::createItem(
return currOrgId == alt.first;
});
- if (currModIter != alternatives.end()) {
- isCurrOrigArchive = currModIter->second.first.size() > 0;
+ if (currModIter == alternatives.end()) {
+ log::error("Mod {} not found in the list of origins for file {}", currOrigin->getName(), fileName);
+ return {};
+ }
+
+ isCurrOrigArchive = currModIter->second.first.size() > 0;
+
+ if (showAllAlts) {
+ // fills 'before' and 'after' with all the alternatives that come
+ // before and after the current mod, trusting the alternatives vector to be
+ // already sorted correctly
- if (showAllAlts) {
- // fills 'before' and 'after' with all the alternatives that come
- // before and after the current mod, trusting the alternatives vector to be
- // already sorted correctly
+ for (auto iter = alternatives.begin(); iter != alternatives.end(); iter++) {
- for (auto iter = alternatives.begin(); iter != alternatives.end(); iter++) {
-
- const auto& altOrigin = ds.getOriginByID(iter->first);
+ const auto& altOrigin = ds.getOriginByID(iter->first);
- if (iter < currModIter) {
- // mod comes before current
+ if (iter < currModIter) {
+ // mod comes before current
- if (!before.empty()) {
- before += L", ";
- }
-
- before += altOrigin.getName();
+ if (!before.empty()) {
+ before += L", ";
}
- else if (iter > currModIter) {
- // mod comes after current
- if (!after.empty()) {
- after += L", ";
- }
+ before += altOrigin.getName();
+ }
+ else if (iter > currModIter) {
+ // mod comes after current
- after += altOrigin.getName();
+ if (!after.empty()) {
+ after += L", ";
}
- }
- // also add the active winner origin (the one outside alternatives) to 'after'
- if (!after.empty()) {
- after += L", ";
+ after += altOrigin.getName();
}
- after += ds.getOriginByID(fileOrigin).getName();
-
+ }
+ // also add the active winner origin (the one outside alternatives) to 'after'
+ if (!after.empty()) {
+ after += L", ";
}
- else {
- // only show nearest origins
+ after += ds.getOriginByID(fileOrigin).getName();
- // before
- if (currModIter > alternatives.begin()) {
- auto previousOrigId = (currModIter-1)->first;
- before += ds.getOriginByID(previousOrigId).getName();
- }
- // after
- if (currModIter < (alternatives.end() - 1)) {
- auto followingOrigId = (currModIter + 1)->first;
- after += ds.getOriginByID(followingOrigId).getName();
- }
- else {
- // current mod is last of alternatives, so closest to the active winner
+ }
+ else {
+ // only show nearest origins
- after += ds.getOriginByID(fileOrigin).getName();
- }
-
+ // before
+ if (currModIter > alternatives.begin()) {
+ auto previousOrigId = (currModIter-1)->first;
+ before += ds.getOriginByID(previousOrigId).getName();
}
- }
- else {
- log::error("Mod {} not found in the list of origins for file {}", currOrigin->getName(), fileName);
- return {};
+ // after
+ if (currModIter < (alternatives.end() - 1)) {
+ auto followingOrigId = (currModIter + 1)->first;
+ after += ds.getOriginByID(followingOrigId).getName();
+ }
+ else {
+ // current mod is last of alternatives, so closest to the active winner
+
+ after += ds.getOriginByID(fileOrigin).getName();
+ }
+
}
}
}