OSDN Git Service

cave_floor_*()の使用に関する変更の途中経過.
[hengband/hengband.git] / src / grid.h
1 /*
2  * File: grid.h
3  * Purpose: header file for grid.c, used only in dungeon generation
4  * files (generate.c, rooms.c)
5  */
6
7 /*
8  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
9  *
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.
13  */
14
15
16 /* Macros */
17
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))
20
21 /* This should not be used */
22 /*#define set_cave_info(Y,X,I)    (cave[(Y)][(X)].info = (I)) */
23
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
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)
33
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)
39
40 #define place_floor_bold(Y, X) \
41 { \
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); \
45 }
46
47 #define place_floor_grid(C) \
48 { \
49         (C)->feat = floor_type[randint0(100)]; \
50         (C)->info &= ~(CAVE_MASK); \
51         (C)->info |= CAVE_FLOOR; \
52 }
53
54 #define place_extra_bold(Y, X) \
55 { \
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); \
59 }
60
61 #define place_extra_grid(C) \
62 { \
63         (C)->feat = fill_type[randint0(100)]; \
64         (C)->info &= ~(CAVE_MASK); \
65         (C)->info |= CAVE_EXTRA; \
66 }
67
68 #define place_extra_perm_bold(Y, X) \
69 { \
70         set_cave_feat(Y,X,FEAT_PERM); \
71         cave[Y][X].info &= ~(CAVE_MASK); \
72         add_cave_info(Y,X,CAVE_EXTRA); \
73 }
74
75 #define place_extra_perm_grid(C) \
76 { \
77         (C)->feat = FEAT_PERM; \
78         (C)->info &= ~(CAVE_MASK); \
79         (C)->info |= CAVE_EXTRA; \
80 }
81
82 #define place_extra_noperm_bold(Y, X) \
83 { \
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); \
90 }
91
92 #define place_inner_bold(Y, X) \
93 { \
94         set_cave_feat(Y,X,feat_wall_inner); \
95         cave[Y][X].info &= ~(CAVE_MASK); \
96         add_cave_info(Y,X,CAVE_INNER); \
97 }
98
99 #define place_inner_grid(C) \
100 { \
101         (C)->feat = feat_wall_inner; \
102         (C)->info &= ~(CAVE_MASK); \
103         (C)->info |= CAVE_INNER; \
104 }
105
106 #define place_inner_perm_bold(Y, X) \
107 { \
108         set_cave_feat(Y,X,FEAT_PERM); \
109         cave[Y][X].info &= ~(CAVE_MASK); \
110         add_cave_info(Y,X,CAVE_INNER); \
111 }
112
113 #define place_inner_perm_grid(C) \
114 { \
115         (C)->feat = FEAT_PERM; \
116         (C)->info &= ~(CAVE_MASK); \
117         (C)->info |= CAVE_INNER; \
118 }
119
120 #define place_outer_bold(Y, X) \
121 { \
122         set_cave_feat(Y,X,feat_wall_outer); \
123         cave[Y][X].info &= ~(CAVE_MASK); \
124         add_cave_info(Y,X,CAVE_OUTER); \
125 }
126
127 #define place_outer_grid(C) \
128 { \
129         (C)->feat = feat_wall_outer; \
130         (C)->info &= ~(CAVE_MASK); \
131         (C)->info |= CAVE_OUTER; \
132 }
133
134 #define place_outer_perm_bold(Y, X) \
135 { \
136         set_cave_feat(Y,X,FEAT_PERM); \
137         cave[Y][X].info &= ~(CAVE_MASK); \
138         add_cave_info(Y,X,CAVE_OUTER); \
139 }
140
141 #define place_outer_perm_grid(C) \
142 { \
143         (C)->feat = FEAT_PERM; \
144         (C)->info &= ~(CAVE_MASK); \
145         (C)->info |= CAVE_OUTER; \
146 }
147
148 #define place_outer_noperm_bold(Y, X) \
149 { \
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)); \
155 }
156
157 #define place_outer_noperm_grid(C) \
158 { \
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); \
164 }
165
166 #define place_solid_bold(Y, X) \
167 { \
168         set_cave_feat(Y,X,feat_wall_solid); \
169         cave[Y][X].info &= ~(CAVE_MASK); \
170         add_cave_info(Y,X,CAVE_SOLID); \
171 }
172
173 #define place_solid_grid(C) \
174 { \
175         (C)->feat = feat_wall_solid; \
176         (C)->info &= ~(CAVE_MASK); \
177         (C)->info |= CAVE_SOLID; \
178 }
179
180 #define place_solid_perm_bold(Y, X) \
181 { \
182         set_cave_feat(Y,X,FEAT_PERM); \
183         cave[Y][X].info &= ~(CAVE_MASK); \
184         add_cave_info(Y,X,CAVE_SOLID); \
185 }
186
187 #define place_solid_perm_grid(C) \
188 { \
189         (C)->feat = FEAT_PERM; \
190         (C)->info &= ~(CAVE_MASK); \
191         (C)->info |= CAVE_SOLID; \
192 }
193
194 #define place_solid_noperm_bold(Y, X) \
195 { \
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); \
202 }
203
204 #define place_solid_noperm_grid(C) \
205 { \
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; \
212 }
213
214
215 /* Externs */
216
217 extern bool new_player_spot(void);
218
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);
228
229 extern int next_to_walls(int y, int x);
230 extern void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2);
231
232 extern void rand_dir(int *rdir, int *cdir);
233
234 extern bool get_is_floor(int x, int y);
235 extern void set_floor(int x, int y);
236
237 extern void build_tunnel(int row1, int col1, int row2, int col2);
238 extern bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff);