diff options
author | Robert C. Helling <helling@atdotde.de> | 2014-07-08 21:42:17 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-07-08 13:01:34 -0700 |
commit | 954d40148390a45b0a6f5178dfbdbc273dae315d (patch) | |
tree | f4c3bdd3a6e0044080aa9f74fddb769024b6fbff /divelist.c | |
parent | c7e8042fbdd815677c146e4d21eed3b3481d21fd (diff) | |
download | subsurface-954d40148390a45b0a6f5178dfbdbc273dae315d.tar.gz |
Considering previous dives for tissue loading
This (hopefully) gets the logic to find dives in the previous 48h for
tissue pre-loading right. In particular it handles the case of a planned
dive which has a number of -1.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/divelist.c b/divelist.c index 632b7703c..1a2111f76 100644 --- a/divelist.c +++ b/divelist.c @@ -365,7 +365,13 @@ double init_decompression(struct dive *dive) divenr = get_divenr(dive); when = dive->when; i = divenr; - while (i && --i) { + if (i < 0) { + i = dive_table.nr - 1; + while (i >= 0 && get_dive(i)->when > when) + --i; + i++; + } + while (i--) { struct dive *pdive = get_dive(i); /* we don't want to mix dives from different trips as we keep looking * for how far back we need to go */ @@ -376,7 +382,7 @@ double init_decompression(struct dive *dive) when = pdive->when; lasttime = when + pdive->duration.seconds; } - while (++i < divenr) { + while (++i < (divenr >= 0 ? divenr : dive_table.nr)) { struct dive *pdive = get_dive(i); /* again skip dives from different trips */ if (dive->divetrip && dive->divetrip != pdive->divetrip) |