Previously we would attempt to sort out Segment.tr_backwards in
resmain_getmovpos. This is wrong because *_getmovpos shouldn't have
that kind of side-effect.
Furthermore the actual code was wrong: it wasn't idempotent: the
number of times tr_backwards would be inverted for a backwards train
would depend on how many times resmain_getmovpos was called.
Actually, for backwards trains not resolving at home, there is no need
to mess with tr_backwards. The existing tr_backwards for the segments
it owns is fine. For trains resolving at home, we need to explicitly
clear the train's direction too, and we should do this in a dedicated
piece of code.
Fixes:
@2011-01-10 20:28:23 GMT info save-dump +dump.2011-01-10T20-28-23+0000
traversed santafe forwards from B8 to B7 when B7/J1
-@2011-01-10 20:28:23 GMT info save-dump +dump.2011-01-10T20-28-23+0000
- traversed santafe forwards from B8 to B7 when B7/J1
-
@2011-01-10 22:42:18 GMT info save-dump +dump.2011-01-10T22-42-18+0000
shinkansen 2nd bogie only derailed at B9, running anticlockwise
first bogie went correctly to C9; 2nd bogie appears to
@2011-01-10 22:42:18 GMT info save-dump +dump.2011-01-10T22-42-18+0000
shinkansen 2nd bogie only derailed at B9, running anticlockwise
first bogie went correctly to C9; 2nd bogie appears to
const char *pn= d->i->pname;
if (d->home && d->home->resolution == RR_H) {
const char *pn= d->i->pname;
if (d->home && d->home->resolution == RR_H) {
- d->tr_backwards= d->ho_backwards;
*use_io= 0; /* a bit kludgey */
DPRINTF(resolving,main, "getmovpos %s H\n", pn);
} else if (d->owner) {
*use_io= 0; /* a bit kludgey */
DPRINTF(resolving,main, "getmovpos %s H\n", pn);
} else if (d->owner) {
- d->tr_backwards ^= d->owner->backwards;
*use_io= d->movposcomb;
DPRINTF(resolving,main, "getmovpos %s E %d\n", pn, *use_io);
} else if (!d->res_movposset) {
*use_io= d->movposcomb;
DPRINTF(resolving,main, "getmovpos %s E %d\n", pn, *use_io);
} else if (!d->res_movposset) {
+
+ FOR_TRAIN(t,NOOP,NOOP) {
+ if (t->resolution == RR_H)
+ t->backwards= 0;
+ }
+ FOR_SEGMENT(d,NOOP,NOOP) {
+ if (d->home && d->home->resolution == RR_H)
+ d->tr_backwards= d->ho_backwards;
+ }
TrackAdvanceContext tac;
MovPosComb target;
TrackAdvanceContext tac;
MovPosComb target;