diff options
author | Rick Walsh <rickmwalsh@gmail.com> | 2015-08-30 21:35:09 +1000 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-08-30 16:55:17 -0700 |
commit | 9238a7f0dfccfe97bc0bf0bba983fadf70035c48 (patch) | |
tree | 5bf929715c3020e58fddee1c11a01a84f90d7845 /profile.c | |
parent | 6d7faa106faa37b887d24fb18b538a34521f1710 (diff) | |
download | subsurface-9238a7f0dfccfe97bc0bf0bba983fadf70035c48.tar.gz |
Profile.c: Fix stepping through loop between sample points
If adjacent samples at times t0 and t1 are greater than time_stepsize apart,
this for loop steps through the time between samples to calculate tissue
tolerance incrementally at each intermediate time, j, (and interpolated depth).
If the difference between t1 and t0 is not a multiple of time_stepsize,
immediately before the final increment time_stepsize needs to be reduced to
t1 - j so that j = t1 in the final increment.
This is necessary when:
t1 - j < time_stepsize (i.e. we are about to start the final
increment, and time_stepsize needs to be
reduced), and
j < t1 (i.e. we didn't just do the final increment -
without this condition time_stepsize would be
set to zero, leading to an infinite loop)
Previously, the check was (j - t0 < time_stepsize), which always returns false.
Signed-off-by: Rick Walsh <rickmwalsh@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r-- | profile.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -857,8 +857,8 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru double min_pressure = add_segment(depth_to_mbar(depth, dive) / 1000.0, &dive->cylinder[entry->cylinderindex].gasmix, time_stepsize, entry->o2pressure.mbar, dive, entry->sac); tissue_tolerance = min_pressure; - if (j - t0 < time_stepsize) - time_stepsize = j - t0; + if ((t1 - j < time_stepsize) && (j < t1)) + time_stepsize = t1 - j; } if (t0 == t1) entry->ceiling = (entry - 1)->ceiling; |