3 * Purpose: header file for grid.c, used only in dungeon generation
4 * files (generate.c, rooms.c)
8 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
10 * This software may be copied and distributed for educational, research, and
11 * not for profit purposes provided that this copyright and statement are
12 * included in all such copies.
18 #define set_cave_feat(Y,X,F) (cave[(Y)][(X)].feat = (F))
19 #define add_cave_info(Y,X,I) (cave[(Y)][(X)].info |= (I))
21 /* This should not be used */
22 /*#define set_cave_info(Y,X,I) (cave[(Y)][(X)].info = (I)) */
24 #define place_rubble(Y,X) set_cave_feat(Y,X,FEAT_RUBBLE)
25 #define place_up_stairs(Y,X) set_cave_feat(Y,X,FEAT_LESS)
26 #define place_down_stairs(Y,X) set_cave_feat(Y,X,FEAT_MORE)
27 #define place_invis_wall(Y,X) set_cave_feat(Y,X,FEAT_WALL_INVIS)
29 #define is_floor_bold(Y,X) (cave[Y][X].info & CAVE_FLOOR)
30 #define is_extra_bold(Y,X) (cave[Y][X].info & CAVE_EXTRA)
31 #define is_inner_bold(Y,X) (cave[Y][X].info & CAVE_INNER)
32 #define is_outer_bold(Y,X) (cave[Y][X].info & CAVE_OUTER)
33 #define is_solid_bold(Y,X) (cave[Y][X].info & CAVE_SOLID)
35 #define is_floor_grid(C) ((C)->info & CAVE_FLOOR)
36 #define is_extra_grid(C) ((C)->info & CAVE_EXTRA)
37 #define is_inner_grid(C) ((C)->info & CAVE_INNER)
38 #define is_outer_grid(C) ((C)->info & CAVE_OUTER)
39 #define is_solid_grid(C) ((C)->info & CAVE_SOLID)
41 #define place_floor_bold(Y, X) \
43 set_cave_feat(Y,X,floor_type[rand_int(100)]); \
44 cave[Y][X].info &= ~(CAVE_MASK); \
45 add_cave_info(Y,X,CAVE_FLOOR); \
48 #define place_floor_grid(C) \
50 (C)->feat = floor_type[rand_int(100)]; \
51 (C)->info &= ~(CAVE_MASK); \
52 (C)->info |= CAVE_FLOOR; \
55 #define place_extra_bold(Y, X) \
57 set_cave_feat(Y,X,fill_type[rand_int(100)]); \
58 cave[Y][X].info &= ~(CAVE_MASK); \
59 add_cave_info(Y,X,CAVE_EXTRA); \
62 #define place_extra_grid(C) \
64 (C)->feat = fill_type[rand_int(100)]; \
65 (C)->info &= ~(CAVE_MASK); \
66 (C)->info |= CAVE_EXTRA; \
69 #define place_extra_noperm_bold(Y, X) \
71 set_cave_feat(Y,X,fill_type[rand_int(100)]); \
72 if ((cave[Y][X].feat >= FEAT_PERM_EXTRA) && (cave[Y][X].feat <= FEAT_PERM_SOLID)) cave[Y][X].feat -= 0x04; \
73 else if (cave[Y][X].feat == FEAT_MOUNTAIN) cave[Y][X].feat = feat_wall_inner; \
74 cave[Y][X].info &= ~(CAVE_MASK); \
75 add_cave_info(Y,X,CAVE_EXTRA); \
78 #define place_inner_bold(Y, X) \
80 set_cave_feat(Y,X,feat_wall_inner); \
81 cave[Y][X].info &= ~(CAVE_MASK); \
82 add_cave_info(Y,X,CAVE_INNER); \
85 #define place_inner_grid(C) \
87 (C)->feat = feat_wall_inner; \
88 (C)->info &= ~(CAVE_MASK); \
89 (C)->info |= CAVE_INNER; \
92 #define place_outer_bold(Y, X) \
94 set_cave_feat(Y,X,feat_wall_outer); \
95 cave[Y][X].info &= ~(CAVE_MASK); \
96 add_cave_info(Y,X,CAVE_OUTER); \
99 #define place_outer_grid(C) \
101 (C)->feat = feat_wall_outer; \
102 (C)->info &= ~(CAVE_MASK); \
103 (C)->info |= CAVE_OUTER; \
106 #define place_outer_noperm_bold(Y, X) \
108 if ((feat_wall_outer >= FEAT_PERM_EXTRA) && (feat_wall_outer <= FEAT_PERM_SOLID)) set_cave_feat(Y, X, feat_wall_outer-0x04); \
109 else if (feat_wall_outer == FEAT_MOUNTAIN) cave[Y][X].feat = feat_wall_inner; \
110 else set_cave_feat(Y,X,feat_wall_outer); \
111 cave[Y][X].info &= ~(CAVE_MASK); \
112 add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
115 #define place_outer_noperm_grid(C) \
117 if ((feat_wall_outer >= FEAT_PERM_EXTRA) && (feat_wall_outer <= FEAT_PERM_SOLID)) (C)->feat = feat_wall_outer-0x04; \
118 else if (feat_wall_outer == FEAT_MOUNTAIN) (C)->feat = feat_wall_inner; \
119 else (C)->feat = feat_wall_outer; \
120 (C)->info &= ~(CAVE_MASK); \
121 (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
124 #define place_solid_bold(Y, X) \
126 set_cave_feat(Y,X,feat_wall_solid); \
127 cave[Y][X].info &= ~(CAVE_MASK); \
128 add_cave_info(Y,X,CAVE_SOLID); \
131 #define place_solid_grid(C) \
133 (C)->feat = feat_wall_solid; \
134 (C)->info &= ~(CAVE_MASK); \
135 (C)->info |= CAVE_SOLID; \
138 #define place_solid_noperm_bold(Y, X) \
140 if ((cave[Y][X].info & CAVE_VAULT) && (feat_wall_solid >= FEAT_PERM_EXTRA) && (feat_wall_solid <= FEAT_PERM_SOLID)) set_cave_feat(Y, X, feat_wall_solid-0x04); \
141 else set_cave_feat(Y,X,feat_wall_solid); \
142 cave[Y][X].info &= ~(CAVE_MASK); \
143 add_cave_info(Y,X,CAVE_SOLID); \
146 #define place_solid_noperm_grid(C) \
148 if ((c_ptr->info & CAVE_VAULT) && (feat_wall_solid >= FEAT_PERM_EXTRA) && (feat_wall_solid <= FEAT_PERM_SOLID)) (C)->feat = feat_wall_solid-0x04; \
149 else (C)->feat = feat_wall_solid; \
150 (C)->info &= ~(CAVE_MASK); \
151 (C)->info |= CAVE_SOLID; \
157 extern bool new_player_spot(void);
159 extern void place_random_stairs(int y, int x);
160 extern void place_random_door(int y, int x);
161 extern void place_closed_door(int y, int x);
162 extern void place_floor(int x1, int x2, int y1, int y2, bool light);
163 extern void place_room(int x1, int x2, int y1, int y2, bool light);
164 extern void vault_monsters(int y1, int x1, int num);
165 extern void vault_objects(int y, int x, int num);
166 extern void vault_trap_aux(int y, int x, int yd, int xd);
167 extern void vault_traps(int y, int x, int yd, int xd, int num);
169 extern int next_to_walls(int y, int x);
170 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
172 extern void rand_dir(int *rdir, int *cdir);
174 extern bool get_is_floor(int x, int y);
175 extern void set_floor(int x, int y);
177 extern void build_tunnel(int row1, int col1, int row2, int col2);
178 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);