From 95a23cf4701d4918f866cb5ef1c25a5b2b380096 Mon Sep 17 00:00:00 2001 From: Stefan Fuchs Date: Sun, 18 Feb 2018 21:55:57 +0100 Subject: Use temperature_t for temperatures in struct stats_t Use struct temperature_t for temperatures in struct stats_t and use get_temperature_string() when printing these temperatures for statistics and HTML export. Signed-off-by: Stefan Fuchs --- core/statistics.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'core/statistics.c') diff --git a/core/statistics.c b/core/statistics.c index 13bcc4a97..c7cd213ff 100644 --- a/core/statistics.c +++ b/core/statistics.c @@ -24,23 +24,23 @@ stats_t *stats_by_type = NULL; static void process_temperatures(struct dive *dp, stats_t *stats) { - int min_temp, mean_temp, max_temp = 0; + temperature_t min_temp, mean_temp, max_temp = {.mkelvin = 0}; - max_temp = dp->maxtemp.mkelvin; - if (max_temp && (!stats->max_temp || max_temp > stats->max_temp)) - stats->max_temp = max_temp; + max_temp.mkelvin = dp->maxtemp.mkelvin; + if (max_temp.mkelvin && (!stats->max_temp.mkelvin || max_temp.mkelvin > stats->max_temp.mkelvin)) + stats->max_temp.mkelvin = max_temp.mkelvin; - min_temp = dp->mintemp.mkelvin; - if (min_temp && (!stats->min_temp || min_temp < stats->min_temp)) - stats->min_temp = min_temp; + min_temp.mkelvin = dp->mintemp.mkelvin; + if (min_temp.mkelvin && (!stats->min_temp.mkelvin || min_temp.mkelvin < stats->min_temp.mkelvin)) + stats->min_temp.mkelvin = min_temp.mkelvin; - if (min_temp || max_temp) { - mean_temp = min_temp; - if (mean_temp) - mean_temp = (mean_temp + max_temp) / 2; + if (min_temp.mkelvin || max_temp.mkelvin) { + mean_temp.mkelvin = min_temp.mkelvin; + if (mean_temp.mkelvin) + mean_temp.mkelvin = (mean_temp.mkelvin + max_temp.mkelvin) / 2; else - mean_temp = max_temp; - stats->combined_temp += get_temp_units(mean_temp, NULL); + mean_temp.mkelvin = max_temp.mkelvin; + stats->combined_temp.mkelvin += mean_temp.mkelvin; stats->combined_count++; } } -- cgit v1.2.3-70-g09d2