Mercurial > public > mk2
changeset 461:68d595db29a1
Minor fix checking first stop on surface
(reported by Artur Wroblewski)
author | JeanDo |
---|---|
date | Fri, 23 Sep 2011 01:32:17 +0200 |
parents | 274689f46b1a |
children | 32e1174fb89e |
files | code_part1/OSTC_code_c_part2/p2_deco.c |
diffstat | 1 files changed, 10 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/code_part1/OSTC_code_c_part2/p2_deco.c Fri Sep 23 00:42:57 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/p2_deco.c Fri Sep 23 01:32:17 2011 +0200 @@ -1547,34 +1547,34 @@ //---- Loop until first stop, gas switch, or surface is reached ---------- for(;;) { - overlay short tmp; // Rounded distance to surface. + overlay float old_deco = temp_deco; // Pamb backup (bars) // Try ascending 1 full minute. - temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar. + temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar. + if( temp_deco < pres_surface ) // But don't go over surface. + temp_deco = pres_surface; - // Compute sim_lead_tissue_limit at GF_low (deepest stop). + // Recompute sim_lead_tissue_limit at GF_low (deepest stop), because + // one minute passed. sim_limit(GF_low); // Did we reach deepest remaining stop ? if( temp_deco < sim_lead_tissue_limit ) { - temp_deco += 10*METER_TO_BAR; // Restore last correct depth, - break; // End fast ascent. + temp_deco = old_deco; // Restore last correct depth, + break; // Do no spend a minute more. } // Did we reach surface ? // NOTE: we should round BEFORE checking surface is reached. - tmp = (short)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); - if( tmp <= 0 ) + temp_depth_limit = (unsigned char)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); + if( temp_depth_limit == 0 ) { temp_deco = pres_surface; // Yes: finished ! break; } // Check for gas change below new depth ? - assert( 0 < tmp && tmp < 255); - temp_depth_limit = (unsigned char)tmp; - if( gas_switch_deepest() ) { assert( temp_depth_limit > 0);