aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/display.h1
-rw-r--r--core/profile.c18
2 files changed, 18 insertions, 1 deletions
diff --git a/core/display.h b/core/display.h
index 8fbe34261..a8ceb1484 100644
--- a/core/display.h
+++ b/core/display.h
@@ -21,6 +21,7 @@ struct plot_info {
enum {AIR, NITROX, TRIMIX, FREEDIVING} dive_type;
double endtempcoord;
double maxpp;
+ bool waypoint_above_ceiling;
struct plot_data *entry;
struct plot_pressure_data *pressures; /* cylinders.nr blocks of nr entries. */
};
diff --git a/core/profile.c b/core/profile.c
index 997b4bb57..3ddd2300b 100644
--- a/core/profile.c
+++ b/core/profile.c
@@ -1026,7 +1026,7 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
for (i = 1; i < pi->nr; i++) {
struct plot_data *entry = pi->entry + i;
int j, t0 = (entry - 1)->sec, t1 = entry->sec;
- int time_stepsize = 20;
+ int time_stepsize = 20, max_ceiling = -1;
current_divemode = get_current_divemode(dc, entry->sec, &evd, &current_divemode);
gasmix = get_gasmix(dive, dc, t1, &ev, gasmix);
@@ -1096,6 +1096,8 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
double m_value = ds->buehlmann_inertgas_a[j] + entry->ambpressure / ds->buehlmann_inertgas_b[j];
double surface_m_value = ds->buehlmann_inertgas_a[j] + surface_pressure / ds->buehlmann_inertgas_b[j];
entry->ceilings[j] = deco_allowed_depth(ds->tolerated_by_tissue[j], surface_pressure, dive, 1);
+ if (entry->ceilings[j] > max_ceiling)
+ max_ceiling = entry->ceilings[j];
double current_gf = (ds->tissue_inertgas_saturation[j] - entry->ambpressure) / (m_value - entry->ambpressure);
entry->percentages[j] = ds->tissue_inertgas_saturation[j] < entry->ambpressure ?
lrint(ds->tissue_inertgas_saturation[j] / entry->ambpressure * AMB_PERCENTAGE) :
@@ -1107,6 +1109,20 @@ static void calculate_deco_information(struct deco_state *ds, const struct deco_
entry->surface_gf = surface_gf;
}
+ // In the planner, if the ceiling is violated, add an event.
+ // TODO: This *really* shouldn't be done here. This is a contract
+ // between the planner and the profile that the planner uses a dive
+ // that can be trampled upon. But ultimately, the ceiling-violation
+ // marker should be handled differently!
+ // Don't scream if we violate the ceiling by a few cm.
+ if (planner_ds && !pi->waypoint_above_ceiling &&
+ entry->depth < max_ceiling - 100 && entry->sec > 0) {
+ struct dive *non_const_dive = (struct dive *)dive; // cast away const!
+ add_event(&non_const_dive->dc, entry->sec, SAMPLE_EVENT_CEILING, -1, max_ceiling / 1000,
+ translate("gettextFromC", "planned waypoint above ceiling"));
+ pi->waypoint_above_ceiling = true;
+ }
+
/* should we do more calculations?
* We don't for print-mode because this info doesn't show up there
* If the ceiling hasn't cleared by the last data point, we need tts for VPM-B CVA calculation