OSDN Git Service

[Refactor] #38824 bldg.c と cmd2.c の get_item() を choose_object() に置換中。 / Replace...
authorDeskull <deskull@users.sourceforge.jp>
Sun, 30 Dec 2018 04:48:45 +0000 (13:48 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Sun, 30 Dec 2018 04:48:45 +0000 (13:48 +0900)
src/bldg.c
src/cmd2.c

index 2d711be..481e750 100644 (file)
@@ -3035,16 +3035,14 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
        /* Only forge broken weapons */
        item_tester_hook = item_tester_hook_orthodox_melee_weapons;
 
-       if (!get_item(&mater, q, s, (USE_INVEN | USE_EQUIP))) return (0);
+       mo_ptr = choose_object(&mater, q, s, (USE_INVEN | USE_EQUIP));
+       if (!mo_ptr) return (0);
        if (mater == item)
        {
                msg_print(_("クラインの壷じゃない!", "This is not a klein bottle!"));
                return (0);
        }
 
-       /* Get the item (in the pack) */
-       mo_ptr = &inventory[mater];
-
        /* Display item name */
        object_desc(basenm, mo_ptr, OD_NAME_ONLY);
        prt(format(_("材料とする武器: %s", "Material : %s"), basenm), row+4, 2);
@@ -3387,19 +3385,9 @@ static void building_recharge(void)
 
        q = _("どのアイテムに魔力を充填しますか? ", "Recharge which item? ");
        s = _("魔力を充填すべきアイテムがない。", "You have nothing to recharge.");
-       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;
 
        k_ptr = &k_info[o_ptr->k_idx];
 
index 8bb63af..114ec36 100644 (file)
@@ -2860,7 +2860,6 @@ void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
                                if (c_ptr->info & (CAVE_MARK)) msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
                                /* Forget the wall */
                                c_ptr->info &= ~(CAVE_MARK);
-
                                p_ptr->update |= (PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE);
 
                                /* Destroy the wall */
@@ -2881,9 +2880,7 @@ void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
                if (snipe_type == SP_LITE)
                {
                        cave[ny][nx].info |= (CAVE_GLOW);
-
                        note_spot(ny, nx);
-
                        lite_spot(ny, nx);
                }
 
@@ -2920,9 +2917,7 @@ void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
                if (snipe_type == SP_EVILNESS)
                {
                        cave[ny][nx].info &= ~(CAVE_GLOW | CAVE_MARK);
-
                        note_spot(ny, nx);
-
                        lite_spot(ny, nx);
                }
 
@@ -2934,7 +2929,6 @@ void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
                x = nx;
                y = ny;
 
-
                /* Monster here, Try to hit it */
                if (cave[y][x].m_idx)
                {
@@ -3232,7 +3226,7 @@ void do_cmd_fire_aux(INVENTORY_IDX item, object_type *j_ptr)
 void do_cmd_fire(void)
 {
        OBJECT_IDX item;
-       object_type *j_ptr;
+       object_type *j_ptr, *ammo_ptr;
        cptr q, s;
 
        is_fired = FALSE;       /* not fired yet */
@@ -3273,7 +3267,10 @@ void do_cmd_fire(void)
 
        q = _("どれを撃ちますか? ", "Fire which item? ");
        s = _("発射されるアイテムがありません。", "You have nothing to fire.");
-       if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
+
+
+       ammo_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
+       if (!ammo_ptr)
        {
                flush();
                return;
@@ -3362,7 +3359,8 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        item_tester_hook = item_tester_hook_boomerang;
                        q = _("どの武器を投げますか? ", "Throw which item? ");
                        s = _("投げる武器がない。", "You have nothing to throw.");
-                       if (!get_item(&item, q, s, (USE_EQUIP)))
+                       o_ptr = choose_object(&item, q, s, (USE_EQUIP));
+                       if (!o_ptr)
                        {
                                flush();
                                return FALSE;
@@ -3375,23 +3373,14 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
        {
                q = _("どのアイテムを投げますか? ", "Throw which item? ");
                s = _("投げるアイテムがない。", "You have nothing to throw.");
-               if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP)))
+               o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR | USE_EQUIP));
+               if (!o_ptr)
                {
                        flush();
                        return FALSE;
                }
        }
 
-       /* Access the item (if in the pack) */
-       if (item >= 0)
-       {
-               o_ptr = &inventory[item];
-       }
-       else
-       {
-               o_ptr = &o_list[0 - item];
-       }
-
        /* Item is cursed */
        if (object_is_cursed(o_ptr) && (item >= INVEN_RARM))
        {