summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/dive.c61
-rw-r--r--core/dive.h3
-rw-r--r--core/divelist.c4
-rw-r--r--core/equipment.c41
-rw-r--r--core/equipment.h19
-rw-r--r--core/import-divinglog.c4
-rw-r--r--core/load-git.c17
-rw-r--r--core/parse-xml.c14
-rw-r--r--core/parse.c4
-rw-r--r--core/parse.h2
-rw-r--r--core/save-git.c6
-rw-r--r--core/save-html.c6
-rw-r--r--core/save-xml.c6
-rw-r--r--core/subsurface-qt/DiveObjectHelper.cpp10
-rw-r--r--core/table.h14
-rw-r--r--core/uemis-downloader.c6
16 files changed, 127 insertions, 90 deletions
diff --git a/core/dive.c b/core/dive.c
index c353d196e..04247a682 100644
--- a/core/dive.c
+++ b/core/dive.c
@@ -355,8 +355,8 @@ static void free_dive_structures(struct dive *d)
STRUCTURED_LIST_FREE(struct picture, d->picture_list, free_picture);
for (int i = 0; i < MAX_CYLINDERS; i++)
free((void *)d->cylinder[i].type.description);
- for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++)
- free((void *)d->weightsystem[i].description);
+ clear_weightsystem_table(&d->weightsystems);
+ free(d->weightsystems.weightsystems);
}
void free_dive(struct dive *d)
@@ -387,6 +387,7 @@ static void copy_dive_nodc(const struct dive *s, struct dive *d)
* relevant components that are referenced through pointers,
* so all the strings and the structured lists */
*d = *s;
+ memset(&d->weightsystems, 0, sizeof(d->weightsystems));
invalidate_dive_cache(d);
d->buddy = copy_string(s->buddy);
d->divemaster = copy_string(s->divemaster);
@@ -394,8 +395,7 @@ static void copy_dive_nodc(const struct dive *s, struct dive *d)
d->suit = copy_string(s->suit);
for (int i = 0; i < MAX_CYLINDERS; i++)
d->cylinder[i].type.description = copy_string(s->cylinder[i].type.description);
- for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++)
- d->weightsystem[i].description = copy_string(s->weightsystem[i].description);
+ copy_weights(&s->weightsystems, &d->weightsystems);
STRUCTURED_LIST_COPY(struct picture, s->picture_list, d->picture_list, copy_pl);
d->tag_list = taglist_copy(s->tag_list);
}
@@ -432,15 +432,6 @@ struct dive *move_dive(struct dive *s)
if (what._component) \
d->_component = copy_string(s->_component)
-void copy_weights(const struct dive *s, struct dive *d)
-{
- for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
- free((void *)d->weightsystem[i].description);
- d->weightsystem[i] = s->weightsystem[i];
- d->weightsystem[i].description = copy_string(s->weightsystem[i].description);
- }
-}
-
// copy elements, depending on bits in what that are set
void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_components what, bool clear)
{
@@ -463,7 +454,7 @@ void selective_copy_dive(const struct dive *s, struct dive *d, struct dive_compo
if (what.cylinders)
copy_cylinders(s, d, false);
if (what.weights)
- copy_weights(s, d);
+ copy_weights(&s->weightsystems, &d->weightsystems);
}
#undef CONDITIONAL_COPY_STRING
@@ -515,14 +506,7 @@ int nr_cylinders(const struct dive *dive)
int nr_weightsystems(const struct dive *dive)
{
- int nr;
-
- for (nr = MAX_WEIGHTSYSTEMS; nr; --nr) {
- const weightsystem_t *ws = dive->weightsystem + nr - 1;
- if (!weightsystem_none(ws))
- break;
- }
- return nr;
+ return dive->weightsystems.nr;
}
/* copy the equipment data part of the cylinders */
@@ -1557,8 +1541,8 @@ struct dive *fixup_dive(struct dive *dive)
cyl->end.mbar = 0;
}
update_cylinder_related_info(dive);
- for (i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
- weightsystem_t *ws = dive->weightsystem + i;
+ for (i = 0; i < dive->weightsystems.nr; i++) {
+ weightsystem_t *ws = &dive->weightsystems.weightsystems[i];
add_weightsystem_description(ws);
}
/* we should always have a uniq ID as that gets assigned during alloc_dive(),
@@ -1922,14 +1906,6 @@ static void merge_events(struct dive *d, struct divecomputer *res,
add_initial_gaschange(d, res, offset, cylinders_map2[0]);
}
-static void merge_weightsystem_info(weightsystem_t *res, const weightsystem_t *a, const weightsystem_t *b)
-{
- if (!a->weight.grams)
- a = b;
- res->weight = a->weight;
- res->description = copy_string(a->description);
-}
-
/* get_cylinder_idx_by_use(): Find the index of the first cylinder with a particular CCR use type.
* The index returned corresponds to that of the first cylinder with a cylinder_use that
* equals the appropriate enum value [oxygen, diluent, bailout] given by cylinder_use_type.
@@ -2307,11 +2283,28 @@ static void merge_cylinders(struct dive *res, const struct dive *a, const struct
}
}
+/* Check whether a weightsystem table contains a given weightsystem */
+static bool has_weightsystem(const struct weightsystem_table *t, const weightsystem_t w)
+{
+ int i;
+ for (i = 0; i < t->nr; i++) {
+ if (same_weightsystem(w, t->weightsystems[i]))
+ return true;
+ }
+ return false;
+}
+
static void merge_equipment(struct dive *res, const struct dive *a, const struct dive *b)
{
int i;
- for (i = 0; i < MAX_WEIGHTSYSTEMS; i++)
- merge_weightsystem_info(res->weightsystem + i, a->weightsystem + i, b->weightsystem + i);
+ for (i = 0; i < a->weightsystems.nr; i++) {
+ if (!has_weightsystem(&res->weightsystems, a->weightsystems.weightsystems[i]))
+ add_cloned_weightsystem(&res->weightsystems, a->weightsystems.weightsystems[i]);
+ }
+ for (i = 0; i < b->weightsystems.nr; i++) {
+ if (!has_weightsystem(&res->weightsystems, b->weightsystems.weightsystems[i]))
+ add_cloned_weightsystem(&res->weightsystems, b->weightsystems.weightsystems[i]);
+ }
}
static void merge_temperatures(struct dive *res, const struct dive *a, const struct dive *b)
diff --git a/core/dive.h b/core/dive.h
index 40ac9fb00..95275aa12 100644
--- a/core/dive.h
+++ b/core/dive.h
@@ -153,7 +153,7 @@ struct dive {
int rating;
int visibility; /* 0 - 5 star rating */
cylinder_t cylinder[MAX_CYLINDERS];
- weightsystem_t weightsystem[MAX_WEIGHTSYSTEMS];
+ struct weightsystem_table weightsystems;
char *suit;
int sac, otu, cns, maxcns;
@@ -374,7 +374,6 @@ extern void copy_events(const struct divecomputer *s, struct divecomputer *d);
extern void free_events(struct event *ev);
extern void copy_cylinders(const struct dive *s, struct dive *d, bool used_only);
extern void copy_samples(const struct divecomputer *s, struct divecomputer *d);
-extern void copy_weights(const struct dive *s, struct dive *d);
extern bool is_cylinder_used(const struct dive *dive, int idx);
extern bool is_cylinder_prot(const struct dive *dive, int idx);
extern void fill_default_cylinder(cylinder_t *cyl);
diff --git a/core/divelist.c b/core/divelist.c
index 71a4b9bda..f088195fd 100644
--- a/core/divelist.c
+++ b/core/divelist.c
@@ -100,8 +100,8 @@ int total_weight(const struct dive *dive)
int i, total_grams = 0;
if (dive)
- for (i = 0; i < MAX_WEIGHTSYSTEMS; i++)
- total_grams += dive->weightsystem[i].weight.grams;
+ for (i = 0; i < dive->weightsystems.nr; i++)
+ total_grams += dive->weightsystems.weightsystems[i].weight.grams;
return total_grams;
}
diff --git a/core/equipment.c b/core/equipment.c
index 91db0cb81..5bf13713c 100644
--- a/core/equipment.c
+++ b/core/equipment.c
@@ -17,6 +17,29 @@
#include "display.h"
#include "divelist.h"
#include "subsurface-string.h"
+#include "table.h"
+
+static void free_weightsystem(weightsystem_t w)
+{
+ free((void *)w.description);
+}
+
+void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d)
+{
+ clear_weightsystem_table(d);
+ for (int i = 0; i < s->nr; i++)
+ add_cloned_weightsystem(d, s->weightsystems[i]);
+}
+
+/* weightsystem table functions */
+//static MAKE_GET_IDX(weightsystem_table, weightsystem_t, weightsystems)
+static MAKE_GROW_TABLE(weightsystem_table, weightsystem_t, weightsystems)
+//static MAKE_GET_INSERTION_INDEX(weightsystem_table, weightsystem_t, weightsystems, weightsystem_less_than)
+MAKE_ADD_TO(weightsystem_table, weightsystem_t, weightsystems)
+MAKE_REMOVE_FROM(weightsystem_table, weightsystems)
+//MAKE_SORT(weightsystem_table, weightsystem_t, weightsystems, comp_weightsystems)
+//MAKE_REMOVE(weightsystem_table, weightsystem_t, weightsystem)
+MAKE_CLEAR_TABLE(weightsystem_table, weightsystems, weightsystem)
const char *cylinderuse_text[NUM_GAS_USE] = {
QT_TRANSLATE_NOOP("gettextFromC", "OC-gas"), QT_TRANSLATE_NOOP("gettextFromC", "diluent"), QT_TRANSLATE_NOOP("gettextFromC", "oxygen"), QT_TRANSLATE_NOOP("gettextFromC", "not used")
@@ -51,6 +74,7 @@ void add_cylinder_description(const cylinder_type_t *type)
tank_info[i].bar = type->workingpressure.mbar / 1000;
}
}
+
void add_weightsystem_description(const weightsystem_t *weightsystem)
{
const char *desc;
@@ -72,10 +96,18 @@ void add_weightsystem_description(const weightsystem_t *weightsystem)
}
}
+/* Add a clone of a weightsystem to the end of a weightsystem table.
+ * Cloned in means that the description-string is copied. */
+void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws)
+{
+ weightsystem_t w_clone = { ws.weight, copy_string(ws.description) };
+ add_to_weightsystem_table(t, t->nr, w_clone);
+}
+
bool same_weightsystem(weightsystem_t w1, weightsystem_t w2)
{
- return w1->weight.grams == w2->weight.grams &&
- same_string(w1->description, w2->description);
+ return w1.weight.grams == w2.weight.grams &&
+ same_string(w1.description, w2.description);
}
bool cylinder_nodata(const cylinder_t *cyl)
@@ -239,10 +271,7 @@ void remove_cylinder(struct dive *dive, int idx)
void remove_weightsystem(struct dive *dive, int idx)
{
- weightsystem_t *ws = dive->weightsystem + idx;
- int nr = MAX_WEIGHTSYSTEMS - idx - 1;
- memmove(ws, ws + 1, nr * sizeof(*ws));
- memset(ws + nr, 0, sizeof(*ws));
+ remove_from_weightsystem_table(&dive->weightsystems, idx);
}
/* when planning a dive we need to make sure that all cylinders have a sane depth assigned
diff --git a/core/equipment.h b/core/equipment.h
index 4e1585c1f..cc8b8dcea 100644
--- a/core/equipment.h
+++ b/core/equipment.h
@@ -39,12 +39,25 @@ typedef struct
const char *description; /* "integrated", "belt", "ankle" */
} weightsystem_t;
+/* Table of weightsystems. Attention: this stores weightsystems,
+ * *not* pointers * to weightsystems. This has two crucial
+ * consequences:
+ * 1) Pointers to weightsystems are not stable. They may be
+ * invalidated if the table is reallocated.
+ * 2) add_to_weightsystem_table(), etc. takes ownership of the
+ * weightsystem. Notably of the description string */
+struct weightsystem_table {
+ int nr, allocated;
+ weightsystem_t *weightsystems;
+};
+
#define MAX_CYLINDERS (20)
-#define MAX_WEIGHTSYSTEMS (6)
#define MAX_TANK_INFO (100)
#define MAX_WS_INFO (100)
extern int cylinderuse_from_text(const char *text);
+extern void copy_weights(const struct weightsystem_table *s, struct weightsystem_table *d);
+extern void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws);
extern void add_cylinder_description(const cylinder_type_t *);
extern void add_weightsystem_description(const weightsystem_t *);
extern bool same_weightsystem(weightsystem_t w1, weightsystem_t w2);
@@ -60,6 +73,10 @@ extern int find_best_gasmix_match(struct gasmix mix, const cylinder_t array[]);
extern void dump_cylinders(struct dive *dive, bool verbose);
#endif
+/* Weightsystem table functions */
+extern void clear_weightsystem_table(struct weightsystem_table *);
+extern void add_to_weightsystem_table(struct weightsystem_table *, int idx, weightsystem_t ws);
+
void get_gas_string(struct gasmix gasmix, char *text, int len);
const char *gasname(struct gasmix gasmix);
diff --git a/core/import-divinglog.c b/core/import-divinglog.c
index 6051cc8bd..d29770080 100644
--- a/core/import-divinglog.c
+++ b/core/import-divinglog.c
@@ -311,8 +311,8 @@ static int divinglog_dive(void *param, int columns, char **data, char **column)
state->cur_dive->watertemp.mkelvin = C_to_mkelvin(atol(data[9]));
if (data[10]) {
- state->cur_dive->weightsystem[0].weight.grams = atol(data[10]) * 1000;
- state->cur_dive->weightsystem[0].description = strdup(translate("gettextFromC", "unknown"));
+ weightsystem_t ws = { { atol(data[10]) * 1000 }, translate("gettextFromC", "unknown") };
+ add_cloned_weightsystem(&state->cur_dive->weightsystems, ws);
}
if (data[11])
diff --git a/core/load-git.c b/core/load-git.c
index ee31e99ac..b23204b79 100644
--- a/core/load-git.c
+++ b/core/load-git.c
@@ -330,7 +330,7 @@ static char *parse_keyvalue_entry(void (*fn)(void *, const char *, const char *)
return line;
}
-static int cylinder_index, weightsystem_index;
+static int cylinder_index;
static int o2pressure_sensor;
static void parse_cylinder_keyvalue(void *_cylinder, const char *key, const char *value)
@@ -424,21 +424,19 @@ static void parse_weightsystem_keyvalue(void *_ws, const char *key, const char *
static void parse_dive_weightsystem(char *line, struct membuffer *str, void *_dive)
{
struct dive *dive = _dive;
- weightsystem_t *ws = dive->weightsystem + weightsystem_index;
+ weightsystem_t ws = { 0 };
- if (weightsystem_index >= MAX_WEIGHTSYSTEMS)
- return;
-
- weightsystem_index++;
- ws->description = get_utf8(str);
+ ws.description = get_utf8(str);
for (;;) {
char c;
while (isspace(c = *line))
line++;
if (!c)
break;
- line = parse_keyvalue_entry(parse_weightsystem_keyvalue, ws, line);
+ line = parse_keyvalue_entry(parse_weightsystem_keyvalue, &ws, line);
}
+
+ add_to_weightsystem_table(&dive->weightsystems, dive->weightsystems.nr, ws);
}
static int match_action(char *line, struct membuffer *str, void *data,
@@ -1506,7 +1504,8 @@ static int parse_dive_entry(git_repository *repo, const git_tree_entry *entry, c
return report_error("Unable to read dive file");
if (*suffix)
dive->number = atoi(suffix+1);
- cylinder_index = weightsystem_index = 0;
+ cylinder_index = 0;
+ clear_weightsystem_table(&dive->weightsystems);
o2pressure_sensor = 1;
for_each_line(blob, dive_parser, active_dive);
git_blob_free(blob);
diff --git a/core/parse-xml.c b/core/parse-xml.c
index 4b3d5b8a4..6f1c272d3 100644
--- a/core/parse-xml.c
+++ b/core/parse-xml.c
@@ -1309,14 +1309,12 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf, str
return;
if (MATCH_STATE("airpressure.dive", pressure, &dive->surface_pressure))
return;
- if (state->cur_ws_index < MAX_WEIGHTSYSTEMS) {
- if (MATCH("description.weightsystem", utf8_string, &dive->weightsystem[state->cur_ws_index].description))
- return;
- if (MATCH_STATE("weight.weightsystem", weight, &dive->weightsystem[state->cur_ws_index].weight))
- return;
- if (MATCH_STATE("weight", weight, &dive->weightsystem[state->cur_ws_index].weight))
- return;
- }
+ if (MATCH("description.weightsystem", utf8_string, &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1].description))
+ return;
+ if (MATCH_STATE("weight.weightsystem", weight, &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1].weight))
+ return;
+ if (MATCH_STATE("weight", weight, &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1].weight))
+ return;
if (state->cur_cylinder_index < MAX_CYLINDERS) {
if (MATCH("size.cylinder", cylindersize, &dive->cylinder[state->cur_cylinder_index].type.size))
return;
diff --git a/core/parse.c b/core/parse.c
index 0581ace00..e33ced85b 100644
--- a/core/parse.c
+++ b/core/parse.c
@@ -257,7 +257,6 @@ void dive_end(struct parser_state *state)
state->cur_location.lat.udeg = 0;
state->cur_location.lon.udeg = 0;
state->cur_cylinder_index = 0;
- state->cur_ws_index = 0;
}
void trip_start(struct parser_state *state)
@@ -299,11 +298,12 @@ void cylinder_end(struct parser_state *state)
void ws_start(struct parser_state *state)
{
+ weightsystem_t w = { {0}, "" };
+ add_cloned_weightsystem(&state->cur_dive->weightsystems, w);
}
void ws_end(struct parser_state *state)
{
- state->cur_ws_index++;
}
/*
diff --git a/core/parse.h b/core/parse.h
index bc955dece..79ba57098 100644
--- a/core/parse.h
+++ b/core/parse.h
@@ -54,7 +54,7 @@ struct parser_state {
bool in_settings;
bool in_userid;
struct tm cur_tm;
- int cur_cylinder_index, cur_ws_index;
+ int cur_cylinder_index;
int lastcylinderindex, next_o2_sensor;
int o2pressure_sensor;
int sample_rate;
diff --git a/core/save-git.c b/core/save-git.c
index 2b50fe7f7..4c57a5350 100644
--- a/core/save-git.c
+++ b/core/save-git.c
@@ -165,9 +165,9 @@ static void save_weightsystem_info(struct membuffer *b, struct dive *dive)
nr = nr_weightsystems(dive);
for (i = 0; i < nr; i++) {
- weightsystem_t *ws = dive->weightsystem + i;
- int grams = ws->weight.grams;
- const char *description = ws->description;
+ weightsystem_t ws = dive->weightsystems.weightsystems[i];
+ int grams = ws.weight.grams;
+ const char *description = ws.description;
put_string(b, "weightsystem");
put_milli(b, " weight=", grams, "kg");
diff --git a/core/save-html.c b/core/save-html.c
index 21b76188e..ecea33458 100644
--- a/core/save-html.c
+++ b/core/save-html.c
@@ -106,9 +106,9 @@ static void put_weightsystem_HTML(struct membuffer *b, struct dive *dive)
char *separator = "";
for (i = 0; i < nr; i++) {
- weightsystem_t *ws = dive->weightsystem + i;
- int grams = ws->weight.grams;
- const char *description = ws->description;
+ weightsystem_t ws = dive->weightsystems.weightsystems[i];
+ int grams = ws.weight.grams;
+ const char *description = ws.description;
put_string(b, separator);
separator = ", ";
diff --git a/core/save-xml.c b/core/save-xml.c
index 75e90f921..d50404059 100644
--- a/core/save-xml.c
+++ b/core/save-xml.c
@@ -205,9 +205,9 @@ static void save_weightsystem_info(struct membuffer *b, struct dive *dive)
nr = nr_weightsystems(dive);
for (i = 0; i < nr; i++) {
- weightsystem_t *ws = dive->weightsystem + i;
- int grams = ws->weight.grams;
- const char *description = ws->description;
+ weightsystem_t ws = dive->weightsystems.weightsystems[i];
+ int grams = ws.weight.grams;
+ const char *description = ws.description;
put_format(b, " <weightsystem");
put_milli(b, " weight='", grams, " kg'");
diff --git a/core/subsurface-qt/DiveObjectHelper.cpp b/core/subsurface-qt/DiveObjectHelper.cpp
index 35ec2df2a..3f740c3e4 100644
--- a/core/subsurface-qt/DiveObjectHelper.cpp
+++ b/core/subsurface-qt/DiveObjectHelper.cpp
@@ -14,7 +14,7 @@ enum returnPressureSelector {START_PRESSURE, END_PRESSURE};
static QString getFormattedWeight(struct dive *dive, unsigned int idx)
{
- weightsystem_t *weight = &dive->weightsystem[idx];
+ weightsystem_t *weight = &dive->weightsystems.weightsystems[idx];
if (!weight->description)
return QString();
QString fmt = QString(weight->description);
@@ -231,7 +231,7 @@ QString DiveObjectHelper::sac() const
QString DiveObjectHelper::weightList() const
{
QString weights;
- for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
+ for (int i = 0; i < m_dive->weightsystems.nr; i++) {
QString w = getFormattedWeight(m_dive, i);
if (w.isEmpty())
continue;
@@ -243,7 +243,7 @@ QString DiveObjectHelper::weightList() const
QStringList DiveObjectHelper::weights() const
{
QStringList weights;
- for (int i = 0; i < MAX_WEIGHTSYSTEMS; i++) {
+ for (int i = 0; i < m_dive->weightsystems.nr; i++) {
QString w = getFormattedWeight(m_dive, i);
if (w.isEmpty())
continue;
@@ -254,12 +254,12 @@ QStringList DiveObjectHelper::weights() const
bool DiveObjectHelper::singleWeight() const
{
- return weightsystem_none(&m_dive->weightsystem[1]);
+ return m_dive->weightsystems.nr == 1;
}
QString DiveObjectHelper::weight(int idx) const
{
- if ( (idx < 0) || idx > MAX_WEIGHTSYSTEMS )
+ if ((idx < 0) || idx >= m_dive->weightsystems.nr)
return QString();
return getFormattedWeight(m_dive, idx);
}
diff --git a/core/table.h b/core/table.h
index da0bc96a5..cf0be3bae 100644
--- a/core/table.h
+++ b/core/table.h
@@ -50,13 +50,13 @@
} \
}
-#define MAKE_REMOVE_FROM(table_type, array_name) \
- void remove_from_##table_type(struct table_type *table, int idx) \
- { \
- int i; \
- for (i = idx; i < table->nr - 1; i++) \
- table->array_name[i] = table->array_name[i + 1]; \
- table->array_name[--table->nr] = NULL; \
+#define MAKE_REMOVE_FROM(table_type, array_name) \
+ void remove_from_##table_type(struct table_type *table, int idx) \
+ { \
+ int i; \
+ for (i = idx; i < table->nr - 1; i++) \
+ table->array_name[i] = table->array_name[i + 1]; \
+ memset(&table->array_name[--table->nr], 0, sizeof(table->array_name[0])); \
}
#define MAKE_GET_IDX(table_type, item_type, array_name) \
diff --git a/core/uemis-downloader.c b/core/uemis-downloader.c
index 83f37545b..5ad6b92be 100644
--- a/core/uemis-downloader.c
+++ b/core/uemis-downloader.c
@@ -194,7 +194,7 @@ static void uemis_get_weight(char *buffer, weightsystem_t *weight, int diveid)
weight->weight.grams = uemis_get_weight_unit(diveid) ?
lbs_to_grams(ascii_strtod(buffer, NULL)) :
lrint(ascii_strtod(buffer, NULL) * 1000);
- weight->description = strdup(translate("gettextFromC", "unknown"));
+ weight->description = translate("gettextFromC", "unknown");
}
static struct dive *uemis_start_dive(uint32_t deviceid)
@@ -815,7 +815,9 @@ static void parse_tag(struct dive *dive, char *tag, char *val)
} else if (!strcmp(tag, "altitude")) {
uemis_get_index(val, &dive->dc.surface_pressure.mbar);
} else if (!strcmp(tag, "f32Weight")) {
- uemis_get_weight(val, &dive->weightsystem[0], dive->dc.diveid);
+ weightsystem_t ws;
+ uemis_get_weight(val, &ws, dive->dc.diveid);
+ add_cloned_weightsystem(&dive->weightsystems, ws);
} else if (!strcmp(tag, "notes")) {
uemis_add_string(val, &dive->notes, " ");
} else if (!strcmp(tag, "u8DiveSuit")) {