Merge branch 'master' into v4.8.x
authorArun Persaud <arun@nubati.net>
Fri, 17 Oct 2014 06:14:42 +0000 (23:14 -0700)
committerArun Persaud <arun@nubati.net>
Fri, 17 Oct 2014 06:14:42 +0000 (23:14 -0700)
backend.c
moves.c
pgntags.c
winboard/wgamelist.c
winboard/winboard.c
winboard/winboard.h

index eb9059f..bab4386 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -8908,6 +8908,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
       /* For variants we don't have   */       && gameInfo.variant != VariantBerolina
       /* correct rules for, we cannot */       && gameInfo.variant != VariantCylinder
       /* enforce legality on our own! */       && gameInfo.variant != VariantUnknown
+                                               && gameInfo.variant != VariantGreat
                                                && gameInfo.variant != VariantFairy    ) return;
       if(piece < EmptySquare) {
         pieceDefs = TRUE;
@@ -12876,6 +12877,8 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList)
            return FALSE;
          }
          CopyBoard(boards[0], initial_position);
+         if(*engineVariant) // [HGM] for now, assume FEN in engine-defined variant game is default initial position
+           CopyBoard(initialPosition, initial_position);
          if (blackPlaysFirst) {
            currentMove = forwardMostMove = backwardMostMove = 1;
            CopyBoard(boards[1], initial_position);
@@ -17870,7 +17873,7 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts)
             q = (boards[move][CASTLING][1] == BOARD_LEFT &&
                  boards[move][CASTLING][2] != NoRights  );
             if(handW) { // for S-Chess with pieces in hand, list virgin pieces between K and Q
-                for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q && j; i--)
+                for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q; i--)
                     if((boards[move][0][i] != WhiteKing || k+q == 0) &&
                         boards[move][VIRGIN][i] & VIRGIN_W) *p++ = i + AAA + 'A' - 'a';
             }
@@ -17881,7 +17884,7 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts)
             q = (boards[move][CASTLING][4] == BOARD_LEFT &&
                  boards[move][CASTLING][5] != NoRights  );
             if(handB) {
-                for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q && j; i--)
+                for(i=BOARD_RGHT-1-k; i>=BOARD_LEFT+q; i--)
                     if((boards[move][BOARD_HEIGHT-1][i] != BlackKing || k+q == 0) &&
                         boards[move][VIRGIN][i] & VIRGIN_B) *p++ = i + AAA;
             }
diff --git a/moves.c b/moves.c
index aca97b5..4279ce9 100644 (file)
--- a/moves.c
+++ b/moves.c
@@ -268,7 +268,7 @@ MovesFromString (Board board, int flags, int f, int r, int tx, int ty, int angle
     int mine, his, dir, bit, occup, i;
     if(flags & F_WHITE_ON_MOVE) his = 2, mine = 1; else his = 1, mine = 2;
     while(*p) {                  // more moves to go
-       int expo = 1, dx, dy, x, y, mode, dirSet, ds2, retry=0, initial=0, jump=1, skip = 0, all = 0;
+       int expo = 1, dx, dy, x, y, mode, dirSet, ds2=0, retry=0, initial=0, jump=1, skip = 0, all = 0;
        char *cont = NULL;
        if(*p == 'i') initial = 1, desc = ++p;
        while(islower(*p)) p++;  // skip prefixes
index f13eb96..fd74df7 100644 (file)
--- a/pgntags.c
+++ b/pgntags.c
@@ -115,10 +115,12 @@ ParsePGNTag (char *tag, GameInfo *gameInfo)
     } else if (StrCaseCmp(name, "Variant") == 0) {
         /* xboard-defined extension */
        success = StrSavePtr(value, &gameInfo->variantName) != NULL;
-        gameInfo->variant = StringToVariant(value);
+        if(*value && strcmp(value, engineVariant)) // keep current engine-defined variant if it matches
+            gameInfo->variant = StringToVariant(value);
     } else if (StrCaseCmp(name, "VariantMen") == 0) {
         /* for now ignore this tag, as we have no method yet */
         /* for assigning the pieces to XBoard pictograms     */
+        success = TRUE;
     } else if (StrCaseCmp(name, PGN_OUT_OF_BOOK) == 0) {
         /* [AS] Out of book annotation */
         success = StrSavePtr(value, &gameInfo->outOfBook) != NULL;
index feda2ca..e31f184 100644 (file)
@@ -48,16 +48,8 @@ static BOOLEAN gameListUp = FALSE;
 static FILE* gameFile;\r
 static char* gameFileName = NULL;\r
 \r
-struct GameListStats\r
-{\r
-    int white_wins;\r
-    int black_wins;\r
-    int drawn;\r
-    int unfinished;\r
-};\r
-\r
 /* [AS] Setup the game list according to the specified filter */\r
-static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos, BOOL narrow )\r
+int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos, BOOL narrow )\r
 {\r
     ListGame * lg = (ListGame *) gameList.head;\r
     int nItem;\r
@@ -66,6 +58,9 @@ static int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct
     int count = 0;\r
     struct GameListStats dummy;\r
 \r
+    if(!hDlg) hDlg = gameListDialog; // [HGM] to allow calling from Game List Options dialog\r
+    if(!hDlg) return 0;\r
+\r
     /* Initialize stats (use a dummy variable if caller not interested in them) */\r
     if( stats == NULL ) {\r
         stats = &dummy;\r
index d0eb772..794ae49 100644 (file)
@@ -8712,8 +8712,11 @@ int GameListOptions()
     result = DialogBoxParam( hInst, MAKEINTRESOURCE(DLG_GameListOptions), hwndMain, (DLGPROC)lpProc, (LPARAM)lpUserGLT );\r
 \r
     if( result == 0 ) {\r
+        char *oldTags = appData.gameListTags;\r
         /* [AS] Memory leak here! */\r
         appData.gameListTags = strdup( lpUserGLT ); \r
+        if(strcmp(oldTags, appData.gameListTags)) // [HGM] redo Game List when we changed something\r
+            GameListToListBox(NULL, TRUE, ".", NULL, FALSE, FALSE); // "." as filter is kludge to select all\r
     }\r
 \r
     return result;\r
@@ -9776,6 +9779,7 @@ OutputToProcess(ProcRef pr, char *message, int count, int *outError)
   int outCount = SOCKET_ERROR;\r
   ChildProc *cp = (ChildProc *) pr;\r
   static OVERLAPPED ovl;\r
+\r
   static int line = 0;\r
 \r
   if (pr == NoProc)\r
index 0998c97..00caa95 100644 (file)
@@ -211,6 +211,15 @@ extern HWND evalGraphDialog;
 \r
 extern HWND engineOutputDialog;\r
 \r
+struct GameListStats\r
+{\r
+    int white_wins;\r
+    int black_wins;\r
+    int drawn;\r
+    int unfinished;\r
+};\r
+\r
+int GameListToListBox( HWND hDlg, BOOL boReset, char * pszFilter, struct GameListStats * stats, BOOL byPos, BOOL narrow );\r
 VOID ShowGameListProc(void);\r
 extern HWND gameListDialog;\r
 \r