OSDN Git Service

[Refactor] #40569 Separated dungeon-flag-types.h
[hengband/hengband.git] / src / floor / floor.h
1 #pragma once
2
3 #include "system/angband.h"
4
5 typedef struct floor_type floor_type;
6 extern floor_type floor_info;
7
8 /*
9  * Determines if a map location is fully inside the outer walls
10  */
11 #define in_bounds(F,Y,X) \
12    (((Y) > 0) && ((X) > 0) && ((Y) < (F)->height-1) && ((X) < (F)->width-1))
13
14 /*
15  * Determines if a map location is on or inside the outer walls
16  */
17 #define in_bounds2(F,Y,X) \
18    (((Y) >= 0) && ((X) >= 0) && ((Y) < (F)->height) && ((X) < (F)->width))
19
20 /*
21  * Determines if a map location is on or inside the outer walls
22  * (unsigned version)
23  */
24 #define in_bounds2u(F,Y,X) \
25    (((Y) < (F)->height) && ((X) < (F)->width))
26
27
28 /*
29  * Determine if player is on this grid
30  */
31 #define player_bold(C,Y,X) \
32         (((Y) == (C)->y) && ((X) == (C)->x))
33
34 /*
35  * Grid based version of "creature_bold()"
36  */
37 #define player_grid(C, G) \
38         ((G) == &(C)->current_floor_ptr->grid_array[(C)->y][(C)->x])
39
40
41 #define cave_have_flag_grid(C,INDEX) \
42         (have_flag(f_info[(C)->feat].flags, (INDEX)))
43
44
45 /*
46  * Determine if a "feature" supports "los"
47  */
48 #define feat_supports_los(F) \
49         (have_flag(f_info[(F)].flags, FF_LOS))
50
51
52 #define cave_los_grid(C) \
53         (feat_supports_los((C)->feat))
54
55
56 /*
57  * Determine if a "legal" grid is a "clean" floor grid
58  * Determine if terrain-change spells are allowed in a grid.
59  *
60  * Line 1 -- forbid non-floors
61  * Line 2 -- forbid object terrains
62  * Line 3 -- forbid normal objects
63  */
64 #define cave_clean_bold(F,Y,X) \
65         (cave_have_flag_bold((F), (Y), (X), FF_FLOOR) && \
66          !((F)->grid_array[Y][X].info & CAVE_OBJECT) && \
67           ((F)->grid_array[Y][X].o_idx == 0))
68
69
70 /*
71  * Determine if an object can be dropped on a "legal" grid
72  *
73  * Line 1 -- forbid non-drops
74  * Line 2 -- forbid object terrains
75  */
76 #define cave_drop_bold(F,Y,X) \
77         (cave_have_flag_bold((F), (Y), (X), FF_DROP) && \
78          !((F)->grid_array[Y][X].info & CAVE_OBJECT))
79
80
81 /*
82  * Determine if a "legal" grid is an "naked" floor grid
83  *
84  * Line 1 -- forbid non-clean gird
85  * Line 2 -- forbid monsters
86  * Line 3 -- forbid the player
87  */
88 #define cave_naked_bold(C,F,Y,X) \
89         (cave_clean_bold(F,Y,X) && \
90          !((F)->grid_array[Y][X].m_idx) && \
91          !player_bold(C,Y,X))
92
93
94 /*
95  * Determine if a "legal" grid is "permanent"
96  *
97  * Line 1 -- permanent flag
98  */
99 #define cave_perma_bold(F,Y,X) \
100         (cave_have_flag_bold((F), (Y), (X), FF_PERMANENT))
101
102
103 /*
104  * Grid based version of "cave_perma_bold()"
105  */
106 #define cave_perma_grid(C) \
107         (cave_have_flag_grid((C), FF_PERMANENT))
108
109
110 /*
111  * Does the grid stop disintegration?
112  */
113 #define cave_stop_disintegration(F,Y,X) \
114         (!cave_have_flag_bold((F), (Y), (X), FF_PROJECT) && \
115          (!cave_have_flag_bold((F), (Y), (X), FF_HURT_DISI) || \
116           cave_have_flag_bold((F), (Y), (X), FF_PERMANENT)))
117
118
119 /*
120  * Determine if a "legal" grid is within "los" of the player
121  *
122  * Note the use of comparison to zero to force a "boolean" result
123  */
124 #define player_has_los_grid(C) \
125     (((C)->info & (CAVE_VIEW)) != 0)
126
127 /*
128  * Determine if a "legal" grid is within "los" of the player
129  *
130  * Note the use of comparison to zero to force a "boolean" result
131  */
132 #define player_has_los_bold(C,Y,X) \
133     ((((C)->current_floor_ptr->grid_array[Y][X].info & (CAVE_VIEW)) != 0) || (C)->phase_out)
134
135
136 /*
137  * Determine if a "feature" is "permanent wall"
138  */
139 #define permanent_wall(F) \
140         (have_flag((F)->flags, FF_WALL) && \
141          have_flag((F)->flags, FF_PERMANENT))
142
143 /*
144  * Convert a "location" (Y,X) into a "grid" (G)
145  */
146 #define GRID(Y,X) \
147         (256 * (Y) + (X))
148
149 /*
150  * Convert a "grid" (G) into a "location" (Y)
151  */
152 #define GRID_Y(G) \
153         ((int)((G) / 256U))
154
155 /*
156  * Convert a "grid" (G) into a "location" (X)
157  */
158 #define GRID_X(G) \
159         ((int)((G) % 256U))
160
161 bool pattern_tile(floor_type *floor_ptr, POSITION y, POSITION x);
162 bool is_cave_empty_bold(player_type *player_ptr, POSITION x, POSITION y);
163 bool is_cave_empty_bold2(player_type *player_ptr, POSITION x, POSITION y);
164 void update_smell(floor_type *floor_ptr, player_type *subject_ptr);
165 void add_door(player_type *player_ptr, POSITION x, POSITION y);
166 void place_secret_door(player_type *player_ptr, POSITION y, POSITION x, int type);
167 void place_locked_door(player_type *player_ptr, POSITION y, POSITION x);
168 void forget_flow(floor_type *floor_ptr);
169 void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x);
170 bool los(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
171 bool projectable(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2);
172 void vault_monsters(player_type *player_ptr, POSITION y1, POSITION x1, int num);
173 bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x);
174 void cave_set_feat(player_type *player_ptr, POSITION y, POSITION x, FEAT_IDX feat);
175 void place_random_door(player_type *player_ptr, POSITION y, POSITION x, bool room);
176 void place_closed_door(player_type *player_ptr, POSITION y, POSITION x, int type);
177 void wipe_o_list(floor_type *floor_ptr);
178 void vault_trap_aux(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd);
179 bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y);
180 void try_door(player_type *player_ptr, POSITION y, POSITION x);
181 FEAT_IDX conv_dungeon_feat(floor_type *floor_ptr, FEAT_IDX newfeat);
182 void vault_objects(player_type *player_ptr, POSITION y, POSITION x, int num);
183 int project_path(player_type *player_ptr, u16b *gp, POSITION range, POSITION y1, POSITION x1, POSITION y2, POSITION x2, BIT_FLAGS flg);
184 void set_floor(player_type *player_ptr, POSITION x, POSITION y);
185 void place_object(player_type *owner_ptr, POSITION y, POSITION x, BIT_FLAGS mode);
186 void place_gold(player_type *player_ptr, POSITION y, POSITION x);
187 void delete_monster(player_type *player_ptr, POSITION y, POSITION x);
188 void compact_objects(player_type *owner_ptr, int size);
189 void vault_traps(player_type *player_ptr, POSITION y, POSITION x, POSITION yd, POSITION xd, int num);
190 void scatter(player_type *player_ptr, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode);
191 bool cave_los_bold(floor_type *floor_ptr, POSITION y, POSITION x);
192
193 typedef enum feature_flag_type feature_flag_type;
194 bool cave_have_flag_bold(floor_type *floor_ptr, POSITION y, POSITION x, feature_flag_type f_idx);