* 2013 Deskull Doxygen向けのコメント整理\n
*/
-#include <queue>
-
+#include "grid/grid.h"
#include "core/window-redrawer.h"
#include "dungeon/dungeon-flag-types.h"
#include "dungeon/dungeon.h"
#include "game-option/game-play-options.h"
#include "game-option/map-screen-options.h"
#include "game-option/special-options.h"
+#include "grid/feature-action-flags.h"
#include "grid/feature.h"
-#include "grid/grid.h"
#include "grid/object-placer.h"
#include "grid/trap.h"
#include "io/screen-util.h"
#include "monster/monster-update.h"
#include "object/item-tester-hooker.h"
#include "object/object-mark-types.h"
-#include "player/player-class.h"
+#include "player-info/class-info.h"
#include "player/player-status-flags.h"
#include "player/player-status.h"
#include "room/rooms-builder.h"
-#include "spell/spell-types.h"
+#include "effect/attribute-types.h"
#include "system/floor-type-definition.h"
+#include "system/grid-type-definition.h"
#include "system/monster-race-definition.h"
#include "system/monster-type-definition.h"
#include "system/object-type-definition.h"
#include "system/player-type-definition.h"
#include "term/term-color-types.h"
#include "util/bit-flags-calculator.h"
+#include "util/enum-converter.h"
#include "util/point-2d.h"
#include "view/display-map.h"
#include "view/display-messages.h"
#include "window/main-window-util.h"
#include "world/world.h"
+#include <queue>
#define MONSTER_FLOW_DEPTH \
32 /*!< 敵のプレイヤーに対する移動道のりの最大値(この値以上は処理を打ち切る) / OPTION: Maximum flow depth when using "MONSTER_FLOW" */
-/*
- * Feature action flags
- */
-#define FAF_DESTROY 0x01
-#define FAF_NO_DROP 0x02
-#define FAF_CRASH_GLASS 0x04
-
-/*!
- * @brief 地形状態フラグテーブル /
- * The table of features' actions
- */
-static const byte feature_action_flags[FF_FLAG_MAX] = {
- 0, /* LOS */
- 0, /* PROJECT */
- 0, /* MOVE */
- 0, /* PLACE */
- 0, /* DROP */
- 0, /* SECRET */
- 0, /* NOTICE */
- 0, /* REMEMBER */
- 0, /* OPEN */
- 0, /* CLOSE */
- FAF_CRASH_GLASS, /* BASH */
- 0, /* SPIKE */
- FAF_DESTROY, /* DISARM */
- 0, /* STORE */
- FAF_DESTROY | FAF_CRASH_GLASS, /* TUNNEL */
- 0, /* MAY_HAVE_GOLD */
- 0, /* HAS_GOLD */
- 0, /* HAS_ITEM */
- 0, /* DOOR */
- 0, /* TRAP */
- 0, /* STAIRS */
- 0, /* RUNE_OF_PROTECTION */
- 0, /* LESS */
- 0, /* MORE */
- 0, /* RUN */
- 0, /* FLOOR */
- 0, /* WALL */
- 0, /* PERMANENT */
- 0, /* INNER */
- 0, /* OUTER */
- 0, /* SOLID */
- 0, /* HIT_TRAP */
-
- 0, /* BRIDGE */
- 0, /* RIVER */
- 0, /* LAKE */
- 0, /* BRIDGED */
- 0, /* COVERED */
- 0, /* GLOW */
- 0, /* ENSECRET */
- 0, /* WATER */
- 0, /* LAVA */
- 0, /* SHALLOW */
- 0, /* DEEP */
- 0, /* FILLED */
- FAF_DESTROY | FAF_CRASH_GLASS, /* HURT_ROCK */
- 0, /* HURT_FIRE */
- 0, /* HURT_COLD */
- 0, /* HURT_ACID */
- 0, /* ICE */
- 0, /* ACID */
- 0, /* OIL */
- 0, /* XXX04 */
- 0, /* CAN_CLIMB */
- 0, /* CAN_FLY */
- 0, /* CAN_SWIM */
- 0, /* CAN_PASS */
- 0, /* CAN_OOZE */
- 0, /* CAN_DIG */
- 0, /* HIDE_ITEM */
- 0, /* HIDE_SNEAK */
- 0, /* HIDE_SWIM */
- 0, /* HIDE_DIG */
- 0, /* KILL_HUGE */
- 0, /* KILL_MOVE */
-
- 0, /* PICK_TRAP */
- 0, /* PICK_DOOR */
- 0, /* ALLOC */
- 0, /* CHEST */
- 0, /* DROP_1D2 */
- 0, /* DROP_2D2 */
- 0, /* DROP_GOOD */
- 0, /* DROP_GREAT */
- 0, /* HURT_POIS */
- 0, /* HURT_ELEC */
- 0, /* HURT_WATER */
- 0, /* HURT_BWATER */
- 0, /* USE_FEAT */
- 0, /* GET_FEAT */
- 0, /* GROUND */
- 0, /* OUTSIDE */
- 0, /* EASY_HIDE */
- 0, /* EASY_CLIMB */
- 0, /* MUST_CLIMB */
- 0, /* TREE */
- 0, /* NEED_TREE */
- 0, /* BLOOD */
- 0, /* DUST */
- 0, /* SLIME */
- 0, /* PLANT */
- 0, /* XXX2 */
- 0, /* INSTANT */
- 0, /* EXPLODE */
- 0, /* TIMED */
- 0, /* ERUPT */
- 0, /* STRIKE */
- 0, /* SPREAD */
-
- 0, /* SPECIAL */
- FAF_DESTROY | FAF_NO_DROP | FAF_CRASH_GLASS, /* HURT_DISI */
- 0, /* QUEST_ENTER */
- 0, /* QUEST_EXIT */
- 0, /* QUEST */
- 0, /* SHAFT */
- 0, /* MOUNTAIN */
- 0, /* BLDG */
- 0, /* RUNE_OF_EXPLOSION */
- 0, /* PATTERN */
- 0, /* TOWN */
- 0, /* ENTRANCE */
- 0, /* MIRROR */
- 0, /* UNPERM */
- 0, /* TELEPORTABLE */
- 0, /* CONVERT */
- 0, /* GLASS */
-};
-
/*!
* @brief 新規フロアに入りたてのプレイヤーをランダムな場所に配置する / Returns random co-ordinates for player/monster/object
- * @param creature_ptr 配置したいクリーチャーの参照ポインタ
+ * @param player_ptr プレイヤーへの参照ポインタ
* @return 配置に成功したらTRUEを返す
*/
-bool new_player_spot(player_type *creature_ptr)
+bool new_player_spot(player_type *player_ptr)
{
POSITION y = 0, x = 0;
int max_attempts = 10000;
while (max_attempts--) {
/* Pick a legal spot */
- y = (POSITION)rand_range(1, creature_ptr->current_floor_ptr->height - 2);
- x = (POSITION)rand_range(1, creature_ptr->current_floor_ptr->width - 2);
+ y = (POSITION)rand_range(1, player_ptr->current_floor_ptr->height - 2);
+ x = (POSITION)rand_range(1, player_ptr->current_floor_ptr->width - 2);
- g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
+ g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
/* Must be a "naked" floor grid */
if (g_ptr->m_idx)
continue;
- if (is_in_dungeon(creature_ptr)) {
+ if (is_in_dungeon(player_ptr)) {
f_ptr = &f_info[g_ptr->feat];
if (max_attempts > 5000) /* Rule 1 */
{
- if (!has_flag(f_ptr->flags, FF_FLOOR))
+ if (f_ptr->flags.has_not(FF::FLOOR))
continue;
} else /* Rule 2 */
{
- if (!has_flag(f_ptr->flags, FF_MOVE))
+ if (f_ptr->flags.has_not(FF::MOVE))
continue;
- if (has_flag(f_ptr->flags, FF_HIT_TRAP))
+ if (f_ptr->flags.has(FF::HIT_TRAP))
continue;
}
/* Refuse to start on anti-teleport grids in dungeon */
- if (!has_flag(f_ptr->flags, FF_TELEPORTABLE))
+ if (f_ptr->flags.has_not(FF::TELEPORTABLE))
continue;
}
- if (!player_can_enter(creature_ptr, g_ptr->feat, 0))
+ if (!player_can_enter(player_ptr, g_ptr->feat, 0))
continue;
- if (!in_bounds(creature_ptr->current_floor_ptr, y, x))
+ if (!in_bounds(player_ptr->current_floor_ptr, y, x))
continue;
/* Refuse to start on anti-teleport grids */
- if (g_ptr->info & (CAVE_ICKY))
+ if (g_ptr->is_icky())
continue;
break;
}
if (max_attempts < 1) /* Should be -1, actually if we failed... */
- return FALSE;
+ return false;
/* Save the new player grid */
- creature_ptr->y = y;
- creature_ptr->x = x;
+ player_ptr->y = y;
+ player_ptr->x = x;
- return TRUE;
-}
-
-/*!
- * @brief マスにフロア端用の永久壁を配置する / Set boundary mimic and add "solid" perma-wall
- * @param g_ptr 永久壁を配置したいマス構造体の参照ポインタ
- */
-void place_bound_perm_wall(player_type *player_ptr, grid_type *g_ptr)
-{
- if (bound_walls_perm) {
- /* Clear boundary mimic */
- g_ptr->mimic = 0;
- } else {
- feature_type *f_ptr = &f_info[g_ptr->feat];
-
- /* Hack -- Decline boundary walls with known treasure */
- if ((has_flag(f_ptr->flags, FF_HAS_GOLD) || has_flag(f_ptr->flags, FF_HAS_ITEM)) && !has_flag(f_ptr->flags, FF_SECRET))
- g_ptr->feat = feat_state(player_ptr->current_floor_ptr, g_ptr->feat, FF_ENSECRET);
-
- /* Set boundary mimic */
- g_ptr->mimic = g_ptr->feat;
- }
-
- /* Add "solid" perma-wall */
- place_grid(player_ptr, g_ptr, GB_SOLID_PERM);
-}
-
-/*!
- * @brief マスに看破済みの罠があるかの判定を行う。 / Return TRUE if the given grid is a known trap
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param g_ptr マス構造体の参照ポインタ
- * @return 看破済みの罠があるならTRUEを返す。
- */
-bool is_known_trap(player_type *player_ptr, grid_type *g_ptr)
-{
- if (!g_ptr->mimic && !cave_has_flag_grid(g_ptr, FF_SECRET) && is_trap(player_ptr, g_ptr->feat))
- return TRUE;
- else
- return FALSE;
+ return true;
}
/*!
* @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
* @param g_ptr マス構造体の参照ポインタ
* @return 隠されたドアがあるならTRUEを返す。
*/
bool is_hidden_door(player_type *player_ptr, grid_type *g_ptr)
{
- if ((g_ptr->mimic || cave_has_flag_grid(g_ptr, FF_SECRET)) && is_closed_door(player_ptr, g_ptr->feat))
- return TRUE;
+ if ((g_ptr->mimic || g_ptr->cave_has_flag(FF::SECRET)) && is_closed_door(player_ptr, g_ptr->feat))
+ return true;
else
- return FALSE;
+ return false;
}
/*!
* @param x x座標
* @return 指定された座標に照明がかかっているならTRUEを返す。。
*/
-bool check_local_illumination(player_type *creature_ptr, POSITION y, POSITION x)
+bool check_local_illumination(player_type *player_ptr, POSITION y, POSITION x)
{
/* Hack -- move towards player */
- POSITION yy = (y < creature_ptr->y) ? (y + 1) : (y > creature_ptr->y) ? (y - 1) : y;
- POSITION xx = (x < creature_ptr->x) ? (x + 1) : (x > creature_ptr->x) ? (x - 1) : x;
+ POSITION yy = (y < player_ptr->y) ? (y + 1) : (y > player_ptr->y) ? (y - 1) : y;
+ POSITION xx = (x < player_ptr->x) ? (x + 1) : (x > player_ptr->x) ? (x - 1) : x;
/* Check for "local" illumination */
/* Check for "complex" illumination */
- if ((feat_supports_los(get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[yy][xx]))
- && (creature_ptr->current_floor_ptr->grid_array[yy][xx].info & CAVE_GLOW))
- || (feat_supports_los(get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[y][xx]))
- && (creature_ptr->current_floor_ptr->grid_array[y][xx].info & CAVE_GLOW))
- || (feat_supports_los(get_feat_mimic(&creature_ptr->current_floor_ptr->grid_array[yy][x]))
- && (creature_ptr->current_floor_ptr->grid_array[yy][x].info & CAVE_GLOW))) {
- return TRUE;
+ auto *floor_ptr = player_ptr->current_floor_ptr;
+ if ((feat_supports_los(floor_ptr->grid_array[yy][xx].get_feat_mimic()) && (floor_ptr->grid_array[yy][xx].info & CAVE_GLOW))
+ || (feat_supports_los(floor_ptr->grid_array[y][xx].get_feat_mimic()) && (floor_ptr->grid_array[y][xx].info & CAVE_GLOW))
+ || (feat_supports_los(floor_ptr->grid_array[yy][x].get_feat_mimic()) && (floor_ptr->grid_array[yy][x].info & CAVE_GLOW))) {
+ return true;
} else
- return FALSE;
+ return false;
}
/*! 対象座標のマスの照明状態を更新する際の補助処理マクロ */
if (player_has_los_bold((C), (Y), (X))) { \
/* Update the monster */ \
if ((C)->current_floor_ptr->grid_array[(Y)][(X)].m_idx) \
- update_monster((C), (C)->current_floor_ptr->grid_array[(Y)][(X)].m_idx, FALSE); \
+ update_monster((C), (C)->current_floor_ptr->grid_array[(Y)][(X)].m_idx, false); \
\
/* Notice and redraw */ \
note_spot((C), (Y), (X)); \
/*!
* @brief 指定された座標の照明状態を更新する / Update "local" illumination
- * @param creature_ptr 視界元のクリーチャー
+ * @param player_ptr プレイヤーへの参照ポインタ
* @param y 視界先y座標
* @param x 視界先x座標
*/
-void update_local_illumination(player_type *creature_ptr, POSITION y, POSITION x)
+void update_local_illumination(player_type *player_ptr, POSITION y, POSITION x)
{
int i;
POSITION yy, xx;
- if (!in_bounds(creature_ptr->current_floor_ptr, y, x))
+ if (!in_bounds(player_ptr->current_floor_ptr, y, x))
return;
- if ((y != creature_ptr->y) && (x != creature_ptr->x)) {
- yy = (y < creature_ptr->y) ? (y - 1) : (y + 1);
- xx = (x < creature_ptr->x) ? (x - 1) : (x + 1);
- update_local_illumination_aux(creature_ptr, yy, xx);
- update_local_illumination_aux(creature_ptr, y, xx);
- update_local_illumination_aux(creature_ptr, yy, x);
- } else if (x != creature_ptr->x) /* y == creature_ptr->y */
+ if ((y != player_ptr->y) && (x != player_ptr->x)) {
+ yy = (y < player_ptr->y) ? (y - 1) : (y + 1);
+ xx = (x < player_ptr->x) ? (x - 1) : (x + 1);
+ update_local_illumination_aux(player_ptr, yy, xx);
+ update_local_illumination_aux(player_ptr, y, xx);
+ update_local_illumination_aux(player_ptr, yy, x);
+ } else if (x != player_ptr->x) /* y == player_ptr->y */
{
- xx = (x < creature_ptr->x) ? (x - 1) : (x + 1);
+ xx = (x < player_ptr->x) ? (x - 1) : (x + 1);
for (i = -1; i <= 1; i++) {
yy = y + i;
- update_local_illumination_aux(creature_ptr, yy, xx);
+ update_local_illumination_aux(player_ptr, yy, xx);
}
yy = y - 1;
- update_local_illumination_aux(creature_ptr, yy, x);
+ update_local_illumination_aux(player_ptr, yy, x);
yy = y + 1;
- update_local_illumination_aux(creature_ptr, yy, x);
- } else if (y != creature_ptr->y) /* x == creature_ptr->x */
+ update_local_illumination_aux(player_ptr, yy, x);
+ } else if (y != player_ptr->y) /* x == player_ptr->x */
{
- yy = (y < creature_ptr->y) ? (y - 1) : (y + 1);
+ yy = (y < player_ptr->y) ? (y - 1) : (y + 1);
for (i = -1; i <= 1; i++) {
xx = x + i;
- update_local_illumination_aux(creature_ptr, yy, xx);
+ update_local_illumination_aux(player_ptr, yy, xx);
}
xx = x - 1;
- update_local_illumination_aux(creature_ptr, y, xx);
+ update_local_illumination_aux(player_ptr, y, xx);
xx = x + 1;
- update_local_illumination_aux(creature_ptr, y, xx);
+ update_local_illumination_aux(player_ptr, y, xx);
} else /* Player's grid */
{
for (i = 0; i < 8; i++) {
yy = y + ddy_cdd[i];
xx = x + ddx_cdd[i];
- update_local_illumination_aux(creature_ptr, yy, xx);
+ update_local_illumination_aux(player_ptr, yy, xx);
}
}
}
* @return 視覚に収められていないならTRUEを返す
* @details player_can_see_bold()関数の返り値の否定を返している。
*/
-bool no_lite(player_type *creature_ptr) { return (!player_can_see_bold(creature_ptr, creature_ptr->y, creature_ptr->x)); }
+bool no_lite(player_type *player_ptr)
+{
+ return (!player_can_see_bold(player_ptr, player_ptr->y, player_ptr->x));
+}
/*
* Place an attr/char pair at the given map coordinate, if legal.
*/
-void print_rel(player_type *subject_ptr, SYMBOL_CODE c, TERM_COLOR a, POSITION y, POSITION x)
+void print_rel(player_type *player_ptr, SYMBOL_CODE c, TERM_COLOR a, POSITION y, POSITION x)
{
/* Only do "legal" locations */
if (panel_contains(y, x)) {
/* Hack -- fake monochrome */
if (!use_graphics) {
- if (current_world_ptr->timewalk_m_idx)
+ if (w_ptr->timewalk_m_idx)
a = TERM_DARK;
- else if (is_invuln(subject_ptr) || subject_ptr->timewalk)
+ else if (is_invuln(player_ptr) || player_ptr->timewalk)
a = TERM_WHITE;
- else if (subject_ptr->wraith_form)
+ else if (player_ptr->wraith_form)
a = TERM_L_DARK;
}
}
/* Hack -- memorize grids */
- if (!(g_ptr->info & (CAVE_MARK))) {
+ if (!g_ptr->is_mark()) {
/* Feature code (applying "mimic" field) */
- feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
+ feature_type *f_ptr = &f_info[g_ptr->get_feat_mimic()];
/* Memorize some "boring" grids */
- if (!has_flag(f_ptr->flags, FF_REMEMBER)) {
+ if (f_ptr->flags.has_not(FF::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);
}
/* Memorize normal grids */
- else if (has_flag(f_ptr->flags, FF_LOS)) {
+ else if (f_ptr->flags.has(FF::LOS)) {
g_ptr->info |= (CAVE_MARK);
}
/* Hack -- fake monochrome */
if (!use_graphics) {
- if (current_world_ptr->timewalk_m_idx)
+ if (w_ptr->timewalk_m_idx)
a = TERM_DARK;
else if (is_invuln(player_ptr) || player_ptr->timewalk)
a = TERM_WHITE;
* We do not need a priority queue because the cost from grid
* to grid is always "one" and we process them in order.
*/
-void update_flow(player_type *subject_ptr)
+void update_flow(player_type *player_ptr)
{
POSITION x, y;
DIRECTION d;
- floor_type *f_ptr = subject_ptr->current_floor_ptr;
+ floor_type *f_ptr = player_ptr->current_floor_ptr;
/* The last way-point is on the map */
- if (subject_ptr->running && in_bounds(f_ptr, flow_y, flow_x)) {
+ if (player_ptr->running && in_bounds(f_ptr, flow_y, flow_x)) {
/* The way point is in sight - do not update. (Speedup) */
if (f_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW)
return;
}
/* Save player position */
- flow_y = subject_ptr->y;
- flow_x = subject_ptr->x;
+ flow_y = player_ptr->y;
+ flow_x = player_ptr->x;
for (int i = 0; i < FLOW_MAX; i++) {
// 幅優先探索用のキュー。
std::queue<Pos2D> que;
- que.emplace(subject_ptr->y, subject_ptr->x);
+ que.emplace(player_ptr->y, player_ptr->x);
/* Now process the queue */
while (!que.empty()) {
/* Add the "children" */
for (d = 0; d < 8; d++) {
- byte m = subject_ptr->current_floor_ptr->grid_array[ty][tx].costs[i] + 1;
- byte n = subject_ptr->current_floor_ptr->grid_array[ty][tx].dists[i] + 1;
+ byte m = player_ptr->current_floor_ptr->grid_array[ty][tx].costs[i] + 1;
+ byte n = player_ptr->current_floor_ptr->grid_array[ty][tx].dists[i] + 1;
/* Child location */
y = ty + ddy_ddd[d];
x = tx + ddx_ddd[d];
/* Ignore player's grid */
- if (player_bold(subject_ptr, y, x))
+ if (player_bold(player_ptr, y, x))
continue;
- grid_type *g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
- if (is_closed_door(subject_ptr, g_ptr->feat))
+ if (is_closed_door(player_ptr, g_ptr->feat))
m += 3;
/* Ignore "pre-stamped" entries */
bool can_move = false;
switch (i) {
case FLOW_CAN_FLY:
- can_move = cave_has_flag_grid(g_ptr, FF_MOVE) || cave_has_flag_grid(g_ptr, FF_CAN_FLY);
+ can_move = g_ptr->cave_has_flag(FF::MOVE) || g_ptr->cave_has_flag(FF::CAN_FLY);
break;
default:
- can_move = cave_has_flag_grid(g_ptr, FF_MOVE);
+ can_move = g_ptr->cave_has_flag(FF::MOVE);
break;
}
- if (!can_move && !is_closed_door(subject_ptr, g_ptr->feat))
+ if (!can_move && !is_closed_door(player_ptr, g_ptr->feat))
continue;
/* Save the flow cost */
}
}
-static flow_type get_grid_flow_type(monster_race *r_ptr) {
- if (any_bits(r_ptr->flags7, RF7_CAN_FLY))
- return FLOW_CAN_FLY;
- return FLOW_NORMAL;
-}
-
-byte grid_cost(grid_type *g_ptr, monster_race *r_ptr)
-{
- return g_ptr->costs[get_grid_flow_type(r_ptr)];
-}
-
-byte grid_dist(grid_type *g_ptr, monster_race *r_ptr)
-{
- return g_ptr->dists[get_grid_flow_type(r_ptr)];
-}
-
/*
* Take a feature, determine what that feature becomes
* through applying the given action.
*/
-FEAT_IDX feat_state(floor_type *floor_ptr, FEAT_IDX feat, int action)
+FEAT_IDX feat_state(floor_type *floor_ptr, FEAT_IDX feat, FF action)
{
feature_type *f_ptr = &f_info[feat];
int i;
return conv_dungeon_feat(floor_ptr, f_ptr->state[i].result);
}
- if (has_flag(f_ptr->flags, FF_PERMANENT))
+ if (f_ptr->flags.has(FF::PERMANENT))
return feat;
- return (feature_action_flags[action] & FAF_DESTROY) ? conv_dungeon_feat(floor_ptr, f_ptr->destroyed) : feat;
+ return (feature_action_flags[enum2i(action)] & FAF_DESTROY) ? conv_dungeon_feat(floor_ptr, f_ptr->destroyed) : feat;
}
/*
* Takes a location and action and changes the feature at that
* location through applying the given action.
*/
-void cave_alter_feat(player_type *player_ptr, POSITION y, POSITION x, int action)
+void cave_alter_feat(player_type *player_ptr, POSITION y, POSITION x, FF action)
{
/* Set old feature */
floor_type *floor_ptr = player_ptr->current_floor_ptr;
/* Set the new feature */
cave_set_feat(player_ptr, y, x, newfeat);
- if (!(feature_action_flags[action] & FAF_NO_DROP)) {
+ if (!(feature_action_flags[enum2i(action)] & FAF_NO_DROP)) {
feature_type *old_f_ptr = &f_info[oldfeat];
feature_type *f_ptr = &f_info[newfeat];
- bool found = FALSE;
+ bool found = false;
/* Handle gold */
- if (has_flag(old_f_ptr->flags, FF_HAS_GOLD) && !has_flag(f_ptr->flags, FF_HAS_GOLD)) {
+ if (old_f_ptr->flags.has(FF::HAS_GOLD) && f_ptr->flags.has_not(FF::HAS_GOLD)) {
/* Place some gold */
place_gold(player_ptr, y, x);
- found = TRUE;
+ found = true;
}
/* Handle item */
- if (has_flag(old_f_ptr->flags, FF_HAS_ITEM) && !has_flag(f_ptr->flags, FF_HAS_ITEM) && (randint0(100) < (15 - floor_ptr->dun_level / 2))) {
+ if (old_f_ptr->flags.has(FF::HAS_ITEM) && f_ptr->flags.has_not(FF::HAS_ITEM) && (randint0(100) < (15 - floor_ptr->dun_level / 2))) {
/* Place object */
place_object(player_ptr, y, x, 0L);
- found = TRUE;
+ found = true;
}
- if (found && current_world_ptr->character_dungeon && player_can_see_bold(player_ptr, y, x)) {
+ if (found && w_ptr->character_dungeon && player_can_see_bold(player_ptr, y, x)) {
msg_print(_("何かを発見した!", "You have found something!"));
}
}
- if (feature_action_flags[action] & FAF_CRASH_GLASS) {
+ if (feature_action_flags[enum2i(action)] & FAF_CRASH_GLASS) {
feature_type *old_f_ptr = &f_info[oldfeat];
- if (has_flag(old_f_ptr->flags, FF_GLASS) && current_world_ptr->character_dungeon) {
- project(player_ptr, PROJECT_WHO_GLASS_SHARDS, 1, y, x, MIN(floor_ptr->dun_level, 100) / 4, GF_SHARDS,
+ if (old_f_ptr->flags.has(FF::GLASS) && w_ptr->character_dungeon) {
+ project(player_ptr, PROJECT_WHO_GLASS_SHARDS, 1, y, x, std::min(floor_ptr->dun_level, 100) / 4, AttributeType::SHARDS,
(PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE | PROJECT_JUMP | PROJECT_NO_HANGEKI));
}
}
}
/* Remove a mirror */
-void remove_mirror(player_type *caster_ptr, POSITION y, POSITION x)
+void remove_mirror(player_type *player_ptr, POSITION y, POSITION x)
{
- grid_type *g_ptr = &caster_ptr->current_floor_ptr->grid_array[y][x];
+ grid_type *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
/* Remove the mirror */
g_ptr->info &= ~(CAVE_OBJECT);
g_ptr->mimic = 0;
- if (d_info[caster_ptr->dungeon_idx].flags.has(DF::DARKNESS)) {
+ if (d_info[player_ptr->dungeon_idx].flags.has(DF::DARKNESS)) {
g_ptr->info &= ~(CAVE_GLOW);
if (!view_torch_grids)
g_ptr->info &= ~(CAVE_MARK);
if (g_ptr->m_idx)
- update_monster(caster_ptr, g_ptr->m_idx, FALSE);
+ update_monster(player_ptr, g_ptr->m_idx, false);
- update_local_illumination(caster_ptr, y, x);
+ update_local_illumination(player_ptr, y, x);
}
- note_spot(caster_ptr, y, x);
-
- lite_spot(caster_ptr, y, x);
-}
+ note_spot(player_ptr, y, x);
-/*
- * Return TRUE if there is a mirror on the grid.
- */
-bool is_mirror_grid(grid_type *g_ptr)
-{
- if ((g_ptr->info & CAVE_OBJECT) && has_flag(f_info[g_ptr->mimic].flags, FF_MIRROR))
- return TRUE;
- else
- return FALSE;
-}
-
-/*
- * Return TRUE if there is a rune of protection on the grid.
- */
-bool is_rune_protection_grid(grid_type *g_ptr)
-{
- if ((g_ptr->info & CAVE_OBJECT) && has_flag(f_info[g_ptr->mimic].flags, FF_RUNE_PROTECTION))
- return TRUE;
- else
- return FALSE;
-}
-
-/*
- * Return TRUE if there is a rune of explosion on the grid.
- */
-bool is_rune_explosion_grid(grid_type *g_ptr)
-{
- if ((g_ptr->info & CAVE_OBJECT) && has_flag(f_info[g_ptr->mimic].flags, FF_RUNE_EXPLOSION))
- return TRUE;
- else
- return FALSE;
+ lite_spot(player_ptr, y, x);
}
/*!
* @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
* @param m_idx モンスターID
* @param y 移動先Y座標
* @param x 移動先X座標
feature_type *f_ptr = &f_info[g_ptr->feat];
/* Require "teleportable" space */
- if (!has_flag(f_ptr->flags, FF_TELEPORTABLE))
- return FALSE;
+ if (f_ptr->flags.has_not(FF::TELEPORTABLE))
+ return false;
if (g_ptr->m_idx && (g_ptr->m_idx != m_idx))
- return FALSE;
+ return false;
if (player_bold(player_ptr, y, x))
- return FALSE;
+ return false;
/* Hack -- no teleport onto rune of protection */
- if (is_rune_protection_grid(g_ptr))
- return FALSE;
- if (is_rune_explosion_grid(g_ptr))
- return FALSE;
+ if (g_ptr->is_rune_protection())
+ return false;
+ if (g_ptr->is_rune_explosion())
+ return false;
if (!(mode & TELEPORT_PASSIVE)) {
if (!monster_can_cross_terrain(player_ptr, g_ptr->feat, &r_info[m_ptr->r_idx], 0))
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
/*!
* @brief 指定されたマスにプレイヤーがテレポート可能かどうかを判定する。
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
* @param y 移動先Y座標
* @param x 移動先X座標
* @param mode オプション
feature_type *f_ptr = &f_info[g_ptr->feat];
/* Require "teleportable" space */
- if (!has_flag(f_ptr->flags, FF_TELEPORTABLE))
- return FALSE;
+ if (f_ptr->flags.has_not(FF::TELEPORTABLE))
+ return false;
/* No magical teleporting into vaults and such */
- if (!(mode & TELEPORT_NONMAGICAL) && (g_ptr->info & CAVE_ICKY))
- return FALSE;
+ if (!(mode & TELEPORT_NONMAGICAL) && g_ptr->is_icky())
+ return false;
if (g_ptr->m_idx && (g_ptr->m_idx != player_ptr->riding))
- return FALSE;
+ return false;
/* don't teleport on a trap. */
- if (has_flag(f_ptr->flags, FF_HIT_TRAP))
- return FALSE;
+ if (f_ptr->flags.has(FF::HIT_TRAP))
+ return false;
if (!(mode & TELEPORT_PASSIVE)) {
if (!player_can_enter(player_ptr, g_ptr->feat, 0))
- return FALSE;
+ return false;
- if (has_flag(f_ptr->flags, FF_WATER) && has_flag(f_ptr->flags, FF_DEEP)) {
+ if (f_ptr->flags.has_all_of({ FF::WATER, FF::DEEP })) {
if (!player_ptr->levitation && !player_ptr->can_swim)
- return FALSE;
+ return false;
}
- if (has_flag(f_ptr->flags, FF_LAVA) && !has_immune_fire(player_ptr) && !is_invuln(player_ptr)) {
+ if (f_ptr->flags.has(FF::LAVA) && !has_immune_fire(player_ptr) && !is_invuln(player_ptr)) {
/* Always forbid deep lava */
- if (has_flag(f_ptr->flags, FF_DEEP))
- return FALSE;
+ if (f_ptr->flags.has(FF::DEEP))
+ return false;
/* Forbid shallow lava when the player don't have levitation */
if (!player_ptr->levitation)
- return FALSE;
+ return false;
}
}
- return TRUE;
+ return true;
}
/*!
*/
bool is_open(player_type *player_ptr, FEAT_IDX feat)
{
- return has_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(player_ptr->current_floor_ptr, feat, FF_CLOSE));
+ return f_info[feat].flags.has(FF::CLOSE) && (feat != feat_state(player_ptr->current_floor_ptr, feat, FF::CLOSE));
}
/*!
* @param mode 移動に関するオプションフラグ
* @return 移動可能ならばTRUEを返す
*/
-bool player_can_enter(player_type *creature_ptr, FEAT_IDX feature, BIT_FLAGS16 mode)
+bool player_can_enter(player_type *player_ptr, FEAT_IDX feature, BIT_FLAGS16 mode)
{
feature_type *f_ptr = &f_info[feature];
- if (creature_ptr->riding)
+ if (player_ptr->riding)
return monster_can_cross_terrain(
- creature_ptr, feature, &r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->riding].r_idx], mode | CEM_RIDING);
+ player_ptr, feature, &r_info[player_ptr->current_floor_ptr->m_list[player_ptr->riding].r_idx], mode | CEM_RIDING);
- if (has_flag(f_ptr->flags, FF_PATTERN)) {
+ if (f_ptr->flags.has(FF::PATTERN)) {
if (!(mode & CEM_P_CAN_ENTER_PATTERN))
- return FALSE;
+ return false;
}
- if (has_flag(f_ptr->flags, FF_CAN_FLY) && creature_ptr->levitation)
- return TRUE;
- if (has_flag(f_ptr->flags, FF_CAN_SWIM) && creature_ptr->can_swim)
- return TRUE;
- if (has_flag(f_ptr->flags, FF_CAN_PASS) && has_pass_wall(creature_ptr))
- return TRUE;
+ if (f_ptr->flags.has(FF::CAN_FLY) && player_ptr->levitation)
+ return true;
+ if (f_ptr->flags.has(FF::CAN_SWIM) && player_ptr->can_swim)
+ return true;
+ if (f_ptr->flags.has(FF::CAN_PASS) && has_pass_wall(player_ptr))
+ return true;
- if (!has_flag(f_ptr->flags, FF_MOVE))
- return FALSE;
+ if (f_ptr->flags.has_not(FF::MOVE))
+ return false;
- return TRUE;
+ return true;
}
void place_grid(player_type *player_ptr, grid_type *g_ptr, grid_bold_type gb_type)
case GB_OUTER_NOPERM: {
feature_type *f_ptr = &f_info[feat_wall_outer];
if (permanent_wall(f_ptr)) {
- g_ptr->feat = (s16b)feat_state(player_ptr->current_floor_ptr, feat_wall_outer, FF_UNPERM);
+ g_ptr->feat = (int16_t)feat_state(player_ptr->current_floor_ptr, feat_wall_outer, FF::UNPERM);
} else {
g_ptr->feat = feat_wall_outer;
}
case GB_SOLID_NOPERM: {
feature_type *f_ptr = &f_info[feat_wall_solid];
if ((g_ptr->info & CAVE_VAULT) && permanent_wall(f_ptr))
- g_ptr->feat = (s16b)feat_state(player_ptr->current_floor_ptr, feat_wall_solid, FF_UNPERM);
+ g_ptr->feat = (int16_t)feat_state(player_ptr->current_floor_ptr, feat_wall_solid, FF::UNPERM);
else
g_ptr->feat = feat_wall_solid;
g_ptr->info &= ~(CAVE_MASK);
/*!
* モンスターにより照明が消されている地形か否かを判定する。 / Is this grid "darkened" by monster?
- * @param player_ptr ã\83\97ã\83¬ã\83¼ヤーへの参照ポインタ
+ * @param player_ptr ã\83\97ã\83¬ã\82¤ヤーへの参照ポインタ
* @param g_ptr グリッドへの参照ポインタ
* @return 照明が消されている地形ならばTRUE
*/
place_grid(player_ptr, g_ptr, gb_type);
}
-void set_cave_feat(floor_type *floor_ptr, POSITION y, POSITION x, FEAT_IDX feature_idx) { floor_ptr->grid_array[y][x].feat = feature_idx; }
-
-/*!
- * @todo intをenumに変更する
- */
-void add_cave_info(floor_type *floor_ptr, POSITION y, POSITION x, int cave_mask) { floor_ptr->grid_array[y][x].info |= cave_mask; }
-
-/*
- * @brief Get feature mimic from f_info[] (applying "mimic" field)
- * @param g_ptr グリッドへの参照ポインタ
- * @return 地形情報
- */
-FEAT_IDX get_feat_mimic(grid_type *g_ptr) { return (f_info[g_ptr->mimic ? g_ptr->mimic : g_ptr->feat].mimic); }
+void set_cave_feat(floor_type *floor_ptr, POSITION y, POSITION x, FEAT_IDX feature_idx)
+{
+ floor_ptr->grid_array[y][x].feat = feature_idx;
+}
/*!
* @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
* @details Return the number of features around (or under) the character.
* Usually look for doors and floor traps.
*/
-int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type *, FEAT_IDX), bool under)
+int count_dt(player_type *player_ptr, POSITION *y, POSITION *x, bool (*test)(player_type *, FEAT_IDX), bool under)
{
int count = 0;
for (DIRECTION d = 0; d < 9; d++) {
if ((d == 8) && !under)
continue;
- POSITION yy = creature_ptr->y + ddy_ddd[d];
- POSITION xx = creature_ptr->x + ddx_ddd[d];
- g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
- if (!(g_ptr->info & (CAVE_MARK)))
+ 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())
continue;
- feat = get_feat_mimic(g_ptr);
- if (!((*test)(creature_ptr, feat)))
+ feat = g_ptr->get_feat_mimic();
+ if (!((*test)(player_ptr, feat)))
continue;
++count;
return count;
}
-bool feat_uses_special(FEAT_IDX f_idx) { return has_flag(f_info[(f_idx)].flags, FF_SPECIAL); }
+/*!
+ * @brief マス構造体のspecial要素を利用する地形かどうかを判定する.
+ */
+bool feat_uses_special(FEAT_IDX f_idx)
+{
+ return f_info[(f_idx)].flags.has(FF::SPECIAL);
+}
+
+/*
+ * This function allows us to efficiently add a grid to the "lite" array,
+ * note that we are never called for illegal grids, or for grids which
+ * have already been placed into the "lite" array, and we are never
+ * called when the "lite" array is full.
+ */
+void cave_lite_hack(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+ auto *g_ptr = &floor_ptr->grid_array[y][x];
+ if (g_ptr->is_lite()) {
+ return;
+ }
+
+ g_ptr->info |= CAVE_LITE;
+ floor_ptr->lite_y[floor_ptr->lite_n] = y;
+ floor_ptr->lite_x[floor_ptr->lite_n++] = x;
+}
+
+/*
+ * For delayed visual update
+ */
+void cave_redraw_later(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+ auto *g_ptr = &floor_ptr->grid_array[y][x];
+ if (g_ptr->is_redraw()) {
+ return;
+ }
+
+ g_ptr->info |= CAVE_REDRAW;
+ floor_ptr->redraw_y[floor_ptr->redraw_n] = y;
+ floor_ptr->redraw_x[floor_ptr->redraw_n++] = x;
+}
+
+/*
+ * For delayed visual update
+ */
+void cave_note_and_redraw_later(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+ floor_ptr->grid_array[y][x].info |= CAVE_NOTE;
+ cave_redraw_later(floor_ptr, y, x);
+}
+
+void cave_view_hack(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+ auto *g_ptr = &floor_ptr->grid_array[y][x];
+ if (g_ptr->is_view()) {
+ return;
+ }
+
+ g_ptr->info |= CAVE_VIEW;
+ floor_ptr->view_y[floor_ptr->view_n] = y;
+ floor_ptr->view_x[floor_ptr->view_n] = x;
+ floor_ptr->view_n++;
+}