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_noperm_bold(Y, X) \
70 feature_type *_f_ptr; \
71 set_cave_feat(Y,X,fill_type[randint0(100)]); \
72 _f_ptr = &f_info[cave[Y][X].feat]; \
73 if (have_flag(_f_ptr->flags, FF_MOUNTAIN)) cave[Y][X].feat = feat_wall_inner; \
74 else if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
75 cave[Y][X].feat = feat_state(cave[Y][X].feat, FF_UNPERM); \
76 cave[Y][X].info &= ~(CAVE_MASK); \
77 add_cave_info(Y,X,CAVE_EXTRA); \
80 #define place_inner_bold(Y, X) \
82 set_cave_feat(Y,X,feat_wall_inner); \
83 cave[Y][X].info &= ~(CAVE_MASK); \
84 add_cave_info(Y,X,CAVE_INNER); \
87 #define place_inner_grid(C) \
89 (C)->feat = feat_wall_inner; \
90 (C)->info &= ~(CAVE_MASK); \
91 (C)->info |= CAVE_INNER; \
94 #define place_outer_bold(Y, X) \
96 set_cave_feat(Y,X,feat_wall_outer); \
97 cave[Y][X].info &= ~(CAVE_MASK); \
98 add_cave_info(Y,X,CAVE_OUTER); \
101 #define place_outer_grid(C) \
103 (C)->feat = feat_wall_outer; \
104 (C)->info &= ~(CAVE_MASK); \
105 (C)->info |= CAVE_OUTER; \
108 #define place_outer_noperm_bold(Y, X) \
110 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
111 if (have_flag(_f_ptr->flags, FF_MOUNTAIN)) cave[Y][X].feat = feat_wall_inner; \
112 else if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
113 set_cave_feat(Y, X, feat_state(feat_wall_outer, FF_UNPERM)); \
114 else set_cave_feat(Y,X,feat_wall_outer); \
115 cave[Y][X].info &= ~(CAVE_MASK); \
116 add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
119 #define place_outer_noperm_grid(C) \
121 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
122 if (have_flag(_f_ptr->flags, FF_MOUNTAIN)) (C)->feat = feat_wall_inner; \
123 else if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
124 (C)->feat = feat_state(feat_wall_outer, FF_UNPERM); \
125 else (C)->feat = feat_wall_outer; \
126 (C)->info &= ~(CAVE_MASK); \
127 (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
130 #define place_solid_bold(Y, X) \
132 set_cave_feat(Y,X,feat_wall_solid); \
133 cave[Y][X].info &= ~(CAVE_MASK); \
134 add_cave_info(Y,X,CAVE_SOLID); \
137 #define place_solid_grid(C) \
139 (C)->feat = feat_wall_solid; \
140 (C)->info &= ~(CAVE_MASK); \
141 (C)->info |= CAVE_SOLID; \
144 #define place_solid_noperm_bold(Y, X) \
146 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
147 if ((cave[Y][X].info & CAVE_VAULT) && have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
148 set_cave_feat(Y, X, feat_state(feat_wall_solid, FF_UNPERM)); \
149 else set_cave_feat(Y,X,feat_wall_solid); \
150 cave[Y][X].info &= ~(CAVE_MASK); \
151 add_cave_info(Y,X,CAVE_SOLID); \
154 #define place_solid_noperm_grid(C) \
156 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
157 if (((C)->info & CAVE_VAULT) && have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
158 (C)->feat = feat_state(feat_wall_solid, FF_UNPERM); \
159 else (C)->feat = feat_wall_solid; \
160 (C)->info &= ~(CAVE_MASK); \
161 (C)->info |= CAVE_SOLID; \
167 extern bool new_player_spot(void);
169 extern void place_random_stairs(int y, int x);
170 extern void place_random_door(int y, int x, bool room);
171 extern void place_closed_door(int y, int x);
172 extern void place_floor(int x1, int x2, int y1, int y2, bool light);
173 extern void place_room(int x1, int x2, int y1, int y2, bool light);
174 extern void vault_monsters(int y1, int x1, int num);
175 extern void vault_objects(int y, int x, int num);
176 extern void vault_trap_aux(int y, int x, int yd, int xd);
177 extern void vault_traps(int y, int x, int yd, int xd, int num);
179 extern int next_to_walls(int y, int x);
180 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
182 extern void rand_dir(int *rdir, int *cdir);
184 extern bool get_is_floor(int x, int y);
185 extern void set_floor(int x, int y);
187 extern void build_tunnel(int row1, int col1, int row2, int col2);
188 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);