From 6bf4120dbbf7be1b9267e0e86f3948b77870ea71 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 18 Nov 2018 11:15:32 +0100 Subject: Core: replace tripflag by notrip boolean The only remaining use of the tripflag was to mark dives that were removed explicitly from a trip, i.e. shouldn't be autogrouped. Therefore replace the enum by a simple boolean. Currently, there is no way of unsetting the notrip flag. But this shouldn't result in a user-visible change. Signed-off-by: Berthold Stoeger --- core/divelist.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'core/divelist.c') diff --git a/core/divelist.c b/core/divelist.c index f887cc82c..41036a65f 100644 --- a/core/divelist.c +++ b/core/divelist.c @@ -875,10 +875,6 @@ struct dive_trip *unregister_dive_from_trip(struct dive *dive, short was_autogen if (idx) unregister_dive_from_table(&trip->dives, idx); dive->divetrip = NULL; - if (was_autogen) - dive->tripflag = TF_NONE; - else - dive->tripflag = NO_TRIP; return trip; } @@ -896,7 +892,6 @@ void add_dive_to_trip(struct dive *dive, dive_trip_t *trip) remove_dive_from_trip(dive, false); add_dive_to_table(&trip->dives, -1, dive); dive->divetrip = trip; - dive->tripflag = IN_TRIP; } dive_trip_t *alloc_trip(void) @@ -981,7 +976,9 @@ dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocat continue; } - if (!DIVE_NEEDS_TRIP(dive)) { + /* Only consider dives that have not been explicitly removed from + * a dive trip by the user. */ + if (dive->notrip) { lastdive = NULL; continue; } @@ -1002,7 +999,7 @@ dive_trip_t *get_dives_to_autogroup(int start, int *from, int *to, bool *allocat lastdive = dive; *from = i; for (*to = *from + 1; (dive = get_dive(*to)) != NULL; (*to)++) { - if (dive->divetrip || !DIVE_NEEDS_TRIP(dive) || + if (dive->divetrip || dive->notrip || dive->when >= lastdive->when + TRIP_THRESHOLD) break; if (get_dive_location(dive) && !trip->location) -- cgit v1.2.3-70-g09d2