mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: turn divecomputer list into std::vector<>
Since struct divecomputer is now fully C++ (i.e. cleans up after itself), we can simply turn the list of divecomputers into an std::vector<>. This makes the code quite a bit simpler, because the first divecomputer was actually a subobject. Yes, this makes the common case of a single divecomputer a little bit less efficient, but it really shouldn't matter. If it does, we can still write a special std::vector<>- like container that keeps the first element inline. This change makes pointers-to-divecomputers not stable. So always access the divecomputer via its index. As far as I can tell, most of the code already does this. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
e237f29fb2
commit
284582d2e8
54 changed files with 738 additions and 893 deletions
|
@ -214,7 +214,7 @@ static int shearwater_mode(void *param, int, char **data, char **)
|
|||
struct parser_state *state = (struct parser_state *)param;
|
||||
|
||||
if (data[0])
|
||||
state->cur_dive->dc.divemode = atoi(data[0]) == 0 ? CCR : OC;
|
||||
state->cur_dive->dcs[0].divemode = atoi(data[0]) == 0 ? CCR : OC;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -249,13 +249,13 @@ static int shearwater_dive(void *param, int, char **data, char **)
|
|||
|
||||
/* TODO: verify that metric calculation is correct */
|
||||
if (data[6])
|
||||
state->cur_dive->dc.maxdepth.mm = state->metric ? lrint(permissive_strtod(data[6], NULL) * 1000) : feet_to_mm(permissive_strtod(data[6], NULL));
|
||||
state->cur_dive->dcs[0].maxdepth.mm = state->metric ? lrint(permissive_strtod(data[6], NULL) * 1000) : feet_to_mm(permissive_strtod(data[6], NULL));
|
||||
|
||||
if (data[7])
|
||||
state->cur_dive->dc.duration.seconds = atoi(data[7]) * 60;
|
||||
state->cur_dive->dcs[0].duration.seconds = atoi(data[7]) * 60;
|
||||
|
||||
if (data[8])
|
||||
state->cur_dive->dc.surface_pressure.mbar = atoi(data[8]);
|
||||
state->cur_dive->dcs[0].surface_pressure.mbar = atoi(data[8]);
|
||||
/*
|
||||
* TODO: the deviceid hash should be calculated here.
|
||||
*/
|
||||
|
@ -285,13 +285,13 @@ static int shearwater_dive(void *param, int, char **data, char **)
|
|||
if (data[10]) {
|
||||
switch (atoi(data[10])) {
|
||||
case 2:
|
||||
state->cur_dive->dc.model = "Shearwater Petrel/Perdix";
|
||||
state->cur_dive->dcs[0].model = "Shearwater Petrel/Perdix";
|
||||
break;
|
||||
case 4:
|
||||
state->cur_dive->dc.model = "Shearwater Predator";
|
||||
state->cur_dive->dcs[0].model = "Shearwater Predator";
|
||||
break;
|
||||
default:
|
||||
state->cur_dive->dc.model = "Shearwater import";
|
||||
state->cur_dive->dcs[0].model = "Shearwater import";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -379,13 +379,13 @@ static int shearwater_cloud_dive(void *param, int, char **data, char **)
|
|||
|
||||
/* TODO: verify that metric calculation is correct */
|
||||
if (data[6])
|
||||
state->cur_dive->dc.maxdepth.mm = state->metric ? lrint(permissive_strtod(data[6], NULL) * 1000) : feet_to_mm(permissive_strtod(data[6], NULL));
|
||||
state->cur_dive->dcs[0].maxdepth.mm = state->metric ? lrint(permissive_strtod(data[6], NULL) * 1000) : feet_to_mm(permissive_strtod(data[6], NULL));
|
||||
|
||||
if (data[7])
|
||||
state->cur_dive->dc.duration.seconds = atoi(data[7]);
|
||||
state->cur_dive->dcs[0].duration.seconds = atoi(data[7]);
|
||||
|
||||
if (data[8])
|
||||
state->cur_dive->dc.surface_pressure.mbar = atoi(data[8]);
|
||||
state->cur_dive->dcs[0].surface_pressure.mbar = atoi(data[8]);
|
||||
/*
|
||||
* TODO: the deviceid hash should be calculated here.
|
||||
*/
|
||||
|
@ -415,13 +415,13 @@ static int shearwater_cloud_dive(void *param, int, char **data, char **)
|
|||
if (data[10]) {
|
||||
switch (atoi(data[10])) {
|
||||
case 2:
|
||||
state->cur_dive->dc.model = "Shearwater Petrel/Perdix";
|
||||
state->cur_dive->dcs[0].model = "Shearwater Petrel/Perdix";
|
||||
break;
|
||||
case 4:
|
||||
state->cur_dive->dc.model = "Shearwater Predator";
|
||||
state->cur_dive->dcs[0].model = "Shearwater Predator";
|
||||
break;
|
||||
default:
|
||||
state->cur_dive->dc.model = "Shearwater import";
|
||||
state->cur_dive->dcs[0].model = "Shearwater import";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue