summaryrefslogtreecommitdiffstats
path: root/core/planner.c
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-11-27 21:56:22 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-12-01 15:47:51 -0800
commitf159792b8050bb6d07dbf29c525dc5e86da2688b (patch)
tree71f4e839949f513d73c9b463c5dd581949e63b02 /core/planner.c
parentc8c580e9c8ea8c6ff5c4ee28cb35aeeb186ece64 (diff)
downloadsubsurface-f159792b8050bb6d07dbf29c525dc5e86da2688b.tar.gz
Cut off excessive deco times
before we run out of memory. Diving deep with air and small GFhigh can cause those (try GF 30/70 at 75m with 25+min bottom time) Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/planner.c')
-rw-r--r--core/planner.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/planner.c b/core/planner.c
index fddb3f0e0..9c1ae2e6c 100644
--- a/core/planner.c
+++ b/core/planner.c
@@ -623,6 +623,9 @@ bool enough_gas(int current_cylinder)
int wait_until(struct deco_state *ds, struct dive *dive, int clock, int min, int leap, int stepsize, int depth, int target_depth, int avg_depth, int bottom_time, struct gasmix *gasmix, int po2, double surface_pressure)
{
+ // When a deco stop exceeds two days, there is something wrong...
+ if (min >= 48 * 3600)
+ return 50 * 3600;
// Round min + leap up to the next multiple of stepsize
int upper = min + leap + stepsize - 1 - (min + leap - 1) % stepsize;
// Is the upper boundary too small?
@@ -997,7 +1000,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
int new_clock = wait_until(ds, dive, clock, clock, laststoptime * 2 + 1, timestep, depth, stoplevels[stopidx], avg_depth, bottom_time, &dive->cylinder[current_cylinder].gasmix, po2, diveplan->surface_pressure / 1000.0);
laststoptime = new_clock - clock;
/* Finish infinite deco */
- if (clock >= 48 * 3600 && depth >= 6000) {
+ if (laststoptime >= 48 * 3600 && depth >= 6000) {
error = LONGDECO;
break;
}