X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=7d8c272ba6cbb60d8c48ee2c37f89ac2526ac93b;hb=3278933131ffc6d325e57eb6a131aee06d624b97;hp=fb64ff7f8448ca14613e18930600658a8908390d;hpb=ea750683ac62717dd7346de17b5ae072622ff92a;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index fb64ff7..7d8c272 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -2,8 +2,10 @@ * WinBoard.c -- Windows NT front end to XBoard * $Id: winboard.c,v 2.3 2003/11/25 05:25:20 mann Exp $ * - * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts. - * Enhancements Copyright 1992-2001 Free Software Foundation, Inc. + * Copyright 1991 by Digital Equipment Corporation, Maynard, + * Massachusetts. Enhancements Copyright + * 1992-2001,2002,2003,2004,2005,2006,2007,2008,2009 Free Software + * Foundation, Inc. * * XBoard borrows its colors and the bitmaps.xchess bitmap set from XChess, * which was written and is copyrighted by Wayne Christopher. @@ -30,30 +32,32 @@ * SOFTWARE. * ------------------------------------------------------------------------ * - * The following terms apply to the enhanced version of XBoard distributed - * by the Free Software Foundation: + * The following terms apply to the enhanced version of XBoard + * distributed by the Free Software Foundation: * ------------------------------------------------------------------------ - * This program is free software; you can redistribute it and/or modify + * + * GNU XBoard is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * GNU XBoard is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * ------------------------------------------------------------------------ - */ + * along with this program. If not, see http://www.gnu.org/licenses/. * + * + *------------------------------------------------------------------------ + ** See the file ChangeLog for a revision history. */ #include "config.h" #include #include #include +#include #include #include @@ -66,6 +70,7 @@ #include #include #include +#include #if __GNUC__ #include @@ -95,6 +100,10 @@ extern int whiteFlag, blackFlag; Boolean flipClock = FALSE; void DisplayHoldingsCount(HDC hdc, int x, int y, int align, int copyNumber); +VOID NewVariantPopup(HWND hwnd); +int FinishMove P((ChessMove moveType, int fromX, int fromY, int toX, int toY, + /*char*/int promoChar)); +void AnimateAtomicCapture(int toX, int toY, int nFrames); typedef struct { ChessSquare piece; @@ -122,6 +131,12 @@ typedef struct { static HighlightInfo highlightInfo = { {{-1, -1}, {-1, -1}} }; static HighlightInfo premoveHighlightInfo = { {{-1, -1}, {-1, -1}} }; +typedef struct { // [HGM] atomic + int x, y, radius; +} ExplodeInfo; + +static ExplodeInfo explodeInfo = {0, 0, 0}; + /* Window class names */ char szAppName[] = "WinBoard"; char szConsoleName[] = "WBConsole"; @@ -173,7 +188,8 @@ static HWND hwndPause; /* pause button */ static HBITMAP pieceBitmap[3][(int) BlackPawn]; /* [HGM] nr of bitmaps referred to bP in stead of wK */ static HBRUSH lightSquareBrush, darkSquareBrush, blackSquareBrush, /* [HGM] for band between board and holdings */ - whitePieceBrush, blackPieceBrush, iconBkgndBrush, outlineBrush; + explodeBrush, /* [HGM] atomic */ + whitePieceBrush, blackPieceBrush, iconBkgndBrush /*, outlineBrush*/; static POINT gridEndpoints[(BOARD_SIZE + 1) * 4]; static DWORD gridVertexCounts[(BOARD_SIZE + 1) * 2]; static HPEN gridPen = NULL; @@ -243,7 +259,7 @@ SizeInfo sizeInfo[] = { NULL, 0, 0, 0, 0, 0, 0 } }; -#define MF(x) {x, {0, }, {0, }, 0} +#define MF(x) {x, {{0,}, 0. }, {0, }, 0} MyFont fontRec[NUM_SIZES][NUM_FONTS] = { { MF(CLOCK_FONT_TINY), MF(MESSAGE_FONT_TINY), MF(COORD_FONT_TINY), MF(CONSOLE_FONT_TINY), MF(COMMENT_FONT_TINY), MF(EDITTAGS_FONT_TINY), MF(MOVEHISTORY_FONT_ALL) }, @@ -474,6 +490,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, { MSG msg; HANDLE hAccelMain, hAccelNoAlt, hAccelNoICS; +// INITCOMMONCONTROLSEX ex; debugFP = stderr; @@ -487,6 +504,9 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, return (FALSE); } +// InitCommonControlsEx(&ex); + InitCommonControls(); + hAccelMain = LoadAccelerators (hInstance, szAppName); hAccelNoAlt = LoadAccelerators (hInstance, "NO_ALT"); hAccelNoICS = LoadAccelerators( hInstance, "NO_ICS"); /* [AS] No Ctrl-V on ICS!!! */ @@ -567,12 +587,14 @@ int screenHeight, screenWidth; void EnsureOnScreen(int *x, int *y) { - int gap = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION); +// int gap = GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYCAPTION); /* Be sure window at (x,y) is not off screen (or even mostly off screen) */ if (*x > screenWidth - 32) *x = 0; if (*y > screenHeight - 32) *y = 0; - if (*x < 10) *x = 10; - if (*y < gap) *y = gap; + if (*x < 0) *x = 0; + if (*y < 0) *y = 0; +// if (*x < 10) *x = 10; +// if (*y < gap) *y = gap; } BOOL @@ -1162,8 +1184,10 @@ ArgDescriptor argDescriptors[] = { { "sUCI", ArgTrue, (LPVOID) &appData.secondIsUCI, FALSE }, { "firstHasOwnBookUCI", ArgBoolean, (LPVOID) &appData.firstHasOwnBookUCI, FALSE }, { "fNoOwnBookUCI", ArgFalse, (LPVOID) &appData.firstHasOwnBookUCI, FALSE }, + { "firstXBook", ArgFalse, (LPVOID) &appData.firstHasOwnBookUCI, FALSE }, { "secondHasOwnBookUCI", ArgBoolean, (LPVOID) &appData.secondHasOwnBookUCI, FALSE }, { "sNoOwnBookUCI", ArgFalse, (LPVOID) &appData.secondHasOwnBookUCI, FALSE }, + { "secondXBook", ArgFalse, (LPVOID) &appData.secondHasOwnBookUCI, FALSE }, { "polyglotDir", ArgFilename, (LPVOID) &appData.polyglotDir, TRUE }, { "usePolyglotBook", ArgBoolean, (LPVOID) &appData.usePolyglotBook, TRUE }, { "polyglotBook", ArgFilename, (LPVOID) &appData.polyglotBook, TRUE }, @@ -1218,6 +1242,8 @@ ArgDescriptor argDescriptors[] = { { "firstLogo", ArgFilename, (LPVOID) &appData.firstLogo, FALSE }, { "secondLogo", ArgFilename, (LPVOID) &appData.secondLogo, FALSE }, { "autoLogo", ArgBoolean, (LPVOID) &appData.autoLogo, TRUE }, + { "firstOptions", ArgString, (LPVOID) &appData.firstOptions, FALSE }, + { "secondOptions", ArgString, (LPVOID) &appData.secondOptions, FALSE }, #ifdef ZIPPY { "zippyTalk", ArgBoolean, (LPVOID) &appData.zippyTalk, FALSE }, @@ -1397,6 +1423,7 @@ FileGet(void *getClosure) FILE* f = (FILE*) getClosure; c = getc(f); + if (c == '\r') c = getc(f); // work around DOS format files by bypassing the '\r' completely if (c == EOF) return NULLCHAR; else @@ -1410,8 +1437,14 @@ ParseSettingsFile(char *name, char fullname[MSG_SIZ]) { char *dummy; FILE *f; + int ok; char buf[MSG_SIZ]; - if (SearchPath(installDir, name, NULL, MSG_SIZ, fullname, &dummy)) { + ok = SearchPath(installDir, name, NULL, MSG_SIZ, fullname, &dummy); + if(!ok && strchr(name, '.') == NULL) { // [HGM] append default file-name extension '.ini' when needed + sprintf(buf, "%s.ini", name); + ok = SearchPath(installDir, buf, NULL, MSG_SIZ, fullname, &dummy); + } + if (ok) { f = fopen(fullname, "r"); if (f != NULL) { ParseArgs(FileGet, f); @@ -1662,6 +1695,8 @@ ParseArgs(GetFunc get, void *cl) case ArgNone: ExitArgError("Unrecognized argument", argValue); break; + case ArgTrue: + case ArgFalse: ; } } } @@ -1835,6 +1870,7 @@ InitAppData(LPSTR lpCmdLine) appData.reuseSecond = TRUE; appData.blindfold = FALSE; appData.icsEngineAnalyze = FALSE; + memset(&dcb, 0, sizeof(DCB)); // required by VS 2002 + dcb.DCBlength = sizeof(DCB); dcb.BaudRate = 9600; dcb.fBinary = TRUE; @@ -1849,12 +1885,6 @@ InitAppData(LPSTR lpCmdLine) dcb.fNull = FALSE; dcb.fRtsControl = RTS_CONTROL_ENABLE; dcb.fAbortOnError = FALSE; - /* Microsoft SDK >= Feb. 2003 (MS VS >= 2002) */ - #if (defined(_MSC_VER) && _MSC_VER <= 1200) - //dcb.wReserved = 0; - #else - dcb.wReserved = 0; - #endif dcb.ByteSize = 7; dcb.Parity = SPACEPARITY; dcb.StopBits = ONESTOPBIT; @@ -1936,6 +1966,8 @@ InitAppData(LPSTR lpCmdLine) appData.defaultHashSize = 64; appData.defaultCacheSizeEGTB = 4; appData.defaultPathEGTB = "c:\\egtb"; + appData.firstOptions = ""; + appData.secondOptions = ""; InitWindowPlacement( &wpMoveHistory ); InitWindowPlacement( &wpEvalGraph ); @@ -2271,14 +2303,14 @@ SaveSettings(char* name) case ArgColor: { COLORREF color = *(COLORREF *)ad->argLoc; - fprintf(f, "/%s=#%02x%02x%02x\n", ad->argName, + fprintf(f, "/%s=#%02lx%02lx%02lx\n", ad->argName, color&0xff, (color>>8)&0xff, (color>>16)&0xff); } break; case ArgAttribs: { MyTextAttribs* ta = &textAttribs[(ColorClass)ad->argLoc]; - fprintf(f, "/%s=\"%s%s%s%s%s#%02x%02x%02x\"\n", ad->argName, + fprintf(f, "/%s=\"%s%s%s%s%s#%02lx%02lx%02lx\"\n", ad->argName, (ta->effects & CFE_BOLD) ? "b" : "", (ta->effects & CFE_ITALIC) ? "i" : "", (ta->effects & CFE_UNDERLINE) ? "u" : "", @@ -2316,6 +2348,8 @@ SaveSettings(char* name) break; case ArgCommSettings: PrintCommSettings(f, ad->argName, (DCB *)ad->argLoc); + case ArgNone: + case ArgSettingsFilename: ; } } fclose(f); @@ -2986,7 +3020,7 @@ InitDrawingColors() whitePieceBrush = CreateSolidBrush(whitePieceColor); blackPieceBrush = CreateSolidBrush(blackPieceColor); iconBkgndBrush = CreateSolidBrush(GetSysColor(COLOR_BACKGROUND)); - + explodeBrush = CreateSolidBrush(highlightSquareColor); // [HGM] atomic /* [AS] Force rendering of the font-based pieces */ if( fontBitmapSquareSize > 0 ) { fontBitmapSquareSize = 0; @@ -3017,8 +3051,8 @@ ResizeBoard(int newSizeX, int newSizeY, int flags) if (recurse > 0) return; recurse++; while (newSize > 0) { - InitDrawingSizes(newSize, 0); - if(newSizeX >= sizeInfo[newSize].cliWidth || + InitDrawingSizes(newSize+1000, 0); // [HGM] kludge to update sizeInfo without visible effects + if(newSizeX >= sizeInfo[newSize].cliWidth && newSizeY >= sizeInfo[newSize].cliHeight) break; newSize--; } @@ -3045,7 +3079,10 @@ InitDrawingSizes(BoardSize boardSize, int flags) int offby; LOGBRUSH logbrush; - /* [HGM] call with -1 uses old size (for if nr of files, ranks changes) */ + int suppressVisibleEffects = 0; // [HGM] kludge to request updating sizeInfo only + if((int)boardSize >= 1000 ) { boardSize -= 1000; suppressVisibleEffects = 1; } + + /* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */ if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize; tinyLayout = sizeInfo[boardSize].tinyLayout; @@ -3148,6 +3185,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) sizeInfo[boardSize].cliWidth = boardRect.right + OUTER_MARGIN; sizeInfo[boardSize].cliHeight = boardRect.bottom + OUTER_MARGIN; + if(suppressVisibleEffects) return; // [HGM] when called for filling sizeInfo only winWidth = 2 * GetSystemMetrics(SM_CXFRAME) + boardRect.right + OUTER_MARGIN; winHeight = 2 * GetSystemMetrics(SM_CYFRAME) + GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CYCAPTION) + boardRect.bottom + OUTER_MARGIN; @@ -3239,7 +3277,6 @@ InitDrawingSizes(BoardSize boardSize, int flags) boardRect.top + lineGap / 2 + (i * (squareSize + lineGap)); gridEndpoints[i*2 + 1].x = boardRect.left + lineGap / 2 + BOARD_WIDTH * (squareSize + lineGap); - lineGap / 2 + (i * (squareSize + lineGap)); gridVertexCounts[i*2] = gridVertexCounts[i*2 + 1] = 2; } for (i = 0; i < BOARD_WIDTH + 1; i++) { @@ -3659,8 +3696,8 @@ DrawPieceOnDC(HDC hdc, ChessSquare piece, int color, int sqcolor, int x, int y, } else { tmpSize = squareSize; if(minorSize && - (piece >= (int)WhiteNightrider && piece <= WhiteGrasshopper || - piece >= (int)BlackNightrider && piece <= BlackGrasshopper) ) { + ((piece >= (int)WhiteNightrider && piece <= WhiteGrasshopper) || + (piece >= (int)BlackNightrider && piece <= BlackGrasshopper)) ) { /* [HGM] no bitmap available for promoted pieces in Crazyhouse */ /* Bitmaps of smaller size are substituted, but we have to align them */ x += (squareSize - minorSize)>>1; @@ -4196,9 +4233,9 @@ void fputDW(FILE *f, int x) VOID DrawLogoOnDC(HDC hdc, RECT logoRect, ChessProgramState *cps) { - HBITMAP bufferBitmap; +// HBITMAP bufferBitmap; BITMAP bi; - RECT Rect; +// RECT Rect; HDC tmphdc; HBITMAP hbm; int w = 100, h = 50; @@ -4444,14 +4481,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) x2 = boardRect.left + animInfo.pos.x; y2 = boardRect.top + animInfo.pos.y; clips[num_clips++] = CreateRectRgn(MIN(x,x2), MIN(y,y2), MAX(x,x2)+squareSize, MAX(y,y2)+squareSize); - /* Slight kludge. The real problem is that after AnimateMove is - done, the position on the screen does not match lastDrawn. - This currently causes trouble only on e.p. captures in - atomic, where the piece moves to an empty square and then - explodes. The old and new positions both had an empty square - at the destination, but animation has drawn a piece there and - we have to remember to erase it. */ - lastDrawn[animInfo.to.y][animInfo.to.x] = animInfo.piece; + /* [HGM] old location of "slight kludge" below */ } } @@ -4469,10 +4499,27 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) } /* Do all the drawing to the memory DC */ - DrawGridOnDC(hdcmem); - DrawHighlightsOnDC(hdcmem); - DrawBoardOnDC(hdcmem, board, tmphdc); - + if(explodeInfo.radius) { // [HGM] atomic + HBRUSH oldBrush; + int x, y, r=(explodeInfo.radius * squareSize)/100; + SquareToPos(explodeInfo.y, explodeInfo.x, &x, &y); + x += squareSize/2; + y += squareSize/2; + if(!fullrepaint) { + clips[num_clips] = CreateRectRgn(x-r, y-r, x+r, y+r); + ExtSelectClipRgn(hdcmem, clips[num_clips++], RGN_OR); + } + DrawGridOnDC(hdcmem); + DrawHighlightsOnDC(hdcmem); + DrawBoardOnDC(hdcmem, board, tmphdc); + oldBrush = SelectObject(hdcmem, explodeBrush); + Ellipse(hdcmem, x-r, y-r, x+r, y+r); + SelectObject(hdcmem, oldBrush); + } else { + DrawGridOnDC(hdcmem); + DrawHighlightsOnDC(hdcmem); + DrawBoardOnDC(hdcmem, board, tmphdc); + } if(logoHeight) { DrawLogoOnDC(hdc, leftLogoRect, flipClock ? &second : &first); DrawLogoOnDC(hdc, rightLogoRect, flipClock ? &first : &second); @@ -4511,6 +4558,14 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) DrawPieceOnDC(hdcmem, animInfo.piece, ((int) animInfo.piece < (int) BlackPawn), (animInfo.from.y + animInfo.from.x) % 2, x, y, tmphdc); + /* Slight kludge. The real problem is that after AnimateMove is + done, the position on the screen does not match lastDrawn. + This currently causes trouble only on e.p. captures in + atomic, where the piece moves to an empty square and then + explodes. The old and new positions both had an empty square + at the destination, but animation has drawn a piece there and + we have to remember to erase it. [HGM] moved until after setting lastDrawn */ + lastDrawn[animInfo.to.y][animInfo.to.x] = animInfo.piece; } /* Release the bufferBitmap by selecting in the old bitmap @@ -4537,7 +4592,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) boardRect.bottom - boardRect.top, tmphdc, boardRect.left, boardRect.top, SRCCOPY); if(saveDiagFlag) { - BITMAP b; int i, j, m, w, wb, fac=0; char pData[1000000]; + BITMAP b; int i, j=0, m, w, wb, fac=0; char pData[1000000]; BITMAPINFOHEADER bih; int color[16], nrColors=0; GetObject(bufferBitmap, sizeof(b), &b); @@ -4581,7 +4636,7 @@ HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board) while(p&3) pData[p++] = 0; } fac = 3; - wb = (wb+31>>5)<<2; + wb = ((wb+31)>>5)<<2; } // write BITMAPFILEHEADER fprintf(diagFile, "BM"); @@ -4641,9 +4696,6 @@ int SaveDiagram(f) FILE *f; { - time_t tm; - char *fen; - saveDiagFlag = 1; diagFile = f; HDCDrawPosition(NULL, TRUE, NULL); @@ -4668,7 +4720,7 @@ PaintProc(HWND hwnd) PAINTSTRUCT ps; HFONT oldFont; - if(hdc = BeginPaint(hwnd, &ps)) { + if((hdc = BeginPaint(hwnd, &ps))) { if (IsIconic(hwnd)) { DrawIcon(hdc, 2, 2, iconCurrent); } else { @@ -4761,7 +4813,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) POINT pt; static int recursive = 0; HMENU hmenu; - BOOLEAN needsRedraw = FALSE; +// BOOLEAN needsRedraw = FALSE; BOOLEAN saveAnimate; BOOLEAN forceFullRepaint = IsFullRepaintPreferrable(); /* [AS] */ static BOOLEAN sameAgain = FALSE, promotionChoice = FALSE; @@ -4836,7 +4888,7 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } if (!appData.highlightLastMove) { ClearHighlights(); - DrawPosition(forceFullRepaint || FALSE, NULL); + DrawPosition((int) (forceFullRepaint || FALSE), NULL); } fromX = fromY = -1; dragInfo.start.x = dragInfo.start.y = -1; @@ -4845,8 +4897,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) } else if (x < 0 || y < 0 /* [HGM] block clicks between board and holdings */ || x == BOARD_LEFT-1 || x == BOARD_RGHT - || x == BOARD_LEFT-2 && y < BOARD_HEIGHT-gameInfo.holdingsSize - || x == BOARD_RGHT+1 && y >= gameInfo.holdingsSize + || (x == BOARD_LEFT-2 && y < BOARD_HEIGHT-gameInfo.holdingsSize) + || (x == BOARD_RGHT+1 && y >= gameInfo.holdingsSize) /* EditPosition, empty square, or different color piece; click-click move is possible */ ) { @@ -4876,8 +4928,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if(moveType != ImpossibleMove) { /* [HGM] We use PromotionToKnight in Shogi to indicate frorced promotion */ if (moveType == WhitePromotionKnight || moveType == BlackPromotionKnight || - (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && - appData.alwaysPromoteToQueen) { + ((moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && + appData.alwaysPromoteToQueen)) { FinishMove(moveType, fromX, fromY, toX, toY, 'q'); if (!appData.highlightLastMove) { ClearHighlights(); @@ -4982,8 +5034,8 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* [HGM] use move type to determine if move is promotion. Knight is Shogi kludge for mandatory promotion, Queen means choice */ if (moveType == WhitePromotionKnight || moveType == BlackPromotionKnight || - (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && - appData.alwaysPromoteToQueen) + ((moveType == WhitePromotionQueen || moveType == BlackPromotionQueen) && + appData.alwaysPromoteToQueen)) FinishMove(moveType, fromX, fromY, toX, toY, 'q'); else if (moveType == WhitePromotionQueen || moveType == BlackPromotionQueen ) { @@ -5000,7 +5052,11 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; } else PromotionPopup(hwnd); /* [HGM] Popup now calls FinishMove */ - } else FinishMove(moveType, fromX, fromY, toX, toY, NULLCHAR); + } else { + if(saveAnimate /* ^$!%@#$!$ */ && gameInfo.variant == VariantAtomic + && boards[currentMove][toY][toX] != EmptySquare) AnimateAtomicCapture(toX, toY, 20); + FinishMove(moveType, fromX, fromY, toX, toY, NULLCHAR); + } } if (gotPremove) SetPremoveHighlights(fromX, fromY, toX, toY); appData.animate = saveAnimate; @@ -5042,15 +5098,19 @@ MouseEvent(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_MOUSEWHEEL: // [DM] + { static int lastDir = 0; // [HGM] build in some hysteresis to avoid spurious events /* Mouse Wheel is being rolled forward * Play moves forward */ - if((short)HIWORD(wParam) > 0 && currentMove < forwardMostMove) ForwardEvent(); + if((short)HIWORD(wParam) > 0 && currentMove < forwardMostMove) + { if(lastDir == 1) ForwardEvent(); else lastDir = 1; } // [HGM] suppress first event in direction /* Mouse Wheel is being rolled backward * Play moves backward */ - if((short)HIWORD(wParam) < 0 && currentMove > backwardMostMove) BackwardEvent(); - break; + if((short)HIWORD(wParam) < 0 && currentMove > backwardMostMove) + { if(lastDir == -1) BackwardEvent(); else lastDir = -1; } + } + break; case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: @@ -5206,16 +5266,16 @@ Promotion(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) SW_SHOW : SW_HIDE); /* [HGM] Only allow C & A promotions if these pieces are defined */ ShowWindow(GetDlgItem(hDlg, PB_Archbishop), - (PieceToChar(WhiteAngel) >= 'A' && - PieceToChar(WhiteAngel) != '~' || - PieceToChar(BlackAngel) >= 'A' && - PieceToChar(BlackAngel) != '~' ) ? + ((PieceToChar(WhiteAngel) >= 'A' && + PieceToChar(WhiteAngel) != '~') || + (PieceToChar(BlackAngel) >= 'A' && + PieceToChar(BlackAngel) != '~') ) ? SW_SHOW : SW_HIDE); ShowWindow(GetDlgItem(hDlg, PB_Chancellor), - (PieceToChar(WhiteMarshall) >= 'A' && - PieceToChar(WhiteMarshall) != '~' || - PieceToChar(BlackMarshall) >= 'A' && - PieceToChar(BlackMarshall) != '~' ) ? + ((PieceToChar(WhiteMarshall) >= 'A' && + PieceToChar(WhiteMarshall) != '~') || + (PieceToChar(BlackMarshall) >= 'A' && + PieceToChar(BlackMarshall) != '~') ) ? SW_SHOW : SW_HIDE); /* [HGM] Hide B & R button in Shogi, use Q as promote, N as defer */ ShowWindow(GetDlgItem(hDlg, PB_Rook), @@ -6765,7 +6825,7 @@ SetStartupDialogEnables(HWND hDlg) { EnableWindow(GetDlgItem(hDlg, OPT_ChessEngineName), IsDlgButtonChecked(hDlg, OPT_ChessEngine) || - appData.zippyPlay && IsDlgButtonChecked(hDlg, OPT_ChessServer)); + (appData.zippyPlay && IsDlgButtonChecked(hDlg, OPT_ChessServer))); EnableWindow(GetDlgItem(hDlg, OPT_SecondChessEngineName), IsDlgButtonChecked(hDlg, OPT_ChessEngine)); EnableWindow(GetDlgItem(hDlg, OPT_ChessServerName), @@ -7391,8 +7451,6 @@ VOID GothicPopUp(char *title, VariantClass variant) { FARPROC lpProc; - char *p, *q; - BOOLEAN modal = hwndMain == NULL; static char *lastTitle; strncpy(errorTitle, title, sizeof(errorTitle)); @@ -7473,7 +7531,7 @@ IcsTextMenuEntry icsTextMenuEntry[ICS_TEXT_MENU_SIZE]; void ParseIcsTextMenu(char *icsTextMenuString) { - int flags = 0; +// int flags = 0; IcsTextMenuEntry *e = icsTextMenuEntry; char *p = icsTextMenuString; while (e->item != NULL && e < icsTextMenuEntry + ICS_TEXT_MENU_SIZE) { @@ -7916,8 +7974,8 @@ LRESULT CALLBACK ConsoleWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static SnapData sd; - static HWND hText, hInput, hFocus; - InputSource *is = consoleInputSource; + static HWND hText, hInput /*, hFocus*/; +// InputSource *is = consoleInputSource; RECT rect; static int sizeX, sizeY; int newSizeX, newSizeY; @@ -8282,7 +8340,7 @@ void CheckForInputBufferFull( InputSource * is ) if( p >= is->next ) { if (appData.debugMode) { - fprintf( debugFP, "Input line exceeded buffer size (source id=%u)\n", is->id ); + fprintf( debugFP, "Input line exceeded buffer size (source id=%lu)\n", is->id ); } is->error = ERROR_BROKEN_PIPE; /* [AS] Just any non-successful code! */ @@ -8331,7 +8389,7 @@ InputThread(LPVOID arg) CloseHandle(is->hFile); if (appData.debugMode) { - fprintf( debugFP, "Input thread terminated (id=%u, error=%d, count=%d)\n", is->id, is->error, is->count ); + fprintf( debugFP, "Input thread terminated (id=%lu, error=%d, count=%ld)\n", is->id, is->error, is->count ); } return 0; @@ -8845,7 +8903,7 @@ DisplayMessage(char *str1, char *str2) } messageText[MESSAGE_TEXT_MAX - 1] = NULLCHAR; - if (IsIconic(hwndMain)) return; + if (hwndMain == NULL || IsIconic(hwndMain)) return; hdc = GetDC(hwndMain); oldFont = SelectObject(hdc, font[boardSize][MESSAGE_FONT]->hf); ExtTextOut(hdc, messageRect.left, messageRect.top, ETO_CLIPPED|ETO_OPAQUE, @@ -9213,7 +9271,7 @@ LRESULT CALLBACK GameListOptions_Proc(HWND hDlg, UINT message, WPARAM wParam, LP { char * pc = lpUserGLT; int idx = 0; - int cnt = (int) SendDlgItemMessage( hDlg, IDC_GameListTags, LB_GETCOUNT, 0, 0 ); +// int cnt = (int) SendDlgItemMessage( hDlg, IDC_GameListTags, LB_GETCOUNT, 0, 0 ); char id; do { @@ -9764,7 +9822,7 @@ DestroyChildProcess(ProcRef pr, int/*boolean*/ signal) result = TerminateProcess( cp->hProcess, 0 ); if ( appData.debugMode) { - fprintf( debugFP, "Terminating process %u, result=%d\n", cp->pid, result ); + fprintf( debugFP, "Terminating process %lu, result=%d\n", cp->pid, result ); } } else if( signal == 10 ) { @@ -9774,7 +9832,7 @@ DestroyChildProcess(ProcRef pr, int/*boolean*/ signal) result = TerminateProcess( cp->hProcess, 0 ); if ( appData.debugMode) { - fprintf( debugFP, "Process %u still alive after timeout, killing... result=%d\n", cp->pid, result ); + fprintf( debugFP, "Process %lu still alive after timeout, killing... result=%d\n", cp->pid, result ); } } @@ -10528,6 +10586,22 @@ static void Tween( POINT * start, POINT * mid, POINT * finish, int factor, POINT frames[], int * nFrames); +void +AnimateAtomicCapture(int toX, int toY, int nFrames) +{ // [HGM] atomic: animate blast wave + int i; +if(appData.debugMode) fprintf(debugFP, "exploding (%d,%d)\n", toX, toY); + explodeInfo.x = toX; + explodeInfo.y = toY; + for(i=0; i