From: Yann Dirson Date: Tue, 15 Oct 2013 22:56:52 +0000 (+0200) Subject: Convert more stuff from #ifdef to dspwrappers: AlwaysShowMessage. X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=3f589711eb3ecc7644378d6a0f2f29bc4b4c7db9;p=gnushogi.git Convert more stuff from #ifdef to dspwrappers: AlwaysShowMessage. --- diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 1ed6e1b..7987307 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -298,20 +298,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) if (SqAttacked(PieceList[opponent][0], computer, &blocked)) { UnmakeMove(opponent, &xnode, &tempb, &tempc, &tempsf, &tempst); - - if (NOT_CURSES) - { - /* Illegal move in check */ - printf(CP[77], s); - printf("\n"); - } - else - { - /* Illegal move in check */ - sprintf(buffer, CP[77], s); - ShowMessage(buffer); - } - + AlwaysShowMessage(CP[77], s); return false; } else @@ -353,17 +340,7 @@ VerifyMove(char *s, VerifyMove_mode iop, unsigned short *mv) } } - if (NOT_CURSES) - { - /* Illegal move */ - printf (CP[75], s); - } - else /* Curses. */ - { - /* Illegal move */ - sprintf(buffer, CP[76], s); - ShowMessage(buffer); - } + AlwaysShowMessage(CP[76], s); if (!barebones && (cnt > 1)) { diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index c717a9f..0deb256 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -151,6 +151,18 @@ Curses_ShowMessage(char *s) void +Curses_AlwaysShowMessage(const char *format, ...) +{ + static char buffer[60]; + va_list ap; + va_start(ap, format); + vsnprintf(buffer, sizeof(buffer), format, ap); + Curses_ShowMessage(buffer); + va_end(ap); +} + + +void Curses_Printf(const char *format, ...) { static char buffer[60]; diff --git a/gnushogi/cursesdsp.h b/gnushogi/cursesdsp.h index e46a992..4f9fd68 100644 --- a/gnushogi/cursesdsp.h +++ b/gnushogi/cursesdsp.h @@ -59,6 +59,7 @@ void Curses_ShowDepth(char ch); void Curses_ShowGameType(void); void Curses_ShowLine(unsigned short *bstline); void Curses_ShowMessage(char *s); +void Curses_AlwaysShowMessage(const char *format, ...); void Curses_Printf(const char *format, ...); void Curses_doRequestInputString(const char* fmt, char* buffer); void Curses_ShowPatternCount(short side, short n); diff --git a/gnushogi/dspwrappers.c b/gnushogi/dspwrappers.c index 87959ed..382c438 100644 --- a/gnushogi/dspwrappers.c +++ b/gnushogi/dspwrappers.c @@ -100,6 +100,7 @@ DISPLAY_FUNC(ShowDepth, (char ch), (ch)) DISPLAY_VOIDFUNC(ShowGameType) DISPLAY_FUNC(ShowLine, (unsigned short *bstline), (bstline)) DISPLAY_FUNC(ShowMessage, (char *s), (s)) +DISPLAY_STDARGFUNC(AlwaysShowMessage, (const char *format, ...), format, (format, ap)) DISPLAY_STDARGFUNC(Printf, (const char *format, ...), format, (format, ap)) DISPLAY_FUNC(ShowPatternCount, (short side, short n), (side, n)) DISPLAY_FUNC(ShowPostnValue, (short sq), (sq)) diff --git a/gnushogi/dspwrappers.h b/gnushogi/dspwrappers.h index ad5ab9d..c1fe649 100644 --- a/gnushogi/dspwrappers.h +++ b/gnushogi/dspwrappers.h @@ -57,6 +57,7 @@ extern void ShowDepth(char ch); extern void ShowGameType(void); extern void ShowLine(unsigned short *bstline); extern void ShowMessage(char *s); +extern void AlwaysShowMessage(const char *format, ...); extern void Printf(const char *format, ...); extern void RequestInputString(char* buffer, unsigned bufsize); extern void ShowPatternCount(short side, short n); diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 4225f32..328d80d 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -122,6 +122,15 @@ Raw_ShowMessage(char *s) printf("%s\n", s); } +void +Raw_AlwaysShowMessage(const char *format, ...) +{ + va_list ap; + va_start(ap, format); + vprintf(format, ap); + va_end(ap); + printf("\n"); +} void Raw_Printf(const char *format, ...) diff --git a/gnushogi/rawdsp.h b/gnushogi/rawdsp.h index ca3b14d..52915e4 100644 --- a/gnushogi/rawdsp.h +++ b/gnushogi/rawdsp.h @@ -59,6 +59,7 @@ void Raw_ShowDepth(char ch); void Raw_ShowGameType(void); void Raw_ShowLine(unsigned short *bstline); void Raw_ShowMessage(char *s); +void Raw_AlwaysShowMessage(const char *format, ...); void Raw_Printf(const char *format, ...); void Raw_doRequestInputString(const char* fmt, char* buffer); void Raw_ShowPatternCount(short side, short n);