diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-06-01 12:38:32 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-01 12:43:40 -0700 |
commit | c539c8f861928c637f6b3e790b05e89914e2be8f (patch) | |
tree | 9728f8d08279bbe98fa8afdec73de9de1d55b66a /dive.c | |
parent | 1a040134538b7733f3088ea34f101cfedecc2c64 (diff) | |
download | subsurface-c539c8f861928c637f6b3e790b05e89914e2be8f.tar.gz |
Remove the .used member of the cylinder structure
Instead calculate this information on the fly, taking into account all
dive computers on the dive in questions.
There is one wrinkle to this - previously we abused the '.used' member to
make sure that a manually added cylinder didn't disappear the moment it
was added (think of the workflow: you add a cylinder, then you add a gas
change to that cylinder -> right after you add it it is unused and would
not be shown).
I am thinking that we might have to add the "manually_added" property to
the properties that we store in XML / git.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'dive.c')
-rw-r--r-- | dive.c | 26 |
1 files changed, 0 insertions, 26 deletions
@@ -678,31 +678,6 @@ static struct event *find_previous_event(struct divecomputer *dc, struct event * return previous; } -/* mark all tanks that we switch to in this dive computer's data as used */ -static void mark_used_tanks(struct dive *dive, struct divecomputer *dc) -{ - struct event *ev = get_next_event(dc->events, "gaschange"); - // unless there is a gas change in the first 30 seconds we can - // always mark the first cylinder as used - if (!ev || ev->time.seconds > 30) - dive->cylinder[0].used = true; - while (ev) { - int idx = get_cylinder_index(dive, ev); - dive->cylinder[idx].used = true; - ev = get_next_event(ev->next, "gaschange"); - } -} - -/* walk all divecomputers to find the unused tanks in this dive */ -static void check_for_unused_tanks(struct dive *dive) -{ - struct divecomputer *dc; - - for_each_dc(dive, dc) { - mark_used_tanks(dive, dc); - } -} - static void fixup_surface_pressure(struct dive *dive) { struct divecomputer *dc; @@ -988,7 +963,6 @@ struct dive *fixup_dive(struct dive *dive) fixup_duration(dive); fixup_watertemp(dive); fixup_airtemp(dive); - check_for_unused_tanks(dive); for (i = 0; i < MAX_CYLINDERS; i++) { cylinder_t *cyl = dive->cylinder + i; add_cylinder_description(&cyl->type); |