diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-08 21:22:59 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-08 21:22:59 +0900 |
commit | 8941e8677e2b56084c07ac840adb1b655d5c806b (patch) | |
tree | 987ad02c9edbf52504e048f9742e609b316e675b /planner.c | |
parent | 1578c1edb2dd7e74b111e6b6b5c7883c37554235 (diff) | |
download | subsurface-8941e8677e2b56084c07ac840adb1b655d5c806b.tar.gz |
Correctly track gases when manually adding and then editing dives
The code had quite a few odd special cases that may have been left-overs
from the old Gtk algorithm. With this the gas is actually in the dive plan
node where it's use starts. And we maintain the gas correctly between
multiple edit sessions.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -233,6 +233,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error int time = dp->time; int depth = dp->depth; +#if 0 // the new planner doesn't use that any more if (time == 0) { /* special entries that just inform the algorithm about * additional gases that are available */ @@ -241,6 +242,7 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error dp = dp->next; continue; } +#endif if (!o2 && !he) { o2 = oldo2; he = oldhe; @@ -256,14 +258,14 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan, const char **error /* Create new gas, and gas change event if necessary; * Sadly, we inherited our gaschange event from libdivecomputer which only * support percentage values, so round the entries */ - if (o2 != oldo2 || he != oldhe) { + if (time == 0 || o2 != oldo2 || he != oldhe) { int plano2 = (o2 + 5) / 10 * 10; int planhe = (he + 5) / 10 * 10; int value; if (add_gas(dive, plano2, planhe) < 0) goto gas_error_exit; value = (plano2 / 10) | ((planhe / 10) << 16); - add_event(dc, lasttime, 25, 0, value, "gaschange"); // SAMPLE_EVENT_GASCHANGE2 + add_event(dc, time, 25, 0, value, "gaschange"); // SAMPLE_EVENT_GASCHANGE2 oldo2 = o2; oldhe = he; } /* Create sample */ |