# HG changeset patch # User Jan Mulder # Date 1556017520 -7200 # Node ID cc2406b835ffc3b9ec186ca7614c2cd6a2dd7bc3 # Parent ec33b9b17ffda35f86b9e62c818b31481fd8c728 Bugfix: do not reset saturation on surfacing Commit 822416168585 introduced a subtle bug. On surfacing, the value of saturation was reset to 0. This is prefect proof why global data is a dangerous thing, and subtle changes can introduce seemingly unrelated bugs. While it would be much better to factor out as much as possible global data, the fix here does not do that. Simply, the bug is fixed without touching the rather complex gTissue_nitrogen_bar/gTissue_helium_bar handling. Signed-off-by: Jan Mulder diff -r ec33b9b17ffd -r cc2406b835ff Discovery/Src/buehlmann.c --- a/Discovery/Src/buehlmann.c Tue Apr 23 09:25:18 2019 +0200 +++ b/Discovery/Src/buehlmann.c Tue Apr 23 13:05:20 2019 +0200 @@ -630,6 +630,9 @@ { float ceiling; + memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16)); + memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16)); + // this is just performance optimizing. The code below runs just fine // without this. There is never a ceiling in NDL deco state if (!pDecoInfo->output_time_to_surface_seconds) { @@ -637,9 +640,6 @@ return; } - memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16)); - memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16)); - ceiling = compute_ceiling(pLifeData->pressure_surface_bar, 1.0f + pLifeData->max_depth_meter/10.0f); pDecoInfo->output_ceiling_meter = (ceiling - pLifeData->pressure_surface_bar) * 10.0f; }