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)
28 #define is_floor_bold(Y,X) (cave[Y][X].info & CAVE_FLOOR)
29 #define is_extra_bold(Y,X) (cave[Y][X].info & CAVE_EXTRA)
30 #define is_inner_bold(Y,X) (cave[Y][X].info & CAVE_INNER)
31 #define is_outer_bold(Y,X) (cave[Y][X].info & CAVE_OUTER)
32 #define is_solid_bold(Y,X) (cave[Y][X].info & CAVE_SOLID)
34 #define is_floor_grid(C) ((C)->info & CAVE_FLOOR)
35 #define is_extra_grid(C) ((C)->info & CAVE_EXTRA)
36 #define is_inner_grid(C) ((C)->info & CAVE_INNER)
37 #define is_outer_grid(C) ((C)->info & CAVE_OUTER)
38 #define is_solid_grid(C) ((C)->info & CAVE_SOLID)
40 #define place_floor_bold(Y, X) \
42 set_cave_feat(Y,X,floor_type[randint0(100)]); \
43 cave[Y][X].info &= ~(CAVE_MASK); \
44 add_cave_info(Y,X,CAVE_FLOOR); \
47 #define place_floor_grid(C) \
49 (C)->feat = floor_type[randint0(100)]; \
50 (C)->info &= ~(CAVE_MASK); \
51 (C)->info |= CAVE_FLOOR; \
54 #define place_extra_bold(Y, X) \
56 set_cave_feat(Y,X,fill_type[randint0(100)]); \
57 cave[Y][X].info &= ~(CAVE_MASK); \
58 add_cave_info(Y,X,CAVE_EXTRA); \
61 #define place_extra_grid(C) \
63 (C)->feat = fill_type[randint0(100)]; \
64 (C)->info &= ~(CAVE_MASK); \
65 (C)->info |= CAVE_EXTRA; \
68 #define place_extra_perm_bold(Y, X) \
70 set_cave_feat(Y,X,FEAT_PERM); \
71 cave[Y][X].info &= ~(CAVE_MASK); \
72 add_cave_info(Y,X,CAVE_EXTRA); \
75 #define place_extra_perm_grid(C) \
77 (C)->feat = FEAT_PERM; \
78 (C)->info &= ~(CAVE_MASK); \
79 (C)->info |= CAVE_EXTRA; \
82 #define place_extra_noperm_bold(Y, X) \
84 feature_type *_f_ptr; \
85 set_cave_feat(Y,X,fill_type[randint0(100)]); \
86 _f_ptr = &f_info[cave[Y][X].feat]; \
87 if (permanent_wall(_f_ptr)) cave[Y][X].feat = feat_state(cave[Y][X].feat, FF_UNPERM); \
88 cave[Y][X].info &= ~(CAVE_MASK); \
89 add_cave_info(Y,X,CAVE_EXTRA); \
92 #define place_inner_bold(Y, X) \
94 set_cave_feat(Y,X,feat_wall_inner); \
95 cave[Y][X].info &= ~(CAVE_MASK); \
96 add_cave_info(Y,X,CAVE_INNER); \
99 #define place_inner_grid(C) \
101 (C)->feat = feat_wall_inner; \
102 (C)->info &= ~(CAVE_MASK); \
103 (C)->info |= CAVE_INNER; \
106 #define place_inner_perm_bold(Y, X) \
108 set_cave_feat(Y,X,FEAT_PERM); \
109 cave[Y][X].info &= ~(CAVE_MASK); \
110 add_cave_info(Y,X,CAVE_INNER); \
113 #define place_inner_perm_grid(C) \
115 (C)->feat = FEAT_PERM; \
116 (C)->info &= ~(CAVE_MASK); \
117 (C)->info |= CAVE_INNER; \
120 #define place_outer_bold(Y, X) \
122 set_cave_feat(Y,X,feat_wall_outer); \
123 cave[Y][X].info &= ~(CAVE_MASK); \
124 add_cave_info(Y,X,CAVE_OUTER); \
127 #define place_outer_grid(C) \
129 (C)->feat = feat_wall_outer; \
130 (C)->info &= ~(CAVE_MASK); \
131 (C)->info |= CAVE_OUTER; \
134 #define place_outer_perm_bold(Y, X) \
136 set_cave_feat(Y,X,FEAT_PERM); \
137 cave[Y][X].info &= ~(CAVE_MASK); \
138 add_cave_info(Y,X,CAVE_OUTER); \
141 #define place_outer_perm_grid(C) \
143 (C)->feat = FEAT_PERM; \
144 (C)->info &= ~(CAVE_MASK); \
145 (C)->info |= CAVE_OUTER; \
148 #define place_outer_noperm_bold(Y, X) \
150 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
151 if (permanent_wall(_f_ptr)) set_cave_feat(Y, X, feat_state(feat_wall_outer, FF_UNPERM)); \
152 else set_cave_feat(Y,X,feat_wall_outer); \
153 cave[Y][X].info &= ~(CAVE_MASK); \
154 add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
157 #define place_outer_noperm_grid(C) \
159 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
160 if (permanent_wall(_f_ptr)) (C)->feat = feat_state(feat_wall_outer, FF_UNPERM); \
161 else (C)->feat = feat_wall_outer; \
162 (C)->info &= ~(CAVE_MASK); \
163 (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
166 #define place_solid_bold(Y, X) \
168 set_cave_feat(Y,X,feat_wall_solid); \
169 cave[Y][X].info &= ~(CAVE_MASK); \
170 add_cave_info(Y,X,CAVE_SOLID); \
173 #define place_solid_grid(C) \
175 (C)->feat = feat_wall_solid; \
176 (C)->info &= ~(CAVE_MASK); \
177 (C)->info |= CAVE_SOLID; \
180 #define place_solid_perm_bold(Y, X) \
182 set_cave_feat(Y,X,FEAT_PERM); \
183 cave[Y][X].info &= ~(CAVE_MASK); \
184 add_cave_info(Y,X,CAVE_SOLID); \
187 #define place_solid_perm_grid(C) \
189 (C)->feat = FEAT_PERM; \
190 (C)->info &= ~(CAVE_MASK); \
191 (C)->info |= CAVE_SOLID; \
194 #define place_solid_noperm_bold(Y, X) \
196 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
197 if ((cave[Y][X].info & CAVE_VAULT) && permanent_wall(_f_ptr)) \
198 set_cave_feat(Y, X, feat_state(feat_wall_solid, FF_UNPERM)); \
199 else set_cave_feat(Y,X,feat_wall_solid); \
200 cave[Y][X].info &= ~(CAVE_MASK); \
201 add_cave_info(Y,X,CAVE_SOLID); \
204 #define place_solid_noperm_grid(C) \
206 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
207 if (((C)->info & CAVE_VAULT) && permanent_wall(_f_ptr)) \
208 (C)->feat = feat_state(feat_wall_solid, FF_UNPERM); \
209 else (C)->feat = feat_wall_solid; \
210 (C)->info &= ~(CAVE_MASK); \
211 (C)->info |= CAVE_SOLID; \
217 extern bool new_player_spot(void);
219 extern void place_random_stairs(int y, int x);
220 extern void place_random_door(int y, int x, bool room);
221 extern void place_closed_door(int y, int x);
222 extern void place_floor(int x1, int x2, int y1, int y2, bool light);
223 extern void place_room(int x1, int x2, int y1, int y2, bool light);
224 extern void vault_monsters(int y1, int x1, int num);
225 extern void vault_objects(int y, int x, int num);
226 extern void vault_trap_aux(int y, int x, int yd, int xd);
227 extern void vault_traps(int y, int x, int yd, int xd, int num);
229 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
231 extern void rand_dir(int *rdir, int *cdir);
233 extern bool get_is_floor(int x, int y);
234 extern void set_floor(int x, int y);
236 extern void build_tunnel(int row1, int col1, int row2, int col2);
237 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);