-/* $NetBSD: battlestar.c,v 1.4 1997/01/07 11:56:32 tls Exp $ */
+/* $NetBSD: battlestar.c,v 1.9 1999/09/18 16:40:04 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
#ifndef lint
-static char copyright[] =
-"@(#) Copyright (c) 1983, 1993\n\
- The Regents of the University of California. All rights reserved.\n";
-#endif /* not lint */
+__COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
+ The Regents of the University of California. All rights reserved.\n");
+#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95";
#else
-static char rcsid[] = "$NetBSD: battlestar.c,v 1.4 1997/01/07 11:56:32 tls Exp $";
+__RCSID("$NetBSD: battlestar.c,v 1.9 1999/09/18 16:40:04 jsm Exp $");
#endif
-#endif /* not lint */
+#endif /* not lint */
/*
* Battlestar - a stellar-tropical adventure game
#include "extern.h"
-main(argc,argv)
-int argc;
-char **argv;
+int main __P((int, char *[]));
+
+int
+main(argc, argv)
+ int argc;
+ char **argv;
{
- char mainbuf[LINELENGTH];
- char *next;
+ char mainbuf[LINELENGTH];
+ char *next;
+
+ /* Open the score file then revoke setgid privileges */
+ open_score_file();
+ setregid(getgid(), getgid());
- initialize(argc < 2 || strcmp(argv[1], "-r"));
+ initialize((argc < 2) ? NULL : (strcmp(argv[1], "-r") ? argv[1]
+ : (argv[2] ? argv[2]
+ : DEFAULT_SAVE_FILE)));
start:
news();
beenthere[position]++;
if (notes[LAUNCHED])
- crash(); /* decrements fuel & crash */
+ crash(); /* decrements fuel & crash */
if (matchlight) {
puts("Your match splutters out.");
matchlight = 0;
}
- if (!notes[CANTSEE] || testbit(inven,LAMPON) ||
+ if (!notes[CANTSEE] || testbit(inven, LAMPON) ||
testbit(location[position].objects, LAMPON)) {
writedes();
printobjs();
whichway(location[position]);
run:
next = getcom(mainbuf, sizeof mainbuf, ">-: ",
- "Please type in something.");
+ "Please type in something.");
for (wordcount = 0; next && wordcount < 20; wordcount++)
next = getword(next, words[wordcount], -1);
parse();
switch (cypher()) {
- case -1:
- goto run;
- case 0:
- goto start;
- default:
- exit();
+ case -1:
+ goto run;
+ case 0:
+ goto start;
+ default:
+ errx(1, "bad return from cypher(): please submit a bug report");
}
}