OSDN Git Service

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