comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 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 5546da23afab
comparison
equal deleted inserted replaced
460:274689f46b1a 461:68d595db29a1
1545 return; 1545 return;
1546 1546
1547 //---- Loop until first stop, gas switch, or surface is reached ---------- 1547 //---- Loop until first stop, gas switch, or surface is reached ----------
1548 for(;;) 1548 for(;;)
1549 { 1549 {
1550 overlay short tmp; // Rounded distance to surface. 1550 overlay float old_deco = temp_deco; // Pamb backup (bars)
1551 1551
1552 // Try ascending 1 full minute. 1552 // Try ascending 1 full minute.
1553 temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar. 1553 temp_deco -= 10*METER_TO_BAR; // 1 min, at 10m/min. ~ 1bar.
1554 1554 if( temp_deco < pres_surface ) // But don't go over surface.
1555 // Compute sim_lead_tissue_limit at GF_low (deepest stop). 1555 temp_deco = pres_surface;
1556
1557 // Recompute sim_lead_tissue_limit at GF_low (deepest stop), because
1558 // one minute passed.
1556 sim_limit(GF_low); 1559 sim_limit(GF_low);
1557 1560
1558 // Did we reach deepest remaining stop ? 1561 // Did we reach deepest remaining stop ?
1559 if( temp_deco < sim_lead_tissue_limit ) 1562 if( temp_deco < sim_lead_tissue_limit )
1560 { 1563 {
1561 temp_deco += 10*METER_TO_BAR; // Restore last correct depth, 1564 temp_deco = old_deco; // Restore last correct depth,
1562 break; // End fast ascent. 1565 break; // Do no spend a minute more.
1563 } 1566 }
1564 1567
1565 // Did we reach surface ? 1568 // Did we reach surface ?
1566 // NOTE: we should round BEFORE checking surface is reached. 1569 // NOTE: we should round BEFORE checking surface is reached.
1567 tmp = (short)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); 1570 temp_depth_limit = (unsigned char)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER);
1568 if( tmp <= 0 ) 1571 if( temp_depth_limit == 0 )
1569 { 1572 {
1570 temp_deco = pres_surface; // Yes: finished ! 1573 temp_deco = pres_surface; // Yes: finished !
1571 break; 1574 break;
1572 } 1575 }
1573 1576
1574 // Check for gas change below new depth ? 1577 // Check for gas change below new depth ?
1575 assert( 0 < tmp && tmp < 255);
1576 temp_depth_limit = (unsigned char)tmp;
1577
1578 if( gas_switch_deepest() ) 1578 if( gas_switch_deepest() )
1579 { 1579 {
1580 assert( temp_depth_limit > 0); 1580 assert( temp_depth_limit > 0);
1581 1581
1582 temp_deco = temp_depth_limit * METER_TO_BAR + pres_surface; 1582 temp_deco = temp_depth_limit * METER_TO_BAR + pres_surface;