Skip to content

Commit

Permalink
Merge branch 'develop' into macos-develop
Browse files Browse the repository at this point in the history
  • Loading branch information
backwardsEric committed Nov 21, 2024
2 parents 65ebfac + 397dc15 commit 0c319c7
Show file tree
Hide file tree
Showing 45 changed files with 364 additions and 336 deletions.
2 changes: 1 addition & 1 deletion src/action/movement-execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ void exe_movement(PlayerType *player_ptr, DIRECTION dir, bool do_pickup, bool br
energy.reset_player_turn();
}
} else {
if (easy_open && is_closed_door(player_ptr, grid.get_feat_mimic()) && easy_open_door(player_ptr, pos.y, pos.x)) {
if (easy_open && floor.is_closed_door(pos, true) && easy_open_door(player_ptr, pos.y, pos.x)) {
return;
}

Expand Down
7 changes: 4 additions & 3 deletions src/action/open-close-execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,13 @@ bool exe_close(PlayerType *player_ptr, POSITION y, POSITION x)
bool easy_open_door(PlayerType *player_ptr, POSITION y, POSITION x)
{
const Pos2D pos(y, x);
const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
const auto &terrain = grid.get_terrain();
if (!is_closed_door(player_ptr, grid.feat)) {
const auto &floor = *player_ptr->current_floor_ptr;
if (!floor.is_closed_door(pos)) {
return false;
}

const auto &grid = floor.get_grid(pos);
const auto &terrain = grid.get_terrain();
if (terrain.flags.has_not(TerrainCharacteristics::OPEN)) {
constexpr auto fmt = _("%sはがっちりと閉じられているようだ。", "The %s appears to be stuck.");
msg_format(fmt, grid.get_terrain_mimic().name.data());
Expand Down
14 changes: 7 additions & 7 deletions src/action/travel-execution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ static DIRECTION travel_test(PlayerType *player_ptr, DIRECTION prev_dir)
return 0;
}

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)) {
auto &floor = *player_ptr->current_floor_ptr;
if ((disturb_trap_detect || alert_trap_detect) && player_ptr->dtrap && !(floor.grid_array[player_ptr->y][player_ptr->x].info & CAVE_IN_DETECT)) {
player_ptr->dtrap = false;
if (!(floor_ptr->grid_array[player_ptr->y][player_ptr->x].info & CAVE_UNSAFE)) {
if (!(floor.grid_array[player_ptr->y][player_ptr->x].info & CAVE_UNSAFE)) {
if (alert_trap_detect) {
msg_print(_("* 注意:この先はトラップの感知範囲外です! *", "*Leaving trap detect region!*"));
}
Expand All @@ -57,9 +57,9 @@ static DIRECTION travel_test(PlayerType *player_ptr, DIRECTION prev_dir)
for (int i = -max; i <= max; i++) {
DIRECTION dir = cycle[chome[prev_dir] + i];
const auto pos = player_ptr->get_neighbor(dir);
const auto &grid = floor_ptr->get_grid(pos);
const auto &grid = floor.get_grid(pos);
if (grid.has_monster()) {
const auto &monster = floor_ptr->m_list[grid.m_idx];
const auto &monster = floor.m_list[grid.m_idx];
if (monster.ml) {
return 0;
}
Expand All @@ -81,11 +81,11 @@ static DIRECTION travel_test(PlayerType *player_ptr, DIRECTION prev_dir)
}

const auto pos_new = player_ptr->get_neighbor(new_dir);
const auto &grid = floor_ptr->get_grid(pos_new);
if (!easy_open && is_closed_door(player_ptr, grid.feat)) {
if (!easy_open && floor.is_closed_door(pos_new)) {
return 0;
}

const auto &grid = floor.get_grid(pos_new);
if (!grid.mimic && !trap_can_be_ignored(player_ptr, grid.feat)) {
return 0;
}
Expand Down
16 changes: 8 additions & 8 deletions src/cmd-action/cmd-open-close.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,9 @@ void do_cmd_open(PlayerType *player_ptr)
}

PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU });
auto &floor = *player_ptr->current_floor_ptr;
if (easy_open) {
const auto &[num_doors, pos_door] = count_dt(player_ptr, GridCountKind::CLOSED_DOOR, false);
const auto &[num_doors, pos_door] = floor.count_doors_traps(player_ptr->get_position(), GridCountKind::CLOSED_DOOR, false);
const auto &[num_chests, pos_chest] = count_chests(player_ptr, false);
if ((num_doors > 0) || (num_chests > 0)) {
const auto pos = pos_chest == Pos2D(0, 0) ? pos_door : pos_chest;
Expand All @@ -125,7 +126,6 @@ void do_cmd_open(PlayerType *player_ptr)

int dir;
if (get_rep_dir(player_ptr, &dir, true)) {
auto &floor = *player_ptr->current_floor_ptr;
const auto pos = player_ptr->get_neighbor(dir);
const auto &grid = floor.get_grid(pos);
const auto o_idx = chest_check(&floor, pos, false);
Expand Down Expand Up @@ -159,9 +159,10 @@ void do_cmd_close(PlayerType *player_ptr)
return;
}

const auto &floor = *player_ptr->current_floor_ptr;
PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU });
if (easy_open) {
const auto &[num_doors, pos] = count_dt(player_ptr, GridCountKind::OPEN, false);
const auto &[num_doors, pos] = floor.count_doors_traps(player_ptr->get_position(), GridCountKind::OPEN, false);
if (num_doors == 1) {
command_dir = coords_to_dir(player_ptr, pos.y, pos.x);
}
Expand All @@ -177,7 +178,7 @@ void do_cmd_close(PlayerType *player_ptr)
int dir;
if (get_rep_dir(player_ptr, &dir)) {
const auto pos = player_ptr->get_neighbor(dir);
const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
const auto &grid = floor.get_grid(pos);
if (grid.get_terrain_mimic().flags.has_not(TerrainCharacteristics::CLOSE)) {
msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
} else if (grid.has_monster()) {
Expand All @@ -204,9 +205,10 @@ void do_cmd_disarm(PlayerType *player_ptr)
return;
}

auto &floor = *player_ptr->current_floor_ptr;
PlayerClass(player_ptr).break_samurai_stance({ SamuraiStanceType::MUSOU });
if (easy_disarm) {
const auto &[num_traps, pos_trap] = count_dt(player_ptr, GridCountKind::TRAP, true);
const auto &[num_traps, pos_trap] = floor.count_doors_traps(player_ptr->get_position(), GridCountKind::TRAP, true);
const auto &[num_chests, pos_chest] = count_chests(player_ptr, true);
if ((num_traps > 0) || (num_chests > 0)) {
const auto pos = pos_chest == Pos2D(0, 0) ? pos_trap : pos_chest;
Expand All @@ -226,12 +228,10 @@ void do_cmd_disarm(PlayerType *player_ptr)
int dir;
auto more = false;
if (get_rep_dir(player_ptr, &dir, true)) {
auto &floor = *player_ptr->current_floor_ptr;
const auto pos = player_ptr->get_neighbor(dir);
const auto &grid = floor.get_grid(pos);
const auto feat = grid.get_feat_mimic();
const auto o_idx = chest_check(&floor, pos, true);
if (!is_trap(player_ptr, feat) && !o_idx) {
if (!floor.is_trap(pos) && !o_idx) {
msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
} else if (grid.has_monster() && !floor.m_list[grid.m_idx].is_riding()) {
msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
Expand Down
2 changes: 1 addition & 1 deletion src/cmd-action/cmd-travel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void do_cmd_travel(PlayerType *player_ptr)
const auto &floor = *player_ptr->current_floor_ptr;
const auto &grid = floor.get_grid(pos);
const auto &terrain = grid.get_terrain();
const auto is_marked = any_bits(grid.info, CAVE_MARK);
const auto is_marked = grid.is_mark();
const auto is_wall = terrain.flags.has_any_of({ TerrainCharacteristics::WALL, TerrainCharacteristics::CAN_DIG });
const auto is_door = terrain.flags.has(TerrainCharacteristics::DOOR) && (grid.mimic > 0);
if (is_marked && (is_wall || is_door)) {
Expand Down
6 changes: 3 additions & 3 deletions src/effect/effect-feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS
}
}

if (is_trap(player_ptr, grid.feat)) {
if (floor.is_trap(pos)) {
if (known) {
msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
obvious = true;
Expand All @@ -187,7 +187,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS
cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::DISARM);
}

if (is_closed_door(player_ptr, grid.feat) && terrain.power && terrain.flags.has(TerrainCharacteristics::OPEN)) {
if (floor.is_closed_door(pos) && terrain.power && terrain.flags.has(TerrainCharacteristics::OPEN)) {
FEAT_IDX old_feat = grid.feat;
cave_alter_feat(player_ptr, y, x, TerrainCharacteristics::DISARM);
if (known && (old_feat != grid.feat)) {
Expand All @@ -206,7 +206,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS
break;
}
case AttributeType::KILL_DOOR: {
if (is_trap(player_ptr, grid.feat) || terrain.flags.has(TerrainCharacteristics::DOOR)) {
if (floor.is_trap(pos) || terrain.flags.has(TerrainCharacteristics::DOOR)) {
if (known) {
msg_print(_("まばゆい閃光が走った!", "There is a bright flash of light!"));
obvious = true;
Expand Down
2 changes: 1 addition & 1 deletion src/floor/floor-leaver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static bool check_pet_preservation_conditions(PlayerType *player_ptr, MonsterEnt

const auto should_preserve = m_ptr->is_named();
auto sight_from_player = player_ptr->current_floor_ptr->has_los(m_pos);
sight_from_player &= projectable(player_ptr, player_ptr->get_position(), m_ptr->get_position());
sight_from_player &= projectable(player_ptr, p_pos, m_pos);
auto sight_from_monster = los(player_ptr, m_ptr->fy, m_ptr->fx, player_ptr->y, player_ptr->x);
sight_from_monster &= projectable(player_ptr, m_pos, p_pos);
if (should_preserve && (sight_from_player || sight_from_monster)) {
Expand Down
2 changes: 1 addition & 1 deletion src/floor/floor-streams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void build_streamer(PlayerType *player_ptr, FEAT_IDX feat, int chance)
if (!grid.is_extra() && !grid.is_inner() && !grid.is_outer() && !grid.is_solid()) {
continue;
}
if (is_closed_door(player_ptr, grid.feat)) {
if (floor.is_closed_door(pos)) {
continue;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/floor/floor-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void update_smell(FloorType *floor_ptr, PlayerType *player_ptr)
}

auto &grid = floor_ptr->get_grid(pos);
auto update_when = !grid.cave_has_flag(TerrainCharacteristics::MOVE) && !is_closed_door(player_ptr, grid.feat);
auto update_when = !grid.cave_has_flag(TerrainCharacteristics::MOVE) && !floor_ptr->is_closed_door(pos);
update_when |= !grid.has_los();
update_when |= scent_adjust[i][j] == -1;
if (update_when) {
Expand Down
2 changes: 1 addition & 1 deletion src/floor/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,6 @@ bool is_seen(PlayerType *player_ptr, MonsterEntity *m_ptr)
auto is_inside_view = !ignore_unview;
is_inside_view |= AngbandSystem::get_instance().is_phase_out();
const auto m_pos = m_ptr->get_position();
is_inside_view |= player_can_see_bold(player_ptr, m_ptr->fy, m_ptr->fx) && projectable(player_ptr, player_ptr->get_position(), m_pos);
is_inside_view |= player_can_see_bold(player_ptr, m_pos.y, m_pos.x) && projectable(player_ptr, player_ptr->get_position(), m_pos);
return m_ptr->ml && is_inside_view;
}
26 changes: 0 additions & 26 deletions src/grid/feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,32 +104,6 @@ FEAT_IDX feat_wall_inner;
FEAT_IDX feat_wall_solid;
FEAT_IDX feat_ground_type[100], feat_wall_type[100];

/*!
* @brief 地形が罠持ちであるかの判定を行う。 / Return TRUE if the given feature is a trap
* @param feat 地形情報のID
* @return 罠持ちの地形ならばTRUEを返す。
*/
bool is_trap(PlayerType *player_ptr, FEAT_IDX feat)
{
/* 関数ポインタの都合 */
(void)player_ptr;
return TerrainList::get_instance().get_terrain(feat).flags.has(TerrainCharacteristics::TRAP);
}

/*!
* @brief 地形が閉じたドアであるかの判定を行う。 / Return TRUE if the given grid is a closed door
* @param feat 地形情報のID
* @return 閉じたドアのある地形ならばTRUEを返す。
*/
bool is_closed_door(PlayerType *player_ptr, FEAT_IDX feat)
{
/* 関数ポインタの都合 */
(void)player_ptr;
const auto &terrain = TerrainList::get_instance().get_terrain(feat);
return (terrain.flags.has(TerrainCharacteristics::OPEN) || terrain.flags.has(TerrainCharacteristics::BASH)) &&
terrain.flags.has_not(TerrainCharacteristics::MOVE);
}

/*
* Not using graphical tiles for this feature?
*/
Expand Down
2 changes: 0 additions & 2 deletions src/grid/feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ extern FEAT_IDX feat_wall_type[100];

class FloorType;
class PlayerType;
bool is_closed_door(PlayerType *player_ptr, FEAT_IDX feat);
bool is_trap(PlayerType *player_ptr, FEAT_IDX feat);
bool is_ascii_graphics(char x);
FEAT_IDX feat_locked_door_random(int door_type);
FEAT_IDX feat_jammed_door_random(int door_type);
Expand Down
43 changes: 4 additions & 39 deletions src/grid/grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
#include "player/player-status.h"
#include "room/rooms-builder.h"
#include "system/dungeon-info.h"
#include "system/enums/grid-count-kind.h"
#include "system/enums/grid-flow.h"
#include "system/floor-type-definition.h"
#include "system/grid-type-definition.h"
Expand Down Expand Up @@ -154,7 +153,7 @@ bool new_player_spot(PlayerType *player_ptr)
*/
bool is_hidden_door(PlayerType *player_ptr, const Grid &grid)
{
return (grid.mimic || grid.cave_has_flag(TerrainCharacteristics::SECRET)) && is_closed_door(player_ptr, grid.feat);
return (grid.mimic || grid.cave_has_flag(TerrainCharacteristics::SECRET)) && player_ptr->current_floor_ptr->is_closed_door(player_ptr->get_position());
}

/*!
Expand Down Expand Up @@ -691,12 +690,12 @@ void update_flow(PlayerType *player_ptr)
continue;
}

auto &grid_neighbor = floor.get_grid(pos_neighbor);
if (is_closed_door(player_ptr, grid_neighbor.feat)) {
if (floor.is_closed_door(pos_neighbor)) {
m += 3;
}

/* Ignore "pre-stamped" entries */
auto &grid_neighbor = floor.get_grid(pos_neighbor);
auto &cost_neighbor = grid_neighbor.costs.at(gf);
auto &dist_neighbor = grid_neighbor.dists.at(gf);
if ((dist_neighbor != 0) && (dist_neighbor <= n) && (cost_neighbor <= m)) {
Expand All @@ -714,7 +713,7 @@ void update_flow(PlayerType *player_ptr)
break;
}

if (!can_move && !is_closed_door(player_ptr, grid_neighbor.feat)) {
if (!can_move && !floor.is_closed_door(pos_neighbor)) {
continue;
}

Expand Down Expand Up @@ -1037,40 +1036,6 @@ void set_cave_feat(FloorType *floor_ptr, POSITION y, POSITION x, FEAT_IDX featur
floor_ptr->grid_array[y][x].feat = feature_idx;
}

/*!
* @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す
* @param player_ptr プレイヤーへの参照ポインタ
* @param gck 判定条件
* @param under TRUEならばプレイヤーの直下の座標も走査対象にする
* @return 該当する地形の数と、該当する地形の中から1つの座標
*/
std::pair<int, Pos2D> count_dt(PlayerType *player_ptr, GridCountKind gck, bool under)
{
auto count = 0;
Pos2D pos(0, 0);
const auto &floor = *player_ptr->current_floor_ptr;
for (auto d = 0; d < 9; d++) {
if ((d == 8) && !under) {
continue;
}

Pos2D pos_neighbor(player_ptr->y + ddy_ddd[d], player_ptr->x + ddx_ddd[d]);
const auto &grid = floor.get_grid(pos_neighbor);
if (!grid.is_mark()) {
continue;
}

if (!floor.check_terrain_state(pos_neighbor, gck)) {
continue;
}

++count;
pos = pos_neighbor;
}

return { count, pos };
}

/*!
* @brief マス構造体のspecial要素を利用する地形かどうかを判定する.
*/
Expand Down
2 changes: 0 additions & 2 deletions src/grid/grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "spell/spells-util.h"
#include "system/angband.h"
#include "util/point-2d.h"
#include <utility>

enum class AttributeType;
class Grid;
Expand Down Expand Up @@ -87,7 +86,6 @@ bool darkened_grid(PlayerType *player_ptr, Grid *g_ptr);
void delete_monster(PlayerType *player_ptr, POSITION y, POSITION x);
void place_bold(PlayerType *player_ptr, POSITION y, POSITION x, grid_bold_type gh_type);
void set_cave_feat(FloorType *floor_ptr, POSITION y, POSITION x, FEAT_IDX feature_idx);
std::pair<int, Pos2D> count_dt(PlayerType *player_ptr, GridCountKind gck, bool under);
void cave_lite_hack(FloorType *floor_ptr, POSITION y, POSITION x);
void cave_redraw_later(FloorType *floor_ptr, POSITION y, POSITION x);
void cave_note_and_redraw_later(FloorType *floor_ptr, POSITION y, POSITION x);
Expand Down
2 changes: 1 addition & 1 deletion src/grid/trap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ void hit_trap(PlayerType *player_ptr, bool break_trap)
break;
}

if (break_trap && is_trap(player_ptr, grid.feat)) {
if (break_trap && floor.is_trap(p_pos)) {
cave_alter_feat(player_ptr, p_pos.y, p_pos.x, TerrainCharacteristics::DISARM);
msg_print(_("トラップを粉砕した。", "You destroyed the trap."));
}
Expand Down
Loading

0 comments on commit 0c319c7

Please sign in to comment.