From e575a64304bf46ab7bcc29634a982dae82721af5 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sun, 16 Feb 2014 14:51:28 +0100 Subject: [PATCH] EditBoard: fix error handling in piece setting. On invalid piece name, the code was anyway destroying any piece in the target location, and the whole logic was diluted. --- NEWS | 1 + gnushogi/cursesdsp.c | 7 +------ gnushogi/rawdsp.c | 6 +----- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 0fda42d..d5bc3b2 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ Changes in version 1.4.2 (unreleased): * XShogi is no longer included in the GNU Shogi source, it is available as a separate source archive. +* Fix clobbering of board on invalid input when editing board. * Fixed Curses mode display: - reversed column number for MiniShogi - clock position for MiniShogi diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 16125a0..2fa6d4c 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -531,13 +531,12 @@ Curses_EditBoard(void) continue; 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])) { + color[sq] = a; if (s[3] == '+') board[sq] = promoted[i]; else @@ -548,10 +547,6 @@ Curses_EditBoard(void) } } - - if (found == 0) - color[sq] = neutral; - DrawPiece(sq); } diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 2c4d185..0ca5c5a 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -396,13 +396,12 @@ Raw_EditBoard(void) } sq = locn(r, c); - color[sq] = a; - board[sq] = no_piece; for (i = no_piece; i <= king; i++) { if ((s[0] == pxx[i]) || (s[0] == qxx[i])) { + color[sq] = a; if (s[3] == '+') board[sq] = promoted[i]; else @@ -412,9 +411,6 @@ Raw_EditBoard(void) break; } } - - if (found == 0) - color[sq] = neutral; } for (sq = 0; sq < NO_SQUARES; sq++) -- 1.7.0.4