mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
748bb90a73
commit
4fe8eb6f65
1 changed files with 15 additions and 0 deletions
15
core/dive.c
15
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++;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue