X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=46a0df4ac157a68bfd932cf1b1b5f2cdc15c24f3;hb=e70077aab0199817f37aef9ed0bdba1bbca93b45;hp=5e346e5855e2d6ee197369487cd86934c150d1de;hpb=259aca883470b6cd7fc47e417475f05120400d3c;p=xboard.git diff --git a/backend.c b/backend.c index 5e346e5..46a0df4 100644 --- a/backend.c +++ b/backend.c @@ -5,7 +5,7 @@ * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -3126,6 +3126,8 @@ read_from_ics(isr, closure, data, count, error) } } // [HGM] kibitz: end of patch + if(looking_at(buf, &i, "* rating adjustment: * --> *\n")) continue; + // [HGM] chat: intercept tells by users for which we have an open chat window channel = -1; if(started == STARTED_NONE && (looking_at(buf, &i, "* tells you:") || looking_at(buf, &i, "* says:") || @@ -4431,6 +4433,13 @@ ParseBoard12(string) board[k][1] = board[k][BOARD_WIDTH-2] = (ChessSquare) 0;; } } + if(moveNum==0 && gameInfo.variant == VariantSChess) { + board[5][BOARD_RGHT+1] = WhiteAngel; + board[6][BOARD_RGHT+1] = WhiteMarshall; + board[1][0] = BlackMarshall; + board[2][0] = BlackAngel; + board[1][1] = board[2][1] = board[5][BOARD_RGHT] = board[6][BOARD_RGHT] = 1; + } CopyBoard(boards[moveNum], board); boards[moveNum][HOLDINGS_SET] = 0; // [HGM] indicate holdings not set if (moveNum == 0) { @@ -4466,6 +4475,7 @@ ParseBoard12(string) if(board[BOARD_HEIGHT-1][i] == BlackRook) j = i; initialRights[4] = boards[moveNum][CASTLING][4] = (castle_bl == 0 && gameInfo.variant != VariantFischeRandom ? NoRights : j); + boards[moveNum][CASTLING][2] = boards[moveNum][CASTLING][5] = NoRights; if(gameInfo.variant == VariantKnightmate) { wKing = WhiteUnicorn; bKing = BlackUnicorn; } for(k=BOARD_LEFT; k>1) moveType = WhitePromotion; // kludge to do gating at Rook + if(moveType == NormalMove) moveType = WhitePromotion; // kludge to do gating } else suffix[0] = NULLCHAR; switch (moveType) { @@ -6023,21 +6033,25 @@ SendBoard(cps, moveNum) } else { ChessSquare *bp; - int i, j; + int i, j, left=0, right=BOARD_WIDTH; /* Kludge to set black to move, avoiding the troublesome and now * 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); + if(!cps->extendedEdit) left = BOARD_LEFT, right = BOARD_RGHT; // only board proper + SendToProgram("edit\n", cps); SendToProgram("#\n", cps); for (i = BOARD_HEIGHT - 1; i >= 0; i--) { - bp = &boards[moveNum][i][BOARD_LEFT]; - for (j = BOARD_LEFT; j < BOARD_RGHT; j++, bp++) { + bp = &boards[moveNum][i][left]; + for (j = left; j < right; j++, bp++) { + if(j == BOARD_LEFT-1 || j == BOARD_RGHT) continue; if ((int) *bp < (int) BlackPawn) { - snprintf(message, MSG_SIZ, "%c%c%c\n", PieceToChar(*bp), - AAA + j, ONE + i); + if(j == BOARD_RGHT+1) + snprintf(message, MSG_SIZ, "%c@%d\n", PieceToChar(*bp), bp[-1]); + else snprintf(message, MSG_SIZ, "%c%c%c\n", PieceToChar(*bp), AAA + j, ONE + i); if(message[0] == '+' || message[0] == '~') { snprintf(message, MSG_SIZ,"%c%c%c+\n", PieceToChar((ChessSquare)(DEMOTED *bp)), @@ -6054,11 +6068,14 @@ SendBoard(cps, moveNum) SendToProgram("c\n", cps); for (i = BOARD_HEIGHT - 1; i >= 0; i--) { - bp = &boards[moveNum][i][BOARD_LEFT]; - for (j = BOARD_LEFT; j < BOARD_RGHT; j++, bp++) { + bp = &boards[moveNum][i][left]; + for (j = left; j < right; j++, bp++) { + if(j == BOARD_LEFT-1 || j == BOARD_RGHT) continue; if (((int) *bp != (int) EmptySquare) && ((int) *bp >= (int) BlackPawn)) { - snprintf(message,MSG_SIZ, "%c%c%c\n", ToUpper(PieceToChar(*bp)), + if(j == BOARD_LEFT-2) + snprintf(message, MSG_SIZ, "%c@%d\n", ToUpper(PieceToChar(*bp)), bp[1]); + else snprintf(message,MSG_SIZ, "%c%c%c\n", ToUpper(PieceToChar(*bp)), AAA + j, ONE + i); if(message[0] == '+' || message[0] == '~') { snprintf(message, MSG_SIZ,"%c%c%c+\n", @@ -8352,6 +8369,8 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. parseList[currentMove], _(cps->which)); DisplayMoveError(buf1); DrawPosition(FALSE, boards[currentMove]); + + SetUserThinkingEnables(); return; } if (strncmp(message, "time", 4) == 0 && StrStr(message, "Illegal")) { @@ -10473,7 +10492,7 @@ GameEnds(result, resultDetails, whosays) first.matchWins, second.matchWins, appData.matchGames - (first.matchWins + second.matchWins)); if(!appData.tourneyFile[0]) matchGame++, DisplayTwoMachinesTitle(); // [HGM] update result in window title - if(strcmp(ranking, "busy") && appData.afterTourney && appData.afterTourney[0]) RunCommand(appData.afterTourney); + if(ranking && strcmp(ranking, "busy") && appData.afterTourney && appData.afterTourney[0]) RunCommand(appData.afterTourney); popupRequested++; // [HGM] crash: postpone to after resetting endingGame if (appData.firstPlaysBlack) { // [HGM] match: back to original for next match first.twoMachinesColor = "black\n"; @@ -10641,6 +10660,7 @@ Reset(redraw, init) ModeHighlight(); if(appData.icsActive) gameInfo.variant = VariantNormal; currentMove = forwardMostMove = backwardMostMove = 0; + MarkTargetSquares(1); InitPosition(redraw); for (i = 0; i < MAX_MOVES; i++) { if (commentList[i] != NULL) { @@ -14883,6 +14903,7 @@ if(appData.debugMode) fprintf(debugFP, "Append: in='%s' %d\n", text, addBraces); while (*text == '\n') text++; len = strlen(text); while (len > 0 && text[len - 1] == '\n') len--; + text[len] = NULLCHAR; if (len == 0) return; @@ -15462,6 +15483,7 @@ ParseFeatures(args, cps) if (*p == NULLCHAR) return; if (BoolFeature(&p, "setboard", &cps->useSetboard, cps)) continue; + if (BoolFeature(&p, "xedit", &cps->extendedEdit, cps)) continue; if (BoolFeature(&p, "time", &cps->sendTime, cps)) continue; if (BoolFeature(&p, "draw", &cps->sendDrawOffers, cps)) continue; if (BoolFeature(&p, "sigint", &cps->useSigint, cps)) continue;