aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-08 15:03:37 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-08 15:03:37 -0800
commitfbea5e31ca27007dbfeb1beac3d8947a4ef64306 (patch)
tree8ea478fb5ad28eac0268cd4e98a9192a7181aeeb
parentf5b62c035643512572e598317e6b6b1c3fe45150 (diff)
downloadsubsurface-fbea5e31ca27007dbfeb1beac3d8947a4ef64306.tar.gz
Allow special entries in diveplan for available gases
An entry with no time is considered special and not considered when constructing the profile. This should allow us to add support for two different ways of adding information about available gas: changedepth 0 gasmix 0 0 gasmix @ po2 The first syntax basically says "during the ascent, switch to this gas at this depth. The second one says "switch to this gas once the pO2 allows for it" Neither of these are implemented, yet, but this commit is necessary in order for the rest of the code to ignore entries with a time field of 0. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--planner.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/planner.c b/planner.c
index 9d304af2b..fd6ba2442 100644
--- a/planner.c
+++ b/planner.c
@@ -156,6 +156,13 @@ struct dive *create_dive_from_plan(struct diveplan *diveplan)
int depth = dp->depth;
struct sample *sample;
+ if (time == 0) {
+ /* special entries that just inform the algorithm about
+ * additional gases that are available */
+ add_gas(dive, o2, he);
+ dp = dp->next;
+ continue;
+ }
if (!o2 && !he) {
o2 = oldo2;
he = oldhe;
@@ -229,7 +236,7 @@ void add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gb
struct divedatapoint *pdp, *dp = get_nth_dp(diveplan, idx);
if (idx > 0) {
pdp = get_nth_dp(diveplan, idx - 1);
- if (is_rel || duration <= pdp->time)
+ if (duration && (is_rel || duration <= pdp->time))
duration += pdp->time;
}
dp->time = duration;
@@ -251,13 +258,16 @@ void add_to_end_of_diveplan(struct diveplan *diveplan, struct divedatapoint *dp)
{
struct divedatapoint **lastdp = &diveplan->dp;
struct divedatapoint *ldp = *lastdp;
+ int lasttime = 0;
while(*lastdp) {
ldp = *lastdp;
+ if (ldp->time > lasttime)
+ lasttime = ldp->time;
lastdp = &(*lastdp)->next;
}
*lastdp = dp;
if (ldp)
- dp->time += ldp->time;
+ dp->time += lasttime;
}
void plan_add_segment(struct diveplan *diveplan, int duration, int depth, int o2, int he)