From: H.G.Muller Date: Sun, 1 May 2016 19:41:40 +0000 (+0200) Subject: Implement -showMoveTime option X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=c0bcf53dc4abc3fc4001252c734b926765598837 Implement -showMoveTime option A persistent option -showMoveTime can cause the time thought so far on the current move to be displayed in the clock field, behind the time left on the clock, in parentheses. --- diff --git a/args.h b/args.h index eb573c6..2924993 100644 --- a/args.h +++ b/args.h @@ -618,6 +618,7 @@ ArgDescriptor argDescriptors[] = { { "inscriptions", ArgString, (void *) &appData.inscriptions, FALSE, (ArgIniType) "" }, { "autoInstall", ArgString, (void *) &appData.autoInstall, XBOARD, (ArgIniType) "" }, { "fixedSize", ArgBoolean, (void *) &appData.fixedSize, TRUE, (ArgIniType) FALSE }, + { "showMoveTime", ArgBoolean, (void *) &appData.moveTime, TRUE, (ArgIniType) FALSE }, // [HGM] tournament options { "tourneyFile", ArgFilename, (void *) &appData.tourneyFile, FALSE, (ArgIniType) "" }, diff --git a/backend.c b/backend.c index e0830fc..b7aafee 100644 --- a/backend.c +++ b/backend.c @@ -17813,11 +17813,13 @@ ResetClocks () #define FUDGE 25 /* 25ms = 1/40 sec; should be plenty even for 50 Hz clocks */ +static int timeSuffix; // [HGM] This should realy be a passed parameter, but it has to pass through too many levels for my laziness... + /* Decrement running clock by amount of time that has passed */ void DecrementClocks () { - long timeRemaining; + long tRemaining; long lastTickLength, fudge; TimeMark now; @@ -17834,28 +17836,32 @@ DecrementClocks () if (WhiteOnMove(forwardMostMove)) { if(whiteNPS >= 0) lastTickLength = 0; - timeRemaining = whiteTimeRemaining -= lastTickLength; - if(timeRemaining < 0 && !appData.icsActive) { + tRemaining = whiteTimeRemaining -= lastTickLength; + if( tRemaining < 0 && !appData.icsActive) { GetTimeQuota((forwardMostMove-whiteStartMove-1)/2, 0, whiteTC); // sets suddenDeath & nextSession; if(suddenDeath) { // [HGM] if we run out of a non-last incremental session, go to the next whiteStartMove = forwardMostMove; whiteTC = nextSession; - lastWhite= timeRemaining = whiteTimeRemaining += GetTimeQuota(-1, 0, whiteTC); + lastWhite= tRemaining = whiteTimeRemaining += GetTimeQuota(-1, 0, whiteTC); } } + if(forwardMostMove && appData.moveTime) timeSuffix = timeRemaining[0][forwardMostMove-1] - tRemaining; DisplayWhiteClock(whiteTimeRemaining - fudge, WhiteOnMove(currentMove < forwardMostMove ? currentMove : forwardMostMove)); + timeSuffix = 0; } else { if(blackNPS >= 0) lastTickLength = 0; - timeRemaining = blackTimeRemaining -= lastTickLength; - if(timeRemaining < 0 && !appData.icsActive) { // [HGM] if we run out of a non-last incremental session, go to the next + tRemaining = blackTimeRemaining -= lastTickLength; + if( tRemaining < 0 && !appData.icsActive) { // [HGM] if we run out of a non-last incremental session, go to the next GetTimeQuota((forwardMostMove-blackStartMove-1)/2, 0, blackTC); if(suddenDeath) { blackStartMove = forwardMostMove; - lastBlack = timeRemaining = blackTimeRemaining += GetTimeQuota(-1, 0, blackTC=nextSession); + lastBlack = tRemaining = blackTimeRemaining += GetTimeQuota(-1, 0, blackTC=nextSession); } } + if(forwardMostMove && appData.moveTime) timeSuffix = timeRemaining[1][forwardMostMove-1] - tRemaining; DisplayBlackClock(blackTimeRemaining - fudge, !WhiteOnMove(currentMove < forwardMostMove ? currentMove : forwardMostMove)); + timeSuffix = 0; } if (CheckFlags()) return; @@ -17870,7 +17876,7 @@ DecrementClocks () } tickStartTM = now; - intendedTickLength = NextTickLength(timeRemaining - fudge) + fudge; + intendedTickLength = NextTickLength( tRemaining - fudge) + fudge; StartClockTimer(intendedTickLength); /* if the time remaining has fallen below the alarm threshold, sound the @@ -17886,9 +17892,9 @@ DecrementClocks () ((gameMode == IcsPlayingBlack) && !WhiteOnMove(currentMove)) )) return; - if (alarmSounded && (timeRemaining > appData.icsAlarmTime)) { + if (alarmSounded && ( tRemaining > appData.icsAlarmTime)) { alarmSounded = FALSE; - } else if (!alarmSounded && (timeRemaining <= appData.icsAlarmTime)) { + } else if (!alarmSounded && ( tRemaining <= appData.icsAlarmTime)) { PlayAlarmSound(); alarmSounded = TRUE; } @@ -18029,7 +18035,7 @@ TimeString (long ms) { long second, minute, hour, day; char *sign = ""; - static char buf[32]; + static char buf[40], moveTime[8]; if (ms > 0 && ms <= 9900) { /* convert milliseconds to tenths, rounding up */ @@ -18056,13 +18062,16 @@ TimeString (long ms) minute = second / 60; second = second % 60; + if(timeSuffix) snprintf(moveTime, 8, " (%d)", timeSuffix/1000); // [HGM] kludge alert; fraction contains move time + else *moveTime = NULLCHAR; + if (day > 0) - snprintf(buf, sizeof(buf)/sizeof(buf[0]), " %s%ld:%02ld:%02ld:%02ld ", - sign, day, hour, minute, second); + snprintf(buf, sizeof(buf)/sizeof(buf[0]), " %s%ld:%02ld:%02ld:%02ld%s ", + sign, day, hour, minute, second, moveTime); else if (hour > 0) - snprintf(buf, sizeof(buf)/sizeof(buf[0]), " %s%ld:%02ld:%02ld ", sign, hour, minute, second); + snprintf(buf, sizeof(buf)/sizeof(buf[0]), " %s%ld:%02ld:%02ld%s ", sign, hour, minute, second, moveTime); else - snprintf(buf, sizeof(buf)/sizeof(buf[0]), " %s%2ld:%02ld ", sign, minute, second); + snprintf(buf, sizeof(buf)/sizeof(buf[0]), " %s%2ld:%02ld%s ", sign, minute, second, moveTime); return buf; } diff --git a/common.h b/common.h index bbaa034..9a4c2c4 100644 --- a/common.h +++ b/common.h @@ -559,6 +559,7 @@ typedef struct { Boolean flipView; Boolean autoFlipView; char *cmailGameName; /* xboard only */ + Boolean moveTime; Boolean headers; Boolean alwaysPromoteToQueen; Boolean oldSaveStyle; diff --git a/xboard.texi b/xboard.texi index 46b95d9..8cde6b3 100644 --- a/xboard.texi +++ b/xboard.texi @@ -2475,6 +2475,11 @@ false, the clocks are not shown, but the side that is to play next is still highlighted. Also, unless @code{searchTime} is set, the chess engine still keeps track of the clock time and uses it to determine how fast to make its moves. +@item -shoMoveTime true/false +@cindex showMoveTime, option +When this option is set the time that has been thought about the current move +will be displayed behind the remaining time in parentheses (in seconds). +Default: false. @item -st or -searchTime minutes[:seconds] @cindex st, option @cindex searchTime, option