X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=blobdiff_plain;f=hostside%2Fmovpos.c;fp=hostside%2Fmovpos.c;h=a31e507b8f806cb84f57655898ecbcda3734f0be;hb=d88accfec332940000f3f0341fa51b99739823d3;hp=6388d5316e9a16c44d1c7e598e6e82f0e073d272;hpb=29f3e8fa5819a9b8ff931676a99b65cc9b2898be;p=trains.git diff --git a/hostside/movpos.c b/hostside/movpos.c index 6388d53..a31e507 100644 --- a/hostside/movpos.c +++ b/hostside/movpos.c @@ -108,6 +108,9 @@ struct Method { /*========== general utility functions ==========*/ +static UnkMap unkfeatbit(int featix) { return (UnkMap)1 << featix; } +static UnkMap unkallfeatbits(int nfeats) { return ~(~(UnkMap)0 << nfeats); } + const char *movpos_pname(const Segment *move, MovPosComb poscomb) { return !SOMEP(poscomb) ? "?" : move->i->poscombs[poscomb].pname; } @@ -709,7 +712,7 @@ static void method_update_feature(Method *m, MovPosChange *indep, ouposn_feat(indep->move, mo->i, mo->posn, m); indep->actualpos= movposcomb_update_feature(indep->actualpos, mo->i, mo->posn); - indep->actualunk &= (~(UnkMap)1 << featix); + indep->actualunk &= ~unkfeatbit(featix); ouposn_moving(indep); } @@ -760,7 +763,7 @@ static int change_needed(int featix, const MovFeatInfo *feati, MovPosComb target) { int r; - r= (startpointunk & ((UnkMap)1 << featix)) || + r= (startpointunk & unkfeatbit(featix)) || (target / feati->weight) % feati->posns - (startpointpos / feati->weight) % feati->posns; @@ -824,7 +827,7 @@ static ErrorCode indep_prepare(Segment *move, MovPosComb target, startpointunk= 0; } else { startpointpos= 0; - startpointunk= ((UnkMap)1 << move->i->n_movfeats) - 1; + startpointunk= unkallfeatbits(move->i->n_movfeats); } DPRINTF2(" actual <-%s&%"PRunkx, movpos_pname(move,startpointpos), startpointunk);