From: H.G.Muller Date: Sun, 5 Apr 2020 20:48:10 +0000 (+0200) Subject: Allow engine to add Prelude tag to PGN X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=149f6f1106a746f1307a5b527c77d8271a424425;p=xboard.git Allow engine to add Prelude tag to PGN The engine can now use a 'tellothers prelude XXX' command at the start of a game to cause adding of a PGN Prelude tag with value XXX when the game later is saved. --- diff --git a/backend.c b/backend.c index 6dc6f4d..9c4e220 100644 --- a/backend.c +++ b/backend.c @@ -8936,6 +8936,7 @@ static int savedWhitePlayer, savedBlackPlayer, pairingReceived; static ChessProgramState *stalledEngine; static char stashedInputMove[MSG_SIZ], abortEngineThink; static Boolean prelude; +static char preludeText[MSG_SIZ]; void HandleMachineMove (char *message, ChessProgramState *cps) @@ -9469,7 +9470,12 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h snprintf(buf1, sizeof(buf1), "%swhisper %s\n", ics_prefix, message + 11); SendToICS(buf1); } - } else if(appData.autoComment) AppendComment (forwardMostMove, message + 11, 1); // in local mode, add as move comment + } else { + if(forwardMostMove == 0 && !strncmp(message+11, "prelude ", 8)) { // allow engine to add Prelude tag + strncpy(preludeText, message+19, MSG_SIZ); + } else + if(appData.autoComment) AppendComment (forwardMostMove, message + 11, 1); // in local mode, add as move comment + } return; } if (!strncmp(message, "tellall ", 8)) { @@ -12343,7 +12349,7 @@ Reset (int redraw, int init) pieceDefs = FALSE; // [HGM] gen: reset engine-defined piece moves deadRanks = 0; // assume entire board is used handSize = 0; - prelude = FALSE; + prelude = FALSE; preludeText[0] = NULLCHAR; for(i=0; i 0 || startedFromSetupPosition) { char *fen = PositionToFEN(backwardMostMove, NULL, 1); fprintf(f, "[FEN \"%s\"]\n[SetUp \"1\"]\n", fen); + if(*preludeText) fprintf(f, "[Prelude \"%s\"]\n", preludeText); fprintf(f, "\n{--------------\n"); PrintPosition(f, backwardMostMove); fprintf(f, "--------------}\n");