OSDN Git Service

74fb2992e259dce28fe1caef414732aa3a63fa78
[hengband/hengband.git] / src / inventory / item-getter.c
1 #include "inventory/item-getter.h"
2 #include "core/stuff-handler.h"
3 #include "core/window-redrawer.h"
4 #include "game-option/input-options.h"
5 #include "game-option/option-flags.h"
6 #include "game-option/text-display-options.h"
7 #include "grid/grid.h"
8 #include "inventory/floor-item-getter.h"
9 #include "inventory/inventory-slot-types.h"
10 #include "inventory/inventory-util.h"
11 #include "inventory/item-selection-util.h"
12 #include "io/command-repeater.h"
13 #include "io/input-key-acceptor.h"
14 #include "io/input-key-requester.h"
15 #include "main/sound-of-music.h"
16 #include "object/item-tester-hooker.h"
17 #include "object/item-use-flags.h"
18 #include "object/object-info.h"
19 #include "object/object-mark-types.h"
20 #include "player/player-status-flags.h"
21 #include "system/floor-type-definition.h"
22 #include "term/gameterm.h"
23 #include "term/screen-processor.h"
24 #include "util/int-char-converter.h"
25 #include "view/display-inventory.h"
26 #include "view/display-messages.h"
27 #include "window/display-sub-windows.h"
28
29 /*!
30  * @brief オブジェクト選択のモード設定
31  * @param item_selection_ptr アイテム選択への参照ポインタ
32  * @return なし
33  */
34 static void check_item_selection_mode(item_selection_type *item_selection_ptr)
35 {
36     if (item_selection_ptr->mode & USE_EQUIP)
37         item_selection_ptr->equip = TRUE;
38
39     if (item_selection_ptr->mode & USE_INVEN)
40         item_selection_ptr->inven = TRUE;
41
42     if (item_selection_ptr->mode & USE_FLOOR)
43         item_selection_ptr->floor = TRUE;
44 }
45
46 /*!
47  * todo 適切な関数名をどうしても付けられなかったので暫定でauxとした
48  * @brief アイテムへにタグ付けがされているかの調査処理 (のはず)
49  * @param owner_ptr プレーヤーへの参照ポインタ
50  * @param item_selection_ptr アイテムへの参照ポインタ
51  * @return プレイヤーによりアイテムが選択されたならTRUEを返す
52  */
53 static bool check_item_tag_aux(player_type *owner_ptr, item_selection_type *item_selection_ptr)
54 {
55     if (!item_selection_ptr->floor || (*item_selection_ptr->cp >= 0))
56         return FALSE;
57
58     object_type *o_ptr;
59     item_selection_ptr->k = 0 - (*item_selection_ptr->cp);
60     o_ptr = &owner_ptr->current_floor_ptr->o_list[item_selection_ptr->k];
61     if (!item_tester_okay(owner_ptr, o_ptr, item_selection_ptr->tval) && ((item_selection_ptr->mode & USE_FULL) == 0))
62         return FALSE;
63
64     item_selection_ptr->tval = 0;
65     item_tester_hook = NULL;
66     command_cmd = 0;
67     return TRUE;
68 }
69
70 /*!
71  * @brief インベントリのアイテムにタグ付けがされているかの調査処理 (のはず)
72  * @param owner_ptr プレーヤーへの参照ポインタ
73  * @param fis_ptr 床上アイテムへの参照ポインタ
74  * @param prev_tag 前回選択したアイテムのタグ (のはず)
75  * @return プレイヤーによりアイテムが選択されたならTRUEを返す
76  */
77 static bool check_item_tag_inventory(player_type *owner_ptr, item_selection_type *item_selection_ptr, char *prev_tag)
78 {
79     if ((!item_selection_ptr->inven || (*item_selection_ptr->cp < 0) || (*item_selection_ptr->cp >= INVEN_PACK))
80         && (!item_selection_ptr->equip || (*item_selection_ptr->cp < INVEN_MAIN_HAND) || (*item_selection_ptr->cp >= INVEN_TOTAL)))
81         return FALSE;
82
83     if (*prev_tag && command_cmd) {
84         
85         bool flag = FALSE;
86         item_use_flag use_flag = (*item_selection_ptr->cp >= INVEN_MAIN_HAND) ? USE_EQUIP : USE_INVEN;
87
88         flag |= !get_tag(owner_ptr, &item_selection_ptr->k, *prev_tag, use_flag, item_selection_ptr->tval);
89         flag |= !get_item_okay(owner_ptr, item_selection_ptr->k, item_selection_ptr->tval);
90
91         if (item_selection_ptr->k < INVEN_MAIN_HAND)
92             flag |= !item_selection_ptr->inven;
93         else
94             flag |= !item_selection_ptr->equip;
95
96         if (flag) {
97             *prev_tag = '\0';
98             return FALSE;
99         }
100
101         *item_selection_ptr->cp = item_selection_ptr->k;
102         item_selection_ptr->tval = 0;
103         item_tester_hook = NULL;
104         command_cmd = 0;
105         return TRUE;
106     }
107
108     if (!get_item_okay(owner_ptr, *item_selection_ptr->cp, item_selection_ptr->tval))
109         return FALSE;
110
111     item_selection_ptr->tval = 0;
112     item_tester_hook = NULL;
113     command_cmd = 0;
114     return TRUE;
115 }
116
117 /*!
118  * @brief アイテムにタグ付けがされているかの調査処理 (のはず)
119  * @param owner_ptr プレーヤーへの参照ポインタ
120  * @param item_selection_ptr アイテムへの参照ポインタ
121  * @param prev_tag 前回選択したアイテムのタグ (のはず)
122  * @return プレイヤーによりアイテムが選択されたならTRUEを返す
123  */
124 static bool check_item_tag(player_type *owner_ptr, item_selection_type *item_selection_ptr, char *prev_tag)
125 {
126     if (!repeat_pull(item_selection_ptr->cp))
127         return FALSE;
128
129     if (item_selection_ptr->mode & USE_FORCE && (*item_selection_ptr->cp == INVEN_FORCE)) {
130         item_selection_ptr->tval = 0;
131         item_tester_hook = NULL;
132         command_cmd = 0;
133         return TRUE;
134     }
135
136     if (check_item_tag_aux(owner_ptr, item_selection_ptr))
137         return TRUE;
138
139     return check_item_tag_inventory(owner_ptr, item_selection_ptr, prev_tag);
140 }
141
142 /*!
143  * @brief インベントリ内のアイテムが妥当かを判定する
144  * @param owner_ptr プレーヤーへの参照ポインタ
145  * @param fis_ptr アイテム選択への参照ポインタ
146  * @return なし
147  */
148 static void test_inventory(player_type *owner_ptr, item_selection_type *item_selection_ptr)
149 {
150     if (!item_selection_ptr->inven) {
151         item_selection_ptr->i2 = -1;
152         return;
153     }
154
155     if (!use_menu)
156         return;
157
158     for (int j = 0; j < INVEN_PACK; j++)
159         if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], item_selection_ptr->tval) || (item_selection_ptr->mode & USE_FULL))
160             item_selection_ptr->max_inven++;
161 }
162
163 /*!
164  * @brief 装備品が妥当かを判定する
165  * @param owner_ptr プレーヤーへの参照ポインタ
166  * @param fis_ptr アイテム選択への参照ポインタ
167  * @return なし
168  */
169 static void test_equipment(player_type *owner_ptr, item_selection_type *item_selection_ptr)
170 {
171     if (!item_selection_ptr->equip) {
172         item_selection_ptr->e2 = -1;
173         return;
174     }
175
176     if (!use_menu)
177         return;
178
179     for (int j = INVEN_MAIN_HAND; j < INVEN_TOTAL; j++)
180         if (owner_ptr->select_ring_slot ? is_ring_slot(j)
181                              : item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], item_selection_ptr->tval) || (item_selection_ptr->mode & USE_FULL))
182             item_selection_ptr->max_equip++;
183
184     if (has_two_handed_weapons(owner_ptr) && !(item_selection_ptr->mode & IGNORE_BOTHHAND_SLOT))
185         item_selection_ptr->max_equip++;
186 }
187
188 /*!
189  * @brief オブジェクト選択の汎用関数 / General function for the selection of item
190  * Let the user select an item, save its "index"
191  * @param owner_ptr プレーヤーへの参照ポインタ
192  * @param cp 選択したオブジェクトのID
193  * @param pmt 選択目的のメッセージ
194  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
195  * @param mode オプションフラグ
196  * @return プレイヤーによりアイテムが選択されたならTRUEを返す
197  * Return TRUE only if an acceptable item was chosen by the user
198  */
199 bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str, BIT_FLAGS mode, tval_type tval)
200 {
201     static char prev_tag = '\0';
202     if (easy_floor || use_menu)
203         return get_item_floor(owner_ptr, cp, pmt, str, mode, tval);
204
205     item_selection_type tmp_selection;
206     item_selection_type *item_selection_ptr = initialize_item_selection_type(&tmp_selection, cp, mode, tval);
207     check_item_selection_mode(item_selection_ptr);
208     if (check_item_tag(owner_ptr, item_selection_ptr, &prev_tag))
209         return TRUE;
210
211     msg_print(NULL);
212     item_selection_ptr->done = FALSE;
213     item_selection_ptr->item = FALSE;
214     item_selection_ptr->i1 = 0;
215     item_selection_ptr->i2 = INVEN_PACK - 1;
216     test_inventory(owner_ptr, item_selection_ptr);
217     while ((item_selection_ptr->i1 <= item_selection_ptr->i2) && (!get_item_okay(owner_ptr, item_selection_ptr->i1, item_selection_ptr->tval)))
218         item_selection_ptr->i1++;
219
220     while ((item_selection_ptr->i1 <= item_selection_ptr->i2) && (!get_item_okay(owner_ptr, item_selection_ptr->i2, item_selection_ptr->tval)))
221         item_selection_ptr->i2--;
222
223     item_selection_ptr->e1 = INVEN_MAIN_HAND;
224     item_selection_ptr->e2 = INVEN_TOTAL - 1;
225     test_equipment(owner_ptr, item_selection_ptr);
226     while ((item_selection_ptr->e1 <= item_selection_ptr->e2) && (!get_item_okay(owner_ptr, item_selection_ptr->e1, item_selection_ptr->tval)))
227         item_selection_ptr->e1++;
228
229     while ((item_selection_ptr->e1 <= item_selection_ptr->e2) && (!get_item_okay(owner_ptr, item_selection_ptr->e2, item_selection_ptr->tval)))
230         item_selection_ptr->e2--;
231
232     if (item_selection_ptr->equip && has_two_handed_weapons(owner_ptr) && !(item_selection_ptr->mode & IGNORE_BOTHHAND_SLOT)) {
233         if (has_right_hand_weapon(owner_ptr)) {
234             if (item_selection_ptr->e2 < INVEN_SUB_HAND)
235                 item_selection_ptr->e2 = INVEN_SUB_HAND;
236         } else if (has_left_hand_weapon(owner_ptr))
237             item_selection_ptr->e1 = INVEN_MAIN_HAND;
238     }
239
240     if (item_selection_ptr->floor) {
241         for (item_selection_ptr->this_o_idx = owner_ptr->current_floor_ptr->grid_array[owner_ptr->y][owner_ptr->x].o_idx; item_selection_ptr->this_o_idx;
242              item_selection_ptr->this_o_idx = item_selection_ptr->next_o_idx) {
243             object_type *o_ptr;
244             o_ptr = &owner_ptr->current_floor_ptr->o_list[item_selection_ptr->this_o_idx];
245             item_selection_ptr->next_o_idx = o_ptr->next_o_idx;
246             if ((item_tester_okay(owner_ptr, o_ptr, item_selection_ptr->tval) || (item_selection_ptr->mode & USE_FULL)) && (o_ptr->marked & OM_FOUND))
247                 item_selection_ptr->allow_floor = TRUE;
248         }
249     }
250
251     if (!item_selection_ptr->allow_floor && (item_selection_ptr->i1 > item_selection_ptr->i2) && (item_selection_ptr->e1 > item_selection_ptr->e2)) {
252         command_see = FALSE;
253         item_selection_ptr->oops = TRUE;
254         item_selection_ptr->done = TRUE;
255
256         if (item_selection_ptr->mode & USE_FORCE) {
257             *item_selection_ptr->cp = INVEN_FORCE;
258             item_selection_ptr->item = TRUE;
259         }
260     } else {
261         if (command_see && command_wrk && item_selection_ptr->equip)
262             command_wrk = TRUE;
263         else if (item_selection_ptr->inven)
264             command_wrk = FALSE;
265         else if (item_selection_ptr->equip)
266             command_wrk = TRUE;
267         else
268             command_wrk = FALSE;
269     }
270
271     /* 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する */
272     if ((always_show_list == TRUE) || use_menu)
273         command_see = TRUE;
274
275     if (command_see)
276         screen_save();
277
278     while (!item_selection_ptr->done) {
279         COMMAND_CODE get_item_label = 0;
280         int ni = 0;
281         int ne = 0;
282         for (int j = 0; j < 8; j++) {
283             if (!angband_term[j])
284                 continue;
285
286             if (window_flag[j] & (PW_INVEN))
287                 ni++;
288
289             if (window_flag[j] & (PW_EQUIP))
290                 ne++;
291         }
292
293         if ((command_wrk && ni && !ne) || (!command_wrk && !ni && ne)) {
294             toggle_inventory_equipment(owner_ptr);
295             item_selection_ptr->toggle = !item_selection_ptr->toggle;
296         }
297
298         owner_ptr->window |= (PW_INVEN | PW_EQUIP);
299         handle_stuff(owner_ptr);
300
301         if (!command_wrk) {
302             if (command_see)
303                 get_item_label = show_inventory(owner_ptr, item_selection_ptr->menu_line, item_selection_ptr->mode, item_selection_ptr->tval);
304         } else {
305             if (command_see)
306                 get_item_label = show_equipment(owner_ptr, item_selection_ptr->menu_line, item_selection_ptr->mode, item_selection_ptr->tval);
307         }
308
309         if (!command_wrk) {
310             sprintf(item_selection_ptr->out_val, _("持ち物:", "Inven:"));
311             if ((item_selection_ptr->i1 <= item_selection_ptr->i2) && !use_menu) {
312                 sprintf(item_selection_ptr->tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(item_selection_ptr->i1),
313                     index_to_label(item_selection_ptr->i2));
314                 strcat(item_selection_ptr->out_val, item_selection_ptr->tmp_val);
315             }
316
317             if (!command_see && !use_menu)
318                 strcat(item_selection_ptr->out_val, _(" '*'一覧,", " * to see,"));
319
320             if (item_selection_ptr->equip)
321                 strcat(item_selection_ptr->out_val, format(_(" %s 装備品,", " %s for Equip,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "/")));
322         } else {
323             sprintf(item_selection_ptr->out_val, _("装備品:", "Equip:"));
324             if ((item_selection_ptr->e1 <= item_selection_ptr->e2) && !use_menu) {
325                 sprintf(item_selection_ptr->tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(item_selection_ptr->e1),
326                     index_to_label(item_selection_ptr->e2));
327                 strcat(item_selection_ptr->out_val, item_selection_ptr->tmp_val);
328             }
329
330             if (!command_see && !use_menu)
331                 strcat(item_selection_ptr->out_val, _(" '*'一覧,", " * to see,"));
332
333             if (item_selection_ptr->inven)
334                 strcat(item_selection_ptr->out_val, format(_(" %s 持ち物,", " %s for Inven,"), use_menu ? _("'4'or'6'", "4 or 6") : _("'/'", "'/'")));
335         }
336
337         if (item_selection_ptr->allow_floor)
338             strcat(item_selection_ptr->out_val, _(" '-'床上,", " - for item_selection_ptr->floor,"));
339
340         if (item_selection_ptr->mode & USE_FORCE)
341             strcat(item_selection_ptr->out_val, _(" 'w'練気術,", " w for the Force,"));
342
343         strcat(item_selection_ptr->out_val, " ESC");
344         sprintf(item_selection_ptr->tmp_val, "(%s) %s", item_selection_ptr->out_val, pmt);
345         prt(item_selection_ptr->tmp_val, 0, 0);
346         item_selection_ptr->which = inkey();
347         if (use_menu) {
348             int max_line = (command_wrk ? item_selection_ptr->max_equip : item_selection_ptr->max_inven);
349             switch (item_selection_ptr->which) {
350             case ESCAPE:
351             case 'z':
352             case 'Z':
353             case '0': {
354                 item_selection_ptr->done = TRUE;
355                 break;
356             }
357
358             case '8':
359             case 'k':
360             case 'K': {
361                 item_selection_ptr->menu_line += (max_line - 1);
362                 break;
363             }
364
365             case '2':
366             case 'j':
367             case 'J': {
368                 item_selection_ptr->menu_line++;
369                 break;
370             }
371
372             case '4':
373             case '6':
374             case 'h':
375             case 'H':
376             case 'l':
377             case 'L': {
378                 if (!item_selection_ptr->inven || !item_selection_ptr->equip) {
379                     bell();
380                     break;
381                 }
382
383                 if (command_see) {
384                     screen_load();
385                     screen_save();
386                 }
387
388                 command_wrk = !command_wrk;
389                 max_line = (command_wrk ? item_selection_ptr->max_equip : item_selection_ptr->max_inven);
390                 if (item_selection_ptr->menu_line > max_line)
391                     item_selection_ptr->menu_line = max_line;
392
393                 break;
394             }
395
396             case 'x':
397             case 'X':
398             case '\r':
399             case '\n': {
400                 if (command_wrk == USE_FLOOR) {
401                     *item_selection_ptr->cp = -get_item_label;
402                 } else {
403                     if (!get_item_okay(owner_ptr, get_item_label, item_selection_ptr->tval)) {
404                         bell();
405                         break;
406                     }
407
408                     if (!get_item_allow(owner_ptr, get_item_label)) {
409                         item_selection_ptr->done = TRUE;
410                         break;
411                     }
412
413                     *item_selection_ptr->cp = get_item_label;
414                 }
415
416                 item_selection_ptr->item = TRUE;
417                 item_selection_ptr->done = TRUE;
418                 break;
419             }
420             case 'w': {
421                 if (item_selection_ptr->mode & USE_FORCE) {
422                     *item_selection_ptr->cp = INVEN_FORCE;
423                     item_selection_ptr->item = TRUE;
424                     item_selection_ptr->done = TRUE;
425                     break;
426                 }
427             }
428             }
429
430             if (item_selection_ptr->menu_line > max_line)
431                 item_selection_ptr->menu_line -= max_line;
432
433             continue;
434         }
435
436         switch (item_selection_ptr->which) {
437         case ESCAPE: {
438             item_selection_ptr->done = TRUE;
439             break;
440         }
441         case '*':
442         case '?':
443         case ' ': {
444             if (command_see) {
445                 command_see = FALSE;
446                 screen_load();
447             } else {
448                 screen_save();
449                 command_see = TRUE;
450             }
451
452             break;
453         }
454         case '/': {
455             if (!item_selection_ptr->inven || !item_selection_ptr->equip) {
456                 bell();
457                 break;
458             }
459
460             if (command_see) {
461                 screen_load();
462                 screen_save();
463             }
464
465             command_wrk = !command_wrk;
466             break;
467         }
468         case '-': {
469             if (item_selection_ptr->allow_floor) {
470                 for (item_selection_ptr->this_o_idx = owner_ptr->current_floor_ptr->grid_array[owner_ptr->y][owner_ptr->x].o_idx;
471                      item_selection_ptr->this_o_idx; item_selection_ptr->this_o_idx = item_selection_ptr->next_o_idx) {
472                     object_type *o_ptr;
473                     o_ptr = &owner_ptr->current_floor_ptr->o_list[item_selection_ptr->this_o_idx];
474                     item_selection_ptr->next_o_idx = o_ptr->next_o_idx;
475                     if (!item_tester_okay(owner_ptr, o_ptr, item_selection_ptr->tval) && !(item_selection_ptr->mode & USE_FULL))
476                         continue;
477
478                     item_selection_ptr->k = 0 - item_selection_ptr->this_o_idx;
479                     if ((other_query_flag && !verify(owner_ptr, _("本当に", "Try"), item_selection_ptr->k))
480                         || !get_item_allow(owner_ptr, item_selection_ptr->k))
481                         continue;
482
483                     *item_selection_ptr->cp = item_selection_ptr->k;
484                     item_selection_ptr->item = TRUE;
485                     item_selection_ptr->done = TRUE;
486                     break;
487                 }
488
489                 if (item_selection_ptr->done)
490                     break;
491             }
492
493             bell();
494             break;
495         }
496         case '0':
497         case '1':
498         case '2':
499         case '3':
500         case '4':
501         case '5':
502         case '6':
503         case '7':
504         case '8':
505         case '9': {
506             if (!get_tag(owner_ptr, &item_selection_ptr->k, item_selection_ptr->which, command_wrk ? USE_EQUIP : USE_INVEN, item_selection_ptr->tval)) {
507                 bell();
508                 break;
509             }
510
511             if ((item_selection_ptr->k < INVEN_MAIN_HAND) ? !item_selection_ptr->inven : !item_selection_ptr->equip) {
512                 bell();
513                 break;
514             }
515
516             if (!get_item_okay(owner_ptr, item_selection_ptr->k, item_selection_ptr->tval)) {
517                 bell();
518                 break;
519             }
520
521             if (!get_item_allow(owner_ptr, item_selection_ptr->k)) {
522                 item_selection_ptr->done = TRUE;
523                 break;
524             }
525
526             *item_selection_ptr->cp = item_selection_ptr->k;
527             item_selection_ptr->item = TRUE;
528             item_selection_ptr->done = TRUE;
529             item_selection_ptr->cur_tag = item_selection_ptr->which;
530             break;
531         }
532         case 'w': {
533             if (item_selection_ptr->mode & USE_FORCE) {
534                 *item_selection_ptr->cp = INVEN_FORCE;
535                 item_selection_ptr->item = TRUE;
536                 item_selection_ptr->done = TRUE;
537                 break;
538             }
539         }
540             /* Fall through */
541         default: {
542             int ver;
543             bool not_found = FALSE;
544             if (!get_tag(owner_ptr, &item_selection_ptr->k, item_selection_ptr->which, command_wrk ? USE_EQUIP : USE_INVEN, item_selection_ptr->tval)) {
545                 not_found = TRUE;
546             } else if ((item_selection_ptr->k < INVEN_MAIN_HAND) ? !item_selection_ptr->inven : !item_selection_ptr->equip) {
547                 not_found = TRUE;
548             } else if (!get_item_okay(owner_ptr, item_selection_ptr->k, item_selection_ptr->tval)) {
549                 not_found = TRUE;
550             }
551
552             if (!not_found) {
553                 *item_selection_ptr->cp = item_selection_ptr->k;
554                 item_selection_ptr->item = TRUE;
555                 item_selection_ptr->done = TRUE;
556                 item_selection_ptr->cur_tag = item_selection_ptr->which;
557                 break;
558             }
559
560             ver = isupper(item_selection_ptr->which);
561             item_selection_ptr->which = (char)tolower(item_selection_ptr->which);
562             if (!command_wrk) {
563                 if (item_selection_ptr->which == '(')
564                     item_selection_ptr->k = item_selection_ptr->i1;
565                 else if (item_selection_ptr->which == ')')
566                     item_selection_ptr->k = item_selection_ptr->i2;
567                 else
568                     item_selection_ptr->k = label_to_inventory(owner_ptr, item_selection_ptr->which);
569             } else {
570                 if (item_selection_ptr->which == '(')
571                     item_selection_ptr->k = item_selection_ptr->e1;
572                 else if (item_selection_ptr->which == ')')
573                     item_selection_ptr->k = item_selection_ptr->e2;
574                 else
575                     item_selection_ptr->k = label_to_equipment(owner_ptr, item_selection_ptr->which);
576             }
577
578             if (!get_item_okay(owner_ptr, item_selection_ptr->k, item_selection_ptr->tval)) {
579                 bell();
580                 break;
581             }
582
583             if (ver && !verify(owner_ptr, _("本当に", "Try"), item_selection_ptr->k)) {
584                 item_selection_ptr->done = TRUE;
585                 break;
586             }
587
588             if (!get_item_allow(owner_ptr, item_selection_ptr->k)) {
589                 item_selection_ptr->done = TRUE;
590                 break;
591             }
592
593             *item_selection_ptr->cp = item_selection_ptr->k;
594             item_selection_ptr->item = TRUE;
595             item_selection_ptr->done = TRUE;
596             break;
597         }
598         }
599     }
600
601     if (command_see) {
602         screen_load();
603         command_see = FALSE;
604     }
605
606     item_selection_ptr->tval = 0;
607     item_tester_hook = NULL;
608     if (item_selection_ptr->toggle)
609         toggle_inventory_equipment(owner_ptr);
610
611     owner_ptr->window |= (PW_INVEN | PW_EQUIP);
612     handle_stuff(owner_ptr);
613     prt("", 0, 0);
614     if (item_selection_ptr->oops && str)
615         msg_print(str);
616
617     if (item_selection_ptr->item) {
618         repeat_push(*item_selection_ptr->cp);
619         if (command_cmd)
620             prev_tag = item_selection_ptr->cur_tag;
621         command_cmd = 0;
622     }
623
624     return item_selection_ptr->item;
625 }