aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar Tim Segers <tsegers@pm.me>2022-10-16 17:44:33 +0200
committerGravatar Tim Segers <tsegers@pm.me>2022-10-16 17:47:10 +0200
commit984be6b122888925a921db46b0df30608739912d (patch)
tree4193c839884189f07b1642b490b6d4fde9588ef5
parent0bbee8727d71c6546921195f09660972be4e3497 (diff)
downloadopendeco-984be6b122888925a921db46b0df30608739912d.tar.gz
Make LAST_STOP_AT_SIX actually set the last stop to 6m
Previously LAST_STOP_AT_SIX just skipped the last stop, which is correct for 3m stop increments, but not for any other ones. The implementation has now been brought in line with its name.
-rw-r--r--src/deco.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/deco.c b/src/deco.c
index 29f07ea..3f27a33 100644
--- a/src/deco.c
+++ b/src/deco.c
@@ -197,7 +197,7 @@ double get_gf(const decostate_t *ds, const double depth)
const unsigned char lo = ds->gflo;
const unsigned char hi = ds->gfhi;
- double last_stop_gauge = LAST_STOP_AT_SIX ? 2 * ds->ceil_multiple : ds->ceil_multiple;
+ const double last_stop_gauge = LAST_STOP_AT_SIX ? msw_to_bar(6) : ds->ceil_multiple;
if (ds->firststop == -1)
return lo;
@@ -216,12 +216,12 @@ double round_ceiling(const decostate_t *ds, const double c)
{
assert(ds->ceil_multiple != 0);
- int numbered_stop = ceil(RND(gauge_depth(c) / ds->ceil_multiple));
+ double ceil_gauge = ds->ceil_multiple * ceil(RND(gauge_depth(c) / ds->ceil_multiple));
- if (numbered_stop == 1 && LAST_STOP_AT_SIX)
- numbered_stop = 2;
-
- return abs_depth(ds->ceil_multiple * numbered_stop);
+ if (LAST_STOP_AT_SIX && ceil_gauge < msw_to_bar(6) && ceil_gauge > 0)
+ return abs_depth(msw_to_bar(6));
+ else
+ return abs_depth(ceil_gauge);
}
double ceiling(const decostate_t *ds, double gf)