summaryrefslogtreecommitdiffstats
path: root/robots
diff options
context:
space:
mode:
authorlukem <lukem@NetBSD.org>1997-10-12 14:09:55 +0000
committerlukem <lukem@NetBSD.org>1997-10-12 14:09:55 +0000
commita0bb5b9abf33dc2d2220eb3bd6e79c964e92a1c1 (patch)
treefd2b88ff5b355622ff28cd9528fb2d026c626a55 /robots
parenta0041450da452d421fa15f352d533a000c2e7921 (diff)
downloadbsdgames-darwin-a0bb5b9abf33dc2d2220eb3bd6e79c964e92a1c1.tar.gz
bsdgames-darwin-a0bb5b9abf33dc2d2220eb3bd6e79c964e92a1c1.tar.zst
bsdgames-darwin-a0bb5b9abf33dc2d2220eb3bd6e79c964e92a1c1.zip
WARNSify
Diffstat (limited to 'robots')
-rw-r--r--robots/Makefile4
-rw-r--r--robots/extern.c5
-rw-r--r--robots/flush_in.c9
-rw-r--r--robots/init_field.c10
-rw-r--r--robots/main.c36
-rw-r--r--robots/make_level.c13
-rw-r--r--robots/move.c27
-rw-r--r--robots/move_robs.c19
-rw-r--r--robots/play_level.c9
-rw-r--r--robots/query.c12
-rw-r--r--robots/rnd_pos.c10
-rw-r--r--robots/robots.66
-rw-r--r--robots/robots.h48
-rw-r--r--robots/score.c42
14 files changed, 144 insertions, 106 deletions
diff --git a/robots/Makefile b/robots/Makefile
index 50d4d6ae..014af7e2 100644
--- a/robots/Makefile
+++ b/robots/Makefile
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 1997/03/24 22:15:49 christos Exp $
+# $NetBSD: Makefile,v 1.8 1997/10/12 14:09:55 lukem Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= robots
@@ -10,7 +10,7 @@ DPADD= ${LIBCURSES} ${LIBTERM}
LDADD= -lcurses -ltermlib
HIDEGAME=hidegame
-FILES=/dev/null
+FILES= /dev/null
FILESNAME=robots_roll
FILESMODE=600
FILESDIR=/var/games
diff --git a/robots/extern.c b/robots/extern.c
index 88cbac1a..81b4df5e 100644
--- a/robots/extern.c
+++ b/robots/extern.c
@@ -1,4 +1,4 @@
-/* $NetBSD: extern.c,v 1.3 1995/04/22 10:08:49 cgd Exp $ */
+/* $NetBSD: extern.c,v 1.4 1997/10/12 14:09:56 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)extern.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: extern.c,v 1.3 1995/04/22 10:08:49 cgd Exp $";
+__RCSID("$NetBSD: extern.c,v 1.4 1997/10/12 14:09:56 lukem Exp $");
#endif
#endif /* not lint */
diff --git a/robots/flush_in.c b/robots/flush_in.c
index fecc4838..0604f548 100644
--- a/robots/flush_in.c
+++ b/robots/flush_in.c
@@ -1,4 +1,4 @@
-/* $NetBSD: flush_in.c,v 1.4 1995/04/28 23:09:08 mycroft Exp $ */
+/* $NetBSD: flush_in.c,v 1.5 1997/10/12 14:09:56 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,21 +33,22 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)flush_in.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: flush_in.c,v 1.4 1995/04/28 23:09:08 mycroft Exp $";
+__RCSID("$NetBSD: flush_in.c,v 1.5 1997/10/12 14:09:56 lukem Exp $");
#endif
#endif /* not lint */
-# include <stdio.h>
-# include <termios.h>
+# include "robots.h"
/*
* flush_in:
* Flush all pending input.
*/
+void
flush_in()
{
tcflush(fileno(stdin), TCIFLUSH);
diff --git a/robots/init_field.c b/robots/init_field.c
index 7a209156..a5fd9e25 100644
--- a/robots/init_field.c
+++ b/robots/init_field.c
@@ -1,4 +1,4 @@
-/* $NetBSD: init_field.c,v 1.4 1997/05/23 23:40:16 jtc Exp $ */
+/* $NetBSD: init_field.c,v 1.5 1997/10/12 14:09:57 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)init_field.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: init_field.c,v 1.4 1997/05/23 23:40:16 jtc Exp $";
+__RCSID("$NetBSD: init_field.c,v 1.5 1997/10/12 14:09:57 lukem Exp $");
#endif
#endif /* not lint */
@@ -48,11 +49,10 @@ static char rcsid[] = "$NetBSD: init_field.c,v 1.4 1997/05/23 23:40:16 jtc Exp $
* Lay down the initial pattern whih is constant across all levels,
* and initialize all the global variables.
*/
+void
init_field()
{
- register int i;
- register WINDOW *wp;
- register int j;
+ int i;
static bool first = TRUE;
static char *desc[] = {
"Directions:",
diff --git a/robots/main.c b/robots/main.c
index 47a113a2..ce0831b4 100644
--- a/robots/main.c
+++ b/robots/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
+/* $NetBSD: main.c,v 1.6 1997/10/12 14:09:58 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,34 +33,34 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1980, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $";
+__RCSID("$NetBSD: main.c,v 1.6 1997/10/12 14:09:58 lukem Exp $");
#endif
#endif /* not lint */
# include "robots.h"
-# include <signal.h>
-# include <ctype.h>
+int main __P((int, char **));
+
+int
main(ac, av)
-int ac;
-char **av;
+ int ac;
+ char **av;
{
- register char *sp;
- register bool bad_arg;
- register bool show_only;
+ char *sp;
+ bool bad_arg;
+ bool show_only;
extern char *Scorefile;
extern int Max_per_uid;
- void quit();
show_only = FALSE;
if (ac > 1) {
@@ -150,7 +150,9 @@ char **av;
refresh();
score();
} while (another());
- quit();
+ quit(0);
+ /* NOTREACHED */
+ return(0);
}
void
@@ -165,7 +167,8 @@ __cputchar(ch)
* Leave the program elegantly.
*/
void
-quit()
+quit(dummy)
+ int dummy;
{
endwin();
exit(0);
@@ -176,9 +179,10 @@ quit()
* another:
* See if another game is desired
*/
+bool
another()
{
- register int y;
+ int y;
#ifdef FANCY
if ((Stand_still || Pattern_roll) && !Newscore)
diff --git a/robots/make_level.c b/robots/make_level.c
index 998155db..55c29d3d 100644
--- a/robots/make_level.c
+++ b/robots/make_level.c
@@ -1,4 +1,4 @@
-/* $NetBSD: make_level.c,v 1.3 1995/04/22 10:08:56 cgd Exp $ */
+/* $NetBSD: make_level.c,v 1.4 1997/10/12 14:09:58 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: make_level.c,v 1.3 1995/04/22 10:08:56 cgd Exp $";
+__RCSID("$NetBSD: make_level.c,v 1.4 1997/10/12 14:09:58 lukem Exp $");
#endif
#endif /* not lint */
@@ -47,12 +48,12 @@ static char rcsid[] = "$NetBSD: make_level.c,v 1.3 1995/04/22 10:08:56 cgd Exp $
* make_level:
* Make the current level
*/
+void
make_level()
{
- register int i;
- register COORD *cp;
- register WINDOW *wp;
- register int x, *endp;
+ int i;
+ COORD *cp;
+ int x;
reset_count();
for (i = 1; i < Y_FIELDSIZE; i++)
diff --git a/robots/move.c b/robots/move.c
index c146eb3d..c78bcb53 100644
--- a/robots/move.c
+++ b/robots/move.c
@@ -1,4 +1,4 @@
-/* $NetBSD: move.c,v 1.5 1997/05/23 23:40:19 jtc Exp $ */
+/* $NetBSD: move.c,v 1.6 1997/10/12 14:09:59 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,16 +33,15 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: move.c,v 1.5 1997/05/23 23:40:19 jtc Exp $";
+__RCSID("$NetBSD: move.c,v 1.6 1997/10/12 14:09:59 lukem Exp $");
#endif
#endif /* not lint */
-#include <sys/ttydefaults.h>
-#include <ctype.h>
#include "robots.h"
# define ESC '\033'
@@ -51,11 +50,10 @@ static char rcsid[] = "$NetBSD: move.c,v 1.5 1997/05/23 23:40:19 jtc Exp $";
* get_move:
* Get and execute a move from the player
*/
+void
get_move()
{
- register int c;
- register int y, x, lastmove;
- static COORD newpos;
+ int c;
if (Waiting)
return;
@@ -156,7 +154,7 @@ over:
case 'q':
case 'Q':
if (query("Really quit?"))
- quit();
+ quit(0);
refresh();
break;
case 'w':
@@ -198,9 +196,10 @@ ret:
* Must I teleport; i.e., is there anywhere I can move without
* being eaten?
*/
+bool
must_telep()
{
- register int x, y;
+ int x, y;
static COORD newpos;
#ifdef FANCY
@@ -229,8 +228,9 @@ must_telep()
* do_move:
* Execute a move
*/
+bool
do_move(dy, dx)
-int dy, dx;
+ int dy, dx;
{
static COORD newpos;
@@ -265,10 +265,11 @@ int dy, dx;
* eaten:
* Player would get eaten at this place
*/
+bool
eaten(pos)
-register COORD *pos;
+ COORD *pos;
{
- register int x, y;
+ int x, y;
for (y = pos->y - 1; y <= pos->y + 1; y++) {
if (y <= 0 || y >= Y_FIELDSIZE)
@@ -287,6 +288,7 @@ register COORD *pos;
* reset_count:
* Reset the count variables
*/
+void
reset_count()
{
Count = 0;
@@ -299,6 +301,7 @@ reset_count()
* jumping:
* See if we are jumping, i.e., we should not refresh.
*/
+bool
jumping()
{
return (Jump && (Count || Running || Waiting));
diff --git a/robots/move_robs.c b/robots/move_robs.c
index 27bfb354..b45357cd 100644
--- a/robots/move_robs.c
+++ b/robots/move_robs.c
@@ -1,4 +1,4 @@
-/* $NetBSD: move_robs.c,v 1.3 1995/04/22 10:08:59 cgd Exp $ */
+/* $NetBSD: move_robs.c,v 1.4 1997/10/12 14:10:00 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,16 +33,16 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)move_robs.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: move_robs.c,v 1.3 1995/04/22 10:08:59 cgd Exp $";
+__RCSID("$NetBSD: move_robs.c,v 1.4 1997/10/12 14:10:00 lukem Exp $");
#endif
#endif /* not lint */
# include "robots.h"
-# include <signal.h>
/*
* move_robots:
@@ -50,12 +50,9 @@ static char rcsid[] = "$NetBSD: move_robs.c,v 1.3 1995/04/22 10:08:59 cgd Exp $"
*/
void
move_robots(was_sig)
-bool was_sig;
+ int was_sig;
{
- register COORD *rp;
- register int y, x;
- register int mindist, d;
- static COORD newpos;
+ COORD *rp;
if (Real_time)
signal(SIGALRM, move_robots);
@@ -134,8 +131,9 @@ bool was_sig;
* add_score:
* Add a score to the overall point total
*/
+void
add_score(add)
-int add;
+ int add;
{
Score += add;
move(Y_SCORE, X_SCORE);
@@ -146,8 +144,9 @@ int add;
* sign:
* Return the sign of the number
*/
+int
sign(n)
-int n;
+ int n;
{
if (n < 0)
return -1;
diff --git a/robots/play_level.c b/robots/play_level.c
index 8f5e1d40..74a013f4 100644
--- a/robots/play_level.c
+++ b/robots/play_level.c
@@ -1,4 +1,4 @@
-/* $NetBSD: play_level.c,v 1.3 1995/04/22 10:09:03 cgd Exp $ */
+/* $NetBSD: play_level.c,v 1.4 1997/10/12 14:10:01 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)play_level.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: play_level.c,v 1.3 1995/04/22 10:09:03 cgd Exp $";
+__RCSID("$NetBSD: play_level.c,v 1.4 1997/10/12 14:10:01 lukem Exp $");
#endif
#endif /* not lint */
@@ -47,10 +48,10 @@ static char rcsid[] = "$NetBSD: play_level.c,v 1.3 1995/04/22 10:09:03 cgd Exp $
* play_level:
* Let the player play the current level
*/
+void
play_level()
{
- register COORD *cp;
- register int y, x, bonus;
+ COORD *cp;
move(My_pos.y, My_pos.x);
addch(PLAYER);
diff --git a/robots/query.c b/robots/query.c
index b33ed63c..e0ca5823 100644
--- a/robots/query.c
+++ b/robots/query.c
@@ -1,4 +1,4 @@
-/* $NetBSD: query.c,v 1.3 1995/04/22 10:09:05 cgd Exp $ */
+/* $NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)query.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: query.c,v 1.3 1995/04/22 10:09:05 cgd Exp $";
+__RCSID("$NetBSD: query.c,v 1.4 1997/10/12 14:10:01 lukem Exp $");
#endif
#endif /* not lint */
@@ -47,11 +48,12 @@ static char rcsid[] = "$NetBSD: query.c,v 1.3 1995/04/22 10:09:05 cgd Exp $";
* query:
* Ask a question and get a yes or no answer. Default is "no".
*/
+int
query(prompt)
-char *prompt;
+ char *prompt;
{
- register int c, retval;
- register int y, x;
+ int c, retval;
+ int y, x;
getyx(stdscr, y, x);
move(Y_PROMPT, X_PROMPT);
diff --git a/robots/rnd_pos.c b/robots/rnd_pos.c
index a08171bb..4ad8fc53 100644
--- a/robots/rnd_pos.c
+++ b/robots/rnd_pos.c
@@ -1,4 +1,4 @@
-/* $NetBSD: rnd_pos.c,v 1.3 1995/04/22 10:09:07 cgd Exp $ */
+/* $NetBSD: rnd_pos.c,v 1.4 1997/10/12 14:10:02 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,11 +33,12 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)rnd_pos.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: rnd_pos.c,v 1.3 1995/04/22 10:09:07 cgd Exp $";
+__RCSID("$NetBSD: rnd_pos.c,v 1.4 1997/10/12 14:10:02 lukem Exp $");
#endif
#endif /* not lint */
@@ -54,7 +55,6 @@ rnd_pos()
{
static COORD pos;
static int call = 0;
- register int i = 0;
do {
pos.y = rnd(Y_FIELDSIZE - 1) + 1;
@@ -65,10 +65,10 @@ rnd_pos()
return &pos;
}
+int
rnd(range)
-int range;
+ int range;
{
- unsigned int rand();
return rand() % range;
}
diff --git a/robots/robots.6 b/robots/robots.6
index 4b67f870..19f7d387 100644
--- a/robots/robots.6
+++ b/robots/robots.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: robots.6,v 1.5 1997/03/08 13:32:52 mouse Exp $
+.\" $NetBSD: robots.6,v 1.6 1997/10/12 14:10:03 lukem Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,11 +40,11 @@
.Nm robots
.Nd fight off villainous robots
.Sh SYNOPSIS
-.Nm robots
+.Nm
.Op Fl sjta
.Op Ar scorefile
.Sh DESCRIPTION
-.Nm Robots
+.Nm
pits you against evil robots, who are trying to kill you (which is why
they are evil).
Fortunately for you, even though they are evil, they are not very bright
diff --git a/robots/robots.h b/robots/robots.h
index 15261c50..d56639cc 100644
--- a/robots/robots.h
+++ b/robots/robots.h
@@ -1,4 +1,4 @@
-/* $NetBSD: robots.h,v 1.5 1995/04/24 12:24:54 cgd Exp $ */
+/* $NetBSD: robots.h,v 1.6 1997/10/12 14:10:04 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -35,9 +35,17 @@
* @(#)robots.h 8.1 (Berkeley) 5/31/93
*/
+# include <sys/ttydefaults.h>
+# include <ctype.h>
# include <curses.h>
+# include <fcntl.h>
+# include <pwd.h>
# include <setjmp.h>
+# include <signal.h>
+# include <stdlib.h>
# include <string.h>
+# include <termios.h>
+# include <unistd.h>
/*
* miscellaneous constants
@@ -75,6 +83,14 @@ typedef struct {
int y, x;
} COORD;
+typedef struct {
+ int s_uid;
+ int s_score;
+ char s_name[MAXNAME];
+} SCORE;
+
+typedef struct passwd PASSWD;
+
/*
* global variables
*/
@@ -100,11 +116,25 @@ extern jmp_buf End_move;
* functions types
*/
-int cmp_sc();
-void move_robots();
-
-COORD *rnd_pos();
-
-
-
-
+void add_score __P((int));
+bool another __P((void));
+int cmp_sc __P((const void *, const void *));
+bool do_move __P((int, int));
+bool eaten __P((COORD *));
+void flush_in __P((void));
+void get_move __P((void));
+void init_field __P((void));
+bool jumping __P((void));
+void make_level __P((void));
+void move_robots __P((int));
+bool must_telep __P((void));
+void play_level __P((void));
+int query __P((char *));
+void quit __P((int));
+void reset_count __P((void));
+int rnd __P((int));
+COORD *rnd_pos __P((void));
+void score __P((void));
+void set_name __P((SCORE *));
+void show_score __P((void));
+int sign __P((int));
diff --git a/robots/score.c b/robots/score.c
index d96c8dff..400b0f12 100644
--- a/robots/score.c
+++ b/robots/score.c
@@ -1,4 +1,4 @@
-/* $NetBSD: score.c,v 1.3 1995/04/22 10:09:12 cgd Exp $ */
+/* $NetBSD: score.c,v 1.4 1997/10/12 14:10:05 lukem Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -33,27 +33,18 @@
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$NetBSD: score.c,v 1.3 1995/04/22 10:09:12 cgd Exp $";
+__RCSID("$NetBSD: score.c,v 1.4 1997/10/12 14:10:05 lukem Exp $");
#endif
#endif /* not lint */
# include "robots.h"
-# include <sys/types.h>
-# include <pwd.h>
# include "pathnames.h"
-typedef struct {
- int s_uid;
- int s_score;
- char s_name[MAXNAME];
-} SCORE;
-
-typedef struct passwd PASSWD;
-
char *Scorefile = _PATH_SCORE;
int Max_per_uid = MAX_PER_UID;
@@ -65,12 +56,13 @@ static SCORE Top[MAXSCORES];
* Post the player's score, if reasonable, and then print out the
* top list.
*/
+void
score()
{
- register int inf;
- register SCORE *scp;
- register int uid;
- register bool done_show = FALSE;
+ int inf;
+ SCORE *scp;
+ int uid;
+ bool done_show = FALSE;
static int numscores, max_uid;
Newscore = FALSE;
@@ -142,10 +134,11 @@ score()
close(inf);
}
+void
set_name(scp)
-register SCORE *scp;
+ SCORE *scp;
{
- register PASSWD *pp;
+ PASSWD *pp;
if ((pp = getpwuid(scp->s_uid)) == NULL)
pp->pw_name = "???";
@@ -156,20 +149,22 @@ register SCORE *scp;
* cmp_sc:
* Compare two scores.
*/
+int
cmp_sc(s1, s2)
-register SCORE *s1, *s2;
+ const void *s1, *s2;
{
- return s2->s_score - s1->s_score;
+ return ((SCORE *)s2)->s_score - ((SCORE *)s1)->s_score;
}
/*
* show_score:
* Show the score list for the '-s' option.
*/
+void
show_score()
{
- register SCORE *scp;
- register int inf;
+ SCORE *scp;
+ int inf;
static int max_score;
if ((inf = open(Scorefile, 0)) < 0) {
@@ -186,5 +181,6 @@ show_score()
inf = 1;
for (scp = Top; scp < &Top[MAXSCORES]; scp++)
if (scp->s_score >= 0)
- printf("%d\t%d\t%.*s\n", inf++, scp->s_score, sizeof scp->s_name, scp->s_name);
+ printf("%d\t%d\t%.*s\n", inf++, scp->s_score,
+ (int)(sizeof(scp->s_name)), scp->s_name);
}