1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-03 12:35:02 +00:00

-Wall fixes.

XXX: This code is sick, and so are some of the "fixes".
This commit is contained in:
Bill Fumerola 1999-12-19 00:21:51 +00:00
parent ee1dd7c481
commit 0d687f3b75
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54797
11 changed files with 295 additions and 168 deletions

View File

@ -44,6 +44,7 @@ static const char rcsid[] =
#endif /* not lint */
#include <sys/types.h>
#include "hdr.h"
const u_long crctab[] = {
0x7fffffff,
@ -111,6 +112,7 @@ const u_long crctab[] = {
u_long crcval;
u_int step;
void
crc_start()
{
crcval = step = 0;

View File

@ -49,6 +49,7 @@ static const char rcsid[] =
#include <stdio.h>
#include "hdr.h"
int
score() /* sort of like 20000 */
{ int scor,i;
mxscor=scor=0;
@ -85,6 +86,7 @@ score() /* sort of like 20000 */
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;

View File

@ -49,6 +49,8 @@
*
* The data file distributed with the fortran source is assumed to be called
* "glorkz" in the directory where the program is first run.
*
* $FreeBSD$
*/
/* hdr.h: included by c advent files */
@ -154,12 +156,63 @@ int chloc,chloc2,dseen[7],dloc[7], /* dwarf stuff */
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;
closng,panic,closed,scorng;
int demo,newloc,limit;
int demo,limit;
char *decr();
unsigned long crc();
int at(int);
int bug(int);
void carry(int,int);
void caveclose(void);
void checkhints(void);
void ciao(void);
void closing(void);
unsigned long crc(const char *, int);
void crc_start(void);
int dark(void);
void datime(int *, int *);
char *decr(char,char,char,char,char);
void die(int);
void done(int);
void drop(int,int);
void dstroy(int);
int fdwarf(void);
int forced(int);
void getin(char **, char **);
int here(int);
void init(void);
void juggle(int);
int liq(void);
int liqloc(int);
int march(void);
void move(int,int);
void mspeak(int);
int pct(int);
void poof(void);
void pspeak(int, int);
int put(int,int,int);
int ran(int);
void rdata(void);
int restore(const char *);
void rspeak(int);
int save(const char *);
int score(void);
void speak(const struct text *);
int Start(void);
void startup(void);
int toting(int);
void trapdel(int);
int trdrop(void);
int trfeed(void);
int trfill(void);
int trkill(void);
int tropen(void);
int trsay(void);
int trtake(void);
int trtoss(void);
int vocab(const char *,int,int);
int yes(int,int,int);
int yesm(int,int,int);
/* We need to get a little tricky to avoid strings */
#define DECR(a,b,c,d,e) decr('a'+'+','b'+'-','c'+'#','d'+'&','e'+'%')

View File

@ -57,7 +57,9 @@ int blklin = TRUE;
int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000,
010000,020000,040000,0100000};
static void linkdata (void);
void
init() /* everything for 1st time run */
{
rdata(); /* read data from orig. file */
@ -79,6 +81,7 @@ char a,b,c,d,e;
return buf;
}
static void
linkdata() /* secondary data manipulation */
{ int i,j;
@ -106,67 +109,67 @@ linkdata() /* secondary data manipulation */
}
/* define mnemonics */
keys = vocab(DECR(k,e,y,s,\0), 1);
lamp = vocab(DECR(l,a,m,p,\0), 1);
grate = vocab(DECR(g,r,a,t,e), 1);
cage = vocab(DECR(c,a,g,e,\0),1);
rod = vocab(DECR(r,o,d,\0,\0),1);
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);
bird = vocab(DECR(b,i,r,d,\0),1);
door = vocab(DECR(d,o,o,r,\0),1);
pillow= vocab(DECR(p,i,l,l,o), 1);
snake = vocab(DECR(s,n,a,k,e), 1);
fissur= vocab(DECR(f,i,s,s,u), 1);
tablet= vocab(DECR(t,a,b,l,e), 1);
clam = vocab(DECR(c,l,a,m,\0),1);
oyster= vocab(DECR(o,y,s,t,e), 1);
magzin= vocab(DECR(m,a,g,a,z), 1);
dwarf = vocab(DECR(d,w,a,r,f), 1);
knife = vocab(DECR(k,n,i,f,e), 1);
food = vocab(DECR(f,o,o,d,\0),1);
bottle= vocab(DECR(b,o,t,t,l), 1);
water = vocab(DECR(w,a,t,e,r), 1);
oil = vocab(DECR(o,i,l,\0,\0),1);
plant = vocab(DECR(p,l,a,n,t), 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);
mirror= vocab(DECR(m,i,r,r,o), 1);
dragon= vocab(DECR(d,r,a,g,o), 1);
chasm = vocab(DECR(c,h,a,s,m), 1);
troll = vocab(DECR(t,r,o,l,l), 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);
messag= vocab(DECR(m,e,s,s,a), 1);
vend = vocab(DECR(v,e,n,d,i), 1);
batter= vocab(DECR(b,a,t,t,e), 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);
coins = vocab(DECR(c,o,i,n,s), 1);
chest = vocab(DECR(c,h,e,s,t), 1);
eggs = vocab(DECR(e,g,g,s,\0),1);
tridnt= vocab(DECR(t,r,i,d,e), 1);
vase = vocab(DECR(v,a,s,e,\0),1);
emrald= vocab(DECR(e,m,e,r,a), 1);
pyram = vocab(DECR(p,y,r,a,m), 1);
pearl = vocab(DECR(p,e,a,r,l), 1);
rug = vocab(DECR(r,u,g,\0,\0),1);
chain = vocab(DECR(c,h,a,i,n), 1);
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);
look = vocab(DECR(l,o,o,k,\0),0);
cave = vocab(DECR(c,a,v,e,\0),0);
null = vocab(DECR(n,u,l,l,\0),0);
entrnc= vocab(DECR(e,n,t,r,a), 0);
dprssn= vocab(DECR(d,e,p,r,e), 0);
enter = vocab(DECR(e,n,t,e,r), 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);
say = vocab(DECR(s,a,y,\0,\0),2);
lock = vocab(DECR(l,o,c,k,\0),2);
throw = vocab(DECR(t,h,r,o,w), 2);
find = vocab(DECR(f,i,n,d,\0),2);
invent= vocab(DECR(i,n,v,e,n), 2);
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;
@ -200,12 +203,15 @@ linkdata() /* secondary data manipulation */
trapdel() /* come here if he hits a del */
void
trapdel(sig) /* come here if he hits a del */
int sig;
{ delhit = 1; /* main checks, treats as QUIT */
signal(2,trapdel); /* catch subsequent DELs */
}
void
startup()
{
demo=Start();

View File

@ -52,7 +52,20 @@ static const char rcsid[] =
#include <string.h>
#include <err.h>
static int next (void);
static int rnum (void);
static void rdesc (int);
static void rdflt (void);
static void rhints (void);
static void rliq (void);
static void rlocs (void);
static void rtrav (void);
static void rvoc (void);
#ifdef DEBUG
static void twrite (int);
#endif
void
getin(wrd1,wrd2) /* get command from user */
char **wrd1,**wrd2; /* no prompt, usually */
{ char *s;
@ -98,10 +111,12 @@ char **wrd1,**wrd2; /* no prompt, usually */
}
}
int
yes(x,y,z) /* confirm with rspeak */
int x,y,z;
{ int result;
int ch;
result = FALSE;
for (;;)
{ rspeak(x); /* tell him what we want*/
if ((ch=getchar())=='y')
@ -120,10 +135,12 @@ int x,y,z;
return(result);
}
int
yesm(x,y,z) /* confirm with mspeak */
int x,y,z;
{ int result;
int ch;
result = FALSE;
for (;;)
{ mspeak(x); /* tell him what we want*/
if ((ch=getchar())=='y')
@ -151,6 +168,7 @@ int outsw = 0; /* putting stuff to data file? */
const char iotape[] = "Ax3F'\003tt$8h\315qer*h\017nGKrX\207:!l";
const char *tape = iotape; /* pointer to encryption tape */
static int
next() /* next virtual char, bump adr */
{
int ch;
@ -166,6 +184,7 @@ next() /* next virtual char, bump adr */
char breakch; /* tell which char ended rnum */
void
rdata() /* "read" data from virtual file*/
{ int sect;
char ch;
@ -236,6 +255,7 @@ rdata() /* "read" data from virtual file*/
char nbf[12];
static int
rnum() /* read initial location num */
{ char *s;
tape = iotape; /* restart encryption tape */
@ -250,12 +270,12 @@ rnum() /* read initial location num */
char *seekhere;
static void
rdesc(sect) /* read description-format msgs */
int sect;
{ char *s,*t;
{
int locc;
char *seekstart, *maystart, *adrstart;
char *entry;
char *seekstart, *maystart;
seekhere = inptr; /* Where are we in virtual file?*/
outsw=1; /* these msgs go into tmp file */
@ -315,18 +335,23 @@ int sect;
}
static void
rtrav() /* read travel table */
{ int locc;
struct travlist *t;
char *s;
char buf[12];
int len,m,n,entries;
entries = 0;
t = NULL;
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 DEBUG
printf("%d:%d entries\n",oldloc,entries);
twrite(oldloc);
#endif
}
if (locc== -1) return;
if (locc!=oldloc) /* getting a new entry */
@ -337,7 +362,8 @@ rtrav() /* read travel table */
entries=0;
oldloc=locc;
}
for (s=buf;; *s++) /* get the newloc number /ASCII */
s = buf;
for (;; s++) /* get the newloc number /ASCII */
if ((*s=next())==TAB || *s==LF) break;
*s=0;
len=strlen(buf); /* quad long number handling */
@ -367,6 +393,7 @@ rtrav() /* read travel table */
#ifdef DEBUG
static void
twrite(loq) /* travel options from this loc */
int loq;
{ struct travlist *t;
@ -387,6 +414,7 @@ int loq;
#endif DEBUG
static void
rvoc()
{ char *s; /* read the vocabulary */
int index;
@ -403,10 +431,10 @@ rvoc()
/* printf("\"%s\"=%d\n",buf,index);*/
vocab(buf,-2,index);
}
/* prht(); */
}
static void
rlocs() /* initial object locations */
{ for (;;)
{ if ((obj=rnum())<0) break;
@ -417,6 +445,7 @@ rlocs() /* initial object locations */
}
}
static void
rdflt() /* default verb messages */
{ for (;;)
{ if ((verb=rnum())<0) break;
@ -424,6 +453,7 @@ rdflt() /* default verb messages */
}
}
static void
rliq() /* liquid assets &c: cond bits */
{ int bitnum;
for (;;) /* read new bit list */
@ -435,6 +465,7 @@ rliq() /* liquid assets &c: cond bits */
}
}
static void
rhints()
{ int hintnum,i;
hntmax=0;
@ -447,18 +478,21 @@ rhints()
}
void
rspeak(msg)
int msg;
{ if (msg!=0) speak(&rtext[msg]);
}
void
mspeak(msg)
int msg;
{ if (msg!=0) speak(&mtext[msg]);
}
void
speak(msg) /* read, decrypt, and print a message (not ptext) */
const struct text *msg;/* msg is a pointer to seek address and length of mess */
{
@ -483,6 +517,7 @@ const struct text *msg;/* msg is a pointer to seek address and length of mess */
}
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*/

View File

@ -53,21 +53,22 @@ static const char rcsid[] =
/* Re-coding of advent in C: main program */
#include <sys/file.h>
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "hdr.h"
int
main(argc,argv)
int argc;
char **argv;
{
extern int errno;
int i;
int rval,ll;
struct text *kk;
extern trapdel();
/* revoke */
setgid(getgid());
@ -117,7 +118,7 @@ char **argv;
}
kk = &rtext[16];
}
l2001: if (toting(bear)) rspeak(141); /* 2001 */
if (toting(bear)) rspeak(141); /* 2001 */
speak(kk);
k=1;
if (forced(loc))
@ -222,11 +223,11 @@ char **argv;
if ((strncmp(wd1,"water",5)&&strncmp(wd1,"oil",3))
|| (strncmp(wd2,"plant",5)&&strncmp(wd2,"door",4)))
goto l2610;
if (at(vocab(wd2,1))) strcpy(wd2,"pour");
if (at(vocab(wd2,1,0))) strcpy(wd2,"pour");
l2610: if (!strncmp(wd1,"west",4))
if (++iwest==10) rspeak(17);
l2630: i=vocab(wd1,-1);
l2630: i=vocab(wd1,-1,0);
if (i== -1)
{ spk=60; /* 3000 */
if (pct(20)) spk=61;
@ -263,7 +264,6 @@ char **argv;
if (*wd2!=0 && verb!=say) goto l2800;
if (verb==say) obj= *wd2;
if (obj!=0) goto l4090;
l4080:
switch(verb)
{ case 1: /* take = 8010 */
if (atloc[loc]==0||linkx[atloc[loc]]!=0) goto l8000;
@ -329,7 +329,7 @@ char **argv;
if (gaveup) done(2);
goto l2012;
case 25: /* foo: 8250 */
k=vocab(wd1,3);
k=vocab(wd1,3,0);
spk=42;
if (foobar==1-k) goto l8252;
if (foobar!=0) spk=151;
@ -394,7 +394,7 @@ char **argv;
case 2012: goto l2012;
default: bug(105);
}
l9030: case 3:
case 3:
switch(trsay())
{ case 2012: goto l2012;
case 2630: goto l2630;
@ -533,7 +533,7 @@ char **argv;
||!closed) goto l2011;
hinted[2]=yes(192,193,54);
goto l2012;
l9280: case 28: /* break */
case 28: /* break */
if (obj==mirror) spk=148;
if (obj==vase&&prop[vase]==0)
{ spk=198;
@ -546,7 +546,7 @@ char **argv;
rspeak(197);
done(3);
l9290: case 29: /* wake */
case 29: /* wake */
if (obj!=dwarf||!closed) goto l2011;
rspeak(199);
done(3);

View File

@ -57,70 +57,71 @@ struct savestruct
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),
linkx, sizeof(linkx),
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)},
{linkx, sizeof(linkx)},
{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 */
const char *outfile; /* to output the data using checksum to start random #s */
{
@ -154,6 +155,7 @@ const char *outfile; /* to output the data using checksum to start random #s */
return 0;
}
int
restore(infile)
const char *infile;
{
@ -163,6 +165,7 @@ const char *infile;
long sum, cksum;
int i;
cksum = 0;
if ((in = fopen(infile, "rb")) == NULL)
{
fprintf(stderr,

View File

@ -73,6 +73,7 @@ static const char rcsid[] =
#define LINE 10 /* How many values do we get on a line? */
int
main(argc, argv)
int argc;
char *argv[];
@ -88,7 +89,7 @@ char *argv[];
puts(SIG1);
puts(SIG2);
puts(" */");
printf("\n\nchar data_file[] =\n{");
printf("\n\nconst char data_file[] =\n{");
srandom(SEED);
count = 0;
linestart = YES;

View File

@ -50,30 +50,43 @@ static const char rcsid[] =
#include <string.h>
# include "hdr.h"
static void badmove (void);
static int bitset (int,int);
static int dropper (void);
static int liq2 (int);
static int mback (void);
static int specials (void);
static int trbridge (void);
/* Statement functions */
int
toting(objj)
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
at(objj)
int objj;
{ if (place[objj]==loc || fixed[objj]==loc) return(TRUE);
else return (FALSE);
}
static int
liq2(pbotl)
int pbotl;
{ return((1-pbotl)*water+(pbotl/2)*(water+oil));
}
int
liq()
{ int i;
i=prop[bottle];
@ -81,6 +94,7 @@ liq()
else return(liq2(-1-i));
}
int
liqloc(locc) /* may want to clean this one up a bit */
int locc;
{ int i,j,l;
@ -91,24 +105,28 @@ int locc;
return(liq2(j*l+1));
}
static int
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
dark()
{ 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);
@ -116,6 +134,7 @@ int n;
}
int
fdwarf() /* 71 */
{ int i,j;
struct travlist *kk;
@ -234,6 +253,7 @@ fdwarf() /* 71 */
}
int
march() /* label 8 */
{ int ll1,ll2;
@ -299,6 +319,7 @@ l11: ll1=tkk->conditions; /* 11 */
static int
mback() /* 20 */
{ struct travlist *tk2,*j;
int ll;
@ -333,6 +354,7 @@ mback() /* 20 */
}
static int
specials() /* 30000 */
{ switch(newloc -= 300)
{ case 1: /* 30100 */
@ -348,9 +370,12 @@ specials() /* 30000 */
return(trbridge());
default: bug(29);
}
/* NOTREACHED */
return(-1);
}
static int
trbridge() /* 30300 */
{ if (prop[troll]==1)
{ pspeak(troll,1);
@ -378,7 +403,7 @@ trbridge() /* 30300 */
}
int
static void
badmove() /* 20 */
{ spk=12;
if (k>=43 && k<=50) spk=9;
@ -438,10 +463,11 @@ checkhints() /* 2600 &c */
}
int
trsay() /* 9030 */
{ int i;
if (*wd2!=0) strcpy(wd1,wd2);
i=vocab(wd1,-1);
i=vocab(wd1,-1,0);
if (i==62||i==65||i==71||i==2025)
{ *wd2=0;
obj=0;
@ -452,8 +478,9 @@ trsay() /* 9030 */
}
int
trtake() /* 9010 */
{ int i;
{
if (toting(obj)) return(2011); /* 9010 */
spk=25;
if (obj==plant&&prop[plant]<=0) spk=115;
@ -497,6 +524,7 @@ l9014: if ((obj==bird||obj==cage)&&prop[bird]!=0)
}
static int
dropper() /* 9021 */
{ k=liq();
if (k==obj) obj=bottle;
@ -507,6 +535,7 @@ dropper() /* 9021 */
return(2012);
}
int
trdrop() /* 9020 */
{
if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2;
@ -553,6 +582,7 @@ trdrop() /* 9020 */
}
int
tropen() /* 9040 */
{ if (obj==clam||obj==oyster)
{ k=0; /* 9046 */
@ -608,6 +638,7 @@ tropen() /* 9040 */
}
int
trkill() /* 9120 */
{ int i;
for (i=1; i<=5; i++)
@ -665,6 +696,7 @@ trkill() /* 9120 */
}
int
trtoss() /* 9170: throw */
{ int i;
if (toting(rod2)&&obj==rod&&!toting(rod)) obj=rod2;
@ -719,6 +751,7 @@ trtoss() /* 9170: throw */
}
int
trfeed() /* 9210 */
{ if (obj==bird)
{ spk=100;
@ -757,6 +790,7 @@ trfeed() /* 9210 */
}
int
trfill() /* 9220 */
{ if (obj==vase)
{ spk=29;

View File

@ -51,11 +51,13 @@ static const char rcsid[] =
#include <err.h>
#include "hdr.h"
void
dstroy(object)
int object;
{ move(object,0);
}
void
juggle(object)
int object;
{ int i,j;
@ -67,6 +69,7 @@ int object;
}
void
move(object,where)
int object,where;
{ int from;
@ -80,12 +83,14 @@ int object,where;
}
int
put(object,where,pval)
int object,where,pval;
{ move(object,where);
return(-1-pval);
}
void
carry(object,where)
int object,where;
{ int temp;
@ -104,6 +109,7 @@ int object,where;
}
void
drop(object,where)
int object,where;
{ if (object>100) fixed[object-100]=where;
@ -117,6 +123,7 @@ int object,where;
}
int
vocab(word,type,value) /* look up or store a word */
const char *word;
int type; /* -2 for store, -1 for user word, >=0 for canned lookup*/
@ -175,25 +182,3 @@ int value; /* used for storing only */
}
}
}
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];
putchar(' ');
if (h->val==0)
{ printf("-----");
continue;
}
for (l=0, c=h->atab; l<5; l++)
if ((*c ^ '=')) putchar(*c++ ^ '=');
else putchar(' ');
}
putchar('\n');
}
}

View File

@ -53,6 +53,9 @@ static const char rcsid[] =
#include <time.h>
# include "hdr.h"
static int wizard (void);
void
datime(d,t)
int *d,*t;
{ struct tm *tptr;
@ -73,12 +76,14 @@ int *d,*t;
char magic[6];
void
poof()
{
strcpy(magic, DECR(d,w,a,r,f));
latncy = 45;
}
int
Start()
{ int d,t,delay;
@ -104,8 +109,9 @@ Start()
return(FALSE);
}
static int
wizard() /* not as complex as advent/10 (for now) */
{ int wiz;
{
char *word,*x;
if (!yesm(16,0,7)) return(FALSE);
mspeak(17);
@ -118,11 +124,10 @@ wizard() /* not as complex as advent/10 (for now) */
return(TRUE);
}
void
ciao()
{ char *c;
int outfd, size;
char fname[80], buf[512];
extern unsigned filesize;
char fname[80];
printf("What would you like to call the saved version?\n");
/* XXX - should use fgetln to avoid arbitrary limit */
@ -141,6 +146,7 @@ ciao()
}
int
ran(range)
int range;
{