summaryrefslogtreecommitdiffstats
path: root/planner.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-07 16:21:26 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-07 16:22:38 -0800
commit7a18edddbbbfa82ba44035557618c92e4535a6de (patch)
treeb149e421a94634f0774c2d75e5bb03c39f34f4cc /planner.c
parent7e1f0d243bc7e73e9c9f479f5993a6a61ecfd65a (diff)
downloadsubsurface-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.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/planner.c b/planner.c
index 52066d673..683fbef42 100644
--- a/planner.c
+++ b/planner.c
@@ -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;
}