X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcommondsp.c;h=79873070bb9f9283f3b2d645eb0297eb9fd846ae;hb=3f589711eb3ecc7644378d6a0f2f29bc4b4c7db9;hp=785b72e986a8e846f1a3ac0b2c7358bbec5e8b15;hpb=7f6340bb48dec4e1e091fcf551af50bd3cfdcd2e;p=gnushogi.git diff --git a/gnushogi/commondsp.c b/gnushogi/commondsp.c index 785b72e..7987307 100644 --- a/gnushogi/commondsp.c +++ b/gnushogi/commondsp.c @@ -4,11 +4,14 @@ * Common display routines for GNU Shogi. * * ---------------------------------------------------------------------- - * - * Copyright (c) 2012 Free Software Foundation + * Copyright (c) 1993, 1994, 1995 Matthias Mutz + * Copyright (c) 1999 Michael Vanier and the Free Software Foundation * * GNU SHOGI is based on GNU CHESS * + * Copyright (c) 1988, 1989, 1990 John Stanback + * Copyright (c) 1992 Free Software Foundation + * * This file is part of GNU SHOGI. * * GNU Shogi is free software; you can redistribute it and/or modify it @@ -161,12 +164,8 @@ algbr(short f, short t, short flag) if ((f == t) && ((f != 0) || (t != 0))) { - if (!barebones) - { - if (NOT_CURSES) - printf("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); - else - printw("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); + if (!barebones) { + Printf("error in algbr: FROM=TO=%d, flag=0x%4x\n", t, flag); } mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = '\0'; @@ -299,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], mvstr[0]); - printf("\n"); - } - else - { - /* Illegal move in check */ - sprintf(buffer, CP[77], s); - ShowMessage(buffer); - } - + AlwaysShowMessage(CP[77], s); return false; } else @@ -354,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)) { @@ -445,24 +421,12 @@ GetGame(void) short sq; short side, isp; - if (savefile[0]) - { + if (savefile[0]) { strcpy(fname, savefile); - } - else - { + } else { /* Enter file name */ ShowMessage(CP[63]); - - if (NOT_CURSES) - { - scanf("%s", fname); - } - else - { - fflush(stdout); - scanw("%s", fname); - } + RequestInputString(fname, sizeof(fname)-1); } /* shogi.000 */ @@ -682,24 +646,12 @@ SaveGame(void) short side, piece; char empty[2] = "\n"; - if (savefile[0]) - { + if (savefile[0]) { strcpy(fname, savefile); - } - else - { + } else { /* Enter file name */ ShowMessage(CP[63]); - - if (NOT_CURSES) - { - scanf("%s", fname); - } - else - { - fflush(stdout); - scanw("%s", fname); - } + RequestInputString(fname, sizeof(fname)-1); } if (fname[0] == '\0') /* shogi.000 */ @@ -843,16 +795,7 @@ GetXGame(void) /* Enter file name */ ShowMessage(CP[63]); - - if (NOT_CURSES) - { - scanf("%s", fname); - } - else - { - fflush(stdout); - scanw("%s", fname); - } + RequestInputString(fname, sizeof(fname)-1); if (fname[0] == '\0') /* XSHOGI.position.read */ strcpy(fname, CP[205]); @@ -980,16 +923,7 @@ SaveXGame(void) /* Enter file name */ ShowMessage(CP[63]); - - if (NOT_CURSES) - { - scanf("%s", fname); - } - else - { - fflush(stdout); - scanw("%s", fname); - } + RequestInputString(fname, sizeof(fname)-1); if (fname[0] == '\0') /* XSHOGI.position.read */ strcpy(fname, CP[205]); @@ -1062,24 +996,12 @@ BookSave(void) char fname[256], sflags[4]; short i, j, f, t; - if (savefile[0]) - { + if (savefile[0]) { strcpy(fname, savefile); - } - else - { + } else { /* Enter file name */ ShowMessage(CP[63]); - - if (NOT_CURSES) - { - scanf("%s", fname); - } - else - { - fflush(stdout); - scanw("%s", fname); - } + RequestInputString(fname, sizeof(fname)-1); } if (fname[0] == '\0') @@ -1440,7 +1362,7 @@ TestSpeed(void(*f)(short side, short ply, #endif unsigned i; - long cnt, rate, t1, t2; + long cnt, t1, t2; #ifdef HAVE_GETTIMEOFDAY struct timeval tv; @@ -1480,17 +1402,7 @@ TestSpeed(void(*f)(short side, short ply, else et = 1; - rate = (((et) ? ((cnt * 100) / et) : 0)); - -#ifdef DYNAMIC_ZNODES - if (rate > 0) - znodes = rate; -#endif - - if (NOT_CURSES) - printf(CP[91], cnt, rate); - else - ShowNodeCnt(cnt); + ShowNodeCnt(cnt); } @@ -1499,7 +1411,7 @@ void TestPSpeed(short(*f) (short side), unsigned j) { short i; - long cnt, rate, t1, t2; + long cnt, t1, t2; #ifdef HAVE_GETTIMEOFDAY struct timeval tv; #endif @@ -1528,14 +1440,7 @@ TestPSpeed(short(*f) (short side), unsigned j) else et = 1; - rate = (et) ? ((cnt * 100) / et) : 0; - - /* printf("Nodes= %ld Nodes/sec= %ld\n", cnt, rate); */ - - if (NOT_CURSES) - printf(CP[91], cnt, rate); - else - ShowNodeCnt(cnt); + ShowNodeCnt(cnt); } @@ -1742,8 +1647,8 @@ InputCommand(char *command) { s[0] = sx[0] = '\0'; - while(!sx[0]) - (void)fgets(sx, 80, stdin); + while(!eof && !sx[0]) + eof = (fgets(sx, 80, stdin) == NULL); } else { @@ -2158,8 +2063,6 @@ InputCommand(char *command) printf("\n"); #endif } - - signal(SIGUSR1, TerminateSearch); }