[PATCH] Improve detection of CCR dives on yearly stats

Miika Turkia miika.turkia at gmail.com
Sat Jan 23 08:31:59 PST 2016


It might be that we do not have the dctype set to CCR but the dive is
still closed circuit. In this case we have an event "SP change" on time
0 sec. So we have to check this case as well. (Note this info is checked
from the main DC only for the stats.)

Signed-off-by: Miika Turkia <miika.turkia at gmail.com>
---
 subsurface-core/statistics.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/subsurface-core/statistics.c b/subsurface-core/statistics.c
index 373a6a0..04ed3eb 100644
--- a/subsurface-core/statistics.c
+++ b/subsurface-core/statistics.c
@@ -93,6 +93,7 @@ void process_all_dives(struct dive *dive, struct dive **prev_dive)
 {
 	int idx;
 	struct dive *dp;
+	struct event *ev;
 	struct tm tm;
 	int current_year = 0;
 	int current_month = 0;
@@ -176,8 +177,14 @@ void process_all_dives(struct dive *dive, struct dive **prev_dive)
 		stats_by_type[0].selection_size++;
 		process_dive(dp, &(stats_by_type[0]));
 
-		process_dive(dp, &(stats_by_type[dp->dc.divemode + 1]));
-		stats_by_type[dp->dc.divemode + 1].selection_size++;
+		ev = get_next_event(dp->dc.events, "SP change");
+		if (ev && ev->time.seconds == 0) {
+			process_dive(dp, &(stats_by_type[CCR + 1]));
+			stats_by_type[CCR + 1].selection_size++;
+		} else {
+			process_dive(dp, &(stats_by_type[dp->dc.divemode + 1]));
+			stats_by_type[dp->dc.divemode + 1].selection_size++;
+		}
 
 		if (dp->divetrip != NULL) {
 			if (trip_ptr != dp->divetrip) {
-- 
2.5.0



More information about the subsurface mailing list