• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

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


Commit MetaInfo

Revision201206dda6ffe39428761e3d4153fee5e6dd2c58 (tree)
Time2018-12-30 14:30:58
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #38824 cmd5.c の get_item() を choose_object() に置換。 / Replace from get_item() to choose_object() in cmd5..

Change Summary

Incremental Difference

--- a/src/cmd5.c
+++ b/src/cmd5.c
@@ -396,9 +396,7 @@ static void confirm_use_force(bool browse_only)
396396 if (which == ESCAPE) break;
397397 else if (which == 'w')
398398 {
399-
400399 repeat_push(INVEN_FORCE);
401-
402400 break;
403401 }
404402 }
@@ -470,31 +468,19 @@ void do_cmd_browse(void)
470468 q = _("どの本を読みますか? ", "Browse which book? ");
471469 s = _("読める本がない。", "You have no books that you can read.");
472470
473- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
471+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
472+ if (!o_ptr)
474473 {
474+ if (item == INVEN_FORCE) /* the_force */
475+ {
476+ do_cmd_mind_browse();
477+ return;
478+ }
475479 select_the_force = FALSE;
476480 return;
477481 }
478482 select_the_force = FALSE;
479483
480- if (item == INVEN_FORCE) /* the_force */
481- {
482- do_cmd_mind_browse();
483- return;
484- }
485-
486- /* Get the item (in the pack) */
487- else if (item >= 0)
488- {
489- o_ptr = &inventory[item];
490- }
491-
492- /* Get the item (on the floor) */
493- else
494- {
495- o_ptr = &o_list[0 - item];
496- }
497-
498484 /* Access the item's sval */
499485 sval = o_ptr->sval;
500486
@@ -504,7 +490,6 @@ void do_cmd_browse(void)
504490 object_kind_track(o_ptr->k_idx);
505491 handle_stuff();
506492
507-
508493 /* Extract spells */
509494 for (spell = 0; spell < 32; spell++)
510495 {
@@ -517,8 +502,6 @@ void do_cmd_browse(void)
517502 }
518503
519504 screen_save();
520-
521- /* Clear the top line */
522505 prt("", 0, 0);
523506
524507 /* Keep browsing spells. Exit browsing on cancel. */
@@ -674,19 +657,8 @@ void do_cmd_study(void)
674657 q = _("どの本から学びますか? ", "Study which book? ");
675658 s = _("読める本がない。", "You have no books that you can read.");
676659
677- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
678-
679- /* Get the item (in the pack) */
680- if (item >= 0)
681- {
682- o_ptr = &inventory[item];
683- }
684-
685- /* Get the item (on the floor) */
686- else
687- {
688- o_ptr = &o_list[0 - item];
689- }
660+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
661+ if (!o_ptr) return;
690662
691663 /* Access the item's sval */
692664 sval = o_ptr->sval;
@@ -948,37 +920,24 @@ void do_cmd_cast(void)
948920 q = _("どの呪文書を使いますか? ", "Use which book? ");
949921 s = _("呪文書がない!", "You have no spell books!");
950922
951- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR)))
923+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
924+ if (!o_ptr)
952925 {
926+ if (item == INVEN_FORCE) /* the_force */
927+ {
928+ do_cmd_mind();
929+ return;
930+ }
953931 select_the_force = FALSE;
954932 return;
955933 }
956934 select_the_force = FALSE;
957935
958- if (item == INVEN_FORCE) /* the_force */
959- {
960- do_cmd_mind();
961- return;
962- }
963-
964- /* Get the item (in the pack) */
965- else if (item >= 0)
966- {
967- o_ptr = &inventory[item];
968- }
969-
970- /* Get the item (on the floor) */
971- else
972- {
973- o_ptr = &o_list[0 - item];
974- }
975-
976936 /* Access the item's sval */
977937 sval = o_ptr->sval;
978938
979939 if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32;
980940
981-
982941 /* Track the object kind */
983942 object_kind_track(o_ptr->k_idx);
984943 handle_stuff();
--- a/src/object1.c
+++ b/src/object1.c
@@ -3496,8 +3496,10 @@ object_type *choose_object(OBJECT_IDX *idx, cptr q, cptr s, BIT_FLAGS option)
34963496 if (!get_item(&item, q, s, option)) return NULL;
34973497 if (idx) *idx = item;
34983498
3499+ if (item == INVEN_FORCE) return NULL;
3500+
34993501 /* Get the item (in the pack) */
3500- if (item >= 0) return &inventory[item];
3502+ else if (item >= 0) return &inventory[item];
35013503
35023504 /* Get the item (on the floor) */
35033505 else return &o_list[0 - item];
Show on old repository browser