X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Fcursesdsp.c;h=21a061bd13f9d02375dc408d657845e9a00ee154;hb=e6d0e922c94c9999f1f8a803af008e0a482bedf0;hp=b32181b6b0a16432f673ac61399b2b9e7b04de4b;hpb=829c253a7cc2d3e1a9ed643485c1b1a92967b5df;p=gnushogi.git diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index b32181b..21a061b 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -6,6 +6,7 @@ * ---------------------------------------------------------------------- * Copyright (c) 1993, 1994, 1995 Matthias Mutz * Copyright (c) 1999 Michael Vanier and the Free Software Foundation + * Copyright (c) 2008, 2013, 2014 Yann Dirson and the Free Software Foundation * * GNU SHOGI is based on GNU CHESS * @@ -30,6 +31,8 @@ * ---------------------------------------------------------------------- */ +/* request *snprintf prototypes*/ +#define _POSIX_C_SOURCE 200112L #include #include @@ -455,7 +458,7 @@ static const short y0[2] = { 20, 4 }; void Curses_EditBoard(void) { - short a, c, sq, i; + short a, c, sq, i, found; short r = 0; char s[80]; @@ -480,6 +483,7 @@ Curses_EditBoard(void) gotoXY(TAB + 24, 7); ClearEoln(); FLUSH_SCANW("%s", s); + found = 0; if (s[0] == '#') { @@ -502,36 +506,46 @@ Curses_EditBoard(void) for (i = NO_PIECES; i > no_piece; i--) { if ((s[0] == pxx[i]) || (s[0] == qxx[i])) + { + Captured[a][unpromoted[i]]++; + UpdateCatched(); + found = 1; break; + } } - Captured[a][unpromoted[i]]++; - UpdateCatched(); c = -1; } else { - c = COL_NAME(s[1]); - r = ROW_NAME(s[2]); + c = COL_NUM(s[1]); + r = ROW_NUM(s[2]); } if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS)) { sq = locn(r, c); - + color[sq] = a; + board[sq] = no_piece; + for (i = NO_PIECES; i > no_piece; i--) { if ((s[0] == pxx[i]) || (s[0] == qxx[i])) + { + if (s[3] == '+') + board[sq] = promoted[i]; + else + board[sq] = unpromoted[i]; + + found = 1; break; + } } + - if (s[3] == '+') - i = promoted[i]; - else - i = unpromoted[i]; + if (found == 0) + color[sq] = neutral; - board[sq] = i; - color[sq] = ((board[sq] == no_piece) ? neutral : a); DrawPiece(sq); } } @@ -854,10 +868,17 @@ Curses_UpdateDisplay(short f, short t, short redraw, short isspec) gotoXY(3, 4 + 2*NO_ROWS); printw(" "); +#ifndef MINISHOGI if (flag.reverse) printw(" 1 2 3 4 5 6 7 8 9"); else printw(" 9 8 7 6 5 4 3 2 1"); +#else + if (flag.reverse) + printw(" 1 2 3 4 5"); + else + printw(" 1 2 3 4 5"); +#endif for (sq = 0; sq < NO_SQUARES; sq++) DrawPiece(sq);