aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert Helling <helling@atdotde.de>2017-02-03 07:31:30 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-02-03 07:41:35 -0800
commit8a8315d6fee28e71c63062c3332d82e1071c70d4 (patch)
treefb030f2d3b33a0637f2a8b84e5745fb7ec74e5c6
parent08c42813e5d3af8ca702be4333daf46cc14c1d39 (diff)
downloadsubsurface-8a8315d6fee28e71c63062c3332d82e1071c70d4.tar.gz
Correct "When merging planned dives keep all cylinders"
When merging a real dive with a planned dive (for comparison), we should not try to be clever in merging similar cylinders, rather keep the union of both cylinder sets as the two versions of the dive might differ in exctly which gas and how much of it was used. Increase MAX_CYLINDERS to 20 to make room for this. We warn if we exceed this number. [Dirk Hohndel: I had mistakenly pushed out an earlier version of this commit, so this fixes things up to the final version] Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--core/dive.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/core/dive.c b/core/dive.c
index 19a950482..3c2c2afde 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -2061,8 +2061,15 @@ static void merge_cylinders(struct dive *res, struct dive *a, struct dive *b)
mapping[j] = i;
++j;
}
- while (j < MAX_CYLINDERS)
+ bool warn = false;
+ while (j < MAX_CYLINDERS) {
+ if (is_cylinder_used(b, j))
+ warn = true;
mapping[j++] = 0;
+ }
+ if (warn) {
+ report_error("Could not merge all cylinders as number exceeds %d", MAX_CYLINDERS);
+ }
cylinder_renumber(b, mapping);
}
}