X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=c81e0fd5fb89e87bd56c4cee31113c3e5d184576;hb=8ee0292f69ffa3ebef03640cc5944d9c60e86bb8;hp=f05359c9e2896e21f6833449c1de04ba739f5e8c;hpb=5ac80d2f3c2a7720f3095a8e4145b1780494dfd2;p=xboard.git diff --git a/backend.c b/backend.c index f05359c..c81e0fd 100644 --- a/backend.c +++ b/backend.c @@ -12364,12 +12364,26 @@ QuickCompare (Board board, int *minCounts, int *maxCounts) int QuickScan (Board board, Move *move) { // reconstruct game,and compare all positions in it - int cnt=0, stretch=0, total = MakePieceList(board, counts); + int cnt=0, stretch=0, found = -1, total = MakePieceList(board, counts); do { int piece = move->piece; int to = move->to, from = pieceList[piece]; + if(!found) { // if already found just scan to game end for final piece count + if(QuickCompare(soughtBoard, minSought, maxSought) || + appData.ignoreColors && QuickCompare(reverseBoard, minReverse, maxReverse) || + flipSearch && (QuickCompare(flipBoard, minSought, maxSought) || + appData.ignoreColors && QuickCompare(rotateBoard, minReverse, maxReverse)) + ) { + static int lastCounts[EmptySquare+1]; + int i; + if(stretch) for(i=0; i= appData.stretch)) found = cnt + 1 - stretch; + if(found && !appData.minPieces) return found; + } if(piece <= Q_PROMO) { // special moves encoded by otherwise invalid piece numbers 1-4 - if(!piece) return -1; + if(!piece) return (appData.minPieces && (total < appData.minPieces || total > appData.maxPieces) ? -1 : found); if(piece == Q_PROMO) { // promotion, encoded as (Q_PROMO, to) + (piece, promoType) piece = (++move)->piece; from = pieceList[piece]; @@ -12400,17 +12414,6 @@ QuickScan (Board board, Move *move) quickBoard[to] = piece; pieceList[piece] = to; cnt++; turn ^= 3; - if(QuickCompare(soughtBoard, minSought, maxSought) || - appData.ignoreColors && QuickCompare(reverseBoard, minReverse, maxReverse) || - flipSearch && (QuickCompare(flipBoard, minSought, maxSought) || - appData.ignoreColors && QuickCompare(rotateBoard, minReverse, maxReverse)) - ) { - static int lastCounts[EmptySquare+1]; - int i; - if(stretch) for(i=0; i= appData.stretch)) return cnt + 1 - stretch; move++; } while(1); }