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
|
@ -191,7 +191,7 @@ static int dm4_dive(void *param, int, char **data, char **)
|
|||
if (data[3])
|
||||
state->cur_dive->duration.seconds = atoi(data[3]);
|
||||
if (data[15])
|
||||
state->cur_dive->dc.duration.seconds = atoi(data[15]);
|
||||
state->cur_dive->dcs[0].duration.seconds = atoi(data[15]);
|
||||
|
||||
/*
|
||||
* TODO: the deviceid hash should be calculated here.
|
||||
|
@ -208,11 +208,11 @@ static int dm4_dive(void *param, int, char **data, char **)
|
|||
settings_end(state);
|
||||
|
||||
if (data[6])
|
||||
state->cur_dive->dc.maxdepth.mm = lrint(permissive_strtod(data[6], NULL) * 1000);
|
||||
state->cur_dive->dcs[0].maxdepth.mm = lrint(permissive_strtod(data[6], NULL) * 1000);
|
||||
if (data[8])
|
||||
state->cur_dive->dc.airtemp.mkelvin = C_to_mkelvin(atoi(data[8]));
|
||||
state->cur_dive->dcs[0].airtemp.mkelvin = C_to_mkelvin(atoi(data[8]));
|
||||
if (data[9])
|
||||
state->cur_dive->dc.watertemp.mkelvin = C_to_mkelvin(atoi(data[9]));
|
||||
state->cur_dive->dcs[0].watertemp.mkelvin = C_to_mkelvin(atoi(data[9]));
|
||||
|
||||
/*
|
||||
* TODO: handle multiple cylinders
|
||||
|
@ -237,7 +237,7 @@ static int dm4_dive(void *param, int, char **data, char **)
|
|||
cylinder_end(state);
|
||||
|
||||
if (data[14])
|
||||
state->cur_dive->dc.surface_pressure.mbar = (atoi(data[14]) * 1000);
|
||||
state->cur_dive->dcs[0].surface_pressure.mbar = (atoi(data[14]) * 1000);
|
||||
|
||||
interval = data[16] ? atoi(data[16]) : 0;
|
||||
profileBlob = (float *)data[17];
|
||||
|
@ -249,7 +249,7 @@ static int dm4_dive(void *param, int, char **data, char **)
|
|||
if (profileBlob)
|
||||
state->cur_sample->depth.mm = lrintf(profileBlob[i] * 1000.0f);
|
||||
else
|
||||
state->cur_sample->depth.mm = state->cur_dive->dc.maxdepth.mm;
|
||||
state->cur_sample->depth.mm = state->cur_dive->dcs[0].maxdepth.mm;
|
||||
|
||||
if (data[18] && data[18][0])
|
||||
state->cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
|
||||
|
@ -372,7 +372,7 @@ static int dm5_dive(void *param, int, char **data, char **)
|
|||
if (data[3])
|
||||
state->cur_dive->duration.seconds = atoi(data[3]);
|
||||
if (data[15])
|
||||
state->cur_dive->dc.duration.seconds = atoi(data[15]);
|
||||
state->cur_dive->dcs[0].duration.seconds = atoi(data[15]);
|
||||
|
||||
/*
|
||||
* TODO: the deviceid hash should be calculated here.
|
||||
|
@ -390,28 +390,28 @@ static int dm5_dive(void *param, int, char **data, char **)
|
|||
settings_end(state);
|
||||
|
||||
if (data[6])
|
||||
state->cur_dive->dc.maxdepth.mm = lrint(permissive_strtod(data[6], NULL) * 1000);
|
||||
state->cur_dive->dcs[0].maxdepth.mm = lrint(permissive_strtod(data[6], NULL) * 1000);
|
||||
if (data[8])
|
||||
state->cur_dive->dc.airtemp.mkelvin = C_to_mkelvin(atoi(data[8]));
|
||||
state->cur_dive->dcs[0].airtemp.mkelvin = C_to_mkelvin(atoi(data[8]));
|
||||
if (data[9])
|
||||
state->cur_dive->dc.watertemp.mkelvin = C_to_mkelvin(atoi(data[9]));
|
||||
state->cur_dive->dcs[0].watertemp.mkelvin = C_to_mkelvin(atoi(data[9]));
|
||||
|
||||
if (data[4]) {
|
||||
state->cur_dive->dc.deviceid = atoi(data[4]);
|
||||
state->cur_dive->dcs[0].deviceid = atoi(data[4]);
|
||||
}
|
||||
if (data[5])
|
||||
utf8_string_std(data[5], &state->cur_dive->dc.model);
|
||||
utf8_string_std(data[5], &state->cur_dive->dcs[0].model);
|
||||
|
||||
if (data[25]) {
|
||||
switch(atoi(data[25])) {
|
||||
case 1:
|
||||
state->cur_dive->dc.divemode = OC;
|
||||
state->cur_dive->dcs[0].divemode = OC;
|
||||
break;
|
||||
case 5:
|
||||
state->cur_dive->dc.divemode = CCR;
|
||||
state->cur_dive->dcs[0].divemode = CCR;
|
||||
break;
|
||||
default:
|
||||
state->cur_dive->dc.divemode = OC;
|
||||
state->cur_dive->dcs[0].divemode = OC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ static int dm5_dive(void *param, int, char **data, char **)
|
|||
}
|
||||
|
||||
if (data[14])
|
||||
state->cur_dive->dc.surface_pressure.mbar = (atoi(data[14]) / 100);
|
||||
state->cur_dive->dcs[0].surface_pressure.mbar = (atoi(data[14]) / 100);
|
||||
|
||||
interval = data[16] ? atoi(data[16]) : 0;
|
||||
|
||||
|
@ -512,7 +512,7 @@ static int dm5_dive(void *param, int, char **data, char **)
|
|||
if (profileBlob)
|
||||
state->cur_sample->depth.mm = lrintf(profileBlob[i] * 1000.0f);
|
||||
else
|
||||
state->cur_sample->depth.mm = state->cur_dive->dc.maxdepth.mm;
|
||||
state->cur_sample->depth.mm = state->cur_dive->dcs[0].maxdepth.mm;
|
||||
|
||||
if (data[18] && data[18][0])
|
||||
state->cur_sample->temperature.mkelvin = C_to_mkelvin(tempBlob[i]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue