mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-08 03:16:17 +00:00
Planner: fix calculation when it is safe to surface
We were comparing with a negative depth which apparently confused the algorithm. Fixes #611 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
9661926131
commit
6c9aaf406a
2 changed files with 3 additions and 2 deletions
|
@ -822,7 +822,6 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
||||||
if (depth <= 0)
|
if (depth <= 0)
|
||||||
break; /* We are at the surface */
|
break; /* We are at the surface */
|
||||||
|
|
||||||
|
|
||||||
if (gi >= 0 && stoplevels[stopidx] == gaschanges[gi].depth) {
|
if (gi >= 0 && stoplevels[stopidx] == gaschanges[gi].depth) {
|
||||||
/* We have reached a gas change.
|
/* We have reached a gas change.
|
||||||
* Record this in the dive plan */
|
* Record this in the dive plan */
|
||||||
|
@ -849,6 +848,8 @@ void plan(struct diveplan *diveplan, char **cached_datap, bool is_planner, bool
|
||||||
clear_to_ascend = true;
|
clear_to_ascend = true;
|
||||||
while (trial_depth > stoplevels[stopidx]) {
|
while (trial_depth > stoplevels[stopidx]) {
|
||||||
int deltad = ascend_velocity(trial_depth, avg_depth, bottom_time) * TIMESTEP;
|
int deltad = ascend_velocity(trial_depth, avg_depth, bottom_time) * TIMESTEP;
|
||||||
|
if (deltad > trial_depth) /* don't test against depth above surface */
|
||||||
|
deltad = trial_depth;
|
||||||
tissue_tolerance = add_segment(depth_to_mbar(trial_depth, &displayed_dive) / 1000.0,
|
tissue_tolerance = add_segment(depth_to_mbar(trial_depth, &displayed_dive) / 1000.0,
|
||||||
&displayed_dive.cylinder[current_cylinder].gasmix,
|
&displayed_dive.cylinder[current_cylinder].gasmix,
|
||||||
TIMESTEP, po2, &displayed_dive);
|
TIMESTEP, po2, &displayed_dive);
|
||||||
|
|
|
@ -167,7 +167,7 @@ void DiveProfileItem::modelDataChanged(const QModelIndex &topLeft, const QModelI
|
||||||
plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
|
plot_data *entry = dataModel->data().entry + dataModel->rowCount() - 1;
|
||||||
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
|
for (int i = dataModel->rowCount() - 1; i >= 0; i--, entry--) {
|
||||||
int max = maxCeiling(i);
|
int max = maxCeiling(i);
|
||||||
// Don't screem if we violate the ceiling by a few cm
|
// Don't scream if we violate the ceiling by a few cm
|
||||||
if (entry->depth < max - 100)
|
if (entry->depth < max - 100)
|
||||||
profileColor = QColor(Qt::red);
|
profileColor = QColor(Qt::red);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue