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. */
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
23 * TRWALL CROSSWALL TLWALL HWALL
28 * BLCORNER TUWALL BRCORNER VWALL
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.] */
44 #define CROSSWALL 7 /* For pretty mazes and special levels */
50 #define TREE 13 /* KMH */
54 #define MOAT 17 /* pool that doesn't boil, adjust messages */
56 #define DRAWBRIDGE_UP 19
58 #define IRONBARS 21 /* KMH */
70 #define DRAWBRIDGE_DOWN 33
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
111 /* begin dungeon characters */
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 */
133 #define S_darkroom 20
138 #define S_upladder 25
139 #define S_dnladder 26
144 #define S_fountain 31
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 */
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
169 #define S_spiked_pit 53
171 #define S_trap_door 55
172 #define S_teleportation_trap 56
173 #define S_level_teleporter 57
174 #define S_magic_portal 58
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. */
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 */
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 */
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)
237 const char *explanation
;
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 */
254 /* misc symbol definitions */
255 #define SYM_BOULDER 0
256 #define SYM_INVISIBLE 1
259 /* linked list of symsets and their characteristics */
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 */
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
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
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.
315 * Thrones should only be looted once.
320 * Trees have more than one kick result.
322 #define TREE_LOOTED 1
326 * Fountains have limits, and special warnings.
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!
345 * Sinks have 3 different types of loot that shouldn't be abused
352 * The four directions for a DrawBridge.
358 #define DB_DIR 3 /* mask for direction */
361 * What's under a drawbridge.
367 #define DB_UNDER 28 /* mask for underneath */
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.
383 * Room areas may be iced pools
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.
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); \
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
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) ---
445 * CORNER: 0 none trcorn, mode 2
446 * 1 outer (3/4 rock) FFF
447 * 2 inner (1/4 rock) F+-
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 */
466 #define WM_W_TOP WM_W_LEFT
467 #define WM_W_BOTTOM WM_W_RIGHT
469 #define WM_C_OUTER 1 /* corner wall */
472 #define WM_T_LONG 1 /* T wall */
476 #define WM_X_TL 1 /* cross wall */
484 * Seen vector values. The seen vector is an array of 8 bits, one for each
485 * octant around a given center x:
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.
505 #define doormask flags
506 #define altarmask flags
507 #define wall_info flags
509 #define drawbridgemask flags
511 #define icedpool flags
513 #define blessedftn horizontal /* a fountain that grants attribs */
514 #define disturbed horizontal /* a grave that has been disturbed */
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 */
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 */
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);
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
571 struct rm locations
[COLNO
][ROWNO
];
572 #ifndef MICROPORT_BUG
573 struct obj
*objects
[COLNO
][ROWNO
];
574 struct monst
*monsters
[COLNO
][ROWNO
];
576 struct obj
*objects
[1][ROWNO
];
577 char *yuk1
[COLNO
- 1][ROWNO
];
578 struct monst
*monsters
[1][ROWNO
];
579 char *yuk2
[COLNO
- 1][ROWNO
];
582 struct obj
*buriedobjlist
;
583 struct monst
*monlist
;
584 struct damage
*damagelist
;
585 struct cemetery
*bonesinfo
;
586 struct levelflags flags
;
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