OSDN Git Service

[Refactor] player_type::tval_ammo を tval_type 型にする
authorHabu <habu1010+github@gmail.com>
Thu, 26 Aug 2021 13:36:04 +0000 (22:36 +0900)
committerHabu <habu1010+github@gmail.com>
Fri, 27 Aug 2021 14:44:14 +0000 (23:44 +0900)
byte型ではなくtval_type型が正しい。
合わせて bow_tval_ammo の戻り値の型も tval_type にする。

src/cmd-action/cmd-shoot.cpp
src/player/player-status.cpp
src/specific-object/bow.cpp
src/specific-object/bow.h
src/system/player-type-definition.h

index 7a138b8..28902c4 100644 (file)
@@ -53,7 +53,7 @@ void do_cmd_fire(player_type *creature_ptr, SPELL_IDX snipe_type)
 
     concptr q = _("どれを撃ちますか? ", "Fire which item? ");
     concptr s = _("発射されるアイテムがありません。", "You have nothing to fire.");
-    ammo_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, static_cast<tval_type>(creature_ptr->tval_ammo));
+    ammo_ptr = choose_object(creature_ptr, &item, q, s, USE_INVEN | USE_FLOOR, creature_ptr->tval_ammo);
     if (!ammo_ptr) {
         flush();
         return;
index f125036..c7ee922 100644 (file)
@@ -372,7 +372,7 @@ static void update_bonuses(player_type *creature_ptr)
 
     o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
     if (o_ptr->k_idx) {
-        creature_ptr->tval_ammo = (byte)bow_tval_ammo(o_ptr);
+        creature_ptr->tval_ammo = bow_tval_ammo(o_ptr);
         creature_ptr->num_fire = calc_num_fire(creature_ptr, o_ptr);
     }
 
@@ -1019,7 +1019,7 @@ int16_t calc_num_fire(player_type *creature_ptr, object_type *o_ptr)
     if (is_heavy_shoot(creature_ptr, o_ptr))
         return (int16_t)num;
 
-    tval_type tval_ammo = static_cast<tval_type>(bow_tval_ammo(o_ptr));
+    tval_type tval_ammo = bow_tval_ammo(o_ptr);
     if ((creature_ptr->pclass == CLASS_RANGER) && (tval_ammo == TV_ARROW)) {
         num += (creature_ptr->lev * 4);
     }
index 11783c7..30844cb 100644 (file)
@@ -7,7 +7,7 @@
  * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
  * @return 対応する矢/弾薬のベースアイテムID
  */
-int bow_tval_ammo(object_type *o_ptr)
+tval_type bow_tval_ammo(object_type *o_ptr)
 {
     switch (o_ptr->sval) {
     case SV_SLING: {
@@ -30,5 +30,5 @@ int bow_tval_ammo(object_type *o_ptr)
     }
     }
 
-    return 0;
+    return TV_NONE;
 }
index 78b5842..6b80ef1 100644 (file)
@@ -1,4 +1,6 @@
 #pragma once
 
+#include "object/tval-types.h"
+
 typedef struct object_type object_type;
-int bow_tval_ammo(object_type *o_ptr);
+tval_type bow_tval_ammo(object_type *o_ptr);
index 63433b3..c421d75 100644 (file)
@@ -2,6 +2,7 @@
 
 #include "mutation/mutation-flag-types.h"
 #include "object-enchant/trc-types.h"
+#include "object/tval-types.h"
 #include "player-ability/player-ability-types.h"
 #include "player/player-class-types.h"
 #include "player/player-personality-types.h"
@@ -410,7 +411,7 @@ typedef struct player_type {
     int16_t num_fire{}; /* Number of shots */
 
     byte tval_xtra{}; /* (Unused)Correct xtra tval */
-    byte tval_ammo{}; /* Correct ammo tval */
+    tval_type tval_ammo{}; /* Correct ammo tval */
 
     int16_t pspeed{}; /*!< 現在の速度 / Current speed */