From 9a052cd0891c08dadbfaff9c24e5f75c3f7c1811 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 8 Mar 2024 11:18:17 +0100 Subject: [PATCH] planner: move decotimestap to diveplannermodel.cpp The deco timestep is a parameter to the plan() function. There seems no need to define this as a global macro. Probably some code reshuffeling artifact. Signed-off-by: Berthold Stoeger --- core/planner.cpp | 2 +- core/planner.h | 2 -- qt-models/diveplannermodel.cpp | 6 ++++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/planner.cpp b/core/planner.cpp index a0eb93151..3a6b50d40 100644 --- a/core/planner.cpp +++ b/core/planner.cpp @@ -799,7 +799,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i po2, diveplan->surface_pressure / 1000.0, dive, divemode) && enough_gas(dive, current_cylinder) && clock < 6 * 3600); - // We did stay one DECOTIMESTEP too many. + // We did stay one timestep 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. diff --git a/core/planner.h b/core/planner.h index d48c55e8f..0d65acf37 100644 --- a/core/planner.h +++ b/core/planner.h @@ -8,8 +8,6 @@ #include "units.h" #include "divemode.h" -#define DECOTIMESTEP 60 /* seconds. Unit of deco stop times */ - /* this should be converted to use our types */ struct divedatapoint { int time; diff --git a/qt-models/diveplannermodel.cpp b/qt-models/diveplannermodel.cpp index 5c51a2de4..d7573db89 100644 --- a/qt-models/diveplannermodel.cpp +++ b/qt-models/diveplannermodel.cpp @@ -27,6 +27,8 @@ #define UNIT_FACTOR ((prefs.units.length == units::METERS) ? 1000.0 / 60.0 : feet_to_mm(1.0) / 60.0) +static constexpr int decotimestep = 60; // seconds + CylindersModel *DivePlannerPointsModel::cylindersModel() { return &cylinders; @@ -1078,7 +1080,7 @@ void DivePlannerPointsModel::updateDiveProfile() struct deco_state plan_deco_state; memset(&plan_deco_state, 0, sizeof(struct deco_state)); - plan(&plan_deco_state, &diveplan, d, DECOTIMESTEP, stoptable, cache, isPlanner(), false); + plan(&plan_deco_state, &diveplan, d, decotimestep, stoptable, cache, isPlanner(), false); updateMaxDepth(); if (isPlanner() && shouldComputeVariations()) { @@ -1290,7 +1292,7 @@ void DivePlannerPointsModel::createPlan(bool replanCopy) createTemporaryPlan(); struct decostop stoptable[60]; - plan(&ds_after_previous_dives, &diveplan, d, DECOTIMESTEP, stoptable, cache, isPlanner(), true); + plan(&ds_after_previous_dives, &diveplan, d, decotimestep, stoptable, cache, isPlanner(), true); if (shouldComputeVariations()) { struct diveplan *plan_copy;