Source:SLASH'EM 0.0.7E7F2/rm.h

From NetHackWiki
Jump to navigation Jump to search

Below is the full text to rm.h from the source code of SLASH'EM 0.0.7E7F2. To link to a particular line, write [[Source:SLASH'EM 0.0.7E7F2/rm.h#line123]], for example.

Source code for vanilla NetHack is at Source code.


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