can_move = false;
disturb(player_ptr, false, true);
} else if (terrain.flags.has_not(TerrainCharacteristics::WATER) && riding_r_ptr->feature_flags.has(MonsterFeatureType::AQUATIC)) {
- msg_print(_(format("%sから上がれない。", terrains_info[floor.grid_array[player_ptr->y][player_ptr->x].get_feat_mimic()].name.data()), "Can't land."));
+ constexpr auto fmt = _("%sから上がれない。", "Can't land from %s.");
+ const auto p_pos = player_ptr->get_position();
+ msg_format(fmt, terrains_info[floor.get_grid(p_pos).get_feat_mimic()].name.data());
energy.reset_player_turn();
can_move = false;
disturb(player_ptr, false, true);
return false;
}
- int16_t feat = grid.get_feat_mimic();
+ const auto feat = grid.get_feat_mimic();
const auto &terrain = terrains_info[feat];
if (!player_can_enter(player_ptr, feat, 0)) {
return terrain.flags.has_not(TerrainCharacteristics::DOOR);
*/
static bool run_test(PlayerType *player_ptr)
{
- DIRECTION prev_dir = find_prevdir;
- int max = (prev_dir & 0x01) + 1;
- auto *floor_ptr = player_ptr->current_floor_ptr;
- if ((disturb_trap_detect || alert_trap_detect) && player_ptr->dtrap && !(floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_IN_DETECT)) {
+ const auto prev_dir = find_prevdir;
+ const auto max = (prev_dir & 0x01) + 1;
+ const auto &floor = *player_ptr->current_floor_ptr;
+ const auto p_pos = player_ptr->get_position();
+ const auto &p_grid = floor.get_grid(p_pos);
+ if ((disturb_trap_detect || alert_trap_detect) && player_ptr->dtrap && !(p_grid.info & CAVE_IN_DETECT)) {
player_ptr->dtrap = false;
- if (!(floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_UNSAFE)) {
+ if (!(p_grid.info & CAVE_UNSAFE)) {
if (alert_trap_detect) {
msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
}
}
}
- DIRECTION check_dir = 0;
- int option = 0, option2 = 0;
- for (int i = -max; i <= max; i++) {
- DIRECTION new_dir = cycle[chome[prev_dir] + i];
- int row = player_ptr->y + ddy[new_dir];
- int col = player_ptr->x + ddx[new_dir];
- Grid *g_ptr;
- g_ptr = &floor_ptr->grid_array[row][col];
- FEAT_IDX feat = g_ptr->get_feat_mimic();
- const auto &terrain = terrains_info[feat];
- if (g_ptr->m_idx) {
- auto *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
- if (m_ptr->ml) {
+ auto check_dir = 0;
+ auto option = 0;
+ auto option2 = 0;
+ for (auto i = -max; i <= max; i++) {
+ int new_dir = cycle[chome[prev_dir] + i];
+ const Pos2D pos(player_ptr->y + ddy[new_dir], player_ptr->x + ddx[new_dir]);
+ const auto &grid = floor.get_grid(pos);
+ const auto &terrain = terrains_info[grid.get_feat_mimic()];
+ if (grid.m_idx) {
+ const auto &monster = floor.m_list[grid.m_idx];
+ if (monster.ml) {
return true;
}
}
- for (const auto this_o_idx : g_ptr->o_idx_list) {
- ItemEntity *o_ptr;
- o_ptr = &floor_ptr->o_list[this_o_idx];
- if (o_ptr->marked.has(OmType::FOUND)) {
+ for (const auto this_o_idx : grid.o_idx_list) {
+ const auto &item = floor.o_list[this_o_idx];
+ if (item.marked.has(OmType::FOUND)) {
return true;
}
}
- bool inv = true;
- if (g_ptr->is_mark()) {
- bool notice = terrain.flags.has(TerrainCharacteristics::NOTICE);
+ auto inv = true;
+ if (grid.is_mark()) {
+ auto notice = terrain.flags.has(TerrainCharacteristics::NOTICE);
if (notice && terrain.flags.has(TerrainCharacteristics::MOVE)) {
if (find_ignore_doors && terrain.flags.has_all_of({ TerrainCharacteristics::DOOR, TerrainCharacteristics::CLOSE })) {
notice = false;
inv = false;
}
- if (!inv && see_wall(player_ptr, 0, row, col)) {
+ if (!inv && see_wall(player_ptr, 0, pos.y, pos.x)) {
if (find_openarea) {
if (i < 0) {
find_breakright = true;
bool cave_has_flag_bold(const FloorType *floor_ptr, int y, int x, TerrainCharacteristics f_idx)
{
- return terrains_info[floor_ptr->grid_array[y][x].feat].flags.has(f_idx);
+ const Pos2D pos(y, x);
+ return terrains_info[floor_ptr->get_grid(pos).feat].flags.has(f_idx);
}
/*
*/
void add_river(FloorType *floor_ptr, dun_data_type *dd_ptr)
{
- POSITION y2, x2;
- POSITION y1 = 0, x1 = 0;
- POSITION wid;
- FEAT_IDX feat1 = 0, feat2 = 0;
+ short feat1 = 0;
+ short feat2 = 0;
const auto &dungeon = floor_ptr->get_dungeon_definition();
feat2 = feat_shallow_water;
} else /* others */
{
- FEAT_IDX select_deep_feat[10];
- FEAT_IDX select_shallow_feat[10];
- int select_id_max = 0, selected;
-
+ short select_deep_feat[10]{};
+ short select_shallow_feat[10]{};
+ auto select_id_max = 0;
if (dungeon.flags.has(DungeonFeatureType::LAVA_RIVER)) {
select_deep_feat[select_id_max] = feat_deep_lava;
select_shallow_feat[select_id_max] = feat_shallow_lava;
}
if (select_id_max > 0) {
- selected = randint0(select_id_max);
+ const auto selected = randint0(select_id_max);
feat1 = select_deep_feat[selected];
feat2 = select_shallow_feat[selected];
} else {
}
/* Hack -- Choose starting point */
- y2 = randint1(floor_ptr->height / 2 - 2) + floor_ptr->height / 2;
- x2 = randint1(floor_ptr->width / 2 - 2) + floor_ptr->width / 2;
+ const auto y2 = randint1(floor_ptr->height / 2 - 2) + floor_ptr->height / 2;
+ const auto x2 = randint1(floor_ptr->width / 2 - 2) + floor_ptr->width / 2;
/* Hack -- Choose ending point somewhere on boundary */
+ auto y1 = 0;
+ auto x1 = 0;
switch (randint1(4)) {
case 1: {
/* top boundary */
}
constexpr auto width_rivers = 2;
- wid = randint1(width_rivers);
+ const auto wid = randint1(width_rivers);
recursive_river(floor_ptr, x1, y1, x2, y2, feat1, feat2, wid);
/* Hack - Save the location as a "room" */
bool pattern_effect(PlayerType *player_ptr)
{
auto *floor_ptr = player_ptr->current_floor_ptr;
- if (!pattern_tile(floor_ptr, player_ptr->y, player_ptr->x)) {
+ const auto p_pos = player_ptr->get_position();
+ if (!pattern_tile(floor_ptr, p_pos.y, p_pos.x)) {
return false;
}
wreck_the_pattern(player_ptr);
}
- int pattern_type = terrains_info[floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
+ int pattern_type = terrains_info[floor_ptr->get_grid(p_pos).feat].subtype;
switch (pattern_type) {
case PATTERN_TILE_END:
(void)BadStatusSetter(player_ptr).hallucination(0);
*/
monsterrace_hook_type get_monster_hook2(PlayerType *player_ptr, POSITION y, POSITION x)
{
- const auto &terrain = terrains_info[player_ptr->current_floor_ptr->grid_array[y][x].feat];
+ const Pos2D pos(y, x);
+ const auto &terrain = terrains_info[player_ptr->current_floor_ptr->get_grid(pos).feat];
if (terrain.flags.has(TerrainCharacteristics::WATER)) {
return terrain.flags.has(TerrainCharacteristics::DEEP) ? (monsterrace_hook_type)mon_hook_deep_water : (monsterrace_hook_type)mon_hook_shallow_water;
}
void wreck_the_pattern(PlayerType *player_ptr)
{
auto *floor_ptr = player_ptr->current_floor_ptr;
- int pattern_type = terrains_info[floor_ptr->grid_array[player_ptr->y][player_ptr->x].feat].subtype;
+ const auto p_pos = player_ptr->get_position();
+ int pattern_type = terrains_info[floor_ptr->get_grid(p_pos).feat].subtype;
if (pattern_type == PATTERN_TILE_WRECKED) {
return;
}
take_hit(player_ptr, DAMAGE_NOESCAPE, damroll(10, 8), _("パターン損壊", "corrupting the Pattern"));
}
- int to_ruin = randint1(45) + 35;
+ auto to_ruin = randint1(45) + 35;
while (to_ruin--) {
- POSITION r_y, r_x;
- scatter(player_ptr, &r_y, &r_x, player_ptr->y, player_ptr->x, 4, PROJECT_NONE);
-
- if (pattern_tile(floor_ptr, r_y, r_x) && (terrains_info[floor_ptr->grid_array[r_y][r_x].feat].subtype != PATTERN_TILE_WRECKED)) {
- cave_set_feat(player_ptr, r_y, r_x, feat_pattern_corrupted);
+ int y;
+ int x;
+ scatter(player_ptr, &y, &x, player_ptr->y, player_ptr->x, 4, PROJECT_NONE);
+ const Pos2D pos(y, x);
+ if (pattern_tile(floor_ptr, pos.y, pos.x) && (terrains_info[floor_ptr->get_grid(pos).feat].subtype != PATTERN_TILE_WRECKED)) {
+ cave_set_feat(player_ptr, pos.y, pos.x, feat_pattern_corrupted);
}
}
}
/* Process "re-glowing" */
- for (POSITION y = (y1 - r); y <= (y1 + r); y++) {
- for (POSITION x = (x1 - r); x <= (x1 + r); x++) {
- if (!in_bounds(&floor, y, x)) {
+ for (auto y = (y1 - r); y <= (y1 + r); y++) {
+ for (auto x = (x1 - r); x <= (x1 + r); x++) {
+ const Pos2D pos(y, x);
+ if (!in_bounds(&floor, pos.y, pos.x)) {
continue;
}
- /* Extract the distance */
- int k = distance(y1, x1, y, x);
-
/* Stay in the circle of death */
+ auto k = distance(y1, x1, pos.y, pos.x);
if (k > r) {
continue;
}
- Grid *g_ptr;
- g_ptr = &floor.grid_array[y][x];
- if (g_ptr->is_mirror()) {
- g_ptr->info |= CAVE_GLOW;
+ auto &grid = floor.get_grid(pos);
+ if (grid.is_mirror()) {
+ grid.info |= CAVE_GLOW;
continue;
}
continue;
}
- DIRECTION i;
- POSITION yy, xx;
- Grid *cc_ptr;
-
- for (i = 0; i < 9; i++) {
- yy = y + ddy_ddd[i];
- xx = x + ddx_ddd[i];
- if (!in_bounds2(&floor, yy, xx)) {
+ for (auto i = 0; i < 9; i++) {
+ const Pos2D pos_neighbor(pos.y + ddy_ddd[i], pos.x + ddx_ddd[i]);
+ if (!in_bounds2(&floor, pos_neighbor.y, pos_neighbor.x)) {
continue;
}
- cc_ptr = &floor.grid_array[yy][xx];
- if (terrains_info[cc_ptr->get_feat_mimic()].flags.has(TerrainCharacteristics::GLOW)) {
- g_ptr->info |= CAVE_GLOW;
+
+ const auto &grid_neighbor = floor.get_grid(pos_neighbor);
+ if (terrains_info[grid_neighbor.get_feat_mimic()].flags.has(TerrainCharacteristics::GLOW)) {
+ grid.info |= CAVE_GLOW;
break;
}
}