From 9fe97e3c568358c3402af44cefb8999e8fb6581d Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sat, 6 Nov 2010 21:39:56 +0100 Subject: [PATCH] Send setup command to GUI After receiving the variant command for variant fairy, Fairy-Max responds with a setup command to inform the GUI about the piece names and opening array of the actually selected variant. The piece names are defeined (in the format of a WinBoard -pieceToCharTable string) after the variant name in the fmax.ini file, separated from it by a '#' sign. --- data/fmax.ini | 2 +- fairymax.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/data/fmax.ini b/data/fmax.ini index a684c2e..db90b99 100644 --- a/data/fmax.ini +++ b/data/fmax.ini @@ -470,7 +470,7 @@ h:640 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7 15,7 17,7 -15,7 -17,7 30,7 34, m:640 14,7 31,7 33,7 18,7 -14,7 -31,7 -33,7 -18,7 1,7 16,7 -1,7 -16,7 2,7 -2,7 32,7 -32,7 // Spartan Chess, where black has a different army from white's orthodox FIDE, with two kings -Game: fairy/Spartan +Game: fairy/Spartan # PNBRQ..............K....q.lwg.....c...hk 8x8 6 4 5 7 11 5 4 6 3 9 11 8 8 11 10 3 diff --git a/fairymax.c b/fairymax.c index 36bda21..be12a63 100644 --- a/fairymax.c +++ b/fairymax.c @@ -435,7 +435,7 @@ void PrintOptions() int LoadGame(char *name) { - int i, j, count=0; char c, buf[80]; + int i, j, ptc, count=0; char c, buf[80], pieceToChar[80]; static int currentVariant; FILE *f; @@ -450,7 +450,7 @@ int LoadGame(char *name) if(name != NULL) { /* search for game name in definition file */ if(!strcmp(name, "fairy")) name = selectedFairy; - while(fscanf(f, "Game: %s", buf)!=1 || strcmp(name, buf) ) { + while((ptc=fscanf(f, "Game: %s # %s", buf, pieceToChar))==0 || strcmp(name, buf) ) { while((c = fgetc(f)) != EOF && c != '\n'); count++; if(c == EOF) { @@ -488,6 +488,14 @@ int LoadGame(char *name) fclose(f); sh = w[7] < 250 ? 3 : 0; makruk = w[7]==181 ? 64 : 0; // w[7] is used as kludge to enable makruk promotions + if(name == selectedFairy) { + printf(ptc == 1 ? "setup " : "setup (%s) ", pieceToChar); // setup board in GUI + for(i=0; i