From 7a18edddbbbfa82ba44035557618c92e4535a6de Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 7 Jan 2013 16:21:26 -0800 Subject: 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 --- planner.c | 5 +++-- 1 file 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; } -- cgit v1.2.3-70-g09d2