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)
232 const char *explanation;
240 #define SYM_CONTROL 1 /* start/finish markers */
241 #define SYM_PCHAR 2 /* index into showsyms */
242 #define SYM_OC 3 /* index into oc_syms */
243 #define SYM_MON 4 /* index into monsyms */
244 #define SYM_OTH 5 /* misc */
249 /* misc symbol definitions */
250 #define SYM_BOULDER 0
251 #define SYM_INVISIBLE 1
254 /* linked list of symsets and their characteristics */
256 struct symsetentry *next; /* next in list */
257 char *name; /* ptr to symset name */
258 char *desc; /* ptr to description */
259 int idx; /* an index value */
260 int handling; /* known handlers value */
261 Bitfield(nocolor, 1); /* don't use color if set */
262 Bitfield(primary, 1); /* restricted for use as primary set */
263 Bitfield(rogue, 1); /* restricted for use as rogue lev set */
268 * Graphics sets for display symbols
270 #define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */
271 #define PRIMARY 0 /* primary graphics set */
272 #define ROGUESET 1 /* rogue graphics set */
273 #define NUM_GRAPHICS 2
276 * special symbol set handling types ( for invoking callbacks, etc.)
277 * Must match the order of the known_handlers strings
284 extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
285 extern const struct symdef def_warnsyms[WARNCOUNT];
286 extern int currentgraphics; /* from drawing.c */
287 extern nhsym showsyms[];
289 extern struct symsetentry symset[NUM_GRAPHICS]; /* from drawing.c */
290 #define SYMHANDLING(ht) (symset[currentgraphics].handling == (ht))
293 * The 5 possible states of doors
302 #define D_SECRET 32 /* only used by sp_lev.c, NOT in rm-struct */
305 * Some altars are considered as shrines, so we need a flag.
310 * Thrones should only be looted once.
315 * Trees have more than one kick result.
317 #define TREE_LOOTED 1
321 * Fountains have limits, and special warnings.
325 #define FOUNTAIN_IS_WARNED(x, y) (levl[x][y].looted & F_WARNED)
326 #define FOUNTAIN_IS_LOOTED(x, y) (levl[x][y].looted & F_LOOTED)
327 #define SET_FOUNTAIN_WARNED(x, y) levl[x][y].looted |= F_WARNED;
328 #define SET_FOUNTAIN_LOOTED(x, y) levl[x][y].looted |= F_LOOTED;
329 #define CLEAR_FOUNTAIN_WARNED(x, y) levl[x][y].looted &= ~F_WARNED;
330 #define CLEAR_FOUNTAIN_LOOTED(x, y) levl[x][y].looted &= ~F_LOOTED;
333 * Doors are even worse :-) The special warning has a side effect
334 * of instantly trapping the door, and if it was defined as trapped,
335 * the guards consider that you have already been warned!
340 * Sinks have 3 different types of loot that shouldn't be abused
347 * The four directions for a DrawBridge.
353 #define DB_DIR 3 /* mask for direction */
356 * What's under a drawbridge.
362 #define DB_UNDER 28 /* mask for underneath */
367 #define WM_MASK 0x07 /* wall mode (bottom three bits) */
368 #define W_NONDIGGABLE 0x08
369 #define W_NONPASSWALL 0x10
372 * Ladders (in Vlad's tower) may be up or down.
378 * Room areas may be iced pools
384 * The structure describing a coordinate position.
385 * Before adding fields, remember that this will significantly affect
386 * the size of temporary files and save files.
388 * Also remember that the run-length encoding for some ports in save.c
389 * must be updated to consider the field.
392 int glyph; /* what the hero thinks is there */
393 schar typ; /* what is really there */
394 uchar seenv; /* seen vector */
395 Bitfield(flags, 5); /* extra information for typ */
396 Bitfield(horizontal, 1); /* wall/door/etc is horiz. (more typ info) */
397 Bitfield(lit, 1); /* speed hack for lit rooms */
398 Bitfield(waslit, 1); /* remember if a location was lit */
400 Bitfield(roomno, 6); /* room # for special rooms */
401 Bitfield(edge, 1); /* marks boundaries for special rooms*/
402 Bitfield(candig, 1); /* Exception to Can_dig_down; was a trapdoor */
405 #define SET_TYPLIT(x, y, ttyp, llit) \
407 if ((x) >= 0 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
408 if ((ttyp) < MAX_TYPE) \
409 levl[(x)][(y)].typ = (ttyp); \
410 if ((ttyp) == LAVAPOOL) \
411 levl[(x)][(y)].lit = 1; \
412 else if ((schar)(llit) != -2) { \
413 if ((schar)(llit) == -1) \
414 levl[(x)][(y)].lit = rn2(2); \
416 levl[(x)][(y)].lit = (llit); \
422 * Add wall angle viewing by defining "modes" for each wall type. Each
423 * mode describes which parts of a wall are finished (seen as as wall)
424 * and which are unfinished (seen as rock).
426 * We use the bottom 3 bits of the flags field for the mode. This comes
427 * in conflict with secret doors, but we avoid problems because until
428 * a secret door becomes discovered, we know what sdoor's bottom three
431 * The following should cover all of the cases.
433 * type mode Examples: R=rock, F=finished
434 * ----- ---- ----------------------------
435 * WALL: 0 none hwall, mode 1
436 * 1 left/top (1/2 rock) RRR
437 * 2 right/bottom (1/2 rock) ---
440 * CORNER: 0 none trcorn, mode 2
441 * 1 outer (3/4 rock) FFF
442 * 2 inner (1/4 rock) F+-
445 * TWALL: 0 none tlwall, mode 3
446 * 1 long edge (1/2 rock) F|F
447 * 2 bottom left (on a tdwall) -+F
448 * 3 bottom right (on a tdwall) R|F
450 * CRWALL: 0 none crwall, mode 5
451 * 1 top left (1/4 rock) R|F
452 * 2 top right (1/4 rock) -+-
453 * 3 bottom left (1/4 rock) F|R
454 * 4 bottom right (1/4 rock)
455 * 5 top left & bottom right (1/2 rock)
456 * 6 bottom left & top right (1/2 rock)
459 #define WM_W_LEFT 1 /* vertical or horizontal wall */
461 #define WM_W_TOP WM_W_LEFT
462 #define WM_W_BOTTOM WM_W_RIGHT
464 #define WM_C_OUTER 1 /* corner wall */
467 #define WM_T_LONG 1 /* T wall */
471 #define WM_X_TL 1 /* cross wall */
479 * Seen vector values. The seen vector is an array of 8 bits, one for each
480 * octant around a given center x:
486 * In the case of walls, a single wall square can be viewed from 8 possible
487 * directions. If we know the type of wall and the directions from which
488 * it has been seen, then we can determine what it looks like to the hero.
500 #define doormask flags
501 #define altarmask flags
502 #define wall_info flags
504 #define drawbridgemask flags
506 #define icedpool flags
508 #define blessedftn horizontal /* a fountain that grants attribs */
509 #define disturbed horizontal /* a grave that has been disturbed */
518 /* for bones levels: identify the dead character, who might have died on
519 an existing bones level; if so, most recent victim will be first in list */
521 struct cemetery *next; /* next struct is previous dead character... */
522 /* "plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */
523 char who[PL_NSIZ + 4 * (1 + 3) + 1];
524 /* death reason, same as in score/log file */
525 char how[100 + 1]; /* [DTHSZ+1] */
526 /* date+time in string of digits rather than binary */
527 char when[4 + 2 + 2 + 2 + 2 + 2 + 1]; /* "YYYYMMDDhhmmss\0" */
528 /* final resting place spot */
534 uchar nfountains; /* number of fountains on level */
535 uchar nsinks; /* number of sinks on the level */
536 /* Several flags that give hints about what's on the level */
537 Bitfield(has_shop, 1);
538 Bitfield(has_vault, 1);
539 Bitfield(has_zoo, 1);
540 Bitfield(has_court, 1);
541 Bitfield(has_morgue, 1);
542 Bitfield(has_beehive, 1);
543 Bitfield(has_barracks, 1);
544 Bitfield(has_temple, 1);
546 Bitfield(has_swamp, 1);
547 Bitfield(noteleport, 1);
548 Bitfield(hardfloor, 1);
550 Bitfield(hero_memory, 1); /* hero has memory */
551 Bitfield(shortsighted, 1); /* monsters are shortsighted */
552 Bitfield(graveyard, 1); /* has_morgue, but remains set */
553 Bitfield(sokoban_rules, 1); /* fill pits and holes w/ boulders */
555 Bitfield(is_maze_lev, 1);
556 Bitfield(is_cavernous_lev, 1);
557 Bitfield(arboreal, 1); /* Trees replace rock */
558 Bitfield(wizard_bones, 1); /* set if level came from a bones file
559 which was created in wizard mode (or
560 normal mode descendant of such) */
561 Bitfield(corrmaze, 1); /* Whether corridors are used for the maze
566 struct rm locations[COLNO][ROWNO];
567 #ifndef MICROPORT_BUG
568 struct obj *objects[COLNO][ROWNO];
569 struct monst *monsters[COLNO][ROWNO];
571 struct obj *objects[1][ROWNO];
572 char *yuk1[COLNO - 1][ROWNO];
573 struct monst *monsters[1][ROWNO];
574 char *yuk2[COLNO - 1][ROWNO];
577 struct obj *buriedobjlist;
578 struct monst *monlist;
579 struct damage *damagelist;
580 struct cemetery *bonesinfo;
581 struct levelflags flags;
584 extern schar lastseentyp[COLNO][ROWNO]; /* last seen/touched dungeon typ */
586 extern dlevel_t level; /* structure describing the current level */
589 * Macros for compatibility with old code. Someday these will go away.
591 #define levl level.locations
592 #define fobj level.objlist
593 #define fmon level.monlist
596 * Covert a trap number into the defsym graphics array.
597 * Convert a defsym number into a trap number.
598 * Assumes that arrow trap will always be the first trap.
600 #define trap_to_defsym(t) (S_arrow_trap + (t) -1)
601 #define defsym_to_trap(d) ((d) -S_arrow_trap + 1)
603 #define OBJ_AT(x, y) (level.objects[x][y] != (struct obj *) 0)
605 * Macros for encapsulation of level.monsters references.
607 #define MON_AT(x, y) \
608 (level.monsters[x][y] != (struct monst *) 0 \
609 && !(level.monsters[x][y])->mburied)
610 #define MON_BURIED_AT(x, y) \
611 (level.monsters[x][y] != (struct monst *) 0 \
612 && (level.monsters[x][y])->mburied)
613 #define place_worm_seg(m, x, y) level.monsters[x][y] = m
614 #define remove_monster(x, y) level.monsters[x][y] = (struct monst *) 0
615 #define m_at(x, y) (MON_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
616 #define m_buried_at(x, y) \
617 (MON_BURIED_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
619 /* restricted movement, potential luck penalties */
620 #define Sokoban level.flags.sokoban_rules