]> git.cameronkatri.com Git - bsdgames-darwin.git/commitdiff
KNFify
authorlukem <lukem@NetBSD.org>
Sat, 11 Oct 1997 01:53:21 +0000 (01:53 +0000)
committerlukem <lukem@NetBSD.org>
Sat, 11 Oct 1997 01:53:21 +0000 (01:53 +0000)
12 files changed:
adventure/crc.c
adventure/done.c
adventure/extern.h
adventure/hdr.h
adventure/init.c
adventure/io.c
adventure/main.c
adventure/save.c
adventure/setup.c
adventure/subr.c
adventure/vocab.c
adventure/wizard.c

index e5e87370e3fdfff2fc166513c6c174fd3a912b35..768882d9aa8e14bf9771b523f96eda736f4c6ba8 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: crc.c,v 1.4 1997/10/10 11:59:36 lukem Exp $    */
+/*     $NetBSD: crc.c,v 1.5 1997/10/11 01:53:21 lukem Exp $    */
 
 /*-
  * Copyright (c) 1993
@@ -42,7 +42,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.4 1997/10/10 11:59:36 lukem Exp $");
+__RCSID("$NetBSD: crc.c,v 1.5 1997/10/11 01:53:21 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -50,59 +50,58 @@ __RCSID("$NetBSD: crc.c,v 1.4 1997/10/10 11:59:36 lukem Exp $");
 
 unsigned long crctab[] = {
        0x7fffffff,
-       0x77073096,  0xee0e612c,  0x990951ba,  0x076dc419,  0x706af48f,
-       0xe963a535,  0x9e6495a3,  0x0edb8832,  0x79dcb8a4,  0xe0d5e91e,
-       0x97d2d988,  0x09b64c2b,  0x7eb17cbd,  0xe7b82d07,  0x90bf1d91,
-       0x1db71064,  0x6ab020f2,  0xf3b97148,  0x84be41de,  0x1adad47d,
-       0x6ddde4eb,  0xf4d4b551,  0x83d385c7,  0x136c9856,  0x646ba8c0,
-       0xfd62f97a,  0x8a65c9ec,  0x14015c4f,  0x63066cd9,  0xfa0f3d63,
-       0x8d080df5,  0x3b6e20c8,  0x4c69105e,  0xd56041e4,  0xa2677172,
-       0x3c03e4d1,  0x4b04d447,  0xd20d85fd,  0xa50ab56b,  0x35b5a8fa,
-       0x42b2986c,  0xdbbbc9d6,  0xacbcf940,  0x32d86ce3,  0x45df5c75,
-       0xdcd60dcf,  0xabd13d59,  0x26d930ac,  0x51de003a,  0xc8d75180,
-       0xbfd06116,  0x21b4f4b5,  0x56b3c423,  0xcfba9599,  0xb8bda50f,
-       0x2802b89e,  0x5f058808,  0xc60cd9b2,  0xb10be924,  0x2f6f7c87,
-       0x58684c11,  0xc1611dab,  0xb6662d3d,  0x76dc4190,  0x01db7106,
-       0x98d220bc,  0xefd5102a,  0x71b18589,  0x06b6b51f,  0x9fbfe4a5,
-       0xe8b8d433,  0x7807c9a2,  0x0f00f934,  0x9609a88e,  0xe10e9818,
-       0x7f6a0dbb,  0x086d3d2d,  0x91646c97,  0xe6635c01,  0x6b6b51f4,
-       0x1c6c6162,  0x856530d8,  0xf262004e,  0x6c0695ed,  0x1b01a57b,
-       0x8208f4c1,  0xf50fc457,  0x65b0d9c6,  0x12b7e950,  0x8bbeb8ea,
-       0xfcb9887c,  0x62dd1ddf,  0x15da2d49,  0x8cd37cf3,  0xfbd44c65,
-       0x4db26158,  0x3ab551ce,  0xa3bc0074,  0xd4bb30e2,  0x4adfa541,
-       0x3dd895d7,  0xa4d1c46d,  0xd3d6f4fb,  0x4369e96a,  0x346ed9fc,
-       0xad678846,  0xda60b8d0,  0x44042d73,  0x33031de5,  0xaa0a4c5f,
-       0xdd0d7cc9,  0x5005713c,  0x270241aa,  0xbe0b1010,  0xc90c2086,
-       0x5768b525,  0x206f85b3,  0xb966d409,  0xce61e49f,  0x5edef90e,
-       0x29d9c998,  0xb0d09822,  0xc7d7a8b4,  0x59b33d17,  0x2eb40d81,
-       0xb7bd5c3b,  0xc0ba6cad,  0xedb88320,  0x9abfb3b6,  0x03b6e20c,
-       0x74b1d29a,  0xead54739,  0x9dd277af,  0x04db2615,  0x73dc1683,
-       0xe3630b12,  0x94643b84,  0x0d6d6a3e,  0x7a6a5aa8,  0xe40ecf0b,
-       0x9309ff9d,  0x0a00ae27,  0x7d079eb1,  0xf00f9344,  0x8708a3d2,
-       0x1e01f268,  0x6906c2fe,  0xf762575d,  0x806567cb,  0x196c3671,
-       0x6e6b06e7,  0xfed41b76,  0x89d32be0,  0x10da7a5a,  0x67dd4acc,
-       0xf9b9df6f,  0x8ebeeff9,  0x17b7be43,  0x60b08ed5,  0xd6d6a3e8,
-       0xa1d1937e,  0x38d8c2c4,  0x4fdff252,  0xd1bb67f1,  0xa6bc5767,
-       0x3fb506dd,  0x48b2364b,  0xd80d2bda,  0xaf0a1b4c,  0x36034af6,
-       0x41047a60,  0xdf60efc3,  0xa867df55,  0x316e8eef,  0x4669be79,
-       0xcb61b38c,  0xbc66831a,  0x256fd2a0,  0x5268e236,  0xcc0c7795,
-       0xbb0b4703,  0x220216b9,  0x5505262f,  0xc5ba3bbe,  0xb2bd0b28,
-       0x2bb45a92,  0x5cb36a04,  0xc2d7ffa7,  0xb5d0cf31,  0x2cd99e8b,
-       0x5bdeae1d,  0x9b64c2b0,  0xec63f226,  0x756aa39c,  0x026d930a,
-       0x9c0906a9,  0xeb0e363f,  0x72076785,  0x05005713,  0x95bf4a82,
-       0xe2b87a14,  0x7bb12bae,  0x0cb61b38,  0x92d28e9b,  0xe5d5be0d,
-       0x7cdcefb7,  0x0bdbdf21,  0x86d3d2d4,  0xf1d4e242,  0x68ddb3f8,
-       0x1fda836e,  0x81be16cd,  0xf6b9265b,  0x6fb077e1,  0x18b74777,
-       0x88085ae6,  0xff0f6a70,  0x66063bca,  0x11010b5c,  0x8f659eff,
-       0xf862ae69,  0x616bffd3,  0x166ccf45,  0xa00ae278,  0xd70dd2ee,
-       0x4e048354,  0x3903b3c2,  0xa7672661,  0xd06016f7,  0x4969474d,
-       0x3e6e77db,  0xaed16a4a,  0xd9d65adc,  0x40df0b66,  0x37d83bf0,
-       0xa9bcae53,  0xdebb9ec5,  0x47b2cf7f,  0x30b5ffe9,  0xbdbdf21c,
-       0xcabac28a,  0x53b39330,  0x24b4a3a6,  0xbad03605,  0xcdd70693,
-       0x54de5729,  0x23d967bf,  0xb3667a2e,  0xc4614ab8,  0x5d681b02,
-       0x2a6f2b94,  0xb40bbe37,  0xc30c8ea1,  0x5a05df1b,  0x2d02ef8d
+       0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
+       0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e,
+       0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
+       0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d,
+       0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0,
+       0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63,
+       0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
+       0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa,
+       0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75,
+       0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180,
+       0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
+       0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87,
+       0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
+       0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5,
+       0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
+       0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4,
+       0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b,
+       0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea,
+       0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
+       0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541,
+       0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc,
+       0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f,
+       0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
+       0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e,
+       0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
+       0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c,
+       0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
+       0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b,
+       0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2,
+       0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671,
+       0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
+       0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8,
+       0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767,
+       0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6,
+       0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
+       0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795,
+       0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
+       0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b,
+       0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
+       0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82,
+       0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d,
+       0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8,
+       0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
+       0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff,
+       0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee,
+       0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d,
+       0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
+       0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c,
+       0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
+       0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02,
+       0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
 };
-
 /*
  * crc --
  *      Compute a POSIX.2 checksum.  This routine modified by Jim Gillogly
@@ -112,7 +111,7 @@ unsigned long crctab[] = {
  */
 
 unsigned long crcval;
-int step;
+int     step;
 
 void
 crc_start()
@@ -121,23 +120,21 @@ crc_start()
 }
 
 unsigned long
-crc(ptr, nr) /* Process nr bytes at a time; ptr points to them */
-       char *ptr;
-       int nr;
+crc(ptr, nr)           /* Process nr bytes at a time; ptr points to them */
+       char   *ptr;
+       int     nr;
 {
-       int i;
-       char *p;
+       int     i;
+       char   *p;
 
        while (nr > 0)
-               for (p = ptr; nr--; ++p)
-               {
-                       if (!(i = crcval >> 24 ^ *p))
-                       {
+               for (p = ptr; nr--; ++p) {
+                       if (!(i = crcval >> 24 ^ *p)) {
                                i = step++;
-                               if (step >= sizeof(crctab)/sizeof(crctab[0]))
+                               if (step >= sizeof(crctab) / sizeof(crctab[0]))
                                        step = 0;
                        }
                        crcval = (crcval << 8) ^ crctab[i];
                }
-       return crcval & 0xffffffff;               /* Mask to 32 bits. */
+       return crcval & 0xffffffff;     /* Mask to 32 bits. */
 }
index 2828db3c3e45cf3f6b418f410a322897aa62c3a5..7d2ba4b1168b0d4d2d05fb58ea46ba76e165a545 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: done.c,v 1.4 1997/10/10 11:59:39 lukem Exp $   */
+/*     $NetBSD: done.c,v 1.5 1997/10/11 01:53:23 lukem Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
 #if 0
 static char sccsid[] = "@(#)done.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: done.c,v 1.4 1997/10/10 11:59:39 lukem Exp $");
+__RCSID("$NetBSD: done.c,v 1.5 1997/10/11 01:53:23 lukem Exp $");
 #endif
 #endif /* not lint */
 
-/*      Re-coding of advent in C: termination routines                  */
+/*      Re-coding of advent in C: termination routines */
 
 #include <stdio.h>
 #include "hdr.h"
 #include "extern.h"
 
 int
-score()                                         /* sort of like 20000   */
-{       int scor,i;
-       mxscor=scor=0;
-       for (i=50; i<=maxtrs; i++)
-       {       if (ptext[i].txtlen==0) continue;
-               k=12;
-               if (i==chest) k=14;
-               if (i>chest) k=16;
-               if (prop[i]>=0) scor += 2;
-               if (place[i]==3&&prop[i]==0) scor += k-2;
+score()
+{                              /* sort of like 20000 */
+       int     scor, i;
+       mxscor = scor = 0;
+       for (i = 50; i <= maxtrs; i++) {
+               if (ptext[i].txtlen == 0)
+                       continue;
+               k = 12;
+               if (i == chest)
+                       k = 14;
+               if (i > chest)
+                       k = 16;
+               if (prop[i] >= 0)
+                       scor += 2;
+               if (place[i] == 3 && prop[i] == 0)
+                       scor += k - 2;
                mxscor += k;
        }
-       scor += (maxdie-numdie)*10;
-       mxscor += maxdie*10;
-       if (!(scorng||gaveup)) scor += 4;
+       scor += (maxdie - numdie) * 10;
+       mxscor += maxdie * 10;
+       if (!(scorng || gaveup))
+               scor += 4;
        mxscor += 4;
-       if (dflag!=0) scor += 25;
+       if (dflag != 0)
+               scor += 25;
        mxscor += 25;
-       if (closng) scor += 25;
+       if (closng)
+               scor += 25;
        mxscor += 25;
-       if (closed)
-       {       if (bonus==0) scor += 10;
-               if (bonus==135) scor += 25;
-               if (bonus==134) scor += 30;
-               if (bonus==133) scor += 45;
+       if (closed) {
+               if (bonus == 0)
+                       scor += 10;
+               if (bonus == 135)
+                       scor += 25;
+               if (bonus == 134)
+                       scor += 30;
+               if (bonus == 133)
+                       scor += 45;
        }
        mxscor += 45;
-       if (place[magzin]==108) scor++;
+       if (place[magzin] == 108)
+               scor++;
        mxscor++;
        scor += 2;
        mxscor += 2;
-       for (i=1; i<=hntmax; i++)
-               if (hinted[i]) scor -= hints[i][2];
-       return(scor);
+       for (i = 1; i <= hntmax; i++)
+               if (hinted[i])
+                       scor -= hints[i][2];
+       return (scor);
 }
 
 void
-done(entry)     /* entry=1 means goto 13000 */  /* game is over         */
-int entry;      /* entry=2 means goto 20000 */ /* 3=19000 */
-{       int i,sc;
-       if (entry==1) mspeak(1);
-       if (entry==3) rspeak(136);
-       printf("\n\n\nYou scored %d out of a ",(sc=score()));
-       printf("possible %d using %d turns.\n",mxscor,turns);
-       for (i=1; i<=clsses; i++)
-               if (cval[i]>=sc)
-               {       speak(&ctext[i]);
-                       if (i==clsses-1)
-                       {       printf("To achieve the next higher rating");
+done(entry)            /* entry=1 means goto 13000 */  /* game is over */
+       int     entry;  /* entry=2 means goto 20000 */  /* 3=19000 */
+{
+       int     i, sc;
+       if (entry == 1)
+               mspeak(1);
+       if (entry == 3)
+               rspeak(136);
+       printf("\n\n\nYou scored %d out of a ", (sc = score()));
+       printf("possible %d using %d turns.\n", mxscor, turns);
+       for (i = 1; i <= clsses; i++)
+               if (cval[i] >= sc) {
+                       speak(&ctext[i]);
+                       if (i == clsses - 1) {
+                               printf("To achieve the next higher rating");
                                printf(" would be a neat trick!\n\n");
                                printf("Congratulations!!\n");
                                exit(0);
                        }
-                       k=cval[i]+1-sc;
+                       k = cval[i] + 1 - sc;
                        printf("To achieve the next higher rating, you need");
-                       printf(" %d more point",k);
-                       if (k==1) printf(".\n");
-                       else printf("s.\n");
+                       printf(" %d more point", k);
+                       if (k == 1)
+                               printf(".\n");
+                       else
+                               printf("s.\n");
                        exit(0);
                }
        printf("You just went off my scale!!!\n");
@@ -120,31 +140,36 @@ int entry;      /* entry=2 means goto 20000 */ /* 3=19000 */
 
 
 int
-die(entry)                                      /* label 90             */
-int entry;
-{       int i;
-       if (entry != 99)
-       {       rspeak(23);
-               oldlc2=loc;
+die(entry)                     /* label 90 */
+       int     entry;
+{
+       int     i;
+       if (entry != 99) {
+               rspeak(23);
+               oldlc2 = loc;
        }
-       if (closng)                             /* 99                   */
-       {       rspeak(131);
+       if (closng) {           /* 99 */
+               rspeak(131);
                numdie++;
                done(2);
        }
-       yea=yes(81+numdie*2,82+numdie*2,54);
+       yea = yes(81 + numdie * 2, 82 + numdie * 2, 54);
        numdie++;
-       if (numdie==maxdie || !yea) done(2);
-       place[water]=0;
-       place[oil]=0;
-       if (toting(lamp)) prop[lamp]=0;
-       for (i=100; i>=1; i--)
-       {       if (!toting(i)) continue;
-               k=oldlc2;
-               if (i==lamp) k=1;
-               drop(i,k);
+       if (numdie == maxdie || !yea)
+               done(2);
+       place[water] = 0;
+       place[oil] = 0;
+       if (toting(lamp))
+               prop[lamp] = 0;
+       for (i = 100; i >= 1; i--) {
+               if (!toting(i))
+                       continue;
+               k = oldlc2;
+               if (i == lamp)
+                       k = 1;
+               drop(i, k);
        }
-       loc=3;
-       oldloc=loc;
-       return(2000);
+       loc = 3;
+       oldloc = loc;
+       return (2000);
 }
index 6da0d42a34ed0f63aae9532bba264ef1eca68e19..5e240d26d27db998aaff4e55277eed7b37c2bbdf 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: extern.h,v 1.1 1997/08/11 14:06:13 christos Exp $      */
+/*     $NetBSD: extern.h,v 1.2 1997/10/11 01:53:25 lukem Exp $ */
 
 /*
  * Copyright (c) 1997 Christos Zoulas.  All rights reserved.
@@ -40,7 +40,7 @@ int die __P((int));
 
 /* init.c */
 void init __P((char *));
-char *decr __P((int, int, int, int, int));
+char   *decr __P((int, int, int, int, int));
 void linkdata __P((void));
 void trapdel __P((int));
 void startup __P((void));
@@ -81,7 +81,7 @@ void fatal __P((char *, int));
 /* subr.c */
 int toting __P((int));
 int here __P((int));
-int at __P((int));
+int at  __P((int));
 int liq2 __P((int));
 int liq __P((int));
 int liqloc __P((int));
index dad807e20e32e9037ee52c5bdfb6783a9653f347..c1450c54215e9ba4b6a0885ed1bc6f6212a555f5 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: hdr.h,v 1.3 1997/08/11 14:06:14 christos Exp $ */
+/*     $NetBSD: hdr.h,v 1.4 1997/10/11 01:53:26 lukem Exp $    */
 
 /*-
  * Copyright (c) 1991, 1993
 
 /* hdr.h: included by c advent files */
 
-int datfd;                              /* message file descriptor      */
-int delhit;
-int yea;
-extern char data_file[];                /* Virtual data file            */
+int     datfd;                 /* message file descriptor */
+int     delhit;
+int     yea;
+extern char data_file[];       /* Virtual data file */
 
 #define TAB     011
 #define LF      012
 #define FLUSHLINE while (getchar()!='\n')
 #define FLUSHLF   while (next()!=LF)
 
-int loc,newloc,oldloc,oldlc2,wzdark,gaveup,kq,k,k2;
-char *wd1,*wd2;                         /* the complete words           */
-int verb,obj,spk;
+int     loc, newloc, oldloc, oldlc2, wzdark, gaveup, kq, k, k2;
+char   *wd1, *wd2;             /* the complete words */
+int     verb, obj, spk;
 extern int blklin;
-int saved,savet,mxscor,latncy;
+int     saved, savet, mxscor, latncy;
 
-#define SHORT 50                        /* How short is a demo game?    */
+#define SHORT 50               /* How short is a demo game? */
 
-#define MAXSTR  20                      /* max length of user's words   */
+#define MAXSTR  20             /* max length of user's words */
 
-#define HTSIZE  512                     /* max number of vocab words    */
-struct hashtab                          /* hash table for vocabulary    */
-{       int val;                        /* word type &index (ktab)      */
-       char *atab;                     /* pointer to actual string     */
-} voc[HTSIZE];
-
-#define SEED 1815622                    /* "Encryption" seed            */
+#define HTSIZE  512            /* max number of vocab words */
+struct hashtab {               /* hash table for vocabulary */
+       int     val;            /* word type &index (ktab) */
+       char   *atab;           /* pointer to actual string */
+}       voc[HTSIZE];
+#define SEED 1815622           /* "Encryption" seed */
 
 struct text
 #ifdef OLDSTUFF
-{       int seekadr;                    /* DATFILE must be < 2**16      */
+{
+       int     seekadr;        /* DATFILE must be < 2**16 */
 #endif /* OLDSTUFF */
-{       char *seekadr;                  /* Msg start in virtual disk    */
-       int txtlen;                     /* length of msg starting here  */
-};
+       {
+               char   *seekadr;/* Msg start in virtual disk */
+               int     txtlen; /* length of msg starting here */
+       };
 
 #define RTXSIZ  205
-struct text rtext[RTXSIZ];              /* random text messages         */
+       struct text rtext[RTXSIZ];      /* random text messages */
 
 #define MAGSIZ  35
-struct text mtext[MAGSIZ];              /* magic messages               */
+       struct text mtext[MAGSIZ];      /* magic messages */
 
-int clsses;
+       int     clsses;
 #define CLSMAX  12
-struct text ctext[CLSMAX];              /* classes of adventurer        */
-int cval[CLSMAX];
+       struct text ctext[CLSMAX];      /* classes of adventurer */
+       int     cval[CLSMAX];
 
-struct text ptext[101];                 /* object descriptions          */
+       struct text ptext[101];         /* object descriptions */
 
-#define LOCSIZ  141                     /* number of locations          */
-struct text ltext[LOCSIZ];              /* long loc description         */
-struct text stext[LOCSIZ];              /* short loc descriptions       */
+#define LOCSIZ  141                    /* number of locations */
+       struct text ltext[LOCSIZ];      /* long loc description */
+       struct text stext[LOCSIZ];      /* short loc descriptions */
 
-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 {               /* 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(...) */
 
-int atloc[LOCSIZ];
+       int     atloc[LOCSIZ];
 
-int  plac[101];                         /* initial object placement     */
-int  fixd[101],fixed[101];              /* location fixed?              */
+       int     plac[101];              /* initial object placement */
+       int     fixd[101], fixed[101];  /* location fixed? */
 
-int actspk[35];                         /* rtext msg for verb <n>       */
+       int     actspk[35];             /* rtext msg for verb <n> */
 
-int cond[LOCSIZ];                       /* various condition bits       */
+       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,... */
 
-int hntmax;
-int hints[20][5];                       /* info on hints                */
-int hinted[20],hintlc[20];
+       int     hntmax;
+       int     hints[20][5];           /* info on hints */
+       int     hinted[20], hintlc[20];
 
-int place[101], prop[101],links[201];
-int abb[LOCSIZ];
+       int     place[101], prop[101], links[201];
+       int     abb[LOCSIZ];
 
-int maxtrs,tally,tally2;                /* treasure values              */
+       int     maxtrs, tally, tally2;  /* treasure values */
 
 #define FALSE   0
 #define TRUE    1
 
-int keys,lamp,grate,cage,rod,rod2,steps,/* mnemonics                    */
-       bird,door,pillow,snake,fissur,tablet,clam,oyster,magzin,
-       dwarf,knife,food,bottle,water,oil,plant,plant2,axe,mirror,dragon,
-       chasm,troll,troll2,bear,messag,vend,batter,
-       nugget,coins,chest,eggs,tridnt,vase,emrald,pyram,pearl,rug,chain,
-       spices,
-       back,look,cave,null,entrnc,dprssn,
-       enter, stream, pour,
-       say,lock,throw,find,invent;
-
-int chloc,chloc2,dseen[7],dloc[7],      /* dwarf stuff                  */
-       odloc[7],dflag,daltlc;
-
-int tk[21],stick,dtotal,attack;
-int turns,lmwarn,iwest,knfloc,detail,   /* various flags & counters     */
-       abbnum,maxdie,numdie,holdng,dkill,foobar,bonus,clock1,clock2,
-       saved,closng,panic,closed,scorng;
-
-int demo,newloc,limit;
+       int     keys, lamp, grate, cage, rod, rod2, steps,      /* mnemonics */
+               bird, door, pillow, snake, fissur, tablet, clam, oyster,
+               magzin, dwarf, knife, food, bottle, water, oil, plant, plant2,
+               axe, mirror, dragon, chasm, troll, troll2, bear, messag,
+               vend, batter, nugget, coins, chest, eggs, tridnt, vase,
+               emrald, pyram, pearl, rug, chain, spices, back, look, cave,
+               null, entrnc, dprssn, enter, stream, pour, say, lock, throw,
+               find, invent;
+
+       int     chloc, chloc2, dseen[7], dloc[7],       /* dwarf stuff */
+               odloc[7], dflag, daltlc;
+
+       int     tk[21], stick, dtotal, attack;
+       int     turns, lmwarn, iwest, knfloc, detail,   /* various flags and
+                                                        * counters */
+               abbnum, maxdie, numdie, holdng, dkill, foobar, bonus, clock1,
+               clock2, saved, closng, panic, closed, scorng;
+
+       int     demo, newloc, limit;
 
 #define DECR(a,b,c,d,e) decr(a+'+',b+'-',c+'#',d+'&',e+'%')
index 5c9aa7c99667408cab86e13bec37095526aaea6f..8b2252ccc319fb7974aeddbfcfb62bb51a2f1c76 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: init.c,v 1.6 1997/10/10 11:59:42 lukem Exp $   */
+/*     $NetBSD: init.c,v 1.7 1997/10/11 01:53:28 lukem Exp $   */
 
 /*-
  * Copyright (c) 1993
 #if 0
 static char sccsid[] = "@(#)init.c     8.1 (Berkeley) 6/2/93";
 #else
-__RCSID("$NetBSD: init.c,v 1.6 1997/10/10 11:59:42 lukem Exp $");
+__RCSID("$NetBSD: init.c,v 1.7 1997/10/11 01:53:28 lukem Exp $");
 #endif
 #endif /* not lint */
 
-/*      Re-coding of advent in C: data initialization                   */
+/*      Re-coding of advent in C: data initialization */
 
 #include <sys/types.h>
 #include <signal.h>
@@ -57,176 +57,184 @@ __RCSID("$NetBSD: init.c,v 1.6 1997/10/10 11:59:42 lukem Exp $");
 #include "hdr.h"
 #include "extern.h"
 
-int blklin = TRUE;
+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};
 
 
 void
-init(command)                           /* everything for 1st time run  */
-char *command;                          /* command we were called with  */
+init(command)                  /* everything for 1st time run */
+       char   *command;        /* command we were called with */
 {
-       rdata();                        /* read data from orig. file    */
+       rdata();                /* read data from orig. file */
        linkdata();
        poof();
 }
 
-char *decr(a,b,c,d,e)
-char a,b,c,d,e;
+char   *
+decr(a, b, c, d, e)
+       char    a, b, c, d, e;
 {
        static char buf[6];
 
-       buf[0] = a-'+';
-       buf[1] = b-'-';
-       buf[2] = c-'#';
-       buf[3] = d-'&';
-       buf[4] = e-'%';
+       buf[0] = a - '+';
+       buf[1] = b - '-';
+       buf[2] = c - '#';
+       buf[3] = d - '&';
+       buf[4] = e - '%';
        buf[5] = 0;
        return buf;
 }
 
 void
-linkdata()                              /*  secondary data manipulation */
-{       int i,j;
-
-       /*      array linkages          */
-       for (i=1; i<=LOCSIZ; i++)
-               if (ltext[i].seekadr!=0 && travel[i] != 0)
-                       if ((travel[i]->tverb)==1) cond[i]=2;
-       for (j=100; j>0; j--)
-               if (fixd[j]>0)
-               {       drop(j+100,fixd[j]);
-                       drop(j,plac[j]);
+linkdata()
+{                              /* secondary data manipulation */
+       int     i, j;
+
+       /* array linkages */
+       for (i = 1; i <= LOCSIZ; i++)
+               if (ltext[i].seekadr != 0 && travel[i] != 0)
+                       if ((travel[i]->tverb) == 1)
+                               cond[i] = 2;
+       for (j = 100; j > 0; j--)
+               if (fixd[j] > 0) {
+                       drop(j + 100, fixd[j]);
+                       drop(j, plac[j]);
                }
-       for (j=100; j>0; j--)
-       {       fixed[j]=fixd[j];
-               if (plac[j]!=0 && fixd[j]<=0) drop(j,plac[j]);
+       for (j = 100; j > 0; j--) {
+               fixed[j] = fixd[j];
+               if (plac[j] != 0 && fixd[j] <= 0)
+                       drop(j, plac[j]);
        }
 
-       maxtrs=79;
-       tally=0;
-       tally2=0;
+       maxtrs = 79;
+       tally = 0;
+       tally2 = 0;
 
-       for (i=50; i<=maxtrs; i++)
-       {       if (ptext[i].seekadr!=0) prop[i] = -1;
+       for (i = 50; i <= maxtrs; i++) {
+               if (ptext[i].seekadr != 0)
+                       prop[i] = -1;
                tally -= prop[i];
        }
 
        /* define mnemonics */
-       keys = vocab(DECR('k','e','y','s','\0'), 1, 0);
-       lamp = vocab(DECR('l','a','m','p','\0'), 1, 0);
-       grate = vocab(DECR('g','r','a','t','e'), 1, 0);
-       cage  = vocab(DECR('c','a','g','e','\0'),1, 0);
-       rod   = vocab(DECR('r','o','d','\0','\0'),1, 0);
-       rod2=rod+1;
-       steps=vocab(DECR('s','t','e','p','s'),1, 0);
-       bird  = vocab(DECR('b','i','r','d','\0'),1, 0);
-       door  = vocab(DECR('d','o','o','r','\0'),1, 0);
-       pillow= vocab(DECR('p','i','l','l','o'), 1, 0);
-       snake = vocab(DECR('s','n','a','k','e'), 1, 0);
-       fissur= vocab(DECR('f','i','s','s','u'), 1, 0);
-       tablet= vocab(DECR('t','a','b','l','e'), 1, 0);
-       clam  = vocab(DECR('c','l','a','m','\0'),1, 0);
-       oyster= vocab(DECR('o','y','s','t','e'), 1, 0);
-       magzin= vocab(DECR('m','a','g','a','z'), 1, 0);
-       dwarf = vocab(DECR('d','w','a','r','f'), 1, 0);
-       knife = vocab(DECR('k','n','i','f','e'), 1, 0);
-       food  = vocab(DECR('f','o','o','d','\0'),1, 0);
-       bottle= vocab(DECR('b','o','t','t','l'), 1, 0);
-       water = vocab(DECR('w','a','t','e','r'), 1, 0);
-       oil   = vocab(DECR('o','i','l','\0','\0'),1, 0);
-       plant = vocab(DECR('p','l','a','n','t'), 1, 0);
-       plant2=plant+1;
-       axe   = vocab(DECR('a','x','e','\0','\0'),1, 0);
-       mirror= vocab(DECR('m','i','r','r','o'), 1, 0);
-       dragon= vocab(DECR('d','r','a','g','o'), 1, 0);
-       chasm = vocab(DECR('c','h','a','s','m'), 1, 0);
-       troll = vocab(DECR('t','r','o','l','l'), 1, 0);
-       troll2=troll+1;
-       bear  = vocab(DECR('b','e','a','r','\0'),1, 0);
-       messag= vocab(DECR('m','e','s','s','a'), 1, 0);
-       vend  = vocab(DECR('v','e','n','d','i'), 1, 0);
-       batter= vocab(DECR('b','a','t','t','e'), 1, 0);
-
-       nugget= vocab(DECR('g','o','l','d','\0'),1, 0);
-       coins = vocab(DECR('c','o','i','n','s'), 1, 0);
-       chest = vocab(DECR('c','h','e','s','t'), 1, 0);
-       eggs  = vocab(DECR('e','g','g','s','\0'),1, 0);
-       tridnt= vocab(DECR('t','r','i','d','e'), 1, 0);
-       vase  = vocab(DECR('v','a','s','e','\0'),1, 0);
-       emrald= vocab(DECR('e','m','e','r','a'), 1, 0);
-       pyram = vocab(DECR('p','y','r','a','m'), 1, 0);
-       pearl = vocab(DECR('p','e','a','r','l'), 1, 0);
-       rug   = vocab(DECR('r','u','g','\0','\0'),1, 0);
-       chain = vocab(DECR('c','h','a','i','n'), 1, 0);
-
-       back  = vocab(DECR('b','a','c','k','\0'),0, 0);
-       look  = vocab(DECR('l','o','o','k','\0'),0, 0);
-       cave  = vocab(DECR('c','a','v','e','\0'),0, 0);
-       null  = vocab(DECR('n','u','l','l','\0'),0, 0);
-       entrnc= vocab(DECR('e','n','t','r','a'), 0, 0);
-       dprssn= vocab(DECR('d','e','p','r','e'), 0, 0);
-       enter = vocab(DECR('e','n','t','e','r'), 0, 0);
-
-       pour  = vocab(DECR('p','o','u','r','\0'), 2, 0);
-       say   = vocab(DECR('s','a','y','\0','\0'),2, 0);
-       lock  = vocab(DECR('l','o','c','k','\0'),2, 0);
-       throw = vocab(DECR('t','h','r','o','w'), 2, 0);
-       find  = vocab(DECR('f','i','n','d','\0'),2, 0);
-       invent= vocab(DECR('i','n','v','e','n'), 2, 0);
+       keys = vocab(DECR('k', 'e', 'y', 's', '\0'), 1, 0);
+       lamp = vocab(DECR('l', 'a', 'm', 'p', '\0'), 1, 0);
+       grate = vocab(DECR('g', 'r', 'a', 't', 'e'), 1, 0);
+       cage = vocab(DECR('c', 'a', 'g', 'e', '\0'), 1, 0);
+       rod = vocab(DECR('r', 'o', 'd', '\0', '\0'), 1, 0);
+       rod2 = rod + 1;
+       steps = vocab(DECR('s', 't', 'e', 'p', 's'), 1, 0);
+       bird = vocab(DECR('b', 'i', 'r', 'd', '\0'), 1, 0);
+       door = vocab(DECR('d', 'o', 'o', 'r', '\0'), 1, 0);
+       pillow = vocab(DECR('p', 'i', 'l', 'l', 'o'), 1, 0);
+       snake = vocab(DECR('s', 'n', 'a', 'k', 'e'), 1, 0);
+       fissur = vocab(DECR('f', 'i', 's', 's', 'u'), 1, 0);
+       tablet = vocab(DECR('t', 'a', 'b', 'l', 'e'), 1, 0);
+       clam = vocab(DECR('c', 'l', 'a', 'm', '\0'), 1, 0);
+       oyster = vocab(DECR('o', 'y', 's', 't', 'e'), 1, 0);
+       magzin = vocab(DECR('m', 'a', 'g', 'a', 'z'), 1, 0);
+       dwarf = vocab(DECR('d', 'w', 'a', 'r', 'f'), 1, 0);
+       knife = vocab(DECR('k', 'n', 'i', 'f', 'e'), 1, 0);
+       food = vocab(DECR('f', 'o', 'o', 'd', '\0'), 1, 0);
+       bottle = vocab(DECR('b', 'o', 't', 't', 'l'), 1, 0);
+       water = vocab(DECR('w', 'a', 't', 'e', 'r'), 1, 0);
+       oil = vocab(DECR('o', 'i', 'l', '\0', '\0'), 1, 0);
+       plant = vocab(DECR('p', 'l', 'a', 'n', 't'), 1, 0);
+       plant2 = plant + 1;
+       axe = vocab(DECR('a', 'x', 'e', '\0', '\0'), 1, 0);
+       mirror = vocab(DECR('m', 'i', 'r', 'r', 'o'), 1, 0);
+       dragon = vocab(DECR('d', 'r', 'a', 'g', 'o'), 1, 0);
+       chasm = vocab(DECR('c', 'h', 'a', 's', 'm'), 1, 0);
+       troll = vocab(DECR('t', 'r', 'o', 'l', 'l'), 1, 0);
+       troll2 = troll + 1;
+       bear = vocab(DECR('b', 'e', 'a', 'r', '\0'), 1, 0);
+       messag = vocab(DECR('m', 'e', 's', 's', 'a'), 1, 0);
+       vend = vocab(DECR('v', 'e', 'n', 'd', 'i'), 1, 0);
+       batter = vocab(DECR('b', 'a', 't', 't', 'e'), 1, 0);
+
+       nugget = vocab(DECR('g', 'o', 'l', 'd', '\0'), 1, 0);
+       coins = vocab(DECR('c', 'o', 'i', 'n', 's'), 1, 0);
+       chest = vocab(DECR('c', 'h', 'e', 's', 't'), 1, 0);
+       eggs = vocab(DECR('e', 'g', 'g', 's', '\0'), 1, 0);
+       tridnt = vocab(DECR('t', 'r', 'i', 'd', 'e'), 1, 0);
+       vase = vocab(DECR('v', 'a', 's', 'e', '\0'), 1, 0);
+       emrald = vocab(DECR('e', 'm', 'e', 'r', 'a'), 1, 0);
+       pyram = vocab(DECR('p', 'y', 'r', 'a', 'm'), 1, 0);
+       pearl = vocab(DECR('p', 'e', 'a', 'r', 'l'), 1, 0);
+       rug = vocab(DECR('r', 'u', 'g', '\0', '\0'), 1, 0);
+       chain = vocab(DECR('c', 'h', 'a', 'i', 'n'), 1, 0);
+
+       back = vocab(DECR('b', 'a', 'c', 'k', '\0'), 0, 0);
+       look = vocab(DECR('l', 'o', 'o', 'k', '\0'), 0, 0);
+       cave = vocab(DECR('c', 'a', 'v', 'e', '\0'), 0, 0);
+       null = vocab(DECR('n', 'u', 'l', 'l', '\0'), 0, 0);
+       entrnc = vocab(DECR('e', 'n', 't', 'r', 'a'), 0, 0);
+       dprssn = vocab(DECR('d', 'e', 'p', 'r', 'e'), 0, 0);
+       enter = vocab(DECR('e', 'n', 't', 'e', 'r'), 0, 0);
+
+       pour = vocab(DECR('p', 'o', 'u', 'r', '\0'), 2, 0);
+       say = vocab(DECR('s', 'a', 'y', '\0', '\0'), 2, 0);
+       lock = vocab(DECR('l', 'o', 'c', 'k', '\0'), 2, 0);
+       throw = vocab(DECR('t', 'h', 'r', 'o', 'w'), 2, 0);
+       find = vocab(DECR('f', 'i', 'n', 'd', '\0'), 2, 0);
+       invent = vocab(DECR('i', 'n', 'v', 'e', 'n'), 2, 0);
 
        /* initialize dwarves */
-       chloc=114;
-       chloc2=140;
-       for (i=1; i<=6; i++)
-               dseen[i]=FALSE;
-       dflag=0;
-       dloc[1]=19;
-       dloc[2]=27;
-       dloc[3]=33;
-       dloc[4]=44;
-       dloc[5]=64;
-       dloc[6]=chloc;
-       daltlc=18;
+       chloc = 114;
+       chloc2 = 140;
+       for (i = 1; i <= 6; i++)
+               dseen[i] = FALSE;
+       dflag = 0;
+       dloc[1] = 19;
+       dloc[2] = 27;
+       dloc[3] = 33;
+       dloc[4] = 44;
+       dloc[5] = 64;
+       dloc[6] = chloc;
+       daltlc = 18;
 
        /* random flags & ctrs */
-       turns=0;
-       lmwarn=FALSE;
-       iwest=0;
-       knfloc=0;
-       detail=0;
-       abbnum=5;
-       for (i=0; i<=4; i++)
-               if (rtext[2*i+81].seekadr!=0) maxdie=i+1;
-       numdie=holdng=dkill=foobar=bonus=0;
-       clock1=30;
-       clock2=50;
-       saved=0;
-       closng=panic=closed=scorng=FALSE;
+       turns = 0;
+       lmwarn = FALSE;
+       iwest = 0;
+       knfloc = 0;
+       detail = 0;
+       abbnum = 5;
+       for (i = 0; i <= 4; i++)
+               if (rtext[2 * i + 81].seekadr != 0)
+                       maxdie = i + 1;
+       numdie = holdng = dkill = foobar = bonus = 0;
+       clock1 = 30;
+       clock2 = 50;
+       saved = 0;
+       closng = panic = closed = scorng = FALSE;
 }
 
 
 
 void
-trapdel(n)                              /* come here if he hits a del   */
-       int n;
-{      delhit++;                       /* main checks, treats as QUIT  */
-       signal(SIGINT,trapdel);         /* catch subsequent DELs        */
+trapdel(n)                     /* come here if he hits a del */
+       int     n;
+{
+       delhit++;               /* main checks, treats as QUIT */
+       signal(SIGINT, trapdel);/* catch subsequent DELs */
 }
 
 
 void
 startup()
 {
-       demo=Start(0);
-       srand((int)(time((time_t *)NULL)));     /* random seed */
+       demo = Start(0);
+       srand((int) (time((time_t *) NULL)));   /* random seed */
 #if 0
-       srand(371);                             /* non-random seed */
+       srand(371);             /* non-random seed */
 #endif
-       hinted[3]=yes(65,1,0);
-       newloc=1;
+       hinted[3] = yes(65, 1, 0);
+       newloc = 1;
        delhit = 0;
-       limit=330;
-       if (hinted[3]) limit=1000;      /* better batteries if instrucs */
+       limit = 330;
+       if (hinted[3])
+               limit = 1000;   /* better batteries if instrucs */
 }
index d76e35fb5fe8d3942b34b6730d573f4b28f0eb78..6343d43416ad7db3b484b4dada55c6bd2a21c949 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.5 1997/10/10 11:59:45 lukem Exp $     */
+/*     $NetBSD: io.c,v 1.6 1997/10/11 01:53:29 lukem Exp $     */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,7 +43,7 @@
 #if 0
 static char sccsid[] = "@(#)io.c       8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: io.c,v 1.5 1997/10/10 11:59:45 lukem Exp $");
+__RCSID("$NetBSD: io.c,v 1.6 1997/10/11 01:53:29 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -57,40 +57,41 @@ __RCSID("$NetBSD: io.c,v 1.5 1997/10/10 11:59:45 lukem Exp $");
 
 
 void
-getin(wrd1,wrd2)                        /* get command from user        */
-char **wrd1,**wrd2;                     /* no prompt, usually           */
-{       char *s;
-       static char wd1buf[MAXSTR],wd2buf[MAXSTR];
-       int first, numch;
-
-       *wrd1=wd1buf;                   /* return ptr to internal string*/
-       *wrd2=wd2buf;
-       wd2buf[0]=0;                    /* in case it isn't set here    */
-       for (s=wd1buf, first=1, numch=0;;)
-       {       if ((*s=getchar())>='A' && *s <='Z') *s = *s - ('A' -'a');
-                                       /* convert to upper case        */
-               switch(*s)              /* start reading from user      */
-               {   case '\n':
-                       *s=0;
+getin(wrd1, wrd2)              /* get command from user        */
+       char  **wrd1, **wrd2;   /* no prompt, usually           */
+{
+       char   *s;
+       static char wd1buf[MAXSTR], wd2buf[MAXSTR];
+       int     first, numch;
+
+       *wrd1 = wd1buf;                         /* return ptr to internal str */
+       *wrd2 = wd2buf;
+       wd2buf[0] = 0;                          /* in case it isn't set here */
+       for (s = wd1buf, first = 1, numch = 0;;) {
+               if ((*s = getchar()) >= 'A' && *s <= 'Z')
+                       *s = *s - ('A' - 'a');
+               /* convert to upper case */
+               switch (*s) {                   /* start reading from user */
+               case '\n':
+                       *s = 0;
                        return;
-                   case ' ':
-                       if (s==wd1buf||s==wd2buf)  /* initial blank   */
+               case ' ':
+                       if (s == wd1buf || s == wd2buf) /* initial blank */
                                continue;
-                       *s=0;
-                       if (first)      /* finished 1st wd; start 2nd   */
-                       {       first=numch=0;
-                               s=wd2buf;
+                       *s = 0;
+                       if (first) {            /* finished 1st wd; start 2nd */
+                               first = numch = 0;
+                               s = wd2buf;
                                break;
-                       }
-                       else            /* finished 2nd word            */
-                       {       FLUSHLINE;
-                               *s=0;
+                       } else {                /* finished 2nd word */
+                               FLUSHLINE;
+                               *s = 0;
                                return;
                        }
-                   default:
-                       if (++numch>=MAXSTR)    /* string too long      */
-                       {       printf("Give me a break!!\n");
-                               wd1buf[0]=wd2buf[0]=0;
+               default:
+                       if (++numch >= MAXSTR) {        /* string too long */
+                               printf("Give me a break!!\n");
+                               wd1buf[0] = wd2buf[0] = 0;
                                FLUSHLINE;
                                return;
                        }
@@ -100,441 +101,498 @@ char **wrd1,**wrd2;                     /* no prompt, usually           */
 }
 
 int
-confirm(mesg)                           /* confirm irreversible action  */
-char *mesg;
-{       int result;
-       printf("%s",mesg);              /* tell him what he did         */
-       if (getchar()=='y')             /* was his first letter a 'y'?  */
-               result=1;
-       else    result=0;
+confirm(mesg)                  /* confirm irreversible action  */
+       char   *mesg;
+{
+       int     result;
+       printf("%s", mesg);     /* tell him what he did         */
+       if (getchar() == 'y')   /* was his first letter a 'y'?  */
+               result = 1;
+       else
+               result = 0;
        FLUSHLINE;
-       return(result);
+       return (result);
 }
 
 int
-yes(x,y,z)                              /* confirm with rspeak          */
-int x,y,z;
-{       int result = TRUE;     /* pacify gcc */
-       char ch;
-       for (;;)
-       {       rspeak(x);                     /* tell him what we want*/
-               if ((ch=getchar())=='y')
-                       result=TRUE;
-               else if (ch=='n') result=FALSE;
+yes(x, y, z)                   /* confirm with rspeak          */
+       int     x, y, z;
+{
+       int     result = TRUE;  /* pacify gcc */
+       char    ch;
+       for (;;) {
+               rspeak(x);      /* tell him what we want */
+               if ((ch = getchar()) == 'y')
+                       result = TRUE;
+               else
+                       if (ch == 'n')
+                               result = FALSE;
                FLUSHLINE;
-               if (ch=='y'|| ch=='n') break;
+               if (ch == 'y' || ch == 'n')
+                       break;
                printf("Please answer the question.\n");
        }
-       if (result==TRUE) rspeak(y);
-       if (result==FALSE) rspeak(z);
-       return(result);
+       if (result == TRUE)
+               rspeak(y);
+       if (result == FALSE)
+               rspeak(z);
+       return (result);
 }
 
 int
-yesm(x,y,z)                             /* confirm with mspeak          */
-int x,y,z;
-{       int result = TRUE;     /* pacify gcc */
-       char ch;
-       for (;;)
-       {       mspeak(x);                     /* tell him what we want*/
-               if ((ch=getchar())=='y')
-                       result=TRUE;
-               else if (ch=='n') result=FALSE;
+yesm(x, y, z)                  /* confirm with mspeak          */
+       int     x, y, z;
+{
+       int     result = TRUE;  /* pacify gcc */
+       char    ch;
+       for (;;) {
+               mspeak(x);      /* tell him what we want */
+               if ((ch = getchar()) == 'y')
+                       result = TRUE;
+               else
+                       if (ch == 'n')
+                               result = FALSE;
                FLUSHLINE;
-               if (ch=='y'|| ch=='n') break;
+               if (ch == 'y' || ch == 'n')
+                       break;
                printf("Please answer the question.\n");
        }
-       if (result==TRUE) mspeak(y);
-       if (result==FALSE) mspeak(z);
-       return(result);
+       if (result == TRUE)
+               mspeak(y);
+       if (result == FALSE)
+               mspeak(z);
+       return (result);
 }
-
 /* FILE *inbuf,*outbuf; */
 
-char *inptr;                            /* Pointer into virtual disk    */
+char   *inptr;                 /* Pointer into virtual disk    */
 
-int outsw = 0;                         /* putting stuff to data file?  */
+int     outsw = 0;             /* putting stuff to data file?  */
 
-char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
-char *tape = iotape;                   /* pointer to encryption tape   */
+char    iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
+char   *tape = iotape;         /* pointer to encryption tape   */
 
 int
-next()                                  /* next virtual char, bump adr  */
-{
-       int ch;
-
-       ch=(*inptr ^ random()) & 0xFF;  /* Decrypt input data           */
-       if (outsw)                      /* putting data in tmp file     */
-       {   if (*tape==0) tape=iotape;  /* rewind encryption tape       */
-           *inptr = ch ^ *tape++;      /* re-encrypt and replace value */
+next()
+{                              /* next virtual char, bump adr  */
+       int     ch;
+
+       ch = (*inptr ^ random()) & 0xFF;        /* Decrypt input data           */
+       if (outsw) {            /* putting data in tmp file     */
+               if (*tape == 0)
+                       tape = iotape;  /* rewind encryption tape       */
+               *inptr = ch ^ *tape++;  /* re-encrypt and replace value */
        }
        inptr++;
-       return(ch);
+       return (ch);
 }
 
-char breakch;                           /* tell which char ended rnum   */
+char    breakch;               /* tell which char ended rnum   */
 
 void
-rdata()                                 /* "read" data from virtual file*/
-{       int sect;
-       char ch;
+rdata()
+{                              /* "read" data from virtual file */
+       int     sect;
+       char    ch;
 
-       inptr = data_file;              /* Pointer to virtual data file */
-       srandom(SEED);                  /* which is lightly encrypted.  */
+       inptr = data_file;      /* Pointer to virtual data file */
+       srandom(SEED);          /* which is lightly encrypted.  */
 
-       clsses=1;
-       for (;;)                        /* read data sections           */
-       {       sect=next()-'0';        /* 1st digit of section number  */
+       clsses = 1;
+       for (;;) {              /* read data sections           */
+               sect = next() - '0';    /* 1st digit of section number  */
 #ifdef VERBOSE
-               printf("Section %c",sect+'0');
+               printf("Section %c", sect + '0');
 #endif
-               if ((ch=next())!=LF)    /* is there a second digit?     */
-               {
+               if ((ch = next()) != LF) {      /* is there a second digit?     */
                        FLUSHLF;
 #ifdef VERBOSE
                        putchar(ch);
 #endif
-                       sect=10*sect+ch-'0';
+                       sect = 10 * sect + ch - '0';
                }
 #ifdef VERBOSE
                putchar('\n');
 #endif
-               switch(sect)
-               {   case 0:             /* finished reading database    */
+               switch (sect) {
+               case 0: /* finished reading database    */
                        return;
-                   case 1:             /* long form descriptions       */
+               case 1: /* long form descriptions       */
                        rdesc(1);
                        break;
-                   case 2:             /* short form descriptions      */
+               case 2: /* short form descriptions      */
                        rdesc(2);
                        break;
-                   case 3:             /* travel table                 */
-                       rtrav();   break;
-                   case 4:             /* vocabulary                   */
+               case 3: /* travel table                 */
+                       rtrav();
+                       break;
+               case 4: /* vocabulary                   */
                        rvoc();
                        break;
-                   case 5:             /* object descriptions          */
+               case 5: /* object descriptions          */
                        rdesc(5);
                        break;
-                   case 6:             /* arbitrary messages           */
+               case 6: /* arbitrary messages           */
                        rdesc(6);
                        break;
-                   case 7:             /* object locations             */
-                       rlocs();   break;
-                   case 8:             /* action defaults              */
-                       rdflt();   break;
-                   case 9:             /* liquid assets                */
-                       rliq();    break;
-                   case 10:            /* class messages               */
+               case 7: /* object locations             */
+                       rlocs();
+                       break;
+               case 8: /* action defaults              */
+                       rdflt();
+                       break;
+               case 9: /* liquid assets                */
+                       rliq();
+                       break;
+               case 10:        /* class messages               */
                        rdesc(10);
                        break;
-                   case 11:            /* hints                        */
-                       rhints();  break;
-                   case 12:            /* magic messages               */
+               case 11:        /* hints                        */
+                       rhints();
+                       break;
+               case 12:        /* magic messages               */
                        rdesc(12);
                        break;
-                   default:
-                       printf("Invalid data section number: %d\n",sect);
-                       for (;;) putchar(next());
+               default:
+                       printf("Invalid data section number: %d\n", sect);
+                       for (;;)
+                               putchar(next());
                }
-               if (breakch!=LF)        /* routines return after "-1"   */
+               if (breakch != LF)      /* routines return after "-1"   */
                        FLUSHLF;
        }
 }
 
-char nbf[12];
+char    nbf[12];
 
 
 int
-rnum()                                  /* read initial location num    */
-{       char *s;
-       tape = iotape;                  /* restart encryption tape      */
-       for (s=nbf,*s=0;; s++)
-               if ((*s=next())==TAB || *s=='\n' || *s==LF)
+rnum()
+{                              /* read initial location num    */
+       char   *s;
+       tape = iotape;          /* restart encryption tape      */
+       for (s = nbf, *s = 0;; s++)
+               if ((*s = next()) == TAB || *s == '\n' || *s == LF)
                        break;
-       breakch= *s;                    /* save char for rtrav()        */
-       *s=0;                           /* got the number as ascii      */
-       if (nbf[0]=='-') return(-1);    /* end of data                  */
-       return(atoi(nbf));              /* convert it to integer        */
+       breakch = *s;           /* save char for rtrav()        */
+       *s = 0;                 /* got the number as ascii      */
+       if (nbf[0] == '-')
+               return (-1);    /* end of data                  */
+       return (atoi(nbf));     /* convert it to integer        */
 }
 
-char *seekhere;
+char   *seekhere;
 
 void
-rdesc(sect)                             /* read description-format msgs */
-int sect;
-{      int locc;
-       char *seekstart, *maystart;
-
-       seekhere = inptr;               /* Where are we in virtual file?*/
-       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*/
-               {       switch(sect)    /* now put it into right table  */
-                       {   case 1:     /* long descriptions            */
-                               ltext[oldloc].seekadr=seekhere;
-                               ltext[oldloc].txtlen=maystart-seekstart;
+rdesc(sect)                    /* read description-format msgs */
+       int     sect;
+{
+       int     locc;
+       char   *seekstart, *maystart;
+
+       seekhere = inptr;       /* Where are we in virtual file? */
+       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 */
+                       switch (sect) { /* now put it into right table  */
+                       case 1:/* long descriptions            */
+                               ltext[oldloc].seekadr = seekhere;
+                               ltext[oldloc].txtlen = maystart - seekstart;
                                break;
-                           case 2:     /* short descriptions           */
-                               stext[oldloc].seekadr=seekhere;
-                               stext[oldloc].txtlen=maystart-seekstart;
+                       case 2:/* short descriptions           */
+                               stext[oldloc].seekadr = seekhere;
+                               stext[oldloc].txtlen = maystart - seekstart;
                                break;
-                           case 5:     /* object descriptions          */
-                               ptext[oldloc].seekadr=seekhere;
-                               ptext[oldloc].txtlen=maystart-seekstart;
+                       case 5:/* object descriptions          */
+                               ptext[oldloc].seekadr = seekhere;
+                               ptext[oldloc].txtlen = maystart - seekstart;
                                break;
-                           case 6:     /* random messages              */
-                               if (oldloc>RTXSIZ)
-                               {       printf("Too many random msgs\n");
+                       case 6:/* random messages              */
+                               if (oldloc > RTXSIZ) {
+                                       printf("Too many random msgs\n");
                                        exit(0);
                                }
-                               rtext[oldloc].seekadr=seekhere;
-                               rtext[oldloc].txtlen=maystart-seekstart;
+                               rtext[oldloc].seekadr = seekhere;
+                               rtext[oldloc].txtlen = maystart - seekstart;
                                break;
-                           case 10:    /* class messages               */
-                               ctext[clsses].seekadr=seekhere;
-                               ctext[clsses].txtlen=maystart-seekstart;
-                               cval[clsses++]=oldloc;
+                       case 10:        /* class messages               */
+                               ctext[clsses].seekadr = seekhere;
+                               ctext[clsses].txtlen = maystart - seekstart;
+                               cval[clsses++] = oldloc;
                                break;
-                           case 12:    /* magic messages               */
-                               if (oldloc>MAGSIZ)
-                               {       printf("Too many magic msgs\n");
+                       case 12:        /* magic messages               */
+                               if (oldloc > MAGSIZ) {
+                                       printf("Too many magic msgs\n");
                                        exit(0);
                                }
-                               mtext[oldloc].seekadr=seekhere;
-                               mtext[oldloc].txtlen=maystart-seekstart;
+                               mtext[oldloc].seekadr = seekhere;
+                               mtext[oldloc].txtlen = maystart - seekstart;
                                break;
-                           default:
+                       default:
                                printf("rdesc called with bad section\n");
                                exit(0);
                        }
-                       seekhere += maystart-seekstart;
+                       seekhere += maystart - seekstart;
                }
-               if (locc<0)
-               {       outsw=0;        /* turn off output              */
-                       seekhere += 3;  /* -1<delimiter>                */
+               if (locc < 0) {
+                       outsw = 0;      /* turn off output              */
+                       seekhere += 3;  /* -1<delimiter>                */
                        return;
                }
-               if (sect!=5 || (locc>0 && locc<100))
-               {       if (oldloc!=locc)/* starting a new message       */
-                               seekstart=maystart;
-                       oldloc=locc;
+               if (sect != 5 || (locc > 0 && locc < 100)) {
+                       if (oldloc != locc)     /* starting a new message       */
+                               seekstart = maystart;
+                       oldloc = locc;
                }
-               FLUSHLF;                /* scan the line                */
+               FLUSHLF;        /* scan the line                */
        }
 }
 
 void
-rtrav()                                 /* read travel table            */
-{       int locc;
+rtrav()
+{                              /* read travel table            */
+       int     locc;
        struct travlist *t = NULL;
-       char *s;
-       char buf[12];
-       int len,m,n,entries = 0;
-
-       for (oldloc= -1;;)              /* get another line             */
-       {       if ((locc=rnum())!=oldloc && oldloc>=0) /* end of entry */
-               {
-                       t->next = 0;    /* terminate the old entry      */
-               /*      printf("%d:%d entries\n",oldloc,entries);       */
-               /*      twrite(oldloc);                                 */
+       char   *s;
+       char    buf[12];
+       int     len, m, n, entries = 0;
+
+       for (oldloc = -1;;) {   /* get another line             */
+               if ((locc = rnum()) != oldloc && oldloc >= 0) { /* end of entry */
+                       t->next = 0;    /* terminate the old entry      */
+                       /* printf("%d:%d entries\n",oldloc,entries);       */
+                       /* twrite(oldloc);                                 */
                }
-               if (locc== -1) return;
-               if (locc!=oldloc)        /* getting a new entry         */
-               {       t=travel[locc]=(struct travlist *) malloc(sizeof (struct travlist));
-               /*      printf("New travel list for %d\n",locc);        */
-                       entries=0;
-                       oldloc=locc;
-               }
-               for (s=buf;; s++)      /* get the newloc number /ASCII */
-                       if ((*s=next())==TAB || *s==LF) break;
-               *s=0;
-               len=length(buf)-1;      /* quad long number handling    */
-       /*      printf("Newloc: %s (%d chars)\n",buf,len);              */
-               if (len<4)              /* no "m" conditions            */
-               {       m=0;
-                       n=atoi(buf);    /* newloc mod 1000 = newloc     */
+               if (locc == -1)
+                       return;
+               if (locc != oldloc) {   /* getting a new entry         */
+                       t = travel[locc] = (struct travlist *) malloc(sizeof(struct travlist));
+                       /* printf("New travel list for %d\n",locc);        */
+                       entries = 0;
+                       oldloc = locc;
                }
-               else                    /* a long integer               */
-               {       n=atoi(buf+len-3);
-                       buf[len-3]=0;   /* terminate newloc/1000        */
-                       m=atoi(buf);
+               for (s = buf;; s++)     /* get the newloc number /ASCII */
+                       if ((*s = next()) == TAB || *s == LF)
+                               break;
+               *s = 0;
+               len = length(buf) - 1;  /* quad long number handling    */
+               /* printf("Newloc: %s (%d chars)\n",buf,len);              */
+               if (len < 4) {  /* no "m" conditions            */
+                       m = 0;
+                       n = atoi(buf);  /* newloc mod 1000 = newloc     */
+               } else {        /* a long integer               */
+                       n = atoi(buf + len - 3);
+                       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->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);       */
+               while (breakch != LF) { /* only do one line at a time   */
+                       if (entries++)
+                               t = t->next = (struct travlist *) malloc(sizeof(struct travlist));
+                       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);       */
                }
        }
 }
-
 #ifdef DEBUG
 
 void
-twrite(loq)                             /* travel options from this loc */
-int loq;
-{       struct travlist *t;
+twrite(loq)                    /* travel options from this loc */
+       int     loq;
+{
+       struct travlist *t;
        printf("If");
        speak(&ltext[loq]);
        printf("then\n");
-       for (t=travel[loq]; t!=0; t=t->next)
-       {       printf("verb %d takes you to ",t->tverb);
-               if (t->tloc<=300)
+       for (t = travel[loq]; t != 0; t = t->next) {
+               printf("verb %d takes you to ", t->tverb);
+               if (t->tloc <= 300)
                        speak(&ltext[t->tloc]);
-               else if (t->tloc<=500)
-                       printf("special code %d\n",t->tloc-300);
                else
-                       rspeak(t->tloc-500);
-               printf("under conditions %d\n",t->conditions);
+                       if (t->tloc <= 500)
+                               printf("special code %d\n", t->tloc - 300);
+                       else
+                               rspeak(t->tloc - 500);
+               printf("under conditions %d\n", t->conditions);
        }
 }
-
-#endif /* DEBUG */
+#endif                         /* DEBUG */
 
 void
 rvoc()
-{       char *s;               /* read the vocabulary          */
-       int index;
-       char buf[6];
-       for (;;)
-       {       index=rnum();
-               if (index<0) break;
-               for (s=buf,*s=0;; s++)  /* get the word                 */
-                       if ((*s=next())==TAB || *s=='\n' || *s==LF
-                               || *s==' ') break;
-                       /* terminate word with newline, LF, tab, blank  */
-               if (*s!='\n' && *s!=LF) FLUSHLF;  /* can be comments    */
-               *s=0;
-       /*      printf("\"%s\"=%d\n",buf,index);*/
-               vocab(buf,-2,index);
+{
+       char   *s;              /* read the vocabulary          */
+       int     index;
+       char    buf[6];
+       for (;;) {
+               index = rnum();
+               if (index < 0)
+                       break;
+               for (s = buf, *s = 0;; s++)     /* get the word                 */
+                       if ((*s = next()) == TAB || *s == '\n' || *s == LF
+                           || *s == ' ')
+                               break;
+               /* terminate word with newline, LF, tab, blank  */
+               if (*s != '\n' && *s != LF)
+                       FLUSHLF;/* can be comments    */
+               *s = 0;
+               /* printf("\"%s\"=%d\n",buf,index); */
+               vocab(buf, -2, index);
        }
 /*     prht(); */
 }
 
 
 void
-rlocs()                                 /* initial object locations     */
-{      for (;;)
-       {       if ((obj=rnum())<0) break;
-               plac[obj]=rnum();       /* initial loc for this obj     */
-               if (breakch==TAB)       /* there's another entry        */
-                       fixd[obj]=rnum();
-               else    fixd[obj]=0;
+rlocs()
+{                              /* initial object locations     */
+       for (;;) {
+               if ((obj = rnum()) < 0)
+                       break;
+               plac[obj] = rnum();     /* initial loc for this obj     */
+               if (breakch == TAB)     /* there's another entry        */
+                       fixd[obj] = rnum();
+               else
+                       fixd[obj] = 0;
        }
 }
 
 void
-rdflt()                                 /* default verb messages        */
-{      for (;;)
-       {       if ((verb=rnum())<0) break;
-               actspk[verb]=rnum();
+rdflt()
+{                              /* default verb messages        */
+       for (;;) {
+               if ((verb = rnum()) < 0)
+                       break;
+               actspk[verb] = rnum();
        }
 }
 
 void
-rliq()                                  /* liquid assets &c: cond bits  */
-{       int bitnum;
-       for (;;)                        /* read new bit list            */
-       {       if ((bitnum=rnum())<0) break;
-               for (;;)                /* read locs for bits           */
-               {       cond[rnum()] |= setbit[bitnum];
-                       if (breakch==LF) break;
+rliq()
+{                              /* liquid assets &c: cond bits  */
+       int     bitnum;
+       for (;;) {              /* read new bit list            */
+               if ((bitnum = rnum()) < 0)
+                       break;
+               for (;;) {      /* read locs for bits           */
+                       cond[rnum()] |= setbit[bitnum];
+                       if (breakch == LF)
+                               break;
                }
        }
 }
 
 void
 rhints()
-{       int hintnum,i;
-       hntmax=0;
-       for (;;)
-       {       if ((hintnum=rnum())<0) break;
-               for (i=1; i<5; i++)
-                       hints[hintnum][i]=rnum();
-               if (hintnum>hntmax) hntmax=hintnum;
+{
+       int     hintnum, i;
+       hntmax = 0;
+       for (;;) {
+               if ((hintnum = rnum()) < 0)
+                       break;
+               for (i = 1; i < 5; i++)
+                       hints[hintnum][i] = rnum();
+               if (hintnum > hntmax)
+                       hntmax = hintnum;
        }
 }
 
 
 void
 rspeak(msg)
-int msg;
-{       if (msg!=0) speak(&rtext[msg]);
+       int     msg;
+{
+       if (msg != 0)
+               speak(&rtext[msg]);
 }
 
 
 void
 mspeak(msg)
-int msg;
-{       if (msg!=0) speak(&mtext[msg]);
+       int     msg;
+{
+       if (msg != 0)
+               speak(&mtext[msg]);
 }
 
 
 void
-speak(msg)       /* read, decrypt, and print a message (not ptext)      */
-struct text *msg;/* msg is a pointer to seek address and length of mess */
+speak(msg)                     /* read, decrypt, and print a message (not
+                                * ptext)      */
+       struct text *msg;       /* msg is a pointer to seek address and length
+                                * of mess */
 {
-       char *s, nonfirst;
+       char   *s, nonfirst;
 
        s = msg->seekadr;
-       nonfirst=0;
-       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       */
+       nonfirst = 0;
+       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       */
                /* assume tape is longer than location number           */
-               /*   plus the lookahead put together                    */
+               /* plus the lookahead put together                    */
                if ((*s ^ *tape) == '>' &&
-                       (*(s+1) ^ *(tape+1)) == '$' &&
-                       (*(s+2) ^ *(tape+2)) == '<') break;
-               if (blklin && !nonfirst++) putchar('\n');
-               do
-               {       if (*tape == 0) tape = iotape;/* rewind decryp tape */
+                   (*(s + 1) ^ *(tape + 1)) == '$' &&
+                   (*(s + 2) ^ *(tape + 2)) == '<')
+                       break;
+               if (blklin && !nonfirst++)
+                       putchar('\n');
+               do {
+                       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   */
        }
 }
 
 
 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(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 */
 {
-       char *s,nonfirst;
-       char *numst, save;
+       char   *s, nonfirst;
+       char   *numst, save;
        struct text *msg;
-       char *tbuf;
+       char   *tbuf;
 
        msg = &ptext[m];
-       if ((tbuf=(char *) malloc(msg->txtlen + 1)) == 0) bug(108);
-       memcpy(tbuf, msg->seekadr, msg->txtlen + 1);   /* Room to null */
+       if ((tbuf = (char *) malloc(msg->txtlen + 1)) == 0)
+               bug(108);
+       memcpy(tbuf, msg->seekadr, msg->txtlen + 1);    /* Room to null */
        s = tbuf;
 
-       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  */
+       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  */
 
-               save = *s; /* Temporarily trash the string (cringe) */
-               *s++ = 0; /* decrypting number within the string          */
+               save = *s;      /* 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    */
-                               if (*tape==0) tape=iotape;
+               if (atoi(numst) != 100 * skip && skip >= 0) {
+                       while ((*s++ ^ *tape++) != LF)  /* flush the line    */
+                               if (*tape == 0)
+                                       tape = iotape;
                        continue;
                }
-               if ((*s^*tape)=='>' && (*(s+1)^*(tape+1))=='$' &&
-                       (*(s+2)^*(tape+2))=='<') break;
-               if (blklin && ! nonfirst++) putchar('\n');
-               do
-               {       if (*tape==0) tape=iotape;
-                       putchar(*s^*tape);
-               } while ((*s++^*tape++)!=LF);   /* better end with LF   */
-               if (skip<0) break;
+               if ((*s ^ *tape) == '>' && (*(s + 1) ^ *(tape + 1)) == '$' &&
+                   (*(s + 2) ^ *(tape + 2)) == '<')
+                       break;
+               if (blklin && !nonfirst++)
+                       putchar('\n');
+               do {
+                       if (*tape == 0)
+                               tape = iotape;
+                       putchar(*s ^ *tape);
+               } while ((*s++ ^ *tape++) != LF);       /* better end with LF   */
+               if (skip < 0)
+                       break;
        }
        free(tbuf);
 }
index a9e83b70218f75cfb9af2da2ede1ba4d9b4d8e38..c8a8108c6cd3e0e47ff641477f2c4a240c286c94 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.7 1997/10/10 11:59:49 lukem Exp $   */
+/*     $NetBSD: main.c,v 1.8 1997/10/11 01:53:31 lukem Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -48,13 +48,14 @@ __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.7 1997/10/10 11:59:49 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.8 1997/10/11 01:53:31 lukem Exp $");
 #endif
 #endif /* not lint */
 
-/*      Re-coding of advent in C: main program                          */
+/*      Re-coding of advent in C: main program */
 
 #include <sys/file.h>
+#include <err.h>
 #include <signal.h>
 #include <stdio.h>
 #include <unistd.h>
@@ -62,543 +63,710 @@ __RCSID("$NetBSD: main.c,v 1.7 1997/10/10 11:59:49 lukem Exp $");
 #include "extern.h"
 
 int
-main(argc,argv)
-int argc;
-char **argv;
+main(argc, argv)
+       int     argc;
+       char  **argv;
 {
-       int i;
-       int rval,ll;
+       int     i;
+       int     rval, ll;
        struct text *kk;
 
        /* adventure doesn't need setuid-ness, so, just get rid of it */
        if (setuid(getuid()) < 0)
-               perror("setuid");
+               warn("setuid");
 
-       init(NULL);         /* Initialize everything */
-       signal(SIGINT,trapdel);
+       init(NULL);             /* Initialize everything */
+       signal(SIGINT, trapdel);
 
-       if (argc > 1)   /* Restore file specified */
-       {               /* Restart is label 8305 (Fortran) */
-               i = restore(argv[1]);       /* See what we've got */
-               switch(i)
-               {
-                   case 0:     /* The restore worked fine */
-                       yea=Start(0);
-                       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 */
-                   case 2:             /* Oops -- file was altered */
-                       rspeak(202);    /* You dissolve */
-                       exit(0);        /* File could be non-adventure */
-               }                       /* So don't unlink it. */
+       if (argc > 1) {         /* Restore file specified */
+                               /* Restart is label 8305 (Fortran) */
+               i = restore(argv[1]);   /* See what we've got */
+               switch (i) {
+               case 0: /* The restore worked fine */
+                       yea = Start(0);
+                       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 */
+               case 2:                         /* Oops -- file was altered */
+                       rspeak(202);            /* You dissolve */
+                       exit(0);        /* File could be non-adventure */
+               }                       /* So don't unlink it. */
        }
+       startup();                      /* prepare for a user */
 
-       startup();              /* prepare for a user           */
-
-       for (;;)                        /* main command loop (label 2)  */
-       {       if (newloc<9 && newloc!=0 && closng)
-               {       rspeak(130);    /* if closing leave only by     */
-                       newloc=loc;     /*      main office             */
-                       if (!panic) clock2=15;
-                       panic=TRUE;
+       for (;;) {                      /* main command loop (label 2) */
+               if (newloc < 9 && newloc != 0 && closng) {
+                       rspeak(130);    /* if closing leave only by */
+                       newloc = loc;   /* main office */
+                       if (!panic)
+                               clock2 = 15;
+                       panic = TRUE;
                }
+               rval = fdwarf();        /* dwarf stuff */
+               if (rval == 99)
+                       die(99);
 
-               rval=fdwarf();          /* dwarf stuff                  */
-               if (rval==99) die(99);
-
-       l2000:  if (loc==0) die(99);    /* label 2000                   */
+l2000:         if (loc == 0)
+                       die(99);        /* label 2000 */
                kk = &stext[loc];
-               if ((abb[loc]%abbnum)==0 || kk->seekadr==0)
+               if ((abb[loc] % abbnum) == 0 || kk->seekadr == 0)
                        kk = &ltext[loc];
-               if (!forced(loc) && dark(0))
-               {       if (wzdark && pct(35))
-                       {       die(90);
+               if (!forced(loc) && dark(0)) {
+                       if (wzdark && pct(35)) {
+                               die(90);
                                goto l2000;
                        }
                        kk = &rtext[16];
                }
 #if 0
-       l2001:
+l2001:
 #endif
-               if (toting(bear)) rspeak(141);  /* 2001                 */
+               if (toting(bear))
+                       rspeak(141);    /* 2001 */
                speak(kk);
-               k=1;
+               k = 1;
                if (forced(loc))
                        goto l8;
-               if (loc==33 && pct(25)&&!closng) rspeak(8);
-               if (!dark(0))
-               {       abb[loc]++;
-                       for (i=atloc[loc]; i!=0; i=links[i])     /*2004  */
-                       {       obj=i;
-                               if (obj>100) obj -= 100;
-                               if (obj==steps && toting(nugget)) continue;
-                               if (prop[obj]<0)
-                               {       if (closed) continue;
-                                       prop[obj]=0;
-                                       if (obj==rug||obj==chain)
-                                               prop[obj]=1;
+               if (loc == 33 && pct(25) && !closng)
+                       rspeak(8);
+               if (!dark(0)) {
+                       abb[loc]++;
+                       for (i = atloc[loc]; i != 0; i = links[i]) { /* 2004 */
+                               obj = i;
+                               if (obj > 100)
+                                       obj -= 100;
+                               if (obj == steps && toting(nugget))
+                                       continue;
+                               if (prop[obj] < 0) {
+                                       if (closed)
+                                               continue;
+                                       prop[obj] = 0;
+                                       if (obj == rug || obj == chain)
+                                               prop[obj] = 1;
                                        tally--;
-                                       if (tally==tally2 && tally != 0)
-                                               if (limit>35) limit=35;
+                                       if (tally == tally2 && tally != 0)
+                                               if (limit > 35)
+                                                       limit = 35;
                                }
-                               ll =  prop[obj];   /* 2006         */
-                               if (obj==steps && loc==fixed[steps])
+                               ll = prop[obj]; /* 2006 */
+                               if (obj == steps && loc == fixed[steps])
                                        ll = 1;
                                pspeak(obj, ll);
-                       }                                       /* 2008 */
+                       }       /* 2008 */
                        goto l2012;
-       l2009:          k=54;                   /* 2009                 */
-       l2010:          spk=k;
-       l2011:          rspeak(spk);
+       l2009:          k = 54; /* 2009 */
+       l2010:          spk = k;
+       l2011:          rspeak(spk);
                }
-       l2012:  verb=0;                         /* 2012                 */
-               obj=0;
-       l2600:  checkhints();                   /* to 2600-2602         */
-               if (closed)
-               {       if (prop[oyster]<0 && toting(oyster))
-                               pspeak(oyster,1);
-                       for (i=1; i<100; i++)
-                               if (toting(i)&&prop[i]<0)       /*2604  */
-                                       prop[i] = -1-prop[i];
+l2012:         verb = 0;       /* 2012 */
+               obj = 0;
+l2600:         checkhints();   /* to 2600-2602 */
+               if (closed) {
+                       if (prop[oyster] < 0 && toting(oyster))
+                               pspeak(oyster, 1);
+                       for (i = 1; i < 100; i++)
+                               if (toting(i) && prop[i] < 0)   /* 2604 */
+                                       prop[i] = -1 - prop[i];
                }
-               wzdark=dark(0);                 /* 2605                 */
-               if (knfloc>0 && knfloc!=loc) knfloc=1;
-               getin(&wd1,&wd2);
-               if (delhit)                     /* user typed a DEL     */
-               {       delhit=0;               /* reset counter        */
-                       copystr("quit",wd1);    /* pretend he's quitting*/
-                       *wd2=0;
+               wzdark = dark(0);       /* 2605 */
+               if (knfloc > 0 && knfloc != loc)
+                       knfloc = 1;
+               getin(&wd1, &wd2);
+               if (delhit) {   /* user typed a DEL */
+                       delhit = 0;     /* reset counter */
+                       copystr("quit", wd1);   /* pretend he's quitting */
+                       *wd2 = 0;
                }
-       l2608:  if ((foobar = -foobar)>0) foobar=0;     /* 2608         */
-               /* should check here for "magic mode"                   */
+l2608:         if ((foobar = -foobar) > 0)
+                       foobar = 0;     /* 2608 */
+               /* should check here for "magic mode" */
                turns++;
-               if (demo && turns>=SHORT) done(1);      /* to 13000     */
+               if (demo && turns >= SHORT)
+                       done(1);        /* to 13000 */
 
-               if (verb==say && *wd2!=0) verb=0;
-               if (verb==say)
+               if (verb == say && *wd2 != 0)
+                       verb = 0;
+               if (verb == say)
                        goto l4090;
-               if (tally==0 && loc>=15 && loc!=33) clock1--;
-               if (clock1==0)
-               {       closing();                      /* to 10000     */
+               if (tally == 0 && loc >= 15 && loc != 33)
+                       clock1--;
+               if (clock1 == 0) {
+                       closing();      /* to 10000 */
                        goto l19999;
                }
-               if (clock1<0) clock2--;
-               if (clock2==0)
-               {       caveclose();            /* to 11000             */
-                       continue;               /* back to 2            */
+               if (clock1 < 0)
+                       clock2--;
+               if (clock2 == 0) {
+                       caveclose();    /* to 11000 */
+                       continue;       /* back to 2 */
                }
-               if (prop[lamp]==1) limit--;
-               if (limit<=30 && here(batter) && prop[batter]==0
-                       && here(lamp))
-               {       rspeak(188);            /* 12000                */
-                       prop[batter]=1;
-                       if (toting(batter)) drop(batter,loc);
-                       limit=limit+2500;
-                       lmwarn=FALSE;
+               if (prop[lamp] == 1)
+                       limit--;
+               if (limit <= 30 && here(batter) && prop[batter] == 0
+                   && here(lamp)) {
+                       rspeak(188);    /* 12000 */
+                       prop[batter] = 1;
+                       if (toting(batter))
+                               drop(batter, loc);
+                       limit = limit + 2500;
+                       lmwarn = FALSE;
                        goto l19999;
                }
-               if (limit==0)
-               {       limit = -1;             /* 12400                */
-                       prop[lamp]=0;
+               if (limit == 0) {
+                       limit = -1;     /* 12400 */
+                       prop[lamp] = 0;
                        rspeak(184);
                        goto l19999;
                }
-               if (limit<0&&loc<=8)
-               {       rspeak(185);            /* 12600                */
-                       gaveup=TRUE;
-                       done(2);                /* to 20000             */
+               if (limit < 0 && loc <= 8) {
+                       rspeak(185);    /* 12600 */
+                       gaveup = TRUE;
+                       done(2);        /* to 20000 */
                }
-               if (limit<=30)
-               {       if (lmwarn|| !here(lamp)) goto l19999;  /*12200*/
-                       lmwarn=TRUE;
-                       spk=187;
-                       if (place[batter]==0) spk=183;
-                       if (prop[batter]==1) spk=189;
+               if (limit <= 30) {
+                       if (lmwarn || !here(lamp))
+                               goto l19999;    /* 12200 */
+                       lmwarn = TRUE;
+                       spk = 187;
+                       if (place[batter] == 0)
+                               spk = 183;
+                       if (prop[batter] == 1)
+                               spk = 189;
                        rspeak(spk);
                }
-       l19999: k=43;
-               if (liqloc(loc)==water) k=70;
-               if (weq(wd1,"enter") &&
-                   (weq(wd2,"strea")||weq(wd2,"water")))
+l19999:        k = 43;
+               if (liqloc(loc) == water)
+                       k = 70;
+               if (weq(wd1, "enter") &&
+                   (weq(wd2, "strea") || weq(wd2, "water")))
                        goto l2010;
-               if (weq(wd1,"enter") && *wd2!=0) goto l2800;
-               if ((!weq(wd1,"water")&&!weq(wd1,"oil"))
-                   || (!weq(wd2,"plant")&&!weq(wd2,"door")))
+               if (weq(wd1, "enter") && *wd2 != 0)
+                       goto l2800;
+               if ((!weq(wd1, "water") && !weq(wd1, "oil"))
+                   || (!weq(wd2, "plant") && !weq(wd2, "door")))
                        goto l2610;
-               if (at(vocab(wd2,1,0))) copystr("pour",wd2);
+               if (at(vocab(wd2, 1, 0)))
+                       copystr("pour", wd2);
 
-       l2610:  if (weq(wd1,"west"))
-                       if (++iwest==10) rspeak(17);
-       l2630:  i=vocab(wd1,-1,0);
-               if (i== -1)
-               {       spk=60;                 /* 3000         */
-                       if (pct(20)) spk=61;
-                       if (pct(20)) spk=13;
+l2610:         if (weq(wd1, "west"))
+                       if (++iwest == 10)
+                               rspeak(17);
+l2630:         i = vocab(wd1, -1, 0);
+               if (i == -1) {
+                       spk = 60;       /* 3000 */
+                       if (pct(20))
+                               spk = 61;
+                       if (pct(20))
+                               spk = 13;
                        rspeak(spk);
                        goto l2600;
                }
-               k=i%1000;
-               kq=i/1000+1;
-               switch(kq)
-               {   case 1: goto l8;
-                   case 2: goto l5000;
-                   case 3: goto l4000;
-                   case 4: goto l2010;
-                   default:
+               k = i % 1000;
+               kq = i / 1000 + 1;
+               switch (kq) {
+               case 1:
+                       goto l8;
+               case 2:
+                       goto l5000;
+               case 3:
+                       goto l4000;
+               case 4:
+                       goto l2010;
+               default:
                        printf("Error 22\n");
                        exit(0);
                }
 
-       l8:
-               switch(march())
-               {   case 2: continue;           /* i.e. goto l2         */
-                   case 99:
-                       switch(die(99))
-                       {   case 2000: goto l2000;
-                           default: bug(111);
+l8:
+               switch (march()) {
+               case 2:
+                       continue;       /* i.e. goto l2 */
+               case 99:
+                       switch (die(99)) {
+                       case 2000:
+                               goto l2000;
+                       default:
+                               bug(111);
                        }
-                   default: bug(110);
+               default:
+                       bug(110);
                }
 
-       l2800:  copystr(wd2,wd1);
-               *wd2=0;
+l2800:         copystr(wd2, wd1);
+               *wd2 = 0;
                goto l2610;
 
-       l4000:  verb=k;
-               spk=actspk[verb];
-               if (*wd2!=0 && verb!=say) goto l2800;
-               if (verb==say) obj= *wd2;
-               if (obj!=0) goto l4090;
+l4000:         verb = k;
+               spk = actspk[verb];
+               if (*wd2 != 0 && verb != say)
+                       goto l2800;
+               if (verb == say)
+                       obj = *wd2;
+               if (obj != 0)
+                       goto l4090;
 #if 0
-       l4080:
+l4080:
 #endif
-               switch(verb)
-               {   case 1:                     /* take = 8010          */
-                       if (atloc[loc]==0||links[atloc[loc]]!=0) goto l8000;
-                       for (i=1; i<=5; i++)
-                               if (dloc[i]==loc&&dflag>=2) goto l8000;
-                       obj=atloc[loc];
+               switch (verb) {
+               case 1: /* take = 8010 */
+                       if (atloc[loc] == 0 || links[atloc[loc]] != 0)
+                               goto l8000;
+                       for (i = 1; i <= 5; i++)
+                               if (dloc[i] == loc && dflag >= 2)
+                                       goto l8000;
+                       obj = atloc[loc];
                        goto l9010;
-                   case 2: case 3: case 9:     /* 8000 : drop,say,wave */
-                   case 10: case 16: case 17:  /* calm,rub,toss        */
-                   case 19: case 21: case 28:  /* find,feed,break      */
-                   case 29:                    /* wake                 */
-               l8000:  printf("%s what?\n",wd1);
-                       obj=0;
+               case 2:
+               case 3:
+               case 9: /* 8000 : drop,say,wave */
+               case 10:
+               case 16:
+               case 17:        /* calm,rub,toss */
+               case 19:
+               case 21:
+               case 28:        /* find,feed,break */
+               case 29:        /* wake */
+       l8000:          printf("%s what?\n", wd1);
+                       obj = 0;
                        goto l2600;
-                   case 4: case 6:             /* 8040 open,lock       */
-                       spk=28;
-                       if (here(clam)) obj=clam;
-                       if (here(oyster)) obj=oyster;
-                       if (at(door)) obj=door;
-                       if (at(grate)) obj=grate;
-                       if (obj!=0 && here(chain)) goto l8000;
-                       if (here(chain)) obj=chain;
-                       if (obj==0) goto l2011;
+               case 4:
+               case 6: /* 8040 open,lock */
+                       spk = 28;
+                       if (here(clam))
+                               obj = clam;
+                       if (here(oyster))
+                               obj = oyster;
+                       if (at(door))
+                               obj = door;
+                       if (at(grate))
+                               obj = grate;
+                       if (obj != 0 && here(chain))
+                               goto l8000;
+                       if (here(chain))
+                               obj = chain;
+                       if (obj == 0)
+                               goto l2011;
                        goto l9040;
-                   case 5: goto l2009;         /* nothing              */
-                   case 7: goto l9070;         /* on                   */
-                   case 8: goto l9080;         /* off                  */
-                   case 11: goto l8000;        /* walk                 */
-                   case 12: goto l9120;        /* kill                 */
-                   case 13: goto l9130;        /* pour                 */
-                   case 14:                    /* eat: 8140            */
-                       if (!here(food)) goto l8000;
-               l8142:  dstroy(food);
-                       spk=72;
+               case 5:
+                       goto l2009;     /* nothing */
+               case 7:
+                       goto l9070;     /* on */
+               case 8:
+                       goto l9080;     /* off */
+               case 11:
+                       goto l8000;     /* walk */
+               case 12:
+                       goto l9120;     /* kill */
+               case 13:
+                       goto l9130;     /* pour */
+               case 14:                /* eat: 8140 */
+                       if (!here(food))
+                               goto l8000;
+       l8142:          dstroy(food);
+                       spk = 72;
                        goto l2011;
-                   case 15: goto l9150;        /* drink                */
-                   case 18:                    /* quit: 8180           */
-                       gaveup=yes(22,54,54);
-                       if (gaveup) done(2);    /* 8185                 */
+               case 15:
+                       goto l9150;     /* drink */
+               case 18:                /* quit: 8180 */
+                       gaveup = yes(22, 54, 54);
+                       if (gaveup)
+                               done(2);        /* 8185 */
                        goto l2012;
-                   case 20:                    /* invent=8200          */
-                       spk=98;
-                       for (i=1; i<=100; i++)
-                       {       if (i!=bear && toting(i))
-                               {       if (spk==98) rspeak(99);
-                                       blklin=FALSE;
-                                       pspeak(i,-1);
-                                       blklin=TRUE;
-                                       spk=0;
+               case 20:        /* invent=8200 */
+                       spk = 98;
+                       for (i = 1; i <= 100; i++) {
+                               if (i != bear && toting(i)) {
+                                       if (spk == 98)
+                                               rspeak(99);
+                                       blklin = FALSE;
+                                       pspeak(i, -1);
+                                       blklin = TRUE;
+                                       spk = 0;
                                }
                        }
-                       if (toting(bear)) spk=141;
+                       if (toting(bear))
+                               spk = 141;
                        goto l2011;
-                   case 22: goto l9220;        /* fill                 */
-                   case 23: goto l9230;        /* blast                */
-                   case 24:                    /* score: 8240          */
-                       scorng=TRUE;
+               case 22:
+                       goto l9220;     /* fill */
+               case 23:
+                       goto l9230;     /* blast */
+               case 24:                /* score: 8240 */
+                       scorng = TRUE;
                        printf("If you were to quit now, you would score");
-                       printf(" %d out of a possible ",score());
-                       printf("%d.",mxscor);
-                       scorng=FALSE;
-                       gaveup=yes(143,54,54);
-                       if (gaveup) done(2);
+                       printf(" %d out of a possible ", score());
+                       printf("%d.", mxscor);
+                       scorng = FALSE;
+                       gaveup = yes(143, 54, 54);
+                       if (gaveup)
+                               done(2);
                        goto l2012;
-                   case 25:                    /* foo: 8250            */
-                       k=vocab(wd1,3,0);
-                       spk=42;
-                       if (foobar==1-k) goto l8252;
-                       if (foobar!=0) spk=151;
+               case 25:        /* foo: 8250 */
+                       k = vocab(wd1, 3, 0);
+                       spk = 42;
+                       if (foobar == 1 - k)
+                               goto l8252;
+                       if (foobar != 0)
+                               spk = 151;
                        goto l2011;
-               l8252:  foobar=k;
-                       if (k!=4) goto l2009;
-                       foobar=0;
-                       if (place[eggs]==plac[eggs]
-                               ||(toting(eggs)&&loc==plac[eggs])) goto l2011;
-                       if (place[eggs]==0&&place[troll]==0&&prop[troll]==0)
-                               prop[troll]=1;
-                       k=2;
-                       if (here(eggs)) k=1;
-                       if (loc==plac[eggs]) k=0;
-                       move(eggs,plac[eggs]);
-                       pspeak(eggs,k);
+       l8252:          foobar = k;
+                       if (k != 4)
+                               goto l2009;
+                       foobar = 0;
+                       if (place[eggs] == plac[eggs]
+                           || (toting(eggs) && loc == plac[eggs]))
+                               goto l2011;
+                       if (place[eggs] == 0 && place[troll] == 0 && prop[troll] == 0)
+                               prop[troll] = 1;
+                       k = 2;
+                       if (here(eggs))
+                               k = 1;
+                       if (loc == plac[eggs])
+                               k = 0;
+                       move(eggs, plac[eggs]);
+                       pspeak(eggs, k);
                        goto l2012;
-                   case 26:                    /* brief=8260           */
-                       spk=156;
-                       abbnum=10000;
-                       detail=3;
+               case 26:        /* brief=8260 */
+                       spk = 156;
+                       abbnum = 10000;
+                       detail = 3;
                        goto l2011;
-                   case 27:                    /* read=8270            */
-                       if (here(magzin)) obj=magzin;
-                       if (here(tablet)) obj=obj*100+tablet;
-                       if (here(messag)) obj=obj*100+messag;
-                       if (closed&&toting(oyster)) obj=oyster;
-                       if (obj>100||obj==0||dark(0)) goto l8000;
+               case 27:        /* read=8270 */
+                       if (here(magzin))
+                               obj = magzin;
+                       if (here(tablet))
+                               obj = obj * 100 + tablet;
+                       if (here(messag))
+                               obj = obj * 100 + messag;
+                       if (closed && toting(oyster))
+                               obj = oyster;
+                       if (obj > 100 || obj == 0 || dark(0))
+                               goto l8000;
                        goto l9270;
-                   case 30:                    /* suspend=8300         */
-                       spk=201;
-                       if (demo) goto l2011;
+               case 30:        /* suspend=8300 */
+                       spk = 201;
+                       if (demo)
+                               goto l2011;
                        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);
-                       if (!yes(200,54,54)) goto l2012;
-                       datime(&saved,&savet);
-                       ciao(argv[0]);          /* Do we quit? */
-                       continue;               /* Maybe not */
-                   case 31:                    /* hours=8310           */
+                       printf(" %d minutes before continuing.", latncy);
+                       if (!yes(200, 54, 54))
+                               goto l2012;
+                       datime(&saved, &savet);
+                       ciao(argv[0]);  /* Do we quit? */
+                       continue;       /* Maybe not */
+               case 31:        /* hours=8310 */
                        printf("Colossal cave is closed 9am-5pm Mon ");
                        printf("through Fri except holidays.\n");
                        goto l2012;
-                   default: bug(23);
+               default:
+                       bug(23);
                }
 
-       l4090:
-               switch(verb)
-               {   case 1:                     /* take = 9010          */
-       l9010:          switch(trtake())
-                       {   case 2011: goto l2011;
-                           case 9220: goto l9220;
-                           case 2009: goto l2009;
-                           case 2012: goto l2012;
-                           default: bug(102);
+l4090:
+               switch (verb) {
+               case 1: /* take = 9010 */
+       l9010:          switch (trtake()) {
+                       case 2011:
+                               goto l2011;
+                       case 9220:
+                               goto l9220;
+                       case 2009:
+                               goto l2009;
+                       case 2012:
+                               goto l2012;
+                       default:
+                               bug(102);
                        }
-       l9020:      case 2:                     /* drop = 9020          */
-                       switch(trdrop())
-                       {   case 2011: goto l2011;
-                           case 19000: done(3);
-                           case 2012: goto l2012;
-                           default: bug(105);
+               l9020: case 2:  /* drop = 9020 */
+                       switch (trdrop()) {
+                       case 2011:
+                               goto l2011;
+                       case 19000:
+                               done(3);
+                       case 2012:
+                               goto l2012;
+                       default:
+                               bug(105);
                        }
 #if 0
        l9030:
 #endif
-                   case 3:
-                       switch(trsay())
-                       {   case 2012: goto l2012;
-                           case 2630: goto l2630;
-                           default: bug(107);
+               case 3:
+                       switch (trsay()) {
+                       case 2012:
+                               goto l2012;
+                       case 2630:
+                               goto l2630;
+                       default:
+                               bug(107);
                        }
-       l9040:      case 4:  case 6:            /* open, close          */
-                       switch(tropen())
-                       {   case 2011: goto l2011;
-                           case 2010: goto l2010;
-                           default: bug(106);
+               l9040: case 4:
+               case 6: /* open, close */
+                       switch (tropen()) {
+                       case 2011:
+                               goto l2011;
+                       case 2010:
+                               goto l2010;
+                       default:
+                               bug(106);
                        }
-                   case 5: goto l2009;         /* nothing              */
-                   case 7:                     /* on   9070            */
-       l9070:          if (!here(lamp))  goto l2011;
-                       spk=184;
-                       if (limit<0) goto l2011;
-                       prop[lamp]=1;
+               case 5:
+                       goto l2009;     /* nothing */
+               case 7:                 /* on   9070 */
+       l9070:          if (!here(lamp))
+                               goto l2011;
+                       spk = 184;
+                       if (limit < 0)
+                               goto l2011;
+                       prop[lamp] = 1;
                        rspeak(39);
-                       if (wzdark) goto l2000;
+                       if (wzdark)
+                               goto l2000;
                        goto l2012;
 
-                   case 8:                     /* off                  */
-       l9080:          if (!here(lamp)) goto l2011;
-                       prop[lamp]=0;
+               case 8:         /* off */
+       l9080:          if (!here(lamp))
+                               goto l2011;
+                       prop[lamp] = 0;
                        rspeak(40);
-                       if (dark(0)) rspeak(16);
+                       if (dark(0))
+                               rspeak(16);
                        goto l2012;
 
-                   case 9:                     /* wave                 */
-                       if ((!toting(obj))&&(obj!=rod||!toting(rod2)))
-                               spk=29;
-                       if (obj!=rod||!at(fissur)||!toting(obj)||closng)
+               case 9: /* wave */
+                       if ((!toting(obj)) && (obj != rod || !toting(rod2)))
+                               spk = 29;
+                       if (obj != rod || !at(fissur) || !toting(obj) || closng)
                                goto l2011;
-                       prop[fissur]=1-prop[fissur];
-                       pspeak(fissur,2-prop[fissur]);
+                       prop[fissur] = 1 - prop[fissur];
+                       pspeak(fissur, 2 - prop[fissur]);
                        goto l2012;
-                   case 10: case 11: case 18:  /* calm, walk, quit     */
-                   case 24: case 25: case 26:  /* score, foo, brief    */
-                   case 30: case 31:           /* suspend, hours       */
-                            goto l2011;
-       l9120:      case 12:                    /* kill                 */
-                       switch(trkill())
-                       {   case 8000: goto l8000;
-                           case 8: goto l8;
-                           case 2011: goto l2011;
-                           case 2608: goto l2608;
-                           case 19000: done(3);
-                           default: bug(112);
+               case 10:
+               case 11:
+               case 18:        /* calm, walk, quit */
+               case 24:
+               case 25:
+               case 26:        /* score, foo, brief */
+               case 30:
+               case 31:        /* suspend, hours */
+                       goto l2011;
+               l9120: case 12:/* kill */
+                       switch (trkill()) {
+                       case 8000:
+                               goto l8000;
+                       case 8:
+                               goto l8;
+                       case 2011:
+                               goto l2011;
+                       case 2608:
+                               goto l2608;
+                       case 19000:
+                               done(3);
+                       default:
+                               bug(112);
                        }
-       l9130:      case 13:                    /* pour                 */
-                       if (obj==bottle||obj==0) obj=liq(0);
-                       if (obj==0) goto l8000;
-                       if (!toting(obj)) goto l2011;
-                       spk=78;
-                       if (obj!=oil&&obj!=water) goto l2011;
-                       prop[bottle]=1;
-                       place[obj]=0;
-                       spk=77;
-                       if (!(at(plant)||at(door))) goto l2011;
-                       if (at(door))
-                       {       prop[door]=0;   /* 9132                 */
-                               if (obj==oil) prop[door]=1;
-                               spk=113+prop[door];
+               l9130: case 13:/* pour */
+                       if (obj == bottle || obj == 0)
+                               obj = liq(0);
+                       if (obj == 0)
+                               goto l8000;
+                       if (!toting(obj))
+                               goto l2011;
+                       spk = 78;
+                       if (obj != oil && obj != water)
+                               goto l2011;
+                       prop[bottle] = 1;
+                       place[obj] = 0;
+                       spk = 77;
+                       if (!(at(plant) || at(door)))
+                               goto l2011;
+                       if (at(door)) {
+                               prop[door] = 0; /* 9132 */
+                               if (obj == oil)
+                                       prop[door] = 1;
+                               spk = 113 + prop[door];
                                goto l2011;
                        }
-                       spk=112;
-                       if (obj!=water) goto l2011;
-                       pspeak(plant,prop[plant]+1);
-                       prop[plant]=(prop[plant]+2)% 6;
-                       prop[plant2]=prop[plant]/2;
-                       k=null;
+                       spk = 112;
+                       if (obj != water)
+                               goto l2011;
+                       pspeak(plant, prop[plant] + 1);
+                       prop[plant] = (prop[plant] + 2) % 6;
+                       prop[plant2] = prop[plant] / 2;
+                       k = null;
                        goto l8;
-                   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) spk=71;
+               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)
+                               spk = 71;
                        goto l2011;
-       l9150:      case 15:                    /* 9150 - drink         */
-                       if (obj==0&&liqloc(loc)!=water&&(liq(0)!=water
-                               ||!here(bottle))) goto l8000;
-                       if (obj!=0&&obj!=water) spk=110;
-                       if (spk==110||liq(0)!=water||!here(bottle))
+               l9150: case 15:/* 9150 - drink */
+                       if (obj == 0 && liqloc(loc) != water && (liq(0) != water
+                               || !here(bottle)))
+                               goto l8000;
+                       if (obj != 0 && obj != water)
+                               spk = 110;
+                       if (spk == 110 || liq(0) != water || !here(bottle))
                                goto l2011;
-                       prop[bottle]=1;
-                       place[water]=0;
-                       spk=74;
+                       prop[bottle] = 1;
+                       place[water] = 0;
+                       spk = 74;
                        goto l2011;
-                   case 16:                    /* 9160: rub            */
-                       if (obj!=lamp) spk=76;
+               case 16:        /* 9160: rub */
+                       if (obj != lamp)
+                               spk = 76;
                        goto l2011;
-                   case 17:                    /* 9170: throw          */
-                       switch(trtoss())
-                       {   case 2011: goto l2011;
-                           case 9020: goto l9020;
-                           case 9120: goto l9120;
-                           case 8: goto l8;
-                           case 9210: goto l9210;
-                           default: bug(113);
+               case 17:        /* 9170: throw */
+                       switch (trtoss()) {
+                       case 2011:
+                               goto l2011;
+                       case 9020:
+                               goto l9020;
+                       case 9120:
+                               goto l9120;
+                       case 8:
+                               goto l8;
+                       case 9210:
+                               goto l9210;
+                       default:
+                               bug(113);
                        }
-                   case 19: case 20:           /* 9190: find, invent   */
-                       if (at(obj)||(liq(0)==obj&&at(bottle))
-                               ||k==liqloc(loc)) spk=94;
-                       for (i=1; i<=5; i++)
-                               if (dloc[i]==loc&&dflag>=2&&obj==dwarf)
-                                       spk=94;
-                       if (closed) spk=138;
-                       if (toting(obj)) spk=24;
+               case 19:
+               case 20:        /* 9190: find, invent */
+                       if (at(obj) || (liq(0) == obj && at(bottle))
+                           || k == liqloc(loc))
+                               spk = 94;
+                       for (i = 1; i <= 5; i++)
+                               if (dloc[i] == loc && dflag >= 2 && obj == dwarf)
+                                       spk = 94;
+                       if (closed)
+                               spk = 138;
+                       if (toting(obj))
+                               spk = 24;
                        goto l2011;
-       l9210:      case 21:                    /* feed                 */
-                       switch(trfeed())
-                       {   case 2011: goto l2011;
-                           default: bug(114);
+               l9210: case 21:/* feed */
+                       switch (trfeed()) {
+                       case 2011:
+                               goto l2011;
+                       default:
+                               bug(114);
                        }
-       l9220:      case 22:                    /* fill                 */
-                       switch(trfill())
-                       {   case 2011: goto l2011;
-                           case 8000: goto l8000;
-                           case 9020: goto l9020;
-                           default: bug(115);
+               l9220: case 22:/* fill */
+                       switch (trfill()) {
+                       case 2011:
+                               goto l2011;
+                       case 8000:
+                               goto l8000;
+                       case 9020:
+                               goto l9020;
+                       default:
+                               bug(115);
                        }
-       l9230:      case 23:                    /* blast                */
-                       if (prop[rod2]<0||!closed) goto l2011;
-                       bonus=133;
-                       if (loc==115) bonus=134;
-                       if (here(rod2)) bonus=135;
+               l9230: case 23:/* blast */
+                       if (prop[rod2] < 0 || !closed)
+                               goto l2011;
+                       bonus = 133;
+                       if (loc == 115)
+                               bonus = 134;
+                       if (here(rod2))
+                               bonus = 135;
                        rspeak(bonus);
                        done(2);
-       l9270:      case 27:                    /* read                 */
-                       if (dark(0)) goto l5190;
-                       if (obj==magzin) spk=190;
-                       if (obj==tablet) spk=196;
-                       if (obj==messag) spk=191;
-                       if (obj==oyster&&hinted[2]&&toting(oyster)) spk=194;
-                       if (obj!=oyster||hinted[2]||!toting(oyster)
-                               ||!closed) goto l2011;
-                       hinted[2]=yes(192,193,54);
+               l9270: case 27:/* read */
+                       if (dark(0))
+                               goto l5190;
+                       if (obj == magzin)
+                               spk = 190;
+                       if (obj == tablet)
+                               spk = 196;
+                       if (obj == messag)
+                               spk = 191;
+                       if (obj == oyster && hinted[2] && toting(oyster))
+                               spk = 194;
+                       if (obj != oyster || hinted[2] || !toting(oyster)
+                           || !closed)
+                               goto l2011;
+                       hinted[2] = yes(192, 193, 54);
                        goto l2012;
 #if 0
        l9280:
 #endif
-                   case 28:                    /* break                */
-                       if (obj==mirror) spk=148;
-                       if (obj==vase&&prop[vase]==0)
-                       {       spk=198;
-                               if (toting(vase)) drop(vase,loc);
-                               prop[vase]=2;
-                               fixed[vase]= -1;
+               case 28:        /* break */
+                       if (obj == mirror)
+                               spk = 148;
+                       if (obj == vase && prop[vase] == 0) {
+                               spk = 198;
+                               if (toting(vase))
+                                       drop(vase, loc);
+                               prop[vase] = 2;
+                               fixed[vase] = -1;
                                goto l2011;
                        }
-                       if (obj!=mirror||!closed) goto l2011;
+                       if (obj != mirror || !closed)
+                               goto l2011;
                        rspeak(197);
                        done(3);
 #if 0
        l9290:
 #endif
-                   case 29:                    /* wake                 */
-                       if (obj!=dwarf||!closed) goto l2011;
+               case 29:        /* wake */
+                       if (obj != dwarf || !closed)
+                               goto l2011;
                        rspeak(199);
                        done(3);
 
-                   default: bug(24);
+               default:
+                       bug(24);
                }
 
-       l5000:
-               obj=k;
-               if (fixed[k]!=loc && !here(k)) goto l5100;
-       l5010:  if (*wd2!=0) goto l2800;
-               if (verb!=0) goto l4090;
-               printf("What do you want to do with the %s?\n",wd1);
+l5000:
+               obj = k;
+               if (fixed[k] != loc && !here(k))
+                       goto l5100;
+l5010:         if (*wd2 != 0)
+                       goto l2800;
+               if (verb != 0)
+                       goto l4090;
+               printf("What do you want to do with the %s?\n", wd1);
                goto l2600;
-       l5100:  if (k!=grate) goto l5110;
-               if (loc==1||loc==4||loc==7) k=dprssn;
-               if (loc>9&&loc<15) k=entrnc;
-               if (k!=grate) goto l8;
-       l5110:  if (k!=dwarf) goto l5120;
-               for (i=1; i<=5; i++)
-                       if (dloc[i]==loc&&dflag>=2) goto l5010;
-       l5120:  if ((liq(0)==k&&here(bottle))||k==liqloc(loc)) goto l5010;
-               if (obj!=plant||!at(plant2)||prop[plant2]==0) goto l5130;
-               obj=plant2;
+l5100:         if (k != grate)
+                       goto l5110;
+               if (loc == 1 || loc == 4 || loc == 7)
+                       k = dprssn;
+               if (loc > 9 && loc < 15)
+                       k = entrnc;
+               if (k != grate)
+                       goto l8;
+l5110:         if (k != dwarf)
+                       goto l5120;
+               for (i = 1; i <= 5; i++)
+                       if (dloc[i] == loc && dflag >= 2)
+                               goto l5010;
+l5120:         if ((liq(0) == k && here(bottle)) || k == liqloc(loc))
+                       goto l5010;
+               if (obj != plant || !at(plant2) || prop[plant2] == 0)
+                       goto l5130;
+               obj = plant2;
                goto l5010;
-       l5130:  if (obj!=knife||knfloc!=loc) goto l5140;
+l5130:         if (obj != knife || knfloc != loc)
+                       goto l5140;
                knfloc = -1;
-               spk=116;
+               spk = 116;
                goto l2011;
-       l5140:  if (obj!=rod||!here(rod2)) goto l5190;
-               obj=rod2;
+l5140:         if (obj != rod || !here(rod2))
+                       goto l5190;
+               obj = rod2;
                goto l5010;
-       l5190:  if ((verb==find||verb==invent)&&*wd2==0) goto l5010;
-               printf("I see no %s here\n",wd1);
+l5190:         if ((verb == find || verb == invent) && *wd2 == 0)
+                       goto l5010;
+               printf("I see no %s here\n", wd1);
                goto l2012;
        }
 }
index 75b451846bdc15288ab0ac88503c250c3bada68b..8eed7e141b4b801f6388566fe3be25eeb30fa490 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: save.c,v 1.3 1997/08/11 14:06:17 christos Exp $        */
+/*     $NetBSD: save.c,v 1.4 1997/10/11 01:53:33 lukem Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
 #if 0
 static char sccsid[] = "@(#)save.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: save.c,v 1.3 1997/08/11 14:06:17 christos Exp $");
+__RCSID("$NetBSD: save.c,v 1.4 1997/10/11 01:53:33 lukem Exp $");
 #endif
-#endif /* not lint */
+#endif                         /* not lint */
 
 #include <stdio.h>
 #include <stdlib.h>
 #include "hdr.h"
 #include "extern.h"
 
-struct savestruct
-{
-       void *address;
-       int width;
+struct savestruct {
+       void   *address;
+       int     width;
 };
 
 struct savestruct save_array[] =
 {
-       { &abbnum,        sizeof(abbnum) },
-       { &attack,        sizeof(attack) },
-       { &blklin,        sizeof(blklin) },
-       { &bonus,         sizeof(bonus) },
-       { &chloc,         sizeof(chloc) },
-       { &chloc2,        sizeof(chloc2) },
-       { &clock1,        sizeof(clock1) },
-       { &clock2,        sizeof(clock2) },
-       { &closed,        sizeof(closed) },
-       { &closng,        sizeof(closng) },
-       { &daltlc,        sizeof(daltlc) },
-       { &demo,          sizeof(demo) },
-       { &detail,        sizeof(detail) },
-       { &dflag,         sizeof(dflag) },
-       { &dkill,         sizeof(dkill) },
-       { &dtotal,        sizeof(dtotal) },
-       { &foobar,        sizeof(foobar) },
-       { &gaveup,        sizeof(gaveup) },
-       { &holdng,        sizeof(holdng) },
-       { &iwest,         sizeof(iwest) },
-       { &k,             sizeof(k) },
-       { &k2,            sizeof(k2) },
-       { &knfloc,        sizeof(knfloc) },
-       { &kq,            sizeof(kq) },
-       { &latncy,        sizeof(latncy) },
-       { &limit,         sizeof(limit) },
-       { &lmwarn,        sizeof(lmwarn) },
-       { &loc,           sizeof(loc) },
-       { &maxdie,        sizeof(maxdie) },
-       { &mxscor,        sizeof(mxscor) },
-       { &newloc,        sizeof(newloc) },
-       { &numdie,        sizeof(numdie) },
-       { &obj,           sizeof(obj) },
-       { &oldlc2,        sizeof(oldlc2) },
-       { &oldloc,        sizeof(oldloc) },
-       { &panic,         sizeof(panic) },
-       { &saved,         sizeof(saved) },
-       { &savet,         sizeof(savet) },
-       { &scorng,        sizeof(scorng) },
-       { &spk,           sizeof(spk) },
-       { &stick,         sizeof(stick) },
-       { &tally,         sizeof(tally) },
-       { &tally2,        sizeof(tally2) },
-       { &tkk,           sizeof(tkk) },
-       { &turns,         sizeof(turns) },
-       { &verb,          sizeof(verb) },
-       { &wd1,           sizeof(wd1) },
-       { &wd2,           sizeof(wd2) },
-       { &wzdark,        sizeof(wzdark) },
-       { &yea,           sizeof(yea) },
-       { atloc,          sizeof(atloc) },
-       { dloc,           sizeof(dloc) },
-       { dseen,          sizeof(dseen) },
-       { fixed,          sizeof(fixed) },
-       { hinted,         sizeof(hinted) },
-       { links,          sizeof(links) },
-       { odloc,          sizeof(odloc) },
-       { place,          sizeof(place) },
-       { prop,           sizeof(prop) },
-       { tk,             sizeof(tk) },
+       {&abbnum, sizeof(abbnum)},
+       {&attack, sizeof(attack)},
+       {&blklin, sizeof(blklin)},
+       {&bonus, sizeof(bonus)},
+       {&chloc, sizeof(chloc)},
+       {&chloc2, sizeof(chloc2)},
+       {&clock1, sizeof(clock1)},
+       {&clock2, sizeof(clock2)},
+       {&closed, sizeof(closed)},
+       {&closng, sizeof(closng)},
+       {&daltlc, sizeof(daltlc)},
+       {&demo, sizeof(demo)},
+       {&detail, sizeof(detail)},
+       {&dflag, sizeof(dflag)},
+       {&dkill, sizeof(dkill)},
+       {&dtotal, sizeof(dtotal)},
+       {&foobar, sizeof(foobar)},
+       {&gaveup, sizeof(gaveup)},
+       {&holdng, sizeof(holdng)},
+       {&iwest, sizeof(iwest)},
+       {&k, sizeof(k)},
+       {&k2, sizeof(k2)},
+       {&knfloc, sizeof(knfloc)},
+       {&kq, sizeof(kq)},
+       {&latncy, sizeof(latncy)},
+       {&limit, sizeof(limit)},
+       {&lmwarn, sizeof(lmwarn)},
+       {&loc, sizeof(loc)},
+       {&maxdie, sizeof(maxdie)},
+       {&mxscor, sizeof(mxscor)},
+       {&newloc, sizeof(newloc)},
+       {&numdie, sizeof(numdie)},
+       {&obj, sizeof(obj)},
+       {&oldlc2, sizeof(oldlc2)},
+       {&oldloc, sizeof(oldloc)},
+       {&panic, sizeof(panic)},
+       {&saved, sizeof(saved)},
+       {&savet, sizeof(savet)},
+       {&scorng, sizeof(scorng)},
+       {&spk, sizeof(spk)},
+       {&stick, sizeof(stick)},
+       {&tally, sizeof(tally)},
+       {&tally2, sizeof(tally2)},
+       {&tkk, sizeof(tkk)},
+       {&turns, sizeof(turns)},
+       {&verb, sizeof(verb)},
+       {&wd1, sizeof(wd1)},
+       {&wd2, sizeof(wd2)},
+       {&wzdark, sizeof(wzdark)},
+       {&yea, sizeof(yea)},
+       {atloc, sizeof(atloc)},
+       {dloc, sizeof(dloc)},
+       {dseen, sizeof(dseen)},
+       {fixed, sizeof(fixed)},
+       {hinted, sizeof(hinted)},
+       {links, sizeof(links)},
+       {odloc, sizeof(odloc)},
+       {place, sizeof(place)},
+       {prop, sizeof(prop)},
+       {tk, sizeof(tk)},
 
-       { NULL,   0 }
+       {NULL, 0}
 };
 
 int
-save(outfile)   /* Two passes on data: first to get checksum, second */
-char *outfile;  /* to output the data using checksum to start random #s */
+save(outfile)                  /* Two passes on data: first to get checksum,
+                                * second */
+       char   *outfile;        /* to output the data using checksum to start
+                                * random #s */
 {
-       FILE *out;
+       FILE   *out;
        struct savestruct *p;
-       char *s;
-       long sum;
-       int i;
+       char   *s;
+       long    sum;
+       int     i;
 
        crc_start();
        for (p = save_array; p->address != NULL; p++)
                sum = crc(p->address, p->width);
        srandom((int) sum);
 
-       if ((out = fopen(outfile, "wb")) == NULL)
-       {
-           fprintf(stderr,
-               "Hmm.  The name \"%s\" appears to be magically blocked.\n",
-               outfile);
-           return 1;
+       if ((out = fopen(outfile, "wb")) == NULL) {
+               fprintf(stderr,
+                   "Hmm.  The name \"%s\" appears to be magically blocked.\n",
+                   outfile);
+               return 1;
        }
-       fwrite(&sum, sizeof(sum), 1, out);      /* Here's the random() key */
-       for (p = save_array; p->address != NULL; p++)
-       {
+       fwrite(&sum, sizeof(sum), 1, out);      /* Here's the random() key */
+       for (p = save_array; p->address != NULL; p++) {
                for (s = p->address, i = 0; i < p->width; i++, s++)
-                       *s = (*s ^ random()) & 0xFF;      /* Lightly encrypt */
+                       *s = (*s ^ random()) & 0xFF;    /* Lightly encrypt */
                fwrite(p->address, p->width, 1, out);
        }
        fclose(out);
@@ -159,36 +158,34 @@ char *outfile;  /* to output the data using checksum to start random #s */
 
 int
 restore(infile)
-char *infile;
+       char   *infile;
 {
-       FILE *in;
+       FILE   *in;
        struct savestruct *p;
-       char *s;
-       long sum, cksum = 0;
-       int i;
+       char   *s;
+       long    sum, cksum = 0;
+       int     i;
 
-       if ((in = fopen(infile, "rb")) == NULL)
-       {
-           fprintf(stderr,
-               "Hmm.  The file \"%s\" appears to be magically blocked.\n",
-               infile);
-           return 1;
+       if ((in = fopen(infile, "rb")) == NULL) {
+               fprintf(stderr,
+                   "Hmm.  The file \"%s\" appears to be magically blocked.\n",
+                   infile);
+               return 1;
        }
-       fread(&sum, sizeof(sum), 1, in);        /* Get the seed */
+       fread(&sum, sizeof(sum), 1, in);        /* Get the seed */
        srandom((int) sum);
-       for (p = save_array; p->address != NULL; p++)
-       {
+       for (p = save_array; p->address != NULL; p++) {
                fread(p->address, p->width, 1, in);
                for (s = p->address, i = 0; i < p->width; i++, s++)
-                       *s = (*s ^ random()) & 0xFF;  /* Lightly decrypt */
+                       *s = (*s ^ random()) & 0xFF;    /* Lightly decrypt */
        }
        fclose(in);
 
-       crc_start();                            /* See if she cheated */
+       crc_start();            /* See if she cheated */
        for (p = save_array; p->address != NULL; p++)
                cksum = crc(p->address, p->width);
-       if (sum != cksum)                       /* Tsk tsk */
-           return 2;                           /* Altered the file */
+       if (sum != cksum)       /* Tsk tsk */
+               return 2;       /* Altered the file */
        /* We successfully restored, so this really was a save file */
        /* Get rid of the file, but don't bother checking that we did */
        return 0;
index 042e1e04226cc7d2483995b934d686ef92ddfd5e..150c275ac5c9e8d76aa0df1359557765fc2ed245 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: setup.c,v 1.2 1995/03/21 12:05:10 cgd Exp $    */
+/*     $NetBSD: setup.c,v 1.3 1997/10/11 01:53:35 lukem Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
 static char copyright[] =
 "@(#) Copyright (c) 1991, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
-#endif /* not lint */
+#endif                         /* not lint */
 
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)setup.c    8.1 (Berkeley) 5/31/93";
 #else
-static char rcsid[] = "$NetBSD: setup.c,v 1.2 1995/03/21 12:05:10 cgd Exp $";
+static char rcsid[] = "$NetBSD: setup.c,v 1.3 1997/10/11 01:53:35 lukem Exp $";
 #endif
-#endif /* not lint */
+#endif                         /* not lint */
 
 /*
  * Setup: keep the structure of the original Adventure port, but use an
@@ -64,25 +64,26 @@ static char rcsid[] = "$NetBSD: setup.c,v 1.2 1995/03/21 12:05:10 cgd Exp $";
 #define SIG2 " *      Sterday, 6 Thrimidge S.R. 1993, 15:24"
 
 #include <stdio.h>
-#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"
 
 #define YES 1
 #define NO  0
 
-void fatal();
+void    fatal();
 
-#define LINE 10         /* How many values do we get on a line? */
+#define LINE 10                        /* How many values do we get on a line? */
 
 main(argc, argv)
-int argc;
-char *argv[];
+       int     argc;
+       char   *argv[];
 {
-       FILE *infile;
-       int c, count, linestart;
+       FILE   *infile;
+       int     c, count, linestart;
 
-       if (argc != 2) fatal(USAGE);
+       if (argc != 2)
+               fatal(USAGE);
 
        if ((infile = fopen(argv[1], "r")) == NULL)
                fatal("Can't read file %s.\n", argv[1]);
@@ -95,25 +96,23 @@ char *argv[];
        count = 0;
        linestart = YES;
 
-       while ((c = getc(infile)) != EOF)
-       {
-               if (linestart && c == ' ') /* Convert first spaces to tab */
-               {
+       while ((c = getc(infile)) != EOF) {
+               if (linestart && c == ' ') {    /* Convert first spaces to tab */
                        printf("0x%02x,", ('\t' ^ random()) & 0xFF);
                        while ((c = getc(infile)) == ' ' && c != EOF);
                        /* Drop the non-whitespace character through */
                        linestart = NO;
                }
-               switch(c)
-               {
-                   case '\t':
-                       linestart = NO; /* Don't need to convert spaces */
+               switch (c) {
+               case '\t':
+                       linestart = NO; /* Don't need to convert spaces */
                        break;
-                   case '\n':
-                       linestart = YES; /* Ready to convert spaces again */
+               case '\n':
+                       linestart = YES;        /* Ready to convert spaces
+                                                * again */
                        break;
                }
-               if (count++ % LINE == 0)   /* Finished a line? */
+               if (count++ % LINE == 0)        /* Finished a line? */
                        printf("\n\t");
                printf("0x%02x,", (c ^ random()) & 0xFF);
        }
@@ -123,8 +122,9 @@ char *argv[];
 }
 
 
-void fatal(format, arg)
-char *format;
+void 
+fatal(format, arg)
+       char   *format;
 {
        fprintf(stderr, format, arg);
        exit(1);
index 64d607142776233c4dd2d0792a5bb4d69314991b..d71e3a495fbcd74e2e44b947347ee3bcfd9c4def 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr.c,v 1.4 1997/10/10 11:59:53 lukem Exp $   */
+/*     $NetBSD: subr.c,v 1.5 1997/10/11 01:53:36 lukem Exp $   */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,9 +43,9 @@
 #if 0
 static char sccsid[] = "@(#)subr.c     8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: subr.c,v 1.4 1997/10/10 11:59:53 lukem Exp $");
+__RCSID("$NetBSD: subr.c,v 1.5 1997/10/11 01:53:36 lukem Exp $");
 #endif
-#endif /* not lint */
+#endif                         /* not lint */
 
 /*      Re-coding of advent in C: subroutines from main                 */
 
@@ -56,811 +56,1007 @@ __RCSID("$NetBSD: subr.c,v 1.4 1997/10/10 11:59:53 lukem Exp $");
 /*              Statement functions     */
 int
 toting(objj)
-int objj;
-{       if (place[objj] == -1) return(TRUE);
-       else return(FALSE);
+       int     objj;
+{
+       if (place[objj] == -1)
+               return (TRUE);
+       else
+               return (FALSE);
 }
 
 int
 here(objj)
-int objj;
-{       if (place[objj]==loc || toting(objj)) return(TRUE);
-       else return(FALSE);
+       int     objj;
+{
+       if (place[objj] == loc || toting(objj))
+               return (TRUE);
+       else
+               return (FALSE);
 }
 
 int
 at(objj)
-int objj;
-{       if (place[objj]==loc || fixed[objj]==loc) return(TRUE);
-       else return (FALSE);
+       int     objj;
+{
+       if (place[objj] == loc || fixed[objj] == loc)
+               return (TRUE);
+       else
+               return (FALSE);
 }
 
 int
 liq2(pbotl)
-int pbotl;
-{       return((1-pbotl)*water+(pbotl/2)*(water+oil));
+       int     pbotl;
+{
+       return ((1 - pbotl) * water + (pbotl / 2) * (water + oil));
 }
 
 int
 liq(foo)
-{       int i;
-       i=prop[bottle];
-       if (i>-1-i) return(liq2(i));
-       else return(liq2(-1-i));
+{
+       int     i;
+       i = prop[bottle];
+       if (i > -1 - i)
+               return (liq2(i));
+       else
+               return (liq2(-1 - i));
 }
 
 int
-liqloc(locc)     /* may want to clean this one up a bit */
-int locc;
-{       int i,j,l;
-       i=cond[locc]/2;
-       j=((i*2)%8)-5;
-       l=cond[locc]/4;
-       l=l%2;
-       return(liq2(j*l+1));
+liqloc(locc)                   /* may want to clean this one up a bit */
+       int     locc;
+{
+       int     i, j, l;
+       i = cond[locc] / 2;
+       j = ((i * 2) % 8) - 5;
+       l = cond[locc] / 4;
+       l = l % 2;
+       return (liq2(j * l + 1));
 }
 
 int
-bitset(l,n)
-int l,n;
-{       if (cond[l] & setbit[n]) return(TRUE);
-       return(FALSE);
+bitset(l, n)
+       int     l, n;
+{
+       if (cond[l] & setbit[n])
+               return (TRUE);
+       return (FALSE);
 }
 
 int
 forced(locc)
-int locc;
-{       if (cond[locc]==2) return(TRUE);
-       return(FALSE);
+       int     locc;
+{
+       if (cond[locc] == 2)
+               return (TRUE);
+       return (FALSE);
 }
 
 int
 dark(foo)
-{       if ((cond[loc]%2)==0 && (prop[lamp]==0 || !here(lamp)))
-               return(TRUE);
-       return(FALSE);
+{
+       if ((cond[loc] % 2) == 0 && (prop[lamp] == 0 || !here(lamp)))
+               return (TRUE);
+       return (FALSE);
 }
 
 int
 pct(n)
-int n;
-{       if (ran(100)<n) return(TRUE);
-       return(FALSE);
+       int     n;
+{
+       if (ran(100) < n)
+               return (TRUE);
+       return (FALSE);
 }
 
 
 int
-fdwarf()               /* 71 */
-{      int i,j;
+fdwarf()
+{                              /* 71 */
+       int     i, j;
        struct travlist *kk;
 
-       if (newloc!=loc&&!forced(loc)&&!bitset(loc,3))
-       {       for (i=1; i<=5; i++)
-               {       if (odloc[i]!=newloc||!dseen[i]) continue;
-                       newloc=loc;
+       if (newloc != loc && !forced(loc) && !bitset(loc, 3)) {
+               for (i = 1; i <= 5; i++) {
+                       if (odloc[i] != newloc || !dseen[i])
+                               continue;
+                       newloc = loc;
                        rspeak(2);
                        break;
                }
        }
-       loc=newloc;                     /* 74 */
-       if (loc==0||forced(loc)||bitset(newloc,3)) return(2000);
-       if (dflag==0)
-       {       if (loc>=15) dflag=1;
-               return(2000);
-       }
-       if (dflag==1)           /* 6000 */
-       {       if (loc<15||pct(95)) return(2000);
-               dflag=2;
-               for (i=1; i<=2; i++)
-               {       j=1+ran(5);
-                       if (pct(50)&&saved== -1) dloc[j]=0; /* 6001 */
+       loc = newloc;           /* 74 */
+       if (loc == 0 || forced(loc) || bitset(newloc, 3))
+               return (2000);
+       if (dflag == 0) {
+               if (loc >= 15)
+                       dflag = 1;
+               return (2000);
+       }
+       if (dflag == 1) {       /* 6000 */
+               if (loc < 15 || pct(95))
+                       return (2000);
+               dflag = 2;
+               for (i = 1; i <= 2; i++) {
+                       j = 1 + ran(5);
+                       if (pct(50) && saved == -1)
+                               dloc[j] = 0;    /* 6001 */
                }
-               for (i=1; i<=5; i++)
-               {       if (dloc[i]==loc) dloc[i]=daltlc;
-                       odloc[i]=dloc[i];               /* 6002 */
+               for (i = 1; i <= 5; i++) {
+                       if (dloc[i] == loc)
+                               dloc[i] = daltlc;
+                       odloc[i] = dloc[i];     /* 6002 */
                }
                rspeak(3);
-               drop(axe,loc);
-               return(2000);
-       }
-       dtotal=attack=stick=0;                  /* 6010 */
-       for (i=1; i<=6; i++)                    /* loop to 6030 */
-       {       if (dloc[i]==0) continue;
-               j=1;
-               for (kk=travel[dloc[i]]; kk!=0; kk=kk->next)
-               {       newloc=kk->tloc;
-                       if (newloc>300||newloc<15||newloc==odloc[i]
-                           ||(j>1&&newloc==tk[j-1])||j>=20
-                           ||newloc==dloc[i]||forced(newloc)
-                           ||(i==6&&bitset(newloc,3))
-                           ||kk->conditions==100) continue;
-                       tk[j++]=newloc;
+               drop(axe, loc);
+               return (2000);
+       }
+       dtotal = attack = stick = 0;    /* 6010 */
+       for (i = 1; i <= 6; i++) {      /* loop to 6030 */
+               if (dloc[i] == 0)
+                       continue;
+               j = 1;
+               for (kk = travel[dloc[i]]; kk != 0; kk = kk->next) {
+                       newloc = kk->tloc;
+                       if (newloc > 300 || newloc < 15 || newloc == odloc[i]
+                           || (j > 1 && newloc == tk[j - 1]) || j >= 20
+                           || newloc == dloc[i] || forced(newloc)
+                           || (i == 6 && bitset(newloc, 3))
+                           || kk->conditions == 100)
+                               continue;
+                       tk[j++] = newloc;
                }
-               tk[j]=odloc[i];                 /* 6016 */
-               if (j>=2) j--;
-               j=1+ran(j);
-               odloc[i]=dloc[i];
-               dloc[i]=tk[j];
-               dseen[i]=(dseen[i]&&loc>=15)||(dloc[i]==loc||odloc[i]==loc);
-               if (!dseen[i]) continue;        /* i.e. goto 6030 */
-               dloc[i]=loc;
-               if (i==6)                       /* pirate's spotted him */
-               {       if (loc==chloc||prop[chest]>=0) continue;
-                       k=0;
-                       for (j=50; j<=maxtrs; j++)      /* loop to 6020 */
-                       {       if (j==pyram&&(loc==plac[pyram]
-                                    || loc==plac[emrald])) goto l6020;
-                               if (toting(j)) goto l6022;
-                       l6020:  if (here(j)) k=1;
-                       }                               /* 6020 */
-                       if (tally==tally2+1 && k==0 && place[chest]==0
-                           &&here(lamp) && prop[lamp]==1) goto l6025;
-                       if (odloc[6]!=dloc[6]&&pct(20))
+               tk[j] = odloc[i];       /* 6016 */
+               if (j >= 2)
+                       j--;
+               j = 1 + ran(j);
+               odloc[i] = dloc[i];
+               dloc[i] = tk[j];
+               dseen[i] = (dseen[i] && loc >= 15) || (dloc[i] == loc || odloc[i] == loc);
+               if (!dseen[i])
+                       continue;       /* i.e. goto 6030 */
+               dloc[i] = loc;
+               if (i == 6) {   /* pirate's spotted him */
+                       if (loc == chloc || prop[chest] >= 0)
+                               continue;
+                       k = 0;
+                       for (j = 50; j <= maxtrs; j++) {        /* loop to 6020 */
+                               if (j == pyram && (loc == plac[pyram]
+                                       || loc == plac[emrald]))
+                                       goto l6020;
+                               if (toting(j))
+                                       goto l6022;
+               l6020:          if (here(j))
+                                       k = 1;
+                       }       /* 6020 */
+                       if (tally == tally2 + 1 && k == 0 && place[chest] == 0
+                           && here(lamp) && prop[lamp] == 1)
+                               goto l6025;
+                       if (odloc[6] != dloc[6] && pct(20))
                                rspeak(127);
-                       continue;       /* to 6030 */
-               l6022:  rspeak(128);
-                       if (place[messag]==0) move(chest,chloc);
-                       move(messag,chloc2);
-                       for (j=50; j<=maxtrs; j++)      /* loop to 6023 */
-                       {       if (j==pyram && (loc==plac[pyram]
-                                   || loc==plac[emrald])) continue;
-                               if (at(j)&&fixed[j]==0) carry(j,loc);
-                               if (toting(j)) drop(j,chloc);
+                       continue;       /* to 6030 */
+       l6022:          rspeak(128);
+                       if (place[messag] == 0)
+                               move(chest, chloc);
+                       move(messag, chloc2);
+                       for (j = 50; j <= maxtrs; j++) {        /* loop to 6023 */
+                               if (j == pyram && (loc == plac[pyram]
+                                       || loc == plac[emrald]))
+                                       continue;
+                               if (at(j) && fixed[j] == 0)
+                                       carry(j, loc);
+                               if (toting(j))
+                                       drop(j, chloc);
                        }
-               l6024:  dloc[6]=odloc[6]=chloc;
-                       dseen[6]=FALSE;
+       l6024:          dloc[6] = odloc[6] = chloc;
+                       dseen[6] = FALSE;
                        continue;
-               l6025:  rspeak(186);
-                       move(chest,chloc);
-                       move(messag,chloc2);
+       l6025:          rspeak(186);
+                       move(chest, chloc);
+                       move(messag, chloc2);
                        goto l6024;
                }
-               dtotal++;                       /* 6027 */
-               if (odloc[i]!=dloc[i]) continue;
+               dtotal++;       /* 6027 */
+               if (odloc[i] != dloc[i])
+                       continue;
                attack++;
-               if (knfloc>=0) knfloc=loc;
-               if (ran(1000)<95*(dflag-2)) stick++;
-       }                                       /* 6030 */
-       if (dtotal==0) return(2000);
-       if (dtotal!=1)
-       {       printf("There are %d threatening little dwarves ",dtotal);
+               if (knfloc >= 0)
+                       knfloc = loc;
+               if (ran(1000) < 95 * (dflag - 2))
+                       stick++;
+       }                       /* 6030 */
+       if (dtotal == 0)
+               return (2000);
+       if (dtotal != 1) {
+               printf("There are %d threatening little dwarves ", dtotal);
                printf("in the room with you.\n");
-       }
-       else rspeak(4);
-       if (attack==0) return(2000);
-       if (dflag==2) dflag=3;
-       if (saved!= -1) dflag=20;
-       if (attack!=1)
-       {       printf("%d of them throw knives at you!\n",attack);
-               k=6;
-       l82:    if (stick<=1)                   /* 82 */
-               {       rspeak(k+stick);
-                       if (stick==0) return(2000);
-               }
-               else
-                       printf("%d of them get you!\n",stick);  /* 83 */
-               oldlc2=loc;
-               return(99);
+       } else
+               rspeak(4);
+       if (attack == 0)
+               return (2000);
+       if (dflag == 2)
+               dflag = 3;
+       if (saved != -1)
+               dflag = 20;
+       if (attack != 1) {
+               printf("%d of them throw knives at you!\n", attack);
+               k = 6;
+l82:           if (stick <= 1) {       /* 82 */
+                       rspeak(k + stick);
+                       if (stick == 0)
+                               return (2000);
+               } else
+                       printf("%d of them get you!\n", stick); /* 83 */
+               oldlc2 = loc;
+               return (99);
        }
        rspeak(5);
-       k=52;
+       k = 52;
        goto l82;
 }
 
 
 int
-march()                                        /* label 8              */
-{       int ll1,ll2;
-
-       if ((tkk=travel[newloc=loc])==0) bug(26);
-       if (k==null) return(2);
-       if (k==cave)                            /* 40                   */
-       {       if (loc<8) rspeak(57);
-               if (loc>=8) rspeak(58);
-               return(2);
-       }
-       if (k==look)                            /* 30                   */
-       {       if (detail++<3) rspeak(15);
-               wzdark=FALSE;
-               abb[loc]=0;
-               return(2);
-       }
-       if (k==back)                            /* 20                   */
-       {       switch(mback())
-               {       case 2: return(2);
-                       case 9: goto l9;
-                       default: bug(100);
+march()
+{                              /* label 8              */
+       int     ll1, ll2;
+
+       if ((tkk = travel[newloc = loc]) == 0)
+               bug(26);
+       if (k == null)
+               return (2);
+       if (k == cave) {        /* 40                   */
+               if (loc < 8)
+                       rspeak(57);
+               if (loc >= 8)
+                       rspeak(58);
+               return (2);
+       }
+       if (k == look) {        /* 30                   */
+               if (detail++ < 3)
+                       rspeak(15);
+               wzdark = FALSE;
+               abb[loc] = 0;
+               return (2);
+       }
+       if (k == back) {        /* 20                   */
+               switch (mback()) {
+               case 2:
+                       return (2);
+               case 9:
+                       goto l9;
+               default:
+                       bug(100);
                }
        }
-       oldlc2=oldloc;
-       oldloc=loc;
+       oldlc2 = oldloc;
+       oldloc = loc;
 l9:
-       for (; tkk!=0; tkk=tkk->next)
-               if (tkk->tverb==1 || tkk->tverb==k) break;
-       if (tkk==0)
-       {       badmove();
-               return(2);
-       }
-l11:    ll1=tkk->conditions;                    /* 11                   */
-       ll2=tkk->tloc;
-       newloc=ll1;                             /* newloc=conditions    */
-       k=newloc%100;                           /* k used for prob      */
-       if (newloc<=300)
-       {       if (newloc<=100)                /* 13                   */
-               {       if (newloc!=0&&!pct(newloc)) goto l12;  /* 14   */
-               l16:    newloc=ll2;             /* newloc=location      */
-                       if (newloc<=300) return(2);
-                       if (newloc<=500)
-                               switch(specials())/* to 30000           */
-                               {   case 2: return(2);
-                                   case 12: goto l12;
-                                   case 99: return(99);
-                                   default: bug(101);
+       for (; tkk != 0; tkk = tkk->next)
+               if (tkk->tverb == 1 || tkk->tverb == k)
+                       break;
+       if (tkk == 0) {
+               badmove();
+               return (2);
+       }
+l11:   ll1 = tkk->conditions;  /* 11                   */
+       ll2 = tkk->tloc;
+       newloc = ll1;           /* newloc=conditions    */
+       k = newloc % 100;       /* k used for prob      */
+       if (newloc <= 300) {
+               if (newloc <= 100) {    /* 13                   */
+                       if (newloc != 0 && !pct(newloc))
+                               goto l12;       /* 14   */
+       l16:            newloc = ll2;   /* newloc=location      */
+                       if (newloc <= 300)
+                               return (2);
+                       if (newloc <= 500)
+                               switch (specials()) {   /* to 30000           */
+                               case 2:
+                                       return (2);
+                               case 12:
+                                       goto l12;
+                               case 99:
+                                       return (99);
+                               default:
+                                       bug(101);
                                }
-                       rspeak(newloc-500);
-                       newloc=loc;
-                       return(2);
+                       rspeak(newloc - 500);
+                       newloc = loc;
+                       return (2);
                }
-               if (toting(k)||(newloc>200&&at(k))) goto l16;
+               if (toting(k) || (newloc > 200 && at(k)))
+                       goto l16;
                goto l12;
        }
-       if (prop[k]!=(newloc/100)-3) goto l16;  /* newloc still conditions*/
-l12:    /* alternative to probability move      */
-       for (; tkk!=0; tkk=tkk->next)
-               if (tkk->tloc!=ll2 || tkk->conditions!=ll1) break;
-       if (tkk==0) bug(25);
+       if (prop[k] != (newloc / 100) - 3)
+               goto l16;       /* newloc still conditions */
+l12:                           /* alternative to probability move      */
+       for (; tkk != 0; tkk = tkk->next)
+               if (tkk->tloc != ll2 || tkk->conditions != ll1)
+                       break;
+       if (tkk == 0)
+               bug(25);
        goto l11;
 }
 
 
 
 int
-mback()                                         /* 20                   */
-{       struct travlist *tk2,*j;
-       int ll;
-       if (forced(k=oldloc)) k=oldlc2;         /* k=location           */
-       oldlc2=oldloc;
-       oldloc=loc;
-       tk2=0;
-       if (k==loc)
-       {       rspeak(91);
-               return(2);
-       }
-       for (; tkk!=0; tkk=tkk->next)           /* 21                   */
-       {       ll=tkk->tloc;
-               if (ll==k)
-               {       k=tkk->tverb;           /* k back to verb       */
-                       tkk=travel[loc];
-                       return(9);
+mback()
+{                              /* 20                   */
+       struct travlist *tk2, *j;
+       int     ll;
+       if (forced(k = oldloc))
+               k = oldlc2;     /* k=location           */
+       oldlc2 = oldloc;
+       oldloc = loc;
+       tk2 = 0;
+       if (k == loc) {
+               rspeak(91);
+               return (2);
+       }
+       for (; tkk != 0; tkk = tkk->next) {     /* 21                   */
+               ll = tkk->tloc;
+               if (ll == k) {
+                       k = tkk->tverb; /* k back to verb       */
+                       tkk = travel[loc];
+                       return (9);
                }
-               if (ll<=300)
-               {       j=travel[loc];
-                       if (forced(ll) && k==j->tloc) tk2=tkk;
+               if (ll <= 300) {
+                       j = travel[loc];
+                       if (forced(ll) && k == j->tloc)
+                               tk2 = tkk;
                }
        }
-       tkk=tk2;                                /* 23                   */
-       if (tkk!=0)
-       {       k=tkk->tverb;
-               tkk=travel[loc];
-               return(9);
+       tkk = tk2;              /* 23                   */
+       if (tkk != 0) {
+               k = tkk->tverb;
+               tkk = travel[loc];
+               return (9);
        }
        rspeak(140);
-       return(2);
+       return (2);
 }
 
 
 int
-specials()                                      /* 30000                */
-{       switch(newloc -= 300)
-       {   case 1:                             /* 30100                */
-               newloc = 99+100-loc;
-               if (holdng==0||(holdng==1&&toting(emrald))) return(2);
-               newloc=loc;
+specials()
+{                              /* 30000                */
+       switch (newloc -= 300) {
+               case 1:         /* 30100                */
+               newloc = 99 + 100 - loc;
+               if (holdng == 0 || (holdng == 1 && toting(emrald)))
+                       return (2);
+               newloc = loc;
                rspeak(117);
-               return(2);
-           case 2:                             /* 30200                */
-               drop(emrald,loc);
-               return(12);
-           case 3:                             /* to 30300             */
-               return(trbridge());
-           default: bug(29);
+               return (2);
+       case 2:         /* 30200                */
+               drop(emrald, loc);
+               return (12);
+       case 3:         /* to 30300             */
+               return (trbridge());
+       default:
+               bug(29);
        }
 }
 
 
 int
-trbridge()                                      /* 30300                */
-{       if (prop[troll]==1)
-       {       pspeak(troll,1);
-               prop[troll]=0;
-               move(troll2,0);
-               move(troll2+100,0);
-               move(troll,plac[troll]);
-               move(troll+100,fixd[troll]);
+trbridge()
+{                              /* 30300                */
+       if (prop[troll] == 1) {
+               pspeak(troll, 1);
+               prop[troll] = 0;
+               move(troll2, 0);
+               move(troll2 + 100, 0);
+               move(troll, plac[troll]);
+               move(troll + 100, fixd[troll]);
                juggle(chasm);
-               newloc=loc;
-               return(2);
+               newloc = loc;
+               return (2);
        }
-       newloc=plac[troll]+fixd[troll]-loc;     /* 30310                */
-       if (prop[troll]==0) prop[troll]=1;
-       if (!toting(bear)) return(2);
+       newloc = plac[troll] + fixd[troll] - loc;       /* 30310                */
+       if (prop[troll] == 0)
+               prop[troll] = 1;
+       if (!toting(bear))
+               return (2);
        rspeak(162);
-       prop[chasm]=1;
-       prop[troll]=2;
-       drop(bear,newloc);
+       prop[chasm] = 1;
+       prop[troll] = 2;
+       drop(bear, newloc);
        fixed[bear] = -1;
-       prop[bear]=3;
-       if (prop[spices]<0) tally2++;
-       oldlc2=newloc;
-       return(99);
+       prop[bear] = 3;
+       if (prop[spices] < 0)
+               tally2++;
+       oldlc2 = newloc;
+       return (99);
 }
 
 
 int
-badmove()                                       /* 20                   */
-{       spk=12;
-       if (k>=43 && k<=50) spk=9;
-       if (k==29||k==30) spk=9;
-       if (k==7||k==36||k==37) spk=10;
-       if (k==11||k==19) spk=11;
-       if (verb==find||verb==invent) spk=59;
-       if (k==62||k==65) spk=42;
-       if (k==17) spk=80;
+badmove()
+{                              /* 20                   */
+       spk = 12;
+       if (k >= 43 && k <= 50)
+               spk = 9;
+       if (k == 29 || k == 30)
+               spk = 9;
+       if (k == 7 || k == 36 || k == 37)
+               spk = 10;
+       if (k == 11 || k == 19)
+               spk = 11;
+       if (verb == find || verb == invent)
+               spk = 59;
+       if (k == 62 || k == 65)
+               spk = 42;
+       if (k == 17)
+               spk = 80;
        rspeak(spk);
-       return(2);
+       return (2);
 }
 
 int
 bug(n)
-int n;
-{       printf("Please tell jim@rand.org that fatal bug %d happened.\n",n);
+       int     n;
+{
+       printf("Please tell jim@rand.org that fatal bug %d happened.\n", n);
        exit(0);
 }
 
 
 int
-checkhints()                                    /* 2600 &c              */
-{       int hint;
-       for (hint=4; hint<=hntmax; hint++)
-       {       if (hinted[hint]) continue;
-               if (!bitset(loc,hint)) hintlc[hint]= -1;
+checkhints()
+{                              /* 2600 &c              */
+       int     hint;
+       for (hint = 4; hint <= hntmax; hint++) {
+               if (hinted[hint])
+                       continue;
+               if (!bitset(loc, hint))
+                       hintlc[hint] = -1;
                hintlc[hint]++;
-               if (hintlc[hint]<hints[hint][1]) continue;
-               switch(hint)
-               {   case 4:     /* 40400 */
-                       if (prop[grate]==0&&!here(keys)) goto l40010;
+               if (hintlc[hint] < hints[hint][1])
+                       continue;
+               switch (hint) {
+               case 4: /* 40400 */
+                       if (prop[grate] == 0 && !here(keys))
+                               goto l40010;
                        goto l40020;
-                   case 5:     /* 40500 */
-                       if (here(bird)&&toting(rod)&&obj==bird) goto l40010;
-                       continue;      /* i.e. goto l40030 */
-                   case 6:     /* 40600 */
-                       if (here(snake)&&!here(bird)) goto l40010;
+               case 5: /* 40500 */
+                       if (here(bird) && toting(rod) && obj == bird)
+                               goto l40010;
+                       continue;       /* i.e. goto l40030 */
+               case 6: /* 40600 */
+                       if (here(snake) && !here(bird))
+                               goto l40010;
                        goto l40020;
-                   case 7:     /* 40700 */
-                       if (atloc[loc]==0&&atloc[oldloc]==0
-                           && atloc[oldlc2]==0&&holdng>1) goto l40010;
+               case 7: /* 40700 */
+                       if (atloc[loc] == 0 && atloc[oldloc] == 0
+                           && atloc[oldlc2] == 0 && holdng > 1)
+                               goto l40010;
                        goto l40020;
-                   case 8:     /* 40800 */
-                       if (prop[emrald]!= -1&&prop[pyram]== -1) goto l40010;
+               case 8: /* 40800 */
+                       if (prop[emrald] != -1 && prop[pyram] == -1)
+                               goto l40010;
                        goto l40020;
-                   case 9:
-                       goto l40010;    /* 40900 */
-                   default: bug(27);
+               case 9:
+                       goto l40010;    /* 40900 */
+               default:
+                       bug(27);
                }
-       l40010: hintlc[hint]=0;
-               if (!yes(hints[hint][3],0,54)) continue;
+l40010:        hintlc[hint] = 0;
+               if (!yes(hints[hint][3], 0, 54))
+                       continue;
                printf("I am prepared to give you a hint, but it will ");
-               printf("cost you %d points.\n",hints[hint][2]);
-               hinted[hint]=yes(175,hints[hint][4],54);
-       l40020: hintlc[hint]=0;
+               printf("cost you %d points.\n", hints[hint][2]);
+               hinted[hint] = yes(175, hints[hint][4], 54);
+l40020:        hintlc[hint] = 0;
        }
        return 0;
 }
 
 
 int
-trsay()                                         /* 9030                 */
-{       int i;
-       if (*wd2!=0) copystr(wd2,wd1);
-       i=vocab(wd1,-1,0);
-       if (i==62||i==65||i==71||i==2025)
-       {       *wd2=0;
-               obj=0;
-               return(2630);
-       }
-       printf("\nOkay, \"%s\".\n",wd2);
-       return(2012);
+trsay()
+{                              /* 9030                 */
+       int     i;
+       if (*wd2 != 0)
+               copystr(wd2, wd1);
+       i = vocab(wd1, -1, 0);
+       if (i == 62 || i == 65 || i == 71 || i == 2025) {
+               *wd2 = 0;
+               obj = 0;
+               return (2630);
+       }
+       printf("\nOkay, \"%s\".\n", wd2);
+       return (2012);
 }
 
 
 int
-trtake()                                        /* 9010                 */
-{      if (toting(obj)) return(2011);  /* 9010 */
-       spk=25;
-       if (obj==plant&&prop[plant]<=0) spk=115;
-       if (obj==bear&&prop[bear]==1) spk=169;
-       if (obj==chain&&prop[bear]!=0) spk=170;
-       if (fixed[obj]!=0) return(2011);
-       if (obj==water||obj==oil)
-       {       if (here(bottle)&&liq(0)==obj)
-               {       obj=bottle;
+trtake()
+{                              /* 9010                 */
+       if (toting(obj))
+               return (2011);  /* 9010 */
+       spk = 25;
+       if (obj == plant && prop[plant] <= 0)
+               spk = 115;
+       if (obj == bear && prop[bear] == 1)
+               spk = 169;
+       if (obj == chain && prop[bear] != 0)
+               spk = 170;
+       if (fixed[obj] != 0)
+               return (2011);
+       if (obj == water || obj == oil) {
+               if (here(bottle) && liq(0) == obj) {
+                       obj = bottle;
                        goto l9017;
                }
-               obj=bottle;
-               if (toting(bottle)&&prop[bottle]==1)
-                       return(9220);
-               if (prop[bottle]!=1) spk=105;
-               if (!toting(bottle)) spk=104;
-               return(2011);
-       }
-l9017:  if (holdng>=7)
-       {       rspeak(92);
-               return(2012);
-       }
-       if (obj==bird)
-       {       if (prop[bird]!=0) goto l9014;
-               if (toting(rod))
-               {       rspeak(26);
-                       return(2012);
+               obj = bottle;
+               if (toting(bottle) && prop[bottle] == 1)
+                       return (9220);
+               if (prop[bottle] != 1)
+                       spk = 105;
+               if (!toting(bottle))
+                       spk = 104;
+               return (2011);
+       }
+l9017: if (holdng >= 7) {
+               rspeak(92);
+               return (2012);
+       }
+       if (obj == bird) {
+               if (prop[bird] != 0)
+                       goto l9014;
+               if (toting(rod)) {
+                       rspeak(26);
+                       return (2012);
                }
-               if (!toting(cage))      /* 9013 */
-               {       rspeak(27);
-                       return(2012);
+               if (!toting(cage)) {    /* 9013 */
+                       rspeak(27);
+                       return (2012);
                }
-               prop[bird]=1;           /* 9015 */
-       }
-l9014:  if ((obj==bird||obj==cage)&&prop[bird]!=0)
-               carry(bird+cage-obj,loc);
-       carry(obj,loc);
-       k=liq(0);
-       if (obj==bottle && k!=0) place[k] = -1;
-       return(2009);
+               prop[bird] = 1; /* 9015 */
+       }
+l9014: if ((obj == bird || obj == cage) && prop[bird] != 0)
+               carry(bird + cage - obj, loc);
+       carry(obj, loc);
+       k = liq(0);
+       if (obj == bottle && k != 0)
+               place[k] = -1;
+       return (2009);
 }
 
 
 int
-dropper()                                       /* 9021                 */
-{       k=liq(0);
-       if (k==obj) obj=bottle;
-       if (obj==bottle&&k!=0) place[k]=0;
-       if (obj==cage&&prop[bird]!=0) drop(bird,loc);
-       if (obj==bird) prop[bird]=0;
-       drop(obj,loc);
-       return(2012);
+dropper()
+{                              /* 9021                 */
+       k = liq(0);
+       if (k == obj)
+               obj = bottle;
+       if (obj == bottle && k != 0)
+               place[k] = 0;
+       if (obj == cage && prop[bird] != 0)
+               drop(bird, loc);
+       if (obj == bird)
+               prop[bird] = 0;
+       drop(obj, loc);
+       return (2012);
 }
 
 int
-trdrop()                                        /* 9020                 */
-{
-       if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2;
-       if (!toting(obj)) return(2011);
-       if (obj==bird&&here(snake))
-       {       rspeak(30);
-               if (closed) return(19000);
+trdrop()
+{                              /* 9020                 */
+       if (toting(rod2) && obj == rod && !toting(rod))
+               obj = rod2;
+       if (!toting(obj))
+               return (2011);
+       if (obj == bird && here(snake)) {
+               rspeak(30);
+               if (closed)
+                       return (19000);
                dstroy(snake);
-               prop[snake]=1;
-               return(dropper());
+               prop[snake] = 1;
+               return (dropper());
        }
-       if (obj==coins&&here(vend))             /* 9024                 */
-       {       dstroy(coins);
-               drop(batter,loc);
-               pspeak(batter,0);
-               return(2012);
+       if (obj == coins && here(vend)) {       /* 9024                 */
+               dstroy(coins);
+               drop(batter, loc);
+               pspeak(batter, 0);
+               return (2012);
        }
-       if (obj==bird&&at(dragon)&&prop[dragon]==0)     /* 9025         */
-       {       rspeak(154);
+       if (obj == bird && at(dragon) && prop[dragon] == 0) {   /* 9025         */
+               rspeak(154);
                dstroy(bird);
-               prop[bird]=0;
-               if (place[snake]==plac[snake]) tally2--;
-               return(2012);
-       }
-       if (obj==bear&&at(troll))               /* 9026                 */
-       {       rspeak(163);
-               move(troll,0);
-               move(troll+100,0);
-               move(troll2,plac[troll]);
-               move(troll2+100,fixd[troll]);
+               prop[bird] = 0;
+               if (place[snake] == plac[snake])
+                       tally2--;
+               return (2012);
+       }
+       if (obj == bear && at(troll)) { /* 9026                 */
+               rspeak(163);
+               move(troll, 0);
+               move(troll + 100, 0);
+               move(troll2, plac[troll]);
+               move(troll2 + 100, fixd[troll]);
                juggle(chasm);
-               prop[troll]=2;
-               return(dropper());
-       }
-       if (obj!=vase||loc==plac[pillow])       /* 9027                 */
-       {       rspeak(54);
-               return(dropper());
-       }
-       prop[vase]=2;                           /* 9028                 */
-       if (at(pillow)) prop[vase]=0;
-       pspeak(vase,prop[vase]+1);
-       if (prop[vase]!=0) fixed[vase] = -1;
-       return(dropper());
+               prop[troll] = 2;
+               return (dropper());
+       }
+       if (obj != vase || loc == plac[pillow]) {       /* 9027                 */
+               rspeak(54);
+               return (dropper());
+       }
+       prop[vase] = 2;         /* 9028                 */
+       if (at(pillow))
+               prop[vase] = 0;
+       pspeak(vase, prop[vase] + 1);
+       if (prop[vase] != 0)
+               fixed[vase] = -1;
+       return (dropper());
 }
 
 
 int
-tropen()                                        /* 9040                 */
-{       if (obj==clam||obj==oyster)
-       {       k=0;                            /* 9046                 */
-               if (obj==oyster) k=1;
-               spk=124+k;
-               if (toting(obj)) spk=120+k;
-               if (!toting(tridnt)) spk=122+k;
-               if (verb==lock) spk=61;
-               if (spk!=124) return(2011);
+tropen()
+{                              /* 9040                 */
+       if (obj == clam || obj == oyster) {
+               k = 0;          /* 9046                 */
+               if (obj == oyster)
+                       k = 1;
+               spk = 124 + k;
+               if (toting(obj))
+                       spk = 120 + k;
+               if (!toting(tridnt))
+                       spk = 122 + k;
+               if (verb == lock)
+                       spk = 61;
+               if (spk != 124)
+                       return (2011);
                dstroy(clam);
-               drop(oyster,loc);
-               drop(pearl,105);
-               return(2011);
-       }
-       if (obj==door) spk=111;
-       if (obj==door&&prop[door]==1) spk=54;
-       if (obj==cage) spk=32;
-       if (obj==keys) spk=55;
-       if (obj==grate||obj==chain) spk=31;
-       if (spk!=31||!here(keys)) return(2011);
-       if (obj==chain)
-       {       if (verb==lock)
-               {       spk=172;                /* 9049: lock           */
-                       if (prop[chain]!=0) spk=34;
-                       if (loc!=plac[chain]) spk=173;
-                       if (spk!=172) return(2011);
-                       prop[chain]=2;
-                       if (toting(chain)) drop(chain,loc);
-                       fixed[chain]= -1;
-                       return(2011);
+               drop(oyster, loc);
+               drop(pearl, 105);
+               return (2011);
+       }
+       if (obj == door)
+               spk = 111;
+       if (obj == door && prop[door] == 1)
+               spk = 54;
+       if (obj == cage)
+               spk = 32;
+       if (obj == keys)
+               spk = 55;
+       if (obj == grate || obj == chain)
+               spk = 31;
+       if (spk != 31 || !here(keys))
+               return (2011);
+       if (obj == chain) {
+               if (verb == lock) {
+                       spk = 172;      /* 9049: lock           */
+                       if (prop[chain] != 0)
+                               spk = 34;
+                       if (loc != plac[chain])
+                               spk = 173;
+                       if (spk != 172)
+                               return (2011);
+                       prop[chain] = 2;
+                       if (toting(chain))
+                               drop(chain, loc);
+                       fixed[chain] = -1;
+                       return (2011);
                }
-               spk=171;
-               if (prop[bear]==0) spk=41;
-               if (prop[chain]==0) spk=37;
-               if (spk!=171) return(2011);
-               prop[chain]=0;
-               fixed[chain]=0;
-               if (prop[bear]!=3) prop[bear]=2;
-               fixed[bear]=2-prop[bear];
-               return(2011);
-       }
-       if (closng)
-       {       k=130;
-               if (!panic) clock2=15;
-               panic=TRUE;
-               return(2010);
-       }
-       k=34+prop[grate];                       /* 9043                 */
-       prop[grate]=1;
-       if (verb==lock) prop[grate]=0;
-       k=k+2*prop[grate];
-       return(2010);
+               spk = 171;
+               if (prop[bear] == 0)
+                       spk = 41;
+               if (prop[chain] == 0)
+                       spk = 37;
+               if (spk != 171)
+                       return (2011);
+               prop[chain] = 0;
+               fixed[chain] = 0;
+               if (prop[bear] != 3)
+                       prop[bear] = 2;
+               fixed[bear] = 2 - prop[bear];
+               return (2011);
+       }
+       if (closng) {
+               k = 130;
+               if (!panic)
+                       clock2 = 15;
+               panic = TRUE;
+               return (2010);
+       }
+       k = 34 + prop[grate];   /* 9043                 */
+       prop[grate] = 1;
+       if (verb == lock)
+               prop[grate] = 0;
+       k = k + 2 * prop[grate];
+       return (2010);
 }
 
 
 int
-trkill()                                /* 9120                         */
-{       int i;
-       for (i=1; i<=5; i++)
-               if (dloc[i]==loc&&dflag>=2) break;
-       if (i==6) i=0;
-       if (obj==0)                     /* 9122                         */
-       {       if (i!=0) obj=dwarf;
-               if (here(snake)) obj=obj*100+snake;
-               if (at(dragon)&&prop[dragon]==0) obj=obj*100+dragon;
-               if (at(troll)) obj=obj*100+troll;
-               if (here(bear)&&prop[bear]==0) obj=obj*100+bear;
-               if (obj>100) return(8000);
-               if (obj==0)
-               {       if (here(bird)&&verb!=throw) obj=bird;
-                       if (here(clam)||here(oyster)) obj=100*obj+clam;
-                       if (obj>100) return(8000);
+trkill()
+{                              /* 9120                         */
+       int     i;
+       for (i = 1; i <= 5; i++)
+               if (dloc[i] == loc && dflag >= 2)
+                       break;
+       if (i == 6)
+               i = 0;
+       if (obj == 0) {         /* 9122                         */
+               if (i != 0)
+                       obj = dwarf;
+               if (here(snake))
+                       obj = obj * 100 + snake;
+               if (at(dragon) && prop[dragon] == 0)
+                       obj = obj * 100 + dragon;
+               if (at(troll))
+                       obj = obj * 100 + troll;
+               if (here(bear) && prop[bear] == 0)
+                       obj = obj * 100 + bear;
+               if (obj > 100)
+                       return (8000);
+               if (obj == 0) {
+                       if (here(bird) && verb != throw)
+                               obj = bird;
+                       if (here(clam) || here(oyster))
+                               obj = 100 * obj + clam;
+                       if (obj > 100)
+                               return (8000);
                }
        }
-       if (obj==bird)                  /* 9124                         */
-       {       spk=137;
-               if (closed) return(2011);
+       if (obj == bird) {      /* 9124                         */
+               spk = 137;
+               if (closed)
+                       return (2011);
                dstroy(bird);
-               prop[bird]=0;
-               if (place[snake]==plac[snake]) tally2++;
-               spk=45;
-       }
-       if (obj==0) spk=44;             /* 9125                         */
-       if (obj==clam||obj==oyster) spk=150;
-       if (obj==snake) spk=46;
-       if (obj==dwarf) spk=49;
-       if (obj==dwarf&&closed) return(19000);
-       if (obj==dragon) spk=147;
-       if (obj==troll) spk=157;
-       if (obj==bear) spk=165+(prop[bear]+1)/2;
-       if (obj!=dragon||prop[dragon]!=0) return(2011);
+               prop[bird] = 0;
+               if (place[snake] == plac[snake])
+                       tally2++;
+               spk = 45;
+       }
+       if (obj == 0)
+               spk = 44;       /* 9125                         */
+       if (obj == clam || obj == oyster)
+               spk = 150;
+       if (obj == snake)
+               spk = 46;
+       if (obj == dwarf)
+               spk = 49;
+       if (obj == dwarf && closed)
+               return (19000);
+       if (obj == dragon)
+               spk = 147;
+       if (obj == troll)
+               spk = 157;
+       if (obj == bear)
+               spk = 165 + (prop[bear] + 1) / 2;
+       if (obj != dragon || prop[dragon] != 0)
+               return (2011);
        rspeak(49);
-       verb=0;
-       obj=0;
-       getin(&wd1,&wd2);
-       if (!weq(wd1,"y")&&!weq(wd1,"yes")) return(2608);
-       pspeak(dragon,1);
-       prop[dragon]=2;
-       prop[rug]=0;
-       k=(plac[dragon]+fixd[dragon])/2;
-       move(dragon+100,-1);
-       move(rug+100,0);
-       move(dragon,k);
-       move(rug,k);
-       for (obj=1; obj<=100; obj++)
-               if (place[obj]==plac[dragon]||place[obj]==fixd[dragon])
-                       move(obj,k);
-       loc=k;
-       k=null;
-       return(8);
+       verb = 0;
+       obj = 0;
+       getin(&wd1, &wd2);
+       if (!weq(wd1, "y") && !weq(wd1, "yes"))
+               return (2608);
+       pspeak(dragon, 1);
+       prop[dragon] = 2;
+       prop[rug] = 0;
+       k = (plac[dragon] + fixd[dragon]) / 2;
+       move(dragon + 100, -1);
+       move(rug + 100, 0);
+       move(dragon, k);
+       move(rug, k);
+       for (obj = 1; obj <= 100; obj++)
+               if (place[obj] == plac[dragon] || place[obj] == fixd[dragon])
+                       move(obj, k);
+       loc = k;
+       k = null;
+       return (8);
 }
 
 
 int
-trtoss()                                /* 9170: throw                  */
-{       int i;
-       if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2;
-       if (!toting(obj)) return(2011);
-       if (obj>=50&&obj<=maxtrs&&at(troll))
-       {       spk=159;                        /* 9178                 */
-               drop(obj,0);
-               move(troll,0);
-               move(troll+100,0);
-               drop(troll2,plac[troll]);
-               drop(troll2+100,fixd[troll]);
+trtoss()
+{                              /* 9170: throw                  */
+       int     i;
+       if (toting(rod2) && obj == rod && !toting(rod))
+               obj = rod2;
+       if (!toting(obj))
+               return (2011);
+       if (obj >= 50 && obj <= maxtrs && at(troll)) {
+               spk = 159;      /* 9178                 */
+               drop(obj, 0);
+               move(troll, 0);
+               move(troll + 100, 0);
+               drop(troll2, plac[troll]);
+               drop(troll2 + 100, fixd[troll]);
                juggle(chasm);
-               return(2011);
-       }
-       if (obj==food&&here(bear))
-       {       obj=bear;                       /* 9177                 */
-               return(9210);
-       }
-       if (obj!=axe) return(9020);
-       for (i=1; i<=5; i++)
-       {       if (dloc[i]==loc)
-               {       spk=48;                 /* 9172                 */
-                       if (ran(3)==0||saved!= -1)
-               l9175:  {       rspeak(spk);
-                               drop(axe,loc);
-                               k=null;
-                               return(8);
+               return (2011);
+       }
+       if (obj == food && here(bear)) {
+               obj = bear;     /* 9177                 */
+               return (9210);
+       }
+       if (obj != axe)
+               return (9020);
+       for (i = 1; i <= 5; i++) {
+               if (dloc[i] == loc) {
+                       spk = 48;       /* 9172                 */
+                       if (ran(3) == 0 || saved != -1)
+       l9175:          {
+                               rspeak(spk);
+                               drop(axe, loc);
+                               k = null;
+                               return (8);
                        }
-                       dseen[i]=FALSE;
-                       dloc[i]=0;
-                       spk=47;
+                       dseen[i] = FALSE;
+                       dloc[i] = 0;
+                       spk = 47;
                        dkill++;
-                       if (dkill==1) spk=149;
+                       if (dkill == 1)
+                               spk = 149;
                        goto l9175;
                }
        }
-       spk=152;
-       if (at(dragon)&&prop[dragon]==0)
+       spk = 152;
+       if (at(dragon) && prop[dragon] == 0)
                goto l9175;
-       spk=158;
-       if (at(troll)) goto l9175;
-       if (here(bear)&&prop[bear]==0)
-       {       spk=164;
-               drop(axe,loc);
-               fixed[axe]= -1;
-               prop[axe]=1;
+       spk = 158;
+       if (at(troll))
+               goto l9175;
+       if (here(bear) && prop[bear] == 0) {
+               spk = 164;
+               drop(axe, loc);
+               fixed[axe] = -1;
+               prop[axe] = 1;
                juggle(bear);
-               return(2011);
+               return (2011);
        }
-       obj=0;
-       return(9120);
+       obj = 0;
+       return (9120);
 }
 
 
 int
-trfeed()                                        /* 9210                 */
-{       if (obj==bird)
-       {       spk=100;
-               return(2011);
-       }
-       if (obj==snake||obj==dragon||obj==troll)
-       {       spk=102;
-               if (obj==dragon&&prop[dragon]!=0) spk=110;
-               if (obj==troll) spk=182;
-               if (obj!=snake||closed||!here(bird)) return(2011);
-               spk=101;
+trfeed()
+{                              /* 9210                 */
+       if (obj == bird) {
+               spk = 100;
+               return (2011);
+       }
+       if (obj == snake || obj == dragon || obj == troll) {
+               spk = 102;
+               if (obj == dragon && prop[dragon] != 0)
+                       spk = 110;
+               if (obj == troll)
+                       spk = 182;
+               if (obj != snake || closed || !here(bird))
+                       return (2011);
+               spk = 101;
                dstroy(bird);
-               prop[bird]=0;
+               prop[bird] = 0;
                tally2++;
-               return(2011);
+               return (2011);
        }
-       if (obj==dwarf)
-       {       if (!here(food)) return(2011);
-               spk=103;
+       if (obj == dwarf) {
+               if (!here(food))
+                       return (2011);
+               spk = 103;
                dflag++;
-               return(2011);
+               return (2011);
        }
-       if (obj==bear)
-       {       if (prop[bear]==0) spk=102;
-               if (prop[bear]==3) spk=110;
-               if (!here(food)) return(2011);
+       if (obj == bear) {
+               if (prop[bear] == 0)
+                       spk = 102;
+               if (prop[bear] == 3)
+                       spk = 110;
+               if (!here(food))
+                       return (2011);
                dstroy(food);
-               prop[bear]=1;
-               fixed[axe]=0;
-               prop[axe]=0;
-               spk=168;
-               return(2011);
-       }
-       spk=14;
-       return(2011);
+               prop[bear] = 1;
+               fixed[axe] = 0;
+               prop[axe] = 0;
+               spk = 168;
+               return (2011);
+       }
+       spk = 14;
+       return (2011);
 }
 
 
 int
-trfill()                                        /* 9220 */
-{       if (obj==vase)
-       {       spk=29;
-               if (liqloc(loc)==0) spk=144;
-               if (liqloc(loc)==0||!toting(vase)) return(2011);
+trfill()
+{                              /* 9220 */
+       if (obj == vase) {
+               spk = 29;
+               if (liqloc(loc) == 0)
+                       spk = 144;
+               if (liqloc(loc) == 0 || !toting(vase))
+                       return (2011);
                rspeak(145);
-               prop[vase]=2;
-               fixed[vase]= -1;
-               return(9020);           /* advent/10 goes to 9024 */
-       }
-       if (obj!=0&&obj!=bottle) return(2011);
-       if (obj==0&&!here(bottle)) return(8000);
-       spk=107;
-       if (liqloc(loc)==0) spk=106;
-       if (liq(0)!=0) spk=105;
-       if (spk!=107) return(2011);
-       prop[bottle]=((cond[loc]%4)/2)*2;
-       k=liq(0);
-       if (toting(bottle)) place[k]= -1;
-       if (k==oil) spk=108;
-       return(2011);
+               prop[vase] = 2;
+               fixed[vase] = -1;
+               return (9020);  /* advent/10 goes to 9024 */
+       }
+       if (obj != 0 && obj != bottle)
+               return (2011);
+       if (obj == 0 && !here(bottle))
+               return (8000);
+       spk = 107;
+       if (liqloc(loc) == 0)
+               spk = 106;
+       if (liq(0) != 0)
+               spk = 105;
+       if (spk != 107)
+               return (2011);
+       prop[bottle] = ((cond[loc] % 4) / 2) * 2;
+       k = liq(0);
+       if (toting(bottle))
+               place[k] = -1;
+       if (k == oil)
+               spk = 108;
+       return (2011);
 }
 
 
 int
-closing()                               /* 10000 */
-{       int i;
-
-       prop[grate]=prop[fissur]=0;
-       for (i=1; i<=6; i++)
-       {       dseen[i]=FALSE;
-               dloc[i]=0;
-       }
-       move(troll,0);
-       move(troll+100,0);
-       move(troll2,plac[troll]);
-       move(troll2+100,fixd[troll]);
+closing()
+{                              /* 10000 */
+       int     i;
+
+       prop[grate] = prop[fissur] = 0;
+       for (i = 1; i <= 6; i++) {
+               dseen[i] = FALSE;
+               dloc[i] = 0;
+       }
+       move(troll, 0);
+       move(troll + 100, 0);
+       move(troll2, plac[troll]);
+       move(troll2 + 100, fixd[troll]);
        juggle(chasm);
-       if(prop[bear]!=3) dstroy(bear);
-       prop[chain]=0;
-       fixed[chain]=0;
-       prop[axe]=0;
-       fixed[axe]=0;
+       if (prop[bear] != 3)
+               dstroy(bear);
+       prop[chain] = 0;
+       fixed[chain] = 0;
+       prop[axe] = 0;
+       fixed[axe] = 0;
        rspeak(129);
        clock1 = -1;
-       closng=TRUE;
-       return(19999);
+       closng = TRUE;
+       return (19999);
 }
 
 
 int
-caveclose()                             /* 11000 */
-{       int i;
-       prop[bottle]=put(bottle,115,1);
-       prop[plant]=put(plant,115,0);
-       prop[oyster]=put(oyster,115,0);
-       prop[lamp]=put(lamp,115,0);
-       prop[rod]=put(rod,115,0);
-       prop[dwarf]=put(dwarf,115,0);
-       loc=115;
-       oldloc=115;
-       newloc=115;
-
-       put(grate,116,0);
-       prop[snake]=put(snake,116,1);
-       prop[bird]=put(bird,116,1);
-       prop[cage]=put(cage,116,0);
-       prop[rod2]=put(rod2,116,0);
-       prop[pillow]=put(pillow,116,0);
-
-       prop[mirror]=put(mirror,115,0);
-       fixed[mirror]=116;
-
-       for (i=1; i<=100; i++)
-               if (toting(i)) dstroy(i);
+caveclose()
+{                              /* 11000 */
+       int     i;
+       prop[bottle] = put(bottle, 115, 1);
+       prop[plant] = put(plant, 115, 0);
+       prop[oyster] = put(oyster, 115, 0);
+       prop[lamp] = put(lamp, 115, 0);
+       prop[rod] = put(rod, 115, 0);
+       prop[dwarf] = put(dwarf, 115, 0);
+       loc = 115;
+       oldloc = 115;
+       newloc = 115;
+
+       put(grate, 116, 0);
+       prop[snake] = put(snake, 116, 1);
+       prop[bird] = put(bird, 116, 1);
+       prop[cage] = put(cage, 116, 0);
+       prop[rod2] = put(rod2, 116, 0);
+       prop[pillow] = put(pillow, 116, 0);
+
+       prop[mirror] = put(mirror, 115, 0);
+       fixed[mirror] = 116;
+
+       for (i = 1; i <= 100; i++)
+               if (toting(i))
+                       dstroy(i);
        rspeak(132);
-       closed=TRUE;
-       return(2);
+       closed = TRUE;
+       return (2);
 }
index 2548724133b04214f1a3425f8c0b4c3cf62ee52c..2090b4706615ff30e44525b32af5764a9d19dca2 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: vocab.c,v 1.4 1997/10/10 11:59:56 lukem Exp $  */
+/*     $NetBSD: vocab.c,v 1.5 1997/10/11 01:53:38 lukem Exp $  */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,9 +43,9 @@
 #if 0
 static char sccsid[] = "@(#)vocab.c    8.1 (Berkeley) 5/31/93";
 #else
-__RCSID("$NetBSD: vocab.c,v 1.4 1997/10/10 11:59:56 lukem Exp $");
+__RCSID("$NetBSD: vocab.c,v 1.5 1997/10/11 01:53:38 lukem Exp $");
 #endif
-#endif /* not lint */
+#endif                         /* not lint */
 
 /*      Re-coding of advent in C: data structure routines               */
 
@@ -56,184 +56,211 @@ __RCSID("$NetBSD: vocab.c,v 1.4 1997/10/10 11:59:56 lukem Exp $");
 
 void
 dstroy(object)
-int object;
-{       move(object,0);
+       int     object;
+{
+       move(object, 0);
 }
 
 void
 juggle(object)
-int object;
-{       int i,j;
+       int     object;
+{
+       int     i, j;
 
-       i=place[object];
-       j=fixed[object];
-       move(object,i);
-       move(object+100,j);
+       i = place[object];
+       j = fixed[object];
+       move(object, i);
+       move(object + 100, j);
 }
 
 
 void
-move(object,where)
-int object,where;
-{       int from;
+move(object, where)
+       int     object, where;
+{
+       int     from;
 
-       if (object<=100)
-               from=place[object];
+       if (object <= 100)
+               from = place[object];
        else
-               from=fixed[object-100];
-       if (from>0 && from<=300) carry(object,from);
-       drop(object,where);
+               from = fixed[object - 100];
+       if (from > 0 && from <= 300)
+               carry(object, from);
+       drop(object, where);
 }
 
 int
-put(object,where,pval)
-int object,where,pval;
-{       move(object,where);
-       return(-1-pval);
+put(object, where, pval)
+       int     object, where, pval;
+{
+       move(object, where);
+       return (-1 - pval);
 }
 
 void
-carry(object,where)
-int object,where;
-{       int temp;
+carry(object, where)
+       int     object, where;
+{
+       int     temp;
 
-       if (object<=100)
-       {       if (place[object]== -1) return;
+       if (object <= 100) {
+               if (place[object] == -1)
+                       return;
                place[object] = -1;
                holdng++;
        }
-       if (atloc[where]==object)
-       {       atloc[where]=links[object];
+       if (atloc[where] == object) {
+               atloc[where] = links[object];
                return;
        }
-       for (temp=atloc[where]; links[temp]!=object; temp=links[temp]);
-       links[temp]=links[object];
+       for (temp = atloc[where]; links[temp] != object; temp = links[temp]);
+       links[temp] = links[object];
 }
 
 
 void
-drop(object,where)
-int object,where;
-{      if (object>100) fixed[object-100]=where;
-       else
-       {       if (place[object]== -1) holdng--;
-               place[object]=where;
+drop(object, where)
+       int     object, where;
+{
+       if (object > 100)
+               fixed[object - 100] = where;
+       else {
+               if (place[object] == -1)
+                       holdng--;
+               place[object] = where;
        }
-       if (where<=0) return;
-       links[object]=atloc[where];
-       atloc[where]=object;
+       if (where <= 0)
+               return;
+       links[object] = atloc[where];
+       atloc[where] = object;
 }
 
 int
-vocab(word,type,value)                  /* look up or store a word      */
-char *word;
-int type;       /* -2 for store, -1 for user word, >=0 for canned lookup*/
-int value;                              /* used for storing only        */
-{       int adr;
-       char *s,*t;
-       int hash, i;
+vocab(word, type, value)       /* look up or store a word      */
+       char   *word;
+       int     type;           /* -2 for store, -1 for user word, >=0 for
+                                * canned lookup */
+       int     value;          /* used for storing only        */
+{
+       int     adr;
+       char   *s, *t;
+       int     hash, i;
        struct hashtab *h;
 
-       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   */
-
-       for(adr=hash;; adr++)           /* look for entry in table      */
-       {       if (adr==HTSIZE) adr=0; /* wrap around                  */
-               h = &voc[adr];          /* point at the entry           */
-               switch(type)
-               {   case -2:            /* fill in entry                */
-                       if (h->val)     /* already got an entry?        */
+       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   */
+
+       for (adr = hash;; adr++) {      /* look for entry in table      */
+               if (adr == HTSIZE)
+                       adr = 0;/* wrap around                  */
+               h = &voc[adr];  /* point at the entry           */
+               switch (type) {
+               case -2:        /* fill in entry                */
+                       if (h->val)     /* already got an entry?        */
                                goto exitloop2;
-                       h->val=value;
-                       h->atab=malloc(length(word));
-                       for (s=word,t=h->atab; *s;)
+                       h->val = value;
+                       h->atab = malloc(length(word));
+                       for (s = word, t = h->atab; *s;)
                                *t++ = *s++ ^ '=';
-                       *t=0^'=';
+                       *t = 0 ^ '=';
                        /* encrypt slightly to thwart core reader       */
-               /*      printf("Stored \"%s\" (%d ch) as entry %d\n",   */
-               /*              word, length(word), adr);               */
-                       return(0);      /* entry unused                 */
-                   case -1:            /* looking up user word         */
-                       if (h->val==0) return(-1);   /* not found    */
-                       for (s=word, t=h->atab;*t ^ '=';)
+                       /* printf("Stored \"%s\" (%d ch) as entry %d\n",   */
+                       /* word, length(word), adr);               */
+                       return (0);     /* entry unused                 */
+               case -1:        /* looking up user word         */
+                       if (h->val == 0)
+                               return (-1);    /* not found    */
+                       for (s = word, t = h->atab; *t ^ '=';)
                                if ((*s++ ^ '=') != *t++)
                                        goto exitloop2;
-                       if ((*s ^ '=') != *t && s-word<5) goto exitloop2;
+                       if ((*s ^ '=') != *t && s - word < 5)
+                               goto exitloop2;
                        /* the word matched o.k.                        */
-                       return(h->val);
-                   default:            /* looking up known word        */
-                       if (h->val==0)
-                       {       printf("Unable to find %s in vocab\n",word);
+                       return (h->val);
+               default:        /* looking up known word        */
+                       if (h->val == 0) {
+                               printf("Unable to find %s in vocab\n", word);
                                exit(0);
                        }
-                       for (s=word, t=h->atab;*t ^ '=';)
-                               if ((*s++ ^ '=') != *t++) goto exitloop2;
+                       for (s = word, t = h->atab; *t ^ '=';)
+                               if ((*s++ ^ '=') != *t++)
+                                       goto exitloop2;
                        /* the word matched o.k.                        */
-                       if (h->val/1000 != type) continue;
-                       return(h->val%1000);
+                       if (h->val / 1000 != type)
+                               continue;
+                       return (h->val % 1000);
                }
 
-           exitloop2:                  /* hashed entry does not match  */
-               if (adr+1==hash || (adr==HTSIZE && hash==0))
-               {       printf("Hash table overflow\n");
+exitloop2:                     /* hashed entry does not match  */
+               if (adr + 1 == hash || (adr == HTSIZE && hash == 0)) {
+                       printf("Hash table overflow\n");
                        exit(0);
                }
        }
 }
 
 void
-copystr(w1,w2)                          /* copy one string to another   */
-char *w1,*w2;
-{       char *s,*t;
-       for (s=w1,t=w2; *s;)
+copystr(w1, w2)                        /* copy one string to another   */
+       char   *w1, *w2;
+{
+       char   *s, *t;
+       for (s = w1, t = w2; *s;)
                *t++ = *s++;
-       *t=0;
+       *t = 0;
 }
 
 int
-weq(w1,w2)                              /* compare words                */
-char *w1,*w2;                           /* w1 is user, w2 is system     */
-{       char *s,*t;
-       int i;
-       s=w1;
-       t=w2;
-       for (i=0; i<5; i++)             /* compare at most 5 chars      */
-       {       if (*t==0 && *s==0)
-                       return(TRUE);
-               if (*s++ != *t++) return(FALSE);
+weq(w1, w2)                    /* compare words                */
+       char   *w1, *w2;        /* w1 is user, w2 is system     */
+{
+       char   *s, *t;
+       int     i;
+       s = w1;
+       t = w2;
+       for (i = 0; i < 5; i++) {       /* compare at most 5 chars      */
+               if (*t == 0 && *s == 0)
+                       return (TRUE);
+               if (*s++ != *t++)
+                       return (FALSE);
        }
-       return(TRUE);
+       return (TRUE);
 }
 
 int
-length(str)                             /* includes 0 at end            */
-char *str;
-{       char *s;
-       int n;
-       for (n=0,s=str; *s++;) n++;
-       return(n+1);
+length(str)                    /* includes 0 at end            */
+       char   *str;
+{
+       char   *s;
+       int     n;
+       for (n = 0, s = str; *s++;)
+               n++;
+       return (n + 1);
 }
 
 void
-prht()                                  /* print hash table             */
-{       int i,j,l;
-       char *c;
+prht()
+{                              /* print hash table             */
+       int     i, j, l;
+       char   *c;
        struct hashtab *h;
-       for (i=0; i<HTSIZE/10+1; i++)
-       {       printf("%4d",i*10);
-               for (j=0; j<10; j++)
-               {       if (i*10+j>=HTSIZE) break;
-                       h= &voc[i*10+j];
+       for (i = 0; i < HTSIZE / 10 + 1; i++) {
+               printf("%4d", i * 10);
+               for (j = 0; j < 10; j++) {
+                       if (i * 10 + j >= HTSIZE)
+                               break;
+                       h = &voc[i * 10 + j];
                        putchar(' ');
-                       if (h->val==0)
-                       {       printf("-----");
+                       if (h->val == 0) {
+                               printf("-----");
                                continue;
                        }
-                       for (l=0, c=h->atab; l<5; l++)
-                               if ((*c ^ '=')) putchar(*c++ ^ '=');
-                               else putchar(' ');
+                       for (l = 0, c = h->atab; l < 5; l++)
+                               if ((*c ^ '='))
+                                       putchar(*c++ ^ '=');
+                               else
+                                       putchar(' ');
                }
                putchar('\n');
        }
index 86d556fce35a7fe614696bce10c58a6a16f7ea84..ae06421954343e03c622715650279fb3eff39a46 100644 (file)
@@ -1,4 +1,4 @@
-/*     $NetBSD: wizard.c,v 1.5 1997/10/10 12:00:02 lukem Exp $ */
+/*     $NetBSD: wizard.c,v 1.6 1997/10/11 01:53:40 lukem Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -43,9 +43,9 @@
 #if 0
 static char sccsid[] = "@(#)wizard.c   8.1 (Berkeley) 6/2/93";
 #else
-__RCSID("$NetBSD: wizard.c,v 1.5 1997/10/10 12:00:02 lukem Exp $");
+__RCSID("$NetBSD: wizard.c,v 1.6 1997/10/11 01:53:40 lukem Exp $");
 #endif
-#endif /* not lint */
+#endif                         /* not lint */
 
 /*      Re-coding of advent in C: privileged operations                 */
 
@@ -57,82 +57,90 @@ __RCSID("$NetBSD: wizard.c,v 1.5 1997/10/10 12:00:02 lukem Exp $");
 #include "extern.h"
 
 void
-datime(d,t)
-int *d,*t;
-{       time_t tvec;
+datime(d, t)
+       int    *d, *t;
+{
+       time_t  tvec;
        struct tm *tptr;
 
        time(&tvec);
-       tptr=localtime(&tvec);
+       tptr = localtime(&tvec);
        /* day since 1977  (mod leap)   */
-       *d=tptr->tm_yday +365*(tptr->tm_year-77);
+       *d = tptr->tm_yday + 365 * (tptr->tm_year - 77);
        /* bug: this will overflow in the year 2066 AD                  */
        /* it will be attributed to Wm the C's millenial celebration    */
        /* and minutes since midnite */
-       *t=tptr->tm_hour*60+tptr->tm_min;
-}                                       /* pretty painless              */
+       *t = tptr->tm_hour * 60 + tptr->tm_min;
+}                              /* pretty painless              */
 
 
-char magic[6];
+char    magic[6];
 
 void
 poof()
 {
-       strcpy(magic, DECR('d','w','a','r','f'));
+       strcpy(magic, DECR('d', 'w', 'a', 'r', 'f'));
        latncy = 45;
 }
 
 int
 Start(n)
-{       int d,t,delay;
+{
+       int     d, t, delay;
 
-       datime(&d,&t);
-       delay=(d-saved)*1440+(t-savet); /* good for about a month     */
+       datime(&d, &t);
+       delay = (d - saved) * 1440 + (t - savet);       /* good for about a
+                                                        * month     */
 
-       if (delay >= latncy)
-       {       saved = -1;
-               return(FALSE);
+       if (delay >= latncy) {
+               saved = -1;
+               return (FALSE);
        }
        printf("This adventure was suspended a mere %d minute%s ago.",
-               delay, delay == 1? "" : "s");
-       if (delay <= latncy/3)
-       {       mspeak(2);
+           delay, delay == 1 ? "" : "s");
+       if (delay <= latncy / 3) {
+               mspeak(2);
                exit(0);
        }
        mspeak(8);
-       if (!wizard())
-       {       mspeak(9);
+       if (!wizard()) {
+               mspeak(9);
                exit(0);
        }
        saved = -1;
-       return(FALSE);
+       return (FALSE);
 }
 
 int
-wizard()                /* not as complex as advent/10 (for now)        */
-{      char *word,*x;
-       if (!yesm(16,0,7)) return(FALSE);
+wizard()
+{                              /* not as complex as advent/10 (for now)        */
+       char   *word, *x;
+       if (!yesm(16, 0, 7))
+               return (FALSE);
        mspeak(17);
-       getin(&word,&x);
-       if (!weq(word,magic))
-       {       mspeak(20);
-               return(FALSE);
+       getin(&word, &x);
+       if (!weq(word, magic)) {
+               mspeak(20);
+               return (FALSE);
        }
        mspeak(19);
-       return(TRUE);
+       return (TRUE);
 }
 
 void
 ciao(cmdfile)
-char *cmdfile;
-{       char *c;
-       char fname[80];
+       char   *cmdfile;
+{
+       char   *c;
+       char    fname[80];
 
        printf("What would you like to call the saved version?\n");
-       for (c=fname;; c++)
-               if ((*c=getchar())=='\n') break;
-       *c=0;
-       if (save(fname) != 0) return;           /* Save failed */
+       for (c = fname;; c++)
+               if ((*c = getchar()) == '\n')
+                       break;
+       *c = 0;
+       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");
        exit(0);
@@ -141,10 +149,10 @@ char *cmdfile;
 
 int
 ran(range)
-int range;
+       int     range;
 {
-       long i;
+       long    i;
 
        i = rand() % range;
-       return(i);
+       return (i);
 }