OSDN Git Service

[Refactor] #37353 player_type の 闘技場観戦モードフラグ名を inside_arena から phase_out に改名。 (効果としては...
[hengband/hengband.git] / src / floor.h
1 #pragma once
2
3 #include "feature.h"
4 #include "grid.h"
5
6 /*!
7  * @brief ダンジョンの最深層 / Maximum dungeon level.
8  * @details
9  * The player can never reach this level
10  * in the dungeon, and this value is used for various calculations
11  * involving object and monster creation.  It must be at least 100.
12  * Setting it below 128 may prevent the creation of some objects.
13  */
14 #define MAX_DEPTH       128 
15
16 /*!
17  * @brief generate.cで用いられる基本的なブロック数単位(垂直方向)
18  * Number of grids in each block (vertically) Probably hard-coded to 11, see "generate.c"
19  */
20 #define BLOCK_HGT 11
21
22 /*!
23  * @brief generate.cで用いられる基本的なブロック数単位(水平方向)
24  * Number of grids in each block (horizontally) Probably hard-coded to 11, see "generate.c"
25  */
26 #define BLOCK_WID 11
27
28 /*!
29  * @brief 表示上の基本的なブロック単位(垂直方向、PANEL_HGTの倍数で設定すること)
30  * Number of grids used to display the dungeon (vertically). Must be a multiple of 11, probably hard-coded to 22.
31  */
32 #define SCREEN_HGT 22
33
34 /*!
35  * @brief 表示上の基本的なブロック単位(水平方向、PANEL_WIDの倍数で設定すること)
36  * Number of grids used to display the dungeon (horizontally). Must be a multiple of 33, probably hard-coded to 66.
37  */
38 #define SCREEN_WID 66
39
40 /*!
41  * @brief 表示上のダンジョンの最大垂直サイズ(SCREEN_HGTの3倍が望ましい)
42  * Maximum dungeon height in grids, must be a multiple of SCREEN_HGT, probably hard-coded to SCREEN_HGT * 3.
43  */
44 #define MAX_HGT 66
45
46 /*!
47  * @brief 表示上のダンジョンの最大水平サイズ(SCREEN_WIDの3倍が望ましい)
48  * Maximum dungeon width in grids, must be a multiple of SCREEN_WID, probably hard-coded to SCREEN_WID * 3.
49  */
50 #define MAX_WID 198
51
52 /*!
53  * @brief プレイヤー用光源処理配列サイズ / Maximum size of the "lite" array (see "current_floor_ptr->grid_array.c")
54  * @details Note that the "lite radius" will NEVER exceed 14, and we would
55  * never require more than 581 entries in the array for circular "lite".
56  */
57 #define LITE_MAX 600
58
59 /*!
60  * @brief モンスター用光源処理配列サイズ / Maximum size of the "mon_lite" array (see "current_floor_ptr->grid_array.c")
61  * @details Note that the "view radius" will NEVER exceed 20, monster illumination
62  * flags are dependent on CAVE_VIEW, and even if the "view" was octagonal,
63  * we would never require more than 1520 entries in the array.
64  */
65 #define MON_LITE_MAX 1536
66
67 /*!
68  * @brief 視界処理配列サイズ / Maximum size of the "view" array (see "current_floor_ptr->grid_array.c")
69  * @details Note that the "view radius" will NEVER exceed 20, and even if the "view"
70  * was octagonal, we would never require more than 1520 entries in the array.
71  */
72 #define VIEW_MAX 1536
73
74 /*!
75  * @brief 再描画処理用配列サイズ / Maximum size of the "redraw" array (see "current_floor_ptr->grid_array.c")
76  * @details We must be large for proper functioning of delayed redrawing.
77  * We must also be as large as two times of the largest view area.
78  * Note that maximum view grids are 1149 entries.
79  */
80 #define REDRAW_MAX 2298
81
82
83 typedef struct {
84         grid_type *grid_array[MAX_HGT];
85         DEPTH dun_level;                /*!< 現在の実ダンジョン階層base_levelの参照元となる / Current dungeon level */
86         DEPTH base_level;               /*!< 基本生成レベル、後述のobject_level, monster_levelの参照元となる / Base dungeon level */
87         DEPTH object_level;             /*!< アイテムの生成レベル、current_floor_ptr->base_levelを起点に一時変更する時に参照 / Current object creation level */
88         DEPTH monster_level;    /*!< モンスターの生成レベル、current_floor_ptr->base_levelを起点に一時変更する時に参照 / Current monster creation level */
89         POSITION width;                 /* Current dungeon width */
90         POSITION height;                /* Current dungeon height */
91         MONSTER_NUMBER num_repro; /*!< Current reproducer count */
92
93         GAME_TURN generated_turn; /* Turn when level began */
94
95         object_type *o_list; /*!< The array of dungeon items [current_floor_ptr->max_o_idx] */
96         OBJECT_IDX max_o_idx; /*!< Maximum number of objects in the level */
97         OBJECT_IDX o_max; /* Number of allocated objects */
98         OBJECT_IDX o_cnt; /* Number of live objects */
99
100         monster_type *m_list; /*!< The array of dungeon monsters [current_floor_ptr->max_m_idx] */
101         MONSTER_IDX max_m_idx; /*!< Maximum number of monsters in the level */
102         MONSTER_IDX m_max; /* Number of allocated monsters */
103         MONSTER_IDX m_cnt; /* Number of live monsters */
104
105         s16b *mproc_list[MAX_MTIMED]; /*!< The array to process dungeon monsters[max_m_idx] */
106         s16b mproc_max[MAX_MTIMED]; /*!< Number of monsters to be processed */
107
108         POSITION_IDX lite_n; //!< Array of grids lit by player lite (see "current_floor_ptr->grid_array.c")
109         POSITION lite_y[LITE_MAX];
110         POSITION lite_x[LITE_MAX];
111
112         POSITION_IDX mon_lite_n; //!< Array of grids lit by player lite (see "current_floor_ptr->grid_array.c")
113         POSITION mon_lite_y[MON_LITE_MAX];
114         POSITION mon_lite_x[MON_LITE_MAX];
115
116         POSITION_IDX view_n; //!< Array of grids viewable to the player (see "grid_array")
117         POSITION view_y[VIEW_MAX];
118         POSITION view_x[VIEW_MAX];
119
120         POSITION_IDX redraw_n; //!< Array of grids for delayed visual updating (see "current_floor_ptr->grid_array.c")
121         POSITION redraw_y[REDRAW_MAX];
122         POSITION redraw_x[REDRAW_MAX];
123
124         bool monster_noise;
125
126 } floor_type;
127
128 #define DUNGEON_MODE_NONE       0
129 #define DUNGEON_MODE_AND        1
130 #define DUNGEON_MODE_NAND       2
131 #define DUNGEON_MODE_OR         3
132 #define DUNGEON_MODE_NOR        4
133
134 /*** Dungeon type flags -- DG ***/
135 #define DF1_WINNER              0x00000001L
136 #define DF1_MAZE                0x00000002L
137 #define DF1_SMALLEST            0x00000004L
138 #define DF1_BEGINNER            0x00000008L
139 #define DF1_BIG                 0x00000010L
140 #define DF1_NO_DOORS            0x00000020L
141 #define DF1_WATER_RIVER         0x00000040L
142 #define DF1_LAVA_RIVER          0x00000080L
143 #define DF1_CURTAIN             0x00000100L
144 #define DF1_GLASS_DOOR          0x00000200L
145 #define DF1_CAVE                0x00000400L
146 #define DF1_CAVERN              0x00000800L
147 #define DF1_ARCADE              0x00001000L
148 #define DF1_LAKE_ACID           0x00002000L
149 #define DF1_LAKE_POISONOUS      0x00004000L
150 #define DF1_XXX15               0x00008000L
151 #define DF1_FORGET              0x00010000L
152 #define DF1_LAKE_WATER          0x00020000L
153 #define DF1_LAKE_LAVA           0x00040000L
154 #define DF1_LAKE_RUBBLE         0x00080000L
155 #define DF1_LAKE_TREE           0x00100000L
156 #define DF1_NO_VAULT            0x00200000L
157 #define DF1_ARENA               0x00400000L
158 #define DF1_DESTROY             0x00800000L
159 #define DF1_GLASS_ROOM          0x01000000L
160 #define DF1_NO_CAVE             0x02000000L
161 #define DF1_NO_MAGIC            0x04000000L
162 #define DF1_NO_MELEE            0x08000000L
163 #define DF1_CHAMELEON           0x10000000L
164 #define DF1_DARKNESS            0x20000000L
165 #define DF1_ACID_RIVER          0x40000000L
166 #define DF1_POISONOUS_RIVER     0x80000000L
167
168 #define DF1_LAKE_MASK (DF1_LAKE_WATER | DF1_LAKE_LAVA | DF1_LAKE_RUBBLE | DF1_LAKE_TREE | DF1_LAKE_POISONOUS | DF1_LAKE_ACID)
169
170 /*
171  * Determines if a map location is fully inside the outer walls
172  */
173 #define in_bounds(Y,X) \
174    (((Y) > 0) && ((X) > 0) && ((Y) < current_floor_ptr->height-1) && ((X) < current_floor_ptr->width-1))
175
176 /*
177  * Determines if a map location is on or inside the outer walls
178  */
179 #define in_bounds2(Y,X) \
180    (((Y) >= 0) && ((X) >= 0) && ((Y) < current_floor_ptr->height) && ((X) < current_floor_ptr->width))
181
182 /*
183  * Determines if a map location is on or inside the outer walls
184  * (unsigned version)
185  */
186 #define in_bounds2u(Y,X) \
187    (((Y) < current_floor_ptr->height) && ((X) < current_floor_ptr->width))
188
189
190 /*
191  * Determine if player is on this grid
192  */
193 #define player_bold(Y,X) \
194         (((Y) == p_ptr->y) && ((X) == p_ptr->x))
195
196 /*
197  * Grid based version of "player_bold()"
198  */
199 #define player_grid(C) \
200         ((C) == &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])
201
202
203 #define cave_have_flag_bold(Y,X,INDEX) \
204         (have_flag(f_info[current_floor_ptr->grid_array[(Y)][(X)].feat].flags, (INDEX)))
205
206
207 #define cave_have_flag_grid(C,INDEX) \
208         (have_flag(f_info[(C)->feat].flags, (INDEX)))
209
210
211 /*
212  * Determine if a "feature" supports "los"
213  */
214 #define feat_supports_los(F) \
215         (have_flag(f_info[(F)].flags, FF_LOS))
216
217
218 /*
219  * Determine if a "legal" grid supports "los"
220  */
221 #define cave_los_bold(Y,X) \
222         (feat_supports_los(current_floor_ptr->grid_array[(Y)][(X)].feat))
223
224 #define cave_los_grid(C) \
225         (feat_supports_los((C)->feat))
226
227
228 /*
229  * Determine if a "legal" grid is a "clean" floor grid
230  * Determine if terrain-change spells are allowed in a grid.
231  *
232  * Line 1 -- forbid non-floors
233  * Line 2 -- forbid object terrains
234  * Line 3 -- forbid normal objects
235  */
236 #define cave_clean_bold(Y,X) \
237         (cave_have_flag_bold((Y), (X), FF_FLOOR) && \
238          !(current_floor_ptr->grid_array[Y][X].info & CAVE_OBJECT) && \
239           (current_floor_ptr->grid_array[Y][X].o_idx == 0))
240
241
242 /*
243  * Determine if an object can be dropped on a "legal" grid
244  *
245  * Line 1 -- forbid non-drops
246  * Line 2 -- forbid object terrains
247  */
248 #define cave_drop_bold(Y,X) \
249         (cave_have_flag_bold((Y), (X), FF_DROP) && \
250          !(current_floor_ptr->grid_array[Y][X].info & CAVE_OBJECT))
251
252
253 /*
254  * Determine if a "legal" grid is an "empty" floor grid
255  * Determine if monsters are allowed to move into a grid
256  *
257  * Line 1 -- forbid non-placement grids
258  * Line 2 -- forbid normal monsters
259  * Line 3 -- forbid the player
260  */
261 #define cave_empty_bold(Y,X) \
262         (cave_have_flag_bold((Y), (X), FF_PLACE) && \
263          !(current_floor_ptr->grid_array[Y][X].m_idx) && \
264          !player_bold(Y,X))
265
266
267 /*
268  * Determine if a "legal" grid is an "empty" floor grid
269  * Determine if monster generation is allowed in a grid
270  *
271  * Line 1 -- forbid non-empty grids
272  * Line 2 -- forbid trees while dungeon generation
273  */
274 #define cave_empty_bold2(Y,X) \
275         (cave_empty_bold(Y,X) && \
276          (current_world_ptr->character_dungeon || !cave_have_flag_bold((Y), (X), FF_TREE)))
277
278
279 /*
280  * Determine if a "legal" grid is an "naked" floor grid
281  *
282  * Line 1 -- forbid non-clean gird
283  * Line 2 -- forbid monsters
284  * Line 3 -- forbid the player
285  */
286 #define cave_naked_bold(Y,X) \
287         (cave_clean_bold(Y,X) && \
288          !(current_floor_ptr->grid_array[Y][X].m_idx) && \
289          !player_bold(Y,X))
290
291
292 /*
293  * Determine if a "legal" grid is "permanent"
294  *
295  * Line 1 -- permanent flag
296  */
297 #define cave_perma_bold(Y,X) \
298         (cave_have_flag_bold((Y), (X), FF_PERMANENT))
299
300
301 /*
302  * Grid based version of "cave_empty_bold()"
303  */
304 #define cave_empty_grid(C) \
305         (cave_have_flag_grid((C), FF_PLACE) && \
306          !((C)->m_idx) && \
307          !player_grid(C))
308
309
310 /*
311  * Grid based version of "cave_perma_bold()"
312  */
313 #define cave_perma_grid(C) \
314         (cave_have_flag_grid((C), FF_PERMANENT))
315
316
317 #define pattern_tile(Y,X) \
318         (cave_have_flag_bold((Y), (X), FF_PATTERN))
319
320 /*
321  * Does the grid stop disintegration?
322  */
323 #define cave_stop_disintegration(Y,X) \
324         (!cave_have_flag_bold((Y), (X), FF_PROJECT) && \
325          (!cave_have_flag_bold((Y), (X), FF_HURT_DISI) || \
326           cave_have_flag_bold((Y), (X), FF_PERMANENT)))
327
328
329 /*
330  * Determine if a "legal" grid is within "los" of the player
331  *
332  * Note the use of comparison to zero to force a "boolean" result
333  */
334 #define player_has_los_grid(C) \
335     (((C)->info & (CAVE_VIEW)) != 0)
336
337 /*
338  * Determine if a "legal" grid is within "los" of the player
339  *
340  * Note the use of comparison to zero to force a "boolean" result
341  */
342 #define player_has_los_bold(Y,X) \
343     (((current_floor_ptr->grid_array[Y][X].info & (CAVE_VIEW)) != 0) || p_ptr->phase_out)
344
345
346 /*
347  * Determine if a "feature" is "permanent wall"
348  */
349 #define permanent_wall(F) \
350         (have_flag((F)->flags, FF_WALL) && \
351          have_flag((F)->flags, FF_PERMANENT))
352
353 extern floor_type *current_floor_ptr;
354 extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
355
356 /*
357  * Convert a "location" (Y,X) into a "grid" (G)
358  */
359 #define GRID(Y,X) \
360         (256 * (Y) + (X))
361
362 /*
363  * Convert a "grid" (G) into a "location" (Y)
364  */
365 #define GRID_Y(G) \
366         ((int)((G) / 256U))
367
368 /*
369  * Convert a "grid" (G) into a "location" (X)
370  */
371 #define GRID_X(G) \
372         ((int)((G) % 256U))
373