OSDN Git Service

[Refactor] #37353 Separated hook-expendable.c/h from object-hook.c/h
authorHourier <hourier@users.sourceforge.jp>
Sun, 28 Jun 2020 07:54:28 +0000 (16:54 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 28 Jun 2020 07:54:28 +0000 (16:54 +0900)
16 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/autopick/autopick-destroyer.c
src/cmd-item/cmd-eat.c
src/cmd-item/cmd-item.c
src/cmd-item/cmd-quaff.c
src/cmd-item/cmd-read.c
src/cmd/cmd-basic.c
src/effect/effect-item.c
src/inventory/inventory-damage.c
src/object-hook/hook-expendable.c [new file with mode: 0644]
src/object-hook/hook-expendable.h [new file with mode: 0644]
src/object/object-hook.c
src/object/object-hook.h
src/spell/spells3.c

index ad15a27..1a59dd4 100644 (file)
     <ClCompile Include="..\..\src\mind\stances-table.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-bow.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-checker.c" />\r
+    <ClCompile Include="..\..\src\object-hook\hook-expendable.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-perception.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-weapon.c" />\r
     <ClCompile Include="..\..\src\object-hook\hook-armor.c" />\r
     <ClInclude Include="..\..\src\object-hook\hook-armor.h" />\r
     <ClInclude Include="..\..\src\object-hook\hook-bow.h" />\r
     <ClInclude Include="..\..\src\object-hook\hook-checker.h" />\r
+    <ClInclude Include="..\..\src\object-hook\hook-expendable.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
index 925aa2b..f260870 100644 (file)
     <ClCompile Include="..\..\src\object-hook\hook-checker.c">
       <Filter>object-hook</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\object-hook\hook-expendable.c">
+      <Filter>object-hook</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\cmd\cmd-basic.h">
     <ClInclude Include="..\..\src\object-hook\hook-checker.h">
       <Filter>object-hook</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\object-hook\hook-expendable.h">
+      <Filter>object-hook</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index c9207e1..33f0691 100644 (file)
@@ -435,6 +435,7 @@ hengband_SOURCES = \
        object-hook/hook-armor.c object-hook/hook-armor.h \
        object-hook/hook-bow.c object-hook/hook-bow.h \
        object-hook/hook-checker.c object-hook/hook-checker.h \
+       object-hook/hook-expendable.c object-hook/hook-expendable.h \
        object-hook/hook-perception.c object-hook/hook-perception.h \
        object-hook/hook-weapon.c object-hook/hook-weapon.h \
        \
index 5843494..c47ea30 100644 (file)
@@ -12,6 +12,7 @@
 #include "monster-race/monster-race.h"
 #include "object-enchant/object-ego.h"
 #include "object-enchant/special-object-flags.h"
+#include "object-hook/hook-expendable.h"
 #include "object-hook/hook-weapon.h"
 #include "object/object-flavor.h"
 #include "object/object-hook.h"
index 3f39f77..f618444 100644 (file)
@@ -13,6 +13,7 @@
 #include "main/sound-of-music.h"
 #include "monster-race/monster-race.h"
 #include "object-enchant/special-object-flags.h"
+#include "object-hook/hook-expendable.h"
 #include "object/item-use-flags.h"
 #include "object/object-flavor.h"
 #include "object/object-generator.h"
index bffa29f..e9a6bed 100644 (file)
@@ -45,6 +45,7 @@
 #include "object-enchant/trc-types.h"
 #include "object-hook/hook-armor.h"
 #include "object-hook/hook-checker.h"
+#include "object-hook/hook-expendable.h"
 #include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-flavor.h"
index b0b4549..3b15077 100644 (file)
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
 #include "mutation/mutation.h"
+#include "object-hook/hook-expendable.h"
 #include "object/item-use-flags.h"
-#include "perception/object-perception.h"
 #include "object/object-broken.h"
 #include "object/object-generator.h"
 #include "object/object-hook.h"
-#include "object/object-kind.h"
 #include "object/object-info.h"
-#include "sv-definition/sv-potion-types.h"
+#include "object/object-kind.h"
+#include "perception/object-perception.h"
 #include "player/avatar.h"
 #include "player/bad-status-setter.h"
 #include "player/eldritch-horror.h"
@@ -41,6 +41,7 @@
 #include "spell-realm/spells-hex.h"
 #include "spell/spells-status.h"
 #include "spell/spells3.h"
+#include "sv-definition/sv-potion-types.h"
 #include "term/screen-processor.h"
 #include "view/display-messages.h"
 
index 4ae4336..14597da 100644 (file)
@@ -17,6 +17,7 @@
 #include "main/sound-of-music.h"
 #include "monster-floor/monster-summon.h"
 #include "monster-floor/place-monster-types.h"
+#include "object-hook/hook-expendable.h"
 #include "object/item-use-flags.h"
 #include "object/object-flavor.h"
 #include "object/object-hook.h"
index d2f4f55..e906742 100644 (file)
@@ -57,6 +57,7 @@
 #include "object-enchant/special-object-flags.h"
 #include "object-enchant/tr-types.h"
 #include "object-hook/hook-checker.h"
+#include "object-hook/hook-expendable.h"
 #include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-broken.h"
index 09a5511..5fafaa4 100644 (file)
@@ -6,6 +6,7 @@
 #include "monster/monster-info.h"
 #include "object-enchant/tr-types.h"
 #include "object-hook/hook-checker.h"
+#include "object-hook/hook-expendable.h"
 #include "object/object-broken.h"
 #include "object/object-flags.h"
 #include "object/object-flavor.h"
index e596655..7aa1ca0 100644 (file)
@@ -2,6 +2,7 @@
 #include "floor/floor.h"
 #include "inventory/inventory-object.h"
 #include "mind/mind-mirror-master.h"
+#include "object-hook/hook-expendable.h"
 #include "object/object-broken.h"
 #include "object/object-flavor.h"
 #include "object/object-hook.h"
diff --git a/src/object-hook/hook-expendable.c b/src/object-hook/hook-expendable.c
new file mode 100644 (file)
index 0000000..00f2c36
--- /dev/null
@@ -0,0 +1,140 @@
+#include "object-hook/hook-expendable.h"
+#include "art-definition/art-accessory-types.h"
+#include "art-definition/art-armor-types.h"
+#include "monster-race/monster-race.h"
+#include "object-enchant/item-feeling.h"
+#include "object-enchant/special-object-flags.h"
+#include "object-hook/hook-checker.h"
+#include "object/object-hook.h"
+#include "object/object-kind.h"
+#include "perception/object-perception.h"
+#include "player/mimic-info-table.h"
+#include "sv-definition/sv-lite-types.h"
+#include "sv-definition/sv-other-types.h"
+#include "system/object-type-definition.h"
+#include "util/string-processor.h"
+
+/*!
+ * @brief オブジェクトをプレイヤーが食べることができるかを判定する /
+ * Hook to determine if an object is eatable
+ * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
+ * @return 食べることが可能ならばTRUEを返す
+ */
+bool item_tester_hook_eatable(player_type *player_ptr, object_type *o_ptr)
+{
+    if (o_ptr->tval == TV_FOOD)
+        return TRUE;
+
+    if (is_specific_player_race(player_ptr, RACE_SKELETON) || is_specific_player_race(player_ptr, RACE_GOLEM)
+        || is_specific_player_race(player_ptr, RACE_ZOMBIE) || is_specific_player_race(player_ptr, RACE_SPECTRE)) {
+        if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)
+            return TRUE;
+    } else if (is_specific_player_race(player_ptr, RACE_BALROG) || (mimic_info[player_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) {
+        if (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE && angband_strchr("pht", r_info[o_ptr->pval].d_char))
+            return TRUE;
+    }
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトをプレイヤーが飲むことができるかを判定する /
+ * Hook to determine if an object can be quaffed
+ * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
+ * @return 飲むことが可能ならばTRUEを返す
+ */
+bool item_tester_hook_quaff(player_type *player_ptr, object_type *o_ptr)
+{
+    if (o_ptr->tval == TV_POTION)
+        return TRUE;
+
+    if (is_specific_player_race(player_ptr, RACE_ANDROID) && (o_ptr->tval == TV_FLASK) && (o_ptr->sval == SV_FLASK_OIL))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトをプレイヤーが読むことができるかを判定する /
+ * Hook to determine if an object is readable
+ * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
+ * @return 読むことが可能ならばTRUEを返す
+ */
+bool item_tester_hook_readable(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    if ((o_ptr->tval == TV_SCROLL) || (o_ptr->tval == TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトがランタンの燃料になるかどうかを判定する
+ * An "item_tester_hook" for refilling lanterns
+ * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
+ * @return オブジェクトがランタンの燃料になるならばTRUEを返す
+ */
+bool item_tester_refill_lantern(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    if ((o_ptr->tval == TV_FLASK) || ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN)))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトが松明に束ねられるかどうかを判定する
+ * An "item_tester_hook" for refilling torches
+ * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
+ * @return オブジェクトが松明に束ねられるならばTRUEを返す
+ */
+bool object_can_refill_torch(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Unused */
+    (void)player_ptr;
+
+    if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
+ * @brief 破壊可能なアイテムかを返す /
+ * Determines whether an object can be destroyed, and makes fake inscription.
+ * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
+ * @return オブジェクトが破壊可能ならばTRUEを返す
+ */
+bool can_player_destroy_object(player_type *player_ptr, object_type *o_ptr)
+{
+    /* Artifacts cannot be destroyed */
+    if (!object_is_artifact(o_ptr))
+        return TRUE;
+
+    if (!object_is_known(o_ptr)) {
+        byte feel = FEEL_SPECIAL;
+        if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
+            feel = FEEL_TERRIBLE;
+
+        o_ptr->feeling = feel;
+        o_ptr->ident |= IDENT_SENSE;
+        player_ptr->update |= (PU_COMBINE);
+        player_ptr->window |= (PW_INVEN | PW_EQUIP);
+        return FALSE;
+    }
+
+    return FALSE;
+}
+
+/*!
+ * @brief オブジェクトが薬であるかを返す
+ * @param o_ptr 対象のオブジェクト構造体ポインタ
+ * @return オブジェクトが薬ならばTRUEを返す
+ */
+bool object_is_potion(object_type *o_ptr) { return (k_info[o_ptr->k_idx].tval == TV_POTION); }
diff --git a/src/object-hook/hook-expendable.h b/src/object-hook/hook-expendable.h
new file mode 100644 (file)
index 0000000..25b7444
--- /dev/null
@@ -0,0 +1,11 @@
+#pragma once
+
+#include "system/angband.h"
+
+bool item_tester_hook_eatable(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_hook_quaff(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_hook_readable(player_type *player_ptr, object_type *o_ptr);
+bool item_tester_refill_lantern(player_type *player_ptr, object_type *o_ptr);
+bool object_can_refill_torch(player_type *player_ptr, object_type *o_ptr);
+bool can_player_destroy_object(player_type *player_ptr, object_type *o_ptr);
+bool object_is_potion(object_type *o_ptr);
index 9862d6f..d3f5700 100644 (file)
 bool (*item_tester_hook)(player_type *, object_type *);
 
 /*!
- * @brief オブジェクトをプレイヤーが食べることができるかを判定する /
- * Hook to determine if an object is eatable
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return 食べることが可能ならばTRUEを返す
- */
-bool item_tester_hook_eatable(player_type *player_ptr, object_type *o_ptr)
-{
-    if (o_ptr->tval == TV_FOOD)
-        return TRUE;
-
-    if (is_specific_player_race(player_ptr, RACE_SKELETON) || is_specific_player_race(player_ptr, RACE_GOLEM) || is_specific_player_race(player_ptr, RACE_ZOMBIE)
-        || is_specific_player_race(player_ptr, RACE_SPECTRE)) {
-        if (o_ptr->tval == TV_STAFF || o_ptr->tval == TV_WAND)
-            return TRUE;
-    } else if (is_specific_player_race(player_ptr, RACE_BALROG) || (mimic_info[player_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) {
-        if (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE && angband_strchr("pht", r_info[o_ptr->pval].d_char))
-            return TRUE;
-    }
-
-    return FALSE;
-}
-
-/*!
  * @brief オブジェクトをプレイヤーが魔道具として発動できるかを判定する /
  * Hook to determine if an object is activatable
  * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
@@ -145,41 +122,6 @@ bool item_tester_hook_use(player_type *player_ptr, object_type *o_ptr)
 }
 
 /*!
- * @brief オブジェクトをプレイヤーが飲むことができるかを判定する /
- * Hook to determine if an object can be quaffed
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return 飲むことが可能ならばTRUEを返す
- */
-bool item_tester_hook_quaff(player_type *player_ptr, object_type *o_ptr)
-{
-    if (o_ptr->tval == TV_POTION)
-        return TRUE;
-
-    if (is_specific_player_race(player_ptr, RACE_ANDROID)) {
-        if (o_ptr->tval == TV_FLASK && o_ptr->sval == SV_FLASK_OIL)
-            return TRUE;
-    }
-    return FALSE;
-}
-
-/*!
- * @brief オブジェクトをプレイヤーが読むことができるかを判定する /
- * Hook to determine if an object is readable
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return 読むことが可能ならばTRUEを返す
- */
-bool item_tester_hook_readable(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    if ((o_ptr->tval == TV_SCROLL) || (o_ptr->tval == TV_PARCHMENT) || (o_ptr->name1 == ART_GHB) || (o_ptr->name1 == ART_POWER))
-        return TRUE;
-
-    return FALSE;
-}
-
-/*!
  * @brief エッセンスの付加可能な武器や矢弾かを返す
  * @param o_ptr チェックしたいオブジェクトの構造体参照ポインタ
  * @return エッセンスの付加可能な武器か矢弾ならばTRUEを返す。
@@ -305,36 +247,6 @@ bool item_tester_high_level_book(object_type *o_ptr)
 }
 
 /*!
- * @brief オブジェクトがランタンの燃料になるかどうかを判定する
- * An "item_tester_hook" for refilling lanterns
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトがランタンの燃料になるならばTRUEを返す
- */
-bool item_tester_refill_lantern(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    /* Flasks of oil are okay */
-    if (o_ptr->tval == TV_FLASK)
-        return TRUE;
-
-    /* Laterns are okay */
-    if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_LANTERN))
-        return TRUE;
-
-    /* Assume not okay */
-    return FALSE;
-}
-
-/*!
- * @brief オブジェクトが薬であるかを返す
- * @param o_ptr 対象のオブジェクト構造体ポインタ
- * @return オブジェクトが薬ならばTRUEを返す
- */
-bool object_is_potion(object_type *o_ptr) { return (k_info[o_ptr->k_idx].tval == TV_POTION); }
-
-/*!
  * @brief オブジェクトが賞金首の報酬対象になるかを返す
  * @param o_ptr 対象のオブジェクト構造体ポインタ
  * @return オブジェクトが報酬対象になるならTRUEを返す
@@ -498,60 +410,6 @@ bool object_is_nameless(player_type *player_ptr, object_type *o_ptr)
 }
 
 /*!
- * @brief オブジェクトが松明に束ねられるかどうかを判定する
- * An "item_tester_hook" for refilling torches
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトが松明に束ねられるならばTRUEを返す
- */
-bool object_can_refill_torch(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Unused */
-    (void)player_ptr;
-
-    /* Torches are okay */
-    if ((o_ptr->tval == TV_LITE) && (o_ptr->sval == SV_LITE_TORCH))
-        return TRUE;
-
-    /* Assume not okay */
-    return FALSE;
-}
-
-/*!
- * @brief 破壊可能なアイテムかを返す /
- * Determines whether an object can be destroyed, and makes fake inscription.
- * @param o_ptr 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトが破壊可能ならばTRUEを返す
- */
-bool can_player_destroy_object(player_type *player_ptr, object_type *o_ptr)
-{
-    /* Artifacts cannot be destroyed */
-    if (!object_is_artifact(o_ptr))
-        return TRUE;
-
-    /* If object is unidentified, makes fake inscription */
-    if (!object_is_known(o_ptr)) {
-        byte feel = FEEL_SPECIAL;
-
-        /* Hack -- Handle icky artifacts */
-        if (object_is_cursed(o_ptr) || object_is_broken(o_ptr))
-            feel = FEEL_TERRIBLE;
-
-        /* Hack -- inscribe the artifact */
-        o_ptr->feeling = feel;
-
-        /* We have "felt" it (again) */
-        o_ptr->ident |= (IDENT_SENSE);
-        player_ptr->update |= (PU_COMBINE);
-        player_ptr->window |= (PW_INVEN | PW_EQUIP);
-
-        return FALSE;
-    }
-
-    /* Identified artifact -- Nothing to do */
-    return FALSE;
-}
-
-/*!
  * @brief オブジェクトがクエストの達成目的か否かを返す。
  * @param o_ptr 特性短縮表記を得たいオブジェクト構造体の参照ポインタ
  * @return 現在クエスト達成目的のアイテムならばTRUEを返す。
index 043ae48..5d7c2ed 100644 (file)
@@ -6,27 +6,20 @@
 extern bool (*item_tester_hook)(player_type *, object_type *o_ptr);
 
 bool item_tester_hook_recharge(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_activate(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_use(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_quaff(player_type *player_ptr, object_type *o_ptr);
-bool item_tester_hook_readable(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_melee_ammo(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_hook_weapon_except_bow(player_type *player_ptr, object_type *o_ptr);
 
 bool item_tester_learn_spell(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_high_level_book(object_type *o_ptr);
-bool item_tester_refill_lantern(player_type *player_ptr, object_type *o_ptr);
 
-bool object_is_potion(object_type *o_ptr);
 bool object_is_bounty(player_type *player_ptr, object_type *o_ptr);
 bool object_is_rare(object_type *o_ptr);
 bool object_is_smith(player_type *player_ptr, object_type *o_ptr);
 bool object_is_artifact(object_type *o_ptr);
 bool object_is_random_artifact(object_type *o_ptr);
 bool object_is_nameless(player_type *player_ptr, object_type *o_ptr);
-bool object_can_refill_torch(player_type *player_ptr, object_type *o_ptr);
-bool can_player_destroy_object(player_type *player_ptr, object_type *o_ptr);
 bool object_is_quest_target(player_type *player_ptr, object_type *o_ptr);
 bool item_tester_okay(player_type *player_ptr, object_type *o_ptr, tval_type tval);
 bool object_is_fixed_artifact(object_type *o_ptr);
index 8665ed6..e5ac1bc 100644 (file)
@@ -66,6 +66,7 @@
 #include "object-enchant/special-object-flags.h"
 #include "object-enchant/tr-types.h"
 #include "object-enchant/trc-types.h"
+#include "object-hook/hook-expendable.h"
 #include "object-hook/hook-perception.h"
 #include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"