X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=f465f95c07fe27d7a5f31e5eca23a7ffc7c2f1a5;hb=bc82c5edb1fefc925642a5b19e4a96caa92f76e3;hp=2e9e18d236cacb90a83a4d37243f3b8d82d8cad4;hpb=e87c200d0b9a61b23af0782f5b4c0d32aa62fd4a;p=xboard.git diff --git a/backend.c b/backend.c index 2e9e18d..f465f95 100644 --- a/backend.c +++ b/backend.c @@ -1600,6 +1600,7 @@ InitBackEnd3 P((void)) char buf[MSG_SIZ]; int err, len; + ParseFeatures(appData.features[0], &first); if(!appData.icsActive && !appData.noChessProgram && !appData.matchMode && // mode involves only first engine !strcmp(appData.variant, "normal") && // no explicit variant request appData.NrRanks == -1 && appData.NrFiles == -1 && appData.holdingsSize == -1 && // no size overrides requested @@ -4301,7 +4302,7 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int } else if (count == 0) { RemoveInputSource(isr); - DisplayFatalError(_("Connection closed by ICS"), 0, 0); + DisplayFatalError(_("Connection closed by ICS"), 0, 6666); } else { DisplayFatalError(_("Error reading from ICS"), error, 1); } @@ -6498,7 +6499,7 @@ SendBoard (ChessProgramState *cps, int moveNum) * deprecated "black" command. */ if (!WhiteOnMove(moveNum)) // [HGM] but better a deprecated command than an illegal move... - SendToProgram(boards[0][1][BOARD_LEFT] == WhitePawn ? "a2a3\n" : "black\n", cps); + SendToProgram(boards[0][1][BOARD_LEFT] == WhitePawn && !pieceDesc[WhitePawn] ? "a2a3\n" : "black\nforce\n", cps); if(!cps->extendedEdit) left = BOARD_LEFT, right = BOARD_RGHT; // only board proper @@ -10212,14 +10213,14 @@ ParseGameHistory (char *game) void ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) { - ChessSquare captured = board[toY][toX], piece, pawn, king, killed, killed2; int p, rookX, oldEP, epRank, berolina = 0; + ChessSquare captured = board[toY][toX], piece, pawn, king, killed, killed2; int p, rookX, oldEP, epRank, epFile, berolina = 0; int promoRank = gameInfo.variant == VariantMakruk || gameInfo.variant == VariantGrand || gameInfo.variant == VariantChuChess ? 3 : 1; /* [HGM] compute & store e.p. status and castling rights for new position */ /* we can always do that 'in place', now pointers to these rights are passed to ApplyMove */ if(gameInfo.variant == VariantBerolina) berolina = EP_BEROLIN_A; - oldEP = (signed char)board[EP_FILE]; epRank = board[EP_RANK]; + oldEP = (signed char)board[EP_FILE]; epRank = board[EP_RANK]; epFile = board[EP_FILE]; board[EP_STATUS] = EP_NONE; board[EP_FILE] = board[EP_RANK] = 100; @@ -10253,6 +10254,13 @@ ApplyMove (int fromX, int fromY, int toX, int toY, int promoChar, Board board) } pawn = board[fromY][fromX]; + if(pieceDesc[pawn] && strchr(pieceDesc[pawn], 'e')) { // piece with user-defined e.p. capture + if(captured == EmptySquare && toX == epFile && (toY == (epRank & 127) || toY + (pawn < BlackPawn ? -1 : 1) == epRank - 128)) { + captured = board[epRank + (pawn < BlackPawn ? -1 : 1)][oldEP & berolina-1]; // remove victim + board[epRank + (pawn < BlackPawn ? -1 : 1)][oldEP & berolina-1] = EmptySquare; + pawn = EmptySquare; // kludge to suppress old e.p. code + } + } if( pawn == WhiteLance || pawn == BlackLance ) { if( gameInfo.variant != VariantSuper && gameInfo.variant != VariantChu ) { if(gameInfo.variant == VariantSpartan) board[EP_STATUS] = EP_PAWN_MOVE; // in Spartan no e.p. rights must be set @@ -11672,7 +11680,7 @@ GameEnds (ChessMove result, char *resultDetails, int whosays) && result != GameIsDrawn) { int i, j, k=0, oppoKings = 0, color = (result==WhiteWins ? (int)WhitePawn : (int)BlackPawn); for(j=BOARD_LEFT; j= 0 && p <= (int)WhiteKing) k++; oppoKings += (p + color == WhiteKing + BlackPawn - color); } @@ -14877,7 +14885,9 @@ MachineWhiteEvent () safeStrCpy(bookMove, "move ", sizeof(bookMove)/sizeof(bookMove[0])); strcat(bookMove, bookHit); - HandleMachineMove(bookMove, &first); + savedMessage = bookMove; // args for deferred call + savedState = &first; + ScheduleDelayedEvent(DeferredBookMove, 1); } } @@ -14952,7 +14962,9 @@ MachineBlackEvent () safeStrCpy(bookMove, "move ", sizeof(bookMove)/sizeof(bookMove[0])); strcat(bookMove, bookHit); - HandleMachineMove(bookMove, &first); + savedMessage = bookMove; // args for deferred call + savedState = &first; + ScheduleDelayedEvent(DeferredBookMove, 1); } } @@ -19081,8 +19093,10 @@ LoadTheme () q = appData.themeNames; snprintf(buf, BUF_SIZ, "\"%s\"", nickName); if(appData.useBitmaps) { - snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -ubt true -lbtf \"%s\" -dbtf \"%s\" -lbtm %d -dbtm %d", - appData.liteBackTextureFile, appData.darkBackTextureFile, + snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -ubt true -lbtf \"%s\"", + Shorten(appData.liteBackTextureFile)); + snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -dbtf \"%s\" -lbtm %d -dbtm %d", + Shorten(appData.darkBackTextureFile), appData.liteBackTextureMode, appData.darkBackTextureMode ); } else { @@ -19109,7 +19123,7 @@ LoadTheme () } else { snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -upf false"); if(appData.pieceDirectory[0]) { - snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -pid \"%s\"", appData.pieceDirectory); + snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -pid \"%s\"", Shorten(appData.pieceDirectory)); if(appData.trueColors != 2) // 2 is a kludge to suppress this in WinBoard snprintf(buf+strlen(buf), BUF_SIZ-strlen(buf), " -trueColors %s", appData.trueColors ? "true" : "false"); }