From 90e87cac12dc1b9f8701372280aae496eeff3256 Mon Sep 17 00:00:00 2001 From: Hourier Date: Fri, 10 Jul 2020 20:29:59 +0900 Subject: [PATCH] [Refactor] #40535 Moved count_dt() from cmd-basic.c to grid.c/h --- src/cmd/cmd-basic.c | 38 -------------------------------------- src/grid/grid.c | 38 ++++++++++++++++++++++++++++++++++++++ src/grid/grid.h | 5 ++--- 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/src/cmd/cmd-basic.c b/src/cmd/cmd-basic.c index ac3cb3fd0..ddd200768 100644 --- a/src/cmd/cmd-basic.c +++ b/src/cmd/cmd-basic.c @@ -190,44 +190,6 @@ static bool exe_open_chest(player_type *creature_ptr, POSITION y, POSITION x, OB } /*! - * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す / - * Attempt to open the given chest at the given location - * @param y 該当する地形の中から1つのY座標を返す参照ポインタ - * @param x 該当する地形の中から1つのX座標を返す参照ポインタ - * @param test 地形条件を判定するための関数ポインタ - * @param under TRUEならばプレイヤーの直下の座標も走査対象にする - * @return 該当する地形の数 - * @details Return the number of features around (or under) the character. - * Usually look for doors and floor traps. - */ -static int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type *, FEAT_IDX feat), bool under) -{ - int count = 0; - for (DIRECTION d = 0; d < 9; d++) { - grid_type *g_ptr; - FEAT_IDX feat; - 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))) - continue; - - feat = get_feat_mimic(g_ptr); - if (!((*test)(creature_ptr, feat))) - continue; - - ++count; - *y = yy; - *x = xx; - } - - return count; -} - -/*! * @brief プレイヤーの周辺9マスに箱のあるマスがいくつあるかを返す / * Return the number of chests around (or under) the character. * @param y 該当するマスの中から1つのY座標を返す参照ポインタ diff --git a/src/grid/grid.c b/src/grid/grid.c index 1d6fc8f7b..7222fcbfd 100644 --- a/src/grid/grid.c +++ b/src/grid/grid.c @@ -1430,3 +1430,41 @@ void add_cave_info(floor_type *floor_ptr, POSITION y, POSITION x, int cave_mask) * @return 地形情報 */ FEAT_IDX get_feat_mimic(grid_type *g_ptr) { return (f_info[g_ptr->mimic ? g_ptr->mimic : g_ptr->feat].mimic); } + +/*! + * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す / + * Attempt to open the given chest at the given location + * @param y 該当する地形の中から1つのY座標を返す参照ポインタ + * @param x 該当する地形の中から1つのX座標を返す参照ポインタ + * @param test 地形条件を判定するための関数ポインタ + * @param under TRUEならばプレイヤーの直下の座標も走査対象にする + * @return 該当する地形の数 + * @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 = 0; + for (DIRECTION d = 0; d < 9; d++) { + grid_type *g_ptr; + FEAT_IDX feat; + 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))) + continue; + + feat = get_feat_mimic(g_ptr); + if (!((*test)(creature_ptr, feat))) + continue; + + ++count; + *y = yy; + *x = xx; + } + + return count; +} diff --git a/src/grid/grid.h b/src/grid/grid.h index 50719ce89..ff22226dc 100644 --- a/src/grid/grid.h +++ b/src/grid/grid.h @@ -170,9 +170,6 @@ extern bool player_can_enter(player_type *creature_ptr, FEAT_IDX feature, BIT_FL */ #define feat_uses_special(F) (have_flag(f_info[(F)].flags, FF_SPECIAL)) -/*! - * grids.c - */ extern POSITION distance(POSITION y1, POSITION x1, POSITION y2, POSITION x2); extern void update_local_illumination(player_type *creature_ptr, POSITION y, POSITION x); extern bool no_lite(player_type *creature_ptr); @@ -263,3 +260,5 @@ FEAT_IDX get_feat_mimic(grid_type *g_ptr); (F)->view_x[(F)->view_n] = (X); \ (F)->view_n++;}\ } + +int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(player_type *, FEAT_IDX), bool under); -- 2.11.0