Fix initial board sizing WB
[xboard.git] / winboard / winboard.c
index 1c41752..a521c04 100644 (file)
@@ -222,6 +222,7 @@ static struct { int x; int y; int mode; } backTextureSquareInfo[BOARD_RANKS][BOA
 #if __GNUC__ && !defined(_winmajor)\r
 #define oldDialog 0 /* cygwin doesn't define _winmajor; mingw does */\r
 #else\r
+\r
 #if defined(_winmajor)\r
 #define oldDialog (_winmajor < 4)\r
 #else\r
@@ -1117,6 +1118,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow, LPSTR lpCmdLine)
   InitDrawingColors();\r
   screenHeight = GetSystemMetrics(SM_CYSCREEN);\r
   screenWidth = GetSystemMetrics(SM_CXSCREEN);\r
+  InitPosition(0); // to set nr of ranks and files, which might be non-default through command-line args\r
   for (ibs = (int) NUM_SIZES - 1; ibs >= 0; ibs--) {\r
     /* Compute window size for each board size, and use the largest\r
        size that fits on this screen as the default. */\r
@@ -2259,6 +2261,7 @@ InitDrawingSizes(BoardSize boardSize, int flags)
 \r
   /* [HGM] call with -2 uses old size (for if nr of files, ranks changes) */\r
   if(boardSize == (BoardSize)(-2) ) boardSize = oldBoardSize;\r
+  if(boardSize == -1) return;     // no size defined yet; abort (to allow early call of InitPosition)\r
   oldBoardSize = boardSize;\r
 \r
   if(boardSize != SizeMiddling && boardSize != SizePetite && boardSize != SizeBulky && !appData.useFont)\r
@@ -2273,7 +2276,7 @@ InitDrawingSizes(BoardSize boardSize, int flags)
                                    boardSize = SizeMiddling;\r
     }\r
   }\r
-  if(!appData.useFont && boardSize == SizePetite && (v == VariantShogi || v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite\r
+  if(!appData.useFont && boardSize == SizePetite && (v == VariantKnightmate)) boardSize = SizeMiddling; // no Unicorn in Petite\r
 \r
   oldRect.left = wpMain.x; //[HGM] placement: remember previous window params\r
   oldRect.top = wpMain.y;\r
@@ -4755,6 +4758,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
       nnew = RealizePalette(hdc);\r
       if (nnew > 0) {\r
        paletteChanged = TRUE;\r
+\r
         InvalidateRect(hwnd, &boardRect, FALSE);\r
       }\r
       ReleaseDC(hwnd, hdc);\r
@@ -10033,6 +10037,6 @@ ActivateTheme (int new)
    InitTextures();\r
    if(new) InitDrawingColors();\r
    fontBitmapSquareSize = 0; // request creation of new font pieces\r
-   InitDrawingSizes(-2, 0);\r
+   InitDrawingSizes(boardSize, 0);\r
    InvalidateRect(hwndMain, NULL, TRUE);\r
 }\r