KNFify
This commit is contained in:
parent
8e80f913ed
commit
84f80fd691
@ -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. */
|
||||
}
|
||||
|
@ -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
|
||||
@ -43,75 +43,95 @@
|
||||
#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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
@ -55,107 +55,108 @@
|
||||
|
||||
/* 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 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 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 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;
|
||||
int demo, newloc, limit;
|
||||
|
||||
#define DECR(a,b,c,d,e) decr(a+'+',b+'-',c+'#',d+'&',e+'%')
|
||||
|
@ -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
|
||||
@ -43,11 +43,11 @@
|
||||
#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;
|
||||
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]);
|
||||
/* 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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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 */
|
||||
}
|
||||
|
@ -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;
|
||||
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;
|
||||
*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;
|
||||
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 */
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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); */
|
||||
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;
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
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(<ext[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(<ext[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);
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
@ -43,114 +43,113 @@
|
||||
#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;
|
||||
|
@ -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
|
||||
@ -40,15 +40,15 @@
|
||||
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);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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 (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 (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');
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user