diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-11-09 20:35:09 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-11-09 20:35:09 +0900 |
commit | 487efb1ee91c5b7e648f31ef3700fae2c45753d4 (patch) | |
tree | ee9226b8abb20f09473dd42ef0dca4578433911d /planner.c | |
parent | 5dce73f62b21b9d70cf4d7f51c8d6ec9cf8bb9f1 (diff) | |
parent | 6d5b2d75927b23183f8864bebf894b7bf4828311 (diff) | |
download | subsurface-487efb1ee91c5b7e648f31ef3700fae2c45753d4.tar.gz |
Merge branch 'addDiveGasFix'
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 9 |
1 files changed, 6 insertions, 3 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 */ @@ -614,7 +616,8 @@ void plan(struct diveplan *diveplan, char **cached_datap, struct dive **divep, b for (stopidx = 0; stopidx < sizeof(decostoplevels) / sizeof(int); stopidx++) if (decostoplevels[stopidx] >= depth) break; - stopidx--; + if (stopidx > 0) + stopidx--; /* so now we know the first decostop level above us * NOTE, this could be the surface or a long list of potential stops |