diff code_part1/OSTC_code_c_part2/p2_deco.c @ 540:9e838e0b3749

BUGFIX decoplan: missing gas changes in CNS prediction, when CF55 = 0
author JeanDo
date Mon, 09 Jan 2012 23:46:18 +0100
parents ba1fb2e23f46
children 6626a6c4eda3
line wrap: on
line diff
--- a/code_part1/OSTC_code_c_part2/p2_deco.c	Sun Jan 08 18:52:19 2012 +0100
+++ b/code_part1/OSTC_code_c_part2/p2_deco.c	Mon Jan 09 23:46:18 2012 +0100
@@ -866,17 +866,11 @@
 
         sim_gas_last_depth = switch_deco;
         sim_gas_last_used  = switch_last;
-        sim_gas_delay = read_custom_function(55);
+        sim_gas_delay      = read_custom_function(55)
+                           + sim_dive_mins;
+        temp_depth_limit = switch_deco;
 
-        // Apply depth correction ONLY if CF#55 is not null:
-        if( sim_gas_delay > 0 )
-        {
-            sim_gas_delay += sim_dive_mins;
-            temp_depth_limit = switch_deco;
-            return 1;
-        }
-        
-        return 0;
+        return 1;
     }
 
     sim_gas_delay = 0;
@@ -1720,7 +1714,7 @@
         if( internal_deco_depth[x] == 0 )
         {
             internal_deco_depth[x] = temp_depth_limit;
-            if( sim_gas_delay > sim_dive_mins )
+            if( sim_gas_delay >= sim_dive_mins )
                 internal_deco_depth[x] |= 0x80;
 
             internal_deco_time[x]  = 1;
@@ -2241,7 +2235,8 @@
     
             //---- Gas Switch ?
             if( char_O_deco_depth[i] & 0x80 )
-                gas_switch_deepest();
+                if( gas_switch_deepest() )
+                    gas_switch_set();
         
             //---- Convert Depth and N2_ratio to ppO2
             actual_ppO2 = (pres_surface + temp_depth_limit * METER_TO_BAR - ppWater)