From 9d8b86afaa7c577625c9287d4e515e8181061e1d Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 8 Mar 2020 10:16:37 +0900 Subject: [PATCH] [Refactor] #40030 Separated monster-move.c/h from monster-process.c --- Hengband_vcs2017/Hengband/Hengband.vcxproj | 2 + Hengband_vcs2017/Hengband/Hengband.vcxproj.filters | 6 ++ src/Makefile.am | 1 + src/monster-process.c | 89 +-------------------- src/monster/monster-move.c | 91 ++++++++++++++++++++++ src/monster/monster-move.h | 7 ++ 6 files changed, 108 insertions(+), 88 deletions(-) create mode 100644 src/monster/monster-move.c create mode 100644 src/monster/monster-move.h diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj b/Hengband_vcs2017/Hengband/Hengband.vcxproj index f4b5a433c..052ae1571 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj @@ -205,6 +205,7 @@ + @@ -355,6 +356,7 @@ + diff --git a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters index 4f3ced524..5ff1405c4 100644 --- a/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters +++ b/Hengband_vcs2017/Hengband/Hengband.vcxproj.filters @@ -490,6 +490,9 @@ monster + + monster + @@ -962,6 +965,9 @@ monster + + monster + diff --git a/src/Makefile.am b/src/Makefile.am index 8fba906b3..1de119fc2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -60,6 +60,7 @@ hengband_SOURCES = \ monster.h monsterrace.c monsterrace.h \ monster/monster-util.c monster/monster-util.h \ monster/monster-attack.c monster/monster-attack.h \ + monster/monster-move.c monster/monster-move.h \ monster/monster-object.c monster/monster-object.h \ monster/quantum-effect.c monster/quantum-effect.h \ monsterrace-hook.c monsterrace-hook.h \ diff --git a/src/monster-process.c b/src/monster-process.c index 0751ebce6..40b6f00ac 100644 --- a/src/monster-process.c +++ b/src/monster-process.c @@ -17,6 +17,7 @@ #include "util.h" #include "monster/monster-attack.h" #include "monster/monster-object.h" +#include "monster/monster-move.h" #include "monster/monster-util.h" #include "monster/quantum-effect.h" @@ -38,7 +39,6 @@ #include "monster-process.h" #include "monster-dist-offsets.h" #include "monsterrace-hook.h" -#include "dungeon.h" #include "floor.h" #include "files.h" #include "view-mainwindow.h" @@ -73,8 +73,6 @@ bool process_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_t bool process_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); bool bash_normal_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); void bash_glass_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, feature_type *f_ptr, bool may_bash); -bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); -bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); bool process_monster_movement(player_type *target_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, DIRECTION *mm, POSITION oy, POSITION ox, int *count); bool process_post_dig_wall(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); @@ -1868,91 +1866,6 @@ void bash_glass_door(player_type *target_ptr, turn_flags *turn_flags_ptr, monste /*! - * @brief 守りのルーンによるモンスターの移動制限を処理する - * @param target_ptr プレーヤーへの参照ポインタ - * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ - * @param m_ptr モンスターへの参照ポインタ - * @param ny モンスターのY座標 - * @param nx モンスターのX座標 - * @return ルーンのある/なし - */ -bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx) -{ - grid_type *g_ptr; - g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx]; - monster_race *r_ptr = &r_info[m_ptr->r_idx]; - if (!turn_flags_ptr->do_move || !is_glyph_grid(g_ptr) || - (((r_ptr->flags1 & RF1_NEVER_BLOW) != 0) && player_bold(target_ptr, ny, nx))) - return FALSE; - - turn_flags_ptr->do_move = FALSE; - if (is_pet(m_ptr) || (randint1(BREAK_GLYPH) >= r_ptr->level)) - return TRUE; - - if (g_ptr->info & CAVE_MARK) - { - msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!")); - } - - g_ptr->info &= ~(CAVE_MARK); - g_ptr->info &= ~(CAVE_OBJECT); - g_ptr->mimic = 0; - turn_flags_ptr->do_move = TRUE; - note_spot(target_ptr, ny, nx); - return TRUE; -} - - -/*! - * @brief 爆発のルーンにを処理する - * @param target_ptr プレーヤーへの参照ポインタ - * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ - * @param m_ptr モンスターへの参照ポインタ - * @param ny モンスターのY座標 - * @param nx モンスターのX座標 - * @return モンスターが死亡した場合のみFALSE - */ -bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx) -{ - grid_type *g_ptr; - g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx]; - monster_race *r_ptr = &r_info[m_ptr->r_idx]; - if (!turn_flags_ptr->do_move || !is_explosive_rune_grid(g_ptr) || - (((r_ptr->flags1 & RF1_NEVER_BLOW) != 0) && player_bold(target_ptr, ny, nx))) - return TRUE; - - turn_flags_ptr->do_move = FALSE; - if (is_pet(m_ptr)) return TRUE; - - if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level) - { - if (g_ptr->info & CAVE_MARK) - { - msg_print(_("ルーンが爆発した!", "The rune explodes!")); - BIT_FLAGS project_flags = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI; - project(target_ptr, 0, 2, ny, nx, 2 * (target_ptr->lev + damroll(7, 7)), GF_MANA, project_flags, -1); - } - } - else - { - msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed.")); - } - - g_ptr->info &= ~(CAVE_MARK); - g_ptr->info &= ~(CAVE_OBJECT); - g_ptr->mimic = 0; - - note_spot(target_ptr, ny, nx); - lite_spot(target_ptr, ny, nx); - - if (!monster_is_valid(m_ptr)) return FALSE; - - turn_flags_ptr->do_move = TRUE; - return TRUE; -} - - -/*! * @brief モンスターが壁を掘った後続処理を実行する * @param target_ptr プレーヤーへの参照ポインタ * @turn_flags_ptr ターン経過処理フラグへの参照ポインタ diff --git a/src/monster/monster-move.c b/src/monster/monster-move.c new file mode 100644 index 000000000..29328065c --- /dev/null +++ b/src/monster/monster-move.c @@ -0,0 +1,91 @@ +/*! + * @brief モンスターの移動に関する処理 + * @date 2020/03/08 + * @author Hourier + */ + +#include "monster/monster-move.h" + +/*! + * @brief 守りのルーンによるモンスターの移動制限を処理する + * @param target_ptr プレーヤーへの参照ポインタ + * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ + * @param m_ptr モンスターへの参照ポインタ + * @param ny モンスターのY座標 + * @param nx モンスターのX座標 + * @return ルーンのある/なし + */ +bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx) +{ + grid_type *g_ptr; + g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx]; + monster_race *r_ptr = &r_info[m_ptr->r_idx]; + if (!turn_flags_ptr->do_move || !is_glyph_grid(g_ptr) || + (((r_ptr->flags1 & RF1_NEVER_BLOW) != 0) && player_bold(target_ptr, ny, nx))) + return FALSE; + + turn_flags_ptr->do_move = FALSE; + if (is_pet(m_ptr) || (randint1(BREAK_GLYPH) >= r_ptr->level)) + return TRUE; + + if (g_ptr->info & CAVE_MARK) + { + msg_print(_("守りのルーンが壊れた!", "The rune of protection is broken!")); + } + + g_ptr->info &= ~(CAVE_MARK); + g_ptr->info &= ~(CAVE_OBJECT); + g_ptr->mimic = 0; + turn_flags_ptr->do_move = TRUE; + note_spot(target_ptr, ny, nx); + return TRUE; +} + + +/*! + * @brief 爆発のルーンを処理する + * @param target_ptr プレーヤーへの参照ポインタ + * @param turn_flags_ptr ターン経過処理フラグへの参照ポインタ + * @param m_ptr モンスターへの参照ポインタ + * @param ny モンスターのY座標 + * @param nx モンスターのX座標 + * @return モンスターが死亡した場合のみFALSE + */ +bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx) +{ + grid_type *g_ptr; + g_ptr = &target_ptr->current_floor_ptr->grid_array[ny][nx]; + monster_race *r_ptr = &r_info[m_ptr->r_idx]; + if (!turn_flags_ptr->do_move || !is_explosive_rune_grid(g_ptr) || + (((r_ptr->flags1 & RF1_NEVER_BLOW) != 0) && player_bold(target_ptr, ny, nx))) + return TRUE; + + turn_flags_ptr->do_move = FALSE; + if (is_pet(m_ptr)) return TRUE; + + if (randint1(BREAK_MINOR_GLYPH) > r_ptr->level) + { + if (g_ptr->info & CAVE_MARK) + { + msg_print(_("ルーンが爆発した!", "The rune explodes!")); + BIT_FLAGS project_flags = PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_JUMP | PROJECT_NO_HANGEKI; + project(target_ptr, 0, 2, ny, nx, 2 * (target_ptr->lev + damroll(7, 7)), GF_MANA, project_flags, -1); + } + } + else + { + msg_print(_("爆発のルーンは解除された。", "An explosive rune was disarmed.")); + } + + g_ptr->info &= ~(CAVE_MARK); + g_ptr->info &= ~(CAVE_OBJECT); + g_ptr->mimic = 0; + + note_spot(target_ptr, ny, nx); + lite_spot(target_ptr, ny, nx); + + if (!monster_is_valid(m_ptr)) return FALSE; + + turn_flags_ptr->do_move = TRUE; + return TRUE; +} diff --git a/src/monster/monster-move.h b/src/monster/monster-move.h new file mode 100644 index 000000000..6a2ad6780 --- /dev/null +++ b/src/monster/monster-move.h @@ -0,0 +1,7 @@ +#pragma once + +#include "angband.h" +#include "monster/monster-util.h" + +bool process_protection_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); +bool process_explosive_rune(player_type *target_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, POSITION ny, POSITION nx); -- 2.11.0