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 /statistics.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 'statistics.c')
-rw-r--r-- | statistics.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/statistics.c b/statistics.c index 43e12efed..d87353b7f 100644 --- a/statistics.c +++ b/statistics.c @@ -127,7 +127,7 @@ static void process_temperatures(struct dive *dp, stats_t *stats) static void process_dive(struct dive *dp, stats_t *stats) { int old_tt, sac_time = 0; - int duration = get_duration_in_sec(dp); + int duration = dp->duration.seconds; old_tt = stats->total_time.seconds; stats->total_time.seconds += duration; @@ -414,7 +414,7 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) *prev_dive = NULL; memset(&stats, 0, sizeof(stats)); if (dive_table.nr > 0) { - stats.shortest_time.seconds = get_duration_in_sec(dive_table.dives[0]); + stats.shortest_time.seconds = dive_table.dives[0]->duration.seconds; stats.min_depth.mm = dive_table.dives[0]->maxdepth.mm; stats.selection_size = dive_table.nr; } @@ -553,10 +553,10 @@ static void show_single_dive_stats(struct dive *dive) tm.tm_hour, tm.tm_min); set_label(single_w.date, buf); - set_label(single_w.dive_time, _("%d min"), (get_duration_in_sec(dive) + 30) / 60); + set_label(single_w.dive_time, _("%d min"), (dive->duration.seconds + 30) / 60); if (prev_dive) set_label(single_w.surf_intv, - get_time_string(dive->when - (prev_dive->when + get_duration_in_sec(prev_dive)), 4)); + get_time_string(dive->when - (prev_dive->when + prev_dive->duration.seconds), 4)); else set_label(single_w.surf_intv, _("unknown")); value = get_depth_units(dc->maxdepth.mm, &decimals, &unit); |