X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fknight.c;h=d9f81facacec814e13cdb984975523867b7cbc13;hp=44537d41d62132cc09b735ed43ec94685e161a3d;hb=5bfda8791637989e00be64748603cf4be2efbce5;hpb=a8987e73ec254703634802b4f7ee30d3a485524d diff --git a/test/knight.c b/test/knight.c index 44537d41..d9f81fac 100644 --- a/test/knight.c +++ b/test/knight.c @@ -1,3 +1,30 @@ +/**************************************************************************** + * Copyright (c) 1998-2008,2010 Free Software Foundation, Inc. * + * * + * Permission is hereby granted, free of charge, to any person obtaining a * + * copy of this software and associated documentation files (the * + * "Software"), to deal in the Software without restriction, including * + * without limitation the rights to use, copy, modify, merge, publish, * + * distribute, distribute with modifications, sublicense, and/or sell * + * copies of the Software, and to permit persons to whom the Software is * + * furnished to do so, subject to the following conditions: * + * * + * The above copyright notice and this permission notice shall be included * + * in all copies or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * + * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + * * + * Except as contained in this notice, the name(s) of the above copyright * + * holders shall not be used in advertising or otherwise to promote the * + * sale, use or other dealings in this Software without prior written * + * authorization. * + ****************************************************************************/ /* * Knight's Tour - a brain game * @@ -6,7 +33,7 @@ * Eric S. Raymond July 22 1995. Mouse support * added September 20th 1995. * - * $Id: knight.c,v 1.26 2002/10/19 22:11:24 tom Exp $ + * $Id: knight.c,v 1.31 2010/11/13 20:44:21 tom Exp $ */ #include @@ -92,9 +119,9 @@ init_program(void) bg = -1; #endif - (void) init_pair(TRAIL_COLOR, COLOR_CYAN, bg); - (void) init_pair(PLUS_COLOR, COLOR_RED, bg); - (void) init_pair(MINUS_COLOR, COLOR_GREEN, bg); + (void) init_pair(TRAIL_COLOR, (short) COLOR_CYAN, (short) bg); + (void) init_pair(PLUS_COLOR, (short) COLOR_RED, (short) bg); + (void) init_pair(MINUS_COLOR, (short) COLOR_GREEN, (short) bg); trail |= COLOR_PAIR(TRAIL_COLOR); plus |= COLOR_PAIR(PLUS_COLOR); @@ -128,8 +155,8 @@ help1(void) (void) waddstr(helpwin, "puzzle; also inform you when you run out\n"); (void) waddstr(helpwin, "of legal moves.\n\n"); - (void) mvwaddstr(helpwin, NOTIFYY - INSTRY, 0, - "Press `?' to go to keystroke help."); + MvWAddStr(helpwin, NOTIFYY - INSTRY, 0, + "Press `?' to go to keystroke help."); } static void @@ -154,8 +181,8 @@ help2(void) (void) waddstr(helpwin, "square with spacebar, Enter, or the keypad\n"); (void) waddstr(helpwin, "center key. Use F/B to review the path.\n"); - (void) mvwaddstr(helpwin, NOTIFYY - INSTRY, 0, - "Press `?' to go to game explanation"); + MvWAddStr(helpwin, NOTIFYY - INSTRY, 0, + "Press `?' to go to game explanation"); } static void @@ -199,7 +226,7 @@ dosquares(void) { int i, j; - mvaddstr(0, 20, "KNIGHT'S MOVE -- a logical solitaire"); + MvAddStr(0, 20, "KNIGHT'S MOVE -- a logical solitaire"); move(BOARDY, BOARDX); waddch(boardwin, ACS_ULCORNER); @@ -292,12 +319,12 @@ find_next_move(int *y, int *x) newx = oldx + offsets[k].x; if (chksqr(newy, newx)) { if (first < 0) - first = k; + first = (int) k; if (newy == *y && newx == *x) { - found = k; + found = (int) k; } else if (found >= 0) { - next = k; + next = (int) k; break; } } @@ -356,7 +383,7 @@ drawmove(chtype tchar, int oldy, int oldx, int row, int column) mark_possibles(oldy, oldx, ' '); } - if (row != -1 && column != -1) { + if (row >= 0 && column >= 0) { markcell(trail, row, column); mark_possibles(row, column, minus); board[row][column] = TRUE; @@ -559,8 +586,8 @@ play(void) history[movecount - 1].y, history[movecount - 1].x, rw, col); - history[movecount].y = rw; - history[movecount].x = col; + history[movecount].y = (short) rw; + history[movecount].x = (short) col; movecount++; trialcount++;