From 09efa4c46ec85dac85fc7275d93303de213c45c4 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 13 Jun 2009 15:27:26 -0700 Subject: [PATCH] some small bugfixes I had overlooked one place from which the FEN writer (of whicf I changed the argument types), which made WB crash if you copied a FEN (or PGN that cotained FEN) to the clipboard. I must have overlooked a warning during compile, or some depedency is not correct in the makefile. Anyway, wclipboard.c had to be changed. I also moved adjudication of some losing conditions to before tetsing for stalemate, (e.g. in atomic, if your king get destroyd you lose, even if you have no moves after that because it was your only piece.). this affects backend.c. I had used the same bits in the frule-modifier flags for indicating mandatory capture as was already used for indicating FRC-style castling. This led to frequent illegal move calls in FRC... (moves.h) --- backend.c | 77 ++++++++++++++++++++++++++------------------------ moves.h | 2 +- winboard/wclipbrd.c | 2 +- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/backend.c b/backend.c index c34724e..0f24243 100644 --- a/backend.c +++ b/backend.c @@ -5606,6 +5606,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h machineMove, fromX+AAA, fromY+ONE, toX+AAA, toY+ONE, 0); GameEnds(machineWhite ? BlackWins : WhiteWins, buf1, GE_XBOARD); + return; } else if(gameInfo.variant != VariantFischeRandom && gameInfo.variant != VariantCapaRandom) /* [HGM] Kludge to handle engines that send FRC-style castling when they shouldn't (like TSCP-Gothic) */ @@ -5699,42 +5700,6 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h int k, count = 0, epFile = epStatus[forwardMostMove]; static int bare = 1; if(gameInfo.holdingsSize == 0 || gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) { - if(appData.testLegality) - // don't wait for engine to announce game end if we can judge ourselves - switch (MateTest(boards[forwardMostMove], - PosFlags(forwardMostMove), epFile, - castlingRights[forwardMostMove]) ) { - case MT_NONE: - case MT_CHECK: - default: - break; - case MT_STALEMATE: - epStatus[forwardMostMove] = EP_STALEMATE; - if(appData.checkMates) { - SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ - ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ - if(gameInfo.variant == VariantLosers || gameInfo.variant == VariantSuicide - || gameInfo.variant == VariantGiveaway) // [HGM] losers: - GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, // stalemated side wins! - "Xboard adjudication: Stalemate", GE_XBOARD ); - else - GameEnds( GameIsDrawn, "Xboard adjudication: Stalemate", GE_XBOARD ); - return; - } - break; - case MT_CHECKMATE: - epStatus[forwardMostMove] = EP_CHECKMATE; - if(appData.checkMates) { - SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ - ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ - GameEnds( WhiteOnMove(forwardMostMove) != (gameInfo.variant == VariantLosers) // [HGM] losers: - ? BlackWins : WhiteWins, // reverse the result ( A!=1 is !A for a boolean) - "Xboard adjudication: Checkmate", GE_XBOARD ); - return; - } - break; - } - if( appData.testLegality ) { /* [HGM] Some more adjudications for obstinate engines */ int NrWN=0, NrBN=0, NrWB=0, NrBB=0, NrWR=0, NrBR=0, @@ -5742,7 +5707,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h NrPieces=0, NrPawns=0, PawnAdvance=0, i, j; static int moveCount = 6; - /* First absolutely insufficient mating material. Count what is on board. */ + /* Count what is on board. */ for(i=0; iother); /* make sure opponent gets to see move */ + ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ + if(gameInfo.variant == VariantLosers || gameInfo.variant == VariantSuicide + || gameInfo.variant == VariantGiveaway) // [HGM] losers: + GameEnds( WhiteOnMove(forwardMostMove) ? WhiteWins : BlackWins, // stalemated side wins! + "Xboard adjudication: Stalemate", GE_XBOARD ); + else + GameEnds( GameIsDrawn, "Xboard adjudication: Stalemate", GE_XBOARD ); + return; + } + break; + case MT_CHECKMATE: + epStatus[forwardMostMove] = EP_CHECKMATE; + if(appData.checkMates) { + SendMoveToProgram(forwardMostMove-1, cps->other); /* make sure opponent gets to see move */ + ShowMove(fromX, fromY, toX, toY); /*updates currentMove*/ + GameEnds( WhiteOnMove(forwardMostMove) != (gameInfo.variant == VariantLosers) // [HGM] losers: + ? BlackWins : WhiteWins, // reverse the result ( A!=1 is !A for a boolean) + "Xboard adjudication: Checkmate", GE_XBOARD ); + return; + } + break; + } + + /* Next absolutely insufficient mating material. */ if( NrPieces == 2 || gameInfo.variant != VariantXiangqi && gameInfo.variant != VariantShatranj && // [HGM] baring will remain possible (NrPieces == 3 && NrWN+NrBN+NrWB+NrBB == 1 || diff --git a/moves.h b/moves.h index 50e6c17..73cf604 100644 --- a/moves.h +++ b/moves.h @@ -77,7 +77,7 @@ typedef void (*MoveCallback) P((Board board, int flags, ChessMove kind, and all non-pawns on adjacent squares; destroying your own king is illegal */ #define F_FRC_TYPE_CASTLING 256 /* generate castlings as captures of own Rook */ -#define F_MANDATORY_CAPTURE 0x100 +#define F_MANDATORY_CAPTURE 0x200 /* Special epfile values. [HGM] positive values are non-reversible moves! */ #define EP_NONE (-4) /* [HGM] Tricky! order matters: */ diff --git a/winboard/wclipbrd.c b/winboard/wclipbrd.c index 838d250..b187344 100644 --- a/winboard/wclipbrd.c +++ b/winboard/wclipbrd.c @@ -48,7 +48,7 @@ CopyFENToClipboard() { char *fen = NULL; - fen = PositionToFEN(currentMove,1); + fen = PositionToFEN(currentMove, NULL); if (!fen) { DisplayError("Unable to convert position to FEN.", 0); return; -- 1.7.0.4