OSDN Git Service

[Refactor] #3217 alloc_entry にget_baseitem() を追加した
authorHourier <66951241+Hourier@users.noreply.github.com>
Sun, 30 Apr 2023 15:30:10 +0000 (00:30 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Mon, 1 May 2023 09:14:34 +0000 (18:14 +0900)
src/system/alloc-entries.cpp
src/system/alloc-entries.h
src/wizard/wizard-item-modifier.cpp
src/world/world-object.cpp

index 17d80b3..3bfe963 100644 (file)
@@ -1,7 +1,13 @@
 #include "system/alloc-entries.h"
+#include "system/baseitem-info.h"
 
 /* The entries in the "race allocator table" */
 std::vector<alloc_entry> alloc_race_table;
 
 /* The entries in the "kind allocator table" */
 std::vector<alloc_entry> alloc_kind_table;
+
+BaseitemInfo &alloc_entry::get_baseitem() const
+{
+    return baseitems_info[this->index];
+}
index c9282b8..c753ebf 100644 (file)
  * Pass 1 is determined from allocation information
  * Pass 2 is determined from allocation restriction
  */
+class BaseitemInfo;
 struct alloc_entry {
     short index; /* The actual index */
 
     DEPTH level; /* Base dungeon level */
     PROB prob1; /* Probability, pass 1 */
     PROB prob2; /* Probability, pass 2 */
+
+    BaseitemInfo &get_baseitem() const;
 };
 
 extern std::vector<alloc_entry> alloc_race_table;
index e5c3c1a..403acef 100644 (file)
@@ -264,7 +264,7 @@ static void prt_alloc(const BaseitemKey &bi_key, TERM_LEN row, TERM_LEN col)
                 prob = entry.prob1 * i * BASEITEM_MAX_DEPTH / (entry.level - 1);
             }
 
-            const auto &baseitem = baseitems_info[entry.index];
+            const auto &baseitem = entry.get_baseitem();
             total[i] += prob / magnificant;
             total_frac += prob % magnificant;
 
index e6f4a69..528c598 100644 (file)
@@ -86,7 +86,7 @@ OBJECT_IDX get_obj_index(PlayerType *player_ptr, DEPTH level, BIT_FLAGS mode)
             break;
         }
 
-        const auto &baseitem = baseitems_info[entry.index];
+        const auto &baseitem = entry.get_baseitem();
         if ((mode & AM_FORBID_CHEST) && (baseitem.bi_key.tval() == ItemKindType::CHEST)) {
             continue;
         }