From df8ac21ffab206d3f69612627f47e86356f11a4d Mon Sep 17 00:00:00 2001 From: jmc Date: Fri, 1 Jul 2005 00:03:36 +0000 Subject: KNF and WARNS=3 --- adventure/crc.c | 9 ++-- adventure/done.c | 16 +++--- adventure/hdr.h | 23 ++++---- adventure/init.c | 26 +++++---- adventure/io.c | 146 ++++++++++++++++++++++++++------------------------ adventure/main.c | 24 ++++----- adventure/save.c | 14 +++-- adventure/setup.c | 15 +++--- adventure/subr.c | 152 +++++++++++++++++++++++++---------------------------- adventure/vocab.c | 39 ++++++-------- adventure/wizard.c | 24 ++++----- 11 files changed, 236 insertions(+), 252 deletions(-) (limited to 'adventure') diff --git a/adventure/crc.c b/adventure/crc.c index 66504f16..d13bdd42 100644 --- a/adventure/crc.c +++ b/adventure/crc.c @@ -1,4 +1,4 @@ -/* $NetBSD: crc.c,v 1.8 2003/08/07 09:36:50 agc Exp $ */ +/* $NetBSD: crc.c,v 1.9 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1993 @@ -38,7 +38,7 @@ static char sccsid[] = "@(#)crc.c 8.1 (Berkeley) 5/31/93"; static char ORIGINAL_sccsid[] = "@(#)crc.c 5.2 (Berkeley) 4/4/91"; #else -__RCSID("$NetBSD: crc.c,v 1.8 2003/08/07 09:36:50 agc Exp $"); +__RCSID("$NetBSD: crc.c,v 1.9 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -115,10 +115,9 @@ crc_start() crcval = step = 0; } +/* Process nr bytes at a time; ptr points to them */ unsigned long -crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */ - const char *ptr; - int nr; +crc(const char *ptr, int nr) { int i; const char *p; diff --git a/adventure/done.c b/adventure/done.c index 54e5fa6c..61daab02 100644 --- a/adventure/done.c +++ b/adventure/done.c @@ -1,4 +1,4 @@ -/* $NetBSD: done.c,v 1.8 2003/08/07 09:36:50 agc Exp $ */ +/* $NetBSD: done.c,v 1.9 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)done.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: done.c,v 1.8 2003/08/07 09:36:50 agc Exp $"); +__RCSID("$NetBSD: done.c,v 1.9 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -51,7 +51,7 @@ __RCSID("$NetBSD: done.c,v 1.8 2003/08/07 09:36:50 agc Exp $"); #include "extern.h" int -score() +score(void) { /* sort of like 20000 */ int scor, i; mxscor = scor = 0; @@ -102,9 +102,10 @@ score() return (scor); } +/* entry=1 means goto 13000 */ /* game is over */ +/* entry=2 means goto 20000 */ /* 3=19000 */ void -done(entry) /* entry=1 means goto 13000 */ /* game is over */ - int entry; /* entry=2 means goto 20000 */ /* 3=19000 */ +done(int entry) { int i, sc; if (entry == 1) @@ -135,10 +136,9 @@ done(entry) /* entry=1 means goto 13000 */ /* game is over */ exit(0); } - +/* label 90 */ void -die(entry) /* label 90 */ - int entry; +die(int entry) { int i; if (entry != 99) { diff --git a/adventure/hdr.h b/adventure/hdr.h index 3843831c..43dee3ec 100644 --- a/adventure/hdr.h +++ b/adventure/hdr.h @@ -1,4 +1,4 @@ -/* $NetBSD: hdr.h,v 1.10 2003/08/07 09:36:50 agc Exp $ */ +/* $NetBSD: hdr.h,v 1.11 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -83,11 +83,10 @@ extern struct hashtab { /* hash table for vocabulary */ } voc[HTSIZE]; #define SEED 1815622 /* "Encryption" seed */ -struct text - { - char *seekadr;/* Msg start in virtual disk */ - int txtlen; /* length of msg starting here */ - }; +struct text { + char *seekadr;/* Msg start in virtual disk */ + int txtlen; /* length of msg starting here */ +}; #define RTXSIZ 205 extern struct text rtext[RTXSIZ]; /* random text messages */ @@ -107,11 +106,11 @@ extern struct text ltext[LOCSIZ]; /* long loc description */ extern struct text stext[LOCSIZ]; /* short loc descriptions */ extern struct travlist { /* direcs & conditions of travel */ - struct travlist *next; /* ptr to next list entry */ - int conditions; /* m in writeup (newloc / 1000) */ - int tloc; /* n in writeup (newloc % 1000) */ - int tverb; /* the verb that takes you there */ - } *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */ + struct travlist *next; /* ptr to next list entry */ + int conditions; /* m in writeup (newloc / 1000) */ + int tloc; /* n in writeup (newloc % 1000) */ + int tverb; /* the verb that takes you there */ +} *travel[LOCSIZ], *tkk; /* travel is closer to keys(...) */ extern int atloc[LOCSIZ]; @@ -122,7 +121,7 @@ extern int actspk[35]; /* rtext msg for verb */ extern int cond[LOCSIZ]; /* various condition bits */ - extern int setbit[16]; /* bit defn masks 1,2,4,... */ +extern int setbit[16]; /* bit defn masks 1,2,4,... */ extern int hntmax; extern int hints[20][5]; /* info on hints */ diff --git a/adventure/init.c b/adventure/init.c index 1816fc1a..eb930181 100644 --- a/adventure/init.c +++ b/adventure/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.14 2003/08/07 09:36:50 agc Exp $ */ +/* $NetBSD: init.c,v 1.15 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)init.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: init.c,v 1.14 2003/08/07 09:36:50 agc Exp $"); +__RCSID("$NetBSD: init.c,v 1.15 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -57,8 +57,8 @@ __RCSID("$NetBSD: init.c,v 1.14 2003/08/07 09:36:50 agc Exp $"); int blklin = TRUE; -int setbit[16] = {1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000, 04000, -010000, 020000, 040000, 0100000}; +int setbit[16] = {1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000, + 04000, 010000, 020000, 040000, 0100000}; int datfd; /* message file descriptor */ volatile sig_atomic_t delhit; @@ -125,17 +125,17 @@ int turns, lmwarn, iwest, knfloc, detail, /* various flags and int demo, limit; +/* everything for 1st time run */ void -init() /* everything for 1st time run */ +init(void) { rdata(); /* read data from orig. file */ linkdata(); poof(); } -char * -decr(a, b, c, d, e) - char a, b, c, d, e; +char * +decr(int a, int b, int c, int d, int e) { static char buf[6]; @@ -149,7 +149,7 @@ decr(a, b, c, d, e) } void -linkdata() +linkdata(void) { /* secondary data manipulation */ int i, j; @@ -273,11 +273,9 @@ linkdata() closng = panic = closed = scorng = FALSE; } - - +/* come here if he hits a del */ void -trapdel(n) /* come here if he hits a del */ - int n __attribute__((__unused__)); +trapdel(int n __attribute__((__unused__))) { delhit = 1; /* main checks, treats as QUIT */ signal(SIGINT, trapdel);/* catch subsequent DELs */ @@ -285,7 +283,7 @@ trapdel(n) /* come here if he hits a del */ void -startup() +startup(void) { demo = Start(); srand((int) (time((time_t *) NULL))); /* random seed */ diff --git a/adventure/io.c b/adventure/io.c index 33ae2fe3..aed2deb4 100644 --- a/adventure/io.c +++ b/adventure/io.c @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.15 2003/09/19 10:01:53 itojun Exp $ */ +/* $NetBSD: io.c,v 1.16 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)io.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: io.c,v 1.15 2003/09/19 10:01:53 itojun Exp $"); +__RCSID("$NetBSD: io.c,v 1.16 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -53,9 +53,10 @@ __RCSID("$NetBSD: io.c,v 1.15 2003/09/19 10:01:53 itojun Exp $"); #include "extern.h" +/* get command from user */ +/* no prompt, usually */ void -getin(wrd1, wrd2) /* get command from user */ - char **wrd1, **wrd2; /* no prompt, usually */ +getin(char **wrd1, char **wrd2) { char *s; static char wd1buf[MAXSTR], wd2buf[MAXSTR]; @@ -100,9 +101,9 @@ getin(wrd1, wrd2) /* get command from user */ } } +/* confirm with rspeak */ int -yes(x, y, z) /* confirm with rspeak */ - int x, y, z; +yes(int x, int y, int z) { int result = TRUE; /* pacify gcc */ int ch; @@ -128,9 +129,9 @@ yes(x, y, z) /* confirm with rspeak */ return (result); } +/* confirm with mspeak */ int -yesm(x, y, z) /* confirm with mspeak */ - int x, y, z; +yesm(int x, int y, int z) { int result = TRUE; /* pacify gcc */ int ch; @@ -164,12 +165,13 @@ int outsw = 0; /* putting stuff to data file? */ const char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l"; const char *tape = iotape; /* pointer to encryption tape */ +/* next virtual char, bump adr */ int -next() -{ /* next virtual char, bump adr */ +next(void) +{ int ch; - ch = (*inptr ^ random()) & 0xFF; /* Decrypt input data */ + ch = (*inptr ^ random()) & 0xFF; /* Decrypt input data */ if (outsw) { /* putting data in tmp file */ if (*tape == 0) tape = iotape; /* rewind encryption tape */ @@ -181,9 +183,10 @@ next() char breakch; /* tell which char ended rnum */ +/* "read" data from virtual file */ void -rdata() -{ /* "read" data from virtual file */ +rdata(void) +{ int sect; char ch; @@ -257,10 +260,10 @@ rdata() char nbf[12]; - +/* read initial location num */ int -rnum() -{ /* read initial location num */ +rnum(void) +{ char *s; tape = iotape; /* restart encryption tape */ for (s = nbf, *s = 0;; s++) @@ -275,9 +278,9 @@ rnum() char *seekhere; +/* read description-format msgs */ void -rdesc(sect) /* read description-format msgs */ - int sect; +rdesc(int sect) { int locc; char *seekstart, *maystart; @@ -286,8 +289,9 @@ rdesc(sect) /* read description-format msgs */ outsw = 1; /* these msgs go into tmp file */ for (oldloc = -1, seekstart = seekhere;;) { maystart = inptr; /* maybe starting new entry */ - if ((locc = rnum()) != oldloc && oldloc >= 0 /* finished msg */ - && !(sect == 5 && (locc == 0 || locc >= 100))) { /* unless sect 5 */ + if ((locc = rnum()) != oldloc && oldloc >= 0 /* finished msg */ + /* unless sect 5 */ + && !(sect == 5 && (locc == 0 || locc >= 100))) { switch (sect) { /* now put it into right table */ case 1:/* long descriptions */ ltext[oldloc].seekadr = seekhere; @@ -329,7 +333,7 @@ rdesc(sect) /* read description-format msgs */ return; } if (sect != 5 || (locc > 0 && locc < 100)) { - if (oldloc != locc) /* starting a new message */ + if (oldloc != locc) /* starting a new message */ seekstart = maystart; oldloc = locc; } @@ -337,9 +341,10 @@ rdesc(sect) /* read description-format msgs */ } } +/* read travel table */ void -rtrav() -{ /* read travel table */ +rtrav(void) +{ int locc; struct travlist *t = NULL; char *s; @@ -347,7 +352,8 @@ rtrav() int len, m, n, entries = 0; for (oldloc = -1;;) { /* get another line */ - if ((locc = rnum()) != oldloc && oldloc >= 0) { /* end of entry */ + /* end of entry */ + if ((locc = rnum()) != oldloc && oldloc >= 0) { t->next = 0; /* terminate the old entry */ /* printf("%d:%d entries\n",oldloc,entries); */ /* twrite(oldloc); */ @@ -355,7 +361,8 @@ rtrav() if (locc == -1) return; if (locc != oldloc) { /* getting a new entry */ - t = travel[locc] = (struct travlist *) malloc(sizeof(struct travlist)); + t = travel[locc] = (struct travlist *) + malloc(sizeof(struct travlist)); if ( t == NULL) err(1, NULL); /* printf("New travel list for %d\n",locc); */ @@ -373,27 +380,28 @@ rtrav() n = atoi(buf); /* newloc mod 1000 = newloc */ } else { /* a long integer */ n = atoi(buf + len - 3); - buf[len - 3] = 0; /* terminate newloc/1000 */ + buf[len - 3] = 0; /* terminate newloc/1000 */ m = atoi(buf); } while (breakch != LF) { /* only do one line at a time */ if (entries++) { - t = t->next = (struct travlist *) malloc(sizeof(struct travlist)); + t = t->next = (struct travlist *) + malloc(sizeof(struct travlist)); if (t == NULL) err(1, NULL); } - t->tverb = rnum(); /* get verb from the file */ + t->tverb = rnum(); /* get verb from the file */ t->tloc = n; /* table entry mod 1000 */ - t->conditions = m; /* table entry / 1000 */ - /* printf("entry %d for %d\n",entries,locc); */ + t->conditions = m; /* table entry / 1000 */ + /* printf("entry %d for %d\n",entries,locc); */ } } } #ifdef DEBUG +/* travel options from this loc */ void -twrite(loq) /* travel options from this loc */ - int loq; +twrite(int loq) { struct travlist *t; printf("If"); @@ -413,17 +421,18 @@ twrite(loq) /* travel options from this loc */ } #endif /* DEBUG */ +/* read the vocabulary */ void -rvoc() +rvoc(void) { - char *s; /* read the vocabulary */ - int index; + char *s; + int idx; char buf[6]; for (;;) { - index = rnum(); - if (index < 0) + idx = rnum(); + if (idx < 0) break; - for (s = buf, *s = 0;; s++) /* get the word */ + for (s = buf, *s = 0;; s++) /* get the word */ if ((*s = next()) == TAB || *s == '\n' || *s == LF || *s == ' ') break; @@ -431,16 +440,16 @@ rvoc() if (*s != '\n' && *s != LF) FLUSHLF;/* can be comments */ *s = 0; - /* printf("\"%s\"=%d\n",buf,index); */ - vocab(buf, -2, index); + /* printf("\"%s\"=%d\n",buf,idx); */ + vocab(buf, -2, idx); } /* prht(); */ } - +/* initial object locations */ void -rlocs() -{ /* initial object locations */ +rlocs(void) +{ for (;;) { if ((obj = rnum()) < 0) break; @@ -452,9 +461,10 @@ rlocs() } } +/* default verb messages */ void -rdflt() -{ /* default verb messages */ +rdflt(void) +{ for (;;) { if ((verb = rnum()) < 0) break; @@ -462,9 +472,10 @@ rdflt() } } +/* liquid assets &c: cond bits */ void -rliq() -{ /* liquid assets &c: cond bits */ +rliq(void) +{ int bitnum; for (;;) { /* read new bit list */ if ((bitnum = rnum()) < 0) @@ -478,7 +489,7 @@ rliq() } void -rhints() +rhints(void) { int hintnum, i; hntmax = 0; @@ -494,8 +505,7 @@ rhints() void -rspeak(msg) - int msg; +rspeak(int msg) { if (msg != 0) speak(&rtext[msg]); @@ -503,27 +513,25 @@ rspeak(msg) void -mspeak(msg) - int msg; +mspeak(int msg) { if (msg != 0) speak(&mtext[msg]); } +/* read, decrypt, and print a message (not ptext) */ +/* msg is a pointer to seek address and length of mess */ void -speak(msg) /* read, decrypt, and print a message (not - * ptext) */ - const struct text *msg; /* msg is a pointer to seek address and length - * of mess */ +speak(const struct text *msg) { char *s, nonfirst; s = msg->seekadr; nonfirst = 0; - while (s - msg->seekadr < msg->txtlen) { /* read a line at a time */ + while (s - msg->seekadr < msg->txtlen) { /* read a line at a time */ tape = iotape; /* restart decryption tape */ - while ((*s++ ^ *tape++) != TAB); /* read past loc num */ + while ((*s++ ^ *tape++) != TAB); /* read past loc num */ /* assume tape is longer than location number */ /* plus the lookahead put together */ if ((*s ^ *tape) == '>' && @@ -536,20 +544,18 @@ speak(msg) /* read, decrypt, and print a message (not if (*tape == 0) tape = iotape; /* rewind decryp tape */ putchar(*s ^ *tape); - } while ((*s++ ^ *tape++) != LF); /* better end with LF */ + } while ((*s++ ^ *tape++) != LF); /* better end with LF */ } } - +/* read, decrypt and print a ptext message */ +/* msg is the number of all the p msgs for this place */ +/* assumes object 1 doesn't have prop 1, obj 2 no prop 2 &c */ void -pspeak(m, skip) /* read, decrypt an print a ptext message */ - int m; /* msg is the number of all the p msgs for - * this place */ - int skip; /* assumes object 1 doesn't have prop 1, obj 2 - * no prop 2 &c */ +pspeak(int m, int skip) { char *s, nonfirst; - char *numst, save; + char *numst; struct text *msg; char *tbuf; @@ -562,10 +568,10 @@ pspeak(m, skip) /* read, decrypt an print a ptext message */ nonfirst = 0; while (s - tbuf < msg->txtlen) { /* read line at a time */ tape = iotape; /* restart decryption tape */ - for (numst = s; (*s ^= *tape++) != TAB; s++); /* get number */ + for (numst = s; (*s ^= *tape++) != TAB; s++); /* get number */ - save = *s; /* Temporarily trash the string (cringe) */ - *s++ = 0; /* decrypting number within the string */ + /* Temporarily trash the string (cringe) */ + *s++ = 0; /* decrypting number within the string */ if (atoi(numst) != 100 * skip && skip >= 0) { while ((*s++ ^ *tape++) != LF) /* flush the line */ @@ -582,7 +588,7 @@ pspeak(m, skip) /* read, decrypt an print a ptext message */ if (*tape == 0) tape = iotape; putchar(*s ^ *tape); - } while ((*s++ ^ *tape++) != LF); /* better end with LF */ + } while ((*s++ ^ *tape++) != LF); /* better end with LF */ if (skip < 0) break; } diff --git a/adventure/main.c b/adventure/main.c index 613a2c77..9a46e0ea 100644 --- a/adventure/main.c +++ b/adventure/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $ */ +/* $NetBSD: main.c,v 1.19 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\n\ #if 0 static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $"); +__RCSID("$NetBSD: main.c,v 1.19 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -59,12 +59,8 @@ __RCSID("$NetBSD: main.c,v 1.18 2004/01/27 20:30:28 jsm Exp $"); #include "hdr.h" #include "extern.h" -int main(int, char **); - int -main(argc, argv) - int argc; - char **argv; +main(int argc, char **argv) { int i; int rval, ll; @@ -411,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)) @@ -595,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; @@ -637,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; diff --git a/adventure/save.c b/adventure/save.c index 2f0e355b..8e25c54b 100644 --- a/adventure/save.c +++ b/adventure/save.c @@ -1,4 +1,4 @@ -/* $NetBSD: save.c,v 1.8 2003/08/07 09:36:51 agc Exp $ */ +/* $NetBSD: save.c,v 1.9 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)save.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: save.c,v 1.8 2003/08/07 09:36:51 agc Exp $"); +__RCSID("$NetBSD: save.c,v 1.9 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -120,11 +120,10 @@ struct savestruct save_array[] = {NULL, 0} }; +/* Two passes on data: first to get checksum, second */ +/* to output the data using checksum to start random #s */ int -save(outfile) /* Two passes on data: first to get checksum, - * second */ - const char *outfile; /* to output the data using checksum to start - * random #s */ +save(const char *outfile) { FILE *out; struct savestruct *p; @@ -157,8 +156,7 @@ save(outfile) /* Two passes on data: first to get checksum, } int -restore(infile) - const char *infile; +restore(const char *infile) { FILE *in; struct savestruct *p; diff --git a/adventure/setup.c b/adventure/setup.c index 56a37dda..36a7c0e9 100644 --- a/adventure/setup.c +++ b/adventure/setup.c @@ -1,4 +1,4 @@ -/* $NetBSD: setup.c,v 1.10 2003/08/07 09:36:51 agc Exp $ */ +/* $NetBSD: setup.c,v 1.11 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ static char copyright[] = "@(#) Copyright (c) 1991, 1993\n\ #if 0 static char sccsid[] = "@(#)setup.c 8.1 (Berkeley) 5/31/93"; #else -static char rcsid[] = "$NetBSD: setup.c,v 1.10 2003/08/07 09:36:51 agc Exp $"; +static char rcsid[] = "$NetBSD: setup.c,v 1.11 2005/07/01 00:03:36 jmc Exp $"; #endif #endif /* not lint */ @@ -60,7 +60,7 @@ static char rcsid[] = "$NetBSD: setup.c,v 1.10 2003/08/07 09:36:51 agc Exp $"; #include #include #include -#include "hdr.h" /* SEED lives in there; keep them coordinated. */ +#include "hdr.h" /* SEED lives in there; keep them coordinated. */ #define USAGE "Usage: setup file > data.c (file is typically glorkz)\n" @@ -72,9 +72,7 @@ static char rcsid[] = "$NetBSD: setup.c,v 1.10 2003/08/07 09:36:51 agc Exp $"; int main(int, char *[]); int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { FILE *infile; int c, count, linestart; @@ -99,8 +97,9 @@ main(argc, argv) linestart = YES; while ((c = getc(infile)) != EOF) { - if (linestart && c == ' ') { /* Convert first spaces to tab */ - printf("0x%02x,", (unsigned int)('\t' ^ random()) & 0xFF); + if (linestart && c == ' ') { /* Convert first spaces to tab */ + printf("0x%02x,", + (unsigned int)('\t' ^ random()) & 0xFF); while ((c = getc(infile)) == ' ' && c != EOF); /* Drop the non-whitespace character through */ linestart = NO; diff --git a/adventure/subr.c b/adventure/subr.c index 297238b0..4ce56561 100644 --- a/adventure/subr.c +++ b/adventure/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.10 2003/08/07 09:36:51 agc Exp $ */ +/* $NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)subr.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: subr.c,v 1.10 2003/08/07 09:36:51 agc Exp $"); +__RCSID("$NetBSD: subr.c,v 1.11 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -52,8 +52,7 @@ __RCSID("$NetBSD: subr.c,v 1.10 2003/08/07 09:36:51 agc Exp $"); /* Statement functions */ int -toting(objj) - int objj; +toting(int objj) { if (place[objj] == -1) return (TRUE); @@ -62,8 +61,7 @@ toting(objj) } int -here(objj) - int objj; +here(int objj) { if (place[objj] == loc || toting(objj)) return (TRUE); @@ -72,8 +70,7 @@ here(objj) } int -at(objj) - int objj; +at(int objj) { if (place[objj] == loc || fixed[objj] == loc) return (TRUE); @@ -82,14 +79,13 @@ at(objj) } int -liq2(pbotl) - int pbotl; +liq2(int pbotl) { return ((1 - pbotl) * water + (pbotl / 2) * (water + oil)); } int -liq() +liq(void) { int i; i = prop[bottle]; @@ -99,9 +95,9 @@ liq() return (liq2(-1 - i)); } +/* may want to clean this one up a bit */ int -liqloc(locc) /* may want to clean this one up a bit */ - int locc; +liqloc(int locc) { int i, j, l; i = cond[locc] / 2; @@ -112,8 +108,7 @@ liqloc(locc) /* may want to clean this one up a bit */ } int -bitset(l, n) - int l, n; +bitset(int l, int n) { if (cond[l] & setbit[n]) return (TRUE); @@ -121,8 +116,7 @@ bitset(l, n) } int -forced(locc) - int locc; +forced(int locc) { if (cond[locc] == 2) return (TRUE); @@ -130,7 +124,7 @@ forced(locc) } int -dark() +dark(void) { if ((cond[loc] % 2) == 0 && (prop[lamp] == 0 || !here(lamp))) return (TRUE); @@ -138,8 +132,7 @@ dark() } int -pct(n) - int n; +pct(int n) { if (ran(100) < n) return (TRUE); @@ -148,7 +141,7 @@ pct(n) int -fdwarf() +fdwarf(void) { /* 71 */ int i, j; struct travlist *kk; @@ -209,7 +202,8 @@ fdwarf() j = 1 + ran(j); odloc[i] = dloc[i]; dloc[i] = tk[j]; - dseen[i] = (dseen[i] && loc >= 15) || (dloc[i] == loc || odloc[i] == loc); + dseen[i] = (dseen[i] && loc >= 15) || + (dloc[i] == loc || odloc[i] == loc); if (!dseen[i]) continue; /* i.e. goto 6030 */ dloc[i] = loc; @@ -217,7 +211,7 @@ fdwarf() if (loc == chloc || prop[chest] >= 0) continue; k = 0; - for (j = 50; j <= maxtrs; j++) { /* loop to 6020 */ + for (j = 50; j <= maxtrs; j++) { /* loop to 6020 */ if (j == pyram && (loc == plac[pyram] || loc == plac[emrald])) goto l6020; @@ -236,7 +230,7 @@ fdwarf() if (place[messag] == 0) move(chest, chloc); move(messag, chloc2); - for (j = 50; j <= maxtrs; j++) { /* loop to 6023 */ + for (j = 50; j <= maxtrs; j++) { /* loop to 6023 */ if (j == pyram && (loc == plac[pyram] || loc == plac[emrald])) continue; @@ -293,9 +287,10 @@ l82: if (stick <= 1) { /* 82 */ } +/* label 8 */ int -march() -{ /* label 8 */ +march(void) +{ int ll1, ll2; if ((tkk = travel[newloc = loc]) == 0) @@ -377,11 +372,10 @@ l12: /* alternative to probability move */ goto l11; } - - +/* 20 */ int -mback() -{ /* 20 */ +mback(void) +{ struct travlist *tk2, *j; int ll; if (forced(k = oldloc)) @@ -416,10 +410,10 @@ mback() return (2); } - +/* 30000 */ int -specials() -{ /* 30000 */ +specials(void) +{ switch (newloc -= 300) { case 1: /* 30100 */ newloc = 99 + 100 - loc; @@ -438,10 +432,10 @@ specials() } } - +/* 30300 */ int -trbridge() -{ /* 30300 */ +trbridge(void) +{ if (prop[troll] == 1) { pspeak(troll, 1); prop[troll] = 0; @@ -453,7 +447,7 @@ trbridge() newloc = loc; return (2); } - newloc = plac[troll] + fixd[troll] - loc; /* 30310 */ + newloc = plac[troll] + fixd[troll] - loc; /* 30310 */ if (prop[troll] == 0) prop[troll] = 1; if (!toting(bear)) @@ -470,10 +464,10 @@ trbridge() return (99); } - +/* 20 */ void -badmove() -{ /* 20 */ +badmove(void) +{ spk = 12; if (k >= 43 && k <= 50) spk = 9; @@ -493,17 +487,16 @@ badmove() } void -bug(n) - int n; +bug(int n) { printf("Please tell jim@rand.org that fatal bug %d happened.\n", n); exit(1); } - +/* 2600 &c */ void -checkhints() -{ /* 2600 &c */ +checkhints(void) +{ int hint; for (hint = 4; hint <= hntmax; hint++) { if (hinted[hint]) @@ -550,10 +543,10 @@ l40020: hintlc[hint] = 0; } } - +/* 9030 */ int -trsay() -{ /* 9030 */ +trsay(void) +{ int i; if (*wd2 != 0) copystr(wd2, wd1); @@ -567,10 +560,10 @@ trsay() return (2012); } - +/* 9010 */ int -trtake() -{ /* 9010 */ +trtake(void) +{ if (toting(obj)) return (2011); /* 9010 */ spk = 25; @@ -622,10 +615,10 @@ l9014: if ((obj == bird || obj == cage) && prop[bird] != 0) return (2009); } - +/* 9021 */ int -dropper() -{ /* 9021 */ +dropper(void) +{ k = liq(); if (k == obj) obj = bottle; @@ -639,9 +632,10 @@ dropper() return (2012); } +/* 9020 */ int -trdrop() -{ /* 9020 */ +trdrop(void) +{ if (toting(rod2) && obj == rod && !toting(rod)) obj = rod2; if (!toting(obj)) @@ -660,7 +654,7 @@ trdrop() pspeak(batter, 0); return (2012); } - if (obj == bird && at(dragon) && prop[dragon] == 0) { /* 9025 */ + if (obj == bird && at(dragon) && prop[dragon] == 0) { /* 9025 */ rspeak(154); dstroy(bird); prop[bird] = 0; @@ -678,7 +672,7 @@ trdrop() prop[troll] = 2; return (dropper()); } - if (obj != vase || loc == plac[pillow]) { /* 9027 */ + if (obj != vase || loc == plac[pillow]) { /* 9027 */ rspeak(54); return (dropper()); } @@ -691,10 +685,10 @@ trdrop() return (dropper()); } - +/* 9040 */ int -tropen() -{ /* 9040 */ +tropen(void) +{ if (obj == clam || obj == oyster) { k = 0; /* 9046 */ if (obj == oyster) @@ -769,10 +763,10 @@ tropen() return (2010); } - +/* 9120 */ int -trkill() -{ /* 9120 */ +trkill(void) +{ int i; for (i = 1; i <= 5; i++) if (dloc[i] == loc && dflag >= 2) @@ -851,10 +845,10 @@ trkill() return (8); } - +/* 9170: throw */ int -trtoss() -{ /* 9170: throw */ +trtoss(void) +{ int i; if (toting(rod2) && obj == rod && !toting(rod)) obj = rod2; @@ -913,10 +907,10 @@ trtoss() return (9120); } - +/* 9210 */ int -trfeed() -{ /* 9210 */ +trfeed(void) +{ if (obj == bird) { spk = 100; return (2011); @@ -960,10 +954,10 @@ trfeed() return (2011); } - +/* 9220 */ int -trfill() -{ /* 9220 */ +trfill(void) +{ if (obj == vase) { spk = 29; if (liqloc(loc) == 0) @@ -995,10 +989,10 @@ trfill() return (2011); } - +/* 10000 */ void -closing() -{ /* 10000 */ +closing(void) +{ int i; prop[grate] = prop[fissur] = 0; @@ -1022,10 +1016,10 @@ closing() closng = TRUE; } - +/* 11000 */ void -caveclose() -{ /* 11000 */ +caveclose(void) +{ int i; prop[bottle] = put(bottle, 115, 1); prop[plant] = put(plant, 115, 0); diff --git a/adventure/vocab.c b/adventure/vocab.c index 78939d3a..f1ee2b95 100644 --- a/adventure/vocab.c +++ b/adventure/vocab.c @@ -1,4 +1,4 @@ -/* $NetBSD: vocab.c,v 1.11 2003/08/07 09:36:51 agc Exp $ */ +/* $NetBSD: vocab.c,v 1.12 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)vocab.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: vocab.c,v 1.11 2003/08/07 09:36:51 agc Exp $"); +__RCSID("$NetBSD: vocab.c,v 1.12 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -52,15 +52,13 @@ __RCSID("$NetBSD: vocab.c,v 1.11 2003/08/07 09:36:51 agc Exp $"); #include "extern.h" void -dstroy(object) - int object; +dstroy(int object) { move(object, 0); } void -juggle(object) - int object; +juggle(int object) { int i, j; @@ -70,10 +68,8 @@ juggle(object) move(object + 100, j); } - void -move(object, where) - int object, where; +move(int object, int where) { int from; @@ -87,16 +83,14 @@ move(object, where) } int -put(object, where, pval) - int object, where, pval; +put(int object, int where, int pval) { move(object, where); return (-1 - pval); } void -carry(object, where) - int object, where; +carry(int object, int where) { int temp; @@ -116,8 +110,7 @@ carry(object, where) void -drop(object, where) - int object, where; +drop(int object, int where) { if (object > 100) fixed[object - 100] = where; @@ -132,12 +125,11 @@ drop(object, where) atloc[where] = object; } +/* look up or store a word */ +/* -2 for store, -1 for user word, >=0 for canned lookup */ +/* used for storing only */ int -vocab(word, type, value) /* look up or store a word */ - const char *word; - int type; /* -2 for store, -1 for user word, >=0 for - * canned lookup */ - int value; /* used for storing only */ +vocab(const char *word, int type, int value) { int adr; const char *s; @@ -145,7 +137,7 @@ vocab(word, type, value) /* look up or store a word */ int hash, i; struct hashtab *h; - for (hash = 0, s = word, i = 0; i < 5 && *s; i++) /* some kind of hash */ + for (hash = 0, s = word, i = 0; i < 5 && *s; i++) /* some kind of hash*/ hash += *s++; /* add all chars in the word */ hash = (hash * 3719) & 077777; /* pulled that one out of a hat */ hash %= HTSIZE; /* put it into range of table */ @@ -197,9 +189,10 @@ exitloop2: /* hashed entry does not match */ } } +/* print hash table */ void -prht() -{ /* print hash table */ +prht(void) +{ int i, j, l; char *c; struct hashtab *h; diff --git a/adventure/wizard.c b/adventure/wizard.c index 5e206056..a63aa069 100644 --- a/adventure/wizard.c +++ b/adventure/wizard.c @@ -1,4 +1,4 @@ -/* $NetBSD: wizard.c,v 1.11 2003/08/07 09:36:51 agc Exp $ */ +/* $NetBSD: wizard.c,v 1.12 2005/07/01 00:03:36 jmc Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -39,7 +39,7 @@ #if 0 static char sccsid[] = "@(#)wizard.c 8.1 (Berkeley) 6/2/93"; #else -__RCSID("$NetBSD: wizard.c,v 1.11 2003/08/07 09:36:51 agc Exp $"); +__RCSID("$NetBSD: wizard.c,v 1.12 2005/07/01 00:03:36 jmc Exp $"); #endif #endif /* not lint */ @@ -53,8 +53,7 @@ __RCSID("$NetBSD: wizard.c,v 1.11 2003/08/07 09:36:51 agc Exp $"); #include "extern.h" void -datime(d, t) - int *d, *t; +datime(int *d, int *t) { time_t tvec; struct tm *tptr; @@ -75,14 +74,14 @@ datime(d, t) char magic[6]; void -poof() +poof(void) { strcpy(magic, DECR('d', 'w', 'a', 'r', 'f')); latncy = 45; } int -Start() +Start(void) { int d, t, delay; @@ -109,9 +108,10 @@ Start() return (FALSE); } +/* not as complex as advent/10 (for now) */ int -wizard() -{ /* not as complex as advent/10 (for now) */ +wizard(void) +{ char *word, *x; if (!yesm(16, 0, 7)) return (FALSE); @@ -126,7 +126,7 @@ wizard() } void -ciao() +ciao(void) { char *c; char fname[80]; @@ -144,14 +144,14 @@ ciao() if (save(fname) != 0) return; /* Save failed */ printf("To resume, say \"adventure %s\".\n", fname); - printf("\"With these rooms I might now have been familiarly acquainted.\"\n"); + printf("\"With these rooms I might now have been familiarly "); + printf("acquainted.\"\n"); exit(0); } int -ran(range) - int range; +ran(int range) { long i; -- cgit v1.2.3-56-ge451