OSDN Git Service

[Refactor] #40634 Separated activation-charm.c/h from activation-switcher.c
authorHourier <hourier@users.sourceforge.jp>
Wed, 19 Aug 2020 02:54:55 +0000 (11:54 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 19 Aug 2020 02:54:55 +0000 (11:54 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/object-activation/activation-charm.c [new file with mode: 0644]
src/object-activation/activation-charm.h [new file with mode: 0644]
src/object-activation/activation-switcher.c

index 2f77de2..7aec0c5 100644 (file)
     <ClCompile Include="..\..\src\mutation\mutation-investor-remover.c" />\r
     <ClCompile Include="..\..\src\object-activation\activation-bolt-ball.c" />\r
     <ClCompile Include="..\..\src\object-activation\activation-breath.c" />\r
+    <ClCompile Include="..\..\src\object-activation\activation-charm.c" />\r
     <ClCompile Include="..\..\src\object-use\read-execution.c" />\r
     <ClCompile Include="..\..\src\player\player-status-flags.c" />\r
     <ClCompile Include="..\..\src\player\player-status-table.c" />\r
     <ClInclude Include="..\..\src\mutation\mutation-investor-remover.h" />\r
     <ClInclude Include="..\..\src\object-activation\activation-bolt-ball.h" />\r
     <ClInclude Include="..\..\src\object-activation\activation-breath.h" />\r
+    <ClInclude Include="..\..\src\object-activation\activation-charm.h" />\r
     <ClInclude Include="..\..\src\object-use\read-execution.h" />\r
     <ClInclude Include="..\..\src\player\player-status-flags.h" />\r
     <ClInclude Include="..\..\src\player\player-status-table.h" />\r
index d4eb41f..58c3f38 100644 (file)
     <ClCompile Include="..\..\src\object-activation\activation-bolt-ball.c">
       <Filter>object-activation</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\object-activation\activation-charm.c">
+      <Filter>object-activation</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\object-activation\activation-bolt-ball.h">
       <Filter>object-activation</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\object-activation\activation-charm.h">
+      <Filter>object-activation</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ac7afa0..cbca0bd 100644 (file)
@@ -540,6 +540,7 @@ hengband_SOURCES = \
        \
        object-activation/activation-bolt-ball.c object-activation/activation-bolt-ball.h \
        object-activation/activation-breath.c object-activation/activation-breath.h \
+       object-activation/activation-charm.c object-activation/activation-charm.h \
        object-activation/activation-switcher.c object-activation/activation-switcher.h \
        \
        object-enchant/activation-info-table.c object-enchant/activation-info-table.h \
diff --git a/src/object-activation/activation-charm.c b/src/object-activation/activation-charm.c
new file mode 100644 (file)
index 0000000..9f8e903
--- /dev/null
@@ -0,0 +1,46 @@
+#include "object-activation/activation-charm.h"
+#include "spell-kind/spells-charm.h"
+#include "spell-kind/spells-sight.h"
+#include "target/target-getter.h"
+
+bool activate_charm_animal(player_type *user_ptr)
+{
+    DIRECTION dir;
+    if (!get_aim_dir(user_ptr, &dir))
+        return FALSE;
+
+    (void)charm_animal(user_ptr, dir, user_ptr->lev);
+    return TRUE;
+}
+
+bool activate_charm_undead(player_type *user_ptr)
+{
+    DIRECTION dir;
+    if (!get_aim_dir(user_ptr, &dir))
+        return FALSE;
+
+    (void)control_one_undead(user_ptr, dir, user_ptr->lev);
+    return TRUE;
+}
+
+bool activate_charm_other(player_type *user_ptr)
+{
+    DIRECTION dir;
+    if (!get_aim_dir(user_ptr, &dir))
+        return FALSE;
+
+    (void)charm_monster(user_ptr, dir, user_ptr->lev * 2);
+    return TRUE;
+}
+
+bool activate_charm_animals(player_type *user_ptr)
+{
+    (void)charm_animals(user_ptr, user_ptr->lev * 2);
+    return TRUE;
+}
+
+bool activate_charm_others(player_type *user_ptr)
+{
+    (void)charm_monsters(user_ptr, user_ptr->lev * 2);
+    return TRUE;
+}
diff --git a/src/object-activation/activation-charm.h b/src/object-activation/activation-charm.h
new file mode 100644 (file)
index 0000000..a5b97dd
--- /dev/null
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool activate_charm_animal(player_type *user_ptr);
+bool activate_charm_undead(player_type *user_ptr);
+bool activate_charm_other(player_type *user_ptr);
+bool activate_charm_animals(player_type *user_ptr);
+bool activate_charm_others(player_type *user_ptr);
index 57f4947..c97a229 100644 (file)
@@ -40,6 +40,7 @@
 #include "monster/smart-learn-types.h"
 #include "object-activation/activation-bolt-ball.h"
 #include "object-activation/activation-breath.h"
+#include "object-activation/activation-charm.h"
 #include "object-enchant/activation-info-table.h"
 #include "object-enchant/dragon-breaths-table.h"
 #include "object-enchant/object-ego.h"
@@ -330,29 +331,15 @@ bool switch_activation(player_type *user_ptr, object_type *o_ptr, const activati
     case ACT_AGGRAVATE:
         return activate_aggravation(user_ptr, o_ptr, name);
     case ACT_CHARM_ANIMAL:
-        if (!get_aim_dir(user_ptr, &dir))
-            return FALSE;
-
-        (void)charm_animal(user_ptr, dir, user_ptr->lev);
-        return TRUE;
+        return activate_charm_animal(user_ptr);
     case ACT_CHARM_UNDEAD:
-        if (!get_aim_dir(user_ptr, &dir))
-            return FALSE;
-
-        (void)control_one_undead(user_ptr, dir, user_ptr->lev);
-        return TRUE;
+        return activate_charm_undead(user_ptr);
     case ACT_CHARM_OTHER:
-        if (!get_aim_dir(user_ptr, &dir))
-            return FALSE;
-
-        (void)charm_monster(user_ptr, dir, user_ptr->lev * 2);
-        return TRUE;
+        return activate_charm_other(user_ptr);
     case ACT_CHARM_ANIMALS:
-        (void)charm_animals(user_ptr, user_ptr->lev * 2);
-        return TRUE;
+        return activate_charm_animals(user_ptr);
     case ACT_CHARM_OTHERS:
-        (void)charm_monsters(user_ptr, user_ptr->lev * 2);
-        return TRUE;
+        return activate_charm_others(user_ptr);
     case ACT_SUMMON_ANIMAL:
         (void)summon_specific(user_ptr, -1, user_ptr->y, user_ptr->x, user_ptr->lev, SUMMON_ANIMAL_RANGER, (PM_ALLOW_GROUP | PM_FORCE_PET));
         return TRUE;