summaryrefslogtreecommitdiffstats
path: root/core/statistics.c
diff options
context:
space:
mode:
authorGravatar Stefan Fuchs <sfuchs@gmx.de>2018-02-18 21:55:57 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-02-24 11:45:17 -0800
commit95a23cf4701d4918f866cb5ef1c25a5b2b380096 (patch)
treed4735ee6e8fe357483f88cab290e1749ad303656 /core/statistics.c
parent928e7ed8694e49efdabe3502eef32c4519bf6b0c (diff)
downloadsubsurface-95a23cf4701d4918f866cb5ef1c25a5b2b380096.tar.gz
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 <sfuchs@gmx.de>
Diffstat (limited to 'core/statistics.c')
-rw-r--r--core/statistics.c26
1 files changed, 13 insertions, 13 deletions
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++;
}
}