Source:NetHack 3.4.3/include/rm.h

From NetHackWiki
Jump to: navigation, search

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

  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. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

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