OSDN Git Service

[Refactor] #3187 関数マクロIS_FLG() をautopick_type::has() に差し替えた (autopick-entry.cpp のみ)
[hengbandforosx/hengbandosx.git] / src / autopick / autopick-entry.cpp
index 7e3d1a6..f0e1d40 100644 (file)
 #include "object-hook/hook-weapon.h"
 #include "object/item-use-flags.h"
 #include "object/object-info.h"
-#include "object/object-kind.h"
 #include "perception/object-perception.h"
 #include "player-base/player-class.h"
 #include "player/player-realm.h"
-#include "system/monster-race-definition.h"
-#include "system/object-type-definition.h"
+#include "system/baseitem-info.h"
+#include "system/item-entity.h"
+#include "system/monster-race-info.h"
 #include "system/player-type-definition.h"
 #include "util/quarks.h"
 #include "util/string-processor.h"
@@ -36,7 +36,7 @@ static char kanji_colon[] = ":";
  */
 bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
 {
-    if (str[0] && str[1] == ':')
+    if (str[0] && str[1] == ':') {
         switch (str[0]) {
         case '?':
         case '%':
@@ -45,8 +45,9 @@ bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
         case 'C':
             return false;
         }
+    }
 
-    entry->flag[0] = entry->flag[1] = 0L;
+    entry->flags[0] = entry->flags[1] = 0L;
     entry->dice = 0;
     entry->bonus = 0;
 
@@ -100,45 +101,56 @@ bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
             break;
         }
 
-        if (isupper(c))
+        if (isupper(c)) {
             c = (char)tolower(c);
+        }
 
         buf[i] = c;
     }
 
     buf[i] = '\0';
-    if (!allow_default && *buf == 0)
+    if (!allow_default && *buf == 0) {
         return false;
-    if (*buf == 0 && insc)
+    }
+    if (*buf == 0 && insc) {
         return false;
+    }
 
     concptr prev_ptr, ptr;
     ptr = prev_ptr = buf;
     concptr old_ptr = nullptr;
     while (old_ptr != ptr) {
         old_ptr = ptr;
-        if (MATCH_KEY(KEY_ALL))
+        if (MATCH_KEY(KEY_ALL)) {
             ADD_FLG(FLG_ALL);
-        if (MATCH_KEY(KEY_COLLECTING))
+        }
+        if (MATCH_KEY(KEY_COLLECTING)) {
             ADD_FLG(FLG_COLLECTING);
-        if (MATCH_KEY(KEY_UNAWARE))
+        }
+        if (MATCH_KEY(KEY_UNAWARE)) {
             ADD_FLG(FLG_UNAWARE);
-        if (MATCH_KEY(KEY_UNIDENTIFIED))
+        }
+        if (MATCH_KEY(KEY_UNIDENTIFIED)) {
             ADD_FLG(FLG_UNIDENTIFIED);
-        if (MATCH_KEY(KEY_IDENTIFIED))
+        }
+        if (MATCH_KEY(KEY_IDENTIFIED)) {
             ADD_FLG(FLG_IDENTIFIED);
-        if (MATCH_KEY(KEY_STAR_IDENTIFIED))
+        }
+        if (MATCH_KEY(KEY_STAR_IDENTIFIED)) {
             ADD_FLG(FLG_STAR_IDENTIFIED);
-        if (MATCH_KEY(KEY_BOOSTED))
+        }
+        if (MATCH_KEY(KEY_BOOSTED)) {
             ADD_FLG(FLG_BOOSTED);
+        }
 
         /*** Weapons whose dd*ds is more than nn ***/
         if (MATCH_KEY2(KEY_MORE_THAN)) {
             int k = 0;
             entry->dice = 0;
 
-            while (' ' == *ptr)
+            while (' ' == *ptr) {
                 ptr++;
+            }
 
             while ('0' <= *ptr && *ptr <= '9') {
                 entry->dice = 10 * entry->dice + (*ptr - '0');
@@ -149,8 +161,9 @@ bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
             if (k > 0 && k <= 2) {
                 (void)MATCH_KEY(KEY_DICE);
                 ADD_FLG(FLG_MORE_DICE);
-            } else
+            } else {
                 ptr = prev_ptr;
+            }
         }
 
         /*** Items whose magical bonus is more than n ***/
@@ -158,8 +171,9 @@ bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
             int k = 0;
             entry->bonus = 0;
 
-            while (' ' == *ptr)
+            while (' ' == *ptr) {
                 ptr++;
+            }
 
             while ('0' <= *ptr && *ptr <= '9') {
                 entry->bonus = 10 * entry->bonus + (*ptr - '0');
@@ -171,107 +185,131 @@ bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
 #ifdef JP
                 (void)MATCH_KEY(KEY_MORE_BONUS2);
 #else
-                if (' ' == *ptr)
+                if (' ' == *ptr) {
                     ptr++;
+                }
 #endif
                 ADD_FLG(FLG_MORE_BONUS);
-            } else
+            } else {
                 ptr = prev_ptr;
+            }
         }
 
-        if (MATCH_KEY(KEY_WORTHLESS))
+        if (MATCH_KEY(KEY_WORTHLESS)) {
             ADD_FLG(FLG_WORTHLESS);
-        if (MATCH_KEY(KEY_EGO))
+        }
+        if (MATCH_KEY(KEY_EGO)) {
             ADD_FLG(FLG_EGO);
-        if (MATCH_KEY(KEY_GOOD))
+        }
+        if (MATCH_KEY(KEY_GOOD)) {
             ADD_FLG(FLG_GOOD);
-        if (MATCH_KEY(KEY_NAMELESS))
+        }
+        if (MATCH_KEY(KEY_NAMELESS)) {
             ADD_FLG(FLG_NAMELESS);
-        if (MATCH_KEY(KEY_AVERAGE))
+        }
+        if (MATCH_KEY(KEY_AVERAGE)) {
             ADD_FLG(FLG_AVERAGE);
-        if (MATCH_KEY(KEY_RARE))
+        }
+        if (MATCH_KEY(KEY_RARE)) {
             ADD_FLG(FLG_RARE);
-        if (MATCH_KEY(KEY_COMMON))
+        }
+        if (MATCH_KEY(KEY_COMMON)) {
             ADD_FLG(FLG_COMMON);
-        if (MATCH_KEY(KEY_WANTED))
+        }
+        if (MATCH_KEY(KEY_WANTED)) {
             ADD_FLG(FLG_WANTED);
-        if (MATCH_KEY(KEY_UNIQUE))
+        }
+        if (MATCH_KEY(KEY_UNIQUE)) {
             ADD_FLG(FLG_UNIQUE);
-        if (MATCH_KEY(KEY_HUMAN))
+        }
+        if (MATCH_KEY(KEY_HUMAN)) {
             ADD_FLG(FLG_HUMAN);
-        if (MATCH_KEY(KEY_UNREADABLE))
+        }
+        if (MATCH_KEY(KEY_UNREADABLE)) {
             ADD_FLG(FLG_UNREADABLE);
-        if (MATCH_KEY(KEY_REALM1))
+        }
+        if (MATCH_KEY(KEY_REALM1)) {
             ADD_FLG(FLG_REALM1);
-        if (MATCH_KEY(KEY_REALM2))
+        }
+        if (MATCH_KEY(KEY_REALM2)) {
             ADD_FLG(FLG_REALM2);
-        if (MATCH_KEY(KEY_FIRST))
+        }
+        if (MATCH_KEY(KEY_FIRST)) {
             ADD_FLG(FLG_FIRST);
-        if (MATCH_KEY(KEY_SECOND))
+        }
+        if (MATCH_KEY(KEY_SECOND)) {
             ADD_FLG(FLG_SECOND);
-        if (MATCH_KEY(KEY_THIRD))
+        }
+        if (MATCH_KEY(KEY_THIRD)) {
             ADD_FLG(FLG_THIRD);
-        if (MATCH_KEY(KEY_FOURTH))
+        }
+        if (MATCH_KEY(KEY_FOURTH)) {
             ADD_FLG(FLG_FOURTH);
+        }
     }
 
     int prev_flg = -1;
-    if (MATCH_KEY2(KEY_ARTIFACT))
+    if (MATCH_KEY2(KEY_ARTIFACT)) {
         ADD_FLG_NOUN(FLG_ARTIFACT);
+    }
 
-    if (MATCH_KEY2(KEY_ITEMS))
+    if (MATCH_KEY2(KEY_ITEMS)) {
         ADD_FLG_NOUN(FLG_ITEMS);
-    else if (MATCH_KEY2(KEY_WEAPONS))
+    } else if (MATCH_KEY2(KEY_WEAPONS)) {
         ADD_FLG_NOUN(FLG_WEAPONS);
-    else if (MATCH_KEY2(KEY_FAVORITE_WEAPONS))
+    } else if (MATCH_KEY2(KEY_FAVORITE_WEAPONS)) {
         ADD_FLG_NOUN(FLG_FAVORITE_WEAPONS);
-    else if (MATCH_KEY2(KEY_ARMORS))
+    } else if (MATCH_KEY2(KEY_ARMORS)) {
         ADD_FLG_NOUN(FLG_ARMORS);
-    else if (MATCH_KEY2(KEY_MISSILES))
+    } else if (MATCH_KEY2(KEY_MISSILES)) {
         ADD_FLG_NOUN(FLG_MISSILES);
-    else if (MATCH_KEY2(KEY_DEVICES))
+    } else if (MATCH_KEY2(KEY_DEVICES)) {
         ADD_FLG_NOUN(FLG_DEVICES);
-    else if (MATCH_KEY2(KEY_LIGHTS))
+    } else if (MATCH_KEY2(KEY_LIGHTS)) {
         ADD_FLG_NOUN(FLG_LIGHTS);
-    else if (MATCH_KEY2(KEY_JUNKS))
+    } else if (MATCH_KEY2(KEY_JUNKS)) {
         ADD_FLG_NOUN(FLG_JUNKS);
-    else if (MATCH_KEY2(KEY_CORPSES))
+    } else if (MATCH_KEY2(KEY_CORPSES)) {
         ADD_FLG_NOUN(FLG_CORPSES);
-    else if (MATCH_KEY2(KEY_SPELLBOOKS))
+    } else if (MATCH_KEY2(KEY_SPELLBOOKS)) {
         ADD_FLG_NOUN(FLG_SPELLBOOKS);
-    else if (MATCH_KEY2(KEY_HAFTED))
+    } else if (MATCH_KEY2(KEY_HAFTED)) {
         ADD_FLG_NOUN(FLG_HAFTED);
-    else if (MATCH_KEY2(KEY_SHIELDS))
+    } else if (MATCH_KEY2(KEY_SHIELDS)) {
         ADD_FLG_NOUN(FLG_SHIELDS);
-    else if (MATCH_KEY2(KEY_BOWS))
+    } else if (MATCH_KEY2(KEY_BOWS)) {
         ADD_FLG_NOUN(FLG_BOWS);
-    else if (MATCH_KEY2(KEY_RINGS))
+    } else if (MATCH_KEY2(KEY_RINGS)) {
         ADD_FLG_NOUN(FLG_RINGS);
-    else if (MATCH_KEY2(KEY_AMULETS))
+    } else if (MATCH_KEY2(KEY_AMULETS)) {
         ADD_FLG_NOUN(FLG_AMULETS);
-    else if (MATCH_KEY2(KEY_SUITS))
+    } else if (MATCH_KEY2(KEY_SUITS)) {
         ADD_FLG_NOUN(FLG_SUITS);
-    else if (MATCH_KEY2(KEY_CLOAKS))
+    } else if (MATCH_KEY2(KEY_CLOAKS)) {
         ADD_FLG_NOUN(FLG_CLOAKS);
-    else if (MATCH_KEY2(KEY_HELMS))
+    } else if (MATCH_KEY2(KEY_HELMS)) {
         ADD_FLG_NOUN(FLG_HELMS);
-    else if (MATCH_KEY2(KEY_GLOVES))
+    } else if (MATCH_KEY2(KEY_GLOVES)) {
         ADD_FLG_NOUN(FLG_GLOVES);
-    else if (MATCH_KEY2(KEY_BOOTS))
+    } else if (MATCH_KEY2(KEY_BOOTS)) {
         ADD_FLG_NOUN(FLG_BOOTS);
+    }
 
-    if (*ptr == ':')
+    if (*ptr == ':') {
         ptr++;
+    }
 #ifdef JP
-    else if (ptr[0] == kanji_colon[0] && ptr[1] == kanji_colon[1])
+    else if (ptr[0] == kanji_colon[0] && ptr[1] == kanji_colon[1]) {
         ptr += 2;
+    }
 #endif
     else if (*ptr == '\0') {
-        if (prev_flg == -1)
+        if (prev_flg == -1) {
             ADD_FLG_NOUN(FLG_ITEMS);
+        }
     } else {
         if (prev_flg != -1) {
-            entry->flag[prev_flg / 32] &= ~(1UL << (prev_flg % 32));
+            entry->flags[prev_flg / 32] &= ~(1UL << (prev_flg % 32));
             ptr = prev_ptr;
         }
     }
@@ -286,16 +324,14 @@ bool autopick_new_entry(autopick_type *entry, concptr str, bool allow_default)
 /*!
  * @brief Get auto-picker entry from o_ptr.
  */
-void autopick_entry_from_object(PlayerType *player_ptr, autopick_type *entry, ObjectType *o_ptr)
+void autopick_entry_from_object(PlayerType *player_ptr, autopick_type *entry, ItemEntity *o_ptr)
 {
     /* Assume that object name is to be added */
     bool name = true;
-    GAME_TEXT name_str[MAX_NLEN + 32];
-    name_str[0] = '\0';
-    auto insc = quark_str(o_ptr->inscription);
-    entry->insc = insc != nullptr ? insc : "";
+    entry->name.clear();
+    entry->insc = o_ptr->inscription.value_or("");
     entry->action = DO_AUTOPICK | DO_DISPLAY;
-    entry->flag[0] = entry->flag[1] = 0L;
+    entry->flags[0] = entry->flags[1] = 0L;
     entry->dice = 0;
 
     // エゴ銘が邪魔かもしれないので、デフォルトで「^」は付けない.
@@ -347,35 +383,38 @@ void autopick_entry_from_object(PlayerType *player_ptr, autopick_type *entry, Ob
                  * are almost meaningless.
                  * Register the ego type only.
                  */
-                auto *e_ptr = &e_info[o_ptr->ego_idx];
+                auto *e_ptr = &egos_info[o_ptr->ego_idx];
 #ifdef JP
                 /* エゴ銘には「^」マークが使える */
-                sprintf(name_str, "^%s", e_ptr->name.c_str());
+                entry->name = "^";
+                entry->name.append(e_ptr->name);
 #else
-                /* We ommit the basename and cannot use the ^ mark */
-                strcpy(name_str, e_ptr->name.c_str());
+                /* We omit the basename and cannot use the ^ mark */
+                entry->name = e_ptr->name;
 #endif
                 name = false;
-                if (!o_ptr->is_rare())
+                if (!o_ptr->is_rare()) {
                     ADD_FLG(FLG_COMMON);
+                }
             }
 
             ADD_FLG(FLG_EGO);
-        } else if (o_ptr->is_artifact())
+        } else if (o_ptr->is_fixed_or_random_artifact()) {
             ADD_FLG(FLG_ARTIFACT);
-        else {
-            if (o_ptr->is_equipment())
+        else {
+            if (o_ptr->is_equipment()) {
                 ADD_FLG(FLG_NAMELESS);
+            }
 
             is_hat_added = true;
         }
     }
 
     if (o_ptr->is_melee_weapon()) {
-        auto *k_ptr = &k_info[o_ptr->k_idx];
-
-        if ((o_ptr->dd != k_ptr->dd) || (o_ptr->ds != k_ptr->ds))
+        const auto &baseitem = baseitems_info[o_ptr->bi_id];
+        if ((o_ptr->dd != baseitem.dd) || (o_ptr->ds != baseitem.ds)) {
             ADD_FLG(FLG_BOOSTED);
+        }
     }
 
     if (object_is_bounty(player_ptr, o_ptr)) {
@@ -383,249 +422,289 @@ void autopick_entry_from_object(PlayerType *player_ptr, autopick_type *entry, Ob
         ADD_FLG(FLG_WANTED);
     }
 
-    if ((o_ptr->tval == ItemKindType::CORPSE || o_ptr->tval == ItemKindType::STATUE) && r_info[o_ptr->pval].kind_flags.has(MonsterKindType::UNIQUE)) {
+    const auto r_idx = i2enum<MonsterRaceId>(o_ptr->pval);
+    const auto &bi_key = o_ptr->bi_key;
+    const auto tval = bi_key.tval();
+    if ((tval == ItemKindType::CORPSE || tval == ItemKindType::STATUE) && monraces_info[r_idx].kind_flags.has(MonsterKindType::UNIQUE)) {
         ADD_FLG(FLG_UNIQUE);
     }
 
-    if (o_ptr->tval == ItemKindType::CORPSE && angband_strchr("pht", r_info[o_ptr->pval].d_char)) {
+    if (tval == ItemKindType::CORPSE && angband_strchr("pht", monraces_info[r_idx].d_char)) {
         ADD_FLG(FLG_HUMAN);
     }
 
-    if (o_ptr->tval >= ItemKindType::LIFE_BOOK && !check_book_realm(player_ptr, o_ptr->tval, o_ptr->sval)) {
+    if (o_ptr->is_spell_book() && !check_book_realm(player_ptr, bi_key)) {
         ADD_FLG(FLG_UNREADABLE);
-        if (o_ptr->tval != ItemKindType::ARCANE_BOOK)
+        if (tval != ItemKindType::ARCANE_BOOK) {
             name = false;
+        }
     }
 
     PlayerClass pc(player_ptr);
     auto realm_except_class = pc.equals(PlayerClassType::SORCERER) || pc.equals(PlayerClassType::RED_MAGE);
 
-    if ((get_realm1_book(player_ptr) == o_ptr->tval) && !realm_except_class) {
+    if ((get_realm1_book(player_ptr) == tval) && !realm_except_class) {
         ADD_FLG(FLG_REALM1);
         name = false;
     }
 
-    if ((get_realm2_book(player_ptr) == o_ptr->tval) && !realm_except_class) {
+    if ((get_realm2_book(player_ptr) == tval) && !realm_except_class) {
         ADD_FLG(FLG_REALM2);
         name = false;
     }
 
-    if (o_ptr->tval >= ItemKindType::LIFE_BOOK && 0 == o_ptr->sval)
+    const auto sval = bi_key.sval();
+    if (o_ptr->is_spell_book() && (sval == 0)) {
         ADD_FLG(FLG_FIRST);
-    if (o_ptr->tval >= ItemKindType::LIFE_BOOK && 1 == o_ptr->sval)
+    }
+    if (o_ptr->is_spell_book() && (sval == 1)) {
         ADD_FLG(FLG_SECOND);
-    if (o_ptr->tval >= ItemKindType::LIFE_BOOK && 2 == o_ptr->sval)
+    }
+    if (o_ptr->is_spell_book() && (sval == 2)) {
         ADD_FLG(FLG_THIRD);
-    if (o_ptr->tval >= ItemKindType::LIFE_BOOK && 3 == o_ptr->sval)
+    }
+    if (o_ptr->is_spell_book() && (sval == 3)) {
         ADD_FLG(FLG_FOURTH);
+    }
 
-    if (o_ptr->is_ammo())
+    if (o_ptr->is_ammo()) {
         ADD_FLG(FLG_MISSILES);
-    else if (o_ptr->tval == ItemKindType::SCROLL || o_ptr->tval == ItemKindType::STAFF || o_ptr->tval == ItemKindType::WAND || o_ptr->tval == ItemKindType::ROD)
+    } else if (tval == ItemKindType::SCROLL || o_ptr->is_wand_staff() || o_ptr->is_wand_rod()) {
         ADD_FLG(FLG_DEVICES);
-    else if (o_ptr->tval == ItemKindType::LITE)
+    } else if (tval == ItemKindType::LITE) {
         ADD_FLG(FLG_LIGHTS);
-    else if (o_ptr->tval == ItemKindType::SKELETON || o_ptr->tval == ItemKindType::BOTTLE || o_ptr->tval == ItemKindType::JUNK || o_ptr->tval == ItemKindType::STATUE)
+    } else if (o_ptr->is_junk()) {
         ADD_FLG(FLG_JUNKS);
-    else if (o_ptr->tval == ItemKindType::CORPSE)
+    } else if (tval == ItemKindType::CORPSE) {
         ADD_FLG(FLG_CORPSES);
-    else if (o_ptr->tval >= ItemKindType::LIFE_BOOK)
+    } else if (o_ptr->is_spell_book()) {
         ADD_FLG(FLG_SPELLBOOKS);
-    else if (o_ptr->tval == ItemKindType::POLEARM || o_ptr->tval == ItemKindType::SWORD || o_ptr->tval == ItemKindType::DIGGING || o_ptr->tval == ItemKindType::HAFTED)
+    } else if (o_ptr->is_melee_weapon()) {
         ADD_FLG(FLG_WEAPONS);
-    else if (o_ptr->tval == ItemKindType::SHIELD)
+    } else if (tval == ItemKindType::SHIELD) {
         ADD_FLG(FLG_SHIELDS);
-    else if (o_ptr->tval == ItemKindType::BOW)
+    } else if (tval == ItemKindType::BOW) {
         ADD_FLG(FLG_BOWS);
-    else if (o_ptr->tval == ItemKindType::RING)
+    } else if (tval == ItemKindType::RING) {
         ADD_FLG(FLG_RINGS);
-    else if (o_ptr->tval == ItemKindType::AMULET)
+    } else if (tval == ItemKindType::AMULET) {
         ADD_FLG(FLG_AMULETS);
-    else if (o_ptr->tval == ItemKindType::DRAG_ARMOR || o_ptr->tval == ItemKindType::HARD_ARMOR || o_ptr->tval == ItemKindType::SOFT_ARMOR)
+    } else if (o_ptr->is_armour()) {
         ADD_FLG(FLG_SUITS);
-    else if (o_ptr->tval == ItemKindType::CLOAK)
+    } else if (tval == ItemKindType::CLOAK) {
         ADD_FLG(FLG_CLOAKS);
-    else if (o_ptr->tval == ItemKindType::HELM)
+    } else if (tval == ItemKindType::HELM) {
         ADD_FLG(FLG_HELMS);
-    else if (o_ptr->tval == ItemKindType::GLOVES)
+    } else if (tval == ItemKindType::GLOVES) {
         ADD_FLG(FLG_GLOVES);
-    else if (o_ptr->tval == ItemKindType::BOOTS)
+    } else if (tval == ItemKindType::BOOTS) {
         ADD_FLG(FLG_BOOTS);
+    }
 
     if (!name) {
-        str_tolower(name_str);
-        entry->name = name_str;
+        str_tolower(entry->name.data());
         return;
     }
 
-    GAME_TEXT o_name[MAX_NLEN];
-    describe_flavor(player_ptr, o_name, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL | OD_NAME_ONLY));
+    const auto item_name = describe_flavor(player_ptr, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NO_PLURAL | OD_NAME_ONLY));
 
     /*
      * If necessary, add a '^' which indicates the
      * beginning of line.
      */
-    sprintf(name_str, "%s%s", is_hat_added ? "^" : "", o_name);
-    str_tolower(name_str);
-    entry->name = name_str;
+    entry->name = std::string(is_hat_added ? "^" : "").append(item_name);
+    str_tolower(entry->name.data());
 }
 
 /*!
  * @brief Reconstruct preference line from entry
  */
-concptr autopick_line_from_entry(autopick_type *entry)
+concptr autopick_line_from_entry(const autopick_type &entry)
 {
-    char buf[MAX_LINELEN];
-    *buf = '\0';
-    if (!(entry->action & DO_DISPLAY))
+    char buf[MAX_LINELEN]{};
+    if (!(entry.action & DO_DISPLAY)) {
         strcat(buf, "(");
-    if (entry->action & DO_QUERY_AUTOPICK)
+    }
+    if (entry.action & DO_QUERY_AUTOPICK) {
         strcat(buf, ";");
-    if (entry->action & DO_AUTODESTROY)
+    }
+    if (entry.action & DO_AUTODESTROY) {
         strcat(buf, "!");
-    if (entry->action & DONT_AUTOPICK)
+    }
+    if (entry.action & DONT_AUTOPICK) {
         strcat(buf, "~");
+    }
 
     char *ptr;
     ptr = buf;
-    if (IS_FLG(FLG_ALL))
+    if (entry.has(FLG_ALL)) {
         ADD_KEY(KEY_ALL);
-    if (IS_FLG(FLG_COLLECTING))
+    }
+    if (entry.has(FLG_COLLECTING)) {
         ADD_KEY(KEY_COLLECTING);
-    if (IS_FLG(FLG_UNAWARE))
+    }
+    if (entry.has(FLG_UNAWARE)) {
         ADD_KEY(KEY_UNAWARE);
-    if (IS_FLG(FLG_UNIDENTIFIED))
+    }
+    if (entry.has(FLG_UNIDENTIFIED)) {
         ADD_KEY(KEY_UNIDENTIFIED);
-    if (IS_FLG(FLG_IDENTIFIED))
+    }
+    if (entry.has(FLG_IDENTIFIED)) {
         ADD_KEY(KEY_IDENTIFIED);
-    if (IS_FLG(FLG_STAR_IDENTIFIED))
+    }
+    if (entry.has(FLG_STAR_IDENTIFIED)) {
         ADD_KEY(KEY_STAR_IDENTIFIED);
-    if (IS_FLG(FLG_BOOSTED))
+    }
+    if (entry.has(FLG_BOOSTED)) {
         ADD_KEY(KEY_BOOSTED);
+    }
 
-    if (IS_FLG(FLG_MORE_DICE)) {
+    if (entry.has(FLG_MORE_DICE)) {
         ADD_KEY(KEY_MORE_THAN);
-        strcat(ptr, format("%d", entry->dice));
+        strcat(ptr, format("%d", entry.dice).data());
         ADD_KEY(KEY_DICE);
     }
 
-    if (IS_FLG(FLG_MORE_BONUS)) {
+    if (entry.has(FLG_MORE_BONUS)) {
         ADD_KEY(KEY_MORE_BONUS);
-        strcat(ptr, format("%d", entry->bonus));
+        strcat(ptr, format("%d", entry.bonus).data());
         ADD_KEY(KEY_MORE_BONUS2);
     }
 
-    if (IS_FLG(FLG_UNREADABLE))
+    if (entry.has(FLG_UNREADABLE)) {
         ADD_KEY(KEY_UNREADABLE);
-    if (IS_FLG(FLG_REALM1))
+    }
+    if (entry.has(FLG_REALM1)) {
         ADD_KEY(KEY_REALM1);
-    if (IS_FLG(FLG_REALM2))
+    }
+    if (entry.has(FLG_REALM2)) {
         ADD_KEY(KEY_REALM2);
-    if (IS_FLG(FLG_FIRST))
+    }
+    if (entry.has(FLG_FIRST)) {
         ADD_KEY(KEY_FIRST);
-    if (IS_FLG(FLG_SECOND))
+    }
+    if (entry.has(FLG_SECOND)) {
         ADD_KEY(KEY_SECOND);
-    if (IS_FLG(FLG_THIRD))
+    }
+    if (entry.has(FLG_THIRD)) {
         ADD_KEY(KEY_THIRD);
-    if (IS_FLG(FLG_FOURTH))
+    }
+    if (entry.has(FLG_FOURTH)) {
         ADD_KEY(KEY_FOURTH);
-    if (IS_FLG(FLG_WANTED))
+    }
+    if (entry.has(FLG_WANTED)) {
         ADD_KEY(KEY_WANTED);
-    if (IS_FLG(FLG_UNIQUE))
+    }
+    if (entry.has(FLG_UNIQUE)) {
         ADD_KEY(KEY_UNIQUE);
-    if (IS_FLG(FLG_HUMAN))
+    }
+    if (entry.has(FLG_HUMAN)) {
         ADD_KEY(KEY_HUMAN);
-    if (IS_FLG(FLG_WORTHLESS))
+    }
+    if (entry.has(FLG_WORTHLESS)) {
         ADD_KEY(KEY_WORTHLESS);
-    if (IS_FLG(FLG_GOOD))
+    }
+    if (entry.has(FLG_GOOD)) {
         ADD_KEY(KEY_GOOD);
-    if (IS_FLG(FLG_NAMELESS))
+    }
+    if (entry.has(FLG_NAMELESS)) {
         ADD_KEY(KEY_NAMELESS);
-    if (IS_FLG(FLG_AVERAGE))
+    }
+    if (entry.has(FLG_AVERAGE)) {
         ADD_KEY(KEY_AVERAGE);
-    if (IS_FLG(FLG_RARE))
+    }
+    if (entry.has(FLG_RARE)) {
         ADD_KEY(KEY_RARE);
-    if (IS_FLG(FLG_COMMON))
+    }
+    if (entry.has(FLG_COMMON)) {
         ADD_KEY(KEY_COMMON);
-    if (IS_FLG(FLG_EGO))
+    }
+    if (entry.has(FLG_EGO)) {
         ADD_KEY(KEY_EGO);
+    }
 
-    if (IS_FLG(FLG_ARTIFACT))
+    if (entry.has(FLG_ARTIFACT)) {
         ADD_KEY(KEY_ARTIFACT);
+    }
 
     bool sepa_flag = true;
-    if (IS_FLG(FLG_ITEMS))
+    if (entry.has(FLG_ITEMS)) {
         ADD_KEY2(KEY_ITEMS);
-    else if (IS_FLG(FLG_WEAPONS))
+    } else if (entry.has(FLG_WEAPONS)) {
         ADD_KEY2(KEY_WEAPONS);
-    else if (IS_FLG(FLG_FAVORITE_WEAPONS))
+    } else if (entry.has(FLG_FAVORITE_WEAPONS)) {
         ADD_KEY2(KEY_FAVORITE_WEAPONS);
-    else if (IS_FLG(FLG_ARMORS))
+    } else if (entry.has(FLG_ARMORS)) {
         ADD_KEY2(KEY_ARMORS);
-    else if (IS_FLG(FLG_MISSILES))
+    } else if (entry.has(FLG_MISSILES)) {
         ADD_KEY2(KEY_MISSILES);
-    else if (IS_FLG(FLG_DEVICES))
+    } else if (entry.has(FLG_DEVICES)) {
         ADD_KEY2(KEY_DEVICES);
-    else if (IS_FLG(FLG_LIGHTS))
+    } else if (entry.has(FLG_LIGHTS)) {
         ADD_KEY2(KEY_LIGHTS);
-    else if (IS_FLG(FLG_JUNKS))
+    } else if (entry.has(FLG_JUNKS)) {
         ADD_KEY2(KEY_JUNKS);
-    else if (IS_FLG(FLG_CORPSES))
+    } else if (entry.has(FLG_CORPSES)) {
         ADD_KEY2(KEY_CORPSES);
-    else if (IS_FLG(FLG_SPELLBOOKS))
+    } else if (entry.has(FLG_SPELLBOOKS)) {
         ADD_KEY2(KEY_SPELLBOOKS);
-    else if (IS_FLG(FLG_HAFTED))
+    } else if (entry.has(FLG_HAFTED)) {
         ADD_KEY2(KEY_HAFTED);
-    else if (IS_FLG(FLG_SHIELDS))
+    } else if (entry.has(FLG_SHIELDS)) {
         ADD_KEY2(KEY_SHIELDS);
-    else if (IS_FLG(FLG_BOWS))
+    } else if (entry.has(FLG_BOWS)) {
         ADD_KEY2(KEY_BOWS);
-    else if (IS_FLG(FLG_RINGS))
+    } else if (entry.has(FLG_RINGS)) {
         ADD_KEY2(KEY_RINGS);
-    else if (IS_FLG(FLG_AMULETS))
+    } else if (entry.has(FLG_AMULETS)) {
         ADD_KEY2(KEY_AMULETS);
-    else if (IS_FLG(FLG_SUITS))
+    } else if (entry.has(FLG_SUITS)) {
         ADD_KEY2(KEY_SUITS);
-    else if (IS_FLG(FLG_CLOAKS))
+    } else if (entry.has(FLG_CLOAKS)) {
         ADD_KEY2(KEY_CLOAKS);
-    else if (IS_FLG(FLG_HELMS))
+    } else if (entry.has(FLG_HELMS)) {
         ADD_KEY2(KEY_HELMS);
-    else if (IS_FLG(FLG_GLOVES))
+    } else if (entry.has(FLG_GLOVES)) {
         ADD_KEY2(KEY_GLOVES);
-    else if (IS_FLG(FLG_BOOTS))
+    } else if (entry.has(FLG_BOOTS)) {
         ADD_KEY2(KEY_BOOTS);
-    else if (!IS_FLG(FLG_ARTIFACT))
+    } else if (!entry.has(FLG_ARTIFACT)) {
         sepa_flag = false;
+    }
 
-    if (!entry->name.empty()) {
-        if (sepa_flag)
+    if (!entry.name.empty()) {
+        if (sepa_flag) {
             strcat(buf, ":");
+        }
 
         int i = strlen(buf);
         int j = 0;
-        while (entry->name[j] && i < MAX_LINELEN - 2 - 1) {
+        while (entry.name[j] && i < MAX_LINELEN - 2 - 1) {
 #ifdef JP
-            if (iskanji(entry->name[j]))
-                buf[i++] = entry->name[j++];
+            if (iskanji(entry.name[j])) {
+                buf[i++] = entry.name[j++];
+            }
 #endif
-            buf[i++] = entry->name[j++];
+            buf[i++] = entry.name[j++];
         }
         buf[i] = '\0';
     }
 
-    if (entry->insc.empty())
+    if (entry.insc.empty()) {
         return string_make(buf);
+    }
 
     int i, j = 0;
     strcat(buf, "#");
     i = strlen(buf);
 
-    while (entry->insc[j] && i < MAX_LINELEN - 2) {
+    while (entry.insc[j] && i < MAX_LINELEN - 2) {
 #ifdef JP
-        if (iskanji(entry->insc[j]))
-            buf[i++] = entry->insc[j++];
+        if (iskanji(entry.insc[j])) {
+            buf[i++] = entry.insc[j++];
+        }
 #endif
-        buf[i++] = entry->insc[j++];
+        buf[i++] = entry.insc[j++];
     }
 
     buf[i] = '\0';
@@ -637,8 +716,7 @@ concptr autopick_line_from_entry(autopick_type *entry)
  */
 concptr autopick_line_from_entry_kill(autopick_type *entry)
 {
-    concptr ptr = autopick_line_from_entry(entry);
-    return ptr;
+    return autopick_line_from_entry(*entry);
 }
 
 /*!
@@ -646,12 +724,12 @@ concptr autopick_line_from_entry_kill(autopick_type *entry)
  */
 bool entry_from_choosed_object(PlayerType *player_ptr, autopick_type *entry)
 {
-    concptr q = _("どのアイテムを登録しますか? ", "Enter which item? ");
-    concptr s = _("アイテムを持っていない。", "You have nothing to enter.");
-    ObjectType *o_ptr;
-    o_ptr = choose_object(player_ptr, nullptr, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP);
-    if (!o_ptr)
+    constexpr auto q = _("どのアイテムを登録しますか? ", "Enter which item? ");
+    constexpr auto s = _("アイテムを持っていない。", "You have nothing to enter.");
+    auto *o_ptr = choose_object(player_ptr, nullptr, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP);
+    if (!o_ptr) {
         return false;
+    }
 
     autopick_entry_from_object(player_ptr, entry, o_ptr);
     return true;