OSDN Git Service

[Refactor] #3179 artifacts_info.at() をArtifactsInfo::get_instance().get_artifact...
authorHourier <66951241+Hourier@users.noreply.github.com>
Sun, 23 Apr 2023 08:22:47 +0000 (17:22 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 30 Apr 2023 05:56:46 +0000 (14:56 +0900)
39 files changed:
src/action/activation-execution.cpp
src/artifact/artifact-info.cpp
src/artifact/fixed-art-generator.cpp
src/combat/shoot.cpp
src/dungeon/quest.cpp
src/flavor/flavor-util.cpp
src/flavor/named-item-describer.cpp
src/floor/fixed-map-generator.cpp
src/floor/floor-changer.cpp
src/floor/floor-leaver.cpp
src/floor/floor-object.cpp
src/floor/floor-streams.cpp
src/floor/floor-util.cpp
src/grid/object-placer.cpp
src/info-reader/general-parser.cpp
src/knowledge/knowledge-items.cpp
src/knowledge/knowledge-quests.cpp
src/load/item/item-loader-base.cpp
src/load/old/load-v1-5-0.cpp
src/load/quest-loader.cpp
src/monster-floor/monster-death.cpp
src/monster-floor/special-death-switcher.cpp
src/object-enchant/item-magic-applier.cpp
src/object-hook/hook-quest.cpp
src/object/object-flags.cpp
src/object/object-value-calc.cpp
src/object/object-value.cpp
src/perception/identification.cpp
src/racial/racial-android.cpp
src/save/save.cpp
src/specific-object/bloody-moon.cpp
src/spell-kind/spells-floor.cpp
src/system/artifact-type-definition.cpp
src/system/artifact-type-definition.h
src/util/sort.cpp
src/wizard/artifact-analyzer.cpp
src/wizard/fixed-artifacts-spoiler.cpp
src/wizard/wizard-item-modifier.cpp
src/wizard/wizard-special-process.cpp

index f3249ef..f04f004 100644 (file)
@@ -55,7 +55,7 @@
 static void decide_activation_level(ae_type *ae_ptr)
 {
     if (ae_ptr->o_ptr->is_fixed_artifact()) {
-        ae_ptr->lev = artifacts_info.at(ae_ptr->o_ptr->fixed_artifact_idx).level;
+        ae_ptr->lev = ArtifactsInfo::get_instance().get_artifact(ae_ptr->o_ptr->fixed_artifact_idx).level;
         return;
     }
 
index 26ca30d..3571e08 100644 (file)
@@ -29,7 +29,7 @@ RandomArtActType activation_index(const ItemEntity *o_ptr)
     }
 
     if (o_ptr->is_fixed_artifact()) {
-        const auto &fixed_artifact = artifacts_info.at(o_ptr->fixed_artifact_idx);
+        const auto &fixed_artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
         if (fixed_artifact.flags.has(TR_ACTIVATE)) {
             return fixed_artifact.act_idx;
         }
index 17179bb..e2319c4 100644 (file)
@@ -225,19 +225,19 @@ static void invest_curse_to_fixed_artifact(const ArtifactType &a_ref, ItemEntity
  */
 void apply_artifact(PlayerType *player_ptr, ItemEntity *o_ptr)
 {
-    auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-    o_ptr->pval = a_ref.pval;
-    o_ptr->ac = a_ref.ac;
-    o_ptr->dd = a_ref.dd;
-    o_ptr->ds = a_ref.ds;
-    o_ptr->to_a = a_ref.to_a;
-    o_ptr->to_h = a_ref.to_h;
-    o_ptr->to_d = a_ref.to_d;
-    o_ptr->weight = a_ref.weight;
-    o_ptr->activation_id = a_ref.act_idx;
-
-    invest_curse_to_fixed_artifact(a_ref, o_ptr);
-    fixed_artifact_random_abilities(player_ptr, a_ref, o_ptr);
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+    o_ptr->pval = artifact.pval;
+    o_ptr->ac = artifact.ac;
+    o_ptr->dd = artifact.dd;
+    o_ptr->ds = artifact.ds;
+    o_ptr->to_a = artifact.to_a;
+    o_ptr->to_h = artifact.to_h;
+    o_ptr->to_d = artifact.to_d;
+    o_ptr->weight = artifact.weight;
+    o_ptr->activation_id = artifact.act_idx;
+
+    invest_curse_to_fixed_artifact(artifact, o_ptr);
+    fixed_artifact_random_abilities(player_ptr, artifact, o_ptr);
 }
 
 /*!
@@ -254,12 +254,12 @@ void apply_artifact(PlayerType *player_ptr, ItemEntity *o_ptr)
  */
 bool create_named_art(PlayerType *player_ptr, FixedArtifactId a_idx, POSITION y, POSITION x)
 {
-    auto &a_ref = artifacts_info.at(a_idx);
-    if (a_ref.name.empty()) {
+    auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+    if (artifact.name.empty()) {
         return false;
     }
 
-    auto bi_id = lookup_baseitem_id(a_ref.bi_key);
+    auto bi_id = lookup_baseitem_id(artifact.bi_key);
     if (bi_id == 0) {
         return true;
     }
@@ -273,7 +273,7 @@ bool create_named_art(PlayerType *player_ptr, FixedArtifactId a_idx, POSITION y,
         return false;
     }
 
-    a_ref.is_generated = true;
+    artifact.is_generated = true;
     return true;
 }
 
index a3c10fc..f4525cc 100644 (file)
@@ -956,7 +956,7 @@ void exe_fire(PlayerType *player_ptr, INVENTORY_IDX item, ItemEntity *j_ptr, SPE
             if (!o_idx) {
                 msg_format(_("%sはどこかへ行った。", "The %s went somewhere."), item_name.data());
                 if (q_ptr->is_fixed_artifact()) {
-                    artifacts_info.at(j_ptr->fixed_artifact_idx).is_generated = false;
+                    ArtifactsInfo::get_instance().get_artifact(j_ptr->fixed_artifact_idx).is_generated = false;
                 }
                 return;
             }
index fa9c54c..2cd48be 100644 (file)
@@ -412,7 +412,7 @@ void leave_quest_check(PlayerType *player_ptr)
         quest_list[QuestId::TOWER1].complev = player_ptr->lev;
         break;
     case QuestKindType::FIND_ARTIFACT:
-        artifacts_info.at(q_ptr->reward_artifact_idx).gen_flags.reset(ItemGenerationTraitType::QUESTITEM);
+        ArtifactsInfo::get_instance().get_artifact(q_ptr->reward_artifact_idx).gen_flags.reset(ItemGenerationTraitType::QUESTITEM);
         break;
     case QuestKindType::RANDOM:
         monraces_info[q_ptr->r_idx].flags1 &= ~(RF1_QUESTOR);
index f3ce34b..a42b59c 100644 (file)
@@ -75,8 +75,8 @@ std::string get_ability_abbreviation(const ItemEntity &item, bool is_kanji, bool
         flags.reset(baseitem.flags);
 
         if (item.is_fixed_artifact()) {
-            const auto &a_ref = artifacts_info.at(item.fixed_artifact_idx);
-            flags.reset(a_ref.flags);
+            const auto &artifact = ArtifactsInfo::get_instance().get_artifact(item.fixed_artifact_idx);
+            flags.reset(artifact.flags);
         }
 
         if (item.is_ego()) {
index 7245cbe..e5bb080 100644 (file)
@@ -34,7 +34,7 @@ static std::string get_fullname_if_set(const ItemEntity &item, const describe_op
 
     const auto fixed_art_id = item.fixed_artifact_idx;
     const auto is_known_artifact = opt.known && item.is_fixed_artifact() && none_bits(opt.mode, OD_BASE_NAME);
-    return is_known_artifact ? artifacts_info.at(fixed_art_id).name : baseitems_info[item.bi_id].name;
+    return is_known_artifact ? ArtifactsInfo::get_instance().get_artifact(fixed_art_id).name : baseitems_info[item.bi_id].name;
 }
 
 #ifdef JP
@@ -110,10 +110,10 @@ static std::string describe_unique_name_before_body_ja(const ItemEntity &item, c
     }
 
     if (item.is_fixed_artifact() && object_flags(&item).has_not(TR_FULL_NAME)) {
-        const auto &a_ref = artifacts_info.at(item.fixed_artifact_idx);
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(item.fixed_artifact_idx);
         /* '『' から始まらない伝説のアイテムの名前は最初に付加する */
-        if (a_ref.name.find("『", 0, 2) != 0) {
-            return a_ref.name;
+        if (artifact.name.find("『", 0, 2) != 0) {
+            return artifact.name;
         }
 
         return "";
@@ -200,7 +200,7 @@ static std::string describe_unique_name_after_body_ja(const ItemEntity &item, co
     }
 
     if (item.is_fixed_artifact()) {
-        const auto &artifact = artifacts_info.at(item.fixed_artifact_idx);
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(item.fixed_artifact_idx);
         if (artifact.name.find("『", 0, 2) == 0) {
             return artifact.name;
         }
@@ -294,7 +294,7 @@ static std::string describe_unique_name_after_body_en(const ItemEntity &item, co
     }
 
     if (item.is_fixed_artifact()) {
-        const auto &artifact = artifacts_info.at(item.fixed_artifact_idx);
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(item.fixed_artifact_idx);
         ss << ' ' << artifact.name;
         return ss.str();
     }
index 865c6e1..c8be1f4 100644 (file)
@@ -76,14 +76,14 @@ static void drop_here(FloorType *floor_ptr, ItemEntity *j_ptr, POSITION y, POSIT
     g_ptr->o_idx_list.add(floor_ptr, o_idx);
 }
 
-static void generate_artifact(PlayerType *player_ptr, qtwg_type *qtwg_ptr, const FixedArtifactId artifact_index)
+static void generate_artifact(PlayerType *player_ptr, qtwg_type *qtwg_ptr, const FixedArtifactId a_idx)
 {
-    if (artifact_index == FixedArtifactId::NONE) {
+    if (a_idx == FixedArtifactId::NONE) {
         return;
     }
 
-    auto &fixed_artifact = artifacts_info.at(artifact_index);
-    if (!fixed_artifact.is_generated && create_named_art(player_ptr, artifact_index, *qtwg_ptr->y, *qtwg_ptr->x)) {
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+    if (!artifact.is_generated && create_named_art(player_ptr, a_idx, *qtwg_ptr->y, *qtwg_ptr->x)) {
         return;
     }
 
@@ -235,7 +235,7 @@ static bool parse_qtw_QQ(quest_type *q_ptr, char **zz, int num)
         return true;
     }
 
-    auto &artifact = artifacts_info.at(q_ptr->reward_artifact_idx);
+    auto &artifact = ArtifactsInfo::get_instance().get_artifact(q_ptr->reward_artifact_idx);
     artifact.gen_flags.set(ItemGenerationTraitType::QUESTITEM);
     return true;
 }
@@ -255,13 +255,14 @@ static bool parse_qtw_QR(quest_type *q_ptr, char **zz, int num)
 
     int count = 0;
     FixedArtifactId reward_idx = FixedArtifactId::NONE;
+    const auto &artifacts = ArtifactsInfo::get_instance();
     for (auto idx = 2; idx < num; idx++) {
         const auto a_idx = i2enum<FixedArtifactId>(atoi(zz[idx]));
         if (a_idx == FixedArtifactId::NONE) {
             continue;
         }
 
-        if (artifacts_info.at(a_idx).is_generated) {
+        if (artifacts.get_artifact(a_idx).is_generated) {
             continue;
         }
 
@@ -273,7 +274,7 @@ static bool parse_qtw_QR(quest_type *q_ptr, char **zz, int num)
 
     if (reward_idx != FixedArtifactId::NONE) {
         q_ptr->reward_artifact_idx = reward_idx;
-        artifacts_info.at(reward_idx).gen_flags.set(ItemGenerationTraitType::QUESTITEM);
+        artifacts.get_artifact(reward_idx).gen_flags.set(ItemGenerationTraitType::QUESTITEM);
     } else {
         q_ptr->type = QuestKindType::KILL_ALL;
     }
index 93c411f..ebded64 100644 (file)
@@ -195,7 +195,7 @@ static void update_unique_artifact(FloorType *floor_ptr, int16_t cur_floor_id)
         }
 
         if (o_ref.is_fixed_artifact()) {
-            artifacts_info.at(o_ref.fixed_artifact_idx).floor_id = cur_floor_id;
+            ArtifactsInfo::get_instance().get_artifact(o_ref.fixed_artifact_idx).floor_id = cur_floor_id;
         }
     }
 }
@@ -295,9 +295,9 @@ static void new_floor_allocation(PlayerType *player_ptr, saved_floor_type *sf_pt
             continue;
         }
 
-        auto &fixed_artifact = artifacts_info.at(o_ptr->fixed_artifact_idx);
-        if (fixed_artifact.floor_id == new_floor_id) {
-            fixed_artifact.is_generated = true;
+        auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+        if (artifact.floor_id == new_floor_id) {
+            artifact.is_generated = true;
         } else {
             delete_object_idx(player_ptr, i);
         }
index e99bac5..1722e66 100644 (file)
@@ -283,7 +283,7 @@ static void preserve_info(PlayerType *player_ptr)
         }
 
         if (o_ptr->is_fixed_artifact()) {
-            artifacts_info.at(o_ptr->fixed_artifact_idx).floor_id = 0;
+            ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx).floor_id = 0;
         }
     }
 }
index a20275c..fb4ffea 100644 (file)
@@ -458,6 +458,7 @@ OBJECT_IDX drop_near(PlayerType *player_ptr, ItemEntity *j_ptr, PERCENTAGE chanc
         flag = true;
     }
 
+    auto &artifact = ArtifactsInfo::get_instance().get_artifact(j_ptr->fixed_artifact_idx);
     if (!flag) {
         int candidates = 0, pick;
         for (ty = 1; ty < floor_ptr->height - 1; ty++) {
@@ -481,7 +482,7 @@ OBJECT_IDX drop_near(PlayerType *player_ptr, ItemEntity *j_ptr, PERCENTAGE chanc
 
             if (preserve_mode) {
                 if (j_ptr->is_fixed_artifact() && !j_ptr->is_known()) {
-                    artifacts_info.at(j_ptr->fixed_artifact_idx).is_generated = false;
+                    artifact.is_generated = false;
                 }
             }
 
@@ -534,7 +535,7 @@ OBJECT_IDX drop_near(PlayerType *player_ptr, ItemEntity *j_ptr, PERCENTAGE chanc
         }
 
         if (j_ptr->is_fixed_artifact()) {
-            artifacts_info.at(j_ptr->fixed_artifact_idx).is_generated = false;
+            artifact.is_generated = false;
         }
 
         return 0;
@@ -551,7 +552,6 @@ OBJECT_IDX drop_near(PlayerType *player_ptr, ItemEntity *j_ptr, PERCENTAGE chanc
     }
 
     if (j_ptr->is_fixed_artifact() && w_ptr->character_dungeon) {
-        auto &artifact = artifacts_info.at(j_ptr->fixed_artifact_idx);
         artifact.floor_id = player_ptr->floor_id;
     }
 
index 8019488..a579e6d 100644 (file)
@@ -363,7 +363,7 @@ void build_streamer(PlayerType *player_ptr, FEAT_IDX feat, int chance)
 
                     /* Hack -- Preserve unknown artifacts */
                     if (o_ptr->is_fixed_artifact()) {
-                        artifacts_info.at(o_ptr->fixed_artifact_idx).is_generated = false;
+                        ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx).is_generated = false;
                         if (cheat_peek) {
                             const auto item_name = describe_flavor(player_ptr, o_ptr, (OD_NAME_ONLY | OD_STORE));
                             msg_format(_("伝説のアイテム (%s) はストリーマーにより削除された。", "Artifact (%s) was deleted by streamer."), item_name.data());
index 3be1e42..5a80ec7 100644 (file)
@@ -133,7 +133,7 @@ void wipe_o_list(FloorType *floor_ptr)
 
         if (!w_ptr->character_dungeon || preserve_mode) {
             if (o_ptr->is_fixed_artifact() && !o_ptr->is_known()) {
-                artifacts_info.at(o_ptr->fixed_artifact_idx).is_generated = false;
+                ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx).is_generated = false;
             }
         }
 
index 94f8747..ffb96f3 100644 (file)
@@ -90,7 +90,7 @@ void place_object(PlayerType *player_ptr, POSITION y, POSITION x, BIT_FLAGS mode
     OBJECT_IDX o_idx = o_pop(floor_ptr);
     if (o_idx == 0) {
         if (q_ptr->is_fixed_artifact()) {
-            artifacts_info.at(q_ptr->fixed_artifact_idx).is_generated = false;
+            ArtifactsInfo::get_instance().get_artifact(q_ptr->fixed_artifact_idx).is_generated = false;
         }
 
         return;
index a6af465..c47a3bc 100644 (file)
@@ -147,9 +147,9 @@ parse_error_type parse_line_feature(FloorType *floor_ptr, char *buf)
                 const auto &quest_list = QuestList::get_instance();
                 const auto a_idx = quest_list[floor_ptr->quest_number].reward_artifact_idx;
                 if (a_idx != FixedArtifactId::NONE) {
-                    const auto &a_ref = artifacts_info.at(a_idx);
-                    if (a_ref.gen_flags.has_not(ItemGenerationTraitType::INSTA_ART)) {
-                        letter[index].object = lookup_baseitem_id(a_ref.bi_key);
+                    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+                    if (artifact.gen_flags.has_not(ItemGenerationTraitType::INSTA_ART)) {
+                        letter[index].object = lookup_baseitem_id(artifact.bi_key);
                     }
                 }
             }
index 3426f87..0f6627f 100644 (file)
@@ -100,9 +100,9 @@ void do_cmd_knowledge_artifacts(PlayerType *player_ptr)
     uint16_t why = 3;
     ang_sort(player_ptr, whats.data(), &why, whats.size(), ang_sort_art_comp, ang_sort_art_swap);
     for (auto a_idx : whats) {
-        const auto &a_ref = artifacts_info.at(a_idx);
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
         constexpr auto unknown_art = _("未知の伝説のアイテム", "Unknown Artifact");
-        const auto bi_id = lookup_baseitem_id(a_ref.bi_key);
+        const auto bi_id = lookup_baseitem_id(artifact.bi_key);
         constexpr auto template_basename = _("     %s\n", "     The %s\n");
         if (bi_id == 0) {
             fprintf(fff, template_basename, unknown_art);
index 923ca0d..742c890 100644 (file)
@@ -102,9 +102,9 @@ static void do_cmd_knowledge_quests_current(PlayerType *player_ptr, FILE *fff)
                 case QuestKindType::FIND_ARTIFACT: {
                     std::string item_name("");
                     if (q_ref.reward_artifact_idx != FixedArtifactId::NONE) {
-                        const auto &a_ref = artifacts_info.at(q_ref.reward_artifact_idx);
+                        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(q_ref.reward_artifact_idx);
                         ItemEntity item;
-                        auto bi_id = lookup_baseitem_id(a_ref.bi_key);
+                        auto bi_id = lookup_baseitem_id(artifact.bi_key);
                         item.prep(bi_id);
                         item.fixed_artifact_idx = q_ref.reward_artifact_idx;
                         item.ident = IDENT_STORE;
index f6b7eb1..29fbc64 100644 (file)
@@ -29,11 +29,10 @@ void ItemLoaderBase::load_item(void)
  */
 void ItemLoaderBase::load_artifact()
 {
-    ArtifactType dummy;
     auto loading_max_a_idx = rd_u16b();
     for (auto i = 0U; i < loading_max_a_idx; i++) {
         const auto a_idx = i2enum<FixedArtifactId>(i);
-        auto &artifact = (i > 0) ? artifacts_info.at(a_idx) : dummy;
+        auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
         artifact.is_generated = rd_bool();
         if (h_older_than(1, 5, 0, 0)) {
             artifact.floor_id = 0;
index e1635db..ec7474f 100644 (file)
@@ -133,11 +133,11 @@ void rd_item_old(ItemEntity *o_ptr)
                 o_ptr->curse_flags.set(CurseTraitType::PERMA_CURSE);
             }
             if (o_ptr->is_fixed_artifact()) {
-                const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-                if (a_ref.gen_flags.has(ItemGenerationTraitType::HEAVY_CURSE)) {
+                const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+                if (artifact.gen_flags.has(ItemGenerationTraitType::HEAVY_CURSE)) {
                     o_ptr->curse_flags.set(CurseTraitType::HEAVY_CURSE);
                 }
-                if (a_ref.gen_flags.has(ItemGenerationTraitType::PERMA_CURSE)) {
+                if (artifact.gen_flags.has(ItemGenerationTraitType::PERMA_CURSE)) {
                     o_ptr->curse_flags.set(CurseTraitType::PERMA_CURSE);
                 }
             } else if (o_ptr->is_ego()) {
@@ -340,8 +340,8 @@ void rd_item_old(ItemEntity *o_ptr)
     }
 
     if (o_ptr->is_fixed_artifact()) {
-        const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-        if (a_ref.name.empty()) {
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+        if (artifact.name.empty()) {
             o_ptr->fixed_artifact_idx = FixedArtifactId::NONE;
         }
     }
index e656589..6dbe44e 100644 (file)
@@ -72,7 +72,7 @@ static void load_quest_details(PlayerType *player_ptr, quest_type *q_ptr, const
     }
     q_ptr->reward_artifact_idx = i2enum<FixedArtifactId>(rd_s16b());
     if (q_ptr->reward_artifact_idx != FixedArtifactId::NONE) {
-        artifacts_info.at(q_ptr->reward_artifact_idx).gen_flags.set(ItemGenerationTraitType::QUESTITEM);
+        ArtifactsInfo::get_instance().get_artifact(q_ptr->reward_artifact_idx).gen_flags.set(ItemGenerationTraitType::QUESTITEM);
     }
 
     q_ptr->flags = rd_byte();
index 456a1fb..d042e1b 100644 (file)
@@ -180,8 +180,8 @@ static void drop_artifact_from_unique(PlayerType *player_ptr, monster_death_type
  */
 bool drop_single_artifact(PlayerType *player_ptr, monster_death_type *md_ptr, FixedArtifactId a_idx)
 {
-    auto &a_ref = artifacts_info.at(a_idx);
-    if (a_ref.is_generated) {
+    auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+    if (artifact.is_generated) {
         return false;
     }
 
@@ -198,8 +198,8 @@ static short drop_dungeon_final_artifact(PlayerType *player_ptr, monster_death_t
     }
 
     const auto a_idx = dungeon.final_artifact;
-    auto &a_ref = artifacts_info.at(a_idx);
-    if (a_ref.is_generated) {
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+    if (artifact.is_generated) {
         return bi_id;
     }
 
index 3c7267c..e22521e 100644 (file)
@@ -183,7 +183,7 @@ static void on_dead_sacred_treasures(PlayerType *player_ptr, monster_death_type
             break;
         }
 
-        a_ptr = &artifacts_info.at(a_idx);
+        a_ptr = &ArtifactsInfo::get_instance().get_artifact(a_idx);
     } while (a_ptr->is_generated);
 
     create_named_art(player_ptr, a_idx, md_ptr->md_y, md_ptr->md_x);
index f4f2e41..67552bd 100644 (file)
@@ -183,9 +183,7 @@ bool ItemMagicApplier::set_fixed_artifact_generation_info()
     }
 
     apply_artifact(this->player_ptr, this->o_ptr);
-    auto &a_ref = artifacts_info.at(this->o_ptr->fixed_artifact_idx);
-    a_ref.is_generated = true;
-
+    ArtifactsInfo::get_instance().get_artifact(this->o_ptr->fixed_artifact_idx).is_generated = true;
     return true;
 }
 
index bf024de..5cd471c 100644 (file)
@@ -58,10 +58,10 @@ bool object_is_quest_target(QuestId quest_idx, const ItemEntity *o_ptr)
         return false;
     }
 
-    const auto &a_ref = artifacts_info.at(a_idx);
-    if (a_ref.gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+    if (artifact.gen_flags.has(ItemGenerationTraitType::INSTA_ART)) {
         return false;
     }
 
-    return o_ptr->bi_key == a_ref.bi_key;
+    return o_ptr->bi_key == artifact.bi_key;
 }
index 88a6b63..31c171f 100644 (file)
@@ -56,7 +56,7 @@ TrFlags object_flags(const ItemEntity *o_ptr)
     auto flags = baseitem.flags;
 
     if (o_ptr->is_fixed_artifact()) {
-        flags = artifacts_info.at(o_ptr->fixed_artifact_idx).flags;
+        flags = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx).flags;
     }
 
     if (o_ptr->is_ego()) {
@@ -105,7 +105,7 @@ TrFlags object_flags_known(const ItemEntity *o_ptr)
 
     if (o_ptr->is_fully_known()) {
         if (o_ptr->is_fixed_artifact()) {
-            flags = artifacts_info.at(o_ptr->fixed_artifact_idx).flags;
+            flags = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx).flags;
         }
 
         flags.set(o_ptr->art_flags);
index 46d5ef3..db3614f 100644 (file)
@@ -26,8 +26,8 @@ PRICE flag_cost(const ItemEntity *o_ptr, int plusses)
     flags.reset(baseitem.flags);
 
     if (o_ptr->is_fixed_artifact()) {
-        const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-        flags.reset(a_ref.flags);
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+        flags.reset(artifact.flags);
     } else if (o_ptr->is_ego()) {
         const auto &e_ref = egos_info[o_ptr->ego_idx];
         flags.reset(e_ref.flags);
index c489fd9..5954db0 100644 (file)
@@ -46,12 +46,12 @@ PRICE object_value_real(const ItemEntity *o_ptr)
     PRICE value = baseitems_info[o_ptr->bi_id].cost;
     auto flags = object_flags(o_ptr);
     if (o_ptr->is_fixed_artifact()) {
-        const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-        if (!a_ref.cost) {
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+        if (!artifact.cost) {
             return 0;
         }
 
-        value = a_ref.cost;
+        value = artifact.cost;
         value += flag_cost(o_ptr, o_ptr->pval);
         return value;
     } else if (o_ptr->is_ego()) {
index 93eea7f..76b1109 100644 (file)
@@ -41,7 +41,8 @@ bool screen_object(PlayerType *player_ptr, ItemEntity *o_ptr, BIT_FLAGS mode)
     int trivial_info = 0;
     auto flags = object_flags(o_ptr);
 
-    const auto item_text = o_ptr->is_fixed_artifact() ? artifacts_info.at(o_ptr->fixed_artifact_idx).text.data() : baseitems_info[o_ptr->bi_id].text.data();
+    const auto &artifacts = ArtifactsInfo::get_instance();
+    const auto item_text = o_ptr->is_fixed_artifact() ? artifacts.get_artifact(o_ptr->fixed_artifact_idx).text.data() : baseitems_info[o_ptr->bi_id].text.data();
     const auto item_text_lines = shape_buffer(item_text, 77 - 15);
 
     int i = 0;
index 020447d..86ffe46 100644 (file)
@@ -84,9 +84,9 @@ void calc_android_exp(PlayerType *player_ptr)
         q_ptr->curse_flags.clear();
 
         if (o_ptr->is_fixed_artifact()) {
-            const auto &fixed_artifact = artifacts_info.at(o_ptr->fixed_artifact_idx);
-            level = (level + std::max(fixed_artifact.level - 8, 5)) / 2;
-            level += std::min(20, fixed_artifact.rarity / (fixed_artifact.gen_flags.has(ItemGenerationTraitType::INSTA_ART) ? 10 : 3));
+            const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+            level = (level + std::max(artifact.level - 8, 5)) / 2;
+            level += std::min(20, artifact.rarity / (artifact.gen_flags.has(ItemGenerationTraitType::INSTA_ART) ? 10 : 3));
         } else if (o_ptr->is_ego()) {
             level += std::max(3, (egos_info[o_ptr->ego_idx].rating - 5) / 2);
         } else if (o_ptr->is_random_artifact()) {
index ae8e880..35b4c1a 100644 (file)
@@ -171,10 +171,9 @@ static bool wr_savefile_new(PlayerType *player_ptr, SaveType type)
     auto max_a_num = enum2i(artifacts_info.rbegin()->first);
     tmp16u = max_a_num + 1;
     wr_u16b(tmp16u);
-    ArtifactType dummy;
     for (auto i = 0U; i < tmp16u; i++) {
         const auto a_idx = i2enum<FixedArtifactId>(i);
-        const auto &artifact = (i > 0) ? artifacts_info.at(a_idx) : dummy;
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
         wr_bool(artifact.is_generated);
         wr_s16b(artifact.floor_id);
     }
index bd9c7e3..520e2e8 100644 (file)
@@ -18,7 +18,7 @@
  */
 void get_bloody_moon_flags(ItemEntity *o_ptr)
 {
-    o_ptr->art_flags = artifacts_info.at(FixedArtifactId::BLOOD).flags;
+    o_ptr->art_flags = ArtifactsInfo::get_instance().get_artifact(FixedArtifactId::BLOOD).flags;
 
     int dummy = randint1(2) + randint1(2);
     for (int i = 0; i < dummy; i++) {
index df2f39f..52bc6ef 100644 (file)
@@ -340,13 +340,14 @@ bool destroy_area(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION r,
             /* During generation, destroyed artifacts are "preserved" */
             if (preserve_mode || in_generate) {
                 /* Scan all objects in the grid */
+                const auto &artifacts = ArtifactsInfo::get_instance();
                 for (const auto this_o_idx : g_ptr->o_idx_list) {
                     ItemEntity *o_ptr;
                     o_ptr = &floor_ptr->o_list[this_o_idx];
 
                     /* Hack -- Preserve unknown artifacts */
                     if (o_ptr->is_fixed_artifact() && (!o_ptr->is_known() || in_generate)) {
-                        artifacts_info.at(o_ptr->fixed_artifact_idx).is_generated = false;
+                        artifacts.get_artifact(o_ptr->fixed_artifact_idx).is_generated = false;
 
                         if (in_generate && cheat_peek) {
                             const auto item_name = describe_flavor(player_ptr, o_ptr, (OD_NAME_ONLY | OD_STORE));
index 2b5f12a..d4e7191 100644 (file)
@@ -11,6 +11,8 @@ std::map<FixedArtifactId, ArtifactType> artifacts_info;
 
 ArtifactsInfo ArtifactsInfo::instance{};
 
+ArtifactType ArtifactsInfo::dummy{};
+
 ArtifactsInfo &ArtifactsInfo::get_instance()
 {
     return instance;
@@ -18,5 +20,9 @@ ArtifactsInfo &ArtifactsInfo::get_instance()
 
 ArtifactType &ArtifactsInfo::get_artifact(const FixedArtifactId id) const
 {
+    if (id == FixedArtifactId::NONE) {
+        return dummy;
+    }
+
     return artifacts_info.at(id);
 }
index b7ffe7c..903e60b 100644 (file)
@@ -56,4 +56,5 @@ public:
 private:
     ArtifactsInfo() = default;
     static ArtifactsInfo instance;
+    static ArtifactType dummy;
 };
index 450c9f8..07c3eac 100644 (file)
@@ -268,10 +268,12 @@ bool ang_sort_art_comp(PlayerType *player_ptr, vptr u, vptr v, int a, int b)
     int z2;
 
     /* Sort by total kills */
+    const auto &artifact_w1 = ArtifactsInfo::get_instance().get_artifact(w1);
+    const auto &artifact_w2 = ArtifactsInfo::get_instance().get_artifact(w2);
     if (*why >= 3) {
         /* Extract total kills */
-        z1 = enum2i(artifacts_info.at(w1).bi_key.tval());
-        z2 = enum2i(artifacts_info.at(w2).bi_key.tval());
+        z1 = enum2i(artifact_w1.bi_key.tval());
+        z2 = enum2i(artifact_w2.bi_key.tval());
 
         /* Compare total kills */
         if (z1 < z2) {
@@ -286,8 +288,8 @@ bool ang_sort_art_comp(PlayerType *player_ptr, vptr u, vptr v, int a, int b)
     /* Sort by monster level */
     if (*why >= 2) {
         /* Extract levels */
-        z1 = artifacts_info.at(w1).bi_key.sval().value();
-        z2 = artifacts_info.at(w2).bi_key.sval().value();
+        z1 = artifact_w1.bi_key.sval().value();
+        z2 = artifact_w2.bi_key.sval().value();
 
         /* Compare levels */
         if (z1 < z2) {
@@ -302,8 +304,8 @@ bool ang_sort_art_comp(PlayerType *player_ptr, vptr u, vptr v, int a, int b)
     /* Sort by monster experience */
     if (*why >= 1) {
         /* Extract experience */
-        z1 = artifacts_info.at(w1).level;
-        z2 = artifacts_info.at(w2).level;
+        z1 = artifact_w1.level;
+        z2 = artifact_w2.level;
 
         /* Compare experience */
         if (z1 < z2) {
index 1d6e295..a8de7cc 100644 (file)
@@ -259,26 +259,26 @@ static void analyze_misc_magic(ItemEntity *o_ptr, concptr *misc_list)
  */
 static void analyze_addition(ItemEntity *o_ptr, char *addition, size_t addition_sz)
 {
-    const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
     strcpy(addition, "");
 
-    if (a_ref.gen_flags.has_all_of({ ItemGenerationTraitType::XTRA_POWER, ItemGenerationTraitType::XTRA_H_RES })) {
+    if (artifact.gen_flags.has_all_of({ ItemGenerationTraitType::XTRA_POWER, ItemGenerationTraitType::XTRA_H_RES })) {
         angband_strcat(addition, _("能力and耐性", "Ability and Resistance"), addition_sz);
-    } else if (a_ref.gen_flags.has(ItemGenerationTraitType::XTRA_POWER)) {
+    } else if (artifact.gen_flags.has(ItemGenerationTraitType::XTRA_POWER)) {
         angband_strcat(addition, _("能力", "Ability"), addition_sz);
-        if (a_ref.gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
+        if (artifact.gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
             angband_strcat(addition, _("(1/2でand耐性)", "(plus Resistance about 1/2)"), addition_sz);
         }
-    } else if (a_ref.gen_flags.has(ItemGenerationTraitType::XTRA_H_RES)) {
+    } else if (artifact.gen_flags.has(ItemGenerationTraitType::XTRA_H_RES)) {
         angband_strcat(addition, _("耐性", "Resistance"), addition_sz);
-        if (a_ref.gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
+        if (artifact.gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
             angband_strcat(addition, _("(1/2でand能力)", "(plus Ability about 1/2)"), addition_sz);
         }
-    } else if (a_ref.gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
+    } else if (artifact.gen_flags.has(ItemGenerationTraitType::XTRA_RES_OR_POWER)) {
         angband_strcat(addition, _("能力or耐性", "Ability or Resistance"), addition_sz);
     }
 
-    if (a_ref.gen_flags.has(ItemGenerationTraitType::XTRA_DICE)) {
+    if (artifact.gen_flags.has(ItemGenerationTraitType::XTRA_DICE)) {
         if (strlen(addition) > 0) {
             angband_strcat(addition, _("、", ", "), addition_sz);
         }
@@ -296,9 +296,10 @@ static void analyze_addition(ItemEntity *o_ptr, char *addition, size_t addition_
  */
 static void analyze_misc(ItemEntity *o_ptr, char *misc_desc, size_t misc_desc_sz)
 {
-    const auto &a_ref = artifacts_info.at(o_ptr->fixed_artifact_idx);
-    strnfmt(misc_desc, misc_desc_sz, _("レベル %d, 希少度 %u, %d.%d kg, $%ld", "Level %d, Rarity %u, %d.%d lbs, %ld Gold"), (int)a_ref.level, a_ref.rarity,
-        _(lb_to_kg_integer(a_ref.weight), a_ref.weight / 10), _(lb_to_kg_fraction(a_ref.weight), a_ref.weight % 10), (long int)a_ref.cost);
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(o_ptr->fixed_artifact_idx);
+    const auto *mes = _("レベル %d, 希少度 %u, %d.%d kg, $%ld", "Level %d, Rarity %u, %d.%d lbs, %ld Gold");
+    strnfmt(misc_desc, misc_desc_sz, mes, (int)artifact.level, artifact.rarity,
+        _(lb_to_kg_integer(artifact.weight), artifact.weight / 10), _(lb_to_kg_fraction(artifact.weight), artifact.weight % 10), (long int)artifact.cost);
 }
 
 /*!
index f2b1291..b40deab 100644 (file)
@@ -68,26 +68,26 @@ void spoiler_outlist(concptr header, concptr *list, char separator)
  */
 static bool make_fake_artifact(ItemEntity *o_ptr, FixedArtifactId fixed_artifact_idx)
 {
-    auto &a_ref = artifacts_info.at(fixed_artifact_idx);
-    if (a_ref.name.empty()) {
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(fixed_artifact_idx);
+    if (artifact.name.empty()) {
         return false;
     }
 
-    const auto bi_id = lookup_baseitem_id(a_ref.bi_key);
+    const auto bi_id = lookup_baseitem_id(artifact.bi_key);
     if (bi_id == 0) {
         return false;
     }
 
     o_ptr->prep(bi_id);
     o_ptr->fixed_artifact_idx = fixed_artifact_idx;
-    o_ptr->pval = a_ref.pval;
-    o_ptr->ac = a_ref.ac;
-    o_ptr->dd = a_ref.dd;
-    o_ptr->ds = a_ref.ds;
-    o_ptr->to_a = a_ref.to_a;
-    o_ptr->to_h = a_ref.to_h;
-    o_ptr->to_d = a_ref.to_d;
-    o_ptr->weight = a_ref.weight;
+    o_ptr->pval = artifact.pval;
+    o_ptr->ac = artifact.ac;
+    o_ptr->dd = artifact.dd;
+    o_ptr->ds = artifact.ds;
+    o_ptr->to_a = artifact.to_a;
+    o_ptr->to_h = artifact.to_h;
+    o_ptr->to_d = artifact.to_d;
+    o_ptr->weight = artifact.weight;
     return true;
 }
 
index 07b3f31..689548f 100644 (file)
@@ -186,7 +186,7 @@ void wiz_restore_aware_flag_of_fixed_arfifact(FixedArtifactId reset_artifact_idx
         }
     }
 
-    artifacts_info.at(i2enum<FixedArtifactId>(int_a_idx)).is_generated = aware;
+    ArtifactsInfo::get_instance().get_artifact(i2enum<FixedArtifactId>(int_a_idx)).is_generated = aware;
     msg_print(aware ? "Modified." : "Restored.");
 }
 
@@ -406,8 +406,9 @@ static void wiz_statistics(PlayerType *player_ptr, ItemEntity *o_ptr)
     concptr p = "Enter number of items to roll: ";
     char tmp_val[80];
 
+    const auto &artifacts = ArtifactsInfo::get_instance();
     if (o_ptr->is_fixed_artifact()) {
-        artifacts_info.at(o_ptr->fixed_artifact_idx).is_generated = false;
+        artifacts.get_artifact(o_ptr->fixed_artifact_idx).is_generated = false;
     }
 
     uint32_t i, matches, better, worse, other, correct;
@@ -461,7 +462,7 @@ static void wiz_statistics(PlayerType *player_ptr, ItemEntity *o_ptr)
             q_ptr->wipe();
             make_object(player_ptr, q_ptr, mode);
             if (q_ptr->is_fixed_artifact()) {
-                artifacts_info.at(q_ptr->fixed_artifact_idx).is_generated = false;
+                artifacts.get_artifact(q_ptr->fixed_artifact_idx).is_generated = false;
             }
 
             if (o_ptr->bi_key != q_ptr->bi_key) {
@@ -486,7 +487,7 @@ static void wiz_statistics(PlayerType *player_ptr, ItemEntity *o_ptr)
     }
 
     if (o_ptr->is_fixed_artifact()) {
-        artifacts_info.at(o_ptr->fixed_artifact_idx).is_generated = true;
+        artifacts.get_artifact(o_ptr->fixed_artifact_idx).is_generated = true;
     }
 }
 
@@ -508,11 +509,12 @@ static void wiz_reroll_item(PlayerType *player_ptr, ItemEntity *o_ptr)
 
     char ch;
     bool changed = false;
+    const auto &artifacts = ArtifactsInfo::get_instance();
     while (true) {
         wiz_display_item(player_ptr, q_ptr);
         if (!get_com("[a]ccept, [w]orthless, [c]ursed, [n]ormal, [g]ood, [e]xcellent, [s]pecial? ", &ch, false)) {
             if (q_ptr->is_fixed_artifact()) {
-                artifacts_info.at(q_ptr->fixed_artifact_idx).is_generated = false;
+                artifacts.get_artifact(q_ptr->fixed_artifact_idx).is_generated = false;
                 q_ptr->fixed_artifact_idx = FixedArtifactId::NONE;
             }
 
@@ -526,7 +528,7 @@ static void wiz_reroll_item(PlayerType *player_ptr, ItemEntity *o_ptr)
         }
 
         if (q_ptr->is_fixed_artifact()) {
-            artifacts_info.at(q_ptr->fixed_artifact_idx).is_generated = false;
+            artifacts.get_artifact(q_ptr->fixed_artifact_idx).is_generated = false;
             q_ptr->fixed_artifact_idx = FixedArtifactId::NONE;
         }
 
@@ -1016,8 +1018,8 @@ WishResultType do_cmd_wishing(PlayerType *player_ptr, int prob, bool allow_art,
 
     if (a_ids.size() == 1) {
         const auto a_idx = a_ids.back();
-        auto &a_ref = artifacts_info.at(a_idx);
-        if (must || (ok_art && !a_ref.is_generated)) {
+        const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+        if (must || (ok_art && !artifact.is_generated)) {
             (void)create_named_art(player_ptr, a_idx, player_ptr->y, player_ptr->x);
         } else {
             wishing_puff_of_smoke();
@@ -1047,8 +1049,8 @@ WishResultType do_cmd_wishing(PlayerType *player_ptr, int prob, bool allow_art,
         }
 
         if (a_idx != FixedArtifactId::NONE) {
-            const auto &a_ref = artifacts_info.at(a_idx);
-            if (must || (ok_art && !a_ref.is_generated)) {
+            const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
+            if (must || (ok_art && !artifact.is_generated)) {
                 (void)create_named_art(player_ptr, a_idx, player_ptr->y, player_ptr->x);
             } else {
                 wishing_puff_of_smoke();
index 919ee03..fa9dcca 100644 (file)
@@ -266,9 +266,9 @@ void wiz_create_item(PlayerType *player_ptr)
  */
 static std::string wiz_make_named_artifact_desc(PlayerType *player_ptr, FixedArtifactId a_idx)
 {
-    const auto &a_ref = artifacts_info.at(a_idx);
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
     ItemEntity item;
-    item.prep(lookup_baseitem_id(a_ref.bi_key));
+    item.prep(lookup_baseitem_id(artifact.bi_key));
     item.fixed_artifact_idx = a_idx;
     object_known(&item);
     return describe_flavor(player_ptr, &item, OD_NAME_ONLY);
@@ -386,7 +386,7 @@ void wiz_create_named_art(PlayerType *player_ptr)
 
     screen_load();
     const auto a_idx = create_a_idx.value();
-    const auto &artifact = artifacts_info.at(a_idx);
+    const auto &artifact = ArtifactsInfo::get_instance().get_artifact(a_idx);
     if (artifact.is_generated) {
         msg_print("It's already allocated.");
         return;