mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Don't do a negative time step in recreational mode when beyond NDL
In recreational mode, we keep adding time at the last depth until an ascent does violate the ceiling. Then we roll back the last added time step and record the ascent. The test for the ceiling violated was before adding the time so if it alreay failed the first time we tried to unroll a time step that was never added which resulted in a small kink in the pressure graph. This patch corrects this logic by changin a while to a do {} while. Furthermore, it removes the computation of deco state during the final ascent since that is not used anywhere later. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b2deb28f58
commit
1c7bc14af9
1 changed files with 12 additions and 9 deletions
21
planner.c
21
planner.c
|
@ -1070,15 +1070,21 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
bool safety_stop = prefs.safetystop && max_depth >= 10000;
|
||||
track_ascent_gas(depth, &displayed_dive.cylinder[current_cylinder], avg_depth, bottom_time, safety_stop);
|
||||
// How long can we stay at the current depth and still directly ascent to the surface?
|
||||
while (trial_ascent(depth, 0, avg_depth, bottom_time, &displayed_dive.cylinder[current_cylinder].gasmix,
|
||||
po2, diveplan->surface_pressure / 1000.0) &&
|
||||
enough_gas(current_cylinder)) {
|
||||
do {
|
||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
||||
DECOTIMESTEP, po2, &displayed_dive, prefs.bottomsac);
|
||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
||||
DECOTIMESTEP, po2, &displayed_dive, prefs.bottomsac);
|
||||
update_cylinder_pressure(&displayed_dive, depth, depth, DECOTIMESTEP, prefs.bottomsac, &displayed_dive.cylinder[current_cylinder], false);
|
||||
clock += DECOTIMESTEP;
|
||||
}
|
||||
} while (trial_ascent(depth, 0, avg_depth, bottom_time, &displayed_dive.cylinder[current_cylinder].gasmix,
|
||||
po2, diveplan->surface_pressure / 1000.0) &&
|
||||
enough_gas(current_cylinder));
|
||||
|
||||
// We did stay one DECOTIMESTEP too many.
|
||||
// In the best of all worlds, we would roll back also the last add_segment in terms of caching deco state, but
|
||||
// let's ignore that since for the eventual ascent in recreational mode, nobody looks at the ceiling anymore,
|
||||
// so we don't really have to compute the deco state.
|
||||
update_cylinder_pressure(&displayed_dive, depth, depth, -DECOTIMESTEP, prefs.bottomsac, &displayed_dive.cylinder[current_cylinder], false);
|
||||
clock -= DECOTIMESTEP;
|
||||
plan_add_segment(diveplan, clock - previous_point_time, depth, gas, po2, true);
|
||||
previous_point_time = clock;
|
||||
|
@ -1093,9 +1099,6 @@ bool plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
|||
if (depth - deltad < 0)
|
||||
deltad = depth;
|
||||
|
||||
add_segment(depth_to_bar(depth, &displayed_dive),
|
||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
||||
TIMESTEP, po2, &displayed_dive, prefs.decosac);
|
||||
clock += TIMESTEP;
|
||||
depth -= deltad;
|
||||
if (depth <= 5000 && depth >= (5000 - deltad) && safety_stop) {
|
||||
|
|
Loading…
Add table
Reference in a new issue