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
|
@ -116,13 +116,13 @@ static void save_dive_temperature(struct membuffer *b, struct dive *dive)
|
|||
{
|
||||
if (!dive->airtemp.mkelvin && !dive->watertemp.mkelvin)
|
||||
return;
|
||||
if (dive->airtemp.mkelvin == dc_airtemp(&dive->dc) && dive->watertemp.mkelvin == dc_watertemp(&dive->dc))
|
||||
if (dive->airtemp.mkelvin == dc_airtemp(dive).mkelvin && dive->watertemp.mkelvin == dc_watertemp(dive).mkelvin)
|
||||
return;
|
||||
|
||||
put_string(b, " <divetemperature");
|
||||
if (dive->airtemp.mkelvin != dc_airtemp(&dive->dc))
|
||||
if (dive->airtemp.mkelvin != dc_airtemp(dive).mkelvin)
|
||||
put_temperature(b, dive->airtemp, " air='", " C'");
|
||||
if (dive->watertemp.mkelvin != dc_watertemp(&dive->dc))
|
||||
if (dive->watertemp.mkelvin != dc_watertemp(dive).mkelvin)
|
||||
put_temperature(b, dive->watertemp, " water='", " C'");
|
||||
put_string(b, "/>\n");
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ static void save_dc(struct membuffer *b, struct dive *dive, struct divecomputer
|
|||
put_format(b, " diveid='%08x'", dc->diveid);
|
||||
if (dc->when && dc->when != dive->when)
|
||||
show_date(b, dc->when);
|
||||
if (dc->duration.seconds && dc->duration.seconds != dive->dc.duration.seconds)
|
||||
if (dc->duration.seconds && dc->duration.seconds != dive->dcs[0].duration.seconds)
|
||||
put_duration(b, dc->duration, " duration='", " min'");
|
||||
if (dc->divemode != OC) {
|
||||
int i = (int)dc->divemode;
|
||||
|
@ -490,7 +490,6 @@ static void save_picture(struct membuffer *b, struct picture *pic)
|
|||
|
||||
void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize)
|
||||
{
|
||||
struct divecomputer *dc;
|
||||
pressure_t surface_pressure = un_fixup_surface_pressure(dive);
|
||||
|
||||
put_string(b, "<dive");
|
||||
|
@ -530,9 +529,9 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize)
|
|||
show_date(b, dive->when);
|
||||
if (surface_pressure.mbar)
|
||||
put_pressure(b, surface_pressure, " airpressure='", " bar'");
|
||||
if (dive->dc.duration.seconds > 0)
|
||||
if (dive->dcs[0].duration.seconds > 0)
|
||||
put_format(b, " duration='%u:%02u min'>\n",
|
||||
FRACTION_TUPLE(dive->dc.duration.seconds, 60));
|
||||
FRACTION_TUPLE(dive->dcs[0].duration.seconds, 60));
|
||||
else
|
||||
put_format(b, ">\n");
|
||||
save_overview(b, dive, anonymize);
|
||||
|
@ -540,8 +539,8 @@ void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize)
|
|||
save_weightsystem_info(b, dive);
|
||||
save_dive_temperature(b, dive);
|
||||
/* Save the dive computer data */
|
||||
for_each_dc(dive, dc)
|
||||
save_dc(b, dive, dc);
|
||||
for (auto &dc: dive->dcs)
|
||||
save_dc(b, dive, &dc);
|
||||
FOR_EACH_PICTURE(dive)
|
||||
save_picture(b, picture);
|
||||
put_format(b, "</dive>\n");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue