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