diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-08 15:03:37 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-08 15:03:37 -0800 |
commit | fbea5e31ca27007dbfeb1beac3d8947a4ef64306 (patch) | |
tree | 8ea478fb5ad28eac0268cd4e98a9192a7181aeeb /planner.c | |
parent | f5b62c035643512572e598317e6b6b1c3fe45150 (diff) | |
download | subsurface-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>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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) |