1/* SCCS Id: @(#)rm.h 3.4 1999/12/12 */ 2/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3/* NetHack may be freely redistributed. See license for details. */ 4 5#ifndef RM_H 6#define RM_H 7 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. 13 * 14 * The door representation was changed by Ari Huttunen(ahuttune@niksula.hut.fi) 15 */ 16 17/* 18 * TLCORNER TDWALL TRCORNER 19 * +- -+- -+ 20 * | | | 21 * 22 * TRWALL CROSSWALL TLWALL HWALL 23 * | | | 24 * +- -+- -+ --- 25 * | | | 26 * 27 * BLCORNER TUWALL BRCORNER VWALL 28 * | | | | 29 * +- -+- -+ | 30 */ 31 32/* Level location types */ 33#define STONE 0 34#define VWALL 1 35#define HWALL 2 36#define TLCORNER 3 37#define TRCORNER 4 38#define BLCORNER 5 39#define BRCORNER 6 40#define CROSSWALL 7 /* For pretty mazes and special levels */ 41#define TUWALL 8 42#define TDWALL 9 43#define TLWALL 10 44#define TRWALL 11 45#define DBWALL 12 46#define TREE 13 /* KMH */ 47#define SDOOR 14 48#define SCORR 15 49#define POOL 16 50#define MOAT 17 /* pool that doesn't boil, adjust messages */ 51#define WATER 18 52#define DRAWBRIDGE_UP 19 53#define LAVAPOOL 20 54#define IRONBARS 21 /* KMH */ 55#define DOOR 22 56#define CORR 23 57#define ROOM 24 58#define STAIRS 25 59#define LADDER 26 60#define FOUNTAIN 27 61#define THRONE 28 62#define SINK 29 63#define GRAVE 30 64#define ALTAR 31 65#define ICE 32 66#define DRAWBRIDGE_DOWN 33 67#define AIR 34 68#define CLOUD 35 69 70#define MAX_TYPE 36 71#define INVALID_TYPE 127 72 73/* 74 * Avoid using the level types in inequalities: 75 * these types are subject to change. 76 * Instead, use one of the macros below. 77 */ 78#define IS_WALL(typ) ((typ) && (typ) <= DBWALL) 79#define IS_STWALL(typ) ((typ) <= DBWALL) /* STONE <= (typ) <= DBWALL */ 80#define IS_ROCK(typ) ((typ) < POOL) /* absolutely nonaccessible */ 81#define IS_DOOR(typ) ((typ) == DOOR) 82#define IS_TREE(typ) ((typ) == TREE || \ 83 (level.flags.arboreal && (typ) == STONE)) 84#define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */ 85#define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM, STAIRS, furniture.. */ 86#define ZAP_POS(typ) ((typ) >= POOL) 87#define SPACE_POS(typ) ((typ) > DOOR) 88#define IS_POOL(typ) ((typ) >= POOL && (typ) <= DRAWBRIDGE_UP) 89#define IS_THRONE(typ) ((typ) == THRONE) 90#define IS_FOUNTAIN(typ) ((typ) == FOUNTAIN) 91#define IS_SINK(typ) ((typ) == SINK) 92#define IS_GRAVE(typ) ((typ) == GRAVE) 93#define IS_ALTAR(typ) ((typ) == ALTAR) 94#define IS_DRAWBRIDGE(typ) ((typ) == DRAWBRIDGE_UP || (typ) == DRAWBRIDGE_DOWN) 95#define IS_FURNITURE(typ) ((typ) >= STAIRS && (typ) <= ALTAR) 96#define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD) 97#define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ)) 98 99/* 100 * The screen symbols may be the default or defined at game startup time. 101 * See drawing.c for defaults. 102 * Note: {ibm|dec}_graphics[] arrays (also in drawing.c) must be kept in synch. 103 */ 104 105/* begin dungeon characters */ 106 107#define S_stone 0 108#define S_vwall 1 109#define S_hwall 2 110#define S_tlcorn 3 111#define S_trcorn 4 112#define S_blcorn 5 113#define S_brcorn 6 114#define S_crwall 7 115#define S_tuwall 8 116#define S_tdwall 9 117#define S_tlwall 10 118#define S_trwall 11 119#define S_ndoor 12 120#define S_vodoor 13 121#define S_hodoor 14 122#define S_vcdoor 15 /* closed door, vertical wall */ 123#define S_hcdoor 16 /* closed door, horizontal wall */ 124#define S_bars 17 /* KMH -- iron bars */ 125#define S_tree 18 /* KMH */ 126#define S_room 19 127#define S_corr 20 128#define S_litcorr 21 129#define S_upstair 22 130#define S_dnstair 23 131#define S_upladder 24 132#define S_dnladder 25 133#define S_altar 26 134#define S_grave 27 135#define S_throne 28 136#define S_sink 29 137#define S_fountain 30 138#define S_pool 31 139#define S_ice 32 140#define S_lava 33 141#define S_vodbridge 34 142#define S_hodbridge 35 143#define S_vcdbridge 36 /* closed drawbridge, vertical wall */ 144#define S_hcdbridge 37 /* closed drawbridge, horizontal wall */ 145#define S_air 38 146#define S_cloud 39 147#define S_water 40 148 149/* end dungeon characters, begin traps */ 150 151#define S_arrow_trap 41 152#define S_dart_trap 42 153#define S_falling_rock_trap 43 154#define S_squeaky_board 44 155#define S_bear_trap 45 156#define S_land_mine 46 157#define S_rolling_boulder_trap 47 158#define S_sleeping_gas_trap 48 159#define S_rust_trap 49 160#define S_fire_trap 50 161#define S_pit 51 162#define S_spiked_pit 52 163#define S_hole 53 164#define S_trap_door 54 165#define S_teleportation_trap 55 166#define S_level_teleporter 56 167#define S_magic_portal 57 168#define S_web 58 169#define S_statue_trap 59 170#define S_magic_trap 60 171#define S_anti_magic_trap 61 172#define S_polymorph_trap 62 173 174/* end traps, begin special effects */ 175 176#define S_vbeam 63 /* The 4 zap beam symbols. Do NOT separate. */ 177#define S_hbeam 64 /* To change order or add, see function */ 178#define S_lslant 65 /* zapdir_to_glyph() in display.c. */ 179#define S_rslant 66 180#define S_digbeam 67 /* dig beam symbol */ 181#define S_flashbeam 68 /* camera flash symbol */ 182#define S_boomleft 69 /* thrown boomerang, open left, e.g ')' */ 183#define S_boomright 70 /* thrown boomerand, open right, e.g. '(' */ 184#define S_ss1 71 /* 4 magic shield glyphs */ 185#define S_ss2 72 186#define S_ss3 73 187#define S_ss4 74 188 189/* The 8 swallow symbols. Do NOT separate. To change order or add, see */ 190/* the function swallow_to_glyph() in display.c. */ 191#define S_sw_tl 75 /* swallow top left [1] */ 192#define S_sw_tc 76 /* swallow top center [2] Order: */ 193#define S_sw_tr 77 /* swallow top right [3] */ 194#define S_sw_ml 78 /* swallow middle left [4] 1 2 3 */ 195#define S_sw_mr 79 /* swallow middle right [6] 4 5 6 */ 196#define S_sw_bl 80 /* swallow bottom left [7] 7 8 9 */ 197#define S_sw_bc 81 /* swallow bottom center [8] */ 198#define S_sw_br 82 /* swallow bottom right [9] */ 199 200#define S_explode1 83 /* explosion top left */ 201#define S_explode2 84 /* explosion top center */ 202#define S_explode3 85 /* explosion top right Ex. */ 203#define S_explode4 86 /* explosion middle left */ 204#define S_explode5 87 /* explosion middle center /-\ */ 205#define S_explode6 88 /* explosion middle right |@| */ 206#define S_explode7 89 /* explosion bottom left \-/ */ 207#define S_explode8 90 /* explosion bottom center */ 208#define S_explode9 91 /* explosion bottom right */ 209 210/* end effects */ 211 212#define MAXPCHARS 92 /* maximum number of mapped characters */ 213#define MAXDCHARS 41 /* maximum of mapped dungeon characters */ 214#define MAXTCHARS 22 /* maximum of mapped trap characters */ 215#define MAXECHARS 29 /* maximum of mapped effects characters */ 216#define MAXEXPCHARS 9 /* number of explosion characters */ 217 218struct symdef { 219 uchar sym; 220 const char *explanation; 221#ifdef TEXTCOLOR 222 uchar color; 223#endif 224}; 225 226extern const struct symdef defsyms[MAXPCHARS]; /* defaults */ 227extern uchar showsyms[MAXPCHARS]; 228extern const struct symdef def_warnsyms[WARNCOUNT]; 229 230/* 231 * Graphics sets for display symbols 232 */ 233#define ASCII_GRAPHICS 0 /* regular characters: '-', '+', &c */ 234#define IBM_GRAPHICS 1 /* PC graphic characters */ 235#define DEC_GRAPHICS 2 /* VT100 line drawing characters */ 236#define MAC_GRAPHICS 3 /* Macintosh drawing characters */ 237 238/* 239 * The 5 possible states of doors 240 */ 241 242#define D_NODOOR 0 243#define D_BROKEN 1 244#define D_ISOPEN 2 245#define D_CLOSED 4 246#define D_LOCKED 8 247#define D_TRAPPED 16 248 249/* 250 * Some altars are considered as shrines, so we need a flag. 251 */ 252#define AM_SHRINE 8 253 254/* 255 * Thrones should only be looted once. 256 */ 257#define T_LOOTED 1 258 259/* 260 * Trees have more than one kick result. 261 */ 262#define TREE_LOOTED 1 263#define TREE_SWARM 2 264 265/* 266 * Fountains have limits, and special warnings. 267 */ 268#define F_LOOTED 1 269#define F_WARNED 2 270#define FOUNTAIN_IS_WARNED(x,y) (levl[x][y].looted & F_WARNED) 271#define FOUNTAIN_IS_LOOTED(x,y) (levl[x][y].looted & F_LOOTED) 272#define SET_FOUNTAIN_WARNED(x,y) levl[x][y].looted |= F_WARNED; 273#define SET_FOUNTAIN_LOOTED(x,y) levl[x][y].looted |= F_LOOTED; 274#define CLEAR_FOUNTAIN_WARNED(x,y) levl[x][y].looted &= ~F_WARNED; 275#define CLEAR_FOUNTAIN_LOOTED(x,y) levl[x][y].looted &= ~F_LOOTED; 276 277/* 278 * Doors are even worse :-) The special warning has a side effect 279 * of instantly trapping the door, and if it was defined as trapped, 280 * the guards consider that you have already been warned! 281 */ 282#define D_WARNED 16 283 284/* 285 * Sinks have 3 different types of loot that shouldn't be abused 286 */ 287#define S_LPUDDING 1 288#define S_LDWASHER 2 289#define S_LRING 4 290 291/* 292 * The four directions for a DrawBridge. 293 */ 294#define DB_NORTH 0 295#define DB_SOUTH 1 296#define DB_EAST 2 297#define DB_WEST 3 298#define DB_DIR 3 /* mask for direction */ 299 300/* 301 * What's under a drawbridge. 302 */ 303#define DB_MOAT 0 304#define DB_LAVA 4 305#define DB_ICE 8 306#define DB_FLOOR 16 307#define DB_UNDER 28 /* mask for underneath */ 308 309/* 310 * Wall information. 311 */ 312#define WM_MASK 0x07 /* wall mode (bottom three bits) */ 313#define W_NONDIGGABLE 0x08 314#define W_NONPASSWALL 0x10 315 316/* 317 * Ladders (in Vlad's tower) may be up or down. 318 */ 319#define LA_UP 1 320#define LA_DOWN 2 321 322/* 323 * Room areas may be iced pools 324 */ 325#define ICED_POOL 8 326#define ICED_MOAT 16 327 328/* 329 * The structure describing a coordinate position. 330 * Before adding fields, remember that this will significantly affect 331 * the size of temporary files and save files. 332 */ 333struct rm { 334 int glyph; /* what the hero thinks is there */ 335 schar typ; /* what is really there */ 336 uchar seenv; /* seen vector */ 337 Bitfield(flags,5); /* extra information for typ */ 338 Bitfield(horizontal,1); /* wall/door/etc is horiz. (more typ info) */ 339 Bitfield(lit,1); /* speed hack for lit rooms */ 340 Bitfield(waslit,1); /* remember if a location was lit */ 341 Bitfield(roomno,6); /* room # for special rooms */ 342 Bitfield(edge,1); /* marks boundaries for special rooms*/ 343}; 344 345/* 346 * Add wall angle viewing by defining "modes" for each wall type. Each 347 * mode describes which parts of a wall are finished (seen as as wall) 348 * and which are unfinished (seen as rock). 349 * 350 * We use the bottom 3 bits of the flags field for the mode. This comes 351 * in conflict with secret doors, but we avoid problems because until 352 * a secret door becomes discovered, we know what sdoor's bottom three 353 * bits are. 354 * 355 * The following should cover all of the cases. 356 * 357 * type mode Examples: R=rock, F=finished 358 * ----- ---- ---------------------------- 359 * WALL: 0 none hwall, mode 1 360 * 1 left/top (1/2 rock) RRR 361 * 2 right/bottom (1/2 rock) --- 362 * FFF 363 * 364 * CORNER: 0 none trcorn, mode 2 365 * 1 outer (3/4 rock) FFF 366 * 2 inner (1/4 rock) F+- 367 * F|R 368 * 369 * TWALL: 0 none tlwall, mode 3 370 * 1 long edge (1/2 rock) F|F 371 * 2 bottom left (on a tdwall) -+F 372 * 3 bottom right (on a tdwall) R|F 373 * 374 * CRWALL: 0 none crwall, mode 5 375 * 1 top left (1/4 rock) R|F 376 * 2 top right (1/4 rock) -+- 377 * 3 bottom left (1/4 rock) F|R 378 * 4 bottom right (1/4 rock) 379 * 5 top left & bottom right (1/2 rock) 380 * 6 bottom left & top right (1/2 rock) 381 */ 382 383#define WM_W_LEFT 1 /* vertical or horizontal wall */ 384#define WM_W_RIGHT 2 385#define WM_W_TOP WM_W_LEFT 386#define WM_W_BOTTOM WM_W_RIGHT 387 388#define WM_C_OUTER 1 /* corner wall */ 389#define WM_C_INNER 2 390 391#define WM_T_LONG 1 /* T wall */ 392#define WM_T_BL 2 393#define WM_T_BR 3 394 395#define WM_X_TL 1 /* cross wall */ 396#define WM_X_TR 2 397#define WM_X_BL 3 398#define WM_X_BR 4 399#define WM_X_TLBR 5 400#define WM_X_BLTR 6 401 402/* 403 * Seen vector values. The seen vector is an array of 8 bits, one for each 404 * octant around a given center x: 405 * 406 * 0 1 2 407 * 7 x 3 408 * 6 5 4 409 * 410 * In the case of walls, a single wall square can be viewed from 8 possible 411 * directions. If we know the type of wall and the directions from which 412 * it has been seen, then we can determine what it looks like to the hero. 413 */ 414#define SV0 0x1 415#define SV1 0x2 416#define SV2 0x4 417#define SV3 0x8 418#define SV4 0x10 419#define SV5 0x20 420#define SV6 0x40 421#define SV7 0x80 422#define SVALL 0xFF 423 424 425 426#define doormask flags 427#define altarmask flags 428#define wall_info flags 429#define ladder flags 430#define drawbridgemask flags 431#define looted flags 432#define icedpool flags 433 434#define blessedftn horizontal /* a fountain that grants attribs */ 435#define disturbed horizontal /* a grave that has been disturbed */ 436 437struct damage { 438 struct damage *next; 439 long when, cost; 440 coord place; 441 schar typ; 442}; 443 444struct levelflags { 445 uchar nfountains; /* number of fountains on level */ 446 uchar nsinks; /* number of sinks on the level */ 447 /* Several flags that give hints about what's on the level */ 448 Bitfield(has_shop, 1); 449 Bitfield(has_vault, 1); 450 Bitfield(has_zoo, 1); 451 Bitfield(has_court, 1); 452 Bitfield(has_morgue, 1); 453 Bitfield(has_beehive, 1); 454 Bitfield(has_barracks, 1); 455 Bitfield(has_temple, 1); 456 457 Bitfield(has_swamp, 1); 458 Bitfield(noteleport,1); 459 Bitfield(hardfloor,1); 460 Bitfield(nommap,1); 461 Bitfield(hero_memory,1); /* hero has memory */ 462 Bitfield(shortsighted,1); /* monsters are shortsighted */ 463 Bitfield(graveyard,1); /* has_morgue, but remains set */ 464 Bitfield(is_maze_lev,1); 465 466 Bitfield(is_cavernous_lev,1); 467 Bitfield(arboreal, 1); /* Trees replace rock */ 468}; 469 470typedef struct 471{ 472 struct rm locations[COLNO][ROWNO]; 473#ifndef MICROPORT_BUG 474 struct obj *objects[COLNO][ROWNO]; 475 struct monst *monsters[COLNO][ROWNO]; 476#else 477 struct obj *objects[1][ROWNO]; 478 char *yuk1[COLNO-1][ROWNO]; 479 struct monst *monsters[1][ROWNO]; 480 char *yuk2[COLNO-1][ROWNO]; 481#endif 482 struct obj *objlist; 483 struct obj *buriedobjlist; 484 struct monst *monlist; 485 struct damage *damagelist; 486 struct levelflags flags; 487} 488dlevel_t; 489 490extern dlevel_t level; /* structure describing the current level */ 491 492/* 493 * Macros for compatibility with old code. Someday these will go away. 494 */ 495#define levl level.locations 496#define fobj level.objlist 497#define fmon level.monlist 498 499/* 500 * Covert a trap number into the defsym graphics array. 501 * Convert a defsym number into a trap number. 502 * Assumes that arrow trap will always be the first trap. 503 */ 504#define trap_to_defsym(t) (S_arrow_trap+(t)-1) 505#define defsym_to_trap(d) ((d)-S_arrow_trap+1) 506 507#define OBJ_AT(x,y) (level.objects[x][y] != (struct obj *)0) 508/* 509 * Macros for encapsulation of level.monsters references. 510 */ 511#define MON_AT(x,y) (level.monsters[x][y] != (struct monst *)0 && \ 512 !(level.monsters[x][y])->mburied) 513#define MON_BURIED_AT(x,y) (level.monsters[x][y] != (struct monst *)0 && \ 514 (level.monsters[x][y])->mburied) 515#ifndef STEED 516#define place_monster(m,x,y) ((m)->mx=(x),(m)->my=(y),\ 517 level.monsters[(m)->mx][(m)->my]=(m)) 518#endif 519#define place_worm_seg(m,x,y) level.monsters[x][y] = m 520#define remove_monster(x,y) level.monsters[x][y] = (struct monst *)0 521#define m_at(x,y) (MON_AT(x,y) ? level.monsters[x][y] : \ 522 (struct monst *)0) 523#define m_buried_at(x,y) (MON_BURIED_AT(x,y) ? level.monsters[x][y] : \ 524 (struct monst *)0) 525 526#endif /* RM_H */ 527