OSDN Git Service

Merge branch 'develop' into macos-develop vauto3.0.1-beta12-5d2121ca2
authorEric Branlund <ebranlund@fastmail.com>
Wed, 15 May 2024 20:19:00 +0000 (14:19 -0600)
committerEric Branlund <ebranlund@fastmail.com>
Wed, 15 May 2024 20:19:00 +0000 (14:19 -0600)
src/birth/game-play-initializer.cpp
src/birth/inventory-initializer.cpp
src/core/visuals-reseter.cpp
src/item-info/flavor-initializer.cpp
src/racial/race-racial-command-setter.cpp
src/system/baseitem-info.cpp
src/system/baseitem-info.h

index 9f37ca2..aad5cc9 100644 (file)
 #include <string>
 
 /*!
- * @brief ベースアイテム構造体の鑑定済みフラグをリセットする。
- * @details
- * 不具合対策で0からリセットする(セーブは0から)
- */
-static void reset_baseitem_idenditication_flags()
-{
-    for (auto &baseitem : BaseitemList::get_instance()) {
-        baseitem.tried = false;
-        baseitem.aware = false;
-    }
-}
-
-/*!
  * @brief プレイヤー構造体の内容を初期値で消去する(名前を除く) / Clear all the global "character" data (without name)
  * @param player_ptr プレイヤーへの参照ポインタ
  * @details 少し長いが、これ1つで処理が完結しているので分割は見送る
@@ -79,7 +66,7 @@ void player_wipe_without_name(PlayerType *player_ptr)
         artifact.is_generated = false;
     }
 
-    reset_baseitem_idenditication_flags();
+    BaseitemList::get_instance().reset_identification_flags();
     for (auto &[r_idx, r_ref] : monraces_info) {
         if (!MonsterRace(r_ref.idx).is_valid()) {
             continue;
index 24a4bba..9d3a171 100644 (file)
@@ -280,5 +280,5 @@ void player_outfit(PlayerType *player_ptr)
         add_outfit(player_ptr, q_ptr);
     }
 
-    BaseitemList::get_instance().get_baseitem(lookup_baseitem_id({ ItemKindType::POTION, SV_POTION_WATER })).mark_as_aware();
+    BaseitemList::get_instance().mark_common_items_as_aware();
 }
index a3532a9..f85c86d 100644 (file)
@@ -19,16 +19,15 @@ void reset_visuals(PlayerType *player_ptr)
         }
     }
 
-    for (auto &baseitem : BaseitemList::get_instance()) {
-        baseitem.cc_config = baseitem.cc_def;
-    }
-
+    BaseitemList::get_instance().reset_all_visuals();
     for (auto &[monrace_id, monrace] : monraces_info) {
         monrace.x_attr = monrace.d_attr;
         monrace.x_char = monrace.d_char;
     }
 
-    concptr pref_file = use_graphics ? "graf.prf" : "font.prf";
+    const auto pref_file = use_graphics ? "graf.prf" : "font.prf";
     process_pref_file(player_ptr, pref_file);
-    process_pref_file(player_ptr, std::string(use_graphics ? "graf-" : "font-").append(player_ptr->base_name).append(".prf"));
+    std::stringstream ss;
+    ss << (use_graphics ? "graf-" : "font-") << player_ptr->base_name << ".prf";
+    process_pref_file(player_ptr, ss.str());
 }
index 6c51a4d..f63b810 100644 (file)
 #include "system/baseitem-info.h"
 
 /*!
- * @brief ベースアイテムの未確定名を共通tval間でシャッフルする / Shuffle flavor indices of a group of objects with given tval
- * @param tval シャッフルしたいtval
- * @details 巻物、各種魔道具などに利用される。
- */
-static void shuffle_flavors(ItemKindType tval)
-{
-    std::vector<std::reference_wrapper<IDX>> flavor_idx_ref_list;
-    auto &baseitems = BaseitemList::get_instance();
-    for (auto &baseitem : baseitems) {
-        if (baseitem.bi_key.tval() != tval) {
-            continue;
-        }
-
-        if (baseitem.flavor == 0) {
-            continue;
-        }
-
-        if (baseitem.flags.has(TR_FIXED_FLAVOR)) {
-            continue;
-        }
-
-        flavor_idx_ref_list.push_back(baseitem.flavor);
-    }
-
-    rand_shuffle(flavor_idx_ref_list.begin(), flavor_idx_ref_list.end());
-}
-
-/*!
  * @brief ゲーム開始時に行われるベースアイテムの初期化ルーチン
  */
 void initialize_items_flavor()
@@ -55,14 +27,7 @@ void initialize_items_flavor()
         baseitem.flavor = baseitem.idx;
     }
 
-    shuffle_flavors(ItemKindType::RING);
-    shuffle_flavors(ItemKindType::AMULET);
-    shuffle_flavors(ItemKindType::STAFF);
-    shuffle_flavors(ItemKindType::WAND);
-    shuffle_flavors(ItemKindType::ROD);
-    shuffle_flavors(ItemKindType::FOOD);
-    shuffle_flavors(ItemKindType::POTION);
-    shuffle_flavors(ItemKindType::SCROLL);
+    baseitems.shuffle_flavors();
     system.set_rng(rng_backup);
     for (auto &baseitem : baseitems) {
         if (!baseitem.is_valid()) {
index 309a1ba..b9873b7 100644 (file)
@@ -25,7 +25,7 @@ void set_mimic_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
         rpi = rpi_type(_("吸血", "Vampiric Drain"));
         rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl * 2);
         rpi.text = _("隣接したモンスター1体から生命力を吸い取る。吸い取った生命力によって満腹度があがる。",
-            "Drains and transfers HP from a monster near by you. You will also gain nutritional sustenance from this.");
+            "Drains and transfers HP from an adjacent monster. You will also gain nutritional sustenance from this.");
         rpi.min_level = 2;
         rpi.cost = 1 + (rc_ptr->lvl / 3);
         rpi.stat = A_CON;
@@ -125,7 +125,7 @@ void set_race_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
     case PlayerRaceType::HALF_OGRE:
         rpi = rpi_type(_("爆発のルーン", "Explosive Rune"));
         rpi.text = _("自分のいる床の上に、モンスターが上を通ろうとすると爆発するルーンを描く。",
-            "Sets a rune on the floor beneath you which exprodes if a monster through upon it. Monsters can try to disarm it.");
+            "Sets a rune on the floor beneath you which explodes if a monster passes over it. Monsters can try to disarm it.");
         rpi.min_level = 25;
         rpi.cost = 35;
         rpi.stat = A_INT;
@@ -153,7 +153,7 @@ void set_race_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
     case PlayerRaceType::CYCLOPS:
         rpi = rpi_type(_("岩石投げ", "Throw Boulder"));
         rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl * 3 / 2);
-        rpi.text = _("弱い魔法のボールを放つ", "Fires a weak boll of magic.");
+        rpi.text = _("弱い魔法のボールを放つ", "Fires a weak ball of magic.");
         rpi.min_level = 20;
         rpi.cost = 15;
         rpi.stat = A_STR;
@@ -182,7 +182,7 @@ void set_race_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
         rpi = rpi_type(_("酸の唾", "Spit Acid"));
         rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl);
         if (rc_ptr->lvl >= 25) {
-            rpi.text = _("酸のボールを放つ", "Fires a boll of acid.");
+            rpi.text = _("酸のボールを放つ", "Fires a ball of acid.");
         } else {
             rpi.text = _("酸の矢を放つ", "Fires a bolt of acid.");
         }
@@ -225,7 +225,7 @@ void set_race_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
     case PlayerRaceType::MIND_FLAYER:
         rpi = rpi_type(_("精神攻撃", "Mind Blast"));
         rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl);
-        rpi.text = _("モンスター1体に精神攻撃を行う。", "Deals PSI damage to a monster.");
+        rpi.text = _("モンスター1体に精神攻撃を行う。", "Deals PSI damage to a monster.");
         rpi.min_level = 15;
         rpi.cost = 12;
         rpi.stat = A_INT;
@@ -271,7 +271,7 @@ void set_race_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
         rpi = rpi_type(_("吸血", "Vampiric Drain"));
         rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl * 2);
         rpi.text = _("隣接したモンスター1体から生命力を吸い取る。吸い取った生命力によって満腹度があがる。",
-            "Drains and transfers HP from a monster near by you. You will also gain nutritional sustenance from this.");
+            "Drains and transfers HP from an adjacent monster. You will also gain nutritional sustenance from this.");
         rpi.min_level = 2;
         rpi.cost = 1 + (rc_ptr->lvl / 3);
         rpi.stat = A_CON;
@@ -334,7 +334,7 @@ void set_race_racial_command(PlayerType *player_ptr, rc_type *rc_ptr)
         } else if (player_ptr->lev < 45) {
             rpi = rpi_type(_("ビームキャノン", "Beam Cannon"));
             rpi.info = format("%s%d", KWD_DAM, rc_ptr->lvl * 2);
-            rpi.text = _("弱い魔法のビームを放つ。", "Fires a beam bolt of magic.");
+            rpi.text = _("弱い魔法のビームを放つ。", "Fires a beam of magic.");
             rpi.min_level = 35;
             rpi.cost = 40;
             rpi.fail = 15;
index d6a2ece..50992e4 100644 (file)
@@ -8,14 +8,17 @@
  */
 
 #include "system/baseitem-info.h"
+#include "object/object-kind-hook.h" // @todo 暫定、後で消す.
 #include "object/tval-types.h"
 #include "sv-definition/sv-armor-types.h"
 #include "sv-definition/sv-bow-types.h"
 #include "sv-definition/sv-food-types.h"
 #include "sv-definition/sv-lite-types.h"
 #include "sv-definition/sv-other-types.h"
+#include "sv-definition/sv-potion-types.h"
 #include "sv-definition/sv-protector-types.h"
 #include "sv-definition/sv-rod-types.h"
+#include "sv-definition/sv-staff-types.h"
 #include "sv-definition/sv-weapon-types.h"
 #include "system/angband-exceptions.h"
 #include "util/string-processor.h"
@@ -794,3 +797,76 @@ void BaseitemList::resize(size_t new_size)
 {
     this->baseitems.resize(new_size);
 }
+
+void BaseitemList::reset_all_visuals()
+{
+    for (auto &baseitem : this->baseitems) {
+        baseitem.cc_config = baseitem.cc_def;
+    }
+}
+
+void BaseitemList::shuffle_flavors()
+{
+    this->shuffle_flavors(ItemKindType::RING);
+    this->shuffle_flavors(ItemKindType::AMULET);
+    this->shuffle_flavors(ItemKindType::STAFF);
+    this->shuffle_flavors(ItemKindType::WAND);
+    this->shuffle_flavors(ItemKindType::ROD);
+    this->shuffle_flavors(ItemKindType::FOOD);
+    this->shuffle_flavors(ItemKindType::POTION);
+    this->shuffle_flavors(ItemKindType::SCROLL);
+}
+
+/*!
+ * @brief ベースアイテムの鑑定済みフラグをリセットする
+ * @details 不具合対策で0からリセットする(セーブは0から)
+ */
+void BaseitemList::reset_identification_flags()
+{
+    for (auto &baseitem : this->baseitems) {
+        baseitem.tried = false;
+        baseitem.aware = false;
+    }
+}
+
+/*!
+ * @brief 未鑑定アイテム種別の内、ゲーム開始時から鑑定済とするアイテムの鑑定済フラグをONにする
+ * @todo 食料用の杖は該当種族 (ゴーレム/骸骨/ゾンビ/幽霊)では鑑定済だが、本来はこのメソッドで鑑定済にすべき.
+ */
+void BaseitemList::mark_common_items_as_aware()
+{
+    std::vector<BaseitemKey> bi_keys;
+    bi_keys.emplace_back(ItemKindType::POTION, SV_POTION_WATER);
+    bi_keys.emplace_back(ItemKindType::STAFF, SV_STAFF_NOTHING);
+    for (const auto &bi_key : bi_keys) {
+        const auto bi_id = lookup_baseitem_id(bi_key);
+        this->baseitems[bi_id].mark_as_aware();
+    }
+}
+
+/*!
+ * @brief ベースアイテムの未確定名を共通tval間でシャッフルする
+ * @param tval シャッフルしたいtval
+ * @details 巻物、各種魔道具などに利用される。
+ */
+void BaseitemList::shuffle_flavors(ItemKindType tval)
+{
+    std::vector<std::reference_wrapper<short>> flavors;
+    for (auto &baseitem : this->baseitems) {
+        if (baseitem.bi_key.tval() != tval) {
+            continue;
+        }
+
+        if (baseitem.flavor == 0) {
+            continue;
+        }
+
+        if (baseitem.flags.has(TR_FIXED_FLAVOR)) {
+            continue;
+        }
+
+        flavors.push_back(baseitem.flavor);
+    }
+
+    rand_shuffle(flavors.begin(), flavors.end());
+}
index 947d7d5..24ba399 100644 (file)
@@ -168,9 +168,16 @@ public:
     bool empty() const;
     void resize(size_t new_size);
 
+    void reset_all_visuals();
+    void shuffle_flavors();
+    void reset_identification_flags();
+    void mark_common_items_as_aware();
+
 private:
     BaseitemList() = default;
 
     static BaseitemList instance;
     std::vector<BaseitemInfo> baseitems{};
+
+    void shuffle_flavors(ItemKindType tval);
 };