core: move merge_dives() functios to struct dive_table

These functions have to access other dives in the list to
calculate CNS, etc, so let's call them from there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-24 20:47:02 +02:00 committed by bstoeger
parent 8ec1f008ab
commit 4d7291d4a1
6 changed files with 178 additions and 163 deletions

View file

@ -110,7 +110,7 @@ static void merge_imported_dives(struct dive_table &table)
prev->endtime() < dive->when)
continue;
auto merged = try_to_merge(*prev, *dive, false);
auto merged = table.try_to_merge(*prev, *dive, false);
if (!merged)
continue;
@ -175,7 +175,7 @@ static bool try_to_merge_into(struct dive &dive_to_add, struct dive *old_dive, b
/* output parameters: */
struct dive_table &dives_to_add, struct std::vector<dive *> &dives_to_remove)
{
auto merged = try_to_merge(*old_dive, dive_to_add, prefer_imported);
auto merged = dives_to_add.try_to_merge(*old_dive, dive_to_add, prefer_imported);
if (!merged)
return false;