From 0b0fc4c9c805e95d883196b947217e23efb443c5 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Tue, 15 Oct 2013 21:44:39 +0200 Subject: [PATCH] XBoard: make messages compatible with xboard protocol. Introduces the "xboard" global var, but only yhe last commit will set it, when support is complete. Some non-compliant utterances had to be disarmed by commenting them out with a leading '#'. YD: split original patch into a series --- gnushogi/book.c | 4 ++-- gnushogi/commondsp.c | 5 +++-- gnushogi/gnushogi.h | 1 + gnushogi/rawdsp.c | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/gnushogi/book.c b/gnushogi/book.c index 6bf2af9..79f9b4c 100644 --- a/gnushogi/book.c +++ b/gnushogi/book.c @@ -293,7 +293,7 @@ BVerifyMove(char *s, unsigned short *mv, int moveno) UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); /* Illegal move in check */ #if !defined QUIETBOOKGEN - puts("Illegal move (in check) %s"); + puts("Illegal move (in check): %s"); bkdisplay(s, cnt, moveno); #endif return false; @@ -313,7 +313,7 @@ BVerifyMove(char *s, unsigned short *mv, int moveno) /* Illegal move */ #if !defined QUIETBOOKGEN - printf("Illegal move (no match) %s\n", s); + printf("Illegal move (no match): %s\n", s); bkdisplay(s, cnt, moveno); #endif return false; diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index e5efc17..7361e76 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -54,6 +54,7 @@ int mycnt1, mycnt2; static char *InPtr; struct display *dsp = &raw_display; +short xboard = false; #if defined(BOOKTEST) @@ -310,7 +311,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) if (SqAttacked(PieceList[opponent][0], computer, &blocked)) { UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); - dsp->AlwaysShowMessage("Illegal move (in check) %s", s); + dsp->AlwaysShowMessage("Illegal move (in check): %s", s); return false; } else @@ -352,7 +353,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) } } - dsp->AlwaysShowMessage("Illegal move (no match) %s", s); + dsp->AlwaysShowMessage("Illegal move (no match): %s", s); if (!XSHOGI && (cnt > 1)) { diff --git a/gnushogi/gnushogi.h b/gnushogi/gnushogi.h index 7854113..322d32f 100644 --- a/gnushogi/gnushogi.h +++ b/gnushogi/gnushogi.h @@ -66,6 +66,7 @@ extern display_t display_type; extern short hard_time_limit; /* If you exceed time limit, you lose. */ extern short nolist; /* Don't list game after exit. */ +extern short xboard; /* Use XBoard instead of xShogi protocol */ /* diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 588f13f..1a1035b 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -177,7 +177,7 @@ static void Raw_ShowPatternCount(short side, short n) { if (flag.post) - printf("%s matches %d pattern(s)\n", ColorStr[side], n); + printf("%s%s matches %d pattern(s)\n", xboard ? "# " : "" , ColorStr[side], n); } @@ -578,10 +578,10 @@ Raw_OutputMove(void) printf("%s mates!\n", ColorStr[computer]); #ifdef VERYBUGGY else if (!XSHOGI && (root->score < -SCORE_LIMIT)) - printf("%s has a forced mate in %d moves!\n", + printf("%s%s has a forced mate in %d moves!\n", xboard ? "# " : "", ColorStr[opponent], SCORE_LIMIT + 999 + root->score - 1); else if (!XSHOGI && (root->score > SCORE_LIMIT)) - printf("%s has a forced mate in %d moves!\n", + printf("%s%s has a forced mate in %d moves!\n", xboard ? "# " : "", ColorStr[computer], SCORE_LIMIT + 998 - root->score - 1); #endif /* VERYBUGGY */ } -- 1.7.0.4