From f159792b8050bb6d07dbf29c525dc5e86da2688b Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Mon, 27 Nov 2017 21:56:22 +0100 Subject: 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 --- core/planner.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'core/planner.c') 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; } -- cgit v1.2.3-70-g09d2