From: H.G.Muller Date: Tue, 20 Oct 2015 15:22:53 +0000 (+0200) Subject: Print mate scores as #N in message field X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=4d3fc238587cf474577210196630a69530cd7c2b Print mate scores as #N in message field --- diff --git a/backend.c b/backend.c index f1dcf5d..bd37f6d 100644 --- a/backend.c +++ b/backend.c @@ -9533,6 +9533,7 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h buf1[0] = NULLCHAR; if (sscanf(message, "%d%c %d %d " u64Display " %[^\n]\n", &plylev, &plyext, &curscore, &time, &nodes, buf1) >= 5) { + char score_buf[MSG_SIZ]; if(nodes>>32 == u64Const(0xFFFFFFFF)) // [HGM] negative node count read nodes += u64Const(0x100000000); @@ -9633,11 +9634,17 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h [AS] Protect the thinkOutput buffer from overflow... this is only useful if buf1 hasn't overflowed first! */ - snprintf(thinkOutput, sizeof(thinkOutput)/sizeof(thinkOutput[0]), "[%d]%c%+.2f %s%s", + if(curscore >= MATE_SCORE) + snprintf(score_buf, MSG_SIZ, "#%d", curscore - MATE_SCORE); + else if(curscore <= -MATE_SCORE) + snprintf(score_buf, MSG_SIZ, "#%d", curscore + MATE_SCORE); + else + snprintf(score_buf, MSG_SIZ, "%+.2f", ((double) curscore) / 100.0); + snprintf(thinkOutput, sizeof(thinkOutput)/sizeof(thinkOutput[0]), "[%d]%c%s %s%s", plylev, (gameMode == TwoMachinesPlay ? ToUpper(cps->twoMachinesColor[0]) : ' '), - ((double) curscore) / 100.0, + score_buf, prefixHint ? lastHint : "", prefixHint ? " " : "" ); diff --git a/common.h b/common.h index 5c7b6d2..4f5b85b 100644 --- a/common.h +++ b/common.h @@ -226,6 +226,7 @@ typedef char *String; #define BELLCHAR '\007' #define NULLCHAR '\000' #define FEATURE_TIMEOUT 10000 /*ms*/ +#define MATE_SCORE 100000 #define CLOCK_FONT 0 #define MESSAGE_FONT 1 diff --git a/engineoutput.c b/engineoutput.c index 522a186..d6fde3c 100644 --- a/engineoutput.c +++ b/engineoutput.c @@ -443,7 +443,6 @@ InsertionPoint (int len, EngineOutputData *ed) return offs + strlen(header[ed->which]); } -#define MATE_SCORE 100000 static char spaces[] = " "; // [HGM] align: spaces for padding static void