Add __attribute__((__noreturn__)) to various function prototypes in games/.
[dragonfly.git] / games / hack / hack.h
CommitLineData
984263bc
MD
1/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2/* hack.h - version 1.0.3 */
3
4#include "config.h"
c7106d58
PA
5#include <fcntl.h>
6#include <signal.h>
7#include <stdarg.h>
8#include <stdbool.h>
9#include <stdio.h>
10#include <stdlib.h>
984263bc 11#include <string.h>
c7106d58 12#include <unistd.h>
984263bc 13
6693db17 14#include "def.objclass.h"
984263bc
MD
15
16typedef struct {
6693db17 17 xchar x, y;
984263bc
MD
18} coord;
19
6693db17
SW
20#include "def.monst.h" /* uses coord */
21#include "def.gold.h"
22#include "def.trap.h"
23#include "def.obj.h"
24#include "def.flag.h"
25#include "def.mkroom.h"
26#include "def.wseg.h"
984263bc
MD
27
28#define plur(x) (((x) == 1) ? "" : "s")
29
30#define BUFSZ 256 /* for getlin buffers */
31#define PL_NSIZ 32 /* name of player, ghost, shopkeeper */
32
6693db17
SW
33#include "def.rm.h"
34#include "def.permonst.h"
984263bc 35
984263bc
MD
36extern xchar xdnstair, ydnstair, xupstair, yupstair; /* stairs up and down. */
37
6693db17 38#define newstring(x) alloc((unsigned)(x))
984263bc
MD
39#include "hack.onames.h"
40
6693db17
SW
41#define ON 1
42#define OFF 0
984263bc
MD
43
44extern struct obj *invent, *uwep, *uarm, *uarm2, *uarmh, *uarms, *uarmg,
45 *uleft, *uright, *fcobj;
46extern struct obj *uchain; /* defined iff PUNISHED */
47extern struct obj *uball; /* defined if PUNISHED */
984263bc
MD
48
49struct prop {
50#define TIMEOUT 007777 /* mask */
51#define LEFT_RING W_RINGL /* 010000L */
52#define RIGHT_RING W_RINGR /* 020000L */
53#define INTRINSIC 040000L
54#define LEFT_SIDE LEFT_RING
55#define RIGHT_SIDE RIGHT_RING
56#define BOTH_SIDES (LEFT_SIDE | RIGHT_SIDE)
57 long p_flgs;
c7106d58 58 void (*p_tofn)(void); /* called after timeout */
984263bc
MD
59};
60
61struct you {
62 xchar ux, uy;
63 schar dx, dy, dz; /* direction of move (or zap or ... ) */
64#ifdef QUEST
65 schar di; /* direction of FF */
66 xchar ux0, uy0; /* initial position FF */
304d60d9 67#endif /* QUEST */
984263bc
MD
68 xchar udisx, udisy; /* last display pos */
69 char usym; /* usually '@' */
70 schar uluck;
71#define LUCKMAX 10 /* on moonlit nights 11 */
72#define LUCKMIN (-10)
73 int last_str_turn:3; /* 0: none, 1: half turn, 2: full turn */
74 /* +: turn right, -: turn left */
75 unsigned udispl:1; /* @ on display */
76 unsigned ulevel:4; /* 1 - 14 */
77#ifdef QUEST
78 unsigned uhorizon:7;
304d60d9 79#endif /* QUEST */
984263bc
MD
80 unsigned utrap:3; /* trap timeout */
81 unsigned utraptype:1; /* defined if utrap nonzero */
82#define TT_BEARTRAP 0
83#define TT_PIT 1
84 unsigned uinshop:6; /* used only in shk.c - (roomno+1) of shop */
85
86
87/* perhaps these #define's should also be generated by makedefs */
88#define TELEPAT LAST_RING /* not a ring */
89#define Telepat u.uprops[TELEPAT].p_flgs
90#define FAST (LAST_RING+1) /* not a ring */
91#define Fast u.uprops[FAST].p_flgs
92#define CONFUSION (LAST_RING+2) /* not a ring */
93#define Confusion u.uprops[CONFUSION].p_flgs
94#define INVIS (LAST_RING+3) /* not a ring */
95#define Invis u.uprops[INVIS].p_flgs
6693db17 96#define Invisible (Invis && !See_invisible)
984263bc
MD
97#define GLIB (LAST_RING+4) /* not a ring */
98#define Glib u.uprops[GLIB].p_flgs
99#define PUNISHED (LAST_RING+5) /* not a ring */
100#define Punished u.uprops[PUNISHED].p_flgs
101#define SICK (LAST_RING+6) /* not a ring */
102#define Sick u.uprops[SICK].p_flgs
103#define BLIND (LAST_RING+7) /* not a ring */
104#define Blind u.uprops[BLIND].p_flgs
105#define WOUNDED_LEGS (LAST_RING+8) /* not a ring */
6693db17
SW
106#define Wounded_legs u.uprops[WOUNDED_LEGS].p_flgs
107#define STONED (LAST_RING+9) /* not a ring */
108#define Stoned u.uprops[STONED].p_flgs
109#define PROP(x) (x-RIN_ADORNMENT) /* convert ring to index in uprops */
984263bc 110 unsigned umconf:1;
fd2d026f 111 const char *usick_cause;
984263bc
MD
112 struct prop uprops[LAST_RING+10];
113
114 unsigned uswallow:1; /* set if swallowed by a monster */
115 unsigned uswldtim:4; /* time you have been swallowed */
116 unsigned uhs:3; /* hunger state - see hack.eat.c */
6693db17 117 schar ustr, ustrmax;
984263bc
MD
118 schar udaminc;
119 schar uac;
6693db17
SW
120 int uhp, uhpmax;
121 long int ugold, ugold0, uexp, urexp;
984263bc
MD
122 int uhunger; /* refd only in eat.c and shk.c */
123 int uinvault;
124 struct monst *ustuck;
125 int nr_killed[CMNUM+2]; /* used for experience bookkeeping */
126};
127
128extern struct you u;
129
fd2d026f 130extern const char *traps[];
984263bc
MD
131extern char vowels[];
132
6693db17 133extern xchar curx, cury; /* cursor location on screen */
984263bc
MD
134
135extern coord bhitpos; /* place where thrown weapon falls to the ground */
136
6693db17 137extern xchar seehx, seelx, seehy, seely; /* where to see*/
fd2d026f 138extern const char *save_cm, *killer, *nomovemsg;
984263bc
MD
139
140extern xchar dlevel, maxdlevel; /* dungeon level */
141
142extern long moves;
143
144extern int multi;
145
984263bc
MD
146extern char lock[];
147
fd2d026f
YT
148extern const char *occtxt;
149extern const char *hu_stat[];
150
6693db17 151#define DIST(x1,y1,x2,y2) (((x1)-(x2))*((x1)-(x2)) + ((y1)-(y2))*((y1)-(y2)))
984263bc
MD
152
153#define PL_CSIZ 20 /* sizeof pl_character */
154#define MAX_CARR_CAP 120 /* so that boulders can be heavier */
155#define MAXLEVEL 40
156#define FAR (COLNO+2) /* position outside screen */
c7106d58
PA
157
158extern schar xdir[], ydir[];
159extern int hackpid, locknum, doorindex, done_stopprint;
160extern char mlarge[], pl_character[PL_CSIZ], genocided[60], fut_geno[60];
161extern char *hname, morc, plname[PL_NSIZ], sdir[];
162extern boolean level_exists[], restoring, in_mklev;
163extern struct permonst pm_eel, pm_ghost;
164extern void (*afternmv)(void);
165extern struct monst *mydogs;
166extern bool (*occupation)(void);
167
168/* Non-static function prototypes */
169
170/* alloc.c */
171void *alloc(size_t);
172
173/* hack.apply.c */
174int doapply(void);
175int holetime(void);
176void dighole(void);
177
178/* hack.bones.c */
179void savebones(void);
180int getbones(void);
181
182/* hack.c */
183void unsee(void);
184void seeoff(bool);
185void domove(void);
186int dopickup(void);
187void pickup(int);
188void lookaround(void);
189bool monster_nearby(void);
190bool cansee(xchar, xchar);
191int sgn(int);
192void setsee(void);
193void nomul(int);
194int abon(void);
195int dbon(void);
196void losestr(int);
197void losehp(int, const char *);
198void losehp_m(int, struct monst *);
199void losexp(void);
200int inv_weight(void);
201long newuexp(void);
202
203/* hack.cmd.c */
204void rhack(const char *);
205bool movecmd(char);
206bool getdir(bool);
207void confdir(void);
208#ifdef QUEST
209void finddir(void);
210#endif
211bool isok(int, int);
212
213/* hack.do.c */
214int dodrop(void);
215void dropx(struct obj *);
216int doddrop(void);
217int dodown(void);
218int doup(void);
219void goto_level(int, bool);
220int donull(void);
221int dopray(void);
222int dothrow(void);
223struct obj *splitobj(struct obj *, int);
224void more_experienced(int, int);
225void set_wounded_legs(long, int);
226void heal_legs(void);
227
228/* hack.do_name.c */
229coord getpos(int, const char *);
230int do_mname(void);
231int ddocall(void);
232void docall(struct obj *);
233char *monnam(struct monst *);
234char *Monnam(struct monst *);
235char *amonnam(struct monst *, const char *);
236char *Amonnam(struct monst *, const char *);
237char *Xmonnam(struct monst *);
238
239/* hack.do_wear.c */
240int doremarm(void);
241int doremring(void);
242bool armoroff(struct obj *);
243int doweararm(void);
244int dowearring(void);
245void ringoff(struct obj *);
246void find_ac(void);
247void glibr(void);
248struct obj *some_armor(void);
249void corrode_armor(void);
250
251/* hack.dog.c */
252void makedog(void);
253void losedogs(void);
254void keepdogs(void);
255void fall_down(struct monst *);
256int dog_move(struct monst *, int);
257int inroom(xchar, xchar);
258bool tamedog(struct monst *, struct obj *);
259
260/* hack.eat.c */
261void init_uhunger(void);
262int doeat(void);
263void gethungry(void);
264void morehungry(int);
265void lesshungry(int);
266bool poisonous(struct obj *);
267
268/* hack.end.c */
269void done1(int);
270void done_in_by(struct monst *);
271void done(const char *);
272void clearlocks(void);
273#ifdef NOSAVEONHANGUP
09ac707a 274void hangup(int) __dead2;
c7106d58
PA
275#endif
276char *eos(char *);
277void charcat(char *, char);
278void prscore(int, char **);
279
280/* hack.engrave.c */
281bool sengr_at(const char *, xchar, xchar);
282void u_wipe_engr(int);
283void wipe_engr_at(xchar, xchar, xchar);
284void read_engr_at(int, int);
285void make_engr_at(int, int, const char *);
286int doengrave(void);
287void save_engravings(int);
288void rest_engravings(int);
289
290/* hack.fight.c */
291int hitmm(struct monst *, struct monst *);
292void mondied(struct monst *);
293int fightm(struct monst *);
294bool thitu(int, int, const char *);
295bool hmon(struct monst *, struct obj *, int);
296bool attack(struct monst *);
297
298/* hack.invent.c */
299struct obj *addinv(struct obj *);
300void useup(struct obj *);
301void freeinv(struct obj *);
302void delobj(struct obj *);
303void freeobj(struct obj *);
304void freegold(struct gold *);
305void deltrap(struct trap *);
306struct monst *m_at(int, int);
307struct obj *o_at(int, int);
308struct obj *sobj_at(int, int, int);
309bool carried(struct obj *);
310bool carrying(int);
311struct obj *o_on(unsigned int, struct obj *);
312struct trap *t_at(int, int);
313struct gold *g_at(int, int);
314struct obj *getobj(const char *, const char *);
315int ggetobj(const char *, int (*)(struct obj *), int);
316int askchain(struct obj *, char *, int, int (*)(struct obj *),
317 bool (*)(struct obj *), int);
318void prinv(struct obj *);
319int ddoinv(void);
320int dotypeinv(void);
321int dolook(void);
322void stackobj(struct obj *);
323int doprgold(void);
324int doprwep(void);
325int doprarm(void);
326int doprring(void);
327bool digit(char);
328
329/* hack.ioctl.c */
330void getioctls(void);
331void setioctls(void);
332#ifdef SUSPEND
333int dosuspend(void);
334#endif
335
336/* hack.lev.c */
337void savelev(int, xchar);
338void bwrite(int, char *, unsigned int);
339void saveobjchn(int, struct obj *);
340void savemonchn(int, struct monst *);
341void getlev(int, int, xchar);
342void mread(int, char *, unsigned int);
343void mklev(void);
344
345/* hack.main.c */
346void glo(int);
347void askname(void);
b58f1e66 348void impossible(const char *, ...) __printflike(1, 2);
c7106d58
PA
349void stop_occupation(void);
350
351/* hack.makemon.c */
352struct monst *makemon(struct permonst *, int, int);
353coord enexto(xchar, xchar);
354bool goodpos(int, int);
355void rloc(struct monst *);
356struct monst *mkmon_at(char, int, int);
357
358/* hack.mhitu.c */
359bool mhitu(struct monst *);
360bool hitu(struct monst *, int);
361
362/* hack.mklev.c */
363void makelevel(void);
364void mktrap(int, int, struct mkroom *);
365
366/* hack.mkmaze.c */
367void makemaz(void);
368coord mazexy(void);
369
370/* hack.mkobj.c */
371struct obj *mkobj_at(int, int, int);
372void mksobj_at(int, int, int);
373struct obj *mkobj(int);
374struct obj *mksobj(int);
375bool letter(char);
376int weight(struct obj *);
377void mkgold(long, int, int);
378
379/* hack.mkshop.c */
380#ifndef QUEST
381void mkshop(void);
382void mkzoo(int);
383void mkswamp(void);
384#endif
385
386/* hack.mon.c */
387void movemon(void);
388void justswld(struct monst *, const char *);
389void youswld(struct monst *, int, int, const char *);
390bool dochug(struct monst *);
391int m_move(struct monst *, int);
392int mfndpos(struct monst *, coord *, int *, int);
393int dist(int, int);
394void poisoned(const char *, const char *);
395void mondead(struct monst *);
396void replmon(struct monst *, struct monst *);
397void relmon(struct monst *);
398void monfree(struct monst *);
399void unstuck(struct monst *);
400void killed(struct monst *);
401void kludge(const char *, const char *);
402void rescham(void);
403bool newcham(struct monst *, struct permonst *);
404void mnexto(struct monst *);
405void setmangry(struct monst *);
406bool canseemon(struct monst *);
407
408/* hack.o_init.c */
409int letindex(char);
410void init_objects(void);
411int probtype(char);
412void oinit(void);
413void savenames(int);
414void restnames(int);
415int dodiscovered(void);
416
417/* hack.objnam.c */
418char *typename(int);
419char *xname(struct obj *);
420char *doname(struct obj *);
421void setan(const char *, char *);
422char *aobjnam(struct obj *, const char *);
423char *Doname(struct obj *);
424struct obj *readobjnam(char *);
425
426/* hack.options.c */
427void initoptions(void);
428int doset(void);
429
430/* hack.pager.c */
431int dowhatis(void);
432void set_whole_screen(void);
433#ifdef NEWS
434bool readnews(void);
435#endif
436void set_pager(int);
437bool page_line(const char *);
438void cornline(int, const char *);
439int dohelp(void);
440bool page_file(const char *, bool);
441#ifdef UNIX
442#ifdef SHELL
443int dosh(void);
444#endif /* SHELL */
445bool child(bool);
446#endif /* UNIX */
447
448/* hack.potion.c */
449int dodrink(void);
450void pluslvl(void);
451void strange_feeling(struct obj *, const char *);
452void potionhit(struct monst *, struct obj *);
453void potionbreathe(struct obj *);
454int dodip(void);
455
456/* hack.pri.c */
457void swallowed(void);
b58f1e66 458void panic(const char *, ...) __printflike(1, 2);
c7106d58
PA
459void atl(int, int, char);
460void on_scr(int, int);
461void tmp_at(schar, schar);
462void Tmp_at(schar, schar);
09ac707a 463void setclipped(void) __dead2;
c7106d58
PA
464void at(xchar, xchar, char);
465void prme(void);
466int doredraw(void);
467void docrt(void);
468void docorner(int, int);
469void curs_on_u(void);
470void pru(void);
471void prl(int, int);
472char news0(xchar, xchar);
473void newsym(int, int);
474void mnewsym(int, int);
475void nosee(int, int);
476#ifndef QUEST
477void prl1(int, int);
478void nose1(int, int);
479#endif
480bool vism_at(int, int);
481void unpobj(struct obj *);
482void seeobjs(void);
483void seemons(void);
484void pmon(struct monst *);
485void unpmon(struct monst *);
486void nscr(void);
487void bot(void);
488#ifdef WAN_PROBING
489void mstatusline(struct monst *);
490#endif
491void cls(void);
492
493/* hack.read.c */
494int doread(void);
495int identify(struct obj *);
496void litroom(bool);
497
498/* hack.rip.c */
499void outrip(void);
500
501/* hack.rumors.c */
502void outrumor(void);
503
504/* hack.save.c */
505int dosave(void);
506#ifndef NOSAVEONHANGUP
09ac707a 507void hangup(int) __dead2;
c7106d58
PA
508#endif
509bool dorecover(int);
510struct obj *restobjchn(int);
511struct monst *restmonchn(int);
512
513/* hack.search.c */
514int findit(void);
515int dosearch(void);
516int doidtrap(void);
517void wakeup(struct monst *);
518void seemimic(struct monst *);
519
520/* hack.shk.c */
521#ifdef QUEST
522void obfree(struct obj *, struct obj *);
523int inshop(void);
524void shopdig(void);
525void addtobill(void);
526void subfrombill(void);
527void splitbill(void);
528int dopay(void);
529void paybill(void);
530int doinvbill(void);
531void shkdead(void);
532int shkcatch(void);
533int shk_move(void);
534void replshk(struct monst *, struct monst *);
535const char *shkname(void);
536#else
537char *shkname(struct monst *);
538void shkdead(struct monst *);
539void replshk(struct monst *, struct monst *);
540int inshop(void);
541void obfree(struct obj *, struct obj *);
542int dopay(void);
543void paybill(void);
544void addtobill(struct obj *);
545void splitbill(struct obj *, struct obj *);
546void subfrombill(struct obj *);
547int doinvbill(int);
548bool shkcatch(struct obj *);
549int shk_move(struct monst *);
550void shopdig(int);
551#endif
552bool online(int, int);
553bool follower(struct monst *);
554
555/* hack.shknam.c */
556void findname(char *, char);
557
558/* hack.steal.c */
559long somegold(void);
560void stealgold(struct monst *);
561bool steal(struct monst *);
562void mpickobj(struct monst *, struct obj *);
563bool stealamulet(struct monst *);
564void relobj(struct monst *, int);
565
566/* hack.termcap.c */
567void startup(void);
568void start_screen(void);
569void end_screen(void);
570void curs(int, int);
571void cl_end(void);
572void clear_screen(void);
573void home(void);
574void standoutbeg(void);
575void standoutend(void);
576void backsp(void);
577void bell(void);
578void cl_eos(void);
579
580/* hack.timeout.c */
581void p_timeout(void);
582
583/* hack.topl.c */
584int doredotopl(void);
585void remember_topl(void);
586void addtopl(const char *);
587void more(void);
588void cmore(const char *);
589void clrlin(void);
b58f1e66
SW
590void pline(const char *, ...) __printflike(1, 2);
591void vpline(const char *, va_list) __printflike(1, 0);
c7106d58
PA
592void putsym(char);
593void putstr(const char *);
594
595/* hack.track.c */
596void initrack(void);
597void settrack(void);
598coord *gettrack(int, int);
599
600/* hack.trap.c */
601struct trap *maketrap(int, int, int);
602void dotrap(struct trap *);
603int mintrap(struct monst *);
604void selftouch(const char *);
605void float_up(void);
606void float_down(void);
607void tele(void);
608int dotele(void);
609void placebc(int);
610void unplacebc(void);
611void level_tele(void);
612void drown(void);
613
614/* hack.tty.c */
615void gettty(void);
616void settty(const char *);
617void setftty(void);
09ac707a 618void error(const char *, ...) __printflike(1, 2) __dead2;
c7106d58
PA
619void getlin(char *);
620void getret(void);
621void cgetret(const char *);
622void xwaitforspace(const char *);
623char *parse(void);
624char readchar(void);
09ac707a 625void end_of_input(void) __dead2;
c7106d58
PA
626
627/* hack.u_init.c */
628void u_init(void);
629void plnamesuffix(void);
630
631/* hack.unix.c */
632void setrandom(void);
633int getyear(void);
634char *getdate(void);
635int phase_of_the_moon(void);
636bool night(void);
637bool midnight(void);
638void gethdate(const char *);
639bool uptodate(int);
640void getlock(void);
641#ifdef MAIL
642void getmailstatus(void);
643void ckmailstatus(void);
644void readmail(void);
645#endif
646void regularize(char *);
647
648/* hack.vault.c */
649void setgd(void);
650int gd_move(void);
651void replgd(struct monst *, struct monst *);
652void invault(void);
653#ifdef QUEST
654void gddead(struct monst *);
655#else
656void gddead(void);
657#endif
658
659/* hack.version.c */
660int doversion(void);
661
662/* hack.wield.c */
663void setuwep(struct obj *);
664int dowield(void);
665void corrode_weapon(void);
666bool chwepon(struct obj *, int);
667
668/* hack.wizard.c */
669void amulet(void);
670bool wiz_hit(struct monst *);
671void inrange(struct monst *);
672
673/* hack.worm.c */
674#ifndef NOWORM
675bool getwn(struct monst *);
676void initworm(struct monst *);
677void worm_move(struct monst *);
678void worm_nomove(struct monst *);
679void wormdead(struct monst *);
680void wormhit(struct monst *);
681void wormsee(unsigned int);
682void pwseg(struct wseg *);
683void cutworm(struct monst *, xchar, xchar, uchar);
684#endif
685
686/* hack.worn.c */
687void setworn(struct obj *, long);
688void setnotworn(struct obj *);
689
690/* hack.zap.c */
691int dozap(void);
692const char *exclam(int);
693void hit(const char *, struct monst *, const char *);
694void miss(const char *, struct monst *);
695struct monst *bhit(int, int, int, char,
696 void (*)(struct monst *, struct obj *),
697 bool (*)(struct obj *, struct obj *), struct obj *);
698struct monst *boomhit(int, int);
699void buzz(int, xchar, xchar, int, int);
700void fracture_rock(struct obj *);
701
702/* rnd.c */
703int rn1(int, int);
704int rn2(int);
705int rnd(int);
706int d(int, int);