From f9dcc468f334f5fe3e16822715539ea94444096d Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Sun, 16 Feb 2014 16:03:39 +0100 Subject: [PATCH] EditBoard: display message on wrong input. --- NEWS | 4 +++- gnushogi/cursesdsp.c | 11 +++++++++-- gnushogi/rawdsp.c | 6 ++++++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index d5bc3b2..35537b8 100644 --- a/NEWS +++ b/NEWS @@ -5,7 +5,9 @@ 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. +* Fixes for edit mode: + - fixed clobbering of board on invalid input + - display a message on wrong input * Fixed Curses mode display: - reversed column number for MiniShogi - clock position for MiniShogi diff --git a/gnushogi/cursesdsp.c b/gnushogi/cursesdsp.c index 2fa6d4c..bf5452f 100644 --- a/gnushogi/cursesdsp.c +++ b/gnushogi/cursesdsp.c @@ -485,6 +485,7 @@ Curses_EditBoard(void) ClearEoln(); FLUSH_SCANW("%s", s); found = 0; + ClearMessage(); if (s[0] == '.') break; @@ -520,15 +521,18 @@ Curses_EditBoard(void) break; } } - + if (!found) + AlwaysShowMessage("Invalid piece type '%c'", s[0]); continue; } c = COL_NUM(s[1]); r = ROW_NUM(s[2]); - if ((c < 0) || (c >= NO_COLS) || (r < 0) || (r >= NO_ROWS)) + if ((c < 0) || (c >= NO_COLS) || (r < 0) || (r >= NO_ROWS)) { + AlwaysShowMessage("Out-of-board '%c%c'", s[1], s[2]); continue; + } sq = locn(r, c); @@ -547,6 +551,9 @@ Curses_EditBoard(void) } } + if (!found) + AlwaysShowMessage("Invalid piece type '%c'", s[0]); + DrawPiece(sq); } diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 0ca5c5a..53d051c 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -385,6 +385,8 @@ Raw_EditBoard(void) break; } } + if (!found) + printf("# Invalid piece type '%c'\n", s[0]); continue; } @@ -392,6 +394,7 @@ Raw_EditBoard(void) r = ROW_NUM(s[2]); if ((c < 0) || (c >= NO_COLS) || (r < 0) || (r >= NO_ROWS)) { + printf("# Out-of-board position '%c%c'\n", s[1], s[2]); continue; } @@ -411,6 +414,9 @@ Raw_EditBoard(void) break; } } + + if (!found) + printf("# Invalid piece type '%c'\n", s[0]); } for (sq = 0; sq < NO_SQUARES; sq++) -- 1.7.0.4