OSDN Git Service

[Refactor] #37353 型の置換(C_MAKE)。 / Type replacement(C_MAKE).
[hengband/hengband.git] / src / object2.c
index b471dee..d1a604a 100644 (file)
@@ -18,7 +18,7 @@
 static void one_sustain(object_type *o_ptr);
 
 
-static cptr const kaji_tips[5] =
+static concptr const kaji_tips[5] =
 {
 #ifdef JP
        "現在持っているエッセンスの一覧を表示する。",
@@ -126,7 +126,6 @@ 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 */
@@ -222,7 +221,6 @@ 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 */
@@ -1897,11 +1895,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++)
@@ -2120,8 +2118,6 @@ static void object_mention(object_type *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);
 }
@@ -2208,8 +2204,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);
@@ -5294,7 +5289,6 @@ 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 */
@@ -5309,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 */
@@ -5319,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 */
@@ -5331,7 +5323,6 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION
                msg_format("The %s disappear%s.", o_name, (plural ? "" : "s"));
 #endif
 
-
                /* Debug */
                if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)"));
 
@@ -5371,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 */
@@ -6013,13 +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);
                        p_ptr->update |= (PU_BONUS);
-
                        p_ptr->window |= (PW_INVEN);
 
                        /* Success */
@@ -6089,16 +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++;
-       p_ptr->update |= (PU_BONUS);
-
-       /* Combine and Reorder pack */
-       p_ptr->update |= (PU_COMBINE | PU_REORDER);
-
+       p_ptr->update |= (PU_BONUS | PU_COMBINE | PU_REORDER);
        p_ptr->window |= (PW_INVEN);
 
        /* Return the slot */
@@ -6127,7 +6106,7 @@ INVENTORY_IDX inven_takeoff(INVENTORY_IDX item, ITEM_NUMBER amt)
 
        object_type *o_ptr;
 
-       cptr act;
+       concptr act;
 
        GAME_TEXT o_name[MAX_NLEN];
 
@@ -7021,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 */
@@ -7260,7 +7239,7 @@ static essence_type essence_info[] =
  * エッセンス名テーブル / Essense names for Weapon smith
  */
 #ifdef JP
-cptr essence_name[] = 
+concptr essence_name[] = 
 {
        "腕力",
        "知能",
@@ -7363,7 +7342,7 @@ cptr essence_name[] =
 
 #else
 
-cptr essence_name[] = 
+concptr essence_name[] = 
 {
        "strength",
        "intelligen.",
@@ -7507,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;
@@ -7522,19 +7501,8 @@ static void drain_essence(void)
        q = _("どのアイテムから抽出しますか?", "Extract from which item? ");
        s = _("抽出できるアイテムがありません。", "You have nothing you can extract from.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) 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))
        {
@@ -7744,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[] = {
                "武器属性", 
                "耐性",
                "能力",
@@ -7754,7 +7722,7 @@ static COMMAND_CODE choose_essence(void)
                "その他"
        };
 #else
-       cptr menu_name[] = {
+       concptr menu_name[] = {
                "Brand weapon",
                "Resistance",
                "Ability",
@@ -7854,7 +7822,7 @@ 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];
@@ -8122,19 +8090,8 @@ static void add_essence(ESSENCE_IDX mode)
        q = _("どのアイテムを改良しますか?", "Improve which item? ");
        s = _("改良できるアイテムがありません。", "You have nothing to improve.");
 
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) 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)))
        {
@@ -8349,7 +8306,7 @@ 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;
        GAME_TEXT o_name[MAX_NLEN];
        BIT_FLAGS flgs[TR_FLAG_SIZE];
@@ -8359,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);