summaryrefslogtreecommitdiffstats
path: root/core/plannernotes.c
diff options
context:
space:
mode:
authorGravatar Willem Ferguson <willemferguson@zoology.up.ac.za>2018-04-07 17:52:16 +0200
committerGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-05-14 23:47:00 +0300
commitcad4eb39c4ac0a46dbaab6932e9319704eb90e6d (patch)
treec9b1ff2298a5b4ec9684ee5b338f1e7110a66b12 /core/plannernotes.c
parentb9174332d562b8b9c436a94880c51acf2c5ab761 (diff)
downloadsubsurface-cad4eb39c4ac0a46dbaab6932e9319704eb90e6d.tar.gz
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>
Diffstat (limited to 'core/plannernotes.c')
-rw-r--r--core/plannernotes.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/core/plannernotes.c b/core/plannernotes.c
index 4d70b9af9..9927ad26a 100644
--- a/core/plannernotes.c
+++ b/core/plannernotes.c
@@ -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, &current_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);