From: H.G.Muller Date: Sun, 24 Apr 2016 20:34:06 +0000 (+0200) Subject: Add option -pgnTimeLeft to print clocks in extended PGN info X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=0fe341b64ac865097b5182ec7740fe18802efbd2 Add option -pgnTimeLeft to print clocks in extended PGN info When set a persistent option -pgnTimeLeft makes XBoard save the time left after the move in the score/depth comments, rather than the time thought about the move. A leading sign will allow the reader to distinguish the two. The time is always printed in integer seconds. --- diff --git a/args.h b/args.h index 8b8fe8e..eb573c6 100644 --- a/args.h +++ b/args.h @@ -535,6 +535,7 @@ ArgDescriptor argDescriptors[] = { { "secondScoreAbs", ArgBoolean, (void *) &appData.secondScoreIsAbsolute, FALSE, (ArgIniType) FALSE }, { "pgnExtendedInfo", ArgBoolean, (void *) &appData.saveExtendedInfoInPGN, TRUE, (ArgIniType) FALSE }, { "hideThinkingFromHuman", ArgBoolean, (void *) &appData.hideThinkingFromHuman, TRUE, (ArgIniType) FALSE }, + { "pgnTimeLeft", ArgBoolean, (void *) &appData.cumulativeTimePGN, TRUE, (ArgIniType) FALSE }, { "liteBackTextureFile", ArgFilename, (void *) &appData.liteBackTextureFile, TRUE, (ArgIniType) "" }, { "lbtf", ArgFilename, (void *) &appData.liteBackTextureFile, FALSE, INVALID }, { "darkBackTextureFile", ArgFilename, (void *) &appData.darkBackTextureFile, TRUE, (ArgIniType) "" }, @@ -1251,10 +1252,10 @@ ParseArgs(GetFunc get, void *cl) if(r) { // must be put in group r char *p = strstr(q, r); if(p) { // group already exists - p += strlen(r); // determine insertion point (immediately after group header line) + p += strlen(r) - 1; // determine insertion point (immediately after group header line) *(char **) ad->argLoc = malloc(l+2); *p++ = NULLCHAR; // spit old value (q) at insertion point into q and p - snprintf(*(char **) ad->argLoc, l+2, "%s%s\n%s", q, s, p); // insert (with newline) + snprintf(*(char **) ad->argLoc, l+2, "%s\n%s\n%s", q, s, p); // insert (with newline) } else { // group did not exist, create at end l += strlen(r) + 8; *(char **) ad->argLoc = malloc(l); diff --git a/backend.c b/backend.c index f5e2b85..55cb253 100644 --- a/backend.c +++ b/backend.c @@ -13925,6 +13925,10 @@ SaveGamePGN2 (FILE *f) snprintf(buf, MSG_SIZ, " %d:%02d%c", seconds/60, seconds%60, 0); } + if(appData.cumulativeTimePGN) { + snprintf(buf, MSG_SIZ, " %+ld", timeRemaining[i & 1][i+1]/1000); + } + snprintf( move_buffer, sizeof(move_buffer)/sizeof(move_buffer[0]),"{%s%.2f/%d%s}", pvInfoList[i].score >= 0 ? "+" : "", pvInfoList[i].score / 100.0, diff --git a/common.h b/common.h index 0136a00..bbaa034 100644 --- a/common.h +++ b/common.h @@ -645,6 +645,7 @@ typedef struct { Boolean scoreIsAbsolute[ENGINES]; /* If true, engine score is always from white side */ Boolean saveExtendedInfoInPGN; /* If true, saved PGN games contain extended info */ Boolean hideThinkingFromHuman; /* If true, program thinking is generated but not displayed in human/computer matches */ + Boolean cumulativeTimePGN; /* If true, times saved in PGN extended info is time left on clock */ Boolean useBitmaps; Boolean useFont; Boolean useBorder; diff --git a/xboard.texi b/xboard.texi index 9c4c125..46b95d9 100644 --- a/xboard.texi +++ b/xboard.texi @@ -3447,7 +3447,14 @@ the @samp{Load Position} menu item. If this option is set, XBoard saves depth, score and time used for each move that the engine found as a comment in the PGN file. Default: false. +@item -pgnTimeLeft true/false +@cindex pgnTimeLeft, option +If this option is set, XBoard will save the remaining clock time for +the player that has just moved as part of the @samp{pgnExtendedInfo}, +rather than the time that player thought about his latest move. +Default: false. @item -pgnEventHeader string +Default: false. @cindex pgnEventHeader, option Sets the name used in the PGN event tag to string. Default: "Computer Chess Game".