OSDN Git Service

[Refactor] #40535 Separated tunnel-execution.c/h from cmd-basic.c
authorHourier <hourier@users.sourceforge.jp>
Sat, 11 Jul 2020 12:30:31 +0000 (21:30 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 11 Jul 2020 12:30:31 +0000 (21:30 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/action/tunnel-execution.c [new file with mode: 0644]
src/action/tunnel-execution.h [new file with mode: 0644]
src/cmd/cmd-basic.c

index ee3d6cf..e6ba826 100644 (file)
     <ClCompile Include="..\..\src\action\action-limited.c" />\r
     <ClCompile Include="..\..\src\action\open-close-execution.c" />\r
     <ClCompile Include="..\..\src\action\open-util.c" />\r
+    <ClCompile Include="..\..\src\action\tunnel-execution.c" />\r
     <ClCompile Include="..\..\src\birth\auto-roller.c" />\r
     <ClCompile Include="..\..\src\birth\birth-body-spec.c" />\r
     <ClCompile Include="..\..\src\birth\birth-select-class.c" />\r
     <ClInclude Include="..\..\src\action\action-limited.h" />\r
     <ClInclude Include="..\..\src\action\open-close-execution.h" />\r
     <ClInclude Include="..\..\src\action\open-util.h" />\r
+    <ClInclude Include="..\..\src\action\tunnel-execution.h" />\r
     <ClInclude Include="..\..\src\art-definition\art-accessory-types.h" />\r
     <ClInclude Include="..\..\src\art-definition\art-armor-types.h" />\r
     <ClInclude Include="..\..\src\art-definition\art-bow-types.h" />\r
index 5526491..97a9aa0 100644 (file)
     <ClCompile Include="..\..\src\action\open-close-execution.c">
       <Filter>action</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\action\tunnel-execution.c">
+      <Filter>action</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\action\open-close-execution.h">
       <Filter>action</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\action\tunnel-execution.h">
+      <Filter>action</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 2798764..72c2517 100644 (file)
@@ -8,7 +8,7 @@ hengband_SOURCES = \
        action/action-limited.c action/action-limited.h \
        action/open-util.c action/open-util.h \
        action/open-close-execution.c action/open-close-execution.h \
-       cmd-action/cmd-open-close.c cmd-action/cmd-open-close.h \
+       action/tunnel-execution.c action/tunnel-execution.h \
        \
        art-definition/art-accessory-types.h \
        art-definition/art-armor-types.h \
@@ -65,6 +65,7 @@ hengband_SOURCES = \
        cmd-action/cmd-hissatsu.c cmd-action/cmd-hissatsu.h \
        cmd-action/cmd-mane.c cmd-action/cmd-mane.h \
        cmd-action/cmd-move.c cmd-action/cmd-move.h \
+       cmd-action/cmd-open-close.c cmd-action/cmd-open-close.h \
        cmd-action/cmd-pet.c cmd-action/cmd-pet.h \
        cmd-action/cmd-spell.c cmd-action/cmd-spell.h \
        \
diff --git a/src/action/tunnel-execution.c b/src/action/tunnel-execution.c
new file mode 100644 (file)
index 0000000..eb28dbf
--- /dev/null
@@ -0,0 +1,111 @@
+#include "action/tunnel-execution.h"
+#include "core/player-update-types.h"
+#include "floor/floor.h"
+#include "grid/feature.h"
+#include "grid/grid.h"
+#include "main/sound-definitions-table.h"
+#include "main/sound-of-music.h"
+#include "player/avatar.h"
+#include "player/player-move.h"
+#include "util/bit-flags-calculator.h"
+#include "view/display-messages.h"
+
+/*!
+ * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
+ * Determine if a given grid may be "tunneled"
+ * @param y 対象を行うマスのY座標
+ * @param x 対象を行うマスのX座標
+ * @return
+ */
+static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+    if (!(g_ptr->info & CAVE_MARK)) {
+        msg_print(_("そこには何も見当たらない。", "You see nothing there."));
+        return FALSE;
+    }
+
+    if (!cave_have_flag_grid(g_ptr, FF_TUNNEL)) {
+        msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
+        return FALSE;
+    }
+
+    return TRUE;
+}
+
+/*!
+ * @brief 「掘る」動作コマンドのサブルーチン /
+ * Perform the basic "tunnel" command
+ * @param y 対象を行うマスのY座標
+ * @param x 対象を行うマスのX座標
+ * @return 実際に処理が行われた場合TRUEを返す。
+ * @details
+ * Assumes that no monster is blocking the destination
+ * Do not use twall anymore
+ * Returns TRUE if repeated commands may continue
+ */
+bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
+{
+    grid_type *g_ptr;
+    feature_type *f_ptr, *mimic_f_ptr;
+    int power;
+    concptr name;
+    bool more = FALSE;
+    if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x))
+        return FALSE;
+
+    take_turn(creature_ptr, 100);
+    g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
+    f_ptr = &f_info[g_ptr->feat];
+    power = f_ptr->power;
+    mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
+    name = f_name + mimic_f_ptr->name;
+    sound(SOUND_DIG);
+    if (have_flag(f_ptr->flags, FF_PERMANENT)) {
+        if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
+            msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
+        else
+            msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
+    } else if (have_flag(f_ptr->flags, FF_CAN_DIG)) {
+        if (creature_ptr->skill_dig > randint0(20 * power)) {
+            msg_format(_("%sをくずした。", "You have removed the %s."), name);
+            cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
+            creature_ptr->update |= PU_FLOW;
+        } else {
+            msg_format(_("%sをくずしている。", "You dig into the %s."), name);
+            more = TRUE;
+        }
+    } else {
+        bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
+        if (creature_ptr->skill_dig > power + randint0(40 * power)) {
+            if (tree)
+                msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
+            else {
+                msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
+                creature_ptr->update |= (PU_FLOW);
+            }
+
+            if (have_flag(f_ptr->flags, FF_GLASS))
+                sound(SOUND_GLASS);
+
+            cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
+            chg_virtue(creature_ptr, V_DILIGENCE, 1);
+            chg_virtue(creature_ptr, V_NATURE, -1);
+        } else {
+            if (tree) {
+                msg_format(_("%sを切っている。", "You chop away at the %s."), name);
+                if (randint0(100) < 25)
+                    search(creature_ptr);
+            } else {
+                msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
+            }
+
+            more = TRUE;
+        }
+    }
+
+    if (is_hidden_door(creature_ptr, g_ptr) && (randint0(100) < 25))
+        search(creature_ptr);
+
+    return more;
+}
diff --git a/src/action/tunnel-execution.h b/src/action/tunnel-execution.h
new file mode 100644 (file)
index 0000000..aa689e0
--- /dev/null
@@ -0,0 +1,5 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x);
index 0c53d59..07dcf0b 100644 (file)
@@ -12,6 +12,7 @@
 #include "cmd/cmd-basic.h"
 #include "action/action-limited.h"
 #include "action/open-close-execution.h"
+#include "action/tunnel-execution.h"
 #include "action/open-util.h"
 #include "art-definition/art-weapon-types.h"
 #include "cmd-action/cmd-attack.h"
@@ -118,106 +119,6 @@ void do_cmd_search(player_type *creature_ptr)
 }
 
 /*!
- * @brief 「掘る」コマンドを該当のマスに行えるかの判定と結果メッセージの表示 /
- * Determine if a given grid may be "tunneled"
- * @param y 対象を行うマスのY座標
- * @param x 対象を行うマスのX座標
- * @return
- */
-static bool do_cmd_tunnel_test(floor_type *floor_ptr, POSITION y, POSITION x)
-{
-    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-    if (!(g_ptr->info & CAVE_MARK)) {
-        msg_print(_("そこには何も見当たらない。", "You see nothing there."));
-        return FALSE;
-    }
-
-    if (!cave_have_flag_grid(g_ptr, FF_TUNNEL)) {
-        msg_print(_("そこには掘るものが見当たらない。", "You see nothing there to tunnel."));
-        return FALSE;
-    }
-
-    return TRUE;
-}
-
-/*!
- * @brief 「掘る」動作コマンドのサブルーチン /
- * Perform the basic "tunnel" command
- * @param y 対象を行うマスのY座標
- * @param x 対象を行うマスのX座標
- * @return 実際に処理が行われた場合TRUEを返す。
- * @details
- * Assumes that no monster is blocking the destination
- * Do not use twall anymore
- * Returns TRUE if repeated commands may continue
- */
-static bool exe_tunnel(player_type *creature_ptr, POSITION y, POSITION x)
-{
-    grid_type *g_ptr;
-    feature_type *f_ptr, *mimic_f_ptr;
-    int power;
-    concptr name;
-    bool more = FALSE;
-    if (!do_cmd_tunnel_test(creature_ptr->current_floor_ptr, y, x))
-        return FALSE;
-
-    take_turn(creature_ptr, 100);
-    g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
-    f_ptr = &f_info[g_ptr->feat];
-    power = f_ptr->power;
-    mimic_f_ptr = &f_info[get_feat_mimic(g_ptr)];
-    name = f_name + mimic_f_ptr->name;
-    sound(SOUND_DIG);
-    if (have_flag(f_ptr->flags, FF_PERMANENT)) {
-        if (have_flag(mimic_f_ptr->flags, FF_PERMANENT))
-            msg_print(_("この岩は硬すぎて掘れないようだ。", "This seems to be permanent rock."));
-        else
-            msg_print(_("そこは掘れない!", "You can't tunnel through that!"));
-    } else if (have_flag(f_ptr->flags, FF_CAN_DIG)) {
-        if (creature_ptr->skill_dig > randint0(20 * power)) {
-            msg_format(_("%sをくずした。", "You have removed the %s."), name);
-            cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
-            creature_ptr->update |= (PU_FLOW);
-        } else {
-            msg_format(_("%sをくずしている。", "You dig into the %s."), name);
-            more = TRUE;
-        }
-    } else {
-        bool tree = have_flag(mimic_f_ptr->flags, FF_TREE);
-        if (creature_ptr->skill_dig > power + randint0(40 * power)) {
-            if (tree)
-                msg_format(_("%sを切り払った。", "You have cleared away the %s."), name);
-            else {
-                msg_print(_("穴を掘り終えた。", "You have finished the tunnel."));
-                creature_ptr->update |= (PU_FLOW);
-            }
-
-            if (have_flag(f_ptr->flags, FF_GLASS))
-                sound(SOUND_GLASS);
-
-            cave_alter_feat(creature_ptr, y, x, FF_TUNNEL);
-            chg_virtue(creature_ptr, V_DILIGENCE, 1);
-            chg_virtue(creature_ptr, V_NATURE, -1);
-        } else {
-            if (tree) {
-                msg_format(_("%sを切っている。", "You chop away at the %s."), name);
-                if (randint0(100) < 25)
-                    search(creature_ptr);
-            } else {
-                msg_format(_("%sに穴を掘っている。", "You tunnel into the %s."), name);
-            }
-
-            more = TRUE;
-        }
-    }
-
-    if (is_hidden_door(creature_ptr, g_ptr) && (randint0(100) < 25))
-        search(creature_ptr);
-
-    return more;
-}
-
-/*!
  * @brief 「掘る」動作コマンドのメインルーチン /
  * Tunnels through "walls" (including rubble and closed doors)
  * @return なし