mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
Core: remove ASSIGNED_TRIP trip flag
The distinction between ASSIGNED_TRIP and IN_TRIP was used to prefer non-autogenerated trips on merging of dives. But owing to bit rot this seem to have worked only partially anyway: The IN_TRIP field was set in create_and_hookup_trip_from_dive() and immediately overwritten in add_dive_to_trip() called in the next line. Instead, use the trip->autogen flag to check for priority and remove the ASSIGNED_TRIP flag alltogether. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
dcb2a17b7d
commit
3b9e0b5931
4 changed files with 11 additions and 18 deletions
21
core/dive.c
21
core/dive.c
|
@ -2578,24 +2578,21 @@ static const struct dive *get_preferred_trip(const struct dive *a, const struct
|
|||
{
|
||||
dive_trip_t *atrip, *btrip;
|
||||
|
||||
/*
|
||||
* The larger tripflag is more relevant: we prefer
|
||||
* take manually assigned trips over auto-generated
|
||||
* ones.
|
||||
*/
|
||||
if (a->tripflag > b->tripflag)
|
||||
return a;
|
||||
|
||||
if (a->tripflag < b->tripflag)
|
||||
return b;
|
||||
|
||||
/* Otherwise, look at the trip data and pick the "better" one */
|
||||
/* If only one dive has a trip, choose that */
|
||||
atrip = a->divetrip;
|
||||
btrip = b->divetrip;
|
||||
if (!atrip)
|
||||
return b;
|
||||
if (!btrip)
|
||||
return a;
|
||||
|
||||
/* Both dives have a trip - prefer the non-autogenerated one */
|
||||
if (atrip->autogen && !btrip->autogen)
|
||||
return b;
|
||||
if (!atrip->autogen && btrip->autogen)
|
||||
return a;
|
||||
|
||||
/* Otherwise, look at the trip data and pick the "better" one */
|
||||
if (!atrip->location)
|
||||
return b;
|
||||
if (!btrip->location)
|
||||
|
|
|
@ -282,7 +282,6 @@ typedef enum {
|
|||
TF_NONE,
|
||||
NO_TRIP,
|
||||
IN_TRIP,
|
||||
ASSIGNED_TRIP,
|
||||
NUM_TRIPFLAGS
|
||||
} tripflag_t;
|
||||
|
||||
|
|
|
@ -896,7 +896,7 @@ 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 = ASSIGNED_TRIP;
|
||||
dive->tripflag = IN_TRIP;
|
||||
}
|
||||
|
||||
dive_trip_t *alloc_trip(void)
|
||||
|
@ -921,7 +921,6 @@ dive_trip_t *create_and_hookup_trip_from_dive(struct dive *dive)
|
|||
dive_trip = create_trip_from_dive(dive);
|
||||
insert_trip(dive_trip);
|
||||
|
||||
dive->tripflag = IN_TRIP;
|
||||
add_dive_to_trip(dive, dive_trip);
|
||||
return dive_trip;
|
||||
}
|
||||
|
|
|
@ -254,10 +254,8 @@ void dive_end(struct parser_state *state)
|
|||
free_dive(state->cur_dive);
|
||||
else
|
||||
record_dive_to_table(state->cur_dive, state->target_table);
|
||||
if (state->cur_trip) {
|
||||
if (state->cur_trip)
|
||||
add_dive_to_trip(state->cur_dive, state->cur_trip);
|
||||
state->cur_dive->tripflag = IN_TRIP;
|
||||
}
|
||||
state->cur_dive = NULL;
|
||||
state->cur_dc = NULL;
|
||||
state->cur_location.lat.udeg = 0;
|
||||
|
|
Loading…
Reference in a new issue