diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-02-09 07:12:30 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-02-09 07:19:29 -0800 |
commit | b9865d6bbc30ff4f82ffa17d4a2e3e74bc1054ed (patch) | |
tree | 0bb5aac0bd1f854ed3ee896b57d4ed73524ffad3 /divelist.c | |
parent | c7efcb23a9a838f88c6691cb7b278126ae639c4b (diff) | |
download | subsurface-b9865d6bbc30ff4f82ffa17d4a2e3e74bc1054ed.tar.gz |
Move duration to dive structure and replace accessor function
When starting on this quest to stop using the first divecomputer instead
of data for the whole dive in commit eb73b5a528c8 ("Duration of a dive is
the maximum duration from all divecomputers") I introduced an accessor
function that calculates the dive duration on the fly as the maximum of
the durations in the divecomputers.
Since then Linus and I have added quite a few of the variables back to the
dive data structure and it makes perfect sense to do the same thing for
the duration as well and simply do the calculation once during fixup.
This commit also replaces accesses to the first divecomputer in
likely_same_dive to use the maxdepth and meandepth of the dive (those two
slipped through the cracks in the previous commits, it seems).
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/divelist.c b/divelist.c index 7d887d353..70a99f9c6 100644 --- a/divelist.c +++ b/divelist.c @@ -780,10 +780,10 @@ double init_decompression(struct dive *dive) * for how far back we need to go */ if (dive->divetrip && pdive->divetrip != dive->divetrip) continue; - if (!pdive || pdive->when > when || pdive->when + get_duration_in_sec(pdive) + 48 * 60 * 60 < when) + if (!pdive || pdive->when > when || pdive->when + pdive->duration.seconds + 48 * 60 * 60 < when) break; when = pdive->when; - lasttime = when + get_duration_in_sec(pdive); + lasttime = when + pdive->duration.seconds; } while (++i < divenr) { struct dive* pdive = get_dive(i); @@ -805,7 +805,7 @@ double init_decompression(struct dive *dive) #endif if (pdive->when > lasttime) { surface_time = pdive->when - lasttime; - lasttime = pdive->when + get_duration_in_sec(pdive); + lasttime = pdive->when + pdive->duration.seconds; tissue_tolerance = add_segment(surface_pressure, &air, surface_time, 0, dive); #if DECO_CALC_DEBUG & 2 printf("after surface intervall of %d:%02u\n", FRACTION(surface_time,60)); @@ -1318,7 +1318,7 @@ static void fill_dive_list(void) DIVE_NR, dive->number, DIVE_DATE, dive->when, DIVE_DEPTH, dive->maxdepth, - DIVE_DURATION, get_duration_in_sec(dive), + DIVE_DURATION, dive->duration.seconds, DIVE_LOCATION, dive->location, DIVE_LOC_ICON, icon, DIVE_RATING, dive->rating, @@ -1331,7 +1331,7 @@ static void fill_dive_list(void) DIVE_NR, dive->number, DIVE_DATE, dive->when, DIVE_DEPTH, dive->maxdepth, - DIVE_DURATION, get_duration_in_sec(dive), + DIVE_DURATION, dive->duration.seconds, DIVE_LOCATION, dive->location, DIVE_LOC_ICON, icon, DIVE_RATING, dive->rating, @@ -2361,7 +2361,7 @@ static void add_dive_merge_label(int idx, GtkMenuShell *menu) return; /* .. and if the surface interval is excessive, you must be kidding us */ - if (b->when > a->when + get_duration_in_sec(a) + 30*60) + if (b->when > a->when + a->duration.seconds + 30*60) return; /* If so, we can add a "merge dive" menu entry */ |