* v1.2 with color support and minor portability fixes, November 1990
* v2.0 featuring strict ANSI/POSIX conformance, November 1993.
* v2.1 for Linux, October 1994.
+ * Slipstreamed in fixes to make it gcc -Wall clean, May '95.
*/
#define _POSIX_SOURCE
-#include <stdio.h>
-#include <termios.h>
-#ifdef NCURSES
-#include <ncurses.h>
-#else
#include <curses.h>
-#endif NCURSES
#include <signal.h>
#include <ctype.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
#include <assert.h>
+#ifndef SIGIOT
+#define SIGIOT SIGABRT
+#endif
+
#ifndef A_UNDERLINE /* BSD curses */
#define beep() write(1,"\007",1);
#define cbreak crmode
#endif /* !A_UNDERLINE */
#ifdef isxdigit /* aha, must be an AT&T system... */
+
+#if !defined(__386BSD__) && !defined(__bsdi__)
#define srand(n) srand48(n)
#define rand() lrand48()
extern long lrand48();
extern void srand48();
+#endif
+
#define bzero(s, n) (void)memset((char *)(s), '\0', n)
extern char *memset();
/*
char symbol; /* symbol for game purposes */
char length; /* length of ship */
char x, y; /* coordinates of ship start point */
- char dir; /* direction of `bow' */
+ unsigned char dir; /* direction of `bow' */
bool placed; /* has it been placed on the board? */
}
ship_t;
if(signal(SIGQUIT,SIG_IGN) != SIG_IGN)
(void)signal(SIGQUIT,uninitgame);
- if(tmpname = getlogin())
+ if((tmpname = getlogin()) != 0)
{
(void)strcpy(name,tmpname);
name[0] = toupper(name[0]);
int collide;
/* anything on the square */
- if (collide = IS_SHIP(board[b][x][y]))
+ if ((collide = IS_SHIP(board[b][x][y])) != 0)
return(collide);
/* anything on the neighbors */
{
ship_t *ss;
bool hit;
- char *m;
+ char *m = NULL;
prompt(1, "Where do you want to shoot? ");
for (;;)
int x, y;
{
bool hit, sunk;
- ship_t *ss;
+ ship_t *ss = NULL;
hits[COMPUTER][x][y] = (hit = (board[PLAYER][x][y])) ? MARK_HIT : MARK_MISS;
(void) mvprintw(PROMPTLINE, 0,
"I shoot at %c%d. I %s!", y + 'A', x, hit ? "hit" : "miss");
- if (sunk = (hit && (ss = hitship(x, y))))
+ if ((sunk = (hit && (ss = hitship(x, y)))))
(void) printw(" I've sunk your %s", ss->name);
(void)clrtoeol();
return(hit);
}
-playagain()
+int playagain()
{
int j;
ship_t *ss;