X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=gnushogi%2Frawdsp.c;h=1a1035b85c72f642cb9d7ca6592be4a0c24e52ae;hb=0b0fc4c9c805e95d883196b947217e23efb443c5;hp=0a4e473059a859757a7bddd83188655eaa7dc0d8;hpb=0f5d4e2b00e7911f02ed0f404a3d96d699cabd7e;p=gnushogi.git diff --git a/gnushogi/rawdsp.c b/gnushogi/rawdsp.c index 0a4e473..1a1035b 100644 --- a/gnushogi/rawdsp.c +++ b/gnushogi/rawdsp.c @@ -177,7 +177,7 @@ static void Raw_ShowPatternCount(short side, short n) { if (flag.post) - printf("%s matches %d pattern(s)\n", ColorStr[side], n); + printf("%s%s matches %d pattern(s)\n", xboard ? "# " : "" , ColorStr[side], n); } @@ -352,18 +352,21 @@ Raw_EditBoard(void) Book = BOOKFAIL; Raw_ClearScreen(); Raw_UpdateDisplay(0, 0, 1, 0); - fputs(". Exit to main\n", stdout); - fputs("# Clear board\n", stdout); - fputs("c Change sides\n", stdout); - fputs("enter piece & location: \n", stdout); + printf(". Exit to main\n"); + printf("# Clear board\n"); + printf("c Change sides\n"); + printf("enter piece & location:\n"); a = black; - do + while(1) { scanf("%s", s); found = 0; + if (s[0] == '.') + break; + if (s[0] == '#') { for (sq = 0; sq < NO_SQUARES; sq++) @@ -373,10 +376,13 @@ Raw_EditBoard(void) } ClearCaptured(); + continue; } - if (s[0] == 'c') + if (s[0] == 'c') { a = otherside[a]; + continue; + } if (s[1] == '*') { @@ -389,41 +395,39 @@ Raw_EditBoard(void) break; } } - - c = -1; - r = -1; + if (!found) + printf("# Invalid piece type '%c'\n", s[0]); + continue; } - 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)) { + printf("# Out-of-board position '%c%c'\n", s[1], s[2]); + continue; } - if ((c >= 0) && (c < NO_COLS) && (r >= 0) && (r < NO_ROWS)) - { - sq = locn(r, c); - color[sq] = a; - board[sq] = no_piece; + sq = locn(r, c); - for (i = no_piece; i <= king; i++) + for (i = no_piece; i <= king; i++) + { + if ((s[0] == pxx[i]) || (s[0] == qxx[i])) { - if ((s[0] == pxx[i]) || (s[0] == qxx[i])) - { - if (s[3] == '+') - board[sq] = promoted[i]; - else - board[sq] = i; + color[sq] = a; + if (s[3] == '+') + board[sq] = promoted[i]; + else + board[sq] = i; - found = 1; - break; - } + found = 1; + break; } - - if (found == 0) - color[sq] = neutral; } + + if (!found) + printf("# Invalid piece type '%c'\n", s[0]); } - while (s[0] != '.'); for (sq = 0; sq < NO_SQUARES; sq++) Mvboard[sq] = ((board[sq] != Stboard[sq]) ? 10 : 0); @@ -574,10 +578,10 @@ Raw_OutputMove(void) printf("%s mates!\n", ColorStr[computer]); #ifdef VERYBUGGY else if (!XSHOGI && (root->score < -SCORE_LIMIT)) - printf("%s has a forced mate in %d moves!\n", + printf("%s%s has a forced mate in %d moves!\n", xboard ? "# " : "", ColorStr[opponent], SCORE_LIMIT + 999 + root->score - 1); else if (!XSHOGI && (root->score > SCORE_LIMIT)) - printf("%s has a forced mate in %d moves!\n", + printf("%s%s has a forced mate in %d moves!\n", xboard ? "# " : "", ColorStr[computer], SCORE_LIMIT + 998 - root->score - 1); #endif /* VERYBUGGY */ }