OSDN Git Service

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