kernel - Remove mplock in process trap/signal code (non-performance)
[dragonfly.git] / games / adventure / init.c
blobbeb36313e188fd5492dce1ff75763f01dc005b72
1 /*-
2 * Copyright (c) 1993
3 * The Regents of the University of California. All rights reserved.
5 * The game adventure was originally written in Fortran by Will Crowther
6 * and Don Woods. It was later translated to C and enhanced by Jim
7 * Gillogly. This code is derived from software contributed to Berkeley
8 * by Jim Gillogly at The Rand Corporation.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * @(#)init.c 8.1 (Berkeley) 6/2/93
35 * $FreeBSD: src/games/adventure/init.c,v 1.9.2.1 2001/03/05 11:43:11 kris Exp $
36 * $DragonFly: src/games/adventure/init.c,v 1.4 2007/04/18 18:32:12 swildner Exp $
39 /* Re-coding of advent in C: data initialization */
41 #include <sys/types.h>
42 #include <signal.h>
43 #include <stdio.h>
44 #include <stdlib.h>
45 #include "hdr.h"
47 int blklin = TRUE;
49 int setbit[16] = { 1, 2, 4, 010, 020, 040, 0100, 0200, 0400, 01000, 02000,
50 04000, 010000, 020000, 040000, 0100000 };
52 static void linkdata (void);
54 /* everything for 1st time run */
55 void
56 init(void)
58 rdata(); /* read data from orig. file */
59 linkdata();
60 poof();
63 char *
64 decr(const char *a, const char *b, const char *c, const char *d, const char *e)
66 static char buf[6];
68 buf[0] = a[0];
69 buf[1] = b[0];
70 buf[2] = c[0];
71 buf[3] = d[0];
72 buf[4] = e[0];
73 buf[5] = 0;
74 return buf;
77 /* secondary data manipulation */
78 static void
79 linkdata(void)
81 int i, j;
83 /* array linkages */
84 for (i = 1; i < LOCSIZ; i++)
85 if (ltext[i].seekadr != 0 && travel[i] != 0)
86 if ((travel[i]->tverb) == 1)
87 cond[i] = 2;
88 for (j = 100; j > 0; j--)
89 if (fixd[j] > 0) {
90 drop(j + 100, fixd[j]);
91 drop(j, plac[j]);
93 for (j = 100; j > 0; j--) {
94 fixed[j] = fixd[j];
95 if (plac[j] != 0 && fixd[j] <= 0)
96 drop(j, plac[j]);
99 maxtrs = 79;
100 tally = 0;
101 tally2 = 0;
103 for (i = 50; i <= maxtrs; i++) {
104 if (ptext[i].seekadr != 0)
105 prop[i] = -1;
106 tally -= prop[i];
109 /* define mnemonics */
110 keys = vocab(DECR(k,e,y,s,\0), 1, 0);
111 lamp = vocab(DECR(l,a,m,p,\0), 1, 0);
112 grate = vocab(DECR(g,r,a,t,e), 1, 0);
113 cage = vocab(DECR(c,a,g,e,\0),1, 0);
114 rod = vocab(DECR(r,o,d,\0,\0),1, 0);
115 rod2 = rod + 1;
116 steps = vocab(DECR(s,t,e,p,s),1, 0);
117 bird = vocab(DECR(b,i,r,d,\0),1, 0);
118 door = vocab(DECR(d,o,o,r,\0),1, 0);
119 pillow= vocab(DECR(p,i,l,l,o), 1, 0);
120 snake = vocab(DECR(s,n,a,k,e), 1, 0);
121 fissur= vocab(DECR(f,i,s,s,u), 1, 0);
122 tablet= vocab(DECR(t,a,b,l,e), 1, 0);
123 clam = vocab(DECR(c,l,a,m,\0),1, 0);
124 oyster= vocab(DECR(o,y,s,t,e), 1, 0);
125 magzin= vocab(DECR(m,a,g,a,z), 1, 0);
126 dwarf = vocab(DECR(d,w,a,r,f), 1, 0);
127 knife = vocab(DECR(k,n,i,f,e), 1, 0);
128 food = vocab(DECR(f,o,o,d,\0),1, 0);
129 bottle= vocab(DECR(b,o,t,t,l), 1, 0);
130 water = vocab(DECR(w,a,t,e,r), 1, 0);
131 oil = vocab(DECR(o,i,l,\0,\0),1, 0);
132 plant = vocab(DECR(p,l,a,n,t), 1, 0);
133 plant2 = plant + 1;
134 axe = vocab(DECR(a,x,e,\0,\0), 1, 0);
135 mirror= vocab(DECR(m,i,r,r,o), 1, 0);
136 dragon= vocab(DECR(d,r,a,g,o), 1, 0);
137 chasm = vocab(DECR(c,h,a,s,m), 1, 0);
138 troll = vocab(DECR(t,r,o,l,l), 1, 0);
139 troll2 = troll + 1;
140 bear = vocab(DECR(b,e,a,r,\0),1, 0);
141 messag= vocab(DECR(m,e,s,s,a), 1, 0);
142 vend = vocab(DECR(v,e,n,d,i), 1, 0);
143 batter= vocab(DECR(b,a,t,t,e), 1, 0);
145 nugget= vocab(DECR(g,o,l,d,\0),1, 0);
146 coins = vocab(DECR(c,o,i,n,s), 1, 0);
147 chest = vocab(DECR(c,h,e,s,t), 1, 0);
148 eggs = vocab(DECR(e,g,g,s,\0),1, 0);
149 tridnt= vocab(DECR(t,r,i,d,e), 1, 0);
150 vase = vocab(DECR(v,a,s,e,\0),1, 0);
151 emrald= vocab(DECR(e,m,e,r,a), 1, 0);
152 pyram = vocab(DECR(p,y,r,a,m), 1, 0);
153 pearl = vocab(DECR(p,e,a,r,l), 1, 0);
154 rug = vocab(DECR(r,u,g,\0,\0),1, 0);
155 chain = vocab(DECR(c,h,a,i,n), 1, 0);
157 back = vocab(DECR(b,a,c,k,\0),0, 0);
158 look = vocab(DECR(l,o,o,k,\0),0, 0);
159 cave = vocab(DECR(c,a,v,e,\0),0, 0);
160 null = vocab(DECR(n,u,l,l,\0),0, 0);
161 entrnc= vocab(DECR(e,n,t,r,a), 0, 0);
162 dprssn= vocab(DECR(d,e,p,r,e), 0, 0);
163 enter = vocab(DECR(e,n,t,e,r), 0, 0);
165 pour = vocab(DECR(p,o,u,r,\0), 2, 0);
166 say = vocab(DECR(s,a,y,\0,\0),2, 0);
167 lock = vocab(DECR(l,o,c,k,\0),2, 0);
168 throw = vocab(DECR(t,h,r,o,w), 2, 0);
169 find = vocab(DECR(f,i,n,d,\0),2, 0);
170 invent= vocab(DECR(i,n,v,e,n), 2, 0);
172 /* initialize dwarves */
173 chloc = 114;
174 chloc2 = 140;
175 for (i = 1; i <= 6; i++)
176 dseen[i] = FALSE;
177 dflag = 0;
178 dloc[1] = 19;
179 dloc[2] = 27;
180 dloc[3] = 33;
181 dloc[4] = 44;
182 dloc[5] = 64;
183 dloc[6] = chloc;
184 daltlc = 18;
186 /* random flags & ctrs */
187 turns = 0;
188 lmwarn = FALSE;
189 iwest = 0;
190 knfloc = 0;
191 detail = 0;
192 abbnum = 5;
193 for (i = 0; i <= 4; i++)
194 if (rtext[2 * i + 81].seekadr != 0)
195 maxdie = i + 1;
196 numdie = holdng = dkill = foobar = bonus = 0;
197 clock1 = 30;
198 clock2 = 50;
199 saved = 0;
200 closng = panic = closed = scorng = FALSE;
203 /* come here if he hits a del */
204 void
205 trapdel(int sig __unused)
207 delhit = 1; /* main checks, treats as QUIT */
208 signal(SIGINT, trapdel); /* catch subsequent DELs */
211 void
212 startup(void)
214 demo = Start();
215 srandomdev();
216 hinted[3] = yes(65, 1, 0);
217 newloc = 1;
218 delhit = 0;
219 limit = 330;
220 if (hinted[3])
221 limit = 1000; /* better batteries if instrucs */