From 180e51a906029b5d54244e9489bc8b4baeb0777c Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Sun, 8 Oct 2017 05:21:31 +0200 Subject: Tidy up code in planner.c - create_dive_from_plan() Tidy up the code which creates the first sample for time = 0 to make clear that the info for this does NOT come from the first planner point (dp). No functional change. Signed-off-by: Stefan Fuchs --- core/planner.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/planner.c b/core/planner.c index e93c48f9f..8010979d9 100644 --- a/core/planner.c +++ b/core/planner.c @@ -261,7 +261,7 @@ static void create_dive_from_plan(struct diveplan *diveplan, struct dive *dive, int oldpo2 = 0; int lasttime = 0; depth_t lastdepth = {.mm = 0}; - int lastcylid = 0; + int lastcylid; enum dive_comp_type type = dive->dc.divemode; if (!diveplan || !diveplan->dp) @@ -287,15 +287,17 @@ static void create_dive_from_plan(struct diveplan *diveplan, struct dive *dive, free(ev); } dp = diveplan->dp; - cyl = &dive->cylinder[lastcylid]; + /* Create first sample at time = 0, not based on dp because + * there is no real dp for time = 0, set first cylinder to 0 + * O2 setpoint for this sample will be filled later from next dp */ + cyl = &dive->cylinder[0]; sample = prepare_sample(dc); - sample->setpoint.mbar = dp->setpoint; sample->sac.mliter = prefs.bottomsac; - oldpo2 = dp->setpoint; if (track_gas && cyl->type.workingpressure.mbar) sample->pressure[0].mbar = cyl->end.mbar; sample->manually_entered = true; finish_sample(dc); + lastcylid = 0; while (dp) { int po2 = dp->setpoint; if (dp->setpoint) -- cgit v1.2.3-70-g09d2