summaryrefslogtreecommitdiff
path: root/games/robots
diff options
context:
space:
mode:
authorPaul Janzen <pjanzen@cvs.openbsd.org>1998-08-22 08:56:02 +0000
committerPaul Janzen <pjanzen@cvs.openbsd.org>1998-08-22 08:56:02 +0000
commit6910826c1b27cf6a9d4cb8400743d571d3c9a27b (patch)
tree9562c830236235b683790903daad5db093658719 /games/robots
parent92cf145f2c1e59139400da3a8db7b06cc24b7b54 (diff)
More largely NetBSD-inspired code cleanup
Diffstat (limited to 'games/robots')
-rw-r--r--games/robots/main.c29
-rw-r--r--games/robots/make_level.c6
-rw-r--r--games/robots/pathnames.h1
-rw-r--r--games/robots/play_level.c4
-rw-r--r--games/robots/robots.66
-rw-r--r--games/robots/robots.h4
-rw-r--r--games/robots/score.c6
7 files changed, 27 insertions, 29 deletions
diff --git a/games/robots/main.c b/games/robots/main.c
index a2adddc02cf..b1f98dec7d4 100644
--- a/games/robots/main.c
+++ b/games/robots/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.6 1998/07/09 04:34:16 pjanzen Exp $ */
+/* $OpenBSD: main.c,v 1.7 1998/08/22 08:55:54 pjanzen Exp $ */
/* $NetBSD: main.c,v 1.5 1995/04/22 10:08:54 cgd Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: main.c,v 1.6 1998/07/09 04:34:16 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: main.c,v 1.7 1998/08/22 08:55:54 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -62,9 +62,8 @@ main(ac, av)
int score_wfd; /* high score writable file descriptor */
int score_err = 0; /* hold errno from score file open */
- if ((score_wfd = open(Scorefile, O_RDWR)) < 0) {
+ if ((score_wfd = open(Scorefile, O_RDWR)) < 0)
score_err = errno;
- }
/* revoke */
setegid(getgid());
@@ -76,16 +75,15 @@ main(ac, av)
for (++av; ac > 1 && *av[0]; av++, ac--)
if (av[0][0] != '-') {
Scorefile = av[0];
- sp = strrchr(Scorefile, '/');
- if (sp == NULL)
- sp = Scorefile;
if (score_wfd >= 0)
close(score_wfd);
- /* This file is in the current directory */
- /* and requires no special privileges: */
+ /* This file requires no special privileges. */
if ((score_wfd = open(Scorefile, O_RDWR)) < 0)
score_err = errno;
#ifdef FANCY
+ sp = strrchr(Scorefile, '/');
+ if (sp == NULL)
+ sp = Scorefile;
if (strcmp(sp, "pattern_roll") == 0)
Pattern_roll = TRUE;
else if (strcmp(sp, "stand_still") == 0)
@@ -112,7 +110,7 @@ main(ac, av)
Teleport = TRUE;
break;
default:
- fprintf(stderr, "robots: unknown option: %c\n", *sp);
+ warnx("unknown option: %c", *sp);
bad_arg = TRUE;
break;
}
@@ -127,10 +125,9 @@ main(ac, av)
exit(0);
}
- if (score_wfd < 0) {
- fprintf(stderr, "%s: %s\n", Scorefile, strerror(score_err));
- exit(1);
- }
+ if (score_wfd < 0)
+ warnx("%s: %s; no scores will be saved", Scorefile,
+ strerror(score_err));
initscr();
signal(SIGINT, quit);
@@ -140,9 +137,7 @@ main(ac, av)
if (LINES != Y_SIZE || COLS != X_SIZE) {
if (LINES < Y_SIZE || COLS < X_SIZE) {
endwin();
- printf("Need at least a %dx%d screen\n",
- Y_SIZE, X_SIZE);
- exit(1);
+ errx(1, "Need at least a %dx%d screen", Y_SIZE, X_SIZE);
}
delwin(stdscr);
stdscr = newwin(Y_SIZE, X_SIZE, 0, 0);
diff --git a/games/robots/make_level.c b/games/robots/make_level.c
index f93534d911f..72b670b5747 100644
--- a/games/robots/make_level.c
+++ b/games/robots/make_level.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: make_level.c,v 1.2 1998/07/09 04:34:17 pjanzen Exp $ */
+/* $OpenBSD: make_level.c,v 1.3 1998/08/22 08:55:55 pjanzen Exp $ */
/* $NetBSD: make_level.c,v 1.3 1995/04/22 10:08:56 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)make_level.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: make_level.c,v 1.2 1998/07/09 04:34:17 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: make_level.c,v 1.3 1998/08/22 08:55:55 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -70,7 +70,7 @@ make_level()
cp->y = -1;
My_pos.y = -1;
- bzero(Field, sizeof Field);
+ memset(Field, 0, sizeof Field);
Min.y = Y_FIELDSIZE;
Min.x = X_FIELDSIZE;
Max.y = 0;
diff --git a/games/robots/pathnames.h b/games/robots/pathnames.h
index 258225c60ac..64484f201e8 100644
--- a/games/robots/pathnames.h
+++ b/games/robots/pathnames.h
@@ -1,3 +1,4 @@
+/* $OpenBSD: pathnames.h,v 1.2 1998/08/22 08:55:56 pjanzen Exp $ */
/* $NetBSD: pathnames.h,v 1.3 1995/04/22 10:09:01 cgd Exp $ */
/*-
diff --git a/games/robots/play_level.c b/games/robots/play_level.c
index 07450f00f2a..2746053e1e4 100644
--- a/games/robots/play_level.c
+++ b/games/robots/play_level.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: play_level.c,v 1.2 1998/07/09 04:34:20 pjanzen Exp $ */
+/* $OpenBSD: play_level.c,v 1.3 1998/08/22 08:55:57 pjanzen Exp $ */
/* $NetBSD: play_level.c,v 1.3 1995/04/22 10:09:03 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#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 $";
+static char rcsid[] = "$OpenBSD: play_level.c,v 1.3 1998/08/22 08:55:57 pjanzen Exp $";
#endif
#endif /* not lint */
diff --git a/games/robots/robots.6 b/games/robots/robots.6
index e3864d49748..b9decdb1b88 100644
--- a/games/robots/robots.6
+++ b/games/robots/robots.6
@@ -1,4 +1,4 @@
-.\" $NetBSD: robots.6,v 1.4 1995/04/22 10:09:09 cgd Exp $
+.\" $OpenBSD: robots.6,v 1.2 1998/08/22 08:55:59 pjanzen Exp $
.\"
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -40,7 +40,7 @@
.Nm robots
.Nd fight off villainous robots
.Sh SYNOPSIS
-.Nm robots
+.Nm
.Op Fl sjta
.Op Ar scorefile
.Sh DESCRIPTION
@@ -119,7 +119,7 @@ you take the risk of dying by miscalculation.
Only five scores are allowed per user on the score file.
If you make it into the score file, you will be shown the list at the end
of the game.
-If an alternate score file is specified, that will be used instead of the
+If an alternative score file is specified, that will be used instead of the
standard file for scores.
.Pp
The options are
diff --git a/games/robots/robots.h b/games/robots/robots.h
index 38f4aac49b3..c660acf4211 100644
--- a/games/robots/robots.h
+++ b/games/robots/robots.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: robots.h,v 1.2 1998/07/09 04:34:24 pjanzen Exp $ */
+/* $OpenBSD: robots.h,v 1.3 1998/08/22 08:56:00 pjanzen Exp $ */
/* $NetBSD: robots.h,v 1.5 1995/04/24 12:24:54 cgd Exp $ */
/*
@@ -128,7 +128,7 @@ bool eaten __P((COORD *));
void flush_in __P((void));
void get_move __P((void));
void init_field __P((void));
-bool jumping __P((void));
+bool jumping __P((void));
void make_level __P((void));
void move_robots __P((int));
bool must_telep __P((void));
diff --git a/games/robots/score.c b/games/robots/score.c
index 46b4d20c217..e03b4135ca8 100644
--- a/games/robots/score.c
+++ b/games/robots/score.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: score.c,v 1.4 1998/07/09 04:34:25 pjanzen Exp $ */
+/* $OpenBSD: score.c,v 1.5 1998/08/22 08:56:01 pjanzen Exp $ */
/* $NetBSD: score.c,v 1.3 1995/04/22 10:09:12 cgd Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)score.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: score.c,v 1.4 1998/07/09 04:34:25 pjanzen Exp $";
+static char rcsid[] = "$OpenBSD: score.c,v 1.5 1998/08/22 08:56:01 pjanzen Exp $";
#endif
#endif /* not lint */
@@ -71,6 +71,8 @@ score(score_wfd)
static int numscores, max_uid;
Newscore = FALSE;
+ if (inf < 0)
+ return;
if (read(inf, &max_uid, sizeof max_uid) == sizeof max_uid)
read(inf, Top, sizeof Top);