From 4fe8eb6f650fde98bb047108a93f695676968f72 Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Thu, 19 Oct 2017 07:53:51 -0400 Subject: Do not overwrite start and end pressures on cylinder The pressure information of cylinder should be kept intact when copy-pasting other cylinder related information from other dive. According to Dirk, the gas mix is wanted to be changed as technical divers might have always the same multiple cylinders and wish to copy the gasmix information over. Fixes #689 Signed-off-by: Miika Turkia --- core/dive.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'core') diff --git a/core/dive.c b/core/dive.c index c84c878f3..fccfe4da9 100644 --- a/core/dive.c +++ b/core/dive.c @@ -663,9 +663,17 @@ int nr_weightsystems(struct dive *dive) void copy_cylinders(struct dive *s, struct dive *d, bool used_only) { int i,j; + cylinder_t t[MAX_CYLINDERS]; if (!s || !d) return; + for (i = 0; i < MAX_CYLINDERS; i++) { + // Store the original start and end pressures + t[i].start.mbar = d->cylinder[i].start.mbar; + t[i].end.mbar = d->cylinder[i].end.mbar; + t[i].sample_start.mbar = d->cylinder[i].sample_start.mbar; + t[i].sample_end.mbar = d->cylinder[i].sample_end.mbar; + free((void *)d->cylinder[i].type.description); memset(&d->cylinder[i], 0, sizeof(cylinder_t)); } @@ -677,6 +685,13 @@ void copy_cylinders(struct dive *s, struct dive *d, bool used_only) d->cylinder[j].depth = s->cylinder[i].depth; d->cylinder[j].cylinder_use = s->cylinder[i].cylinder_use; d->cylinder[j].manually_added = true; + + // Restore the start and end pressures from original cylinder + d->cylinder[i].start.mbar = t[i].start.mbar; + d->cylinder[i].end.mbar = t[i].end.mbar; + d->cylinder[i].sample_start.mbar = t[i].sample_start.mbar; + d->cylinder[i].sample_end.mbar = t[i].sample_end.mbar; + j++; } } -- cgit v1.2.3-70-g09d2