summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--snake/Makefile4
-rw-r--r--snake/snake/Makefile4
-rw-r--r--snake/snake/move.c75
-rw-r--r--snake/snake/pathnames.h9
-rw-r--r--snake/snake/snake.611
-rw-r--r--snake/snake/snake.c27
-rw-r--r--snake/snake/snake.h17
-rw-r--r--snake/snscore/Makefile4
-rw-r--r--snake/snscore/snscore.c41
9 files changed, 133 insertions, 59 deletions
diff --git a/snake/Makefile b/snake/Makefile
index a58f6493..df4495b4 100644
--- a/snake/Makefile
+++ b/snake/Makefile
@@ -1,5 +1,5 @@
-# from: @(#)Makefile 5.1 (Berkeley) 2/28/91
-# $Id: Makefile,v 1.2 1993/08/01 05:44:08 mycroft Exp $
+# $NetBSD: Makefile,v 1.3 1995/04/22 08:34:18 cgd Exp $
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
SUBDIR= snake snscore
diff --git a/snake/snake/Makefile b/snake/snake/Makefile
index 1a93af48..ab465a34 100644
--- a/snake/snake/Makefile
+++ b/snake/snake/Makefile
@@ -1,5 +1,5 @@
-# from: @(#)Makefile 5.11 (Berkeley) 2/28/91
-# $Id: Makefile,v 1.5 1994/12/22 09:36:14 cgd Exp $
+# $NetBSD: Makefile,v 1.6 1995/04/22 08:34:27 cgd Exp $
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= snake
SRCS= snake.c move.c
diff --git a/snake/snake/move.c b/snake/snake/move.c
index 1f28ef99..cd6d268c 100644
--- a/snake/snake/move.c
+++ b/snake/snake/move.c
@@ -1,6 +1,8 @@
+/* $NetBSD: move.c,v 1.8 1995/04/22 08:34:30 cgd Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,8 +34,11 @@
*/
#ifndef lint
-/*static char sccsid[] = "from: @(#)move.c 5.8 (Berkeley) 2/28/91";*/
-static char rcsid[] = "$Id: move.c,v 1.7 1994/04/05 22:56:56 deraadt Exp $";
+#if 0
+static char sccsid[] = "@(#)move.c 8.1 (Berkeley) 7/19/93";
+#else
+static char rcsid[] = "$NetBSD: move.c,v 1.8 1995/04/22 08:34:30 cgd Exp $";
+#endif
#endif /* not lint */
/*************************************************************************
@@ -92,7 +97,11 @@ static char rcsid[] = "$Id: move.c,v 1.7 1994/04/05 22:56:56 deraadt Exp $";
*
******************************************************************************/
+#if __STDC__
#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
#include "snake.h"
int CMlength;
@@ -408,6 +417,52 @@ pch(c)
}
}
+void
+#if __STDC__
+apr(struct point *ps, const char *fmt, ...)
+#else
+apr(ps, fmt, va_alist)
+ struct point *ps;
+ char *fmt;
+ va_dcl
+#endif
+{
+ struct point p;
+ va_list ap;
+
+ p.line = ps->line+1; p.col = ps->col+1;
+ move(&p);
+#if __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+ (void)vsprintf(str, fmt, ap);
+ va_end(ap);
+ pstring(str);
+}
+
+void
+#if __STDC__
+pr(const char *fmt, ...)
+#else
+pr(fmt, va_alist)
+ char *fmt;
+ va_dcl
+#endif
+{
+ va_list ap;
+
+#if __STDC__
+ va_start(ap, fmt);
+#else
+ va_start(ap);
+#endif
+ (void)vsprintf(str, fmt, ap);
+ va_end(ap);
+ pstring(str);
+}
+
pstring(s)
char *s;{
struct point z;
@@ -549,7 +604,7 @@ getcap()
struct point z;
void stop();
#ifdef TIOCGWINSZ
- struct winsize ws;
+ struct winsize win;
#endif
term = getenv("TERM");
@@ -570,16 +625,14 @@ getcap()
ap = tcapbuf;
#ifdef TIOCGWINSZ
- if (ioctl(fileno(stdout), TIOCGWINSZ, &ws) != -1 &&
- ws.ws_col && ws.ws_row) {
- LINES = ws.ws_row;
- COLUMNS = ws.ws_col;
- } else
+ if (ioctl(0, TIOCGWINSZ, (char *) &win) < 0 ||
+ (LINES = win.ws_row) == 0 || (COLUMNS = win.ws_col) == 0) {
#endif
- {
LINES = tgetnum("li");
COLUMNS = tgetnum("co");
+#ifdef TIOCGWINSZ
}
+#endif
if (!lcnt)
lcnt = LINES - 2;
if (!ccnt)
diff --git a/snake/snake/pathnames.h b/snake/snake/pathnames.h
index 9f6ee2e7..2d71f4a3 100644
--- a/snake/snake/pathnames.h
+++ b/snake/snake/pathnames.h
@@ -1,6 +1,8 @@
+/* $NetBSD: pathnames.h,v 1.3 1995/04/22 08:34:33 cgd Exp $ */
+
/*
- * Copyright (c) 1989 The Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1989, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,8 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)pathnames.h 5.3 (Berkeley) 6/1/90
- * $Id: pathnames.h,v 1.2 1993/08/01 18:51:17 mycroft Exp $
+ * @(#)pathnames.h 8.1 (Berkeley) 5/31/93
*/
#define _PATH_RAWSCORES "/var/games/snakerawscores"
diff --git a/snake/snake/snake.6 b/snake/snake/snake.6
index 57a01098..f44de895 100644
--- a/snake/snake/snake.6
+++ b/snake/snake/snake.6
@@ -1,5 +1,7 @@
-.\" Copyright (c) 1980 The Regents of the University of California.
-.\" All rights reserved.
+.\" $NetBSD: snake.6,v 1.5 1995/04/22 08:34:35 cgd Exp $
+.\"
+.\" Copyright (c) 1980, 1993
+.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -29,10 +31,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" from: @(#)snake.6 6.4 (Berkeley) 6/23/90
-.\" $Id: snake.6,v 1.4 1993/08/09 22:22:24 jtc Exp $
+.\" @(#)snake.6 8.1 (Berkeley) 5/31/93
.\"
-.Dd June 23, 1990
+.Dd May 31, 1993
.Dt SNAKE 6
.Os
.Sh NAME
diff --git a/snake/snake/snake.c b/snake/snake/snake.c
index cbf401eb..14f2f162 100644
--- a/snake/snake/snake.c
+++ b/snake/snake/snake.c
@@ -1,6 +1,8 @@
+/* $NetBSD: snake.c,v 1.5 1995/04/22 08:34:36 cgd Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,14 +34,17 @@
*/
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1980 Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-/*static char sccsid[] = "from: @(#)snake.c 5.10 (Berkeley) 2/28/91";*/
-static char rcsid[] = "$Id: snake.c,v 1.4 1994/04/01 03:02:32 cgd Exp $";
+#if 0
+static char sccsid[] = "@(#)snake.c 8.2 (Berkeley) 1/7/94";
+#else
+static char rcsid[] = "$NetBSD: snake.c,v 1.5 1995/04/22 08:34:36 cgd Exp $";
+#endif
#endif /* not lint */
/*
@@ -54,11 +59,13 @@ static char rcsid[] = "$Id: snake.c,v 1.4 1994/04/01 03:02:32 cgd Exp $";
*/
#include <sys/param.h>
+
+#include <errno.h>
#include <fcntl.h>
#include <pwd.h>
-#include <errno.h>
-#include <stdlib.h>
+#include <stdlib>
#include <time.h>
+
#include "snake.h"
#include "pathnames.h"
@@ -538,7 +545,7 @@ struct point *sp, *np;
snake would get too good */
struct point d;
int w, i, wt[8];
- double sqrt(), v1, v2, vp, max;
+ double v1, v2, vp, max;
point(&d,you.col-sp->col,you.line-sp->line);
v1 = sqrt( (double) (d.col*d.col + d.line*d.line) );
w=0;
diff --git a/snake/snake/snake.h b/snake/snake/snake.h
index 89148fbd..bdbd1362 100644
--- a/snake/snake/snake.h
+++ b/snake/snake/snake.h
@@ -1,6 +1,8 @@
+/* $NetBSD: snake.h,v 1.3 1995/04/22 08:34:38 cgd Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -30,8 +32,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)snake.h 5.5 (Berkeley) 6/1/90
- * $Id: snake.h,v 1.2 1993/08/01 18:51:16 mycroft Exp $
+ * @(#)snake.h 8.1 (Berkeley) 5/31/93
*/
# include <stdio.h>
@@ -75,6 +76,12 @@ struct sgttyb orig, new;
struct ltchars olttyc, nlttyc;
#endif
struct point *point();
+#if __STDC__
+void apr(struct point *, const char *, ...);
+void pr(const char *, ...);
+#else
+void apr();
+void pr();
+#endif
#define same(s1, s2) ((s1)->line == (s2)->line && (s1)->col == (s2)->col)
-
diff --git a/snake/snscore/Makefile b/snake/snscore/Makefile
index 28768f32..08ebc767 100644
--- a/snake/snscore/Makefile
+++ b/snake/snscore/Makefile
@@ -1,5 +1,5 @@
-# from: @(#)Makefile 5.2 (Berkeley) 2/28/91
-# $Id: Makefile,v 1.2 1993/08/01 05:44:03 mycroft Exp $
+# $NetBSD: Makefile,v 1.3 1995/04/22 08:34:41 cgd Exp $
+# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= snscore
CFLAGS+=-I${.CURDIR}/../snake
diff --git a/snake/snscore/snscore.c b/snake/snscore/snscore.c
index 6b8c2e4e..8ad6b59a 100644
--- a/snake/snscore/snscore.c
+++ b/snake/snscore/snscore.c
@@ -1,6 +1,8 @@
+/* $NetBSD: snscore.c,v 1.4 1995/04/22 08:34:43 cgd Exp $ */
+
/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.
+ * Copyright (c) 1980, 1993
+ * The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,14 +34,17 @@
*/
#ifndef lint
-char copyright[] =
-"@(#) Copyright (c) 1980 Regents of the University of California.\n\
- All rights reserved.\n";
+static char copyright[] =
+"@(#) Copyright (c) 1980, 1993\n\
+ The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-/*static char sccsid[] = "from: @(#)snscore.c 5.7 (Berkeley) 2/28/91";*/
-static char rcsid[] = "$Id: snscore.c,v 1.3 1994/04/05 00:42:49 cgd Exp $";
+#if 0
+static char sccsid[] = "@(#)snscore.c 8.1 (Berkeley) 7/19/93";
+#else
+static char rcsid[] = "$NetBSD: snscore.c,v 1.4 1995/04/22 08:34:43 cgd Exp $";
+#endif
#endif /* not lint */
#include <sys/types.h>
@@ -57,9 +62,9 @@ struct player {
char *name;
} players[MAXPLAYERS], temp;
+int
main()
{
- char buf[80], cp;
short uid, score;
FILE *fd;
int noplayers;
@@ -77,7 +82,7 @@ main()
fread(&whoallbest, sizeof(short), 1, fd);
fread(&allbest, sizeof(short), 1, fd);
noplayers = 0;
- for (uid=2;;uid++) {
+ for (uid = 2; ;uid++) {
if(fread(&score, sizeof(short), 1, fd) == 0)
break;
if (score > 0) {
@@ -91,29 +96,29 @@ main()
if (p == NULL)
continue;
q = p -> pw_name;
- players[noplayers].name = malloc(strlen(q)+1);
+ players[noplayers].name = malloc(strlen(q) + 1);
strcpy(players[noplayers].name, q);
noplayers++;
}
}
/* bubble sort scores */
- for (notsorted=1; notsorted; ) {
+ for (notsorted = 1; notsorted; ) {
notsorted = 0;
- for (i=0; i<noplayers-1; i++)
- if (players[i].scores < players[i+1].scores) {
+ for (i = 0; i < noplayers - 1; i++)
+ if (players[i].scores < players[i + 1].scores) {
temp = players[i];
- players[i] = players[i+1];
- players[i+1] = temp;
+ players[i] = players[i + 1];
+ players[i + 1] = temp;
notsorted++;
}
}
j = 1;
- for (i=0; i<noplayers; i++) {
+ for (i = 0; i < noplayers; i++) {
printf("%d:\t$%d\t%s\n", j, players[i].scores, players[i].name);
- if (players[i].scores > players[i+1].scores)
- j = i+2;
+ if (players[i].scores > players[i + 1].scores)
+ j = i + 2;
}
exit(0);
}