mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 21:13:23 +00:00
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>
This commit is contained in:
parent
f5b62c0356
commit
fbea5e31ca
1 changed files with 12 additions and 2 deletions
14
planner.c
14
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue