diff Discovery/Src/buehlmann.c @ 261:cc2406b835ff bm-3

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 <jlmulder@xs4all.nl>
author Jan Mulder <jlmulder@xs4all.nl>
date Tue, 23 Apr 2019 13:05:20 +0200
parents 0087d6251f59
children 24ff72e627f4
line wrap: on
line diff
--- 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;
 }