\r
#include <windows.h>\r
#include <winuser.h>\r
+#include <winsock.h>\r
\r
#include <stdio.h>\r
#include <stdlib.h>\r
#include <malloc.h>\r
-#include <io.h>\r
#include <sys/stat.h>\r
#include <fcntl.h>\r
#include <math.h>\r
#include <commdlg.h>\r
#include <dlgs.h>\r
#include <richedit.h>\r
+#include <mmsystem.h>\r
\r
#if __GNUC__\r
#include <errno.h>\r
static HICON iconWhite, iconBlack, iconCurrent;\r
static int doingSizing = FALSE;\r
static int lastSizing = 0;\r
+static int prevStderrPort;\r
\r
#if __GNUC__ && !defined(_winmajor)\r
#define oldDialog 0 /* cygwin doesn't define _winmajor; mingw does */\r
\r
char *programVersion;\r
\r
-#include <winsock.h>\r
-\r
#define CPReal 1\r
#define CPComm 2\r
#define CPSock 3\r
/* Center the dialog over the application window */\r
CenterWindow(hDlg, GetWindow(hDlg, GW_OWNER));\r
ShowWindow(GetDlgItem(hDlg, PB_King), \r
- (!appData.testLegality || gameInfo.variant == VariantSuicide) ?\r
+ (!appData.testLegality || gameInfo.variant == VariantSuicide ||\r
+ gameInfo.variant == VariantGiveaway) ?\r
SW_SHOW : SW_HIDE);\r
return TRUE;\r
\r
if (write ? GetSaveFileName(&openFileName) : \r
GetOpenFileName(&openFileName)) {\r
/* open the file */\r
- f = fopen(openFileName.lpstrFile, write ? "a" : "r");\r
+ f = fopen(openFileName.lpstrFile, write ? "a" : "rb");\r
if (f == NULL) {\r
MessageBox(hwnd, "File open failed", NULL,\r
MB_OK|MB_ICONEXCLAMATION);\r
switch (LOWORD(wParam)) {\r
case IDOK:\r
case IDCANCEL:\r
- if (errorDialog = hDlg) errorDialog = NULL;\r
+ if (errorDialog == hDlg) errorDialog = NULL;\r
DestroyWindow(hDlg);\r
return TRUE;\r
\r
mysa.sin_family = AF_INET;\r
mysa.sin_addr.s_addr = INADDR_ANY;\r
for (fromPort = 1023;; fromPort--) {\r
+ if (fromPort == prevStderrPort) continue; // don't reuse port\r
if (fromPort < 0) {\r
(void) closesocket(s);\r
WSACleanup();\r
}\r
break;\r
}\r
+ prevStderrPort = fromPort; // remember port used\r
sprintf(stderrPortStr, "%d", fromPort);\r
\r
if (send(s, stderrPortStr, strlen(stderrPortStr) + 1, 0) == SOCKET_ERROR) {\r