|
|
1.1 root 1: #
2: /* Re-coding of advent in C: data initialization */
3:
4: static char sccsid[] = " init.c 4.1 82/05/11 ";
5:
6: # include "hdr.h"
7:
8: int blklin = TRUE;
9: int setup = 0;
10:
11: int setbit[16] = {1,2,4,010,020,040,0100,0200,0400,01000,02000,04000,
12: 010000,020000,040000,0100000};
13:
14:
15: init(command) /* everything for 1st time run */
16: char *command; /* command we were called with */
17: { int stat,adfd;
18: rdata(); /* read data from orig. file */
19: linkdata();
20: poof();
21: setup=1; /* indicate that data is in */
22: if (confirm("got the data. save as \"advent\"? "))
23: { if (save(command,"advent")<0) /* save core image */
24: { printf("Save failed\n");
25: exit(0);
26: }
27: }
28: else exit(0);
29: printf("Save succeeded. Adding messages.\n");
30: adfd=open("advent",1);
31: lseek(adfd,0L,2);
32: close(datfd);
33: if (fork()==0) /* child process */
34: { close(1);
35: dup(adfd); /* output goes to advent file */
36: execl("/bin/cat","cat",TMPFILE,0);
37: printf("unable to find /bin/cat\n");
38: }
39: wait(&stat);
40: unlink(TMPFILE);
41: printf("Advent is ready.\n");
42: exit(0);
43: }
44:
45:
46: linkdata() /* secondary data manipulation */
47: { register int i,j;
48: /* array linkages */
49: for (i=1; i<=LOCSIZ; i++)
50: if (ltext[i].seekadr!=0 && travel[i] != 0)
51: if ((travel[i]->tverb)==1) cond[i]=2;
52: for (j=100; j>0; j--)
53: if (fixd[j]>0)
54: { drop(j+100,fixd[j]);
55: drop(j,plac[j]);
56: }
57: for (j=100; j>0; j--)
58: { fixed[j]=fixd[j];
59: if (plac[j]!=0 && fixd[j]<=0) drop(j,plac[j]);
60: }
61:
62: maxtrs=79;
63: tally=0;
64: tally2=0;
65:
66: for (i=50; i<=maxtrs; i++)
67: { if (ptext[i].seekadr!=0) prop[i] = -1;
68: tally -= prop[i];
69: }
70:
71: /* define mnemonics */
72: keys=vocab("keys",1);
73: lamp=vocab("lamp",1);
74: grate=vocab("grate",1);
75: cage=vocab("cage",1);
76: rod=vocab("rod",1);
77: rod2=rod+1;
78: steps=vocab("steps",1);
79: bird=vocab("bird",1);
80: door=vocab("door",1);
81: pillow=vocab("pillow",1);
82: snake=vocab("snake",1);
83: fissur=vocab("fissu",1);
84: tablet=vocab("table",1);
85: clam=vocab("clam",1);
86: oyster=vocab("oyster",1);
87: magzin=vocab("magaz",1);
88: dwarf=vocab("dwarf",1);
89: knife=vocab("knife",1);
90: food=vocab("food",1);
91: bottle=vocab("bottl",1);
92: water=vocab("water",1);
93: oil=vocab("oil",1);
94: plant=vocab("plant",1);
95: plant2=plant+1;
96: axe=vocab("axe",1);
97: mirror=vocab("mirro",1);
98: dragon=vocab("drago",1);
99: chasm=vocab("chasm",1);
100: troll=vocab("troll",1);
101: troll2=troll+1;
102: bear=vocab("bear",1);
103: messag=vocab("messa",1);
104: vend=vocab("vendi",1);
105: batter=vocab("batte",1);
106:
107: nugget=vocab("gold",1);
108: coins=vocab("coins",1);
109: chest=vocab("chest",1);
110: eggs=vocab("eggs",1);
111: tridnt=vocab("tride",1);
112: vase=vocab("vase",1);
113: emrald=vocab("emera",1);
114: pyram=vocab("pyram",1);
115: pearl=vocab("pearl",1);
116: rug=vocab("rug",1);
117: chain=vocab("chain",1);
118:
119: back=vocab("back",0);
120: look=vocab("look",0);
121: cave=vocab("cave",0);
122: null=vocab("null",0);
123: entrnc=vocab("entra",0);
124: dprssn=vocab("depre",0);
125:
126: say=vocab("say",2);
127: lock=vocab("lock",2);
128: throw=vocab("throw",2);
129: find=vocab("find",2);
130: invent=vocab("inven",2);
131: /* initialize dwarves */
132: chloc=114;
133: chloc2=140;
134: for (i=1; i<=6; i++)
135: dseen[i]=FALSE;
136: dflag=0;
137: dloc[1]=19;
138: dloc[2]=27;
139: dloc[3]=33;
140: dloc[4]=44;
141: dloc[5]=64;
142: dloc[6]=chloc;
143: daltlc=18;
144:
145: /* random flags & ctrs */
146: turns=0;
147: lmwarn=FALSE;
148: iwest=0;
149: knfloc=0;
150: detail=0;
151: abbnum=5;
152: for (i=0; i<=4; i++)
153: if (rtext[2*i+81].seekadr!=0) maxdie=i+1;
154: numdie=holdng=dkill=foobar=bonus=0;
155: clock1=30;
156: clock2=50;
157: saved=0;
158: closng=panic=closed=scorng=FALSE;
159: }
160:
161:
162:
163: trapdel() /* come here if he hits a del */
164: { delhit++; /* main checks, treats as QUIT */
165: signal(2,trapdel); /* catch subsequent DELs */
166: }
167:
168:
169: startup()
170: { int tvec[2];
171: demo=start(0);
172: time(tvec);
173: srand(tvec[1]|1); /* random odd seed */
174: /* srand(371); */ /* non-random seed */
175: hinted[3]=yes(65,1,0);
176: newloc=1;
177: setup=3;
178: limit=330;
179: if (hinted[3]) limit=1000; /* better batteries if instrucs */
180: }
181:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.