147851Sbostic /*- 2*60735Sbostic * Copyright (c) 1993 The Regents of the University of California. 347851Sbostic * All rights reserved. 447851Sbostic * 559968Sbostic * The game adventure was originally written in Fortran by Will Crowther 659968Sbostic * and Don Woods. It was later translated to C and enhanced by Jim 759968Sbostic * Gillogly. This code is derived from software contributed to Berkeley 859968Sbostic * by Jim Gillogly at The Rand Corporation. 947851Sbostic * 1047851Sbostic * %sccs.include.redist.c% 1147851Sbostic */ 1247851Sbostic 13*60735Sbostic #ifndef lint 14*60735Sbostic static char sccsid[] = "@(#)init.c 5.3 (Berkeley) 05/31/93"; 15*60735Sbostic #endif /* not lint */ 16*60735Sbostic 176735Srrh /* Re-coding of advent in C: data initialization */ 186735Srrh 1937005Sbostic #include <sys/types.h> 2037005Sbostic #include <stdio.h> 2137005Sbostic #include "hdr.h" 226735Srrh 236735Srrh int blklin = TRUE; 246735Srrh 256735Srrh int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000, 266735Srrh 010000,020000,040000,0100000}; 276735Srrh 286735Srrh 296735Srrh init(command) /* everything for 1st time run */ 306735Srrh char *command; /* command we were called with */ 3159968Sbostic { 326735Srrh rdata(); /* read data from orig. file */ 336735Srrh linkdata(); 346735Srrh poof(); 356735Srrh } 366735Srrh 3759968Sbostic char *decr(a,b,c,d,e) 3859968Sbostic char a,b,c,d,e; 3959968Sbostic { 4059968Sbostic static char buf[6]; 416735Srrh 4259968Sbostic buf[0] = a-'+'; 4359968Sbostic buf[1] = b-'-'; 4459968Sbostic buf[2] = c-'#'; 4559968Sbostic buf[3] = d-'&'; 4659968Sbostic buf[4] = e-'%'; 4759968Sbostic buf[5] = 0; 4859968Sbostic return buf; 4959968Sbostic } 5059968Sbostic 516735Srrh linkdata() /* secondary data manipulation */ 526735Srrh { register int i,j; 5359968Sbostic 546735Srrh /* array linkages */ 556735Srrh for (i=1; i<=LOCSIZ; i++) 566735Srrh if (ltext[i].seekadr!=0 && travel[i] != 0) 576735Srrh if ((travel[i]->tverb)==1) cond[i]=2; 586735Srrh for (j=100; j>0; j--) 596735Srrh if (fixd[j]>0) 606735Srrh { drop(j+100,fixd[j]); 616735Srrh drop(j,plac[j]); 626735Srrh } 636735Srrh for (j=100; j>0; j--) 646735Srrh { fixed[j]=fixd[j]; 656735Srrh if (plac[j]!=0 && fixd[j]<=0) drop(j,plac[j]); 666735Srrh } 676735Srrh 686735Srrh maxtrs=79; 696735Srrh tally=0; 706735Srrh tally2=0; 716735Srrh 726735Srrh for (i=50; i<=maxtrs; i++) 736735Srrh { if (ptext[i].seekadr!=0) prop[i] = -1; 746735Srrh tally -= prop[i]; 756735Srrh } 766735Srrh 776735Srrh /* define mnemonics */ 7859968Sbostic keys = vocab(DECR(k,e,y,s,\0), 1); 7959968Sbostic lamp = vocab(DECR(l,a,m,p,\0), 1); 8059968Sbostic grate = vocab(DECR(g,r,a,t,e), 1); 8159968Sbostic cage = vocab(DECR(c,a,g,e,\0),1); 8259968Sbostic rod = vocab(DECR(r,o,d,\0,\0),1); 836735Srrh rod2=rod+1; 8459968Sbostic steps=vocab(DECR(s,t,e,p,s),1); 8559968Sbostic bird = vocab(DECR(b,i,r,d,\0),1); 8659968Sbostic door = vocab(DECR(d,o,o,r,\0),1); 8759968Sbostic pillow= vocab(DECR(p,i,l,l,o), 1); 8859968Sbostic snake = vocab(DECR(s,n,a,k,e), 1); 8959968Sbostic fissur= vocab(DECR(f,i,s,s,u), 1); 9059968Sbostic tablet= vocab(DECR(t,a,b,l,e), 1); 9159968Sbostic clam = vocab(DECR(c,l,a,m,\0),1); 9259968Sbostic oyster= vocab(DECR(o,y,s,t,e), 1); 9359968Sbostic magzin= vocab(DECR(m,a,g,a,z), 1); 9459968Sbostic dwarf = vocab(DECR(d,w,a,r,f), 1); 9559968Sbostic knife = vocab(DECR(k,n,i,f,e), 1); 9659968Sbostic food = vocab(DECR(f,o,o,d,\0),1); 9759968Sbostic bottle= vocab(DECR(b,o,t,t,l), 1); 9859968Sbostic water = vocab(DECR(w,a,t,e,r), 1); 9959968Sbostic oil = vocab(DECR(o,i,l,\0,\0),1); 10059968Sbostic plant = vocab(DECR(p,l,a,n,t), 1); 1016735Srrh plant2=plant+1; 10259968Sbostic axe = vocab(DECR(a,x,e,\0,\0),1); 10359968Sbostic mirror= vocab(DECR(m,i,r,r,o), 1); 10459968Sbostic dragon= vocab(DECR(d,r,a,g,o), 1); 10559968Sbostic chasm = vocab(DECR(c,h,a,s,m), 1); 10659968Sbostic troll = vocab(DECR(t,r,o,l,l), 1); 1076735Srrh troll2=troll+1; 10859968Sbostic bear = vocab(DECR(b,e,a,r,\0),1); 10959968Sbostic messag= vocab(DECR(m,e,s,s,a), 1); 11059968Sbostic vend = vocab(DECR(v,e,n,d,i), 1); 11159968Sbostic batter= vocab(DECR(b,a,t,t,e), 1); 1126735Srrh 11359968Sbostic nugget= vocab(DECR(g,o,l,d,\0),1); 11459968Sbostic coins = vocab(DECR(c,o,i,n,s), 1); 11559968Sbostic chest = vocab(DECR(c,h,e,s,t), 1); 11659968Sbostic eggs = vocab(DECR(e,g,g,s,\0),1); 11759968Sbostic tridnt= vocab(DECR(t,r,i,d,e), 1); 11859968Sbostic vase = vocab(DECR(v,a,s,e,\0),1); 11959968Sbostic emrald= vocab(DECR(e,m,e,r,a), 1); 12059968Sbostic pyram = vocab(DECR(p,y,r,a,m), 1); 12159968Sbostic pearl = vocab(DECR(p,e,a,r,l), 1); 12259968Sbostic rug = vocab(DECR(r,u,g,\0,\0),1); 12359968Sbostic chain = vocab(DECR(c,h,a,i,n), 1); 1246735Srrh 12559968Sbostic back = vocab(DECR(b,a,c,k,\0),0); 12659968Sbostic look = vocab(DECR(l,o,o,k,\0),0); 12759968Sbostic cave = vocab(DECR(c,a,v,e,\0),0); 12859968Sbostic null = vocab(DECR(n,u,l,l,\0),0); 12959968Sbostic entrnc= vocab(DECR(e,n,t,r,a), 0); 13059968Sbostic dprssn= vocab(DECR(d,e,p,r,e), 0); 13159968Sbostic enter = vocab(DECR(e,n,t,e,r), 0); 1326735Srrh 13359968Sbostic pour = vocab(DECR(p,o,u,r,\0), 2); 13459968Sbostic say = vocab(DECR(s,a,y,\0,\0),2); 13559968Sbostic lock = vocab(DECR(l,o,c,k,\0),2); 13659968Sbostic throw = vocab(DECR(t,h,r,o,w), 2); 13759968Sbostic find = vocab(DECR(f,i,n,d,\0),2); 13859968Sbostic invent= vocab(DECR(i,n,v,e,n), 2); 13959968Sbostic 1406735Srrh /* initialize dwarves */ 1416735Srrh chloc=114; 1426735Srrh chloc2=140; 1436735Srrh for (i=1; i<=6; i++) 1446735Srrh dseen[i]=FALSE; 1456735Srrh dflag=0; 1466735Srrh dloc[1]=19; 1476735Srrh dloc[2]=27; 1486735Srrh dloc[3]=33; 1496735Srrh dloc[4]=44; 1506735Srrh dloc[5]=64; 1516735Srrh dloc[6]=chloc; 1526735Srrh daltlc=18; 1536735Srrh 1546735Srrh /* random flags & ctrs */ 1556735Srrh turns=0; 1566735Srrh lmwarn=FALSE; 1576735Srrh iwest=0; 1586735Srrh knfloc=0; 1596735Srrh detail=0; 1606735Srrh abbnum=5; 1616735Srrh for (i=0; i<=4; i++) 1626735Srrh if (rtext[2*i+81].seekadr!=0) maxdie=i+1; 1636735Srrh numdie=holdng=dkill=foobar=bonus=0; 1646735Srrh clock1=30; 1656735Srrh clock2=50; 1666735Srrh saved=0; 1676735Srrh closng=panic=closed=scorng=FALSE; 1686735Srrh } 1696735Srrh 1706735Srrh 1716735Srrh 1726735Srrh trapdel() /* come here if he hits a del */ 1736735Srrh { delhit++; /* main checks, treats as QUIT */ 1746735Srrh signal(2,trapdel); /* catch subsequent DELs */ 1756735Srrh } 1766735Srrh 1776735Srrh 1786735Srrh startup() 17937005Sbostic { 18037005Sbostic time_t time(); 18137005Sbostic 1826735Srrh demo=start(0); 18337005Sbostic srand((int)(time((time_t *)NULL))); /* random seed */ 18437005Sbostic /* srand(371); /* non-random seed */ 1856735Srrh hinted[3]=yes(65,1,0); 1866735Srrh newloc=1; 18759968Sbostic delhit = 0; 1886735Srrh limit=330; 1896735Srrh if (hinted[3]) limit=1000; /* better batteries if instrucs */ 1906735Srrh } 191