X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=593e0560390997cf4eb9d74aebf19bc69e93a57c;hb=39fd546eed3b517c4da83bc48d019a121d645cfc;hp=3a36a304d40070bf4bb6a9d5882c63ef1883ae92;hpb=37948ed62b289c847349f54d3100ac4a223c7d35;p=xboard.git diff --git a/backend.c b/backend.c index 3a36a30..593e056 100644 --- a/backend.c +++ b/backend.c @@ -2472,6 +2472,8 @@ read_from_ics(isr, closure, data, count, error) } else if(looking_at(buf, &i, "kibitzed to *\n") && atoi(star_match[0])) { // suppress the acknowledgements of our own autoKibitz + char *p; + if(p = strchr(star_match[0], ' ')) p[1] = NULLCHAR; // clip off "players)" on FICS SendToPlayer(star_match[0], strlen(star_match[0])); looking_at(buf, &i, "*% "); // eat prompt next_out = i; @@ -2493,14 +2495,14 @@ read_from_ics(isr, closure, data, count, error) if(channel >= 0) // channel broadcast; look if there is a chatbox for this channel for(p=0; p= 3) // [HGM] chat: continuation of line for chat box + chattingPartner = savingComment - 3; // kludge to remember the box } else { started = STARTED_CHATTER; } @@ -5891,13 +5895,13 @@ void LeftClick(ClickType clickType, int xPix, int yPix) if(x == BOARD_LEFT-2 && piece >= BlackPawn) { n = PieceToNumber(piece - (int)BlackPawn); - if(n > gameInfo.holdingsSize) { n = 0; piece = BlackPawn; } + if(n >= gameInfo.holdingsSize) { n = 0; piece = BlackPawn; } boards[currentMove][BOARD_HEIGHT-1 - n][0] = piece; boards[currentMove][BOARD_HEIGHT-1 - n][1]++; } else if(x == BOARD_RGHT+1 && piece < BlackPawn) { n = PieceToNumber(piece); - if(n > gameInfo.holdingsSize) { n = 0; piece = WhitePawn; } + if(n >= gameInfo.holdingsSize) { n = 0; piece = WhitePawn; } boards[currentMove][n][BOARD_WIDTH-1] = piece; boards[currentMove][n][BOARD_WIDTH-2]++; } @@ -5941,6 +5945,63 @@ void LeftClick(ClickType clickType, int xPix, int yPix) } } +int RightClick(ClickType action, int x, int y, int *fromX, int *fromY) +{ // front-end-free part taken out of PieceMenuPopup + int whichMenu; int xSqr, ySqr; + + xSqr = EventToSquare(x, BOARD_WIDTH); + ySqr = EventToSquare(y, BOARD_HEIGHT); + if (action == Release) UnLoadPV(); // [HGM] pv + if (action != Press) return -2; + switch (gameMode) { + case IcsExamining: + if(xSqr < BOARD_LEFT || xSqr >= BOARD_RGHT) return -1; + case EditPosition: + if (xSqr == BOARD_LEFT-1 || xSqr == BOARD_RGHT) return -1; + if (xSqr < 0 || ySqr < 0) return -1; + whichMenu = 0; // edit-position menu + break; + case IcsObserving: + if(!appData.icsEngineAnalyze) return -1; + case IcsPlayingWhite: + case IcsPlayingBlack: + if(!appData.zippyPlay) goto noZip; + case AnalyzeMode: + case AnalyzeFile: + case MachinePlaysWhite: + case MachinePlaysBlack: + case TwoMachinesPlay: // [HGM] pv: use for showing PV + if (!appData.dropMenu) { + LoadPV(x, y); + return 2; // flag front-end to grab mouse events + } + if(gameMode == TwoMachinesPlay || gameMode == AnalyzeMode || + gameMode == AnalyzeFile || gameMode == IcsObserving) return -1; + case EditGame: + noZip: + if (xSqr < 0 || ySqr < 0) return -1; + if (!appData.dropMenu || appData.testLegality && + gameInfo.variant != VariantBughouse && + gameInfo.variant != VariantCrazyhouse) return -1; + whichMenu = 1; // drop menu + break; + default: + return -1; + } + + if (((*fromX = xSqr) < 0) || + ((*fromY = ySqr) < 0)) { + *fromX = *fromY = -1; + return -1; + } + if (flipView) + *fromX = BOARD_WIDTH - 1 - *fromX; + else + *fromY = BOARD_HEIGHT - 1 - *fromY; + + return whichMenu; +} + void SendProgramStatsToFrontend( ChessProgramState * cps, ChessProgramStats * cpstats ) { // char * hint = lastHint; @@ -6558,14 +6619,6 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h strcat(machineMove, "\n"); strcpy(moveList[forwardMostMove], machineMove); - /* [AS] Save move info and clear stats for next move */ - pvInfoList[ forwardMostMove ].score = programStats.score; - pvInfoList[ forwardMostMove ].depth = programStats.depth; - pvInfoList[ forwardMostMove ].time = programStats.time; // [HGM] PGNtime: take time from engine stats - ClearProgramStats(); - thinkOutput[0] = NULLCHAR; - hiddenThinkOutputState = 0; - MakeMove(fromX, fromY, toX, toY, promoChar);/*updates forwardMostMove*/ /* [AS] Adjudicate game if needed (note: remember that forwardMostMove now points past the last move) */ @@ -6625,6 +6678,14 @@ if(appData.debugMode) fprintf(debugFP, "nodes = %d, %lld\n", (int) programStats. } #endif + /* [AS] Save move info and clear stats for next move */ + pvInfoList[ forwardMostMove-1 ].score = programStats.score; + pvInfoList[ forwardMostMove-1 ].depth = programStats.depth; + pvInfoList[ forwardMostMove-1 ].time = programStats.time; // [HGM] PGNtime: take time from engine stats + ClearProgramStats(); + thinkOutput[0] = NULLCHAR; + hiddenThinkOutputState = 0; + bookHit = NULL; if (gameMode == TwoMachinesPlay) { /* [HGM] relaying draw offers moved to after reception of move */ @@ -11628,13 +11689,13 @@ EditPositionMenuEvent(selection, x, y) int n; if(x == BOARD_LEFT-2 && selection >= BlackPawn) { n = PieceToNumber(selection - BlackPawn); - if(n > gameInfo.holdingsSize) { n = 0; selection = BlackPawn; } + if(n >= gameInfo.holdingsSize) { n = 0; selection = BlackPawn; } boards[0][BOARD_HEIGHT-1-n][0] = selection; boards[0][BOARD_HEIGHT-1-n][1]++; } else if(x == BOARD_RGHT+1 && selection < BlackPawn) { n = PieceToNumber(selection); - if(n > gameInfo.holdingsSize) { n = 0; selection = WhitePawn; } + if(n >= gameInfo.holdingsSize) { n = 0; selection = WhitePawn; } boards[0][n][BOARD_WIDTH-1] = selection; boards[0][n][BOARD_WIDTH-2]++; }