From c804c4e02e0530889697fab524cba294a55ffeeb Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 19 Sep 2012 23:42:11 -0400 Subject: Partial rewrite of the dive trip code This introduces a new data structure for dive trips - reuseing the struct dive just got way too messy. The dive_trip_t datastructure now allows the code to remember if the trip was auto generated or if its time stamp changed when dives where added to the trip during auto generation. The algorithm also distinguishes between dives that were intentionally added to a trip (either in an XML file or by adding them to trip in the UI) and dives that were added to trips via autogen. Saving dives that were added to trips via autogen makes that assignment "intentional". With this partial rewrite several of the oddities of the old code should be resolved - especially turning autogen on and off again should get the divelist back to the previous stage. Also, when dives are merged during file open or import we now try to pick the correct tripflag (instead of just ignoring the tripflag completely and resetting it to TF_NONE by mistake). Finally, the dive trip debugging code got more verbose and is trying harder to detect issues at the earliest time possible. Signed-off-by: Dirk Hohndel --- dive.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'dive.c') diff --git a/dive.c b/dive.c index 52ec64517..b1739ad80 100644 --- a/dive.c +++ b/dive.c @@ -710,6 +710,11 @@ struct dive *try_to_merge(struct dive *a, struct dive *b) res = alloc_dive(); res->when = a->when; + /* the larger tripflag is more relevant */ + if(a->tripflag > b->tripflag) + res->tripflag = a->tripflag; + else + res->tripflag = b->tripflag; MERGE_NONZERO(res, a, b, latitude); MERGE_NONZERO(res, a, b, longitude); MERGE_TXT(res, a, b, location); -- cgit v1.2.3-70-g09d2