Explicitly copy a cylinder which was marked as "unused" in the planner

When planning a new dive (not replan!!!) based on an existing (planned)
dive, the cylinders from the existing selected dive are copied.
This patch guarantees that cylinders which had been marked as "unused"
are indeed copied as well. Sounds strange at the first moment but makes
sense because if one marks a cylinder explicitly as "unused" in the
planner instead of deleting it that does mean that one wants to keep
this cylinder to have it available and be able to reenable it later-on.

Signed-off-by: Stefan Fuchs <sfuchs@gmx.de>
This commit is contained in:
Stefan Fuchs 2017-10-05 20:04:07 +02:00 committed by Robert C. Helling
parent 3487612337
commit c127a92e8e

View file

@ -670,7 +670,7 @@ void copy_cylinders(struct dive *s, struct dive *d, bool used_only)
memset(&d->cylinder[i], 0, sizeof(cylinder_t)); memset(&d->cylinder[i], 0, sizeof(cylinder_t));
} }
for (i = j = 0; i < MAX_CYLINDERS; i++) { for (i = j = 0; i < MAX_CYLINDERS; i++) {
if (!used_only || is_cylinder_used(s, i)) { if (!used_only || is_cylinder_used(s, i) || s->cylinder[i].cylinder_use == NOT_USED) {
d->cylinder[j].type = s->cylinder[i].type; d->cylinder[j].type = s->cylinder[i].type;
d->cylinder[j].type.description = copy_string(s->cylinder[i].type.description); d->cylinder[j].type.description = copy_string(s->cylinder[i].type.description);
d->cylinder[j].gasmix = s->cylinder[i].gasmix; d->cylinder[j].gasmix = s->cylinder[i].gasmix;