summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2017-10-19 07:53:51 -0400
committerGravatar Robert C. Helling <helling@atdotde.de>2017-10-20 15:16:11 +0200
commit4fe8eb6f650fde98bb047108a93f695676968f72 (patch)
treebdee38c2b836ffaec548d9c7ab2c8ef3077fee3f /core
parent748bb90a7309fc4df5c88f7f9f85a5630140e0f7 (diff)
downloadsubsurface-4fe8eb6f650fde98bb047108a93f695676968f72.tar.gz
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 <miika.turkia@gmail.com>
Diffstat (limited to 'core')
-rw-r--r--core/dive.c15
1 files changed, 15 insertions, 0 deletions
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++;
}
}