OSDN Git Service

[Refactor] #37353 Separated hook-weapon.c/h from object-hook.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 28 Jun 2020 06:29:12 +0000 (15:29 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 28 Jun 2020 06:29:12 +0000 (15:29 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/cmd-item/cmd-item.c
src/cmd/cmd-basic.c
src/market/building-craft-fix.c
src/market/building-craft-weapon.c
src/object-hook/hook-weapon.c [new file with mode: 0644]
src/object-hook/hook-weapon.h [new file with mode: 0644]
src/object/object-hook.c
src/object/object-hook.h

index 9bba822..8f3a2f1 100644 (file)
     <ClCompile Include="..\..\src\mind\racial-kutar.c" />\r
     <ClCompile Include="..\..\src\mind\stances-table.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-perception.c" />\r
+    <ClCompile Include="..\..\src\object-hook\hook-weapon.c" />\r
     <ClCompile Include="..\..\src\player\bad-status-setter.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-curse-removal.c" />\r
     <ClCompile Include="..\..\src\spell-kind\spells-perception.c" />\r
     <ClInclude Include="..\..\src\mspell\mspells2.h" />\r
     <ClInclude Include="..\..\src\mspell\mspells3.h" />\r
     <ClInclude Include="..\..\src\object-hook\hook-perception.h" />\r
+    <ClInclude Include="..\..\src\object-hook\hook-weapon.h" />\r
     <ClInclude Include="..\..\src\player\bad-status-setter.h" />\r
     <ClInclude Include="..\..\src\player\special-defense-types.h" />\r
     <ClInclude Include="..\..\src\spell-kind\spells-curse-removal.h" />\r
index 65b3552..88665d8 100644 (file)
     <ClCompile Include="..\..\src\object-hook\hook-perception.c">
       <Filter>object-hook</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\object-hook\hook-weapon.c">
+      <Filter>object-hook</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\object-hook\hook-perception.h">
       <Filter>object-hook</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\object-hook\hook-weapon.h">
+      <Filter>object-hook</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 9240f9d..828e2d0 100644 (file)
@@ -433,6 +433,7 @@ hengband_SOURCES = \
        object-enchant/vorpal-weapon.c object-enchant/vorpal-weapon.h \
        \
        object-hook/hook-perception.c object-hook/hook-perception.h \
+       object-hook/hook-weapon.c object-hook/hook-weapon.h \
        \
        perception/identification.c perception/identification.h \
        perception/object-perception.c perception/object-perception.h \
@@ -642,7 +643,7 @@ COMPILE = $(srcdir)/gcc-wrap $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
        -Icombat -Icore -Idungeon -Ieffect -Ifloor -Igame-option -Igrid \
        -Iinfo-reader -Iinventory -Iio -Iio-dump -Iknowledge -Imarket -Imelee \
        -Imind -Imonster -Imonster-attack -Imonster-floor -Imonster-race -Ilore \
-       -Imspell -Imutation -Iobject -Iobject-enchant -Ipet -Iplayer \
+       -Imspell -Imutation -Iobject -Iobject-enchant -Iobject-hook -Ipet -Iplayer \
        -Iplayer-attack -Irealm -Iroom -Ispecific-object -Ispell -Ispell-kind \
        -Ispell-realm -Isv-definition -Isystem -Iterm -Iutil -Iview -Iwizard -Iworld
 
index 9b69eba..bfbb60c 100644 (file)
@@ -43,6 +43,7 @@
 #include "object-enchant/object-ego.h"
 #include "object-enchant/special-object-flags.h"
 #include "object-enchant/trc-types.h"
+#include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-flavor.h"
 #include "object/object-generator.h"
index 975ff9d..9040861 100644 (file)
@@ -56,6 +56,7 @@
 #include "monster/monster-info.h"
 #include "object-enchant/special-object-flags.h"
 #include "object-enchant/tr-types.h"
+#include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-broken.h"
 #include "object/object-flags.h"
index 5bf127f..bd6a4c7 100644 (file)
@@ -9,6 +9,7 @@
 #include "object-enchant/object-boost.h"
 #include "object-enchant/special-object-flags.h"
 #include "object-enchant/tr-types.h"
+#include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-flags.h"
 #include "object/object-flavor.h"
index b7ce23a..88a28ef 100644 (file)
@@ -7,6 +7,7 @@
 #include "io/input-key-acceptor.h"
 #include "market/building-util.h"
 #include "object-enchant/tr-types.h"
+#include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-flags.h"
 #include "object/object-flavor.h"
diff --git a/src/object-hook/hook-weapon.c b/src/object-hook/hook-weapon.c
new file mode 100644 (file)
index 0000000..a38b566
--- /dev/null
@@ -0,0 +1,100 @@
+#include "object-hook/hook-weapon.h"
+#include "sv-definition/sv-weapon-types.h"
+#include "system/object-type-definition.h"
+
+/*!
+ * @brief 武器匠の「武器」鑑定対象になるかを判定する。/ Hook to specify "weapon"
+ * @param o_ptr オブジェクトの構造体の参照ポインタ。
+ * @return 対象になるならTRUEを返す。
+ */
+bool item_tester_hook_orthodox_melee_weapons(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    switch (o_ptr->tval) {
+    case TV_HAFTED:
+    case TV_POLEARM:
+    case TV_DIGGING: {
+        return TRUE;
+    }
+    case TV_SWORD: {
+        if (o_ptr->sval != SV_POISON_NEEDLE)
+            return TRUE;
+    }
+    }
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトが右手か左手に装備できる武器かどうかの判定
+ * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
+ * @return 右手か左手の武器として装備できるならばTRUEを返す。
+ */
+bool item_tester_hook_melee_weapon(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    /* Check for a usable slot */
+    if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
+ * @brief 修復対象となる壊れた武器かを判定する。 / Hook to specify "broken weapon"
+ * @param o_ptr オブジェクトの構造体の参照ポインタ。
+ * @return 修復対象になるならTRUEを返す。
+ */
+bool item_tester_hook_broken_weapon(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    if (o_ptr->tval != TV_SWORD)
+        return FALSE;
+
+    switch (o_ptr->sval) {
+    case SV_BROKEN_DAGGER:
+    case SV_BROKEN_SWORD:
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトが投射可能な武器かどうかを返す。
+ * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
+ * @return 投射可能な武器ならばTRUE
+ */
+bool item_tester_hook_boomerang(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    if ((o_ptr->tval == TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトがどちらの手にも装備できる武器かどうかの判定
+ * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
+ * @return 左右両方の手で装備できるならばTRUEを返す。
+ */
+bool item_tester_hook_mochikae(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    /* Check for a usable slot */
+    if (((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD)) || (o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CAPTURE) || (o_ptr->tval == TV_CARD))
+        return TRUE;
+
+    return FALSE;
+}
diff --git a/src/object-hook/hook-weapon.h b/src/object-hook/hook-weapon.h
new file mode 100644 (file)
index 0000000..8b6c2e2
--- /dev/null
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool item_tester_hook_orthodox_melee_weapons(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_hook_melee_weapon(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_hook_broken_weapon(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_hook_boomerang(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_hook_mochikae(player_type *player_ptr, object_type *o_ptr);
index db97336..6812c7c 100644 (file)
@@ -60,48 +60,6 @@ bool item_tester_hook_convertible(player_type *player_ptr, object_type *o_ptr)
 }
 
 /*!
- * @brief 武器匠の「武器」鑑定対象になるかを判定する。/ Hook to specify "weapon"
- * @param o_ptr オブジェクトの構造体の参照ポインタ。
- * @return 対象になるならTRUEを返す。
- */
-bool item_tester_hook_orthodox_melee_weapons(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    switch (o_ptr->tval) {
-    case TV_HAFTED:
-    case TV_POLEARM:
-    case TV_DIGGING: {
-        return TRUE;
-    }
-    case TV_SWORD: {
-        if (o_ptr->sval != SV_POISON_NEEDLE)
-            return TRUE;
-    }
-    }
-
-    return FALSE;
-}
-
-/*!
- * @brief オブジェクトが右手か左手に装備できる武器かどうかの判定
- * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
- * @return 右手か左手の武器として装備できるならばTRUEを返す。
- */
-bool item_tester_hook_melee_weapon(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    /* Check for a usable slot */
-    if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD))
-        return TRUE;
-
-    return FALSE;
-}
-
-/*!
  * @brief 武器匠の「矢弾」鑑定対象になるかを判定する。/ Hook to specify "weapon"
  * @param o_ptr オブジェクトの構造体の参照ポインタ。
  * @return 対象になるならTRUEを返す。
@@ -123,44 +81,6 @@ bool item_tester_hook_ammo(player_type *player_ptr, object_type *o_ptr)
 }
 
 /*!
- * @brief 修復対象となる壊れた武器かを判定する。 / Hook to specify "broken weapon"
- * @param o_ptr オブジェクトの構造体の参照ポインタ。
- * @return 修復対象になるならTRUEを返す。
- */
-bool item_tester_hook_broken_weapon(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    if (o_ptr->tval != TV_SWORD)
-        return FALSE;
-
-    switch (o_ptr->sval) {
-    case SV_BROKEN_DAGGER:
-    case SV_BROKEN_SWORD:
-        return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*!
- * @brief オブジェクトが投射可能な武器かどうかを返す。
- * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
- * @return 投射可能な武器ならばTRUE
- */
-bool item_tester_hook_boomerang(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    if ((o_ptr->tval == TV_DIGGING) || (o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM) || (o_ptr->tval == TV_HAFTED))
-        return TRUE;
-
-    return FALSE;
-}
-
-/*!
  * @brief オブジェクトをプレイヤーが食べることができるかを判定する /
  * Hook to determine if an object is eatable
  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
@@ -184,23 +104,6 @@ bool item_tester_hook_eatable(player_type *player_ptr, object_type *o_ptr)
 }
 
 /*!
- * @brief オブジェクトがどちらの手にも装備できる武器かどうかの判定
- * @param o_ptr 判定するオブジェクトの構造体参照ポインタ
- * @return 左右両方の手で装備できるならばTRUEを返す。
- */
-bool item_tester_hook_mochikae(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    /* Check for a usable slot */
-    if (((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD)) || (o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CAPTURE) || (o_ptr->tval == TV_CARD))
-        return TRUE;
-
-    return FALSE;
-}
-
-/*!
  * @brief オブジェクトをプレイヤーが魔道具として発動できるかを判定する /
  * Hook to determine if an object is activatable
  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
index 6c6fdf0..8b66bb2 100644 (file)
@@ -7,13 +7,8 @@ extern bool (*item_tester_hook)(player_type *, object_type *o_ptr);
 
 bool item_tester_hook_convertible(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_recharge(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_orthodox_melee_weapons(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_melee_weapon(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_ammo(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_broken_weapon(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_boomerang(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_eatable(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_mochikae(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_activate(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_wear(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_use(player_type *player_ptr, object_type *o_ptr);