変愚蛮怒のメインリポジトリです
Revision | 836e640b1afbf88c42a41fa07c12729c5878f37c (tree) |
---|---|
Time | 2018-12-30 13:30:53 |
Author | Deskull <deskull@user...> |
Commiter | Deskull |
[Refactor] #38824 choose_object()の修正とget_item()の置換。 / Fix choose_object() and replace from get_item().
@@ -3244,7 +3244,7 @@ static bool entry_from_choosed_object(autopick_type *entry) | ||
3244 | 3244 | |
3245 | 3245 | q = _("どのアイテムを登録しますか? ", "Enter which item? "); |
3246 | 3246 | 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); | |
3248 | 3248 | if (!o_ptr) return FALSE; |
3249 | 3249 | |
3250 | 3250 | autopick_entry_from_object(entry, o_ptr); |
@@ -3263,7 +3263,7 @@ static byte get_object_for_search(object_type **o_handle, cptr *search_strp) | ||
3263 | 3263 | |
3264 | 3264 | q = _("どのアイテムを検索しますか? ", "Enter which item? "); |
3265 | 3265 | 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); | |
3267 | 3267 | if (!o_ptr) return 0; |
3268 | 3268 | |
3269 | 3269 | *o_handle = o_ptr; |
@@ -2736,14 +2736,13 @@ static PRICE compare_weapons(PRICE bcost) | ||
2736 | 2736 | q = _("第一の武器は?", "What is your first weapon? "); |
2737 | 2737 | s = _("比べるものがありません。", "You have nothing to compare."); |
2738 | 2738 | |
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) | |
2740 | 2741 | { |
2741 | 2742 | screen_load(); |
2742 | 2743 | return (0); |
2743 | 2744 | } |
2744 | 2745 | |
2745 | - /* Get the item (in the pack) */ | |
2746 | - o_ptr[0] = &inventory[item]; | |
2747 | 2746 | n = 1; |
2748 | 2747 | total = bcost; |
2749 | 2748 |
@@ -2809,13 +2808,11 @@ static PRICE compare_weapons(PRICE bcost) | ||
2809 | 2808 | s = _("比べるものがありません。", "You have nothing to compare."); |
2810 | 2809 | |
2811 | 2810 | /* 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; | |
2813 | 2813 | |
2814 | 2814 | total += cost; |
2815 | 2815 | cost = bcost / 2; |
2816 | - | |
2817 | - /* Get the item (in the pack) */ | |
2818 | - o_ptr[1] = &inventory[item2]; | |
2819 | 2816 | n = 2; |
2820 | 2817 | } |
2821 | 2818 | else |
@@ -2998,7 +2995,7 @@ static PRICE repair_broken_weapon_aux(PRICE bcost) | ||
2998 | 2995 | int i, dd_bonus, ds_bonus; |
2999 | 2996 | KIND_OBJECT_IDX k_idx; |
3000 | 2997 | char basenm[MAX_NLEN]; |
3001 | - cptr q, s; /* For get_item prompt */ | |
2998 | + cptr q, s; | |
3002 | 2999 | int row = 7; |
3003 | 3000 | clear_bldg(0, 22); |
3004 | 3001 |
@@ -3011,10 +3008,8 @@ static PRICE repair_broken_weapon_aux(PRICE bcost) | ||
3011 | 3008 | /* Only forge broken weapons */ |
3012 | 3009 | item_tester_hook = item_tester_hook_broken_weapon; |
3013 | 3010 | |
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); | |
3018 | 3013 | |
3019 | 3014 | /* It is worthless */ |
3020 | 3015 | 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 | ||
3280 | 3275 | q = _("どのアイテムを改良しますか?", "Improve which item? "); |
3281 | 3276 | s = _("改良できるものがありません。", "You have nothing to improve."); |
3282 | 3277 | |
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); | |
3287 | 3280 | |
3288 | 3281 | /* Check if the player has enough money */ |
3289 | 3282 | if (p_ptr->au < (cost * o_ptr->number)) |
@@ -167,17 +167,15 @@ bool select_ring_slot = FALSE; | ||
167 | 167 | void do_cmd_wield(void) |
168 | 168 | { |
169 | 169 | OBJECT_IDX item, slot; |
170 | - | |
171 | 170 | object_type forge; |
172 | 171 | object_type *q_ptr; |
173 | - | |
174 | 172 | object_type *o_ptr; |
175 | 173 | |
176 | 174 | cptr act; |
175 | + cptr q, s; | |
177 | 176 | |
178 | 177 | char o_name[MAX_NLEN]; |
179 | 178 | |
180 | - cptr q, s; | |
181 | 179 | |
182 | 180 | OBJECT_IDX need_switch_wielding = 0; |
183 | 181 |
@@ -192,20 +190,8 @@ void do_cmd_wield(void) | ||
192 | 190 | q = _("どれを装備しますか? ", "Wear/Wield which item? "); |
193 | 191 | s = _("装備可能なアイテムがない。", "You have nothing you can wear or wield."); |
194 | 192 | |
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; | |
209 | 195 | |
210 | 196 | /* Check the slot */ |
211 | 197 | slot = wield_slot(o_ptr); |
@@ -801,7 +801,7 @@ extern COMMAND_CODE show_equip(int target_item); | ||
801 | 801 | extern void toggle_inven_equip(void); |
802 | 802 | extern bool can_get_item(void); |
803 | 803 | 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); | |
805 | 805 | |
806 | 806 | /* object2.c */ |
807 | 807 | extern void excise_object_idx(OBJECT_IDX o_idx); |
@@ -3490,11 +3490,11 @@ bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, BIT_FLAGS mode) | ||
3490 | 3490 | /* |
3491 | 3491 | * Choose an item and get auto-picker entry from it. |
3492 | 3492 | */ |
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) | |
3494 | 3494 | { |
3495 | 3495 | OBJECT_IDX item; |
3496 | 3496 | if (!get_item(&item, q, s, option)) return NULL; |
3497 | - if (idx) idx = item; | |
3497 | + if (idx) *idx = item; | |
3498 | 3498 | |
3499 | 3499 | /* Get the item (in the pack) */ |
3500 | 3500 | if (item >= 0) return &inventory[item]; |