-/* $NetBSD: main.c,v 1.11 1998/09/13 15:21:37 hubertf Exp $ */
+/* $NetBSD: main.c,v 1.21 2009/08/25 06:56:52 dholland Exp $ */
/*-
* Copyright (c) 1991, 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.
*
#include <sys/cdefs.h>
#ifndef lint
-__COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\
- The Regents of the University of California. All rights reserved.\n");
+__COPYRIGHT("@(#) Copyright (c) 1991, 1993\
+ The Regents of the University of California. All rights reserved.");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
#else
-__RCSID("$NetBSD: main.c,v 1.11 1998/09/13 15:21:37 hubertf Exp $");
+__RCSID("$NetBSD: main.c,v 1.21 2009/08/25 06:56:52 dholland Exp $");
#endif
#endif /* not lint */
#include <err.h>
#include <signal.h>
#include <stdio.h>
+#include <stdlib.h>
#include <unistd.h>
#include "hdr.h"
#include "extern.h"
-int main __P((int, char **));
-
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
int i;
int rval, ll;
struct text *kk;
- /* adventure doesn't need setuid-ness, so, just get rid of it */
- if (setuid(getuid()) < 0)
- warn("setuid");
+ /* revoke setgid privileges from dm */
+ setgid(getgid());
init(); /* Initialize everything */
signal(SIGINT, trapdel);
unlink(argv[1]); /* Don't re-use the save */
goto l8; /* Get where we're going */
case 1: /* Couldn't open it */
- exit(0); /* So give up */
+ errx(1,"can't open file"); /* So give up */
case 2: /* Oops -- file was altered */
rspeak(202); /* You dissolve */
- exit(0); /* File could be non-adventure */
+ exit(1); /* File could be non-adventure */
} /* So don't unlink it. */
}
startup(); /* prepare for a user */
for (;;) { /* main command loop (label 2) */
- if (newloc < 9 && newloc != 0 && closng) {
+ if (newloc < 9 && newloc != 0 && isclosing) {
rspeak(130); /* if closing leave only by */
newloc = loc; /* main office */
if (!panic)
if ((abb[loc] % abbnum) == 0 || kk->seekadr == 0)
kk = <ext[loc];
if (!forced(loc) && dark()) {
- if (wzdark && pct(35)) {
+ if (wasdark && pct(35)) {
die(90);
goto l2000;
}
k = 1;
if (forced(loc))
goto l8;
- if (loc == 33 && pct(25) && !closng)
+ if (loc == 33 && pct(25) && !isclosing)
rspeak(8);
if (!dark()) {
abb[loc]++;
if (toting(i) && prop[i] < 0) /* 2604 */
prop[i] = -1 - prop[i];
}
- wzdark = dark(); /* 2605 */
+ wasdark = dark(); /* 2605 */
if (knfloc > 0 && knfloc != loc)
knfloc = 1;
getin(&wd1, &wd2);
case 4:
goto l2010;
default:
- printf("Error 22\n");
- exit(0);
+ bug(22);
}
l8:
goto l2610;
l4000: verb = k;
- spk = actspk[verb];
+ spk = actspeak[verb];
if (*wd2 != 0 && verb != say)
goto l2800;
if (verb == say)
case 14: /* eat: 8140 */
if (!here(food))
goto l8000;
- l8142: dstroy(food);
+ l8142: destroy(food);
spk = 72;
goto l2011;
case 15:
case 23:
goto l9230; /* blast */
case 24: /* score: 8240 */
- scorng = TRUE;
+ scoring = TRUE;
printf("If you were to quit now, you would score");
printf(" %d out of a possible ", score());
- printf("%d.", mxscor);
- scorng = FALSE;
+ printf("%d.", maxscore);
+ scoring = FALSE;
gaveup = yes(143, 54, 54);
if (gaveup)
done(2);
if (place[eggs] == plac[eggs]
|| (toting(eggs) && loc == plac[eggs]))
goto l2011;
- if (place[eggs] == 0 && place[troll] == 0 && prop[troll] == 0)
+ if (place[eggs] == 0 && place[troll] == 0 &&
+ prop[troll] == 0)
prop[troll] = 1;
k = 2;
if (here(eggs))
detail = 3;
goto l2011;
case 27: /* read=8270 */
- if (here(magzin))
- obj = magzin;
+ if (here(magazine))
+ obj = magazine;
if (here(tablet))
obj = obj * 100 + tablet;
- if (here(messag))
- obj = obj * 100 + messag;
+ if (here(message))
+ obj = obj * 100 + message;
if (closed && toting(oyster))
obj = oyster;
if (obj > 100 || obj == 0 || dark())
printf("I can suspend your adventure for you so");
printf(" you can resume later, but\n");
printf("you will have to wait at least");
- printf(" %d minutes before continuing.", latncy);
+ printf(" %d minutes before continuing.", latency);
if (!yes(200, 54, 54))
goto l2012;
- datime(&saved, &savet);
+ datime(&saveday, &savet);
ciao(); /* Do we quit? */
continue; /* Maybe not */
case 31: /* hours=8310 */
goto l2011;
prop[lamp] = 1;
rspeak(39);
- if (wzdark)
+ if (wasdark)
goto l2000;
goto l2012;
case 9: /* wave */
if ((!toting(obj)) && (obj != rod || !toting(rod2)))
spk = 29;
- if (obj != rod || !at(fissur) || !toting(obj) || closng)
+ if (obj != rod || !at(fissure) || !toting(obj) || isclosing)
goto l2011;
- prop[fissur] = 1 - prop[fissur];
- pspeak(fissur, 2 - prop[fissur]);
+ prop[fissure] = 1 - prop[fissure];
+ pspeak(fissure, 2 - prop[fissure]);
goto l2012;
case 10:
case 11:
case 14: /* 9140 - eat */
if (obj == food)
goto l8142;
- if (obj == bird || obj == snake || obj == clam || obj == oyster
- || obj == dwarf || obj == dragon || obj == troll
- || obj == bear)
+ if (obj == bird || obj == snake || obj == clam
+ || obj == oyster || obj == dwarf || obj == dragon
+ || obj == troll || obj == bear)
spk = 71;
goto l2011;
l9150: case 15:/* 9150 - drink */
if (obj == 0 && liqloc(loc) != water && (liq() != water
- || !here(bottle)))
+ || !here(bottle)))
goto l8000;
if (obj != 0 && obj != water)
spk = 110;
|| k == liqloc(loc))
spk = 94;
for (i = 1; i <= 5; i++)
- if (dloc[i] == loc && dflag >= 2 && obj == dwarf)
+ if (dloc[i] == loc && dflag >= 2
+ && obj == dwarf)
spk = 94;
if (closed)
spk = 138;
l9270: case 27:/* read */
if (dark())
goto l5190;
- if (obj == magzin)
+ if (obj == magazine)
spk = 190;
if (obj == tablet)
spk = 196;
- if (obj == messag)
+ if (obj == message)
spk = 191;
if (obj == oyster && hinted[2] && toting(oyster))
spk = 194;
l5100: if (k != grate)
goto l5110;
if (loc == 1 || loc == 4 || loc == 7)
- k = dprssn;
+ k = depression;
if (loc > 9 && loc < 15)
- k = entrnc;
+ k = entrance;
if (k != grate)
goto l8;
l5110: if (k != dwarf)