X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/392c1216403cc962eb63d4d0d8abdf9f9123733d..b4408559c1e6e0df3ce61a198f9a4d1f444ecb87:/adventure/main.c diff --git a/adventure/main.c b/adventure/main.c index cf5e268a..ee30e14e 100644 --- a/adventure/main.c +++ b/adventure/main.c @@ -1,4 +1,4 @@ -/* $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 @@ -17,11 +17,7 @@ * 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. * @@ -40,15 +36,15 @@ #include #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 */ @@ -58,24 +54,20 @@ __RCSID("$NetBSD: main.c,v 1.11 1998/09/13 15:21:37 hubertf Exp $"); #include #include #include +#include #include #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); @@ -90,16 +82,16 @@ main(argc, argv) 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) @@ -116,7 +108,7 @@ l2000: if (loc == 0) 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; } @@ -131,7 +123,7 @@ l2001: 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]++; @@ -172,7 +164,7 @@ l2600: checkhints(); /* to 2600-2602 */ 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); @@ -277,8 +269,7 @@ l2630: i = vocab(wd1, -1, 0); case 4: goto l2010; default: - printf("Error 22\n"); - exit(0); + bug(22); } l8: @@ -297,7 +288,7 @@ l2800: copystr(wd2, wd1); goto l2610; l4000: verb = k; - spk = actspk[verb]; + spk = actspeak[verb]; if (*wd2 != 0 && verb != say) goto l2800; if (verb == say) @@ -362,7 +353,7 @@ l4080: case 14: /* eat: 8140 */ if (!here(food)) goto l8000; - l8142: dstroy(food); + l8142: destroy(food); spk = 72; goto l2011; case 15: @@ -392,11 +383,11 @@ l4080: 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); @@ -416,7 +407,8 @@ l4080: 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)) @@ -432,12 +424,12 @@ l4080: 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()) @@ -450,10 +442,10 @@ l4080: 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 */ @@ -522,7 +514,7 @@ l4090: goto l2011; prop[lamp] = 1; rspeak(39); - if (wzdark) + if (wasdark) goto l2000; goto l2012; @@ -538,10 +530,10 @@ l4090: 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: @@ -600,14 +592,14 @@ l4090: 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; @@ -642,7 +634,8 @@ l4090: || 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; @@ -680,11 +673,11 @@ l4090: 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; @@ -737,9 +730,9 @@ l5010: if (*wd2 != 0) 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)