diff options
-rw-r--r-- | core/dive.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/core/dive.c b/core/dive.c index 688ccb989..67cfc5fa5 100644 --- a/core/dive.c +++ b/core/dive.c @@ -1828,19 +1828,21 @@ static void merge_one_sample(struct sample *sample, int time, struct divecompute { int last = dc->samples - 1; if (last >= 0) { - static struct sample surface = { .bearing.degrees = -1, .ndl.seconds = -1 }; struct sample *prev = dc->sample + last; int last_time = prev->time.seconds; int last_depth = prev->depth.mm; - /* Init a few values from prev sample to avoid useless info in XML */ - surface.bearing.degrees = prev->bearing.degrees; - surface.ndl.seconds = prev->ndl.seconds; /* * Only do surface events if the samples are more than * a minute apart, and shallower than 5m */ if (time > last_time + 60 && last_depth < 5000) { + struct sample surface = { 0 }; + + /* Init a few values from prev sample to avoid useless info in XML */ + surface.bearing.degrees = prev->bearing.degrees; + surface.ndl.seconds = prev->ndl.seconds; + add_sample(&surface, last_time + 20, dc); add_sample(&surface, time - 20, dc); } |