-/* $NetBSD: main.c,v 1.8 1997/10/11 01:53:31 lukem Exp $ */
+/* $NetBSD: main.c,v 1.14 1999/07/16 01:38:20 hubertf Exp $ */
/*-
* Copyright (c) 1991, 1993
#if 0
static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93";
#else
-__RCSID("$NetBSD: main.c,v 1.8 1997/10/11 01:53:31 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.14 1999/07/16 01:38:20 hubertf Exp $");
#endif
#endif /* not lint */
#include "hdr.h"
#include "extern.h"
+int main __P((int, char **));
+
int
main(argc, argv)
int argc;
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 */
+ setregid(getgid(), getgid());
- init(NULL); /* Initialize everything */
+ init(); /* Initialize everything */
signal(SIGINT, trapdel);
if (argc > 1) { /* Restore file specified */
i = restore(argv[1]); /* See what we've got */
switch (i) {
case 0: /* The restore worked fine */
- yea = Start(0);
+ yea = Start();
k = null;
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 */
kk = &stext[loc];
if ((abb[loc] % abbnum) == 0 || kk->seekadr == 0)
kk = <ext[loc];
- if (!forced(loc) && dark(0)) {
+ if (!forced(loc) && dark()) {
if (wzdark && pct(35)) {
die(90);
goto l2000;
goto l8;
if (loc == 33 && pct(25) && !closng)
rspeak(8);
- if (!dark(0)) {
+ if (!dark()) {
abb[loc]++;
for (i = atloc[loc]; i != 0; i = links[i]) { /* 2004 */
obj = i;
if (toting(i) && prop[i] < 0) /* 2604 */
prop[i] = -1 - prop[i];
}
- wzdark = dark(0); /* 2605 */
+ wzdark = 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:
case 2:
continue; /* i.e. goto l2 */
case 99:
- switch (die(99)) {
- case 2000:
- goto l2000;
- default:
- bug(111);
- }
+ die(99);
+ goto l2000;
default:
bug(110);
}
obj = obj * 100 + messag;
if (closed && toting(oyster))
obj = oyster;
- if (obj > 100 || obj == 0 || dark(0))
+ if (obj > 100 || obj == 0 || dark())
goto l8000;
goto l9270;
case 30: /* suspend=8300 */
printf(" %d minutes before continuing.", latncy);
if (!yes(200, 54, 54))
goto l2012;
- datime(&saved, &savet);
- ciao(argv[0]); /* Do we quit? */
+ datime(&saveday, &savet);
+ ciao(); /* Do we quit? */
continue; /* Maybe not */
case 31: /* hours=8310 */
printf("Colossal cave is closed 9am-5pm Mon ");
goto l2011;
prop[lamp] = 0;
rspeak(40);
- if (dark(0))
+ if (dark())
rspeak(16);
goto l2012;
}
l9130: case 13:/* pour */
if (obj == bottle || obj == 0)
- obj = liq(0);
+ obj = liq();
if (obj == 0)
goto l8000;
if (!toting(obj))
spk = 71;
goto l2011;
l9150: case 15:/* 9150 - drink */
- if (obj == 0 && liqloc(loc) != water && (liq(0) != water
+ if (obj == 0 && liqloc(loc) != water && (liq() != water
|| !here(bottle)))
goto l8000;
if (obj != 0 && obj != water)
spk = 110;
- if (spk == 110 || liq(0) != water || !here(bottle))
+ if (spk == 110 || liq() != water || !here(bottle))
goto l2011;
prop[bottle] = 1;
place[water] = 0;
}
case 19:
case 20: /* 9190: find, invent */
- if (at(obj) || (liq(0) == obj && at(bottle))
+ if (at(obj) || (liq() == obj && at(bottle))
|| k == liqloc(loc))
spk = 94;
for (i = 1; i <= 5; i++)
rspeak(bonus);
done(2);
l9270: case 27:/* read */
- if (dark(0))
+ if (dark())
goto l5190;
if (obj == magzin)
spk = 190;
for (i = 1; i <= 5; i++)
if (dloc[i] == loc && dflag >= 2)
goto l5010;
-l5120: if ((liq(0) == k && here(bottle)) || k == liqloc(loc))
+l5120: if ((liq() == k && here(bottle)) || k == liqloc(loc))
goto l5010;
if (obj != plant || !at(plant2) || prop[plant2] == 0)
goto l5130;