X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=moves.c;h=aca97b5d43da7d3429d491c4bec444bfc9b41a50;hb=ba3e6a6301920d112fde459b61a5a5206565dcbd;hp=d1b65086c6cd9d3b69f423fa2abd7a6a6e345835;hpb=15d5c0ddf1340c62460477de0507a9237907c76e;p=xboard.git diff --git a/moves.c b/moves.c index d1b6508..aca97b5 100644 --- a/moves.c +++ b/moves.c @@ -300,6 +300,9 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle break; case 'N': all = 0xFF; // oblique atom (degenerate 8-fold) if(tx >= 0) goto king; // continuation legs specified in K/Q system! + if(*desc == 'h') { // chiral direction sets 'hr' and 'hl' + dirSet = (desc[1] == 'r' ? 0x55 : 0xAA); desc += 2; + } else while(islower(*desc) && (i = dirType[*desc-'a']) != '0') { int b = dirs2[*desc-'a']; // when alone, use narrow version if(desc[1] == 'h') b = dirs1[*desc-'a'], desc += 2; // dirs1 is wide version @@ -359,7 +362,7 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle mode |= 1024; dy = 1; } if(!cont) { - if(!(mode & 15)) mode = his + 4; // no mode spec, use default = mc + if(!(mode & 15)) mode |= his + 4; // no mode spec, use default = mc } else { strncpy(buf, cont, 80); cont = buf; // copy next leg(s), so we can modify atom = buf; while(islower(*atom)) atom++; // skip to atom @@ -371,12 +374,12 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle atom[1] = atom[2] = '\0'; // make sure any old range is stripped off if(expo == 1) atom[1] = '0'; // turn other leapers into riders } - if(!(mode & 0x30F)) mode = 4; // and default of this leg = m + if(!(mode & 0x30F)) mode |= 4; // and default of this leg = m } if(dy == 1) skip = jump - 1, jump = 1; // on W & F atoms 'j' = skip first square do { for(dir=0, bit=1; dir<8; dir++, bit += bit) { // loop over directions - int i = expo, j = skip, hop = mode, vx, vy; + int i = expo, j = skip, hop = mode, vx, vy, loop = 0; if(!(bit & dirSet)) continue; // does not move in this direction if(dy != 1) j = 0; // vx = dx*rot[dir][0] + dy*rot[dir][1]; // rotate step vector @@ -386,12 +389,12 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle do { // traverse ray x += vx; y += vy; // step to next square if(y < 0 || y >= BOARD_HEIGHT) break; // vertically off-board: always done - if(x < BOARD_LEFT) { if(mode & 128) x += BOARD_RGHT - BOARD_LEFT; else break; } - if(x >= BOARD_RGHT) { if(mode & 128) x -= BOARD_RGHT - BOARD_LEFT; else break; } + if(x < BOARD_LEFT) { if(mode & 128) x += BOARD_RGHT - BOARD_LEFT, loop++; else break; } + if(x >= BOARD_RGHT) { if(mode & 128) x -= BOARD_RGHT - BOARD_LEFT, loop++; else break; } if(j) { j--; continue; } // skip irrespective of occupation if(!jump && board[y - vy + vy/2][x - vx + vx/2] != EmptySquare) break; // blocked if(jump > 1 && board[y - vy + vy/2][x - vx + vx/2] == EmptySquare) break; // no hop - if(x == f && y == r) occup = 4; else // start square counts as empty + if(x == f && y == r && !loop) occup = 4; else // start square counts as empty (if not around cylinder!) if(board[y][x] < BlackPawn) occup = 0x101; else if(board[y][x] < EmptySquare) occup = 0x102; else occup = 4; @@ -430,6 +433,7 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle cb(board, flags, mine == 1 ? WhiteKingSideCastle : BlackKingSideCastle, r, f, y, f + expo, cl); break; } + if(mode & 16 && (board[y][x] == WhiteKing || board[y][x] == BlackKing)) break; // tame piece, cannot capture royal if(occup & mode) cb(board, flags, NormalMove, r, f, y, x, cl); // allowed, generate if(occup != 4) break; // not valid transit square } while(--i); @@ -1606,6 +1610,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant CheckTestClosure cl; ChessSquare king = flags & F_WHITE_ON_MOVE ? WhiteKing : BlackKing; ChessSquare captured = EmptySquare, ep=0, trampled=0; + int saveKill = killX; /* Suppress warnings on uninitialized variables */ if(gameInfo.variant == VariantXiangqi) @@ -1628,7 +1633,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant board[rf][ft] = EmptySquare; } else { captured = board[rt][ft]; - if(killX >= 0) { trampled = board[killY][killX]; board[killY][killX] = EmptySquare; } + if(killX >= 0) { trampled = board[killY][killX]; board[killY][killX] = EmptySquare; killX = -1; } } if(rf == DROP_RANK) board[rt][ft] = ff; else { // [HGM] drop board[rt][ft] = board[rf][ff]; @@ -1676,7 +1681,7 @@ CheckTest (Board board, int flags, int rf, int ff, int rt, int ft, int enPassant board[rf][ft] = captured; board[rt][ft] = EmptySquare; } else { - if(killX >= 0) board[killY][killX] = trampled; + if(saveKill >= 0) board[killY][killX] = trampled, killX = saveKill; board[rt][ft] = captured; } board[EP_STATUS] = ep;