mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
Refactoring: Use core functions to find gasmixes in TankItem.
Small refactoring to use `get_gasmix_at_time` from `core` in `TankItem` to find the first gasmix used during a dive. Signed-off-by: Michael Keller <github@ike.ch>
This commit is contained in:
parent
72c40a18c2
commit
a92ee1e05d
1 changed files with 4 additions and 10 deletions
|
@ -79,16 +79,10 @@ void TankItem::setData(const struct dive *d, const struct divecomputer *dc, int
|
||||||
if (d->cylinders.nr <= 0)
|
if (d->cylinders.nr <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// start with the first gasmix and at the start of the dive
|
// start with the first gasmix and at the start of the plotted range
|
||||||
int cyl = explicit_first_cylinder(d, dc);
|
const struct event *ev = NULL;
|
||||||
struct gasmix gasmix = get_cylinder(d, cyl)->gasmix;
|
struct gasmix gasmix = gasmix_air;
|
||||||
|
gasmix = get_gasmix(d, dc, plotStartTime, &ev, gasmix);
|
||||||
// skip over all gas changes before the plotted range
|
|
||||||
const struct event *ev = get_next_event(dc->events, "gaschange");
|
|
||||||
while (ev && (int)ev->time.seconds <= plotStartTime) {
|
|
||||||
gasmix = get_gasmix_from_event(d, ev);
|
|
||||||
ev = get_next_event(ev->next, "gaschange");
|
|
||||||
}
|
|
||||||
|
|
||||||
// work through all the gas changes and add the rectangle for each gas while it was used
|
// work through all the gas changes and add the rectangle for each gas while it was used
|
||||||
int startTime = plotStartTime;
|
int startTime = plotStartTime;
|
||||||
|
|
Loading…
Reference in a new issue