mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Implement get_divemode() to find the divemode at a particular time
Replaced a rather cumbersome function that that did the above. Upon the suggestion of Robert Helling who proposed a much shorter way, this new function replaced the previous ones. This necessitated changes to divelist.c, profile.c and plannernotes.c, as well as dive.c/h. Signed-off-by: Willem Ferguson <willemferguson@zoology.up.ac.za>
This commit is contained in:
parent
b9174332d5
commit
cad4eb39c4
5 changed files with 28 additions and 62 deletions
|
@ -539,10 +539,8 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
bool o2warning_exist = false;
|
||||
enum dive_comp_type current_divemode;
|
||||
double amb;
|
||||
struct event *nextev, *evd = dive->dc.events;
|
||||
|
||||
current_divemode = dive->dc.divemode;
|
||||
nextev = get_next_divemodechange(&evd, TRUE);
|
||||
struct event *evd = NULL;
|
||||
current_divemode = UNDEF_COMP_TYPE;
|
||||
|
||||
if (dive->dc.divemode != CCR) {
|
||||
while (dp) {
|
||||
|
@ -550,11 +548,7 @@ void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_d
|
|||
struct gas_pressures pressures;
|
||||
struct gasmix *gasmix = &dive->cylinder[dp->cylinderid].gasmix;
|
||||
|
||||
if (nextev && (dp->time >= nextev->time.seconds)) { // If there are divemode changes and divedatapoint time
|
||||
current_divemode = nextev->divemode; // has reached that of the current divemode event, then set the
|
||||
nextev = get_next_divemodechange(&evd, TRUE); // current divemode and find the next divemode event
|
||||
}
|
||||
|
||||
current_divemode = get_current_divemode(&dive->dc, dp->time, &evd, ¤t_divemode);
|
||||
amb = depth_to_atm(dp->depth.mm, dive);
|
||||
fill_pressures(&pressures, amb, gasmix, (current_divemode == OC) ? 0.0 : amb * gasmix->o2.permille / 1000.0, current_divemode);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue