Mercurial > public > mk2
changeset 460:274689f46b1a
BUGFIX round depth before checking surface
author | JeanDo |
---|---|
date | Fri, 23 Sep 2011 00:42:57 +0200 |
parents | 770456638c66 |
children | 68d595db29a1 |
files | code_part1/OSTC_code_c_part2/p2_deco.c |
diffstat | 1 files changed, 7 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/code_part1/OSTC_code_c_part2/p2_deco.c Thu Sep 01 14:39:44 2011 +0200 +++ b/code_part1/OSTC_code_c_part2/p2_deco.c Fri Sep 23 00:42:57 2011 +0200 @@ -1547,6 +1547,8 @@ //---- Loop until first stop, gas switch, or surface is reached ---------- for(;;) { + overlay short tmp; // Rounded distance to surface. + // Try ascending 1 full minute. temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar. @@ -1561,15 +1563,17 @@ } // Did we reach surface ? - if( temp_deco <= pres_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_deco = pres_surface; // Yes: finished ! break; } // Check for gas change below new depth ? - temp_depth_limit = (int)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); - assert( temp_depth_limit > 0); + assert( 0 < tmp && tmp < 255); + temp_depth_limit = (unsigned char)tmp; if( gas_switch_deepest() ) {