OSDN Git Service

[Refactor] #37353 複数のフロアに関するマクロを floor.h へ移動。
[hengband/hengband.git] / src / floor.h
1 
2 /*
3  * Flags for change floor mode
4  */
5 #define CFM_UP           0x0001  /* Move up */
6 #define CFM_DOWN         0x0002  /* Move down */
7 #define CFM_LONG_STAIRS  0x0004  /* Randomly occurred long stairs/shaft */
8 #define CFM_XXX          0x0008  /* XXX */
9 #define CFM_SHAFT        0x0010  /* Shaft */
10 #define CFM_RAND_PLACE   0x0020  /* Arrive at random grid */
11 #define CFM_RAND_CONNECT 0x0040  /* Connect with random stairs */
12 #define CFM_SAVE_FLOORS  0x0080  /* Save floors */
13 #define CFM_NO_RETURN    0x0100  /* Flee from random quest etc... */
14 #define CFM_FIRST_FLOOR  0x0200  /* Create exit from the dungeon */
15
16 /*
17  * Determines if a map location is fully inside the outer walls
18  */
19 #define in_bounds(Y,X) \
20    (((Y) > 0) && ((X) > 0) && ((Y) < current_floor_ptr->height-1) && ((X) < current_floor_ptr->width-1))
21
22 /*
23  * Determines if a map location is on or inside the outer walls
24  */
25 #define in_bounds2(Y,X) \
26    (((Y) >= 0) && ((X) >= 0) && ((Y) < current_floor_ptr->height) && ((X) < current_floor_ptr->width))
27
28 /*
29  * Determines if a map location is on or inside the outer walls
30  * (unsigned version)
31  */
32 #define in_bounds2u(Y,X) \
33    (((Y) < current_floor_ptr->height) && ((X) < current_floor_ptr->width))
34
35
36 /*
37  * Determine if player is on this grid
38  */
39 #define player_bold(Y,X) \
40         (((Y) == p_ptr->y) && ((X) == p_ptr->x))
41
42 /*
43  * Grid based version of "player_bold()"
44  */
45 #define player_grid(C) \
46         ((C) == &current_floor_ptr->grid_array[p_ptr->y][p_ptr->x])
47
48
49 #define cave_have_flag_bold(Y,X,INDEX) \
50         (have_flag(f_info[current_floor_ptr->grid_array[(Y)][(X)].feat].flags, (INDEX)))
51
52
53 #define cave_have_flag_grid(C,INDEX) \
54         (have_flag(f_info[(C)->feat].flags, (INDEX)))
55
56
57 /*
58  * Determine if a "feature" supports "los"
59  */
60 #define feat_supports_los(F) \
61         (have_flag(f_info[(F)].flags, FF_LOS))
62
63
64 /*
65  * Determine if a "legal" grid supports "los"
66  */
67 #define cave_los_bold(Y,X) \
68         (feat_supports_los(current_floor_ptr->grid_array[(Y)][(X)].feat))
69
70 #define cave_los_grid(C) \
71         (feat_supports_los((C)->feat))
72
73
74 /*
75  * Determine if a "legal" grid is a "clean" floor grid
76  * Determine if terrain-change spells are allowed in a grid.
77  *
78  * Line 1 -- forbid non-floors
79  * Line 2 -- forbid object terrains
80  * Line 3 -- forbid normal objects
81  */
82 #define cave_clean_bold(Y,X) \
83         (cave_have_flag_bold((Y), (X), FF_FLOOR) && \
84          !(current_floor_ptr->grid_array[Y][X].info & CAVE_OBJECT) && \
85           (current_floor_ptr->grid_array[Y][X].o_idx == 0))
86
87
88 /*
89  * Determine if an object can be dropped on a "legal" grid
90  *
91  * Line 1 -- forbid non-drops
92  * Line 2 -- forbid object terrains
93  */
94 #define cave_drop_bold(Y,X) \
95         (cave_have_flag_bold((Y), (X), FF_DROP) && \
96          !(current_floor_ptr->grid_array[Y][X].info & CAVE_OBJECT))
97
98
99 /*
100  * Determine if a "legal" grid is an "empty" floor grid
101  * Determine if monsters are allowed to move into a grid
102  *
103  * Line 1 -- forbid non-placement grids
104  * Line 2 -- forbid normal monsters
105  * Line 3 -- forbid the player
106  */
107 #define cave_empty_bold(Y,X) \
108         (cave_have_flag_bold((Y), (X), FF_PLACE) && \
109          !(current_floor_ptr->grid_array[Y][X].m_idx) && \
110          !player_bold(Y,X))
111
112
113 /*
114  * Determine if a "legal" grid is an "empty" floor grid
115  * Determine if monster generation is allowed in a grid
116  *
117  * Line 1 -- forbid non-empty grids
118  * Line 2 -- forbid trees while dungeon generation
119  */
120 #define cave_empty_bold2(Y,X) \
121         (cave_empty_bold(Y,X) && \
122          (character_dungeon || !cave_have_flag_bold((Y), (X), FF_TREE)))
123
124
125 /*
126  * Determine if a "legal" grid is an "naked" floor grid
127  *
128  * Line 1 -- forbid non-clean gird
129  * Line 2 -- forbid monsters
130  * Line 3 -- forbid the player
131  */
132 #define cave_naked_bold(Y,X) \
133         (cave_clean_bold(Y,X) && \
134          !(current_floor_ptr->grid_array[Y][X].m_idx) && \
135          !player_bold(Y,X))
136
137
138 /*
139  * Determine if a "legal" grid is "permanent"
140  *
141  * Line 1 -- permanent flag
142  */
143 #define cave_perma_bold(Y,X) \
144         (cave_have_flag_bold((Y), (X), FF_PERMANENT))
145
146
147 /*
148  * Grid based version of "cave_empty_bold()"
149  */
150 #define cave_empty_grid(C) \
151         (cave_have_flag_grid((C), FF_PLACE) && \
152          !((C)->m_idx) && \
153          !player_grid(C))
154
155
156 /*
157  * Grid based version of "cave_perma_bold()"
158  */
159 #define cave_perma_grid(C) \
160         (cave_have_flag_grid((C), FF_PERMANENT))
161
162
163 #define pattern_tile(Y,X) \
164         (cave_have_flag_bold((Y), (X), FF_PATTERN))
165
166 /*
167  * Does the grid stop disintegration?
168  */
169 #define cave_stop_disintegration(Y,X) \
170         (!cave_have_flag_bold((Y), (X), FF_PROJECT) && \
171          (!cave_have_flag_bold((Y), (X), FF_HURT_DISI) || \
172           cave_have_flag_bold((Y), (X), FF_PERMANENT)))
173
174
175 /*
176  * Determine if a "legal" grid is within "los" of the player
177  *
178  * Note the use of comparison to zero to force a "boolean" result
179  */
180 #define player_has_los_grid(C) \
181     (((C)->info & (CAVE_VIEW)) != 0)
182
183 /*
184  * Determine if a "legal" grid is within "los" of the player
185  *
186  * Note the use of comparison to zero to force a "boolean" result
187  */
188 #define player_has_los_bold(Y,X) \
189     (((current_floor_ptr->grid_array[Y][X].info & (CAVE_VIEW)) != 0) || p_ptr->inside_battle)
190
191
192 /*
193  * Determine if a "feature" is "permanent wall"
194  */
195 #define permanent_wall(F) \
196         (have_flag((F)->flags, FF_WALL) && \
197          have_flag((F)->flags, FF_PERMANENT))
198
199 /*
200  * Get feature mimic from f_info[] (applying "mimic" field)
201  */
202 #define get_feat_mimic(C) \
203         (f_info[(C)->mimic ? (C)->mimic : (C)->feat].mimic)