diff options
author | Tim Segers <tsegers@pm.me> | 2022-10-16 17:44:33 +0200 |
---|---|---|
committer | Tim Segers <tsegers@pm.me> | 2022-10-16 17:47:10 +0200 |
commit | 984be6b122888925a921db46b0df30608739912d (patch) | |
tree | 4193c839884189f07b1642b490b6d4fde9588ef5 /src/deco.c | |
parent | 0bbee8727d71c6546921195f09660972be4e3497 (diff) | |
download | opendeco-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.
Diffstat (limited to 'src/deco.c')
-rw-r--r-- | src/deco.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -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) |