#include "io/screen-util.h"
#include "monster-floor/monster-remover.h"
#include "monster-race/monster-race.h"
-#include "monster-race/race-flags2.h"
-#include "monster-race/race-flags7.h"
#include "monster/monster-info.h"
#include "monster/monster-status.h"
#include "monster/monster-update.h"
const auto &grid = player_ptr->current_floor_ptr->get_grid({ y, x });
/* Must be a "naked" floor grid */
- if (grid.m_idx) {
+ if (grid.has_monster()) {
continue;
}
if (floor.is_in_dungeon()) {
- const auto &terrain = terrains_info[grid.feat];
+ const auto &terrain = grid.get_terrain();
if (max_attempts > 5000) /* Rule 1 */
{
/*!
* @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door
* @param player_ptr プレイヤーへの参照ポインタ
- * @param g_ptr マス構造体の参照ポインタ
+ * @param grid マス構造体の参照ポインタ
* @return 隠されたドアがあるならTRUEを返す。
*/
bool is_hidden_door(PlayerType *player_ptr, const Grid &grid)
return;
}
- if (grid.m_idx > 0) {
+ if (grid.has_monster()) {
update_monster(player_ptr, grid.m_idx, false);
}
*/
void note_spot(PlayerType *player_ptr, POSITION y, POSITION x)
{
- auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+ const Pos2D pos(y, x);
+ auto &floor = *player_ptr->current_floor_ptr;
+ auto &grid = floor.get_grid(pos);
/* Blind players see nothing */
if (player_ptr->effects()->blindness()->is_blind()) {
}
/* Analyze non-torch-lit grids */
- if (!(g_ptr->info & (CAVE_LITE | CAVE_MNLT))) {
+ if (!(grid.info & (CAVE_LITE | CAVE_MNLT))) {
/* Require line of sight to the grid */
- if (!(g_ptr->info & (CAVE_VIEW))) {
+ if (!(grid.info & (CAVE_VIEW))) {
return;
}
/* Require "perma-lite" of the grid */
- if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) {
+ if ((grid.info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) {
/* Not Ninja */
if (!player_ptr->see_nocto) {
return;
}
/* Hack -- memorize objects */
- for (const auto this_o_idx : g_ptr->o_idx_list) {
- auto *o_ptr = &player_ptr->current_floor_ptr->o_list[this_o_idx];
-
- /* Memorize objects */
- o_ptr->marked.set(OmType::FOUND);
+ for (const auto this_o_idx : grid.o_idx_list) {
+ auto &item = floor.o_list[this_o_idx];
+ item.marked.set(OmType::FOUND);
RedrawingFlagsUpdater::get_instance().set_flag(SubWindowRedrawingFlag::FOUND_ITEMS);
}
/* Hack -- memorize grids */
- if (!g_ptr->is_mark()) {
+ if (!grid.is_mark()) {
/* Feature code (applying "mimic" field) */
- auto *f_ptr = &terrains_info[g_ptr->get_feat_mimic()];
+ const auto &terrain = grid.get_terrain_mimic();
/* Memorize some "boring" grids */
- if (f_ptr->flags.has_not(TerrainCharacteristics::REMEMBER)) {
+ if (terrain.flags.has_not(TerrainCharacteristics::REMEMBER)) {
/* Option -- memorize all torch-lit floors */
- if (view_torch_grids && ((g_ptr->info & (CAVE_LITE | CAVE_MNLT)) || player_ptr->see_nocto)) {
- g_ptr->info |= (CAVE_MARK);
+ if (view_torch_grids && ((grid.info & (CAVE_LITE | CAVE_MNLT)) || player_ptr->see_nocto)) {
+ grid.info |= (CAVE_MARK);
}
/* Option -- memorize all perma-lit floors */
- else if (view_perma_grids && ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)) {
- g_ptr->info |= (CAVE_MARK);
+ else if (view_perma_grids && ((grid.info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)) {
+ grid.info |= (CAVE_MARK);
}
}
/* Memorize normal grids */
- else if (f_ptr->flags.has(TerrainCharacteristics::LOS)) {
- g_ptr->info |= (CAVE_MARK);
+ else if (terrain.flags.has(TerrainCharacteristics::LOS)) {
+ grid.info |= (CAVE_MARK);
}
/* Memorize torch-lit walls */
- else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT)) {
- g_ptr->info |= (CAVE_MARK);
+ else if (grid.info & (CAVE_LITE | CAVE_MNLT)) {
+ grid.info |= (CAVE_MARK);
}
/* Memorize walls seen by noctovision of Ninja */
else if (player_ptr->see_nocto) {
- g_ptr->info |= (CAVE_MARK);
+ grid.info |= (CAVE_MARK);
}
/* Memorize certain non-torch-lit wall grids */
else if (check_local_illumination(player_ptr, y, x)) {
- g_ptr->info |= (CAVE_MARK);
+ grid.info |= (CAVE_MARK);
}
}
/* Memorize terrain of the grid */
- g_ptr->info |= (CAVE_KNOWN);
+ grid.info |= (CAVE_KNOWN);
}
/*
const Pos2D pos(y, x);
const auto &floor = *player_ptr->current_floor_ptr;
const auto &grid = floor.get_grid(pos);
- const auto &terrain = terrains_info[grid.feat];
+ const auto &terrain = grid.get_terrain();
/* Require "teleportable" space */
if (terrain.flags.has_not(TerrainCharacteristics::TELEPORTABLE)) {
return false;
}
- if (grid.m_idx && (grid.m_idx != m_idx)) {
+ if (grid.has_monster() && (grid.m_idx != m_idx)) {
return false;
}
if (player_ptr->is_located_at(pos)) {
{
const Pos2D pos(y, x);
const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
- const auto &terrain = terrains_info[grid.feat];
+ const auto &terrain = grid.get_terrain();
/* Require "teleportable" space */
if (terrain.flags.has_not(TerrainCharacteristics::TELEPORTABLE)) {
return false;
}
- if (grid.m_idx && (grid.m_idx != player_ptr->riding)) {
+ if (grid.has_monster() && (grid.m_idx != player_ptr->riding)) {
return false;
}
return;
}
- if (g_ptr->m_idx > 0) {
+ if (g_ptr->has_monster()) {
delete_monster_idx(player_ptr, g_ptr->m_idx);
}
}
/*!
* モンスターにより照明が消されている地形か否かを判定する。 / Is this grid "darkened" by monster?
* @param player_ptr プレイヤーへの参照ポインタ
- * @param g_ptr グリッドへの参照ポインタ
+ * @param grid グリッドへの参照ポインタ
* @return 照明が消されている地形ならばTRUE
*/
bool darkened_grid(PlayerType *player_ptr, Grid *g_ptr)
}
/*!
- * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
- * Attempt to open the given chest at the given location
- * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
- * @param x 該当する地形の中から1つのX座標を返す参照ポインタ
+ * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す
+ * @param player_ptr プレイヤーへの参照ポインタ
* @param test 地形条件を判定するための関数ポインタ
* @param under TRUEならばプレイヤーの直下の座標も走査対象にする
- * @return 該当する地形の数
- * @details Return the number of features around (or under) the character.
- * Usually look for doors and floor traps.
+ * @return 該当する地形の数と、該当する地形の中から1つの座標
*/
-int count_dt(PlayerType *player_ptr, POSITION *y, POSITION *x, bool (*test)(PlayerType *, FEAT_IDX), bool under)
+std::pair<int, Pos2D> count_dt(PlayerType *player_ptr, bool (*test)(PlayerType *, short), bool under)
{
- int count = 0;
- for (DIRECTION d = 0; d < 9; d++) {
- Grid *g_ptr;
- FEAT_IDX feat;
+ auto count = 0;
+ Pos2D pos(0, 0);
+ for (auto d = 0; d < 9; d++) {
if ((d == 8) && !under) {
continue;
}
- POSITION yy = player_ptr->y + ddy_ddd[d];
- POSITION xx = player_ptr->x + ddx_ddd[d];
- g_ptr = &player_ptr->current_floor_ptr->grid_array[yy][xx];
- if (!g_ptr->is_mark()) {
+ Pos2D pos_neighbor(player_ptr->y + ddy_ddd[d], player_ptr->x + ddx_ddd[d]);
+ const auto &grid = player_ptr->current_floor_ptr->get_grid(pos_neighbor);
+ if (!grid.is_mark()) {
continue;
}
- feat = g_ptr->get_feat_mimic();
+ const auto feat = grid.get_feat_mimic();
if (!((*test)(player_ptr, feat))) {
continue;
}
++count;
- *y = yy;
- *x = xx;
+ pos = pos_neighbor;
}
- return count;
+ return { count, pos };
}
/*!
*/
bool feat_uses_special(FEAT_IDX f_idx)
{
- return terrains_info[(f_idx)].flags.has(TerrainCharacteristics::SPECIAL);
+ return TerrainList::get_instance()[(f_idx)].flags.has(TerrainCharacteristics::SPECIAL);
}
/*