summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-10 07:13:00 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-06-10 09:28:40 -0700
commit2365531c686be62954c201a690d89e0eebdef456 (patch)
treef18fda74383da6e92e580a8d4c4d3aac850cc50a /save-xml.c
parentd24de5b72b69d6a114654706f6f7821b73bf4400 (diff)
downloadsubsurface-2365531c686be62954c201a690d89e0eebdef456.tar.gz
When saving only selected dives, only include referenced dive sites
The algorithm seems rather brute force; basically quadratic in the number of dives, assuming we have about the same number of dive sites as dives which seems a reasonable assumotion. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/save-xml.c b/save-xml.c
index 173f6a8ec..58f274722 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -509,10 +509,10 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
/* save the dive sites */
put_format(b, "<divesites>\n");
for (i = 0; i < dive_site_table.nr; i++) {
+ int j;
+ struct dive *d;
struct dive_site *ds = get_dive_site(i);
if (dive_site_is_empty(ds)) {
- int j;
- struct dive *d;
for_each_dive(j, d) {
if (d->dive_site_uuid == ds->uuid)
d->dive_site_uuid = 0;
@@ -521,6 +521,17 @@ void save_dives_buffer(struct membuffer *b, const bool select_only)
i--; // since we just deleted that one
continue;
}
+ if (select_only) {
+ bool found = false;
+ for_each_dive(j, d) {
+ if (d->selected && d->dive_site_uuid == ds->uuid) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ continue;
+ }
put_format(b, "<site uuid='%8x'", ds->uuid);
show_utf8(b, ds->name, " name='", "'", 1);
if (ds->latitude.udeg || ds->longitude.udeg) {