Accessibility: Pick travel/cursor targets from a menu
[aNetHack.git] / include / rm.h
blob3e85f2e2dbd6045007bb3fe028965e0edb39e38c
1 /* NetHack 3.6 rm.h $NHDT-Date: 1432512776 2015/05/25 00:12:56 $ $NHDT-Branch: master $:$NHDT-Revision: 1.41 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #ifndef RM_H
6 #define RM_H
8 /*
9 * The dungeon presentation graphics code and data structures were rewritten
10 * and generalized for NetHack's release 2 by Eric S. Raymond (eric@snark)
11 * building on Don G. Kneller's MS-DOS implementation. See drawing.c for
12 * the code that permits the user to set the contents of the symbol structure.
14 * The door representation was changed by Ari
15 * Huttunen(ahuttune@niksula.hut.fi)
19 * TLCORNER TDWALL TRCORNER
20 * +- -+- -+
21 * | | |
23 * TRWALL CROSSWALL TLWALL HWALL
24 * | | |
25 * +- -+- -+ ---
26 * | | |
28 * BLCORNER TUWALL BRCORNER VWALL
29 * | | | |
30 * +- -+- -+ |
33 /* Level location types. [Some debugging code in src/display.c
34 defines array type_names[] which contains an entry for each of
35 these, so needs to be kept in sync if any new types are added
36 or existing ones renumbered.] */
37 #define STONE 0
38 #define VWALL 1
39 #define HWALL 2
40 #define TLCORNER 3
41 #define TRCORNER 4
42 #define BLCORNER 5
43 #define BRCORNER 6
44 #define CROSSWALL 7 /* For pretty mazes and special levels */
45 #define TUWALL 8
46 #define TDWALL 9
47 #define TLWALL 10
48 #define TRWALL 11
49 #define DBWALL 12
50 #define TREE 13 /* KMH */
51 #define SDOOR 14
52 #define SCORR 15
53 #define POOL 16
54 #define MOAT 17 /* pool that doesn't boil, adjust messages */
55 #define WATER 18
56 #define DRAWBRIDGE_UP 19
57 #define LAVAPOOL 20
58 #define IRONBARS 21 /* KMH */
59 #define DOOR 22
60 #define CORR 23
61 #define ROOM 24
62 #define STAIRS 25
63 #define LADDER 26
64 #define FOUNTAIN 27
65 #define THRONE 28
66 #define SINK 29
67 #define GRAVE 30
68 #define ALTAR 31
69 #define ICE 32
70 #define DRAWBRIDGE_DOWN 33
71 #define AIR 34
72 #define CLOUD 35
74 #define MAX_TYPE 36
75 #define INVALID_TYPE 127
78 * Avoid using the level types in inequalities:
79 * these types are subject to change.
80 * Instead, use one of the macros below.
82 #define IS_WALL(typ) ((typ) && (typ) <= DBWALL)
83 #define IS_STWALL(typ) ((typ) <= DBWALL) /* STONE <= (typ) <= DBWALL */
84 #define IS_ROCK(typ) ((typ) < POOL) /* absolutely nonaccessible */
85 #define IS_DOOR(typ) ((typ) == DOOR)
86 #define IS_TREE(typ) \
87 ((typ) == TREE || (level.flags.arboreal && (typ) == STONE))
88 #define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */
89 #define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM, STAIRS, furniture.. */
90 #define ZAP_POS(typ) ((typ) >= POOL)
91 #define SPACE_POS(typ) ((typ) > DOOR)
92 #define IS_POOL(typ) ((typ) >= POOL && (typ) <= DRAWBRIDGE_UP)
93 #define IS_THRONE(typ) ((typ) == THRONE)
94 #define IS_FOUNTAIN(typ) ((typ) == FOUNTAIN)
95 #define IS_SINK(typ) ((typ) == SINK)
96 #define IS_GRAVE(typ) ((typ) == GRAVE)
97 #define IS_ALTAR(typ) ((typ) == ALTAR)
98 #define IS_DRAWBRIDGE(typ) \
99 ((typ) == DRAWBRIDGE_UP || (typ) == DRAWBRIDGE_DOWN)
100 #define IS_FURNITURE(typ) ((typ) >= STAIRS && (typ) <= ALTAR)
101 #define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD)
102 #define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ))
105 * The screen symbols may be the default or defined at game startup time.
106 * See drawing.c for defaults.
107 * Note: {ibm|dec}_graphics[] arrays (also in drawing.c) must be kept in
108 * synch.
111 /* begin dungeon characters */
113 #define S_stone 0
114 #define S_vwall 1
115 #define S_hwall 2
116 #define S_tlcorn 3
117 #define S_trcorn 4
118 #define S_blcorn 5
119 #define S_brcorn 6
120 #define S_crwall 7
121 #define S_tuwall 8
122 #define S_tdwall 9
123 #define S_tlwall 10
124 #define S_trwall 11
125 #define S_ndoor 12
126 #define S_vodoor 13
127 #define S_hodoor 14
128 #define S_vcdoor 15 /* closed door, vertical wall */
129 #define S_hcdoor 16 /* closed door, horizontal wall */
130 #define S_bars 17 /* KMH -- iron bars */
131 #define S_tree 18 /* KMH */
132 #define S_room 19
133 #define S_darkroom 20
134 #define S_corr 21
135 #define S_litcorr 22
136 #define S_upstair 23
137 #define S_dnstair 24
138 #define S_upladder 25
139 #define S_dnladder 26
140 #define S_altar 27
141 #define S_grave 28
142 #define S_throne 29
143 #define S_sink 30
144 #define S_fountain 31
145 #define S_pool 32
146 #define S_ice 33
147 #define S_lava 34
148 #define S_vodbridge 35
149 #define S_hodbridge 36
150 #define S_vcdbridge 37 /* closed drawbridge, vertical wall */
151 #define S_hcdbridge 38 /* closed drawbridge, horizontal wall */
152 #define S_air 39
153 #define S_cloud 40
154 #define S_water 41
156 /* end dungeon characters, begin traps */
158 #define S_arrow_trap 42
159 #define S_dart_trap 43
160 #define S_falling_rock_trap 44
161 #define S_squeaky_board 45
162 #define S_bear_trap 46
163 #define S_land_mine 47
164 #define S_rolling_boulder_trap 48
165 #define S_sleeping_gas_trap 49
166 #define S_rust_trap 50
167 #define S_fire_trap 51
168 #define S_pit 52
169 #define S_spiked_pit 53
170 #define S_hole 54
171 #define S_trap_door 55
172 #define S_teleportation_trap 56
173 #define S_level_teleporter 57
174 #define S_magic_portal 58
175 #define S_web 59
176 #define S_statue_trap 60
177 #define S_magic_trap 61
178 #define S_anti_magic_trap 62
179 #define S_polymorph_trap 63
180 #define S_vibrating_square 64
182 /* end traps, begin special effects */
184 #define S_vbeam 65 /* The 4 zap beam symbols. Do NOT separate. */
185 #define S_hbeam 66 /* To change order or add, see function */
186 #define S_lslant 67 /* zapdir_to_glyph() in display.c. */
187 #define S_rslant 68
188 #define S_digbeam 69 /* dig beam symbol */
189 #define S_flashbeam 70 /* camera flash symbol */
190 #define S_boomleft 71 /* thrown boomerang, open left, e.g ')' */
191 #define S_boomright 72 /* thrown boomerang, open right, e.g. '(' */
192 #define S_ss1 73 /* 4 magic shield glyphs */
193 #define S_ss2 74
194 #define S_ss3 75
195 #define S_ss4 76
196 #define S_poisoncloud 77
197 #define S_goodpos 78 /* valid position for targeting */
199 /* The 8 swallow symbols. Do NOT separate. To change order or add, see */
200 /* the function swallow_to_glyph() in display.c. */
201 #define S_sw_tl 79 /* swallow top left [1] */
202 #define S_sw_tc 80 /* swallow top center [2] Order: */
203 #define S_sw_tr 81 /* swallow top right [3] */
204 #define S_sw_ml 82 /* swallow middle left [4] 1 2 3 */
205 #define S_sw_mr 83 /* swallow middle right [6] 4 5 6 */
206 #define S_sw_bl 84 /* swallow bottom left [7] 7 8 9 */
207 #define S_sw_bc 85 /* swallow bottom center [8] */
208 #define S_sw_br 86 /* swallow bottom right [9] */
210 #define S_explode1 87 /* explosion top left */
211 #define S_explode2 88 /* explosion top center */
212 #define S_explode3 89 /* explosion top right Ex. */
213 #define S_explode4 90 /* explosion middle left */
214 #define S_explode5 91 /* explosion middle center /-\ */
215 #define S_explode6 92 /* explosion middle right |@| */
216 #define S_explode7 93 /* explosion bottom left \-/ */
217 #define S_explode8 94 /* explosion bottom center */
218 #define S_explode9 95 /* explosion bottom right */
220 /* end effects */
222 #define MAXPCHARS 96 /* maximum number of mapped characters */
223 #define MAXDCHARS 42 /* maximum of mapped dungeon characters */
224 #define MAXTCHARS 22 /* maximum of mapped trap characters */
225 #define MAXECHARS 31 /* maximum of mapped effects characters */
226 #define MAXEXPCHARS 9 /* number of explosion characters */
228 #define DARKROOMSYM (Is_rogue_level(&u.uz) ? S_stone : S_darkroom)
230 #define is_cmap_trap(i) ((i) >= S_arrow_trap && (i) <= S_polymorph_trap)
231 #define is_cmap_drawbridge(i) ((i) >= S_vodbridge && (i) <= S_hcdbridge)
232 #define is_cmap_door(i) ((i) >= S_vodoor && (i) <= S_hcdoor)
233 #define is_cmap_wall(i) ((i) >= S_stone && (i) <= S_trwall)
235 struct symdef {
236 uchar sym;
237 const char *explanation;
238 #ifdef TEXTCOLOR
239 uchar color;
240 #endif
243 struct symparse {
244 unsigned range;
245 #define SYM_CONTROL 1 /* start/finish markers */
246 #define SYM_PCHAR 2 /* index into showsyms */
247 #define SYM_OC 3 /* index into oc_syms */
248 #define SYM_MON 4 /* index into monsyms */
249 #define SYM_OTH 5 /* misc */
250 int idx;
251 const char *name;
254 /* misc symbol definitions */
255 #define SYM_BOULDER 0
256 #define SYM_INVISIBLE 1
257 #define MAXOTHER 2
259 /* linked list of symsets and their characteristics */
260 struct symsetentry {
261 struct symsetentry *next; /* next in list */
262 char *name; /* ptr to symset name */
263 char *desc; /* ptr to description */
264 int idx; /* an index value */
265 int handling; /* known handlers value */
266 Bitfield(nocolor, 1); /* don't use color if set */
267 Bitfield(primary, 1); /* restricted for use as primary set */
268 Bitfield(rogue, 1); /* restricted for use as rogue lev set */
269 /* 5 free bits */
273 * Graphics sets for display symbols
275 #define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */
276 #define PRIMARY 0 /* primary graphics set */
277 #define ROGUESET 1 /* rogue graphics set */
278 #define NUM_GRAPHICS 2
281 * special symbol set handling types ( for invoking callbacks, etc.)
282 * Must match the order of the known_handlers strings
283 * in drawing.c
285 #define H_UNK 0
286 #define H_IBM 1
287 #define H_DEC 2
289 extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
290 extern const struct symdef def_warnsyms[WARNCOUNT];
291 extern int currentgraphics; /* from drawing.c */
292 extern nhsym showsyms[];
294 extern struct symsetentry symset[NUM_GRAPHICS]; /* from drawing.c */
295 #define SYMHANDLING(ht) (symset[currentgraphics].handling == (ht))
298 * The 5 possible states of doors
301 #define D_NODOOR 0
302 #define D_BROKEN 1
303 #define D_ISOPEN 2
304 #define D_CLOSED 4
305 #define D_LOCKED 8
306 #define D_TRAPPED 16
307 #define D_SECRET 32 /* only used by sp_lev.c, NOT in rm-struct */
310 * Some altars are considered as shrines, so we need a flag.
312 #define AM_SHRINE 8
315 * Thrones should only be looted once.
317 #define T_LOOTED 1
320 * Trees have more than one kick result.
322 #define TREE_LOOTED 1
323 #define TREE_SWARM 2
326 * Fountains have limits, and special warnings.
328 #define F_LOOTED 1
329 #define F_WARNED 2
330 #define FOUNTAIN_IS_WARNED(x, y) (levl[x][y].looted & F_WARNED)
331 #define FOUNTAIN_IS_LOOTED(x, y) (levl[x][y].looted & F_LOOTED)
332 #define SET_FOUNTAIN_WARNED(x, y) levl[x][y].looted |= F_WARNED;
333 #define SET_FOUNTAIN_LOOTED(x, y) levl[x][y].looted |= F_LOOTED;
334 #define CLEAR_FOUNTAIN_WARNED(x, y) levl[x][y].looted &= ~F_WARNED;
335 #define CLEAR_FOUNTAIN_LOOTED(x, y) levl[x][y].looted &= ~F_LOOTED;
338 * Doors are even worse :-) The special warning has a side effect
339 * of instantly trapping the door, and if it was defined as trapped,
340 * the guards consider that you have already been warned!
342 #define D_WARNED 16
345 * Sinks have 3 different types of loot that shouldn't be abused
347 #define S_LPUDDING 1
348 #define S_LDWASHER 2
349 #define S_LRING 4
352 * The four directions for a DrawBridge.
354 #define DB_NORTH 0
355 #define DB_SOUTH 1
356 #define DB_EAST 2
357 #define DB_WEST 3
358 #define DB_DIR 3 /* mask for direction */
361 * What's under a drawbridge.
363 #define DB_MOAT 0
364 #define DB_LAVA 4
365 #define DB_ICE 8
366 #define DB_FLOOR 16
367 #define DB_UNDER 28 /* mask for underneath */
370 * Wall information.
372 #define WM_MASK 0x07 /* wall mode (bottom three bits) */
373 #define W_NONDIGGABLE 0x08
374 #define W_NONPASSWALL 0x10
377 * Ladders (in Vlad's tower) may be up or down.
379 #define LA_UP 1
380 #define LA_DOWN 2
383 * Room areas may be iced pools
385 #define ICED_POOL 8
386 #define ICED_MOAT 16
389 * The structure describing a coordinate position.
390 * Before adding fields, remember that this will significantly affect
391 * the size of temporary files and save files.
393 * Also remember that the run-length encoding for some ports in save.c
394 * must be updated to consider the field.
396 struct rm {
397 int glyph; /* what the hero thinks is there */
398 schar typ; /* what is really there */
399 uchar seenv; /* seen vector */
400 Bitfield(flags, 5); /* extra information for typ */
401 Bitfield(horizontal, 1); /* wall/door/etc is horiz. (more typ info) */
402 Bitfield(lit, 1); /* speed hack for lit rooms */
403 Bitfield(waslit, 1); /* remember if a location was lit */
405 Bitfield(roomno, 6); /* room # for special rooms */
406 Bitfield(edge, 1); /* marks boundaries for special rooms*/
407 Bitfield(candig, 1); /* Exception to Can_dig_down; was a trapdoor */
410 #define SET_TYPLIT(x, y, ttyp, llit) \
412 if ((x) >= 0 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
413 if ((ttyp) < MAX_TYPE) \
414 levl[(x)][(y)].typ = (ttyp); \
415 if ((ttyp) == LAVAPOOL) \
416 levl[(x)][(y)].lit = 1; \
417 else if ((schar)(llit) != -2) { \
418 if ((schar)(llit) == -1) \
419 levl[(x)][(y)].lit = rn2(2); \
420 else \
421 levl[(x)][(y)].lit = (llit); \
427 * Add wall angle viewing by defining "modes" for each wall type. Each
428 * mode describes which parts of a wall are finished (seen as as wall)
429 * and which are unfinished (seen as rock).
431 * We use the bottom 3 bits of the flags field for the mode. This comes
432 * in conflict with secret doors, but we avoid problems because until
433 * a secret door becomes discovered, we know what sdoor's bottom three
434 * bits are.
436 * The following should cover all of the cases.
438 * type mode Examples: R=rock, F=finished
439 * ----- ---- ----------------------------
440 * WALL: 0 none hwall, mode 1
441 * 1 left/top (1/2 rock) RRR
442 * 2 right/bottom (1/2 rock) ---
443 * FFF
445 * CORNER: 0 none trcorn, mode 2
446 * 1 outer (3/4 rock) FFF
447 * 2 inner (1/4 rock) F+-
448 * F|R
450 * TWALL: 0 none tlwall, mode 3
451 * 1 long edge (1/2 rock) F|F
452 * 2 bottom left (on a tdwall) -+F
453 * 3 bottom right (on a tdwall) R|F
455 * CRWALL: 0 none crwall, mode 5
456 * 1 top left (1/4 rock) R|F
457 * 2 top right (1/4 rock) -+-
458 * 3 bottom left (1/4 rock) F|R
459 * 4 bottom right (1/4 rock)
460 * 5 top left & bottom right (1/2 rock)
461 * 6 bottom left & top right (1/2 rock)
464 #define WM_W_LEFT 1 /* vertical or horizontal wall */
465 #define WM_W_RIGHT 2
466 #define WM_W_TOP WM_W_LEFT
467 #define WM_W_BOTTOM WM_W_RIGHT
469 #define WM_C_OUTER 1 /* corner wall */
470 #define WM_C_INNER 2
472 #define WM_T_LONG 1 /* T wall */
473 #define WM_T_BL 2
474 #define WM_T_BR 3
476 #define WM_X_TL 1 /* cross wall */
477 #define WM_X_TR 2
478 #define WM_X_BL 3
479 #define WM_X_BR 4
480 #define WM_X_TLBR 5
481 #define WM_X_BLTR 6
484 * Seen vector values. The seen vector is an array of 8 bits, one for each
485 * octant around a given center x:
487 * 0 1 2
488 * 7 x 3
489 * 6 5 4
491 * In the case of walls, a single wall square can be viewed from 8 possible
492 * directions. If we know the type of wall and the directions from which
493 * it has been seen, then we can determine what it looks like to the hero.
495 #define SV0 0x1
496 #define SV1 0x2
497 #define SV2 0x4
498 #define SV3 0x8
499 #define SV4 0x10
500 #define SV5 0x20
501 #define SV6 0x40
502 #define SV7 0x80
503 #define SVALL 0xFF
505 #define doormask flags
506 #define altarmask flags
507 #define wall_info flags
508 #define ladder flags
509 #define drawbridgemask flags
510 #define looted flags
511 #define icedpool flags
513 #define blessedftn horizontal /* a fountain that grants attribs */
514 #define disturbed horizontal /* a grave that has been disturbed */
516 struct damage {
517 struct damage *next;
518 long when, cost;
519 coord place;
520 schar typ;
523 /* for bones levels: identify the dead character, who might have died on
524 an existing bones level; if so, most recent victim will be first in list */
525 struct cemetery {
526 struct cemetery *next; /* next struct is previous dead character... */
527 /* "plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */
528 char who[PL_NSIZ + 4 * (1 + 3) + 1];
529 /* death reason, same as in score/log file */
530 char how[100 + 1]; /* [DTHSZ+1] */
531 /* date+time in string of digits rather than binary */
532 char when[4 + 2 + 2 + 2 + 2 + 2 + 1]; /* "YYYYMMDDhhmmss\0" */
533 /* final resting place spot */
534 schar frpx, frpy;
535 boolean bonesknown;
538 struct levelflags {
539 uchar nfountains; /* number of fountains on level */
540 uchar nsinks; /* number of sinks on the level */
541 /* Several flags that give hints about what's on the level */
542 Bitfield(has_shop, 1);
543 Bitfield(has_vault, 1);
544 Bitfield(has_zoo, 1);
545 Bitfield(has_court, 1);
546 Bitfield(has_morgue, 1);
547 Bitfield(has_beehive, 1);
548 Bitfield(has_barracks, 1);
549 Bitfield(has_temple, 1);
551 Bitfield(has_swamp, 1);
552 Bitfield(noteleport, 1);
553 Bitfield(hardfloor, 1);
554 Bitfield(nommap, 1);
555 Bitfield(hero_memory, 1); /* hero has memory */
556 Bitfield(shortsighted, 1); /* monsters are shortsighted */
557 Bitfield(graveyard, 1); /* has_morgue, but remains set */
558 Bitfield(sokoban_rules, 1); /* fill pits and holes w/ boulders */
560 Bitfield(is_maze_lev, 1);
561 Bitfield(is_cavernous_lev, 1);
562 Bitfield(arboreal, 1); /* Trees replace rock */
563 Bitfield(wizard_bones, 1); /* set if level came from a bones file
564 which was created in wizard mode (or
565 normal mode descendant of such) */
566 Bitfield(corrmaze, 1); /* Whether corridors are used for the maze
567 rather than ROOM */
570 typedef struct {
571 struct rm locations[COLNO][ROWNO];
572 #ifndef MICROPORT_BUG
573 struct obj *objects[COLNO][ROWNO];
574 struct monst *monsters[COLNO][ROWNO];
575 #else
576 struct obj *objects[1][ROWNO];
577 char *yuk1[COLNO - 1][ROWNO];
578 struct monst *monsters[1][ROWNO];
579 char *yuk2[COLNO - 1][ROWNO];
580 #endif
581 struct obj *objlist;
582 struct obj *buriedobjlist;
583 struct monst *monlist;
584 struct damage *damagelist;
585 struct cemetery *bonesinfo;
586 struct levelflags flags;
587 } dlevel_t;
589 extern schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */
591 extern dlevel_t level; /* structure describing the current level */
594 * Macros for compatibility with old code. Someday these will go away.
596 #define levl level.locations
597 #define fobj level.objlist
598 #define fmon level.monlist
601 * Covert a trap number into the defsym graphics array.
602 * Convert a defsym number into a trap number.
603 * Assumes that arrow trap will always be the first trap.
605 #define trap_to_defsym(t) (S_arrow_trap + (t) -1)
606 #define defsym_to_trap(d) ((d) -S_arrow_trap + 1)
608 #define OBJ_AT(x, y) (level.objects[x][y] != (struct obj *) 0)
610 * Macros for encapsulation of level.monsters references.
612 #define MON_AT(x, y) \
613 (level.monsters[x][y] != (struct monst *) 0 \
614 && !(level.monsters[x][y])->mburied)
615 #define MON_BURIED_AT(x, y) \
616 (level.monsters[x][y] != (struct monst *) 0 \
617 && (level.monsters[x][y])->mburied)
618 #define place_worm_seg(m, x, y) level.monsters[x][y] = m
619 #define remove_monster(x, y) level.monsters[x][y] = (struct monst *) 0
620 #define m_at(x, y) (MON_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
621 #define m_buried_at(x, y) \
622 (MON_BURIED_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
624 /* restricted movement, potential luck penalties */
625 #define Sokoban level.flags.sokoban_rules
627 #endif /* RM_H */