* Massachusetts.\r
*\r
* Enhancements Copyright 1992-2001, 2002, 2003, 2004, 2005, 2006,\r
- * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Free Software Foundation, Inc.\r
+ * 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 Free\r
+ * Software Foundation, Inc.\r
*\r
* Enhancements Copyright 2005 Alessandro Scotti\r
*\r
screenGeometry.bottom = screenGeometry.top + screenHeight;\r
}\r
\r
+ChessProgramState broadcast;\r
+\r
BOOL\r
InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine)\r
{\r
appData.ringBellAfterMoves = TRUE;\r
}\r
if (appData.debugMode) {\r
- debugFP = fopen(appData.nameOfDebugFile, "w");\r
+ char *c = appData.nameOfDebugFile;\r
+ if(strstr(c, "///") == c) {\r
+ broadcast.which = "broadcaster";\r
+ broadcast.pr = NoProc;\r
+ broadcast.isr = NULL;\r
+ broadcast.program = c + 3;\r
+ broadcast.dir = ".";\r
+ broadcast.host = "localhost";\r
+ StartChessProgram(&broadcast);\r
+ debugFP = (FILE*) _fdopen(_open_osfhandle((long)(((ChildProc*)(broadcast.pr))->hTo), _O_WRONLY), "w");\r
+ } else\r
+ debugFP = fopen(c, "w");\r
setbuf(debugFP, NULL);\r
}\r
\r
piece = (ChessSquare) ((int) piece + 1)) {\r
if (pieceBitmap[i][piece] != NULL)\r
DeleteObject(pieceBitmap[i][piece]);\r
+ pieceBitmap[i][piece] = NULL;\r
}\r
}\r
\r
fontBitmapSquareSize = 0; /* [HGM] render: make sure pieces will be recreated, as we might need others now */\r
+\r
// Orthodox Chess pieces\r
pieceBitmap[0][WhitePawn] = DoLoadBitmap(hInst, "p", squareSize, "s");\r
pieceBitmap[0][WhiteKnight] = DoLoadBitmap(hInst, "n", squareSize, "s");\r
pieceBitmap[0][WhiteLance] = DoLoadBitmap(hInst, "l", squareSize, "s");\r
pieceBitmap[1][WhiteLance] = DoLoadBitmap(hInst, "l", squareSize, "o");\r
pieceBitmap[2][WhiteLance] = DoLoadBitmap(hInst, "l", squareSize, "w");\r
+ pieceBitmap[0][WhiteAmazon] = DoLoadBitmap(hInst, "l", squareSize, "s");\r
+ pieceBitmap[1][WhiteAmazon] = DoLoadBitmap(hInst, "l", squareSize, "o");\r
+ pieceBitmap[2][WhiteAmazon] = DoLoadBitmap(hInst, "l", squareSize, "w");\r
pieceBitmap[0][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "s");\r
pieceBitmap[1][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "o");\r
pieceBitmap[2][WhiteUnicorn] = DoLoadBitmap(hInst, "u", squareSize, "w");\r
pieceBitmap[0][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "s");\r
pieceBitmap[1][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "o");\r
pieceBitmap[2][WhiteLion] = DoLoadBitmap(hInst, "ln", squareSize, "w");\r
+ pieceBitmap[0][WhiteCub] = DoLoadBitmap(hInst, "ln", squareSize, "s");\r
+ pieceBitmap[1][WhiteCub] = DoLoadBitmap(hInst, "ln", squareSize, "o");\r
+ pieceBitmap[2][WhiteCub] = DoLoadBitmap(hInst, "ln", squareSize, "w");\r
+ pieceBitmap[0][WhiteWolf] = DoLoadBitmap(hInst, "wolf", squareSize, "s");\r
+ pieceBitmap[1][WhiteWolf] = DoLoadBitmap(hInst, "wolf", squareSize, "o");\r
+ pieceBitmap[2][WhiteWolf] = DoLoadBitmap(hInst, "wolf", squareSize, "w");\r
+ pieceBitmap[0][WhiteCamel] = DoLoadBitmap(hInst, "camel", squareSize, "s");\r
+ pieceBitmap[1][WhiteCamel] = DoLoadBitmap(hInst, "camel", squareSize, "o");\r
+ pieceBitmap[2][WhiteCamel] = DoLoadBitmap(hInst, "camel", squareSize, "w");\r
+ pieceBitmap[0][WhiteZebra] = DoLoadBitmap(hInst, "zebra", squareSize, "s");\r
+ pieceBitmap[1][WhiteZebra] = DoLoadBitmap(hInst, "zebra", squareSize, "o");\r
+ pieceBitmap[2][WhiteZebra] = DoLoadBitmap(hInst, "n", squareSize, "w");\r
\r
if(gameInfo.variant == VariantShogi && BOARD_HEIGHT != 7) { /* promoted Gold representations (but not in Tori!)*/\r
pieceBitmap[0][WhiteCannon] = DoLoadBitmap(hInst, "wp", squareSize, "s");\r
pieceBitmap[2][WhiteSilver] = DoLoadBitmap(hInst, "sw", squareSize, "w");\r
minorSize = 0;\r
}\r
+\r
+ if(appData.pieceDirectory[0]) for(i=WhitePawn; i<BlackPawn; i++) { // try for all missing pieces with new naming convention\r
+ char buf[MSG_SIZ];\r
+ if(pieceBitmap[0][i]) continue;\r
+ snprintf(buf, MSG_SIZ, "piece%d_", i);\r
+ pieceBitmap[0][i] = DoLoadBitmap(hInst, buf, squareSize, "s");\r
+ pieceBitmap[1][i] = DoLoadBitmap(hInst, buf, squareSize, "o");\r
+ pieceBitmap[2][i] = DoLoadBitmap(hInst, buf, squareSize, "w");\r
+ }\r
}\r
\r
HBITMAP\r
{\r
}\r
\r
+\r
+\r
VOID\r
HDCDrawPosition(HDC hdc, BOOLEAN repaint, Board board)\r
{\r
explodes. The old and new positions both had an empty square\r
at the destination, but animation has drawn a piece there and\r
we have to remember to erase it. [HGM] moved until after setting lastDrawn */\r
+\r
lastDrawn[0][animInfo.to.y][animInfo.to.x] = animInfo.piece;\r
}\r
}\r
if(saveDiagFlag) { \r
BITMAP b; int i, j=0, m, w, wb, fac=0; char *pData; \r
BITMAPINFOHEADER bih; int color[16], nrColors=0;\r
+ HBITMAP src = bufferBitmap, obmp; HDC tmp = CreateCompatibleDC(hdc);\r
\r
+ bufferBitmap = CreateCompatibleBitmap(hdc, boardRect.right-boardRect.left, Rect.bottom-Rect.top-2*OUTER_MARGIN);\r
+ obmp = SelectObject(tmp, bufferBitmap);\r
+ BitBlt(tmp, 0, 0, boardRect.right - boardRect.left, Rect.bottom - Rect.top - 2*OUTER_MARGIN,\r
+ tmphdc, boardRect.left, OUTER_MARGIN, SRCCOPY);\r
GetObject(bufferBitmap, sizeof(b), &b);\r
if(pData = malloc(b.bmWidthBytes*b.bmHeight + 10000)) {\r
bih.biSize = sizeof(BITMAPINFOHEADER);\r
fputc(pData[i], diagFile);\r
free(pData);\r
}\r
+ DeleteObject(bufferBitmap); bufferBitmap = src;\r
+ SelectObject(tmp, obmp);\r
+ DeleteDC(tmp);\r
}\r
\r
SelectObject(tmphdc, oldBitmap);\r
break;\r
\r
case IDM_Match: // [HGM] match: flows into next case, after setting Match Mode and nr of Games\r
+ if(matchMode) EnableMenuItem(GetMenu(hwndMain), IDM_Match, MF_BYCOMMAND|MF_GRAYED);\r
MatchEvent(2); // distinguish from command-line-triggered case (matchMode=1)\r
break;\r
\r
ReattachAfterMove( &rcMain, lpwp->x, lpwp->y, hwndConsole, &wpConsole );\r
wpMain.x = lpwp->x;\r
wpMain.y = lpwp->y;\r
+\r
}\r
}\r
break;\r
case IDOK:\r
GetDlgItemText(hDlg, OPT_Name, move, sizeof(move));\r
appData.userName = strdup(move);\r
- SetUserLogo();\r
+ SetUserLogo(); DisplayLogos();\r
SetGameInfo();\r
if(gameMode == MachinePlaysWhite || gameMode == MachinePlaysBlack) {\r
snprintf(move, MSG_SIZ, "%s vs. %s", gameInfo.white, gameInfo.black);\r
oldFg = SetTextColor(hdc, RGB(0, 0, 0)); /* black */\r
oldBg = SetBkColor(hdc, RGB(255, 255, 255)); /* white */\r
}\r
+\r
oldFont = SelectObject(hdc, font[boardSize][CLOCK_FONT]->hf);\r
\r
JAWS_SILENCE\r
{ IDM_Annotate, MF_BYCOMMAND|MF_GRAYED },\r
{ IDM_NewChat, MF_BYCOMMAND|MF_GRAYED },\r
\r
+\r
// Needed to switch from ncp to GNU mode on Engine Load\r
{ ACTION_POS, MF_BYPOSITION|MF_ENABLED },\r
{ IDM_MachineWhite, MF_BYCOMMAND|MF_ENABLED },\r
nowChecked = 0;\r
break;\r
}\r
+ if(prevChecked == IDM_TwoMachines) // [HGM] 'Machine Match' might have gotten disabled when stopping match\r
+ EnableMenuItem(GetMenu(hwndMain), IDM_Match, MF_BYCOMMAND|MF_ENABLED);\r
CheckMark(prevChecked, MF_UNCHECKED);\r
CheckMark(nowChecked, MF_CHECKED);\r
CheckMark(IDM_Match, matchMode && matchGame < appData.matchGames ? MF_CHECKED : MF_UNCHECKED);\r
fprintf(debugFP, "%s: %s\n", label, str);\r
}\r
if (appData.popupExitMessage) {\r
+ if(appData.icsActive) SendToICS("logout\n"); // [HGM] make sure no new games will be started!\r
(void) MessageBox(hwndMain, str, label, MB_OK|\r
(exitStatus ? MB_ICONSTOP : MB_ICONINFORMATION));\r
}\r
*/\r
if (nice < -15) return 0x00000080;\r
if (nice < 0) return 0x00008000;\r
+\r
if (nice == 0) return 0x00000020;\r
if (nice < 15) return 0x00004000;\r
return 0x00000040;\r
int toX;\r
int toY;\r
{\r
- ChessSquare piece;\r
- int x = toX, y = toY;\r
+ ChessSquare piece, victim = EmptySquare, victim2 = EmptySquare;\r
+ int x = toX, y = toY, x2 = kill2X;\r
POINT start, finish, mid;\r
POINT frames[kFactor * 2 + 1];\r
int nFrames, n;\r
piece = board[fromY][fromX];\r
if (piece >= EmptySquare) return;\r
\r
- if(killX >= 0) toX = killX, toY = killY; // [HGM] lion: first to kill square\r
+ if(x2 >= 0) toX = kill2X, toY = kill2Y, victim = board[killY][killX], victim2 = board[kill2Y][kill2X]; else\r
+ if(killX >= 0) toX = killX, toY = killY, victim = board[killY][killX]; // [HGM] lion: first to kill square\r
+\r
+ animInfo.from.x = fromX;\r
+ animInfo.from.y = fromY;\r
\r
again:\r
\r
else\r
Tween(&start, &mid, &finish, kFactor, frames, &nFrames);\r
\r
- animInfo.from.x = fromX;\r
- animInfo.from.y = fromY;\r
animInfo.to.x = toX;\r
animInfo.to.y = toY;\r
animInfo.lastpos = start;\r
animInfo.piece = piece;\r
for (n = 0; n < nFrames; n++) {\r
animInfo.pos = frames[n];\r
- DrawPosition(FALSE, NULL);\r
+ DrawPosition(FALSE, board);\r
animInfo.lastpos = animInfo.pos;\r
Sleep(appData.animSpeed);\r
}\r
animInfo.pos = finish;\r
- DrawPosition(FALSE, NULL);\r
-\r
- if(toX != x || toY != y) { fromX = toX; fromY = toY; toX = x; toY = y; goto again; } // second leg\r
+ DrawPosition(FALSE, board);\r
+\r
+ if(toX == x2 && toY == kill2Y) {\r
+ fromX = toX; fromY = toY; toX = killX; toY = killY; x2 = -1;\r
+ board[kill2Y][kill2X] = EmptySquare; goto again;\r
+ } // second leg\r
+ if(toX != x || toY != y) {\r
+ fromX = toX; fromY = toY; toX = x; toY = y;\r
+ board[killY][killX] = EmptySquare; goto again;\r
+ } // second leg\r
+\r
+if(victim2 != EmptySquare) board[kill2Y][kill2X] = victim2;\r
+if(victim != EmptySquare) board[killY][killX] = victim;\r
\r
animInfo.piece = EmptySquare;\r
Explode(board, fromX, fromY, toX, toY);\r