diff options
author | Stefan Fuchs <sfuchs@gmx.de> | 2017-10-08 05:21:31 +0200 |
---|---|---|
committer | Robert C. Helling <helling@atdotde.de> | 2017-10-16 18:23:27 +0200 |
commit | 180e51a906029b5d54244e9489bc8b4baeb0777c (patch) | |
tree | 9bc7ccc155b7bd922ed05483daf167d1d39f0ae8 /core/planner.c | |
parent | f812dc5d9b337f0c9c0e47798a23afdb0c8a310b (diff) | |
download | subsurface-180e51a906029b5d54244e9489bc8b4baeb0777c.tar.gz |
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 <sfuchs@gmx.de>
Diffstat (limited to 'core/planner.c')
-rw-r--r-- | core/planner.c | 10 |
1 files changed, 6 insertions, 4 deletions
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) |