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_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
74 cave[Y][X].feat = feat_state(cave[Y][X].feat, FF_UNPERM); \
75 cave[Y][X].info &= ~(CAVE_MASK); \
76 add_cave_info(Y,X,CAVE_EXTRA); \
79 #define place_inner_bold(Y, X) \
81 set_cave_feat(Y,X,feat_wall_inner); \
82 cave[Y][X].info &= ~(CAVE_MASK); \
83 add_cave_info(Y,X,CAVE_INNER); \
86 #define place_inner_grid(C) \
88 (C)->feat = feat_wall_inner; \
89 (C)->info &= ~(CAVE_MASK); \
90 (C)->info |= CAVE_INNER; \
93 #define place_outer_bold(Y, X) \
95 set_cave_feat(Y,X,feat_wall_outer); \
96 cave[Y][X].info &= ~(CAVE_MASK); \
97 add_cave_info(Y,X,CAVE_OUTER); \
100 #define place_outer_grid(C) \
102 (C)->feat = feat_wall_outer; \
103 (C)->info &= ~(CAVE_MASK); \
104 (C)->info |= CAVE_OUTER; \
107 #define place_outer_noperm_bold(Y, X) \
109 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
110 if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
111 set_cave_feat(Y, X, feat_state(feat_wall_outer, FF_UNPERM)); \
112 else set_cave_feat(Y,X,feat_wall_outer); \
113 cave[Y][X].info &= ~(CAVE_MASK); \
114 add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
117 #define place_outer_noperm_grid(C) \
119 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
120 if (have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
121 (C)->feat = feat_state(feat_wall_outer, FF_UNPERM); \
122 else (C)->feat = feat_wall_outer; \
123 (C)->info &= ~(CAVE_MASK); \
124 (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
127 #define place_solid_bold(Y, X) \
129 set_cave_feat(Y,X,feat_wall_solid); \
130 cave[Y][X].info &= ~(CAVE_MASK); \
131 add_cave_info(Y,X,CAVE_SOLID); \
134 #define place_solid_grid(C) \
136 (C)->feat = feat_wall_solid; \
137 (C)->info &= ~(CAVE_MASK); \
138 (C)->info |= CAVE_SOLID; \
141 #define place_solid_noperm_bold(Y, X) \
143 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
144 if ((cave[Y][X].info & CAVE_VAULT) && have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
145 set_cave_feat(Y, X, feat_state(feat_wall_solid, FF_UNPERM)); \
146 else set_cave_feat(Y,X,feat_wall_solid); \
147 cave[Y][X].info &= ~(CAVE_MASK); \
148 add_cave_info(Y,X,CAVE_SOLID); \
151 #define place_solid_noperm_grid(C) \
153 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
154 if (((C)->info & CAVE_VAULT) && have_flag(_f_ptr->flags, FF_WALL) && have_flag(_f_ptr->flags, FF_PERMANENT)) \
155 (C)->feat = feat_state(feat_wall_solid, FF_UNPERM); \
156 else (C)->feat = feat_wall_solid; \
157 (C)->info &= ~(CAVE_MASK); \
158 (C)->info |= CAVE_SOLID; \
164 extern bool new_player_spot(void);
166 extern void place_random_stairs(int y, int x);
167 extern void place_random_door(int y, int x, bool room);
168 extern void place_closed_door(int y, int x);
169 extern void place_floor(int x1, int x2, int y1, int y2, bool light);
170 extern void place_room(int x1, int x2, int y1, int y2, bool light);
171 extern void vault_monsters(int y1, int x1, int num);
172 extern void vault_objects(int y, int x, int num);
173 extern void vault_trap_aux(int y, int x, int yd, int xd);
174 extern void vault_traps(int y, int x, int yd, int xd, int num);
176 extern int next_to_walls(int y, int x);
177 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
179 extern void rand_dir(int *rdir, int *cdir);
181 extern bool get_is_floor(int x, int y);
182 extern void set_floor(int x, int y);
184 extern void build_tunnel(int row1, int col1, int row2, int col2);
185 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);