/****************************************************************************
- * Copyright (c) 1998-2009,2010 Free Software Foundation, Inc. *
+ * Copyright (c) 1998-2010,2012 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 *
* v2.0 featuring strict ANSI/POSIX conformance, November 1993.
* v2.1 with ncurses mouse support, September 1995
*
- * $Id: bs.c,v 1.52 2010/11/13 20:07:52 tom Exp $
+ * $Id: bs.c,v 1.56 2012/12/08 23:35:58 tom Exp $
*/
#include <test.priv.h>
MvAddCh(PYBASE + i, PXBASE - 3, (chtype) (i + 'A'));
#ifdef A_COLOR
if (has_colors())
- attron(COLOR_PAIR(COLOR_BLUE));
+ attron((attr_t) COLOR_PAIR(COLOR_BLUE));
#endif /* A_COLOR */
(void) addch(' ');
for (j = 0; j < BWIDTH; j++)
MvAddCh(CYBASE + i, CXBASE - 3, (chtype) (i + 'A'));
#ifdef A_COLOR
if (has_colors())
- attron(COLOR_PAIR(COLOR_BLUE));
+ attron((attr_t) COLOR_PAIR(COLOR_BLUE));
#endif /* A_COLOR */
(void) addch(' ');
for (j = 0; j < BWIDTH; j++)
placeship(COMPUTER, ss, FALSE);
}
- ss = (ship_t *) NULL;
do {
char c, docked[SHIPTYPES + 2], *cp = docked;
+ ss = (ship_t *) NULL;
+
/* figure which ships still wait to be placed */
*cp++ = 'R';
for (i = 0; i < SHIPTYPES; i++)
do {
c = (char) getch();
} while
- (!(strchr("hjklrR", c) || c == FF));
+ (!(strchr("hjkl8462rR", c) || c == FF));
if (c == FF) {
(void) clearok(stdscr, TRUE);
(void) refresh();
+ } else if (ss == 0) {
+ beep(); /* simple to verify, unlikely to happen */
} else if (c == 'r') {
- assert(ss != 0);
prompt(1, "Random-placing your %s", ss->name);
randomplace(PLAYER, ss);
placeship(PLAYER, ss, TRUE);
}
error((char *) NULL);
} else if (strchr("hjkl8462", c)) {
- assert(ss != 0);
ss->x = curx;
ss->y = cury;
cgoto(y1, x1);
#ifdef A_COLOR
if (has_colors())
- attron(COLOR_PAIR(COLOR_GREEN));
+ attron((attr_t) COLOR_PAIR(COLOR_GREEN));
#endif /* A_COLOR */
(void) addch(MARK_MISS);
#ifdef A_COLOR
pgoto(y1, x1);
#ifdef A_COLOR
if (has_colors())
- attron(COLOR_PAIR(COLOR_RED));
+ attron((attr_t) COLOR_PAIR(COLOR_RED));
#endif /* A_COLOR */
(void) addch(SHOWHIT);
#ifdef A_COLOR
#ifdef A_COLOR
if (has_colors()) {
if (hit)
- attron(COLOR_PAIR(COLOR_RED));
+ attron((attr_t) COLOR_PAIR(COLOR_RED));
else
- attron(COLOR_PAIR(COLOR_GREEN));
+ attron((attr_t) COLOR_PAIR(COLOR_GREEN));
}
#endif /* A_COLOR */
(void) addch((chtype) hits[PLAYER][curx][cury]);
m = " You'll pick up survivors from my %s, I hope...!";
break;
}
- (void) printw(m, ss->name);
+ if (m != 0) {
+ (void) printw(m, ss->name);
+ }
(void) beep();
}
return (hit);
#ifdef A_COLOR
if (has_colors()) {
if (hit)
- attron(COLOR_PAIR(COLOR_RED));
+ attron((attr_t) COLOR_PAIR(COLOR_RED));
else
- attron(COLOR_PAIR(COLOR_GREEN));
+ attron((attr_t) COLOR_PAIR(COLOR_GREEN));
}
#endif /* A_COLOR */
(void) addch((chtype) (hit ? SHOWHIT : SHOWSPLASH));