OSDN Git Service

#37287 #37353 (2.2.0.89) TERM_COLOR 型を定義し、型の置換を継続中。 / Define TERM_COLOR, ongoing...
[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         if (!(have_flag(flgs, TR_ACTIVATE))) return (_("なし", "nothing"));
483
484         /* Get an explain of an activation */
485         if (activation_index(o_ptr))
486         {
487                 return item_activation_aux(o_ptr);
488         }
489
490         /* Special items */
491         if (o_ptr->tval == TV_WHISTLE)
492         {
493                 return _("ペット呼び寄せ : 100+d100ターン毎", "call pet every 100+d100 turns");
494         }
495
496         if (o_ptr->tval == TV_CAPTURE)
497         {
498                 return _("モンスターを捕える、又は解放する。", "captures or releases a monster.");
499         }
500
501         /* Oops */
502         return _("何も起きない", "Nothing");
503 }
504
505
506 /*!
507  * @brief オブジェクトの*鑑定*内容を詳述して表示する /
508  * Describe a "fully identified" item
509  * @param o_ptr *鑑定*情報を取得する元のオブジェクト構造体参照ポインタ
510  * @param mode 表示オプション
511  * @return 特筆すべき情報が一つでもあった場合TRUE、一つもなく表示がキャンセルされた場合FALSEを返す。
512  */
513 bool screen_object(object_type *o_ptr, u32b mode)
514 {
515         int                     i = 0, j, k;
516
517         u32b flgs[TR_FLAG_SIZE];
518
519         char temp[70 * 20];
520         cptr            info[128];
521         char o_name[MAX_NLEN];
522         int wid, hgt;
523         int rad;
524         char desc[256];
525
526         int trivial_info = 0;
527
528         /* Extract the flags */
529         object_flags(o_ptr, flgs);
530
531         /* Extract the description */
532         {
533                 roff_to_buf(o_ptr->name1 ? (a_text + a_info[o_ptr->name1].text) :
534                             (k_text + k_info[o_ptr->k_idx].text),
535                             77 - 15, temp, sizeof(temp));
536                 for (j = 0; temp[j]; j += 1 + strlen(&temp[j]))
537                 { info[i] = &temp[j]; i++;}
538         }
539
540         if (object_is_equipment(o_ptr))
541         {
542                 /* Descriptions of a basic equipment is just a flavor */
543                 trivial_info = i;
544         }
545
546         /* Mega-Hack -- describe activation */
547         if (have_flag(flgs, TR_ACTIVATE))
548         {
549                 info[i++] = _("始動したときの効果...", "It can be activated for...");
550                 info[i++] = item_activation(o_ptr);
551                 info[i++] = _("...ただし装備していなければならない。", "...if it is being worn.");
552         }
553
554         /* Figurines, a hack */
555         if (o_ptr->tval == TV_FIGURINE)
556         {
557                 info[i++] = _("それは投げた時ペットに変化する。", "It will transform into a pet when thrown.");
558         }
559
560         /* Figurines, a hack */
561         if (o_ptr->name1 == ART_STONEMASK)
562         {
563                 info[i++] = _("それを装備した者は吸血鬼になる。", "It makes you turn into a vampire permanently.");
564         }
565
566         if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI))
567         {
568                 info[i++] = _("それは相手を一撃で倒すことがある。", "It will attempt to kill a monster instantly.");
569         }
570
571         if ((o_ptr->tval == TV_POLEARM) && (o_ptr->sval == SV_DEATH_SCYTHE))
572         {
573                 info[i++] = _("それは自分自身に攻撃が返ってくることがある。", "It causes you to strike yourself sometimes.");
574                 info[i++] = _("それは無敵のバリアを切り裂く。", "It always penetrates invulnerability barriers.");
575         }
576
577         if (o_ptr->name2 == EGO_2WEAPON)
578         {
579                 info[i++] = _("それは二刀流での命中率を向上させる。", "It affects your ability to hit when you are wielding two weapons.");
580         }
581
582         if (have_flag(flgs, TR_EASY_SPELL))
583         {
584                 info[i++] = _("それは魔法の難易度を下げる。", "It affects your ability to cast spells.");
585         }
586
587         if (o_ptr->name2 == EGO_AMU_FOOL)
588         {
589                 info[i++] = _("それは魔法の難易度を上げる。", "It interferes with casting spells.");
590         }
591
592         if (o_ptr->name2 == EGO_RING_THROW)
593         {
594                 info[i++] = _("それは物を強く投げることを可能にする。", "It provides great strength when you throw an item.");
595         }
596
597         if (o_ptr->name2 == EGO_AMU_NAIVETY)
598         {
599                 info[i++] = _("それは魔法抵抗力を下げる。", "It decreases your magic resistance.");
600         }
601
602         if (o_ptr->tval == TV_STATUE)
603         {
604                 monster_race *r_ptr = &r_info[o_ptr->pval];
605
606                 if (o_ptr->pval == MON_BULLGATES)
607                         info[i++] = _("それは部屋に飾ると恥ずかしい。", "It is shameful.");
608                 else if ( r_ptr->flags2 & (RF2_ELDRITCH_HORROR))
609                         info[i++] = _("それは部屋に飾ると恐い。", "It is fearful.");
610                 else
611                         info[i++] = _("それは部屋に飾ると楽しい。", "It is cheerful.");
612         }
613         
614         /* Hack -- describe lite's */
615         
616         if (o_ptr->name2 == EGO_LITE_DARKNESS) info[i++] = _("それは全く光らない。", "It provides no light.");
617         
618         rad = 0;
619         if (have_flag(flgs, TR_LITE_1) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 1;
620         if (have_flag(flgs, TR_LITE_2) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 2;
621         if (have_flag(flgs, TR_LITE_3) && o_ptr->name2 != EGO_LITE_DARKNESS)  rad += 3;
622         if (have_flag(flgs, TR_LITE_M1)) rad -= 1;
623         if (have_flag(flgs, TR_LITE_M2)) rad -= 2;
624         if (have_flag(flgs, TR_LITE_M3)) rad -= 3;
625         
626         if(o_ptr->name2 == EGO_LITE_SHINE) rad++;
627                 
628         if (have_flag(flgs, TR_LITE_FUEL) && o_ptr->name2 != EGO_LITE_DARKNESS)
629         {
630                 if(rad > 0) sprintf(desc, _("それは燃料補給によって明かり(半径 %d)を授ける。", "It provides light (radius %d) when fueled."), rad);        
631         }
632         else
633         {
634                 if(rad > 0) sprintf(desc, _("それは永遠なる明かり(半径 %d)を授ける。", "It provides light (radius %d) forever."), rad);        
635                 if(rad < 0) sprintf(desc, _("それは明かりの半径を狭める(半径に-%d)。", "It decreases radius of light source by %d."), -rad);
636         }
637         
638         if(rad != 0) info[i++] = desc;
639
640         
641         if (o_ptr->name2 == EGO_LITE_LONG)
642         {
643                 info[i++] = _("それは長いターン明かりを授ける。", "It provides light for much longer time.");
644         }
645
646         /* And then describe it fully */
647
648         if (have_flag(flgs, TR_RIDING))
649         {
650                 if ((o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
651                         info[i++] = _("それは乗馬中は非常に使いやすい。", "It is made for use while riding.");
652                 else
653                 {
654                         info[i++] = _("それは乗馬中でも使いやすい。", "It is suitable for use while riding.");
655                         /* This information is not important enough */
656                         trivial_info++;
657                 }
658         }
659         if (have_flag(flgs, TR_STR))
660         {
661                 info[i++] = _("それは腕力に影響を及ぼす。", "It affects your strength.");
662         }
663         if (have_flag(flgs, TR_INT))
664         {
665                 info[i++] = _("それは知能に影響を及ぼす。", "It affects your intelligence.");
666         }
667         if (have_flag(flgs, TR_WIS))
668         {
669                 info[i++] = _("それは賢さに影響を及ぼす。", "It affects your wisdom.");
670         }
671         if (have_flag(flgs, TR_DEX))
672         {
673                 info[i++] = _("それは器用さに影響を及ぼす。", "It affects your dexterity.");
674         }
675         if (have_flag(flgs, TR_CON))
676         {
677                 info[i++] = _("それは耐久力に影響を及ぼす。", "It affects your constitution.");
678         }
679         if (have_flag(flgs, TR_CHR))
680         {
681                 info[i++] = _("それは魅力に影響を及ぼす。", "It affects your charisma.");
682         }
683
684         if (have_flag(flgs, TR_MAGIC_MASTERY))
685         {
686                 info[i++] = _("それは魔法道具使用能力に影響を及ぼす。", "It affects your ability to use magic devices.");
687
688         }
689         if (have_flag(flgs, TR_STEALTH))
690         {
691                 info[i++] = _("それは隠密行動能力に影響を及ぼす。", "It affects your stealth.");
692         }
693         if (have_flag(flgs, TR_SEARCH))
694         {
695                 info[i++] = _("それは探索能力に影響を及ぼす。", "It affects your searching.");
696         }
697         if (have_flag(flgs, TR_INFRA))
698         {
699                 info[i++] = _("それは赤外線視力に影響を及ぼす。", "It affects your infravision.");
700         }
701         if (have_flag(flgs, TR_TUNNEL))
702         {
703                 info[i++] = _("それは採掘能力に影響を及ぼす。", "It affects your ability to tunnel.");
704         }
705         if (have_flag(flgs, TR_SPEED))
706         {
707                 info[i++] = _("それはスピードに影響を及ぼす。", "It affects your speed.");
708         }
709         if (have_flag(flgs, TR_BLOWS))
710         {
711                 info[i++] = _("それは打撃回数に影響を及ぼす。", "It affects your attack speed.");
712         }
713
714         if (have_flag(flgs, TR_BRAND_ACID))
715         {
716                 info[i++] = _("それは酸によって大きなダメージを与える。", "It does extra damage from acid.");
717         }
718         if (have_flag(flgs, TR_BRAND_ELEC))
719         {
720                 info[i++] = _("それは電撃によって大きなダメージを与える。", "It does extra damage from electricity.");
721         }
722         if (have_flag(flgs, TR_BRAND_FIRE))
723         {
724                 info[i++] = _("それは火炎によって大きなダメージを与える。", "It does extra damage from fire.");
725         }
726         if (have_flag(flgs, TR_BRAND_COLD))
727         {
728                 info[i++] = _("それは冷気によって大きなダメージを与える。", "It does extra damage from frost.");
729         }
730
731         if (have_flag(flgs, TR_BRAND_POIS))
732         {
733                 info[i++] = _("それは敵を毒する。", "It poisons your foes.");
734         }
735
736         if (have_flag(flgs, TR_CHAOTIC))
737         {
738                 info[i++] = _("それはカオス的な効果を及ぼす。", "It produces chaotic effects.");
739         }
740
741         if (have_flag(flgs, TR_VAMPIRIC))
742         {
743                 info[i++] = _("それは敵から生命力を吸収する。", "It drains life from your foes.");
744         }
745
746         if (have_flag(flgs, TR_IMPACT))
747         {
748                 info[i++] = _("それは地震を起こすことができる。", "It can cause earthquakes.");
749         }
750
751         if (have_flag(flgs, TR_VORPAL))
752         {
753                 info[i++] = _("それは非常に切れ味が鋭く敵を切断することができる。", "It is very sharp and can cut your foes.");
754         }
755
756         if (have_flag(flgs, TR_KILL_DRAGON))
757         {
758                 info[i++] = _("それはドラゴンにとっての天敵である。", "It is a great bane of dragons.");
759         }
760         else if (have_flag(flgs, TR_SLAY_DRAGON))
761         {
762                 info[i++] = _("それはドラゴンに対して特に恐るべき力を発揮する。", "It is especially deadly against dragons.");
763         }
764
765         if (have_flag(flgs, TR_KILL_ORC))
766         {
767                 info[i++] = _("それはオークにとっての天敵である。", "It is a great bane of orcs.");
768         }
769         if (have_flag(flgs, TR_SLAY_ORC))
770         {
771                 info[i++] = _("それはオークに対して特に恐るべき力を発揮する。", "It is especially deadly against orcs.");
772         }
773
774         if (have_flag(flgs, TR_KILL_TROLL))
775         {
776                 info[i++] = _("それはトロルにとっての天敵である。", "It is a great bane of trolls.");
777         }
778         if (have_flag(flgs, TR_SLAY_TROLL))
779         {
780                 info[i++] = _("それはトロルに対して特に恐るべき力を発揮する。", "It is especially deadly against trolls.");
781         }
782
783         if (have_flag(flgs, TR_KILL_GIANT))
784         {
785                 info[i++] = _("それは巨人にとっての天敵である。", "It is a great bane of giants.");
786         }
787         else if (have_flag(flgs, TR_SLAY_GIANT))
788         {
789                 info[i++] = _("それはジャイアントに対して特に恐るべき力を発揮する。", "It is especially deadly against giants.");
790         }
791
792         if (have_flag(flgs, TR_KILL_DEMON))
793         {
794                 info[i++] = _("それはデーモンにとっての天敵である。", "It is a great bane of demons.");
795         }
796         if (have_flag(flgs, TR_SLAY_DEMON))
797         {
798                 info[i++] = _("それはデーモンに対して聖なる力を発揮する。", "It strikes at demons with holy wrath.");
799         }
800
801         if (have_flag(flgs, TR_KILL_UNDEAD))
802         {
803                 info[i++] = _("それはアンデッドにとっての天敵である。", "It is a great bane of undead.");
804         }
805         if (have_flag(flgs, TR_SLAY_UNDEAD))
806         {
807                 info[i++] = _("それはアンデッドに対して聖なる力を発揮する。", "It strikes at undead with holy wrath.");
808         }
809
810         if (have_flag(flgs, TR_KILL_EVIL))
811         {
812                 info[i++] = _("それは邪悪なる存在にとっての天敵である。", "It is a great bane of evil monsters.");
813         }
814         if (have_flag(flgs, TR_SLAY_EVIL))
815         {
816                 info[i++] = _("それは邪悪なる存在に対して聖なる力で攻撃する。", "It fights against evil with holy fury.");
817         }
818
819         if (have_flag(flgs, TR_KILL_ANIMAL))
820         {
821                 info[i++] = _("それは自然界の動物にとっての天敵である。", "It is a great bane of natural creatures.");
822         }
823         if (have_flag(flgs, TR_SLAY_ANIMAL))
824         {
825                 info[i++] = _("それは自然界の動物に対して特に恐るべき力を発揮する。", "It is especially deadly against natural creatures.");
826         }
827
828         if (have_flag(flgs, TR_KILL_HUMAN))
829         {
830                 info[i++] = _("それは人間にとっての天敵である。", "It is a great bane of humans.");
831         }
832         if (have_flag(flgs, TR_SLAY_HUMAN))
833         {
834                 info[i++] = _("それは人間に対して特に恐るべき力を発揮する。", "It is especially deadly against humans.");
835         }
836
837         if (have_flag(flgs, TR_FORCE_WEAPON))
838         {
839                 info[i++] = _("それは使用者の魔力を使って攻撃する。", "It powerfully strikes at a monster using your mana.");
840         }
841         if (have_flag(flgs, TR_DEC_MANA))
842         {
843                 info[i++] = _("それは魔力の消費を押さえる。", "It decreases your mana consumption.");
844         }
845         if (have_flag(flgs, TR_SUST_STR))
846         {
847                 info[i++] = _("それはあなたの腕力を維持する。", "It sustains your strength.");
848         }
849         if (have_flag(flgs, TR_SUST_INT))
850         {
851                 info[i++] = _("それはあなたの知能を維持する。", "It sustains your intelligence.");
852         }
853         if (have_flag(flgs, TR_SUST_WIS))
854         {
855                 info[i++] = _("それはあなたの賢さを維持する。", "It sustains your wisdom.");
856         }
857         if (have_flag(flgs, TR_SUST_DEX))
858         {
859                 info[i++] = _("それはあなたの器用さを維持する。", "It sustains your dexterity.");
860         }
861         if (have_flag(flgs, TR_SUST_CON))
862         {
863                 info[i++] = _("それはあなたの耐久力を維持する。", "It sustains your constitution.");
864         }
865         if (have_flag(flgs, TR_SUST_CHR))
866         {
867                 info[i++] = _("それはあなたの魅力を維持する。", "It sustains your charisma.");
868         }
869
870         if (have_flag(flgs, TR_IM_ACID))
871         {
872                 info[i++] = _("それは酸に対する完全な免疫を授ける。", "It provides immunity to acid.");
873         }
874         if (have_flag(flgs, TR_IM_ELEC))
875         {
876                 info[i++] = _("それは電撃に対する完全な免疫を授ける。", "It provides immunity to electricity.");
877         }
878         if (have_flag(flgs, TR_IM_FIRE))
879         {
880                 info[i++] = _("それは火に対する完全な免疫を授ける。", "It provides immunity to fire.");
881         }
882         if (have_flag(flgs, TR_IM_COLD))
883         {
884                 info[i++] = _("それは寒さに対する完全な免疫を授ける。", "It provides immunity to cold.");
885         }
886
887         if (have_flag(flgs, TR_THROW))
888         {
889                 info[i++] = _("それは敵に投げて大きなダメージを与えることができる。", "It is perfectly balanced for throwing.");
890         }
891
892         if (have_flag(flgs, TR_FREE_ACT))
893         {
894                 info[i++] = _("それは麻痺に対する完全な免疫を授ける。", "It provides immunity to paralysis.");
895         }
896         if (have_flag(flgs, TR_HOLD_EXP))
897         {
898                 info[i++] = _("それは経験値吸収に対する耐性を授ける。", "It provides resistance to experience draining.");
899         }
900         if (have_flag(flgs, TR_RES_FEAR))
901         {
902                 info[i++] = _("それは恐怖への完全な耐性を授ける。", "It makes you completely fearless.");
903         }
904         if (have_flag(flgs, TR_RES_ACID))
905         {
906                 info[i++] = _("それは酸への耐性を授ける。", "It provides resistance to acid.");
907         }
908         if (have_flag(flgs, TR_RES_ELEC))
909         {
910                 info[i++] = _("それは電撃への耐性を授ける。", "It provides resistance to electricity.");
911         }
912         if (have_flag(flgs, TR_RES_FIRE))
913         {
914                 info[i++] = _("それは火への耐性を授ける。", "It provides resistance to fire.");
915         }
916         if (have_flag(flgs, TR_RES_COLD))
917         {
918                 info[i++] = _("それは寒さへの耐性を授ける。", "It provides resistance to cold.");
919         }
920         if (have_flag(flgs, TR_RES_POIS))
921         {
922                 info[i++] = _("それは毒への耐性を授ける。", "It provides resistance to poison.");
923         }
924
925         if (have_flag(flgs, TR_RES_LITE))
926         {
927                 info[i++] = _("それは閃光への耐性を授ける。", "It provides resistance to light.");
928         }
929         if (have_flag(flgs, TR_RES_DARK))
930         {
931                 info[i++] = _("それは暗黒への耐性を授ける。", "It provides resistance to dark.");
932         }
933
934         if (have_flag(flgs, TR_RES_BLIND))
935         {
936                 info[i++] = _("それは盲目への耐性を授ける。", "It provides resistance to blindness.");
937         }
938         if (have_flag(flgs, TR_RES_CONF))
939         {
940                 info[i++] = _("それは混乱への耐性を授ける。", "It provides resistance to confusion.");
941         }
942         if (have_flag(flgs, TR_RES_SOUND))
943         {
944                 info[i++] = _("それは轟音への耐性を授ける。", "It provides resistance to sound.");
945         }
946         if (have_flag(flgs, TR_RES_SHARDS))
947         {
948                 info[i++] = _("それは破片への耐性を授ける。", "It provides resistance to shards.");
949         }
950
951         if (have_flag(flgs, TR_RES_NETHER))
952         {
953                 info[i++] = _("それは地獄への耐性を授ける。", "It provides resistance to nether.");
954         }
955         if (have_flag(flgs, TR_RES_NEXUS))
956         {
957                 info[i++] = _("それは因果混乱への耐性を授ける。", "It provides resistance to nexus.");
958         }
959         if (have_flag(flgs, TR_RES_CHAOS))
960         {
961                 info[i++] = _("それはカオスへの耐性を授ける。", "It provides resistance to chaos.");
962         }
963         if (have_flag(flgs, TR_RES_DISEN))
964         {
965                 info[i++] = _("それは劣化への耐性を授ける。", "It provides resistance to disenchantment.");
966         }
967
968         if (have_flag(flgs, TR_LEVITATION))
969         {
970                 info[i++] = _("それは宙に浮くことを可能にする。", "It allows you to levitate.");
971         }
972                 
973         if (have_flag(flgs, TR_SEE_INVIS))
974         {
975                 info[i++] = _("それは透明なモンスターを見ることを可能にする。", "It allows you to see invisible monsters.");
976         }
977         if (have_flag(flgs, TR_TELEPATHY))
978         {
979                 info[i++] = _("それはテレパシー能力を授ける。", "It gives telepathic powers.");
980         }
981         if (have_flag(flgs, TR_ESP_ANIMAL))
982         {
983                 info[i++] = _("それは自然界の生物を感知する。", "It senses natural creatures.");
984         }
985         if (have_flag(flgs, TR_ESP_UNDEAD))
986         {
987                 info[i++] = _("それはアンデッドを感知する。", "It senses undead.");
988         }
989         if (have_flag(flgs, TR_ESP_DEMON))
990         {
991                 info[i++] = _("それは悪魔を感知する。", "It senses demons.");
992         }
993         if (have_flag(flgs, TR_ESP_ORC))
994         {
995                 info[i++] = _("それはオークを感知する。", "It senses orcs.");
996         }
997         if (have_flag(flgs, TR_ESP_TROLL))
998         {
999                 info[i++] = _("それはトロルを感知する。", "It senses trolls.");
1000         }
1001         if (have_flag(flgs, TR_ESP_GIANT))
1002         {
1003                 info[i++] = _("それは巨人を感知する。", "It senses giants.");
1004         }
1005         if (have_flag(flgs, TR_ESP_DRAGON))
1006         {
1007                 info[i++] = _("それはドラゴンを感知する。", "It senses dragons.");
1008         }
1009         if (have_flag(flgs, TR_ESP_HUMAN))
1010         {
1011                 info[i++] = _("それは人間を感知する。", "It senses humans.");
1012         }
1013         if (have_flag(flgs, TR_ESP_EVIL))
1014         {
1015                 info[i++] = _("それは邪悪な存在を感知する。", "It senses evil creatures.");
1016         }
1017         if (have_flag(flgs, TR_ESP_GOOD))
1018         {
1019                 info[i++] = _("それは善良な存在を感知する。", "It senses good creatures.");
1020         }
1021         if (have_flag(flgs, TR_ESP_NONLIVING))
1022         {
1023                 info[i++] = _("それは活動する無生物体を感知する。", "It senses non-living creatures.");
1024         }
1025         if (have_flag(flgs, TR_ESP_UNIQUE))
1026         {
1027                 info[i++] = _("それは特別な強敵を感知する。", "It senses unique monsters.");
1028         }
1029         if (have_flag(flgs, TR_SLOW_DIGEST))
1030         {
1031                 info[i++] = _("それはあなたの新陳代謝を遅くする。", "It slows your metabolism.");
1032         }
1033         if (have_flag(flgs, TR_REGEN))
1034         {
1035                 info[i++] = _("それは体力回復力を強化する。", "It speeds your regenerative powers.");
1036         }
1037         if (have_flag(flgs, TR_WARNING))
1038         {
1039                 info[i++] = _("それは危険に対して警告を発する。", "It warns you of danger");
1040         }
1041         if (have_flag(flgs, TR_REFLECT))
1042         {
1043                 info[i++] = _("それは矢の呪文を反射する。", "It reflects bolt spells.");
1044         }
1045         if (have_flag(flgs, TR_SH_FIRE))
1046         {
1047                 info[i++] = _("それは炎のバリアを張る。", "It produces a fiery sheath.");
1048         }
1049         if (have_flag(flgs, TR_SH_ELEC))
1050         {
1051                 info[i++] = _("それは電気のバリアを張る。", "It produces an electric sheath.");
1052         }
1053         if (have_flag(flgs, TR_SH_COLD))
1054         {
1055                 info[i++] = _("それは冷気のバリアを張る。", "It produces a sheath of coldness.");
1056         }
1057         if (have_flag(flgs, TR_NO_MAGIC))
1058         {
1059                 info[i++] = _("それは反魔法バリアを張る。", "It produces an anti-magic shell.");
1060         }
1061         if (have_flag(flgs, TR_NO_TELE))
1062         {
1063                 info[i++] = _("それはテレポートを邪魔する。", "It prevents teleportation.");
1064         }
1065         if (have_flag(flgs, TR_XTRA_MIGHT))
1066         {
1067                 info[i++] = _("それは矢/ボルト/弾をより強力に発射することができる。", "It fires missiles with extra might.");
1068         }
1069         if (have_flag(flgs, TR_XTRA_SHOTS))
1070         {
1071                 info[i++] = _("それは矢/ボルト/弾を非常に早く発射することができる。", "It fires missiles excessively fast.");
1072         }
1073
1074         if (have_flag(flgs, TR_BLESSED))
1075         {
1076                 info[i++] = _("それは神に祝福されている。", "It has been blessed by the gods.");
1077         }
1078
1079         if (object_is_cursed(o_ptr))
1080         {
1081                 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
1082                 {
1083                         info[i++] = _("それは永遠の呪いがかけられている。", "It is permanently cursed.");
1084                 }
1085                 else if (o_ptr->curse_flags & TRC_HEAVY_CURSE)
1086                 {
1087                         info[i++] = _("それは強力な呪いがかけられている。", "It is heavily cursed.");
1088                 }
1089                 else
1090                 {
1091                         info[i++] = _("それは呪われている。", "It is cursed.");
1092
1093                         /*
1094                          * It's a trivial infomation since there is
1095                          * fake inscription {cursed}
1096                          */
1097                         trivial_info++;
1098                 }
1099         }
1100
1101         if ((have_flag(flgs, TR_TY_CURSE)) || (o_ptr->curse_flags & TRC_TY_CURSE))
1102         {
1103                 info[i++] = _("それは太古の禍々しい怨念が宿っている。", "It carries an ancient foul curse.");
1104         }
1105         if ((have_flag(flgs, TR_AGGRAVATE)) || (o_ptr->curse_flags & TRC_AGGRAVATE))
1106         {
1107                 info[i++] = _("それは付近のモンスターを怒らせる。", "It aggravates nearby creatures.");
1108         }
1109         if ((have_flag(flgs, TR_DRAIN_EXP)) || (o_ptr->curse_flags & TRC_DRAIN_EXP))
1110         {
1111                 info[i++] = _("それは経験値を吸い取る。", "It drains experience.");
1112         }
1113         if (o_ptr->curse_flags & TRC_SLOW_REGEN)
1114         {
1115                 info[i++] = _("それは回復力を弱める。", "It slows your regenerative powers.");
1116         }
1117         if ((o_ptr->curse_flags & TRC_ADD_L_CURSE) || have_flag(flgs, TR_ADD_L_CURSE))
1118         {
1119                 info[i++] = _("それは弱い呪いを増やす。","It adds weak curses.");
1120         }
1121         if ((o_ptr->curse_flags & TRC_ADD_H_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
1122         {
1123                 info[i++] = _("それは強力な呪いを増やす。","It adds heavy curses.");
1124         }
1125         if ((have_flag(flgs, TR_CALL_ANIMAL)) || (o_ptr->curse_flags & TRC_CALL_ANIMAL))
1126         {
1127                 info[i++] = _("それは動物を呼び寄せる。", "It attracts animals.");
1128         }
1129         if ((have_flag(flgs, TR_CALL_DEMON)) || (o_ptr->curse_flags & TRC_CALL_DEMON))
1130         {
1131                 info[i++] = _("それは悪魔を呼び寄せる。", "It attracts demons.");
1132         }
1133         if ((have_flag(flgs, TR_CALL_DRAGON)) || (o_ptr->curse_flags & TRC_CALL_DRAGON))
1134         {
1135                 info[i++] = _("それはドラゴンを呼び寄せる。", "It attracts dragons.");
1136         }
1137         if ((have_flag(flgs, TR_CALL_UNDEAD)) || (o_ptr->curse_flags & TRC_CALL_UNDEAD))
1138         {
1139                 info[i++] = _("それは死霊を呼び寄せる。", "It attracts undeads.");
1140         }
1141         if ((have_flag(flgs, TR_COWARDICE)) ||  (o_ptr->curse_flags & TRC_COWARDICE))
1142         {
1143                 info[i++] = _("それは恐怖感を引き起こす。", "It makes you subject to cowardice.");
1144         }
1145         if ((have_flag(flgs, TR_TELEPORT)) || (o_ptr->curse_flags & TRC_TELEPORT))
1146         {
1147                 info[i++] = _("それはランダムなテレポートを引き起こす。", "It induces random teleportation.");
1148         }
1149         if ((have_flag(flgs, TR_LOW_MELEE)) || o_ptr->curse_flags & TRC_LOW_MELEE)
1150         {
1151                 info[i++] = _("それは攻撃を外しやすい。", "It causes you to miss blows.");
1152         }
1153         if ((have_flag(flgs, TR_LOW_AC)) || (o_ptr->curse_flags & TRC_LOW_AC))
1154         {
1155                 info[i++] = _("それは攻撃を受けやすい。", "It helps your enemies' blows.");
1156         }
1157         if ((have_flag(flgs, TR_LOW_MAGIC)) || (o_ptr->curse_flags & TRC_LOW_MAGIC))
1158         {
1159                 info[i++] = _("それは魔法を唱えにくくする。", "It encumbers you while spellcasting.");
1160         }
1161         if ((have_flag(flgs, TR_FAST_DIGEST)) || (o_ptr->curse_flags & TRC_FAST_DIGEST))
1162         {
1163                 info[i++] = _("それはあなたの新陳代謝を速くする。", "It speeds your metabolism.");
1164         }
1165         if ((have_flag(flgs, TR_DRAIN_HP)) || (o_ptr->curse_flags & TRC_DRAIN_HP))
1166         {
1167                 info[i++] = _("それはあなたの体力を吸い取る。", "It drains you.");
1168         }
1169         if ((have_flag(flgs, TR_DRAIN_MANA)) || (o_ptr->curse_flags & TRC_DRAIN_MANA))
1170         {
1171                 info[i++] = _("それはあなたの魔力を吸い取る。", "It drains your mana.");
1172         }
1173
1174         /* Describe about this kind of object instead of THIS fake object */
1175         if (mode & SCROBJ_FAKE_OBJECT)
1176         {
1177                 switch (o_ptr->tval)
1178                 {
1179                 case TV_RING:
1180                         switch (o_ptr->sval)
1181                         {
1182                         case SV_RING_LORDLY:
1183                                 info[i++] = _("それは幾つかのランダムな耐性を授ける。", "It provides some random resistances.");
1184                                 break;
1185                         case SV_RING_WARNING:
1186                                 info[i++] = _("それはひとつの低級なESPを授ける事がある。", "It may provide a low rank ESP.");
1187                                 break;
1188                         }
1189                         break;
1190
1191                 case TV_AMULET:
1192                         switch (o_ptr->sval)
1193                         {
1194                         case SV_AMULET_RESISTANCE:
1195                                 info[i++] = _("それは毒への耐性を授ける事がある。", "It may provides resistance to poison.");
1196                                 info[i++] = _("それはランダムな耐性を授ける事がある。", "It may provide a random resistances.");
1197                                 break;
1198                         case SV_AMULET_THE_MAGI:
1199                                 info[i++] = _("それは最大で3つまでの低級なESPを授ける。", "It provides up to three low rank ESPs.");
1200                                 break;
1201                         }
1202                         break;
1203                 }
1204         }
1205
1206         if (have_flag(flgs, TR_IGNORE_ACID) &&
1207             have_flag(flgs, TR_IGNORE_ELEC) &&
1208             have_flag(flgs, TR_IGNORE_FIRE) &&
1209             have_flag(flgs, TR_IGNORE_COLD))
1210         {
1211                 info[i++] = _("それは酸・電撃・火炎・冷気では傷つかない。", "It cannot be harmed by the elements.");
1212         }
1213         else
1214         {
1215                 if (have_flag(flgs, TR_IGNORE_ACID))
1216                 {
1217                         info[i++] = _("それは酸では傷つかない。", "It cannot be harmed by acid.");
1218                 }
1219                 if (have_flag(flgs, TR_IGNORE_ELEC))
1220                 {
1221                         info[i++] = _("それは電撃では傷つかない。", "It cannot be harmed by electricity.");
1222                 }
1223                 if (have_flag(flgs, TR_IGNORE_FIRE))
1224                 {
1225                         info[i++] = _("それは火炎では傷つかない。", "It cannot be harmed by fire.");
1226                 }
1227                 if (have_flag(flgs, TR_IGNORE_COLD))
1228                 {
1229                         info[i++] = _("それは冷気では傷つかない。", "It cannot be harmed by cold.");
1230                 }
1231         }
1232
1233         if (mode & SCROBJ_FORCE_DETAIL) trivial_info = 0;
1234
1235         /* No relevant informations */
1236         if (i <= trivial_info) return (FALSE);
1237
1238         /* Save the screen */
1239         screen_save();
1240
1241         /* Get size */
1242         Term_get_size(&wid, &hgt);
1243
1244         /* Display Item name */
1245         if (!(mode & SCROBJ_FAKE_OBJECT))
1246                 object_desc(o_name, o_ptr, 0);
1247         else
1248                 object_desc(o_name, o_ptr, (OD_NAME_ONLY | OD_STORE));
1249
1250         prt(o_name, 0, 0);
1251
1252         /* Erase the screen */
1253         for (k = 1; k < hgt; k++) prt("", k, 13);
1254
1255         /* Label the information */
1256         if ((o_ptr->tval == TV_STATUE) && (o_ptr->sval == SV_PHOTO))
1257         {
1258                 monster_race *r_ptr = &r_info[o_ptr->pval];
1259                 int namelen = strlen(r_name + r_ptr->name);
1260                 prt(format("%s: '", r_name + r_ptr->name), 1, 15);
1261                 Term_queue_bigchar(18 + namelen, 1, r_ptr->x_attr, r_ptr->x_char, 0, 0);
1262                 prt("'", 1, (use_bigtile ? 20 : 19) + namelen);
1263         }
1264         else
1265         {
1266                 prt(_("     アイテムの能力:", "     Item Attributes:"), 1, 15);
1267         }
1268
1269         /* We will print on top of the map (column 13) */
1270         for (k = 2, j = 0; j < i; j++)
1271         {
1272                 /* Show the info */
1273                 prt(info[j], k++, 15);
1274
1275                 /* Every 20 entries (lines 2 to 21), start over */
1276                 if ((k == hgt - 2) && (j+1 < i))
1277                 {
1278                         prt(_("-- 続く --", "-- more --"), k, 15);
1279                         inkey();
1280                         for (; k > 2; k--) prt("", k, 15);
1281                 }
1282         }
1283
1284         /* Wait for it */
1285         prt(_("[何かキーを押すとゲームに戻ります]", "[Press any key to continue]"), k, 15);
1286
1287         inkey();
1288
1289         /* Restore the screen */
1290         screen_load();
1291
1292         /* Gave knowledge */
1293         return (TRUE);
1294 }
1295
1296
1297
1298 /*!
1299  * @brief オブジェクト選択時の選択アルファベットラベルを返す /
1300  * Convert an inventory index into a one character label
1301  * @param i プレイヤーの所持/装備オブジェクトID
1302  * @return 対応するアルファベット
1303  * @details Note that the label does NOT distinguish inven/equip.
1304  */
1305 char index_to_label(int i)
1306 {
1307         /* Indexes for "inven" are easy */
1308         if (i < INVEN_RARM) return (I2A(i));
1309
1310         /* Indexes for "equip" are offset */
1311         return (I2A(i - INVEN_RARM));
1312 }
1313
1314 /*!
1315  * @brief 選択アルファベットラベルからプレイヤーの所持オブジェクトIDを返す /
1316  * Convert a label into the index of an item in the "inven"
1317  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1318  * @details Note that the label does NOT distinguish inven/equip.
1319  */
1320 INVENTORY_IDX label_to_inven(int c)
1321 {
1322         INVENTORY_IDX i;
1323
1324         /* Convert */
1325         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1);
1326
1327         /* Verify the index */
1328         if ((i < 0) || (i > INVEN_PACK)) return (-1);
1329
1330         /* Empty slots can never be chosen */
1331         if (!inventory[i].k_idx) return (-1);
1332
1333         /* Return the index */
1334         return (i);
1335 }
1336
1337
1338 /*! See cmd5.c */
1339 extern bool select_ring_slot;
1340
1341
1342 /*!
1343  * @brief プレイヤーの所持/装備オブジェクトIDが指輪枠かを返す /
1344  * @param i プレイヤーの所持/装備オブジェクトID
1345  * @return 指輪枠ならばTRUEを返す。
1346  */
1347 static bool is_ring_slot(int i)
1348 {
1349         return (i == INVEN_RIGHT) || (i == INVEN_LEFT);
1350 }
1351
1352
1353 /*!
1354  * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
1355  * Convert a label into the index of a item in the "equip"
1356  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
1357  */
1358 INVENTORY_IDX label_to_equip(int c)
1359 {
1360         INVENTORY_IDX i;
1361
1362         /* Convert */
1363         i = (INVENTORY_IDX)(islower(c) ? A2I(c) : -1) + INVEN_RARM;
1364
1365         /* Verify the index */
1366         if ((i < INVEN_RARM) || (i >= INVEN_TOTAL)) return (-1);
1367
1368         if (select_ring_slot) return is_ring_slot(i) ? i : -1;
1369
1370         /* Empty slots can never be chosen */
1371         if (!inventory[i].k_idx) return (-1);
1372
1373         /* Return the index */
1374         return (i);
1375 }
1376
1377
1378
1379 /*!
1380  * @brief オブジェクトの該当装備部位IDを返す /
1381  * Determine which equipment slot (if any) an item likes
1382  * @param o_ptr 名称を取得する元のオブジェクト構造体参照ポインタ
1383  * @return 対応する装備部位ID
1384  */
1385 s16b wield_slot(object_type *o_ptr)
1386 {
1387         /* Slot for equipment */
1388         switch (o_ptr->tval)
1389         {
1390                 case TV_DIGGING:
1391                 case TV_HAFTED:
1392                 case TV_POLEARM:
1393                 case TV_SWORD:
1394                 {
1395                         if (!inventory[INVEN_RARM].k_idx) return (INVEN_RARM);
1396                         if (inventory[INVEN_LARM].k_idx) return (INVEN_RARM);
1397                         return (INVEN_LARM);
1398                 }
1399
1400                 case TV_CAPTURE:
1401                 case TV_CARD:
1402                 case TV_SHIELD:
1403                 {
1404                         if (!inventory[INVEN_LARM].k_idx) return (INVEN_LARM);
1405                         if (inventory[INVEN_RARM].k_idx) return (INVEN_LARM);
1406                         return (INVEN_RARM);
1407                 }
1408
1409                 case TV_BOW:
1410                 {
1411                         return (INVEN_BOW);
1412                 }
1413
1414                 case TV_RING:
1415                 {
1416                         /* Use the right hand first */
1417                         if (!inventory[INVEN_RIGHT].k_idx) return (INVEN_RIGHT);
1418
1419                         /* Use the left hand for swapping (by default) */
1420                         return (INVEN_LEFT);
1421                 }
1422
1423                 case TV_AMULET:
1424                 case TV_WHISTLE:
1425                 {
1426                         return (INVEN_NECK);
1427                 }
1428
1429                 case TV_LITE:
1430                 {
1431                         return (INVEN_LITE);
1432                 }
1433
1434                 case TV_DRAG_ARMOR:
1435                 case TV_HARD_ARMOR:
1436                 case TV_SOFT_ARMOR:
1437                 {
1438                         return (INVEN_BODY);
1439                 }
1440
1441                 case TV_CLOAK:
1442                 {
1443                         return (INVEN_OUTER);
1444                 }
1445
1446                 case TV_CROWN:
1447                 case TV_HELM:
1448                 {
1449                         return (INVEN_HEAD);
1450                 }
1451
1452                 case TV_GLOVES:
1453                 {
1454                         return (INVEN_HANDS);
1455                 }
1456
1457                 case TV_BOOTS:
1458                 {
1459                         return (INVEN_FEET);
1460                 }
1461         }
1462
1463         /* No slot available */
1464         return (-1);
1465 }
1466
1467 /*!
1468  * @brief 所持/装備オブジェクトIDの部位表現を返す /
1469  * Return a string mentioning how a given item is carried
1470  * @param i 部位表現を求めるプレイヤーの所持/装備オブジェクトID
1471  * @return 部位表現の文字列ポインタ
1472  */
1473 cptr mention_use(int i)
1474 {
1475         cptr p;
1476
1477         /* Examine the location */
1478         switch (i)
1479         {
1480 #ifdef JP
1481                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中" : ((p_ptr->ryoute && p_ptr->migite) ? " 両手" : (left_hander ? " 左手" : " 右手")); break;
1482 #else
1483                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "Just lifting" : (p_ptr->migite ? "Wielding" : "On arm"); break;
1484 #endif
1485
1486 #ifdef JP
1487                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中" : ((p_ptr->ryoute && p_ptr->hidarite) ? " 両手" : (left_hander ? " 右手" : " 左手")); break;
1488 #else
1489                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "Just lifting" : (p_ptr->hidarite ? "Wielding" : "On arm"); break;
1490 #endif
1491
1492 #ifdef JP
1493                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "運搬中" : "射撃用"; break;
1494 #else
1495                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "Just holding" : "Shooting"; break;
1496 #endif
1497
1498 #ifdef JP
1499                 case INVEN_RIGHT: p = (left_hander ? "左手指" : "右手指"); break;
1500 #else
1501                 case INVEN_RIGHT: p = (left_hander ? "On left hand" : "On right hand"); break;
1502 #endif
1503
1504 #ifdef JP
1505                 case INVEN_LEFT:  p = (left_hander ? "右手指" : "左手指"); break;
1506 #else
1507                 case INVEN_LEFT:  p = (left_hander ? "On right hand" : "On left hand"); break;
1508 #endif
1509
1510                 case INVEN_NECK:  p = _("  首", "Around neck"); break;
1511                 case INVEN_LITE:  p = _(" 光源", "Light source"); break;
1512                 case INVEN_BODY:  p = _("  体", "On body"); break;
1513                 case INVEN_OUTER: p = _("体の上", "About body"); break;
1514                 case INVEN_HEAD:  p = _("  頭", "On head"); break;
1515                 case INVEN_HANDS: p = _("  手", "On hands"); break;
1516                 case INVEN_FEET:  p = _("  足", "On feet"); break;
1517                 default:          p = _("ザック", "In pack"); break;
1518         }
1519
1520         /* Return the result */
1521         return p;
1522 }
1523
1524
1525 /*!
1526  * @brief 所持/装備オブジェクトIDの現在の扱い方の状態表現を返す /
1527  * Return a string describing how a given item is being worn.
1528  * @param i 状態表現を求めるプレイヤーの所持/装備オブジェクトID
1529  * @return 状態表現内容の文字列ポインタ
1530  * @details
1531  * Currently, only used for items in the equipment, not inventory.
1532  */
1533 cptr describe_use(int i)
1534 {
1535         cptr p;
1536
1537         switch (i)
1538         {
1539 #ifdef JP
1540                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->migite) ? "両手に装備している" : (left_hander ? "左手に装備している" : "右手に装備している")); break;
1541 #else
1542                 case INVEN_RARM:  p = p_ptr->heavy_wield[0] ? "just lifting" : (p_ptr->migite ? "attacking monsters with" : "wearing on your arm"); break;
1543 #endif
1544
1545 #ifdef JP
1546                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "運搬中の" : ((p_ptr->ryoute && p_ptr->hidarite) ? "両手に装備している" : (left_hander ? "右手に装備している" : "左手に装備している")); break;
1547 #else
1548                 case INVEN_LARM:  p = p_ptr->heavy_wield[1] ? "just lifting" : (p_ptr->hidarite ? "attacking monsters with" : "wearing on your arm"); break;
1549 #endif
1550
1551 #ifdef JP
1552                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "持つだけで精一杯の" : "射撃用に装備している"; break;
1553 #else
1554                 case INVEN_BOW:   p = (adj_str_hold[p_ptr->stat_ind[A_STR]] < inventory[i].weight / 10) ? "just holding" : "shooting missiles with"; break;
1555 #endif
1556
1557 #ifdef JP
1558                 case INVEN_RIGHT: p = (left_hander ? "左手の指にはめている" : "右手の指にはめている"); break;
1559 #else
1560                 case INVEN_RIGHT: p = (left_hander ? "wearing on your left hand" : "wearing on your right hand"); break;
1561 #endif
1562
1563 #ifdef JP
1564                 case INVEN_LEFT:  p = (left_hander ? "右手の指にはめている" : "左手の指にはめている"); break;
1565 #else
1566                 case INVEN_LEFT:  p = (left_hander ? "wearing on your right hand" : "wearing on your left hand"); break;
1567 #endif
1568
1569                 case INVEN_NECK:  p = _("首にかけている", "wearing around your neck"); break;
1570                 case INVEN_LITE:  p = _("光源にしている", "using to light the way"); break;
1571                 case INVEN_BODY:  p = _("体に着ている", "wearing on your body"); break;
1572                 case INVEN_OUTER: p = _("身にまとっている", "wearing on your back"); break;
1573                 case INVEN_HEAD:  p = _("頭にかぶっている", "wearing on your head"); break;
1574                 case INVEN_HANDS: p = _("手につけている", "wearing on your hands"); break;
1575                 case INVEN_FEET:  p = _("足にはいている", "wearing on your feet"); break;
1576                 default:          p = _("ザックに入っている", "carrying in your pack"); break;
1577         }
1578
1579         /* Return the result */
1580         return p;
1581 }
1582
1583
1584 /*!
1585  * @brief tval/sval指定のベースアイテムがプレイヤーの使用可能な魔法書かどうかを返す /
1586  * Hack: Check if a spellbook is one of the realms we can use. -- TY
1587  * @param book_tval ベースアイテムのtval
1588  * @param book_sval ベースアイテムのsval
1589  * @return 使用可能な魔法書ならばTRUEを返す。
1590  */
1591
1592 bool check_book_realm(const OBJECT_TYPE_VALUE book_tval, const OBJECT_SUBTYPE_VALUE book_sval)
1593 {
1594         if (book_tval < TV_LIFE_BOOK) return FALSE;
1595         if (p_ptr->pclass == CLASS_SORCERER)
1596         {
1597                 return is_magic(tval2realm(book_tval));
1598         }
1599         else if (p_ptr->pclass == CLASS_RED_MAGE)
1600         {
1601                 if (is_magic(tval2realm(book_tval)))
1602                         return ((book_tval == TV_ARCANE_BOOK) || (book_sval < 2));
1603         }
1604         return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
1605 }
1606
1607 /*!
1608  * @brief アイテムがitem_tester_hookグローバル関数ポインタの条件を満たしているかを返す汎用関数
1609  * Check an item against the item tester info
1610  * @param o_ptr 判定を行いたいオブジェクト構造体参照ポインタ
1611  * @return item_tester_hookの参照先、その他いくつかの例外に応じてTRUE/FALSEを返す。
1612  */
1613 bool item_tester_okay(object_type *o_ptr)
1614 {
1615         /* Hack -- allow listing empty slots */
1616         if (item_tester_full) return (TRUE);
1617
1618         /* Require an item */
1619         if (!o_ptr->k_idx) return (FALSE);
1620
1621         /* Hack -- ignore "gold" */
1622         if (o_ptr->tval == TV_GOLD)
1623         {
1624                 /* See xtra2.c */
1625                 extern bool show_gold_on_floor;
1626
1627                 if (!show_gold_on_floor) return (FALSE);
1628         }
1629
1630         /* Check the tval */
1631         if (item_tester_tval)
1632         {
1633                 /* Is it a spellbook? If so, we need a hack -- TY */
1634                 if ((item_tester_tval <= TV_DEATH_BOOK) &&
1635                         (item_tester_tval >= TV_LIFE_BOOK))
1636                         return check_book_realm(o_ptr->tval, o_ptr->sval);
1637                 else
1638                         if (item_tester_tval != o_ptr->tval) return (FALSE);
1639         }
1640
1641         /* Check the hook */
1642         if (item_tester_hook)
1643         {
1644                 if (!(*item_tester_hook)(o_ptr)) return (FALSE);
1645         }
1646
1647         /* Assume okay */
1648         return (TRUE);
1649 }
1650
1651
1652 /*!
1653  * @brief 所持アイテム一覧を表示する /
1654  * Choice window "shadow" of the "show_inven()" function
1655  * @return なし
1656  */
1657 void display_inven(void)
1658 {
1659         register        int i, n, z = 0;
1660         object_type     *o_ptr;
1661         byte            attr = TERM_WHITE;
1662         char            tmp_val[80];
1663         char            o_name[MAX_NLEN];
1664         int             wid, hgt;
1665
1666         /* Get size */
1667         Term_get_size(&wid, &hgt);
1668
1669         /* Find the "final" slot */
1670         for (i = 0; i < INVEN_PACK; i++)
1671         {
1672                 o_ptr = &inventory[i];
1673
1674                 /* Skip non-objects */
1675                 if (!o_ptr->k_idx) continue;
1676
1677                 /* Track */
1678                 z = i + 1;
1679         }
1680
1681         /* Display the pack */
1682         for (i = 0; i < z; i++)
1683         {
1684                 /* Examine the item */
1685                 o_ptr = &inventory[i];
1686
1687                 /* Start with an empty "index" */
1688                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1689
1690                 /* Is this item "acceptable"? */
1691                 if (item_tester_okay(o_ptr))
1692                 {
1693                         /* Prepare an "index" */
1694                         tmp_val[0] = index_to_label(i);
1695
1696                         /* Bracket the "index" --(-- */
1697                         tmp_val[1] = ')';
1698                 }
1699
1700                 /* Display the index (or blank space) */
1701                 Term_putstr(0, i, 3, TERM_WHITE, tmp_val);
1702
1703                 /* Obtain an item description */
1704                 object_desc(o_name, o_ptr, 0);
1705
1706                 /* Obtain the length of the description */
1707                 n = strlen(o_name);
1708
1709                 /* Get a color */
1710                 attr = tval_to_attr[o_ptr->tval % 128];
1711
1712                 /* Grey out charging items */
1713                 if (o_ptr->timeout)
1714                 {
1715                         attr = TERM_L_DARK;
1716                 }
1717
1718                 /* Display the entry itself */
1719                 Term_putstr(3, i, n, attr, o_name);
1720
1721                 /* Erase the rest of the line */
1722                 Term_erase(3+n, i, 255);
1723
1724                 /* Display the weight if needed */
1725                 if (show_weights)
1726                 {
1727                         int wgt = o_ptr->weight * o_ptr->number;
1728 #ifdef JP
1729                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt),lbtokg2(wgt) );
1730 #else
1731                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1732 #endif
1733
1734                         prt(tmp_val, i, wid - 9);
1735                 }
1736         }
1737
1738         /* Erase the rest of the window */
1739         for (i = z; i < hgt; i++)
1740         {
1741                 /* Erase the line */
1742                 Term_erase(0, i, 255);
1743         }
1744 }
1745
1746
1747
1748 /*!
1749  * @brief 装備アイテム一覧を表示する /
1750  * Choice window "shadow" of the "show_equip()" function
1751  * @return なし
1752  */
1753 void display_equip(void)
1754 {
1755         register        int i, n;
1756         object_type     *o_ptr;
1757         byte            attr = TERM_WHITE;
1758         char            tmp_val[80];
1759         char            o_name[MAX_NLEN];
1760         int             wid, hgt;
1761
1762         /* Get size */
1763         Term_get_size(&wid, &hgt);
1764
1765         /* Display the equipment */
1766         for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
1767         {
1768                 /* Examine the item */
1769                 o_ptr = &inventory[i];
1770
1771                 /* Start with an empty "index" */
1772                 tmp_val[0] = tmp_val[1] = tmp_val[2] = ' ';
1773
1774                 /* Is this item "acceptable"? */
1775                 if (select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr))
1776                 {
1777                         /* Prepare an "index" */
1778                         tmp_val[0] = index_to_label(i);
1779
1780                         /* Bracket the "index" --(-- */
1781                         tmp_val[1] = ')';
1782                 }
1783
1784                 /* Display the index (or blank space) */
1785                 Term_putstr(0, i - INVEN_RARM, 3, TERM_WHITE, tmp_val);
1786
1787                 /* Obtain an item description */
1788                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
1789                 {
1790                         strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
1791                         attr = TERM_WHITE;
1792                 }
1793                 else
1794                 {
1795                         object_desc(o_name, o_ptr, 0);
1796                         attr = tval_to_attr[o_ptr->tval % 128];
1797                 }
1798
1799                 /* Obtain the length of the description */
1800                 n = strlen(o_name);
1801
1802                 /* Grey out charging items */
1803                 if (o_ptr->timeout)
1804                 {
1805                         attr = TERM_L_DARK;
1806                 }
1807
1808                 /* Display the entry itself */
1809                 Term_putstr(3, i - INVEN_RARM, n, attr, o_name);
1810
1811                 /* Erase the rest of the line */
1812                 Term_erase(3+n, i - INVEN_RARM, 255);
1813
1814                 /* Display the weight (if needed) */
1815                 if (show_weights)
1816                 {
1817                         int wgt = o_ptr->weight * o_ptr->number;
1818 #ifdef JP
1819                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt));
1820 #else
1821                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
1822 #endif
1823
1824                         prt(tmp_val, i - INVEN_RARM, wid - (show_labels ? 28 : 9));
1825                 }
1826
1827                 /* Display the slot description (if needed) */
1828                 if (show_labels)
1829                 {
1830                         Term_putstr(wid - 20, i - INVEN_RARM, -1, TERM_WHITE, " <-- ");
1831                         prt(mention_use(i), i - INVEN_RARM, wid - 15);
1832                 }
1833         }
1834
1835         /* Erase the rest of the window */
1836         for (i = INVEN_TOTAL - INVEN_RARM; i < hgt; i++)
1837         {
1838                 /* Clear that line */
1839                 Term_erase(0, i, 255);
1840         }
1841 }
1842
1843
1844 /*!
1845  * @brief 所持/装備オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1846  * Find the "first" inventory object with the given "tag".
1847  * @param cp 対応するタグIDを与える参照ポインタ
1848  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1849  * @param mode 所持、装備の切り替え
1850  * @return タグに該当するオブジェクトがあるならTRUEを返す
1851  * @details
1852  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1853  * inscription of an object.  Alphabetical characters don't work as a\n
1854  * tag in this form.\n
1855  *\n
1856  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1857  * and "x" is the "current" command_cmd code.\n
1858  */
1859 static bool get_tag(COMMAND_CODE *cp, char tag, int mode)
1860 {
1861         COMMAND_CODE i;
1862         COMMAND_CODE start, end;
1863         cptr s;
1864
1865         /* Extract index from mode */
1866         switch (mode)
1867         {
1868         case USE_EQUIP:
1869                 start = INVEN_RARM;
1870                 end = INVEN_TOTAL - 1;
1871                 break;
1872
1873         case USE_INVEN:
1874                 start = 0;
1875                 end = INVEN_PACK - 1;
1876                 break;
1877
1878         default:
1879                 return FALSE;
1880         }
1881
1882         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1883
1884         /* Check every inventory object */
1885         for (i = start; i <= end; i++)
1886         {
1887                 object_type *o_ptr = &inventory[i];
1888
1889                 /* Skip non-objects */
1890                 if (!o_ptr->k_idx) continue;
1891
1892                 /* Skip empty inscriptions */
1893                 if (!o_ptr->inscription) continue;
1894
1895                 /* Skip non-choice */
1896                 if (!item_tester_okay(o_ptr)) continue;
1897
1898                 /* Find a '@' */
1899                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1900
1901                 /* Process all tags */
1902                 while (s)
1903                 {
1904                         /* Check the special tags */
1905                         if ((s[1] == command_cmd) && (s[2] == tag))
1906                         {
1907                                 /* Save the actual inventory ID */
1908                                 *cp = i;
1909
1910                                 /* Success */
1911                                 return (TRUE);
1912                         }
1913
1914                         /* Find another '@' */
1915                         s = my_strchr(s + 1, '@');
1916                 }
1917         }
1918
1919
1920         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
1921
1922         /* Don't allow {@#} with '#' being alphabet */
1923         if (tag < '0' || '9' < tag)
1924         {
1925                 /* No such tag */
1926                 return FALSE;
1927         }
1928
1929         /* Check every object */
1930         for (i = start; i <= end; i++)
1931         {
1932                 object_type *o_ptr = &inventory[i];
1933
1934                 /* Skip non-objects */
1935                 if (!o_ptr->k_idx) continue;
1936
1937                 /* Skip empty inscriptions */
1938                 if (!o_ptr->inscription) continue;
1939
1940                 /* Skip non-choice */
1941                 if (!item_tester_okay(o_ptr)) continue;
1942
1943                 /* Find a '@' */
1944                 s = my_strchr(quark_str(o_ptr->inscription), '@');
1945
1946                 /* Process all tags */
1947                 while (s)
1948                 {
1949                         /* Check the normal tags */
1950                         if (s[1] == tag)
1951                         {
1952                                 /* Save the actual inventory ID */
1953                                 *cp = i;
1954
1955                                 /* Success */
1956                                 return (TRUE);
1957                         }
1958
1959                         /* Find another '@' */
1960                         s = my_strchr(s + 1, '@');
1961                 }
1962         }
1963
1964         /* No such tag */
1965         return (FALSE);
1966 }
1967
1968
1969 /*!
1970  * @brief 床オブジェクトに選択タグを与える/タグに該当するオブジェクトがあるかを返す /
1971  * Find the "first" inventory object with the given "tag".
1972  * @param cp 対応するタグIDを与える参照ポインタ
1973  * @param tag 該当するオブジェクトがあるかを調べたいタグ
1974  * @param floor_list 床上アイテムの配列
1975  * @param floor_num  床上アイテムの配列ID
1976  * @return タグに該当するオブジェクトがあるならTRUEを返す
1977  * @details
1978  * A "tag" is a numeral "n" appearing as "@n" anywhere in the\n
1979  * inscription of an object.  Alphabetical characters don't work as a\n
1980  * tag in this form.\n
1981  *\n
1982  * Also, the tag "@xn" will work as well, where "n" is a any tag-char,\n
1983  * and "x" is the "current" command_cmd code.\n
1984  */
1985 static bool get_tag_floor(COMMAND_CODE *cp, char tag, int floor_list[], int floor_num)
1986 {
1987         COMMAND_CODE i;
1988         cptr s;
1989
1990         /**** Find a tag in the form of {@x#} (allow alphabet tag) ***/
1991
1992         /* Check every object in the grid */
1993         for (i = 0; i < floor_num && i < 23; i++)
1994         {
1995                 object_type *o_ptr = &o_list[floor_list[i]];
1996
1997                 /* Skip empty inscriptions */
1998                 if (!o_ptr->inscription) continue;
1999
2000                 /* Find a '@' */
2001                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2002
2003                 /* Process all tags */
2004                 while (s)
2005                 {
2006                         /* Check the special tags */
2007                         if ((s[1] == command_cmd) && (s[2] == tag))
2008                         {
2009                                 /* Save the actual floor object ID */
2010                                 *cp = i;
2011
2012                                 /* Success */
2013                                 return (TRUE);
2014                         }
2015
2016                         /* Find another '@' */
2017                         s = my_strchr(s + 1, '@');
2018                 }
2019         }
2020
2021
2022         /**** Find a tag in the form of {@#} (allows only numerals)  ***/
2023
2024         /* Don't allow {@#} with '#' being alphabet */
2025         if (tag < '0' || '9' < tag)
2026         {
2027                 /* No such tag */
2028                 return FALSE;
2029         }
2030
2031         /* Check every object in the grid */
2032         for (i = 0; i < floor_num && i < 23; i++)
2033         {
2034                 object_type *o_ptr = &o_list[floor_list[i]];
2035
2036                 /* Skip empty inscriptions */
2037                 if (!o_ptr->inscription) continue;
2038
2039                 /* Find a '@' */
2040                 s = my_strchr(quark_str(o_ptr->inscription), '@');
2041
2042                 /* Process all tags */
2043                 while (s)
2044                 {
2045                         /* Check the normal tags */
2046                         if (s[1] == tag)
2047                         {
2048                                 /* Save the floor object ID */
2049                                 *cp = i;
2050
2051                                 /* Success */
2052                                 return (TRUE);
2053                         }
2054
2055                         /* Find another '@' */
2056                         s = my_strchr(s + 1, '@');
2057                 }
2058         }
2059
2060         /* No such tag */
2061         return (FALSE);
2062 }
2063
2064
2065 /*!
2066  * @brief タグIDにあわせてタグアルファベットのリストを返す /
2067  * Move around label characters with correspond tags
2068  * @param label ラベルリストを取得する文字列参照ポインタ
2069  * @param mode 所持品リストか装備品リストかの切り替え
2070  * @return なし
2071  */
2072 static void prepare_label_string(char *label, int mode)
2073 {
2074         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2075         int  offset = (mode == USE_EQUIP) ? INVEN_RARM : 0;
2076         int  i;
2077
2078         /* Prepare normal labels */
2079         strcpy(label, alphabet_chars);
2080
2081         /* Move each label */
2082         for (i = 0; i < 52; i++)
2083         {
2084                 COMMAND_CODE index;
2085                 char c = alphabet_chars[i];
2086
2087                 /* Find a tag with this label */
2088                 if (get_tag(&index, c, mode))
2089                 {
2090                         /* Delete the overwritten label */
2091                         if (label[i] == c) label[i] = ' ';
2092
2093                         /* Move the label to the place of corresponding tag */
2094                         label[index - offset] = c;
2095                 }
2096         }
2097 }
2098
2099
2100 /*!
2101  * @brief タグIDにあわせてタグアルファベットのリストを返す(床上アイテム用) /
2102  * Move around label characters with correspond tags (floor version)
2103  * @param label ラベルリストを取得する文字列参照ポインタ
2104  * @param floor_list 床上アイテムの配列
2105  * @param floor_num  床上アイテムの配列ID
2106  * @return なし
2107  */
2108 /*
2109  */
2110 static void prepare_label_string_floor(char *label, int floor_list[], int floor_num)
2111 {
2112         cptr alphabet_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2113         int  i;
2114
2115         /* Prepare normal labels */
2116         strcpy(label, alphabet_chars);
2117
2118         /* Move each label */
2119         for (i = 0; i < 52; i++)
2120         {
2121                 COMMAND_CODE index;
2122                 char c = alphabet_chars[i];
2123
2124                 /* Find a tag with this label */
2125                 if (get_tag_floor(&index, c, floor_list, floor_num))
2126                 {
2127                         /* Delete the overwritten label */
2128                         if (label[i] == c) label[i] = ' ';
2129
2130                         /* Move the label to the place of corresponding tag */
2131                         label[index] = c;
2132                 }
2133         }
2134 }
2135
2136
2137 /*!
2138  * @brief 所持アイテムの表示を行う /
2139  * Display the inventory.
2140  * @param target_item アイテムの選択処理を行うか否か。
2141  * @return 選択したアイテムのタグ
2142  * @details
2143  * Hack -- do not display "trailing" empty slots
2144  */
2145 COMMAND_CODE show_inven(int target_item)
2146 {
2147         COMMAND_CODE i;
2148         int j, k, l, z = 0;
2149         int             col, cur_col, len;
2150         object_type     *o_ptr;
2151         char            o_name[MAX_NLEN];
2152         char            tmp_val[80];
2153         COMMAND_CODE out_index[23];
2154         byte            out_color[23];
2155         char            out_desc[23][MAX_NLEN];
2156         COMMAND_CODE target_item_label = 0;
2157         TERM_POSITION wid, hgt;
2158         char            inven_label[52 + 1];
2159
2160         /* Starting column */
2161         col = command_gap;
2162
2163         /* Get size */
2164         Term_get_size(&wid, &hgt);
2165
2166         /* Default "max-length" */
2167         len = wid - col - 1;
2168
2169
2170         /* Find the "final" slot */
2171         for (i = 0; i < INVEN_PACK; i++)
2172         {
2173                 o_ptr = &inventory[i];
2174
2175                 /* Skip non-objects */
2176                 if (!o_ptr->k_idx) continue;
2177
2178                 /* Track */
2179                 z = i + 1;
2180         }
2181
2182         prepare_label_string(inven_label, USE_INVEN);
2183
2184         /* Display the inventory */
2185         for (k = 0, i = 0; i < z; i++)
2186         {
2187                 o_ptr = &inventory[i];
2188
2189                 /* Is this item acceptable? */
2190                 if (!item_tester_okay(o_ptr)) continue;
2191
2192                 /* Describe the object */
2193                 object_desc(o_name, o_ptr, 0);
2194
2195                 /* Save the object index, color, and description */
2196                 out_index[k] = i;
2197                 out_color[k] = tval_to_attr[o_ptr->tval % 128];
2198
2199                 /* Grey out charging items */
2200                 if (o_ptr->timeout)
2201                 {
2202                         out_color[k] = TERM_L_DARK;
2203                 }
2204
2205                 (void)strcpy(out_desc[k], o_name);
2206
2207                 /* Find the predicted "line length" */
2208                 l = strlen(out_desc[k]) + 5;
2209
2210                 /* Be sure to account for the weight */
2211                 if (show_weights) l += 9;
2212
2213                 /* Account for icon if displayed */
2214                 if (show_item_graph)
2215                 {
2216                         l += 2;
2217                         if (use_bigtile) l++;
2218                 }
2219
2220                 /* Maintain the maximum length */
2221                 if (l > len) len = l;
2222
2223                 /* Advance to next "line" */
2224                 k++;
2225         }
2226
2227         /* Find the column to start in */
2228         col = (len > wid - 4) ? 0 : (wid - len - 1);
2229
2230         /* Output each entry */
2231         for (j = 0; j < k; j++)
2232         {
2233                 /* Get the index */
2234                 i = out_index[j];
2235
2236                 /* Get the item */
2237                 o_ptr = &inventory[i];
2238
2239                 /* Clear the line */
2240                 prt("", j + 1, col ? col - 2 : col);
2241
2242                 if (use_menu && target_item)
2243                 {
2244                         if (j == (target_item-1))
2245                         {
2246                                 strcpy(tmp_val, _("》", "> "));
2247                                 target_item_label = i;
2248                         }
2249                         else strcpy(tmp_val, "  ");
2250                 }
2251                 else if (i <= INVEN_PACK)
2252                 {
2253                         /* Prepare an index --(-- */
2254                         sprintf(tmp_val, "%c)", inven_label[i]);
2255                 }
2256                 else
2257                 {
2258                         /* Prepare an index --(-- */
2259                         sprintf(tmp_val, "%c)", index_to_label(i));
2260                 }
2261
2262                 /* Clear the line with the (possibly indented) index */
2263                 put_str(tmp_val, j + 1, col);
2264
2265                 cur_col = col + 3;
2266
2267                 /* Display graphics for object, if desired */
2268                 if (show_item_graph)
2269                 {
2270                         byte  a = object_attr(o_ptr);
2271                         char c = object_char(o_ptr);
2272                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2273                         if (use_bigtile) cur_col++;
2274
2275                         cur_col += 2;
2276                 }
2277
2278
2279                 /* Display the entry itself */
2280                 c_put_str(out_color[j], out_desc[j], j + 1, cur_col);
2281
2282                 /* Display the weight if needed */
2283                 if (show_weights)
2284                 {
2285                         int wgt = o_ptr->weight * o_ptr->number;
2286 #ifdef JP
2287                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2288 #else
2289                         (void)sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
2290 #endif
2291
2292                         prt(tmp_val, j + 1, wid - 9);
2293                 }
2294         }
2295
2296         /* Make a "shadow" below the list (only if needed) */
2297         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2298
2299         /* Save the new column */
2300         command_gap = col;
2301
2302         return target_item_label;
2303 }
2304
2305
2306 /*!
2307  * @brief 装備アイテムの表示を行う /
2308  * Display the equipment.
2309  * @param target_item アイテムの選択処理を行うか否か。
2310  * @return 選択したアイテムのタグ
2311  */
2312 COMMAND_CODE show_equip(int target_item)
2313 {
2314         COMMAND_CODE i;
2315         int j, k, l;
2316         int             col, cur_col, len;
2317         object_type     *o_ptr;
2318         char            tmp_val[80];
2319         char            o_name[MAX_NLEN];
2320         COMMAND_CODE out_index[23];
2321         byte            out_color[23];
2322         char            out_desc[23][MAX_NLEN];
2323         COMMAND_CODE target_item_label = 0;
2324         TERM_POSITION wid, hgt;
2325         char            equip_label[52 + 1];
2326
2327         /* Starting column */
2328         col = command_gap;
2329
2330         /* Get size */
2331         Term_get_size(&wid, &hgt);
2332
2333         /* Maximal length */
2334         len = wid - col - 1;
2335
2336
2337         /* Scan the equipment list */
2338         for (k = 0, i = INVEN_RARM; i < INVEN_TOTAL; i++)
2339         {
2340                 o_ptr = &inventory[i];
2341
2342                 /* Is this item acceptable? */
2343                 if (!(select_ring_slot ? is_ring_slot(i) : item_tester_okay(o_ptr)) &&
2344                     (!((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute) ||
2345                      item_tester_no_ryoute)) continue;
2346
2347                 /* Description */
2348                 object_desc(o_name, o_ptr, 0);
2349
2350                 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
2351                 {
2352 #ifdef JP
2353                         (void)strcpy(out_desc[k],"(武器を両手持ち)");
2354 #else
2355                         (void)strcpy(out_desc[k],"(wielding with two-hands)");
2356 #endif
2357                         out_color[k] = TERM_WHITE;
2358                 }
2359                 else
2360                 {
2361                         (void)strcpy(out_desc[k], o_name);
2362                         out_color[k] = tval_to_attr[o_ptr->tval % 128];
2363                 }
2364
2365                 out_index[k] = i;
2366                 /* Grey out charging items */
2367                 if (o_ptr->timeout)
2368                 {
2369                         out_color[k] = TERM_L_DARK;
2370                 }
2371
2372                 /* Extract the maximal length (see below) */
2373 #ifdef JP
2374                 l = strlen(out_desc[k]) + (2 + 1);
2375 #else
2376                 l = strlen(out_desc[k]) + (2 + 3);
2377 #endif
2378
2379
2380                 /* Increase length for labels (if needed) */
2381 #ifdef JP
2382                 if (show_labels) l += (7 + 2);
2383 #else
2384                 if (show_labels) l += (14 + 2);
2385 #endif
2386
2387
2388                 /* Increase length for weight (if needed) */
2389                 if (show_weights) l += 9;
2390
2391                 if (show_item_graph) l += 2;
2392
2393                 /* Maintain the max-length */
2394                 if (l > len) len = l;
2395
2396                 /* Advance the entry */
2397                 k++;
2398         }
2399
2400         /* Hack -- Find a column to start in */
2401 #ifdef JP
2402         col = (len > wid - 6) ? 0 : (wid - len - 1);
2403 #else
2404         col = (len > wid - 4) ? 0 : (wid - len - 1);
2405 #endif
2406
2407         prepare_label_string(equip_label, USE_EQUIP);
2408
2409         /* Output each entry */
2410         for (j = 0; j < k; j++)
2411         {
2412                 /* Get the index */
2413                 i = out_index[j];
2414
2415                 /* Get the item */
2416                 o_ptr = &inventory[i];
2417
2418                 /* Clear the line */
2419                 prt("", j + 1, col ? col - 2 : col);
2420
2421                 if (use_menu && target_item)
2422                 {
2423                         if (j == (target_item-1))
2424                         {
2425                                 strcpy(tmp_val, _("》", "> "));
2426                                 target_item_label = i;
2427                         }
2428                         else strcpy(tmp_val, "  ");
2429                 }
2430                 else if (i >= INVEN_RARM)
2431                 {
2432                         /* Prepare an index --(-- */
2433                         sprintf(tmp_val, "%c)", equip_label[i - INVEN_RARM]);
2434                 }
2435                 else /* Paranoia */
2436                 {
2437                         /* Prepare an index --(-- */
2438                         sprintf(tmp_val, "%c)", index_to_label(i));
2439                 }
2440
2441                 /* Clear the line with the (possibly indented) index */
2442                 put_str(tmp_val, j+1, col);
2443
2444                 cur_col = col + 3;
2445
2446                 /* Display graphics for object, if desired */
2447                 if (show_item_graph)
2448                 {
2449                         byte a = object_attr(o_ptr);
2450                         char c = object_char(o_ptr);
2451                         Term_queue_bigchar(cur_col, j + 1, a, c, 0, 0);
2452                         if (use_bigtile) cur_col++;
2453
2454                         cur_col += 2;
2455                 }
2456
2457                 /* Use labels */
2458                 if (show_labels)
2459                 {
2460                         /* Mention the use */
2461                         (void)sprintf(tmp_val, _("%-7s: ", "%-14s: "), mention_use(i));
2462
2463                         put_str(tmp_val, j+1, cur_col);
2464
2465                         /* Display the entry itself */
2466                         c_put_str(out_color[j], out_desc[j], j+1, _(cur_col + 9, cur_col + 16));
2467                 }
2468
2469                 /* No labels */
2470                 else
2471                 {
2472                         /* Display the entry itself */
2473                         c_put_str(out_color[j], out_desc[j], j+1, cur_col);
2474                 }
2475
2476                 /* Display the weight if needed */
2477                 if (show_weights)
2478                 {
2479                         int wgt = o_ptr->weight * o_ptr->number;
2480 #ifdef JP
2481                         (void)sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
2482 #else
2483                         (void)sprintf(tmp_val, "%3d.%d lb", wgt / 10, wgt % 10);
2484 #endif
2485
2486                         prt(tmp_val, j + 1, wid - 9);
2487                 }
2488         }
2489
2490         /* Make a "shadow" below the list (only if needed) */
2491         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
2492
2493         /* Save the new column */
2494         command_gap = col;
2495
2496         return target_item_label;
2497 }
2498
2499 /*!
2500  * @brief サブウィンドウに所持品、装備品リストの表示を行う /
2501  * Flip "inven" and "equip" in any sub-windows
2502  * @return なし
2503  */
2504 void toggle_inven_equip(void)
2505 {
2506         int j;
2507
2508         /* Scan windows */
2509         for (j = 0; j < 8; j++)
2510         {
2511                 /* Unused */
2512                 if (!angband_term[j]) continue;
2513
2514                 /* Flip inven to equip */
2515                 if (window_flag[j] & (PW_INVEN))
2516                 {
2517                         /* Flip flags */
2518                         window_flag[j] &= ~(PW_INVEN);
2519                         window_flag[j] |= (PW_EQUIP);
2520
2521                         /* Window stuff */
2522                         p_ptr->window |= (PW_EQUIP);
2523                 }
2524
2525                 /* Flip inven to equip */
2526                 else if (window_flag[j] & (PW_EQUIP))
2527                 {
2528                         /* Flip flags */
2529                         window_flag[j] &= ~(PW_EQUIP);
2530                         window_flag[j] |= (PW_INVEN);
2531
2532                         /* Window stuff */
2533                         p_ptr->window |= (PW_INVEN);
2534                 }
2535         }
2536 }
2537
2538 /*!
2539  * @brief 選択したアイテムの確認処理の補助 /
2540  * Verify the choice of an item.
2541  * @param prompt メッセージ表示の一部
2542  * @param item 選択アイテムID
2543  * @return 確認がYesならTRUEを返す。
2544  * @details The item can be negative to mean "item on floor".
2545  */
2546 static bool verify(cptr prompt, int item)
2547 {
2548         char        o_name[MAX_NLEN];
2549         char        out_val[MAX_NLEN+20];
2550         object_type *o_ptr;
2551
2552
2553         /* Inventory */
2554         if (item >= 0)
2555         {
2556                 o_ptr = &inventory[item];
2557         }
2558
2559         /* Floor */
2560         else
2561         {
2562                 o_ptr = &o_list[0 - item];
2563         }
2564
2565         /* Describe */
2566         object_desc(o_name, o_ptr, 0);
2567
2568         /* Prompt */
2569         (void)sprintf(out_val, _("%s%sですか? ", "%s %s? "), prompt, o_name);
2570
2571         /* Query */
2572         return (get_check(out_val));
2573 }
2574
2575
2576 /*!
2577  * @brief 選択したアイテムの確認処理のメインルーチン /
2578  * @param item 選択アイテムID
2579  * @return 確認がYesならTRUEを返す。
2580  * @details The item can be negative to mean "item on floor".
2581  * Hack -- allow user to "prevent" certain choices
2582  */
2583 static bool get_item_allow(int item)
2584 {
2585         cptr s;
2586
2587         object_type *o_ptr;
2588
2589         if (!command_cmd) return TRUE; /* command_cmd is no longer effective */
2590
2591         /* Inventory */
2592         if (item >= 0)
2593         {
2594                 o_ptr = &inventory[item];
2595         }
2596
2597         /* Floor */
2598         else
2599         {
2600                 o_ptr = &o_list[0 - item];
2601         }
2602
2603         /* No inscription */
2604         if (!o_ptr->inscription) return (TRUE);
2605
2606         /* Find a '!' */
2607         s = my_strchr(quark_str(o_ptr->inscription), '!');
2608
2609         /* Process preventions */
2610         while (s)
2611         {
2612                 /* Check the "restriction" */
2613                 if ((s[1] == command_cmd) || (s[1] == '*'))
2614                 {
2615                         /* Verify the choice */
2616                         if (!verify(_("本当に", "Really try"), item)) return (FALSE);
2617                 }
2618
2619                 /* Find another '!' */
2620                 s = my_strchr(s + 1, '!');
2621         }
2622
2623         /* Allow it */
2624         return (TRUE);
2625 }
2626
2627
2628 /*!
2629  * @brief プレイヤーの所持/装備オブジェクトが正規のものかを返す /
2630  * Auxiliary function for "get_item()" -- test an index
2631  * @param i 選択アイテムID
2632  * @return 正規のIDならばTRUEを返す。
2633  */
2634 static bool get_item_okay(OBJECT_IDX i)
2635 {
2636         /* Illegal items */
2637         if ((i < 0) || (i >= INVEN_TOTAL)) return (FALSE);
2638
2639         if (select_ring_slot) return is_ring_slot(i);
2640
2641         /* Verify the item */
2642         if (!item_tester_okay(&inventory[i])) return (FALSE);
2643
2644         /* Assume okay */
2645         return (TRUE);
2646 }
2647
2648 /*!
2649  * @brief プレイヤーがオブジェクトを拾うことができる状態かを返す /
2650  * Determine whether get_item() can get some item or not
2651  * @return アイテムを拾えるならばTRUEを返す。
2652  * @details assuming mode = (USE_EQUIP | USE_INVEN | USE_FLOOR).
2653  */
2654 bool can_get_item(void)
2655 {
2656         int j, floor_list[23], floor_num = 0;
2657
2658         for (j = 0; j < INVEN_TOTAL; j++)
2659                 if (item_tester_okay(&inventory[j]))
2660                         return TRUE;
2661
2662         floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
2663         if (floor_num)
2664                 return TRUE;
2665
2666         return FALSE;
2667 }
2668
2669 /*!
2670  * @brief オブジェクト選択の汎用関数 /
2671  * Let the user select an item, save its "index"
2672  * @param cp 選択したオブジェクトのIDを返す。
2673  * @param pmt 選択目的のメッセージ
2674  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
2675  * @param mode オプションフラグ
2676  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
2677  * Return TRUE only if an acceptable item was chosen by the user.\n
2678  * @details
2679  * The selected item must satisfy the "item_tester_hook()" function,\n
2680  * if that hook is set, and the "item_tester_tval", if that value is set.\n
2681  *\n
2682  * All "item_tester" restrictions are cleared before this function returns.\n
2683  *\n
2684  * The user is allowed to choose acceptable items from the equipment,\n
2685  * inventory, or floor, respectively, if the proper flag was given,\n
2686  * and there are any acceptable items in that location.\n
2687  *\n
2688  * The equipment or inventory are displayed (even if no acceptable\n
2689  * items are in that location) if the proper flag was given.\n
2690  *\n
2691  * If there are no acceptable items available anywhere, and "str" is\n
2692  * not NULL, then it will be used as the text of a warning message\n
2693  * before the function returns.\n
2694  *\n
2695  * Note that the user must press "-" to specify the item on the floor,\n
2696  * and there is no way to "examine" the item on the floor, while the\n
2697  * use of "capital" letters will "examine" an inventory/equipment item,\n
2698  * and prompt for its use.\n
2699  *\n
2700  * If a legal item is selected from the inventory, we save it in "cp"\n
2701  * directly (0 to 35), and return TRUE.\n
2702  *\n
2703  * If a legal item is selected from the floor, we save it in "cp" as\n
2704  * a negative (-1 to -511), and return TRUE.\n
2705  *\n
2706  * If no item is available, we do nothing to "cp", and we display a\n
2707  * warning message, using "str" if available, and return FALSE.\n
2708  *\n
2709  * If no item is selected, we do nothing to "cp", and return FALSE.\n
2710  *\n
2711  * Global "p_ptr->command_new" is used when viewing the inventory or equipment\n
2712  * to allow the user to enter a command while viewing those screens, and\n
2713  * also to induce "auto-enter" of stores, and other such stuff.\n
2714  *\n
2715  * Global "p_ptr->command_see" may be set before calling this function to start\n
2716  * out in "browse" mode.  It is cleared before this function returns.\n
2717  *\n
2718  * Global "p_ptr->command_wrk" is used to choose between equip/inven listings.\n
2719  * If it is TRUE then we are viewing inventory, else equipment.\n
2720  *\n
2721  * We always erase the prompt when we are done, leaving a blank line,\n
2722  * or a warning message, if appropriate, if no items are available.\n
2723  */
2724 bool get_item(OBJECT_IDX *cp, cptr pmt, cptr str, int mode)
2725 {
2726         OBJECT_IDX this_o_idx, next_o_idx = 0;
2727
2728         char which = ' ';
2729
2730         int j;
2731         OBJECT_IDX k;
2732         OBJECT_IDX i1, i2;
2733         OBJECT_IDX e1, e2;
2734
2735         bool done, item;
2736
2737         bool oops = FALSE;
2738
2739         bool equip = FALSE;
2740         bool inven = FALSE;
2741         bool floor = FALSE;
2742
2743         bool allow_floor = FALSE;
2744
2745         bool toggle = FALSE;
2746
2747         char tmp_val[160];
2748         char out_val[160];
2749
2750         /* See cmd5.c */
2751         extern bool select_the_force;
2752
2753         int menu_line = (use_menu ? 1 : 0);
2754         int max_inven = 0;
2755         int max_equip = 0;
2756
2757 #ifdef ALLOW_REPEAT
2758
2759         static char prev_tag = '\0';
2760         char cur_tag = '\0';
2761
2762 #endif /* ALLOW_REPEAT */
2763
2764 #ifdef ALLOW_EASY_FLOOR /* TNB */
2765
2766         if (easy_floor || use_menu) return get_item_floor(cp, pmt, str, mode);
2767
2768 #endif /* ALLOW_EASY_FLOOR -- TNB */
2769
2770         /* Extract args */
2771         if (mode & USE_EQUIP) equip = TRUE;
2772         if (mode & USE_INVEN) inven = TRUE;
2773         if (mode & USE_FLOOR) floor = TRUE;
2774
2775 #ifdef ALLOW_REPEAT
2776
2777         /* Get the item index */
2778         if (repeat_pull(cp))
2779         {
2780                 /* the_force */
2781                 if (select_the_force && (*cp == INVEN_FORCE))
2782                 {
2783                         item_tester_tval = 0;
2784                         item_tester_hook = NULL;
2785                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2786                         return (TRUE);
2787                 }
2788
2789                 /* Floor item? */
2790                 else if (floor && (*cp < 0))
2791                 {
2792                         object_type *o_ptr;
2793
2794                         /* Special index */
2795                         k = 0 - (*cp);
2796
2797                         /* Acquire object */
2798                         o_ptr = &o_list[k];
2799
2800                         /* Validate the item */
2801                         if (item_tester_okay(o_ptr))
2802                         {
2803                                 /* Forget restrictions */
2804                                 item_tester_tval = 0;
2805                                 item_tester_hook = NULL;
2806                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2807
2808                                 /* Success */
2809                                 return TRUE;
2810                         }
2811                 }
2812
2813                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
2814                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
2815                 {
2816                         if (prev_tag && command_cmd)
2817                         {
2818                                 /* Look up the tag and validate the item */
2819                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
2820                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
2821                                 else if (!get_item_okay(k)) /* Reject */;
2822                                 else
2823                                 {
2824                                         /* Accept that choice */
2825                                         (*cp) = k;
2826
2827                                         /* Forget restrictions */
2828                                         item_tester_tval = 0;
2829                                         item_tester_hook = NULL;
2830                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2831
2832                                         /* Success */
2833                                         return TRUE;
2834                                 }
2835
2836                                 prev_tag = '\0'; /* prev_tag is no longer effective */
2837                         }
2838
2839                         /* Verify the item */
2840                         else if (get_item_okay(*cp))
2841                         {
2842                                 /* Forget restrictions */
2843                                 item_tester_tval = 0;
2844                                 item_tester_hook = NULL;
2845                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
2846
2847                                 /* Success */
2848                                 return TRUE;
2849                         }
2850                 }
2851         }
2852
2853 #endif /* ALLOW_REPEAT */
2854
2855
2856         /* Paranoia XXX XXX XXX */
2857         msg_print(NULL);
2858
2859
2860         /* Not done */
2861         done = FALSE;
2862
2863         /* No item selected */
2864         item = FALSE;
2865
2866
2867         /* Full inventory */
2868         i1 = 0;
2869         i2 = INVEN_PACK - 1;
2870
2871         /* Forbid inventory */
2872         if (!inven) i2 = -1;
2873         else if (use_menu)
2874         {
2875                 for (j = 0; j < INVEN_PACK; j++)
2876                         if (item_tester_okay(&inventory[j])) max_inven++;
2877         }
2878
2879         /* Restrict inventory indexes */
2880         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
2881         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
2882
2883
2884         /* Full equipment */
2885         e1 = INVEN_RARM;
2886         e2 = INVEN_TOTAL - 1;
2887
2888         /* Forbid equipment */
2889         if (!equip) e2 = -1;
2890         else if (use_menu)
2891         {
2892                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
2893                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
2894                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
2895         }
2896
2897         /* Restrict equipment indexes */
2898         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
2899         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
2900
2901         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
2902         {
2903                 if (p_ptr->migite)
2904                 {
2905                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
2906                 }
2907                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
2908         }
2909
2910
2911         /* Restrict floor usage */
2912         if (floor)
2913         {
2914                 /* Scan all objects in the grid */
2915                 for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
2916                 {
2917                         object_type *o_ptr;
2918
2919                         /* Acquire object */
2920                         o_ptr = &o_list[this_o_idx];
2921
2922                         /* Acquire next object */
2923                         next_o_idx = o_ptr->next_o_idx;
2924
2925                         /* Accept the item on the floor if legal */
2926                         if (item_tester_okay(o_ptr) && (o_ptr->marked & OM_FOUND)) allow_floor = TRUE;
2927                 }
2928         }
2929
2930         /* Require at least one legal choice */
2931         if (!allow_floor && (i1 > i2) && (e1 > e2))
2932         {
2933                 /* Cancel p_ptr->command_see */
2934                 command_see = FALSE;
2935
2936                 /* Oops */
2937                 oops = TRUE;
2938
2939                 /* Done */
2940                 done = TRUE;
2941
2942                 if (select_the_force) {
2943                     *cp = INVEN_FORCE;
2944                     item = TRUE;
2945                 }
2946         }
2947
2948         /* Analyze choices */
2949         else
2950         {
2951                 /* Hack -- Start on equipment if requested */
2952                 if (command_see && command_wrk && equip)
2953                 {
2954                         command_wrk = TRUE;
2955                 }
2956
2957                 /* Use inventory if allowed */
2958                 else if (inven)
2959                 {
2960                         command_wrk = FALSE;
2961                 }
2962
2963                 /* Use equipment if allowed */
2964                 else if (equip)
2965                 {
2966                         command_wrk = TRUE;
2967                 }
2968
2969                 /* Use inventory for floor */
2970                 else
2971                 {
2972                         command_wrk = FALSE;
2973                 }
2974         }
2975
2976
2977         /*
2978          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
2979          */
2980         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
2981
2982         /* Hack -- start out in "display" mode */
2983         if (command_see)
2984         {
2985                 /* Save screen */
2986                 screen_save();
2987         }
2988
2989
2990         /* Repeat until done */
2991         while (!done)
2992         {
2993                 COMMAND_CODE get_item_label = 0;
2994
2995                 /* Show choices */
2996                 int ni = 0;
2997                 int ne = 0;
2998
2999                 /* Scan windows */
3000                 for (j = 0; j < 8; j++)
3001                 {
3002                         /* Unused */
3003                         if (!angband_term[j]) continue;
3004
3005                         /* Count windows displaying inven */
3006                         if (window_flag[j] & (PW_INVEN)) ni++;
3007
3008                         /* Count windows displaying equip */
3009                         if (window_flag[j] & (PW_EQUIP)) ne++;
3010                 }
3011
3012                 /* Toggle if needed */
3013                 if ((command_wrk && ni && !ne) ||
3014                     (!command_wrk && !ni && ne))
3015                 {
3016                         /* Toggle */
3017                         toggle_inven_equip();
3018
3019                         /* Track toggles */
3020                         toggle = !toggle;
3021                 }
3022
3023                 /* Update */
3024                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
3025
3026                 /* Redraw windows */
3027                 window_stuff();
3028
3029
3030                 /* Inventory screen */
3031                 if (!command_wrk)
3032                 {
3033                         /* Redraw if needed */
3034                         if (command_see) get_item_label = show_inven(menu_line);
3035                 }
3036
3037                 /* Equipment screen */
3038                 else
3039                 {
3040                         /* Redraw if needed */
3041                         if (command_see) get_item_label = show_equip(menu_line);
3042                 }
3043
3044                 /* Viewing inventory */
3045                 if (!command_wrk)
3046                 {
3047                         /* Begin the prompt */
3048                         sprintf(out_val, _("持ち物:", "Inven:"));
3049
3050                         /* Some legal items */
3051                         if ((i1 <= i2) && !use_menu)
3052                         {
3053                                 /* Build the prompt */
3054                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3055                                         index_to_label(i1), index_to_label(i2));
3056
3057                                 /* Append */
3058                                 strcat(out_val, tmp_val);
3059                         }
3060
3061                         /* Indicate ability to "view" */
3062                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3063
3064                         /* Append */
3065 #ifdef JP
3066                         if (equip) strcat(out_val, format(" %s 装備品,", use_menu ? "'4'or'6'" : "'/'"));
3067 #else
3068                         if (equip) strcat(out_val, format(" %s for Equip,", use_menu ? "4 or 6" : "/"));
3069 #endif
3070                 }
3071
3072                 /* Viewing equipment */
3073                 else
3074                 {
3075                         /* Begin the prompt */
3076                         sprintf(out_val, _("装備品:", "Equip:"));
3077
3078                         /* Some legal items */
3079                         if ((e1 <= e2) && !use_menu)
3080                         {
3081                                 /* Build the prompt */
3082                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
3083                                         index_to_label(e1), index_to_label(e2));
3084
3085                                 /* Append */
3086                                 strcat(out_val, tmp_val);
3087                         }
3088
3089                         /* Indicate ability to "view" */
3090                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
3091
3092                         /* Append */
3093 #ifdef JP
3094                         if (inven) strcat(out_val, format(" %s 持ち物,", use_menu ? "'4'or'6'" : "'/'"));
3095 #else
3096                         if (inven) strcat(out_val, format(" %s for Inven,", use_menu ? "4 or 6" : "'/'"));
3097 #endif
3098                 }
3099
3100                 /* Indicate legality of the "floor" item */
3101                 if (allow_floor) strcat(out_val, _(" '-'床上,", " - for floor,"));
3102                 if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
3103
3104                 /* Finish the prompt */
3105                 strcat(out_val, " ESC");
3106
3107                 /* Build the prompt */
3108                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
3109
3110                 /* Show the prompt */
3111                 prt(tmp_val, 0, 0);
3112
3113                 /* Get a key */
3114                 which = inkey();
3115
3116                 if (use_menu)
3117                 {
3118                 int max_line = (command_wrk ? max_equip : max_inven);
3119                 switch (which)
3120                 {
3121                         case ESCAPE:
3122                         case 'z':
3123                         case 'Z':
3124                         case '0':
3125                         {
3126                                 done = TRUE;
3127                                 break;
3128                         }
3129
3130                         case '8':
3131                         case 'k':
3132                         case 'K':
3133                         {
3134                                 menu_line += (max_line - 1);
3135                                 break;
3136                         }
3137
3138                         case '2':
3139                         case 'j':
3140                         case 'J':
3141                         {
3142                                 menu_line++;
3143                                 break;
3144                         }
3145
3146                         case '4':
3147                         case '6':
3148                         case 'h':
3149                         case 'H':
3150                         case 'l':
3151                         case 'L':
3152                         {
3153                                 /* Verify legality */
3154                                 if (!inven || !equip)
3155                                 {
3156                                         bell();
3157                                         break;
3158                                 }
3159
3160                                 /* Hack -- Fix screen */
3161                                 if (command_see)
3162                                 {
3163                                         /* Load screen */
3164                                         screen_load();
3165
3166                                         /* Save screen */
3167                                         screen_save();
3168                                 }
3169
3170                                 /* Switch inven/equip */
3171                                 command_wrk = !command_wrk;
3172                                 max_line = (command_wrk ? max_equip : max_inven);
3173                                 if (menu_line > max_line) menu_line = max_line;
3174
3175                                 /* Need to redraw */
3176                                 break;
3177                         }
3178
3179                         case 'x':
3180                         case 'X':
3181                         case '\r':
3182                         case '\n':
3183                         {
3184                                 if (command_wrk == USE_FLOOR)
3185                                 {
3186                                         /* Special index */
3187                                         (*cp) = -get_item_label;
3188                                 }
3189                                 else
3190                                 {
3191                                         /* Validate the item */
3192                                         if (!get_item_okay(get_item_label))
3193                                         {
3194                                                 bell();
3195                                                 break;
3196                                         }
3197
3198                                         /* Allow player to "refuse" certain actions */
3199                                         if (!get_item_allow(get_item_label))
3200                                         {
3201                                                 done = TRUE;
3202                                                 break;
3203                                         }
3204
3205                                         /* Accept that choice */
3206                                         (*cp) = get_item_label;
3207                                 }
3208
3209                                 item = TRUE;
3210                                 done = TRUE;
3211                                 break;
3212                         }
3213                         case 'w':
3214                         {
3215                                 if (select_the_force) {
3216                                         *cp = INVEN_FORCE;
3217                                         item = TRUE;
3218                                         done = TRUE;
3219                                         break;
3220                                 }
3221                         }
3222                 }
3223                 if (menu_line > max_line) menu_line -= max_line;
3224                 }
3225                 else
3226                 {
3227                 /* Parse it */
3228                 switch (which)
3229                 {
3230                         case ESCAPE:
3231                         {
3232                                 done = TRUE;
3233                                 break;
3234                         }
3235
3236                         case '*':
3237                         case '?':
3238                         case ' ':
3239                         {
3240                                 /* Hide the list */
3241                                 if (command_see)
3242                                 {
3243                                         /* Flip flag */
3244                                         command_see = FALSE;
3245
3246                                         /* Load screen */
3247                                         screen_load();
3248                                 }
3249
3250                                 /* Show the list */
3251                                 else
3252                                 {
3253                                         /* Save screen */
3254                                         screen_save();
3255
3256                                         /* Flip flag */
3257                                         command_see = TRUE;
3258                                 }
3259                                 break;
3260                         }
3261
3262                         case '/':
3263                         {
3264                                 /* Verify legality */
3265                                 if (!inven || !equip)
3266                                 {
3267                                         bell();
3268                                         break;
3269                                 }
3270
3271                                 /* Hack -- Fix screen */
3272                                 if (command_see)
3273                                 {
3274                                         /* Load screen */
3275                                         screen_load();
3276
3277                                         /* Save screen */
3278                                         screen_save();
3279                                 }
3280
3281                                 /* Switch inven/equip */
3282                                 command_wrk = !command_wrk;
3283
3284                                 /* Need to redraw */
3285                                 break;
3286                         }
3287
3288                         case '-':
3289                         {
3290                                 /* Use floor item */
3291                                 if (allow_floor)
3292                                 {
3293                                         /* Scan all objects in the grid */
3294                                         for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3295                                         {
3296                                                 object_type *o_ptr;
3297
3298                                                 /* Acquire object */
3299                                                 o_ptr = &o_list[this_o_idx];
3300
3301                                                 /* Acquire next object */
3302                                                 next_o_idx = o_ptr->next_o_idx;
3303
3304                                                 /* Validate the item */
3305                                                 if (!item_tester_okay(o_ptr)) continue;
3306
3307                                                 /* Special index */
3308                                                 k = 0 - this_o_idx;
3309
3310                                                 /* Verify the item (if required) */
3311                                                 if (other_query_flag && !verify(_("本当に", "Try"), k)) continue;
3312
3313                                                 /* Allow player to "refuse" certain actions */
3314                                                 if (!get_item_allow(k)) continue;
3315
3316                                                 /* Accept that choice */
3317                                                 (*cp) = k;
3318                                                 item = TRUE;
3319                                                 done = TRUE;
3320                                                 break;
3321                                         }
3322
3323                                         /* Outer break */
3324                                         if (done) break;
3325                                 }
3326
3327                                 /* Oops */
3328                                 bell();
3329                                 break;
3330                         }
3331
3332                         case '0':
3333                         case '1': case '2': case '3':
3334                         case '4': case '5': case '6':
3335                         case '7': case '8': case '9':
3336                         {
3337                                 /* Look up the tag */
3338                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3339                                 {
3340                                         bell();
3341                                         break;
3342                                 }
3343
3344                                 /* Hack -- Validate the item */
3345                                 if ((k < INVEN_RARM) ? !inven : !equip)
3346                                 {
3347                                         bell();
3348                                         break;
3349                                 }
3350
3351                                 /* Validate the item */
3352                                 if (!get_item_okay(k))
3353                                 {
3354                                         bell();
3355                                         break;
3356                                 }
3357
3358                                 /* Allow player to "refuse" certain actions */
3359                                 if (!get_item_allow(k))
3360                                 {
3361                                         done = TRUE;
3362                                         break;
3363                                 }
3364
3365                                 /* Accept that choice */
3366                                 (*cp) = k;
3367                                 item = TRUE;
3368                                 done = TRUE;
3369 #ifdef ALLOW_REPEAT
3370                                 cur_tag = which;
3371 #endif /* ALLOW_REPEAT */
3372                                 break;
3373                         }
3374
3375 #if 0
3376                         case '\n':
3377                         case '\r':
3378                         {
3379                                 /* Choose "default" inventory item */
3380                                 if (!command_wrk)
3381                                 {
3382                                         k = ((i1 == i2) ? i1 : -1);
3383                                 }
3384
3385                                 /* Choose "default" equipment item */
3386                                 else
3387                                 {
3388                                         k = ((e1 == e2) ? e1 : -1);
3389                                 }
3390
3391                                 /* Validate the item */
3392                                 if (!get_item_okay(k))
3393                                 {
3394                                         bell();
3395                                         break;
3396                                 }
3397
3398                                 /* Allow player to "refuse" certain actions */
3399                                 if (!get_item_allow(k))
3400                                 {
3401                                         done = TRUE;
3402                                         break;
3403                                 }
3404
3405                                 /* Accept that choice */
3406                                 (*cp) = k;
3407                                 item = TRUE;
3408                                 done = TRUE;
3409                                 break;
3410                         }
3411 #endif
3412
3413                         case 'w':
3414                         {
3415                                 if (select_the_force) {
3416                                         *cp = INVEN_FORCE;
3417                                         item = TRUE;
3418                                         done = TRUE;
3419                                         break;
3420                                 }
3421
3422                                 /* Fall through */
3423                         }
3424
3425                         default:
3426                         {
3427                                 int ver;
3428                                 bool not_found = FALSE;
3429
3430                                 /* Look up the alphabetical tag */
3431                                 if (!get_tag(&k, which, command_wrk ? USE_EQUIP : USE_INVEN))
3432                                 {
3433                                         not_found = TRUE;
3434                                 }
3435
3436                                 /* Hack -- Validate the item */
3437                                 else if ((k < INVEN_RARM) ? !inven : !equip)
3438                                 {
3439                                         not_found = TRUE;
3440                                 }
3441
3442                                 /* Validate the item */
3443                                 else if (!get_item_okay(k))
3444                                 {
3445                                         not_found = TRUE;
3446                                 }
3447
3448                                 if (!not_found)
3449                                 {
3450                                         /* Accept that choice */
3451                                         (*cp) = k;
3452                                         item = TRUE;
3453                                         done = TRUE;
3454 #ifdef ALLOW_REPEAT
3455                                         cur_tag = which;
3456 #endif /* ALLOW_REPEAT */
3457                                         break;
3458                                 }
3459
3460                                 /* Extract "query" setting */
3461                                 ver = isupper(which);
3462                                 which = (char)tolower(which);
3463
3464                                 /* Convert letter to inventory index */
3465                                 if (!command_wrk)
3466                                 {
3467                                         if (which == '(') k = i1;
3468                                         else if (which == ')') k = i2;
3469                                         else k = label_to_inven(which);
3470                                 }
3471
3472                                 /* Convert letter to equipment index */
3473                                 else
3474                                 {
3475                                         if (which == '(') k = e1;
3476                                         else if (which == ')') k = e2;
3477                                         else k = label_to_equip(which);
3478                                 }
3479
3480                                 /* Validate the item */
3481                                 if (!get_item_okay(k))
3482                                 {
3483                                         bell();
3484                                         break;
3485                                 }
3486
3487                                 /* Verify the item */
3488                                 if (ver && !verify(_("本当に", "Try"), k))
3489                                 {
3490                                         done = TRUE;
3491                                         break;
3492                                 }
3493
3494                                 /* Allow player to "refuse" certain actions */
3495                                 if (!get_item_allow(k))
3496                                 {
3497                                         done = TRUE;
3498                                         break;
3499                                 }
3500
3501                                 /* Accept that choice */
3502                                 (*cp) = k;
3503                                 item = TRUE;
3504                                 done = TRUE;
3505                                 break;
3506                         }
3507                 }
3508                 }
3509         }
3510
3511
3512         /* Fix the screen if necessary */
3513         if (command_see)
3514         {
3515                 /* Load screen */
3516                 screen_load();
3517
3518                 /* Hack -- Cancel "display" */
3519                 command_see = FALSE;
3520         }
3521
3522
3523         /* Forget the item_tester_tval restriction */
3524         item_tester_tval = 0;
3525
3526         item_tester_no_ryoute = FALSE;
3527
3528         /* Forget the item_tester_hook restriction */
3529         item_tester_hook = NULL;
3530
3531
3532         /* Clean up  'show choices' */
3533         /* Toggle again if needed */
3534         if (toggle) toggle_inven_equip();
3535
3536         /* Update */
3537         p_ptr->window |= (PW_INVEN | PW_EQUIP);
3538
3539         /* Window stuff */
3540         window_stuff();
3541
3542
3543         /* Clear the prompt line */
3544         prt("", 0, 0);
3545
3546         /* Warning if needed */
3547         if (oops && str) msg_print(str);
3548
3549         if (item)
3550         {
3551 #ifdef ALLOW_REPEAT
3552                 repeat_push(*cp);
3553                 if (command_cmd) prev_tag = cur_tag;
3554 #endif /* ALLOW_REPEAT */
3555
3556                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3557         }
3558
3559         /* Result */
3560         return (item);
3561 }
3562
3563
3564 #ifdef ALLOW_EASY_FLOOR
3565
3566 /*!
3567  * @brief 床下に落ちているオブジェクトの数を返す / scan_floor
3568  * @param items オブジェクトのIDリストを返すための配列参照ポインタ
3569  * @param y 走査するフロアのY座標
3570  * @param x 走査するフロアのX座標
3571  * @param mode オプションフラグ
3572  * @return 対象のマスに落ちているアイテム数
3573  * @details
3574  * Return a list of o_list[] indexes of items at the given cave
3575  * location. Valid flags are:
3576  *
3577  *              mode & 0x01 -- Item tester
3578  *              mode & 0x02 -- Marked items only
3579  *              mode & 0x04 -- Stop after first
3580  */
3581 int scan_floor(int *items, POSITION y, POSITION x, int mode)
3582 {
3583         int this_o_idx, next_o_idx;
3584
3585         int num = 0;
3586
3587         /* Sanity */
3588         if (!in_bounds(y, x)) return 0;
3589
3590         /* Scan all objects in the grid */
3591         for (this_o_idx = cave[y][x].o_idx; this_o_idx; this_o_idx = next_o_idx)
3592         {
3593                 object_type *o_ptr;
3594
3595                 /* Acquire object */
3596                 o_ptr = &o_list[this_o_idx];
3597
3598                 /* Acquire next object */
3599                 next_o_idx = o_ptr->next_o_idx;
3600
3601                 /* Item tester */
3602                 if ((mode & 0x01) && !item_tester_okay(o_ptr)) continue;
3603
3604                 /* Marked */
3605                 if ((mode & 0x02) && !(o_ptr->marked & OM_FOUND)) continue;
3606
3607                 /* Accept this item */
3608                 /* XXX Hack -- Enforce limit */
3609                 if (num < 23)
3610                         items[num] = this_o_idx;
3611
3612                 num++;
3613
3614                 /* Only one */
3615                 if (mode & 0x04) break;
3616         }
3617
3618         /* Result */
3619         return num;
3620 }
3621
3622
3623 /*!
3624  * @brief 床下に落ちているアイテムの一覧を返す / Display a list of the items on the floor at the given location.
3625  * @param target_item カーソルの初期値
3626  * @param y 走査するフロアのY座標
3627  * @param x 走査するフロアのX座標
3628  * @param min_width 表示の長さ
3629  * @return 選択したアイテムの添え字
3630  * @details
3631  */
3632 COMMAND_CODE show_floor(int target_item, POSITION y, POSITION x, TERM_POSITION *min_width)
3633 {
3634         COMMAND_CODE i;
3635         int j, k, l;
3636         int col, len;
3637
3638         object_type *o_ptr;
3639
3640         char o_name[MAX_NLEN];
3641
3642         char tmp_val[80];
3643
3644         COMMAND_CODE out_index[23];
3645         byte out_color[23];
3646         char out_desc[23][MAX_NLEN];
3647         COMMAND_CODE target_item_label = 0;
3648
3649         int floor_list[23], floor_num;
3650         int wid, hgt;
3651         char floor_label[52 + 1];
3652
3653         bool dont_need_to_show_weights = TRUE;
3654
3655         /* Get size */
3656         Term_get_size(&wid, &hgt);
3657
3658         /* Default length */
3659         len = MAX((*min_width), 20);
3660
3661
3662         /* Scan for objects in the grid, using item_tester_okay() */
3663         floor_num = scan_floor(floor_list, y, x, 0x03);
3664
3665         /* Display the floor objects */
3666         for (k = 0, i = 0; i < floor_num && i < 23; i++)
3667         {
3668                 o_ptr = &o_list[floor_list[i]];
3669
3670                 /* Describe the object */
3671                 object_desc(o_name, o_ptr, 0);
3672
3673                 /* Save the index */
3674                 out_index[k] = i;
3675
3676                 /* Acquire inventory color */
3677                 out_color[k] = tval_to_attr[o_ptr->tval & 0x7F];
3678
3679                 /* Save the object description */
3680                 strcpy(out_desc[k], o_name);
3681
3682                 /* Find the predicted "line length" */
3683                 l = strlen(out_desc[k]) + 5;
3684
3685                 /* Be sure to account for the weight */
3686                 if (show_weights) l += 9;
3687
3688                 if (o_ptr->tval != TV_GOLD) dont_need_to_show_weights = FALSE;
3689
3690                 /* Maintain the maximum length */
3691                 if (l > len) len = l;
3692
3693                 /* Advance to next "line" */
3694                 k++;
3695         }
3696
3697         if (show_weights && dont_need_to_show_weights) len -= 9;
3698
3699         /* Save width */
3700         *min_width = len;
3701
3702         /* Find the column to start in */
3703         col = (len > wid - 4) ? 0 : (wid - len - 1);
3704
3705         prepare_label_string_floor(floor_label, floor_list, floor_num);
3706
3707         /* Output each entry */
3708         for (j = 0; j < k; j++)
3709         {
3710                 /* Get the index */
3711                 i = floor_list[out_index[j]];
3712
3713                 /* Get the item */
3714                 o_ptr = &o_list[i];
3715
3716                 /* Clear the line */
3717                 prt("", j + 1, col ? col - 2 : col);
3718
3719                 if (use_menu && target_item)
3720                 {
3721                         if (j == (target_item-1))
3722                         {
3723                                 strcpy(tmp_val, _("》", "> "));
3724                                 target_item_label = i;
3725                         }
3726                         else strcpy(tmp_val, "   ");
3727                 }
3728                 else
3729                 {
3730                         /* Prepare an index --(-- */
3731                         sprintf(tmp_val, "%c)", floor_label[j]);
3732                 }
3733
3734                 /* Clear the line with the (possibly indented) index */
3735                 put_str(tmp_val, j + 1, col);
3736
3737                 /* Display the entry itself */
3738                 c_put_str(out_color[j], out_desc[j], j + 1, col + 3);
3739
3740                 /* Display the weight if needed */
3741                 if (show_weights && (o_ptr->tval != TV_GOLD))
3742                 {
3743                         int wgt = o_ptr->weight * o_ptr->number;
3744 #ifdef JP
3745                         sprintf(tmp_val, "%3d.%1d kg", lbtokg1(wgt) , lbtokg2(wgt) );
3746 #else
3747                         sprintf(tmp_val, "%3d.%1d lb", wgt / 10, wgt % 10);
3748 #endif
3749
3750                         prt(tmp_val, j + 1, wid - 9);
3751                 }
3752         }
3753
3754         /* Make a "shadow" below the list (only if needed) */
3755         if (j && (j < 23)) prt("", j + 1, col ? col - 2 : col);
3756
3757         return target_item_label;
3758 }
3759
3760 /*!
3761  * @brief オブジェクト選択の汎用関数(床上アイテム用) /
3762  * Let the user select an item, save its "index"
3763  * @param cp 選択したオブジェクトのIDを返す。
3764  * @param pmt 選択目的のメッセージ
3765  * @param str 選択できるオブジェクトがない場合のキャンセルメッセージ
3766  * @param mode オプションフラグ
3767  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。/
3768  */
3769 bool get_item_floor(COMMAND_CODE *cp, cptr pmt, cptr str, int mode)
3770 {
3771         char n1 = ' ', n2 = ' ', which = ' ';
3772
3773         int j;
3774         COMMAND_CODE i1, i2;
3775         COMMAND_CODE e1, e2;
3776         COMMAND_CODE k;
3777
3778         bool done, item;
3779
3780         bool oops = FALSE;
3781
3782         /* Extract args */
3783         bool equip = (mode & USE_EQUIP) ? TRUE : FALSE;
3784         bool inven = (mode & USE_INVEN) ? TRUE : FALSE;
3785         bool floor = (mode & USE_FLOOR) ? TRUE : FALSE;
3786
3787         bool allow_equip = FALSE;
3788         bool allow_inven = FALSE;
3789         bool allow_floor = FALSE;
3790
3791         bool toggle = FALSE;
3792
3793         char tmp_val[160];
3794         char out_val[160];
3795
3796         int floor_num, floor_list[23], floor_top = 0;
3797         TERM_POSITION min_width = 0;
3798
3799         extern bool select_the_force;
3800
3801         int menu_line = (use_menu ? 1 : 0);
3802         int max_inven = 0;
3803         int max_equip = 0;
3804
3805 #ifdef ALLOW_REPEAT
3806
3807         static char prev_tag = '\0';
3808         char cur_tag = '\0';
3809
3810         /* Get the item index */
3811         if (repeat_pull(cp))
3812         {
3813                 /* the_force */
3814                 if (select_the_force && (*cp == INVEN_FORCE))
3815                 {
3816                         item_tester_tval = 0;
3817                         item_tester_hook = NULL;
3818                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3819                         return (TRUE);
3820                 }
3821
3822                 /* Floor item? */
3823                 else if (floor && (*cp < 0))
3824                 {
3825                         if (prev_tag && command_cmd)
3826                         {
3827                                 /* Scan all objects in the grid */
3828                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3829
3830                                 /* Look up the tag */
3831                                 if (get_tag_floor(&k, prev_tag, floor_list, floor_num))
3832                                 {
3833                                         /* Accept that choice */
3834                                         (*cp) = 0 - floor_list[k];
3835
3836                                         /* Forget restrictions */
3837                                         item_tester_tval = 0;
3838                                         item_tester_hook = NULL;
3839                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3840
3841                                         /* Success */
3842                                         return TRUE;
3843                                 }
3844
3845                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3846                         }
3847
3848                         /* Validate the item */
3849                         else if (item_tester_okay(&o_list[0 - (*cp)]))
3850                         {
3851                                 /* Forget restrictions */
3852                                 item_tester_tval = 0;
3853                                 item_tester_hook = NULL;
3854                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3855
3856                                 /* Success */
3857                                 return TRUE;
3858                         }
3859                 }
3860
3861                 else if ((inven && (*cp >= 0) && (*cp < INVEN_PACK)) ||
3862                          (equip && (*cp >= INVEN_RARM) && (*cp < INVEN_TOTAL)))
3863                 {
3864                         if (prev_tag && command_cmd)
3865                         {
3866                                 /* Look up the tag and validate the item */
3867                                 if (!get_tag(&k, prev_tag, (*cp >= INVEN_RARM) ? USE_EQUIP : USE_INVEN)) /* Reject */;
3868                                 else if ((k < INVEN_RARM) ? !inven : !equip) /* Reject */;
3869                                 else if (!get_item_okay(k)) /* Reject */;
3870                                 else
3871                                 {
3872                                         /* Accept that choice */
3873                                         (*cp) = k;
3874
3875                                         /* Forget restrictions */
3876                                         item_tester_tval = 0;
3877                                         item_tester_hook = NULL;
3878                                         command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3879
3880                                         /* Success */
3881                                         return TRUE;
3882                                 }
3883
3884                                 prev_tag = '\0'; /* prev_tag is no longer effective */
3885                         }
3886
3887                         /* Verify the item */
3888                         else if (get_item_okay(*cp))
3889                         {
3890                                 /* Forget restrictions */
3891                                 item_tester_tval = 0;
3892                                 item_tester_hook = NULL;
3893                                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
3894
3895                                 /* Success */
3896                                 return TRUE;
3897                         }
3898                 }
3899         }
3900
3901 #endif /* ALLOW_REPEAT */
3902
3903
3904         /* Paranoia XXX XXX XXX */
3905         msg_print(NULL);
3906
3907
3908         /* Not done */
3909         done = FALSE;
3910
3911         /* No item selected */
3912         item = FALSE;
3913
3914
3915         /* Full inventory */
3916         i1 = 0;
3917         i2 = INVEN_PACK - 1;
3918
3919         /* Forbid inventory */
3920         if (!inven) i2 = -1;
3921         else if (use_menu)
3922         {
3923                 for (j = 0; j < INVEN_PACK; j++)
3924                         if (item_tester_okay(&inventory[j])) max_inven++;
3925         }
3926
3927         /* Restrict inventory indexes */
3928         while ((i1 <= i2) && (!get_item_okay(i1))) i1++;
3929         while ((i1 <= i2) && (!get_item_okay(i2))) i2--;
3930
3931
3932         /* Full equipment */
3933         e1 = INVEN_RARM;
3934         e2 = INVEN_TOTAL - 1;
3935
3936         /* Forbid equipment */
3937         if (!equip) e2 = -1;
3938         else if (use_menu)
3939         {
3940                 for (j = INVEN_RARM; j < INVEN_TOTAL; j++)
3941                         if (select_ring_slot ? is_ring_slot(j) : item_tester_okay(&inventory[j])) max_equip++;
3942                 if (p_ptr->ryoute && !item_tester_no_ryoute) max_equip++;
3943         }
3944
3945         /* Restrict equipment indexes */
3946         while ((e1 <= e2) && (!get_item_okay(e1))) e1++;
3947         while ((e1 <= e2) && (!get_item_okay(e2))) e2--;
3948
3949         if (equip && p_ptr->ryoute && !item_tester_no_ryoute)
3950         {
3951                 if (p_ptr->migite)
3952                 {
3953                         if (e2 < INVEN_LARM) e2 = INVEN_LARM;
3954                 }
3955                 else if (p_ptr->hidarite) e1 = INVEN_RARM;
3956         }
3957
3958
3959         /* Count "okay" floor items */
3960         floor_num = 0;
3961
3962         /* Restrict floor usage */
3963         if (floor)
3964         {
3965                 /* Scan all objects in the grid */
3966                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
3967         }
3968
3969         /* Accept inventory */
3970         if (i1 <= i2) allow_inven = TRUE;
3971
3972         /* Accept equipment */
3973         if (e1 <= e2) allow_equip = TRUE;
3974
3975         /* Accept floor */
3976         if (floor_num) allow_floor = TRUE;
3977
3978         /* Require at least one legal choice */
3979         if (!allow_inven && !allow_equip && !allow_floor)
3980         {
3981                 /* Cancel p_ptr->command_see */
3982                 command_see = FALSE;
3983
3984                 /* Oops */
3985                 oops = TRUE;
3986
3987                 /* Done */
3988                 done = TRUE;
3989
3990                 if (select_the_force) {
3991                     *cp = INVEN_FORCE;
3992                     item = TRUE;
3993                 }
3994         }
3995
3996         /* Analyze choices */
3997         else
3998         {
3999                 /* Hack -- Start on equipment if requested */
4000                 if (command_see && (command_wrk == (USE_EQUIP))
4001                         && allow_equip)
4002                 {
4003                         command_wrk = (USE_EQUIP);
4004                 }
4005
4006                 /* Use inventory if allowed */
4007                 else if (allow_inven)
4008                 {
4009                         command_wrk = (USE_INVEN);
4010                 }
4011
4012                 /* Use equipment if allowed */
4013                 else if (allow_equip)
4014                 {
4015                         command_wrk = (USE_EQUIP);
4016                 }
4017
4018                 /* Use floor if allowed */
4019                 else if (allow_floor)
4020                 {
4021                         command_wrk = (USE_FLOOR);
4022                 }
4023         }
4024
4025         /*
4026          * 追加オプション(always_show_list)が設定されている場合は常に一覧を表示する
4027          */
4028         if ((always_show_list == TRUE) || use_menu) command_see = TRUE;
4029
4030         /* Hack -- start out in "display" mode */
4031         if (command_see)
4032         {
4033                 /* Save screen */
4034                 screen_save();
4035         }
4036
4037         /* Repeat until done */
4038         while (!done)
4039         {
4040                 COMMAND_CODE get_item_label = 0;
4041
4042                 /* Show choices */
4043                 int ni = 0;
4044                 int ne = 0;
4045
4046                 /* Scan windows */
4047                 for (j = 0; j < 8; j++)
4048                 {
4049                         /* Unused */
4050                         if (!angband_term[j]) continue;
4051
4052                         /* Count windows displaying inven */
4053                         if (window_flag[j] & (PW_INVEN)) ni++;
4054
4055                         /* Count windows displaying equip */
4056                         if (window_flag[j] & (PW_EQUIP)) ne++;
4057                 }
4058
4059                 /* Toggle if needed */
4060                 if ((command_wrk == (USE_EQUIP) && ni && !ne) ||
4061                     (command_wrk == (USE_INVEN) && !ni && ne))
4062                 {
4063                         /* Toggle */
4064                         toggle_inven_equip();
4065
4066                         /* Track toggles */
4067                         toggle = !toggle;
4068                 }
4069
4070                 /* Update */
4071                 p_ptr->window |= (PW_INVEN | PW_EQUIP);
4072
4073                 /* Redraw windows */
4074                 window_stuff();
4075
4076                 /* Inventory screen */
4077                 if (command_wrk == (USE_INVEN))
4078                 {
4079                         /* Extract the legal requests */
4080                         n1 = I2A(i1);
4081                         n2 = I2A(i2);
4082
4083                         /* Redraw if needed */
4084                         if (command_see) get_item_label = show_inven(menu_line);
4085                 }
4086
4087                 /* Equipment screen */
4088                 else if (command_wrk == (USE_EQUIP))
4089                 {
4090                         /* Extract the legal requests */
4091                         n1 = I2A(e1 - INVEN_RARM);
4092                         n2 = I2A(e2 - INVEN_RARM);
4093
4094                         /* Redraw if needed */
4095                         if (command_see) get_item_label = show_equip(menu_line);
4096                 }
4097
4098                 /* Floor screen */
4099                 else if (command_wrk == (USE_FLOOR))
4100                 {
4101                         j = floor_top;
4102                         k = MIN(floor_top + 23, floor_num) - 1;
4103
4104                         /* Extract the legal requests */
4105                         n1 = I2A(j - floor_top);
4106                         n2 = I2A(k - floor_top);
4107
4108                         /* Redraw if needed */
4109                         if (command_see) get_item_label = show_floor(menu_line, p_ptr->y, p_ptr->x, &min_width);
4110                 }
4111
4112                 /* Viewing inventory */
4113                 if (command_wrk == (USE_INVEN))
4114                 {
4115                         /* Begin the prompt */
4116                         sprintf(out_val, _("持ち物:", "Inven:"));
4117
4118                         if (!use_menu)
4119                         {
4120                                 /* Build the prompt */
4121                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
4122                                         index_to_label(i1), index_to_label(i2));
4123
4124                                 /* Append */
4125                                 strcat(out_val, tmp_val);
4126                         }
4127
4128                         /* Indicate ability to "view" */
4129                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4130
4131                         /* Append */
4132                         if (allow_equip)
4133                         {
4134 #ifdef JP
4135                                 if (!use_menu)
4136                                         strcat(out_val, " '/' 装備品,");
4137                                 else if (allow_floor)
4138                                         strcat(out_val, " '6' 装備品,");
4139                                 else
4140                                         strcat(out_val, " '4'or'6' 装備品,");
4141 #else
4142                                 if (!use_menu)
4143                                         strcat(out_val, " / for Equip,");
4144                                 else if (allow_floor)
4145                                         strcat(out_val, " 6 for Equip,");
4146                                 else
4147                                         strcat(out_val, " 4 or 6 for Equip,");
4148 #endif
4149                         }
4150
4151                         /* Append */
4152                         if (allow_floor)
4153                         {
4154 #ifdef JP
4155                                 if (!use_menu)
4156                                         strcat(out_val, " '-'床上,");
4157                                 else if (allow_equip)
4158                                         strcat(out_val, " '4' 床上,");
4159                                 else
4160                                         strcat(out_val, " '4'or'6' 床上,");
4161 #else
4162                                 if (!use_menu)
4163                                         strcat(out_val, " - for floor,");
4164                                 else if (allow_equip)
4165                                         strcat(out_val, " 4 for floor,");
4166                                 else
4167                                         strcat(out_val, " 4 or 6 for floor,");
4168 #endif
4169                         }
4170                 }
4171
4172                 /* Viewing equipment */
4173                 else if (command_wrk == (USE_EQUIP))
4174                 {
4175                         /* Begin the prompt */
4176                         sprintf(out_val, _("装備品:", "Equip:"));
4177
4178                         if (!use_menu)
4179                         {
4180                                 /* Build the prompt */
4181                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"),
4182                                         index_to_label(e1), index_to_label(e2));
4183
4184                                 /* Append */
4185                                 strcat(out_val, tmp_val);
4186                         }
4187
4188                         /* Indicate ability to "view" */
4189                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4190
4191                         /* Append */
4192                         if (allow_inven)
4193                         {
4194 #ifdef JP
4195                                 if (!use_menu)
4196                                         strcat(out_val, " '/' 持ち物,");
4197                                 else if (allow_floor)
4198                                         strcat(out_val, " '4' 持ち物,");
4199                                 else
4200                                         strcat(out_val, " '4'or'6' 持ち物,");
4201 #else
4202                                 if (!use_menu)
4203                                         strcat(out_val, " / for Inven,");
4204                                 else if (allow_floor)
4205                                         strcat(out_val, " 4 for Inven,");
4206                                 else
4207                                         strcat(out_val, " 4 or 6 for Inven,");
4208 #endif
4209                         }
4210
4211                         /* Append */
4212                         if (allow_floor)
4213                         {
4214 #ifdef JP
4215                                 if (!use_menu)
4216                                         strcat(out_val, " '-'床上,");
4217                                 else if (allow_inven)
4218                                         strcat(out_val, " '6' 床上,");
4219                                 else
4220                                         strcat(out_val, " '4'or'6' 床上,");
4221 #else
4222                                 if (!use_menu)
4223                                         strcat(out_val, " - for floor,");
4224                                 else if (allow_inven)
4225                                         strcat(out_val, " 6 for floor,");
4226                                 else
4227                                         strcat(out_val, " 4 or 6 for floor,");
4228 #endif
4229                         }
4230                 }
4231
4232                 /* Viewing floor */
4233                 else if (command_wrk == (USE_FLOOR))
4234                 {
4235                         /* Begin the prompt */
4236                         sprintf(out_val, _("床上:", "Floor:"));
4237
4238                         if (!use_menu)
4239                         {
4240                                 /* Build the prompt */
4241                                 sprintf(tmp_val, _("%c-%c,'(',')',", " %c-%c,'(',')',"), n1, n2);
4242
4243                                 /* Append */
4244                                 strcat(out_val, tmp_val);
4245                         }
4246
4247                         /* Indicate ability to "view" */
4248                         if (!command_see && !use_menu) strcat(out_val, _(" '*'一覧,", " * to see,"));
4249
4250                         if (use_menu)
4251                         {
4252                                 if (allow_inven && allow_equip)
4253                                 {
4254                                         strcat(out_val, _(" '4' 装備品, '6' 持ち物,", " 4 for Equip, 6 for Inven,"));
4255                                 }
4256                                 else if (allow_inven)
4257                                 {
4258                                         strcat(out_val, _(" '4'or'6' 持ち物,", " 4 or 6 for Inven,"));
4259                                 }
4260                                 else if (allow_equip)
4261                                 {
4262                                         strcat(out_val, _(" '4'or'6' 装備品,", " 4 or 6 for Equip,"));
4263                                 }
4264                         }
4265                         /* Append */
4266                         else if (allow_inven)
4267                         {
4268                                 strcat(out_val, _(" '/' 持ち物,", " / for Inven,"));
4269                         }
4270                         else if (allow_equip)
4271                         {
4272                                 strcat(out_val, _(" '/'装備品,", " / for Equip,"));
4273                         }
4274
4275                         /* Append */
4276                         if (command_see && !use_menu)
4277                         {
4278                                 strcat(out_val, _(" Enter 次,", " Enter for scroll down,"));
4279                         }
4280                 }
4281
4282                 /* Append */
4283                 if (select_the_force) strcat(out_val, _(" 'w'練気術,", " w for the Force,"));
4284
4285                 /* Finish the prompt */
4286                 strcat(out_val, " ESC");
4287
4288                 /* Build the prompt */
4289                 sprintf(tmp_val, "(%s) %s", out_val, pmt);
4290
4291                 /* Show the prompt */
4292                 prt(tmp_val, 0, 0);
4293
4294                 /* Get a key */
4295                 which = inkey();
4296
4297                 if (use_menu)
4298                 {
4299                 int max_line = 1;
4300                 if (command_wrk == USE_INVEN) max_line = max_inven;
4301                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4302                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4303                 switch (which)
4304                 {
4305                         case ESCAPE:
4306                         case 'z':
4307                         case 'Z':
4308                         case '0':
4309                         {
4310                                 done = TRUE;
4311                                 break;
4312                         }
4313
4314                         case '8':
4315                         case 'k':
4316                         case 'K':
4317                         {
4318                                 menu_line += (max_line - 1);
4319                                 break;
4320                         }
4321
4322                         case '2':
4323                         case 'j':
4324                         case 'J':
4325                         {
4326                                 menu_line++;
4327                                 break;
4328                         }
4329
4330                         case '4':
4331                         case 'h':
4332                         case 'H':
4333                         {
4334                                 /* Verify legality */
4335                                 if (command_wrk == (USE_INVEN))
4336                                 {
4337                                         if (allow_floor) command_wrk = USE_FLOOR;
4338                                         else if (allow_equip) command_wrk = USE_EQUIP;
4339                                         else
4340                                         {
4341                                                 bell();
4342                                                 break;
4343                                         }
4344                                 }
4345                                 else if (command_wrk == (USE_EQUIP))
4346                                 {
4347                                         if (allow_inven) command_wrk = USE_INVEN;
4348                                         else if (allow_floor) command_wrk = USE_FLOOR;
4349                                         else
4350                                         {
4351                                                 bell();
4352                                                 break;
4353                                         }
4354                                 }
4355                                 else if (command_wrk == (USE_FLOOR))
4356                                 {
4357                                         if (allow_equip) command_wrk = USE_EQUIP;
4358                                         else if (allow_inven) command_wrk = USE_INVEN;
4359                                         else
4360                                         {
4361                                                 bell();
4362                                                 break;
4363                                         }
4364                                 }
4365                                 else
4366                                 {
4367                                         bell();
4368                                         break;
4369                                 }
4370
4371                                 /* Hack -- Fix screen */
4372                                 if (command_see)
4373                                 {
4374                                         /* Load screen */
4375                                         screen_load();
4376
4377                                         /* Save screen */
4378                                         screen_save();
4379                                 }
4380
4381                                 /* Switch inven/equip */
4382                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4383                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4384                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4385                                 if (menu_line > max_line) menu_line = max_line;
4386
4387                                 /* Need to redraw */
4388                                 break;
4389                         }
4390
4391                         case '6':
4392                         case 'l':
4393                         case 'L':
4394                         {
4395                                 /* Verify legality */
4396                                 if (command_wrk == (USE_INVEN))
4397                                 {
4398                                         if (allow_equip) command_wrk = USE_EQUIP;
4399                                         else if (allow_floor) command_wrk = USE_FLOOR;
4400                                         else
4401                                         {
4402                                                 bell();
4403                                                 break;
4404                                         }
4405                                 }
4406                                 else if (command_wrk == (USE_EQUIP))
4407                                 {
4408                                         if (allow_floor) command_wrk = USE_FLOOR;
4409                                         else if (allow_inven) command_wrk = USE_INVEN;
4410                                         else
4411                                         {
4412                                                 bell();
4413                                                 break;
4414                                         }
4415                                 }
4416                                 else if (command_wrk == (USE_FLOOR))
4417                                 {
4418                                         if (allow_inven) command_wrk = USE_INVEN;
4419                                         else if (allow_equip) command_wrk = USE_EQUIP;
4420                                         else
4421                                         {
4422                                                 bell();
4423                                                 break;
4424                                         }
4425                                 }
4426                                 else
4427                                 {
4428                                         bell();
4429                                         break;
4430                                 }
4431
4432                                 /* Hack -- Fix screen */
4433                                 if (command_see)
4434                                 {
4435                                         /* Load screen */
4436                                         screen_load();
4437
4438                                         /* Save screen */
4439                                         screen_save();
4440                                 }
4441
4442                                 /* Switch inven/equip */
4443                                 if (command_wrk == USE_INVEN) max_line = max_inven;
4444                                 else if (command_wrk == USE_EQUIP) max_line = max_equip;
4445                                 else if (command_wrk == USE_FLOOR) max_line = MIN(23, floor_num);
4446                                 if (menu_line > max_line) menu_line = max_line;
4447
4448                                 /* Need to redraw */
4449                                 break;
4450                         }
4451
4452                         case 'x':
4453                         case 'X':
4454                         case '\r':
4455                         case '\n':
4456                         {
4457                                 if (command_wrk == USE_FLOOR)
4458                                 {
4459                                         /* Special index */
4460                                         (*cp) = -get_item_label;
4461                                 }
4462                                 else
4463                                 {
4464                                         /* Validate the item */
4465                                         if (!get_item_okay(get_item_label))
4466                                         {
4467                                                 bell();
4468                                                 break;
4469                                         }
4470
4471                                         /* Allow player to "refuse" certain actions */
4472                                         if (!get_item_allow(get_item_label))
4473                                         {
4474                                                 done = TRUE;
4475                                                 break;
4476                                         }
4477
4478                                         /* Accept that choice */
4479                                         (*cp) = get_item_label;
4480                                 }
4481
4482                                 item = TRUE;
4483                                 done = TRUE;
4484                                 break;
4485                         }
4486                         case 'w':
4487                         {
4488                                 if (select_the_force) {
4489                                         *cp = INVEN_FORCE;
4490                                         item = TRUE;
4491                                         done = TRUE;
4492                                         break;
4493                                 }
4494                         }
4495                 }
4496                 if (menu_line > max_line) menu_line -= max_line;
4497                 }
4498                 else
4499                 {
4500                 /* Parse it */
4501                 switch (which)
4502                 {
4503                         case ESCAPE:
4504                         {
4505                                 done = TRUE;
4506                                 break;
4507                         }
4508
4509                         case '*':
4510                         case '?':
4511                         case ' ':
4512                         {
4513                                 /* Hide the list */
4514                                 if (command_see)
4515                                 {
4516                                         /* Flip flag */
4517                                         command_see = FALSE;
4518
4519                                         /* Load screen */
4520                                         screen_load();
4521                                 }
4522
4523                                 /* Show the list */
4524                                 else
4525                                 {
4526                                         /* Save screen */
4527                                         screen_save();
4528
4529                                         /* Flip flag */
4530                                         command_see = TRUE;
4531                                 }
4532                                 break;
4533                         }
4534
4535                         case '\n':
4536                         case '\r':
4537                         case '+':
4538                         {
4539                                 int i;
4540                                 IDX o_idx;
4541                                 cave_type *c_ptr = &cave[p_ptr->y][p_ptr->x];
4542
4543                                 if (command_wrk != (USE_FLOOR)) break;
4544
4545                                 /* Get the object being moved. */
4546                                 o_idx = c_ptr->o_idx;
4547
4548                                 /* Only rotate a pile of two or more objects. */
4549                                 if (!(o_idx && o_list[o_idx].next_o_idx)) break;
4550
4551                                 /* Remove the first object from the list. */
4552                                 excise_object_idx(o_idx);
4553
4554                                 /* Find end of the list. */
4555                                 i = c_ptr->o_idx;
4556                                 while (o_list[i].next_o_idx)
4557                                         i = o_list[i].next_o_idx;
4558
4559                                 /* Add after the last object. */
4560                                 o_list[i].next_o_idx = o_idx;
4561
4562                                 /* Re-scan floor list */ 
4563                                 floor_num = scan_floor(floor_list, p_ptr->y, p_ptr->x, 0x03);
4564
4565                                 /* Hack -- Fix screen */
4566                                 if (command_see)
4567                                 {
4568                                         /* Load screen */
4569                                         screen_load();
4570
4571                                         /* Save screen */
4572                                         screen_save();
4573                                 }
4574
4575                                 break;
4576                         }
4577
4578                         case '/':
4579                         {
4580                                 if (command_wrk == (USE_INVEN))
4581                                 {
4582                                         if (!allow_equip)
4583                                         {
4584                                                 bell();
4585                                                 break;
4586                                         }
4587                                         command_wrk = (USE_EQUIP);
4588                                 }
4589                                 else if (command_wrk == (USE_EQUIP))
4590                                 {
4591                                         if (!allow_inven)
4592                                         {
4593                                                 bell();
4594                                                 break;
4595                                         }
4596                                         command_wrk = (USE_INVEN);
4597                                 }
4598                                 else if (command_wrk == (USE_FLOOR))
4599                                 {
4600                                         if (allow_inven)
4601                                         {
4602                                                 command_wrk = (USE_INVEN);
4603                                         }
4604                                         else if (allow_equip)
4605                                         {
4606                                                 command_wrk = (USE_EQUIP);
4607                                         }
4608                                         else
4609                                         {
4610                                                 bell();
4611                                                 break;
4612                                         }
4613                                 }
4614
4615                                 /* Hack -- Fix screen */
4616                                 if (command_see)
4617                                 {
4618                                         /* Load screen */
4619                                         screen_load();
4620
4621                                         /* Save screen */
4622                                         screen_save();
4623                                 }
4624
4625                                 /* Need to redraw */
4626                                 break;
4627                         }
4628
4629                         case '-':
4630                         {
4631                                 if (!allow_floor)
4632                                 {
4633                                         bell();
4634                                         break;
4635                                 }
4636
4637                                 /*
4638                                  * If we are already examining the floor, and there
4639                                  * is only one item, we will always select it.
4640                                  * If we aren't examining the floor and there is only
4641                                  * one item, we will select it if floor_query_flag
4642                                  * is FALSE.
4643                                  */
4644                                 if (floor_num == 1)
4645                                 {
4646                                         if ((command_wrk == (USE_FLOOR)) || (!carry_query_flag))
4647                                         {
4648                                                 /* Special index */
4649                                                 k = 0 - floor_list[0];
4650
4651                                                 /* Allow player to "refuse" certain actions */
4652                                                 if (!get_item_allow(k))
4653                                                 {
4654                                                         done = TRUE;
4655                                                         break;
4656                                                 }
4657
4658                                                 /* Accept that choice */
4659                                                 (*cp) = k;
4660                                                 item = TRUE;
4661                                                 done = TRUE;
4662
4663                                                 break;
4664                                         }
4665                                 }
4666
4667                                 /* Hack -- Fix screen */
4668                                 if (command_see)
4669                                 {
4670                                         /* Load screen */
4671                                         screen_load();
4672
4673                                         /* Save screen */
4674                                         screen_save();
4675                                 }
4676
4677                                 command_wrk = (USE_FLOOR);
4678
4679                                 break;
4680                         }
4681
4682                         case '0':
4683                         case '1': case '2': case '3':
4684                         case '4': case '5': case '6':
4685                         case '7': case '8': case '9':
4686                         {
4687                                 if (command_wrk != USE_FLOOR)
4688                                 {
4689                                         /* Look up the tag */
4690                                         if (!get_tag(&k, which, command_wrk))
4691                                         {
4692                                                 bell();
4693                                                 break;
4694                                         }
4695
4696                                         /* Hack -- Validate the item */
4697                                         if ((k < INVEN_RARM) ? !inven : !equip)
4698                                         {
4699                                                 bell();
4700                                                 break;
4701                                         }
4702
4703                                         /* Validate the item */
4704                                         if (!get_item_okay(k))
4705                                         {
4706                                                 bell();
4707                                                 break;
4708                                         }
4709                                 }
4710                                 else
4711                                 {
4712                                         /* Look up the alphabetical tag */
4713                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4714                                         {
4715                                                 /* Special index */
4716                                                 k = 0 - floor_list[k];
4717                                         }
4718                                         else
4719                                         {
4720                                                 bell();
4721                                                 break;
4722                                         }
4723                                 }
4724
4725                                 /* Allow player to "refuse" certain actions */
4726                                 if (!get_item_allow(k))
4727                                 {
4728                                         done = TRUE;
4729                                         break;
4730                                 }
4731
4732                                 /* Accept that choice */
4733                                 (*cp) = k;
4734                                 item = TRUE;
4735                                 done = TRUE;
4736 #ifdef ALLOW_REPEAT
4737                                 cur_tag = which;
4738 #endif /* ALLOW_REPEAT */
4739                                 break;
4740                         }
4741
4742 #if 0
4743                         case '\n':
4744                         case '\r':
4745                         {
4746                                 /* Choose "default" inventory item */
4747                                 if (command_wrk == (USE_INVEN))
4748                                 {
4749                                         k = ((i1 == i2) ? i1 : -1);
4750                                 }
4751
4752                                 /* Choose "default" equipment item */
4753                                 else if (command_wrk == (USE_EQUIP))
4754                                 {
4755                                         k = ((e1 == e2) ? e1 : -1);
4756                                 }
4757
4758                                 /* Choose "default" floor item */
4759                                 else if (command_wrk == (USE_FLOOR))
4760                                 {
4761                                         if (floor_num == 1)
4762                                         {
4763                                                 /* Special index */
4764                                                 k = 0 - floor_list[0];
4765
4766                                                 /* Allow player to "refuse" certain actions */
4767                                                 if (!get_item_allow(k))
4768                                                 {
4769                                                         done = TRUE;
4770                                                         break;
4771                                                 }
4772
4773                                                 /* Accept that choice */
4774                                                 (*cp) = k;
4775                                                 item = TRUE;
4776                                                 done = TRUE;
4777                                         }
4778                                         break;
4779                                 }
4780
4781                                 /* Validate the item */
4782                                 if (!get_item_okay(k))
4783                                 {
4784                                         bell();
4785                                         break;
4786                                 }
4787
4788                                 /* Allow player to "refuse" certain actions */
4789                                 if (!get_item_allow(k))
4790                                 {
4791                                         done = TRUE;
4792                                         break;
4793                                 }
4794
4795                                 /* Accept that choice */
4796                                 (*cp) = k;
4797                                 item = TRUE;
4798                                 done = TRUE;
4799                                 break;
4800                         }
4801 #endif
4802
4803                         case 'w':
4804                         {
4805                                 if (select_the_force) {
4806                                         *cp = INVEN_FORCE;
4807                                         item = TRUE;
4808                                         done = TRUE;
4809                                         break;
4810                                 }
4811
4812                                 /* Fall through */
4813                         }
4814
4815                         default:
4816                         {
4817                                 int ver;
4818
4819                                 if (command_wrk != USE_FLOOR)
4820                                 {
4821                                         bool not_found = FALSE;
4822
4823                                         /* Look up the alphabetical tag */
4824                                         if (!get_tag(&k, which, command_wrk))
4825                                         {
4826                                                 not_found = TRUE;
4827                                         }
4828
4829                                         /* Hack -- Validate the item */
4830                                         else if ((k < INVEN_RARM) ? !inven : !equip)
4831                                         {
4832                                                 not_found = TRUE;
4833                                         }
4834
4835                                         /* Validate the item */
4836                                         else if (!get_item_okay(k))
4837                                         {
4838                                                 not_found = TRUE;
4839                                         }
4840
4841                                         if (!not_found)
4842                                         {
4843                                                 /* Accept that choice */
4844                                                 (*cp) = k;
4845                                                 item = TRUE;
4846                                                 done = TRUE;
4847 #ifdef ALLOW_REPEAT
4848                                                 cur_tag = which;
4849 #endif /* ALLOW_REPEAT */
4850                                                 break;
4851                                         }
4852                                 }
4853                                 else
4854                                 {
4855                                         /* Look up the alphabetical tag */
4856                                         if (get_tag_floor(&k, which, floor_list, floor_num))
4857                                         {
4858                                                 /* Special index */
4859                                                 k = 0 - floor_list[k];
4860
4861                                                 /* Accept that choice */
4862                                                 (*cp) = k;
4863                                                 item = TRUE;
4864                                                 done = TRUE;
4865 #ifdef ALLOW_REPEAT
4866                                                 cur_tag = which;
4867 #endif /* ALLOW_REPEAT */
4868                                                 break;
4869                                         }
4870                                 }
4871
4872                                 /* Extract "query" setting */
4873                                 ver = isupper(which);
4874                                 which = (char)tolower(which);
4875
4876                                 /* Convert letter to inventory index */
4877                                 if (command_wrk == (USE_INVEN))
4878                                 {
4879                                         if (which == '(') k = i1;
4880                                         else if (which == ')') k = i2;
4881                                         else k = label_to_inven(which);
4882                                 }
4883
4884                                 /* Convert letter to equipment index */
4885                                 else if (command_wrk == (USE_EQUIP))
4886                                 {
4887                                         if (which == '(') k = e1;
4888                                         else if (which == ')') k = e2;
4889                                         else k = label_to_equip(which);
4890                                 }
4891
4892                                 /* Convert letter to floor index */
4893                                 else if (command_wrk == USE_FLOOR)
4894                                 {
4895                                         if (which == '(') k = 0;
4896                                         else if (which == ')') k = floor_num - 1;
4897                                         else k = islower(which) ? A2I(which) : -1;
4898                                         if (k < 0 || k >= floor_num || k >= 23)
4899                                         {
4900                                                 bell();
4901                                                 break;
4902                                         }
4903
4904                                         /* Special index */
4905                                         k = 0 - floor_list[k];
4906                                 }
4907
4908                                 /* Validate the item */
4909                                 if ((command_wrk != USE_FLOOR) && !get_item_okay(k))
4910                                 {
4911                                         bell();
4912                                         break;
4913                                 }
4914
4915                                 /* Verify the item */
4916                                 if (ver && !verify(_("本当に", "Try"), k))
4917                                 {
4918                                         done = TRUE;
4919                                         break;
4920                                 }
4921
4922                                 /* Allow player to "refuse" certain actions */
4923                                 if (!get_item_allow(k))
4924                                 {
4925                                         done = TRUE;
4926                                         break;
4927                                 }
4928
4929                                 /* Accept that choice */
4930                                 (*cp) = k;
4931                                 item = TRUE;
4932                                 done = TRUE;
4933                                 break;
4934                         }
4935                 }
4936                 }
4937         }
4938
4939         /* Fix the screen if necessary */
4940         if (command_see)
4941         {
4942                 /* Load screen */
4943                 screen_load();
4944
4945                 /* Hack -- Cancel "display" */
4946                 command_see = FALSE;
4947         }
4948
4949
4950         /* Forget the item_tester_tval restriction */
4951         item_tester_tval = 0;
4952
4953         /* Forget the item_tester_hook restriction */
4954         item_tester_hook = NULL;
4955
4956
4957         /* Clean up  'show choices' */
4958         /* Toggle again if needed */
4959         if (toggle) toggle_inven_equip();
4960
4961         /* Update */
4962         p_ptr->window |= (PW_INVEN | PW_EQUIP);
4963
4964         /* Window stuff */
4965         window_stuff();
4966
4967
4968         /* Clear the prompt line */
4969         prt("", 0, 0);
4970
4971         /* Warning if needed */
4972         if (oops && str) msg_print(str);
4973
4974         if (item)
4975         {
4976 #ifdef ALLOW_REPEAT
4977                 repeat_push(*cp);
4978                 if (command_cmd) prev_tag = cur_tag;
4979 #endif /* ALLOW_REPEAT */
4980
4981                 command_cmd = 0; /* Hack -- command_cmd is no longer effective */
4982         }
4983
4984         /* Result */
4985         return (item);
4986 }
4987
4988 /*!
4989  * @brief 床上のアイテムを拾う選択用サブルーチン 
4990  * @return プレイヤーによりアイテムが選択されたならTRUEを返す。
4991  */
4992 static bool py_pickup_floor_aux(void)
4993 {
4994         OBJECT_IDX this_o_idx;
4995
4996         cptr q, s;
4997
4998         OBJECT_IDX item;
4999
5000         /* Restrict the choices */
5001         item_tester_hook = inven_carry_okay;
5002
5003         /* Get an object */
5004         q = _("どれを拾いますか?", "Get which item? ");
5005         s = _("もうザックには床にあるどのアイテムも入らない。", "You no longer have any room for the objects on the floor.");
5006
5007         if (get_item(&item, q, s, (USE_FLOOR)))
5008         {
5009                 this_o_idx = 0 - item;
5010         }
5011         else
5012         {
5013                 return (FALSE);
5014         }
5015
5016         /* Pick up the object */
5017         py_pickup_aux(this_o_idx);
5018
5019         return (TRUE);
5020 }
5021
5022 /*!
5023  * @brief 床上のアイテムを拾うメイン処理
5024  * @param pickup FALSEなら金銭の自動拾いのみを行う/ FALSE then only gold will be picked up
5025  * @return なし
5026  * @details
5027  * This is called by py_pickup() when easy_floor is TRUE.
5028  */
5029 void py_pickup_floor(bool pickup)
5030 {
5031         s16b this_o_idx, next_o_idx = 0;
5032
5033         char o_name[MAX_NLEN];
5034         object_type *o_ptr;
5035
5036         int floor_num = 0, floor_o_idx = 0;
5037
5038         int can_pickup = 0;
5039
5040         /* Scan the pile of objects */
5041         for (this_o_idx = cave[p_ptr->y][p_ptr->x].o_idx; this_o_idx; this_o_idx = next_o_idx)
5042         {
5043                 /* Access the object */
5044                 o_ptr = &o_list[this_o_idx];
5045
5046                 /* Describe the object */
5047                 object_desc(o_name, o_ptr, 0);
5048
5049                 /* Access the next object */
5050                 next_o_idx = o_ptr->next_o_idx;
5051
5052                 /* Hack -- disturb */
5053                 disturb(0, 0);
5054
5055                 /* Pick up gold */
5056                 if (o_ptr->tval == TV_GOLD)
5057                 {
5058                         /* Message */
5059 #ifdef JP
5060                         msg_format(" $%ld の価値がある%sを見つけた。",
5061                                 (long)o_ptr->pval, o_name);
5062 #else
5063                         msg_format("You have found %ld gold pieces worth of %s.",
5064                                 (long)o_ptr->pval, o_name);
5065 #endif
5066
5067                         /* Collect the gold */
5068                         p_ptr->au += o_ptr->pval;
5069
5070                         /* Redraw gold */
5071                         p_ptr->redraw |= (PR_GOLD);
5072
5073                         /* Window stuff */
5074                         p_ptr->window |= (PW_PLAYER);
5075
5076                         /* Delete the gold */
5077                         delete_object_idx(this_o_idx);
5078
5079                         /* Check the next object */
5080                         continue;
5081                 }
5082                 else if (o_ptr->marked & OM_NOMSG)
5083                 {
5084                         /* If 0 or 1 non-NOMSG items are in the pile, the NOMSG ones are
5085                          * ignored. Otherwise, they are included in the prompt. */
5086                         o_ptr->marked &= ~(OM_NOMSG);
5087                         continue;
5088                 }
5089
5090                 /* Count non-gold objects that can be picked up. */
5091                 if (inven_carry_okay(o_ptr))
5092                 {
5093                         can_pickup++;
5094                 }
5095
5096                 /* Count non-gold objects */
5097                 floor_num++;
5098
5099                 /* Remember this index */
5100                 floor_o_idx = this_o_idx;
5101         }
5102
5103         /* There are no non-gold objects */
5104         if (!floor_num)
5105                 return;
5106
5107         /* Mention the number of objects */
5108         if (!pickup)
5109         {
5110                 /* One object */
5111                 if (floor_num == 1)
5112                 {
5113                         /* Access the object */
5114                         o_ptr = &o_list[floor_o_idx];
5115
5116 #ifdef ALLOW_EASY_SENSE
5117
5118                         /* Option: Make object sensing easy */
5119                         if (easy_sense)
5120                         {
5121                                 /* Sense the object */
5122                                 (void) sense_object(o_ptr);
5123                         }
5124
5125 #endif /* ALLOW_EASY_SENSE */
5126
5127                         /* Describe the object */
5128                         object_desc(o_name, o_ptr, 0);
5129
5130                         /* Message */
5131                         msg_format(_("%sがある。", "You see %s."), o_name);
5132                 }
5133
5134                 /* Multiple objects */
5135                 else
5136                 {
5137                         /* Message */
5138                         msg_format(_("%d 個のアイテムの山がある。", "You see a pile of %d items."), floor_num);
5139                 }
5140
5141                 /* Done */
5142                 return;
5143         }
5144
5145         /* The player has no room for anything on the floor. */
5146         if (!can_pickup)
5147         {
5148                 /* One object */
5149                 if (floor_num == 1)
5150                 {
5151                         /* Access the object */
5152                         o_ptr = &o_list[floor_o_idx];
5153
5154 #ifdef ALLOW_EASY_SENSE
5155
5156                         /* Option: Make object sensing easy */
5157                         if (easy_sense)
5158                         {
5159                                 /* Sense the object */
5160                                 (void) sense_object(o_ptr);
5161                         }
5162
5163 #endif /* ALLOW_EASY_SENSE */
5164
5165                         /* Describe the object */
5166                         object_desc(o_name, o_ptr, 0);
5167
5168                         /* Message */
5169                         msg_format(_("ザックには%sを入れる隙間がない。", "You have no room for %s."), o_name);
5170                 }
5171
5172                 /* Multiple objects */
5173                 else
5174                 {
5175                         /* Message */
5176                         msg_print(_("ザックには床にあるどのアイテムも入らない。", "You have no room for any of the objects on the floor."));
5177
5178                 }
5179
5180                 /* Done */
5181                 return;
5182         }
5183
5184         /* One object */
5185         if (floor_num == 1)
5186         {
5187                 /* Hack -- query every object */
5188                 if (carry_query_flag)
5189                 {
5190                         char out_val[MAX_NLEN+20];
5191
5192                         /* Access the object */
5193                         o_ptr = &o_list[floor_o_idx];
5194
5195 #ifdef ALLOW_EASY_SENSE
5196
5197                         /* Option: Make object sensing easy */
5198                         if (easy_sense)
5199                         {
5200                                 /* Sense the object */
5201                                 (void) sense_object(o_ptr);
5202                         }
5203
5204 #endif /* ALLOW_EASY_SENSE */
5205
5206                         /* Describe the object */
5207                         object_desc(o_name, o_ptr, 0);
5208
5209                         /* Build a prompt */
5210                         (void) sprintf(out_val, _("%sを拾いますか? ", "Pick up %s? "), o_name);
5211
5212                         /* Ask the user to confirm */
5213                         if (!get_check(out_val))
5214                         {
5215                                 /* Done */
5216                                 return;
5217                         }
5218                 }
5219
5220                 /* Access the object */
5221                 o_ptr = &o_list[floor_o_idx];
5222
5223 #ifdef ALLOW_EASY_SENSE
5224
5225                 /* Option: Make object sensing easy */
5226                 if (easy_sense)
5227                 {
5228                         /* Sense the object */
5229                         (void) sense_object(o_ptr);
5230                 }
5231
5232 #endif /* ALLOW_EASY_SENSE */
5233
5234                 /* Pick up the object */
5235                 py_pickup_aux(floor_o_idx);
5236         }
5237
5238         /* Allow the user to choose an object */
5239         else
5240         {
5241                 while (can_pickup--)
5242                 {
5243                         if (!py_pickup_floor_aux()) break;
5244                 }
5245         }
5246 }
5247
5248 #endif /* ALLOW_EASY_FLOOR */