3 * @brief ダンジョンの生成処理の基幹部分ヘッダーファイル
6 * Purpose: header file for grid.c, used only in dungeon generation
7 * files (generate.c, rooms.c)
9 * 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.
17 #define set_cave_feat(Y,X,F) (current_floor_ptr->grid_array[(Y)][(X)].feat = (F))
18 #define add_cave_info(Y,X,I) (current_floor_ptr->grid_array[(Y)][(X)].info |= (I))
20 /* This should not be used */
21 /*#define set_cave_info(Y,X,I) (current_floor_ptr->grid_array[(Y)][(X)].info = (I)) */
24 * @brief 指定座標が瓦礫かどうかを返す
29 #define place_rubble(Y,X) set_cave_feat(Y,X,feat_rubble)
32 * @brief 指定座標が上り階段かどうかを返す
37 #define place_up_stairs(Y,X) set_cave_feat(Y,X,feat_up_stair)
40 * @brief 指定座標が下り階段かどうかを返す
45 #define place_down_stairs(Y,X) set_cave_feat(Y,X,feat_down_stair)
48 * @brief 指定座標がFLOOR属性を持ったマスかどうかを返す
51 * @return FLOOR属性を持っているならばTRUE
53 #define is_floor_bold(Y,X) (current_floor_ptr->grid_array[Y][X].info & CAVE_FLOOR)
54 #define is_extra_bold(Y,X) (current_floor_ptr->grid_array[Y][X].info & CAVE_EXTRA)
56 #define is_inner_bold(Y,X) (current_floor_ptr->grid_array[Y][X].info & CAVE_INNER)
57 #define is_outer_bold(Y,X) (current_floor_ptr->grid_array[Y][X].info & CAVE_OUTER)
58 #define is_solid_bold(Y,X) (current_floor_ptr->grid_array[Y][X].info & CAVE_SOLID)
60 #define is_floor_grid(C) ((C)->info & CAVE_FLOOR)
61 #define is_extra_grid(C) ((C)->info & CAVE_EXTRA)
62 #define is_inner_grid(C) ((C)->info & CAVE_INNER)
63 #define is_outer_grid(C) ((C)->info & CAVE_OUTER)
64 #define is_solid_grid(C) ((C)->info & CAVE_SOLID)
66 #define place_floor_bold(Y, X) \
68 set_cave_feat(Y,X,feat_ground_type[randint0(100)]); \
69 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
70 add_cave_info(Y,X,CAVE_FLOOR); \
71 delete_monster(Y, X); \
74 #define place_floor_grid(C) \
76 (C)->feat = feat_ground_type[randint0(100)]; \
77 (C)->info &= ~(CAVE_MASK); \
78 (C)->info |= CAVE_FLOOR; \
79 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
82 #define place_extra_bold(Y, X) \
84 set_cave_feat(Y,X,feat_wall_type[randint0(100)]); \
85 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
86 add_cave_info(Y,X,CAVE_EXTRA); \
87 delete_monster(Y, X); \
90 #define place_extra_grid(C) \
92 (C)->feat = feat_wall_type[randint0(100)]; \
93 (C)->info &= ~(CAVE_MASK); \
94 (C)->info |= CAVE_EXTRA; \
95 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
98 #define place_extra_perm_bold(Y, X) \
100 set_cave_feat(Y,X,feat_permanent); \
101 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
102 add_cave_info(Y,X,CAVE_EXTRA); \
103 delete_monster(Y, X); \
106 #define place_extra_perm_grid(C) \
108 (C)->feat = feat_permanent; \
109 (C)->info &= ~(CAVE_MASK); \
110 (C)->info |= CAVE_EXTRA; \
111 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
114 #define place_extra_noperm_bold(Y, X) \
116 feature_type *_f_ptr; \
117 set_cave_feat(Y,X,feat_wall_type[randint0(100)]); \
118 _f_ptr = &f_info[current_floor_ptr->grid_array[Y][X].feat]; \
119 if (permanent_wall(_f_ptr)) current_floor_ptr->grid_array[Y][X].feat = feat_state(current_floor_ptr->grid_array[Y][X].feat, FF_UNPERM); \
120 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
121 add_cave_info(Y,X,CAVE_EXTRA); \
122 delete_monster(Y, X); \
125 #define place_inner_bold(Y, X) \
127 set_cave_feat(Y,X,feat_wall_inner); \
128 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
129 add_cave_info(Y,X,CAVE_INNER); \
130 delete_monster(Y, X); \
133 #define place_inner_grid(C) \
135 (C)->feat = feat_wall_inner; \
136 (C)->info &= ~(CAVE_MASK); \
137 (C)->info |= CAVE_INNER; \
138 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
141 #define place_inner_perm_bold(Y, X) \
143 set_cave_feat(Y,X,feat_permanent); \
144 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
145 add_cave_info(Y,X,CAVE_INNER); \
146 delete_monster(Y, X); \
149 #define place_inner_perm_grid(C) \
151 (C)->feat = feat_permanent; \
152 (C)->info &= ~(CAVE_MASK); \
153 (C)->info |= CAVE_INNER; \
154 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
157 #define place_outer_bold(Y, X) \
159 set_cave_feat(Y,X,feat_wall_outer); \
160 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
161 add_cave_info(Y,X,CAVE_OUTER); \
162 delete_monster(Y, X); \
165 #define place_outer_grid(C) \
167 (C)->feat = feat_wall_outer; \
168 (C)->info &= ~(CAVE_MASK); \
169 (C)->info |= CAVE_OUTER; \
170 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
173 #define place_outer_perm_bold(Y, X) \
175 set_cave_feat(Y,X,feat_permanent); \
176 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
177 add_cave_info(Y,X,CAVE_OUTER); \
178 delete_monster(Y, X); \
181 #define place_outer_perm_grid(C) \
183 (C)->feat = feat_permanent; \
184 (C)->info &= ~(CAVE_MASK); \
185 (C)->info |= CAVE_OUTER; \
186 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
189 #define place_outer_noperm_bold(Y, X) \
191 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
192 if (permanent_wall(_f_ptr)) set_cave_feat(Y, X, (s16b)feat_state(feat_wall_outer, FF_UNPERM)); \
193 else set_cave_feat(Y,X,feat_wall_outer); \
194 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
195 add_cave_info(Y,X,(CAVE_OUTER | CAVE_VAULT)); \
196 delete_monster(Y, X); \
199 #define place_outer_noperm_grid(C) \
201 feature_type *_f_ptr = &f_info[feat_wall_outer]; \
202 if (permanent_wall(_f_ptr)) (C)->feat = (s16b)feat_state(feat_wall_outer, FF_UNPERM); \
203 else (C)->feat = feat_wall_outer; \
204 (C)->info &= ~(CAVE_MASK); \
205 (C)->info |= (CAVE_OUTER | CAVE_VAULT); \
206 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
209 #define place_solid_bold(Y, X) \
211 set_cave_feat(Y,X,feat_wall_solid); \
212 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
213 add_cave_info(Y,X,CAVE_SOLID); \
214 delete_monster(Y, X); \
217 #define place_solid_grid(C) \
219 (C)->feat = feat_wall_solid; \
220 (C)->info &= ~(CAVE_MASK); \
221 (C)->info |= CAVE_SOLID; \
222 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
225 #define place_solid_perm_bold(Y, X) \
227 set_cave_feat(Y,X,feat_permanent); \
228 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
229 add_cave_info(Y,X,CAVE_SOLID); \
230 delete_monster(Y, X); \
233 #define place_solid_perm_grid(C) \
235 (C)->feat = feat_permanent; \
236 (C)->info &= ~(CAVE_MASK); \
237 (C)->info |= CAVE_SOLID; \
238 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
241 #define place_solid_noperm_bold(Y, X) \
243 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
244 if ((current_floor_ptr->grid_array[Y][X].info & CAVE_VAULT) && permanent_wall(_f_ptr)) \
245 set_cave_feat(Y, X, feat_state(feat_wall_solid, FF_UNPERM)); \
246 else set_cave_feat(Y,X,feat_wall_solid); \
247 current_floor_ptr->grid_array[Y][X].info &= ~(CAVE_MASK); \
248 add_cave_info(Y,X,CAVE_SOLID); \
249 delete_monster(Y, X); \
252 #define place_solid_noperm_grid(C) \
254 feature_type *_f_ptr = &f_info[feat_wall_solid]; \
255 if (((C)->info & CAVE_VAULT) && permanent_wall(_f_ptr)) \
256 (C)->feat = feat_state(feat_wall_solid, FF_UNPERM); \
257 else (C)->feat = feat_wall_solid; \
258 (C)->info &= ~(CAVE_MASK); \
259 (C)->info |= CAVE_SOLID; \
260 if ((C)->m_idx) delete_monster_idx((C)->m_idx); \
265 * 特殊なマス状態フラグ / Special grid flags
267 #define CAVE_MARK 0x0001 /*!< 現在プレイヤーの記憶に収まっている / memorized feature */
268 #define CAVE_GLOW 0x0002 /*!< マス自体が光源を持っている / self-illuminating */
269 #define CAVE_ICKY 0x0004 /*!< 生成されたVaultの一部である / part of a vault */
270 #define CAVE_ROOM 0x0008 /*!< 生成された部屋の一部である / part of a room */
271 #define CAVE_LITE 0x0010 /*!< 現在光に照らされている / lite flag */
272 #define CAVE_VIEW 0x0020 /*!< 現在プレイヤーの視界に収まっている / view flag */
273 #define CAVE_TEMP 0x0040 /*!< 光源に関する処理のアルゴリズム用記録フラグ / temp flag */
274 #define CAVE_XTRA 0x0080 /*!< 視界に関する処理のアルゴリズム用記録フラグ(update_view()等参照) / misc flag */
275 #define CAVE_MNLT 0x0100 /*!< モンスターの光源によって照らされている / Illuminated by monster */
276 #define CAVE_MNDK 0x8000 /*!< モンスターの暗源によって暗闇になっている / Darken by monster */
278 /* Used only while current_floor_ptr->grid_array generation */
279 #define CAVE_FLOOR 0x0200 /*!< フロア属性のあるマス */
280 #define CAVE_EXTRA 0x0400
281 #define CAVE_INNER 0x0800
282 #define CAVE_OUTER 0x1000
283 #define CAVE_SOLID 0x2000
284 #define CAVE_VAULT 0x4000
285 #define CAVE_MASK (CAVE_FLOOR | CAVE_EXTRA | CAVE_INNER | CAVE_OUTER | CAVE_SOLID | CAVE_VAULT)
287 /* Used only after current_floor_ptr->grid_array generation */
288 #define CAVE_KNOWN 0x0200 /* Directly viewed or map detected flag */
289 #define CAVE_NOTE 0x0400 /* Flag for delayed visual update (needs note_spot()) */
290 #define CAVE_REDRAW 0x0800 /* Flag for delayed visual update (needs lite_spot()) */
291 #define CAVE_OBJECT 0x1000 /* Mirror, glyph, etc. */
292 #define CAVE_UNSAFE 0x2000 /* Might have trap */
293 #define CAVE_IN_DETECT 0x4000 /* trap detected area (inner circle only) */
297 extern bool new_player_spot(void);
299 extern void place_random_stairs(POSITION y, POSITION x);
300 extern void place_random_door(POSITION y, POSITION x, bool room);
301 extern void place_closed_door(POSITION y, POSITION x, int type);
302 extern void add_door(POSITION x, POSITION y);
303 extern void place_secret_door(POSITION y, POSITION x, int type);
304 extern void place_locked_door(POSITION y, POSITION x);
305 extern void try_door(POSITION y, POSITION x);
306 extern void place_floor(POSITION x1, POSITION x2, POSITION y1, POSITION y2, bool light);
307 extern void place_room(POSITION x1, POSITION x2, POSITION y1, POSITION y2, bool light);
308 extern void vault_monsters(POSITION y1, POSITION x1, int num);
309 extern void vault_objects(POSITION y, POSITION x, int num);
310 extern void vault_trap_aux(POSITION y, POSITION x, POSITION yd, POSITION xd);
311 extern void vault_traps(POSITION y, POSITION x, POSITION yd, POSITION xd, int num);
313 extern bool get_is_floor(POSITION x, POSITION y);
314 extern void set_floor(POSITION x, POSITION y);
315 extern void place_bound_perm_wall(grid_type *g_ptr);
317 extern bool is_known_trap(grid_type *g_ptr);
318 extern bool is_hidden_door(grid_type *g_ptr);
319 extern bool is_mirror_grid(grid_type *g_ptr);
320 extern bool is_glyph_grid(grid_type *g_ptr);
321 extern bool is_explosive_rune_grid(grid_type *g_ptr);
323 extern bool player_can_enter(FEAT_IDX feature, BIT_FLAGS16 mode);
326 * マス構造体のspecial要素を利用する地形かどうかを判定するマクロ / Is this feature has special meaning (except floor_id) with g_ptr->special?
328 #define feat_uses_special(F) (have_flag(f_info[(F)].flags, FF_SPECIAL))
331 extern POSITION distance(POSITION y1, POSITION x1, POSITION y2, POSITION x2);
332 extern bool los(POSITION y1, POSITION x1, POSITION y2, POSITION x2);
333 extern void update_local_illumination(POSITION y, POSITION x);
334 extern bool player_can_see_bold(POSITION y, POSITION x);
335 extern bool cave_valid_bold(POSITION y, POSITION x);
336 extern bool no_lite(void);
337 extern void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp);
338 extern void move_cursor_relative(int row, int col);
339 extern void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x);
340 extern void note_spot(POSITION y, POSITION x);
341 extern void display_dungeon(void);
342 extern void lite_spot(POSITION y, POSITION x);
343 extern void prt_map(void);
344 extern void prt_path(POSITION y, POSITION x);
345 extern void display_map(int *cy, int *cx);
346 extern void forget_lite(void);
347 extern void update_lite(void);
348 extern void forget_view(void);
349 extern void update_view(void);
350 extern void update_mon_lite(void);
351 extern void clear_mon_lite(void);
352 extern void delayed_visual_update(void);
353 extern void forget_flow(void);
354 extern void update_flow(void);
355 extern void update_smell(void);
356 extern void map_area(POSITION range);
357 extern void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat);
358 extern FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat);
359 extern FEAT_IDX feat_state(FEAT_IDX feat, int action);
360 extern void cave_alter_feat(POSITION y, POSITION x, int action);
361 extern void remove_mirror(POSITION y, POSITION x);
362 extern void lite_spot(POSITION y, POSITION x);
363 extern bool is_open(FEAT_IDX feat);
364 extern bool check_local_illumination(POSITION y, POSITION x);
367 * モンスターにより照明が消されている地形か否かを判定する。 / Is this grid "darkened" by monster?
369 #define darkened_grid(C) \
370 ((((C)->info & (CAVE_VIEW | CAVE_LITE | CAVE_MNLT | CAVE_MNDK)) == (CAVE_VIEW | CAVE_MNDK)) && \
374 * Get feature mimic from f_info[] (applying "mimic" field)
376 #define get_feat_mimic(C) \
377 (f_info[(C)->mimic ? (C)->mimic : (C)->feat].mimic)