Mercurial > public > mk2
comparison code_part1/OSTC_code_c_part2/p2_deco.c @ 460:274689f46b1a
BUGFIX round depth before checking surface
author | JeanDo |
---|---|
date | Fri, 23 Sep 2011 00:42:57 +0200 |
parents | 4c7f304de294 |
children | 68d595db29a1 |
comparison
equal
deleted
inserted
replaced
459:770456638c66 | 460:274689f46b1a |
---|---|
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. | |
1551 | |
1550 // Try ascending 1 full minute. | 1552 // Try ascending 1 full minute. |
1551 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. |
1552 | 1554 |
1553 // Compute sim_lead_tissue_limit at GF_low (deepest stop). | 1555 // Compute sim_lead_tissue_limit at GF_low (deepest stop). |
1554 sim_limit(GF_low); | 1556 sim_limit(GF_low); |
1559 temp_deco += 10*METER_TO_BAR; // Restore last correct depth, | 1561 temp_deco += 10*METER_TO_BAR; // Restore last correct depth, |
1560 break; // End fast ascent. | 1562 break; // End fast ascent. |
1561 } | 1563 } |
1562 | 1564 |
1563 // Did we reach surface ? | 1565 // Did we reach surface ? |
1564 if( temp_deco <= pres_surface ) | 1566 // NOTE: we should round BEFORE checking surface is reached. |
1567 tmp = (short)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); | |
1568 if( tmp <= 0 ) | |
1565 { | 1569 { |
1566 temp_deco = pres_surface; // Yes: finished ! | 1570 temp_deco = pres_surface; // Yes: finished ! |
1567 break; | 1571 break; |
1568 } | 1572 } |
1569 | 1573 |
1570 // Check for gas change below new depth ? | 1574 // Check for gas change below new depth ? |
1571 temp_depth_limit = (int)(0.5 + (temp_deco - pres_surface) * BAR_TO_METER); | 1575 assert( 0 < tmp && tmp < 255); |
1572 assert( temp_depth_limit > 0); | 1576 temp_depth_limit = (unsigned char)tmp; |
1573 | 1577 |
1574 if( gas_switch_deepest() ) | 1578 if( gas_switch_deepest() ) |
1575 { | 1579 { |
1576 assert( temp_depth_limit > 0); | 1580 assert( temp_depth_limit > 0); |
1577 | 1581 |