1 /* aNetHack 0.0.1 rm.h $ANH-Date: 1432512776 2015/05/25 00:12:56 $ $ANH-Branch: master $:$ANH-Revision: 1.41 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* aNetHack may be freely redistributed. See license for details. */
9 * The dungeon presentation graphics code and data structures were rewritten
10 * and generalized for aNetHack'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.] */
45 CROSSWALL
, /* For pretty mazes and special levels */
55 MOAT
, /* pool that doesn't boil, adjust messages */
80 * Avoid using the level types in inequalities:
81 * these types are subject to change.
82 * Instead, use one of the macros below.
84 #define IS_WALL(typ) ((typ) && (typ) <= DBWALL)
85 #define IS_STWALL(typ) ((typ) <= DBWALL) /* STONE <= (typ) <= DBWALL */
86 #define IS_ROCK(typ) ((typ) < POOL) /* absolutely nonaccessible */
87 #define IS_DOOR(typ) ((typ) == DOOR)
88 #define IS_TREE(typ) \
89 ((typ) == TREE || (level.flags.arboreal && (typ) == STONE))
90 #define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */
91 #define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM, STAIRS, furniture.. */
92 #define ZAP_POS(typ) ((typ) >= POOL)
93 #define SPACE_POS(typ) ((typ) > DOOR)
94 #define IS_POOL(typ) ((typ) >= POOL && (typ) <= DRAWBRIDGE_UP)
95 #define IS_THRONE(typ) ((typ) == THRONE)
96 #define IS_FOUNTAIN(typ) ((typ) == FOUNTAIN)
97 #define IS_SINK(typ) ((typ) == SINK)
98 #define IS_GRAVE(typ) ((typ) == GRAVE)
99 #define IS_ALTAR(typ) ((typ) == ALTAR)
100 #define IS_DRAWBRIDGE(typ) \
101 ((typ) == DRAWBRIDGE_UP || (typ) == DRAWBRIDGE_DOWN)
102 #define IS_FURNITURE(typ) ((typ) >= STAIRS && (typ) <= ALTAR)
103 #define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD)
104 #define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ))
107 * The screen symbols may be the default or defined at game startup time.
108 * See drawing.c for defaults.
109 * Note: {ibm|dec}_graphics[] arrays (also in drawing.c) must be kept in
113 /* begin dungeon characters */
114 enum screen_symbols
{
130 S_vcdoor
, /* closed door, vertical wall */
131 S_hcdoor
, /* closed door, horizontal wall */
132 S_bars
, /* KMH -- iron bars */
152 S_vcdbridge
, /* closed drawbridge, vertical wall */
153 S_hcdbridge
, /* closed drawbridge, horizontal wall */
158 /* end dungeon characters, begin traps */
166 S_rolling_boulder_trap
,
174 S_teleportation_trap
,
184 /* end traps, begin special effects */
186 S_vbeam
, /* The 4 zap beam symbols. Do NOT separate. */
187 S_hbeam
, /* To change order or add, see function */
188 S_lslant
, /* zapdir_to_glyph() in display.c. */
190 S_digbeam
, /* dig beam symbol */
191 S_flashbeam
, /* camera flash symbol */
192 S_boomleft
, /* thrown boomerang, open left, e.g ')' */
193 S_boomright
, /* thrown boomerang, open right, e.g. '(' */
194 S_ss1
, /* 4 magic shield glyphs */
199 S_goodpos
, /* valid position for targeting */
201 /* The 8 swallow symbols. Do NOT separate. To change order or add, see */
202 /* the function swallow_to_glyph() in display.c. */
203 S_sw_tl
, /* swallow top left [1] */
204 S_sw_tc
, /* swallow top center [2] Order: */
205 S_sw_tr
, /* swallow top right [3] */
206 S_sw_ml
, /* swallow middle left [4] 1 2 3 */
207 S_sw_mr
, /* swallow middle right [6] 4 5 6 */
208 S_sw_bl
, /* swallow bottom left [7] 7 8 9 */
209 S_sw_bc
, /* swallow bottom center [8] */
210 S_sw_br
, /* swallow bottom right [9] */
212 S_explode1
, /* explosion top left */
213 S_explode2
, /* explosion top center */
214 S_explode3
, /* explosion top right Ex. */
215 S_explode4
, /* explosion middle left */
216 S_explode5
, /* explosion middle center /-\ */
217 S_explode6
, /* explosion middle right |@| */
218 S_explode7
, /* explosion bottom left \-/ */
219 S_explode8
, /* explosion bottom center */
220 S_explode9
, /* explosion bottom right */
224 MAXPCHARS
/* maximum number of mapped characters */
227 #define MAXDCHARS (S_water - S_stone + 1) /* maximum of mapped dungeon characters */
228 #define MAXTCHARS (S_vibrating_square - S_arrow_trap + 1) /* maximum of mapped trap characters */
229 #define MAXECHARS (S_explode9 - S_vbeam + 1) /* maximum of mapped effects characters */
230 #define MAXEXPCHARS 9 /* number of explosion characters */
232 #define DARKROOMSYM (Is_rogue_level(&u.uz) ? S_stone : S_darkroom)
234 #define is_cmap_trap(i) ((i) >= S_arrow_trap && (i) <= S_polymorph_trap)
235 #define is_cmap_drawbridge(i) ((i) >= S_vodbridge && (i) <= S_hcdbridge)
236 #define is_cmap_door(i) ((i) >= S_vodoor && (i) <= S_hcdoor)
237 #define is_cmap_wall(i) ((i) >= S_stone && (i) <= S_trwall)
241 const char *explanation
;
249 #define SYM_CONTROL 1 /* start/finish markers */
250 #define SYM_PCHAR 2 /* index into showsyms */
251 #define SYM_OC 3 /* index into oc_syms */
252 #define SYM_MON 4 /* index into monsyms */
253 #define SYM_OTH 5 /* misc */
258 /* misc symbol definitions */
259 #define SYM_BOULDER 0
260 #define SYM_INVISIBLE 1
263 /* linked list of symsets and their characteristics */
265 struct symsetentry
*next
; /* next in list */
266 char *name
; /* ptr to symset name */
267 char *desc
; /* ptr to description */
268 int idx
; /* an index value */
269 int handling
; /* known handlers value */
270 Bitfield(nocolor
, 1); /* don't use color if set */
271 Bitfield(primary
, 1); /* restricted for use as primary set */
272 Bitfield(rogue
, 1); /* restricted for use as rogue lev set */
277 * Graphics sets for display symbols
279 #define DEFAULT_GRAPHICS 0 /* regular characters: '-', '+', &c */
280 #define PRIMARY 0 /* primary graphics set */
281 #define ROGUESET 1 /* rogue graphics set */
282 #define NUM_GRAPHICS 2
285 * special symbol set handling types ( for invoking callbacks, etc.)
286 * Must match the order of the known_handlers strings
293 extern const struct symdef defsyms
[MAXPCHARS
]; /* defaults */
294 extern const struct symdef def_warnsyms
[WARNCOUNT
];
295 extern int currentgraphics
; /* from drawing.c */
296 extern nhsym showsyms
[];
298 extern struct symsetentry symset
[NUM_GRAPHICS
]; /* from drawing.c */
299 #define SYMHANDLING(ht) (symset[currentgraphics].handling == (ht))
302 * The 5 possible states of doors
311 #define D_SECRET 32 /* only used by sp_lev.c, NOT in rm-struct */
314 * Some altars are considered as shrines, so we need a flag.
319 * Thrones should only be looted once.
324 * Trees have more than one kick result.
326 #define TREE_LOOTED 1
330 * Fountains have limits, and special warnings.
334 #define FOUNTAIN_IS_WARNED(x, y) (levl[x][y].looted & F_WARNED)
335 #define FOUNTAIN_IS_LOOTED(x, y) (levl[x][y].looted & F_LOOTED)
336 #define SET_FOUNTAIN_WARNED(x, y) levl[x][y].looted |= F_WARNED;
337 #define SET_FOUNTAIN_LOOTED(x, y) levl[x][y].looted |= F_LOOTED;
338 #define CLEAR_FOUNTAIN_WARNED(x, y) levl[x][y].looted &= ~F_WARNED;
339 #define CLEAR_FOUNTAIN_LOOTED(x, y) levl[x][y].looted &= ~F_LOOTED;
342 * Doors are even worse :-) The special warning has a side effect
343 * of instantly trapping the door, and if it was defined as trapped,
344 * the guards consider that you have already been warned!
349 * Sinks have 3 different types of loot that shouldn't be abused
356 * The four directions for a DrawBridge.
362 #define DB_DIR 3 /* mask for direction */
365 * What's under a drawbridge.
371 #define DB_UNDER 28 /* mask for underneath */
376 #define WM_MASK 0x07 /* wall mode (bottom three bits) */
377 #define W_NONDIGGABLE 0x08
378 #define W_NONPASSWALL 0x10
381 * Ladders (in Vlad's tower) may be up or down.
387 * Room areas may be iced pools
393 * The structure describing a coordinate position.
394 * Before adding fields, remember that this will significantly affect
395 * the size of temporary files and save files.
397 * Also remember that the run-length encoding for some ports in save.c
398 * must be updated to consider the field.
401 int glyph
; /* what the hero thinks is there */
402 schar typ
; /* what is really there */
403 uchar seenv
; /* seen vector */
404 Bitfield(flags
, 5); /* extra information for typ */
405 Bitfield(horizontal
, 1); /* wall/door/etc is horiz. (more typ info) */
406 Bitfield(lit
, 1); /* speed hack for lit rooms */
407 Bitfield(waslit
, 1); /* remember if a location was lit */
409 Bitfield(roomno
, 6); /* room # for special rooms */
410 Bitfield(edge
, 1); /* marks boundaries for special rooms*/
411 Bitfield(candig
, 1); /* Exception to Can_dig_down; was a trapdoor */
414 #define SET_TYPLIT(x, y, ttyp, llit) \
416 if ((x) >= 0 && (y) >= 0 && (x) < COLNO && (y) < ROWNO) { \
417 if ((ttyp) < MAX_TYPE) \
418 levl[(x)][(y)].typ = (ttyp); \
419 if ((ttyp) == LAVAPOOL) \
420 levl[(x)][(y)].lit = 1; \
421 else if ((schar)(llit) != -2) { \
422 if ((schar)(llit) == -1) \
423 levl[(x)][(y)].lit = rn2(2); \
425 levl[(x)][(y)].lit = (llit); \
431 * Add wall angle viewing by defining "modes" for each wall type. Each
432 * mode describes which parts of a wall are finished (seen as as wall)
433 * and which are unfinished (seen as rock).
435 * We use the bottom 3 bits of the flags field for the mode. This comes
436 * in conflict with secret doors, but we avoid problems because until
437 * a secret door becomes discovered, we know what sdoor's bottom three
440 * The following should cover all of the cases.
442 * type mode Examples: R=rock, F=finished
443 * ----- ---- ----------------------------
444 * WALL: 0 none hwall, mode 1
445 * 1 left/top (1/2 rock) RRR
446 * 2 right/bottom (1/2 rock) ---
449 * CORNER: 0 none trcorn, mode 2
450 * 1 outer (3/4 rock) FFF
451 * 2 inner (1/4 rock) F+-
454 * TWALL: 0 none tlwall, mode 3
455 * 1 long edge (1/2 rock) F|F
456 * 2 bottom left (on a tdwall) -+F
457 * 3 bottom right (on a tdwall) R|F
459 * CRWALL: 0 none crwall, mode 5
460 * 1 top left (1/4 rock) R|F
461 * 2 top right (1/4 rock) -+-
462 * 3 bottom left (1/4 rock) F|R
463 * 4 bottom right (1/4 rock)
464 * 5 top left & bottom right (1/2 rock)
465 * 6 bottom left & top right (1/2 rock)
468 #define WM_W_LEFT 1 /* vertical or horizontal wall */
470 #define WM_W_TOP WM_W_LEFT
471 #define WM_W_BOTTOM WM_W_RIGHT
473 #define WM_C_OUTER 1 /* corner wall */
476 #define WM_T_LONG 1 /* T wall */
480 #define WM_X_TL 1 /* cross wall */
488 * Seen vector values. The seen vector is an array of 8 bits, one for each
489 * octant around a given center x:
495 * In the case of walls, a single wall square can be viewed from 8 possible
496 * directions. If we know the type of wall and the directions from which
497 * it has been seen, then we can determine what it looks like to the hero.
509 #define doormask flags
510 #define altarmask flags
511 #define wall_info flags
513 #define drawbridgemask flags
515 #define icedpool flags
517 #define blessedftn horizontal /* a fountain that grants attribs */
518 #define disturbed horizontal /* a grave that has been disturbed */
527 /* for bones levels: identify the dead character, who might have died on
528 an existing bones level; if so, most recent victim will be first in list */
530 struct cemetery
*next
; /* next struct is previous dead character... */
531 /* "plname" + "-ROLe" + "-RACe" + "-GENder" + "-ALIgnment" + \0 */
532 char who
[PL_NSIZ
+ 4 * (1 + 3) + 1];
533 /* death reason, same as in score/log file */
534 char how
[100 + 1]; /* [DTHSZ+1] */
535 /* date+time in string of digits rather than binary */
536 char when
[4 + 2 + 2 + 2 + 2 + 2 + 1]; /* "YYYYMMDDhhmmss\0" */
537 /* final resting place spot */
543 uchar nfountains
; /* number of fountains on level */
544 uchar nsinks
; /* number of sinks on the level */
545 /* Several flags that give hints about what's on the level */
546 Bitfield(has_shop
, 1);
547 Bitfield(has_vault
, 1);
548 Bitfield(has_zoo
, 1);
549 Bitfield(has_court
, 1);
550 Bitfield(has_morgue
, 1);
551 Bitfield(has_beehive
, 1);
552 Bitfield(has_barracks
, 1);
553 Bitfield(has_temple
, 1);
555 Bitfield(has_swamp
, 1);
556 Bitfield(noteleport
, 1);
557 Bitfield(hardfloor
, 1);
559 Bitfield(hero_memory
, 1); /* hero has memory */
560 Bitfield(shortsighted
, 1); /* monsters are shortsighted */
561 Bitfield(graveyard
, 1); /* has_morgue, but remains set */
562 Bitfield(sokoban_rules
, 1); /* fill pits and holes w/ boulders */
564 Bitfield(is_maze_lev
, 1);
565 Bitfield(is_cavernous_lev
, 1);
566 Bitfield(arboreal
, 1); /* Trees replace rock */
567 Bitfield(wizard_bones
, 1); /* set if level came from a bones file
568 which was created in wizard mode (or
569 normal mode descendant of such) */
570 Bitfield(corrmaze
, 1); /* Whether corridors are used for the maze
575 struct rm locations
[COLNO
][ROWNO
];
576 #ifndef MICROPORT_BUG
577 struct obj
*objects
[COLNO
][ROWNO
];
578 struct monst
*monsters
[COLNO
][ROWNO
];
580 struct obj
*objects
[1][ROWNO
];
581 char *yuk1
[COLNO
- 1][ROWNO
];
582 struct monst
*monsters
[1][ROWNO
];
583 char *yuk2
[COLNO
- 1][ROWNO
];
586 struct obj
*buriedobjlist
;
587 struct monst
*monlist
;
588 struct damage
*damagelist
;
589 struct cemetery
*bonesinfo
;
590 struct levelflags flags
;
593 extern schar lastseentyp
[COLNO
][ROWNO
]; /* last seen/touched dungeon typ */
595 extern dlevel_t level
; /* structure describing the current level */
598 * Macros for compatibility with old code. Someday these will go away.
600 #define levl level.locations
601 #define fobj level.objlist
602 #define fmon level.monlist
605 * Covert a trap number into the defsym graphics array.
606 * Convert a defsym number into a trap number.
607 * Assumes that arrow trap will always be the first trap.
609 #define trap_to_defsym(t) (S_arrow_trap + (t) -1)
610 #define defsym_to_trap(d) ((d) -S_arrow_trap + 1)
612 #define OBJ_AT(x, y) (level.objects[x][y] != (struct obj *) 0)
614 * Macros for encapsulation of level.monsters references.
616 #define MON_AT(x, y) \
617 (level.monsters[x][y] != (struct monst *) 0 \
618 && !(level.monsters[x][y])->mburied)
619 #define MON_BURIED_AT(x, y) \
620 (level.monsters[x][y] != (struct monst *) 0 \
621 && (level.monsters[x][y])->mburied)
622 #define place_worm_seg(m, x, y) level.monsters[x][y] = m
623 #define remove_monster(x, y) level.monsters[x][y] = (struct monst *) 0
624 #define m_at(x, y) (MON_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
625 #define m_buried_at(x, y) \
626 (MON_BURIED_AT(x, y) ? level.monsters[x][y] : (struct monst *) 0)
628 /* restricted movement, potential luck penalties */
629 #define Sokoban level.flags.sokoban_rules