変愚蛮怒のメインリポジトリです
Revision | 201206dda6ffe39428761e3d4153fee5e6dd2c58 (tree) |
---|---|
Time | 2018-12-30 14:30:58 |
Author | Deskull <deskull@user...> |
Commiter | Deskull |
[Refactor] #38824 cmd5.c の get_item() を choose_object() に置換。 / Replace from get_item() to choose_object() in cmd5..
@@ -396,9 +396,7 @@ static void confirm_use_force(bool browse_only) | ||
396 | 396 | if (which == ESCAPE) break; |
397 | 397 | else if (which == 'w') |
398 | 398 | { |
399 | - | |
400 | 399 | repeat_push(INVEN_FORCE); |
401 | - | |
402 | 400 | break; |
403 | 401 | } |
404 | 402 | } |
@@ -470,31 +468,19 @@ void do_cmd_browse(void) | ||
470 | 468 | q = _("どの本を読みますか? ", "Browse which book? "); |
471 | 469 | s = _("読める本がない。", "You have no books that you can read."); |
472 | 470 | |
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) | |
474 | 473 | { |
474 | + if (item == INVEN_FORCE) /* the_force */ | |
475 | + { | |
476 | + do_cmd_mind_browse(); | |
477 | + return; | |
478 | + } | |
475 | 479 | select_the_force = FALSE; |
476 | 480 | return; |
477 | 481 | } |
478 | 482 | select_the_force = FALSE; |
479 | 483 | |
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 | - | |
498 | 484 | /* Access the item's sval */ |
499 | 485 | sval = o_ptr->sval; |
500 | 486 |
@@ -504,7 +490,6 @@ void do_cmd_browse(void) | ||
504 | 490 | object_kind_track(o_ptr->k_idx); |
505 | 491 | handle_stuff(); |
506 | 492 | |
507 | - | |
508 | 493 | /* Extract spells */ |
509 | 494 | for (spell = 0; spell < 32; spell++) |
510 | 495 | { |
@@ -517,8 +502,6 @@ void do_cmd_browse(void) | ||
517 | 502 | } |
518 | 503 | |
519 | 504 | screen_save(); |
520 | - | |
521 | - /* Clear the top line */ | |
522 | 505 | prt("", 0, 0); |
523 | 506 | |
524 | 507 | /* Keep browsing spells. Exit browsing on cancel. */ |
@@ -674,19 +657,8 @@ void do_cmd_study(void) | ||
674 | 657 | q = _("どの本から学びますか? ", "Study which book? "); |
675 | 658 | s = _("読める本がない。", "You have no books that you can read."); |
676 | 659 | |
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; | |
690 | 662 | |
691 | 663 | /* Access the item's sval */ |
692 | 664 | sval = o_ptr->sval; |
@@ -948,37 +920,24 @@ void do_cmd_cast(void) | ||
948 | 920 | q = _("どの呪文書を使いますか? ", "Use which book? "); |
949 | 921 | s = _("呪文書がない!", "You have no spell books!"); |
950 | 922 | |
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) | |
952 | 925 | { |
926 | + if (item == INVEN_FORCE) /* the_force */ | |
927 | + { | |
928 | + do_cmd_mind(); | |
929 | + return; | |
930 | + } | |
953 | 931 | select_the_force = FALSE; |
954 | 932 | return; |
955 | 933 | } |
956 | 934 | select_the_force = FALSE; |
957 | 935 | |
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 | - | |
976 | 936 | /* Access the item's sval */ |
977 | 937 | sval = o_ptr->sval; |
978 | 938 | |
979 | 939 | if ((p_ptr->pclass != CLASS_SORCERER) && (p_ptr->pclass != CLASS_RED_MAGE) && (o_ptr->tval == REALM2_BOOK)) increment = 32; |
980 | 940 | |
981 | - | |
982 | 941 | /* Track the object kind */ |
983 | 942 | object_kind_track(o_ptr->k_idx); |
984 | 943 | handle_stuff(); |
@@ -3496,8 +3496,10 @@ object_type *choose_object(OBJECT_IDX *idx, cptr q, cptr s, BIT_FLAGS option) | ||
3496 | 3496 | if (!get_item(&item, q, s, option)) return NULL; |
3497 | 3497 | if (idx) *idx = item; |
3498 | 3498 | |
3499 | + if (item == INVEN_FORCE) return NULL; | |
3500 | + | |
3499 | 3501 | /* Get the item (in the pack) */ |
3500 | - if (item >= 0) return &inventory[item]; | |
3502 | + else if (item >= 0) return &inventory[item]; | |
3501 | 3503 | |
3502 | 3504 | /* Get the item (on the floor) */ |
3503 | 3505 | else return &o_list[0 - item]; |