Add __attribute__((__noreturn__)) to various function prototypes in games/.
[dragonfly.git] / games / battlestar / externs.h
CommitLineData
6693db17 1/*-
984263bc
MD
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
6693db17 13 * 3. Neither the name of the University nor the names of its contributors
984263bc
MD
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)externs.h 8.1 (Berkeley) 5/31/93
30 *
31 * $FreeBSD: src/games/battlestar/externs.h,v 1.9.2.1 2001/03/05 11:45:36 kris Exp $
32 */
33
34#include <errno.h>
35#include <sys/param.h>
36#include <sys/signal.h>
984263bc
MD
37#include <stdio.h>
38#include <stdlib.h>
5c7cac79 39#include <string.h>
984263bc
MD
40#include <unistd.h>
41
4ff89011 42/* We use our own */
43#undef setbit
44#undef testbit
45#undef clearbit
46
984263bc
MD
47#define BITS (8)
48
49#define OUTSIDE (position > 68 && position < 246 && position != 218)
50#define rnd(x) (random() % (x))
51#define max(a,b) ((a) < (b) ? (b) : (a))
52#define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
984263bc 53#define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
984263bc
MD
54#define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
55
56 /* well known rooms */
57#define FINAL 275
58#define GARDEN 197
59#define POOLS 126
60#define DOCK 93
61
62 /* word types */
63#define VERB 0
64#define OBJECT 1
65#define NOUNS 2
66#define PREPS 3
67#define ADJS 4
68#define CONJ 5
69
70 /* words numbers */
71#define KNIFE 0
72#define SWORD 1
73#define LAND 2
74#define WOODSMAN 3
75#define TWO_HANDED 4
76#define CLEAVER 5
77#define BROAD 6
78#define MAIL 7
79#define HELM 8
80#define SHIELD 9
81#define MAID 10
82#define BODY 10
83#define VIPER 11
84#define LAMPON 12
85#define SHOES 13
86#define CYLON 14
87#define PAJAMAS 15
88#define ROBE 16
89#define AMULET 17
90#define MEDALION 18
91#define TALISMAN 19
92#define DEADWOOD 20
93#define MALLET 21
94#define LASER 22
95#define BATHGOD 23
96#define NORMGOD 24
97#define GRENADE 25
98#define CHAIN 26
99#define ROPE 27
100#define LEVIS 28
101#define MACE 29
102#define SHOVEL 30
103#define HALBERD 31
104#define COMPASS 32
105#define CRASH 33
106#define ELF 34
107#define FOOT 35
108#define COINS 36
109#define MATCHES 37
110#define MAN 38
111#define PAPAYAS 39
112#define PINEAPPLE 40
113#define KIWI 41
114#define COCONUTS 42
115#define MANGO 43
116#define RING 44
117#define POTION 45
118#define BRACELET 46
119#define GIRL 47
120#define GIRLTALK 48
121#define DARK 49
122#define TIMER 50
123#define CHAR 53
124#define BOMB 54
125#define DEADGOD 55
126#define DEADTIME 56
127#define DEADNATIVE 57
128#define NATIVE 58
129#define HORSE 59
130#define CAR 60
131#define POT 61
132#define BAR 62
133#define BLOCK 63
134#define NUMOFOBJECTS 64
135 /* non-objects below */
136#define UP 1000
137#define DOWN 1001
138#define AHEAD 1002
139#define BACK 1003
140#define RIGHT 1004
141#define LEFT 1005
142#define TAKE 1006
143#define USE 1007
144#define LOOK 1008
145#define QUIT 1009
146#define NORTH 1010
147#define SOUTH 1011
148#define EAST 1012
149#define WEST 1013
150#define SU 1014
151#define DROP 1015
152#define TAKEOFF 1016
153#define DRAW 1017
154#define PUTON 1018
155#define WEARIT 1019
156#define PUT 1020
157#define INVEN 1021
158#define EVERYTHING 1022
159#define AND 1023
160#define KILL 1024
161#define RAVAGE 1025
162#define UNDRESS 1026
163#define THROW 1027
164#define LAUNCH 1028
165#define LANDIT 1029
166#define LIGHT 1030
167#define FOLLOW 1031
168#define KISS 1032
169#define LOVE 1033
170#define GIVE 1034
171#define SMITE 1035
172#define SHOOT 1036
173#define ON 1037
174#define OFF 1038
175#define TIME 1039
176#define SLEEP 1040
177#define DIG 1041
178#define EAT 1042
179#define SWIM 1043
180#define DRINK 1044
181#define DOOR 1045
182#define SAVE 1046
183#define RIDE 1047
184#define DRIVE 1048
185#define SCORE 1049
186#define BURY 1050
187#define JUMP 1051
188#define KICK 1052
189
190 /* injuries */
191#define ARM 6 /* broken arm */
192#define RIBS 7 /* broken ribs */
193#define SPINE 9 /* broken back */
194#define SKULL 11 /* fractured skull */
195#define INCISE 10 /* deep incisions */
196#define NECK 12 /* broken NECK */
197#define NUMOFINJURIES 13
198
199 /* notes */
200#define CANTLAUNCH 0
201#define LAUNCHED 1
202#define CANTSEE 2
203#define CANTMOVE 3
204#define JINXED 4
205#define DUG 5
206#define NUMOFNOTES 6
207
208 /* fundamental constants */
209#define NUMOFROOMS 275
210#define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
211#define LINELENGTH 81
212
213#define TODAY 0
214#define TONIGHT 1
215#define CYCLE 100
216
217 /* initial variable values */
218#define TANKFULL 250
219#define TORPEDOES 10
220#define MAXWEIGHT 60
221#define MAXCUMBER 10
222
223struct room {
224 const char *name;
225 int link[8];
226#define north link[0]
227#define south link[1]
228#define east link[2]
229#define west link[3]
230#define up link[4]
231#define access link[5]
232#define down link[6]
233#define flyhere link[7]
234 const char *desc;
235 unsigned int objects[NUMOFWORDS];
236};
237extern struct room dayfile[];
238extern struct room nightfile[];
239struct room *location;
240
241 /* object characteristics */
242extern const char *const objdes[NUMOFOBJECTS];
243extern const char *const objsht[NUMOFOBJECTS];
244extern const char *const ouch[NUMOFINJURIES];
245extern const int objwt[NUMOFOBJECTS];
246extern const int objcumber[NUMOFOBJECTS];
247
248 /* current input line */
249#define NWORD 20 /* words per line */
250char words[NWORD][15];
251int wordvalue[NWORD];
252int wordtype[NWORD];
253int wordcount, wordnumber;
254
984263bc 255 /* state of the game */
6693db17 256extern int gclock;
984263bc
MD
257int gtime;
258int position;
259int direction;
260int left, right, ahead, back;
261int fuel, torps;
262int carrying, encumber;
263int rythmn;
264extern int followfight;
265int ate;
266int snooze;
267int meetgirl;
268extern int followgod;
269int godready;
270extern int bs_win;
271int wintime;
272int wiz;
273int tempwiz;
274int matchlight;
275extern int matchcount;
276int loved;
277int pleasure, power, ego;
278extern int WEIGHT;
279extern int CUMBER;
280int notes[NUMOFNOTES];
281unsigned int inven[NUMOFWORDS];
282u_int wear[NUMOFWORDS];
283char beenthere[NUMOFROOMS+1];
284char injuries[NUMOFINJURIES];
285
286char uname[MAXLOGNAME];
287
288struct wlist {
289 const char *string;
290 int value, article;
291 struct wlist *next;
292};
293#define HASHSIZE 256
294#define HASHMUL 81
295#define HASHMASK (HASHSIZE - 1)
296struct wlist *hashtab[HASHSIZE];
297extern struct wlist wlist[];
298
299struct objs {
300 short room;
301 short obj;
302};
303extern const struct objs dayobjs[];
304extern const struct objs nightobjs[];
305
306extern gid_t egid;
6693db17
SW
307
308
309int battlestar_move(int, int);
310void bury(void);
311int card(const char *, int);
312void chime(void);
313void crash(void);
314int cypher(void);
09ac707a 315void die(int) __dead2;
6693db17
SW
316void dig(void);
317int draw(void);
318void drink(void);
319int drive(void);
320int drop(const char *);
321int eat(void);
322int fight(int, int);
323int follow(void);
324char *getcom(char *, int, const char *, const char *);
325char *getword(char *, char *, int);
326int give(void);
327void initialize(int);
328int jump(void);
329void kiss(void);
330int land(void);
331int launch(void);
332void light(void);
09ac707a 333void live(void) __dead2;
6693db17
SW
334void love(void);
335void murder(void);
336void news(void);
337void newway(int);
338void open_score_file(void);
339void parse(void);
340void printobjs(void);
341int put(void);
342int puton(void);
343const char *rate(void);
344void ravage(void);
345void restore(void);
346int ride(void);
347void save(void);
348int shoot(void);
349int take(unsigned int[]);
350int takeoff(void);
351int throw(const char *);
352const char *truedirec(int, unsigned int);
353int ucard(const unsigned int *);
354int use(void);
355int visual(void);
356int wearit(void);
357void whichway(struct room);
358void wordinit(void);
359void writedes(void);
360int zzz(void);