diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-01-07 16:21:26 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-07 16:22:38 -0800 |
commit | 7a18edddbbbfa82ba44035557618c92e4535a6de (patch) | |
tree | b149e421a94634f0774c2d75e5bb03c39f34f4cc /planner.c | |
parent | 7e1f0d243bc7e73e9c9f479f5993a6a61ecfd65a (diff) | |
download | subsurface-7a18edddbbbfa82ba44035557618c92e4535a6de.tar.gz |
Prevent time travel in planner dive edit
If the user enters an absolute time that is before the previous waypoint,
silently assume that this is a relative time.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'planner.c')
-rw-r--r-- | planner.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -218,9 +218,10 @@ struct divedatapoint *get_nth_dp(struct diveplan *diveplan, int idx) void add_duration_to_nth_dp(struct diveplan *diveplan, int idx, int duration, gboolean is_rel) { struct divedatapoint *pdp, *dp = get_nth_dp(diveplan, idx); - if (idx > 0 && is_rel) { + if (idx > 0) { pdp = get_nth_dp(diveplan, idx - 1); - duration += pdp->time; + if (is_rel || dp->time <= pdp->time) + duration += pdp->time; } dp->time = duration; } |