From 774b3b1216f067dd963d72af7d8043d98338dfb7 Mon Sep 17 00:00:00 2001
From: H.G.Muller <hgm@hgm-xboard.(none)>
Date: Thu, 16 Oct 2014 13:27:04 +0200
Subject: [PATCH] Implement Info option

This button option pops up a notice with the comment line above the
game definition.
---
 fairymax.c |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/fairymax.c b/fairymax.c
index 9f6571b..3c19a21 100644
--- a/fairymax.c
+++ b/fairymax.c
@@ -109,6 +109,7 @@ int prom, pm, gating, succession, hill;
 char piecename[32], piecetype[32], blacktype[32];
 char selectedFairy[80];
 char *inifile = INI_FILE;
+char info[999];
 
 int Ticks, tlim, Setup, SetupQ;
 
@@ -464,6 +465,7 @@ void PrintOptions()
 	printf("feature option=\"Dummy Slider Example -slider 20 0 100\"\n");
 	printf("feature option=\"Dummy String Example -string happy birthday!\"\n");
 	printf("feature option=\"Dummy Path Example -path .\"\n");
+	printf("feature option=\"Info -button\"\n");
 	printf("feature option=\"Clear Hash -button\"\n");
 	printf("feature done=1\n");
 }
@@ -489,7 +491,9 @@ void LoadGame(char *name)
            if(!strcmp(name, "fairy")) name = selectedFairy;
            gating = !strcmp(name, "seirawan");
            while((ptc=fscanf(f, "Game: %s # %s # %s", buf, pieceToChar, parent))==0 || strcmp(name, buf) ) {
-               while((c = fgetc(f)) != EOF && c != '\n');
+               char *p = info;
+               while((c = fgetc(f)) != EOF && c != '\n') *p++ = c;
+               if(*info == '/') *p = 0; else *info = 0; // remember last line before Game if it was comment
                count++;
                if(c == EOF) {
                    printf("telluser variant %s not supported\n", name);
@@ -759,6 +763,7 @@ printf("# promo = %d (%c) GT = %d\n", prom, prom + '`', GT);
 				inifile = filename; continue;
 			}
 			if(sscanf(line+7, "Clear Hash%c", &c) == 1) for(i=0; i<=U; i++) A->K = 0;
+			if(sscanf(line+7, "Info%c", &c) == 1) printf("telluser %s\n", info+3);
 			if(sscanf(line+7, "MultiVariation Margin=%d", &margin) == 1) continue;
 			if(sscanf(line+7, "Variant fairy selects=%s", selectedFairy+6) == 1) continue;
 			if(sscanf(line+7, "Makruk rules=%s", Cambodian) == 1) continue;
-- 
1.7.0.4