OSDN Git Service

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