X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=winboard%2Fwinboard.c;h=e4b8692a25517b987b4994008c554826a8334e20;hb=HEAD;hp=ed71d937d2a090b290f2ef992057f19b045eaf17;hpb=23f576b5778c131f6c445fecc23e9d9aa693a5e3;p=xboard.git diff --git a/winboard/winboard.c b/winboard/winboard.c index ed71d93..e4b8692 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -2,10 +2,11 @@ * WinBoard.c -- Windows NT front end to XBoard * * Copyright 1991 by Digital Equipment Corporation, Maynard, - * Massachusetts. + * Massachusetts. * * Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006, - * 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. + * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free + * Software Foundation, Inc. * * Enhancements Copyright 2005 Alessandro Scotti * @@ -92,6 +93,9 @@ #include "help.h" #include "wsnap.h" +#define SLASH '/' +#define DATADIR "~~" + //void InitEngineUCI( const char * iniDir, ChessProgramState * cps ); int myrandom(void); @@ -163,7 +167,7 @@ BoardSize boardSize; Boolean chessProgram; //static int boardX, boardY; int minX, minY; // [HGM] placement: volatile limits on upper-left corner -int squareSize, lineGap, minorSize, border; +int squareSize, lineGap, minorSize; static int winW, winH; static RECT messageRect, whiteRect, blackRect, leftLogoRect, rightLogoRect; // [HGM] logo static int logoHeight = 0; @@ -257,7 +261,8 @@ int dialogItems[][42] = { { DLG_TimeControl, IDC_Babble, OPT_TCUseMoves, OPT_TCUseInc, OPT_TCUseFixed, OPT_TCtext1, OPT_TCtext2, OPT_TCitext1, OPT_TCitext2, OPT_TCftext, GPB_Factors, IDC_Factor1, IDC_Factor2, IDOK, IDCANCEL }, { DLG_LoadOptions, OPT_Autostep, OPT_AStext1, OPT_Exact, OPT_Subset, OPT_Struct, OPT_Material, OPT_Range, OPT_Difference, - OPT_elo1t, OPT_elo2t, OPT_datet, OPT_Stretch, OPT_Stretcht, OPT_Reversed, OPT_SearchMode, OPT_Mirror, OPT_thresholds, IDOK, IDCANCEL }, + OPT_elo1t, OPT_elo2t, OPT_datet, OPT_Stretch, OPT_Stretcht, OPT_Reversed, OPT_SearchMode, OPT_Mirror, OPT_thresholds, + OPT_Ranget, IDOK, IDCANCEL }, { DLG_SaveOptions, OPT_Autosave, OPT_AVPrompt, OPT_AVToFile, OPT_AVBrowse, 801, OPT_PGN, OPT_Old, OPT_OutOfBookInfo, IDOK, IDCANCEL }, { 1536, 1090, IDC_Directories, 1089, 1091, IDOK, IDCANCEL, 1038, IDC_IndexNr, 1037 }, @@ -530,12 +535,12 @@ typedef struct { SizeInfo sizeInfo[] = { - { "tiny", 21, 0, 1, 1, 0, 0 }, - { "teeny", 25, 1, 1, 1, 0, 0 }, - { "dinky", 29, 1, 1, 1, 0, 0 }, - { "petite", 33, 1, 1, 1, 0, 0 }, - { "slim", 37, 2, 1, 0, 0, 0 }, - { "small", 40, 2, 1, 0, 0, 0 }, + { "tiny", 21, 0, 1, 2, 0, 0 }, + { "teeny", 25, 1, 1, 2, 0, 0 }, + { "dinky", 29, 1, 1, 2, 0, 0 }, + { "petite", 33, 1, 1, 2, 0, 0 }, + { "slim", 37, 2, 1, 1, 0, 0 }, + { "small", 40, 2, 1, 1, 0, 0 }, { "mediocre", 45, 2, 1, 0, 0, 0 }, { "middling", 49, 2, 0, 0, 0, 0 }, { "average", 54, 2, 0, 0, 0, 0 }, @@ -583,7 +588,7 @@ typedef struct { WNDPROC wndproc; } MyButtonDesc; -#define BUTTON_WIDTH (tinyLayout ? 16 : 32) +#define BUTTON_WIDTH (tinyLayout == 2 ? 16 : 32) #define N_BUTTONS 5 MyButtonDesc buttonDesc[N_BUTTONS] = @@ -597,8 +602,9 @@ MyButtonDesc buttonDesc[N_BUTTONS] = int tinyLayout = 0, smallLayout = 0; #define MENU_BAR_ITEMS 9 -char *menuBarText[2][MENU_BAR_ITEMS+1] = { +char *menuBarText[3][MENU_BAR_ITEMS+1] = { { N_("&File"), N_("&Edit"), N_("&View"), N_("&Mode"), N_("&Action"), N_("E&ngine"), N_("&Options"), N_("&Help"), NULL }, + { N_("&Fil"), N_("&Ed"), N_("&Vw"), N_("&Mod"), N_("&Act"), N_("E&ng"), N_("&Opt"), N_("&Hlp"), NULL }, { N_("&F"), N_("&E"), N_("&V"), N_("&M"), N_("&A"), N_("&N"), N_("&O"), N_("&H"), NULL }, }; @@ -782,12 +788,14 @@ void ThawUI() * \*---------------------------------------------------------------------------*/ +static void HandleMessage P((MSG *message)); +static HANDLE hAccelMain, hAccelNoAlt, hAccelNoICS; + int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { MSG msg; - HANDLE hAccelMain, hAccelNoAlt, hAccelNoICS; // INITCOMMONCONTROLSEX ex; debugFP = stderr; @@ -819,6 +827,17 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 0, /* lowest message to examine */ 0)) /* highest message to examine */ { + HandleMessage(&msg); + } + + + return (msg.wParam); /* Returns the value from PostQuitMessage */ +} + +static void +HandleMessage (MSG *message) +{ + MSG msg = *message; if(msg.message == WM_CHAR && msg.wParam == '\t') { // [HGM] navigate: switch between all windows with tab @@ -886,7 +905,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, if(currentElement < 5 && IsIconic(hwndMain)) ShowWindow(hwndMain, SW_RESTORE); // all open together SetFocus(h); - continue; // this message now has been processed + return; // this message now has been processed } } @@ -905,14 +924,24 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, if(chatHandle[i] && IsDialogMessage(chatHandle[i], &msg)) { done = 1; break; } - if(done) continue; // [HGM] chat: end patch + if(done) return; // [HGM] chat: end patch TranslateMessage(&msg); /* Translates virtual key codes */ DispatchMessage(&msg); /* Dispatches message to window */ } - } - +} - return (msg.wParam); /* Returns the value from PostQuitMessage */ +void +DoEvents () +{ /* Dispatch pending messages */ + MSG msg; + while (PeekMessage(&msg, /* message structure */ + NULL, /* handle of window receiving the message */ + 0, /* lowest message to examine */ + 0, /* highest message to examine */ + PM_REMOVE)) + { + HandleMessage(&msg); + } } /*---------------------------------------------------------------------------*\ @@ -981,16 +1010,17 @@ InitApplication(HINSTANCE hInstance) /* Set by InitInstance, used by EnsureOnScreen */ int screenHeight, screenWidth; +RECT screenGeometry; void EnsureOnScreen(int *x, int *y, int minX, int minY) { // 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 < minX) *x = minX; - if (*y < minY) *y = minY; + if (*x > screenGeometry.right - 32) *x = screenGeometry.left; + if (*y > screenGeometry.bottom - 32) *y = screenGeometry.top; + if (*x < screenGeometry.left + minX) *x = screenGeometry.left + minX; + if (*y < screenGeometry.top + minY) *y = screenGeometry.top + minY; } VOID @@ -1051,6 +1081,34 @@ InitTextures() } } +#ifndef SM_CXVIRTUALSCREEN +#define SM_CXVIRTUALSCREEN 78 +#endif +#ifndef SM_CYVIRTUALSCREEN +#define SM_CYVIRTUALSCREEN 79 +#endif +#ifndef SM_XVIRTUALSCREEN +#define SM_XVIRTUALSCREEN 76 +#endif +#ifndef SM_YVIRTUALSCREEN +#define SM_YVIRTUALSCREEN 77 +#endif + +VOID +InitGeometry() +{ + screenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN); + if( !screenHeight ) screenHeight = GetSystemMetrics(SM_CYSCREEN); + screenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN); + if( !screenWidth ) screenWidth = GetSystemMetrics(SM_CXSCREEN); + screenGeometry.left = GetSystemMetrics(SM_XVIRTUALSCREEN); + screenGeometry.top = GetSystemMetrics(SM_YVIRTUALSCREEN); + screenGeometry.right = screenGeometry.left + screenWidth; + screenGeometry.bottom = screenGeometry.top + screenHeight; +} + +ChessProgramState broadcast; + BOOL InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) { @@ -1069,7 +1127,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) GetCurrentDirectory(MSG_SIZ, installDir); } gameInfo.boardWidth = gameInfo.boardHeight = 8; // [HGM] won't have open window otherwise - screenWidth = screenHeight = 1000; // [HGM] placement: kludge to allow calling EnsureOnScreen from InitAppData + InitGeometry(); InitAppData(lpCmdLine); /* Get run-time parameters */ /* xboard, and older WinBoards, controlled the move sound with the appData.ringBellAfterMoves option. In the current WinBoard, we @@ -1083,7 +1141,18 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) appData.ringBellAfterMoves = TRUE; } if (appData.debugMode) { - debugFP = fopen(appData.nameOfDebugFile, "w"); + char *c = appData.nameOfDebugFile; + if(strstr(c, "///") == c) { + broadcast.which = "broadcaster"; + broadcast.pr = NoProc; + broadcast.isr = NULL; + broadcast.program = c + 3; + broadcast.dir = "."; + broadcast.host = "localhost"; + StartChessProgram(&broadcast); + debugFP = (FILE*) _fdopen(_open_osfhandle((long)(((ChildProc*)(broadcast.pr))->hTo), _O_WRONLY), "w"); + } else + debugFP = fopen(c, "w"); setbuf(debugFP, NULL); } @@ -1116,8 +1185,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine) iconBlack = LoadIcon(hInstance, "icon_black"); iconCurrent = iconWhite; InitDrawingColors(); - screenHeight = GetSystemMetrics(SM_CYSCREEN); - screenWidth = GetSystemMetrics(SM_CXSCREEN); + InitPosition(0); // to set nr of ranks and files, which might be non-default through command-line args for (ibs = (int) NUM_SIZES - 1; ibs >= 0; ibs--) { /* Compute window size for each board size, and use the largest @@ -1198,6 +1266,7 @@ InitMenuChecks() (void) CheckMenuItem(hmenu, IDM_SaveSettingsOnExit, MF_BYCOMMAND|(saveSettingsOnExit ? MF_CHECKED : MF_UNCHECKED)); + EnableMenuItem(hmenu, IDM_SaveSelected, MF_GRAYED); } //--------------------------------------------------------------------------------------------------------- @@ -1228,6 +1297,9 @@ LFfromMFP(LOGFONT* lf, MyFontParams *mfp) lf->lfStrikeOut = mfp->strikeout; lf->lfCharSet = mfp->charset; lf->lfOutPrecision = OUT_DEFAULT_PRECIS; + + + lf->lfClipPrecision = CLIP_DEFAULT_PRECIS; lf->lfQuality = DEFAULT_QUALITY; lf->lfPitchAndFamily = DEFAULT_PITCH|FF_DONTCARE; @@ -1781,6 +1853,8 @@ static void CreatePieceMaskFromFont( HDC hdc_window, HDC hdc, int index ) COLORREF chroma = RGB(0xFF,0x00,0xFF); RECT rc; SIZE sz; + + POINT pt; int backColor = whitePieceColor; int foreColor = blackPieceColor; @@ -2270,6 +2344,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) { // correct board size to one where built-in pieces exist if((v == VariantCapablanca || v == VariantGothic || v == VariantGrand || v == VariantCapaRandom || v == VariantJanus || v == VariantSuper) && (boardSize < SizePetite || boardSize > SizeBulky) // Archbishop and Chancellor available in entire middle range + || (v == VariantShogi && boardSize != SizeModerate) // Japanese-style Shogi || v == VariantKnightmate || v == VariantSChess || v == VariantXiangqi || v == VariantSpartan || v == VariantShatranj || v == VariantMakruk || v == VariantGreat || v == VariantFairy || v == VariantLion ) { @@ -2292,13 +2367,17 @@ InitDrawingSizes(BoardSize boardSize, int flags) minorSize = 0; /* [HGM] Kludge to see if demagnified pieces need to be shifted */ border = appData.useBorder && appData.border[0] ? squareSize/2 : 0; + // [HGM] decide on tininess based on total board width rather than square size + tinyLayout = squareSize * (BOARD_WIDTH); + tinyLayout = tinyLayout < 35*8 ? 2 : tinyLayout < 43*8 ? 1 : 0; + if( appData.overrideLineGap >= 0 && appData.overrideLineGap <= 5 ) { lineGap = appData.overrideLineGap; } if (tinyLayout != oldTinyLayout) { long style = GetWindowLongPtr(hwndMain, GWL_STYLE); - if (tinyLayout) { + if (tinyLayout == 2) { style &= ~WS_SYSMENU; InsertMenu(hmenu, IDM_Exit, MF_BYCOMMAND, IDM_Minimize, "&Minimize\tCtrl+F4"); @@ -2334,7 +2413,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) ReleaseDC(hwndMain, hdc); /* Compute where everything goes */ - if((first.programLogo || second.programLogo) && !tinyLayout) { + if((first.programLogo || second.programLogo) && tinyLayout != 2) { /* [HGM] logo: if either logo is on, reserve space for it */ logoHeight = 2*clockSize.cy; leftLogoRect.left = OUTER_MARGIN; @@ -2455,7 +2534,7 @@ InitDrawingSizes(BoardSize boardSize, int flags) messageRect.top, BUTTON_WIDTH, messageSize.cy, hwndMain, (HMENU) buttonDesc[i].id, (HINSTANCE) GetWindowLongPtr(hwndMain, GWLP_HINSTANCE), NULL); - if (tinyLayout) { + if (tinyLayout == 2) { SendMessage(buttonDesc[i].hwnd, WM_SETFONT, (WPARAM)font[boardSize][MESSAGE_FONT]->hf, MAKELPARAM(FALSE, 0)); @@ -2524,10 +2603,12 @@ InitDrawingSizes(BoardSize boardSize, int flags) piece = (ChessSquare) ((int) piece + 1)) { if (pieceBitmap[i][piece] != NULL) DeleteObject(pieceBitmap[i][piece]); + pieceBitmap[i][piece] = NULL; } } fontBitmapSquareSize = 0; /* [HGM] render: make sure pieces will be recreated, as we might need others now */ + // Orthodox Chess pieces pieceBitmap[0][WhitePawn] = DoLoadBitmap(hInst, "p", squareSize, "s"); pieceBitmap[0][WhiteKnight] = DoLoadBitmap(hInst, "n", squareSize, "s"); @@ -2625,14 +2706,29 @@ InitDrawingSizes(BoardSize boardSize, int flags) pieceBitmap[0][WhiteLance] = DoLoadBitmap(hInst, "l", squareSize, "s"); pieceBitmap[1][WhiteLance] = DoLoadBitmap(hInst, "l", squareSize, "o"); pieceBitmap[2][WhiteLance] = DoLoadBitmap(hInst, "l", squareSize, "w"); + pieceBitmap[0][WhiteAmazon] = DoLoadBitmap(hInst, "l", squareSize, "s"); + pieceBitmap[1][WhiteAmazon] = DoLoadBitmap(hInst, "l", squareSize, "o"); + pieceBitmap[2][WhiteAmazon] = DoLoadBitmap(hInst, "l", squareSize, "w"); pieceBitmap[0][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "s"); pieceBitmap[1][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "o"); pieceBitmap[2][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "w"); pieceBitmap[0][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "s"); pieceBitmap[1][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "o"); pieceBitmap[2][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "w"); - - if(gameInfo.variant == VariantShogi) { /* promoted Gold represemtations */ + pieceBitmap[0][WhiteCub] = DoLoadBitmap(hInst, "ln", squareSize, "s"); + pieceBitmap[1][WhiteCub] = DoLoadBitmap(hInst, "ln", squareSize, "o"); + pieceBitmap[2][WhiteCub] = DoLoadBitmap(hInst, "ln", squareSize, "w"); + pieceBitmap[0][WhiteWolf] = DoLoadBitmap(hInst, "wolf", squareSize, "s"); + pieceBitmap[1][WhiteWolf] = DoLoadBitmap(hInst, "wolf", squareSize, "o"); + pieceBitmap[2][WhiteWolf] = DoLoadBitmap(hInst, "wolf", squareSize, "w"); + pieceBitmap[0][WhiteCamel] = DoLoadBitmap(hInst, "camel", squareSize, "s"); + pieceBitmap[1][WhiteCamel] = DoLoadBitmap(hInst, "camel", squareSize, "o"); + pieceBitmap[2][WhiteCamel] = DoLoadBitmap(hInst, "camel", squareSize, "w"); + pieceBitmap[0][WhiteZebra] = DoLoadBitmap(hInst, "zebra", squareSize, "s"); + pieceBitmap[1][WhiteZebra] = DoLoadBitmap(hInst, "zebra", squareSize, "o"); + pieceBitmap[2][WhiteZebra] = DoLoadBitmap(hInst, "n", squareSize, "w"); + + if(gameInfo.variant == VariantShogi && BOARD_HEIGHT != 7) { /* promoted Gold representations (but not in Tori!)*/ pieceBitmap[0][WhiteCannon] = DoLoadBitmap(hInst, "wp", squareSize, "s"); pieceBitmap[1][WhiteCannon] = DoLoadBitmap(hInst, "wp", squareSize, "o"); pieceBitmap[2][WhiteCannon] = DoLoadBitmap(hInst, "w", squareSize, "w"); @@ -2732,6 +2828,15 @@ InitDrawingSizes(BoardSize boardSize, int flags) pieceBitmap[2][WhiteSilver] = DoLoadBitmap(hInst, "sw", squareSize, "w"); minorSize = 0; } + + if(appData.pieceDirectory[0]) for(i=WhitePawn; iflags & SWP_NOMOVE) == 0) && ((lpwp->flags & SWP_NOSIZE) != 0) ) { + if( ((lpwp->flags & SWP_NOMOVE) == 0) /*&& ((lpwp->flags & SWP_NOSIZE) != 0)*/ ) { // [HGM] in Win8 size always accompanies move? /* Window is moving */ RECT rcMain; @@ -5618,6 +5749,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, hwndConsole, &wpConsole ); wpMain.x = lpwp->x; wpMain.y = lpwp->y; + } } break; @@ -5670,6 +5802,8 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) default: /* Passes it on if unprocessed */ return (DefWindowProc(hwnd, message, wParam, lParam)); } + + return 0; } @@ -6360,7 +6494,7 @@ LRESULT CALLBACK CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static HANDLE hwndText = NULL; - int len, newSizeX, newSizeY, flags; + int len, newSizeX, newSizeY; static int sizeX, sizeY; char *str; RECT rect; @@ -6388,7 +6522,6 @@ CommentDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) /* Size and position the dialog */ if (!commentDialog) { commentDialog = hDlg; - flags = SWP_NOZORDER; GetClientRect(hDlg, &rect); sizeX = rect.right; sizeY = rect.bottom; @@ -6634,7 +6767,7 @@ TypeInNameDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) case IDOK: GetDlgItemText(hDlg, OPT_Name, move, sizeof(move)); appData.userName = strdup(move); - SetUserLogo(); + SetUserLogo(); DisplayLogos(); SetGameInfo(); if(gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack) { snprintf(move, MSG_SIZ, "%s vs. %s", gameInfo.white, gameInfo.black); @@ -6725,7 +6858,6 @@ ErrorPopDown() LRESULT CALLBACK ErrorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - HANDLE hwndText; RECT rChild; switch (message) { @@ -6749,7 +6881,6 @@ ErrorDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) errorDialog = hDlg; SetWindowText(hDlg, errorTitle); - hwndText = GetDlgItem(hDlg, OPT_ErrorText); SetDlgItemText(hDlg, OPT_ErrorText, errorMessage); return FALSE; @@ -6775,7 +6906,6 @@ HWND gothicDialog = NULL; LRESULT CALLBACK GothicDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - HANDLE hwndText; RECT rChild; int height = GetSystemMetrics(SM_CYCAPTION)+GetSystemMetrics(SM_CYFRAME); @@ -6794,7 +6924,6 @@ GothicDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) */ gothicDialog = hDlg; SetWindowText(hDlg, errorTitle); - hwndText = GetDlgItem(hDlg, OPT_ErrorText); SetDlgItemText(hDlg, OPT_ErrorText, errorMessage); return FALSE; @@ -7578,7 +7707,7 @@ DisplayAClock(HDC hdc, int timeRemaining, int highlight, if (twoBoards && partnerUp) return; if (appData.clockMode) { - if (tinyLayout) + if (tinyLayout == 2) snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%c %s %s", color[0], TimeString(timeRemaining), flagFell); else snprintf(buf, sizeof(buf)/sizeof(buf[0]), "%s:%c%s %s", color, (logoHeight>0 ? 0 : ' '), TimeString(timeRemaining), flagFell); @@ -7594,6 +7723,7 @@ DisplayAClock(HDC hdc, int timeRemaining, int highlight, oldFg = SetTextColor(hdc, RGB(0, 0, 0)); /* black */ oldBg = SetBkColor(hdc, RGB(255, 255, 255)); /* white */ } + oldFont = SelectObject(hdc, font[boardSize][CLOCK_FONT]->hf); JAWS_SILENCE @@ -7671,6 +7801,7 @@ DoWriteFile(HANDLE hFile, char *buf, int count, DWORD *outCount, else err = GetLastError(); } + } return err; } @@ -7909,6 +8040,7 @@ Enables gnuEnables[] = { { IDM_Annotate, MF_BYCOMMAND|MF_GRAYED }, { IDM_NewChat, MF_BYCOMMAND|MF_GRAYED }, + // Needed to switch from ncp to GNU mode on Engine Load { ACTION_POS, MF_BYPOSITION|MF_ENABLED }, { IDM_MachineWhite, MF_BYCOMMAND|MF_ENABLED }, @@ -8138,6 +8270,8 @@ ModeHighlight() nowChecked = 0; break; } + if(prevChecked == IDM_TwoMachines) // [HGM] 'Machine Match' might have gotten disabled when stopping match + EnableMenuItem(GetMenu(hwndMain), IDM_Match, MF_BYCOMMAND|MF_ENABLED); CheckMark(prevChecked, MF_UNCHECKED); CheckMark(nowChecked, MF_CHECKED); CheckMark(IDM_Match, matchMode && matchGame < appData.matchGames ? MF_CHECKED : MF_UNCHECKED); @@ -8382,6 +8516,7 @@ DisplayFatalError(char *str, int error, int exitStatus) fprintf(debugFP, "%s: %s\n", label, str); } if (appData.popupExitMessage) { + if(appData.icsActive) SendToICS("logout\n"); // [HGM] make sure no new games will be started! (void) MessageBox(hwndMain, str, label, MB_OK| (exitStatus ? MB_ICONSTOP : MB_ICONINFORMATION)); } @@ -8645,8 +8780,11 @@ int GameListOptions() result = DialogBoxParam( hInst, MAKEINTRESOURCE(DLG_GameListOptions), hwndMain, (DLGPROC)lpProc, (LPARAM)lpUserGLT ); if( result == 0 ) { + char *oldTags = appData.gameListTags; /* [AS] Memory leak here! */ appData.gameListTags = strdup( lpUserGLT ); + if(strcmp(oldTags, appData.gameListTags)) // [HGM] redo Game List when we changed something + GameListToListBox(NULL, TRUE, ".", NULL, FALSE, FALSE); // "." as filter is kludge to select all } return result; @@ -9001,6 +9139,7 @@ IDLE_PRIORITY_CLASS 0x00000040 */ if (nice < -15) return 0x00000080; if (nice < 0) return 0x00008000; + if (nice == 0) return 0x00000020; if (nice < 15) return 0x00004000; return 0x00000040; @@ -9204,15 +9343,15 @@ DestroyChildProcess(ProcRef pr, int/*boolean*/ signal) /*!!if (signal) GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, cp->pid);*/ /* [AS] Special termination modes for misbehaving programs... */ - if( signal == 9 ) { + if( signal & 8 ) { result = TerminateProcess( cp->hProcess, 0 ); if ( appData.debugMode) { fprintf( debugFP, "Terminating process %lu, result=%d\n", cp->pid, result ); } } - else if( signal == 10 ) { - DWORD dw = WaitForSingleObject( cp->hProcess, 3*1000 ); // Wait 3 seconds at most + else if( signal & 4 ) { + DWORD dw = WaitForSingleObject( cp->hProcess, appData.delayAfterQuit*1000 + 50 ); // Wait 3 seconds at most if( dw != WAIT_OBJECT_0 ) { result = TerminateProcess( cp->hProcess, 0 ); @@ -9709,6 +9848,7 @@ OutputToProcess(ProcRef pr, char *message, int count, int *outError) int outCount = SOCKET_ERROR; ChildProc *cp = (ChildProc *) pr; static OVERLAPPED ovl; + static int line = 0; if (pr == NoProc) @@ -9910,8 +10050,8 @@ AnimateMove(board, fromX, fromY, toX, toY) int toX; int toY; { - ChessSquare piece; - int x = toX, y = toY; + ChessSquare piece, victim = EmptySquare, victim2 = EmptySquare; + int x = toX, y = toY, x2 = kill2X; POINT start, finish, mid; POINT frames[kFactor * 2 + 1]; int nFrames, n; @@ -9924,7 +10064,11 @@ AnimateMove(board, fromX, fromY, toX, toY) piece = board[fromY][fromX]; if (piece >= EmptySquare) return; - if(killX >= 0) toX = killX, toY = killY; // [HGM] lion: first to kill square + if(x2 >= 0) toX = kill2X, toY = kill2Y, victim = board[killY][killX], victim2 = board[kill2Y][kill2X]; else + if(killX >= 0) toX = killX, toY = killY, victim = board[killY][killX]; // [HGM] lion: first to kill square + + animInfo.from.x = fromX; + animInfo.from.y = fromY; again: @@ -9952,22 +10096,30 @@ again: else Tween(&start, &mid, &finish, kFactor, frames, &nFrames); - animInfo.from.x = fromX; - animInfo.from.y = fromY; animInfo.to.x = toX; animInfo.to.y = toY; animInfo.lastpos = start; animInfo.piece = piece; for (n = 0; n < nFrames; n++) { animInfo.pos = frames[n]; - DrawPosition(FALSE, NULL); + DrawPosition(FALSE, board); animInfo.lastpos = animInfo.pos; Sleep(appData.animSpeed); } animInfo.pos = finish; - DrawPosition(FALSE, NULL); + DrawPosition(FALSE, board); - if(toX != x || toY != y) { fromX = toX; fromY = toY; toX = x; toY = y; goto again; } // second leg + if(toX == x2 && toY == kill2Y) { + fromX = toX; fromY = toY; toX = killX; toY = killY; x2 = -1; + board[kill2Y][kill2X] = EmptySquare; goto again; + } // second leg + if(toX != x || toY != y) { + fromX = toX; fromY = toY; toX = x; toY = y; + board[killY][killX] = EmptySquare; goto again; + } // second leg + +if(victim2 != EmptySquare) board[kill2Y][kill2X] = victim2; +if(victim != EmptySquare) board[killY][killX] = victim; animInfo.piece = EmptySquare; Explode(board, fromX, fromY, toX, toY); @@ -10046,6 +10198,7 @@ int flock(int fid, int code) ov.OffsetHigh = 0; switch(code) { case 1: LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, 1024, 0, &ov); break; // LOCK_SH + case 2: LockFileEx(hFile, LOCKFILE_EXCLUSIVE_LOCK, 0, 1024, 0, &ov); break; // LOCK_EX case 3: UnlockFileEx(hFile, 0, 1024, 0, &ov); break; // LOCK_UN default: return -1;