extern.h 9.7 KB

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