mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: small cleanup concerning depth_t
Operate directly on depth_t instead of working with the base type. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
c9cb83d6b0
commit
b53cb559ec
2 changed files with 5 additions and 6 deletions
|
@ -490,7 +490,7 @@ static int sac_between(const struct dive *dive, const struct plot_info &pi, int
|
||||||
do {
|
do {
|
||||||
const struct plot_data &entry = pi.entry[first];
|
const struct plot_data &entry = pi.entry[first];
|
||||||
const struct plot_data &next = pi.entry[first + 1];
|
const struct plot_data &next = pi.entry[first + 1];
|
||||||
depth_t depth { .mm = (entry.depth.mm + next.depth.mm) / 2 };
|
depth_t depth = (entry.depth + next.depth) / 2;
|
||||||
int time = next.sec - entry.sec;
|
int time = next.sec - entry.sec;
|
||||||
double atm = dive->depth_to_atm(depth);
|
double atm = dive->depth_to_atm(depth);
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,7 @@ void DivePlannerPointsModel::loadFromDive(dive *dIn, int dcNrIn)
|
||||||
d = dIn;
|
d = dIn;
|
||||||
dcNr = dcNrIn;
|
dcNr = dcNrIn;
|
||||||
|
|
||||||
int depthsum = 0;
|
depth_t depthsum;
|
||||||
int samplecount = 0;
|
int samplecount = 0;
|
||||||
o2pressure_t last_sp;
|
o2pressure_t last_sp;
|
||||||
struct divecomputer *dc = d->get_dc(dcNr);
|
struct divecomputer *dc = d->get_dc(dcNr);
|
||||||
|
@ -157,7 +157,7 @@ void DivePlannerPointsModel::loadFromDive(dive *dIn, int dcNrIn)
|
||||||
while (j * plansamples <= i * static_cast<int>(dc->samples.size())) {
|
while (j * plansamples <= i * static_cast<int>(dc->samples.size())) {
|
||||||
const sample &s = dc->samples[j];
|
const sample &s = dc->samples[j];
|
||||||
if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) {
|
if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) {
|
||||||
depthsum += s.depth.mm;
|
depthsum += s.depth;
|
||||||
if (j > 0)
|
if (j > 0)
|
||||||
last_sp = dc->samples[j-1].setpoint;
|
last_sp = dc->samples[j-1].setpoint;
|
||||||
++samplecount;
|
++samplecount;
|
||||||
|
@ -173,12 +173,11 @@ void DivePlannerPointsModel::loadFromDive(dive *dIn, int dcNrIn)
|
||||||
if (newtime.seconds == lastrecordedtime.seconds)
|
if (newtime.seconds == lastrecordedtime.seconds)
|
||||||
newtime.seconds += 10;
|
newtime.seconds += 10;
|
||||||
divemode_t current_divemode = loop.at(newtime.seconds - 1);
|
divemode_t current_divemode = loop.at(newtime.seconds - 1);
|
||||||
depth_t depth { .mm = depthsum / samplecount };
|
addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true, current_divemode);
|
||||||
addStop(depth, newtime.seconds, cylinderid, last_sp.mbar, true, current_divemode);
|
|
||||||
lastrecordedtime = newtime;
|
lastrecordedtime = newtime;
|
||||||
}
|
}
|
||||||
lasttime = newtime;
|
lasttime = newtime;
|
||||||
depthsum = 0;
|
depthsum = 0_m;
|
||||||
samplecount = 0;
|
samplecount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue