X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=54f337d00de2de799d70409534434d1a9a7f6689;hb=3243b1f4122f27ef0360ee3f7b51de8088b6eba0;hp=c6eedec7f5a35c86b2f0f6201094d286da9a29d1;hpb=f4f20b290bc05bdd35be748a9282adcbdc582534;p=xboard.git diff --git a/backend.c b/backend.c index c6eedec..54f337d 100755 --- a/backend.c +++ b/backend.c @@ -1904,6 +1904,8 @@ CopyHoldings(Board board, char *holdings, ChessSquare lowestPiece) ChessSquare piece; if(gameInfo.holdingsWidth < 2) return; + if(gameInfo.variant != VariantBughouse && board[BOARD_SIZE-1][BOARD_SIZE-2]) + return; // prevent overwriting by pre-board holdings if( (int)lowestPiece >= BlackPawn ) { holdingsColumn = 0; @@ -1932,7 +1934,6 @@ CopyHoldings(Board board, char *holdings, ChessSquare lowestPiece) board[holdingsStartRow+j*direction][holdingsColumn] = piece; board[holdingsStartRow+j*direction][countsColumn]++; } - } @@ -2011,8 +2012,9 @@ VariantSwitch(Board board, VariantClass newVariant) gameInfo.holdingsWidth = newHoldingsWidth; gameInfo.variant = newVariant; InitDrawingSizes(-2, 0); - InitPosition(TRUE); /* this sets up board[0], but also other stuff */ - } else { gameInfo.variant = newVariant; InitPosition(TRUE); } + InitPosition(FALSE); /* this sets up board[0], but also other stuff */ + } else { gameInfo.variant = newVariant; InitPosition(FALSE); } + DrawPosition(TRUE, boards[currentMove]); } static int loggedOn = FALSE; @@ -2729,7 +2731,7 @@ read_from_ics(isr, closure, data, count, error) moves and soak them up so user can step through them and/or save them. */ - Reset(TRUE, TRUE); + Reset(FALSE, TRUE); gameMode = IcsObserving; ModeHighlight(); ics_gamenum = -1; @@ -2901,7 +2903,7 @@ read_from_ics(isr, closure, data, count, error) currentMove = forwardMostMove; ClearHighlights();/*!!could figure this out*/ flipView = appData.flipView; - DrawPosition(FALSE, boards[currentMove]); + DrawPosition(TRUE, boards[currentMove]); DisplayBothClocks(); sprintf(str, "%s vs. %s", gameInfo.white, gameInfo.black); @@ -3232,16 +3234,14 @@ read_from_ics(isr, closure, data, count, error) if (currentMove == 0 && gameMode == IcsPlayingWhite && appData.premoveWhite) { - sprintf(str, "%s%s\n", ics_prefix, - appData.premoveWhiteText); + sprintf(str, "%s\n", appData.premoveWhiteText); if (appData.debugMode) fprintf(debugFP, "Sending premove:\n"); SendToICS(str); } else if (currentMove == 1 && gameMode == IcsPlayingBlack && appData.premoveBlack) { - sprintf(str, "%s%s\n", ics_prefix, - appData.premoveBlackText); + sprintf(str, "%s\n", appData.premoveBlackText); if (appData.debugMode) fprintf(debugFP, "Sending premove:\n"); SendToICS(str); @@ -3303,6 +3303,7 @@ read_from_ics(isr, closure, data, count, error) /* [HGM] copy holdings to board holdings area */ CopyHoldings(boards[forwardMostMove], white_holding, WhitePawn); CopyHoldings(boards[forwardMostMove], black_holding, BlackPawn); + boards[forwardMostMove][BOARD_SIZE-1][BOARD_SIZE-2] = 1; // flag holdings as set #if ZIPPY if (appData.zippyPlay && first.initDone) { ZippyHoldings(white_holding, black_holding, @@ -3654,6 +3655,7 @@ ParseBoard12(string) } } CopyBoard(boards[moveNum], board); + boards[moveNum][BOARD_SIZE-1][BOARD_SIZE-2] = 0; // [HGM] indicate holdings not set if (moveNum == 0) { startedFromSetupPosition = !CompareBoards(board, initialPosition); @@ -5271,6 +5273,7 @@ UserMoveTest(fromX, fromY, toX, toY, promoChar, captureOwn) return ImpossibleMove; } + if(toX < 0 || toY < 0) return ImpossibleMove; pdown = boards[currentMove][fromY][fromX]; pup = boards[currentMove][toY][toX]; @@ -5615,16 +5618,11 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } return; } - // ignore to-clicks in holdings + // ignore clicks on holdings if(x < BOARD_LEFT || x >= BOARD_RGHT) return; } - if (clickType == Release && (x == fromX && y == fromY || - x < BOARD_LEFT || x >= BOARD_RGHT)) { - - // treat drags into holding as click on start square - x = fromX; y = fromY; - + if (clickType == Release && x == fromX && y == fromY) { DragPieceEnd(xPix, yPix); if (appData.animateDragging) { /* Undo animation damage if any */ @@ -5644,7 +5642,7 @@ void LeftClick(ClickType clickType, int xPix, int yPix) return; } - /* we now have a different from- and to-square */ + /* we now have a different from- and (possibly off-board) to-square */ /* Completed move */ toX = x; toY = y; @@ -5667,6 +5665,17 @@ void LeftClick(ClickType clickType, int xPix, int yPix) /* Don't animate move and drag both */ appData.animate = FALSE; } + + // moves into holding are invalid for now (later perhaps allow in EditPosition) + if(x >= 0 && x < BOARD_LEFT || x >= BOARD_RGHT) { + ClearHighlights(); + fromX = fromY = -1; + return; + } + + // off-board moves should not be highlighted + if(x < 0 || x < 0) ClearHighlights(); + if (HasPromotionChoice(fromX, fromY, toX, toY, &promoChoice)) { SetHighlights(fromX, fromY, toX, toY); if(gameInfo.variant == VariantSuper || gameInfo.variant == VariantGreat) {