From 9c24d6bef816c05992c59b45d32fcb4fe256d5a3 Mon Sep 17 00:00:00 2001 From: Willem Ferguson Date: Sun, 8 Apr 2018 14:37:30 +0200 Subject: Fix bug for CCR dive bailout Under some conditions get_current_divemode() (in dive.c) returns an erroneous divemode. This happens when there are several events at the very beginning of the dive, as can happen in some CCR dive logs. This commit fixes that bug. Signed-off-by: Willem Ferguson --- core/dive.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/dive.c b/core/dive.c index 950f4b336..d75de418e 100644 --- a/core/dive.c +++ b/core/dive.c @@ -253,7 +253,8 @@ enum dive_comp_type get_current_divemode(struct divecomputer *dc, int time, stru ev = dc ? dc->events : NULL; } while (ev && ev->time.seconds < time) { - *divemode = (enum dive_comp_type) ev->value; + if (ev != dc->events) + *divemode = (enum dive_comp_type) ev->value; ev = get_next_event(ev->next, "modechange"); } *evp = ev; -- cgit v1.2.3-70-g09d2