From: ian Date: Sun, 13 Feb 2005 11:32:19 +0000 (+0000) Subject: wip; before get rid of all separate detections X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=175f35014bc922361efa36225304e7b50e72583c;p=trains.git wip; before get rid of all separate detections --- diff --git a/hostside/safety.c b/hostside/safety.c index 5969300..d0f51c9 100644 --- a/hostside/safety.c +++ b/hostside/safety.c @@ -6,17 +6,25 @@ State safety_actual; -typedef struct TrackFollow TrackFollow; -struct TrackFollow { +typedef struct TrackLocation TrackLocation; +struct TrackLocation { + SegmentIx segi; /* current segment */ + Distance into; /* distance from start of segment */ + unsigned backwards:1; /* if 1, into is positive and measured from end */ }; -void trackfollow_begin(TrackFollow*, SegmentIx begin, unsigned backwards, - Distance); - +void trackfollow_further(TrackLocation *tloc, Distance *remain_io); + /* Advances tloc, decrementing *remain_io, until either + * *remain_io becomes zero, or tloc->segi changes. */ void safety_train_changed(TrainIx trai) { State *s = &safety_actual; TrainState *tra = s->tras[trai]; + TrackLocation tloc; + + tloc.segi= tra->foredetect; + tloc.into= tra->justarrived ? JUSTARRIVED_DIST : + for (segi = s->trais[trai]