From d751524d5961fb741157d71b106f98a70681b94d Mon Sep 17 00:00:00 2001 From: Deskull Date: Sun, 30 Dec 2018 13:48:45 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38824=20bldg.c=20=E3=81=A8=20cmd2.?= =?utf8?q?c=20=E3=81=AE=20get=5Fitem()=20=E3=82=92=20choose=5Fobject()=20?= =?utf8?q?=E3=81=AB=E7=BD=AE=E6=8F=9B=E4=B8=AD=E3=80=82=20/=20Replace=20fr?= =?utf8?q?om=20get=5Fitem()=20to=20choose=5Fobject()=20in=20bldg.c=20and?= =?utf8?q?=20cmd2.c.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/bldg.c | 20 ++++---------------- src/cmd2.c | 29 +++++++++-------------------- 2 files changed, 13 insertions(+), 36 deletions(-) diff --git a/src/bldg.c b/src/bldg.c index 2d711be31..481e75018 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -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]; diff --git a/src/cmd2.c b/src/cmd2.c index 8bb63afd5..114ec36b1 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -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)) { -- 2.11.0