X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=fairymax.c;h=0f4dd5f62f69d8c37dd4b43481fd4790582f0ef1;hb=178720867b5f21ece6bde4502d0d249f532f6a7f;hp=ce2d7ae4e2eea85d5bfebc5ee51622235824ae48;hpb=cdb80be80d2895990ffe4b3f88ab566e5553ca3c;p=fairymax.git diff --git a/fairymax.c b/fairymax.c index ce2d7ae..0f4dd5f 100644 --- a/fairymax.c +++ b/fairymax.c @@ -859,14 +859,19 @@ int main(int argc, char **argv) if (m) /* doesn't have move syntax */ printf("Error (unknown command): %s\n", command); - else if(D(Side,-I,I,Q,O,LL|S,3)!=I) { + else { int i=-1; + if(b[L] && (b[L]&16) == Side && w[b[L]&15] < 0) // capture own King: castling + { i=K; K = L; L = i>L ? i-1 : i+2; } + if(D(Side,-I,I,Q,O,LL|S,3)!=I) { /* did have move syntax, but illegal move */ printf("Illegal move:%s\n", line); - } else { /* legal move, perform it */ + } else { /* legal move, perform it */ + if(i >= 0) b[i]=b[K],b[K]=0; // reverse Seirawan gating GameHistory[GamePtr++] = PACK_MOVE; Side ^= BLACK^WHITE; CopyBoard(HistPtr=HistPtr+1&1023); if(PrintResult(Side)) Computer = EMPTY; + } } } }