Source:NetHack 3.4.0/rm.h

Below is the full text to rm.h from the source code of NetHack 3.4.0. To link to a particular line, write [[NetHack 3.4.0/rm.h#line123 ]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code

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.  218.  struct symdef { 219.     uchar sym; 220.     const char	*explanation; 221. #ifdef TEXTCOLOR 222.     uchar color; 223. #endif 224. };  225.   226.  extern const struct symdef defsyms[MAXPCHARS];	/* defaults */ 227. extern uchar showsyms[MAXPCHARS]; 228. extern 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.  271.  /*  272.   * Doors are even worse :-) The special warning has a side effect  273.   * of instantly trapping the door, and if it was defined as trapped,  274.   * the guards consider that you have already been warned!  275.   */  276.  #define D_WARNED	16  277.   278.  /*  279.   * Sinks have 3 different types of loot that shouldn't be abused  280.   */  281.  #define S_LPUDDING	1  282.  #define S_LDWASHER	2  283.  #define S_LRING		4  284.   285.  /*  286.   * The four directions for a DrawBridge.  287.   */  288.  #define DB_NORTH	0  289.  #define DB_SOUTH	1  290.  #define DB_EAST		2  291.  #define DB_WEST		3  292.  #define DB_DIR		3	/* mask for direction */  293.   294.  /*  295.   * What's under a drawbridge.  296.   */  297.  #define DB_MOAT		0  298.  #define DB_LAVA		4  299.  #define DB_ICE		8  300.  #define DB_FLOOR	16  301.  #define DB_UNDER	28	/* mask for underneath */ 302.  303.  /*  304.   * Wall information. 305.  */  306.  #define WM_MASK		0x07	/* wall mode (bottom three bits) */ 307. #define W_NONDIGGABLE	0x08 308. #define W_NONPASSWALL	0x10 309.  310.  /*  311.   * Ladders (in Vlad's tower) may be up or down. 312.  */  313.  #define LA_UP		1 314. #define LA_DOWN		2 315.  316.  /*  317.   * Room areas may be iced pools 318.  */  319.  #define ICED_POOL	8 320. #define ICED_MOAT	16 321.  322.  /*  323.   * The structure describing a coordinate position. 324.  * Before adding fields, remember that this will significantly affect 325.  * the size of temporary files and save files. 326.  */  327.  struct rm { 328. 	int glyph;		/* what the hero thinks is there */ 329. 	schar typ;		/* what is really there */ 330. 	uchar seenv;		/* seen vector */ 331. 	Bitfield(flags,5);	/* extra information for typ */ 332. 	Bitfield(horizontal,1); /* wall/door/etc is horiz. (more typ info) */ 333. 	Bitfield(lit,1);	/* speed hack for lit rooms */ 334. 	Bitfield(waslit,1);	/* remember if a location was lit */ 335. 	Bitfield(roomno,6);	/* room # for special rooms */ 336. 	Bitfield(edge,1);	/* marks boundaries for special rooms*/ 337. };  338.   339.  /*  340.   * Add wall angle viewing by defining "modes" for each wall type. Each 341.  * mode describes which parts of a wall are finished (seen as as wall) 342.  * and which are unfinished (seen as rock). 343.  *  344.   * We use the bottom 3 bits of the flags field for the mode. This comes 345.  * in conflict with secret doors, but we avoid problems because until 346.  * a secret door becomes discovered, we know what sdoor's bottom three 347.  * bits are. 348.  *  349.   * The following should cover all of the cases. 350.  *  351.   *	type	mode				Examples: R=rock, F=finished 352.  *	-					  353.   *	WALL:	0 none				hwall, mode 1 354.  *		1 left/top (1/2 rock)			RRR 355.  *		2 right/bottom (1/2 rock)		--- 356.  *							FFF 357.  *  358.   *	CORNER: 0 none				trcorn, mode 2 359.  *		1 outer (3/4 rock)			FFF 360.  *		2 inner (1/4 rock)			F+- 361.  *							F|R 362.  *  363.   *	TWALL:	0 none				tlwall, mode 3 364.  *		1 long edge (1/2 rock)			F|F 365.  *		2 bottom left (on a tdwall)		-+F 366.  *		3 bottom right (on a tdwall)		R|F 367.  *  368.   *	CRWALL: 0 none				crwall, mode 5 369.  *		1 top left (1/4 rock)			R|F 370.  *		2 top right (1/4 rock)			-+- 371.  *		3 bottom left (1/4 rock)		F|R 372.  *		4 bottom right (1/4 rock) 373.  *		5 top left & bottom right (1/2 rock) 374.  *		6 bottom left & top right (1/2 rock) 375.  */  376.   377.  #define WM_W_LEFT 1			/* vertical or horizontal wall */ 378. #define WM_W_RIGHT 2 379. #define WM_W_TOP WM_W_LEFT 380. #define WM_W_BOTTOM WM_W_RIGHT 381.  382.  #define WM_C_OUTER 1			/* corner wall */ 383. #define WM_C_INNER 2 384.  385.  #define WM_T_LONG 1			/* T wall */ 386. #define WM_T_BL   2 387. #define WM_T_BR   3 388.  389.  #define WM_X_TL   1			/* cross wall */ 390. #define WM_X_TR   2 391. #define WM_X_BL   3 392. #define WM_X_BR   4 393. #define WM_X_TLBR 5 394. #define WM_X_BLTR 6 395.  396.  /*  397.   * Seen vector values. The seen vector is an array of 8 bits, one for each 398.  * octant around a given center x:  399. * 400.   *			0 1 2  401.   *			7 x 3 402.  *			6 5 4  403.   *  404.   * In the case of walls, a single wall square can be viewed from 8 possible 405.  * directions. If we know the type of wall and the directions from which 406.  * it has been seen, then we can determine what it looks like to the hero. 407.  */  408.  #define SV0 0x1 409. #define SV1 0x2 410. #define SV2 0x4 411. #define SV3 0x8 412. #define SV4 0x10 413. #define SV5 0x20 414. #define SV6 0x40 415. #define SV7 0x80 416. #define SVALL 0xFF 417.  418.   419.   420.  #define doormask	flags 421. #define altarmask	flags 422. #define wall_info	flags 423. #define ladder		flags 424. #define drawbridgemask	flags 425. #define looted		flags 426. #define icedpool	flags 427.  428.  #define blessedftn	horizontal  /* a fountain that grants attribs */ 429. #define disturbed	horizontal  /* a grave that has been disturbed */ 430.  431.  struct damage { 432. 	struct damage *next; 433. 	long when, cost; 434. 	coord place; 435. 	schar typ; 436. };  437.   438.  struct levelflags { 439. 	uchar	nfountains;		/* number of fountains on level */ 440. 	uchar	nsinks;			/* number of sinks on the level */ 441. 	/* Several flags that give hints about what's on the level */ 442. 	Bitfield(has_shop, 1); 443. 	Bitfield(has_vault, 1); 444. 	Bitfield(has_zoo, 1); 445. 	Bitfield(has_court, 1); 446. 	Bitfield(has_morgue, 1); 447. 	Bitfield(has_beehive, 1); 448. 	Bitfield(has_barracks, 1); 449. 	Bitfield(has_temple, 1); 450.  451.  	Bitfield(has_swamp, 1); 452. 	Bitfield(noteleport,1); 453. 	Bitfield(hardfloor,1); 454. 	Bitfield(nommap,1); 455. 	Bitfield(hero_memory,1);	/* hero has memory */ 456. 	Bitfield(shortsighted,1);	/* monsters are shortsighted */ 457. 	Bitfield(graveyard,1);		/* has_morgue, but remains set */ 458. 	Bitfield(is_maze_lev,1); 459.  460.  	Bitfield(is_cavernous_lev,1); 461. 	Bitfield(arboreal, 1);		/* Trees replace rock */ 462. };  463.   464.  typedef struct 465. {  466.      struct rm		locations[COLNO][ROWNO]; 467. #ifndef MICROPORT_BUG 468.     struct obj		*objects[COLNO][ROWNO]; 469.     struct monst	*monsters[COLNO][ROWNO]; 470. #else 471.     struct obj		*objects[1][ROWNO]; 472.     char		*yuk1[COLNO-1][ROWNO]; 473.     struct monst	*monsters[1][ROWNO]; 474.     char		*yuk2[COLNO-1][ROWNO]; 475. #endif 476.     struct obj		*objlist; 477.     struct obj		*buriedobjlist; 478.     struct monst	*monlist; 479.     struct damage	*damagelist; 480.     struct levelflags	flags; 481. }  482.  dlevel_t; 483.  484.  extern dlevel_t level;	/* structure describing the current level */ 485.  486.  /*  487.   * Macros for compatibility with old code. Someday these will go away. 488.  */  489.  #define levl		level.locations 490. #define fobj		level.objlist 491. #define fmon		level.monlist 492.  493.  /*  494.   * Covert a trap number into the defsym graphics array. 495.  * Convert a defsym number into a trap number. 496.  * Assumes that arrow trap will always be the first trap. 497.  */  498.  #define trap_to_defsym(t) (S_arrow_trap+(t)-1) 499. #define defsym_to_trap(d) ((d)-S_arrow_trap+1) 500.  501.  #define OBJ_AT(x,y)	(level.objects[x][y] != (struct obj *)0) 502. /*  503.   * Macros for encapsulation of level.monsters references. 504.  */  505.  #define MON_AT(x,y)	(level.monsters[x][y] != (struct monst *)0 && \  506.  			 !(level.monsters[x][y])->mburied) 507. #define MON_BURIED_AT(x,y)	(level.monsters[x][y] != (struct monst *)0 && \  508.  				(level.monsters[x][y])->mburied) 509. #ifndef STEED 510. #define place_monster(m,x,y)	((m)->mx=(x),(m)->my=(y),\  511.  				 level.monsters[(m)->mx][(m)->my]=(m)) 512. #endif 513. #define place_worm_seg(m,x,y)	level.monsters[x][y] = m  514. #define remove_monster(x,y)	level.monsters[x][y] = (struct monst *)0 515. #define m_at(x,y)		(MON_AT(x,y) ? level.monsters[x][y] : \  516.  						(struct monst *)0) 517. #define m_buried_at(x,y)	(MON_BURIED_AT(x,y) ? level.monsters[x][y] : \  518.  						       (struct monst *)0) 519.  520.  #endif /* RM_H */