Add __attribute__((__noreturn__)) to various function prototypes in games/.
[dragonfly.git] / games / larn / header.h
CommitLineData
984263bc
MD
1/* header.h Larn is copyrighted 1986 by Noah Morgan. */
2
88fe92e6
PA
3#include <fcntl.h>
4#include <stdio.h>
984263bc
MD
5#include <stdlib.h>
6#include <string.h>
7#include <termcap.h>
8#include <time.h>
9#include <unistd.h>
10
11#define MAXLEVEL 11
6693db17 12/* max # levels in the dungeon */
984263bc 13#define MAXVLEVEL 3
6693db17 14/* max # of levels in the temple of the luran */
984263bc
MD
15#define MAXX 67
16#define MAXY 17
17
18#define SCORESIZE 10
6693db17 19/* this is the number of people on a scoreboard max */
984263bc 20#define MAXPLEVEL 100
6693db17 21/* maximum player level allowed */
984263bc 22#define MAXMONST 56
6693db17 23/* maximum # monsters in the dungeon */
984263bc 24#define SPNUM 38
6693db17 25/* maximum number of spells in existence */
984263bc 26#define MAXSCROLL 28
6693db17 27/* maximum number of scrolls that are possible */
984263bc 28#define MAXPOTION 35
6693db17 29/* maximum number of potions that are possible */
984263bc 30#define TIMELIMIT 30000
6693db17 31/* the maximum number of moves before the game is called */
984263bc 32#define TAXRATE 1/20
6693db17 33/* the tax rate for the LRS */
984263bc 34#define MAXOBJ 93
6693db17 35/* the maximum number of objects n < MAXOBJ */
984263bc 36
6693db17
SW
37/* this is the structure definition of the monster data */
38struct monst {
88fe92e6 39 const char *name;
984263bc
MD
40 char level;
41 short armorclass;
42 char damage;
43 char attack;
44 char defense;
45 char genocided;
6693db17 46 char intelligence; /* monsters intelligence -- used to choose movement */
984263bc
MD
47 short gold;
48 short hitpoints;
49 unsigned long experience;
6693db17 50};
984263bc 51
6693db17
SW
52/* this is the structure definition for the items in the dnd store */
53struct _itm {
984263bc 54 short price;
88fe92e6
PA
55 short obj;
56 short arg;
57 short qty;
6693db17
SW
58};
59
60/* this is the structure that holds the entire dungeon specifications */
61struct cel {
62 short hitp; /* monster's hit points */
63 char mitem; /* the monster ID */
64 char item; /* the object's ID */
65 short iarg; /* the object's argument */
66 char know; /* have we been here before */
67};
984263bc
MD
68
69/* this is the structure for maintaining & moving the spheres of annihilation */
6693db17 70struct sphere {
984263bc
MD
71 struct sphere *p; /* pointer to next structure */
72 char x,y,lev; /* location of the sphere */
6693db17 73 char dir; /* direction sphere is going in */
984263bc 74 char lifetime; /* duration of the sphere */
6693db17 75};
984263bc 76
6693db17
SW
77/* defines for the character attribute array c[] */
78#define STRENGTH 0 /* characters physical strength not due to objects */
984263bc
MD
79#define INTELLIGENCE 1
80#define WISDOM 2
81#define CONSTITUTION 3
82#define DEXTERITY 4
83#define CHARISMA 5
84#define HPMAX 6
85#define HP 7
86#define GOLD 8
87#define EXPERIENCE 9
88#define LEVEL 10
89#define REGEN 11
90#define WCLASS 12
91#define AC 13
92#define BANKACCOUNT 14
93#define SPELLMAX 15
94#define SPELLS 16
95#define ENERGY 17
96#define ECOUNTER 18
97#define MOREDEFENSES 19
98#define WEAR 20
99#define PROTECTIONTIME 21
100#define WIELD 22
101#define AMULET 23
102#define REGENCOUNTER 24
103#define MOREDAM 25
104#define DEXCOUNT 26
105#define STRCOUNT 27
106#define BLINDCOUNT 28
107#define CAVELEVEL 29
108#define CONFUSE 30
109#define ALTPRO 31
110#define HERO 32
111#define CHARMCOUNT 33
112#define INVISIBILITY 34
113#define CANCELLATION 35
114#define HASTESELF 36
115#define EYEOFLARN 37
116#define AGGRAVATE 38
117#define GLOBE 39
118#define TELEFLAG 40
119#define SLAYING 41
120#define NEGATESPIRIT 42
121#define SCAREMONST 43
122#define AWARENESS 44
123#define HOLDMONST 45
124#define TIMESTOP 46
125#define HASTEMONST 47
126#define CUBEofUNDEAD 48
127#define GIANTSTR 49
128#define FIRERESISTANCE 50
129#define BESSMANN 51
130#define NOTHEFT 52
131#define HARDGAME 53
132#define CPUTIME 54
133#define BYTESIN 55
134#define BYTESOUT 56
135#define MOVESMADE 57
136#define MONSTKILLED 58
137#define SPELLSCAST 59
138#define LANCEDEATH 60
139#define SPIRITPRO 61
140#define UNDEADPRO 62
141#define SHIELD 63
142#define STEALTH 64
143#define ITCHING 65
144#define LAUGHING 66
145#define DRAINSTRENGTH 67
146#define CLUMSINESS 68
147#define INFEEBLEMENT 69
148#define HALFDAM 70
149#define SEEINVISIBLE 71
150#define FILLROOM 72
151#define RANDOMWALK 73
152#define SPHCAST 74 /* nz if an active sphere of annihilation */
153#define WTW 75 /* walk through walls */
154#define STREXTRA 76 /* character strength due to objects or enchantments */
6693db17
SW
155#define TMP 77 /* misc scratch space */
156#define LIFEPROT 78 /* life protection counter */
984263bc 157
6693db17 158/* defines for the objects in the game */
984263bc
MD
159
160#define OALTAR 1
161#define OTHRONE 2
162#define OORB 3
163#define OPIT 4
164#define OSTAIRSUP 5
165#define OELEVATORUP 6
166#define OFOUNTAIN 7
167#define OSTATUE 8
168#define OTELEPORTER 9
169#define OSCHOOL 10
170#define OMIRROR 11
171#define ODNDSTORE 12
172#define OSTAIRSDOWN 13
173#define OELEVATORDOWN 14
174#define OBANK2 15
175#define OBANK 16
176#define ODEADFOUNTAIN 17
177#define OMAXGOLD 70
178#define OGOLDPILE 18
179#define OOPENDOOR 19
180#define OCLOSEDDOOR 20
181#define OWALL 21
182#define OTRAPARROW 66
183#define OTRAPARROWIV 67
184
185#define OLARNEYE 22
186
187#define OPLATE 23
188#define OCHAIN 24
189#define OLEATHER 25
190#define ORING 60
191#define OSTUDLEATHER 61
192#define OSPLINT 62
193#define OPLATEARMOR 63
194#define OSSPLATE 64
195#define OSHIELD 68
196#define OELVENCHAIN 92
197
198#define OSWORDofSLASHING 26
199#define OHAMMER 27
200#define OSWORD 28
201#define O2SWORD 29
202#define OSPEAR 30
203#define ODAGGER 31
204#define OBATTLEAXE 57
205#define OLONGSWORD 58
206#define OFLAIL 59
207#define OLANCE 65
208#define OVORPAL 90
209#define OSLAYER 91
210
211#define ORINGOFEXTRA 32
212#define OREGENRING 33
213#define OPROTRING 34
214#define OENERGYRING 35
215#define ODEXRING 36
216#define OSTRRING 37
217#define OCLEVERRING 38
218#define ODAMRING 39
219
220#define OBELT 40
221
222#define OSCROLL 41
223#define OPOTION 42
224#define OBOOK 43
225#define OCHEST 44
226#define OAMULET 45
227
228#define OORBOFDRAGON 46
229#define OSPIRITSCARAB 47
230#define OCUBEofUNDEAD 48
231#define ONOTHEFT 49
232
233#define ODIAMOND 50
234#define ORUBY 51
235#define OEMERALD 52
236#define OSAPPHIRE 53
237
238#define OENTRANCE 54
239#define OVOLDOWN 55
240#define OVOLUP 56
241#define OHOME 69
242
243#define OKGOLD 71
244#define ODGOLD 72
245#define OIVDARTRAP 73
246#define ODARTRAP 74
247#define OTRAPDOOR 75
248#define OIVTRAPDOOR 76
249#define OTRADEPOST 77
250#define OIVTELETRAP 78
251#define ODEADTHRONE 79
6693db17 252#define OANNIHILATION 80 /* sphere of annihilation */
984263bc 253#define OTHRONE2 81
6693db17 254#define OLRS 82 /* Larn Revenue Service */
984263bc
MD
255#define OCOOKIE 83
256#define OURN 84
257#define OBRASSLAMP 85
258#define OHANDofFEAR 86 /* hand of fear */
259#define OSPHTAILSMAN 87 /* tailsman of the sphere */
6693db17
SW
260#define OWWAND 88 /* wand of wonder */
261#define OPSTAFF 89 /* staff of power */
984263bc
MD
262/* used up to 92 */
263
6693db17 264/* defines for the monsters as objects */
984263bc
MD
265
266#define BAT 1
267#define GNOME 2
268#define HOBGOBLIN 3
269#define JACKAL 4
270#define KOBOLD 5
271#define ORC 6
272#define SNAKE 7
273#define CENTIPEDE 8
274#define JACULI 9
275#define TROGLODYTE 10
276#define ANT 11
277#define EYE 12
278#define LEPRECHAUN 13
279#define NYMPH 14
280#define QUASIT 15
281#define RUSTMONSTER 16
282#define ZOMBIE 17
283#define ASSASSINBUG 18
284#define BUGBEAR 19
285#define HELLHOUND 20
286#define ICELIZARD 21
287#define CENTAUR 22
288#define TROLL 23
289#define YETI 24
290#define WHITEDRAGON 25
291#define ELF 26
292#define CUBE 27
293#define METAMORPH 28
294#define VORTEX 29
295#define ZILLER 30
296#define VIOLETFUNGI 31
297#define WRAITH 32
298#define FORVALAKA 33
299#define LAMANOBE 34
300#define OSEQUIP 35
301#define ROTHE 36
302#define XORN 37
303#define VAMPIRE 38
304#define INVISIBLESTALKER 39
305#define POLTERGEIST 40
306#define DISENCHANTRESS 41
307#define SHAMBLINGMOUND 42
308#define YELLOWMOLD 43
309#define UMBERHULK 44
310#define GNOMEKING 45
311#define MIMIC 46
312#define WATERLORD 47
313#define BRONZEDRAGON 48
314#define GREENDRAGON 49
315#define PURPLEWORM 50
316#define XVART 51
317#define SPIRITNAGA 52
318#define SILVERDRAGON 53
319#define PLATINUMDRAGON 54
320#define GREENURCHIN 55
321#define REDDRAGON 56
322#define DEMONLORD 57
323#define DEMONPRINCE 64
324
6693db17
SW
325#define BUFBIG 4096 /* size of the output buffer */
326#define MAXIBUF 4096 /* size of the input buffer */
327#define LOGNAMESIZE 40 /* max size of the players name */
328#define PSNAMESIZE 40 /* max size of the process name */
984263bc
MD
329
330#ifndef NODEFS
6693db17
SW
331extern char VERSION, SUBVERSION;
332extern char aborted[], alpha[], beenhere[], boldon, cheat, ckpfile[], ckpflag;
333extern char *class[], course[], diagfile[], fortfile[], helpfile[];
334extern char *inbuffer, is_alpha[], is_digit[];
335extern char item[MAXX][MAXY], iven[], know[MAXX][MAXY], larnlevels[], lastmonst[];
336extern char level, *levelname[], logfile[], loginname[], logname[], *lpbuf, *lpend;
337extern char *lpnt, moved[MAXX][MAXY], mitem[MAXX][MAXY], monstlevel[];
338extern char monstnamelist[], nch[], ndgg[], nlpts[], nomove, nosignal, nowelcome;
339extern char nplt[], nsw[], *objectname[];
340extern char objnamelist[], optsfile[], playerids[], potprob[];
341extern char predostuff, psname[], restorflag, savefilename[], scorefile[], scprob[];
342extern char screen[MAXX][MAXY], sex, *spelcode[], *speldescript[];
343extern char spelknow[], *spelname[], *spelmes[], spelweird[MAXMONST + 8][SPNUM];
344extern char splev[], stealth[MAXX][MAXY], to_lower[], to_upper[], wizard;
345extern short diroffx[], diroffy[], hitflag, hit2flag, hit3flag, hitp[MAXX][MAXY];
346extern short iarg[MAXX][MAXY], ivenarg[], lasthx, lasthy, lastnum, lastpx, lastpy;
347extern short nobeep, oldx, oldy, playerx, playery;
348extern int dayplay, enable_scroll, srcount, yrepcount, userid, wisid,
349 io_outfd, io_infd;
350extern time_t initialtime;
351extern long outstanding_taxes, skill[], gtime, c[], cbak[];
984263bc
MD
352extern struct cel *cell;
353extern struct monst monster[];
354extern struct sphere *spheres;
88fe92e6 355extern struct _itm itm_[];
6693db17 356extern const char *potionhide[], *potionname[], *scrollhide[], *scrollname[];
984263bc 357
88fe92e6 358/* bill.c */
09ac707a 359void mailbill(void) __dead2;
88fe92e6
PA
360
361/* create.c */
362void makeplayer(void);
363void newcavelevel(int);
364void eat(int, int);
365int fillmonst(char);
366
367/* diag.c */
368#ifdef EXTRA
369int diag(void);
370#endif
371int savegame(char *);
372void restoregame(char *);
373
374/* display.c */
375void bottomline(void);
376void bottomhp(void);
377void bottomspell(void);
378void bottomdo(void);
379void bot_linex(void);
380void bottomgold(void);
381void draws(int, int, int, int);
382void drawscreen(void);
383void showcell(int, int);
384void show1cell(int, int);
385void showplayer(void);
386int moveplayer(int);
387void seemagic(int);
388
389/* fortune.c */
390const char *fortune(void);
391
392/* global.c */
393void raiselevel(void);
394void loselevel(void);
395void raiseexperience(long);
396void loseexperience(long);
397void losehp(int);
398void losemhp(int);
399void raisehp(int);
400void raisemhp(int);
401void raisemspells(int);
402void losemspells(int);
403int makemonst(int);
404void positionplayer(void);
405void recalc(void);
406void quit(void);
407void more(void);
408int take(int, int);
409int drop_object(int);
410void enchantarmor(void);
411void enchweapon(void);
412int pocketfull(void);
413int nearbymonst(void);
414int stealsomething(void);
415int emptyhanded(void);
416void creategem(void);
417void adjustcvalues(int, int);
418int getpassword(void);
419int getyn(void);
420int packweight(void);
421#ifndef MACRORND
422int rnd(int);
423int rund(int);
424#endif
425
426/* help.c */
427void help(void);
428void welcome(void);
429
430/* io.c */
431void setupvt100(void);
432void clearvt100(void);
433char getchr(void);
434void scbr(void);
435void sncbr(void);
436void newgame(void);
437void lprintf(const char *, ...);
438void lprint(long);
439void lwrite(char *, int);
440long lgetc(void);
441long lrint_x(void);
442void lrfill(char *, int);
443char *lgetw(void);
444char *lgetl(void);
445int lcreat(char *);
446int lopen(char *);
447int lappend(char *);
448void lrclose(void);
449void lwclose(void);
450void lprcat(const char *);
451void cursor(int, int);
452void cursors(void);
453#ifndef VT100
454void init_term(void);
455#endif
456void cl_line(int, int);
457void cl_up(int, int);
458void cl_dn(int, int);
459void standout(const char *);
460void set_score_output(void);
461void lflush(void);
462#ifndef VT100
463char *tmcapcnv(char *, char *);
464#endif
465void beep(void);
466
467/* main.c */
468void qshowstr(void);
469void show3(int);
470void parse2(void);
471unsigned long readnum(long);
472
473/* monster.c */
474void createmonster(int);
475void createitem(int, int);
476void cast(void);
477void godirect(int, int, const char *, int, char);
478int vxy(int *, int *);
479void hitmonster(int, int);
480int hitm(int, int, int);
481void hitplayer(int, int);
482void dropgold(int);
483void something(int);
484int newobject(int, int *);
485void checkloss(int);
486long annihilate(void);
487long newsphere(int, int, int, int);
488long rmsphere(int, int);
489
490/* moreobj.c */
491void oaltar(void);
492void othrone(int);
493void odeadthrone(void);
494void ochest(void);
495void ofountain(void);
496
497/* movem.c */
498void movemonst(void);
499
500/* nap.c */
501void nap(int);
502
503/* object.c */
504void lookforobject(void);
505void oteleport(int);
506void quaffpotion(int);
507void larn_adjtime(long);
508void read_scroll(int);
509void readbook(int);
510void iopts(void);
511void ignore(void);
512
513/* regen.c */
514void regen(void);
515
516/* savelev.c */
517void savelevel(void);
518void getlevel(void);
519
520/* scores.c */
521int makeboard(void);
522int hashewon(void);
523long paytaxes(long);
524void showscores(void);
525void showallscores(void);
526void died(int);
527void diedlog(void);
528#ifndef UIDSCORE
529int getplid(char *);
530#endif
531
532/* signal.c */
533void sigsetup(void);
534
535/* store.c */
536void dndstore(void);
537void oschool(void);
538void obank(void);
539void obank2(void);
540void ointerest(void);
541void otradepost(void);
542void olrs(void);
543
544/* tok.c */
545int yylex(void);
546void flushall(void);
547void sethard(int);
548void readopts(void);
984263bc
MD
549
550 /* macro to create scroll #'s with probability of occurrence */
551#define newscroll() (scprob[rund(81)])
6693db17 552/* macro to return a potion # created with probability of occurrence */
984263bc 553#define newpotion() (potprob[rund(41)])
6693db17 554/* macro to return the + points on created leather armor */
984263bc 555#define newleather() (nlpts[rund(c[HARDGAME]?13:15)])
6693db17 556/* macro to return the + points on chain armor */
984263bc 557#define newchain() (nch[rund(10)])
6693db17 558/* macro to return + points on plate armor */
984263bc 559#define newplate() (nplt[rund(c[HARDGAME]?4:12)])
6693db17 560/* macro to return + points on new daggers */
984263bc 561#define newdagger() (ndgg[rund(13)])
6693db17 562/* macro to return + points on new swords */
984263bc 563#define newsword() (nsw[rund(c[HARDGAME]?6:13)])
6693db17 564/* macro to destroy object at present location */
984263bc 565#define forget() (item[playerx][playery]=know[playerx][playery]=0)
6693db17 566/* macro to wipe out a monster at a location */
984263bc
MD
567#define disappear(x,y) (mitem[x][y]=know[x][y]=0)
568
569#ifdef VT100
6693db17 570/* macro to turn on bold display for the terminal */
984263bc 571#define setbold() (lprcat(boldon?"\33[1m":"\33[7m"))
6693db17 572/* macro to turn off bold display for the terminal */
984263bc 573#define resetbold() (lprcat("\33[m"))
6693db17 574/* macro to setup the scrolling region for the terminal */
984263bc 575#define setscroll() (lprcat("\33[20;24r"))
6693db17 576/* macro to clear the scrolling region for the terminal */
984263bc 577#define resetscroll() (lprcat("\33[;24r"))
6693db17 578/* macro to clear the screen and home the cursor */
984263bc
MD
579#define clear() (lprcat("\33[2J\33[f"), cbak[SPELLS]= -50)
580#define cltoeoln() lprcat("\33[K")
0d4e6976 581#else /* VT100 */
6693db17 582/* defines below are for use in the termcap mode only */
984263bc
MD
583#define ST_START 1
584#define ST_END 2
585#define BOLD 3
586#define END_BOLD 4
587#define CLEAR 5
588#define CL_LINE 6
589#define CL_DOWN 14
590#define CURSOR 15
6693db17 591/* macro to turn on bold display for the terminal */
984263bc 592#define setbold() (*lpnt++ = ST_START)
6693db17 593/* macro to turn off bold display for the terminal */
984263bc 594#define resetbold() (*lpnt++ = ST_END)
6693db17 595/* macro to setup the scrolling region for the terminal */
984263bc 596#define setscroll() enable_scroll=1
6693db17 597/* macro to clear the scrolling region for the terminal */
984263bc 598#define resetscroll() enable_scroll=0
6693db17 599/* macro to clear the screen and home the cursor */
984263bc 600#define clear() (*lpnt++ =CLEAR, cbak[SPELLS]= -50)
6693db17 601/* macro to clear to end of line */
984263bc 602#define cltoeoln() (*lpnt++ = CL_LINE)
0d4e6976 603#endif /* VT100 */
984263bc 604
6693db17
SW
605/* macro to output one byte to the output buffer */
606#define lprc(ch) ((lpnt>=lpend)?(*lpnt++ =(ch), lflush()):(*lpnt++ = (ch)))
984263bc
MD
607
608#ifdef MACRORND
609extern unsigned long randx;
6693db17 610/* macro to seed the random number generator */
984263bc 611#define srand(x) (randx=x)
6693db17 612/* macros to generate random numbers 1<=rnd(N)<=N 0<=rund(N)<=N-1 */
984263bc
MD
613#define rnd(x) ((((randx=randx*1103515245+12345)>>7)%(x))+1)
614#define rund(x) ((((randx=randx*1103515245+12345)>>7)%(x)) )
0d4e6976 615#endif /* MACRORND */
6693db17 616/* macros for miscellaneous data conversion */
984263bc
MD
617#define min(x,y) (((x)>(y))?(y):(x))
618#define max(x,y) (((x)>(y))?(x):(y))
619#define isalpha(x) (is_alpha[x])
620#define isdigit(x) (is_digit[x])
621#define tolower(x) (to_lower[x])
622#define toupper(x) (to_upper[x])
623#define lcc(x) (to_lower[x])
624#define ucc(x) (to_upper[x])
0d4e6976 625#endif /* NODEFS */