From 7e6add73e2e7e3ce25757042cd7a0f424d70d50e Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 8 Jun 2008 11:44:27 +0000 Subject: [PATCH] get stopping distance right in !u.stopping case --- hostside/safety.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hostside/safety.c b/hostside/safety.c index 485b639..0f2500f 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -793,14 +793,17 @@ ErrorCode predict(Train *tra, struct timeval tnow, unsigned flags, u.fdetc.trackend= pred_trackend; u.tailc.nextseg= tail_nextseg; - if ((flags & PREDF_JUSTDET) && u.stopping) { + if (!u.stopping) { + /* we're carrying on until the next segment */ + u.fdetc.distance= u.fdet.remain; + } else if (flags & PREDF_JUSTDET) { /* we actually know exactly where we are */ - u.fdetc.distance= u.stopping_distance; - } else { - u.fdetc.distance= tra->uncertainty + u.stopping_distance; - u.elapsed= -tra->uncertainty / u.maxspeed; + u.fdetc.distance= 0; + } else { /* stopping, but we're mid-segment */ + u.fdetc.distance= tra->uncertainty; } - u.fdetc.distance += MARGIN_NOSE; + u.elapsed= -u.fdetc.distance / u.maxspeed; /* imagine we're already there */ + u.fdetc.distance += u.stopping_distance + MARGIN_NOSE; u.was_distance= u.fdetc.distance; ec= trackloc_advance(&u.fdet,&u.fdetc); -- 2.30.2