summaryrefslogtreecommitdiffstats
path: root/libdivecomputer.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-23 14:54:42 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-23 22:00:39 -0800
commit03a0678b00856e10e18559a41be2f67f839fe44d (patch)
treeb2d5ff8fa7f858ec6d171106b70ddafbc310c4bf /libdivecomputer.c
parent450fd9c7bdf6942a4f451760e1aeb0c07d2a9231 (diff)
downloadsubsurface-03a0678b00856e10e18559a41be2f67f839fe44d.tar.gz
Use a default tank when populating tank data after download
This is super-simplistic and also is kinda wrong. It forces all tanks that haven't been specified by the DC (so far only Atomics Aquatics Cobalt and UEMIS Zurich (which doesn't even use libdivecomputer) to be AL80. Just as we used AL80 as default for manually adding tanks. Obviously this needs to become an option where the user can pick. See #145 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'libdivecomputer.c')
-rw-r--r--libdivecomputer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libdivecomputer.c b/libdivecomputer.c
index 7b91458e9..bc2aea6d0 100644
--- a/libdivecomputer.c
+++ b/libdivecomputer.c
@@ -54,7 +54,7 @@ struct atomics_gas_info {
#define COBALT_CFATBAR 2
#define COBALT_WETINDL 3
-static void get_tanksize(device_data_t *devdata, const unsigned char *data, cylinder_t *cyl, int idx)
+static bool get_tanksize(device_data_t *devdata, const unsigned char *data, cylinder_t *cyl, int idx)
{
/* I don't like this kind of match... I'd love to have an ID and
* a firmware version or... something; and even better, just get
@@ -69,7 +69,7 @@ static void get_tanksize(device_data_t *devdata, const unsigned char *data, cyli
* right data */
if (*(uint32_t *)data != 0xFFFEFFFE) {
printf("incorrect header for Atomics dive\n");
- return;
+ return FALSE;
}
atomics_gas_info = (void*)(data + COBALT_HEADER);
switch (atomics_gas_info[idx].tankspecmethod) {
@@ -89,7 +89,9 @@ static void get_tanksize(device_data_t *devdata, const unsigned char *data, cyli
cyl[idx].type.size.mliter = atomics_gas_info[idx].tanksize * 100;
break;
}
+ return TRUE;
}
+ return FALSE;
}
static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t *parser, int ngases,
@@ -121,7 +123,8 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t
dive->cylinder[i].gasmix.o2.permille = o2;
dive->cylinder[i].gasmix.he.permille = he;
- get_tanksize(devdata, data, dive->cylinder, i);
+ if (!get_tanksize(devdata, data, dive->cylinder, i))
+ fill_default_cylinder(&dive->cylinder[i]);
}
return DC_STATUS_SUCCESS;
}