diff options
author | christos <christos@NetBSD.org> | 2005-08-09 02:38:32 +0000 |
---|---|---|
committer | christos <christos@NetBSD.org> | 2005-08-09 02:38:32 +0000 |
commit | d6237184f66652f05e744b26749cb40605e3af0b (patch) | |
tree | c1033279b12797fa0a684e660daf9e4ed281531d /dab | |
parent | a38a988e1c270bda5e561359772f96eeb81357cd (diff) | |
download | bsdgames-darwin-d6237184f66652f05e744b26749cb40605e3af0b.tar.gz bsdgames-darwin-d6237184f66652f05e744b26749cb40605e3af0b.tar.zst bsdgames-darwin-d6237184f66652f05e744b26749cb40605e3af0b.zip |
Pass WARNS=3
Diffstat (limited to 'dab')
-rw-r--r-- | dab/Makefile | 4 | ||||
-rw-r--r-- | dab/algor.cc | 16 | ||||
-rw-r--r-- | dab/algor.h | 10 | ||||
-rw-r--r-- | dab/board.cc | 8 | ||||
-rw-r--r-- | dab/box.cc | 10 | ||||
-rw-r--r-- | dab/ttyscrn.cc | 9 |
6 files changed, 29 insertions, 28 deletions
diff --git a/dab/Makefile b/dab/Makefile index 76cbc7c8..d135ee25 100644 --- a/dab/Makefile +++ b/dab/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.3 2004/01/05 15:35:59 christos Exp $ +# $NetBSD: Makefile,v 1.4 2005/08/09 02:38:32 christos Exp $ -WARNS=2 +WARNS=3 DPADD+=${LIBCURSES} ${LIBTERMCAP} ${LIBM} LDADD+=-lcurses -ltermcap -lm diff --git a/dab/algor.cc b/dab/algor.cc index b84a3bda..1dbf7337 100644 --- a/dab/algor.cc +++ b/dab/algor.cc @@ -1,4 +1,4 @@ -/* $NetBSD: algor.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */ +/* $NetBSD: algor.cc,v 1.2 2005/08/09 02:38:32 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ * algor.C: Computer algorithm */ #include "defs.h" -RCSID("$NetBSD: algor.cc,v 1.1 2003/12/27 01:16:55 christos Exp $") +RCSID("$NetBSD: algor.cc,v 1.2 2005/08/09 02:38:32 christos Exp $") #include "algor.h" #include "board.h" @@ -132,7 +132,7 @@ size_t ALGOR::count_closure(size_t& y, size_t& x, int& dir, BOARD& b) * return the number of boxes closed in the maximum closure, * and the first box of the maximum closure in (x, y, dir) */ -int ALGOR::find_max_closure(size_t& y, size_t& x, int& dir, const BOARD& b) +size_t ALGOR::find_max_closure(size_t& y, size_t& x, int& dir, const BOARD& b) { BOARD nb(b); int tdir, maxdir = -1; @@ -237,8 +237,8 @@ int ALGOR::find_bad_turn(size_t& y, size_t& x, int& dir, BOARD& b, int last) return 0; } -int ALGOR::find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b, - int last) +size_t ALGOR::find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b, + int last) { BOARD nb(b); int tdir, mindir = -1, xdir, mv; @@ -275,11 +275,11 @@ int ALGOR::find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b, // Search for the move that makes the opponent close the least number of // boxes; returns 1 if a move found, 0 otherwise -int ALGOR::find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b) +size_t ALGOR::find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b) { size_t x1, y1; int dir1; - int count = b.ny() * b.nx() + 1, count1; + size_t count = b.ny() * b.nx() + 1, count1; for (size_t i = 0; i < 3; i++) if (count > (count1 = find_min_closure1(y1, x1, dir1, b, i))) { @@ -289,7 +289,7 @@ int ALGOR::find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b) dir = dir1; } - return (size_t) count != b.ny() * b.nx() + 1; + return count != b.ny() * b.nx() + 1; } // Return a move in (y, x, dir) diff --git a/dab/algor.h b/dab/algor.h index 862c93a7..af0be629 100644 --- a/dab/algor.h +++ b/dab/algor.h @@ -1,4 +1,4 @@ -/* $NetBSD: algor.h,v 1.1.1.1 2003/12/26 17:57:03 christos Exp $ */ +/* $NetBSD: algor.h,v 1.2 2005/08/09 02:38:32 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -57,10 +57,10 @@ class ALGOR : public PLAYER { private: // Closure searches int find_closure(size_t& y, size_t& x, int& dir, BOARD& b); - int find_max_closure(size_t& y, size_t& x, int& dir, const BOARD& b); - int find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b, - int last); - int find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b); + size_t find_max_closure(size_t& y, size_t& x, int& dir, const BOARD& b); + size_t find_min_closure1(size_t& y, size_t& x, int& dir, const BOARD& b, + int last); + size_t find_min_closure(size_t& y, size_t& x, int& dir, const BOARD& b); // Move searches int find_good_turn(size_t& y, size_t& x, int& dir, const BOARD& b); diff --git a/dab/board.cc b/dab/board.cc index 6cd3e957..dcded524 100644 --- a/dab/board.cc +++ b/dab/board.cc @@ -1,4 +1,4 @@ -/* $NetBSD: board.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */ +/* $NetBSD: board.cc,v 1.2 2005/08/09 02:38:32 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ * board.C: Board manipulations */ #include "defs.h" -RCSID("$NetBSD: board.cc,v 1.1 2003/12/27 01:16:55 christos Exp $") +RCSID("$NetBSD: board.cc,v 1.2 2005/08/09 02:38:32 christos Exp $") #include <stdio.h> #include <string.h> @@ -154,7 +154,7 @@ int BOARD::full(void) const { for (size_t y = 0; y < _ny; y++) for (size_t x = 0; x < _nx; x++) { - BOX box(y, x, (BOARD&) *this); + BOX box(y, x, const_cast<BOARD&>(*this)); if (box.count() != 4) return 0; } @@ -173,7 +173,7 @@ void BOARD::paint(void) const { for (size_t y = 0; y < _ny; y++) for (size_t x = 0; x < _nx; x++) { - BOX box(y, x, (BOARD&) *this); + BOX box(y, x, const_cast<BOARD&>(*this)); box.paint(); } } @@ -1,4 +1,4 @@ -/* $NetBSD: box.cc,v 1.1 2003/12/27 01:16:55 christos Exp $ */ +/* $NetBSD: box.cc,v 1.2 2005/08/09 02:38:32 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -40,7 +40,7 @@ * box.C: Box computations */ #include "defs.h" -RCSID("$NetBSD: box.cc,v 1.1 2003/12/27 01:16:55 christos Exp $") +RCSID("$NetBSD: box.cc,v 1.2 2005/08/09 02:38:32 christos Exp $") #include "box.h" #include "board.h" @@ -103,7 +103,7 @@ void BOX::paint(void) for (e = BOX::first; e < BOX::last; e++) { addcorner(_centery + corners[e].y, _centerx + corners[e].x); _b.getScrn()->moveto(_centery + edges[e].y, _centerx + edges[e].x); - _b.getScrn()->addedge(edge((EDGE) e)); + _b.getScrn()->addedge(edge(static_cast<EDGE>(e))); } _b.getScrn()->redraw(); } @@ -144,7 +144,7 @@ int BOX::count(void) const int cnt = 0; for (int e = BOX::first; e < BOX::last; e++) - cnt += isset((EDGE) e); + cnt += isset(static_cast<EDGE>(e)); return cnt; } @@ -152,6 +152,6 @@ int BOX::count(void) const void BOX::reset(void) { for (int e = BOX::first; e < BOX::last; e++) - clr((EDGE) e); + clr(static_cast<EDGE>(e)); name() = ' '; } diff --git a/dab/ttyscrn.cc b/dab/ttyscrn.cc index 62ae843a..9ed58e95 100644 --- a/dab/ttyscrn.cc +++ b/dab/ttyscrn.cc @@ -1,4 +1,4 @@ -/* $NetBSD: ttyscrn.cc,v 1.2 2003/12/27 18:24:51 martin Exp $ */ +/* $NetBSD: ttyscrn.cc,v 1.3 2005/08/09 02:38:32 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -41,7 +41,7 @@ */ #include "defs.h" -RCSID("$NetBSD: ttyscrn.cc,v 1.2 2003/12/27 18:24:51 martin Exp $") +RCSID("$NetBSD: ttyscrn.cc,v 1.3 2005/08/09 02:38:32 christos Exp $") #include <stdio.h> #include <curses.h> @@ -207,8 +207,9 @@ TTYSCRN* TTYSCRN::create(int acs, size_t y, size_t x) tx = getmaxx(stdscr); ty = getmaxy(stdscr); - if (tx == ERR || ty == ERR || (size_t)tx < x * 2 + TTYSCRN::offsx + 12 - || (size_t)ty < y * 2 + TTYSCRN::offsy) { + if (tx == ERR || ty == ERR + || static_cast<size_t>(tx) < x * 2 + TTYSCRN::offsx + 12 + || static_cast<size_t>(ty) < y * 2 + TTYSCRN::offsy) { endwin(); return NULL; } |