OSDN Git Service

[Refactor] #37353 混乱時のコマンド制限処理を cmd_limit_confused() に統合。 / Integrate command limitat...
[hengband/hengband.git] / src / object2.c
index 486a6ce..690c8da 100644 (file)
 #include "angband.h"
 #include "object-hook.h"
 #include "object-curse.h"
+#include "artifact.h"
+#include "player-status.h"
 
 static void one_sustain(object_type *o_ptr);
 
 
-static cptr const kaji_tips[5] =
+static concptr const kaji_tips[5] =
 {
 #ifdef JP
        "現在持っているエッセンスの一覧を表示する。",
@@ -64,9 +66,7 @@ void excise_object_idx(OBJECT_IDX o_idx)
        object_type *j_ptr;
 
        OBJECT_IDX this_o_idx, next_o_idx = 0;
-
-       s16b prev_o_idx = 0;
-
+       OBJECT_IDX prev_o_idx = 0;
 
        /* Object */
        j_ptr = &o_list[o_idx];
@@ -83,8 +83,6 @@ void excise_object_idx(OBJECT_IDX o_idx)
                for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
                {
                        object_type *o_ptr;
-
-                       /* Acquire object */
                        o_ptr = &o_list[this_o_idx];
 
                        /* Acquire next object */
@@ -130,15 +128,12 @@ void excise_object_idx(OBJECT_IDX o_idx)
                POSITION y = j_ptr->iy;
                POSITION x = j_ptr->ix;
 
-               /* Grid */
                c_ptr = &cave[y][x];
 
                /* Scan all objects in the grid */
                for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                {
                        object_type *o_ptr;
-
-                       /* Acquire object */
                        o_ptr = &o_list[this_o_idx];
 
                        /* Acquire next object */
@@ -228,15 +223,12 @@ void delete_object(POSITION y, POSITION x)
        /* Refuse "illegal" locations */
        if (!in_bounds(y, x)) return;
 
-       /* Grid */
        c_ptr = &cave[y][x];
 
        /* Scan all objects in the grid */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -262,20 +254,18 @@ void delete_object(POSITION y, POSITION x)
  * @param i2 整理したい配列の終点
  * @return なし
  */
-static void compact_objects_aux(IDX i1, IDX i2)
+static void compact_objects_aux(OBJECT_IDX i1, OBJECT_IDX i2)
 {
-       IDX i;
+       OBJECT_IDX i;
        cave_type *c_ptr;
        object_type *o_ptr;
 
        /* Do nothing */
        if (i1 == i2) return;
 
-
        /* Repair objects */
        for (i = 1; i < o_max; i++)
        {
-               /* Acquire object */
                o_ptr = &o_list[i];
 
                /* Skip "dead" objects */
@@ -288,12 +278,8 @@ static void compact_objects_aux(IDX i1, IDX i2)
                        o_ptr->next_o_idx = i2;
                }
        }
-
-
-       /* Acquire object */
        o_ptr = &o_list[i1];
 
-
        /* Monster */
        if (o_ptr->held_m_idx)
        {
@@ -330,7 +316,6 @@ static void compact_objects_aux(IDX i1, IDX i2)
                }
        }
 
-
        /* Structure copy */
        o_list[i2] = o_list[i1];
 
@@ -363,15 +348,11 @@ void compact_objects(int size)
        int cur_lev, cur_dis, chance;
        object_type *o_ptr;
 
-
        /* Compact */
        if (size)
        {
                msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
-
-               /* Redraw map */
                p_ptr->redraw |= (PR_MAP);
-
                p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
        }
 
@@ -404,7 +385,6 @@ void compact_objects(int size)
                                /* Acquire monster */
                                m_ptr = &m_list[o_ptr->held_m_idx];
 
-                               /* Get the location */
                                y = m_ptr->fy;
                                x = m_ptr->fx;
 
@@ -415,7 +395,6 @@ void compact_objects(int size)
                        /* Dungeon */
                        else
                        {
-                               /* Get the location */
                                y = o_ptr->iy;
                                x = o_ptr->ix;
                        }
@@ -564,8 +543,6 @@ OBJECT_IDX o_pop(void)
        for (i = 1; i < o_max; i++)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[i];
 
                /* Skip live objects */
@@ -811,7 +788,7 @@ void object_aware(object_type *o_ptr)
        {
                object_type forge;
                object_type *q_ptr;
-               char o_name[MAX_NLEN];
+               GAME_TEXT o_name[MAX_NLEN];
 
                q_ptr = &forge;
                object_copy(q_ptr, o_ptr);
@@ -1530,7 +1507,7 @@ bool can_player_destroy_object(object_type *o_ptr)
                o_ptr->ident |= (IDENT_SENSE);
 
                /* Combine the pack */
-               p_ptr->notice |= (PN_COMBINE);
+               p_ptr->update |= (PU_COMBINE);
 
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
@@ -1920,11 +1897,11 @@ void object_absorb(object_type *o_ptr, object_type *j_ptr)
  * @param sval 検索したいベースアイテムのsval
  * @return なし
  */
-IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
+KIND_OBJECT_IDX lookup_kind(OBJECT_TYPE_VALUE tval, OBJECT_SUBTYPE_VALUE sval)
 {
-       IDX k;
+       KIND_OBJECT_IDX k;
        int num = 0;
-       IDX bk = 0;
+       KIND_OBJECT_IDX bk = 0;
 
        /* Look for it */
        for (k = 1; k < max_k_idx; k++)
@@ -2136,15 +2113,13 @@ int m_bonus(int max, DEPTH level)
  */
 static void object_mention(object_type *o_ptr)
 {
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        object_aware(o_ptr);
        object_known(o_ptr);
 
        /* Mark the item as fully known */
        o_ptr->ident |= (IDENT_MENTAL);
-
-       /* Description */
        object_desc(o_name, o_ptr, 0);
        msg_format_wizard(CHEAT_OBJECT, _("%sを生成しました。", "%s was generated."), o_name);
 }
@@ -2231,8 +2206,7 @@ static bool make_artifact_special(object_type *o_ptr)
  */
 static bool make_artifact(object_type *o_ptr)
 {
-       IDX i;
-
+       ARTIFACT_IDX i;
 
        /* No artifacts in the town */
        if (!dun_level) return (FALSE);
@@ -3647,7 +3621,6 @@ static void a_m_aux_3(object_type *o_ptr, DEPTH level, int power)
                                                break;
                                        }
                                }
-                               /* Uncurse it */
                                o_ptr->curse_flags = 0L;
                        }
                        else if ((power == -2) && one_in_(2))
@@ -3930,7 +3903,6 @@ static void a_m_aux_3(object_type *o_ptr, DEPTH level, int power)
                                                }
                                        }
                                }
-                               /* Uncurse it */
                                o_ptr->curse_flags = 0L;
                        }
                        else if ((power == -2) && one_in_(2))
@@ -4456,8 +4428,6 @@ void apply_magic(object_type *o_ptr, DEPTH lev, BIT_FLAGS mode)
                return;
        }
 
-
-       /* Apply magic */
        switch (o_ptr->tval)
        {
                case TV_DIGGING:
@@ -4913,8 +4883,6 @@ void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
        /* Avoid stacking on other objects */
        if (c_ptr->o_idx) return;
 
-
-       /* Get local object */
        q_ptr = &forge;
        object_wipe(q_ptr);
 
@@ -4929,8 +4897,6 @@ void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
        if (o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[o_idx];
 
                /* Structure Copy */
@@ -4947,7 +4913,6 @@ void place_object(POSITION y, POSITION x, BIT_FLAGS mode)
 
                note_spot(y, x);
 
-               /* Redraw */
                lite_spot(y, x);
        }
        else
@@ -5032,8 +4997,6 @@ void place_gold(POSITION y, POSITION x)
        /* Avoid stacking on other objects */
        if (c_ptr->o_idx) return;
 
-
-       /* Get local object */
        q_ptr = &forge;
        object_wipe(q_ptr);
 
@@ -5047,8 +5010,6 @@ void place_gold(POSITION y, POSITION x)
        if (o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[o_idx];
 
                /* Copy the object */
@@ -5066,7 +5027,6 @@ void place_gold(POSITION y, POSITION x)
 
                note_spot(y, x);
 
-               /* Redraw */
                lite_spot(y, x);
        }
 }
@@ -5108,7 +5068,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
 
        cave_type *c_ptr;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        bool flag = FALSE;
        bool done = FALSE;
@@ -5184,8 +5144,6 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
                        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                        {
                                object_type *o_ptr;
-
-                               /* Acquire object */
                                o_ptr = &o_list[this_o_idx];
 
                                /* Acquire next object */
@@ -5331,15 +5289,12 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
        }
 
 
-       /* Grid */
        c_ptr = &cave[by][bx];
 
        /* Scan objects in that grid for combination */
        for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -5348,7 +5303,6 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
                /* Check for combination */
                if (object_similar(o_ptr, j_ptr))
                {
-                       /* Combine the items */
                        object_absorb(o_ptr, j_ptr);
 
                        /* Success */
@@ -5358,7 +5312,6 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
                }
        }
 
-       /* Get new object */
        if (!done) o_idx = o_pop();
 
        /* Failure */
@@ -5367,11 +5320,9 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
 #ifdef JP
                msg_format("%sは消えた。", o_name);
 #else
-               msg_format("The %s disappear%s.",
-                          o_name, (plural ? "" : "s"));
+               msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
 #endif
 
-
                /* Debug */
                if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
 
@@ -5411,12 +5362,8 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
                done = TRUE;
        }
 
-       /* Note the spot */
        note_spot(by, bx);
-
-       /* Draw the spot */
        lite_spot(by, bx);
-
        sound(SOUND_DROP);
 
        /* Mega-Hack -- no message if "dropped" by player */
@@ -5450,7 +5397,6 @@ void acquirement(POSITION y1, POSITION x1, int num, bool great, bool special, bo
        /* Acquirement */
        while (num--)
        {
-               /* Get local object */
                i_ptr = &object_type_body;
                object_wipe(i_ptr);
 
@@ -5538,8 +5484,6 @@ void amusement(POSITION y1, POSITION x1, int num, bool known)
                        r -= amuse_info[i].prob;
                        if (r <= 0) break;
                }
-
-               /* Get local object */
                i_ptr = &object_type_body;
                object_wipe(i_ptr);
                k_idx = lookup_kind(amuse_info[i].tval, amuse_info[i].sval);
@@ -5645,7 +5589,7 @@ void inven_item_charges(INVENTORY_IDX item)
 void inven_item_describe(INVENTORY_IDX item)
 {
        object_type *o_ptr = &inventory[item];
-       char        o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        object_desc(o_name, o_ptr, 0);
 
@@ -5668,13 +5612,13 @@ void inven_item_describe(INVENTORY_IDX item)
 }
 
 /*!
- * @brief アイテムを増やし残り所持数メッセージを表示する /
+ * @brief アイテムを増減させ残り所持数メッセージを表示する /
  * Increase the "number" of an item in the inventory
  * @param item 所持数を増やしたいプレイヤーのアイテム所持スロット
  * @param num 増やしたい量
  * @return なし
  */
-void inven_item_increase(INVENTORY_IDX item, int num)
+void inven_item_increase(INVENTORY_IDX item, ITEM_NUMBER num)
 {
        object_type *o_ptr = &inventory[item];
 
@@ -5686,7 +5630,7 @@ void inven_item_increase(INVENTORY_IDX item, int num)
        else if (num < 0) num = 0;
 
        /* Un-apply */
-       num -= (ITEM_NUMBER)o_ptr->number;
+       num -= o_ptr->number;
 
        /* Change the number and weight */
        if (num)
@@ -5696,15 +5640,13 @@ void inven_item_increase(INVENTORY_IDX item, int num)
 
                /* Add the weight */
                p_ptr->total_weight += (num * o_ptr->weight);
-
-               /* Recalculate bonuses */
                p_ptr->update |= (PU_BONUS);
 
                /* Recalculate mana XXX */
                p_ptr->update |= (PU_MANA);
 
                /* Combine the pack */
-               p_ptr->notice |= (PN_COMBINE);
+               p_ptr->update |= (PU_COMBINE);
 
                p_ptr->window |= (PW_INVEN | PW_EQUIP);
 
@@ -5713,7 +5655,7 @@ void inven_item_increase(INVENTORY_IDX item, int num)
                {
                        if ((item == INVEN_RARM) || (item == INVEN_LARM))
                        {
-                               if (!buki_motteruka(INVEN_RARM + INVEN_LARM - item))
+                               if (!has_melee_weapon(INVEN_RARM + INVEN_LARM - item))
                                {
                                        /* Clear all temporary elemental brands */
                                        set_ele_attack(0, 0);
@@ -5768,8 +5710,6 @@ void inven_item_optimize(INVENTORY_IDX item)
 
                /* Erase the empty slot */
                object_wipe(&inventory[item]);
-
-               /* Recalculate bonuses */
                p_ptr->update |= (PU_BONUS);
 
                /* Recalculate torch */
@@ -5834,7 +5774,7 @@ void floor_item_charges(INVENTORY_IDX item)
 void floor_item_describe(INVENTORY_IDX item)
 {
        object_type *o_ptr = &o_list[item];
-       char        o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
        object_desc(o_name, o_ptr, 0);
 
@@ -5862,7 +5802,7 @@ void floor_item_describe(INVENTORY_IDX item)
  * @param num 増やしたいアイテムの数
  * @return なし
  */
-void floor_item_increase(INVENTORY_IDX item, int num)
+void floor_item_increase(INVENTORY_IDX item, ITEM_NUMBER num)
 {
        object_type *o_ptr = &o_list[item];
 
@@ -5874,10 +5814,10 @@ void floor_item_increase(INVENTORY_IDX item, int num)
        else if (num < 0) num = 0;
 
        /* Un-apply */
-       num -= (int)o_ptr->number;
+       num -=  o_ptr->number;
 
        /* Change the number */
-       o_ptr->number += (ITEM_NUMBER)num;
+       o_ptr->number += num;
 }
 
 
@@ -6060,15 +6000,10 @@ s16b inven_carry(object_type *o_ptr)
                /* Check if the two items can be combined */
                if (object_similar(j_ptr, o_ptr))
                {
-                       /* Combine the items */
                        object_absorb(j_ptr, o_ptr);
 
-                       /* Increase the weight */
                        p_ptr->total_weight += (o_ptr->number * o_ptr->weight);
-
-                       /* Recalculate bonuses */
                        p_ptr->update |= (PU_BONUS);
-
                        p_ptr->window |= (PW_INVEN);
 
                        /* Success */
@@ -6138,18 +6073,11 @@ s16b inven_carry(object_type *o_ptr)
        /* Player touches it, and no longer marked */
        j_ptr->marked = OM_TOUCHED;
 
-       /* Increase the weight */
        p_ptr->total_weight += (j_ptr->number * j_ptr->weight);
 
        /* Count the items */
        inven_cnt++;
-
-       /* Recalculate bonuses */
-       p_ptr->update |= (PU_BONUS);
-
-       /* Combine and Reorder pack */
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
-
+       p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
        p_ptr->window |= (PW_INVEN);
 
        /* Return the slot */
@@ -6178,9 +6106,9 @@ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
 
        object_type *o_ptr;
 
-       cptr act;
+       concptr act;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
 
        /* Get the item to take off */
@@ -6191,8 +6119,6 @@ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
 
        /* Verify */
        if (amt > o_ptr->number) amt = o_ptr->number;
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Obtain a local object */
@@ -6262,8 +6188,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
        object_type *q_ptr;
        object_type *o_ptr;
 
-       char o_name[MAX_NLEN];
-
+       GAME_TEXT o_name[MAX_NLEN];
 
        /* Access original object */
        o_ptr = &inventory[item];
@@ -6274,7 +6199,6 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
        /* Not too many */
        if (amt > o_ptr->number) amt = o_ptr->number;
 
-
        /* Take off equipment */
        if (item >= INVEN_RARM)
        {
@@ -6285,8 +6209,6 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
                o_ptr = &inventory[item];
        }
 
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Obtain local object */
@@ -6323,7 +6245,7 @@ void inven_drop(INVENTORY_IDX item, ITEM_NUMBER amt)
 void combine_pack(void)
 {
        int             i, j, k;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        object_type     *j_ptr;
        bool            flag = FALSE, combined;
 
@@ -6433,7 +6355,7 @@ void reorder_pack(void)
        s32b            o_value;
        object_type     forge;
        object_type     *q_ptr;
-       object_type     *o_ptr;
+       object_type *o_ptr;
        bool            flag = FALSE;
 
 
@@ -6462,8 +6384,6 @@ void reorder_pack(void)
 
                /* Take note */
                flag = TRUE;
-
-               /* Get local object */
                q_ptr = &forge;
 
                /* Save a copy of the moving item */
@@ -6502,7 +6422,7 @@ void display_koff(KIND_OBJECT_IDX k_idx)
        int         sval;
        REALM_IDX   use_realm;
 
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
 
        /* Erase the window */
@@ -6514,8 +6434,6 @@ void display_koff(KIND_OBJECT_IDX k_idx)
 
        /* No info */
        if (!k_idx) return;
-
-       /* Get local object */
        q_ptr = &forge;
 
        /* Prepare the object */
@@ -6945,7 +6863,7 @@ bool process_warning(POSITION xx, POSITION yy)
 {
        POSITION mx, my;
        cave_type *c_ptr;
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
 
 #define WARNING_AWARE_RANGE 12
        int dam_max = 0;
@@ -7082,7 +7000,7 @@ bool process_warning(POSITION xx, POSITION yy)
  */
 typedef struct {
        int add;       /* TR flag number or special essence id */
-       cptr add_name; /* Name of this ability */
+       concptr add_name; /* Name of this ability */
        ESSENCE_IDX type;      /* Menu number */
        int essence;   /* Index for carrying essences */
        int value;     /* Needed value to add this ability */
@@ -7321,7 +7239,7 @@ static essence_type essence_info[] =
  * エッセンス名テーブル / Essense names for Weapon smith
  */
 #ifdef JP
-cptr essence_name[] = 
+concptr essence_name[] = 
 {
        "腕力",
        "知能",
@@ -7424,7 +7342,7 @@ cptr essence_name[] =
 
 #else
 
-cptr essence_name[] = 
+concptr essence_name[] = 
 {
        "strength",
        "intelligen.",
@@ -7568,7 +7486,7 @@ static void drain_essence(void)
        TIME_EFFECT old_timeout;
        BIT_FLAGS old_flgs[TR_FLAG_SIZE], new_flgs[TR_FLAG_SIZE];
        object_type *o_ptr;
-       cptr q, s;
+       concptr q, s;
        POSITION iy, ix;
        byte_hack marked;
        ITEM_NUMBER number;
@@ -7579,28 +7497,16 @@ static void drain_essence(void)
                drain_value[i] = 0;
 
        item_tester_hook = object_is_weapon_armour_ammo;
-       item_tester_no_ryoute = TRUE;
 
        q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
        s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        if (object_is_known(o_ptr) && !object_is_nameless(o_ptr))
        {
-               char o_name[MAX_NLEN];
+               GAME_TEXT o_name[MAX_NLEN];
                object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
                if (!get_check(format(_("本当に%sから抽出してよろしいですか?", "Really extract from %s? "), o_name))) return;
        }
@@ -7790,7 +7696,7 @@ static void drain_essence(void)
        autopick_alter_item(item, TRUE);
 
        /* Combine the pack */
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+       p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
        p_ptr->window |= (PW_INVEN);
 }
@@ -7806,7 +7712,7 @@ static COMMAND_CODE choose_essence(void)
        COMMAND_CODE menu_line = (use_menu ? 1 : 0);
 
 #ifdef JP
-       cptr menu_name[] = {
+       concptr menu_name[] = {
                "武器属性", 
                "耐性",
                "能力",
@@ -7816,7 +7722,7 @@ static COMMAND_CODE choose_essence(void)
                "その他"
        };
 #else
-       cptr menu_name[] = {
+       concptr menu_name[] = {
                "Brand weapon",
                "Resistance",
                "Ability",
@@ -7916,12 +7822,12 @@ static void add_essence(ESSENCE_IDX mode)
        COMMAND_CODE i;
        bool flag,redraw;
        char choice;
-       cptr            q, s;
+       concptr            q, s;
        object_type *o_ptr;
        int ask = TRUE;
        char out_val[160];
        int num[22];
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
        int use_essence;
        essence_type *es_ptr;
        bool able[22] = { 0 };
@@ -8025,8 +7931,6 @@ static void add_essence(ESSENCE_IDX mode)
 
                                /* Show list */
                                redraw = TRUE;
-
-                               /* Save the screen */
                                if (!use_menu) screen_save();
 
                                for (y = 1; y < 24; y++)
@@ -8123,8 +8027,6 @@ static void add_essence(ESSENCE_IDX mode)
                        {
                                /* Hide list */
                                redraw = FALSE;
-
-                               /* Restore the screen */
                                screen_load();
                        }
 
@@ -8166,8 +8068,6 @@ static void add_essence(ESSENCE_IDX mode)
                /* Stop the loop */
                flag = TRUE;
        }
-
-       /* Restore the screen */
        if (redraw) screen_load();
 
        if (!flag) return;
@@ -8186,24 +8086,12 @@ static void add_essence(ESSENCE_IDX mode)
                item_tester_hook = object_is_armour;
        else
                item_tester_hook = object_is_weapon_armour_ammo;
-       item_tester_no_ryoute = TRUE;
 
        q = _("どのアイテムを改良しますか?", "Improve which item? ");
        s = _("改良できるアイテムがありません。", "You have nothing to improve.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
+       if (!o_ptr) return;
 
        if ((mode != 10) && (object_is_artifact(o_ptr) || object_is_smith(o_ptr)))
        {
@@ -8406,7 +8294,7 @@ static void add_essence(ESSENCE_IDX mode)
 #endif
 
        /* Combine the pack */
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+       p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
        p_ptr->window |= (PW_INVEN);
 }
@@ -8418,9 +8306,9 @@ static void add_essence(ESSENCE_IDX mode)
 static void erase_essence(void)
 {
        OBJECT_IDX item;
-       cptr q, s;
+       concptr q, s;
        object_type *o_ptr;
-       char o_name[MAX_NLEN];
+       GAME_TEXT o_name[MAX_NLEN];
        BIT_FLAGS flgs[TR_FLAG_SIZE];
 
        item_tester_hook = object_is_smith;
@@ -8428,26 +8316,15 @@ static void erase_essence(void)
        q = _("どのアイテムのエッセンスを消去しますか?", "Remove from which item? ");
        s = _("エッセンスを付加したアイテムがありません。", "You have nothing to remove essence.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
-
-       /* Get the item (in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-
-       /* Get the item (on the floor) */
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
+       o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!o_ptr) return;
 
        object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
        if (!get_check(format(_("よろしいですか? [%s]", "Are you sure? [%s]"), o_name))) return;
 
        p_ptr->energy_use = 100;
 
-       if (o_ptr->xtra3 == 1+ESSENCE_SLAY_GLOVE)
+       if (o_ptr->xtra3 == 1 + ESSENCE_SLAY_GLOVE)
        {
                o_ptr->to_h -= (o_ptr->xtra4>>8);
                o_ptr->to_d -= (o_ptr->xtra4 & 0x000f);
@@ -8461,7 +8338,7 @@ static void erase_essence(void)
        msg_print(_("エッセンスを取り去った。", "You removed all essence you have added."));
 
        /* Combine the pack */
-       p_ptr->notice |= (PN_COMBINE | PN_REORDER);
+       p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
        p_ptr->window |= (PW_INVEN);
 }
@@ -8480,11 +8357,7 @@ void do_cmd_kaji(bool only_browse)
 
        if (!only_browse)
        {
-               if (p_ptr->confused)
-               {
-                       msg_print(_("混乱していて作業できない!", "You are too confused!"));
-                       return;
-               }
+               if (cmd_limit_confused(p_ptr)) return;
                if (p_ptr->blind)
                {
                        msg_print(_("目が見えなくて作業できない!", "You are blind!"));