OSDN Git Service

[Refactor] #2797 BaseitemInfo::tval とBaseitemInfo::sval をBaseitemInfo::bi_key に差し替えた
authorHourier <66951241+Hourier@users.noreply.github.com>
Tue, 15 Nov 2022 10:31:10 +0000 (19:31 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Tue, 15 Nov 2022 11:19:46 +0000 (20:19 +0900)
17 files changed:
src/flavor/object-flavor.cpp
src/info-reader/baseitem-reader.cpp
src/io/interpret-pref-file.cpp
src/knowledge/knowledge-experiences.cpp
src/knowledge/knowledge-items.cpp
src/load/old/item-loader-savefile50.cpp
src/market/building-craft-fix.cpp
src/object/object-broken.cpp
src/object/object-kind-hook.cpp
src/spell/spells-object.cpp
src/system/baseitem-info-definition.cpp
src/system/baseitem-info-definition.h
src/system/object-type-definition.cpp
src/wizard/items-spoiler.cpp
src/wizard/wizard-item-modifier.cpp
src/wizard/wizard-special-process.cpp
src/world/world-object.cpp

index 20d91e8..2bc43d1 100644 (file)
@@ -55,7 +55,7 @@
 static bool object_easy_know(int i)
 {
     auto *k_ptr = &baseitems_info[i];
-    switch (k_ptr->tval) {
+    switch (k_ptr->bi_key.tval()) {
     case ItemKindType::LIFE_BOOK:
     case ItemKindType::SORCERY_BOOK:
     case ItemKindType::NATURE_BOOK:
@@ -192,7 +192,7 @@ static void shuffle_flavors(ItemKindType tval)
 {
     std::vector<std::reference_wrapper<IDX>> flavor_idx_ref_list;
     for (const auto &k_ref : baseitems_info) {
-        if (k_ref.tval != tval) {
+        if (k_ref.bi_key.tval() != tval) {
             continue;
         }
 
index 55bc93a..ac09e40 100644 (file)
@@ -14,6 +14,7 @@
 #include "system/baseitem-info-definition.h"
 #include "term/gameterm.h"
 #include "util/bit-flags-calculator.h"
+#include "util/enum-converter.h"
 #include "util/string-processor.h"
 #include "view/display-messages.h"
 
@@ -124,8 +125,10 @@ errr parse_baseitems_info(std::string_view buf, angband_header *head)
             return PARSE_ERROR_TOO_FEW_ARGUMENTS;
         }
 
-        info_set_value(k_ptr->tval, tokens[1]);
-        info_set_value(k_ptr->sval, tokens[2]);
+        constexpr auto base = 10;
+        const auto tval = i2enum<ItemKindType>(std::stoi(tokens[1], nullptr, base));
+        const auto sval = std::stoi(tokens[2], nullptr, base);
+        k_ptr->bi_key = { tval, sval };
         info_set_value(k_ptr->pval, tokens[3]);
     } else if (tokens[0] == "W") {
         // W:level:weight:cost
index 77c83b9..ac99e92 100644 (file)
@@ -208,11 +208,11 @@ static errr interpret_u_token(char *buf)
         return 1;
     }
 
-    int j = (int)strtol(zz[0], nullptr, 0);
+    const auto tval = i2enum<ItemKindType>(strtol(zz[0], nullptr, 0));
     TERM_COLOR n1 = (TERM_COLOR)strtol(zz[1], nullptr, 0);
     auto n2 = static_cast<char>(strtol(zz[2], nullptr, 0));
     for (auto &k_ref : baseitems_info) {
-        if ((k_ref.idx > 0) && (enum2i(k_ref.tval) == j)) {
+        if ((k_ref.idx > 0) && (k_ref.bi_key.tval() == tval)) {
             if (n1) {
                 k_ref.d_attr = n1;
             }
index 2f86c8d..0c5bd12 100644 (file)
@@ -34,11 +34,14 @@ void do_cmd_knowledge_weapon_exp(PlayerType *player_ptr)
 
     for (auto tval : { ItemKindType::SWORD, ItemKindType::POLEARM, ItemKindType::HAFTED, ItemKindType::DIGGING, ItemKindType::BOW }) {
         for (int num = 0; num < 64; num++) {
+            BaseitemKey bi_key(tval, num);
             for (const auto &k_ref : baseitems_info) {
-                if ((k_ref.tval != tval) || (k_ref.sval != num)) {
+                if (k_ref.bi_key != bi_key) {
                     continue;
                 }
-                if ((k_ref.tval == ItemKindType::BOW) && (k_ref.sval == SV_CRIMSON || k_ref.sval == SV_HARP)) {
+
+                const auto sval = k_ref.bi_key.sval();
+                if ((k_ref.bi_key.tval() == ItemKindType::BOW) && (sval == SV_CRIMSON || sval == SV_HARP)) {
                     continue;
                 }
 
index 58f79f5..8bc9653 100644 (file)
@@ -152,13 +152,14 @@ static KIND_OBJECT_IDX collect_objects(int grp_cur, KIND_OBJECT_IDX object_idx[]
             }
         }
 
+        const auto tval = k_ref.bi_key.tval();
         if (group_tval == ItemKindType::LIFE_BOOK) {
-            if (ItemKindType::LIFE_BOOK <= k_ref.tval && k_ref.tval <= ItemKindType::HEX_BOOK) {
+            if (ItemKindType::LIFE_BOOK <= tval && tval <= ItemKindType::HEX_BOOK) {
                 object_idx[object_cnt++] = k_ref.idx;
             } else {
                 continue;
             }
-        } else if (k_ref.tval == group_tval) {
+        } else if (tval == group_tval) {
             object_idx[object_cnt++] = k_ref.idx;
         } else {
             continue;
index 3a62572..2ba5b02 100644 (file)
@@ -35,8 +35,8 @@ void ItemLoader50::rd_item(ObjectType *o_ptr)
     o_ptr->iy = rd_byte();
     o_ptr->ix = rd_byte();
     auto *k_ptr = &baseitems_info[o_ptr->k_idx];
-    o_ptr->tval = k_ptr->tval;
-    o_ptr->sval = k_ptr->sval;
+    o_ptr->tval = k_ptr->bi_key.tval();
+    o_ptr->sval = k_ptr->bi_key.sval().value();
     o_ptr->pval = any_bits(flags, SaveDataItemFlagType::PVAL) ? rd_s16b() : 0;
     o_ptr->discount = any_bits(flags, SaveDataItemFlagType::DISCOUNT) ? rd_byte() : 0;
     o_ptr->number = any_bits(flags, SaveDataItemFlagType::NUMBER) ? rd_byte() : 1;
index b210417..c0e3c06 100644 (file)
@@ -157,12 +157,15 @@ static PRICE repair_broken_weapon_aux(PlayerType *player_ptr, PRICE bcost)
         int n = 1;
         k_idx = 0;
         for (const auto &k_ref : baseitems_info) {
-            if (k_ref.tval != ItemKindType::SWORD) {
+            if (k_ref.bi_key.tval() != ItemKindType::SWORD) {
                 continue;
             }
-            if ((k_ref.sval == SV_BROKEN_DAGGER) || (k_ref.sval == SV_BROKEN_SWORD) || (k_ref.sval == SV_POISON_NEEDLE)) {
+
+            const auto sval = k_ref.bi_key.sval();
+            if ((sval == SV_BROKEN_DAGGER) || (sval == SV_BROKEN_SWORD) || (sval == SV_POISON_NEEDLE)) {
                 continue;
             }
+
             if (k_ref.weight > 99) {
                 continue;
             }
@@ -175,22 +178,23 @@ static PRICE repair_broken_weapon_aux(PlayerType *player_ptr, PRICE bcost)
     } else {
         auto tval = (one_in_(5) ? mo_ptr->tval : ItemKindType::SWORD);
         while (true) {
-            BaseitemInfo *ck_ptr;
             k_idx = lookup_baseitem_id({ tval });
-            ck_ptr = &baseitems_info[k_idx];
-
+            const auto &bi_ref = baseitems_info[k_idx];
+            const auto sval = bi_ref.bi_key.sval();
             if (tval == ItemKindType::SWORD) {
-                if ((ck_ptr->sval == SV_BROKEN_DAGGER) || (ck_ptr->sval == SV_BROKEN_SWORD) || (ck_ptr->sval == SV_DIAMOND_EDGE) || (ck_ptr->sval == SV_POISON_NEEDLE)) {
+                if ((sval == SV_BROKEN_DAGGER) || (sval == SV_BROKEN_SWORD) || (sval == SV_DIAMOND_EDGE) || (sval == SV_POISON_NEEDLE)) {
                     continue;
                 }
             }
+
             if (tval == ItemKindType::POLEARM) {
-                if ((ck_ptr->sval == SV_DEATH_SCYTHE) || (ck_ptr->sval == SV_TSURIZAO)) {
+                if ((sval == SV_DEATH_SCYTHE) || (sval == SV_TSURIZAO)) {
                     continue;
                 }
             }
+
             if (tval == ItemKindType::HAFTED) {
-                if ((ck_ptr->sval == SV_GROND) || (ck_ptr->sval == SV_WIZSTAFF) || (ck_ptr->sval == SV_NAMAKE_HAMMER)) {
+                if ((sval == SV_GROND) || (sval == SV_WIZSTAFF) || (sval == SV_NAMAKE_HAMMER)) {
                     continue;
                 }
             }
@@ -208,8 +212,8 @@ static PRICE repair_broken_weapon_aux(PlayerType *player_ptr, PRICE bcost)
     k_ptr = &baseitems_info[k_idx];
     o_ptr->k_idx = k_idx;
     o_ptr->weight = k_ptr->weight;
-    o_ptr->tval = k_ptr->tval;
-    o_ptr->sval = k_ptr->sval;
+    o_ptr->tval = k_ptr->bi_key.tval();
+    o_ptr->sval = k_ptr->bi_key.sval().value();
     o_ptr->dd = k_ptr->dd;
     o_ptr->ds = k_ptr->ds;
 
index 00649c3..b411a94 100644 (file)
@@ -256,7 +256,7 @@ bool potion_smash_effect(PlayerType *player_ptr, MONSTER_IDX who, POSITION y, PO
     int dam = 0;
     bool angry = false;
     auto *k_ptr = &baseitems_info[k_idx];
-    switch (k_ptr->sval) {
+    switch (k_ptr->bi_key.sval().value()) {
     case SV_POTION_SALT_WATER:
     case SV_POTION_SLIME_MOLD:
     case SV_POTION_LOSE_MEMORIES:
index 205cc21..66bfa4e 100644 (file)
@@ -14,9 +14,7 @@
 #include <sstream>
 #include <vector>
 
-/*
- * Special "sval" limit -- first "good" magic/prayer book
- */
+// @brief 3冊目の魔法書からは上質アイテムとして扱う.
 static const int SV_BOOK_MIN_GOOD = 2;
 
 /*!
@@ -26,7 +24,7 @@ static const int SV_BOOK_MIN_GOOD = 2;
  */
 bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::CLOAK;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::CLOAK;
 }
 
 /*!
@@ -36,7 +34,7 @@ bool kind_is_cloak(KIND_OBJECT_IDX k_idx)
  */
 bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::POLEARM;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::POLEARM;
 }
 
 /*!
@@ -47,7 +45,7 @@ bool kind_is_polearm(KIND_OBJECT_IDX k_idx)
 bool kind_is_sword(KIND_OBJECT_IDX k_idx)
 {
     auto *k_ptr = &baseitems_info[k_idx];
-    return (k_ptr->tval == ItemKindType::SWORD) && (k_ptr->sval > 2);
+    return (k_ptr->bi_key.tval() == ItemKindType::SWORD) && (k_ptr->bi_key.sval() > 2);
 }
 
 /*!
@@ -58,7 +56,7 @@ bool kind_is_sword(KIND_OBJECT_IDX k_idx)
 bool kind_is_book(KIND_OBJECT_IDX k_idx)
 {
     auto *k_ptr = &baseitems_info[k_idx];
-    return (k_ptr->tval >= ItemKindType::LIFE_BOOK) && (k_ptr->tval <= ItemKindType::CRUSADE_BOOK);
+    return (k_ptr->bi_key.tval() >= ItemKindType::LIFE_BOOK) && (k_ptr->bi_key.tval() <= ItemKindType::CRUSADE_BOOK);
 }
 
 /*!
@@ -69,7 +67,7 @@ bool kind_is_book(KIND_OBJECT_IDX k_idx)
 bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
 {
     auto *k_ptr = &baseitems_info[k_idx];
-    return (k_ptr->tval >= ItemKindType::LIFE_BOOK) && (k_ptr->tval <= ItemKindType::CRUSADE_BOOK) && (k_ptr->tval != ItemKindType::ARCANE_BOOK) && (k_ptr->sval > 1);
+    return (k_ptr->bi_key.tval() >= ItemKindType::LIFE_BOOK) && (k_ptr->bi_key.tval() <= ItemKindType::CRUSADE_BOOK) && (k_ptr->bi_key.tval() != ItemKindType::ARCANE_BOOK) && (k_ptr->bi_key.sval() > 1);
 }
 
 /*!
@@ -79,7 +77,7 @@ bool kind_is_good_book(KIND_OBJECT_IDX k_idx)
  */
 bool kind_is_armor(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::HARD_ARMOR;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::HARD_ARMOR;
 }
 
 /*!
@@ -89,7 +87,7 @@ bool kind_is_armor(KIND_OBJECT_IDX k_idx)
  */
 bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::HAFTED;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::HAFTED;
 }
 
 /*!
@@ -99,7 +97,7 @@ bool kind_is_hafted(KIND_OBJECT_IDX k_idx)
  */
 bool kind_is_potion(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::POTION;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::POTION;
 }
 
 /*!
@@ -109,7 +107,7 @@ bool kind_is_potion(KIND_OBJECT_IDX k_idx)
  */
 bool kind_is_boots(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::BOOTS;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::BOOTS;
 }
 
 /*!
@@ -119,7 +117,7 @@ bool kind_is_boots(KIND_OBJECT_IDX k_idx)
  */
 bool kind_is_amulet(KIND_OBJECT_IDX k_idx)
 {
-    return baseitems_info[k_idx].tval == ItemKindType::AMULET;
+    return baseitems_info[k_idx].bi_key.tval() == ItemKindType::AMULET;
 }
 
 /*!
@@ -131,7 +129,7 @@ bool kind_is_amulet(KIND_OBJECT_IDX k_idx)
 bool kind_is_good(KIND_OBJECT_IDX k_idx)
 {
     auto *k_ptr = &baseitems_info[k_idx];
-    switch (k_ptr->tval) {
+    switch (k_ptr->bi_key.tval()) {
         /* Armor -- Good unless damaged */
     case ItemKindType::HARD_ARMOR:
     case ItemKindType::SOFT_ARMOR:
@@ -170,15 +168,15 @@ bool kind_is_good(KIND_OBJECT_IDX k_idx)
     case ItemKindType::MUSIC_BOOK:
     case ItemKindType::HISSATSU_BOOK:
     case ItemKindType::HEX_BOOK:
-        return k_ptr->sval >= SV_BOOK_MIN_GOOD;
+        return k_ptr->bi_key.sval() >= SV_BOOK_MIN_GOOD;
 
     /* Rings -- Rings of Speed are good */
     case ItemKindType::RING:
-        return (k_ptr->sval == SV_RING_SPEED) || (k_ptr->sval == SV_RING_LORDLY);
+        return (k_ptr->bi_key.sval() == SV_RING_SPEED) || (k_ptr->bi_key.sval() == SV_RING_LORDLY);
 
     /* Amulets -- Amulets of the Magi and Resistance are good */
     case ItemKindType::AMULET:
-        return (k_ptr->sval == SV_AMULET_THE_MAGI) || (k_ptr->sval == SV_AMULET_RESISTANCE);
+        return (k_ptr->bi_key.sval() == SV_AMULET_THE_MAGI) || (k_ptr->bi_key.sval() == SV_AMULET_RESISTANCE);
     default:
         return false;
     }
@@ -192,32 +190,32 @@ static const std::map<ItemKindType, std::vector<int>> &create_baseitems_cache()
 {
     static std::map<ItemKindType, std::vector<int>> cache;
     for (const auto &baseitem : baseitems_info) {
-        const auto tval = baseitem.tval;
+        const auto &bi_key = baseitem.bi_key;
+        const auto tval = bi_key.tval();
         if (tval == ItemKindType::NONE) {
             continue;
         }
 
-        cache[tval].push_back(baseitem.sval);
+        cache[tval].push_back(bi_key.sval().value());
     }
 
     return cache;
 }
 
 /*
- * @brief tvalとsvalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する
+ * @brief tvalとbi_key.svalに対応する、BaseitenDefinitions のIDを返すためのキャッシュを生成する
  * @return tvalと(実在する)svalの組み合わせをキーに、ベースアイテムIDを値とした辞書
  */
 static const std::map<BaseitemKey, short> &create_baseitem_index_chache()
 {
     static std::map<BaseitemKey, short> cache;
     for (const auto &baseitem : baseitems_info) {
-        const auto tval = baseitem.tval;
-        if (tval == ItemKindType::NONE) {
+        const auto &bi_key = baseitem.bi_key;
+        if (bi_key.tval() == ItemKindType::NONE) {
             continue;
         }
 
-        const BaseitemKey key(tval, baseitem.sval);
-        cache[key] = baseitem.idx;
+        cache[bi_key] = baseitem.idx;
     }
 
     return cache;
@@ -225,8 +223,7 @@ static const std::map<BaseitemKey, short> &create_baseitem_index_chache()
 
 /*!
  * @brief tvalとsvalに対応するベースアイテムのIDを検索する
- * @param tval 検索したいベースアイテムのtval
- * @param sval 検索したいベースアイテムのsval (nulloptの可能性はない)
+ * @param key 検索したいベースアイテムの、tval/svalのペア (svalがnulloptの可能性はない)
  * @return tvalとsvalに対応するベースアイテムが存在すればそのID、存在しなければ0
  * @details 存在しないことはリファクタリング成果により考えにくく、自作の不存在例外を投げればいいはず.
  * 但し呼び出し側全部の処理を保証するのが面倒なので旧処理のままとする.
index d8ba98c..42a3d9d 100644 (file)
@@ -105,11 +105,7 @@ static std::optional<FixedArtifactId> sweep_amusement_artifact(const bool insta_
             continue;
         }
 
-        if (a_ref.bi_key.tval() != baseitems_info[k_idx].tval) {
-            continue;
-        }
-
-        if (a_ref.bi_key.sval() != baseitems_info[k_idx].sval) {
+        if (a_ref.bi_key != baseitems_info[k_idx].bi_key) {
             continue;
         }
 
index b51c571..865dd0a 100644 (file)
@@ -45,4 +45,9 @@ std::optional<int> BaseitemKey::sval() const
     return this->subtype_value;
 }
 
+BaseitemInfo::BaseitemInfo()
+    : bi_key(ItemKindType::NONE)
+{
+}
+
 std::vector<BaseitemInfo> baseitems_info;
index 55baa4e..f104819 100644 (file)
@@ -46,15 +46,14 @@ enum class ItemKindType : short;
 enum class RandomArtActType : short;
 class BaseitemInfo {
 public:
-    BaseitemInfo() = default;
+    BaseitemInfo();
     KIND_OBJECT_IDX idx{};
 
     std::string name; /*!< ベースアイテム名 */
     std::string text; /*!< 解説テキスト */
     std::string flavor_name; /*!< 未確定名 */
 
-    ItemKindType tval{}; /*!< ベースアイテム種別の大項目値 Object type */
-    OBJECT_SUBTYPE_VALUE sval{}; /*!< ベースアイテム種別の小項目値 Object sub type */
+    BaseitemKey bi_key;
 
     PARAMETER_VALUE pval{}; /*!< ベースアイテムのpval(能力修正共通値) Object extra info */
 
index fe7556e..453fa61 100644 (file)
@@ -69,8 +69,8 @@ void ObjectType::prep(KIND_OBJECT_IDX ko_idx)
     wipe();
     this->stack_idx = old_stack_idx;
     this->k_idx = ko_idx;
-    this->tval = k_ptr->tval;
-    this->sval = k_ptr->sval;
+    this->tval = k_ptr->bi_key.tval();
+    this->sval = k_ptr->bi_key.sval().value();
     this->pval = k_ptr->pval;
     this->number = 1;
     this->weight = k_ptr->weight;
@@ -480,7 +480,7 @@ bool ObjectType::is_tried() const
  */
 bool ObjectType::is_potion() const
 {
-    return baseitems_info[this->k_idx].tval == ItemKindType::POTION;
+    return baseitems_info[this->k_idx].bi_key.tval() == ItemKindType::POTION;
 }
 
 /*!
index 6a8b516..5c709b5 100644 (file)
@@ -108,7 +108,7 @@ SpoilerOutputResultType spoil_obj_desc(concptr fname)
         std::vector<KIND_OBJECT_IDX> whats;
         for (auto tval : tval_list) {
             for (const auto &k_ref : baseitems_info) {
-                if ((k_ref.tval == tval) && k_ref.gen_flags.has_not(ItemGenerationTraitType::INSTA_ART)) {
+                if ((k_ref.bi_key.tval() == tval) && k_ref.gen_flags.has_not(ItemGenerationTraitType::INSTA_ART)) {
                     whats.push_back(k_ref.idx);
                 }
             }
index 828cfea..9adde2f 100644 (file)
@@ -269,7 +269,8 @@ static void prt_alloc(ItemKindType tval, OBJECT_SUBTYPE_VALUE sval, TERM_LEN row
             total[i] += prob / (CHANCE_BASEITEM_LEVEL_BOOST * K_MAX_DEPTH);
             total_frac += prob % (CHANCE_BASEITEM_LEVEL_BOOST * K_MAX_DEPTH);
 
-            if ((k_ptr->tval == tval) && (k_ptr->sval == sval)) {
+            BaseitemKey bi_key(tval, sval);
+            if (k_ptr->bi_key == bi_key) {
                 home = k_ptr->level;
                 rarity[i] += prob / (CHANCE_BASEITEM_LEVEL_BOOST * K_MAX_DEPTH);
             }
@@ -1038,7 +1039,7 @@ WishResultType do_cmd_wishing(PlayerType *player_ptr, int prob, bool allow_art,
         FixedArtifactId a_idx = FixedArtifactId::NONE;
         if (k_ptr->gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
             for (const auto &[a_idx_loop, a_ref_loop] : artifacts_info) {
-                if (a_idx_loop == FixedArtifactId::NONE || a_ref_loop.bi_key.tval() != k_ptr->tval || a_ref_loop.bi_key.sval() != k_ptr->sval) {
+                if (a_idx_loop == FixedArtifactId::NONE || a_ref_loop.bi_key != k_ptr->bi_key) {
                     continue;
                 }
 
index 6e530a5..05f3c39 100644 (file)
@@ -163,7 +163,7 @@ static KIND_OBJECT_IDX wiz_select_sval(const ItemKindType tval, concptr tval_des
             break;
         }
 
-        if (k_ref.idx == 0 || k_ref.tval != tval) {
+        if (k_ref.idx == 0 || k_ref.bi_key.tval() != tval) {
             continue;
         }
 
@@ -240,7 +240,7 @@ void wiz_create_item(PlayerType *player_ptr)
     const auto &baseitem = baseitems_info[bi_id];
     if (baseitem.gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
         for (const auto &[a_idx, a_ref] : artifacts_info) {
-            if ((a_idx == FixedArtifactId::NONE) || (a_ref.bi_key.tval() != baseitem.tval) || (a_ref.bi_key.sval() != baseitem.sval)) {
+            if ((a_idx == FixedArtifactId::NONE) || (a_ref.bi_key != baseitem.bi_key)) {
                 continue;
             }
 
index 5e0730d..58779c8 100644 (file)
@@ -88,10 +88,8 @@ OBJECT_IDX get_obj_index(PlayerType *player_ptr, DEPTH level, BIT_FLAGS mode)
             break;
         }
 
-        KIND_OBJECT_IDX k_idx = entry.index;
-        auto *k_ptr = &baseitems_info[k_idx];
-
-        if ((mode & AM_FORBID_CHEST) && (k_ptr->tval == ItemKindType::CHEST)) {
+        const auto &k_ref = baseitems_info[entry.index];
+        if ((mode & AM_FORBID_CHEST) && (k_ref.bi_key.tval() == ItemKindType::CHEST)) {
             continue;
         }