2 * @brief ダンジョンの壁等に関する判定関数の集合
6 * Dance with a colorless dress. Shout with a withered voice.
9 #include "floor/cave.h"
10 #include "grid/feature.h"
11 #include "grid/grid.h"
12 #include "system/floor-type-definition.h"
13 #include "system/grid-type-definition.h"
14 #include "system/player-type-definition.h"
15 #include "util/bit-flags-calculator.h"
16 #include "world/world.h"
19 * Determines if a map location is fully inside the outer walls
21 bool in_bounds(floor_type *floor_ptr, POSITION y, POSITION x) { return (y > 0) && (x > 0) && (y < floor_ptr->height - 1) && (x < floor_ptr->width - 1); }
24 * Determines if a map location is on or inside the outer walls
26 bool in_bounds2(floor_type *floor_ptr, POSITION y, POSITION x) { return (y >= 0) && (x >= 0) && (y < floor_ptr->height) && (x < floor_ptr->width); }
29 * Determines if a map location is on or inside the outer walls
32 bool in_bounds2u(floor_type *floor_ptr, POSITION y, POSITION x) { return (y < floor_ptr->height) && (x < floor_ptr->width); }
35 * Determine if a "legal" grid is an "empty" floor grid
36 * Determine if monsters are allowed to move into a grid
38 * Line 1 -- forbid non-placement grids
39 * Line 2 -- forbid normal monsters
40 * Line 3 -- forbid the player
42 bool is_cave_empty_bold(player_type *player_ptr, POSITION y, POSITION x)
44 floor_type *floor_ptr = player_ptr->current_floor_ptr;
45 bool is_empty_grid = cave_has_flag_bold(floor_ptr, y, x, FF_PLACE);
46 is_empty_grid &= !(floor_ptr->grid_array[y][x].m_idx);
47 is_empty_grid &= !player_bold(player_ptr, y, x);
52 * Determine if a "legal" grid is an "empty" floor grid
53 * Determine if monster generation is allowed in a grid
55 * Line 1 -- forbid non-empty grids
56 * Line 2 -- forbid trees while dungeon generation
58 bool is_cave_empty_bold2(player_type *player_ptr, POSITION y, POSITION x)
60 bool is_empty_grid = is_cave_empty_bold(player_ptr, y, x);
61 is_empty_grid &= current_world_ptr->character_dungeon || !cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, FF_TREE);
65 bool cave_has_flag_bold(floor_type *floor_ptr, POSITION y, POSITION x, feature_flag_type f_idx)
67 return has_flag(f_info[floor_ptr->grid_array[y][x].feat].flags, f_idx);
71 * Determine if a "legal" grid is within "los" of the player
73 bool player_has_los_bold(player_type *player_ptr, POSITION y, POSITION x)
75 return ((player_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_VIEW) != 0) || player_ptr->phase_out;
79 * Determine if player is on this grid
81 bool player_bold(player_type *player_ptr, POSITION y, POSITION x) { return (y == player_ptr->y) && (x == player_ptr->x); }
84 * Does the grid stop disintegration?
86 bool cave_stop_disintegration(floor_type *floor_ptr, POSITION y, POSITION x)
88 return !cave_has_flag_bold(floor_ptr, y, x, FF_PROJECT)
89 && (!cave_has_flag_bold(floor_ptr, y, x, FF_HURT_DISI) || cave_has_flag_bold(floor_ptr, y, x, FF_PERMANENT));
93 * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
94 * @param floor_ptr 配置するフロアの参照ポインタ
97 * @return 光を通すならばtrueを返す。
99 bool cave_los_bold(floor_type *floor_ptr, POSITION y, POSITION x) { return feat_supports_los(floor_ptr->grid_array[y][x].feat); }
102 * Determine if a "feature" supports "los"
104 bool feat_supports_los(FEAT_IDX f_idx) { return has_flag(f_info[f_idx].flags, FF_LOS); }
107 * Determine if a "legal" grid is a "clean" floor grid
108 * Determine if terrain-change spells are allowed in a grid.
110 * Line 1 -- forbid non-floors
111 * Line 2 -- forbid object terrains
112 * Line 3 -- forbid normal objects
114 bool cave_clean_bold(floor_type *floor_ptr, POSITION y, POSITION x)
116 return cave_has_flag_bold(floor_ptr, y, x, FF_FLOOR) && ((floor_ptr->grid_array[y][x].is_object()) == 0)
117 && floor_ptr->grid_array[y][x].o_idx_list.empty();
121 * Determine if an object can be dropped on a "legal" grid
123 * Line 1 -- forbid non-drops
124 * Line 2 -- forbid object terrains
126 bool cave_drop_bold(floor_type *floor_ptr, POSITION y, POSITION x)
128 return cave_has_flag_bold(floor_ptr, y, x, FF_DROP) && ((floor_ptr->grid_array[y][x].is_object()) == 0);
131 bool pattern_tile(floor_type *floor_ptr, POSITION y, POSITION x) { return cave_has_flag_bold(floor_ptr, y, x, FF_PATTERN); }