OSDN Git Service

[Refactor] #38997 compact_objects() に floor_type * 引数を追加. / Add floor_type * argument...
[hengband/hengband.git] / src / floor.h
1 #pragma once
2
3 #include "feature.h"
4 #include "grid.h"
5 #include "object.h"
6 #include "monster.h"
7
8 /*!
9  * @brief ダンジョンの最深層 / Maximum dungeon level.
10  * @details
11  * The player can never reach this level
12  * in the dungeon, and this value is used for various calculations
13  * involving object and monster creation.  It must be at least 100.
14  * Setting it below 128 may prevent the creation of some objects.
15  */
16 #define MAX_DEPTH       128 
17
18 /*!
19  * @brief generate.cで用いられる基本的なブロック数単位(垂直方向)
20  * Number of grids in each block (vertically) Probably hard-coded to 11, see "generate.c"
21  */
22 #define BLOCK_HGT 11
23
24 /*!
25  * @brief generate.cで用いられる基本的なブロック数単位(水平方向)
26  * Number of grids in each block (horizontally) Probably hard-coded to 11, see "generate.c"
27  */
28 #define BLOCK_WID 11
29
30 /*!
31  * @brief 表示上の基本的なブロック単位(垂直方向、PANEL_HGTの倍数で設定すること)
32  * Number of grids used to display the dungeon (vertically). Must be a multiple of 11, probably hard-coded to 22.
33  */
34 #define SCREEN_HGT 22
35
36 /*!
37  * @brief 表示上の基本的なブロック単位(水平方向、PANEL_WIDの倍数で設定すること)
38  * Number of grids used to display the dungeon (horizontally). Must be a multiple of 33, probably hard-coded to 66.
39  */
40 #define SCREEN_WID 66
41
42 /*!
43  * @brief 表示上のダンジョンの最大垂直サイズ(SCREEN_HGTの3倍が望ましい)
44  * Maximum dungeon height in grids, must be a multiple of SCREEN_HGT, probably hard-coded to SCREEN_HGT * 3.
45  */
46 #define MAX_HGT 66
47
48 /*!
49  * @brief 表示上のダンジョンの最大水平サイズ(SCREEN_WIDの3倍が望ましい)
50  * Maximum dungeon width in grids, must be a multiple of SCREEN_WID, probably hard-coded to SCREEN_WID * 3.
51  */
52 #define MAX_WID 198
53
54 /*!
55  * @brief プレイヤー用光源処理配列サイズ / Maximum size of the "lite" array (see "grid.c")
56  * @details Note that the "lite radius" will NEVER exceed 14, and we would
57  * never require more than 581 entries in the array for circular "lite".
58  */
59 #define LITE_MAX 600
60
61 /*!
62  * @brief モンスター用光源処理配列サイズ / Maximum size of the "mon_lite" array (see ">grid.c")
63  * @details Note that the "view radius" will NEVER exceed 20, monster illumination
64  * flags are dependent on CAVE_VIEW, and even if the "view" was octagonal,
65  * we would never require more than 1520 entries in the array.
66  */
67 #define MON_LITE_MAX 1536
68
69 /*!
70  * @brief 視界処理配列サイズ / Maximum size of the "view" array
71  * @details Note that the "view radius" will NEVER exceed 20, and even if the "view"
72  * was octagonal, we would never require more than 1520 entries in the array.
73  */
74 #define VIEW_MAX 1536
75
76 /*!
77  * @brief 再描画処理用配列サイズ / Maximum size of the "redraw" array
78  * @details We must be large for proper functioning of delayed redrawing.
79  * We must also be as large as two times of the largest view area.
80  * Note that maximum view grids are 1149 entries.
81  */
82 #define REDRAW_MAX 2298
83
84
85 typedef struct {
86         DUNGEON_IDX dungeon_idx;
87         grid_type *grid_array[MAX_HGT];
88         DEPTH dun_level;                /*!< 現在の実ダンジョン階層 base_level の参照元となる / Current dungeon level */
89         DEPTH base_level;               /*!< 基本生成レベル、後述のobject_level, monster_levelの参照元となる / Base dungeon level */
90         DEPTH object_level;             /*!< アイテムの生成レベル、 base_level を起点に一時変更する時に参照 / Current object creation level */
91         DEPTH monster_level;    /*!< モンスターの生成レベル、 base_level を起点に一時変更する時に参照 / Current monster creation level */
92         POSITION width;                 /*!< Current dungeon width */
93         POSITION height;                /*!< Current dungeon height */
94         MONSTER_NUMBER num_repro; /*!< Current reproducer count */
95
96         GAME_TURN generated_turn; /* Turn when level began */
97
98         object_type *o_list; /*!< The array of dungeon items [max_o_idx] */
99         OBJECT_IDX o_max; /* Number of allocated objects */
100         OBJECT_IDX o_cnt; /* Number of live objects */
101
102         monster_type *m_list; /*!< The array of dungeon monsters [max_m_idx] */
103         MONSTER_IDX m_max; /* Number of allocated monsters */
104         MONSTER_IDX m_cnt; /* Number of live monsters */
105
106         s16b *mproc_list[MAX_MTIMED]; /*!< The array to process dungeon monsters[max_m_idx] */
107         s16b mproc_max[MAX_MTIMED]; /*!< Number of monsters to be processed */
108
109         POSITION_IDX lite_n; //!< Array of grids lit by player lite
110         POSITION lite_y[LITE_MAX];
111         POSITION lite_x[LITE_MAX];
112
113         POSITION_IDX mon_lite_n; //!< Array of grids lit by player lite
114         POSITION mon_lite_y[MON_LITE_MAX];
115         POSITION mon_lite_x[MON_LITE_MAX];
116
117         POSITION_IDX view_n; //!< Array of grids viewable to the player
118         POSITION view_y[VIEW_MAX];
119         POSITION view_x[VIEW_MAX];
120
121         POSITION_IDX redraw_n; //!< Array of grids for delayed visual updating
122         POSITION redraw_y[REDRAW_MAX];
123         POSITION redraw_x[REDRAW_MAX];
124
125         bool monster_noise;
126         QUEST_IDX inside_quest;         /* Inside quest level */
127         bool inside_arena;              /* Is character inside arena? */
128
129 } floor_type;
130
131 extern floor_type floor_info;
132
133 #define DUNGEON_MODE_NONE       0
134 #define DUNGEON_MODE_AND        1
135 #define DUNGEON_MODE_NAND       2
136 #define DUNGEON_MODE_OR         3
137 #define DUNGEON_MODE_NOR        4
138
139 /*** Dungeon type flags -- DG ***/
140 #define DF1_WINNER              0x00000001L
141 #define DF1_MAZE                0x00000002L
142 #define DF1_SMALLEST            0x00000004L
143 #define DF1_BEGINNER            0x00000008L
144 #define DF1_BIG                 0x00000010L
145 #define DF1_NO_DOORS            0x00000020L
146 #define DF1_WATER_RIVER         0x00000040L
147 #define DF1_LAVA_RIVER          0x00000080L
148 #define DF1_CURTAIN             0x00000100L
149 #define DF1_GLASS_DOOR          0x00000200L
150 #define DF1_CAVE                0x00000400L
151 #define DF1_CAVERN              0x00000800L
152 #define DF1_ARCADE              0x00001000L
153 #define DF1_LAKE_ACID           0x00002000L
154 #define DF1_LAKE_POISONOUS      0x00004000L
155 #define DF1_XXX15               0x00008000L
156 #define DF1_FORGET              0x00010000L
157 #define DF1_LAKE_WATER          0x00020000L
158 #define DF1_LAKE_LAVA           0x00040000L
159 #define DF1_LAKE_RUBBLE         0x00080000L
160 #define DF1_LAKE_TREE           0x00100000L
161 #define DF1_NO_VAULT            0x00200000L
162 #define DF1_ARENA               0x00400000L
163 #define DF1_DESTROY             0x00800000L
164 #define DF1_GLASS_ROOM          0x01000000L
165 #define DF1_NO_CAVE             0x02000000L
166 #define DF1_NO_MAGIC            0x04000000L
167 #define DF1_NO_MELEE            0x08000000L
168 #define DF1_CHAMELEON           0x10000000L
169 #define DF1_DARKNESS            0x20000000L
170 #define DF1_ACID_RIVER          0x40000000L
171 #define DF1_POISONOUS_RIVER     0x80000000L
172
173 #define DF1_LAKE_MASK (DF1_LAKE_WATER | DF1_LAKE_LAVA | DF1_LAKE_RUBBLE | DF1_LAKE_TREE | DF1_LAKE_POISONOUS | DF1_LAKE_ACID)
174
175 /*
176  * Determines if a map location is fully inside the outer walls
177  */
178 #define in_bounds(F,Y,X) \
179    (((Y) > 0) && ((X) > 0) && ((Y) < (F)->height-1) && ((X) < (F)->width-1))
180
181 /*
182  * Determines if a map location is on or inside the outer walls
183  */
184 #define in_bounds2(F,Y,X) \
185    (((Y) >= 0) && ((X) >= 0) && ((Y) < (F)->height) && ((X) < (F)->width))
186
187 /*
188  * Determines if a map location is on or inside the outer walls
189  * (unsigned version)
190  */
191 #define in_bounds2u(F,Y,X) \
192    (((Y) < (F)->height) && ((X) < (F)->width))
193
194
195 /*
196  * Determine if player is on this grid
197  */
198 #define player_bold(C,Y,X) \
199         (((Y) == (C)->y) && ((X) == (C)->x))
200
201 /*
202  * Grid based version of "creature_bold()"
203  */
204 #define player_grid(C, G) \
205         ((G) == &(C)->current_floor_ptr->grid_array[(C)->y][(C)->x])
206
207
208 #define cave_have_flag_bold(F,Y,X,INDEX) \
209         (have_flag(f_info[(F)->grid_array[(Y)][(X)].feat].flags, (INDEX)))
210
211
212 #define cave_have_flag_grid(C,INDEX) \
213         (have_flag(f_info[(C)->feat].flags, (INDEX)))
214
215
216 /*
217  * Determine if a "feature" supports "los"
218  */
219 #define feat_supports_los(F) \
220         (have_flag(f_info[(F)].flags, FF_LOS))
221
222
223 /*
224  * Determine if a "legal" grid supports "los"
225  */
226 #define cave_los_bold(F,Y,X) \
227         (feat_supports_los((F)->grid_array[(Y)][(X)].feat))
228
229 #define cave_los_grid(C) \
230         (feat_supports_los((C)->feat))
231
232
233 /*
234  * Determine if a "legal" grid is a "clean" floor grid
235  * Determine if terrain-change spells are allowed in a grid.
236  *
237  * Line 1 -- forbid non-floors
238  * Line 2 -- forbid object terrains
239  * Line 3 -- forbid normal objects
240  */
241 #define cave_clean_bold(F,Y,X) \
242         (cave_have_flag_bold((F), (Y), (X), FF_FLOOR) && \
243          !((F)->grid_array[Y][X].info & CAVE_OBJECT) && \
244           ((F)->grid_array[Y][X].o_idx == 0))
245
246
247 /*
248  * Determine if an object can be dropped on a "legal" grid
249  *
250  * Line 1 -- forbid non-drops
251  * Line 2 -- forbid object terrains
252  */
253 #define cave_drop_bold(F,Y,X) \
254         (cave_have_flag_bold((F), (Y), (X), FF_DROP) && \
255          !((F)->grid_array[Y][X].info & CAVE_OBJECT))
256
257
258 /*
259  * Determine if a "legal" grid is an "empty" floor grid
260  * Determine if monsters are allowed to move into a grid
261  *
262  * Line 1 -- forbid non-placement grids
263  * Line 2 -- forbid normal monsters
264  * Line 3 -- forbid the player
265  */
266 #define cave_empty_bold(F,Y,X) \
267         (cave_have_flag_bold((F), (Y), (X), FF_PLACE) && \
268          !((F)->grid_array[Y][X].m_idx) && \
269          !player_bold(p_ptr, Y,X))
270
271
272 /*
273  * Determine if a "legal" grid is an "empty" floor grid
274  * Determine if monster generation is allowed in a grid
275  *
276  * Line 1 -- forbid non-empty grids
277  * Line 2 -- forbid trees while dungeon generation
278  */
279 #define cave_empty_bold2(F,Y,X) \
280         (cave_empty_bold(F,Y,X) && \
281          (current_world_ptr->character_dungeon || !cave_have_flag_bold((F), (Y), (X), FF_TREE)))
282
283
284 /*
285  * Determine if a "legal" grid is an "naked" floor grid
286  *
287  * Line 1 -- forbid non-clean gird
288  * Line 2 -- forbid monsters
289  * Line 3 -- forbid the player
290  */
291 #define cave_naked_bold(C,F,Y,X) \
292         (cave_clean_bold(F,Y,X) && \
293          !((F)->grid_array[Y][X].m_idx) && \
294          !player_bold(C,Y,X))
295
296
297 /*
298  * Determine if a "legal" grid is "permanent"
299  *
300  * Line 1 -- permanent flag
301  */
302 #define cave_perma_bold(F,Y,X) \
303         (cave_have_flag_bold((F), (Y), (X), FF_PERMANENT))
304
305
306 /*
307  * Grid based version of "cave_empty_bold()"
308  */
309 #define cave_empty_grid(C) \
310         (cave_have_flag_grid((C), FF_PLACE) && \
311          !((C)->m_idx) && !player_grid(p_ptr, C))
312
313
314 /*
315  * Grid based version of "cave_perma_bold()"
316  */
317 #define cave_perma_grid(C) \
318         (cave_have_flag_grid((C), FF_PERMANENT))
319
320
321 #define pattern_tile(Y,X) \
322         (cave_have_flag_bold(p_ptr->current_floor_ptr, (Y), (X), FF_PATTERN))
323
324 /*
325  * Does the grid stop disintegration?
326  */
327 #define cave_stop_disintegration(F,Y,X) \
328         (!cave_have_flag_bold((F), (Y), (X), FF_PROJECT) && \
329          (!cave_have_flag_bold((F), (Y), (X), FF_HURT_DISI) || \
330           cave_have_flag_bold((F), (Y), (X), FF_PERMANENT)))
331
332
333 /*
334  * Determine if a "legal" grid is within "los" of the player
335  *
336  * Note the use of comparison to zero to force a "boolean" result
337  */
338 #define player_has_los_grid(C) \
339     (((C)->info & (CAVE_VIEW)) != 0)
340
341 /*
342  * Determine if a "legal" grid is within "los" of the player
343  *
344  * Note the use of comparison to zero to force a "boolean" result
345  */
346 #define player_has_los_bold(C,Y,X) \
347     ((((C)->current_floor_ptr->grid_array[Y][X].info & (CAVE_VIEW)) != 0) || (C)->phase_out)
348
349
350 /*
351  * Determine if a "feature" is "permanent wall"
352  */
353 #define permanent_wall(F) \
354         (have_flag((F)->flags, FF_WALL) && \
355          have_flag((F)->flags, FF_PERMANENT))
356
357 extern saved_floor_type saved_floors[MAX_SAVED_FLOORS];
358
359 /*
360  * Convert a "location" (Y,X) into a "grid" (G)
361  */
362 #define GRID(Y,X) \
363         (256 * (Y) + (X))
364
365 /*
366  * Convert a "grid" (G) into a "location" (Y)
367  */
368 #define GRID_Y(G) \
369         ((int)((G) / 256U))
370
371 /*
372  * Convert a "grid" (G) into a "location" (X)
373  */
374 #define GRID_X(G) \
375         ((int)((G) % 256U))
376
377 extern void update_smell(floor_type *floor_ptr, player_type *subject_ptr);
378
379 extern void add_door(floor_type *floor_ptr, POSITION x, POSITION y);
380 extern void place_secret_door(floor_type *floor_ptr, POSITION y, POSITION x, int type);
381 extern void place_locked_door(floor_type *floor_ptr, POSITION y, POSITION x);
382 extern void forget_flow(floor_type *floor_ptr);
383 extern void place_random_stairs(floor_type *floor_ptr, POSITION y, POSITION x);
384
385 extern bool los(floor_type* floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
386 extern bool projectable(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
387 extern int project_length;
388
389 extern void vault_monsters(floor_type *floor_ptr, POSITION y1, POSITION x1, int num);
390 extern bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x);
391 extern void cave_set_feat(floor_type *floor_ptr, POSITION y, POSITION x, FEAT_IDX feat);
392 extern void place_random_door(floor_type *floor_ptr, POSITION y, POSITION x, bool room);
393 extern void place_closed_door(floor_type *floor_ptr, POSITION y, POSITION x, int type);
394
395 extern void wipe_o_list(floor_type *floor_ptr);
396 extern void vault_trap_aux(floor_type *floor_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd);
397
398 extern bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y);
399 extern void try_door(floor_type *floor_ptr, POSITION y, POSITION x);
400
401 extern FEAT_IDX conv_dungeon_feat(floor_type *floor_ptr, FEAT_IDX newfeat);
402 extern void vault_objects(floor_type *floor_ptr, POSITION y, POSITION x, int num);
403
404 /*
405  * project()関数に用いられる、遠隔攻撃特性ビットフラグ / Bit flags for the "project()" function
406  */
407 #define PROJECT_JUMP        0x0001 /*!< 遠隔攻撃特性: 発動者からの軌跡を持たず、指定地点に直接発生する(予め置いたトラップ、上空からの発生などのイメージ) / Jump directly to the target location (this is a hack) */
408 #define PROJECT_BEAM        0x0002 /*!< 遠隔攻撃特性: ビーム範囲を持つ。 / Work as a beam weapon (affect every grid passed through) */
409 #define PROJECT_THRU        0x0004 /*!< 遠隔攻撃特性: 目標地点に到達しても射程と遮蔽の限り引き延ばす。 / Continue "through" the target (used for "bolts"/"beams") */
410 #define PROJECT_STOP        0x0008 /*!< 遠隔攻撃特性: 道中にプレイヤーかモンスターがいた時点で到達地点を更新して停止する(壁や森はPROJECT_DISIがない限り最初から貫通しない) */
411 #define PROJECT_GRID        0x0010 /*!< 遠隔攻撃特性: 射程内の地形に影響を及ぼす / Affect each grid in the "blast area" in some way */
412 #define PROJECT_ITEM        0x0020 /*!< 遠隔攻撃特性: 射程内のアイテムに影響を及ぼす / Affect each object in the "blast area" in some way */
413 #define PROJECT_KILL        0x0040 /*!< 遠隔攻撃特性: 射程内のモンスターに影響を及ぼす / Affect each monster in the "blast area" in some way */
414 #define PROJECT_HIDE        0x0080 /*!< 遠隔攻撃特性: / Hack -- disable "visual" feedback from projection */
415 #define PROJECT_DISI        0x0100 /*!< 遠隔攻撃特性: / Disintegrate non-permanent features */
416 #define PROJECT_PLAYER      0x0200 /*!< 遠隔攻撃特性: / Main target is player (used for riding player) */
417 #define PROJECT_AIMED       0x0400 /*!< 遠隔攻撃特性: / Target is only player or monster, so don't affect another. Depend on PROJECT_PLAYER. (used for minimum (rad == 0) balls on riding player) */
418 #define PROJECT_REFLECTABLE 0x0800 /*!< 遠隔攻撃特性: 反射可能(ボルト系魔法に利用) / Refrectable spell attacks (used for "bolts") */
419 #define PROJECT_NO_HANGEKI  0x1000 /*!< 遠隔攻撃特性: / Avoid counter attacks of monsters */
420 #define PROJECT_PATH        0x2000 /*!< 遠隔攻撃特性: / Only used for printing project path */
421 #define PROJECT_FAST        0x4000 /*!< 遠隔攻撃特性: / Hide "visual" of flying bolts until blast */
422 #define PROJECT_LOS         0x8000 /*!< 遠隔攻撃特性: /  */
423 extern sint project_path(floor_type *floor_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg);
424
425 extern void set_floor(floor_type *floor_ptr, POSITION x, POSITION y);
426 extern void place_object(floor_type *floor_ptr, POSITION y, POSITION x, BIT_FLAGS mode);
427 extern void place_gold(floor_type *floor_ptr, POSITION y, POSITION x);
428 extern void delete_monster(floor_type *floor_ptr, POSITION y, POSITION x);
429 extern void compact_objects(floor_type *floor_ptr, int size);