Correct the detection of existing dives in the Uemis downloader

This didn't take multiple divecomputers into account and didn't compare
the model as well as the deviceid to match a divecomputer.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-12-28 18:21:34 -08:00
parent 020154215d
commit 0233239198

View file

@ -730,8 +730,12 @@ static char *get_divenr(char *deviceidstr)
deviceid = atoi(deviceidstr);
for (i = 0; i < dive_table.nr; i++) {
struct divecomputer *dc = &dive_table.dives[i]->dc;
if (dc->deviceid == deviceid && dc->diveid > maxdiveid)
maxdiveid = dc->diveid;
while (dc) {
if (!strcmp(dc->model, "Uemis Zurich") &&
dc->deviceid == deviceid && dc->diveid > maxdiveid)
maxdiveid = dc->diveid;
dc = dc->next;
}
}
snprintf(divenr, 10, "%d", maxdiveid);
return strdup(divenr);