aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/opendeco.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/opendeco.c')
-rw-r--r--src/opendeco.c35
1 files changed, 15 insertions, 20 deletions
diff --git a/src/opendeco.c b/src/opendeco.c
index 8e22e4b..6c2be17 100644
--- a/src/opendeco.c
+++ b/src/opendeco.c
@@ -67,36 +67,38 @@ void print_gas_use(void)
}
}
-void print_segment_callback_fn(const decostate_t *ds, waypoint_t wp, segtype_t type, void *arg)
+void print_segment_callback_fn(const decostate_t *ds, segtype_t type, void *arg)
{
static double last_depth;
- static double runtime;
+ static double last_runtime;
wchar_t sign;
+ double time_diff;
/* first time initialization */
if (!last_depth)
last_depth = SURFACE_PRESSURE;
- runtime += wp.time;
-
- if (wp.depth < last_depth)
+ if (ds->depth < last_depth)
sign = ASC;
- else if (wp.depth > last_depth)
+ else if (ds->depth > last_depth)
sign = DEC;
else
sign = LVL;
+ time_diff = ds->runtime - last_runtime;
+
if (SHOW_TRAVEL || type != SEG_TRAVEL)
- print_planline(sign, wp.depth, wp.time, runtime, wp.gas);
+ print_planline(sign, ds->depth, time_diff, ds->runtime, ds->gas);
/* register gas use */
- double avg_seg_depth = wp.depth == last_depth ? last_depth : (wp.depth + last_depth) / 2;
+ double avg_seg_depth = (ds->depth + last_depth) / 2;
double rmv = type == SEG_DIVE ? RMV_DIVE : RMV_DECO;
- register_gas_use(avg_seg_depth, wp.time, wp.gas, rmv);
+ register_gas_use(avg_seg_depth, time_diff, ds->gas, rmv);
- last_depth = wp.depth;
+ last_depth = ds->depth;
+ last_runtime = ds->runtime;
}
int parse_gasses(gas_t **gasses, char *str)
@@ -194,9 +196,6 @@ int main(int argc, char *argv[])
gas_t bottom_gas;
gas_t *deco_gasses;
- double depth;
- const gas_t *gas;
-
double dec_per_min = xsw_to_bar(msw_or_fsw(9, 30));
int nof_gasses = parse_gasses(&deco_gasses, arguments.decogasses);
@@ -227,19 +226,15 @@ int main(int argc, char *argv[])
};
print_planhead();
-
simulate_dive(&ds, waypoints, len(waypoints), &print_segment_callback);
-
- depth = waypoints[len(waypoints) - 1].depth;
- gas = waypoints[len(waypoints) - 1].gas;
ds_p5 = ds;
/* calculate deco */
- decoinfo_t di = calc_deco(&ds, depth, gas, deco_gasses, nof_gasses, &print_segment_callback);
+ decoinfo_t di = calc_deco(&ds, deco_gasses, nof_gasses, &print_segment_callback);
/* calculate @+5 TTS */
- add_segment_const(&ds_p5, depth, 5, gas);
- decoinfo_t di_p5 = calc_deco(&ds_p5, depth, gas, deco_gasses, nof_gasses, NULL);
+ add_segment_const(&ds_p5, ds_p5.depth, 5, ds_p5.gas);
+ decoinfo_t di_p5 = calc_deco(&ds_p5, deco_gasses, nof_gasses, NULL);
/* output deco info and disclaimer */
wprintf(L"\nNDL: %imin TTS: %imin TTS @+5: %imin\n", (int) floor(di.ndl), (int) ceil(di.tts),