-/* $NetBSD: fly.c,v 1.8 1999/09/08 21:45:25 jsm Exp $ */
+/* $NetBSD: fly.c,v 1.15 2012/10/13 19:58:53 dholland Exp $ */
/*
* Copyright (c) 1983, 1993
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
#if 0
static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95";
#else
-__RCSID("$NetBSD: fly.c,v 1.8 1999/09/08 21:45:25 jsm Exp $");
+__RCSID("$NetBSD: fly.c,v 1.15 2012/10/13 19:58:53 dholland Exp $");
#endif
#endif /* not lint */
#include "extern.h"
#undef UP
#include <curses.h>
+#include <assert.h>
-#define abs(a) ((a) < 0 ? -(a) : (a))
#define MIDR (LINES/2 - 1)
#define MIDC (COLS/2 - 1)
-int row, column;
-int dr = 0, dc = 0;
-char destroyed;
+static int row, column;
+static int dr = 0, dc = 0;
+static char destroyed;
int ourclock = 120; /* time for all the flights in the game */
-char cross = 0;
-sig_t oldsig;
+static char cross = 0;
+static sig_t oldsig;
-void
-succumb(dummy)
- int dummy __attribute__((__unused__));
+static void blast(void);
+static void endfly(void);
+static void moveenemy(int);
+static void notarget(void);
+static void screen(void);
+static void succumb(int);
+static void target(void);
+
+static void
+succumb(int dummy __unused)
{
if (oldsig == SIG_DFL) {
endfly();
}
int
-visual()
+visual(void)
{
destroyed = 0;
if (initscr() == NULL) {
return (0);
}
oldsig = signal(SIGINT, succumb);
- crmode();
+ cbreak();
noecho();
screen();
row = rnd(LINES - 3) + 1;
if (torps) {
torps -= 2;
blast();
- if (row == MIDR && column - MIDC < 2 && MIDC - column < 2) {
+ if (row == MIDR && column < MIDC + 2 &&
+ column > MIDC - 2) {
destroyed = 1;
alarm(0);
}
}
}
-void
-screen()
+static void
+screen(void)
{
int r, c, n;
int i;
refresh();
}
-void
-target()
+static void
+target(void)
{
int n;
}
}
-void
-notarget()
+static void
+notarget(void)
{
int n;
}
}
-void
-blast()
+static void
+blast(void)
{
int n;
alarm(1);
}
-void
-moveenemy(dummy)
- int dummy __attribute__((__unused__));
+static void
+moveenemy(int dummy __unused)
{
double d;
int oldr, oldc;
fuel = 0;
mvaddstr(0, 60, "*** Out of fuel ***");
}
- d = (double) ((row - MIDR) * (row - MIDR) + (column - MIDC) * (column - MIDC));
+ d = (double) ((row - MIDR) * (row - MIDR) + (column - MIDC) *
+ (column - MIDC));
if (d < 16) {
row += (rnd(9) - 4) % (4 - abs(row - MIDR));
column += (rnd(9) - 4) % (4 - abs(column - MIDC));
alarm(1);
}
-void
-endfly()
+static void
+endfly(void)
{
alarm(0);
signal(SIGALRM, SIG_DFL);