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 "util/bit-flags-calculator.h"
14 #include "world/world.h"
17 * Determines if a map location is fully inside the outer walls
19 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); }
22 * Determines if a map location is on or inside the outer walls
24 bool in_bounds2(floor_type *floor_ptr, POSITION y, POSITION x) { return (y >= 0) && (x >= 0) && (y < floor_ptr->height) && (x < floor_ptr->width); }
27 * Determines if a map location is on or inside the outer walls
30 bool in_bounds2u(floor_type *floor_ptr, POSITION y, POSITION x) { return (y < floor_ptr->height) && (x < floor_ptr->width); }
33 * Determine if a "legal" grid is an "empty" floor grid
34 * Determine if monsters are allowed to move into a grid
36 * Line 1 -- forbid non-placement grids
37 * Line 2 -- forbid normal monsters
38 * Line 3 -- forbid the player
40 bool is_cave_empty_bold(player_type *player_ptr, POSITION y, POSITION x)
42 floor_type *floor_ptr = player_ptr->current_floor_ptr;
43 bool is_empty_grid = cave_have_flag_bold(floor_ptr, y, x, FF_PLACE);
44 is_empty_grid &= !(floor_ptr->grid_array[y][x].m_idx);
45 is_empty_grid &= !player_bold(player_ptr, y, x);
50 * Determine if a "legal" grid is an "empty" floor grid
51 * Determine if monster generation is allowed in a grid
53 * Line 1 -- forbid non-empty grids
54 * Line 2 -- forbid trees while dungeon generation
56 bool is_cave_empty_bold2(player_type *player_ptr, POSITION y, POSITION x)
58 bool is_empty_grid = is_cave_empty_bold(player_ptr, y, x);
59 is_empty_grid &= current_world_ptr->character_dungeon || !cave_have_flag_bold(player_ptr->current_floor_ptr, y, x, FF_TREE);
63 bool cave_have_flag_bold(floor_type *floor_ptr, POSITION y, POSITION x, feature_flag_type f_idx)
65 return have_flag(f_info[floor_ptr->grid_array[y][x].feat].flags, f_idx);
69 * Determine if a "legal" grid is within "los" of the player
71 bool player_has_los_bold(player_type *player_ptr, POSITION y, POSITION x)
73 return ((player_ptr->current_floor_ptr->grid_array[y][x].info & CAVE_VIEW) != 0) || player_ptr->phase_out;
77 * Determine if player is on this grid
79 bool player_bold(player_type *player_ptr, POSITION y, POSITION x) { return (y == player_ptr->y) && (x == player_ptr->x); }
82 * Does the grid stop disintegration?
84 bool cave_stop_disintegration(floor_type *floor_ptr, POSITION y, POSITION x)
86 return !cave_have_flag_bold(floor_ptr, y, x, FF_PROJECT)
87 && (!cave_have_flag_bold(floor_ptr, y, x, FF_HURT_DISI) || cave_have_flag_bold(floor_ptr, y, x, FF_PERMANENT));
91 * @brief 指定のマスが光を通すか(LOSフラグを持つか)を返す。 / Aux function -- see below
92 * @param floor_ptr 配置するフロアの参照ポインタ
95 * @return 光を通すならばtrueを返す。
97 bool cave_los_bold(floor_type *floor_ptr, POSITION y, POSITION x) { return feat_supports_los(floor_ptr->grid_array[y][x].feat); }
100 * Determine if a "feature" supports "los"
102 bool feat_supports_los(FEAT_IDX f_idx) { return have_flag(f_info[f_idx].flags, FF_LOS); }
104 bool cave_los_grid(grid_type *grid_ptr) { return feat_supports_los(grid_ptr->feat); }
106 bool cave_have_flag_grid(grid_type *grid_ptr, int feature_flags) { return have_flag(f_info[grid_ptr->feat].flags, feature_flags); }
109 * Determine if a "feature" is "permanent wall"
111 bool permanent_wall(feature_type *f_ptr) { return have_flag(f_ptr->flags, FF_WALL) && have_flag(f_ptr->flags, FF_PERMANENT); }