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