diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2021-07-16 21:11:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2021-07-23 11:30:17 -0700 |
commit | 63e1516579977e68a8cd18c7845682d4655b9677 (patch) | |
tree | 7248b06e7dae4960a78ff0116819d86bfdffce8e | |
parent | b18b3119b54083c762f891c1ab98d10f20211482 (diff) | |
download | subsurface-63e1516579977e68a8cd18c7845682d4655b9677.tar.gz |
core: recalculate CNS values on merge
When merging two dives, the higher CNS value was taken. This could
result in inconsistent CNS values if two dives were merged where
one dive's CNS was calculated from a "fake profile", i.e. a dive
without dive-computer profile. In that case, the most conservative
value (all time spent at the bottom) was assumed. The merged dive
then consisted of the dive-computer profile and the conservative
CNS estimate.
This is fixed by setting the CNS value to "0" after merging,
which means "unknown". The correct value will then be recalculated
in "fixup_dive" from the actual sample data.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r-- | core/dive.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/core/dive.c b/core/dive.c index e96036611..a4a47ab90 100644 --- a/core/dive.c +++ b/core/dive.c @@ -2614,7 +2614,6 @@ struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset, MERGE_MAX(res, a, b, rating); MERGE_TXT(res, a, b, suit, ", "); MERGE_MAX(res, a, b, number); - MERGE_NONZERO(res, a, b, cns); MERGE_NONZERO(res, a, b, visibility); copy_pictures(a->pictures.nr ? &a->pictures : &b->pictures, &res->pictures); taglist_merge(&res->tag_list, a->tag_list, b->tag_list); @@ -2631,6 +2630,9 @@ struct dive *merge_dives(const struct dive *a, const struct dive *b, int offset, else join_dive_computers(res, &res->dc, &a->dc, &b->dc, cylinders_map_a, cylinders_map_b, 0); + /* The CNS values will be recalculated from the sample in fixup_dive() */ + res->cns = res->maxcns = 0; + /* we take the first dive site, unless it's empty */ *site = a->dive_site && !dive_site_is_empty(a->dive_site) ? a->dive_site : b->dive_site; fixup_dive(res); |