• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revision85418d622cc14cf7ba7ae5652f7c46836395e70f (tree)
Time2019-01-10 22:30:39
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #38824 cmd_item.c の get_item() を choose_object() に置換。 / Replace get_item() to choose_object() in cmd-item.c.

Change Summary

Incremental Difference

--- a/src/cmd-item.c
+++ b/src/cmd-item.c
@@ -232,7 +232,7 @@ void do_cmd_wield(void)
232232 q = _("どちらの手に装備しますか?", "Equip which hand? ");
233233 s = _("おっと。", "Oops.");
234234
235- if (!get_item(&slot, q, s, (USE_EQUIP))) return;
235+ if (!choose_object(&slot, q, s, (USE_EQUIP))) return;
236236 if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
237237 need_switch_wielding = INVEN_RARM;
238238 }
@@ -254,7 +254,7 @@ void do_cmd_wield(void)
254254 /* Restrict the choices */
255255 select_ring_slot = TRUE;
256256
257- if (!get_item(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
257+ if (!choose_object(&slot, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT)))
258258 {
259259 select_ring_slot = FALSE;
260260 return;
@@ -527,20 +527,8 @@ void do_cmd_takeoff(void)
527527 q = _("どれを装備からはずしますか? ", "Take off which item? ");
528528 s = _("はずせる装備がない。", "You are not wearing anything to take off.");
529529
530- if (!get_item(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT))) return;
531-
532- /* Get the item (in the pack) */
533- if (item >= 0)
534- {
535- o_ptr = &inventory[item];
536- }
537-
538- /* Get the item (on the floor) */
539- else
540- {
541- o_ptr = &o_list[0 - item];
542- }
543-
530+ o_ptr = choose_object(&item, q, s, (USE_EQUIP | IGNORE_BOTHHAND_SLOT));
531+ if (!o_ptr) return;
544532
545533 /* Item is cursed */
546534 if (object_is_cursed(o_ptr))
@@ -605,20 +593,8 @@ void do_cmd_drop(void)
605593 q = _("どのアイテムを落としますか? ", "Drop which item? ");
606594 s = _("落とせるアイテムを持っていない。", "You have nothing to drop.");
607595
608- if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT))) return;
609-
610- /* Get the item (in the pack) */
611- if (item >= 0)
612- {
613- o_ptr = &inventory[item];
614- }
615-
616- /* Get the item (on the floor) */
617- else
618- {
619- o_ptr = &o_list[0 - item];
620- }
621-
596+ o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | IGNORE_BOTHHAND_SLOT));
597+ if (!o_ptr) return;
622598
623599 /* Hack -- Cannot remove cursed items */
624600 if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
@@ -715,19 +691,8 @@ void do_cmd_destroy(void)
715691 q = _("どのアイテムを壊しますか? ", "Destroy which item? ");
716692 s = _("壊せるアイテムを持っていない。", "You have nothing to destroy.");
717693
718- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
719-
720- /* Get the item (in the pack) */
721- if (item >= 0)
722- {
723- o_ptr = &inventory[item];
724- }
725-
726- /* Get the item (on the floor) */
727- else
728- {
729- o_ptr = &o_list[0 - item];
730- }
694+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
695+ if (!o_ptr) return;
731696
732697 /* Verify unless quantity given beforehand */
733698 if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
@@ -904,24 +869,11 @@ void do_cmd_observe(void)
904869 GAME_TEXT o_name[MAX_NLEN];
905870 cptr q, s;
906871
907-
908872 q = _("どのアイテムを調べますか? ", "Examine which item? ");
909873 s = _("調べられるアイテムがない。", "You have nothing to examine.");
910874
911- if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
912-
913- /* Get the item (in the pack) */
914- if (item >= 0)
915- {
916- o_ptr = &inventory[item];
917- }
918-
919- /* Get the item (on the floor) */
920- else
921- {
922- o_ptr = &o_list[0 - item];
923- }
924-
875+ o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
876+ if (!o_ptr) return;
925877
926878 /* Require full knowledge */
927879 if (!(o_ptr->ident & IDENT_MENTAL))
@@ -930,7 +882,6 @@ void do_cmd_observe(void)
930882 return;
931883 }
932884
933-
934885 /* Description */
935886 object_desc(o_name, o_ptr, 0);
936887 msg_format(_("%sを調べている...", "Examining %s..."), o_name);
@@ -954,19 +905,8 @@ void do_cmd_uninscribe(void)
954905 q = _("どのアイテムの銘を消しますか? ", "Un-inscribe which item? ");
955906 s = _("銘を消せるアイテムがない。", "You have nothing to un-inscribe.");
956907
957- if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
958-
959- /* Get the item (in the pack) */
960- if (item >= 0)
961- {
962- o_ptr = &inventory[item];
963- }
964-
965- /* Get the item (on the floor) */
966- else
967- {
968- o_ptr = &o_list[0 - item];
969- }
908+ o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
909+ if (!o_ptr) return;
970910
971911 /* Nothing to remove */
972912 if (!o_ptr->inscription)
@@ -999,27 +939,16 @@ void do_cmd_uninscribe(void)
999939 void do_cmd_inscribe(void)
1000940 {
1001941 OBJECT_IDX item;
1002- object_type *o_ptr;
942+ object_type *o_ptr;
1003943 GAME_TEXT o_name[MAX_NLEN];
1004- char out_val[80];
944+ char out_val[80];
1005945 cptr q, s;
1006946
1007947 q = _("どのアイテムに銘を刻みますか? ", "Inscribe which item? ");
1008948 s = _("銘を刻めるアイテムがない。", "You have nothing to inscribe.");
1009949
1010- if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1011-
1012- /* Get the item (in the pack) */
1013- if (item >= 0)
1014- {
1015- o_ptr = &inventory[item];
1016- }
1017-
1018- /* Get the item (on the floor) */
1019- else
1020- {
1021- o_ptr = &o_list[0 - item];
1022- }
950+ o_ptr = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
951+ if (!o_ptr) return;
1023952
1024953 /* Describe the activity */
1025954 object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
@@ -1089,31 +1018,14 @@ static void do_cmd_refill_lamp(void)
10891018
10901019 cptr q, s;
10911020
1092-
10931021 /* Restrict the choices */
10941022 item_tester_hook = item_tester_refill_lantern;
10951023
1096-#ifdef JP
1097- q = "どの油つぼから注ぎますか? ";
1098- s = "油つぼがない。";
1099-#else
1100- q = "Refill with which flask? ";
1101- s = "You have no flasks of oil.";
1102-#endif
1103-
1104- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1105-
1106- /* Get the item (in the pack) */
1107- if (item >= 0)
1108- {
1109- o_ptr = &inventory[item];
1110- }
1024+ q = _("どの油つぼから注ぎますか? ", "Refill with which flask? ");
1025+ s = _("油つぼがない。", "You have no flasks of oil.");
11111026
1112- /* Get the item (on the floor) */
1113- else
1114- {
1115- o_ptr = &o_list[0 - item];
1116- }
1027+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1028+ if (!o_ptr) return;
11171029
11181030 /* Take a partial turn */
11191031 p_ptr->energy_use = 50;
@@ -1199,20 +1111,8 @@ static void do_cmd_refill_torch(void)
11991111 q = _("どの松明で明かりを強めますか? ", "Refuel with which torch? ");
12001112 s = _("他に松明がない。", "You have no extra torches.");
12011113
1202- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1203-
1204- /* Get the item (in the pack) */
1205- if (item >= 0)
1206- {
1207- o_ptr = &inventory[item];
1208- }
1209-
1210- /* Get the item (on the floor) */
1211- else
1212- {
1213- o_ptr = &o_list[0 - item];
1214- }
1215-
1114+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
1115+ if (!o_ptr) return;
12161116
12171117 /* Take a partial turn */
12181118 p_ptr->energy_use = 50;
@@ -1870,18 +1770,8 @@ void do_cmd_use(void)
18701770 q = _("どれを使いますか?", "Use which item? ");
18711771 s = _("使えるものがありません。", "You have nothing to use.");
18721772
1873- if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT))) return;
1874-
1875- /* Get the item (in the pack) */
1876- if (item >= 0)
1877- {
1878- o_ptr = &inventory[item];
1879- }
1880- /* Get the item (on the floor) */
1881- else
1882- {
1883- o_ptr = &o_list[0 - item];
1884- }
1773+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP | USE_FLOOR | IGNORE_BOTHHAND_SLOT));
1774+ if (!o_ptr) return;
18851775
18861776 switch (o_ptr->tval)
18871777 {
Show on old repository browser