summaryrefslogtreecommitdiffstats
path: root/load-git.c
diff options
context:
space:
mode:
authorGravatar Miika Turkia <miika.turkia@gmail.com>2016-01-30 12:57:19 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-26 09:23:43 +0100
commita5dde4c34aa828df3d9eb616dbf649f4818675ff (patch)
tree839cc135254a3db618706e4b26f1879f810a0635 /load-git.c
parent43ec76283bc9c3ccac6fdf46611b87fbcf852e06 (diff)
downloadsubsurface-a5dde4c34aa828df3d9eb616dbf649f4818675ff.tar.gz
Mark CCR dive's divetype properly
We used to mark CCR dives by having "SP change" event at time 0:00. As we nowadays mark CCR dives by setting dc->divemode appropriately, better to convert the old dives to this format as well. This way we do not have to take the special old format into account on multiple places in the source. Signed-off-by: Miika Turkia <miika.turkia@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'load-git.c')
-rw-r--r--load-git.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/load-git.c b/load-git.c
index 39dab4367..cedbd8dee 100644
--- a/load-git.c
+++ b/load-git.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <fcntl.h>
#include <git2.h>
+#include <libdivecomputer/parser.h>
#include "gettext.h"
@@ -744,6 +745,16 @@ static void parse_dc_event(char *line, struct membuffer *str, void *_dc)
if (str->len)
name = mb_cstring(str);
ev = add_event(dc, event.time.seconds, event.type, event.flags, event.value, name);
+
+ /*
+ * Older logs might mark the dive to be CCR by having an "SP change" event at time 0:00.
+ * Better to mark them being CCR on import so no need for special treatments elsewhere on
+ * the code.
+ */
+ if (ev && event.time.seconds == 0 && event.type == SAMPLE_EVENT_PO2 && dc->divemode==OC) {
+ dc->divemode = CCR;
+ }
+
if (ev && event_is_gaschange(ev)) {
/*
* We subtract one here because "0" is "no index",