From f4b6fc17a0314cfbcba68547fd90c0f287e3e1f8 Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 8 Jun 2008 00:47:25 +0000 Subject: [PATCH] get initial resolution more right --- hostside/resolve.c | 7 ++++++- hostside/safety.c | 7 +++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/hostside/resolve.c b/hostside/resolve.c index 87947d0..c041cc6 100644 --- a/hostside/resolve.c +++ b/hostside/resolve.c @@ -428,7 +428,11 @@ static int findhead_nextseg(TrackLocation *t, struct TrackAdvanceContext *c, t->seg->tr_backwards= t->backwards; t->seg->resfin_done= 1; - if (!t->seg->res_detect) { u->extraspace= 0; return -1; } + if (!t->seg->res_detect) { + u->train->plan_lookahead_nsegs= 1; + u->extraspace= 0; + return -1; + } u->train->foredetect= t->seg; return 0; } @@ -477,6 +481,7 @@ static int resolve_complete_ends_train(Train *tra) { t.backwards= t.seg->tr_backwards ^ tra->backwards; tra->backwards= 0; + tra->plan_lookahead_nsegs= 0; tc.distance= TL_DIST_INF; tc.nextseg= findhead_nextseg; diff --git a/hostside/safety.c b/hostside/safety.c index e67f85a..485b639 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -271,7 +271,8 @@ typedef struct { walk_compute_polarise:1, /* nose_nextseg still needs to worry */ need_polarise:1, /* when we commit */ train_polarity_inverted:1, /* right now, or if know_best, the best */ - know_best_polarity:1; /* longest-lasting into the future */ + know_best_polarity:1, /* longest-lasting into the future */ + done_fdet:1; /* for report_nextseg */ TrackLocation nose, fdet, tail; TrackAdvanceContext nosec, tailc, fdetc; TimeInterval elapsed; /* from now, minimum */ @@ -987,7 +988,7 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c, char flags[6]; int r; - if (!u->usecurrentposn) /* we've had foredetect */ + if (u->done_fdet) /* we've had foredetect */ if (++u->lookahead > u->train->plan_lookahead_nsegs) return -1; @@ -1000,6 +1001,7 @@ static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c, if (t->seg == u->train->foredetect) { strcat(flags,"!"); u->usecurrentposn= 0; + u->done_fdet= 1; } ouprintf(" %s%s", t->backwards?"-":"", t->seg->i->pname); @@ -1021,6 +1023,7 @@ void report_train_ownerships(Train *tra, Segment *hindmost, u.train= tra; u.hindmost= 0; u.usecurrentposn= !always_use_motions; + u.done_fdet= 0; /* Walk along the train printing its segments: */ ouprintf("train %s has", tra->pname); -- 2.30.2