* 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 <curses.h>
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));
}
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)
attrset(0);
#endif /* A_COLOR */
}
+ else
+ {
+ pgoto(y1, x1);
+ (void)addch(SHOWSPLASH);
+ }
}
}
}
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);