comparison 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
comparison
equal deleted inserted replaced
260:ec33b9b17ffd 261:cc2406b835ff
628 628
629 void buehlmann_ceiling_calculator(SLifeData *pLifeData, SDecoinfo *pDecoInfo) 629 void buehlmann_ceiling_calculator(SLifeData *pLifeData, SDecoinfo *pDecoInfo)
630 { 630 {
631 float ceiling; 631 float ceiling;
632 632
633 memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16));
634 memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16));
635
633 // this is just performance optimizing. The code below runs just fine 636 // this is just performance optimizing. The code below runs just fine
634 // without this. There is never a ceiling in NDL deco state 637 // without this. There is never a ceiling in NDL deco state
635 if (!pDecoInfo->output_time_to_surface_seconds) { 638 if (!pDecoInfo->output_time_to_surface_seconds) {
636 pDecoInfo->output_ceiling_meter = 0; 639 pDecoInfo->output_ceiling_meter = 0;
637 return; 640 return;
638 } 641 }
639 642
640 memcpy(gTissue_nitrogen_bar, pLifeData->tissue_nitrogen_bar, (4*16));
641 memcpy(gTissue_helium_bar, pLifeData->tissue_helium_bar, (4*16));
642
643 ceiling = compute_ceiling(pLifeData->pressure_surface_bar, 1.0f + pLifeData->max_depth_meter/10.0f); 643 ceiling = compute_ceiling(pLifeData->pressure_surface_bar, 1.0f + pLifeData->max_depth_meter/10.0f);
644 pDecoInfo->output_ceiling_meter = (ceiling - pLifeData->pressure_surface_bar) * 10.0f; 644 pDecoInfo->output_ceiling_meter = (ceiling - pLifeData->pressure_surface_bar) * 10.0f;
645 } 645 }