Import: pass a dive table to process_imported_dives()

Dives were directly imported into the global dive table and then
merged in process_imported_dives(). Make this interface more flexible,
by passing an independent dive table.

The dive table of the to-be-imported dives will be sorted and merged.
Then each dive is inserted in a one-by-one manner to into the global
dive table.

This actually introduces (at least) two functional changes:
1) If a new dive spans two old dives, it will only be merged to the
   first dive. But this seems like a pathological case, which is of
   dubious value anyway.
2) Dives unrelated to the import will not be merged. The old code
   would happily merge dives that were not even close to the
   newly imported dives. A surprising behavior.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-09-28 10:21:23 +02:00 committed by Dirk Hohndel
parent c32e71e64d
commit 810903bdb9
9 changed files with 203 additions and 111 deletions

View file

@ -19,7 +19,7 @@ extern int init_decompression(struct deco_state *ds, struct dive *dive);
/* divelist core logic functions */
extern void process_loaded_dives();
extern void process_imported_dives(bool prefer_imported);
extern void process_imported_dives(struct dive_table *import_table, bool prefer_imported);
extern char *get_dive_gas_string(struct dive *dive);
struct dive **grow_dive_table(struct dive_table *table);
@ -43,6 +43,7 @@ extern struct dive *last_selected_dive();
extern bool is_trip_before_after(const struct dive *dive, bool before);
extern void set_dive_nr_for_current_dive();
extern timestamp_t get_surface_interval(timestamp_t when);
extern void delete_dive_from_table(struct dive_table *table, int idx);
int get_min_datafile_version();
void reset_min_datafile_version();