OSDN Git Service

Fix Doxygen warning in object1.c.
[hengband/hengband.git] / src / object1.c
1 /*!
2  * @file object1.c
3  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î¼ÂÁõ / Object code, part 1
4  * @date 2014/01/10
5  * @author
6  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
7  *\n
8  * This software may be copied and distributed for educational, research,\n
9  * and not for profit purposes provided that this copyright and statement\n
10  * are included in all such copies.  Other copyrights may also apply.\n
11  * 2014 Deskull rearranged comment for Doxygen.\n
12  */
13
14 #include "angband.h"
15
16 #if defined(MACINTOSH) || defined(MACH_O_CARBON)
17 #ifdef verify
18 #undef verify
19 #endif
20 #endif
21
22 /*!
23  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¡¢ÃÏ·Á¤Îɽ¼¨¥·¥ó¥Ü¥ë¤Ê¤É½é´ü²½¤¹¤ë / Reset the "visual" lists
24  * @return ¤Ê¤·
25  * This involves resetting various things to their "default" state.\n
26  *\n
27  * If the "prefs" flag is TRUE, then we will also load the appropriate\n
28  * "user pref file" based on the current setting of the "use_graphics"\n
29  * flag.  This is useful for switching "graphics" on/off.\n
30  *\n
31  * The features, objects, and monsters, should all be encoded in the\n
32  * relevant "font.pref" and/or "graf.prf" files.  XXX XXX XXX\n
33  *\n
34  * The "prefs" parameter is no longer meaningful.  XXX XXX XXX\n
35  */
36 void reset_visuals(void)
37 {
38         int i, j;
39
40         /* Extract some info about terrain features */
41         for (i = 0; i < max_f_idx; i++)
42         {
43                 feature_type *f_ptr = &f_info[i];
44
45                 /* Assume we will use the underlying values */
46                 for (j = 0; j < F_LIT_MAX; j++)
47                 {
48                         f_ptr->x_attr[j] = f_ptr->d_attr[j];
49                         f_ptr->x_char[j] = f_ptr->d_char[j];
50                 }
51         }
52
53         /* Extract default attr/char code for objects */
54         for (i = 0; i < max_k_idx; i++)
55         {
56                 object_kind *k_ptr = &k_info[i];
57
58                 /* Default attr/char */
59                 k_ptr->x_attr = k_ptr->d_attr;
60                 k_ptr->x_char = k_ptr->d_char;
61         }
62
63         /* Extract default attr/char code for monsters */
64         for (i = 0; i < max_r_idx; i++)
65         {
66                 monster_race *r_ptr = &r_info[i];
67
68                 /* Default attr/char */
69                 r_ptr->x_attr = r_ptr->d_attr;
70                 r_ptr->x_char = r_ptr->d_char;
71         }
72
73         if (use_graphics)
74         {
75                 char buf[1024];
76
77                 /* Process "graf.prf" */
78                 process_pref_file("graf.prf");
79
80                 /* Access the "character" pref file */
81                 sprintf(buf, "graf-%s.prf", player_base);
82
83                 /* Process "graf-<playername>.prf" */
84                 process_pref_file(buf);
85         }
86
87         /* Normal symbols */
88         else
89         {
90                 char buf[1024];
91
92                 /* Process "font.prf" */
93                 process_pref_file("font.prf");
94
95                 /* Access the "character" pref file */
96                 sprintf(buf, "font-%s.prf", player_base);
97
98                 /* Process "font-<playername>.prf" */
99                 process_pref_file(buf);
100         }
101 }
102
103 /*!
104  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Õ¥é¥°Îà¤òÇÛÎó¤ËÍ¿¤¨¤ë
105  * Obtain the "flags" for an item
106  * @param o_ptr ¥Õ¥é¥°¼èÆÀ¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΥݥ¤¥ó¥¿
107  * @param flgs ¥Õ¥é¥°¾ðÊó¤ò¼õ¤±¼è¤ëÇÛÎó
108  * @return ¤Ê¤·
109  */
110 void object_flags(object_type *o_ptr, u32b flgs[TR_FLAG_SIZE])
111 {
112         object_kind *k_ptr = &k_info[o_ptr->k_idx];
113         int i;
114
115         /* Base object */
116         for (i = 0; i < TR_FLAG_SIZE; i++)
117                 flgs[i] = k_ptr->flags[i];
118
119         /* Artifact */
120         if (object_is_fixed_artifact(o_ptr))
121         {
122                 artifact_type *a_ptr = &a_info[o_ptr->name1];
123
124                 for (i = 0; i < TR_FLAG_SIZE; i++)
125                         flgs[i] = a_ptr->flags[i];
126         }
127
128         /* Ego-item */
129         if (object_is_ego(o_ptr))
130         {
131                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
132
133                 for (i = 0; i < TR_FLAG_SIZE; i++)
134                         flgs[i] |= e_ptr->flags[i];
135
136                 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
137                 {
138                         remove_flag(flgs, TR_SH_FIRE);
139                 }
140                 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
141                 {
142                         remove_flag(flgs, TR_INFRA);
143                 }
144                 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
145                 {
146                         remove_flag(flgs, TR_RES_BLIND);
147                         remove_flag(flgs, TR_SEE_INVIS);
148                 }
149         }
150
151         /* Random artifact ! */
152         for (i = 0; i < TR_FLAG_SIZE; i++)
153                 flgs[i] |= o_ptr->art_flags[i];
154
155         if (object_is_smith(o_ptr))
156         {
157                 int add = o_ptr->xtra3 - 1;
158
159                 if (add < TR_FLAG_MAX)
160                 {
161                         add_flag(flgs, add);
162                 }
163                 else if (add == ESSENCE_TMP_RES_ACID)
164                 {
165                         add_flag(flgs, TR_RES_ACID);
166                         add_flag(flgs, TR_ACTIVATE);
167                 }
168                 else if (add == ESSENCE_TMP_RES_ELEC)
169                 {
170                         add_flag(flgs, TR_RES_ELEC);
171                         add_flag(flgs, TR_ACTIVATE);
172                 }
173                 else if (add == ESSENCE_TMP_RES_FIRE)
174                 {
175                         add_flag(flgs, TR_RES_FIRE);
176                         add_flag(flgs, TR_ACTIVATE);
177                 }
178                 else if (add == ESSENCE_TMP_RES_COLD)
179                 {
180                         add_flag(flgs, TR_RES_COLD);
181                         add_flag(flgs, TR_ACTIVATE);
182                 }
183                 else if (add == ESSENCE_SH_FIRE)
184                 {
185                         add_flag(flgs, TR_RES_FIRE);
186                         add_flag(flgs, TR_SH_FIRE);
187                 }
188                 else if (add == ESSENCE_SH_ELEC)
189                 {
190                         add_flag(flgs, TR_RES_ELEC);
191                         add_flag(flgs, TR_SH_ELEC);
192                 }
193                 else if (add == ESSENCE_SH_COLD)
194                 {
195                         add_flag(flgs, TR_RES_COLD);
196                         add_flag(flgs, TR_SH_COLD);
197                 }
198                 else if (add == ESSENCE_RESISTANCE)
199                 {
200                         add_flag(flgs, TR_RES_ACID);
201                         add_flag(flgs, TR_RES_ELEC);
202                         add_flag(flgs, TR_RES_FIRE);
203                         add_flag(flgs, TR_RES_COLD);
204                 }
205                 else if (add == TR_IMPACT)
206                 {
207                         add_flag(flgs, TR_ACTIVATE);
208                 }
209         }
210 }
211
212 /*!
213  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÌÀ¼¨¤µ¤ì¤Æ¤¤¤ë¥Õ¥é¥°Îà¤ò¼èÆÀ¤¹¤ë
214  * Obtain the "flags" for an item which are known to the player
215  * @param o_ptr ¥Õ¥é¥°¼èÆÀ¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤ÂΥݥ¤¥ó¥¿
216  * @param flgs ¥Õ¥é¥°¾ðÊó¤ò¼õ¤±¼è¤ëÇÛÎó
217  * @return ¤Ê¤·
218  */
219 void object_flags_known(object_type *o_ptr, u32b flgs[TR_FLAG_SIZE])
220 {
221         bool spoil = FALSE;
222         int i;
223
224         object_kind *k_ptr = &k_info[o_ptr->k_idx];
225
226         /* Clear */
227         for (i = 0; i < TR_FLAG_SIZE; i++)
228                 flgs[i] = 0;
229
230         if (!object_is_aware(o_ptr)) return;
231
232         /* Base object */
233         for (i = 0; i < TR_FLAG_SIZE; i++)
234                 flgs[i] = k_ptr->flags[i];
235
236         /* Must be identified */
237         if (!object_is_known(o_ptr)) return;
238
239         /* Ego-item (known basic flags) */
240         if (object_is_ego(o_ptr))
241         {
242                 ego_item_type *e_ptr = &e_info[o_ptr->name2];
243
244                 for (i = 0; i < TR_FLAG_SIZE; i++)
245                         flgs[i] |= e_ptr->flags[i];
246
247                 if ((o_ptr->name2 == EGO_LITE_AURA_FIRE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
248                 {
249                         remove_flag(flgs, TR_SH_FIRE);
250                 }
251                 else if ((o_ptr->name2 == EGO_LITE_INFRA) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
252                 {
253                         remove_flag(flgs, TR_INFRA);
254                 }
255                 else if ((o_ptr->name2 == EGO_LITE_EYE) && !o_ptr->xtra4 && (o_ptr->sval <= SV_LITE_LANTERN))
256                 {
257                         remove_flag(flgs, TR_RES_BLIND);
258                         remove_flag(flgs, TR_SEE_INVIS);
259                 }
260         }
261
262
263 #ifdef SPOIL_ARTIFACTS
264         /* Full knowledge for some artifacts */
265         if (object_is_artifact(o_ptr)) spoil = TRUE;
266 #endif /* SPOIL_ARTIFACTS */
267
268 #ifdef SPOIL_EGO_ITEMS
269         /* Full knowledge for some ego-items */
270         if (object_is_ego(o_ptr)) spoil = TRUE;
271 #endif /* SPOIL_EGO_ITEMS */
272
273         /* Need full knowledge or spoilers */
274         if (spoil || (o_ptr->ident & IDENT_MENTAL))
275         {
276                 /* Artifact */
277                 if (object_is_fixed_artifact(o_ptr))
278                 {
279                         artifact_type *a_ptr = &a_info[o_ptr->name1];
280
281                         for (i = 0; i < TR_FLAG_SIZE; i++)
282                                 flgs[i] = a_ptr->flags[i];
283                 }
284
285                 /* Random artifact ! */
286                 for (i = 0; i < TR_FLAG_SIZE; i++)
287                         flgs[i] |= o_ptr->art_flags[i];
288         }
289
290         if (object_is_smith(o_ptr))
291         {
292                 int add = o_ptr->xtra3 - 1;
293
294                 if (add < TR_FLAG_MAX)
295                 {
296                         add_flag(flgs, add);
297                 }
298                 else if (add == ESSENCE_TMP_RES_ACID)
299                 {
300                         add_flag(flgs, TR_RES_ACID);
301                 }
302                 else if (add == ESSENCE_TMP_RES_ELEC)
303                 {
304                         add_flag(flgs, TR_RES_ELEC);
305                 }
306                 else if (add == ESSENCE_TMP_RES_FIRE)
307                 {
308                         add_flag(flgs, TR_RES_FIRE);
309                 }
310                 else if (add == ESSENCE_TMP_RES_COLD)
311                 {
312                         add_flag(flgs, TR_RES_COLD);
313                 }
314                 else if (add == ESSENCE_SH_FIRE)
315                 {
316                         add_flag(flgs, TR_RES_FIRE);
317                         add_flag(flgs, TR_SH_FIRE);
318                 }
319                 else if (add == ESSENCE_SH_ELEC)
320                 {
321                         add_flag(flgs, TR_RES_ELEC);
322                         add_flag(flgs, TR_SH_ELEC);
323                 }
324                 else if (add == ESSENCE_SH_COLD)
325                 {
326                         add_flag(flgs, TR_RES_COLD);
327                         add_flag(flgs, TR_SH_COLD);
328                 }
329                 else if (add == ESSENCE_RESISTANCE)
330                 {
331                         add_flag(flgs, TR_RES_ACID);
332                         add_flag(flgs, TR_RES_ELEC);
333                         add_flag(flgs, TR_RES_FIRE);
334                         add_flag(flgs, TR_RES_COLD);
335                 }
336         }
337 }
338
339 /*!
340  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Îȯư¸ú²Ì̾¾Î¤òÊÖ¤¹¡Ê¥µ¥Ö¥ë¡¼¥Á¥ó/¥Ö¥ì¥¹¡Ë
341  * @param o_ptr Ì¾¾Î¤ò¼èÆÀ¤¹¤ë¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
342  * @return cptr È¯Æ°Ì¾¾Î¤òÊÖ¤¹Ê¸»úÎó¥Ý¥¤¥ó¥¿
343  */
344 static cptr item_activation_dragon_breath(object_type *o_ptr)
345 {
346         static char desc[256];
347         u32b flgs[TR_FLAG_SIZE]; /* for resistance flags */
348         int i, n = 0;
349
350         object_flags(o_ptr, flgs);
351         strcpy(desc, _("", "breath "));
352
353         for (i = 0; dragonbreath_info[i].flag != 0; i++)
354         {
355                 if (have_flag(flgs, dragonbreath_info[i].flag))
356                 {
357                         if (n > 0) strcat(desc, _("¡¢", ", "));
358                         strcat(desc, dragonbreath_info[i].name);
359                         n++;
360                 }
361         }
362
363         strcat(desc, _("¤Î¥Ö¥ì¥¹(250)", ""));
364
365         return (desc);
366 }
367
368 /*!
369  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Îȯư¸ú²Ì̾¾Î¤òÊÖ¤¹¡Ê¥µ¥Ö¥ë¡¼¥Á¥ó/ÈÆÍÑ¡Ë
370  * @param o_ptr Ì¾¾Î¤ò¼èÆÀ¤¹¤ë¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
371  * @return cptr È¯Æ°Ì¾¾Î¤òÊÖ¤¹Ê¸»úÎó¥Ý¥¤¥ó¥¿
372  */
373 static cptr item_activation_aux(object_type *o_ptr)
374 {
375         static char activation_detail[256];
376         cptr desc;
377         char timeout[32];
378         int constant, dice;
379         const activation_type* const act_ptr = find_activation_info(o_ptr);
380
381         if (!act_ptr) return _("̤ÄêµÁ", "something undefined");
382
383         desc = act_ptr->desc;
384
385         /* Overwrite description if it is special */
386         switch (act_ptr->index) {
387         case ACT_BR_FIRE:
388                 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES))
389                         desc = _("²Ð±ê¤Î¥Ö¥ì¥¹ (200) ¤È²Ð¤Ø¤ÎÂÑÀ­", "breath of fire (200) and resist fire");
390                 break;
391         case ACT_BR_COLD:
392                 if ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE))
393                         desc = _("Î䵤¤Î¥Ö¥ì¥¹ (200) ¤ÈÎ䵤¤Ø¤ÎÂÑÀ­", "breath of cold (200) and resist cold");
394                 break;
395         case ACT_BR_DRAGON:
396                 desc = item_activation_dragon_breath(o_ptr);
397                 break;
398         case ACT_AGGRAVATE:
399                 if (o_ptr->name1 == ART_HYOUSIGI)
400                         desc = _("Çï»ÒÌÚ¤òÂǤÁ¤Ê¤é¤¹", "beat wooden clappers");
401                 break;
402         case ACT_RESIST_ACID:
403                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ACID)) || (o_ptr->name2 == EGO_BRAND_ACID))
404                         desc = _("¥¢¥·¥Ã¥É¡¦¥Ü¡¼¥ë (100) ¤È»À¤Ø¤ÎÂÑÀ­", "ball of acid (100) and resist acid");
405                 break;
406         case ACT_RESIST_FIRE:
407                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) || (o_ptr->name2 == EGO_BRAND_FIRE))
408                         desc = _("¥Õ¥¡¥¤¥¢¡¦¥Ü¡¼¥ë (100) ¤È²Ð¤Ø¤ÎÂÑÀ­", "ball of fire (100) and resist fire");
409                 break;
410         case ACT_RESIST_COLD:
411                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) || (o_ptr->name2 == EGO_BRAND_COLD))
412                         desc = _("¥¢¥¤¥¹¡¦¥Ü¡¼¥ë (100) ¤ÈÎ䵤¤Ø¤ÎÂÑÀ­", "ball of cold (100) and resist cold");
413                 break;
414         case ACT_RESIST_ELEC:
415                 if (((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ELEC)) || (o_ptr->name2 == EGO_BRAND_ELEC))
416                         desc = _("¥µ¥ó¥À¡¼¡¦¥Ü¡¼¥ë (100) ¤ÈÅÅ·â¤Ø¤ÎÂÑÀ­", "ball of elec (100) and resist elec");
417                 break;
418         case ACT_RESIST_POIS:
419                 if (o_ptr->name2 == EGO_BRAND_POIS)
420                         desc = _("°­½­±À (100) ¤ÈÆǤؤÎÂÑÀ­", "ball of poison (100) and resist elec");
421                 break;
422         }
423
424         /* Timeout description */
425         constant = act_ptr->timeout.constant;
426         dice = act_ptr->timeout.dice;
427         if (constant == 0 && dice == 0) {
428                 /* We can activate it every turn */
429                 strcpy(timeout, _("¤¤¤Ä¤Ç¤â", "every turn"));
430         } else if (constant < 0) {
431                 /* Activations that have special timeout */
432                 switch (act_ptr->index) {
433                 case ACT_BR_FIRE:
434                         sprintf(timeout, _("%d ¥¿¡¼¥óËè", "every %d turns"),
435                                 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250);
436                         break;
437                 case ACT_BR_COLD:
438                         sprintf(timeout, _("%d ¥¿¡¼¥óËè", "every %d turns"),
439                                 ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250);
440                         break;
441                 case ACT_TERROR:
442                         strcpy(timeout, _("3*(¥ì¥Ù¥ë+10) ¥¿¡¼¥óËè", "every 3 * (level+10) turns"));
443                         break;
444                 case ACT_MURAMASA:
445                         strcpy(timeout, _("³ÎΨ50%¤Ç²õ¤ì¤ë", "(destroyed 50%)"));
446                         break;
447                 default:
448                         strcpy(timeout, "undefined");
449                         break;
450                 }
451         } else {
452                 /* Normal timeout activations */
453                 char constant_str[16], dice_str[16];
454                 sprintf(constant_str, "%d", constant);
455                 sprintf(dice_str, "d%d", dice);
456                 sprintf(timeout, _("%s%s%s ¥¿¡¼¥óËè", "every %s%s%s turns"),
457                         (constant > 0) ? constant_str : "",
458                         (constant > 0 && dice > 0) ? "+" : "",
459                         (dice > 0) ? dice_str : "");
460         }
461
462         /* Build detail activate description */
463         sprintf(activation_detail, _("%s : %s", "%s %s"), desc, timeout);
464
465         return activation_detail;
466 }
467
468 /*!
469  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Îȯư¸ú²Ì̾¾Î¤òÊÖ¤¹¡Ê¥á¥¤¥ó¥ë¡¼¥Á¥ó¡Ë /
470  * Determine the "Activation" (if any) for an artifact Return a string, or NULL for "no activation"
471  * @param o_ptr Ì¾¾Î¤ò¼èÆÀ¤¹¤ë¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
472  * @return cptr È¯Æ°Ì¾¾Î¤òÊÖ¤¹Ê¸»úÎó¥Ý¥¤¥ó¥¿
473  */
474 cptr item_activation(object_type *o_ptr)
475 {
476         u32b flgs[TR_FLAG_SIZE];
477
478         /* Extract the flags */
479         object_flags(o_ptr, flgs);
480
481         /* Require activation ability */
482 #ifdef JP
483         if (!(have_flag(flgs, TR_ACTIVATE))) return ("¤Ê¤·");
484 #else
485         if (!(have_flag(flgs, TR_ACTIVATE))) return ("nothing");
486 #endif
487
488         /* Get an explain of an activation */
489         if (activation_index(o_ptr))
490         {
491                 return item_activation_aux(o_ptr);
492         }
493
494         /* Special items */
495         if (o_ptr->tval == TV_WHISTLE)
496         {
497 #ifdef JP
498 return "¥Ú¥Ã¥È¸Æ¤Ó´ó¤» : 100+d100¥¿¡¼¥óËè";
499 #else
500                 return "call pet every 100+d100 turns";
501 #endif
502         }
503
504         if (o_ptr->tval == TV_CAPTURE)
505         {
506 #ifdef JP
507 return "¥â¥ó¥¹¥¿¡¼¤òÊᤨ¤ë¡¢Ëô¤Ï²òÊü¤¹¤ë¡£";
508 #else
509                 return "captures or releases a monster.";
510 #endif
511         }
512
513         /* Oops */
514 #ifdef JP
515         return "²¿¤âµ¯¤­¤Ê¤¤";
516 #else
517         return "Nothing";
518 #endif
519 }
520
521
522 /*!
523  * @brief ¥ª¥Ö¥¸¥§¥¯¥È¤Î*´ÕÄê*ÆâÍƤò¾Ü½Ò¤·¤Æɽ¼¨¤¹¤ë /
524  * Describe a "fully identified" item
525  * @param o_ptr *´ÕÄê*¾ðÊó¤ò¼èÆÀ¤¹¤ë¸µ¤Î¥ª¥Ö¥¸¥§¥¯¥È¹½Â¤Âλ²¾È¥Ý¥¤¥ó¥¿
526  * @param mode É½¼¨¥ª¥×¥·¥ç¥ó
527  * @return ÆÃÉ®¤¹¤Ù¤­¾ðÊ󤬰ì¤Ä¤Ç¤â¤¢¤Ã¤¿¾ì¹çTRUE¡¢°ì¤Ä¤â¤Ê¤¯É½¼¨¤¬¥­¥ã¥ó¥»¥ë¤µ¤ì¤¿¾ì¹çFALSE¤òÊÖ¤¹¡£
528  */
529 bool screen_object(object_type *o_ptr, u32b mode)
530 {
531         int                     i = 0, j, k;
532
533         u32b flgs[TR_FLAG_SIZE];
534
535         char temp[70 * 20];
536         cptr            info[128];
537         char o_name[MAX_NLEN];
538         int wid, hgt;
539         int rad;
540         char desc[256];
541
542         int trivial_info = 0;
543
544         /* Extract the flags */
545         object_flags(o_ptr, flgs);
546
547         /* Extract the description */
548         {
549                 roff_to_buf(o_ptr->name1 ? (a_text + a_info[o_ptr->name1].text) :
550                             (k_text + k_info[o_ptr->k_idx].text),
551                             77 - 15, temp, sizeof(temp));
552                 for (j = 0; temp[j]; j += 1 + strlen(&temp[j]))
553                 { info[i] = &temp[j]; i++;}
554         }
555
556         if (object_is_equipment(o_ptr))
557         {
558                 /* Descriptions of a basic equipment is just a flavor */
559                 trivial_info = i;
560         }
561
562         /* Mega-Hack -- describe activation */
563         if (have_flag(flgs, TR_ACTIVATE))
564         {
565 #ifdef JP
566 info[i++] = "»ÏÆ°¤·¤¿¤È¤­¤Î¸ú²Ì...";
567 #else
568                 info[i++] = "It can be activated for...";
569 #endif
570
571                 info[i++] = item_activation(o_ptr);
572 #ifdef JP
573 info[i++] = "...¤¿¤À¤·ÁõÈ÷¤·¤Æ¤¤¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£";
574 #else
575                 info[i++] = "...if it is being worn.";
576 #endif
577
578         }
579
580         /* Figurines, a hack */
581         if (o_ptr->tval == TV_FIGURINE)
582         {
583 #ifdef JP
584 info[i++] = "¤½¤ì¤ÏÅꤲ¤¿»þ¥Ú¥Ã¥È¤ËÊѲ½¤¹¤ë¡£";
585 #else
586                 info[i++] = "It will transform into a pet when thrown.";
587 #endif
588
589         }
590
591         /* Figurines, a hack */
592         if (o_ptr->name1 == ART_STONEMASK)
593         {
594 #ifdef JP
595 info[i++] = "¤½¤ì¤òÁõÈ÷¤·¤¿¼Ô¤ÏµÛ·ìµ´¤Ë¤Ê¤ë¡£";
596 #else
597                 info[i++] = "It makes you turn into a vampire permanently.";
598 #endif
599
600         }
601
602         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
603         {
604 #ifdef JP
605 info[i++] = "¤½¤ì¤ÏÁê¼ê¤ò°ì·â¤ÇÅݤ¹¤³¤È¤¬¤¢¤ë¡£";
606 #else
607                 info[i++] = "It will attempt to kill a monster instantly.";
608 #endif
609
610         }
611
612         if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
613         {
614 #ifdef JP
615 info[i++] = "¤½¤ì¤Ï¼«Ê¬¼«¿È¤Ë¹¶·â¤¬Ê֤äƤ¯¤ë¤³¤È¤¬¤¢¤ë¡£";
616 #else
617                 info[i++] = "It causes you to strike yourself sometimes.";
618 #endif
619
620 #ifdef JP
621 info[i++] = "¤½¤ì¤Ï̵Ũ¤Î¥Ð¥ê¥¢¤òÀÚ¤êÎö¤¯¡£";
622 #else
623                 info[i++] = "It always penetrates invulnerability barriers.";
624 #endif
625         }
626
627         if (o_ptr->name2 == EGO_2WEAPON)
628         {
629 #ifdef JP
630 info[i++] = "¤½¤ì¤ÏÆóÅáή¤Ç¤ÎÌ¿ÃæΨ¤ò¸þ¾å¤µ¤»¤ë¡£";
631 #else
632                 info[i++] = "It affects your ability to hit when you are wielding two weapons.";
633 #endif
634
635         }
636
637         if (have_flag(flgs, TR_EASY_SPELL))
638         {
639 #ifdef JP
640 info[i++] = "¤½¤ì¤ÏËâË¡¤ÎÆñ°×ÅÙ¤ò²¼¤²¤ë¡£";
641 #else
642                 info[i++] = "It affects your ability to cast spells.";
643 #endif
644         }
645
646         if (o_ptr->name2 == EGO_AMU_FOOL)
647         {
648 #ifdef JP
649 info[i++] = "¤½¤ì¤ÏËâË¡¤ÎÆñ°×ÅÙ¤ò¾å¤²¤ë¡£";
650 #else
651                 info[i++] = "It interferes with casting spells.";
652 #endif
653         }
654
655         if (o_ptr->name2 == EGO_RING_THROW)
656         {
657 #ifdef JP
658 info[i++] = "¤½¤ì¤Ïʪ¤ò¶¯¤¯Åꤲ¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë¡£";
659 #else
660                 info[i++] = "It provides great strength when you throw an item.";
661 #endif
662         }
663
664         if (o_ptr->name2 == EGO_AMU_NAIVETY)
665         {
666 #ifdef JP
667 info[i++] = "¤½¤ì¤ÏËâË¡Äñ¹³ÎϤò²¼¤²¤ë¡£";
668 #else
669                 info[i++] = "It decreases your magic resistance.";
670 #endif
671         }
672
673         if (o_ptr->tval == TV_STATUE)
674         {
675                 monster_race *r_ptr = &r_info[o_ptr->pval];
676
677                 if (o_ptr->pval == MON_BULLGATES)
678 #ifdef JP
679                         info[i++] = "¤½¤ì¤ÏÉô²°¤Ë¾þ¤ë¤ÈÃѤº¤«¤·¤¤¡£";
680 #else
681                         info[i++] = "It is shameful.";
682 #endif
683                 else if ( r_ptr->flags2 & (RF2_ELDRITCH_HORROR))
684 #ifdef JP
685                         info[i++] = "¤½¤ì¤ÏÉô²°¤Ë¾þ¤ë¤È¶²¤¤¡£";
686 #else
687                 info[i++] = "It is fearful.";
688 #endif
689                 else
690 #ifdef JP
691                         info[i++] = "¤½¤ì¤ÏÉô²°¤Ë¾þ¤ë¤È³Ú¤·¤¤¡£";
692 #else
693                 info[i++] = "It is cheerful.";
694 #endif
695         }
696         
697         /* Hack -- describe lite's */
698         
699         if (o_ptr->name2 == EGO_LITE_DARKNESS) info[i++] = _("¤½¤ì¤ÏÁ´¤¯¸÷¤é¤Ê¤¤¡£", "It provides no light.");
700         
701         rad = 0;
702         if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
703         if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
704         if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
705         if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
706         if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
707         if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
708         
709         if(o_ptr->name2 == EGO_LITE_SHINE) rad++;
710                 
711         if (have_flag(flgs, TR_LITE_FUEL) && o_ptr->name2 != EGO_LITE_DARKNESS)
712         {
713                 if(rad > 0) sprintf(desc, _("¤½¤ì¤ÏdzÎÁÊäµë¤Ë¤è¤Ã¤ÆÌÀ¤«¤ê(Ⱦ·Â %d)¤ò¼ø¤±¤ë¡£", "It provides light (radius %d) when fueled."), rad);     
714         }
715         else
716         {
717                 if(rad > 0) sprintf(desc, _("¤½¤ì¤Ï±Ê±ó¤Ê¤ëÌÀ¤«¤ê(Ⱦ·Â %d)¤ò¼ø¤±¤ë¡£", "It provides light (radius %d) forever."), rad); 
718                 if(rad < 0) sprintf(desc, _("¤½¤ì¤ÏÌÀ¤«¤ê¤ÎȾ·Â¤ò¶¹¤á¤ë(Ⱦ·Â¤Ë-%d)¡£", "It decreases radius of light source by %d."), -rad);
719         }
720         
721         if(rad != 0) info[i++] = desc;
722
723         
724         if (o_ptr->name2 == EGO_LITE_LONG)
725         {
726                 info[i++] = _("¤½¤ì¤ÏŤ¤¥¿¡¼¥óÌÀ¤«¤ê¤ò¼ø¤±¤ë¡£", "It provides light for much longer time.");
727         }
728
729         /* And then describe it fully */
730
731         if (have_flag(flgs, TR_RIDING))
732         {
733                 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
734 #ifdef JP
735 info[i++] = "¤½¤ì¤Ï¾èÇÏÃæ¤ÏÈó¾ï¤Ë»È¤¤¤ä¤¹¤¤¡£";
736 #else
737                         info[i++] = "It is made for use while riding.";
738 #endif
739                 else
740                 {
741 #ifdef JP
742                         info[i++] = "¤½¤ì¤Ï¾èÇÏÃæ¤Ç¤â»È¤¤¤ä¤¹¤¤¡£";
743 #else
744                         info[i++] = "It is suitable for use while riding.";
745 #endif
746                         /* This information is not important enough */
747                         trivial_info++;
748                 }
749         }
750         if (have_flag(flgs, TR_STR))
751         {
752 #ifdef JP
753 info[i++] = "¤½¤ì¤ÏÏÓÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
754 #else
755                 info[i++] = "It affects your strength.";
756 #endif
757
758         }
759         if (have_flag(flgs, TR_INT))
760         {
761 #ifdef JP
762 info[i++] = "¤½¤ì¤ÏÃÎǽ¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¡£";
763 #else
764                 info[i++] = "It affects your intelligence.";
765 #endif
766
767         }
768         if (have_flag(flgs, TR_WIS))
769         {
770 #ifdef JP
771 info[i++] = "¤½¤ì¤Ï¸­¤µ¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¡£";
772 #else
773                 info[i++] = "It affects your wisdom.";
774 #endif
775
776         }
777         if (have_flag(flgs, TR_DEX))
778         {
779 #ifdef JP
780 info[i++] = "¤½¤ì¤Ï´ïÍѤµ¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¡£";
781 #else
782                 info[i++] = "It affects your dexterity.";
783 #endif
784
785         }
786         if (have_flag(flgs, TR_CON))
787         {
788 #ifdef JP
789 info[i++] = "¤½¤ì¤ÏÂѵ×ÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
790 #else
791                 info[i++] = "It affects your constitution.";
792 #endif
793
794         }
795         if (have_flag(flgs, TR_CHR))
796         {
797 #ifdef JP
798 info[i++] = "¤½¤ì¤ÏÌ¥ÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
799 #else
800                 info[i++] = "It affects your charisma.";
801 #endif
802
803         }
804
805         if (have_flag(flgs, TR_MAGIC_MASTERY))
806         {
807 #ifdef JP
808 info[i++] = "¤½¤ì¤ÏËâË¡Æ»¶ñ»ÈÍÑǽÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
809 #else
810                 info[i++] = "It affects your ability to use magic devices.";
811 #endif
812
813         }
814         if (have_flag(flgs, TR_STEALTH))
815         {
816 #ifdef JP
817 info[i++] = "¤½¤ì¤Ï±£Ì©¹ÔưǽÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
818 #else
819                 info[i++] = "It affects your stealth.";
820 #endif
821
822         }
823         if (have_flag(flgs, TR_SEARCH))
824         {
825 #ifdef JP
826 info[i++] = "¤½¤ì¤Ïõº÷ǽÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
827 #else
828                 info[i++] = "It affects your searching.";
829 #endif
830
831         }
832         if (have_flag(flgs, TR_INFRA))
833         {
834 #ifdef JP
835 info[i++] = "¤½¤ì¤ÏÀÖ³°Àþ»ëÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
836 #else
837                 info[i++] = "It affects your infravision.";
838 #endif
839
840         }
841         if (have_flag(flgs, TR_TUNNEL))
842         {
843 #ifdef JP
844 info[i++] = "¤½¤ì¤ÏºÎ·¡Ç½ÎϤ˱ƶÁ¤òµÚ¤Ü¤¹¡£";
845 #else
846                 info[i++] = "It affects your ability to tunnel.";
847 #endif
848
849         }
850         if (have_flag(flgs, TR_SPEED))
851         {
852 #ifdef JP
853 info[i++] = "¤½¤ì¤Ï¥¹¥Ô¡¼¥É¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¡£";
854 #else
855                 info[i++] = "It affects your speed.";
856 #endif
857
858         }
859         if (have_flag(flgs, TR_BLOWS))
860         {
861 #ifdef JP
862 info[i++] = "¤½¤ì¤ÏÂÇ·â²ó¿ô¤Ë±Æ¶Á¤òµÚ¤Ü¤¹¡£";
863 #else
864                 info[i++] = "It affects your attack speed.";
865 #endif
866
867         }
868
869         if (have_flag(flgs, TR_BRAND_ACID))
870         {
871 #ifdef JP
872 info[i++] = "¤½¤ì¤Ï»À¤Ë¤è¤Ã¤ÆÂ礭¤Ê¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¡£";
873 #else
874                 info[i++] = "It does extra damage from acid.";
875 #endif
876
877         }
878         if (have_flag(flgs, TR_BRAND_ELEC))
879         {
880 #ifdef JP
881 info[i++] = "¤½¤ì¤ÏÅÅ·â¤Ë¤è¤Ã¤ÆÂ礭¤Ê¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¡£";
882 #else
883                 info[i++] = "It does extra damage from electricity.";
884 #endif
885
886         }
887         if (have_flag(flgs, TR_BRAND_FIRE))
888         {
889 #ifdef JP
890 info[i++] = "¤½¤ì¤Ï²Ð±ê¤Ë¤è¤Ã¤ÆÂ礭¤Ê¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¡£";
891 #else
892                 info[i++] = "It does extra damage from fire.";
893 #endif
894
895         }
896         if (have_flag(flgs, TR_BRAND_COLD))
897         {
898 #ifdef JP
899 info[i++] = "¤½¤ì¤ÏÎ䵤¤Ë¤è¤Ã¤ÆÂ礭¤Ê¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¡£";
900 #else
901                 info[i++] = "It does extra damage from frost.";
902 #endif
903
904         }
905
906         if (have_flag(flgs, TR_BRAND_POIS))
907         {
908 #ifdef JP
909 info[i++] = "¤½¤ì¤ÏŨ¤òÆǤ¹¤ë¡£";
910 #else
911                 info[i++] = "It poisons your foes.";
912 #endif
913
914         }
915
916         if (have_flag(flgs, TR_CHAOTIC))
917         {
918 #ifdef JP
919 info[i++] = "¤½¤ì¤Ï¥«¥ª¥¹Åª¤Ê¸ú²Ì¤òµÚ¤Ü¤¹¡£";
920 #else
921                 info[i++] = "It produces chaotic effects.";
922 #endif
923
924         }
925
926         if (have_flag(flgs, TR_VAMPIRIC))
927         {
928 #ifdef JP
929 info[i++] = "¤½¤ì¤ÏŨ¤«¤é¥Ò¥Ã¥È¥Ý¥¤¥ó¥È¤òµÛ¼ý¤¹¤ë¡£";
930 #else
931                 info[i++] = "It drains life from your foes.";
932 #endif
933
934         }
935
936         if (have_flag(flgs, TR_IMPACT))
937         {
938 #ifdef JP
939 info[i++] = "¤½¤ì¤ÏÃϿ̤òµ¯¤³¤¹¤³¤È¤¬¤Ç¤­¤ë¡£";
940 #else
941                 info[i++] = "It can cause earthquakes.";
942 #endif
943
944         }
945
946         if (have_flag(flgs, TR_VORPAL))
947         {
948 #ifdef JP
949 info[i++] = "¤½¤ì¤ÏÈó¾ï¤ËÀÚ¤ìÌ£¤¬±Ô¤¯Å¨¤òÀÚÃǤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£";
950 #else
951                 info[i++] = "It is very sharp and can cut your foes.";
952 #endif
953
954         }
955
956         if (have_flag(flgs, TR_KILL_DRAGON))
957         {
958 #ifdef JP
959 info[i++] = "¤½¤ì¤Ï¥É¥é¥´¥ó¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
960 #else
961                 info[i++] = "It is a great bane of dragons.";
962 #endif
963
964         }
965         else if (have_flag(flgs, TR_SLAY_DRAGON))
966         {
967 #ifdef JP
968 info[i++] = "¤½¤ì¤Ï¥É¥é¥´¥ó¤ËÂФ·¤ÆÆä˶²¤ë¤Ù¤­ÎϤòȯ´ø¤¹¤ë¡£";
969 #else
970                 info[i++] = "It is especially deadly against dragons.";
971 #endif
972
973         }
974
975         if (have_flag(flgs, TR_KILL_ORC))
976         {
977 #ifdef JP
978 info[i++] = "¤½¤ì¤Ï¥ª¡¼¥¯¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
979 #else
980                 info[i++] = "It is a great bane of orcs.";
981 #endif
982
983         }
984         if (have_flag(flgs, TR_SLAY_ORC))
985         {
986 #ifdef JP
987 info[i++] = "¤½¤ì¤Ï¥ª¡¼¥¯¤ËÂФ·¤ÆÆä˶²¤ë¤Ù¤­ÎϤòȯ´ø¤¹¤ë¡£";
988 #else
989                 info[i++] = "It is especially deadly against orcs.";
990 #endif
991
992         }
993
994         if (have_flag(flgs, TR_KILL_TROLL))
995         {
996 #ifdef JP
997 info[i++] = "¤½¤ì¤Ï¥È¥í¥ë¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
998 #else
999                 info[i++] = "It is a great bane of trolls.";
1000 #endif
1001
1002         }
1003         if (have_flag(flgs, TR_SLAY_TROLL))
1004         {
1005 #ifdef JP
1006 info[i++] = "¤½¤ì¤Ï¥È¥í¥ë¤ËÂФ·¤ÆÆä˶²¤ë¤Ù¤­ÎϤòȯ´ø¤¹¤ë¡£";
1007 #else
1008                 info[i++] = "It is especially deadly against trolls.";
1009 #endif
1010
1011         }
1012
1013         if (have_flag(flgs, TR_KILL_GIANT))
1014         {
1015 #ifdef JP
1016 info[i++] = "¤½¤ì¤Ïµð¿Í¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
1017 #else
1018                 info[i++] = "It is a great bane of giants.";
1019 #endif
1020         }
1021         else if (have_flag(flgs, TR_SLAY_GIANT))
1022         {
1023 #ifdef JP
1024 info[i++] = "¤½¤ì¤Ï¥¸¥ã¥¤¥¢¥ó¥È¤ËÂФ·¤ÆÆä˶²¤ë¤Ù¤­ÎϤòȯ´ø¤¹¤ë¡£";
1025 #else
1026                 info[i++] = "It is especially deadly against giants.";
1027 #endif
1028
1029         }
1030
1031         if (have_flag(flgs, TR_KILL_DEMON))
1032         {
1033 #ifdef JP
1034 info[i++] = "¤½¤ì¤Ï¥Ç¡¼¥â¥ó¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
1035 #else
1036                 info[i++] = "It is a great bane of demons.";
1037 #endif
1038
1039         }
1040         if (have_flag(flgs, TR_SLAY_DEMON))
1041         {
1042 #ifdef JP
1043 info[i++] = "¤½¤ì¤Ï¥Ç¡¼¥â¥ó¤ËÂФ·¤ÆÀ»¤Ê¤ëÎϤòȯ´ø¤¹¤ë¡£";
1044 #else
1045                 info[i++] = "It strikes at demons with holy wrath.";
1046 #endif
1047
1048         }
1049
1050         if (have_flag(flgs, TR_KILL_UNDEAD))
1051         {
1052 #ifdef JP
1053 info[i++] = "¤½¤ì¤Ï¥¢¥ó¥Ç¥Ã¥É¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
1054 #else
1055                 info[i++] = "It is a great bane of undead.";
1056 #endif
1057
1058         }
1059         if (have_flag(flgs, TR_SLAY_UNDEAD))
1060         {
1061 #ifdef JP
1062 info[i++] = "¤½¤ì¤Ï¥¢¥ó¥Ç¥Ã¥É¤ËÂФ·¤ÆÀ»¤Ê¤ëÎϤòȯ´ø¤¹¤ë¡£";
1063 #else
1064                 info[i++] = "It strikes at undead with holy wrath.";
1065 #endif
1066
1067         }
1068
1069         if (have_flag(flgs, TR_KILL_EVIL))
1070         {
1071 #ifdef JP
1072 info[i++] = "¤½¤ì¤Ï¼Ù°­¤Ê¤ë¸ºß¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
1073 #else
1074                 info[i++] = "It is a great bane of evil monsters.";
1075 #endif
1076
1077         }
1078         if (have_flag(flgs, TR_SLAY_EVIL))
1079         {
1080 #ifdef JP
1081 info[i++] = "¤½¤ì¤Ï¼Ù°­¤Ê¤ë¸ºß¤ËÂФ·¤ÆÀ»¤Ê¤ëÎϤǹ¶·â¤¹¤ë¡£";
1082 #else
1083                 info[i++] = "It fights against evil with holy fury.";
1084 #endif
1085
1086         }
1087
1088         if (have_flag(flgs, TR_KILL_ANIMAL))
1089         {
1090 #ifdef JP
1091 info[i++] = "¤½¤ì¤Ï¼«Á³³¦¤Îưʪ¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
1092 #else
1093                 info[i++] = "It is a great bane of natural creatures.";
1094 #endif
1095
1096         }
1097         if (have_flag(flgs, TR_SLAY_ANIMAL))
1098         {
1099 #ifdef JP
1100 info[i++] = "¤½¤ì¤Ï¼«Á³³¦¤Îưʪ¤ËÂФ·¤ÆÆä˶²¤ë¤Ù¤­ÎϤòȯ´ø¤¹¤ë¡£";
1101 #else
1102                 info[i++] = "It is especially deadly against natural creatures.";
1103 #endif
1104
1105         }
1106
1107         if (have_flag(flgs, TR_KILL_HUMAN))
1108         {
1109 #ifdef JP
1110 info[i++] = "¤½¤ì¤Ï¿Í´Ö¤Ë¤È¤Ã¤Æ¤ÎŷŨ¤Ç¤¢¤ë¡£";
1111 #else
1112                 info[i++] = "It is a great bane of humans.";
1113 #endif
1114
1115         }
1116         if (have_flag(flgs, TR_SLAY_HUMAN))
1117         {
1118 #ifdef JP
1119 info[i++] = "¤½¤ì¤Ï¿Í´Ö¤ËÂФ·¤ÆÆä˶²¤ë¤Ù¤­ÎϤòȯ´ø¤¹¤ë¡£";
1120 #else
1121                 info[i++] = "It is especially deadly against humans.";
1122 #endif
1123
1124         }
1125
1126         if (have_flag(flgs, TR_FORCE_WEAPON))
1127         {
1128 #ifdef JP
1129 info[i++] = "¤½¤ì¤Ï»ÈÍѼԤÎËâÎϤò»È¤Ã¤Æ¹¶·â¤¹¤ë¡£";
1130 #else
1131                 info[i++] = "It powerfully strikes at a monster using your mana.";
1132 #endif
1133
1134         }
1135         if (have_flag(flgs, TR_DEC_MANA))
1136         {
1137 #ifdef JP
1138 info[i++] = "¤½¤ì¤ÏËâÎϤξÃÈñ¤ò²¡¤µ¤¨¤ë¡£";
1139 #else
1140                 info[i++] = "It decreases your mana consumption.";
1141 #endif
1142
1143         }
1144         if (have_flag(flgs, TR_SUST_STR))
1145         {
1146 #ifdef JP
1147 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤ÎÏÓÎϤò°Ý»ý¤¹¤ë¡£";
1148 #else
1149                 info[i++] = "It sustains your strength.";
1150 #endif
1151
1152         }
1153         if (have_flag(flgs, TR_SUST_INT))
1154         {
1155 #ifdef JP
1156 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤ÎÃÎǽ¤ò°Ý»ý¤¹¤ë¡£";
1157 #else
1158                 info[i++] = "It sustains your intelligence.";
1159 #endif
1160
1161         }
1162         if (have_flag(flgs, TR_SUST_WIS))
1163         {
1164 #ifdef JP
1165 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤Î¸­¤µ¤ò°Ý»ý¤¹¤ë¡£";
1166 #else
1167                 info[i++] = "It sustains your wisdom.";
1168 #endif
1169
1170         }
1171         if (have_flag(flgs, TR_SUST_DEX))
1172         {
1173 #ifdef JP
1174 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤Î´ïÍѤµ¤ò°Ý»ý¤¹¤ë¡£";
1175 #else
1176                 info[i++] = "It sustains your dexterity.";
1177 #endif
1178
1179         }
1180         if (have_flag(flgs, TR_SUST_CON))
1181         {
1182 #ifdef JP
1183 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤ÎÂѵ×ÎϤò°Ý»ý¤¹¤ë¡£";
1184 #else
1185                 info[i++] = "It sustains your constitution.";
1186 #endif
1187
1188         }
1189         if (have_flag(flgs, TR_SUST_CHR))
1190         {
1191 #ifdef JP
1192 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤ÎÌ¥ÎϤò°Ý»ý¤¹¤ë¡£";
1193 #else
1194                 info[i++] = "It sustains your charisma.";
1195 #endif
1196
1197         }
1198
1199         if (have_flag(flgs, TR_IM_ACID))
1200         {
1201 #ifdef JP
1202 info[i++] = "¤½¤ì¤Ï»À¤ËÂФ¹¤ë´°Á´¤ÊÌȱ֤ò¼ø¤±¤ë¡£";
1203 #else
1204                 info[i++] = "It provides immunity to acid.";
1205 #endif
1206
1207         }
1208         if (have_flag(flgs, TR_IM_ELEC))
1209         {
1210 #ifdef JP
1211 info[i++] = "¤½¤ì¤ÏÅÅ·â¤ËÂФ¹¤ë´°Á´¤ÊÌȱ֤ò¼ø¤±¤ë¡£";
1212 #else
1213                 info[i++] = "It provides immunity to electricity.";
1214 #endif
1215
1216         }
1217         if (have_flag(flgs, TR_IM_FIRE))
1218         {
1219 #ifdef JP
1220 info[i++] = "¤½¤ì¤Ï²Ð¤ËÂФ¹¤ë´°Á´¤ÊÌȱ֤ò¼ø¤±¤ë¡£";
1221 #else
1222                 info[i++] = "It provides immunity to fire.";
1223 #endif
1224
1225         }
1226         if (have_flag(flgs, TR_IM_COLD))
1227         {
1228 #ifdef JP
1229 info[i++] = "¤½¤ì¤Ï´¨¤µ¤ËÂФ¹¤ë´°Á´¤ÊÌȱ֤ò¼ø¤±¤ë¡£";
1230 #else
1231                 info[i++] = "It provides immunity to cold.";
1232 #endif
1233
1234         }
1235
1236         if (have_flag(flgs, TR_THROW))
1237         {
1238 #ifdef JP
1239 info[i++] = "¤½¤ì¤ÏŨ¤ËÅꤲ¤ÆÂ礭¤Ê¥À¥á¡¼¥¸¤òÍ¿¤¨¤ë¤³¤È¤¬¤Ç¤­¤ë¡£";
1240 #else
1241                 info[i++] = "It is perfectly balanced for throwing.";
1242 #endif
1243         }
1244
1245         if (have_flag(flgs, TR_FREE_ACT))
1246         {
1247 #ifdef JP
1248 info[i++] = "¤½¤ì¤ÏËãáã¤ËÂФ¹¤ë´°Á´¤ÊÌȱ֤ò¼ø¤±¤ë¡£";
1249 #else
1250                 info[i++] = "It provides immunity to paralysis.";
1251 #endif
1252
1253         }
1254         if (have_flag(flgs, TR_HOLD_LIFE))
1255         {
1256 #ifdef JP
1257 info[i++] = "¤½¤ì¤ÏÀ¸Ì¿Îϵۼý¤ËÂФ¹¤ëÂÑÀ­¤ò¼ø¤±¤ë¡£";
1258 #else
1259                 info[i++] = "It provides resistance to life draining.";
1260 #endif
1261
1262         }
1263         if (have_flag(flgs, TR_RES_FEAR))
1264         {
1265 #ifdef JP
1266 info[i++] = "¤½¤ì¤Ï¶²Éݤؤδ°Á´¤ÊÂÑÀ­¤ò¼ø¤±¤ë¡£";
1267 #else
1268                 info[i++] = "It makes you completely fearless.";
1269 #endif
1270
1271         }
1272         if (have_flag(flgs, TR_RES_ACID))
1273         {
1274 #ifdef JP
1275 info[i++] = "¤½¤ì¤Ï»À¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1276 #else
1277                 info[i++] = "It provides resistance to acid.";
1278 #endif
1279
1280         }
1281         if (have_flag(flgs, TR_RES_ELEC))
1282         {
1283 #ifdef JP
1284 info[i++] = "¤½¤ì¤ÏÅÅ·â¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1285 #else
1286                 info[i++] = "It provides resistance to electricity.";
1287 #endif
1288
1289         }
1290         if (have_flag(flgs, TR_RES_FIRE))
1291         {
1292 #ifdef JP
1293 info[i++] = "¤½¤ì¤Ï²Ð¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1294 #else
1295                 info[i++] = "It provides resistance to fire.";
1296 #endif
1297
1298         }
1299         if (have_flag(flgs, TR_RES_COLD))
1300         {
1301 #ifdef JP
1302 info[i++] = "¤½¤ì¤Ï´¨¤µ¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1303 #else
1304                 info[i++] = "It provides resistance to cold.";
1305 #endif
1306
1307         }
1308         if (have_flag(flgs, TR_RES_POIS))
1309         {
1310 #ifdef JP
1311 info[i++] = "¤½¤ì¤ÏÆǤؤÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1312 #else
1313                 info[i++] = "It provides resistance to poison.";
1314 #endif
1315
1316         }
1317
1318         if (have_flag(flgs, TR_RES_LITE))
1319         {
1320 #ifdef JP
1321 info[i++] = "¤½¤ì¤ÏÁ®¸÷¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1322 #else
1323                 info[i++] = "It provides resistance to light.";
1324 #endif
1325
1326         }
1327         if (have_flag(flgs, TR_RES_DARK))
1328         {
1329 #ifdef JP
1330 info[i++] = "¤½¤ì¤Ï°Å¹õ¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1331 #else
1332                 info[i++] = "It provides resistance to dark.";
1333 #endif
1334
1335         }
1336
1337         if (have_flag(flgs, TR_RES_BLIND))
1338         {
1339 #ifdef JP
1340 info[i++] = "¤½¤ì¤ÏÌÕÌܤؤÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1341 #else
1342                 info[i++] = "It provides resistance to blindness.";
1343 #endif
1344
1345         }
1346         if (have_flag(flgs, TR_RES_CONF))
1347         {
1348 #ifdef JP
1349 info[i++] = "¤½¤ì¤Ïº®Íð¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1350 #else
1351                 info[i++] = "It provides resistance to confusion.";
1352 #endif
1353
1354         }
1355         if (have_flag(flgs, TR_RES_SOUND))
1356         {
1357 #ifdef JP
1358 info[i++] = "¤½¤ì¤Ï¹ì²»¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1359 #else
1360                 info[i++] = "It provides resistance to sound.";
1361 #endif
1362
1363         }
1364         if (have_flag(flgs, TR_RES_SHARDS))
1365         {
1366 #ifdef JP
1367 info[i++] = "¤½¤ì¤ÏÇËÊҤؤÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1368 #else
1369                 info[i++] = "It provides resistance to shards.";
1370 #endif
1371
1372         }
1373
1374         if (have_flag(flgs, TR_RES_NETHER))
1375         {
1376 #ifdef JP
1377 info[i++] = "¤½¤ì¤ÏÃϹö¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1378 #else
1379                 info[i++] = "It provides resistance to nether.";
1380 #endif
1381
1382         }
1383         if (have_flag(flgs, TR_RES_NEXUS))
1384         {
1385 #ifdef JP
1386 info[i++] = "¤½¤ì¤Ï°ø²Ìº®Íð¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1387 #else
1388                 info[i++] = "It provides resistance to nexus.";
1389 #endif
1390
1391         }
1392         if (have_flag(flgs, TR_RES_CHAOS))
1393         {
1394 #ifdef JP
1395 info[i++] = "¤½¤ì¤Ï¥«¥ª¥¹¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1396 #else
1397                 info[i++] = "It provides resistance to chaos.";
1398 #endif
1399
1400         }
1401         if (have_flag(flgs, TR_RES_DISEN))
1402         {
1403 #ifdef JP
1404 info[i++] = "¤½¤ì¤ÏÎô²½¤Ø¤ÎÂÑÀ­¤ò¼ø¤±¤ë¡£";
1405 #else
1406                 info[i++] = "It provides resistance to disenchantment.";
1407 #endif
1408
1409         }
1410
1411         if (have_flag(flgs, TR_LEVITATION))
1412         {
1413 #ifdef JP
1414 info[i++] = "¤½¤ì¤ÏÃè¤ËÉ⤯¤³¤È¤ò²Äǽ¤Ë¤¹¤ë¡£";
1415 #else
1416                 info[i++] = "It allows you to levitate.";
1417 #endif
1418
1419         }
1420                 
1421         if (have_flag(flgs, TR_SEE_INVIS))
1422         {
1423                 info[i++] = _("¤½¤ì¤ÏÆ©ÌÀ¤Ê¥â¥ó¥¹¥¿¡¼¤ò¸«¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë¡£", "It allows you to see invisible monsters.");
1424         }
1425         if (have_flag(flgs, TR_TELEPATHY))
1426         {
1427 #ifdef JP
1428 info[i++] = "¤½¤ì¤Ï¥Æ¥ì¥Ñ¥·¡¼Ç½ÎϤò¼ø¤±¤ë¡£";
1429 #else
1430                 info[i++] = "It gives telepathic powers.";
1431 #endif
1432
1433         }
1434         if (have_flag(flgs, TR_ESP_ANIMAL))
1435         {
1436 #ifdef JP
1437 info[i++] = "¤½¤ì¤Ï¼«Á³³¦¤ÎÀ¸Êª¤ò´¶ÃΤ¹¤ë¡£";
1438 #else
1439                 info[i++] = "It senses natural creatures.";
1440 #endif
1441
1442         }
1443         if (have_flag(flgs, TR_ESP_UNDEAD))
1444         {
1445 #ifdef JP
1446 info[i++] = "¤½¤ì¤Ï¥¢¥ó¥Ç¥Ã¥É¤ò´¶ÃΤ¹¤ë¡£";
1447 #else
1448                 info[i++] = "It senses undead.";
1449 #endif
1450
1451         }
1452         if (have_flag(flgs, TR_ESP_DEMON))
1453         {
1454 #ifdef JP
1455 info[i++] = "¤½¤ì¤Ï°­Ëâ¤ò´¶ÃΤ¹¤ë¡£";
1456 #else
1457                 info[i++] = "It senses demons.";
1458 #endif
1459
1460         }
1461         if (have_flag(flgs, TR_ESP_ORC))
1462         {
1463 #ifdef JP
1464 info[i++] = "¤½¤ì¤Ï¥ª¡¼¥¯¤ò´¶ÃΤ¹¤ë¡£";
1465 #else
1466                 info[i++] = "It senses orcs.";
1467 #endif
1468
1469         }
1470         if (have_flag(flgs, TR_ESP_TROLL))
1471         {
1472 #ifdef JP
1473 info[i++] = "¤½¤ì¤Ï¥È¥í¥ë¤ò´¶ÃΤ¹¤ë¡£";
1474 #else
1475                 info[i++] = "It senses trolls.";
1476 #endif
1477
1478         }
1479         if (have_flag(flgs, TR_ESP_GIANT))
1480         {
1481 #ifdef JP
1482 info[i++] = "¤½¤ì¤Ïµð¿Í¤ò´¶ÃΤ¹¤ë¡£";
1483 #else
1484                 info[i++] = "It senses giants.";
1485 #endif
1486
1487         }
1488         if (have_flag(flgs, TR_ESP_DRAGON))
1489         {
1490 #ifdef JP
1491 info[i++] = "¤½¤ì¤Ï¥É¥é¥´¥ó¤ò´¶ÃΤ¹¤ë¡£";
1492 #else
1493                 info[i++] = "It senses dragons.";
1494 #endif
1495
1496         }
1497         if (have_flag(flgs, TR_ESP_HUMAN))
1498         {
1499 #ifdef JP
1500 info[i++] = "¤½¤ì¤Ï¿Í´Ö¤ò´¶ÃΤ¹¤ë¡£";
1501 #else
1502                 info[i++] = "It senses humans.";
1503 #endif
1504
1505         }
1506         if (have_flag(flgs, TR_ESP_EVIL))
1507         {
1508 #ifdef JP
1509 info[i++] = "¤½¤ì¤Ï¼Ù°­¤Ê¸ºß¤ò´¶ÃΤ¹¤ë¡£";
1510 #else
1511                 info[i++] = "It senses evil creatures.";
1512 #endif
1513
1514         }
1515         if (have_flag(flgs, TR_ESP_GOOD))
1516         {
1517 #ifdef JP
1518 info[i++] = "¤½¤ì¤ÏÁ±Îɤʸºß¤ò´¶ÃΤ¹¤ë¡£";
1519 #else
1520                 info[i++] = "It senses good creatures.";
1521 #endif
1522
1523         }
1524         if (have_flag(flgs, TR_ESP_NONLIVING))
1525         {
1526 #ifdef JP
1527 info[i++] = "¤½¤ì¤Ï³èÆ°¤¹¤ë̵À¸ÊªÂΤò´¶ÃΤ¹¤ë¡£";
1528 #else
1529                 info[i++] = "It senses non-living creatures.";
1530 #endif
1531
1532         }
1533         if (have_flag(flgs, TR_ESP_UNIQUE))
1534         {
1535 #ifdef JP
1536 info[i++] = "¤½¤ì¤ÏÆÃÊ̤ʶ¯Å¨¤ò´¶ÃΤ¹¤ë¡£";
1537 #else
1538                 info[i++] = "It senses unique monsters.";
1539 #endif
1540
1541         }
1542         if (have_flag(flgs, TR_SLOW_DIGEST))
1543         {
1544 #ifdef JP
1545 info[i++] = "¤½¤ì¤Ï¤¢¤Ê¤¿¤Î¿·ÄÄÂå¼Õ¤òÃÙ¤¯¤¹¤ë¡£";
1546 #else
1547                 info[i++] = "It slows your metabolism.";
1548 #endif
1549
1550         }
1551         if (have_flag(flgs, TR_REGEN))
1552         {
1553 #ifdef JP
1554 info[i++] = "¤½¤ì¤ÏÂÎÎϲóÉüÎϤò¶¯²½¤¹¤ë¡£";
1555 #else
1556                 info[i++] = "It speeds your regenerative powers.";
1557 #endif
1558
1559         }
1560         if (have_flag(flgs, TR_WARNING))
1561         {
1562 #ifdef JP
1563 info[i++] = "¤½¤ì¤Ï´í¸±¤ËÂФ·¤Æ·Ù¹ð¤òȯ¤¹¤ë¡£";
1564 #else
1565                 info[i++] = "It warns you of danger";
1566 #endif
1567
1568         }
1569         if (have_flag(flgs, TR_REFLECT))
1570         {
1571                 info[i++] = _("¤½¤ì¤ÏÌð¤Î¼öʸ¤òÈ¿¼Í¤¹¤ë¡£", "It reflects bolt spells.");
1572         }
1573         if (have_flag(flgs, TR_SH_FIRE))
1574         {
1575                 info[i++] = _("¤½¤ì¤Ï±ê¤Î¥Ð¥ê¥¢¤òÄ¥¤ë¡£", "It produces a fiery sheath.");
1576         }
1577         if (have_flag(flgs, TR_SH_ELEC))
1578         {
1579                 info[i++] = _("¤½¤ì¤ÏÅŵ¤¤Î¥Ð¥ê¥¢¤òÄ¥¤ë¡£", "It produces an electric sheath.");
1580         }
1581         if (have_flag(flgs, TR_SH_COLD))
1582         {
1583 #ifdef JP
1584 info[i++] = "¤½¤ì¤ÏÎ䵤¤Î¥Ð¥ê¥¢¤òÄ¥¤ë¡£";
1585 #else
1586                 info[i++] = "It produces a sheath of coldness.";
1587 #endif
1588
1589         }
1590         if (have_flag(flgs, TR_NO_MAGIC))
1591         {
1592 #ifdef JP
1593 info[i++] = "¤½¤ì¤ÏÈ¿ËâË¡¥Ð¥ê¥¢¤òÄ¥¤ë¡£";
1594 #else
1595                 info[i++] = "It produces an anti-magic shell.";
1596 #endif
1597
1598         }
1599         if (have_flag(flgs, TR_NO_TELE))
1600         {
1601 #ifdef JP
1602 info[i++] = "¤½¤ì¤Ï¥Æ¥ì¥Ý¡¼¥È¤ò¼ÙË⤹¤ë¡£";
1603 #else
1604                 info[i++] = "It prevents teleportation.";
1605 #endif
1606
1607         }
1608         if (have_flag(flgs, TR_XTRA_MIGHT))
1609         {
1610 #ifdef JP
1611 info[i++] = "¤½¤ì¤ÏÌ𡿥ܥë¥È¡¿ÃƤò¤è¤ê¶¯ÎϤËȯ¼Í¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£";
1612 #else
1613                 info[i++] = "It fires missiles with extra might.";
1614 #endif
1615
1616         }
1617         if (have_flag(flgs, TR_XTRA_SHOTS))
1618         {
1619 #ifdef JP
1620 info[i++] = "¤½¤ì¤ÏÌ𡿥ܥë¥È¡¿ÃƤòÈó¾ï¤ËÁ᤯ȯ¼Í¤¹¤ë¤³¤È¤¬¤Ç¤­¤ë¡£";
1621 #else
1622                 info[i++] = "It fires missiles excessively fast.";
1623 #endif
1624
1625         }
1626
1627         if (have_flag(flgs, TR_BLESSED))
1628         {
1629 #ifdef JP
1630 info[i++] = "¤½¤ì¤Ï¿À¤Ë½ËÊ¡¤µ¤ì¤Æ¤¤¤ë¡£";
1631 #else
1632                 info[i++] = "It has been blessed by the gods.";
1633 #endif
1634
1635         }
1636
1637         if (object_is_cursed(o_ptr))
1638         {
1639                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1640                 {
1641 #ifdef JP
1642 info[i++] = "¤½¤ì¤Ï±Ê±ó¤Î¼ö¤¤¤¬¤«¤±¤é¤ì¤Æ¤¤¤ë¡£";
1643 #else
1644                         info[i++] = "It is permanently cursed.";
1645 #endif
1646
1647                 }
1648                 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1649                 {
1650 #ifdef JP
1651 info[i++] = "¤½¤ì¤Ï¶¯ÎϤʼö¤¤¤¬¤«¤±¤é¤ì¤Æ¤¤¤ë¡£";
1652 #else
1653                         info[i++] = "It is heavily cursed.";
1654 #endif
1655
1656                 }
1657                 else
1658                 {
1659 #ifdef JP
1660 info[i++] = "¤½¤ì¤Ï¼ö¤ï¤ì¤Æ¤¤¤ë¡£";
1661 #else
1662                         info[i++] = "It is cursed.";
1663 #endif
1664
1665                         /*
1666                          * It's a trivial infomation since there is
1667                          * fake inscription {cursed}
1668                          */
1669                         trivial_info++;
1670                 }
1671         }
1672
1673         if ((have_flag(flgs, TR_TY_CURSE)) || (o_ptr->curse_flags & TRC_TY_CURSE))
1674         {
1675                 info[i++] = _("¤½¤ì¤ÏÂÀ¸Å¤Î²Ò¡¹¤·¤¤±åÇ°¤¬½É¤Ã¤Æ¤¤¤ë¡£", "It carries an ancient foul curse.");
1676         }
1677         if ((have_flag(flgs, TR_AGGRAVATE)) || (o_ptr->curse_flags & TRC_AGGRAVATE))
1678         {
1679                 info[i++] = _("¤½¤ì¤ÏÉÕ¶á¤Î¥â¥ó¥¹¥¿¡¼¤òÅܤ餻¤ë¡£", "It aggravates nearby creatures.");
1680         }
1681         if ((have_flag(flgs, TR_DRAIN_EXP)) || (o_ptr->curse_flags & TRC_DRAIN_EXP))
1682         {
1683                 info[i++] = _("¤½¤ì¤Ï·Ð¸³ÃͤòµÛ¤¤¼è¤ë¡£", "It drains experience.");
1684         }
1685         if (o_ptr->curse_flags & TRC_SLOW_REGEN)
1686         {
1687                 info[i++] = _("¤½¤ì¤Ï²óÉüÎϤò¼å¤á¤ë¡£", "It slows your regenerative powers.");
1688         }
1689         if ((o_ptr->curse_flags & TRC_ADD_L_CURSE) || have_flag(flgs, TR_ADD_L_CURSE))
1690         {
1691                 info[i++] = _("¤½¤ì¤Ï¼å¤¤¼ö¤¤¤òÁý¤ä¤¹¡£","It adds weak curses.");
1692         }
1693         if ((o_ptr->curse_flags & TRC_ADD_H_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
1694         {
1695                 info[i++] = _("¤½¤ì¤Ï¶¯ÎϤʼö¤¤¤òÁý¤ä¤¹¡£","It adds heavy curses.");
1696         }
1697         if ((have_flag(flgs, TR_CALL_ANIMAL)) || (o_ptr->curse_flags & TRC_CALL_ANIMAL))
1698         {
1699                 info[i++] = _("¤½¤ì¤Ïưʪ¤ò¸Æ¤Ó´ó¤»¤ë¡£", "It attracts animals.");
1700         }
1701         if ((have_flag(flgs, TR_CALL_DEMON)) || (o_ptr->curse_flags & TRC_CALL_DEMON))
1702         {
1703                 info[i++] = _("¤½¤ì¤Ï°­Ëâ¤ò¸Æ¤Ó´ó¤»¤ë¡£", "It attracts demons.");
1704         }
1705         if ((have_flag(flgs, TR_CALL_DRAGON)) || (o_ptr->curse_flags & TRC_CALL_DRAGON))
1706         {
1707                 info[i++] = _("¤½¤ì¤Ï¥É¥é¥´¥ó¤ò¸Æ¤Ó´ó¤»¤ë¡£", "It attracts dragons.");
1708         }
1709         if ((have_flag(flgs, TR_CALL_UNDEAD)) || (o_ptr->curse_flags & TRC_CALL_UNDEAD))
1710         {
1711                 info[i++] = _("¤½¤ì¤Ï»àÎî¤ò¸Æ¤Ó´ó¤»¤ë¡£", "It attracts undeads.");
1712         }
1713         if ((have_flag(flgs, TR_COWARDICE)) ||  (o_ptr->curse_flags & TRC_COWARDICE))
1714         {
1715                 info[i++] = _("¤½¤ì¤Ï¶²ÉÝ´¶¤ò°ú¤­µ¯¤³¤¹¡£", "It makes you subject to cowardice.");
1716         }
1717         if ((have_flag(flgs, TR_TELEPORT)) || (o_ptr->curse_flags & TRC_TELEPORT))
1718         {
1719                 info[i++] = _("¤½¤ì¤Ï¥é¥ó¥À¥à¤Ê¥Æ¥ì¥Ý¡¼¥È¤ò°ú¤­µ¯¤³¤¹¡£", "It induces random teleportation.");
1720         }
1721         if ((have_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags & TRC_LOW_MELEE)
1722         {
1723                 info[i++] = _("¤½¤ì¤Ï¹¶·â¤ò³°¤·¤ä¤¹¤¤¡£", "It causes you to miss blows.");
1724         }
1725         if ((have_flag(flgs, TR_LOW_AC)) || (o_ptr->curse_flags & TRC_LOW_AC))
1726         {
1727                 info[i++] = _("¤½¤ì¤Ï¹¶·â¤ò¼õ¤±¤ä¤¹¤¤¡£", "It helps your enemies' blows.");
1728         }
1729         if ((have_flag(flgs, TR_LOW_MAGIC)) || (o_ptr->curse_flags & TRC_LOW_MAGIC))
1730         {
1731                 info[i++] = _("¤½¤ì¤ÏËâË¡¤ò¾§¤¨¤Ë¤¯¤¯¤¹¤ë¡£", "It encumbers you while spellcasting.");
1732         }
1733         if ((have_flag(flgs, TR_FAST_DIGEST)) || (o_ptr->curse_flags & TRC_FAST_DIGEST))
1734         {
1735                 info[i++] = _("¤½¤ì¤Ï¤¢¤Ê¤¿¤Î¿·ÄÄÂå¼Õ¤ò®¤¯¤¹¤ë¡£", "It speeds your metabolism.");
1736         }
1737         if ((have_flag(flgs, TR_DRAIN_HP)) || (o_ptr->curse_flags & TRC_DRAIN_HP))
1738         {
1739                 info[i++] = _("¤½¤ì¤Ï¤¢¤Ê¤¿¤ÎÂÎÎϤòµÛ¤¤¼è¤ë¡£", "It drains you.");
1740         }
1741         if ((have_flag(flgs, TR_DRAIN_MANA)) || (o_ptr->curse_flags & TRC_DRAIN_MANA))
1742         {
1743                 info[i++] = _("¤½¤ì¤Ï¤¢¤Ê¤¿¤ÎËâÎϤòµÛ¤¤¼è¤ë¡£", "It drains your mana.");
1744         }
1745
1746         /* Describe about this kind of object instead of THIS fake object */
1747         if (mode & SCROBJ_FAKE_OBJECT)
1748         {
1749                 switch (o_ptr->tval)
1750                 {
1751                 case TV_RING:
1752                         switch (o_ptr->sval)
1753                         {
1754                         case SV_RING_LORDLY:
1755 #ifdef JP
1756                                 info[i++] = "¤½¤ì¤Ï´ö¤Ä¤«¤Î¥é¥ó¥À¥à¤ÊÂÑÀ­¤ò¼ø¤±¤ë¡£";
1757 #else
1758                                 info[i++] = "It provides some random resistances.";
1759 #endif
1760                                 break;
1761                         case SV_RING_WARNING:
1762 #ifdef JP
1763                                 info[i++] = "¤½¤ì¤Ï¤Ò¤È¤Ä¤ÎÄãµé¤ÊESP¤ò¼ø¤±¤ë»ö¤¬¤¢¤ë¡£";
1764 #else
1765                                 info[i++] = "It may provide a low rank ESP.";
1766 #endif
1767                                 break;
1768                         }
1769                         break;
1770
1771                 case TV_AMULET:
1772                         switch (o_ptr->sval)
1773                         {
1774                         case SV_AMULET_RESISTANCE:
1775 #ifdef JP
1776                                 info[i++] = "¤½¤ì¤ÏÆǤؤÎÂÑÀ­¤ò¼ø¤±¤ë»ö¤¬¤¢¤ë¡£";
1777 #else
1778                                 info[i++] = "It may provides resistance to poison.";
1779 #endif
1780 #ifdef JP
1781                                 info[i++] = "¤½¤ì¤Ï¥é¥ó¥À¥à¤ÊÂÑÀ­¤ò¼ø¤±¤ë»ö¤¬¤¢¤ë¡£";
1782 #else
1783                                 info[i++] = "It may provide a random resistances.";
1784 #endif
1785                                 break;
1786                         case SV_AMULET_THE_MAGI:
1787 #ifdef JP
1788                                 info[i++] = "¤½¤ì¤ÏºÇÂç¤Ç£³¤Ä¤Þ¤Ç¤ÎÄãµé¤ÊESP¤ò¼ø¤±¤ë¡£";
1789 #else
1790                                 info[i++] = "It provides up to three low rank ESPs.";
1791 #endif
1792                                 break;
1793                         }
1794                         break;
1795                 }
1796         }
1797
1798         if (have_flag(flgs, TR_IGNORE_ACID) &&
1799             have_flag(flgs, TR_IGNORE_ELEC) &&
1800             have_flag(flgs, TR_IGNORE_FIRE) &&
1801             have_flag(flgs, TR_IGNORE_COLD))
1802         {
1803 #ifdef JP
1804                 info[i++] = "¤½¤ì¤Ï»À¡¦Åŷ⡦²Ð±ê¡¦Î䵤¤Ç¤Ï½ý¤Ä¤«¤Ê¤¤¡£";
1805 #else
1806                 info[i++] = "It cannot be harmed by the elements.";
1807 #endif
1808         }
1809         else
1810         {
1811                 if (have_flag(flgs, TR_IGNORE_ACID))
1812                 {
1813 #ifdef JP
1814                         info[i++] = "¤½¤ì¤Ï»À¤Ç¤Ï½ý¤Ä¤«¤Ê¤¤¡£";
1815 #else
1816                         info[i++] = "It cannot be harmed by acid.";
1817 #endif
1818                 }
1819                 if (have_flag(flgs, TR_IGNORE_ELEC))
1820                 {
1821 #ifdef JP
1822                         info[i++] = "¤½¤ì¤ÏÅÅ·â¤Ç¤Ï½ý¤Ä¤«¤Ê¤¤¡£";
1823 #else
1824                         info[i++] = "It cannot be harmed by electricity.";
1825 #endif
1826                 }
1827                 if (have_flag(flgs, TR_IGNORE_FIRE))
1828                 {
1829 #ifdef JP
1830                         info[i++] = "¤½¤ì¤Ï²Ð±ê¤Ç¤Ï½ý¤Ä¤«¤Ê¤¤¡£";
1831 #else
1832                         info[i++] = "It cannot be harmed by fire.";
1833 #endif
1834                 }
1835                 if (have_flag(flgs, TR_IGNORE_COLD))
1836                 {
1837 #ifdef JP
1838                         info[i++] = "¤½¤ì¤ÏÎ䵤¤Ç¤Ï½ý¤Ä¤«¤Ê¤¤¡£";
1839 #else
1840                         info[i++] = "It cannot be harmed by cold.";
1841 #endif
1842                 }
1843         }
1844
1845         if (mode & SCROBJ_FORCE_DETAIL) trivial_info = 0;
1846
1847         /* No relevant informations */
1848         if (i <= trivial_info) return (FALSE);
1849
1850         /* Save the screen */
1851         screen_save();
1852
1853         /* Get size */
1854         Term_get_size(&wid, &hgt);
1855
1856         /* Display Item name */
1857         if (!(mode & SCROBJ_FAKE_OBJECT))
1858                 object_desc(o_name, o_ptr, 0);
1859         else
1860                 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1861
1862         prt(o_name, 0, 0);
1863
1864         /* Erase the screen */
1865         for (k = 1; k < hgt; k++) prt("", k, 13);
1866
1867         /* Label the information */
1868         if ((o_ptr->tval == TV_STATUE) && (o_ptr->sval == SV_PHOTO))
1869         {
1870                 monster_race *r_ptr = &r_info[o_ptr->pval];
1871                 int namelen = strlen(r_name + r_ptr->name);
1872                 prt(format("%s: '", r_name + r_ptr->name), 1, 15);
1873                 Term_queue_bigchar(18 + namelen, 1, r_ptr->x_attr, r_ptr->x_char, 0, 0);
1874                 prt("'", 1, (use_bigtile ? 20 : 19) + namelen);
1875         }
1876         else
1877 #ifdef JP
1878 prt("     ¥¢¥¤¥Æ¥à¤ÎǽÎÏ:", 1, 15);
1879 #else
1880         prt("     Item Attributes:", 1, 15);
1881 #endif
1882
1883         /* We will print on top of the map (column 13) */
1884         for (k = 2, j = 0; j < i; j++)
1885         {
1886                 /* Show the info */
1887                 prt(info[j], k++, 15);
1888
1889                 /* Every 20 entries (lines 2 to 21), start over */
1890                 if ((k == hgt - 2) && (j+1 < i))
1891                 {
1892 #ifdef JP
1893 prt("-- Â³¤¯ --", k, 15);
1894 #else
1895                         prt("-- more --", k, 15);
1896 #endif
1897                         inkey();
1898                         for (; k > 2; k--) prt("", k, 15);
1899                 }
1900         }
1901
1902         /* Wait for it */
1903 #ifdef JP
1904 prt("[²¿¤«¥­¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹]", k, 15);
1905 #else
1906         prt("[Press any key to continue]", k, 15);
1907 #endif
1908
1909         inkey();
1910
1911         /* Restore the screen */
1912         screen_load();
1913
1914         /* Gave knowledge */
1915         return (TRUE);
1916 }
1917
1918
1919
1920 /*
1921  * Convert an inventory index into a one character label
1922  * Note that the label does NOT distinguish inven/equip.
1923  */
1924 char index_to_label(int i)
1925 {
1926         /* Indexes for "inven" are easy */
1927         if (i < INVEN_RARM) return (I2A(i));
1928
1929         /* Indexes for "equip" are offset */
1930         return (I2A(i - INVEN_RARM));
1931 }
1932
1933
1934 /*
1935  * Convert a label into the index of an item in the "inven"
1936  * Return "-1" if the label does not indicate a real item
1937  */
1938 s16b label_to_inven(int c)
1939 {
1940         int i;
1941
1942         /* Convert */
1943         i = (islower(c) ? A2I(c) : -1);
1944
1945         /* Verify the index */
1946         if ((i < 0) || (i > INVEN_PACK)) return (-1);
1947
1948         /* Empty slots can never be chosen */
1949         if (!inventory[i].k_idx) return (-1);
1950
1951         /* Return the index */
1952         return (i);
1953 }
1954
1955
1956 /* See cmd5.c */
1957 extern bool select_ring_slot;
1958
1959
1960 static bool is_ring_slot(int i)
1961 {
1962         return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1963 }
1964
1965
1966 /*
1967  * Convert a label into the index of a item in the "equip"
1968  * Return "-1" if the label does not indicate a real item
1969  */
1970 s16b label_to_equip(int c)
1971 {
1972         int i;
1973
1974         /* Convert */
1975         i = (islower(c) ? A2I(c) : -1) + INVEN_RARM;
1976
1977         /* Verify the index */
1978         if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1979
1980         if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1981
1982         /* Empty slots can never be chosen */
1983         if (!inventory[i].k_idx) return (-1);
1984
1985         /* Return the index */
1986         return (i);
1987 }
1988
1989
1990
1991 /*
1992  * Determine which equipment slot (if any) an item likes
1993  */
1994 s16b wield_slot(object_type *o_ptr)
1995 {
1996         /* Slot for equipment */
1997         switch (o_ptr->tval)
1998         {
1999                 case TV_DIGGING:
2000                 case TV_HAFTED:
2001                 case TV_POLEARM:
2002                 case TV_SWORD:
2003                 {
2004                         if (!inventory[INVEN_RARM].k_idx) return (INVEN_RARM);
2005                         if (inventory[INVEN_LARM].k_idx) return (INVEN_RARM);
2006                         return (INVEN_LARM);
2007                 }
2008
2009                 case TV_CAPTURE:
2010                 case TV_CARD:
2011                 case TV_SHIELD:
2012                 {
2013                         if (!inventory[INVEN_LARM].k_idx) return (INVEN_LARM);
2014                         if (inventory[INVEN_RARM].k_idx) return (INVEN_LARM);
2015                         return (INVEN_RARM);
2016                 }
2017
2018                 case TV_BOW:
2019                 {
2020                         return (INVEN_BOW);
2021                 }
2022
2023                 case TV_RING:
2024                 {
2025                         /* Use the right hand first */
2026                         if (!inventory[INVEN_RIGHT].k_idx) return (INVEN_RIGHT);
2027
2028                         /* Use the left hand for swapping (by default) */
2029                         return (INVEN_LEFT);
2030                 }
2031
2032                 case TV_AMULET:
2033                 case TV_WHISTLE:
2034                 {
2035                         return (INVEN_NECK);
2036                 }
2037
2038                 case TV_LITE:
2039                 {
2040                         return (INVEN_LITE);
2041                 }
2042
2043                 case TV_DRAG_ARMOR:
2044                 case TV_HARD_ARMOR:
2045                 case TV_SOFT_ARMOR:
2046                 {
2047                         return (INVEN_BODY);
2048                 }
2049
2050                 case TV_CLOAK:
2051                 {
2052                         return (INVEN_OUTER);
2053                 }
2054
2055                 case TV_CROWN:
2056                 case TV_HELM:
2057                 {
2058                         return (INVEN_HEAD);
2059                 }
2060
2061                 case TV_GLOVES:
2062                 {
2063                         return (INVEN_HANDS);
2064                 }
2065
2066                 case TV_BOOTS:
2067                 {
2068                         return (INVEN_FEET);
2069                 }
2070         }
2071
2072         /* No slot available */
2073         return (-1);
2074 }
2075
2076
2077 /*
2078  * Return a string mentioning how a given item is carried
2079  */
2080 cptr mention_use(int i)
2081 {
2082         cptr p;
2083
2084         /* Examine the location */
2085         switch (i)
2086         {
2087 #ifdef JP
2088                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "±¿ÈÂÃæ" : ((p_ptr->ryoute && p_ptr->migite) ? " Î¾¼ê" : (left_hander ? " º¸¼ê" : " ±¦¼ê")); break;
2089 #else
2090                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "Just lifting" : (p_ptr->migite ? "Wielding" : "On arm"); break;
2091 #endif
2092
2093 #ifdef JP
2094                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "±¿ÈÂÃæ" : ((p_ptr->ryoute && p_ptr->hidarite) ? " Î¾¼ê" : (left_hander ? " ±¦¼ê" : " º¸¼ê")); break;
2095 #else
2096                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "Just lifting" : (p_ptr->hidarite ? "Wielding" : "On arm"); break;
2097 #endif
2098
2099 #ifdef JP
2100                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "±¿ÈÂÃæ" : "¼Í·âÍÑ"; break;
2101 #else
2102                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "Just holding" : "Shooting"; break;
2103 #endif
2104
2105 #ifdef JP
2106                 case INVEN_RIGHT: p = (left_hander ? "º¸¼ê»Ø" : "±¦¼ê»Ø"); break;
2107 #else
2108                 case INVEN_RIGHT: p = (left_hander ? "On left hand" : "On right hand"); break;
2109 #endif
2110
2111 #ifdef JP
2112                 case INVEN_LEFT:  p = (left_hander ? "±¦¼ê»Ø" : "º¸¼ê»Ø"); break;
2113 #else
2114                 case INVEN_LEFT:  p = (left_hander ? "On right hand" : "On left hand"); break;
2115 #endif
2116
2117 #ifdef JP
2118                 case INVEN_NECK:  p = "  ¼ó"; break;
2119 #else
2120                 case INVEN_NECK:  p = "Around neck"; break;
2121 #endif
2122
2123 #ifdef JP
2124                 case INVEN_LITE:  p = " ¸÷¸»"; break;
2125 #else
2126                 case INVEN_LITE:  p = "Light source"; break;
2127 #endif
2128
2129 #ifdef JP
2130                 case INVEN_BODY:  p = "  ÂÎ"; break;
2131 #else
2132                 case INVEN_BODY:  p = "On body"; break;
2133 #endif
2134
2135 #ifdef JP
2136                 case INVEN_OUTER: p = "ÂΤξå"; break;
2137 #else
2138                 case INVEN_OUTER: p = "About body"; break;
2139 #endif
2140
2141 #ifdef JP
2142                 case INVEN_HEAD:  p = "  Ƭ"; break;
2143 #else
2144                 case INVEN_HEAD:  p = "On head"; break;
2145 #endif
2146
2147 #ifdef JP
2148                 case INVEN_HANDS: p = "  ¼ê"; break;
2149 #else
2150                 case INVEN_HANDS: p = "On hands"; break;
2151 #endif
2152
2153 #ifdef JP
2154                 case INVEN_FEET:  p = "  ­"; break;
2155 #else
2156                 case INVEN_FEET:  p = "On feet"; break;
2157 #endif
2158
2159 #ifdef JP
2160                 default:          p = "¥¶¥Ã¥¯"; break;
2161 #else
2162                 default:          p = "In pack"; break;
2163 #endif
2164         }
2165
2166         /* Return the result */
2167         return p;
2168 }
2169
2170
2171 /*
2172  * Return a string describing how a given item is being worn.
2173  * Currently, only used for items in the equipment, not inventory.
2174  */
2175 cptr describe_use(int i)
2176 {
2177         cptr p;
2178
2179         switch (i)
2180         {
2181 #ifdef JP
2182                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "±¿ÈÂÃæ¤Î" : ((p_ptr->ryoute && p_ptr->migite) ? "ξ¼ê¤ËÁõÈ÷¤·¤Æ¤¤¤ë" : (left_hander ? "º¸¼ê¤ËÁõÈ÷¤·¤Æ¤¤¤ë" : "±¦¼ê¤ËÁõÈ÷¤·¤Æ¤¤¤ë")); break;
2183 #else
2184                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "just lifting" : (p_ptr->migite ? "attacking monsters with" : "wearing on your arm"); break;
2185 #endif
2186
2187 #ifdef JP
2188                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "±¿ÈÂÃæ¤Î" : ((p_ptr->ryoute && p_ptr->hidarite) ? "ξ¼ê¤ËÁõÈ÷¤·¤Æ¤¤¤ë" : (left_hander ? "±¦¼ê¤ËÁõÈ÷¤·¤Æ¤¤¤ë" : "º¸¼ê¤ËÁõÈ÷¤·¤Æ¤¤¤ë")); break;
2189 #else
2190                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "just lifting" : (p_ptr->hidarite ? "attacking monsters with" : "wearing on your arm"); break;
2191 #endif
2192
2193 #ifdef JP
2194                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "»ý¤Ä¤À¤±¤ÇÀº°ìÇÕ¤Î" : "¼Í·âÍѤËÁõÈ÷¤·¤Æ¤¤¤ë"; break;
2195 #else
2196                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "just holding" : "shooting missiles with"; break;
2197 #endif
2198
2199 #ifdef JP
2200                 case INVEN_RIGHT: p = (left_hander ? "º¸¼ê¤Î»Ø¤Ë¤Ï¤á¤Æ¤¤¤ë" : "±¦¼ê¤Î»Ø¤Ë¤Ï¤á¤Æ¤¤¤ë"); break;
2201 #else
2202                 case INVEN_RIGHT: p = (left_hander ? "wearing on your left hand" : "wearing on your right hand"); break;
2203 #endif
2204
2205 #ifdef JP
2206                 case INVEN_LEFT:  p = (left_hander ? "±¦¼ê¤Î»Ø¤Ë¤Ï¤á¤Æ¤¤¤ë" : "º¸¼ê¤Î»Ø¤Ë¤Ï¤á¤Æ¤¤¤ë"); break;
2207 #else
2208                 case INVEN_LEFT:  p = (left_hander ? "wearing on your right hand" : "wearing on your left hand"); break;
2209 #endif
2210
2211 #ifdef JP
2212                 case INVEN_NECK:  p = "¼ó¤Ë¤«¤±¤Æ¤¤¤ë"; break;
2213 #else
2214                 case INVEN_NECK:  p = "wearing around your neck"; break;
2215 #endif
2216
2217 #ifdef JP
2218                 case INVEN_LITE:  p = "¸÷¸»¤Ë¤·¤Æ¤¤¤ë"; break;
2219 #else
2220                 case INVEN_LITE:  p = "using to light the way"; break;
2221 #endif
2222
2223 #ifdef JP
2224                 case INVEN_BODY:  p = "ÂΤËÃå¤Æ¤¤¤ë"; break;
2225 #else
2226                 case INVEN_BODY:  p = "wearing on your body"; break;
2227 #endif
2228
2229 #ifdef JP
2230                 case INVEN_OUTER: p = "¿È¤Ë¤Þ¤È¤Ã¤Æ¤¤¤ë"; break;
2231 #else
2232                 case INVEN_OUTER: p = "wearing on your back"; break;
2233 #endif
2234
2235 #ifdef JP
2236                 case INVEN_HEAD:  p = "Ƭ¤Ë¤«¤Ö¤Ã¤Æ¤¤¤ë"; break;
2237 #else
2238                 case INVEN_HEAD:  p = "wearing on your head"; break;
2239 #endif
2240
2241 #ifdef JP
2242                 case INVEN_HANDS: p = "¼ê¤Ë¤Ä¤±¤Æ¤¤¤ë"; break;
2243 #else
2244                 case INVEN_HANDS: p = "wearing on your hands"; break;
2245 #endif
2246
2247 #ifdef JP
2248                 case INVEN_FEET:  p = "­¤Ë¤Ï¤¤¤Æ¤¤¤ë"; break;
2249 #else
2250                 case INVEN_FEET:  p = "wearing on your feet"; break;
2251 #endif
2252
2253 #ifdef JP
2254                 default:          p = "¥¶¥Ã¥¯¤ËÆþ¤Ã¤Æ¤¤¤ë"; break;
2255 #else
2256                 default:          p = "carrying in your pack"; break;
2257 #endif
2258         }
2259
2260         /* Return the result */
2261         return p;
2262 }
2263
2264
2265 /* Hack: Check if a spellbook is one of the realms we can use. -- TY */
2266
2267 bool check_book_realm(const byte book_tval, const byte book_sval)
2268 {
2269         if (book_tval < TV_LIFE_BOOK) return FALSE;
2270         if (p_ptr->pclass == CLASS_SORCERER)
2271         {
2272                 return is_magic(tval2realm(book_tval));
2273         }
2274         else if (p_ptr->pclass == CLASS_RED_MAGE)
2275         {
2276                 if (is_magic(tval2realm(book_tval)))
2277                         return ((book_tval == TV_ARCANE_BOOK) || (book_sval < 2));
2278         }
2279         return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
2280 }
2281
2282
2283 /*
2284  * Check an item against the item tester info
2285  */
2286 bool item_tester_okay(object_type *o_ptr)
2287 {
2288         /* Hack -- allow listing empty slots */
2289         if (item_tester_full) return (TRUE);
2290
2291         /* Require an item */
2292         if (!o_ptr->k_idx) return (FALSE);
2293
2294         /* Hack -- ignore "gold" */
2295         if (o_ptr->tval == TV_GOLD)
2296         {
2297                 /* See xtra2.c */
2298                 extern bool show_gold_on_floor;
2299
2300                 if (!show_gold_on_floor) return (FALSE);
2301         }
2302
2303         /* Check the tval */
2304         if (item_tester_tval)
2305         {
2306                 /* Is it a spellbook? If so, we need a hack -- TY */
2307                 if ((item_tester_tval <= TV_DEATH_BOOK) &&
2308                         (item_tester_tval >= TV_LIFE_BOOK))
2309                         return check_book_realm(o_ptr->tval, o_ptr->sval);
2310                 else
2311                         if (item_tester_tval != o_ptr->tval) return (FALSE);
2312         }
2313
2314         /* Check the hook */
2315         if (item_tester_hook)
2316         {
2317                 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
2318         }
2319
2320         /* Assume okay */
2321         return (TRUE);
2322 }
2323
2324
2325
2326
2327 /*
2328  * Choice window "shadow" of the "show_inven()" function
2329  */
2330 void display_inven(void)
2331 {
2332         register        int i, n, z = 0;
2333         object_type     *o_ptr;
2334         byte            attr = TERM_WHITE;
2335         char            tmp_val[80];
2336         char            o_name[MAX_NLEN];
2337         int             wid, hgt;
2338
2339         /* Get size */
2340         Term_get_size(&wid, &hgt);
2341
2342         /* Find the "final" slot */
2343         for (i = 0; i < INVEN_PACK; i++)
2344         {
2345                 o_ptr = &inventory[i];
2346
2347                 /* Skip non-objects */
2348                 if (!o_ptr->k_idx) continue;
2349
2350                 /* Track */
2351                 z = i + 1;
2352         }
2353
2354         /* Display the pack */
2355         for (i = 0; i < z; i++)
2356         {
2357                 /* Examine the item */
2358                 o_ptr = &inventory[i];
2359
2360                 /* Start with an empty "index" */
2361                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
2362
2363                 /* Is this item "acceptable"? */
2364                 if (item_tester_okay(o_ptr))
2365                 {
2366                         /* Prepare an "index" */
2367                         tmp_val[0] = index_to_label(i);
2368
2369                         /* Bracket the "index" --(-- */
2370                         tmp_val[1] = ')';
2371                 }
2372
2373                 /* Display the index (or blank space) */
2374                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
2375
2376                 /* Obtain an item description */
2377                 object_desc(o_name, o_ptr, 0);
2378
2379                 /* Obtain the length of the description */
2380                 n = strlen(o_name);
2381
2382                 /* Get a color */
2383                 attr = tval_to_attr[o_ptr->tval % 128];
2384
2385                 /* Grey out charging items */
2386                 if (o_ptr->timeout)
2387                 {
2388                         attr = TERM_L_DARK;
2389                 }
2390
2391                 /* Display the entry itself */
2392                 Term_putstr(3, i, n, attr, o_name);
2393
2394                 /* Erase the rest of the line */
2395                 Term_erase(3+n, i, 255);
2396
2397                 /* Display the weight if needed */
2398                 if (show_weights)
2399                 {
2400                         int wgt = o_ptr->weight * o_ptr->number;
2401 #ifdef JP
2402                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt),lbtokg2(wgt) );
2403 #else
2404                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2405 #endif
2406
2407                         prt(tmp_val, i, wid - 9);
2408                 }
2409         }
2410
2411         /* Erase the rest of the window */
2412         for (i = z; i < hgt; i++)
2413         {
2414                 /* Erase the line */
2415                 Term_erase(0, i, 255);
2416         }
2417 }
2418
2419
2420
2421 /*
2422  * Choice window "shadow" of the "show_equip()" function
2423  */
2424 void display_equip(void)
2425 {
2426         register        int i, n;
2427         object_type     *o_ptr;
2428         byte            attr = TERM_WHITE;
2429         char            tmp_val[80];
2430         char            o_name[MAX_NLEN];
2431         int             wid, hgt;
2432
2433         /* Get size */
2434         Term_get_size(&wid, &hgt);
2435
2436         /* Display the equipment */
2437         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2438         {
2439                 /* Examine the item */
2440                 o_ptr = &inventory[i];
2441
2442                 /* Start with an empty "index" */
2443                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
2444
2445                 /* Is this item "acceptable"? */
2446                 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
2447                 {
2448                         /* Prepare an "index" */
2449                         tmp_val[0] = index_to_label(i);
2450
2451                         /* Bracket the "index" --(-- */
2452                         tmp_val[1] = ')';
2453                 }
2454
2455                 /* Display the index (or blank space) */
2456                 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
2457
2458                 /* Obtain an item description */
2459                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2460                 {
2461 #ifdef JP
2462                         strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
2463 #else
2464                         strcpy(o_name, "(wielding with two-hands)");
2465 #endif
2466                         attr = TERM_WHITE;
2467                 }
2468                 else
2469                 {
2470                         object_desc(o_name, o_ptr, 0);
2471                         attr = tval_to_attr[o_ptr->tval % 128];
2472                 }
2473
2474                 /* Obtain the length of the description */
2475                 n = strlen(o_name);
2476
2477                 /* Grey out charging items */
2478                 if (o_ptr->timeout)
2479                 {
2480                         attr = TERM_L_DARK;
2481                 }
2482
2483                 /* Display the entry itself */
2484                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
2485
2486                 /* Erase the rest of the line */
2487                 Term_erase(3+n, i - INVEN_RARM, 255);
2488
2489                 /* Display the weight (if needed) */
2490                 if (show_weights)
2491                 {
2492                         int wgt = o_ptr->weight * o_ptr->number;
2493 #ifdef JP
2494                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
2495 #else
2496                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2497 #endif
2498
2499                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
2500                 }
2501
2502                 /* Display the slot description (if needed) */
2503                 if (show_labels)
2504                 {
2505                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
2506                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
2507                 }
2508         }
2509
2510         /* Erase the rest of the window */
2511         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
2512         {
2513                 /* Clear that line */
2514                 Term_erase(0, i, 255);
2515         }
2516 }
2517
2518
2519 /*
2520  * Find the "first" inventory object with the given "tag".
2521  *
2522  * A "tag" is a numeral "n" appearing as "@n" anywhere in the
2523  * inscription of an object.  Alphabetical characters don't work as a
2524  * tag in this form.
2525  *
2526  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,
2527  * and "x" is the "current" command_cmd code.
2528  */
2529 static bool get_tag(int *cp, char tag, int mode)
2530 {
2531         int i, start, end;
2532         cptr s;
2533
2534         /* Extract index from mode */
2535         switch (mode)
2536         {
2537         case USE_EQUIP:
2538                 start = INVEN_RARM;
2539                 end = INVEN_TOTAL - 1;
2540                 break;
2541
2542         case USE_INVEN:
2543                 start = 0;
2544                 end = INVEN_PACK - 1;
2545                 break;
2546
2547         default:
2548                 return FALSE;
2549         }
2550
2551         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
2552
2553         /* Check every inventory object */
2554         for (i = start; i <= end; i++)
2555         {
2556                 object_type *o_ptr = &inventory[i];
2557
2558                 /* Skip non-objects */
2559                 if (!o_ptr->k_idx) continue;
2560
2561                 /* Skip empty inscriptions */
2562                 if (!o_ptr->inscription) continue;
2563
2564                 /* Skip non-choice */
2565                 if (!item_tester_okay(o_ptr)) continue;
2566
2567                 /* Find a '@' */
2568                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2569
2570                 /* Process all tags */
2571                 while (s)
2572                 {
2573                         /* Check the special tags */
2574                         if ((s[1] == command_cmd) && (s[2] == tag))
2575                         {
2576                                 /* Save the actual inventory ID */
2577                                 *cp = i;
2578
2579                                 /* Success */
2580                                 return (TRUE);
2581                         }
2582
2583                         /* Find another '@' */
2584                         s = my_strchr(s + 1, '@');
2585                 }
2586         }
2587
2588
2589         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
2590
2591         /* Don't allow {@#} with '#' being alphabet */
2592         if (tag < '0' || '9' < tag)
2593         {
2594                 /* No such tag */
2595                 return FALSE;
2596         }
2597
2598         /* Check every object */
2599         for (i = start; i <= end; i++)
2600         {
2601                 object_type *o_ptr = &inventory[i];
2602
2603                 /* Skip non-objects */
2604                 if (!o_ptr->k_idx) continue;
2605
2606                 /* Skip empty inscriptions */
2607                 if (!o_ptr->inscription) continue;
2608
2609                 /* Skip non-choice */
2610                 if (!item_tester_okay(o_ptr)) continue;
2611
2612                 /* Find a '@' */
2613                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2614
2615                 /* Process all tags */
2616                 while (s)
2617                 {
2618                         /* Check the normal tags */
2619                         if (s[1] == tag)
2620                         {
2621                                 /* Save the actual inventory ID */
2622                                 *cp = i;
2623
2624                                 /* Success */
2625                                 return (TRUE);
2626                         }
2627
2628                         /* Find another '@' */
2629                         s = my_strchr(s + 1, '@');
2630                 }
2631         }
2632
2633         /* No such tag */
2634         return (FALSE);
2635 }
2636
2637
2638 /*
2639  * Find the "first" floor object with the given "tag".
2640  *
2641  * A "tag" is a numeral "n" appearing as "@n" anywhere in the
2642  * inscription of an object.  Alphabetical characters don't work as a
2643  * tag in this form.
2644  *
2645  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,
2646  * and "x" is the "current" command_cmd code.
2647  */
2648 static bool get_tag_floor(int *cp, char tag, int floor_list[], int floor_num)
2649 {
2650         int i;
2651         cptr s;
2652
2653         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
2654
2655         /* Check every object in the grid */
2656         for (i = 0; i < floor_num && i < 23; i++)
2657         {
2658                 object_type *o_ptr = &o_list[floor_list[i]];
2659
2660                 /* Skip empty inscriptions */
2661                 if (!o_ptr->inscription) continue;
2662
2663                 /* Find a '@' */
2664                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2665
2666                 /* Process all tags */
2667                 while (s)
2668                 {
2669                         /* Check the special tags */
2670                         if ((s[1] == command_cmd) && (s[2] == tag))
2671                         {
2672                                 /* Save the actual floor object ID */
2673                                 *cp = i;
2674
2675                                 /* Success */
2676                                 return (TRUE);
2677                         }
2678
2679                         /* Find another '@' */
2680                         s = my_strchr(s + 1, '@');
2681                 }
2682         }
2683
2684
2685         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
2686
2687         /* Don't allow {@#} with '#' being alphabet */
2688         if (tag < '0' || '9' < tag)
2689         {
2690                 /* No such tag */
2691                 return FALSE;
2692         }
2693
2694         /* Check every object in the grid */
2695         for (i = 0; i < floor_num && i < 23; i++)
2696         {
2697                 object_type *o_ptr = &o_list[floor_list[i]];
2698
2699                 /* Skip empty inscriptions */
2700                 if (!o_ptr->inscription) continue;
2701
2702                 /* Find a '@' */
2703                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2704
2705                 /* Process all tags */
2706                 while (s)
2707                 {
2708                         /* Check the normal tags */
2709                         if (s[1] == tag)
2710                         {
2711                                 /* Save the floor object ID */
2712                                 *cp = i;
2713
2714                                 /* Success */
2715                                 return (TRUE);
2716                         }
2717
2718                         /* Find another '@' */
2719                         s = my_strchr(s + 1, '@');
2720                 }
2721         }
2722
2723         /* No such tag */
2724         return (FALSE);
2725 }
2726
2727
2728 /*
2729  * Move around label characters with correspond tags
2730  */
2731 static void prepare_label_string(char *label, int mode)
2732 {
2733         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2734         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
2735         int  i;
2736
2737         /* Prepare normal labels */
2738         strcpy(label, alphabet_chars);
2739
2740         /* Move each label */
2741         for (i = 0; i < 52; i++)
2742         {
2743                 int index;
2744                 char c = alphabet_chars[i];
2745
2746                 /* Find a tag with this label */
2747                 if (get_tag(&index, c, mode))
2748                 {
2749                         /* Delete the overwritten label */
2750                         if (label[i] == c) label[i] = ' ';
2751
2752                         /* Move the label to the place of corresponding tag */
2753                         label[index - offset] = c;
2754                 }
2755         }
2756 }
2757
2758
2759 /*
2760  * Move around label characters with correspond tags (floor version)
2761  */
2762 static void prepare_label_string_floor(char *label, int floor_list[], int floor_num)
2763 {
2764         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2765         int  i;
2766
2767         /* Prepare normal labels */
2768         strcpy(label, alphabet_chars);
2769
2770         /* Move each label */
2771         for (i = 0; i < 52; i++)
2772         {
2773                 int index;
2774                 char c = alphabet_chars[i];
2775
2776                 /* Find a tag with this label */
2777                 if (get_tag_floor(&index, c, floor_list, floor_num))
2778                 {
2779                         /* Delete the overwritten label */
2780                         if (label[i] == c) label[i] = ' ';
2781
2782                         /* Move the label to the place of corresponding tag */
2783                         label[index] = c;
2784                 }
2785         }
2786 }
2787
2788
2789 /*
2790  * Display the inventory.
2791  *
2792  * Hack -- do not display "trailing" empty slots
2793  */
2794 int show_inven(int target_item)
2795 {
2796         int             i, j, k, l, z = 0;
2797         int             col, cur_col, len;
2798         object_type     *o_ptr;
2799         char            o_name[MAX_NLEN];
2800         char            tmp_val[80];
2801         int             out_index[23];
2802         byte            out_color[23];
2803         char            out_desc[23][MAX_NLEN];
2804         int             target_item_label = 0;
2805         int             wid, hgt;
2806         char            inven_label[52 + 1];
2807
2808         /* Starting column */
2809         col = command_gap;
2810
2811         /* Get size */
2812         Term_get_size(&wid, &hgt);
2813
2814         /* Default "max-length" */
2815         len = wid - col - 1;
2816
2817
2818         /* Find the "final" slot */
2819         for (i = 0; i < INVEN_PACK; i++)
2820         {
2821                 o_ptr = &inventory[i];
2822
2823                 /* Skip non-objects */
2824                 if (!o_ptr->k_idx) continue;
2825
2826                 /* Track */
2827                 z = i + 1;
2828         }
2829
2830         prepare_label_string(inven_label, USE_INVEN);
2831
2832         /* Display the inventory */
2833         for (k = 0, i = 0; i < z; i++)
2834         {
2835                 o_ptr = &inventory[i];
2836
2837                 /* Is this item acceptable? */
2838                 if (!item_tester_okay(o_ptr)) continue;
2839
2840                 /* Describe the object */
2841                 object_desc(o_name, o_ptr, 0);
2842
2843                 /* Save the object index, color, and description */
2844                 out_index[k] = i;
2845                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2846
2847                 /* Grey out charging items */
2848                 if (o_ptr->timeout)
2849                 {
2850                         out_color[k] = TERM_L_DARK;
2851                 }
2852
2853                 (void)strcpy(out_desc[k], o_name);
2854
2855                 /* Find the predicted "line length" */
2856                 l = strlen(out_desc[k]) + 5;
2857
2858                 /* Be sure to account for the weight */
2859                 if (show_weights) l += 9;
2860
2861                 /* Account for icon if displayed */
2862                 if (show_item_graph)
2863                 {
2864                         l += 2;
2865                         if (use_bigtile) l++;
2866                 }
2867
2868                 /* Maintain the maximum length */
2869                 if (l > len) len = l;
2870
2871                 /* Advance to next "line" */
2872                 k++;
2873         }
2874
2875         /* Find the column to start in */
2876         col = (len > wid - 4) ? 0 : (wid - len - 1);
2877
2878         /* Output each entry */
2879         for (j = 0; j < k; j++)
2880         {
2881                 /* Get the index */
2882                 i = out_index[j];
2883
2884                 /* Get the item */
2885                 o_ptr = &inventory[i];
2886
2887                 /* Clear the line */
2888                 prt("", j + 1, col ? col - 2 : col);
2889
2890                 if (use_menu && target_item)
2891                 {
2892                         if (j == (target_item-1))
2893                         {
2894 #ifdef JP
2895                                 strcpy(tmp_val, "¡Õ");
2896 #else
2897                                 strcpy(tmp_val, "> ");
2898 #endif
2899                                 target_item_label = i;
2900                         }
2901                         else strcpy(tmp_val, "  ");
2902                 }
2903                 else if (i <= INVEN_PACK)
2904                 {
2905                         /* Prepare an index --(-- */
2906                         sprintf(tmp_val, "%c)", inven_label[i]);
2907                 }
2908                 else
2909                 {
2910                         /* Prepare an index --(-- */
2911                         sprintf(tmp_val, "%c)", index_to_label(i));
2912                 }
2913
2914                 /* Clear the line with the (possibly indented) index */
2915                 put_str(tmp_val, j + 1, col);
2916
2917                 cur_col = col + 3;
2918
2919                 /* Display graphics for object, if desired */
2920                 if (show_item_graph)
2921                 {
2922                         byte  a = object_attr(o_ptr);
2923                         char c = object_char(o_ptr);
2924
2925 #ifdef AMIGA
2926                         if (a & 0x80) a |= 0x40;
2927 #endif
2928
2929                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2930                         if (use_bigtile) cur_col++;
2931
2932                         cur_col += 2;
2933                 }
2934
2935
2936                 /* Display the entry itself */
2937                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2938
2939                 /* Display the weight if needed */
2940                 if (show_weights)
2941                 {
2942                         int wgt = o_ptr->weight * o_ptr->number;
2943 #ifdef JP
2944                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2945 #else
2946                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2947 #endif
2948
2949                         prt(tmp_val, j + 1, wid - 9);
2950                 }
2951         }
2952
2953         /* Make a "shadow" below the list (only if needed) */
2954         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2955
2956         /* Save the new column */
2957         command_gap = col;
2958
2959         return target_item_label;
2960 }
2961
2962
2963
2964 /*
2965  * Display the equipment.
2966  */
2967 int show_equip(int target_item)
2968 {
2969         int             i, j, k, l;
2970         int             col, cur_col, len;
2971         object_type     *o_ptr;
2972         char            tmp_val[80];
2973         char            o_name[MAX_NLEN];
2974         int             out_index[23];
2975         byte            out_color[23];
2976         char            out_desc[23][MAX_NLEN];
2977         int             target_item_label = 0;
2978         int             wid, hgt;
2979         char            equip_label[52 + 1];
2980
2981         /* Starting column */
2982         col = command_gap;
2983
2984         /* Get size */
2985         Term_get_size(&wid, &hgt);
2986
2987         /* Maximal length */
2988         len = wid - col - 1;
2989
2990
2991         /* Scan the equipment list */
2992         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2993         {
2994                 o_ptr = &inventory[i];
2995
2996                 /* Is this item acceptable? */
2997                 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr)) &&
2998                     (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2999                      item_tester_no_ryoute)) continue;
3000
3001                 /* Description */
3002                 object_desc(o_name, o_ptr, 0);
3003
3004                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
3005                 {
3006 #ifdef JP
3007                         (void)strcpy(out_desc[k],"(Éð´ï¤òξ¼ê»ý¤Á)");
3008 #else
3009                         (void)strcpy(out_desc[k],"(wielding with two-hands)");
3010 #endif
3011                         out_color[k] = TERM_WHITE;
3012                 }
3013                 else
3014                 {
3015                         (void)strcpy(out_desc[k], o_name);
3016                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
3017                 }
3018
3019                 out_index[k] = i;
3020                 /* Grey out charging items */
3021                 if (o_ptr->timeout)
3022                 {
3023                         out_color[k] = TERM_L_DARK;
3024                 }
3025
3026                 /* Extract the maximal length (see below) */
3027 #ifdef JP
3028                 l = strlen(out_desc[k]) + (2 + 1);
3029 #else
3030                 l = strlen(out_desc[k]) + (2 + 3);
3031 #endif
3032
3033
3034                 /* Increase length for labels (if needed) */
3035 #ifdef JP
3036                 if (show_labels) l += (7 + 2);
3037 #else
3038                 if (show_labels) l += (14 + 2);
3039 #endif
3040
3041
3042                 /* Increase length for weight (if needed) */
3043                 if (show_weights) l += 9;
3044
3045                 if (show_item_graph) l += 2;
3046
3047                 /* Maintain the max-length */
3048                 if (l > len) len = l;
3049
3050                 /* Advance the entry */
3051                 k++;
3052         }
3053
3054         /* Hack -- Find a column to start in */
3055 #ifdef JP
3056         col = (len > wid - 6) ? 0 : (wid - len - 1);
3057 #else
3058         col = (len > wid - 4) ? 0 : (wid - len - 1);
3059 #endif
3060
3061         prepare_label_string(equip_label, USE_EQUIP);
3062
3063         /* Output each entry */
3064         for (j = 0; j < k; j++)
3065         {
3066                 /* Get the index */
3067                 i = out_index[j];
3068
3069                 /* Get the item */
3070                 o_ptr = &inventory[i];
3071
3072                 /* Clear the line */
3073                 prt("", j + 1, col ? col - 2 : col);
3074
3075                 if (use_menu && target_item)
3076                 {
3077                         if (j == (target_item-1))
3078                         {
3079 #ifdef JP
3080                                 strcpy(tmp_val, "¡Õ");
3081 #else
3082                                 strcpy(tmp_val, "> ");
3083 #endif
3084                                 target_item_label = i;
3085                         }
3086                         else strcpy(tmp_val, "  ");
3087                 }
3088                 else if (i >= INVEN_RARM)
3089                 {
3090                         /* Prepare an index --(-- */
3091                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
3092                 }
3093                 else /* Paranoia */
3094                 {
3095                         /* Prepare an index --(-- */
3096                         sprintf(tmp_val, "%c)", index_to_label(i));
3097                 }
3098
3099                 /* Clear the line with the (possibly indented) index */
3100                 put_str(tmp_val, j+1, col);
3101
3102                 cur_col = col + 3;
3103
3104                 /* Display graphics for object, if desired */
3105                 if (show_item_graph)
3106                 {
3107                         byte a = object_attr(o_ptr);
3108                         char c = object_char(o_ptr);
3109
3110 #ifdef AMIGA
3111                         if (a & 0x80) a |= 0x40;
3112 #endif
3113
3114                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
3115                         if (use_bigtile) cur_col++;
3116
3117                         cur_col += 2;
3118                 }
3119
3120                 /* Use labels */
3121                 if (show_labels)
3122                 {
3123                         /* Mention the use */
3124 #ifdef JP
3125                         (void)sprintf(tmp_val, "%-7s: ", mention_use(i));
3126 #else
3127                         (void)sprintf(tmp_val, "%-14s: ", mention_use(i));
3128 #endif
3129
3130                         put_str(tmp_val, j+1, cur_col);
3131
3132                         /* Display the entry itself */
3133 #ifdef JP
3134                         c_put_str(out_color[j], out_desc[j], j+1, cur_col + 9);
3135 #else
3136                         c_put_str(out_color[j], out_desc[j], j+1, cur_col + 16);
3137 #endif
3138                 }
3139
3140                 /* No labels */
3141                 else
3142                 {
3143                         /* Display the entry itself */
3144                         c_put_str(out_color[j], out_desc[j], j+1, cur_col);
3145                 }
3146
3147                 /* Display the weight if needed */
3148                 if (show_weights)
3149                 {
3150                         int wgt = o_ptr->weight * o_ptr->number;
3151 #ifdef JP
3152                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3153 #else
3154                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
3155 #endif
3156
3157                         prt(tmp_val, j + 1, wid - 9);
3158                 }
3159         }
3160
3161         /* Make a "shadow" below the list (only if needed) */
3162         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3163
3164         /* Save the new column */
3165         command_gap = col;
3166
3167         return target_item_label;
3168 }
3169
3170
3171
3172
3173 /*
3174  * Flip "inven" and "equip" in any sub-windows
3175  */
3176 void toggle_inven_equip(void)
3177 {
3178         int j;
3179
3180         /* Scan windows */
3181         for (j = 0; j < 8; j++)
3182         {
3183                 /* Unused */
3184                 if (!angband_term[j]) continue;
3185
3186                 /* Flip inven to equip */
3187                 if (window_flag[j] & (PW_INVEN))
3188                 {
3189                         /* Flip flags */
3190                         window_flag[j] &= ~(PW_INVEN);
3191                         window_flag[j] |= (PW_EQUIP);
3192
3193                         /* Window stuff */
3194                         p_ptr->window |= (PW_EQUIP);
3195                 }
3196
3197                 /* Flip inven to equip */
3198                 else if (window_flag[j] & (PW_EQUIP))
3199                 {
3200                         /* Flip flags */
3201                         window_flag[j] &= ~(PW_EQUIP);
3202                         window_flag[j] |= (PW_INVEN);
3203
3204                         /* Window stuff */
3205                         p_ptr->window |= (PW_INVEN);
3206                 }
3207         }
3208 }
3209
3210
3211
3212 /*
3213  * Verify the choice of an item.
3214  *
3215  * The item can be negative to mean "item on floor".
3216  */
3217 static bool verify(cptr prompt, int item)
3218 {
3219         char        o_name[MAX_NLEN];
3220         char        out_val[MAX_NLEN+20];
3221         object_type *o_ptr;
3222
3223
3224         /* Inventory */
3225         if (item >= 0)
3226         {
3227                 o_ptr = &inventory[item];
3228         }
3229
3230         /* Floor */
3231         else
3232         {
3233                 o_ptr = &o_list[0 - item];
3234         }
3235
3236         /* Describe */
3237         object_desc(o_name, o_ptr, 0);
3238
3239         /* Prompt */
3240 #ifdef JP
3241 (void)sprintf(out_val, "%s%s¤Ç¤¹¤«? ", prompt, o_name);
3242 #else
3243         (void)sprintf(out_val, "%s %s? ", prompt, o_name);
3244 #endif
3245
3246
3247         /* Query */
3248         return (get_check(out_val));
3249 }
3250
3251
3252 /*
3253  * Hack -- allow user to "prevent" certain choices
3254  *
3255  * The item can be negative to mean "item on floor".
3256  */
3257 static bool get_item_allow(int item)
3258 {
3259         cptr s;
3260
3261         object_type *o_ptr;
3262
3263         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
3264
3265         /* Inventory */
3266         if (item >= 0)
3267         {
3268                 o_ptr = &inventory[item];
3269         }
3270
3271         /* Floor */
3272         else
3273         {
3274                 o_ptr = &o_list[0 - item];
3275         }
3276
3277         /* No inscription */
3278         if (!o_ptr->inscription) return (TRUE);
3279
3280         /* Find a '!' */
3281         s = my_strchr(quark_str(o_ptr->inscription), '!');
3282
3283         /* Process preventions */
3284         while (s)
3285         {
3286                 /* Check the "restriction" */
3287                 if ((s[1] == command_cmd) || (s[1] == '*'))
3288                 {
3289                         /* Verify the choice */
3290 #ifdef JP
3291 if (!verify("ËÜÅö¤Ë", item)) return (FALSE);
3292 #else
3293                         if (!verify("Really try", item)) return (FALSE);
3294 #endif
3295
3296                 }
3297
3298                 /* Find another '!' */
3299                 s = my_strchr(s + 1, '!');
3300         }
3301
3302         /* Allow it */
3303         return (TRUE);
3304 }
3305
3306
3307
3308 /*
3309  * Auxiliary function for "get_item()" -- test an index
3310  */
3311 static bool get_item_okay(int i)
3312 {
3313         /* Illegal items */
3314         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
3315
3316         if (select_ring_slot) return is_ring_slot(i);
3317
3318         /* Verify the item */
3319         if (!item_tester_okay(&inventory[i])) return (FALSE);
3320
3321         /* Assume okay */
3322         return (TRUE);
3323 }
3324
3325
3326
3327 /*
3328  * Determine whether get_item() can get some item or not
3329  * assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
3330  */
3331 bool can_get_item(void)
3332 {
3333         int j, floor_list[23], floor_num = 0;
3334
3335         for (j = 0; j < INVEN_TOTAL; j++)
3336                 if (item_tester_okay(&inventory[j]))
3337                         return TRUE;
3338
3339         floor_num = scan_floor(floor_list, py, px, 0x03);
3340         if (floor_num)
3341                 return TRUE;
3342
3343         return FALSE;
3344 }
3345
3346 /*
3347  * Let the user select an item, save its "index"
3348  *
3349  * Return TRUE only if an acceptable item was chosen by the user.
3350  *
3351  * The selected item must satisfy the "item_tester_hook()" function,
3352  * if that hook is set, and the "item_tester_tval", if that value is set.
3353  *
3354  * All "item_tester" restrictions are cleared before this function returns.
3355  *
3356  * The user is allowed to choose acceptable items from the equipment,
3357  * inventory, or floor, respectively, if the proper flag was given,
3358  * and there are any acceptable items in that location.
3359  *
3360  * The equipment or inventory are displayed (even if no acceptable
3361  * items are in that location) if the proper flag was given.
3362  *
3363  * If there are no acceptable items available anywhere, and "str" is
3364  * not NULL, then it will be used as the text of a warning message
3365  * before the function returns.
3366  *
3367  * Note that the user must press "-" to specify the item on the floor,
3368  * and there is no way to "examine" the item on the floor, while the
3369  * use of "capital" letters will "examine" an inventory/equipment item,
3370  * and prompt for its use.
3371  *
3372  * If a legal item is selected from the inventory, we save it in "cp"
3373  * directly (0 to 35), and return TRUE.
3374  *
3375  * If a legal item is selected from the floor, we save it in "cp" as
3376  * a negative (-1 to -511), and return TRUE.
3377  *
3378  * If no item is available, we do nothing to "cp", and we display a
3379  * warning message, using "str" if available, and return FALSE.
3380  *
3381  * If no item is selected, we do nothing to "cp", and return FALSE.
3382  *
3383  * Global "p_ptr->command_new" is used when viewing the inventory or equipment
3384  * to allow the user to enter a command while viewing those screens, and
3385  * also to induce "auto-enter" of stores, and other such stuff.
3386  *
3387  * Global "p_ptr->command_see" may be set before calling this function to start
3388  * out in "browse" mode.  It is cleared before this function returns.
3389  *
3390  * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.
3391  * If it is TRUE then we are viewing inventory, else equipment.
3392  *
3393  * We always erase the prompt when we are done, leaving a blank line,
3394  * or a warning message, if appropriate, if no items are available.
3395  */
3396 bool get_item(int *cp, cptr pmt, cptr str, int mode)
3397 {
3398         s16b this_o_idx, next_o_idx = 0;
3399
3400         char which = ' ';
3401
3402         int j, k, i1, i2, e1, e2;
3403
3404         bool done, item;
3405
3406         bool oops = FALSE;
3407
3408         bool equip = FALSE;
3409         bool inven = FALSE;
3410         bool floor = FALSE;
3411
3412         bool allow_floor = FALSE;
3413
3414         bool toggle = FALSE;
3415
3416         char tmp_val[160];
3417         char out_val[160];
3418
3419         /* See cmd5.c */
3420         extern bool select_the_force;
3421
3422         int menu_line = (use_menu ? 1 : 0);
3423         int max_inven = 0;
3424         int max_equip = 0;
3425
3426 #ifdef ALLOW_REPEAT
3427
3428         static char prev_tag = '\0';
3429         char cur_tag = '\0';
3430
3431 #endif /* ALLOW_REPEAT */
3432
3433 #ifdef ALLOW_EASY_FLOOR /* TNB */
3434
3435         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
3436
3437 #endif /* ALLOW_EASY_FLOOR -- TNB */
3438
3439         /* Extract args */
3440         if (mode & USE_EQUIP) equip = TRUE;
3441         if (mode & USE_INVEN) inven = TRUE;
3442         if (mode & USE_FLOOR) floor = TRUE;
3443
3444 #ifdef ALLOW_REPEAT
3445
3446         /* Get the item index */
3447         if (repeat_pull(cp))
3448         {
3449                 /* the_force */
3450                 if (select_the_force && (*cp == INVEN_FORCE))
3451                 {
3452                         item_tester_tval = 0;
3453                         item_tester_hook = NULL;
3454                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3455                         return (TRUE);
3456                 }
3457
3458                 /* Floor item? */
3459                 else if (floor && (*cp < 0))
3460                 {
3461                         object_type *o_ptr;
3462
3463                         /* Special index */
3464                         k = 0 - (*cp);
3465
3466                         /* Acquire object */
3467                         o_ptr = &o_list[k];
3468
3469                         /* Validate the item */
3470                         if (item_tester_okay(o_ptr))
3471                         {
3472                                 /* Forget restrictions */
3473                                 item_tester_tval = 0;
3474                                 item_tester_hook = NULL;
3475                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3476
3477                                 /* Success */
3478                                 return TRUE;
3479                         }
3480                 }
3481
3482                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3483                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3484                 {
3485                         if (prev_tag && command_cmd)
3486                         {
3487                                 /* Look up the tag and validate the item */
3488                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3489                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3490                                 else if (!get_item_okay(k)) /* Reject */;
3491                                 else
3492                                 {
3493                                         /* Accept that choice */
3494                                         (*cp) = k;
3495
3496                                         /* Forget restrictions */
3497                                         item_tester_tval = 0;
3498                                         item_tester_hook = NULL;
3499                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3500
3501                                         /* Success */
3502                                         return TRUE;
3503                                 }
3504
3505                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3506                         }
3507
3508                         /* Verify the item */
3509                         else if (get_item_okay(*cp))
3510                         {
3511                                 /* Forget restrictions */
3512                                 item_tester_tval = 0;
3513                                 item_tester_hook = NULL;
3514                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3515
3516                                 /* Success */
3517                                 return TRUE;
3518                         }
3519                 }
3520         }
3521
3522 #endif /* ALLOW_REPEAT */
3523
3524
3525         /* Paranoia XXX XXX XXX */
3526         msg_print(NULL);
3527
3528
3529         /* Not done */
3530         done = FALSE;
3531
3532         /* No item selected */
3533         item = FALSE;
3534
3535
3536         /* Full inventory */
3537         i1 = 0;
3538         i2 = INVEN_PACK - 1;
3539
3540         /* Forbid inventory */
3541         if (!inven) i2 = -1;
3542         else if (use_menu)
3543         {
3544                 for (j = 0; j < INVEN_PACK; j++)
3545                         if (item_tester_okay(&inventory[j])) max_inven++;
3546         }
3547
3548         /* Restrict inventory indexes */
3549         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3550         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3551
3552
3553         /* Full equipment */
3554         e1 = INVEN_RARM;
3555         e2 = INVEN_TOTAL - 1;
3556
3557         /* Forbid equipment */
3558         if (!equip) e2 = -1;
3559         else if (use_menu)
3560         {
3561                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3562                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
3563                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
3564         }
3565
3566         /* Restrict equipment indexes */
3567         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3568         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3569
3570         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
3571         {
3572                 if (p_ptr->migite)
3573                 {
3574                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3575                 }
3576                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3577         }
3578
3579
3580         /* Restrict floor usage */
3581         if (floor)
3582         {
3583                 /* Scan all objects in the grid */
3584                 for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
3585                 {
3586                         object_type *o_ptr;
3587
3588                         /* Acquire object */
3589                         o_ptr = &o_list[this_o_idx];
3590
3591                         /* Acquire next object */
3592                         next_o_idx = o_ptr->next_o_idx;
3593
3594                         /* Accept the item on the floor if legal */
3595                         if (item_tester_okay(o_ptr) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
3596                 }
3597         }
3598
3599         /* Require at least one legal choice */
3600         if (!allow_floor && (i1 > i2) && (e1 > e2))
3601         {
3602                 /* Cancel p_ptr->command_see */
3603                 command_see = FALSE;
3604
3605                 /* Oops */
3606                 oops = TRUE;
3607
3608                 /* Done */
3609                 done = TRUE;
3610
3611                 if (select_the_force) {
3612                     *cp = INVEN_FORCE;
3613                     item = TRUE;
3614                 }
3615         }
3616
3617         /* Analyze choices */
3618         else
3619         {
3620                 /* Hack -- Start on equipment if requested */
3621                 if (command_see && command_wrk && equip)
3622                 {
3623                         command_wrk = TRUE;
3624                 }
3625
3626                 /* Use inventory if allowed */
3627                 else if (inven)
3628                 {
3629                         command_wrk = FALSE;
3630                 }
3631
3632                 /* Use equipment if allowed */
3633                 else if (equip)
3634                 {
3635                         command_wrk = TRUE;
3636                 }
3637
3638                 /* Use inventory for floor */
3639                 else
3640                 {
3641                         command_wrk = FALSE;
3642                 }
3643         }
3644
3645
3646         /*
3647          * Äɲ媥ץ·¥ç¥ó(always_show_list)¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¾ï¤Ë°ìÍ÷¤òɽ¼¨¤¹¤ë
3648          */
3649         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
3650
3651         /* Hack -- start out in "display" mode */
3652         if (command_see)
3653         {
3654                 /* Save screen */
3655                 screen_save();
3656         }
3657
3658
3659         /* Repeat until done */
3660         while (!done)
3661         {
3662                 int get_item_label = 0;
3663
3664                 /* Show choices */
3665                 int ni = 0;
3666                 int ne = 0;
3667
3668                 /* Scan windows */
3669                 for (j = 0; j < 8; j++)
3670                 {
3671                         /* Unused */
3672                         if (!angband_term[j]) continue;
3673
3674                         /* Count windows displaying inven */
3675                         if (window_flag[j] & (PW_INVEN)) ni++;
3676
3677                         /* Count windows displaying equip */
3678                         if (window_flag[j] & (PW_EQUIP)) ne++;
3679                 }
3680
3681                 /* Toggle if needed */
3682                 if ((command_wrk && ni && !ne) ||
3683                     (!command_wrk && !ni && ne))
3684                 {
3685                         /* Toggle */
3686                         toggle_inven_equip();
3687
3688                         /* Track toggles */
3689                         toggle = !toggle;
3690                 }
3691
3692                 /* Update */
3693                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3694
3695                 /* Redraw windows */
3696                 window_stuff();
3697
3698
3699                 /* Inventory screen */
3700                 if (!command_wrk)
3701                 {
3702                         /* Redraw if needed */
3703                         if (command_see) get_item_label = show_inven(menu_line);
3704                 }
3705
3706                 /* Equipment screen */
3707                 else
3708                 {
3709                         /* Redraw if needed */
3710                         if (command_see) get_item_label = show_equip(menu_line);
3711                 }
3712
3713                 /* Viewing inventory */
3714                 if (!command_wrk)
3715                 {
3716                         /* Begin the prompt */
3717 #ifdef JP
3718                         sprintf(out_val, "»ý¤Áʪ:");
3719 #else
3720                         sprintf(out_val, "Inven:");
3721 #endif
3722
3723                         /* Some legal items */
3724                         if ((i1 <= i2) && !use_menu)
3725                         {
3726                                 /* Build the prompt */
3727 #ifdef JP
3728                                 sprintf(tmp_val, "%c-%c,'(',')',",
3729 #else
3730                                 sprintf(tmp_val, " %c-%c,'(',')',",
3731 #endif
3732                                         index_to_label(i1), index_to_label(i2));
3733
3734                                 /* Append */
3735                                 strcat(out_val, tmp_val);
3736                         }
3737
3738                         /* Indicate ability to "view" */
3739 #ifdef JP
3740                         if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
3741 #else
3742                         if (!command_see && !use_menu) strcat(out_val, " * to see,");
3743 #endif
3744
3745                         /* Append */
3746 #ifdef JP
3747                         if (equip) strcat(out_val, format(" %s ÁõÈ÷ÉÊ,", use_menu ? "'4'or'6'" : "'/'"));
3748 #else
3749                         if (equip) strcat(out_val, format(" %s for Equip,", use_menu ? "4 or 6" : "/"));
3750 #endif
3751                 }
3752
3753                 /* Viewing equipment */
3754                 else
3755                 {
3756                         /* Begin the prompt */
3757 #ifdef JP
3758                         sprintf(out_val, "ÁõÈ÷ÉÊ:");
3759 #else
3760                         sprintf(out_val, "Equip:");
3761 #endif
3762
3763                         /* Some legal items */
3764                         if ((e1 <= e2) && !use_menu)
3765                         {
3766                                 /* Build the prompt */
3767 #ifdef JP
3768                                 sprintf(tmp_val, "%c-%c,'(',')',",
3769 #else
3770                                 sprintf(tmp_val, " %c-%c,'(',')',",
3771 #endif
3772                                         index_to_label(e1), index_to_label(e2));
3773
3774                                 /* Append */
3775                                 strcat(out_val, tmp_val);
3776                         }
3777
3778                         /* Indicate ability to "view" */
3779 #ifdef JP
3780                         if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
3781 #else
3782                         if (!command_see) strcat(out_val, " * to see,");
3783 #endif
3784
3785                         /* Append */
3786 #ifdef JP
3787                         if (inven) strcat(out_val, format(" %s »ý¤Áʪ,", use_menu ? "'4'or'6'" : "'/'"));
3788 #else
3789                         if (inven) strcat(out_val, format(" %s for Inven,", use_menu ? "4 or 6" : "'/'"));
3790 #endif
3791                 }
3792
3793                 /* Indicate legality of the "floor" item */
3794 #ifdef JP
3795                 if (allow_floor) strcat(out_val, " '-'¾²¾å,");
3796                 if (select_the_force) strcat(out_val, " 'w'Îýµ¤½Ñ,");
3797 #else
3798                 if (allow_floor) strcat(out_val, " - for floor,");
3799                 if (select_the_force) strcat(out_val, " w for the Force,");
3800 #endif
3801
3802                 /* Finish the prompt */
3803                 strcat(out_val, " ESC");
3804
3805                 /* Build the prompt */
3806                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
3807
3808                 /* Show the prompt */
3809                 prt(tmp_val, 0, 0);
3810
3811                 /* Get a key */
3812                 which = inkey();
3813
3814                 if (use_menu)
3815                 {
3816                 int max_line = (command_wrk ? max_equip : max_inven);
3817                 switch (which)
3818                 {
3819                         case ESCAPE:
3820                         case 'z':
3821                         case 'Z':
3822                         case '0':
3823                         {
3824                                 done = TRUE;
3825                                 break;
3826                         }
3827
3828                         case '8':
3829                         case 'k':
3830                         case 'K':
3831                         {
3832                                 menu_line += (max_line - 1);
3833                                 break;
3834                         }
3835
3836                         case '2':
3837                         case 'j':
3838                         case 'J':
3839                         {
3840                                 menu_line++;
3841                                 break;
3842                         }
3843
3844                         case '4':
3845                         case '6':
3846                         case 'h':
3847                         case 'H':
3848                         case 'l':
3849                         case 'L':
3850                         {
3851                                 /* Verify legality */
3852                                 if (!inven || !equip)
3853                                 {
3854                                         bell();
3855                                         break;
3856                                 }
3857
3858                                 /* Hack -- Fix screen */
3859                                 if (command_see)
3860                                 {
3861                                         /* Load screen */
3862                                         screen_load();
3863
3864                                         /* Save screen */
3865                                         screen_save();
3866                                 }
3867
3868                                 /* Switch inven/equip */
3869                                 command_wrk = !command_wrk;
3870                                 max_line = (command_wrk ? max_equip : max_inven);
3871                                 if (menu_line > max_line) menu_line = max_line;
3872
3873                                 /* Need to redraw */
3874                                 break;
3875                         }
3876
3877                         case 'x':
3878                         case 'X':
3879                         case '\r':
3880                         case '\n':
3881                         {
3882                                 if (command_wrk == USE_FLOOR)
3883                                 {
3884                                         /* Special index */
3885                                         (*cp) = -get_item_label;
3886                                 }
3887                                 else
3888                                 {
3889                                         /* Validate the item */
3890                                         if (!get_item_okay(get_item_label))
3891                                         {
3892                                                 bell();
3893                                                 break;
3894                                         }
3895
3896                                         /* Allow player to "refuse" certain actions */
3897                                         if (!get_item_allow(get_item_label))
3898                                         {
3899                                                 done = TRUE;
3900                                                 break;
3901                                         }
3902
3903                                         /* Accept that choice */
3904                                         (*cp) = get_item_label;
3905                                 }
3906
3907                                 item = TRUE;
3908                                 done = TRUE;
3909                                 break;
3910                         }
3911                         case 'w':
3912                         {
3913                                 if (select_the_force) {
3914                                         *cp = INVEN_FORCE;
3915                                         item = TRUE;
3916                                         done = TRUE;
3917                                         break;
3918                                 }
3919                         }
3920                 }
3921                 if (menu_line > max_line) menu_line -= max_line;
3922                 }
3923                 else
3924                 {
3925                 /* Parse it */
3926                 switch (which)
3927                 {
3928                         case ESCAPE:
3929                         {
3930                                 done = TRUE;
3931                                 break;
3932                         }
3933
3934                         case '*':
3935                         case '?':
3936                         case ' ':
3937                         {
3938                                 /* Hide the list */
3939                                 if (command_see)
3940                                 {
3941                                         /* Flip flag */
3942                                         command_see = FALSE;
3943
3944                                         /* Load screen */
3945                                         screen_load();
3946                                 }
3947
3948                                 /* Show the list */
3949                                 else
3950                                 {
3951                                         /* Save screen */
3952                                         screen_save();
3953
3954                                         /* Flip flag */
3955                                         command_see = TRUE;
3956                                 }
3957                                 break;
3958                         }
3959
3960                         case '/':
3961                         {
3962                                 /* Verify legality */
3963                                 if (!inven || !equip)
3964                                 {
3965                                         bell();
3966                                         break;
3967                                 }
3968
3969                                 /* Hack -- Fix screen */
3970                                 if (command_see)
3971                                 {
3972                                         /* Load screen */
3973                                         screen_load();
3974
3975                                         /* Save screen */
3976                                         screen_save();
3977                                 }
3978
3979                                 /* Switch inven/equip */
3980                                 command_wrk = !command_wrk;
3981
3982                                 /* Need to redraw */
3983                                 break;
3984                         }
3985
3986                         case '-':
3987                         {
3988                                 /* Use floor item */
3989                                 if (allow_floor)
3990                                 {
3991                                         /* Scan all objects in the grid */
3992                                         for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
3993                                         {
3994                                                 object_type *o_ptr;
3995
3996                                                 /* Acquire object */
3997                                                 o_ptr = &o_list[this_o_idx];
3998
3999                                                 /* Acquire next object */
4000                                                 next_o_idx = o_ptr->next_o_idx;
4001
4002                                                 /* Validate the item */
4003                                                 if (!item_tester_okay(o_ptr)) continue;
4004
4005                                                 /* Special index */
4006                                                 k = 0 - this_o_idx;
4007
4008                                                 /* Verify the item (if required) */
4009 #ifdef JP
4010 if (other_query_flag && !verify("ËÜÅö¤Ë", k)) continue;
4011 #else
4012                                                 if (other_query_flag && !verify("Try", k)) continue;
4013 #endif
4014
4015
4016                                                 /* Allow player to "refuse" certain actions */
4017                                                 if (!get_item_allow(k)) continue;
4018
4019                                                 /* Accept that choice */
4020                                                 (*cp) = k;
4021                                                 item = TRUE;
4022                                                 done = TRUE;
4023                                                 break;
4024                                         }
4025
4026                                         /* Outer break */
4027                                         if (done) break;
4028                                 }
4029
4030                                 /* Oops */
4031                                 bell();
4032                                 break;
4033                         }
4034
4035                         case '0':
4036                         case '1': case '2': case '3':
4037                         case '4': case '5': case '6':
4038                         case '7': case '8': case '9':
4039                         {
4040                                 /* Look up the tag */
4041                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
4042                                 {
4043                                         bell();
4044                                         break;
4045                                 }
4046
4047                                 /* Hack -- Validate the item */
4048                                 if ((k < INVEN_RARM) ? !inven : !equip)
4049                                 {
4050                                         bell();
4051                                         break;
4052                                 }
4053
4054                                 /* Validate the item */
4055                                 if (!get_item_okay(k))
4056                                 {
4057                                         bell();
4058                                         break;
4059                                 }
4060
4061                                 /* Allow player to "refuse" certain actions */
4062                                 if (!get_item_allow(k))
4063                                 {
4064                                         done = TRUE;
4065                                         break;
4066                                 }
4067
4068                                 /* Accept that choice */
4069                                 (*cp) = k;
4070                                 item = TRUE;
4071                                 done = TRUE;
4072 #ifdef ALLOW_REPEAT
4073                                 cur_tag = which;
4074 #endif /* ALLOW_REPEAT */
4075                                 break;
4076                         }
4077
4078 #if 0
4079                         case '\n':
4080                         case '\r':
4081                         {
4082                                 /* Choose "default" inventory item */
4083                                 if (!command_wrk)
4084                                 {
4085                                         k = ((i1 == i2) ? i1 : -1);
4086                                 }
4087
4088                                 /* Choose "default" equipment item */
4089                                 else
4090                                 {
4091                                         k = ((e1 == e2) ? e1 : -1);
4092                                 }
4093
4094                                 /* Validate the item */
4095                                 if (!get_item_okay(k))
4096                                 {
4097                                         bell();
4098                                         break;
4099                                 }
4100
4101                                 /* Allow player to "refuse" certain actions */
4102                                 if (!get_item_allow(k))
4103                                 {
4104                                         done = TRUE;
4105                                         break;
4106                                 }
4107
4108                                 /* Accept that choice */
4109                                 (*cp) = k;
4110                                 item = TRUE;
4111                                 done = TRUE;
4112                                 break;
4113                         }
4114 #endif
4115
4116                         case 'w':
4117                         {
4118                                 if (select_the_force) {
4119                                         *cp = INVEN_FORCE;
4120                                         item = TRUE;
4121                                         done = TRUE;
4122                                         break;
4123                                 }
4124
4125                                 /* Fall through */
4126                         }
4127
4128                         default:
4129                         {
4130                                 int ver;
4131                                 bool not_found = FALSE;
4132
4133                                 /* Look up the alphabetical tag */
4134                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
4135                                 {
4136                                         not_found = TRUE;
4137                                 }
4138
4139                                 /* Hack -- Validate the item */
4140                                 else if ((k < INVEN_RARM) ? !inven : !equip)
4141                                 {
4142                                         not_found = TRUE;
4143                                 }
4144
4145                                 /* Validate the item */
4146                                 else if (!get_item_okay(k))
4147                                 {
4148                                         not_found = TRUE;
4149                                 }
4150
4151                                 if (!not_found)
4152                                 {
4153                                         /* Accept that choice */
4154                                         (*cp) = k;
4155                                         item = TRUE;
4156                                         done = TRUE;
4157 #ifdef ALLOW_REPEAT
4158                                         cur_tag = which;
4159 #endif /* ALLOW_REPEAT */
4160                                         break;
4161                                 }
4162
4163                                 /* Extract "query" setting */
4164                                 ver = isupper(which);
4165                                 which = tolower(which);
4166
4167                                 /* Convert letter to inventory index */
4168                                 if (!command_wrk)
4169                                 {
4170                                         if (which == '(') k = i1;
4171                                         else if (which == ')') k = i2;
4172                                         else k = label_to_inven(which);
4173                                 }
4174
4175                                 /* Convert letter to equipment index */
4176                                 else
4177                                 {
4178                                         if (which == '(') k = e1;
4179                                         else if (which == ')') k = e2;
4180                                         else k = label_to_equip(which);
4181                                 }
4182
4183                                 /* Validate the item */
4184                                 if (!get_item_okay(k))
4185                                 {
4186                                         bell();
4187                                         break;
4188                                 }
4189
4190                                 /* Verify the item */
4191 #ifdef JP
4192 if (ver && !verify("ËÜÅö¤Ë", k))
4193 #else
4194                                 if (ver && !verify("Try", k))
4195 #endif
4196
4197                                 {
4198                                         done = TRUE;
4199                                         break;
4200                                 }
4201
4202                                 /* Allow player to "refuse" certain actions */
4203                                 if (!get_item_allow(k))
4204                                 {
4205                                         done = TRUE;
4206                                         break;
4207                                 }
4208
4209                                 /* Accept that choice */
4210                                 (*cp) = k;
4211                                 item = TRUE;
4212                                 done = TRUE;
4213                                 break;
4214                         }
4215                 }
4216                 }
4217         }
4218
4219
4220         /* Fix the screen if necessary */
4221         if (command_see)
4222         {
4223                 /* Load screen */
4224                 screen_load();
4225
4226                 /* Hack -- Cancel "display" */
4227                 command_see = FALSE;
4228         }
4229
4230
4231         /* Forget the item_tester_tval restriction */
4232         item_tester_tval = 0;
4233
4234         item_tester_no_ryoute = FALSE;
4235
4236         /* Forget the item_tester_hook restriction */
4237         item_tester_hook = NULL;
4238
4239
4240         /* Clean up  'show choices' */
4241         /* Toggle again if needed */
4242         if (toggle) toggle_inven_equip();
4243
4244         /* Update */
4245         p_ptr->window |= (PW_INVEN | PW_EQUIP);
4246
4247         /* Window stuff */
4248         window_stuff();
4249
4250
4251         /* Clear the prompt line */
4252         prt("", 0, 0);
4253
4254         /* Warning if needed */
4255         if (oops && str) msg_print(str);
4256
4257         if (item)
4258         {
4259 #ifdef ALLOW_REPEAT
4260                 repeat_push(*cp);
4261                 if (command_cmd) prev_tag = cur_tag;
4262 #endif /* ALLOW_REPEAT */
4263
4264                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4265         }
4266
4267         /* Result */
4268         return (item);
4269 }
4270
4271
4272 #ifdef ALLOW_EASY_FLOOR
4273
4274 /*
4275  * scan_floor --
4276  *
4277  * Return a list of o_list[] indexes of items at the given cave
4278  * location. Valid flags are:
4279  *
4280  *              mode & 0x01 -- Item tester
4281  *              mode & 0x02 -- Marked items only
4282  *              mode & 0x04 -- Stop after first
4283  */
4284 int scan_floor(int *items, int y, int x, int mode)
4285 {
4286         int this_o_idx, next_o_idx;
4287
4288         int num = 0;
4289
4290         /* Sanity */
4291         if (!in_bounds(y, x)) return 0;
4292
4293         /* Scan all objects in the grid */
4294         for (this_o_idx = cave[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
4295         {
4296                 object_type *o_ptr;
4297
4298                 /* Acquire object */
4299                 o_ptr = &o_list[this_o_idx];
4300
4301                 /* Acquire next object */
4302                 next_o_idx = o_ptr->next_o_idx;
4303
4304                 /* Item tester */
4305                 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
4306
4307                 /* Marked */
4308                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
4309
4310                 /* Accept this item */
4311                 /* XXX Hack -- Enforce limit */
4312                 if (num < 23)
4313                         items[num] = this_o_idx;
4314
4315                 num++;
4316
4317                 /* Only one */
4318                 if (mode & 0x04) break;
4319         }
4320
4321         /* Result */
4322         return num;
4323 }
4324
4325
4326 /*
4327  * Display a list of the items on the floor at the given location.
4328  */
4329 int show_floor(int target_item, int y, int x, int *min_width)
4330 {
4331         int i, j, k, l;
4332         int col, len;
4333
4334         object_type *o_ptr;
4335
4336         char o_name[MAX_NLEN];
4337
4338         char tmp_val[80];
4339
4340         int out_index[23];
4341         byte out_color[23];
4342         char out_desc[23][MAX_NLEN];
4343         int target_item_label = 0;
4344
4345         int floor_list[23], floor_num;
4346         int wid, hgt;
4347         char floor_label[52 + 1];
4348
4349         bool dont_need_to_show_weights = TRUE;
4350
4351         /* Get size */
4352         Term_get_size(&wid, &hgt);
4353
4354         /* Default length */
4355         len = MAX((*min_width), 20);
4356
4357
4358         /* Scan for objects in the grid, using item_tester_okay() */
4359         floor_num = scan_floor(floor_list, y, x, 0x03);
4360
4361         /* Display the floor objects */
4362         for (k = 0, i = 0; i < floor_num && i < 23; i++)
4363         {
4364                 o_ptr = &o_list[floor_list[i]];
4365
4366                 /* Describe the object */
4367                 object_desc(o_name, o_ptr, 0);
4368
4369                 /* Save the index */
4370                 out_index[k] = i;
4371
4372                 /* Acquire inventory color */
4373                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
4374
4375                 /* Save the object description */
4376                 strcpy(out_desc[k], o_name);
4377
4378                 /* Find the predicted "line length" */
4379                 l = strlen(out_desc[k]) + 5;
4380
4381                 /* Be sure to account for the weight */
4382                 if (show_weights) l += 9;
4383
4384                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
4385
4386                 /* Maintain the maximum length */
4387                 if (l > len) len = l;
4388
4389                 /* Advance to next "line" */
4390                 k++;
4391         }
4392
4393         if (show_weights && dont_need_to_show_weights) len -= 9;
4394
4395         /* Save width */
4396         *min_width = len;
4397
4398         /* Find the column to start in */
4399         col = (len > wid - 4) ? 0 : (wid - len - 1);
4400
4401         prepare_label_string_floor(floor_label, floor_list, floor_num);
4402
4403         /* Output each entry */
4404         for (j = 0; j < k; j++)
4405         {
4406                 /* Get the index */
4407                 i = floor_list[out_index[j]];
4408
4409                 /* Get the item */
4410                 o_ptr = &o_list[i];
4411
4412                 /* Clear the line */
4413                 prt("", j + 1, col ? col - 2 : col);
4414
4415                 if (use_menu && target_item)
4416                 {
4417                         if (j == (target_item-1))
4418                         {
4419 #ifdef JP
4420                                 strcpy(tmp_val, "¡Õ");
4421 #else
4422                                 strcpy(tmp_val, "> ");
4423 #endif
4424                                 target_item_label = i;
4425                         }
4426                         else strcpy(tmp_val, "   ");
4427                 }
4428                 else
4429                 {
4430                         /* Prepare an index --(-- */
4431                         sprintf(tmp_val, "%c)", floor_label[j]);
4432                 }
4433
4434                 /* Clear the line with the (possibly indented) index */
4435                 put_str(tmp_val, j + 1, col);
4436
4437                 /* Display the entry itself */
4438                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
4439
4440                 /* Display the weight if needed */
4441                 if (show_weights && (o_ptr->tval != TV_GOLD))
4442                 {
4443                         int wgt = o_ptr->weight * o_ptr->number;
4444 #ifdef JP
4445                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
4446 #else
4447                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
4448 #endif
4449
4450                         prt(tmp_val, j + 1, wid - 9);
4451                 }
4452         }
4453
4454         /* Make a "shadow" below the list (only if needed) */
4455         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
4456
4457         return target_item_label;
4458 }
4459
4460 /*
4461  * This version of get_item() is called by get_item() when
4462  * the easy_floor is on.
4463  */
4464 bool get_item_floor(int *cp, cptr pmt, cptr str, int mode)
4465 {
4466         char n1 = ' ', n2 = ' ', which = ' ';
4467
4468         int j, k, i1, i2, e1, e2;
4469
4470         bool done, item;
4471
4472         bool oops = FALSE;
4473
4474         /* Extract args */
4475         bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
4476         bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
4477         bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
4478
4479         bool allow_equip = FALSE;
4480         bool allow_inven = FALSE;
4481         bool allow_floor = FALSE;
4482
4483         bool toggle = FALSE;
4484
4485         char tmp_val[160];
4486         char out_val[160];
4487
4488         int floor_num, floor_list[23], floor_top = 0;
4489         int min_width = 0;
4490
4491         extern bool select_the_force;
4492
4493         int menu_line = (use_menu ? 1 : 0);
4494         int max_inven = 0;
4495         int max_equip = 0;
4496
4497 #ifdef ALLOW_REPEAT
4498
4499         static char prev_tag = '\0';
4500         char cur_tag = '\0';
4501
4502         /* Get the item index */
4503         if (repeat_pull(cp))
4504         {
4505                 /* the_force */
4506                 if (select_the_force && (*cp == INVEN_FORCE))
4507                 {
4508                         item_tester_tval = 0;
4509                         item_tester_hook = NULL;
4510                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4511                         return (TRUE);
4512                 }
4513
4514                 /* Floor item? */
4515                 else if (floor && (*cp < 0))
4516                 {
4517                         if (prev_tag && command_cmd)
4518                         {
4519                                 /* Scan all objects in the grid */
4520                                 floor_num = scan_floor(floor_list, py, px, 0x03);
4521
4522                                 /* Look up the tag */
4523                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
4524                                 {
4525                                         /* Accept that choice */
4526                                         (*cp) = 0 - floor_list[k];
4527
4528                                         /* Forget restrictions */
4529                                         item_tester_tval = 0;
4530                                         item_tester_hook = NULL;
4531                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4532
4533                                         /* Success */
4534                                         return TRUE;
4535                                 }
4536
4537                                 prev_tag = '\0'; /* prev_tag is no longer effective */
4538                         }
4539
4540                         /* Validate the item */
4541                         else if (item_tester_okay(&o_list[0 - (*cp)]))
4542                         {
4543                                 /* Forget restrictions */
4544                                 item_tester_tval = 0;
4545                                 item_tester_hook = NULL;
4546                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4547
4548                                 /* Success */
4549                                 return TRUE;
4550                         }
4551                 }
4552
4553                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
4554                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
4555                 {
4556                         if (prev_tag && command_cmd)
4557                         {
4558                                 /* Look up the tag and validate the item */
4559                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
4560                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
4561                                 else if (!get_item_okay(k)) /* Reject */;
4562                                 else
4563                                 {
4564                                         /* Accept that choice */
4565                                         (*cp) = k;
4566
4567                                         /* Forget restrictions */
4568                                         item_tester_tval = 0;
4569                                         item_tester_hook = NULL;
4570                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4571
4572                                         /* Success */
4573                                         return TRUE;
4574                                 }
4575
4576                                 prev_tag = '\0'; /* prev_tag is no longer effective */
4577                         }
4578
4579                         /* Verify the item */
4580                         else if (get_item_okay(*cp))
4581                         {
4582                                 /* Forget restrictions */
4583                                 item_tester_tval = 0;
4584                                 item_tester_hook = NULL;
4585                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4586
4587                                 /* Success */
4588                                 return TRUE;
4589                         }
4590                 }
4591         }
4592
4593 #endif /* ALLOW_REPEAT */
4594
4595
4596         /* Paranoia XXX XXX XXX */
4597         msg_print(NULL);
4598
4599
4600         /* Not done */
4601         done = FALSE;
4602
4603         /* No item selected */
4604         item = FALSE;
4605
4606
4607         /* Full inventory */
4608         i1 = 0;
4609         i2 = INVEN_PACK - 1;
4610
4611         /* Forbid inventory */
4612         if (!inven) i2 = -1;
4613         else if (use_menu)
4614         {
4615                 for (j = 0; j < INVEN_PACK; j++)
4616                         if (item_tester_okay(&inventory[j])) max_inven++;
4617         }
4618
4619         /* Restrict inventory indexes */
4620         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
4621         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
4622
4623
4624         /* Full equipment */
4625         e1 = INVEN_RARM;
4626         e2 = INVEN_TOTAL - 1;
4627
4628         /* Forbid equipment */
4629         if (!equip) e2 = -1;
4630         else if (use_menu)
4631         {
4632                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
4633                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
4634                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
4635         }
4636
4637         /* Restrict equipment indexes */
4638         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
4639         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
4640
4641         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
4642         {
4643                 if (p_ptr->migite)
4644                 {
4645                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
4646                 }
4647                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
4648         }
4649
4650
4651         /* Count "okay" floor items */
4652         floor_num = 0;
4653
4654         /* Restrict floor usage */
4655         if (floor)
4656         {
4657                 /* Scan all objects in the grid */
4658                 floor_num = scan_floor(floor_list, py, px, 0x03);
4659         }
4660
4661         /* Accept inventory */
4662         if (i1 <= i2) allow_inven = TRUE;
4663
4664         /* Accept equipment */
4665         if (e1 <= e2) allow_equip = TRUE;
4666
4667         /* Accept floor */
4668         if (floor_num) allow_floor = TRUE;
4669
4670         /* Require at least one legal choice */
4671         if (!allow_inven && !allow_equip && !allow_floor)
4672         {
4673                 /* Cancel p_ptr->command_see */
4674                 command_see = FALSE;
4675
4676                 /* Oops */
4677                 oops = TRUE;
4678
4679                 /* Done */
4680                 done = TRUE;
4681
4682                 if (select_the_force) {
4683                     *cp = INVEN_FORCE;
4684                     item = TRUE;
4685                 }
4686         }
4687
4688         /* Analyze choices */
4689         else
4690         {
4691                 /* Hack -- Start on equipment if requested */
4692                 if (command_see && (command_wrk == (USE_EQUIP))
4693                         && allow_equip)
4694                 {
4695                         command_wrk = (USE_EQUIP);
4696                 }
4697
4698                 /* Use inventory if allowed */
4699                 else if (allow_inven)
4700                 {
4701                         command_wrk = (USE_INVEN);
4702                 }
4703
4704                 /* Use equipment if allowed */
4705                 else if (allow_equip)
4706                 {
4707                         command_wrk = (USE_EQUIP);
4708                 }
4709
4710                 /* Use floor if allowed */
4711                 else if (allow_floor)
4712                 {
4713                         command_wrk = (USE_FLOOR);
4714                 }
4715         }
4716
4717         /*
4718          * Äɲ媥ץ·¥ç¥ó(always_show_list)¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¤Ï¾ï¤Ë°ìÍ÷¤òɽ¼¨¤¹¤ë
4719          */
4720         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
4721
4722         /* Hack -- start out in "display" mode */
4723         if (command_see)
4724         {
4725                 /* Save screen */
4726                 screen_save();
4727         }
4728
4729         /* Repeat until done */
4730         while (!done)
4731         {
4732                 int get_item_label = 0;
4733
4734                 /* Show choices */
4735                 int ni = 0;
4736                 int ne = 0;
4737
4738                 /* Scan windows */
4739                 for (j = 0; j < 8; j++)
4740                 {
4741                         /* Unused */
4742                         if (!angband_term[j]) continue;
4743
4744                         /* Count windows displaying inven */
4745                         if (window_flag[j] & (PW_INVEN)) ni++;
4746
4747                         /* Count windows displaying equip */
4748                         if (window_flag[j] & (PW_EQUIP)) ne++;
4749                 }
4750
4751                 /* Toggle if needed */
4752                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
4753                     (command_wrk == (USE_INVEN) && !ni && ne))
4754                 {
4755                         /* Toggle */
4756                         toggle_inven_equip();
4757
4758                         /* Track toggles */
4759                         toggle = !toggle;
4760                 }
4761
4762                 /* Update */
4763                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4764
4765                 /* Redraw windows */
4766                 window_stuff();
4767
4768                 /* Inventory screen */
4769                 if (command_wrk == (USE_INVEN))
4770                 {
4771                         /* Extract the legal requests */
4772                         n1 = I2A(i1);
4773                         n2 = I2A(i2);
4774
4775                         /* Redraw if needed */
4776                         if (command_see) get_item_label = show_inven(menu_line);
4777                 }
4778
4779                 /* Equipment screen */
4780                 else if (command_wrk == (USE_EQUIP))
4781                 {
4782                         /* Extract the legal requests */
4783                         n1 = I2A(e1 - INVEN_RARM);
4784                         n2 = I2A(e2 - INVEN_RARM);
4785
4786                         /* Redraw if needed */
4787                         if (command_see) get_item_label = show_equip(menu_line);
4788                 }
4789
4790                 /* Floor screen */
4791                 else if (command_wrk == (USE_FLOOR))
4792                 {
4793                         j = floor_top;
4794                         k = MIN(floor_top + 23, floor_num) - 1;
4795
4796                         /* Extract the legal requests */
4797                         n1 = I2A(j - floor_top);
4798                         n2 = I2A(k - floor_top);
4799
4800                         /* Redraw if needed */
4801                         if (command_see) get_item_label = show_floor(menu_line, py, px, &min_width);
4802                 }
4803
4804                 /* Viewing inventory */
4805                 if (command_wrk == (USE_INVEN))
4806                 {
4807                         /* Begin the prompt */
4808 #ifdef JP
4809                         sprintf(out_val, "»ý¤Áʪ:");
4810 #else
4811                         sprintf(out_val, "Inven:");
4812 #endif
4813
4814                         if (!use_menu)
4815                         {
4816                                 /* Build the prompt */
4817 #ifdef JP
4818                                 sprintf(tmp_val, "%c-%c,'(',')',",
4819 #else
4820                                 sprintf(tmp_val, " %c-%c,'(',')',",
4821 #endif
4822                                         index_to_label(i1), index_to_label(i2));
4823
4824                                 /* Append */
4825                                 strcat(out_val, tmp_val);
4826                         }
4827
4828                         /* Indicate ability to "view" */
4829 #ifdef JP
4830                         if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
4831 #else
4832                         if (!command_see && !use_menu) strcat(out_val, " * to see,");
4833 #endif
4834
4835                         /* Append */
4836                         if (allow_equip)
4837                         {
4838 #ifdef JP
4839                                 if (!use_menu)
4840                                         strcat(out_val, " '/' ÁõÈ÷ÉÊ,");
4841                                 else if (allow_floor)
4842                                         strcat(out_val, " '6' ÁõÈ÷ÉÊ,");
4843                                 else
4844                                         strcat(out_val, " '4'or'6' ÁõÈ÷ÉÊ,");
4845 #else
4846                                 if (!use_menu)
4847                                         strcat(out_val, " / for Equip,");
4848                                 else if (allow_floor)
4849                                         strcat(out_val, " 6 for Equip,");
4850                                 else
4851                                         strcat(out_val, " 4 or 6 for Equip,");
4852 #endif
4853                         }
4854
4855                         /* Append */
4856                         if (allow_floor)
4857                         {
4858 #ifdef JP
4859                                 if (!use_menu)
4860                                         strcat(out_val, " '-'¾²¾å,");
4861                                 else if (allow_equip)
4862                                         strcat(out_val, " '4' ¾²¾å,");
4863                                 else
4864                                         strcat(out_val, " '4'or'6' ¾²¾å,");
4865 #else
4866                                 if (!use_menu)
4867                                         strcat(out_val, " - for floor,");
4868                                 else if (allow_equip)
4869                                         strcat(out_val, " 4 for floor,");
4870                                 else
4871                                         strcat(out_val, " 4 or 6 for floor,");
4872 #endif
4873                         }
4874                 }
4875
4876                 /* Viewing equipment */
4877                 else if (command_wrk == (USE_EQUIP))
4878                 {
4879                         /* Begin the prompt */
4880 #ifdef JP
4881                         sprintf(out_val, "ÁõÈ÷ÉÊ:");
4882 #else
4883                         sprintf(out_val, "Equip:");
4884 #endif
4885
4886                         if (!use_menu)
4887                         {
4888                                 /* Build the prompt */
4889 #ifdef JP
4890                                 sprintf(tmp_val, "%c-%c,'(',')',",
4891 #else
4892                                 sprintf(tmp_val, " %c-%c,'(',')',",
4893 #endif
4894                                         index_to_label(e1), index_to_label(e2));
4895
4896                                 /* Append */
4897                                 strcat(out_val, tmp_val);
4898                         }
4899
4900                         /* Indicate ability to "view" */
4901 #ifdef JP
4902                         if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
4903 #else
4904                         if (!command_see && !use_menu) strcat(out_val, " * to see,");
4905 #endif
4906
4907                         /* Append */
4908                         if (allow_inven)
4909                         {
4910 #ifdef JP
4911                                 if (!use_menu)
4912                                         strcat(out_val, " '/' »ý¤Áʪ,");
4913                                 else if (allow_floor)
4914                                         strcat(out_val, " '4' »ý¤Áʪ,");
4915                                 else
4916                                         strcat(out_val, " '4'or'6' »ý¤Áʪ,");
4917 #else
4918                                 if (!use_menu)
4919                                         strcat(out_val, " / for Inven,");
4920                                 else if (allow_floor)
4921                                         strcat(out_val, " 4 for Inven,");
4922                                 else
4923                                         strcat(out_val, " 4 or 6 for Inven,");
4924 #endif
4925                         }
4926
4927                         /* Append */
4928                         if (allow_floor)
4929                         {
4930 #ifdef JP
4931                                 if (!use_menu)
4932                                         strcat(out_val, " '-'¾²¾å,");
4933                                 else if (allow_inven)
4934                                         strcat(out_val, " '6' ¾²¾å,");
4935                                 else
4936                                         strcat(out_val, " '4'or'6' ¾²¾å,");
4937 #else
4938                                 if (!use_menu)
4939                                         strcat(out_val, " - for floor,");
4940                                 else if (allow_inven)
4941                                         strcat(out_val, " 6 for floor,");
4942                                 else
4943                                         strcat(out_val, " 4 or 6 for floor,");
4944 #endif
4945                         }
4946                 }
4947
4948                 /* Viewing floor */
4949                 else if (command_wrk == (USE_FLOOR))
4950                 {
4951                         /* Begin the prompt */
4952 #ifdef JP
4953                         sprintf(out_val, "¾²¾å:");
4954 #else
4955                         sprintf(out_val, "Floor:");
4956 #endif
4957
4958                         if (!use_menu)
4959                         {
4960                                 /* Build the prompt */
4961 #ifdef JP
4962                                 sprintf(tmp_val, "%c-%c,'(',')',", n1, n2);
4963 #else
4964                                 sprintf(tmp_val, " %c-%c,'(',')',", n1, n2);
4965 #endif
4966
4967                                 /* Append */
4968                                 strcat(out_val, tmp_val);
4969                         }
4970
4971                         /* Indicate ability to "view" */
4972 #ifdef JP
4973                         if (!command_see && !use_menu) strcat(out_val, " '*'°ìÍ÷,");
4974 #else
4975                         if (!command_see && !use_menu) strcat(out_val, " * to see,");
4976 #endif
4977
4978                         if (use_menu)
4979                         {
4980                                 if (allow_inven && allow_equip)
4981                                 {
4982 #ifdef JP
4983                                         strcat(out_val, " '4' ÁõÈ÷ÉÊ, '6' »ý¤Áʪ,");
4984 #else
4985                                         strcat(out_val, " 4 for Equip, 6 for Inven,");
4986 #endif
4987                                 }
4988                                 else if (allow_inven)
4989                                 {
4990 #ifdef JP
4991                                         strcat(out_val, " '4'or'6' »ý¤Áʪ,");
4992 #else
4993                                         strcat(out_val, " 4 or 6 for Inven,");
4994 #endif
4995                                 }
4996                                 else if (allow_equip)
4997                                 {
4998 #ifdef JP
4999                                         strcat(out_val, " '4'or'6' ÁõÈ÷ÉÊ,");
5000 #else
5001                                         strcat(out_val, " 4 or 6 for Equip,");
5002 #endif
5003                                 }
5004                         }
5005                         /* Append */
5006                         else if (allow_inven)
5007                         {
5008 #ifdef JP
5009                                 strcat(out_val, " '/' »ý¤Áʪ,");
5010 #else
5011                                 strcat(out_val, " / for Inven,");
5012 #endif
5013                         }
5014                         else if (allow_equip)
5015                         {
5016 #ifdef JP
5017                                 strcat(out_val, " '/'ÁõÈ÷ÉÊ,");
5018 #else
5019                                 strcat(out_val, " / for Equip,");
5020 #endif
5021                         }
5022
5023                         /* Append */
5024                         if (command_see && !use_menu)
5025                         {
5026 #ifdef JP
5027                                 strcat(out_val, " Enter ¼¡,");
5028 #else
5029                                 strcat(out_val, " Enter for scroll down,");
5030 #endif
5031                         }
5032                 }
5033
5034                 /* Append */
5035 #ifdef JP
5036                 if (select_the_force) strcat(out_val, " 'w'Îýµ¤½Ñ,");
5037 #else
5038                 if (select_the_force) strcat(out_val, " w for the Force,");
5039 #endif
5040
5041                 /* Finish the prompt */
5042                 strcat(out_val, " ESC");
5043
5044                 /* Build the prompt */
5045                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
5046
5047                 /* Show the prompt */
5048                 prt(tmp_val, 0, 0);
5049
5050                 /* Get a key */
5051                 which = inkey();
5052
5053                 if (use_menu)
5054                 {
5055                 int max_line = 1;
5056                 if (command_wrk == USE_INVEN) max_line = max_inven;
5057                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
5058                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
5059                 switch (which)
5060                 {
5061                         case ESCAPE:
5062                         case 'z':
5063                         case 'Z':
5064                         case '0':
5065                         {
5066                                 done = TRUE;
5067                                 break;
5068                         }
5069
5070                         case '8':
5071                         case 'k':
5072                         case 'K':
5073                         {
5074                                 menu_line += (max_line - 1);
5075                                 break;
5076                         }
5077
5078                         case '2':
5079                         case 'j':
5080                         case 'J':
5081                         {
5082                                 menu_line++;
5083                                 break;
5084                         }
5085
5086                         case '4':
5087                         case 'h':
5088                         case 'H':
5089                         {
5090                                 /* Verify legality */
5091                                 if (command_wrk == (USE_INVEN))
5092                                 {
5093                                         if (allow_floor) command_wrk = USE_FLOOR;
5094                                         else if (allow_equip) command_wrk = USE_EQUIP;
5095                                         else
5096                                         {
5097                                                 bell();
5098                                                 break;
5099                                         }
5100                                 }
5101                                 else if (command_wrk == (USE_EQUIP))
5102                                 {
5103                                         if (allow_inven) command_wrk = USE_INVEN;
5104                                         else if (allow_floor) command_wrk = USE_FLOOR;
5105                                         else
5106                                         {
5107                                                 bell();
5108                                                 break;
5109                                         }
5110                                 }
5111                                 else if (command_wrk == (USE_FLOOR))
5112                                 {
5113                                         if (allow_equip) command_wrk = USE_EQUIP;
5114                                         else if (allow_inven) command_wrk = USE_INVEN;
5115                                         else
5116                                         {
5117                                                 bell();
5118                                                 break;
5119                                         }
5120                                 }
5121                                 else
5122                                 {
5123                                         bell();
5124                                         break;
5125                                 }
5126
5127                                 /* Hack -- Fix screen */
5128                                 if (command_see)
5129                                 {
5130                                         /* Load screen */
5131                                         screen_load();
5132
5133                                         /* Save screen */
5134                                         screen_save();
5135                                 }
5136
5137                                 /* Switch inven/equip */
5138                                 if (command_wrk == USE_INVEN) max_line = max_inven;
5139                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
5140                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
5141                                 if (menu_line > max_line) menu_line = max_line;
5142
5143                                 /* Need to redraw */
5144                                 break;
5145                         }
5146
5147                         case '6':
5148                         case 'l':
5149                         case 'L':
5150                         {
5151                                 /* Verify legality */
5152                                 if (command_wrk == (USE_INVEN))
5153                                 {
5154                                         if (allow_equip) command_wrk = USE_EQUIP;
5155                                         else if (allow_floor) command_wrk = USE_FLOOR;
5156                                         else
5157                                         {
5158                                                 bell();
5159                                                 break;
5160                                         }
5161                                 }
5162                                 else if (command_wrk == (USE_EQUIP))
5163                                 {
5164                                         if (allow_floor) command_wrk = USE_FLOOR;
5165                                         else if (allow_inven) command_wrk = USE_INVEN;
5166                                         else
5167                                         {
5168                                                 bell();
5169                                                 break;
5170                                         }
5171                                 }
5172                                 else if (command_wrk == (USE_FLOOR))
5173                                 {
5174                                         if (allow_inven) command_wrk = USE_INVEN;
5175                                         else if (allow_equip) command_wrk = USE_EQUIP;
5176                                         else
5177                                         {
5178                                                 bell();
5179                                                 break;
5180                                         }
5181                                 }
5182                                 else
5183                                 {
5184                                         bell();
5185                                         break;
5186                                 }
5187
5188                                 /* Hack -- Fix screen */
5189                                 if (command_see)
5190                                 {
5191                                         /* Load screen */
5192                                         screen_load();
5193
5194                                         /* Save screen */
5195                                         screen_save();
5196                                 }
5197
5198                                 /* Switch inven/equip */
5199                                 if (command_wrk == USE_INVEN) max_line = max_inven;
5200                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
5201                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
5202                                 if (menu_line > max_line) menu_line = max_line;
5203
5204                                 /* Need to redraw */
5205                                 break;
5206                         }
5207
5208                         case 'x':
5209                         case 'X':
5210                         case '\r':
5211                         case '\n':
5212                         {
5213                                 if (command_wrk == USE_FLOOR)
5214                                 {
5215                                         /* Special index */
5216                                         (*cp) = -get_item_label;
5217                                 }
5218                                 else
5219                                 {
5220                                         /* Validate the item */
5221                                         if (!get_item_okay(get_item_label))
5222                                         {
5223                                                 bell();
5224                                                 break;
5225                                         }
5226
5227                                         /* Allow player to "refuse" certain actions */
5228                                         if (!get_item_allow(get_item_label))
5229                                         {
5230                                                 done = TRUE;
5231                                                 break;
5232                                         }
5233
5234                                         /* Accept that choice */
5235                                         (*cp) = get_item_label;
5236                                 }
5237
5238                                 item = TRUE;
5239                                 done = TRUE;
5240                                 break;
5241                         }
5242                         case 'w':
5243                         {
5244                                 if (select_the_force) {
5245                                         *cp = INVEN_FORCE;
5246                                         item = TRUE;
5247                                         done = TRUE;
5248                                         break;
5249                                 }
5250                         }
5251                 }
5252                 if (menu_line > max_line) menu_line -= max_line;
5253                 }
5254                 else
5255                 {
5256                 /* Parse it */
5257                 switch (which)
5258                 {
5259                         case ESCAPE:
5260                         {
5261                                 done = TRUE;
5262                                 break;
5263                         }
5264
5265                         case '*':
5266                         case '?':
5267                         case ' ':
5268                         {
5269                                 /* Hide the list */
5270                                 if (command_see)
5271                                 {
5272                                         /* Flip flag */
5273                                         command_see = FALSE;
5274
5275                                         /* Load screen */
5276                                         screen_load();
5277                                 }
5278
5279                                 /* Show the list */
5280                                 else
5281                                 {
5282                                         /* Save screen */
5283                                         screen_save();
5284
5285                                         /* Flip flag */
5286                                         command_see = TRUE;
5287                                 }
5288                                 break;
5289                         }
5290
5291                         case '\n':
5292                         case '\r':
5293                         case '+':
5294                         {
5295                                 int i, o_idx;
5296                                 cave_type *c_ptr = &cave[py][px];
5297
5298                                 if (command_wrk != (USE_FLOOR)) break;
5299
5300                                 /* Get the object being moved. */
5301                                 o_idx = c_ptr->o_idx;
5302
5303                                 /* Only rotate a pile of two or more objects. */
5304                                 if (!(o_idx && o_list[o_idx].next_o_idx)) break;
5305
5306                                 /* Remove the first object from the list. */
5307                                 excise_object_idx(o_idx);
5308
5309                                 /* Find end of the list. */
5310                                 i = c_ptr->o_idx;
5311                                 while (o_list[i].next_o_idx)
5312                                         i = o_list[i].next_o_idx;
5313
5314                                 /* Add after the last object. */
5315                                 o_list[i].next_o_idx = o_idx;
5316
5317                                 /* Re-scan floor list */ 
5318                                 floor_num = scan_floor(floor_list, py, px, 0x03);
5319
5320                                 /* Hack -- Fix screen */
5321                                 if (command_see)
5322                                 {
5323                                         /* Load screen */
5324                                         screen_load();
5325
5326                                         /* Save screen */
5327                                         screen_save();
5328                                 }
5329
5330                                 break;
5331                         }
5332
5333                         case '/':
5334                         {
5335                                 if (command_wrk == (USE_INVEN))
5336                                 {
5337                                         if (!allow_equip)
5338                                         {
5339                                                 bell();
5340                                                 break;
5341                                         }
5342                                         command_wrk = (USE_EQUIP);
5343                                 }
5344                                 else if (command_wrk == (USE_EQUIP))
5345                                 {
5346                                         if (!allow_inven)
5347                                         {
5348                                                 bell();
5349                                                 break;
5350                                         }
5351                                         command_wrk = (USE_INVEN);
5352                                 }
5353                                 else if (command_wrk == (USE_FLOOR))
5354                                 {
5355                                         if (allow_inven)
5356                                         {
5357                                                 command_wrk = (USE_INVEN);
5358                                         }
5359                                         else if (allow_equip)
5360                                         {
5361                                                 command_wrk = (USE_EQUIP);
5362                                         }
5363                                         else
5364                                         {
5365                                                 bell();
5366                                                 break;
5367                                         }
5368                                 }
5369
5370                                 /* Hack -- Fix screen */
5371                                 if (command_see)
5372                                 {
5373                                         /* Load screen */
5374                                         screen_load();
5375
5376                                         /* Save screen */
5377                                         screen_save();
5378                                 }
5379
5380                                 /* Need to redraw */
5381                                 break;
5382                         }
5383
5384                         case '-':
5385                         {
5386                                 if (!allow_floor)
5387                                 {
5388                                         bell();
5389                                         break;
5390                                 }
5391
5392                                 /*
5393                                  * If we are already examining the floor, and there
5394                                  * is only one item, we will always select it.
5395                                  * If we aren't examining the floor and there is only
5396                                  * one item, we will select it if floor_query_flag
5397                                  * is FALSE.
5398                                  */
5399                                 if (floor_num == 1)
5400                                 {
5401                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
5402                                         {
5403                                                 /* Special index */
5404                                                 k = 0 - floor_list[0];
5405
5406                                                 /* Allow player to "refuse" certain actions */
5407                                                 if (!get_item_allow(k))
5408                                                 {
5409                                                         done = TRUE;
5410                                                         break;
5411                                                 }
5412
5413                                                 /* Accept that choice */
5414                                                 (*cp) = k;
5415                                                 item = TRUE;
5416                                                 done = TRUE;
5417
5418                                                 break;
5419                                         }
5420                                 }
5421
5422                                 /* Hack -- Fix screen */
5423                                 if (command_see)
5424                                 {
5425                                         /* Load screen */
5426                                         screen_load();
5427
5428                                         /* Save screen */
5429                                         screen_save();
5430                                 }
5431
5432                                 command_wrk = (USE_FLOOR);
5433
5434                                 break;
5435                         }
5436
5437                         case '0':
5438                         case '1': case '2': case '3':
5439                         case '4': case '5': case '6':
5440                         case '7': case '8': case '9':
5441                         {
5442                                 if (command_wrk != USE_FLOOR)
5443                                 {
5444                                         /* Look up the tag */
5445                                         if (!get_tag(&k, which, command_wrk))
5446                                         {
5447                                                 bell();
5448                                                 break;
5449                                         }
5450
5451                                         /* Hack -- Validate the item */
5452                                         if ((k < INVEN_RARM) ? !inven : !equip)
5453                                         {
5454                                                 bell();
5455                                                 break;
5456                                         }
5457
5458                                         /* Validate the item */
5459                                         if (!get_item_okay(k))
5460                                         {
5461                                                 bell();
5462                                                 break;
5463                                         }
5464                                 }
5465                                 else
5466                                 {
5467                                         /* Look up the alphabetical tag */
5468                                         if (get_tag_floor(&k, which, floor_list, floor_num))
5469                                         {
5470                                                 /* Special index */
5471                                                 k = 0 - floor_list[k];
5472                                         }
5473                                         else
5474                                         {
5475                                                 bell();
5476                                                 break;
5477                                         }
5478                                 }
5479
5480                                 /* Allow player to "refuse" certain actions */
5481                                 if (!get_item_allow(k))
5482                                 {
5483                                         done = TRUE;
5484                                         break;
5485                                 }
5486
5487                                 /* Accept that choice */
5488                                 (*cp) = k;
5489                                 item = TRUE;
5490                                 done = TRUE;
5491 #ifdef ALLOW_REPEAT
5492                                 cur_tag = which;
5493 #endif /* ALLOW_REPEAT */
5494                                 break;
5495                         }
5496
5497 #if 0
5498                         case '\n':
5499                         case '\r':
5500                         {
5501                                 /* Choose "default" inventory item */
5502                                 if (command_wrk == (USE_INVEN))
5503                                 {
5504                                         k = ((i1 == i2) ? i1 : -1);
5505                                 }
5506
5507                                 /* Choose "default" equipment item */
5508                                 else if (command_wrk == (USE_EQUIP))
5509                                 {
5510                                         k = ((e1 == e2) ? e1 : -1);
5511                                 }
5512
5513                                 /* Choose "default" floor item */
5514                                 else if (command_wrk == (USE_FLOOR))
5515                                 {
5516                                         if (floor_num == 1)
5517                                         {
5518                                                 /* Special index */
5519                                                 k = 0 - floor_list[0];
5520
5521                                                 /* Allow player to "refuse" certain actions */
5522                                                 if (!get_item_allow(k))
5523                                                 {
5524                                                         done = TRUE;
5525                                                         break;
5526                                                 }
5527
5528                                                 /* Accept that choice */
5529                                                 (*cp) = k;
5530                                                 item = TRUE;
5531                                                 done = TRUE;
5532                                         }
5533                                         break;
5534                                 }
5535
5536                                 /* Validate the item */
5537                                 if (!get_item_okay(k))
5538                                 {
5539                                         bell();
5540                                         break;
5541                                 }
5542
5543                                 /* Allow player to "refuse" certain actions */
5544                                 if (!get_item_allow(k))
5545                                 {
5546                                         done = TRUE;
5547                                         break;
5548                                 }
5549
5550                                 /* Accept that choice */
5551                                 (*cp) = k;
5552                                 item = TRUE;
5553                                 done = TRUE;
5554                                 break;
5555                         }
5556 #endif
5557
5558                         case 'w':
5559                         {
5560                                 if (select_the_force) {
5561                                         *cp = INVEN_FORCE;
5562                                         item = TRUE;
5563                                         done = TRUE;
5564                                         break;
5565                                 }
5566
5567                                 /* Fall through */
5568                         }
5569
5570                         default:
5571                         {
5572                                 int ver;
5573
5574                                 if (command_wrk != USE_FLOOR)
5575                                 {
5576                                         bool not_found = FALSE;
5577
5578                                         /* Look up the alphabetical tag */
5579                                         if (!get_tag(&k, which, command_wrk))
5580                                         {
5581                                                 not_found = TRUE;
5582                                         }
5583
5584                                         /* Hack -- Validate the item */
5585                                         else if ((k < INVEN_RARM) ? !inven : !equip)
5586                                         {
5587                                                 not_found = TRUE;
5588                                         }
5589
5590                                         /* Validate the item */
5591                                         else if (!get_item_okay(k))
5592                                         {
5593                                                 not_found = TRUE;
5594                                         }
5595
5596                                         if (!not_found)
5597                                         {
5598                                                 /* Accept that choice */
5599                                                 (*cp) = k;
5600                                                 item = TRUE;
5601                                                 done = TRUE;
5602 #ifdef ALLOW_REPEAT
5603                                                 cur_tag = which;
5604 #endif /* ALLOW_REPEAT */
5605                                                 break;
5606                                         }
5607                                 }
5608                                 else
5609                                 {
5610                                         /* Look up the alphabetical tag */
5611                                         if (get_tag_floor(&k, which, floor_list, floor_num))
5612                                         {
5613                                                 /* Special index */
5614                                                 k = 0 - floor_list[k];
5615
5616                                                 /* Accept that choice */
5617                                                 (*cp) = k;
5618                                                 item = TRUE;
5619                                                 done = TRUE;
5620 #ifdef ALLOW_REPEAT
5621                                                 cur_tag = which;
5622 #endif /* ALLOW_REPEAT */
5623                                                 break;
5624                                         }
5625                                 }
5626
5627                                 /* Extract "query" setting */
5628                                 ver = isupper(which);
5629                                 which = tolower(which);
5630
5631                                 /* Convert letter to inventory index */
5632                                 if (command_wrk == (USE_INVEN))
5633                                 {
5634                                         if (which == '(') k = i1;
5635                                         else if (which == ')') k = i2;
5636                                         else k = label_to_inven(which);
5637                                 }
5638
5639                                 /* Convert letter to equipment index */
5640                                 else if (command_wrk == (USE_EQUIP))
5641                                 {
5642                                         if (which == '(') k = e1;
5643                                         else if (which == ')') k = e2;
5644                                         else k = label_to_equip(which);
5645                                 }
5646
5647                                 /* Convert letter to floor index */
5648                                 else if (command_wrk == USE_FLOOR)
5649                                 {
5650                                         if (which == '(') k = 0;
5651                                         else if (which == ')') k = floor_num - 1;
5652                                         else k = islower(which) ? A2I(which) : -1;
5653                                         if (k < 0 || k >= floor_num || k >= 23)
5654                                         {
5655                                                 bell();
5656                                                 break;
5657                                         }
5658
5659                                         /* Special index */
5660                                         k = 0 - floor_list[k];
5661                                 }
5662
5663                                 /* Validate the item */
5664                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
5665                                 {
5666                                         bell();
5667                                         break;
5668                                 }
5669
5670                                 /* Verify the item */
5671 #ifdef JP
5672 if (ver && !verify("ËÜÅö¤Ë", k))
5673 #else
5674                                 if (ver && !verify("Try", k))
5675 #endif
5676
5677                                 {
5678                                         done = TRUE;
5679                                         break;
5680                                 }
5681
5682                                 /* Allow player to "refuse" certain actions */
5683                                 if (!get_item_allow(k))
5684                                 {
5685                                         done = TRUE;
5686                                         break;
5687                                 }
5688
5689                                 /* Accept that choice */
5690                                 (*cp) = k;
5691                                 item = TRUE;
5692                                 done = TRUE;
5693                                 break;
5694                         }
5695                 }
5696                 }
5697         }
5698
5699         /* Fix the screen if necessary */
5700         if (command_see)
5701         {
5702                 /* Load screen */
5703                 screen_load();
5704
5705                 /* Hack -- Cancel "display" */
5706                 command_see = FALSE;
5707         }
5708
5709
5710         /* Forget the item_tester_tval restriction */
5711         item_tester_tval = 0;
5712
5713         /* Forget the item_tester_hook restriction */
5714         item_tester_hook = NULL;
5715
5716
5717         /* Clean up  'show choices' */
5718         /* Toggle again if needed */
5719         if (toggle) toggle_inven_equip();
5720
5721         /* Update */
5722         p_ptr->window |= (PW_INVEN | PW_EQUIP);
5723
5724         /* Window stuff */
5725         window_stuff();
5726
5727
5728         /* Clear the prompt line */
5729         prt("", 0, 0);
5730
5731         /* Warning if needed */
5732         if (oops && str) msg_print(str);
5733
5734         if (item)
5735         {
5736 #ifdef ALLOW_REPEAT
5737                 repeat_push(*cp);
5738                 if (command_cmd) prev_tag = cur_tag;
5739 #endif /* ALLOW_REPEAT */
5740
5741                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
5742         }
5743
5744         /* Result */
5745         return (item);
5746 }
5747
5748
5749 static bool py_pickup_floor_aux(void)
5750 {
5751         s16b this_o_idx;
5752
5753         cptr q, s;
5754
5755         int item;
5756
5757         /* Restrict the choices */
5758         item_tester_hook = inven_carry_okay;
5759
5760         /* Get an object */
5761 #ifdef JP
5762         q = "¤É¤ì¤ò½¦¤¤¤Þ¤¹¤«¡©";
5763         s = "¤â¤¦¥¶¥Ã¥¯¤Ë¤Ï¾²¤Ë¤¢¤ë¤É¤Î¥¢¥¤¥Æ¥à¤âÆþ¤é¤Ê¤¤¡£";
5764 #else
5765         q = "Get which item? ";
5766         s = "You no longer have any room for the objects on the floor.";
5767 #endif
5768
5769         if (get_item(&item, q, s, (USE_FLOOR)))
5770         {
5771                 this_o_idx = 0 - item;
5772         }
5773         else
5774         {
5775                 return (FALSE);
5776         }
5777
5778         /* Pick up the object */
5779         py_pickup_aux(this_o_idx);
5780
5781         return (TRUE);
5782 }
5783
5784
5785 /*
5786  * Make the player carry everything in a grid
5787  *
5788  * If "pickup" is FALSE then only gold will be picked up
5789  *
5790  * This is called by py_pickup() when easy_floor is TRUE.
5791  */
5792 void py_pickup_floor(bool pickup)
5793 {
5794         s16b this_o_idx, next_o_idx = 0;
5795
5796         char o_name[MAX_NLEN];
5797         object_type *o_ptr;
5798
5799         int floor_num = 0, floor_o_idx = 0;
5800
5801         int can_pickup = 0;
5802
5803         /* Scan the pile of objects */
5804         for (this_o_idx = cave[py][px].o_idx; this_o_idx; this_o_idx = next_o_idx)
5805         {
5806                 object_type *o_ptr;
5807
5808                 /* Access the object */
5809                 o_ptr = &o_list[this_o_idx];
5810
5811                 /* Describe the object */
5812                 object_desc(o_name, o_ptr, 0);
5813
5814                 /* Access the next object */
5815                 next_o_idx = o_ptr->next_o_idx;
5816
5817                 /* Hack -- disturb */
5818                 disturb(0, 0);
5819
5820                 /* Pick up gold */
5821                 if (o_ptr->tval == TV_GOLD)
5822                 {
5823                         /* Message */
5824 #ifdef JP
5825                 msg_format(" $%ld ¤Î²ÁÃͤ¬¤¢¤ë%s¤ò¸«¤Ä¤±¤¿¡£",
5826                            (long)o_ptr->pval, o_name);
5827 #else
5828                         msg_format("You have found %ld gold pieces worth of %s.",
5829                                 (long) o_ptr->pval, o_name);
5830 #endif
5831
5832
5833                         /* Collect the gold */
5834                         p_ptr->au += o_ptr->pval;
5835
5836                         /* Redraw gold */
5837                         p_ptr->redraw |= (PR_GOLD);
5838
5839                         /* Window stuff */
5840                         p_ptr->window |= (PW_PLAYER);
5841
5842                         /* Delete the gold */
5843                         delete_object_idx(this_o_idx);
5844
5845                         /* Check the next object */
5846                         continue;
5847                 }
5848                 else if (o_ptr->marked & OM_NOMSG)
5849                 {
5850                         /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
5851                          * ignored. Otherwise, they are included in the prompt. */
5852                         o_ptr->marked &= ~(OM_NOMSG);
5853                         continue;
5854                 }
5855
5856                 /* Count non-gold objects that can be picked up. */
5857                 if (inven_carry_okay(o_ptr))
5858                 {
5859                         can_pickup++;
5860                 }
5861
5862                 /* Count non-gold objects */
5863                 floor_num++;
5864
5865                 /* Remember this index */
5866                 floor_o_idx = this_o_idx;
5867         }
5868
5869         /* There are no non-gold objects */
5870         if (!floor_num)
5871                 return;
5872
5873         /* Mention the number of objects */
5874         if (!pickup)
5875         {
5876                 /* One object */
5877                 if (floor_num == 1)
5878                 {
5879                         /* Access the object */
5880                         o_ptr = &o_list[floor_o_idx];
5881
5882 #ifdef ALLOW_EASY_SENSE
5883
5884                         /* Option: Make object sensing easy */
5885                         if (easy_sense)
5886                         {
5887                                 /* Sense the object */
5888                                 (void) sense_object(o_ptr);
5889                         }
5890
5891 #endif /* ALLOW_EASY_SENSE */
5892
5893                         /* Describe the object */
5894                         object_desc(o_name, o_ptr, 0);
5895
5896                         /* Message */
5897 #ifdef JP
5898                                 msg_format("%s¤¬¤¢¤ë¡£", o_name);
5899 #else
5900                         msg_format("You see %s.", o_name);
5901 #endif
5902
5903                 }
5904
5905                 /* Multiple objects */
5906                 else
5907                 {
5908                         /* Message */
5909 #ifdef JP
5910                         msg_format("%d ¸Ä¤Î¥¢¥¤¥Æ¥à¤Î»³¤¬¤¢¤ë¡£", floor_num);
5911 #else
5912                         msg_format("You see a pile of %d items.", floor_num);
5913 #endif
5914
5915                 }
5916
5917                 /* Done */
5918                 return;
5919         }
5920
5921         /* The player has no room for anything on the floor. */
5922         if (!can_pickup)
5923         {
5924                 /* One object */
5925                 if (floor_num == 1)
5926                 {
5927                         /* Access the object */
5928                         o_ptr = &o_list[floor_o_idx];
5929
5930 #ifdef ALLOW_EASY_SENSE
5931
5932                         /* Option: Make object sensing easy */
5933                         if (easy_sense)
5934                         {
5935                                 /* Sense the object */
5936                                 (void) sense_object(o_ptr);
5937                         }
5938
5939 #endif /* ALLOW_EASY_SENSE */
5940
5941                         /* Describe the object */
5942                         object_desc(o_name, o_ptr, 0);
5943
5944                         /* Message */
5945 #ifdef JP
5946                                 msg_format("¥¶¥Ã¥¯¤Ë¤Ï%s¤òÆþ¤ì¤ë·ä´Ö¤¬¤Ê¤¤¡£", o_name);
5947 #else
5948                         msg_format("You have no room for %s.", o_name);
5949 #endif
5950
5951                 }
5952
5953                 /* Multiple objects */
5954                 else
5955                 {
5956                         /* Message */
5957 #ifdef JP
5958                         msg_format("¥¶¥Ã¥¯¤Ë¤Ï¾²¤Ë¤¢¤ë¤É¤Î¥¢¥¤¥Æ¥à¤âÆþ¤é¤Ê¤¤¡£", o_name);
5959 #else
5960                         msg_print("You have no room for any of the objects on the floor.");
5961 #endif
5962
5963                 }
5964
5965                 /* Done */
5966                 return;
5967         }
5968
5969         /* One object */
5970         if (floor_num == 1)
5971         {
5972                 /* Hack -- query every object */
5973                 if (carry_query_flag)
5974                 {
5975                         char out_val[MAX_NLEN+20];
5976
5977                         /* Access the object */
5978                         o_ptr = &o_list[floor_o_idx];
5979
5980 #ifdef ALLOW_EASY_SENSE
5981
5982                         /* Option: Make object sensing easy */
5983                         if (easy_sense)
5984                         {
5985                                 /* Sense the object */
5986                                 (void) sense_object(o_ptr);
5987                         }
5988
5989 #endif /* ALLOW_EASY_SENSE */
5990
5991                         /* Describe the object */
5992                         object_desc(o_name, o_ptr, 0);
5993
5994                         /* Build a prompt */
5995 #ifdef JP
5996                         (void) sprintf(out_val, "%s¤ò½¦¤¤¤Þ¤¹¤«? ", o_name);
5997 #else
5998                         (void) sprintf(out_val, "Pick up %s? ", o_name);
5999 #endif
6000
6001
6002                         /* Ask the user to confirm */
6003                         if (!get_check(out_val))
6004                         {
6005                                 /* Done */
6006                                 return;
6007                         }
6008                 }
6009
6010                 /* Access the object */
6011                 o_ptr = &o_list[floor_o_idx];
6012
6013 #ifdef ALLOW_EASY_SENSE
6014
6015                 /* Option: Make object sensing easy */
6016                 if (easy_sense)
6017                 {
6018                         /* Sense the object */
6019                         (void) sense_object(o_ptr);
6020                 }
6021
6022 #endif /* ALLOW_EASY_SENSE */
6023
6024                 /* Pick up the object */
6025                 py_pickup_aux(floor_o_idx);
6026         }
6027
6028         /* Allow the user to choose an object */
6029         else
6030         {
6031                 while (can_pickup--)
6032                 {
6033                         if (!py_pickup_floor_aux()) break;
6034                 }
6035         }
6036 }
6037
6038 #endif /* ALLOW_EASY_FLOOR */