OSDN Git Service

[Refactor] #40521 Separated floor-item-getter.c/h from player-inventory.c/h
[hengband/hengband.git] / src / inventory / floor-item-getter.c
1 /*!
2  * @brief オブジェクト選択処理
3  * @date 2020/07/02
4  * @author Hourier
5  */
6
7 #include "inventory/floor-item-getter.h"
8 #include "core/stuff-handler.h"
9 #include "floor/floor-object.h"
10 #include "floor/floor.h"
11 #include "game-option/input-options.h"
12 #include "game-option/option-flags.h"
13 #include "game-option/text-display-options.h"
14 #include "grid/grid.h"
15 #include "inventory/inventory-util.h"
16 #include "inventory/player-inventory.h" // todo 相互依存している.
17 #include "io/command-repeater.h"
18 #include "io/input-key-acceptor.h"
19 #include "io/input-key-requester.h"
20 #include "main/sound-of-music.h"
21 #include "object/item-tester-hooker.h"
22 #include "object/item-use-flags.h"
23 #include "object/object-info.h"
24 #include "term/gameterm.h"
25 #include "term/screen-processor.h"
26 #include "util/int-char-converter.h"
27 #include "view/display-messages.h"
28
29 /*!
30  * @brief オブジェクト選択の汎用関数(床上アイテム用) /
31  * Let the user select an item, save its "index"
32  * @param cp 選択したオブジェクトのIDを返す。
33  * @param pmt 選択目的のメッセージ
34  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
35  * @param mode オプションフラグ
36  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
37  */
38 bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concptr str, BIT_FLAGS mode, tval_type tval)
39 {
40     char n1 = ' ', n2 = ' ', which = ' ';
41     int j;
42     COMMAND_CODE i1, i2;
43     COMMAND_CODE e1, e2;
44     COMMAND_CODE k;
45     bool done;
46     bool item;
47     bool oops = FALSE;
48     bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
49     bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
50     bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
51     bool force = (mode & USE_FORCE) ? TRUE : FALSE;
52     bool allow_equip = FALSE;
53     bool allow_inven = FALSE;
54     bool allow_floor = FALSE;
55     bool toggle = FALSE;
56     char tmp_val[160];
57     char out_val[160];
58     ITEM_NUMBER floor_num;
59     OBJECT_IDX floor_list[23];
60     int floor_top = 0;
61     TERM_LEN min_width = 0;
62     int menu_line = (use_menu ? 1 : 0);
63     int max_inven = 0;
64     int max_equip = 0;
65     static char prev_tag = '\0';
66     char cur_tag = '\0';
67     if (repeat_pull(cp)) {
68         if (force && (*cp == INVEN_FORCE)) {
69             tval = 0;
70             item_tester_hook = NULL;
71             command_cmd = 0;
72             return TRUE;
73         } else if (floor && (*cp < 0)) {
74             if (prev_tag && command_cmd) {
75                 floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
76                 if (get_tag_floor(owner_ptr->current_floor_ptr, &k, prev_tag, floor_list, floor_num)) {
77                     (*cp) = 0 - floor_list[k];
78                     tval = 0;
79                     item_tester_hook = NULL;
80                     command_cmd = 0;
81                     return TRUE;
82                 }
83
84                 prev_tag = '\0';
85             } else if (item_tester_okay(owner_ptr, &owner_ptr->current_floor_ptr->o_list[0 - (*cp)], tval) || (mode & USE_FULL)) {
86                 tval = 0;
87                 item_tester_hook = NULL;
88                 command_cmd = 0;
89                 return TRUE;
90             }
91         } else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) || (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL))) {
92             if (prev_tag && command_cmd) {
93                 if (!get_tag(owner_ptr, &k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN, tval)) /* Reject */
94                     ;
95                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */
96                     ;
97                 else if (!get_item_okay(owner_ptr, k, tval)) /* Reject */
98                     ;
99                 else {
100                     (*cp) = k;
101                     tval = 0;
102                     item_tester_hook = NULL;
103                     command_cmd = 0;
104                     return TRUE;
105                 }
106
107                 prev_tag = '\0';
108             } else if (get_item_okay(owner_ptr, *cp, tval)) {
109                 tval = 0;
110                 item_tester_hook = NULL;
111                 command_cmd = 0;
112                 return TRUE;
113             }
114         }
115     }
116
117     msg_print(NULL);
118     done = FALSE;
119     item = FALSE;
120     i1 = 0;
121     i2 = INVEN_PACK - 1;
122     if (!inven)
123         i2 = -1;
124     else if (use_menu)
125         for (j = 0; j < INVEN_PACK; j++)
126             if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval) || (mode & USE_FULL))
127                 max_inven++;
128
129     while ((i1 <= i2) && (!get_item_okay(owner_ptr, i1, tval)))
130         i1++;
131
132     while ((i1 <= i2) && (!get_item_okay(owner_ptr, i2, tval)))
133         i2--;
134
135     e1 = INVEN_RARM;
136     e2 = INVEN_TOTAL - 1;
137     if (!equip)
138         e2 = -1;
139     else if (use_menu)
140         for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
141             if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], tval) || (mode & USE_FULL))
142                 max_equip++;
143     if (owner_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT))
144         max_equip++;
145
146     while ((e1 <= e2) && (!get_item_okay(owner_ptr, e1, tval)))
147         e1++;
148
149     while ((e1 <= e2) && (!get_item_okay(owner_ptr, e2, tval)))
150         e2--;
151
152     if (equip && owner_ptr->ryoute && !(mode & IGNORE_BOTHHAND_SLOT)) {
153         if (owner_ptr->migite) {
154             if (e2 < INVEN_LARM)
155                 e2 = INVEN_LARM;
156         } else if (owner_ptr->hidarite)
157             e1 = INVEN_RARM;
158     }
159
160     floor_num = 0;
161     if (floor)
162         floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
163
164     if (i1 <= i2)
165         allow_inven = TRUE;
166
167     if (e1 <= e2)
168         allow_equip = TRUE;
169
170     if (floor_num)
171         allow_floor = TRUE;
172
173     if (!allow_inven && !allow_equip && !allow_floor) {
174         command_see = FALSE;
175         oops = TRUE;
176         done = TRUE;
177
178         if (force) {
179             *cp = INVEN_FORCE;
180             item = TRUE;
181         }
182     } else {
183         if (command_see && (command_wrk == (USE_EQUIP)) && allow_equip)
184             command_wrk = (USE_EQUIP);
185         else if (allow_inven)
186             command_wrk = (USE_INVEN);
187         else if (allow_equip)
188             command_wrk = (USE_EQUIP);
189         else if (allow_floor)
190             command_wrk = (USE_FLOOR);
191     }
192
193     /*
194      * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
195      */
196     if ((always_show_list == TRUE) || use_menu)
197         command_see = TRUE;
198
199     if (command_see)
200         screen_save();
201
202     while (!done) {
203         COMMAND_CODE get_item_label = 0;
204         int ni = 0;
205         int ne = 0;
206         for (j = 0; j < 8; j++) {
207             if (!angband_term[j])
208                 continue;
209
210             if (window_flag[j] & (PW_INVEN))
211                 ni++;
212
213             if (window_flag[j] & (PW_EQUIP))
214                 ne++;
215         }
216
217         if ((command_wrk == (USE_EQUIP) && ni && !ne) || (command_wrk == (USE_INVEN) && !ni && ne)) {
218             toggle_inventory_equipment(owner_ptr);
219             toggle = !toggle;
220         }
221
222         owner_ptr->window |= (PW_INVEN | PW_EQUIP);
223         handle_stuff(owner_ptr);
224         if (command_wrk == (USE_INVEN)) {
225             n1 = I2A(i1);
226             n2 = I2A(i2);
227             if (command_see)
228                 get_item_label = show_inventory(owner_ptr, menu_line, mode, tval);
229         } else if (command_wrk == (USE_EQUIP)) {
230             n1 = I2A(e1 - INVEN_RARM);
231             n2 = I2A(e2 - INVEN_RARM);
232             if (command_see)
233                 get_item_label = show_equipment(owner_ptr, menu_line, mode, tval);
234         } else if (command_wrk == (USE_FLOOR)) {
235             j = floor_top;
236             k = MIN(floor_top + 23, floor_num) - 1;
237             n1 = I2A(j - floor_top);
238             n2 = I2A(k - floor_top);
239             if (command_see)
240                 get_item_label = show_floor(owner_ptr, menu_line, owner_ptr->y, owner_ptr->x, &min_width, tval);
241         }
242
243         if (command_wrk == (USE_INVEN)) {
244             sprintf(out_val, _("持ち物:", "Inven:"));
245             if (!use_menu) {
246                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(i1), index_to_label(i2));
247                 strcat(out_val, tmp_val);
248             }
249
250             if (!command_see && !use_menu)
251                 strcat(out_val, _(" '*'一覧,", " * to see,"));
252
253             if (allow_equip) {
254                 if (!use_menu)
255                     strcat(out_val, _(" '/' 装備品,", " / for Equip,"));
256                 else if (allow_floor)
257                     strcat(out_val, _(" '6' 装備品,", " 6 for Equip,"));
258                 else
259                     strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
260             }
261
262             if (allow_floor) {
263                 if (!use_menu)
264                     strcat(out_val, _(" '-'床上,", " - for floor,"));
265                 else if (allow_equip)
266                     strcat(out_val, _(" '4' 床上,", " 4 for floor,"));
267                 else
268                     strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
269             }
270         } else if (command_wrk == (USE_EQUIP)) {
271             sprintf(out_val, _("装備品:", "Equip:"));
272             if (!use_menu) {
273                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), index_to_label(e1), index_to_label(e2));
274                 strcat(out_val, tmp_val);
275             }
276
277             if (!command_see && !use_menu)
278                 strcat(out_val, _(" '*'一覧,", " * to see,"));
279
280             if (allow_inven) {
281                 if (!use_menu)
282                     strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
283                 else if (allow_floor)
284                     strcat(out_val, _(" '4' 持ち物,", " 4 for Inven,"));
285                 else
286                     strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
287             }
288
289             if (allow_floor) {
290                 if (!use_menu)
291                     strcat(out_val, _(" '-'床上,", " - for floor,"));
292                 else if (allow_inven)
293                     strcat(out_val, _(" '6' 床上,", " 6 for floor,"));
294                 else
295                     strcat(out_val, _(" '4'or'6' 床上,", " 4 or 6 for floor,"));
296             }
297         } else if (command_wrk == (USE_FLOOR)) {
298             sprintf(out_val, _("床上:", "Floor:"));
299             if (!use_menu) {
300                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
301                 strcat(out_val, tmp_val);
302             }
303
304             if (!command_see && !use_menu)
305                 strcat(out_val, _(" '*'一覧,", " * to see,"));
306
307             if (use_menu) {
308                 if (allow_inven && allow_equip) {
309                     strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
310                 } else if (allow_inven) {
311                     strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
312                 } else if (allow_equip) {
313                     strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
314                 }
315             } else if (allow_inven) {
316                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
317             } else if (allow_equip) {
318                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
319             }
320
321             if (command_see && !use_menu) {
322                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
323             }
324         }
325
326         if (force)
327             strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
328
329         strcat(out_val, " ESC");
330         sprintf(tmp_val, "(%s) %s", out_val, pmt);
331         prt(tmp_val, 0, 0);
332         which = inkey();
333         if (use_menu) {
334             int max_line = 1;
335             if (command_wrk == USE_INVEN)
336                 max_line = max_inven;
337             else if (command_wrk == USE_EQUIP)
338                 max_line = max_equip;
339             else if (command_wrk == USE_FLOOR)
340                 max_line = MIN(23, floor_num);
341             switch (which) {
342             case ESCAPE:
343             case 'z':
344             case 'Z':
345             case '0': {
346                 done = TRUE;
347                 break;
348             }
349             case '8':
350             case 'k':
351             case 'K': {
352                 menu_line += (max_line - 1);
353                 break;
354             }
355             case '2':
356             case 'j':
357             case 'J': {
358                 menu_line++;
359                 break;
360             }
361             case '4':
362             case 'h':
363             case 'H': {
364                 if (command_wrk == (USE_INVEN)) {
365                     if (allow_floor)
366                         command_wrk = USE_FLOOR;
367                     else if (allow_equip)
368                         command_wrk = USE_EQUIP;
369                     else {
370                         bell();
371                         break;
372                     }
373                 } else if (command_wrk == (USE_EQUIP)) {
374                     if (allow_inven)
375                         command_wrk = USE_INVEN;
376                     else if (allow_floor)
377                         command_wrk = USE_FLOOR;
378                     else {
379                         bell();
380                         break;
381                     }
382                 } else if (command_wrk == (USE_FLOOR)) {
383                     if (allow_equip)
384                         command_wrk = USE_EQUIP;
385                     else if (allow_inven)
386                         command_wrk = USE_INVEN;
387                     else {
388                         bell();
389                         break;
390                     }
391                 } else {
392                     bell();
393                     break;
394                 }
395
396                 if (command_see) {
397                     screen_load();
398                     screen_save();
399                 }
400
401                 if (command_wrk == USE_INVEN)
402                     max_line = max_inven;
403                 else if (command_wrk == USE_EQUIP)
404                     max_line = max_equip;
405                 else if (command_wrk == USE_FLOOR)
406                     max_line = MIN(23, floor_num);
407
408                 if (menu_line > max_line)
409                     menu_line = max_line;
410
411                 break;
412             }
413             case '6':
414             case 'l':
415             case 'L': {
416                 if (command_wrk == (USE_INVEN)) {
417                     if (allow_equip)
418                         command_wrk = USE_EQUIP;
419                     else if (allow_floor)
420                         command_wrk = USE_FLOOR;
421                     else {
422                         bell();
423                         break;
424                     }
425                 } else if (command_wrk == (USE_EQUIP)) {
426                     if (allow_floor)
427                         command_wrk = USE_FLOOR;
428                     else if (allow_inven)
429                         command_wrk = USE_INVEN;
430                     else {
431                         bell();
432                         break;
433                     }
434                 } else if (command_wrk == (USE_FLOOR)) {
435                     if (allow_inven)
436                         command_wrk = USE_INVEN;
437                     else if (allow_equip)
438                         command_wrk = USE_EQUIP;
439                     else {
440                         bell();
441                         break;
442                     }
443                 } else {
444                     bell();
445                     break;
446                 }
447
448                 if (command_see) {
449                     screen_load();
450                     screen_save();
451                 }
452
453                 if (command_wrk == USE_INVEN)
454                     max_line = max_inven;
455                 else if (command_wrk == USE_EQUIP)
456                     max_line = max_equip;
457                 else if (command_wrk == USE_FLOOR)
458                     max_line = MIN(23, floor_num);
459
460                 if (menu_line > max_line)
461                     menu_line = max_line;
462
463                 break;
464             }
465             case 'x':
466             case 'X':
467             case '\r':
468             case '\n': {
469                 if (command_wrk == USE_FLOOR)
470                     (*cp) = -get_item_label;
471                 else {
472                     if (!get_item_okay(owner_ptr, get_item_label, tval)) {
473                         bell();
474                         break;
475                     }
476
477                     if (!get_item_allow(owner_ptr, get_item_label)) {
478                         done = TRUE;
479                         break;
480                     }
481
482                     (*cp) = get_item_label;
483                 }
484
485                 item = TRUE;
486                 done = TRUE;
487                 break;
488             }
489             case 'w': {
490                 if (force) {
491                     *cp = INVEN_FORCE;
492                     item = TRUE;
493                     done = TRUE;
494                     break;
495                 }
496             }
497             }
498
499             if (menu_line > max_line)
500                 menu_line -= max_line;
501
502             continue;
503         }
504
505         switch (which) {
506         case ESCAPE: {
507             done = TRUE;
508             break;
509         }
510         case '*':
511         case '?':
512         case ' ': {
513             if (command_see) {
514                 command_see = FALSE;
515                 screen_load();
516             } else {
517                 screen_save();
518                 command_see = TRUE;
519             }
520
521             break;
522         }
523         case '\n':
524         case '\r':
525         case '+': {
526             int i;
527             OBJECT_IDX o_idx;
528             grid_type *g_ptr = &owner_ptr->current_floor_ptr->grid_array[owner_ptr->y][owner_ptr->x];
529             if (command_wrk != (USE_FLOOR))
530                 break;
531
532             o_idx = g_ptr->o_idx;
533             if (!(o_idx && owner_ptr->current_floor_ptr->o_list[o_idx].next_o_idx))
534                 break;
535
536             excise_object_idx(owner_ptr->current_floor_ptr, o_idx);
537             i = g_ptr->o_idx;
538             while (owner_ptr->current_floor_ptr->o_list[i].next_o_idx)
539                 i = owner_ptr->current_floor_ptr->o_list[i].next_o_idx;
540
541             owner_ptr->current_floor_ptr->o_list[i].next_o_idx = o_idx;
542             floor_num = scan_floor(owner_ptr, floor_list, owner_ptr->y, owner_ptr->x, 0x03, tval);
543             if (command_see) {
544                 screen_load();
545                 screen_save();
546             }
547
548             break;
549         }
550         case '/': {
551             if (command_wrk == (USE_INVEN)) {
552                 if (!allow_equip) {
553                     bell();
554                     break;
555                 }
556                 command_wrk = (USE_EQUIP);
557             } else if (command_wrk == (USE_EQUIP)) {
558                 if (!allow_inven) {
559                     bell();
560                     break;
561                 }
562                 command_wrk = (USE_INVEN);
563             } else if (command_wrk == (USE_FLOOR)) {
564                 if (allow_inven) {
565                     command_wrk = (USE_INVEN);
566                 } else if (allow_equip) {
567                     command_wrk = (USE_EQUIP);
568                 } else {
569                     bell();
570                     break;
571                 }
572             }
573
574             if (command_see) {
575                 screen_load();
576                 screen_save();
577             }
578
579             break;
580         }
581         case '-': {
582             if (!allow_floor) {
583                 bell();
584                 break;
585             }
586
587             if (floor_num == 1) {
588                 if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag)) {
589                     k = 0 - floor_list[0];
590                     if (!get_item_allow(owner_ptr, k)) {
591                         done = TRUE;
592                         break;
593                     }
594
595                     (*cp) = k;
596                     item = TRUE;
597                     done = TRUE;
598                     break;
599                 }
600             }
601
602             if (command_see) {
603                 screen_load();
604                 screen_save();
605             }
606
607             command_wrk = (USE_FLOOR);
608             break;
609         }
610         case '0':
611         case '1':
612         case '2':
613         case '3':
614         case '4':
615         case '5':
616         case '6':
617         case '7':
618         case '8':
619         case '9': {
620             if (command_wrk != USE_FLOOR) {
621                 if (!get_tag(owner_ptr, &k, which, command_wrk, tval)) {
622                     bell();
623                     break;
624                 }
625
626                 if ((k < INVEN_RARM) ? !inven : !equip) {
627                     bell();
628                     break;
629                 }
630
631                 if (!get_item_okay(owner_ptr, k, tval)) {
632                     bell();
633                     break;
634                 }
635             } else {
636                 if (get_tag_floor(owner_ptr->current_floor_ptr, &k, which, floor_list, floor_num)) {
637                     k = 0 - floor_list[k];
638                 } else {
639                     bell();
640                     break;
641                 }
642             }
643
644             if (!get_item_allow(owner_ptr, k)) {
645                 done = TRUE;
646                 break;
647             }
648
649             (*cp) = k;
650             item = TRUE;
651             done = TRUE;
652             cur_tag = which;
653             break;
654         }
655         case 'w': {
656             if (force) {
657                 *cp = INVEN_FORCE;
658                 item = TRUE;
659                 done = TRUE;
660                 break;
661             }
662         }
663             /* Fall through */
664         default: {
665             int ver;
666             if (command_wrk != USE_FLOOR) {
667                 bool not_found = FALSE;
668                 if (!get_tag(owner_ptr, &k, which, command_wrk, tval))
669                     not_found = TRUE;
670                 else if ((k < INVEN_RARM) ? !inven : !equip)
671                     not_found = TRUE;
672                 else if (!get_item_okay(owner_ptr, k, tval))
673                     not_found = TRUE;
674
675                 if (!not_found) {
676                     (*cp) = k;
677                     item = TRUE;
678                     done = TRUE;
679                     cur_tag = which;
680                     break;
681                 }
682             } else {
683                 if (get_tag_floor(owner_ptr->current_floor_ptr, &k, which, floor_list, floor_num)) {
684                     k = 0 - floor_list[k];
685                     (*cp) = k;
686                     item = TRUE;
687                     done = TRUE;
688                     cur_tag = which;
689                     break;
690                 }
691             }
692
693             ver = isupper(which);
694             which = (char)tolower(which);
695             if (command_wrk == (USE_INVEN)) {
696                 if (which == '(')
697                     k = i1;
698                 else if (which == ')')
699                     k = i2;
700                 else
701                     k = label_to_inventory(owner_ptr, which);
702             } else if (command_wrk == (USE_EQUIP)) {
703                 if (which == '(')
704                     k = e1;
705                 else if (which == ')')
706                     k = e2;
707                 else
708                     k = label_to_equipment(owner_ptr, which);
709             } else if (command_wrk == USE_FLOOR) {
710                 if (which == '(')
711                     k = 0;
712                 else if (which == ')')
713                     k = floor_num - 1;
714                 else
715                     k = islower(which) ? A2I(which) : -1;
716                 if (k < 0 || k >= floor_num || k >= 23) {
717                     bell();
718                     break;
719                 }
720
721                 k = 0 - floor_list[k];
722             }
723
724             if ((command_wrk != USE_FLOOR) && !get_item_okay(owner_ptr, k, tval)) {
725                 bell();
726                 break;
727             }
728
729             if (ver && !verify(owner_ptr, _("本当に", "Try"), k)) {
730                 done = TRUE;
731                 break;
732             }
733
734             if (!get_item_allow(owner_ptr, k)) {
735                 done = TRUE;
736                 break;
737             }
738
739             (*cp) = k;
740             item = TRUE;
741             done = TRUE;
742             break;
743         }
744         }
745     }
746
747     if (command_see) {
748         screen_load();
749         command_see = FALSE;
750     }
751
752     tval = 0;
753     item_tester_hook = NULL;
754     if (toggle)
755         toggle_inventory_equipment(owner_ptr);
756
757     owner_ptr->window |= (PW_INVEN | PW_EQUIP);
758     handle_stuff(owner_ptr);
759     prt("", 0, 0);
760     if (oops && str)
761         msg_print(str);
762
763     if (item) {
764         repeat_push(*cp);
765         if (command_cmd)
766             prev_tag = cur_tag;
767         command_cmd = 0;
768     }
769
770     return item;
771 }