neednewplan:1,
stopping:1,
done_first_new_fdet:1,
- usecurrentposn:1, /* for pred_getmovpos */
+ usecurrentposn:1, /* for {pred,report}_getmovpos */
optimistic:1, /* for autopoint */
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 */
- alwaysusemotions:1; /* for report_train_ownerships, uses ->motion */
+ know_best_polarity:1; /* longest-lasting into the future */
TrackLocation nose, fdet, tail;
TrackAdvanceContext nosec, tailc, fdetc;
TimeInterval elapsed; /* from now, minimum */
static int pred_getmovpos(TrackLocation *t, TrackAdvanceContext *c,
MovPosComb *use_io) {
PredictUserContext *u= c->u;
- if (u->usecurrentposn) return 0;
- if (u->alwaysusemotions) {
- if (t->seg->motion)
- *use_io= movpos_change_intent(t->seg->motion);
- } else if (t->seg->moving || t->seg->pred_vacated) {
- if (t->seg->motion_newplan)
- *use_io= movpos_change_intent(t->seg->motion_newplan);
- }
+ if (!u->usecurrentposn &&
+ !t->seg->now_present &&
+ t->seg->motion_newplan)
+ *use_io= movpos_change_intent(t->seg->motion_newplan);
if (*use_io<0) safety_panic(u->train, t->seg,
"track route unexpectedly not known");
return 0;
}
}
+ int autopoint= u->train->autopoint && t->seg->autopoint;
+
if (t->seg->motion_newplan) {
route_plan= movpos_change_intent(t->seg->motion);
*mpc_io= route_plan;
if (route_plan != u->desire_movposcomb)
return predict_problem(u, t->seg, " proposed route would be against"
" approaching train");
+ autopoint= 1;
} else if (t->seg->motion) {
/* We already have a plan. */
route_plan= movpos_change_intent(t->seg->motion);
max_ms= u->elapsed;
}
- if (!u->train->autopoint || !t->seg->autopoint)
+ if (!autopoint)
return predict_problem(u,t->seg,"will not automatically set route");
ec= movpos_reserve(t->seg, max_ms, &t->seg->motion_newplan,
u.desire_movposcomb= desire_movposcomb;
oprintf(DUPO("safety") " predict ***starting*** %s%s maxspeed=%f"
- " (speed %f try %f, step %d%s) stopdist=%d flags=%c%c"
- " desire=%s/%s %s\n",
+ " (speed %f try %f, step %d%s) stopdist=%d flags=%c%c%s"
+ " desire=%s/%s\n",
tra->backwards?"-":"",tra->pname,
u.maxspeed, tra->speed.speed, tra->speed.try_speed, tra->speed.step,
tra->speed.decel.running ? " decel" : "",
tra->foredetect->i->pname, tra->maxinto, tra->uncertainty);
}
+static int report_getmovpos(TrackLocation *t, TrackAdvanceContext *c,
+ MovPosComb *use_io) {
+ PredictUserContext *u= c->u;
+ if (!u->usecurrentposn && t->seg->motion)
+ *use_io= movpos_change_intent(t->seg->motion);
+ assert(*use_io>=0);
+ return 0;
+}
+
static int report_nextseg(TrackLocation *t, struct TrackAdvanceContext *c,
MovPosComb *mpc, const TrackLocation *before) {
PredictUserContext *u= c->u;
char flags[6];
int r;
- if (u->alwaysusemotions) /* we've had foredetect */
+ if (!u->usecurrentposn) /* we've had foredetect */
if (++u->lookahead > u->train->plan_lookahead_nsegs)
return -1;
if (t->seg == u->train->foredetect) {
strcat(flags,"!");
u->usecurrentposn= 0;
- u->alwaysusemotions= 1;
}
oprintf(UPO," %s%s", t->backwards?"-":"", t->seg->i->pname);
if (t->seg->i->n_poscombs > 1) {
- r= pred_getmovpos(t,c,mpc); assert(!r); assert(*mpc>=0);
+ r= report_getmovpos(t,c,mpc); assert(!r); assert(*mpc>=0);
oprintf(UPO,"/%s", t->seg->i->poscombs[*mpc].pname);
}
oprintf(UPO,"%s",flags);
memset(&u,0,sizeof(u));
u.train= tra;
u.hindmost= 0;
- u.alwaysusemotions= always_use_motions;
u.usecurrentposn= !always_use_motions;
/* Walk along the train printing its segments: */
u.nosec.distance= TL_DIST_INF;;
u.nosec.nextseg= report_nextseg;
- u.nosec.getmovpos= pred_getmovpos;
+ u.nosec.getmovpos= report_getmovpos;
u.nosec.u= &u;
u.hindmost= hindmost;