Send parent variant with setup command
[fairymax.git] / fairymax.c
index f9cf637..46b3890 100644 (file)
@@ -491,7 +491,7 @@ void PrintOptions()
                                          \r
 void LoadGame(char *name)\r
 {\r
-        int i, j, ptc, count=0; char c, buf[80], pieceToChar[80];\r
+        int i, j, ptc, count=0; char c, buf[80], pieceToChar[80], parent[80];\r
         static int currentVariant;\r
         FILE *f;\r
 \r
@@ -509,7 +509,7 @@ void LoadGame(char *name)
            if(!strcmp(name, "makruk") && Cambodian) name = "cambodian"; else\r
            if(!strcmp(name, "fairy")) name = selectedFairy;\r
            gating = !strcmp(name, "seirawan");\r
-           while((ptc=fscanf(f, "Game: %s # %s", buf, pieceToChar))==0 || strcmp(name, buf) ) {\r
+           while((ptc=fscanf(f, "Game: %s # %s %s", buf, pieceToChar, parent))==0 || strcmp(name, buf) ) {\r
                while((c = fgetc(f)) != EOF && c != '\n');\r
                count++;\r
                if(c == EOF) {\r
@@ -552,8 +552,9 @@ void LoadGame(char *name)
         fclose(f);\r
        sh = w[7] < 250 ? 3 : 0;\r
        makruk = w[7]==181 ? 64 : 0; // w[7] is used as kludge to enable makruk promotions\r
-        if(name == selectedFairy) {\r
-            printf(ptc == 1 ? "setup " : "setup (%s) ", pieceToChar); // setup board in GUI\r
+        if(ptc > 1) { // setup board in GUI, by sending it pieceToCharTable and FEN\r
+            if(ptc == 2) printf("setup (%s) ", pieceToChar);\r
+            else printf("setup (%s) %dx%d+0_%s", pieceToChar, BW, BH, parent);\r
             for(i=0; i<BW; i++) printf("%c", piecename[oo[i+16]]+'`'); printf("/");\r
             for(i=0; i<BW; i++) printf("%c", piecename[2]+'`'); printf("/");\r
             for(i=2; i<BH-2; i++) printf("%d/", BW);\r