mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Editing air or water temperature should modify dive computer, not dive
The dive fields are summary fields, the actual data needs to be in the divecomputer specific fields. Fixes #307
This commit is contained in:
parent
d936c55a01
commit
ff5fa70a88
4 changed files with 25 additions and 11 deletions
22
dive.c
22
dive.c
|
@ -646,19 +646,29 @@ static void fixup_duration(struct dive *dive)
|
|||
dive->duration.seconds = duration;
|
||||
}
|
||||
|
||||
static void fixup_watertemp(struct dive *dive)
|
||||
/*
|
||||
* What do the dive computers say the water temperature is?
|
||||
* (not in the samples, but as dc property for dcs that support that)
|
||||
*/
|
||||
unsigned int dc_watertemp(struct divecomputer *dc)
|
||||
{
|
||||
struct divecomputer *dc;
|
||||
int sum = 0, nr = 0;
|
||||
|
||||
for_each_dc(dive, dc) {
|
||||
do {
|
||||
if (dc->watertemp.mkelvin) {
|
||||
sum += dc->watertemp.mkelvin;
|
||||
nr++;
|
||||
}
|
||||
}
|
||||
if (nr)
|
||||
dive->watertemp.mkelvin = (sum + nr / 2) / nr;
|
||||
} while ((dc = dc->next) != NULL);
|
||||
if (!nr)
|
||||
return 0;
|
||||
return (sum + nr / 2) / nr;
|
||||
}
|
||||
|
||||
static void fixup_watertemp(struct dive *dive)
|
||||
{
|
||||
if (!dive->watertemp.mkelvin)
|
||||
dive->watertemp.mkelvin = dc_watertemp(&dive->dc);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue