From: H.G. Muller Date: Tue, 26 Nov 2013 12:21:51 +0000 (+0100) Subject: Save clocks with unfinished PGN games X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=0b487f0b8319a23d5334c63b035f692bcbae6221;p=xboard.git Save clocks with unfinished PGN games When saving a game with an unfinished result, the remaining time of both players is appended to the result comment, as "(Clocks: WHITETIME, BLACKTIME)" with the times in seconds. When a game with unfinished result is loaded, and the result message contains such a text, the clock settings are restored from it accordingly. This makes it easier to resume interrupted games. --- diff --git a/backend.c b/backend.c index ab84abe..5bc1eaf 100644 --- a/backend.c +++ b/backend.c @@ -12609,6 +12609,15 @@ LoadGame (FILE *f, int gameNumber, char *title, int useList) AnalyzeFileEvent(); } + if(gameInfo.result == GameUnfinished && gameInfo.resultDetails && appData.clockMode) { + long int w, b; // [HGM] adjourn: restore saved clock times + char *p = strstr(gameInfo.resultDetails, "(Clocks:"); + if(p && sscanf(p+8, "%ld,%ld", &w, &b) == 2) { + timeRemaining[0][forwardMostMove] = whiteTimeRemaining = 1000*w + 500; + timeRemaining[1][forwardMostMove] = blackTimeRemaining = 1000*b + 500; + } + } + if(creatingBook) return TRUE; if (!matchMode && pos > 0) { ToNrEvent(pos); // [HGM] no autoplay if selected on position @@ -13110,8 +13119,10 @@ SaveGamePGN (FILE *f) /* Print result */ if (gameInfo.resultDetails != NULL && gameInfo.resultDetails[0] != NULLCHAR) { - fprintf(f, "{%s} %s\n\n", gameInfo.resultDetails, - PGNResult(gameInfo.result)); + char buf[MSG_SIZ], *p = gameInfo.resultDetails; + if(gameInfo.result == GameUnfinished && appData.clockMode && !appData.icsActive) // [HGM] adjourn: save clock settings + snprintf(buf, MSG_SIZ, "%s (Clocks: %ld, %ld)", p, whiteTimeRemaining/1000, blackTimeRemaining/1000), p = buf; + fprintf(f, "{%s} %s\n\n", p, PGNResult(gameInfo.result)); } else { fprintf(f, "%s\n\n", PGNResult(gameInfo.result)); }