From 3018a62f2d049e7295b703ce7780a9bd2c547ada Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 7 Feb 2010 21:26:39 +0100 Subject: [PATCH] Observe a game in the background while playing A new (persistent) option -backgroundObserve true|false is added. When set, observed boards received while playing a game will not trigger a game switch, but will be ignored except for storing in a dedicated board buffer. Pressing the right mouse button will cause the board to be displayed, until we release it. Time, strength and stm are always displayed in the message window. --- args.h | 1 + backend.c | 29 +++++++++++++++++++++++++++++ common.h | 1 + 3 files changed, 31 insertions(+), 0 deletions(-) diff --git a/args.h b/args.h index 079e3c9..615b3ff 100644 --- a/args.h +++ b/args.h @@ -559,6 +559,7 @@ ArgDescriptor argDescriptors[] = { { "trivialDraws", ArgBoolean, (void *) &appData.trivialDraws, TRUE, (ArgIniType) FALSE }, { "ruleMoves", ArgInt, (void *) &appData.ruleMoves, TRUE, (ArgIniType) 51 }, { "repeatsToDraw", ArgInt, (void *) &appData.drawRepeats, TRUE, (ArgIniType) 6 }, + { "backgroundObserve", ArgBoolean, (void *) &appData.bgObserve, TRUE, (ArgIniType) FALSE }, { "autoKibitz", ArgTrue, (void *) &appData.autoKibitz, FALSE, INVALID }, { "engineDebugOutput", ArgInt, (void *) &appData.engineComments, FALSE, (ArgIniType) 1 }, { "userName", ArgString, (void *) &appData.userName, FALSE, INVALID }, diff --git a/backend.c b/backend.c index 8f77f6b..4ac6084 100644 --- a/backend.c +++ b/backend.c @@ -242,6 +242,8 @@ int endPV = -1; static int exiting = 0; /* [HGM] moved to top */ static int setboardSpoiledMachineBlack = 0 /*, errorExitFlag = 0*/; int startedFromPositionFile = FALSE; Board filePosition; /* [HGM] loadPos */ +Board partnerBoard; /* [HGM] bughouse: for peeking at partner game */ +Boolean partnerUp; char endingGame = 0; /* [HGM] crash: flag to prevent recursion of GameEnds() */ int whiteNPS, blackNPS; /* [HGM] nps: for easily making clocks aware of NPS */ VariantClass currentlyInitializedVariant; /* [HGM] variantswitch */ @@ -3766,6 +3768,26 @@ ParseBoard12(string) break; } + if((gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack) + && newGameMode == IcsObserving && appData.bgObserve) { + // [HGM] bughouse: don't act on alien boards while we play. Just parse the board and save it */ + char buf[MSG_SIZ]; + for (k = 0; k < ranks; k++) { + for (j = 0; j < files; j++) + board[k][j+gameInfo.holdingsWidth] = CharToPiece(board_chars[(ranks-1-k)*(files+1) + j]); + if(gameInfo.holdingsWidth > 1) { + board[k][0] = board[k][BOARD_WIDTH-1] = EmptySquare; + board[k][1] = board[k][BOARD_WIDTH-2] = (ChessSquare) 0;; + } + } + CopyBoard(partnerBoard, board); + if(partnerUp) DrawPosition(FALSE, partnerBoard); + sprintf(buf, "W: %d:%d B: %d:%d (%d-%d) %c", white_time/60000, (white_time%60000)/1000, + (black_time/60000), (black_time%60000)/1000, white_stren, black_stren, to_play); + DisplayMessage(buf, ""); + return; + } + /* Modify behavior for initial board display on move listing of wild games. */ @@ -6274,6 +6296,13 @@ int RightClick(ClickType action, int x, int y, int *fromX, int *fromY) return -2; } + if((gameMode == IcsPlayingWhite || gameMode == IcsPlayingBlack) + && !appData.zippyPlay && appData.bgObserve) { // [HGM] bughouse: show background game + if(action == Press) { flipView = !flipView; DrawPosition(TRUE, partnerBoard); partnerUp = TRUE; } else + if(action == Release) { flipView = !flipView; DrawPosition(TRUE, boards[currentMove]); partnerUp = FALSE; } + return -2; + } + xSqr = EventToSquare(x, BOARD_WIDTH); ySqr = EventToSquare(y, BOARD_HEIGHT); if (action == Release) UnLoadPV(); // [HGM] pv diff --git a/common.h b/common.h index 4ef81fa..745ceac 100644 --- a/common.h +++ b/common.h @@ -555,6 +555,7 @@ typedef struct { Boolean highlightMoveWithArrow; int highlightArrowColor; Boolean useStickyWindows; + Boolean bgObserve; /* [HGM] bughouse */ int adjudicateDrawMoves; Boolean autoDisplayComment; Boolean autoDisplayTags; -- 1.7.0.4