OSDN Git Service

42e7e3a2ad063645f96b3d32cd0fb9a5af932f11
[hengband/hengband.git] / src / cmd3.c
1 /* File: cmd3.c */
2
3 /* Purpose: Inventory commands */
4
5 /*
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
7  *
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  */
12
13 #include "angband.h"
14
15
16
17 /*
18  * Display inventory
19  */
20 void do_cmd_inven(void)
21 {
22         char out_val[160];
23
24
25         /* Note that we are in "inventory" mode */
26         command_wrk = FALSE;
27
28 #ifdef ALLOW_EASY_FLOOR
29
30         /* Note that we are in "inventory" mode */
31         if (easy_floor) command_wrk = (USE_INVEN);
32
33 #endif /* ALLOW_EASY_FLOOR */
34
35         /* Save screen */
36         screen_save();
37
38         /* Hack -- show empty slots */
39         item_tester_full = TRUE;
40
41         /* Display the inventory */
42         (void)show_inven(0);
43
44         /* Hack -- hide empty slots */
45         item_tester_full = FALSE;
46
47 #ifdef JP
48         sprintf(out_val, "»ý¤Áʪ¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ",
49             lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) ,
50             (p_ptr->total_weight * 100) / weight_limit());
51 #else
52         sprintf(out_val, "Inventory: carrying %d.%d pounds (%ld%% of capacity). Command: ",
53             (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
54             (p_ptr->total_weight * 100) / weight_limit());
55 #endif
56
57
58         /* Get a command */
59         prt(out_val, 0, 0);
60
61         /* Get a new command */
62         command_new = inkey();
63
64         /* Load screen */
65         screen_load();
66
67
68         /* Process "Escape" */
69         if (command_new == ESCAPE)
70         {
71                 int wid, hgt;
72
73                 /* Get size */
74                 Term_get_size(&wid, &hgt);
75
76                 /* Reset stuff */
77                 command_new = 0;
78                 command_gap = wid - 30;
79         }
80
81         /* Process normal keys */
82         else
83         {
84                 /* Hack -- Use "display" mode */
85                 command_see = TRUE;
86         }
87 }
88
89
90 /*
91  * Display equipment
92  */
93 void do_cmd_equip(void)
94 {
95         char out_val[160];
96
97
98         /* Note that we are in "equipment" mode */
99         command_wrk = TRUE;
100
101 #ifdef ALLOW_EASY_FLOOR
102
103         /* Note that we are in "equipment" mode */
104         if (easy_floor) command_wrk = (USE_EQUIP);
105
106 #endif /* ALLOW_EASY_FLOOR  */
107
108         /* Save the screen */
109         screen_save();
110
111         /* Hack -- show empty slots */
112         item_tester_full = TRUE;
113
114         /* Display the equipment */
115         (void)show_equip(0);
116
117         /* Hack -- undo the hack above */
118         item_tester_full = FALSE;
119
120         /* Build a prompt */
121 #ifdef JP
122         sprintf(out_val, "ÁõÈ÷¡§ ¹ç·× %3d.%1d kg (¸Â³¦¤Î%ld%%) ¥³¥Þ¥ó¥É: ",
123             lbtokg1(p_ptr->total_weight) , lbtokg2(p_ptr->total_weight) ,
124             (p_ptr->total_weight * 100) / weight_limit());
125 #else
126         sprintf(out_val, "Equipment: carrying %d.%d pounds (%ld%% of capacity). Command: ",
127             (int)(p_ptr->total_weight / 10), (int)(p_ptr->total_weight % 10),
128             (p_ptr->total_weight * 100) / weight_limit());
129 #endif
130
131
132         /* Get a command */
133         prt(out_val, 0, 0);
134
135         /* Get a new command */
136         command_new = inkey();
137
138         /* Restore the screen */
139         screen_load();
140
141
142         /* Process "Escape" */
143         if (command_new == ESCAPE)
144         {
145                 int wid, hgt;
146
147                 /* Get size */
148                 Term_get_size(&wid, &hgt);
149
150                 /* Reset stuff */
151                 command_new = 0;
152                 command_gap = wid - 30;
153         }
154
155         /* Process normal keys */
156         else
157         {
158                 /* Enter "display" mode */
159                 command_see = TRUE;
160         }
161 }
162
163
164 /*
165  * The "wearable" tester
166  */
167 static bool item_tester_hook_wear(object_type *o_ptr)
168 {
169         if ((o_ptr->tval == TV_SOFT_ARMOR) && (o_ptr->sval == SV_ABUNAI_MIZUGI))
170                 if (p_ptr->psex == SEX_MALE) return FALSE;
171
172         /* Check for a usable slot */
173         if (wield_slot(o_ptr) >= INVEN_RARM) return (TRUE);
174
175         /* Assume not wearable */
176         return (FALSE);
177 }
178
179
180 static bool item_tester_hook_mochikae(object_type *o_ptr)
181 {
182         /* Check for a usable slot */
183         if (((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD)) ||
184             (o_ptr->tval == TV_SHIELD) || (o_ptr->tval == TV_CAPTURE) ||
185             (o_ptr->tval == TV_CARD)) return (TRUE);
186
187         /* Assume not wearable */
188         return (FALSE);
189 }
190
191
192 static bool item_tester_hook_melee_weapon(object_type *o_ptr)
193 {
194         /* Check for a usable slot */
195         if ((o_ptr->tval >= TV_DIGGING) && (o_ptr->tval <= TV_SWORD))return (TRUE);
196
197         /* Assume not wearable */
198         return (FALSE);
199 }
200
201
202 bool select_ring_slot = FALSE;
203
204 /*
205  * Wield or wear a single item from the pack or floor
206  */
207 void do_cmd_wield(void)
208 {
209         int i, item, slot;
210
211         object_type forge;
212         object_type *q_ptr;
213
214         object_type *o_ptr;
215
216         cptr act;
217
218         char o_name[MAX_NLEN];
219
220         cptr q, s;
221
222         int need_switch_wielding = 0;
223
224         if (p_ptr->special_defense & KATA_MUSOU)
225         {
226                 set_action(ACTION_NONE);
227         }
228
229         /* Restrict the choices */
230         item_tester_hook = item_tester_hook_wear;
231
232         /* Get an item */
233 #ifdef JP
234         q = "¤É¤ì¤òÁõÈ÷¤·¤Þ¤¹¤«? ";
235         s = "ÁõÈ÷²Äǽ¤Ê¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
236 #else
237         q = "Wear/Wield which item? ";
238         s = "You have nothing you can wear or wield.";
239 #endif
240
241         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
242
243         /* Get the item (in the pack) */
244         if (item >= 0)
245         {
246                 o_ptr = &inventory[item];
247         }
248
249         /* Get the item (on the floor) */
250         else
251         {
252                 o_ptr = &o_list[0 - item];
253         }
254
255
256         /* Check the slot */
257         slot = wield_slot(o_ptr);
258
259         switch (o_ptr->tval)
260         {
261         /* Shields and some misc. items */
262         case TV_CAPTURE:
263         case TV_SHIELD:
264         case TV_CARD:
265                 /* Dual wielding */
266                 if (buki_motteruka(INVEN_RARM) && buki_motteruka(INVEN_LARM))
267                 {
268                         /* Restrict the choices */
269                         item_tester_hook = item_tester_hook_melee_weapon;
270                         item_tester_no_ryoute = TRUE;
271
272                         /* Choose a weapon from the equipment only */
273 #ifdef JP
274                         q = "¤É¤Á¤é¤ÎÉð´ï¤È¼è¤êÂؤ¨¤Þ¤¹¤«?";
275                         s = "¤ª¤Ã¤È¡£";
276 #else
277                         q = "Replace which weapon? ";
278                         s = "Oops.";
279 #endif
280
281                         if (!get_item(&slot, q, s, (USE_EQUIP))) return;
282                         if (slot == INVEN_RARM) need_switch_wielding = INVEN_LARM;
283                 }
284
285                 else if (buki_motteruka(INVEN_LARM)) slot = INVEN_RARM;
286
287                 /* Both arms are already used by non-weapon */
288                 else if (inventory[INVEN_RARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_RARM]) &&
289                          inventory[INVEN_LARM].k_idx && !object_is_melee_weapon(&inventory[INVEN_LARM]))
290                 {
291                         /* Restrict the choices */
292                         item_tester_hook = item_tester_hook_mochikae;
293
294                         /* Choose a hand */
295 #ifdef JP
296                         q = "¤É¤Á¤é¤Î¼ê¤ËÁõÈ÷¤·¤Þ¤¹¤«?";
297                         s = "¤ª¤Ã¤È¡£";
298 #else
299                         q = "Equip which hand? ";
300                         s = "Oops.";
301 #endif
302
303                         if (!get_item(&slot, q, s, (USE_EQUIP))) return;
304                 }
305                 break;
306
307         /* Melee weapons */
308         case TV_DIGGING:
309         case TV_HAFTED:
310         case TV_POLEARM:
311         case TV_SWORD:
312                 /* Asking for dual wielding */
313                 if (slot == INVEN_LARM)
314                 {
315 #ifdef JP
316                         if (!get_check("ÆóÅáή¤ÇÀ襤¤Þ¤¹¤«¡©")) slot = INVEN_RARM;
317 #else
318                         if (!get_check("Dual wielding? ")) slot = INVEN_RARM;
319 #endif
320                 }
321
322                 else if (!inventory[INVEN_RARM].k_idx && buki_motteruka(INVEN_LARM))
323                 {
324 #ifdef JP
325                         if (!get_check("ÆóÅáή¤ÇÀ襤¤Þ¤¹¤«¡©")) slot = INVEN_LARM;
326 #else
327                         if (!get_check("Dual wielding? ")) slot = INVEN_LARM;
328 #endif
329                 }
330
331                 /* Both arms are already used */
332                 else if (inventory[INVEN_LARM].k_idx && inventory[INVEN_RARM].k_idx)
333                 {
334                         /* Restrict the choices */
335                         item_tester_hook = item_tester_hook_mochikae;
336
337                         /* Choose a hand */
338 #ifdef JP
339                         q = "¤É¤Á¤é¤Î¼ê¤ËÁõÈ÷¤·¤Þ¤¹¤«?";
340                         s = "¤ª¤Ã¤È¡£";
341 #else
342                         q = "Equip which hand? ";
343                         s = "Oops.";
344 #endif
345
346                         if (!get_item(&slot, q, s, (USE_EQUIP))) return;
347                         if ((slot == INVEN_LARM) && !buki_motteruka(INVEN_RARM))
348                                 need_switch_wielding = INVEN_RARM;
349                 }
350                 break;
351
352         /* Rings */
353         case TV_RING:
354                 /* Choose a ring slot */
355                 if (inventory[INVEN_LEFT].k_idx && inventory[INVEN_RIGHT].k_idx)
356                 {
357 #ifdef JP
358                         q = "¤É¤Á¤é¤Î»ØÎؤȼè¤êÂؤ¨¤Þ¤¹¤«?";
359 #else
360                         q = "Replace which ring? ";
361 #endif
362                 }
363                 else
364                 {
365 #ifdef JP
366                         q = "¤É¤Á¤é¤Î¼ê¤ËÁõÈ÷¤·¤Þ¤¹¤«?";
367 #else
368                         q = "Equip which hand? ";
369 #endif
370                 }
371
372 #ifdef JP
373                 s = "¤ª¤Ã¤È¡£";
374 #else
375                 s = "Oops.";
376 #endif
377
378                 /* Restrict the choices */
379                 select_ring_slot = TRUE;
380                 item_tester_no_ryoute = TRUE;
381
382                 if (!get_item(&slot, q, s, (USE_EQUIP)))
383                 {
384                         select_ring_slot = FALSE;
385                         return;
386                 }
387                 select_ring_slot = FALSE;
388                 break;
389         }
390
391         /* Prevent wielding into a cursed slot */
392         if (object_is_cursed(&inventory[slot]))
393         {
394                 /* Describe it */
395                 object_desc(o_name, &inventory[slot], (OD_OMIT_PREFIX | OD_NAME_ONLY));
396
397                 /* Message */
398 #ifdef JP
399                 msg_format("%s%s¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£",
400                            describe_use(slot) , o_name );
401 #else
402                 msg_format("The %s you are %s appears to be cursed.",
403                            o_name, describe_use(slot));
404 #endif
405
406                 /* Cancel the command */
407                 return;
408         }
409
410         if (object_is_cursed(o_ptr) && confirm_wear &&
411             (object_is_known(o_ptr) || (o_ptr->ident & IDENT_SENSE)))
412         {
413                 char dummy[MAX_NLEN+80];
414
415                 /* Describe it */
416                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
417
418 #ifdef JP
419 sprintf(dummy, "ËÜÅö¤Ë%s{¼ö¤ï¤ì¤Æ¤¤¤ë}¤ò»È¤¤¤Þ¤¹¤«¡©", o_name);
420 #else
421                 sprintf(dummy, "Really use the %s {cursed}? ", o_name);
422 #endif
423
424                 if (!get_check(dummy)) return;
425         }
426
427         if ((o_ptr->name1 == ART_STONEMASK) && object_is_known(o_ptr) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
428         {
429                 char dummy[MAX_NLEN+80];
430
431                 /* Describe it */
432                 object_desc(o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
433
434 #ifdef JP
435 sprintf(dummy, "%s¤òÁõÈ÷¤¹¤ë¤ÈµÛ·ìµ´¤Ë¤Ê¤ê¤Þ¤¹¡£¤è¤í¤·¤¤¤Ç¤¹¤«¡©", o_name);
436 #else
437                 msg_format("%s will transforms you into a vampire permanently when equiped.", o_name);
438                 sprintf(dummy, "Do you become a vampire?");
439 #endif
440
441                 if (!get_check(dummy)) return;
442         }
443
444         if (need_switch_wielding && !object_is_cursed(&inventory[need_switch_wielding]))
445         {
446                 object_type *slot_o_ptr = &inventory[slot];
447                 object_type *switch_o_ptr = &inventory[need_switch_wielding];
448                 object_type object_tmp;
449                 object_type *otmp_ptr = &object_tmp;
450                 char switch_name[MAX_NLEN];
451
452                 object_desc(switch_name, switch_o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
453
454                 object_copy(otmp_ptr, switch_o_ptr);
455                 object_copy(switch_o_ptr, slot_o_ptr);
456                 object_copy(slot_o_ptr, otmp_ptr);
457 #ifdef JP
458                 msg_format("%s¤ò%s¤Ë¹½¤¨¤Ê¤ª¤·¤¿¡£", switch_name, (slot == INVEN_RARM) ? (left_hander ? "º¸¼ê" : "±¦¼ê") : (left_hander ? "±¦¼ê" : "º¸¼ê"));
459 #else
460                 msg_format("You wield %s at %s hand.", switch_name, (slot == INVEN_RARM) ? (left_hander ? "left" : "right") : (left_hander ? "right" : "left"));
461 #endif
462
463                 slot = need_switch_wielding;
464         }
465
466         /* Check if completed a quest */
467         for (i = 0; i < max_quests; i++)
468         {
469                 if ((quest[i].type == QUEST_TYPE_FIND_ARTIFACT) &&
470                     (quest[i].status == QUEST_STATUS_TAKEN) &&
471                     (quest[i].k_idx == o_ptr->name1))
472                 {
473                         if (record_fix_quest) do_cmd_write_nikki(NIKKI_FIX_QUEST_C, i, NULL);
474                         quest[i].status = QUEST_STATUS_COMPLETED;
475                         quest[i].complev = (byte)p_ptr->lev;
476 #ifdef JP
477 msg_print("¥¯¥¨¥¹¥È¤òãÀ®¤·¤¿¡ª");
478 #else
479                         msg_print("You completed the quest!");
480 #endif
481
482                         msg_print(NULL);
483                 }
484         }
485
486         if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
487         {
488                 identify_item(o_ptr);
489
490                 /* Auto-inscription */
491                 autopick_alter_item(item, FALSE);
492         }
493
494         /* Take a turn */
495         energy_use = 100;
496
497         /* Get local object */
498         q_ptr = &forge;
499
500         /* Obtain local object */
501         object_copy(q_ptr, o_ptr);
502
503         /* Modify quantity */
504         q_ptr->number = 1;
505
506         /* Decrease the item (from the pack) */
507         if (item >= 0)
508         {
509                 inven_item_increase(item, -1);
510                 inven_item_optimize(item);
511         }
512
513         /* Decrease the item (from the floor) */
514         else
515         {
516                 floor_item_increase(0 - item, -1);
517                 floor_item_optimize(0 - item);
518         }
519
520         /* Access the wield slot */
521         o_ptr = &inventory[slot];
522
523         /* Take off existing item */
524         if (o_ptr->k_idx)
525         {
526                 /* Take off existing item */
527                 (void)inven_takeoff(slot, 255);
528         }
529
530         /* Wear the new stuff */
531         object_copy(o_ptr, q_ptr);
532
533         /* Increase the weight */
534         p_ptr->total_weight += q_ptr->weight;
535
536         /* Increment the equip counter by hand */
537         equip_cnt++;
538
539 #ifdef JP
540 #define STR_WIELD_RARM "%s(%c)¤ò±¦¼ê¤ËÁõÈ÷¤·¤¿¡£"
541 #define STR_WIELD_LARM "%s(%c)¤òº¸¼ê¤ËÁõÈ÷¤·¤¿¡£"
542 #define STR_WIELD_ARMS "%s(%c)¤òξ¼ê¤Ç¹½¤¨¤¿¡£"
543 #else
544 #define STR_WIELD_RARM "You are wielding %s (%c) in your right hand."
545 #define STR_WIELD_LARM "You are wielding %s (%c) in your left hand."
546 #define STR_WIELD_ARMS "You are wielding %s (%c) with both hands."
547 #endif
548
549         /* Where is the item now */
550         switch (slot)
551         {
552         case INVEN_RARM:
553                 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING())
554                         act = STR_WIELD_ARMS;
555                 else
556                         act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM);
557                 break;
558
559         case INVEN_LARM:
560                 if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING())
561                         act = STR_WIELD_ARMS;
562                 else
563                         act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM);
564                 break;
565
566         case INVEN_BOW:
567 #ifdef JP
568                 act = "%s(%c)¤ò¼Í·âÍѤËÁõÈ÷¤·¤¿¡£";
569 #else
570                 act = "You are shooting with %s (%c).";
571 #endif
572                 break;
573
574         case INVEN_LITE:
575 #ifdef JP
576                 act = "%s(%c)¤ò¸÷¸»¤Ë¤·¤¿¡£";
577 #else
578                 act = "Your light source is %s (%c).";
579 #endif
580                 break;
581
582         default:
583 #ifdef JP
584                 act = "%s(%c)¤òÁõÈ÷¤·¤¿¡£";
585 #else
586                 act = "You are wearing %s (%c).";
587 #endif
588                 break;
589         }
590
591         /* Describe the result */
592         object_desc(o_name, o_ptr, 0);
593
594         /* Message */
595         msg_format(act, o_name, index_to_label(slot));
596
597
598         /* Cursed! */
599         if (object_is_cursed(o_ptr))
600         {
601                 /* Warn the player */
602 #ifdef JP
603                 msg_print("¤¦¤ï¡ª ¤¹¤µ¤Þ¤¸¤¯Î䤿¤¤¡ª");
604 #else
605                 msg_print("Oops! It feels deathly cold!");
606 #endif
607
608
609                 chg_virtue(V_HARMONY, -1);
610
611                 /* Note the curse */
612                 o_ptr->ident |= (IDENT_SENSE);
613         }
614
615         /* The Stone Mask make the player turn into a vampire! */
616         if ((o_ptr->name1 == ART_STONEMASK) && (p_ptr->prace != RACE_VAMPIRE) && (p_ptr->prace != RACE_ANDROID))
617         {
618                 /* Turn into a vampire */
619                 change_race(RACE_VAMPIRE, "");
620         }
621
622         /* Recalculate bonuses */
623         p_ptr->update |= (PU_BONUS);
624
625         /* Recalculate torch */
626         p_ptr->update |= (PU_TORCH);
627
628         /* Recalculate mana */
629         p_ptr->update |= (PU_MANA);
630
631         p_ptr->redraw |= (PR_EQUIPPY);
632
633         /* Window stuff */
634         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
635
636         calc_android_exp();
637 }
638
639
640 void kamaenaoshi(int item)
641 {
642         object_type *o_ptr, *new_o_ptr;
643         char o_name[MAX_NLEN];
644
645         if (item == INVEN_RARM)
646         {
647                 if (buki_motteruka(INVEN_LARM))
648                 {
649                         o_ptr = &inventory[INVEN_LARM];
650                         object_desc(o_name, o_ptr, 0);
651
652                         if (!object_is_cursed(o_ptr))
653                         {
654                                 new_o_ptr = &inventory[INVEN_RARM];
655                                 object_copy(new_o_ptr, o_ptr);
656                                 p_ptr->total_weight += o_ptr->weight;
657                                 inven_item_increase(INVEN_LARM, -((int)o_ptr->number));
658                                 inven_item_optimize(INVEN_LARM);
659                                 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
660 #ifdef JP
661                                         msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name);
662 #else
663                                         msg_format("You are wielding %s with both hands.", o_name);
664 #endif
665                                  else
666 #ifdef JP
667                                         msg_format("%s¤ò%s¤Ç¹½¤¨¤¿¡£", o_name, (left_hander ? "º¸¼ê" : "±¦¼ê"));
668 #else
669                                         msg_format("You are wielding %s in your %s hand.", o_name, (left_hander ? "left":"right"));
670 #endif
671                         }
672                         else
673                         {
674                                 if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
675 #ifdef JP
676                                         msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name);
677 #else
678                                         msg_format("You are wielding %s with both hands.", o_name);
679 #endif
680                         }
681                 }
682         }
683         else if (item == INVEN_LARM)
684         {
685                 o_ptr = &inventory[INVEN_RARM];
686                 if (o_ptr->k_idx) object_desc(o_name, o_ptr, 0);
687
688                 if (buki_motteruka(INVEN_RARM))
689                 {
690                         if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING())
691 #ifdef JP
692                                 msg_format("%s¤òξ¼ê¤Ç¹½¤¨¤¿¡£", o_name);
693 #else
694                                 msg_format("You are wielding %s with both hands.", o_name);
695 #endif
696                 }
697                 else if (!(empty_hands(FALSE) & EMPTY_HAND_RARM) && !object_is_cursed(o_ptr))
698                 {
699                         new_o_ptr = &inventory[INVEN_LARM];
700                         object_copy(new_o_ptr, o_ptr);
701                         p_ptr->total_weight += o_ptr->weight;
702                         inven_item_increase(INVEN_RARM, -((int)o_ptr->number));
703                         inven_item_optimize(INVEN_RARM);
704 #ifdef JP
705                         msg_format("%s¤ò»ý¤ÁÂؤ¨¤¿¡£", o_name);
706 #else
707                         msg_format("You switched hand of %s.", o_name);
708 #endif
709                 }
710         }
711 }
712
713
714 /*
715  * Take off an item
716  */
717 void do_cmd_takeoff(void)
718 {
719         int item;
720
721         object_type *o_ptr;
722
723         cptr q, s;
724
725         if (p_ptr->special_defense & KATA_MUSOU)
726         {
727                 set_action(ACTION_NONE);
728         }
729
730         item_tester_no_ryoute = TRUE;
731         /* Get an item */
732 #ifdef JP
733         q = "¤É¤ì¤òÁõÈ÷¤«¤é¤Ï¤º¤·¤Þ¤¹¤«? ";
734         s = "¤Ï¤º¤»¤ëÁõÈ÷¤¬¤Ê¤¤¡£";
735 #else
736         q = "Take off which item? ";
737         s = "You are not wearing anything to take off.";
738 #endif
739
740         if (!get_item(&item, q, s, (USE_EQUIP))) return;
741
742         /* Get the item (in the pack) */
743         if (item >= 0)
744         {
745                 o_ptr = &inventory[item];
746         }
747
748         /* Get the item (on the floor) */
749         else
750         {
751                 o_ptr = &o_list[0 - item];
752         }
753
754
755         /* Item is cursed */
756         if (object_is_cursed(o_ptr))
757         {
758                 if ((o_ptr->curse_flags & TRC_PERMA_CURSE) || (p_ptr->pclass != CLASS_BERSERKER))
759                 {
760                         /* Oops */
761 #ifdef JP
762                         msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
763 #else
764                         msg_print("Hmmm, it seems to be cursed.");
765 #endif
766
767                         /* Nope */
768                         return;
769                 }
770
771                 if (((o_ptr->curse_flags & TRC_HEAVY_CURSE) && one_in_(7)) || one_in_(4))
772                 {
773 #ifdef JP
774                         msg_print("¼ö¤ï¤ì¤¿ÁõÈ÷¤òÎϤŤ¯¤ÇÇí¤¬¤·¤¿¡ª");
775 #else
776                         msg_print("You teared a cursed equipment off by sheer strength!");
777 #endif
778
779                         /* Hack -- Assume felt */
780                         o_ptr->ident |= (IDENT_SENSE);
781
782                         o_ptr->curse_flags = 0L;
783
784                         /* Take note */
785                         o_ptr->feeling = FEEL_NONE;
786
787                         /* Recalculate the bonuses */
788                         p_ptr->update |= (PU_BONUS);
789
790                         /* Window stuff */
791                         p_ptr->window |= (PW_EQUIP);
792
793 #ifdef JP
794                         msg_print("¼ö¤¤¤òÂǤÁÇˤä¿¡£");
795 #else
796                         msg_print("You break the curse.");
797 #endif
798                 }
799                 else
800                 {
801 #ifdef JP
802                         msg_print("ÁõÈ÷¤ò³°¤»¤Ê¤«¤Ã¤¿¡£");
803 #else
804                         msg_print("You couldn't remove the equipment.");
805 #endif
806                         energy_use = 50;
807                         return;
808                 }
809         }
810
811         /* Take a partial turn */
812         energy_use = 50;
813
814         /* Take off the item */
815         (void)inven_takeoff(item, 255);
816
817         kamaenaoshi(item);
818
819         calc_android_exp();
820
821         p_ptr->redraw |= (PR_EQUIPPY);
822 }
823
824
825 /*
826  * Drop an item
827  */
828 void do_cmd_drop(void)
829 {
830         int item, amt = 1;
831
832         object_type *o_ptr;
833
834         cptr q, s;
835
836         if (p_ptr->special_defense & KATA_MUSOU)
837         {
838                 set_action(ACTION_NONE);
839         }
840
841         item_tester_no_ryoute = TRUE;
842         /* Get an item */
843 #ifdef JP
844         q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÍî¤È¤·¤Þ¤¹¤«? ";
845         s = "Íî¤È¤»¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
846 #else
847         q = "Drop which item? ";
848         s = "You have nothing to drop.";
849 #endif
850
851         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN))) return;
852
853         /* Get the item (in the pack) */
854         if (item >= 0)
855         {
856                 o_ptr = &inventory[item];
857         }
858
859         /* Get the item (on the floor) */
860         else
861         {
862                 o_ptr = &o_list[0 - item];
863         }
864
865
866         /* Hack -- Cannot remove cursed items */
867         if ((item >= INVEN_RARM) && object_is_cursed(o_ptr))
868         {
869                 /* Oops */
870 #ifdef JP
871                 msg_print("¤Õ¡¼¤à¡¢¤É¤¦¤ä¤é¼ö¤ï¤ì¤Æ¤¤¤ë¤è¤¦¤À¡£");
872 #else
873                 msg_print("Hmmm, it seems to be cursed.");
874 #endif
875
876
877                 /* Nope */
878                 return;
879         }
880
881
882         /* See how many items */
883         if (o_ptr->number > 1)
884         {
885                 /* Get a quantity */
886                 amt = get_quantity(NULL, o_ptr->number);
887
888                 /* Allow user abort */
889                 if (amt <= 0) return;
890         }
891
892
893         /* Take a partial turn */
894         energy_use = 50;
895
896         /* Drop (some of) the item */
897         inven_drop(item, amt);
898
899         if (item >= INVEN_RARM)
900         {
901                 kamaenaoshi(item);
902                 calc_android_exp();
903         }
904
905         p_ptr->redraw |= (PR_EQUIPPY);
906 }
907
908
909 static bool high_level_book(object_type *o_ptr)
910 {
911         if ((o_ptr->tval == TV_LIFE_BOOK) ||
912             (o_ptr->tval == TV_SORCERY_BOOK) ||
913             (o_ptr->tval == TV_NATURE_BOOK) ||
914             (o_ptr->tval == TV_CHAOS_BOOK) ||
915             (o_ptr->tval == TV_DEATH_BOOK) ||
916             (o_ptr->tval == TV_TRUMP_BOOK) ||
917             (o_ptr->tval == TV_CRAFT_BOOK) ||
918             (o_ptr->tval == TV_DAEMON_BOOK) ||
919             (o_ptr->tval == TV_CRUSADE_BOOK) ||
920             (o_ptr->tval == TV_MUSIC_BOOK))
921         {
922                 if (o_ptr->sval > 1)
923                         return TRUE;
924                 else
925                         return FALSE;
926         }
927
928         return FALSE;
929 }
930
931
932 /*
933  * Destroy an item
934  */
935 void do_cmd_destroy(void)
936 {
937         int                     item, amt = 1;
938         int                     old_number;
939
940         bool            force = FALSE;
941
942         object_type             *o_ptr;
943         object_type             forge;
944         object_type             *q_ptr = &forge;
945
946         char            o_name[MAX_NLEN];
947
948         char            out_val[MAX_NLEN+40];
949
950         cptr q, s;
951
952         if (p_ptr->special_defense & KATA_MUSOU)
953         {
954                 set_action(ACTION_NONE);
955         }
956
957         /* Hack -- force destruction */
958         if (command_arg > 0) force = TRUE;
959
960
961         /* Get an item */
962 #ifdef JP
963         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ò²õ¤·¤Þ¤¹¤«? ";
964         s = "²õ¤»¤ë¥¢¥¤¥Æ¥à¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£";
965 #else
966         q = "Destroy which item? ";
967         s = "You have nothing to destroy.";
968 #endif
969
970         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
971
972         /* Get the item (in the pack) */
973         if (item >= 0)
974         {
975                 o_ptr = &inventory[item];
976         }
977
978         /* Get the item (on the floor) */
979         else
980         {
981                 o_ptr = &o_list[0 - item];
982         }
983
984         /* Verify unless quantity given beforehand */
985         if (!force && (confirm_destroy || (object_value(o_ptr) > 0)))
986         {
987                 object_desc(o_name, o_ptr, OD_OMIT_PREFIX);
988
989                 /* Make a verification */
990                 sprintf(out_val, 
991 #ifdef JP
992                         "ËÜÅö¤Ë%s¤ò²õ¤·¤Þ¤¹¤«? [y/n/Auto]",
993 #else
994                         "Really destroy %s? [y/n/Auto]",
995 #endif
996                         o_name);
997
998                 msg_print(NULL);
999
1000                 /* HACK : Add the line to message buffer */
1001                 message_add(out_val);
1002                 p_ptr->window |= (PW_MESSAGE);
1003                 window_stuff();
1004
1005                 /* Get an acceptable answer */
1006                 while (TRUE)
1007                 {
1008                         char i;
1009
1010                         /* Prompt */
1011                         prt(out_val, 0, 0);
1012
1013                         i = inkey();
1014
1015                         /* Erase the prompt */
1016                         prt("", 0, 0);
1017
1018
1019                         if (i == 'y' || i == 'Y')
1020                         {
1021                                 break;
1022                         }
1023                         if (i == ESCAPE || i == 'n' || i == 'N')
1024                         {
1025                                 /* Cancel */
1026                                 return;
1027                         }
1028                         if (i == 'A')
1029                         {
1030                                 /* Add an auto-destroy preference line */
1031                                 if (autopick_autoregister(o_ptr))
1032                                 {
1033                                         /* Auto-destroy it */
1034                                         autopick_alter_item(item, TRUE);
1035                                 }
1036
1037                                 /* The object is already destroyed. */
1038                                 return;
1039                         }
1040                 } /* while (TRUE) */
1041         }
1042
1043         /* See how many items */
1044         if (o_ptr->number > 1)
1045         {
1046                 /* Get a quantity */
1047                 amt = get_quantity(NULL, o_ptr->number);
1048
1049                 /* Allow user abort */
1050                 if (amt <= 0) return;
1051         }
1052
1053
1054         /* Describe the object */
1055         old_number = o_ptr->number;
1056         o_ptr->number = amt;
1057         object_desc(o_name, o_ptr, 0);
1058         o_ptr->number = old_number;
1059
1060         /* Take a turn */
1061         energy_use = 100;
1062
1063         /* Artifacts cannot be destroyed */
1064         if (!can_player_destroy_object(o_ptr))
1065         {
1066                 energy_use = 0;
1067
1068                 /* Message */
1069 #ifdef JP
1070                 msg_format("%s¤ÏÇ˲õÉÔ²Äǽ¤À¡£", o_name);
1071 #else
1072                 msg_format("You cannot destroy %s.", o_name);
1073 #endif
1074
1075                 /* Done */
1076                 return;
1077         }
1078
1079         object_copy(q_ptr, o_ptr);
1080
1081         /* Message */
1082 #ifdef JP
1083         msg_format("%s¤ò²õ¤·¤¿¡£", o_name);
1084 #else
1085         msg_format("You destroy %s.", o_name);
1086 #endif
1087
1088         sound(SOUND_DESTITEM);
1089
1090         /* Reduce the charges of rods/wands */
1091         reduce_charges(o_ptr, amt);
1092
1093         /* Eliminate the item (from the pack) */
1094         if (item >= 0)
1095         {
1096                 inven_item_increase(item, -amt);
1097                 inven_item_describe(item);
1098                 inven_item_optimize(item);
1099         }
1100
1101         /* Eliminate the item (from the floor) */
1102         else
1103         {
1104                 floor_item_increase(0 - item, -amt);
1105                 floor_item_describe(0 - item);
1106                 floor_item_optimize(0 - item);
1107         }
1108
1109         if (high_level_book(q_ptr))
1110         {
1111                 bool gain_expr = FALSE;
1112
1113                 if (p_ptr->prace == RACE_ANDROID)
1114                 {
1115                 }
1116                 else if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
1117                 {
1118                         gain_expr = TRUE;
1119                 }
1120                 else if (p_ptr->pclass == CLASS_PALADIN)
1121                 {
1122                         if (is_good_realm(p_ptr->realm1))
1123                         {
1124                                 if (!is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1125                         }
1126                         else
1127                         {
1128                                 if (is_good_realm(tval2realm(q_ptr->tval))) gain_expr = TRUE;
1129                         }
1130                 }
1131
1132                 if (gain_expr && (p_ptr->exp < PY_MAX_EXP))
1133                 {
1134                         s32b tester_exp = p_ptr->max_exp / 20;
1135                         if (tester_exp > 10000) tester_exp = 10000;
1136                         if (q_ptr->sval < 3) tester_exp /= 4;
1137                         if (tester_exp<1) tester_exp = 1;
1138
1139 #ifdef JP
1140 msg_print("¹¹¤Ë·Ð¸³¤òÀѤó¤À¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£");
1141 #else
1142                         msg_print("You feel more experienced.");
1143 #endif
1144
1145                         gain_exp(tester_exp * amt);
1146                 }
1147                 if (high_level_book(q_ptr) && q_ptr->tval == TV_LIFE_BOOK)
1148                 {
1149                         chg_virtue(V_UNLIFE, 1);
1150                         chg_virtue(V_VITALITY, -1);
1151                 }
1152                 else if (high_level_book(q_ptr) && q_ptr->tval == TV_DEATH_BOOK)
1153                 {
1154                         chg_virtue(V_UNLIFE, -1);
1155                         chg_virtue(V_VITALITY, 1);
1156                 }
1157         
1158                 if (q_ptr->to_a || q_ptr->to_h || q_ptr->to_d)
1159                         chg_virtue(V_ENCHANT, -1);
1160         
1161                 if (object_value_real(q_ptr) > 30000)
1162                         chg_virtue(V_SACRIFICE, 2);
1163         
1164                 else if (object_value_real(q_ptr) > 10000)
1165                         chg_virtue(V_SACRIFICE, 1);
1166         }
1167
1168         if (q_ptr->to_a != 0 || q_ptr->to_d != 0 || q_ptr->to_h != 0)
1169                 chg_virtue(V_HARMONY, 1);
1170
1171         if (item >= INVEN_RARM) calc_android_exp();
1172 }
1173
1174
1175 /*
1176  * Observe an item which has been *identify*-ed
1177  */
1178 void do_cmd_observe(void)
1179 {
1180         int                     item;
1181
1182         object_type             *o_ptr;
1183
1184         char            o_name[MAX_NLEN];
1185
1186         cptr q, s;
1187
1188         item_tester_no_ryoute = TRUE;
1189         /* Get an item */
1190 #ifdef JP
1191         q = "¤É¤Î¥¢¥¤¥Æ¥à¤òÄ´¤Ù¤Þ¤¹¤«? ";
1192         s = "Ä´¤Ù¤é¤ì¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1193 #else
1194         q = "Examine which item? ";
1195         s = "You have nothing to examine.";
1196 #endif
1197
1198         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1199
1200         /* Get the item (in the pack) */
1201         if (item >= 0)
1202         {
1203                 o_ptr = &inventory[item];
1204         }
1205
1206         /* Get the item (on the floor) */
1207         else
1208         {
1209                 o_ptr = &o_list[0 - item];
1210         }
1211
1212
1213         /* Require full knowledge */
1214         if (!(o_ptr->ident & IDENT_MENTAL))
1215         {
1216 #ifdef JP
1217                 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ä¤¤¤ÆÆäËÃΤäƤ¤¤ë¤³¤È¤Ï¤Ê¤¤¡£");
1218 #else
1219                 msg_print("You have no special knowledge about that item.");
1220 #endif
1221
1222                 return;
1223         }
1224
1225
1226         /* Description */
1227         object_desc(o_name, o_ptr, 0);
1228
1229         /* Describe */
1230 #ifdef JP
1231         msg_format("%s¤òÄ´¤Ù¤Æ¤¤¤ë...", o_name);
1232 #else
1233         msg_format("Examining %s...", o_name);
1234 #endif
1235
1236         /* Describe it fully */
1237 #ifdef JP
1238         if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
1239 #else
1240         if (!screen_object(o_ptr, SCROBJ_FORCE_DETAIL)) msg_print("You see nothing special.");
1241 #endif
1242
1243 }
1244
1245
1246
1247 /*
1248  * Remove the inscription from an object
1249  * XXX Mention item (when done)?
1250  */
1251 void do_cmd_uninscribe(void)
1252 {
1253         int   item;
1254
1255         object_type *o_ptr;
1256
1257         cptr q, s;
1258
1259         item_tester_no_ryoute = TRUE;
1260         /* Get an item */
1261 #ifdef JP
1262         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ÎÌäò¾Ã¤·¤Þ¤¹¤«? ";
1263         s = "Ìäò¾Ã¤»¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1264 #else
1265         q = "Un-inscribe which item? ";
1266         s = "You have nothing to un-inscribe.";
1267 #endif
1268
1269         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1270
1271         /* Get the item (in the pack) */
1272         if (item >= 0)
1273         {
1274                 o_ptr = &inventory[item];
1275         }
1276
1277         /* Get the item (on the floor) */
1278         else
1279         {
1280                 o_ptr = &o_list[0 - item];
1281         }
1282
1283         /* Nothing to remove */
1284         if (!o_ptr->inscription)
1285         {
1286 #ifdef JP
1287                 msg_print("¤³¤Î¥¢¥¤¥Æ¥à¤Ë¤Ï¾Ã¤¹¤Ù¤­Ì䬤ʤ¤¡£");
1288 #else
1289                 msg_print("That item had no inscription to remove.");
1290 #endif
1291
1292                 return;
1293         }
1294
1295         /* Message */
1296 #ifdef JP
1297         msg_print("Ìäò¾Ã¤·¤¿¡£");
1298 #else
1299         msg_print("Inscription removed.");
1300 #endif
1301
1302
1303         /* Remove the incription */
1304         o_ptr->inscription = 0;
1305
1306         /* Combine the pack */
1307         p_ptr->notice |= (PN_COMBINE);
1308
1309         /* Window stuff */
1310         p_ptr->window |= (PW_INVEN | PW_EQUIP);
1311
1312         /* .¤ä$¤Î´Ø·¸¤Ç, ºÆ·×»»¤¬É¬ÍפʤϤº -- henkma */
1313         p_ptr->update |= (PU_BONUS);
1314
1315 }
1316
1317
1318 /*
1319  * Inscribe an object with a comment
1320  */
1321 void do_cmd_inscribe(void)
1322 {
1323         int                     item;
1324
1325         object_type             *o_ptr;
1326
1327         char            o_name[MAX_NLEN];
1328
1329         char            out_val[80];
1330
1331         cptr q, s;
1332
1333         item_tester_no_ryoute = TRUE;
1334         /* Get an item */
1335 #ifdef JP
1336         q = "¤É¤Î¥¢¥¤¥Æ¥à¤ËÌäò¹ï¤ß¤Þ¤¹¤«? ";
1337         s = "Ìäò¹ï¤á¤ë¥¢¥¤¥Æ¥à¤¬¤Ê¤¤¡£";
1338 #else
1339         q = "Inscribe which item? ";
1340         s = "You have nothing to inscribe.";
1341 #endif
1342
1343         if (!get_item(&item, q, s, (USE_EQUIP | USE_INVEN | USE_FLOOR))) return;
1344
1345         /* Get the item (in the pack) */
1346         if (item >= 0)
1347         {
1348                 o_ptr = &inventory[item];
1349         }
1350
1351         /* Get the item (on the floor) */
1352         else
1353         {
1354                 o_ptr = &o_list[0 - item];
1355         }
1356
1357         /* Describe the activity */
1358         object_desc(o_name, o_ptr, OD_OMIT_INSCRIPTION);
1359
1360         /* Message */
1361 #ifdef JP
1362         msg_format("%s¤ËÌäò¹ï¤à¡£", o_name);
1363 #else
1364         msg_format("Inscribing %s.", o_name);
1365 #endif
1366
1367         msg_print(NULL);
1368
1369         /* Start with nothing */
1370         strcpy(out_val, "");
1371
1372         /* Use old inscription */
1373         if (o_ptr->inscription)
1374         {
1375                 /* Start with the old inscription */
1376                 strcpy(out_val, quark_str(o_ptr->inscription));
1377         }
1378
1379         /* Get a new inscription (possibly empty) */
1380 #ifdef JP
1381         if (get_string("ÌÃ: ", out_val, 80))
1382 #else
1383         if (get_string("Inscription: ", out_val, 80))
1384 #endif
1385         {
1386                 /* Save the inscription */
1387                 o_ptr->inscription = quark_add(out_val);
1388
1389                 /* Combine the pack */
1390                 p_ptr->notice |= (PN_COMBINE);
1391
1392                 /* Window stuff */
1393                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
1394
1395                 /* .¤ä$¤Î´Ø·¸¤Ç, ºÆ·×»»¤¬É¬ÍפʤϤº -- henkma */
1396                 p_ptr->update |= (PU_BONUS);
1397         }
1398 }
1399
1400
1401
1402 /*
1403  * An "item_tester_hook" for refilling lanterns
1404  */
1405 static bool item_tester_refill_lantern(object_type *o_ptr)
1406 {
1407         /* Flasks of oil are okay */
1408         if (o_ptr->tval == TV_FLASK) return (TRUE);
1409
1410         /* Laterns are okay */
1411         if ((o_ptr->tval == TV_LITE) &&
1412             (o_ptr->sval == SV_LITE_LANTERN)) return (TRUE);
1413
1414         /* Assume not okay */
1415         return (FALSE);
1416 }
1417
1418
1419 /*
1420  * Refill the players lamp (from the pack or floor)
1421  */
1422 static void do_cmd_refill_lamp(void)
1423 {
1424         int item;
1425
1426         object_type *o_ptr;
1427         object_type *j_ptr;
1428
1429         cptr q, s;
1430
1431
1432         /* Restrict the choices */
1433         item_tester_hook = item_tester_refill_lantern;
1434
1435         /* Get an item */
1436 #ifdef JP
1437         q = "¤É¤ÎÌý¤Ä¤Ü¤«¤éÃí¤®¤Þ¤¹¤«? ";
1438         s = "Ìý¤Ä¤Ü¤¬¤Ê¤¤¡£";
1439 #else
1440         q = "Refill with which flask? ";
1441         s = "You have no flasks of oil.";
1442 #endif
1443
1444         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1445
1446         /* Get the item (in the pack) */
1447         if (item >= 0)
1448         {
1449                 o_ptr = &inventory[item];
1450         }
1451
1452         /* Get the item (on the floor) */
1453         else
1454         {
1455                 o_ptr = &o_list[0 - item];
1456         }
1457
1458
1459         /* Take a partial turn */
1460         energy_use = 50;
1461
1462         /* Access the lantern */
1463         j_ptr = &inventory[INVEN_LITE];
1464
1465         /* Refuel */
1466         j_ptr->xtra4 += o_ptr->xtra4;
1467
1468         /* Message */
1469 #ifdef JP
1470         msg_print("¥é¥ó¥×¤ËÌý¤òÃí¤¤¤À¡£");
1471 #else
1472         msg_print("You fuel your lamp.");
1473 #endif
1474
1475         /* Comment */
1476         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1477         {
1478                 j_ptr->xtra4 = 0;
1479 #ifdef JP
1480                 msg_print("¥é¥ó¥×¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
1481 #else
1482                 msg_print("Your lamp has gone out!");
1483 #endif
1484         }
1485         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1486         {
1487                 j_ptr->xtra4 = 0;
1488 #ifdef JP
1489                 msg_print("¤·¤«¤·¥é¥ó¥×¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£");
1490 #else
1491                 msg_print("Curiously, your lamp doesn't light.");
1492 #endif
1493         }
1494         else if (j_ptr->xtra4 >= FUEL_LAMP)
1495         {
1496                 j_ptr->xtra4 = FUEL_LAMP;
1497 #ifdef JP
1498                 msg_print("¥é¥ó¥×¤ÎÌý¤Ï°ìÇÕ¤À¡£");
1499 #else
1500                 msg_print("Your lamp is full.");
1501 #endif
1502
1503         }
1504
1505         /* Decrease the item (from the pack) */
1506         if (item >= 0)
1507         {
1508                 inven_item_increase(item, -1);
1509                 inven_item_describe(item);
1510                 inven_item_optimize(item);
1511         }
1512
1513         /* Decrease the item (from the floor) */
1514         else
1515         {
1516                 floor_item_increase(0 - item, -1);
1517                 floor_item_describe(0 - item);
1518                 floor_item_optimize(0 - item);
1519         }
1520
1521         /* Recalculate torch */
1522         p_ptr->update |= (PU_TORCH);
1523 }
1524
1525
1526 /*
1527  * An "item_tester_hook" for refilling torches
1528  */
1529 static bool item_tester_refill_torch(object_type *o_ptr)
1530 {
1531         /* Torches are okay */
1532         if ((o_ptr->tval == TV_LITE) &&
1533             (o_ptr->sval == SV_LITE_TORCH)) return (TRUE);
1534
1535         /* Assume not okay */
1536         return (FALSE);
1537 }
1538
1539
1540 /*
1541  * Refuel the players torch (from the pack or floor)
1542  */
1543 static void do_cmd_refill_torch(void)
1544 {
1545         int item;
1546
1547         object_type *o_ptr;
1548         object_type *j_ptr;
1549
1550         cptr q, s;
1551
1552
1553         /* Restrict the choices */
1554         item_tester_hook = item_tester_refill_torch;
1555
1556         /* Get an item */
1557 #ifdef JP
1558         q = "¤É¤Î¾¾ÌÀ¤ÇÌÀ¤«¤ê¤ò¶¯¤á¤Þ¤¹¤«? ";
1559         s = "¾¤Ë¾¾ÌÀ¤¬¤Ê¤¤¡£";
1560 #else
1561         q = "Refuel with which torch? ";
1562         s = "You have no extra torches.";
1563 #endif
1564
1565         if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
1566
1567         /* Get the item (in the pack) */
1568         if (item >= 0)
1569         {
1570                 o_ptr = &inventory[item];
1571         }
1572
1573         /* Get the item (on the floor) */
1574         else
1575         {
1576                 o_ptr = &o_list[0 - item];
1577         }
1578
1579
1580         /* Take a partial turn */
1581         energy_use = 50;
1582
1583         /* Access the primary torch */
1584         j_ptr = &inventory[INVEN_LITE];
1585
1586         /* Refuel */
1587         j_ptr->xtra4 += o_ptr->xtra4 + 5;
1588
1589         /* Message */
1590 #ifdef JP
1591         msg_print("¾¾ÌÀ¤ò·ë¹ç¤·¤¿¡£");
1592 #else
1593         msg_print("You combine the torches.");
1594 #endif
1595
1596
1597         /* Comment */
1598         if ((o_ptr->name2 == EGO_LITE_DARKNESS) && (j_ptr->xtra4 > 0))
1599         {
1600                 j_ptr->xtra4 = 0;
1601 #ifdef JP
1602                 msg_print("¾¾ÌÀ¤¬¾Ã¤¨¤Æ¤·¤Þ¤Ã¤¿¡ª");
1603 #else
1604                 msg_print("Your torch has gone out!");
1605 #endif
1606         }
1607         else if ((o_ptr->name2 == EGO_LITE_DARKNESS) || (j_ptr->name2 == EGO_LITE_DARKNESS))
1608         {
1609                 j_ptr->xtra4 = 0;
1610 #ifdef JP
1611                 msg_print("¤·¤«¤·¾¾ÌÀ¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£");
1612 #else
1613                 msg_print("Curiously, your torche don't light.");
1614 #endif
1615         }
1616         /* Over-fuel message */
1617         else if (j_ptr->xtra4 >= FUEL_TORCH)
1618         {
1619                 j_ptr->xtra4 = FUEL_TORCH;
1620 #ifdef JP
1621                 msg_print("¾¾ÌÀ¤Î¼÷Ì¿¤Ï½½Ê¬¤À¡£");
1622 #else
1623                 msg_print("Your torch is fully fueled.");
1624 #endif
1625
1626         }
1627
1628         /* Refuel message */
1629         else
1630         {
1631 #ifdef JP
1632                 msg_print("¾¾ÌÀ¤Ï¤¤¤Ã¤½¤¦ÌÀ¤ë¤¯µ±¤¤¤¿¡£");
1633 #else
1634                 msg_print("Your torch glows more brightly.");
1635 #endif
1636
1637         }
1638
1639         /* Decrease the item (from the pack) */
1640         if (item >= 0)
1641         {
1642                 inven_item_increase(item, -1);
1643                 inven_item_describe(item);
1644                 inven_item_optimize(item);
1645         }
1646
1647         /* Decrease the item (from the floor) */
1648         else
1649         {
1650                 floor_item_increase(0 - item, -1);
1651                 floor_item_describe(0 - item);
1652                 floor_item_optimize(0 - item);
1653         }
1654
1655         /* Recalculate torch */
1656         p_ptr->update |= (PU_TORCH);
1657 }
1658
1659
1660 /*
1661  * Refill the players lamp, or restock his torches
1662  */
1663 void do_cmd_refill(void)
1664 {
1665         object_type *o_ptr;
1666
1667         /* Get the light */
1668         o_ptr = &inventory[INVEN_LITE];
1669
1670         if (p_ptr->special_defense & KATA_MUSOU)
1671         {
1672                 set_action(ACTION_NONE);
1673         }
1674
1675         /* It is nothing */
1676         if (o_ptr->tval != TV_LITE)
1677         {
1678 #ifdef JP
1679                 msg_print("¸÷¸»¤òÁõÈ÷¤·¤Æ¤¤¤Ê¤¤¡£");
1680 #else
1681                 msg_print("You are not wielding a light.");
1682 #endif
1683
1684         }
1685
1686         /* It's a lamp */
1687         else if (o_ptr->sval == SV_LITE_LANTERN)
1688         {
1689                 do_cmd_refill_lamp();
1690         }
1691
1692         /* It's a torch */
1693         else if (o_ptr->sval == SV_LITE_TORCH)
1694         {
1695                 do_cmd_refill_torch();
1696         }
1697
1698         /* No torch to refill */
1699         else
1700         {
1701 #ifdef JP
1702                 msg_print("¤³¤Î¸÷¸»¤Ï¼÷Ì¿¤ò±ä¤Ð¤»¤Ê¤¤¡£");
1703 #else
1704                 msg_print("Your light cannot be refilled.");
1705 #endif
1706
1707         }
1708 }
1709
1710
1711 /*
1712  * Target command
1713  */
1714 void do_cmd_target(void)
1715 {
1716         /* Target set */
1717         if (target_set(TARGET_KILL))
1718         {
1719 #ifdef JP
1720                 msg_print("¥¿¡¼¥²¥Ã¥È·èÄê¡£");
1721 #else
1722                 msg_print("Target Selected.");
1723 #endif
1724
1725         }
1726
1727         /* Target aborted */
1728         else
1729         {
1730 #ifdef JP
1731                 msg_print("¥¿¡¼¥²¥Ã¥È²ò½ü¡£");
1732 #else
1733                 msg_print("Target Aborted.");
1734 #endif
1735
1736         }
1737 }
1738
1739
1740
1741 /*
1742  * Look command
1743  */
1744 void do_cmd_look(void)
1745 {
1746         /* Look around */
1747         if (target_set(TARGET_LOOK))
1748         {
1749 #ifdef JP
1750                 msg_print("¥¿¡¼¥²¥Ã¥È·èÄê¡£");
1751 #else
1752                 msg_print("Target Selected.");
1753 #endif
1754
1755         }
1756 }
1757
1758
1759
1760 /*
1761  * Allow the player to examine other sectors on the map
1762  */
1763 void do_cmd_locate(void)
1764 {
1765         int             dir, y1, x1, y2, x2;
1766
1767         char    tmp_val[80];
1768
1769         char    out_val[160];
1770
1771         int wid, hgt;
1772
1773         /* Get size */
1774         get_screen_size(&wid, &hgt);
1775
1776
1777         /* Start at current panel */
1778         y2 = y1 = panel_row_min;
1779         x2 = x1 = panel_col_min;
1780
1781         /* Show panels until done */
1782         while (1)
1783         {
1784                 /* Describe the location */
1785                 if ((y2 == y1) && (x2 == x1))
1786                 {
1787 #ifdef JP
1788                         strcpy(tmp_val, "¿¿¾å");
1789 #else
1790                         tmp_val[0] = '\0';
1791 #endif
1792
1793                 }
1794                 else
1795                 {
1796 #ifdef JP
1797                         sprintf(tmp_val, "%s%s",
1798                                 ((y2 < y1) ? "ËÌ" : (y2 > y1) ? "Æî" : ""),
1799                                 ((x2 < x1) ? "À¾" : (x2 > x1) ? "Åì" : ""));
1800 #else
1801                         sprintf(tmp_val, "%s%s of",
1802                                 ((y2 < y1) ? " North" : (y2 > y1) ? " South" : ""),
1803                                 ((x2 < x1) ? " West" : (x2 > x1) ? " East" : ""));
1804 #endif
1805
1806                 }
1807
1808                 /* Prepare to ask which way to look */
1809                 sprintf(out_val,
1810 #ifdef JP
1811                         "¥Þ¥Ã¥×°ÌÃÖ [%d(%02d),%d(%02d)] (¥×¥ì¥¤¥ä¡¼¤Î%s)  Êý¸þ?",
1812 #else
1813                         "Map sector [%d(%02d),%d(%02d)], which is%s your sector.  Direction?",
1814 #endif
1815
1816                         y2 / (hgt / 2), y2 % (hgt / 2),
1817                         x2 / (wid / 2), x2 % (wid / 2), tmp_val);
1818
1819                 /* Assume no direction */
1820                 dir = 0;
1821
1822                 /* Get a direction */
1823                 while (!dir)
1824                 {
1825                         char command;
1826
1827                         /* Get a command (or Cancel) */
1828                         if (!get_com(out_val, &command, TRUE)) break;
1829
1830                         /* Extract the action (if any) */
1831                         dir = get_keymap_dir(command);
1832
1833                         /* Error */
1834                         if (!dir) bell();
1835                 }
1836
1837                 /* No direction */
1838                 if (!dir) break;
1839
1840                 /* Apply the motion */
1841                 if (change_panel(ddy[dir], ddx[dir]))
1842                 {
1843                         y2 = panel_row_min;
1844                         x2 = panel_col_min;
1845                 }
1846         }
1847
1848
1849         /* Recenter the map around the player */
1850         verify_panel();
1851
1852         /* Update stuff */
1853         p_ptr->update |= (PU_MONSTERS);
1854
1855         /* Redraw map */
1856         p_ptr->redraw |= (PR_MAP);
1857
1858         /* Window stuff */
1859         p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
1860
1861         /* Handle stuff */
1862         handle_stuff();
1863 }
1864
1865
1866
1867 /*
1868  * Sorting hook -- Comp function -- see below
1869  *
1870  * We use "u" to point to array of monster indexes,
1871  * and "v" to select the type of sorting to perform on "u".
1872  */
1873 bool ang_sort_comp_hook(vptr u, vptr v, int a, int b)
1874 {
1875         u16b *who = (u16b*)(u);
1876
1877         u16b *why = (u16b*)(v);
1878
1879         int w1 = who[a];
1880         int w2 = who[b];
1881
1882         int z1, z2;
1883
1884         /* Sort by player kills */
1885         if (*why >= 4)
1886         {
1887                 /* Extract player kills */
1888                 z1 = r_info[w1].r_pkills;
1889                 z2 = r_info[w2].r_pkills;
1890
1891                 /* Compare player kills */
1892                 if (z1 < z2) return (TRUE);
1893                 if (z1 > z2) return (FALSE);
1894         }
1895
1896
1897         /* Sort by total kills */
1898         if (*why >= 3)
1899         {
1900                 /* Extract total kills */
1901                 z1 = r_info[w1].r_tkills;
1902                 z2 = r_info[w2].r_tkills;
1903
1904                 /* Compare total kills */
1905                 if (z1 < z2) return (TRUE);
1906                 if (z1 > z2) return (FALSE);
1907         }
1908
1909
1910         /* Sort by monster level */
1911         if (*why >= 2)
1912         {
1913                 /* Extract levels */
1914                 z1 = r_info[w1].level;
1915                 z2 = r_info[w2].level;
1916
1917                 /* Compare levels */
1918                 if (z1 < z2) return (TRUE);
1919                 if (z1 > z2) return (FALSE);
1920         }
1921
1922
1923         /* Sort by monster experience */
1924         if (*why >= 1)
1925         {
1926                 /* Extract experience */
1927                 z1 = r_info[w1].mexp;
1928                 z2 = r_info[w2].mexp;
1929
1930                 /* Compare experience */
1931                 if (z1 < z2) return (TRUE);
1932                 if (z1 > z2) return (FALSE);
1933         }
1934
1935
1936         /* Compare indexes */
1937         return (w1 <= w2);
1938 }
1939
1940
1941 /*
1942  * Sorting hook -- Swap function -- see below
1943  *
1944  * We use "u" to point to array of monster indexes,
1945  * and "v" to select the type of sorting to perform.
1946  */
1947 void ang_sort_swap_hook(vptr u, vptr v, int a, int b)
1948 {
1949         u16b *who = (u16b*)(u);
1950
1951         u16b holder;
1952
1953         /* Unused */
1954         (void)v;
1955
1956         /* Swap */
1957         holder = who[a];
1958         who[a] = who[b];
1959         who[b] = holder;
1960 }
1961
1962
1963
1964 /*
1965  * Identify a character, allow recall of monsters
1966  *
1967  * Several "special" responses recall "multiple" monsters:
1968  *   ^A (all monsters)
1969  *   ^U (all unique monsters)
1970  *   ^N (all non-unique monsters)
1971  *
1972  * The responses may be sorted in several ways, see below.
1973  *
1974  * Note that the player ghosts are ignored. XXX XXX XXX
1975  */
1976 void do_cmd_query_symbol(void)
1977 {
1978         int             i, n, r_idx;
1979         char    sym, query;
1980         char    buf[128];
1981
1982         bool    all = FALSE;
1983         bool    uniq = FALSE;
1984         bool    norm = FALSE;
1985         bool    ride = FALSE;
1986         char    temp[80] = "";
1987
1988         bool    recall = FALSE;
1989
1990         u16b    why = 0;
1991         u16b    *who;
1992
1993         /* Get a character, or abort */
1994 #ifdef JP
1995         if (!get_com("ÃΤꤿ¤¤Ê¸»ú¤òÆþÎϤ·¤Æ²¼¤µ¤¤(µ­¹æ or ^AÁ´,^U¥æ,^NÈó¥æ,^R¾èÇÏ,^M̾Á°): ", &sym, FALSE)) return;
1996 #else
1997         if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym, FALSE)) return;
1998 #endif
1999
2000         /* Find that character info, and describe it */
2001         for (i = 0; ident_info[i]; ++i)
2002         {
2003                 if (sym == ident_info[i][0]) break;
2004         }
2005
2006         /* Describe */
2007         if (sym == KTRL('A'))
2008         {
2009                 all = TRUE;
2010 #ifdef JP
2011                 strcpy(buf, "Á´¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2012 #else
2013                 strcpy(buf, "Full monster list.");
2014 #endif
2015         }
2016         else if (sym == KTRL('U'))
2017         {
2018                 all = uniq = TRUE;
2019 #ifdef JP
2020                 strcpy(buf, "¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2021 #else
2022                 strcpy(buf, "Unique monster list.");
2023 #endif
2024         }
2025         else if (sym == KTRL('N'))
2026         {
2027                 all = norm = TRUE;
2028 #ifdef JP
2029                 strcpy(buf, "¥æ¥Ë¡¼¥¯³°¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2030 #else
2031                 strcpy(buf, "Non-unique monster list.");
2032 #endif
2033         }
2034         else if (sym == KTRL('R'))
2035         {
2036                 all = ride = TRUE;
2037 #ifdef JP
2038                 strcpy(buf, "¾èÇϲÄǽ¥â¥ó¥¹¥¿¡¼¤Î¥ê¥¹¥È");
2039 #else
2040                 strcpy(buf, "Ridable monster list.");
2041 #endif
2042         }
2043         /* XTRA HACK WHATSEARCH */
2044         else if (sym == KTRL('M'))
2045         {
2046                 all = TRUE;
2047 #ifdef JP
2048                 if (!get_string("̾Á°(±Ñ¸ì¤Î¾ì¹ç¾®Ê¸»ú¤Ç²Ä)",temp, 70))
2049 #else
2050                 if (!get_string("Enter name:",temp, 70))
2051 #endif
2052                 {
2053                         temp[0]=0;
2054                         return;
2055                 }
2056 #ifdef JP
2057                 sprintf(buf, "̾Á°:%s¤Ë¥Þ¥Ã¥Á",temp);
2058 #else
2059                 sprintf(buf, "Monsters with a name \"%s\"",temp);
2060 #endif
2061         }
2062         else if (ident_info[i])
2063         {
2064                 sprintf(buf, "%c - %s.", sym, ident_info[i] + 2);
2065         }
2066         else
2067         {
2068 #ifdef JP
2069                 sprintf(buf, "%c - %s", sym, "̵¸ú¤Êʸ»ú");
2070 #else
2071                 sprintf(buf, "%c - %s.", sym, "Unknown Symbol");
2072 #endif
2073         }
2074
2075         /* Display the result */
2076         prt(buf, 0, 0);
2077
2078         /* Allocate the "who" array */
2079         C_MAKE(who, max_r_idx, u16b);
2080
2081         /* Collect matching monsters */
2082         for (n = 0, i = 1; i < max_r_idx; i++)
2083         {
2084                 monster_race *r_ptr = &r_info[i];
2085
2086                 /* Nothing to recall */
2087                 if (!cheat_know && !r_ptr->r_sights) continue;
2088
2089                 /* Require non-unique monsters if needed */
2090                 if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue;
2091
2092                 /* Require unique monsters if needed */
2093                 if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue;
2094
2095                 /* Require ridable monsters if needed */
2096                 if (ride && !(r_ptr->flags7 & (RF7_RIDING))) continue;
2097
2098                 /* XTRA HACK WHATSEARCH */
2099                 if (temp[0])
2100                 {
2101                   int xx;
2102                   char temp2[80];
2103   
2104                   for (xx=0; temp[xx] && xx<80; xx++)
2105                   {
2106 #ifdef JP
2107                     if (iskanji( temp[xx])) { xx++; continue; }
2108 #endif
2109                     if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]);
2110                   }
2111   
2112 #ifdef JP
2113                   strcpy(temp2, r_name+r_ptr->E_name);
2114 #else
2115                   strcpy(temp2, r_name+r_ptr->name);
2116 #endif
2117                   for (xx=0; temp2[xx] && xx<80; xx++)
2118                     if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]);
2119   
2120 #ifdef JP
2121                   if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) )
2122 #else
2123                   if (my_strstr(temp2, temp))
2124 #endif
2125                           who[n++]=i;
2126                 }
2127
2128                 /* Collect "appropriate" monsters */
2129                 else if (all || (r_ptr->d_char == sym)) who[n++] = i;
2130         }
2131
2132         /* Nothing to recall */
2133         if (!n)
2134         {
2135                 /* Free the "who" array */
2136                 C_KILL(who, max_r_idx, u16b);
2137
2138                 return;
2139         }
2140
2141
2142         /* Prompt XXX XXX XXX */
2143 #ifdef JP
2144         put_str("»×¤¤½Ð¤ò¸«¤Þ¤¹¤«? (k:»¦³²½ç/y/n): ", 0, 36);
2145 #else
2146         put_str("Recall details? (k/y/n): ", 0, 40);
2147 #endif
2148
2149
2150         /* Query */
2151         query = inkey();
2152
2153         /* Restore */
2154         prt(buf, 0, 0);
2155
2156         why = 2;
2157
2158         /* Select the sort method */
2159         ang_sort_comp = ang_sort_comp_hook;
2160         ang_sort_swap = ang_sort_swap_hook;
2161
2162         /* Sort the array */
2163         ang_sort(who, &why, n);
2164
2165         /* Sort by kills (and level) */
2166         if (query == 'k')
2167         {
2168                 why = 4;
2169                 query = 'y';
2170         }
2171
2172         /* Catch "escape" */
2173         if (query != 'y')
2174         {
2175                 /* Free the "who" array */
2176                 C_KILL(who, max_r_idx, u16b);
2177
2178                 return;
2179         }
2180
2181         /* Sort if needed */
2182         if (why == 4)
2183         {
2184                 /* Select the sort method */
2185                 ang_sort_comp = ang_sort_comp_hook;
2186                 ang_sort_swap = ang_sort_swap_hook;
2187
2188                 /* Sort the array */
2189                 ang_sort(who, &why, n);
2190         }
2191
2192
2193         /* Start at the end */
2194         i = n - 1;
2195
2196         /* Scan the monster memory */
2197         while (1)
2198         {
2199                 /* Extract a race */
2200                 r_idx = who[i];
2201
2202                 /* Hack -- Auto-recall */
2203                 monster_race_track(r_idx);
2204
2205                 /* Hack -- Handle stuff */
2206                 handle_stuff();
2207
2208                 /* Interact */
2209                 while (1)
2210                 {
2211                         /* Recall */
2212                         if (recall)
2213                         {
2214                                 /* Save the screen */
2215                                 screen_save();
2216
2217                                 /* Recall on screen */
2218                                 screen_roff(who[i], 0);
2219                         }
2220
2221                         /* Hack -- Begin the prompt */
2222                         roff_top(r_idx);
2223
2224                         /* Hack -- Complete the prompt */
2225 #ifdef JP
2226                         Term_addstr(-1, TERM_WHITE, " ['r'»×¤¤½Ð, ESC]");
2227 #else
2228                         Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]");
2229 #endif
2230
2231                         /* Command */
2232                         query = inkey();
2233
2234                         /* Unrecall */
2235                         if (recall)
2236                         {
2237                                 /* Restore */
2238                                 screen_load();
2239                         }
2240
2241                         /* Normal commands */
2242                         if (query != 'r') break;
2243
2244                         /* Toggle recall */
2245                         recall = !recall;
2246                 }
2247
2248                 /* Stop scanning */
2249                 if (query == ESCAPE) break;
2250
2251                 /* Move to "prev" monster */
2252                 if (query == '-')
2253                 {
2254                         if (++i == n)
2255                         {
2256                                 i = 0;
2257                                 if (!expand_list) break;
2258                         }
2259                 }
2260
2261                 /* Move to "next" monster */
2262                 else
2263                 {
2264                         if (i-- == 0)
2265                         {
2266                                 i = n - 1;
2267                                 if (!expand_list) break;
2268                         }
2269                 }
2270         }
2271
2272         /* Free the "who" array */
2273         C_KILL(who, max_r_idx, u16b);
2274
2275         /* Re-display the identity */
2276         prt(buf, 0, 0);
2277 }
2278
2279