OSDN Git Service

[Refactor] object_can_refill_*() を object_type のメンバ関数化
authorHabu <habu1010+github@gmail.com>
Fri, 3 Sep 2021 05:22:32 +0000 (14:22 +0900)
committerHabu <habu1010+github@gmail.com>
Fri, 3 Sep 2021 05:22:32 +0000 (14:22 +0900)
is_refill_lantern は can_refill_lantern に改名する。

src/cmd-item/cmd-refill.cpp
src/object-hook/hook-expendable.cpp
src/object-hook/hook-expendable.h
src/system/object-type-definition.cpp
src/system/object-type-definition.h

index e594c43..cd6efc7 100644 (file)
@@ -31,7 +31,7 @@ static void do_cmd_refill_lamp(player_type *user_ptr)
     object_type *j_ptr;
     concptr q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
     concptr s = _("油つぼがない。", "You have no flasks of oil.");
-    o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, FuncItemTester(object_is_refill_lantern));
+    o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, FuncItemTester(&object_type::can_refill_lantern));
     if (!o_ptr)
         return;
 
@@ -69,7 +69,7 @@ static void do_cmd_refill_torch(player_type *user_ptr)
     object_type *j_ptr;
     concptr q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
     concptr s = _("他に松明がない。", "You have no extra torches.");
-    o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, FuncItemTester(object_can_refill_torch));
+    o_ptr = choose_object(user_ptr, &item, q, s, USE_INVEN | USE_FLOOR, FuncItemTester(&object_type::can_refill_torch));
     if (!o_ptr)
         return;
 
index 7b0b928..1e0dcf3 100644 (file)
@@ -58,34 +58,6 @@ bool item_tester_hook_quaff(player_type *player_ptr, const object_type *o_ptr)
 }
 
 /*!
- * @brief オブジェクトがランタンの燃料になるかどうかを判定する
- * An "item_tester_hook" for refilling lanterns
- * @param o_ptr 判定したいオブジェクトの構造体参照ポインタ
- * @return オブジェクトがランタンの燃料になるならばTRUEを返す
- */
-bool object_is_refill_lantern(const object_type *o_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(const object_type *o_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 破壊可能かを確認したいオブジェクトの構造体参照ポインタ
index c11b585..52ebd2f 100644 (file)
@@ -4,6 +4,4 @@ typedef struct object_type object_type;
 typedef struct player_type player_type;
 bool item_tester_hook_eatable(player_type *player_ptr, const object_type *o_ptr);
 bool item_tester_hook_quaff(player_type *player_ptr, const object_type *o_ptr);
-bool object_is_refill_lantern(const object_type *o_ptr);
-bool object_can_refill_torch(const object_type *o_ptr);
 bool can_player_destroy_object(player_type *player_ptr, object_type *o_ptr);
index b817745..7fbe44a 100644 (file)
@@ -13,6 +13,7 @@
 #include "object-enchant/trg-types.h"
 #include "object/object-kind.h"
 #include "sv-definition/sv-armor-types.h"
+#include "sv-definition/sv-lite-types.h"
 #include "sv-definition/sv-other-types.h"
 #include "sv-definition/sv-protector-types.h"
 #include "sv-definition/sv-weapon-types.h"
@@ -503,3 +504,23 @@ bool object_type::is_readable() const
 {
     return (this->tval == TV_SCROLL) || (this->tval == TV_PARCHMENT) || (this->name1 == ART_GHB) || (this->name1 == ART_POWER);
 }
+
+/*!
+ * @brief オブジェクトがランタンの燃料になるかどうかを判定する
+ * An "item_tester_hook" for refilling lanterns
+ * @return オブジェクトがランタンの燃料になるならばTRUEを返す
+ */
+bool object_type::can_refill_lantern() const
+{
+    return (this->tval == TV_FLASK) || ((this->tval == TV_LITE) && (this->sval == SV_LITE_LANTERN));
+}
+
+/*!
+ * @brief オブジェクトが松明に束ねられるかどうかを判定する
+ * An "item_tester_hook" for refilling torches
+ * @return オブジェクトが松明に束ねられるならばTRUEを返す
+ */
+bool object_type::can_refill_torch() const
+{
+    return (this->tval == TV_LITE) && (this->sval == SV_LITE_TORCH);
+}
index 5d72000..805d413 100644 (file)
@@ -93,4 +93,6 @@ typedef struct object_type {
     bool is_tried() const;
     bool is_potion() const;
     bool is_readable() const;
+    bool can_refill_lantern() const;
+    bool can_refill_torch() const;
 } object_type;