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