X-Git-Url: http://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=test%2Fknight.c;h=f9f725b0fc6c96ae9270aac9ac6c19d4478f0559;hp=50cba37f8682e3f6a60d7ed2ea49f6dc18d2cdb0;hb=312665d3aaaf5d8e3ba34d80fdd650abf758272a;hpb=8b6693ef8fb9e7bafb52d7c42fc3d15b7a1bea3f diff --git a/test/knight.c b/test/knight.c index 50cba37f..f9f725b0 100644 --- a/test/knight.c +++ b/test/knight.c @@ -1,5 +1,6 @@ /**************************************************************************** - * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc. * + * Copyright 2018-2020,2021 Thomas E. Dickey * + * Copyright 1998-2013,2017 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 * @@ -33,7 +34,7 @@ * Eric S. Raymond July 22 1995. Mouse support * added September 20th 1995. * - * $Id: knight.c,v 1.45 2019/04/20 20:34:55 tom Exp $ + * $Id: knight.c,v 1.48 2021/04/25 00:10:43 tom Exp $ */ #include @@ -328,21 +329,20 @@ mark_possibles(SQUARES squares, int y, int x, chtype mark) static bool find_next_move(SQUARES squares, HISTORY * doneData, int doneSize, int *y, int *x) { - unsigned j, k; - int found = -1; - int first = -1; - int next = -1; - int oldy, oldx; - int newy, newx; bool result = FALSE; if (doneSize > 1) { - oldy = doneData[doneSize - 1].y; - oldx = doneData[doneSize - 1].x; + unsigned j; + int oldy = doneData[doneSize - 1].y; + int oldx = doneData[doneSize - 1].x; + int found = -1; + int first = -1; + int next = -1; + for (j = 0; j < MAX_OFFSET * 2; j++) { - k = j % MAX_OFFSET; - newy = oldy + offsets[k].y; - newx = oldx + offsets[k].x; + unsigned k = j % MAX_OFFSET; + int newy = oldy + offsets[k].y; + int newx = oldx + offsets[k].x; if (isUnusedYX(squares, newy, newx)) { if (first < 0) first = (int) k; @@ -502,12 +502,11 @@ recurBack(SQUARES squares, int y, int x, int total) int result; if (total < maxmoves) { - int try_x, try_y; unsigned k; for (k = 0; k < MAX_OFFSET; k++) { - try_x = x + offsets[k].x; - try_y = y + offsets[k].y; + int try_x = x + offsets[k].x; + int try_y = y + offsets[k].y; if (isUnusedYX(squares, try_y, try_x)) { ++test_test; squares[try_y][try_x] = total + 1; @@ -596,8 +595,8 @@ play(void) { bool keyhelp; /* TRUE if keystroke help is up */ int i, j, count; - int lastcol = 0; /* last location visited */ - int lastrow = 0; + int lastcol; /* last location visited */ + int lastrow; int ny = 0, nx = 0; int review = 0; /* review history */ int test_size;