From: Eric S. Raymond Date: Mon, 7 May 2001 20:27:59 +0000 (+0000) Subject: Bug fixes by Eric Sigra. X-Git-Tag: 2.3~2 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=b08eba3f0566476d9782b8390739925819a924cf;p=bs.git Bug fixes by Eric Sigra. --- diff --git a/Makefile b/Makefile index 743c626..955ebd4 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # Note: When the version changes, you also have to change # * the name of the containing directory # * the RPM spec file -V=2.2 +V=2.3 # Flags for use with the Linux ncurses package (recommended) TERMLIB = -lncurses diff --git a/bs.c b/bs.c index 1da99d5..c8a0287 100644 --- a/bs.c +++ b/bs.c @@ -7,8 +7,9 @@ * v2.0 featuring strict ANSI/POSIX conformance, November 1993. * v2.1 with ncurses mouse support, September 1995 * v2.2 code cleanup. + * v2.3 bug fixes by Erik Sigra. * - * $Id: bs.c,v 1.22 1997/12/20 15:11:53 tom Exp $ + * $Id: bs.c,v 1.8 1998/08/14 03:53:19 esr Exp esr $ */ #include @@ -311,13 +312,11 @@ static int rnd(int n) static void randomplace(int b, ship_t *ss) /* generate a valid random ship placement into px,py */ { - register int bwidth = BWIDTH - ss->length; - register int bdepth = BDEPTH - ss->length; do { - ss->y = rnd(bdepth); - ss->x = rnd(bwidth); ss->dir = rnd(2) ? E : S; + ss->x = rnd(BWIDTH - (ss->dir == E ? ss->length : 0)); + ss->y = rnd(BDEPTH - (ss->dir == S ? ss->length : 0)); } while (!checkplace(b, ss, FALSE)); } @@ -675,8 +674,8 @@ static bool checkplace(int b, ship_t *ss, int vis) int l, xend, yend; /* first, check for board edges */ - xend = ss->x + ss->length * xincr[ss->dir]; - yend = ss->y + ss->length * yincr[ss->dir]; + xend = ss->x + (ss->length - 1) * xincr[ss->dir]; + yend = ss->y + (ss->length - 1) * yincr[ss->dir]; if (!ONBOARD(xend, yend)) { if (vis) @@ -782,6 +781,11 @@ static ship_t *hitship(int x, int y) attrset(0); #endif /* A_COLOR */ } + else + { + pgoto(y1, x1); + (void)addch(SHOWSPLASH); + } } } } @@ -797,6 +801,18 @@ static ship_t *hitship(int x, int y) cgoto(y1, x1); (void) addch((chtype)(ss->symbol)); } + else + { + pgoto(y1, x1); +#ifdef A_COLOR + if (has_colors()) + attron(COLOR_PAIR(COLOR_RED)); +#endif /* A_COLOR */ + (void)addch(SHOWHIT); +#ifdef A_COLOR + attrset(0); +#endif /* A_COLOR */ + } } (void) move(oldy, oldx);