• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

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


Commit MetaInfo

Revision836e640b1afbf88c42a41fa07c12729c5878f37c (tree)
Time2018-12-30 13:30:53
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #38824 choose_object()の修正とget_item()の置換。 / Fix choose_object() and replace from get_item().

Change Summary

Incremental Difference

--- a/src/autopick.c
+++ b/src/autopick.c
@@ -3244,7 +3244,7 @@ static bool entry_from_choosed_object(autopick_type *entry)
32443244
32453245 q = _("どのアイテムを登録しますか? ", "Enter which item? ");
32463246 s = _("アイテムを持っていない。", "You have nothing to enter.");
3247- o_ptr = choose_object(q, s, USE_INVEN | USE_FLOOR | USE_EQUIP, NULL);
3247+ o_ptr = choose_object(NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP);
32483248 if (!o_ptr) return FALSE;
32493249
32503250 autopick_entry_from_object(entry, o_ptr);
@@ -3263,7 +3263,7 @@ static byte get_object_for_search(object_type **o_handle, cptr *search_strp)
32633263
32643264 q = _("どのアイテムを検索しますか? ", "Enter which item? ");
32653265 s = _("アイテムを持っていない。", "You have nothing to enter.");
3266- o_ptr = choose_object(q, s, USE_INVEN | USE_FLOOR | USE_EQUIP, NULL);
3266+ o_ptr = choose_object(NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP);
32673267 if (!o_ptr) return 0;
32683268
32693269 *o_handle = o_ptr;
--- a/src/bldg.c
+++ b/src/bldg.c
@@ -2736,14 +2736,13 @@ static PRICE compare_weapons(PRICE bcost)
27362736 q = _("第一の武器は?", "What is your first weapon? ");
27372737 s = _("比べるものがありません。", "You have nothing to compare.");
27382738
2739- if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN)))
2739+ o_ptr[0] = choose_object(&item, q, s, (USE_EQUIP | USE_INVEN));
2740+ if (!o_ptr)
27402741 {
27412742 screen_load();
27422743 return (0);
27432744 }
27442745
2745- /* Get the item (in the pack) */
2746- o_ptr[0] = &inventory[item];
27472746 n = 1;
27482747 total = bcost;
27492748
@@ -2809,13 +2808,11 @@ static PRICE compare_weapons(PRICE bcost)
28092808 s = _("比べるものがありません。", "You have nothing to compare.");
28102809
28112810 /* Get the second weapon */
2812- if (!get_item(&item2, q, s, (USE_EQUIP | USE_INVEN))) continue;
2811+ o_ptr[1] = choose_object(&item2, q, s, (USE_EQUIP | USE_INVEN));
2812+ if (!o_ptr) continue;
28132813
28142814 total += cost;
28152815 cost = bcost / 2;
2816-
2817- /* Get the item (in the pack) */
2818- o_ptr[1] = &inventory[item2];
28192816 n = 2;
28202817 }
28212818 else
@@ -2998,7 +2995,7 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
29982995 int i, dd_bonus, ds_bonus;
29992996 KIND_OBJECT_IDX k_idx;
30002997 char basenm[MAX_NLEN];
3001- cptr q, s; /* For get_item prompt */
2998+ cptr q, s;
30022999 int row = 7;
30033000 clear_bldg(0, 22);
30043001
@@ -3011,10 +3008,8 @@ static PRICE repair_broken_weapon_aux(PRICE bcost)
30113008 /* Only forge broken weapons */
30123009 item_tester_hook = item_tester_hook_broken_weapon;
30133010
3014- if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) return (0);
3015-
3016- /* Get the item (in the pack) */
3017- o_ptr = &inventory[item];
3011+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP));
3012+ if (!o_ptr) return (0);
30183013
30193014 /* It is worthless */
30203015 if (!object_is_ego(o_ptr) && !object_is_artifact(o_ptr))
@@ -3280,10 +3275,8 @@ static bool enchant_item(PRICE cost, HIT_PROB to_hit, HIT_POINT to_dam, ARMOUR_C
32803275 q = _("どのアイテムを改良しますか?", "Improve which item? ");
32813276 s = _("改良できるものがありません。", "You have nothing to improve.");
32823277
3283- if (!get_item(&item, q, s, (USE_INVEN | USE_EQUIP))) return (FALSE);
3284-
3285- /* Get the item (in the pack) */
3286- o_ptr = &inventory[item];
3278+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_EQUIP));
3279+ if (!o_ptr) return (FALSE);
32873280
32883281 /* Check if the player has enough money */
32893282 if (p_ptr->au < (cost * o_ptr->number))
--- a/src/cmd-item.c
+++ b/src/cmd-item.c
@@ -167,17 +167,15 @@ bool select_ring_slot = FALSE;
167167 void do_cmd_wield(void)
168168 {
169169 OBJECT_IDX item, slot;
170-
171170 object_type forge;
172171 object_type *q_ptr;
173-
174172 object_type *o_ptr;
175173
176174 cptr act;
175+ cptr q, s;
177176
178177 char o_name[MAX_NLEN];
179178
180- cptr q, s;
181179
182180 OBJECT_IDX need_switch_wielding = 0;
183181
@@ -192,20 +190,8 @@ void do_cmd_wield(void)
192190 q = _("どれを装備しますか? ", "Wear/Wield which item? ");
193191 s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield.");
194192
195- if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
196-
197- /* Get the item (in the pack) */
198- if (item >= 0)
199- {
200- o_ptr = &inventory[item];
201- }
202-
203- /* Get the item (on the floor) */
204- else
205- {
206- o_ptr = &o_list[0 - item];
207- }
208-
193+ o_ptr = choose_object(&item, q, s, (USE_INVEN | USE_FLOOR));
194+ if (!o_ptr) return;
209195
210196 /* Check the slot */
211197 slot = wield_slot(o_ptr);
--- a/src/externs.h
+++ b/src/externs.h
@@ -801,7 +801,7 @@ extern COMMAND_CODE show_equip(int target_item);
801801 extern void toggle_inven_equip(void);
802802 extern bool can_get_item(void);
803803 extern bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode);
804-extern object_type *choose_object(cptr q, cptr s, BIT_FLAGS option, OBJECT_IDX *id);
804+extern object_type *choose_object(OBJECT_IDX *idx, cptr q, cptr s, BIT_FLAGS option);
805805
806806 /* object2.c */
807807 extern void excise_object_idx(OBJECT_IDX o_idx);
--- a/src/object1.c
+++ b/src/object1.c
@@ -3490,11 +3490,11 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode)
34903490 /*
34913491 * Choose an item and get auto-picker entry from it.
34923492 */
3493-object_type *choose_object(cptr q, cptr s, BIT_FLAGS option, OBJECT_IDX *idx)
3493+object_type *choose_object(OBJECT_IDX *idx, cptr q, cptr s, BIT_FLAGS option)
34943494 {
34953495 OBJECT_IDX item;
34963496 if (!get_item(&item, q, s, option)) return NULL;
3497- if (idx) idx = item;
3497+ if (idx) *idx = item;
34983498
34993499 /* Get the item (in the pack) */
35003500 if (item >= 0) return &inventory[item];
Show on old repository browser