OSDN Git Service

Add Doxygen comment to store.c.
[hengband/hengband.git] / src / cmd4.c
1 /*!
2  * @file cmd4.c
3  * @brief ¥×¥ì¥¤¥ä¡¼¤Î¥¤¥ó¥¿¡¼¥Õ¥§¥¤¥¹¤Ë´Ø¤¹¤ë¥³¥Þ¥ó¥É¤Î¼ÂÁõ / Interface commands
4  * @date 2014/01/02
5  * @author
6  * <pre>
7  * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8  * This software may be copied and distributed for educational, research,
9  * and not for profit purposes provided that this copyright and statement
10  * are included in all such copies.  Other copyrights may also apply.
11  * </pre>
12  * @details
13  * <pre>
14  * A set of functions to maintain automatic dumps of various kinds.
15  * -Mogami-
16  * remove_auto_dump(orig_file, mark)
17  *     Remove the old automatic dump of type "mark".
18  * auto_dump_printf(fmt, ...)
19  *     Dump a formatted string using fprintf().
20  * open_auto_dump(buf, mark)
21  *     Open a file, remove old dump, and add new header.
22  * close_auto_dump(void)
23  *     Add a footer, and close the file.
24  *    The dump commands of original Angband simply add new lines to
25  * existing files; these files will become bigger and bigger unless
26  * an user deletes some or all of these files by hand at some
27  * point.
28  *     These three functions automatically delete old dumped lines 
29  * before adding new ones.  Since there are various kinds of automatic 
30  * dumps in a single file, we add a header and a footer with a type 
31  * name for every automatic dump, and kill old lines only when the 
32  * lines have the correct type of header and footer.
33  *     We need to be quite paranoid about correctness; the user might 
34  * (mistakenly) edit the file by hand, and see all their work come
35  * to nothing on the next auto dump otherwise.  The current code only 
36  * detects changes by noting inconsistencies between the actual number 
37  * of lines and the number written in the footer.  Note that this will 
38  * not catch single-line edits.
39  * </pre>
40  */
41
42 #include "angband.h"
43
44
45
46 /*
47  */
48
49 /*
50  *  Mark strings for auto dump
51  */
52 static char auto_dump_header[] = "# vvvvvvv== %s ==vvvvvvv";
53 static char auto_dump_footer[] = "# ^^^^^^^== %s ==^^^^^^^";
54
55 /*
56  * Variables for auto dump
57  */
58 static FILE *auto_dump_stream;
59 static cptr auto_dump_mark;
60 static int auto_dump_line_num;
61
62
63 /*!
64  * @brief prf½ÐÎÏÆâÍƤò¾Ãµî¤¹¤ë /
65  * Remove old lines automatically generated before.
66  * @param orig_file ¾Ãµî¤ò¹Ô¤¦¥Õ¥¡¥¤¥ë̾
67  */
68 static void remove_auto_dump(cptr orig_file)
69 {
70         FILE *tmp_fff, *orig_fff;
71
72         char tmp_file[1024];
73         char buf[1024];
74         bool between_mark = FALSE;
75         bool changed = FALSE;
76         int line_num = 0;
77         long header_location = 0;
78         char header_mark_str[80];
79         char footer_mark_str[80];
80         size_t mark_len;
81
82         /* Prepare a header/footer mark string */
83         sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
84         sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
85
86         mark_len = strlen(footer_mark_str);
87
88         /* Open an old dump file in read-only mode */
89         orig_fff = my_fopen(orig_file, "r");
90
91         /* If original file does not exist, nothing to do */
92         if (!orig_fff) return;
93
94         /* Open a new (temporary) file */
95         tmp_fff = my_fopen_temp(tmp_file, 1024);
96
97         if (!tmp_fff)
98         {
99 #ifdef JP
100             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", tmp_file);
101 #else
102             msg_format("Failed to create temporary file %s.", tmp_file);
103 #endif
104             msg_print(NULL);
105             return;
106         }
107
108         /* Loop for every line */
109         while (TRUE)
110         {
111                 /* Read a line */
112                 if (my_fgets(orig_fff, buf, sizeof(buf)))
113                 {
114                         /* Read error: Assume End of File */
115
116                         /*
117                          * Was looking for the footer, but not found.
118                          *
119                          * Since automatic dump might be edited by hand,
120                          * it's dangerous to kill these lines.
121                          * Seek back to the next line of the (pseudo) header,
122                          * and read again.
123                          */
124                         if (between_mark)
125                         {
126                                 fseek(orig_fff, header_location, SEEK_SET);
127                                 between_mark = FALSE;
128                                 continue;
129                         }
130
131                         /* Success -- End the loop */
132                         else
133                         {
134                                 break;
135                         }
136                 }
137
138                 /* We are looking for the header mark of automatic dump */
139                 if (!between_mark)
140                 {
141                         /* Is this line a header? */
142                         if (!strcmp(buf, header_mark_str))
143                         {
144                                 /* Memorise seek point of this line */
145                                 header_location = ftell(orig_fff);
146
147                                 /* Initialize counter for number of lines */
148                                 line_num = 0;
149
150                                 /* Look for the footer from now */
151                                 between_mark = TRUE;
152
153                                 /* There are some changes */
154                                 changed = TRUE;
155                         }
156
157                         /* Not a header */
158                         else
159                         {
160                                 /* Copy orginally lines */
161                                 fprintf(tmp_fff, "%s\n", buf);
162                         }
163                 }
164
165                 /* We are looking for the footer mark of automatic dump */
166                 else
167                 {
168                         /* Is this line a footer? */
169                         if (!strncmp(buf, footer_mark_str, mark_len))
170                         {
171                                 int tmp;
172
173                                 /*
174                                  * Compare the number of lines
175                                  *
176                                  * If there is an inconsistency between
177                                  * actual number of lines and the
178                                  * number here, the automatic dump
179                                  * might be edited by hand.  So it's
180                                  * dangerous to kill these lines.
181                                  * Seek back to the next line of the
182                                  * (pseudo) header, and read again.
183                                  */
184                                 if (!sscanf(buf + mark_len, " (%d)", &tmp)
185                                     || tmp != line_num)
186                                 {
187                                         fseek(orig_fff, header_location, SEEK_SET);
188                                 }
189
190                                 /* Look for another header */
191                                 between_mark = FALSE;
192                         }
193
194                         /* Not a footer */
195                         else
196                         {
197                                 /* Ignore old line, and count number of lines */
198                                 line_num++;
199                         }
200                 }
201         }
202
203         /* Close files */
204         my_fclose(orig_fff);
205         my_fclose(tmp_fff);
206
207         /* If there are some changes, overwrite the original file with new one */
208         if (changed)
209         {
210                 /* Copy contents of temporary file */
211
212                 tmp_fff = my_fopen(tmp_file, "r");
213                 orig_fff = my_fopen(orig_file, "w");
214
215                 while (!my_fgets(tmp_fff, buf, sizeof(buf)))
216                         fprintf(orig_fff, "%s\n", buf);
217
218                 my_fclose(orig_fff);
219                 my_fclose(tmp_fff);
220         }
221
222         /* Kill the temporary file */
223         fd_kill(tmp_file);
224
225         return;
226 }
227
228
229 /*!
230  * @brief prf¥Õ¥¡¥¤¥ë¤Î¥Õ¥©¡¼¥Þ¥Ã¥È¤Ë½¾¤Ã¤¿ÆâÍƤò½ÐÎϤ¹¤ë /
231  * Dump a formatted line, using "vstrnfmt()".
232  * @param fmt ½ÐÎÏÆâÍÆ
233  */
234 static void auto_dump_printf(cptr fmt, ...)
235 {
236         cptr p;
237         va_list vp;
238
239         char buf[1024];
240
241         /* Begin the Varargs Stuff */
242         va_start(vp, fmt);
243
244         /* Format the args, save the length */
245         (void)vstrnfmt(buf, sizeof(buf), fmt, vp);
246
247         /* End the Varargs Stuff */
248         va_end(vp);
249
250         /* Count number of lines */
251         for (p = buf; *p; p++)
252         {
253                 if (*p == '\n') auto_dump_line_num++;
254         }
255
256         /* Dump it */
257         fprintf(auto_dump_stream, "%s", buf);
258 }
259
260
261 /*!
262  * @brief prf¥Õ¥¡¥¤¥ë¤ò¥Õ¥¡¥¤¥ë¥ª¡¼¥×¥ó¤¹¤ë /
263  * Open file to append auto dump.
264  * @param buf ¥Õ¥¡¥¤¥ë̾
265  * @param mark ½ÐÎϤ¹¤ë¥Ø¥Ã¥À¥Þ¡¼¥¯
266  * @return ¥Õ¥¡¥¤¥ë¥Ý¥¤¥ó¥¿¤ò¼èÆÀ¤Ç¤­¤¿¤éTRUE¤òÊÖ¤¹
267  */
268 static bool open_auto_dump(cptr buf, cptr mark)
269 {
270
271         char header_mark_str[80];
272
273         /* Save the mark string */
274         auto_dump_mark = mark;
275
276         /* Prepare a header mark string */
277         sprintf(header_mark_str, auto_dump_header, auto_dump_mark);
278
279         /* Remove old macro dumps */
280         remove_auto_dump(buf);
281
282         /* Append to the file */
283         auto_dump_stream = my_fopen(buf, "a");
284
285         /* Failure */
286         if (!auto_dump_stream) {
287 #ifdef JP
288                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
289 #else
290                 msg_format("Failed to open %s.", buf);
291 #endif
292                 msg_print(NULL);
293
294                 /* Failed */
295                 return FALSE;
296         }
297
298         /* Start dumping */
299         fprintf(auto_dump_stream, "%s\n", header_mark_str);
300
301         /* Initialize counter */
302         auto_dump_line_num = 0;
303
304 #ifdef JP
305         auto_dump_printf("# *·Ù¹ð!!* °Ê¹ß¤Î¹Ô¤Ï¼«Æ°À¸À®¤µ¤ì¤¿¤â¤Î¤Ç¤¹¡£\n");
306         auto_dump_printf("# *·Ù¹ð!!* ¸å¤Ç¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤ë¤Î¤ÇÊÔ½¸¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£\n");
307 #else
308         auto_dump_printf("# *Warning!*  The lines below are an automatic dump.\n");
309         auto_dump_printf("# Don't edit them; changes will be deleted and replaced automatically.\n");
310 #endif
311
312         /* Success */
313         return TRUE;
314 }
315
316 /*!
317  * @brief prf¥Õ¥¡¥¤¥ë¤ò¥Õ¥¡¥¤¥ë¥¯¥í¡¼¥º¤¹¤ë /
318  * Append foot part and close auto dump.
319  * @return ¤Ê¤·
320  */
321 static void close_auto_dump(void)
322 {
323         char footer_mark_str[80];
324
325         /* Prepare a footer mark string */
326         sprintf(footer_mark_str, auto_dump_footer, auto_dump_mark);
327
328 #ifdef JP
329         auto_dump_printf("# *·Ù¹ð!!* °Ê¾å¤Î¹Ô¤Ï¼«Æ°À¸À®¤µ¤ì¤¿¤â¤Î¤Ç¤¹¡£\n");
330         auto_dump_printf("# *·Ù¹ð!!* ¸å¤Ç¼«Æ°Åª¤Ëºï½ü¤µ¤ì¤ë¤Î¤ÇÊÔ½¸¤·¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£\n");
331 #else
332         auto_dump_printf("# *Warning!*  The lines above are an automatic dump.\n");
333         auto_dump_printf("# Don't edit them; changes will be deleted and replaced automatically.\n");
334 #endif
335
336         /* End of dump */
337         fprintf(auto_dump_stream, "%s (%d)\n", footer_mark_str, auto_dump_line_num);
338
339         /* Close */
340         my_fclose(auto_dump_stream);
341
342         return;
343 }
344
345
346 #ifndef JP
347
348 /*!
349  * @brief Return suffix of ordinal number
350  * @param num number
351  * @return pointer of suffix string.
352  */
353 cptr get_ordinal_number_suffix(int num)
354 {
355         num = ABS(num) % 100;
356         switch (num % 10)
357         {
358         case 1:
359                 return (num == 11) ? "th" : "st";
360         case 2:
361                 return (num == 12) ? "th" : "nd";
362         case 3:
363                 return (num == 13) ? "th" : "rd";
364         default:
365                 return "th";
366         }
367 }
368 #endif
369
370
371 /*!
372  * @brief Æüµ­¤Ë¥á¥Ã¥»¡¼¥¸¤òÄɲ乤ë /
373  * Take note to the diary.
374  * @param type Æüµ­ÆâÍƤÎID
375  * @param num Æüµ­ÆâÍƤÎID¤Ë±þ¤¸¤¿¿ôÃÍ
376  * @param note Æüµ­ÆâÍƤÎID¤Ë±þ¤¸¤¿Ê¸»úÎ󻲾ȥݥ¤¥ó¥¿
377  * @return ¥¨¥é¡¼ID
378  */
379 errr do_cmd_write_nikki(int type, int num, cptr note)
380 {
381         int day, hour, min;
382         FILE *fff = NULL;
383         char file_name[80];
384         char buf[1024];
385         cptr note_level = "";
386         bool do_level = TRUE;
387         char note_level_buf[40];
388         int q_idx;
389
390         static bool disable_nikki = FALSE;
391
392         extract_day_hour_min(&day, &hour, &min);
393
394         if (disable_nikki) return(-1);
395
396         if (type == NIKKI_FIX_QUEST_C ||
397             type == NIKKI_FIX_QUEST_F ||
398             type == NIKKI_RAND_QUEST_C ||
399             type == NIKKI_RAND_QUEST_F ||
400             type == NIKKI_TO_QUEST)
401         {
402                 int old_quest;
403
404                 old_quest = p_ptr->inside_quest;
405                 p_ptr->inside_quest = (quest[num].type == QUEST_TYPE_RANDOM) ? 0 : num;
406
407                 /* Get the quest text */
408                 init_flags = INIT_NAME_ONLY;
409
410                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
411
412                 /* Reset the old quest number */
413                 p_ptr->inside_quest = old_quest;
414         }
415
416 #ifdef JP
417         sprintf(file_name,"playrecord-%s.txt",savefile_base);
418 #else
419         /* different filne name to avoid mixing */
420         sprintf(file_name,"playrec-%s.txt",savefile_base);
421 #endif
422
423         /* Build the filename */
424         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
425
426         /* File type is "TEXT" */
427         FILE_TYPE(FILE_TYPE_TEXT);
428
429         fff = my_fopen(buf, "a");
430
431         /* Failure */
432         if (!fff)
433         {
434 #ifdef JP
435                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£¥×¥ì¥¤µ­Ï¿¤ò°ì»þÄä»ß¤·¤Þ¤¹¡£", buf);
436 #else
437                 msg_format("Failed to open %s. Play-Record is disabled temporally.", buf);
438 #endif
439                 msg_format(NULL);
440                 disable_nikki=TRUE;
441                 return (-1);
442         }
443
444         q_idx = quest_number(dun_level);
445
446         if (write_level)
447         {
448                 if (p_ptr->inside_arena)
449 #ifdef JP
450                         note_level = "¥¢¥ê¡¼¥Ê:";
451 #else
452                         note_level = "Arane:";
453 #endif
454                 else if (!dun_level)
455 #ifdef JP
456                         note_level = "ÃϾå:";
457 #else
458                         note_level = "Surface:";
459 #endif
460                 else if (q_idx && (is_fixed_quest_idx(q_idx)
461                          && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
462 #ifdef JP
463                         note_level = "¥¯¥¨¥¹¥È:";
464 #else
465                         note_level = "Quest:";
466 #endif
467                 else
468                 {
469 #ifdef JP
470                         sprintf(note_level_buf, "%d³¬(%s):", dun_level, d_name+d_info[dungeon_type].name);
471 #else
472                         sprintf(note_level_buf, "%s L%d:", d_name+d_info[dungeon_type].name, dun_level);
473 #endif
474                         note_level = note_level_buf;
475                 }
476         }
477
478         switch(type)
479         {
480                 case NIKKI_HIGAWARI:
481                 {
482 #ifdef JP
483                         if (day < MAX_DAYS) fprintf(fff, "%dÆüÌÜ\n", day);
484                         else fputs("*****ÆüÌÜ\n", fff);
485 #else
486                         if (day < MAX_DAYS) fprintf(fff, "Day %d\n", day);
487                         else fputs("Day *****\n", fff);
488 #endif
489                         do_level = FALSE;
490                         break;
491                 }
492                 case NIKKI_BUNSHOU:
493                 {
494                         if (num)
495                         {
496                                 fprintf(fff, "%s\n",note);
497                                 do_level = FALSE;
498                         }
499                         else
500                                 fprintf(fff, " %2d:%02d %20s %s\n",hour, min, note_level, note);
501                         break;
502                 }
503                 case NIKKI_ART:
504                 {
505 #ifdef JP
506                         fprintf(fff, " %2d:%02d %20s %s¤òȯ¸«¤·¤¿¡£\n", hour, min, note_level, note);
507 #else
508                         fprintf(fff, " %2d:%02d %20s discovered %s.\n", hour, min, note_level, note);
509 #endif
510                         break;
511                 }
512                 case NIKKI_UNIQUE:
513                 {
514 #ifdef JP
515                         fprintf(fff, " %2d:%02d %20s %s¤òÅݤ·¤¿¡£\n", hour, min, note_level, note);
516 #else
517                         fprintf(fff, " %2d:%02d %20s defeated %s.\n", hour, min, note_level, note);
518 #endif
519                         break;
520                 }
521                 case NIKKI_FIX_QUEST_C:
522                 {
523                         if (quest[num].flags & QUEST_FLAG_SILENT) break;
524 #ifdef JP
525                         fprintf(fff, " %2d:%02d %20s ¥¯¥¨¥¹¥È¡Ö%s¡×¤òãÀ®¤·¤¿¡£\n", hour, min, note_level, quest[num].name);
526 #else
527                         fprintf(fff, " %2d:%02d %20s completed quest '%s'.\n", hour, min, note_level, quest[num].name);
528 #endif
529                         break;
530                 }
531                 case NIKKI_FIX_QUEST_F:
532                 {
533                         if (quest[num].flags & QUEST_FLAG_SILENT) break;
534 #ifdef JP
535                         fprintf(fff, " %2d:%02d %20s ¥¯¥¨¥¹¥È¡Ö%s¡×¤«¤éÌ¿¤«¤é¤¬¤éƨ¤²µ¢¤Ã¤¿¡£\n", hour, min, note_level, quest[num].name);
536 #else
537                         fprintf(fff, " %2d:%02d %20s run away from quest '%s'.\n", hour, min, note_level, quest[num].name);
538 #endif
539                         break;
540                 }
541                 case NIKKI_RAND_QUEST_C:
542                 {
543                         char name[80];
544                         strcpy(name, r_name+r_info[quest[num].r_idx].name);
545 #ifdef JP
546                         fprintf(fff, " %2d:%02d %20s ¥é¥ó¥À¥à¥¯¥¨¥¹¥È(%s)¤òãÀ®¤·¤¿¡£\n", hour, min, note_level, name);
547 #else
548                         fprintf(fff, " %2d:%02d %20s completed random quest '%s'\n", hour, min, note_level, name);
549 #endif
550                         break;
551                 }
552                 case NIKKI_RAND_QUEST_F:
553                 {
554                         char name[80];
555                         strcpy(name, r_name+r_info[quest[num].r_idx].name);
556 #ifdef JP
557                         fprintf(fff, " %2d:%02d %20s ¥é¥ó¥À¥à¥¯¥¨¥¹¥È(%s)¤«¤éƨ¤²½Ð¤·¤¿¡£\n", hour, min, note_level, name);
558 #else
559                         fprintf(fff, " %2d:%02d %20s ran away from quest '%s'.\n", hour, min, note_level, name);
560 #endif
561                         break;
562                 }
563                 case NIKKI_MAXDEAPTH:
564                 {
565 #ifdef JP
566                         fprintf(fff, " %2d:%02d %20s %s¤ÎºÇ¿¼³¬%d³¬¤ËÅþ㤷¤¿¡£\n", hour, min, note_level, d_name+d_info[dungeon_type].name, num);
567 #else
568                         fprintf(fff, " %2d:%02d %20s reached level %d of %s for the first time.\n", hour, min, note_level, num, d_name+d_info[dungeon_type].name);
569 #endif
570                         break;
571                 }
572                 case NIKKI_TRUMP:
573                 {
574 #ifdef JP
575                         fprintf(fff, " %2d:%02d %20s %s%s¤ÎºÇ¿¼³¬¤ò%d³¬¤Ë¥»¥Ã¥È¤·¤¿¡£\n", hour, min, note_level, note, d_name + d_info[num].name, max_dlv[num]);
576 #else
577                         fprintf(fff, " %2d:%02d %20s reset recall level of %s to %d %s.\n", hour, min, note_level, d_name + d_info[num].name, max_dlv[num], note);
578 #endif
579                         break;
580                 }
581                 case NIKKI_STAIR:
582                 {
583                         cptr to;
584                         if (q_idx && (is_fixed_quest_idx(q_idx)
585                              && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
586                         {
587 #ifdef JP
588                                 to = "ÃϾå";
589 #else
590                                 to = "the surface";
591 #endif
592                         }
593                         else
594                         {
595 #ifdef JP
596                                 if (!(dun_level+num)) to = "ÃϾå";
597                                 else to = format("%d³¬", dun_level+num);
598 #else
599                                 if (!(dun_level+num)) to = "the surface";
600                                 else to = format("level %d", dun_level+num);
601 #endif
602                         }
603
604 #ifdef JP 
605                         fprintf(fff, " %2d:%02d %20s %s¤Ø%s¡£\n", hour, min, note_level, to, note);
606 #else
607                         fprintf(fff, " %2d:%02d %20s %s %s.\n", hour, min, note_level, note, to);
608 #endif
609                         break;
610                 }
611                 case NIKKI_RECALL:
612                 {
613                         if (!num)
614 #ifdef JP
615                                 fprintf(fff, " %2d:%02d %20s µ¢´Ô¤ò»È¤Ã¤Æ%s¤Î%d³¬¤Ø²¼¤ê¤¿¡£\n", hour, min, note_level, d_name+d_info[dungeon_type].name, max_dlv[dungeon_type]);
616 #else
617                                 fprintf(fff, " %2d:%02d %20s recalled to dungeon level %d of %s.\n", hour, min, note_level, max_dlv[dungeon_type], d_name+d_info[dungeon_type].name);
618 #endif
619                         else
620 #ifdef JP
621                                 fprintf(fff, " %2d:%02d %20s µ¢´Ô¤ò»È¤Ã¤ÆÃϾå¤Ø¤ÈÌá¤Ã¤¿¡£\n", hour, min, note_level);
622 #else
623                                 fprintf(fff, " %2d:%02d %20s recalled from dungeon to surface.\n", hour, min, note_level);
624 #endif
625                         break;
626                 }
627                 case NIKKI_TO_QUEST:
628                 {
629                         if (quest[num].flags & QUEST_FLAG_SILENT) break;
630 #ifdef JP
631                         fprintf(fff, " %2d:%02d %20s ¥¯¥¨¥¹¥È¡Ö%s¡×¤Ø¤ÈÆÍÆþ¤·¤¿¡£\n", hour, min, note_level, quest[num].name);
632 #else
633                         fprintf(fff, " %2d:%02d %20s entered the quest '%s'.\n", hour, min, note_level, quest[num].name);
634 #endif
635                         break;
636                 }
637                 case NIKKI_TELE_LEV:
638                 {
639 #ifdef JP
640                         fprintf(fff, " %2d:%02d %20s ¥ì¥Ù¥ë¡¦¥Æ¥ì¥Ý¡¼¥È¤Çæ½Ð¤·¤¿¡£\n", hour, min, note_level);
641 #else
642                         fprintf(fff, " %2d:%02d %20s Got out using teleport level.\n", hour, min, note_level);
643 #endif
644                         break;
645                 }
646                 case NIKKI_BUY:
647                 {
648 #ifdef JP
649                         fprintf(fff, " %2d:%02d %20s %s¤ò¹ØÆþ¤·¤¿¡£\n", hour, min, note_level, note);
650 #else
651                         fprintf(fff, " %2d:%02d %20s bought %s.\n", hour, min, note_level, note);
652 #endif
653                         break;
654                 }
655                 case NIKKI_SELL:
656                 {
657 #ifdef JP
658                         fprintf(fff, " %2d:%02d %20s %s¤òÇäµÑ¤·¤¿¡£\n", hour, min, note_level, note);
659 #else
660                         fprintf(fff, " %2d:%02d %20s sold %s.\n", hour, min, note_level, note);
661 #endif
662                         break;
663                 }
664                 case NIKKI_ARENA:
665                 {
666                         if (num < 0)
667                         {
668 #ifdef JP
669                                 fprintf(fff, " %2d:%02d %20s Æ®µ»¾ì¤Î%d²óÀï¤Ç¡¢%s¤ÎÁ°¤ËÇÔ¤ìµî¤Ã¤¿¡£\n", hour, min, note_level, -num, note);
670 #else
671                                 int n = -num;
672                                 fprintf(fff, " %2d:%02d %20s beaten by %s in the %d%s fight.\n", hour, min, note_level, note, n, get_ordinal_number_suffix(n));
673 #endif
674                                 break;
675                         }
676 #ifdef JP
677                         fprintf(fff, " %2d:%02d %20s Æ®µ»¾ì¤Î%d²óÀï(%s)¤Ë¾¡Íø¤·¤¿¡£\n", hour, min, note_level, num, note);
678 #else
679                         fprintf(fff, " %2d:%02d %20s won the %d%s fight (%s).\n", hour, min, note_level, num, get_ordinal_number_suffix(num), note);
680 #endif
681                         if (num == MAX_ARENA_MONS)
682                         {
683 #ifdef JP
684                                 fprintf(fff, "                 Æ®µ»¾ì¤Î¤¹¤Ù¤Æ¤ÎŨ¤Ë¾¡Íø¤·¡¢¥Á¥ã¥ó¥Ô¥ª¥ó¤È¤Ê¤Ã¤¿¡£\n");
685 #else
686                                 fprintf(fff, "                 won all fight to become a Chanpion.\n");
687 #endif
688                                 do_level = FALSE;
689                         }
690                         break;
691                 }
692                 case NIKKI_HANMEI:
693                 {
694 #ifdef JP
695                         fprintf(fff, " %2d:%02d %20s %s¤ò¼±Ê̤·¤¿¡£\n", hour, min, note_level, note);
696 #else
697                         fprintf(fff, " %2d:%02d %20s identified %s.\n", hour, min, note_level, note);
698 #endif
699                         break;
700                 }
701                 case NIKKI_WIZ_TELE:
702                 {
703                         cptr to;
704                         if (!dun_level)
705 #ifdef JP
706                                 to = "ÃϾå";
707 #else
708                                 to = "the surface";
709 #endif
710                         else
711 #ifdef JP
712                                 to = format("%d³¬(%s)", dun_level, d_name+d_info[dungeon_type].name);
713 #else
714                                 to = format("level %d of %s", dun_level, d_name+d_info[dungeon_type].name);
715 #endif
716
717 #ifdef JP
718                         fprintf(fff, " %2d:%02d %20s %s¤Ø¤È¥¦¥£¥¶¡¼¥É¡¦¥Æ¥ì¥Ý¡¼¥È¤Ç°ÜÆ°¤·¤¿¡£\n", hour, min, note_level, to);
719 #else
720                         fprintf(fff, " %2d:%02d %20s wizard-teleport to %s.\n", hour, min, note_level, to);
721 #endif
722                         break;
723                 }
724                 case NIKKI_PAT_TELE:
725                 {
726                         cptr to;
727                         if (!dun_level)
728 #ifdef JP
729                                 to = "ÃϾå";
730 #else
731                                 to = "the surface";
732 #endif
733                         else
734 #ifdef JP
735                                 to = format("%d³¬(%s)", dun_level, d_name+d_info[dungeon_type].name);
736 #else
737                                 to = format("level %d of %s", dun_level, d_name+d_info[dungeon_type].name);
738 #endif
739
740 #ifdef JP
741                         fprintf(fff, " %2d:%02d %20s %s¤Ø¤È¥Ñ¥¿¡¼¥ó¤ÎÎϤǰÜÆ°¤·¤¿¡£\n", hour, min, note_level, to);
742 #else
743                         fprintf(fff, " %2d:%02d %20s used Pattern to teleport to %s.\n", hour, min, note_level, to);
744 #endif
745                         break;
746                 }
747                 case NIKKI_LEVELUP:
748                 {
749 #ifdef JP
750                         fprintf(fff, " %2d:%02d %20s ¥ì¥Ù¥ë¤¬%d¤Ë¾å¤¬¤Ã¤¿¡£\n", hour, min, note_level, num);
751 #else
752                         fprintf(fff, " %2d:%02d %20s reached player level %d.\n", hour, min, note_level, num);
753 #endif
754                         break;
755                 }
756                 case NIKKI_GAMESTART:
757                 {
758                         time_t ct = time((time_t*)0);
759                         do_level = FALSE;
760                         if (num)
761                         {
762                                 fprintf(fff, "%s %s",note, ctime(&ct));
763                         }
764                         else
765                                 fprintf(fff, " %2d:%02d %20s %s %s",hour, min, note_level, note, ctime(&ct));
766                         break;
767                 }
768                 case NIKKI_NAMED_PET:
769                 {
770                         fprintf(fff, " %2d:%02d %20s ", hour, min, note_level);
771                         switch (num)
772                         {
773                                 case RECORD_NAMED_PET_NAME:
774 #ifdef JP
775                                         fprintf(fff, "%s¤òι¤Îͧ¤Ë¤¹¤ë¤³¤È¤Ë·è¤á¤¿¡£\n", note);
776 #else
777                                         fprintf(fff, "decided to travel together with %s.\n", note);
778 #endif
779                                         break;
780                                 case RECORD_NAMED_PET_UNNAME:
781 #ifdef JP
782                                         fprintf(fff, "%s¤Î̾Á°¤ò¾Ã¤·¤¿¡£\n", note);
783 #else
784                                         fprintf(fff, "unnamed %s.\n", note);
785 #endif
786                                         break;
787                                 case RECORD_NAMED_PET_DISMISS:
788 #ifdef JP
789                                         fprintf(fff, "%s¤ò²òÊü¤·¤¿¡£\n", note);
790 #else
791                                         fprintf(fff, "dismissed %s.\n", note);
792 #endif
793                                         break;
794                                 case RECORD_NAMED_PET_DEATH:
795 #ifdef JP
796                                         fprintf(fff, "%s¤¬»à¤ó¤Ç¤·¤Þ¤Ã¤¿¡£\n", note);
797 #else
798                                         fprintf(fff, "%s died.\n", note);
799 #endif
800                                         break;
801                                 case RECORD_NAMED_PET_MOVED:
802 #ifdef JP
803                                         fprintf(fff, "%s¤ò¤ª¤¤¤ÆÊ̤ΥޥåפذÜÆ°¤·¤¿¡£\n", note);
804 #else
805                                         fprintf(fff, "moved to another map leaving %s behind.\n", note);
806 #endif
807                                         break;
808                                 case RECORD_NAMED_PET_LOST_SIGHT:
809 #ifdef JP
810                                         fprintf(fff, "%s¤È¤Ï¤°¤ì¤Æ¤·¤Þ¤Ã¤¿¡£\n", note);
811 #else
812                                         fprintf(fff, "lost sight of %s.\n", note);
813 #endif
814                                         break;
815                                 case RECORD_NAMED_PET_DESTROY:
816 #ifdef JP
817                                         fprintf(fff, "%s¤¬*Ç˲õ*¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
818 #else
819                                         fprintf(fff, "%s was made disappeared by *destruction*.\n", note);
820 #endif
821                                         break;
822                                 case RECORD_NAMED_PET_EARTHQUAKE:
823 #ifdef JP
824                                         fprintf(fff, "%s¤¬´äÀФ˲¡¤·ÄÙ¤µ¤ì¤¿¡£\n", note);
825 #else
826                                         fprintf(fff, "%s was crushed by falling rocks.\n", note);
827 #endif
828                                         break;
829                                 case RECORD_NAMED_PET_GENOCIDE:
830 #ifdef JP
831                                         fprintf(fff, "%s¤¬Ëõ»¦¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
832 #else
833                                         fprintf(fff, "%s was made disappeared by genocide.\n", note);
834 #endif
835                                         break;
836                                 case RECORD_NAMED_PET_WIZ_ZAP:
837 #ifdef JP
838                                         fprintf(fff, "%s¤¬¥Ç¥Ð¥Ã¥°¥³¥Þ¥ó¥É¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
839 #else
840                                         fprintf(fff, "%s was removed by debug command.\n", note);
841 #endif
842                                         break;
843                                 case RECORD_NAMED_PET_TELE_LEVEL:
844 #ifdef JP
845                                         fprintf(fff, "%s¤¬¥Æ¥ì¥Ý¡¼¥È¡¦¥ì¥Ù¥ë¤Ë¤è¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
846 #else
847                                         fprintf(fff, "%s was made disappeared by teleport level.\n", note);
848 #endif
849                                         break;
850                                 case RECORD_NAMED_PET_BLAST:
851 #ifdef JP
852                                         fprintf(fff, "%s¤òÇúÇˤ·¤¿¡£\n", note);
853 #else
854                                         fprintf(fff, "blasted %s.\n", note);
855 #endif
856                                         break;
857                                 case RECORD_NAMED_PET_HEAL_LEPER:
858 #ifdef JP
859                                         fprintf(fff, "%s¤Îɵ¤¤¬¼£¤ê餫¤é³°¤ì¤¿¡£\n", note);
860 #else
861                                         fprintf(fff, "%s was healed and left.\n", note);
862 #endif
863                                         break;
864                                 case RECORD_NAMED_PET_COMPACT:
865 #ifdef JP
866                                         fprintf(fff, "%s¤¬¥â¥ó¥¹¥¿¡¼¾ðÊ󰵽̤ˤè¤Ã¤Æ¾Ã¤¨µî¤Ã¤¿¡£\n", note);
867 #else
868                                         fprintf(fff, "%s was made disappeared by compacting monsters.\n", note);
869 #endif
870                                         break;
871                                 case RECORD_NAMED_PET_LOSE_PARENT:
872 #ifdef JP
873                                         fprintf(fff, "%s¤Î¾¤´­¼Ô¤¬´û¤Ë¤¤¤Ê¤¤¤¿¤á¾Ã¤¨µî¤Ã¤¿¡£\n", note);
874 #else
875                                         fprintf(fff, "%s disappeared because there does not exist summoner.\n", note);
876 #endif
877                                         break;
878                                 default:
879                                         fprintf(fff, "\n");
880                                         break;
881                         }
882                         break;
883                 }
884                 default:
885                         break;
886         }
887
888         my_fclose(fff);
889
890         if (do_level) write_level = FALSE;
891
892         return (0);
893 }
894
895
896 #define MAX_SUBTITLE (sizeof(subtitle)/sizeof(subtitle[0]))
897
898 /*!
899  * @brief Æüµ­¤Î¥¿¥¤¥È¥ëɽµ­¤ÈÆâÍƽÐÎÏ /
900  * @return ¤Ê¤·
901  */
902 static void do_cmd_disp_nikki(void)
903 {
904         char nikki_title[256];
905         char file_name[80];
906         char buf[1024];
907         char tmp[80];
908 #ifdef JP
909         static const char subtitle[][30] = {"ºÇ¶¯¤ÎÆùÂΤòµá¤á¤Æ",
910                                            "¿ÍÀ¸¤½¤ì¤Ï¤Ï¤«¤Ê¤¤",
911                                            "ÌÀÆü¤Ë¸þ¤«¤Ã¤Æ",
912                                            "꤫¤é¤Ü¤¿¤â¤Á",
913                                            "¤¢¤È¤Îº×¤ê",
914                                            "¤½¤ì¤Ï¤¤¤¤¹Í¤¨¤À",
915                                            "²¿¤È¤Ç¤â¸À¤¨",
916                                            "ÅƤˤâ³Ñ¤Ë¤â",
917                                            "¥¦¥½¤À¤±¤É",
918                                            "¤â¤Ï¤ä¤³¤ì¤Þ¤Ç",
919                                            "¤Ê¤ó¤Ç¤³¤¦¤Ê¤ë¤Î",
920                                            "¤½¤ì¤Ï̵Íý¤À",
921                                            "Åݤ¹¤Ù¤­Å¨¤Ï¥²¡û¥Ä",
922                                            "¤ó¡Á¡©Ê¹¤³¤¨¤ó¤Ê¤¡",
923                                            "¥ª¥ì¤Î̾¤ò¸À¤Ã¤Æ¤ß¤í",
924                                            "Ƭ¤¬ÊѤˤʤäÁ¤ã¤Ã¤¿",
925                                            "¸ß´¹¤·¤Þ¤»¤ó",
926                                            "¤»¤Ã¤«¤¯¤À¤«¤é",
927                                            "¤Þ¤À¤Þ¤À´Å¤¤¤Í",
928                                            "¤à¤´¤¤¤à¤´¤¹¤®¤ë",
929                                            "¤³¤ó¤Ê¤â¤ó¤¸¤ã¤Ê¤¤",
930                                            "¤À¤á¤À¤³¤ê¤ã",
931                                            "¼¡¤¤¤Ã¤Æ¤ß¤è¤¦",
932                                            "¤Á¤ç¤Ã¤È¤À¤±¤è",
933                                            "°¥¤·¤­ËÁ¸±¼Ô",
934                                            "Ìî˾¤Î²Ì¤Æ",
935                                            "̵¸ÂÃϹö",
936                                            "¿À¤Ë·ö²Þ¤òÇä¤ë¼Ô",
937                                            "̤ÃΤÎÀ¤³¦¤Ø",
938                                            "ºÇ¹â¤ÎƬǾ¤òµá¤á¤Æ"};
939 #else
940         static const char subtitle[][51] ={"Quest of The World's Toughest Body",
941                                            "Attack is the best form of defence.",
942                                            "Might is right.",
943                                            "An unexpected windfall",
944                                            "A drowning man will catch at a straw",
945                                            "Don't count your chickens before they are hatched.",
946                                            "It is no use crying over spilt milk.",
947                                            "Seeing is believing.",
948                                            "Strike the iron while it is hot.",
949                                            "I don't care what follows.",
950                                            "To dig a well to put out a house on fire.",
951                                            "Tomorrow is another day.",
952                                            "Easy come, easy go.",
953                                            "The more haste, the less speed.",
954                                            "Where there is life, there is hope.",
955                                            "There is no royal road to *WINNER*.",
956                                            "Danger past, God forgotten.",
957                                            "The best thing to do now is to run away.",
958                                            "Life is but an empty dream.",
959                                            "Dead men tell no tales.",
960                                            "A book that remains shut is but a block.",
961                                            "Misfortunes never come singly.",
962                                            "A little knowledge is a dangerous thing.",
963                                            "History repeats itself.",
964                                            "*WINNER* was not built in a day.",
965                                            "Ignorance is bliss.",
966                                            "To lose is to win?",
967                                            "No medicine can cure folly.",
968                                            "All good things come to an end.",
969                                            "M$ Empire strikes back.",
970                                            "To see is to believe",
971                                            "Time is money.",
972                                            "Quest of The World's Greatest Brain"};
973 #endif
974 #ifdef JP
975         sprintf(file_name,"playrecord-%s.txt",savefile_base);
976 #else
977         sprintf(file_name,"playrec-%s.txt",savefile_base);
978 #endif
979
980         /* Build the filename */
981         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
982
983         if (p_ptr->pclass == CLASS_WARRIOR || p_ptr->pclass == CLASS_MONK || p_ptr->pclass == CLASS_SAMURAI || p_ptr->pclass == CLASS_BERSERKER)
984                 strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-1)]);
985         else if (p_ptr->pclass == CLASS_MAGE || p_ptr->pclass == CLASS_HIGH_MAGE || p_ptr->pclass == CLASS_SORCERER)
986                 strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-1)+1]);
987         else strcpy(tmp,subtitle[randint0(MAX_SUBTITLE-2)+1]);
988
989 #ifdef JP
990         sprintf(nikki_title, "¡Ö%s%s%s¤ÎÅÁÀâ -%s-¡×",
991                 ap_ptr->title, ap_ptr->no ? "¤Î" : "", player_name, tmp);
992 #else
993         sprintf(nikki_title, "Legend of %s %s '%s'",
994                 ap_ptr->title, player_name, tmp);
995 #endif
996
997         /* Display the file contents */
998         show_file(FALSE, buf, nikki_title, -1, 0);
999 }
1000
1001 /*!
1002  * @brief Æüµ­¤ËǤ°Õ¤ÎÆâÍƤòɽµ­¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1003  * @return ¤Ê¤·
1004  */
1005 static void do_cmd_bunshou(void)
1006 {
1007         char tmp[80] = "\0";
1008         char bunshou[80] = "\0";
1009
1010 #ifdef JP
1011         if (get_string("ÆâÍÆ: ", tmp, 79))
1012 #else
1013         if (get_string("diary note: ", tmp, 79))
1014 #endif
1015         {
1016                 strcpy(bunshou, tmp);
1017
1018                 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, bunshou);
1019         }
1020 }
1021
1022 /*!
1023  * @brief ºÇ¸å¤Ë¼èÆÀ¤·¤¿¥¢¥¤¥Æ¥à¤Î¾ðÊó¤òÆüµ­¤ËÄɲ乤ë¥á¥¤¥ó¥ë¡¼¥Á¥ó /
1024  * @return ¤Ê¤·
1025  */
1026 static void do_cmd_last_get(void)
1027 {
1028         char buf[256];
1029         s32b turn_tmp;
1030
1031         if (record_o_name[0] == '\0') return;
1032
1033 #ifdef JP
1034         sprintf(buf,"%s¤ÎÆþ¼ê¤òµ­Ï¿¤·¤Þ¤¹¡£",record_o_name);
1035 #else
1036         sprintf(buf,"Do you really want to record getting %s? ",record_o_name);
1037 #endif
1038         if (!get_check(buf)) return;
1039
1040         turn_tmp = turn;
1041         turn = record_turn;
1042 #ifdef JP
1043         sprintf(buf,"%s¤ò¼ê¤ËÆþ¤ì¤¿¡£", record_o_name);
1044 #else
1045         sprintf(buf,"descover %s.", record_o_name);
1046 #endif
1047         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, buf);
1048         turn = turn_tmp;
1049 }
1050
1051 static void do_cmd_erase_nikki(void)
1052 {
1053         char file_name[80];
1054         char buf[256];
1055         FILE *fff = NULL;
1056
1057 #ifdef JP
1058         if (!get_check("ËÜÅö¤Ëµ­Ï¿¤ò¾Ãµî¤·¤Þ¤¹¤«¡©")) return;
1059 #else
1060         if (!get_check("Do you really want to delete all your record? ")) return;
1061 #endif
1062
1063 #ifdef JP
1064         sprintf(file_name,"playrecord-%s.txt",savefile_base);
1065 #else
1066         sprintf(file_name,"playrec-%s.txt",savefile_base);
1067 #endif
1068
1069         /* Build the filename */
1070         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, file_name);
1071
1072         /* Remove the file */
1073         fd_kill(buf);
1074
1075         fff = my_fopen(buf, "w");
1076         if(fff){
1077                 my_fclose(fff);
1078 #ifdef JP
1079                 msg_format("µ­Ï¿¤ò¾Ãµî¤·¤Þ¤·¤¿¡£");
1080 #else
1081                 msg_format("deleted record.");
1082 #endif
1083         }else{
1084 #ifdef JP
1085                 msg_format("%s ¤Î¾Ãµî¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡£", buf);
1086 #else
1087                 msg_format("failed to delete %s.", buf);
1088 #endif
1089         }
1090         msg_print(NULL);
1091 }
1092
1093 /*!
1094  * @brief Æüµ­¥³¥Þ¥ó¥É
1095  * @return ¤Ê¤·
1096  */
1097 void do_cmd_nikki(void)
1098 {
1099         int i;
1100
1101         /* File type is "TEXT" */
1102         FILE_TYPE(FILE_TYPE_TEXT);
1103
1104         /* Save the screen */
1105         screen_save();
1106
1107         /* Interact until done */
1108         while (1)
1109         {
1110                 /* Clear screen */
1111                 Term_clear();
1112
1113                 /* Ask for a choice */
1114 #ifdef JP
1115                 prt("[ µ­Ï¿¤ÎÀßÄê ]", 2, 0);
1116 #else
1117                 prt("[ Play Record ]", 2, 0);
1118 #endif
1119
1120
1121                 /* Give some choices */
1122 #ifdef JP
1123                 prt("(1) µ­Ï¿¤ò¸«¤ë", 4, 5);
1124                 prt("(2) Ê¸¾Ï¤òµ­Ï¿¤¹¤ë", 5, 5);
1125                 prt("(3) Ä¾Á°¤ËÆþ¼êËô¤Ï´ÕÄꤷ¤¿¤â¤Î¤òµ­Ï¿¤¹¤ë", 6, 5);
1126                 prt("(4) µ­Ï¿¤ò¾Ãµî¤¹¤ë", 7, 5);
1127
1128                 prt("(R) ¥×¥ì¥¤Æ°²è¤òµ­Ï¿¤¹¤ë/Ãæ»ß¤¹¤ë", 9, 5);
1129 #else
1130                 prt("(1) Display your record", 4, 5);
1131                 prt("(2) Add record", 5, 5);
1132                 prt("(3) Record item you last get/identify", 6, 5);
1133                 prt("(4) Delete your record", 7, 5);
1134
1135                 prt("(R) Record playing movie / or stop it", 9, 5);
1136 #endif
1137
1138
1139                 /* Prompt */
1140 #ifdef JP
1141                 prt("¥³¥Þ¥ó¥É:", 18, 0);
1142 #else
1143                 prt("Command: ", 18, 0);
1144 #endif
1145
1146
1147                 /* Prompt */
1148                 i = inkey();
1149
1150                 /* Done */
1151                 if (i == ESCAPE) break;
1152
1153                 switch (i)
1154                 {
1155                 case '1':
1156                         do_cmd_disp_nikki();
1157                         break;
1158                 case '2':
1159                         do_cmd_bunshou();
1160                         break;
1161                 case '3':
1162                         do_cmd_last_get();
1163                         break;
1164                 case '4':
1165                         do_cmd_erase_nikki();
1166                         break;
1167                 case 'r': case 'R':
1168                         screen_load();
1169                         prepare_movie_hooks();
1170                         return;
1171                 default: /* Unknown option */
1172                         bell();
1173                 }
1174
1175                 /* Flush messages */
1176                 msg_print(NULL);
1177         }
1178
1179         /* Restore the screen */
1180         screen_load();
1181 }
1182
1183 /*!
1184  * @brief ²èÌ̤òºÆÉÁ²è¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
1185  * Hack -- redraw the screen
1186  * @return ¤Ê¤·
1187  * @details
1188  * <pre>
1189  * This command performs various low level updates, clears all the "extra"
1190  * windows, does a total redraw of the main window, and requests all of the
1191  * interesting updates and redraws that I can think of.
1192  *
1193  * This command is also used to "instantiate" the results of the user
1194  * selecting various things, such as graphics mode, so it must call
1195  * the "TERM_XTRA_REACT" hook before redrawing the windows.
1196  * </pre>
1197  */
1198 void do_cmd_redraw(void)
1199 {
1200         int j;
1201
1202         term *old = Term;
1203
1204
1205         /* Hack -- react to changes */
1206         Term_xtra(TERM_XTRA_REACT, 0);
1207
1208
1209         /* Combine and Reorder the pack (later) */
1210         p_ptr->notice |= (PN_COMBINE | PN_REORDER);
1211
1212
1213         /* Update torch */
1214         p_ptr->update |= (PU_TORCH);
1215
1216         /* Update stuff */
1217         p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
1218
1219         /* Forget lite/view */
1220         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
1221
1222         /* Update lite/view */
1223         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
1224
1225         /* Update monsters */
1226         p_ptr->update |= (PU_MONSTERS);
1227
1228         /* Redraw everything */
1229         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1230
1231         /* Window stuff */
1232         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
1233
1234         /* Window stuff */
1235         p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
1236
1237         update_playtime();
1238
1239         /* Hack -- update */
1240         handle_stuff();
1241
1242         if (p_ptr->prace == RACE_ANDROID) calc_android_exp();
1243
1244
1245         /* Redraw every window */
1246         for (j = 0; j < 8; j++)
1247         {
1248                 /* Dead window */
1249                 if (!angband_term[j]) continue;
1250
1251                 /* Activate */
1252                 Term_activate(angband_term[j]);
1253
1254                 /* Redraw */
1255                 Term_redraw();
1256
1257                 /* Refresh */
1258                 Term_fresh();
1259
1260                 /* Restore */
1261                 Term_activate(old);
1262         }
1263 }
1264
1265
1266 /*!
1267  * @brief Ì¾Á°¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
1268  * Hack -- change name
1269  * @return ¤Ê¤·
1270  */
1271 void do_cmd_change_name(void)
1272 {
1273         char    c;
1274
1275         int             mode = 0;
1276
1277         char    tmp[160];
1278
1279
1280         /* Save the screen */
1281         screen_save();
1282
1283         /* Forever */
1284         while (1)
1285         {
1286                 update_playtime();
1287
1288                 /* Display the player */
1289                 display_player(mode);
1290
1291                 if (mode == 4)
1292                 {
1293                         mode = 0;
1294                         display_player(mode);
1295                 }
1296
1297                 /* Prompt */
1298 #ifdef JP
1299                 Term_putstr(2, 23, -1, TERM_WHITE,
1300                             "['c'¤Ç̾Á°Êѹ¹, 'f'¤Ç¥Õ¥¡¥¤¥ë¤Ø½ñ½Ð, 'h'¤Ç¥â¡¼¥ÉÊѹ¹, ESC¤Ç½ªÎ»]");
1301 #else
1302                 Term_putstr(2, 23, -1, TERM_WHITE,
1303                         "['c' to change name, 'f' to file, 'h' to change mode, or ESC]");
1304 #endif
1305
1306
1307                 /* Query */
1308                 c = inkey();
1309
1310                 /* Exit */
1311                 if (c == ESCAPE) break;
1312
1313                 /* Change name */
1314                 if (c == 'c')
1315                 {
1316                         get_name();
1317
1318                         /* Process the player name */
1319                         process_player_name(FALSE);
1320                 }
1321
1322                 /* File dump */
1323                 else if (c == 'f')
1324                 {
1325                         sprintf(tmp, "%s.txt", player_base);
1326 #ifdef JP
1327                         if (get_string("¥Õ¥¡¥¤¥ë̾: ", tmp, 80))
1328 #else
1329                         if (get_string("File name: ", tmp, 80))
1330 #endif
1331
1332                         {
1333                                 if (tmp[0] && (tmp[0] != ' '))
1334                                 {
1335                                         file_character(tmp);
1336                                 }
1337                         }
1338                 }
1339
1340                 /* Toggle mode */
1341                 else if (c == 'h')
1342                 {
1343                         mode++;
1344                 }
1345
1346                 /* Oops */
1347                 else
1348                 {
1349                         bell();
1350                 }
1351
1352                 /* Flush messages */
1353                 msg_print(NULL);
1354         }
1355
1356         /* Restore the screen */
1357         screen_load();
1358
1359         /* Redraw everything */
1360         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
1361
1362         handle_stuff();
1363 }
1364
1365
1366 /*!
1367  * @brief ºÇ¶áɽ¼¨¤µ¤ì¤¿¥á¥Ã¥»¡¼¥¸¤òºÆɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
1368  * Recall the most recent message
1369  * @return ¤Ê¤·
1370  */
1371 void do_cmd_message_one(void)
1372 {
1373         /* Recall one message XXX XXX XXX */
1374         prt(format("> %s", message_str(0)), 0, 0);
1375 }
1376
1377
1378 /*!
1379  * @brief ¥á¥Ã¥»¡¼¥¸¤Î¥í¥°¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
1380  * Recall the most recent message
1381  * @return ¤Ê¤·
1382  * @details
1383  * <pre>
1384  * Show previous messages to the user   -BEN-
1385  *
1386  * The screen format uses line 0 and 23 for headers and prompts,
1387  * skips line 1 and 22, and uses line 2 thru 21 for old messages.
1388  *
1389  * This command shows you which commands you are viewing, and allows
1390  * you to "search" for strings in the recall.
1391  *
1392  * Note that messages may be longer than 80 characters, but they are
1393  * displayed using "infinite" length, with a special sub-command to
1394  * "slide" the virtual display to the left or right.
1395  *
1396  * Attempt to only hilite the matching portions of the string.
1397  * </pre>
1398  */
1399 void do_cmd_messages(int num_now)
1400 {
1401         int i, n;
1402
1403         char shower_str[81];
1404         char finder_str[81];
1405         char back_str[81];
1406         cptr shower = NULL;
1407         int wid, hgt;
1408         int num_lines;
1409
1410         /* Get size */
1411         Term_get_size(&wid, &hgt);
1412
1413         /* Number of message lines in a screen */
1414         num_lines = hgt - 4;
1415
1416         /* Wipe finder */
1417         strcpy(finder_str, "");
1418
1419         /* Wipe shower */
1420         strcpy(shower_str, "");
1421
1422         /* Total messages */
1423         n = message_num();
1424
1425         /* Start on first message */
1426         i = 0;
1427
1428         /* Save the screen */
1429         screen_save();
1430
1431         /* Clear screen */
1432         Term_clear();
1433
1434         /* Process requests until done */
1435         while (1)
1436         {
1437                 int j;
1438                 int skey;
1439
1440                 /* Dump up to 20 lines of messages */
1441                 for (j = 0; (j < num_lines) && (i + j < n); j++)
1442                 {
1443                         cptr msg = message_str(i+j);
1444
1445                         /* Dump the messages, bottom to top */
1446                         c_prt((i + j < num_now ? TERM_WHITE : TERM_SLATE), msg, num_lines + 1 - j, 0);
1447
1448                         /* Hilite "shower" */
1449                         if (shower && shower[0])
1450                         {
1451                                 cptr str = msg;
1452
1453                                 /* Display matches */
1454                                 while ((str = my_strstr(str, shower)) != NULL)
1455                                 {
1456                                         int len = strlen(shower);
1457
1458                                         /* Display the match */
1459                                         Term_putstr(str-msg, num_lines + 1 - j, len, TERM_YELLOW, shower);
1460
1461                                         /* Advance */
1462                                         str += len;
1463                                 }
1464                         }
1465                 }
1466
1467                 /* Erase remaining lines */
1468                 for (; j < num_lines; j++)
1469                 {
1470                         Term_erase(0, num_lines + 1 - j, 255);
1471                 }
1472
1473                 /* Display header XXX XXX XXX */
1474 #ifdef JP
1475                 /* translation */
1476                 prt(format("°ÊÁ°¤Î¥á¥Ã¥»¡¼¥¸ %d-%d Á´Éô¤Ç(%d)",
1477                            i, i + j - 1, n), 0, 0);
1478 #else
1479                 prt(format("Message Recall (%d-%d of %d)",
1480                            i, i + j - 1, n), 0, 0);
1481 #endif
1482
1483                 /* Display prompt (not very informative) */
1484 #ifdef JP
1485                 prt("[ 'p' ¤Ç¹¹¤Ë¸Å¤¤¤â¤Î, 'n' ¤Ç¹¹¤Ë¿·¤·¤¤¤â¤Î, '/' ¤Ç¸¡º÷, ESC ¤ÇÃæÃÇ ]", hgt - 1, 0);
1486 #else
1487                 prt("[Press 'p' for older, 'n' for newer, ..., or ESCAPE]", hgt - 1, 0);
1488 #endif
1489
1490                 /* Get a command */
1491                 skey = inkey_special(TRUE);
1492
1493                 /* Exit on Escape */
1494                 if (skey == ESCAPE) break;
1495
1496                 /* Hack -- Save the old index */
1497                 j = i;
1498
1499                 switch (skey)
1500                 {
1501                 /* Hack -- handle show */
1502                 case '=':
1503                         /* Prompt */
1504 #ifdef JP
1505                         prt("¶¯Ä´: ", hgt - 1, 0);
1506 #else
1507                         prt("Show: ", hgt - 1, 0);
1508 #endif
1509
1510                         /* Get a "shower" string, or continue */
1511                         strcpy(back_str, shower_str);
1512                         if (askfor(shower_str, 80))
1513                         {
1514                                 /* Show it */
1515                                 shower = shower_str[0] ? shower_str : NULL;
1516                         }
1517                         else strcpy(shower_str, back_str);
1518
1519                         /* Okay */
1520                         continue;
1521
1522                 /* Hack -- handle find */
1523                 case '/':
1524                 case KTRL('s'):
1525                         {
1526                                 int z;
1527
1528                                 /* Prompt */
1529 #ifdef JP
1530                                 prt("¸¡º÷: ", hgt - 1, 0);
1531 #else
1532                                 prt("Find: ", hgt - 1, 0);
1533 #endif
1534
1535                                 /* Get a "finder" string, or continue */
1536                                 strcpy(back_str, finder_str);
1537                                 if (!askfor(finder_str, 80))
1538                                 {
1539                                         strcpy(finder_str, back_str);
1540                                         continue;
1541                                 }
1542                                 else if (!finder_str[0])
1543                                 {
1544                                         shower = NULL; /* Stop showing */
1545                                         continue;
1546                                 }
1547
1548                                 /* Show it */
1549                                 shower = finder_str;
1550
1551                                 /* Scan messages */
1552                                 for (z = i + 1; z < n; z++)
1553                                 {
1554                                         cptr msg = message_str(z);
1555
1556                                         /* Search for it */
1557                                         if (my_strstr(msg, finder_str))
1558                                         {
1559                                                 /* New location */
1560                                                 i = z;
1561
1562                                                 /* Done */
1563                                                 break;
1564                                         }
1565                                 }
1566                         }
1567                         break;
1568
1569                 /* Recall 1 older message */
1570                 case SKEY_TOP:
1571                         /* Go to the oldest line */
1572                         i = n - num_lines;
1573                         break;
1574
1575                 /* Recall 1 newer message */
1576                 case SKEY_BOTTOM:
1577                         /* Go to the newest line */
1578                         i = 0;
1579                         break;
1580
1581                 /* Recall 1 older message */
1582                 case '8':
1583                 case SKEY_UP:
1584                 case '\n':
1585                 case '\r':
1586                         /* Go older if legal */
1587                         i = MIN(i + 1, n - num_lines);
1588                         break;
1589
1590                 /* Recall 10 older messages */
1591                 case '+':
1592                         /* Go older if legal */
1593                         i = MIN(i + 10, n - num_lines);
1594                         break;
1595
1596                 /* Recall 20 older messages */
1597                 case 'p':
1598                 case KTRL('P'):
1599                 case ' ':
1600                 case SKEY_PGUP:
1601                         /* Go older if legal */
1602                         i = MIN(i + num_lines, n - num_lines);
1603                         break;
1604
1605                 /* Recall 20 newer messages */
1606                 case 'n':
1607                 case KTRL('N'):
1608                 case SKEY_PGDOWN:
1609                         /* Go newer (if able) */
1610                         i = MAX(0, i - num_lines);
1611                         break;
1612
1613                 /* Recall 10 newer messages */
1614                 case '-':
1615                         /* Go newer (if able) */
1616                         i = MAX(0, i - 10);
1617                         break;
1618
1619                 /* Recall 1 newer messages */
1620                 case '2':
1621                 case SKEY_DOWN:
1622                         /* Go newer (if able) */
1623                         i = MAX(0, i - 1);
1624                         break;
1625                 }
1626
1627                 /* Hack -- Error of some kind */
1628                 if (i == j) bell();
1629         }
1630
1631         /* Restore the screen */
1632         screen_load();
1633 }
1634
1635
1636
1637 /*!
1638  * ¥Á¡¼¥È¥ª¥×¥·¥ç¥ó¤ÎºÇÂç¿ô / Number of cheating options
1639  */
1640 #define CHEAT_MAX 7
1641
1642 /*!
1643  * ¥Á¡¼¤È¥ª¥×¥·¥ç¥ó¤ÎÄêµÁ¥Æ¡¼¥Ö¥ë / Cheating options
1644  */
1645 static option_type cheat_info[CHEAT_MAX] =
1646 {
1647         { &cheat_peek,          FALSE,  255,    0x01, 0x00,
1648 #ifdef JP
1649         "cheat_peek",           "¥¢¥¤¥Æ¥à¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
1650 #else
1651         "cheat_peek",           "Peek into object creation"
1652 #endif
1653         },
1654
1655         { &cheat_hear,          FALSE,  255,    0x02, 0x00,
1656 #ifdef JP
1657         "cheat_hear",           "¥â¥ó¥¹¥¿¡¼¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
1658 #else
1659         "cheat_hear",           "Peek into monster creation"
1660 #endif
1661         },
1662
1663         { &cheat_room,          FALSE,  255,    0x04, 0x00,
1664 #ifdef JP
1665         "cheat_room",           "¥À¥ó¥¸¥ç¥ó¤ÎÀ¸À®¤ò¤Î¤¾¤­¸«¤ë"
1666 #else
1667         "cheat_room",           "Peek into dungeon creation"
1668 #endif
1669         },
1670
1671         { &cheat_xtra,          FALSE,  255,    0x08, 0x00,
1672 #ifdef JP
1673         "cheat_xtra",           "¤½¤Î¾¤Î»ö¤ò¤Î¤¾¤­¸«¤ë"
1674 #else
1675         "cheat_xtra",           "Peek into something else"
1676 #endif
1677         },
1678
1679         { &cheat_know,          FALSE,  255,    0x10, 0x00,
1680 #ifdef JP
1681         "cheat_know",           "´°Á´¤Ê¥â¥ó¥¹¥¿¡¼¤Î»×¤¤½Ð¤òÃΤë"
1682 #else
1683         "cheat_know",           "Know complete monster info"
1684 #endif
1685         },
1686
1687         { &cheat_live,          FALSE,  255,    0x20, 0x00,
1688 #ifdef JP
1689         "cheat_live",           "»à¤ò²óÈò¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë"
1690 #else
1691         "cheat_live",           "Allow player to avoid death"
1692 #endif
1693         },
1694
1695         { &cheat_save,          FALSE,  255,    0x40, 0x00,
1696 #ifdef JP
1697         "cheat_save",           "»à¤ó¤À»þ¥»¡¼¥Ö¤¹¤ë¤«³Îǧ¤¹¤ë"
1698 #else
1699         "cheat_save",           "Ask for saving death"
1700 #endif
1701         }
1702 };
1703
1704 /*!
1705  * @brief ¥Á¡¼¥È¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
1706  * Interact with some options for cheating
1707  * @param info É½¼¨¥á¥Ã¥»¡¼¥¸
1708  * @return ¤Ê¤·
1709  */
1710 static void do_cmd_options_cheat(cptr info)
1711 {
1712         char    ch;
1713
1714         int             i, k = 0, n = CHEAT_MAX;
1715
1716         char    buf[80];
1717
1718
1719         /* Clear screen */
1720         Term_clear();
1721
1722         /* Interact with the player */
1723         while (TRUE)
1724         {
1725                 int dir;
1726
1727                 /* Prompt XXX XXX XXX */
1728 #ifdef JP
1729                 sprintf(buf, "%s ( ¥ê¥¿¡¼¥ó¤Ç¼¡¤Ø, y/n ¤Ç¥»¥Ã¥È, ESC ¤Ç·èÄê )", info);
1730 #else
1731                 sprintf(buf, "%s (RET to advance, y/n to set, ESC to accept) ", info);
1732 #endif
1733
1734                 prt(buf, 0, 0);
1735
1736 #ifdef JP
1737                 /* º¾µ½¥ª¥×¥·¥ç¥ó¤ò¤¦¤Ã¤«¤ê¤¤¤¸¤Ã¤Æ¤·¤Þ¤¦¿Í¤¬¤¤¤ë¤è¤¦¤Ê¤Î¤ÇÃí°Õ */
1738                 prt("                                 <<  Ãí°Õ  >>", 11, 0);
1739                 prt("      º¾µ½¥ª¥×¥·¥ç¥ó¤ò°ìÅ٤ǤâÀßÄꤹ¤ë¤È¡¢¥¹¥³¥¢µ­Ï¿¤¬»Ä¤é¤Ê¤¯¤Ê¤ê¤Þ¤¹¡ª", 12, 0);
1740                 prt("      ¸å¤Ë²ò½ü¤·¤Æ¤â¥À¥á¤Ç¤¹¤Î¤Ç¡¢¾¡Íø¼Ô¤òÌܻؤ¹Êý¤Ï¤³¤³¤Î¥ª¥×¥·¥ç¥ó¤Ï¤¤", 13, 0);
1741                 prt("      ¤¸¤é¤Ê¤¤¤è¤¦¤Ë¤·¤Æ²¼¤µ¤¤¡£", 14, 0);
1742 #endif
1743                 /* Display the options */
1744                 for (i = 0; i < n; i++)
1745                 {
1746                         byte a = TERM_WHITE;
1747
1748                         /* Color current option */
1749                         if (i == k) a = TERM_L_BLUE;
1750
1751                         /* Display the option text */
1752                         sprintf(buf, "%-48s: %s (%s)",
1753                             cheat_info[i].o_desc,
1754 #ifdef JP
1755                             (*cheat_info[i].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
1756 #else
1757                             (*cheat_info[i].o_var ? "yes" : "no "),
1758 #endif
1759
1760                             cheat_info[i].o_text);
1761                         c_prt(a, buf, i + 2, 0);
1762                 }
1763
1764                 /* Hilite current option */
1765                 move_cursor(k + 2, 50);
1766
1767                 /* Get a key */
1768                 ch = inkey();
1769
1770                 /*
1771                  * HACK - Try to translate the key into a direction
1772                  * to allow using the roguelike keys for navigation.
1773                  */
1774                 dir = get_keymap_dir(ch);
1775                 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
1776                         ch = I2D(dir);
1777
1778                 /* Analyze */
1779                 switch (ch)
1780                 {
1781                         case ESCAPE:
1782                         {
1783                                 return;
1784                         }
1785
1786                         case '-':
1787                         case '8':
1788                         {
1789                                 k = (n + k - 1) % n;
1790                                 break;
1791                         }
1792
1793                         case ' ':
1794                         case '\n':
1795                         case '\r':
1796                         case '2':
1797                         {
1798                                 k = (k + 1) % n;
1799                                 break;
1800                         }
1801
1802                         case 'y':
1803                         case 'Y':
1804                         case '6':
1805                         {
1806                                 if(!p_ptr->noscore)
1807 #ifdef JP
1808                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "º¾µ½¥ª¥×¥·¥ç¥ó¤òON¤Ë¤·¤Æ¡¢¥¹¥³¥¢¤ò»Ä¤»¤Ê¤¯¤Ê¤Ã¤¿¡£");
1809 #else
1810                                         do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up sending score to use cheating options.");
1811 #endif
1812                                 p_ptr->noscore |= (cheat_info[k].o_set * 256 + cheat_info[k].o_bit);
1813                                 (*cheat_info[k].o_var) = TRUE;
1814                                 k = (k + 1) % n;
1815                                 break;
1816                         }
1817
1818                         case 'n':
1819                         case 'N':
1820                         case '4':
1821                         {
1822                                 (*cheat_info[k].o_var) = FALSE;
1823                                 k = (k + 1) % n;
1824                                 break;
1825                         }
1826
1827                         case '?':
1828                         {
1829 #ifdef JP
1830                                 strnfmt(buf, sizeof(buf), "joption.txt#%s", cheat_info[k].o_text);
1831 #else
1832                                 strnfmt(buf, sizeof(buf), "option.txt#%s", cheat_info[k].o_text);
1833 #endif
1834                                 /* Peruse the help file */
1835                                 (void)show_file(TRUE, buf, NULL, 0, 0);
1836
1837                                 Term_clear(); 
1838                                 break;
1839                         }
1840
1841                         default:
1842                         {
1843                                 bell();
1844                                 break;
1845                         }
1846                 }
1847         }
1848 }
1849
1850
1851 /*!
1852  * ¼«Æ°¥»¡¼¥Ö¥ª¥×¥·¥ç¥ó¥Æ¡¼¥Ö¥ë
1853  */
1854 static option_type autosave_info[2] =
1855 {
1856         { &autosave_l,      FALSE, 255, 0x01, 0x00,
1857 #ifdef JP
1858             "autosave_l",    "¿·¤·¤¤³¬¤ËÆþ¤ëÅ٤˼«Æ°¥»¡¼¥Ö¤¹¤ë" },
1859 #else
1860             "autosave_l",    "Autosave when entering new levels" },
1861 #endif
1862
1863
1864         { &autosave_t,      FALSE, 255, 0x02, 0x00,
1865 #ifdef JP
1866             "autosave_t",   "°ìÄ꥿¡¼¥óËè¤Ë¼«Æ°¥»¡¼¥Ö¤¹¤ë" },
1867 #else
1868             "autosave_t",   "Timed autosave" },
1869 #endif
1870
1871 };
1872
1873 /*!
1874  * @brief ¥»¡¼¥ÖÉÑÅÙ¥¿¡¼¥ó¤Î¼¡¤ÎÃͤòÊÖ¤¹
1875  * @param current ¸½ºß¤Î¥»¡¼¥ÖÉÑÅÙ¥¿¡¼¥óÃÍ
1876  * @return ¼¡¤Î¥»¡¼¥ÖÉÑÅÙ¥¿¡¼¥óÃÍ
1877  */
1878 static s16b toggle_frequency(s16b current)
1879 {
1880         switch (current)
1881         {
1882         case 0: return 50;
1883         case 50: return 100;
1884         case 100: return 250;
1885         case 250: return 500;
1886         case 500: return 1000;
1887         case 1000: return 2500;
1888         case 2500: return 5000;
1889         case 5000: return 10000;
1890         case 10000: return 25000;
1891         default: return 0;
1892         }
1893 }
1894
1895
1896 /*!
1897  * @brief ¼«Æ°¥»¡¼¥Ö¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
1898  * @param info É½¼¨¥á¥Ã¥»¡¼¥¸
1899  * @return ¤Ê¤·
1900  */
1901 static void do_cmd_options_autosave(cptr info)
1902 {
1903         char    ch;
1904
1905         int     i, k = 0, n = 2;
1906
1907         char    buf[80];
1908
1909
1910         /* Clear screen */
1911         Term_clear();
1912
1913         /* Interact with the player */
1914         while (TRUE)
1915         {
1916                 /* Prompt XXX XXX XXX */
1917 #ifdef JP
1918                 sprintf(buf, "%s ( ¥ê¥¿¡¼¥ó¤Ç¼¡¤Ø, y/n ¤Ç¥»¥Ã¥È, F ¤ÇÉÑÅÙ¤òÆþÎÏ, ESC ¤Ç·èÄê ) ", info);
1919 #else
1920                 sprintf(buf, "%s (RET to advance, y/n to set, 'F' for frequency, ESC to accept) ", info);
1921 #endif
1922
1923                 prt(buf, 0, 0);
1924
1925                 /* Display the options */
1926                 for (i = 0; i < n; i++)
1927                 {
1928                         byte a = TERM_WHITE;
1929
1930                         /* Color current option */
1931                         if (i == k) a = TERM_L_BLUE;
1932
1933                         /* Display the option text */
1934                         sprintf(buf, "%-48s: %s (%s)",
1935                             autosave_info[i].o_desc,
1936 #ifdef JP
1937                             (*autosave_info[i].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
1938 #else
1939                             (*autosave_info[i].o_var ? "yes" : "no "),
1940 #endif
1941
1942                             autosave_info[i].o_text);
1943                         c_prt(a, buf, i + 2, 0);
1944                 }
1945
1946 #ifdef JP
1947                 prt(format("¼«Æ°¥»¡¼¥Ö¤ÎÉÑÅÙ¡§ %d ¥¿¡¼¥óËè",  autosave_freq), 5, 0);
1948 #else
1949                 prt(format("Timed autosave frequency: every %d turns",  autosave_freq), 5, 0);
1950 #endif
1951
1952
1953
1954                 /* Hilite current option */
1955                 move_cursor(k + 2, 50);
1956
1957                 /* Get a key */
1958                 ch = inkey();
1959
1960                 /* Analyze */
1961                 switch (ch)
1962                 {
1963                         case ESCAPE:
1964                         {
1965                                 return;
1966                         }
1967
1968                         case '-':
1969                         case '8':
1970                         {
1971                                 k = (n + k - 1) % n;
1972                                 break;
1973                         }
1974
1975                         case ' ':
1976                         case '\n':
1977                         case '\r':
1978                         case '2':
1979                         {
1980                                 k = (k + 1) % n;
1981                                 break;
1982                         }
1983
1984                         case 'y':
1985                         case 'Y':
1986                         case '6':
1987                         {
1988
1989                                 (*autosave_info[k].o_var) = TRUE;
1990                                 k = (k + 1) % n;
1991                                 break;
1992                         }
1993
1994                         case 'n':
1995                         case 'N':
1996                         case '4':
1997                         {
1998                                 (*autosave_info[k].o_var) = FALSE;
1999                                 k = (k + 1) % n;
2000                                 break;
2001                         }
2002
2003                         case 'f':
2004                         case 'F':
2005                         {
2006                                 autosave_freq = toggle_frequency(autosave_freq);
2007 #ifdef JP
2008                                 prt(format("¼«Æ°¥»¡¼¥Ö¤ÎÉÑÅÙ¡§ %d ¥¿¡¼¥óËè", 
2009                                            autosave_freq), 5, 0);
2010 #else
2011                                 prt(format("Timed autosave frequency: every %d turns",
2012                                            autosave_freq), 5, 0);
2013 #endif
2014                                 break;
2015                         }
2016
2017                         case '?':
2018                         {
2019 #ifdef JP
2020                                 (void)show_file(TRUE, "joption.txt#Autosave", NULL, 0, 0);
2021 #else
2022                                 (void)show_file(TRUE, "option.txt#Autosave", NULL, 0, 0);
2023 #endif
2024
2025
2026                                 Term_clear(); 
2027                                 break;
2028                         }
2029
2030                         default:
2031                         {
2032                                 bell();
2033                                 break;
2034                         }
2035                 }
2036         }
2037 }
2038
2039
2040 /*!
2041  * @brief É¸½à¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥µ¥Ö¥ë¡¼¥Á¥ó /
2042  * Interact with some options
2043  * @param page ¥ª¥×¥·¥ç¥ó¥Ú¡¼¥¸ÈÖ¹æ
2044  * @param info É½¼¨¥á¥Ã¥»¡¼¥¸
2045  * @return ¤Ê¤·
2046  */
2047 void do_cmd_options_aux(int page, cptr info)
2048 {
2049         char    ch;
2050         int     i, k = 0, n = 0, l;
2051         int     opt[24];
2052         char    buf[80];
2053         bool    browse_only = (page == OPT_PAGE_BIRTH) && character_generated &&
2054                               (!p_ptr->wizard || !allow_debug_opts);
2055
2056
2057         /* Lookup the options */
2058         for (i = 0; i < 24; i++) opt[i] = 0;
2059
2060         /* Scan the options */
2061         for (i = 0; option_info[i].o_desc; i++)
2062         {
2063                 /* Notice options on this "page" */
2064                 if (option_info[i].o_page == page) opt[n++] = i;
2065         }
2066
2067
2068         /* Clear screen */
2069         Term_clear();
2070
2071         /* Interact with the player */
2072         while (TRUE)
2073         {
2074                 int dir;
2075
2076                 /* Prompt XXX XXX XXX */
2077 #ifdef JP
2078                 sprintf(buf, "%s (¥ê¥¿¡¼¥ó:¼¡, %sESC:½ªÎ», ?:¥Ø¥ë¥×) ", info, browse_only ? "" : "y/n:Êѹ¹, ");
2079 #else
2080                 sprintf(buf, "%s (RET:next, %s, ?:help) ", info, browse_only ? "ESC:exit" : "y/n:change, ESC:accept");
2081 #endif
2082
2083                 prt(buf, 0, 0);
2084
2085
2086                 /* HACK -- description for easy-auto-destroy options */
2087 #ifdef JP
2088                 if (page == OPT_PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "°Ê²¼¤Î¥ª¥×¥·¥ç¥ó¤Ï¡¢´Ê°×¼«Æ°Ç˲õ¤ò»ÈÍѤ¹¤ë¤È¤­¤Î¤ßÍ­¸ú", 6, 6);
2089 #else
2090                 if (page == OPT_PAGE_AUTODESTROY) c_prt(TERM_YELLOW, "Following options will protect items from easy auto-destroyer.", 6, 3);
2091 #endif
2092
2093                 /* Display the options */
2094                 for (i = 0; i < n; i++)
2095                 {
2096                         byte a = TERM_WHITE;
2097
2098                         /* Color current option */
2099                         if (i == k) a = TERM_L_BLUE;
2100
2101                         /* Display the option text */
2102                         sprintf(buf, "%-48s: %s (%.19s)",
2103                                 option_info[opt[i]].o_desc,
2104 #ifdef JP
2105                                 (*option_info[opt[i]].o_var ? "¤Ï¤¤  " : "¤¤¤¤¤¨"),
2106 #else
2107                                 (*option_info[opt[i]].o_var ? "yes" : "no "),
2108 #endif
2109
2110                                 option_info[opt[i]].o_text);
2111                         if ((page == OPT_PAGE_AUTODESTROY) && i > 2) c_prt(a, buf, i + 5, 0);
2112                         else c_prt(a, buf, i + 2, 0);
2113                 }
2114
2115                 if ((page == OPT_PAGE_AUTODESTROY) && (k > 2)) l = 3;
2116                 else l = 0;
2117
2118                 /* Hilite current option */
2119                 move_cursor(k + 2 + l, 50);
2120
2121                 /* Get a key */
2122                 ch = inkey();
2123
2124                 /*
2125                  * HACK - Try to translate the key into a direction
2126                  * to allow using the roguelike keys for navigation.
2127                  */
2128                 dir = get_keymap_dir(ch);
2129                 if ((dir == 2) || (dir == 4) || (dir == 6) || (dir == 8))
2130                         ch = I2D(dir);
2131
2132                 /* Analyze */
2133                 switch (ch)
2134                 {
2135                         case ESCAPE:
2136                         {
2137                                 return;
2138                         }
2139
2140                         case '-':
2141                         case '8':
2142                         {
2143                                 k = (n + k - 1) % n;
2144                                 break;
2145                         }
2146
2147                         case ' ':
2148                         case '\n':
2149                         case '\r':
2150                         case '2':
2151                         {
2152                                 k = (k + 1) % n;
2153                                 break;
2154                         }
2155
2156                         case 'y':
2157                         case 'Y':
2158                         case '6':
2159                         {
2160                                 if (browse_only) break;
2161                                 (*option_info[opt[k]].o_var) = TRUE;
2162                                 k = (k + 1) % n;
2163                                 break;
2164                         }
2165
2166                         case 'n':
2167                         case 'N':
2168                         case '4':
2169                         {
2170                                 if (browse_only) break;
2171                                 (*option_info[opt[k]].o_var) = FALSE;
2172                                 k = (k + 1) % n;
2173                                 break;
2174                         }
2175
2176                         case 't':
2177                         case 'T':
2178                         {
2179                                 if (!browse_only) (*option_info[opt[k]].o_var) = !(*option_info[opt[k]].o_var);
2180                                 break;
2181                         }
2182
2183                         case '?':
2184                         {
2185 #ifdef JP
2186                                 strnfmt(buf, sizeof(buf), "joption.txt#%s", option_info[opt[k]].o_text);
2187 #else
2188                                 strnfmt(buf, sizeof(buf), "option.txt#%s", option_info[opt[k]].o_text);
2189 #endif
2190                                 /* Peruse the help file */
2191                                 (void)show_file(TRUE, buf, NULL, 0, 0);
2192
2193                                 Term_clear();
2194                                 break;
2195                         }
2196
2197                         default:
2198                         {
2199                                 bell();
2200                                 break;
2201                         }
2202                 }
2203         }
2204 }
2205
2206
2207 /*!
2208  * @brief ¥¦¥£¥ó¥É¥¦¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2209  * Modify the "window" options
2210  * @return ¤Ê¤·
2211  */
2212 static void do_cmd_options_win(void)
2213 {
2214         int i, j, d;
2215
2216         int y = 0;
2217         int x = 0;
2218
2219         char ch;
2220
2221         bool go = TRUE;
2222
2223         u32b old_flag[8];
2224
2225
2226         /* Memorize old flags */
2227         for (j = 0; j < 8; j++)
2228         {
2229                 /* Acquire current flags */
2230                 old_flag[j] = window_flag[j];
2231         }
2232
2233
2234         /* Clear screen */
2235         Term_clear();
2236
2237         /* Interact */
2238         while (go)
2239         {
2240                 /* Prompt XXX XXX XXX */
2241 #ifdef JP
2242                 prt("¥¦¥£¥ó¥É¥¦¡¦¥Õ¥é¥° (<Êý¸þ>¤Ç°ÜÆ°, t¤Ç¥Á¥§¥ó¥¸, y/n ¤Ç¥»¥Ã¥È, ESC)", 0, 0);
2243 #else
2244                 prt("Window Flags (<dir>, t, y, n, ESC) ", 0, 0);
2245 #endif
2246
2247
2248                 /* Display the windows */
2249                 for (j = 0; j < 8; j++)
2250                 {
2251                         byte a = TERM_WHITE;
2252
2253                         cptr s = angband_term_name[j];
2254
2255                         /* Use color */
2256                         if (j == x) a = TERM_L_BLUE;
2257
2258                         /* Window name, staggered, centered */
2259                         Term_putstr(35 + j * 5 - strlen(s) / 2, 2 + j % 2, -1, a, s);
2260                 }
2261
2262                 /* Display the options */
2263                 for (i = 0; i < 16; i++)
2264                 {
2265                         byte a = TERM_WHITE;
2266
2267                         cptr str = window_flag_desc[i];
2268
2269                         /* Use color */
2270                         if (i == y) a = TERM_L_BLUE;
2271
2272                         /* Unused option */
2273 #ifdef JP
2274                         if (!str) str = "(̤»ÈÍÑ)";
2275 #else
2276                         if (!str) str = "(Unused option)";
2277 #endif
2278
2279
2280                         /* Flag name */
2281                         Term_putstr(0, i + 5, -1, a, str);
2282
2283                         /* Display the windows */
2284                         for (j = 0; j < 8; j++)
2285                         {
2286                                 byte a = TERM_WHITE;
2287
2288                                 char c = '.';
2289
2290                                 /* Use color */
2291                                 if ((i == y) && (j == x)) a = TERM_L_BLUE;
2292
2293                                 /* Active flag */
2294                                 if (window_flag[j] & (1L << i)) c = 'X';
2295
2296                                 /* Flag value */
2297                                 Term_putch(35 + j * 5, i + 5, a, c);
2298                         }
2299                 }
2300
2301                 /* Place Cursor */
2302                 Term_gotoxy(35 + x * 5, y + 5);
2303
2304                 /* Get key */
2305                 ch = inkey();
2306
2307                 /* Analyze */
2308                 switch (ch)
2309                 {
2310                         case ESCAPE:
2311                         {
2312                                 go = FALSE;
2313                                 break;
2314                         }
2315
2316                         case 'T':
2317                         case 't':
2318                         {
2319                                 /* Clear windows */
2320                                 for (j = 0; j < 8; j++)
2321                                 {
2322                                         window_flag[j] &= ~(1L << y);
2323                                 }
2324
2325                                 /* Clear flags */
2326                                 for (i = 0; i < 16; i++)
2327                                 {
2328                                         window_flag[x] &= ~(1L << i);
2329                                 }
2330
2331                                 /* Fall through */
2332                         }
2333
2334                         case 'y':
2335                         case 'Y':
2336                         {
2337                                 /* Ignore screen */
2338                                 if (x == 0) break;
2339
2340                                 /* Set flag */
2341                                 window_flag[x] |= (1L << y);
2342                                 break;
2343                         }
2344
2345                         case 'n':
2346                         case 'N':
2347                         {
2348                                 /* Clear flag */
2349                                 window_flag[x] &= ~(1L << y);
2350                                 break;
2351                         }
2352
2353                         case '?':
2354                         {
2355 #ifdef JP
2356                                 (void)show_file(TRUE, "joption.txt#Window", NULL, 0, 0);
2357 #else
2358                                 (void)show_file(TRUE, "option.txt#Window", NULL, 0, 0);
2359 #endif
2360
2361
2362                                 Term_clear(); 
2363                                 break;
2364                         }
2365
2366                         default:
2367                         {
2368                                 d = get_keymap_dir(ch);
2369
2370                                 x = (x + ddx[d] + 8) % 8;
2371                                 y = (y + ddy[d] + 16) % 16;
2372
2373                                 if (!d) bell();
2374                         }
2375                 }
2376         }
2377
2378         /* Notice changes */
2379         for (j = 0; j < 8; j++)
2380         {
2381                 term *old = Term;
2382
2383                 /* Dead window */
2384                 if (!angband_term[j]) continue;
2385
2386                 /* Ignore non-changes */
2387                 if (window_flag[j] == old_flag[j]) continue;
2388
2389                 /* Activate */
2390                 Term_activate(angband_term[j]);
2391
2392                 /* Erase */
2393                 Term_clear();
2394
2395                 /* Refresh */
2396                 Term_fresh();
2397
2398                 /* Restore */
2399                 Term_activate(old);
2400         }
2401 }
2402
2403
2404
2405 #define OPT_NUM 15
2406
2407 static struct opts
2408 {
2409         char key;
2410         cptr name;
2411         int row;
2412 }
2413 option_fields[OPT_NUM] =
2414 {
2415 #ifdef JP
2416         { '1', "    ¥­¡¼ÆþÎÏ     ¥ª¥×¥·¥ç¥ó", 3 },
2417         { '2', "   ¥Þ¥Ã¥×²èÌÌ    ¥ª¥×¥·¥ç¥ó", 4 },
2418         { '3', "  ¥Æ¥­¥¹¥Èɽ¼¨   ¥ª¥×¥·¥ç¥ó", 5 },
2419         { '4', "  ¥²¡¼¥à¥×¥ì¥¤   ¥ª¥×¥·¥ç¥ó", 6 },
2420         { '5', "  ¹ÔÆ°Ãæ»ß´Ø·¸   ¥ª¥×¥·¥ç¥ó", 7 },
2421         { '6', "  ´Ê°×¼«Æ°Ç˲õ   ¥ª¥×¥·¥ç¥ó", 8 },
2422         { 'r', "   ¥×¥ì¥¤µ­Ï¿    ¥ª¥×¥·¥ç¥ó", 9 },
2423
2424         { 'p', "¼«Æ°½¦¤¤¥¨¥Ç¥£¥¿", 11 },
2425         { 'd', " ´ðËÜ¥¦¥§¥¤¥ÈÎÌ ", 12 },
2426         { 'h', "Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È", 13 },
2427         { 'm', "  ÄãËâÎÏ¿§ïçÃÍ  ", 14 },
2428         { 'a', "   ¼«Æ°¥»¡¼¥Ö    ¥ª¥×¥·¥ç¥ó", 15 },
2429         { 'w', "¥¦¥¤¥ó¥É¥¦¥Õ¥é¥°", 16 },
2430
2431         { 'b', "      ½é´ü       ¥ª¥×¥·¥ç¥ó (»²¾È¤Î¤ß)", 18 },
2432         { 'c', "      º¾µ½       ¥ª¥×¥·¥ç¥ó", 19 },
2433 #else
2434         { '1', "Input Options", 3 },
2435         { '2', "Map Screen Options", 4 },
2436         { '3', "Text Display Options", 5 },
2437         { '4', "Game-Play Options", 6 },
2438         { '5', "Disturbance Options", 7 },
2439         { '6', "Easy Auto-Destroyer Options", 8 },
2440         { 'r', "Play record Options", 9 },
2441
2442         { 'p', "Auto-picker/destroyer editor", 11 },
2443         { 'd', "Base Delay Factor", 12 },
2444         { 'h', "Hitpoint Warning", 13 },
2445         { 'm', "Mana Color Threshold", 14 },
2446         { 'a', "Autosave Options", 15 },
2447         { 'w', "Window Flags", 16 },
2448
2449         { 'b', "Birth Options (Browse Only)", 18 },
2450         { 'c', "Cheat Options", 19 },
2451 #endif
2452 };
2453
2454
2455 /*!
2456  * @brief É¸½à¥ª¥×¥·¥ç¥ó¤òÊѹ¹¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2457  * Set or unset various options.
2458  * @return ¤Ê¤·
2459  * @details
2460  * <pre>
2461  * The user must use the "Ctrl-R" command to "adapt" to changes
2462  * in any options which control "visual" aspects of the game.
2463  * </pre>
2464  */
2465 void do_cmd_options(void)
2466 {
2467         char k;
2468         int i, d, skey;
2469         int y = 0;
2470
2471         /* Save the screen */
2472         screen_save();
2473
2474         /* Interact */
2475         while (1)
2476         {
2477                 int n = OPT_NUM;
2478
2479                 /* Does not list cheat option when cheat option is off */
2480                 if (!p_ptr->noscore && !allow_debug_opts) n--;
2481
2482                 /* Clear screen */
2483                 Term_clear();
2484
2485                 /* Why are we here */
2486 #ifdef JP
2487                 prt("[ ¥ª¥×¥·¥ç¥ó¤ÎÀßÄê ]", 1, 0);
2488 #else
2489                 prt("TinyAngband options", 1, 0);
2490 #endif
2491
2492                 while(1)
2493                 {
2494                         /* Give some choices */
2495                         for (i = 0; i < n; i++)
2496                         {
2497                                 byte a = TERM_WHITE;
2498                                 if (i == y) a = TERM_L_BLUE;
2499                                 Term_putstr(5, option_fields[i].row, -1, a, 
2500                                         format("(%c) %s", toupper(option_fields[i].key), option_fields[i].name));
2501                         }
2502
2503 #ifdef JP
2504                         prt("<Êý¸þ>¤Ç°ÜÆ°, Enter¤Ç·èÄê, ESC¤Ç¥­¥ã¥ó¥»¥ë, ?¤Ç¥Ø¥ë¥×: ", 21, 0);
2505 #else
2506                         prt("Move to <dir>, Select to Enter, Cancel to ESC, ? to help: ", 21, 0);
2507 #endif
2508
2509                         /* Get command */
2510                         skey = inkey_special(TRUE);
2511                         if (!(skey & SKEY_MASK)) k = (char)skey;
2512                         else k = 0;
2513
2514                         /* Exit */
2515                         if (k == ESCAPE) break;
2516
2517                         if (my_strchr("\n\r ", k))
2518                         {
2519                                 k = option_fields[y].key;
2520                                 break;
2521                         }
2522
2523                         for (i = 0; i < n; i++)
2524                         {
2525                                 if (tolower(k) == option_fields[i].key) break;
2526                         }
2527
2528                         /* Command is found */
2529                         if (i < n) break;
2530
2531                         /* Hack -- browse help */
2532                         if (k == '?') break;
2533
2534                         /* Move cursor */
2535                         d = 0;
2536                         if (skey == SKEY_UP) d = 8;
2537                         if (skey == SKEY_DOWN) d = 2;
2538                         y = (y + ddy[d] + n) % n;
2539                         if (!d) bell();
2540                 }
2541
2542                 /* Exit */
2543                 if (k == ESCAPE) break;
2544
2545                 /* Analyze */
2546                 switch (k)
2547                 {
2548                         case '1':
2549                         {
2550                                 /* Process the general options */
2551 #ifdef JP
2552                                 do_cmd_options_aux(OPT_PAGE_INPUT, "¥­¡¼ÆþÎÏ¥ª¥×¥·¥ç¥ó");
2553 #else
2554                                 do_cmd_options_aux(OPT_PAGE_INPUT, "Input Options");
2555 #endif
2556                                 break;
2557                         }
2558
2559                         case '2':
2560                         {
2561                                 /* Process the general options */
2562 #ifdef JP
2563                                 do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "¥Þ¥Ã¥×²èÌÌ¥ª¥×¥·¥ç¥ó");
2564 #else
2565                                 do_cmd_options_aux(OPT_PAGE_MAPSCREEN, "Map Screen Options");
2566 #endif
2567                                 break;
2568                         }
2569
2570                         case '3':
2571                         {
2572                                 /* Spawn */
2573 #ifdef JP
2574                                 do_cmd_options_aux(OPT_PAGE_TEXT, "¥Æ¥­¥¹¥Èɽ¼¨¥ª¥×¥·¥ç¥ó");
2575 #else
2576                                 do_cmd_options_aux(OPT_PAGE_TEXT, "Text Display Options");
2577 #endif
2578                                 break;
2579                         }
2580
2581                         case '4':
2582                         {
2583                                 /* Spawn */
2584 #ifdef JP
2585                                 do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "¥²¡¼¥à¥×¥ì¥¤¡¦¥ª¥×¥·¥ç¥ó");
2586 #else
2587                                 do_cmd_options_aux(OPT_PAGE_GAMEPLAY, "Game-Play Options");
2588 #endif
2589                                 break;
2590                         }
2591
2592                         case '5':
2593                         {
2594                                 /* Spawn */
2595 #ifdef JP
2596                                 do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "¹ÔÆ°Ãæ»ß´Ø·¸¤Î¥ª¥×¥·¥ç¥ó");
2597 #else
2598                                 do_cmd_options_aux(OPT_PAGE_DISTURBANCE, "Disturbance Options");
2599 #endif
2600                                 break;
2601                         }
2602
2603                         case '6':
2604                         {
2605                                 /* Spawn */
2606 #ifdef JP
2607                                 do_cmd_options_aux(OPT_PAGE_AUTODESTROY, "´Ê°×¼«Æ°Ç˲õ¥ª¥×¥·¥ç¥ó");
2608 #else
2609                                 do_cmd_options_aux(OPT_PAGE_AUTODESTROY, "Easy Auto-Destroyer Options");
2610 #endif
2611                                 break;
2612                         }
2613
2614                         /* Play-record Options */
2615                         case 'R':
2616                         case 'r':
2617                         {
2618                                 /* Spawn */
2619 #ifdef JP
2620                                 do_cmd_options_aux(OPT_PAGE_PLAYRECORD, "¥×¥ì¥¤µ­Ï¿¥ª¥×¥·¥ç¥ó");
2621 #else
2622                                 do_cmd_options_aux(OPT_PAGE_PLAYRECORD, "Play-record Options");
2623 #endif
2624                                 break;
2625                         }
2626
2627                         /* Birth Options */
2628                         case 'B':
2629                         case 'b':
2630                         {
2631                                 /* Spawn */
2632 #ifdef JP
2633                                 do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "½é´ü¥ª¥×¥·¥ç¥ó(»²¾È¤Î¤ß)" : "½é´ü¥ª¥×¥·¥ç¥ó((*)¤Ï¥¹¥³¥¢¤Ë±Æ¶Á)");
2634 #else
2635                                 do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? "Birth Options(browse only)" : "Birth Options((*)s effect score)");
2636 #endif
2637                                 break;
2638                         }
2639
2640                         /* Cheating Options */
2641                         case 'C':
2642                         {
2643                                 if (!p_ptr->noscore && !allow_debug_opts)
2644                                 {
2645                                         /* Cheat options are not permitted */
2646                                         bell();
2647                                         break;
2648                                 }
2649
2650                                 /* Spawn */
2651 #ifdef JP
2652                                 do_cmd_options_cheat("º¾µ½»Õ¤Ï·è¤·¤Æ¾¡Íø¤Ç¤­¤Ê¤¤¡ª");
2653 #else
2654                                 do_cmd_options_cheat("Cheaters never win");
2655 #endif
2656                                 break;
2657                         }
2658
2659                         case 'a':
2660                         case 'A':
2661                         {
2662 #ifdef JP
2663                                 do_cmd_options_autosave("¼«Æ°¥»¡¼¥Ö");
2664 #else
2665                                 do_cmd_options_autosave("Autosave");
2666 #endif
2667                                 break;
2668                         }
2669
2670                         /* Window flags */
2671                         case 'W':
2672                         case 'w':
2673                         {
2674                                 /* Spawn */
2675                                 do_cmd_options_win();
2676                                 p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL |
2677                                                   PW_PLAYER | PW_MESSAGE | PW_OVERHEAD |
2678                                                         PW_MONSTER | PW_OBJECT | PW_SNAPSHOT |
2679                                                         PW_BORG_1 | PW_BORG_2 | PW_DUNGEON   |
2680                                                         PW_MONSTER_LIST);
2681                                 break;
2682                         }
2683
2684                         /* Auto-picker/destroyer editor */
2685                         case 'P':
2686                         case 'p':
2687                         {
2688                                 do_cmd_edit_autopick();
2689                                 break;
2690                         }
2691
2692                         /* Hack -- Delay Speed */
2693                         case 'D':
2694                         case 'd':
2695                         {
2696                                 /* Prompt */
2697                                 clear_from(18);
2698 #ifdef JP
2699                                 prt("¥³¥Þ¥ó¥É: ´ðËÜ¥¦¥§¥¤¥ÈÎÌ", 19, 0);
2700 #else
2701                                 prt("Command: Base Delay Factor", 19, 0);
2702 #endif
2703
2704                                 /* Get a new value */
2705                                 while (1)
2706                                 {
2707                                         int msec = delay_factor * delay_factor * delay_factor;
2708 #ifdef JP
2709                                         prt(format("¸½ºß¤Î¥¦¥§¥¤¥È: %d (%d¥ß¥êÉÃ)",
2710                                                    delay_factor, msec), 22, 0);
2711 #else
2712                                         prt(format("Current base delay factor: %d (%d msec)",
2713                                                    delay_factor, msec), 22, 0);
2714 #endif
2715
2716 #ifdef JP
2717                                         prt("¥¦¥§¥¤¥È (0-9) ESC¤Ç·èÄê: ", 20, 0);
2718 #else
2719                                         prt("Delay Factor (0-9 or ESC to accept): ", 20, 0);
2720 #endif
2721
2722                                         k = inkey();
2723                                         if (k == ESCAPE) break;
2724                                         else if (k == '?')
2725                                         {
2726 #ifdef JP
2727                                                 (void)show_file(TRUE, "joption.txt#BaseDelay", NULL, 0, 0);
2728 #else
2729                                                 (void)show_file(TRUE, "option.txt#BaseDelay", NULL, 0, 0);
2730 #endif
2731                                                 Term_clear(); 
2732                                         }
2733                                         else if (isdigit(k)) delay_factor = D2I(k);
2734                                         else bell();
2735                                 }
2736
2737                                 break;
2738                         }
2739
2740                         /* Hack -- hitpoint warning factor */
2741                         case 'H':
2742                         case 'h':
2743                         {
2744                                 /* Prompt */
2745                                 clear_from(18);
2746 #ifdef JP
2747                                 prt("¥³¥Þ¥ó¥É: Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð", 19, 0);
2748 #else
2749                                 prt("Command: Hitpoint Warning", 19, 0);
2750 #endif
2751
2752                                 /* Get a new value */
2753                                 while (1)
2754                                 {
2755 #ifdef JP
2756                                         prt(format("¸½ºß¤ÎÄã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð: %d0%%",
2757                                                    hitpoint_warn), 22, 0);
2758 #else
2759                                         prt(format("Current hitpoint warning: %d0%%",
2760                                                    hitpoint_warn), 22, 0);
2761 #endif
2762
2763 #ifdef JP
2764                                         prt("Äã¥Ò¥Ã¥È¥Ý¥¤¥ó¥È·Ù¹ð (0-9) ESC¤Ç·èÄê: ", 20, 0);
2765 #else
2766                                         prt("Hitpoint Warning (0-9 or ESC to accept): ", 20, 0);
2767 #endif
2768
2769                                         k = inkey();
2770                                         if (k == ESCAPE) break;
2771                                         else if (k == '?')
2772                                         {
2773 #ifdef JP
2774                                                 (void)show_file(TRUE, "joption.txt#Hitpoint", NULL, 0, 0);
2775 #else
2776                                                 (void)show_file(TRUE, "option.txt#Hitpoint", NULL, 0, 0);
2777 #endif
2778                                                 Term_clear(); 
2779                                         }
2780                                         else if (isdigit(k)) hitpoint_warn = D2I(k);
2781                                         else bell();
2782                                 }
2783
2784                                 break;
2785                         }
2786
2787                         /* Hack -- mana color factor */
2788                         case 'M':
2789                         case 'm':
2790                         {
2791                                 /* Prompt */
2792                                 clear_from(18);
2793 #ifdef JP
2794                                 prt("¥³¥Þ¥ó¥É: ÄãËâÎÏ¿§ïçÃÍ", 19, 0);
2795 #else
2796                                 prt("Command: Mana Color Threshold", 19, 0);
2797 #endif
2798
2799                                 /* Get a new value */
2800                                 while (1)
2801                                 {
2802 #ifdef JP
2803                                         prt(format("¸½ºß¤ÎÄãËâÎÏ¿§ïçÃÍ: %d0%%",
2804                                                    mana_warn), 22, 0);
2805 #else
2806                                         prt(format("Current mana color threshold: %d0%%",
2807                                                    mana_warn), 22, 0);
2808 #endif
2809
2810 #ifdef JP
2811                                         prt("ÄãËâÎÏïçÃÍ (0-9) ESC¤Ç·èÄê: ", 20, 0);
2812 #else
2813                                         prt("Mana color Threshold (0-9 or ESC to accept): ", 20, 0);
2814 #endif
2815
2816                                         k = inkey();
2817                                         if (k == ESCAPE) break;
2818                                         else if (k == '?')
2819                                         {
2820 #ifdef JP
2821                                                 (void)show_file(TRUE, "joption.txt#Manapoint", NULL, 0, 0);
2822 #else
2823                                                 (void)show_file(TRUE, "option.txt#Manapoint", NULL, 0, 0);
2824 #endif
2825                                                 Term_clear(); 
2826                                         }
2827                                         else if (isdigit(k)) mana_warn = D2I(k);
2828                                         else bell();
2829                                 }
2830
2831                                 break;
2832                         }
2833
2834                         case '?':
2835 #ifdef JP
2836                                 (void)show_file(TRUE, "joption.txt", NULL, 0, 0);
2837 #else
2838                                 (void)show_file(TRUE, "option.txt", NULL, 0, 0);
2839 #endif
2840                                 Term_clear(); 
2841                                 break;
2842
2843                         /* Unknown option */
2844                         default:
2845                         {
2846                                 /* Oops */
2847                                 bell();
2848                                 break;
2849                         }
2850                 }
2851
2852                 /* Flush messages */
2853                 msg_print(NULL);
2854         }
2855
2856
2857         /* Restore the screen */
2858         screen_load();
2859
2860         /* Hack - Redraw equippy chars */
2861         p_ptr->redraw |= (PR_EQUIPPY);
2862 }
2863
2864
2865
2866 /*!
2867  * @brief pref¥Õ¥¡¥¤¥ë¤òÁªÂò¤·¤Æ½èÍý¤¹¤ë /
2868  * Ask for a "user pref line" and process it
2869  * @return ¤Ê¤·
2870  * @details
2871  * XXX XXX XXX Allow absolute file names?
2872  */
2873 void do_cmd_pref(void)
2874 {
2875         char buf[80];
2876
2877         /* Default */
2878         strcpy(buf, "");
2879
2880         /* Ask for a "user pref command" */
2881 #ifdef JP
2882         if (!get_string("ÀßÄêÊѹ¹¥³¥Þ¥ó¥É: ", buf, 80)) return;
2883 #else
2884         if (!get_string("Pref: ", buf, 80)) return;
2885 #endif
2886
2887
2888         /* Process that pref command */
2889         (void)process_pref_file_command(buf);
2890 }
2891
2892 /*!
2893  * @brief ¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
2894  * @return ¤Ê¤·
2895  */
2896 void do_cmd_reload_autopick(void)
2897 {
2898 #ifdef JP
2899         if (!get_check("¼«Æ°½¦¤¤ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹¤«? ")) return;
2900 #else
2901         if (!get_check("Reload auto-pick preference file? ")) return;
2902 #endif
2903
2904         /* Load the file with messages */
2905         autopick_load_pref(TRUE);
2906 }
2907
2908 #ifdef ALLOW_MACROS
2909
2910 /*!
2911  * @brief ¥Þ¥¯¥í¾ðÊó¤òpref¥Õ¥¡¥¤¥ë¤ËÊݸ¤¹¤ë /
2912  * @param fname ¥Õ¥¡¥¤¥ë̾
2913  * @return ¤Ê¤·
2914  */
2915 static errr macro_dump(cptr fname)
2916 {
2917         static cptr mark = "Macro Dump";
2918
2919         int i;
2920
2921         char buf[1024];
2922
2923         /* Build the filename */
2924         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
2925
2926         /* File type is "TEXT" */
2927         FILE_TYPE(FILE_TYPE_TEXT);
2928
2929         /* Append to the file */
2930         if (!open_auto_dump(buf, mark)) return (-1);
2931
2932         /* Start dumping */
2933 #ifdef JP
2934         auto_dump_printf("\n# ¼«Æ°¥Þ¥¯¥í¥»¡¼¥Ö\n\n");
2935 #else
2936         auto_dump_printf("\n# Automatic macro dump\n\n");
2937 #endif
2938
2939         /* Dump them */
2940         for (i = 0; i < macro__num; i++)
2941         {
2942                 /* Extract the action */
2943                 ascii_to_text(buf, macro__act[i]);
2944
2945                 /* Dump the macro */
2946                 auto_dump_printf("A:%s\n", buf);
2947
2948                 /* Extract the action */
2949                 ascii_to_text(buf, macro__pat[i]);
2950
2951                 /* Dump normal macros */
2952                 auto_dump_printf("P:%s\n", buf);
2953
2954                 /* End the macro */
2955                 auto_dump_printf("\n");
2956         }
2957
2958         /* Close */
2959         close_auto_dump();
2960
2961         /* Success */
2962         return (0);
2963 }
2964
2965
2966 /*!
2967  * @brief ¥Þ¥¯¥í¤Î¥È¥ê¥¬¡¼¥­¡¼¤ò¼èÆÀ¤¹¤ë /
2968  * Hack -- ask for a "trigger" (see below)
2969  * @param buf ¥­¡¼É½µ­¤òÊݴɤ¹¤ë¥Ð¥Ã¥Õ¥¡
2970  * @return ¤Ê¤·
2971  * @details
2972  * <pre>
2973  * Note the complex use of the "inkey()" function from "util.c".
2974  *
2975  * Note that both "flush()" calls are extremely important.
2976  * </pre>
2977  */
2978 static void do_cmd_macro_aux(char *buf)
2979 {
2980         int i, n = 0;
2981
2982         char tmp[1024];
2983
2984
2985         /* Flush */
2986         flush();
2987
2988         /* Do not process macros */
2989         inkey_base = TRUE;
2990
2991         /* First key */
2992         i = inkey();
2993
2994         /* Read the pattern */
2995         while (i)
2996         {
2997                 /* Save the key */
2998                 buf[n++] = i;
2999
3000                 /* Do not process macros */
3001                 inkey_base = TRUE;
3002
3003                 /* Do not wait for keys */
3004                 inkey_scan = TRUE;
3005
3006                 /* Attempt to read a key */
3007                 i = inkey();
3008         }
3009
3010         /* Terminate */
3011         buf[n] = '\0';
3012
3013         /* Flush */
3014         flush();
3015
3016
3017         /* Convert the trigger */
3018         ascii_to_text(tmp, buf);
3019
3020         /* Hack -- display the trigger */
3021         Term_addstr(-1, TERM_WHITE, tmp);
3022 }
3023
3024 #endif
3025
3026 /*!
3027  * @brief ¥Þ¥¯¥í¤Î¥­¡¼É½µ­¤«¤é¥¢¥¹¥­¡¼¥³¡¼¥É¤òÆÀ¤Æ¥¿¡¼¥ß¥Ê¥ë¤Ëɽ¼¨¤¹¤ë /
3028  * Hack -- ask for a keymap "trigger" (see below)
3029  * @param buf ¥­¡¼É½µ­¤ò¼èÆÀ¤¹¤ë¥Ð¥Ã¥Õ¥¡
3030  * @return ¤Ê¤·
3031  * @details
3032  * <pre>
3033  * Note that both "flush()" calls are extremely important.  This may
3034  * no longer be true, since "util.c" is much simpler now.  XXX XXX XXX
3035  * </pre>
3036  */
3037 static void do_cmd_macro_aux_keymap(char *buf)
3038 {
3039         char tmp[1024];
3040
3041
3042         /* Flush */
3043         flush();
3044
3045
3046         /* Get a key */
3047         buf[0] = inkey();
3048         buf[1] = '\0';
3049
3050
3051         /* Convert to ascii */
3052         ascii_to_text(tmp, buf);
3053
3054         /* Hack -- display the trigger */
3055         Term_addstr(-1, TERM_WHITE, tmp);
3056
3057
3058         /* Flush */
3059         flush();
3060 }
3061
3062
3063 /*!
3064  * @brief ¥­¡¼¥Þ¥Ã¥×¤òpref¥Õ¥¡¥¤¥ë¤Ë¥À¥ó¥×¤¹¤ë /
3065  * Hack -- append all keymaps to the given file
3066  * @param fname ¥Õ¥¡¥¤¥ë¥Í¡¼¥à
3067  * @return ¥¨¥é¡¼¥³¡¼¥É
3068  * @details
3069  */
3070 static errr keymap_dump(cptr fname)
3071 {
3072         static cptr mark = "Keymap Dump";
3073         int i;
3074
3075         char key[1024];
3076         char buf[1024];
3077
3078         int mode;
3079
3080         /* Roguelike */
3081         if (rogue_like_commands)
3082         {
3083                 mode = KEYMAP_MODE_ROGUE;
3084         }
3085
3086         /* Original */
3087         else
3088         {
3089                 mode = KEYMAP_MODE_ORIG;
3090         }
3091
3092
3093         /* Build the filename */
3094         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
3095
3096         /* File type is "TEXT" */
3097         FILE_TYPE(FILE_TYPE_TEXT);
3098
3099         /* Append to the file */
3100         if (!open_auto_dump(buf, mark)) return -1;
3101
3102         /* Start dumping */
3103 #ifdef JP
3104         auto_dump_printf("\n# ¼«Æ°¥­¡¼ÇÛÃÖ¥»¡¼¥Ö\n\n");
3105 #else
3106         auto_dump_printf("\n# Automatic keymap dump\n\n");
3107 #endif
3108
3109         /* Dump them */
3110         for (i = 0; i < 256; i++)
3111         {
3112                 cptr act;
3113
3114                 /* Loop up the keymap */
3115                 act = keymap_act[mode][i];
3116
3117                 /* Skip empty keymaps */
3118                 if (!act) continue;
3119
3120                 /* Encode the key */
3121                 buf[0] = i;
3122                 buf[1] = '\0';
3123                 ascii_to_text(key, buf);
3124
3125                 /* Encode the action */
3126                 ascii_to_text(buf, act);
3127
3128                 /* Dump the macro */
3129                 auto_dump_printf("A:%s\n", buf);
3130                 auto_dump_printf("C:%d:%s\n", mode, key);
3131         }
3132
3133         /* Close */
3134         close_auto_dump();
3135
3136         /* Success */
3137         return (0);
3138 }
3139
3140
3141 /*!
3142  * @brief ¥Þ¥¯¥í¤òÀßÄꤹ¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
3143  * Interact with "macros"
3144  * @return ¤Ê¤·
3145  * @details
3146  * <pre>
3147  * Note that the macro "action" must be defined before the trigger.
3148  *
3149  * Could use some helpful instructions on this page.  XXX XXX XXX
3150  * </pre>
3151  */
3152 void do_cmd_macros(void)
3153 {
3154         int i;
3155
3156         char tmp[1024];
3157
3158         char buf[1024];
3159
3160         int mode;
3161
3162
3163         /* Roguelike */
3164         if (rogue_like_commands)
3165         {
3166                 mode = KEYMAP_MODE_ROGUE;
3167         }
3168
3169         /* Original */
3170         else
3171         {
3172                 mode = KEYMAP_MODE_ORIG;
3173         }
3174
3175         /* File type is "TEXT" */
3176         FILE_TYPE(FILE_TYPE_TEXT);
3177
3178
3179         /* Save screen */
3180         screen_save();
3181
3182
3183         /* Process requests until done */
3184         while (1)
3185         {
3186                 /* Clear screen */
3187                 Term_clear();
3188
3189                 /* Describe */
3190 #ifdef JP
3191                 prt("[ ¥Þ¥¯¥í¤ÎÀßÄê ]", 2, 0);
3192 #else
3193                 prt("Interact with Macros", 2, 0);
3194 #endif
3195
3196
3197
3198                 /* Describe that action */
3199 #ifdef JP
3200                 prt("¥Þ¥¯¥í¹ÔÆ°¤¬(¤â¤·¤¢¤ì¤Ð)²¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹:", 20, 0);
3201 #else
3202                 prt("Current action (if any) shown below:", 20, 0);
3203 #endif
3204
3205
3206                 /* Analyze the current action */
3207                 ascii_to_text(buf, macro__buf);
3208
3209                 /* Display the current action */
3210                 prt(buf, 22, 0);
3211
3212
3213                 /* Selections */
3214 #ifdef JP
3215                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
3216 #else
3217                 prt("(1) Load a user pref file", 4, 5);
3218 #endif
3219
3220 #ifdef ALLOW_MACROS
3221 #ifdef JP
3222                 prt("(2) ¥Õ¥¡¥¤¥ë¤Ë¥Þ¥¯¥í¤òÄɲÃ", 5, 5);
3223                 prt("(3) ¥Þ¥¯¥í¤Î³Îǧ", 6, 5);
3224                 prt("(4) ¥Þ¥¯¥í¤ÎºîÀ®", 7, 5);
3225                 prt("(5) ¥Þ¥¯¥í¤Îºï½ü", 8, 5);
3226                 prt("(6) ¥Õ¥¡¥¤¥ë¤Ë¥­¡¼ÇÛÃÖ¤òÄɲÃ", 9, 5);
3227                 prt("(7) ¥­¡¼ÇÛÃ֤γÎǧ", 10, 5);
3228                 prt("(8) ¥­¡¼ÇÛÃ֤κîÀ®", 11, 5);
3229                 prt("(9) ¥­¡¼ÇÛÃ֤κï½ü", 12, 5);
3230                 prt("(0) ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 13, 5);
3231 #else
3232                 prt("(2) Append macros to a file", 5, 5);
3233                 prt("(3) Query a macro", 6, 5);
3234                 prt("(4) Create a macro", 7, 5);
3235                 prt("(5) Remove a macro", 8, 5);
3236                 prt("(6) Append keymaps to a file", 9, 5);
3237                 prt("(7) Query a keymap", 10, 5);
3238                 prt("(8) Create a keymap", 11, 5);
3239                 prt("(9) Remove a keymap", 12, 5);
3240                 prt("(0) Enter a new action", 13, 5);
3241 #endif
3242
3243 #endif /* ALLOW_MACROS */
3244
3245                 /* Prompt */
3246 #ifdef JP
3247                 prt("¥³¥Þ¥ó¥É: ", 16, 0);
3248 #else
3249                 prt("Command: ", 16, 0);
3250 #endif
3251
3252
3253                 /* Get a command */
3254                 i = inkey();
3255
3256                 /* Leave */
3257                 if (i == ESCAPE) break;
3258
3259                 /* Load a 'macro' file */
3260                 else if (i == '1')
3261                 {
3262                         errr err;
3263
3264                         /* Prompt */
3265 #ifdef JP
3266                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 16, 0);
3267 #else
3268                         prt("Command: Load a user pref file", 16, 0);
3269 #endif
3270
3271
3272                         /* Prompt */
3273 #ifdef JP
3274                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3275 #else
3276                         prt("File: ", 18, 0);
3277 #endif
3278
3279
3280                         /* Default filename */
3281                         sprintf(tmp, "%s.prf", player_base);
3282
3283                         /* Ask for a file */
3284                         if (!askfor(tmp, 80)) continue;
3285
3286                         /* Process the given filename */
3287                         err = process_pref_file(tmp);
3288                         if (-2 == err)
3289                         {
3290 #ifdef JP
3291                                 msg_format("ɸ½à¤ÎÀßÄê¥Õ¥¡¥¤¥ë'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
3292 #else
3293                                 msg_format("Loaded default '%s'.", tmp);
3294 #endif
3295                         }
3296                         else if (err)
3297                         {
3298                                 /* Prompt */
3299 #ifdef JP
3300                                 msg_format("'%s'¤ÎÆɤ߹þ¤ß¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", tmp);
3301 #else
3302                                 msg_format("Failed to load '%s'!");
3303 #endif
3304                         }
3305                         else
3306                         {
3307 #ifdef JP
3308                                 msg_format("'%s'¤òÆɤ߹þ¤ß¤Þ¤·¤¿¡£", tmp);
3309 #else
3310                                 msg_format("Loaded '%s'.", tmp);
3311 #endif
3312                         }
3313                 }
3314
3315 #ifdef ALLOW_MACROS
3316
3317                 /* Save macros */
3318                 else if (i == '2')
3319                 {
3320                         /* Prompt */
3321 #ifdef JP
3322                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤ò¥Õ¥¡¥¤¥ë¤ËÄɲ乤ë", 16, 0);
3323 #else
3324                         prt("Command: Append macros to a file", 16, 0);
3325 #endif
3326
3327
3328                         /* Prompt */
3329 #ifdef JP
3330                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3331 #else
3332                         prt("File: ", 18, 0);
3333 #endif
3334
3335
3336                         /* Default filename */
3337                         sprintf(tmp, "%s.prf", player_base);
3338
3339                         /* Ask for a file */
3340                         if (!askfor(tmp, 80)) continue;
3341
3342                         /* Dump the macros */
3343                         (void)macro_dump(tmp);
3344
3345                         /* Prompt */
3346 #ifdef JP
3347                         msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
3348 #else
3349                         msg_print("Appended macros.");
3350 #endif
3351
3352                 }
3353
3354                 /* Query a macro */
3355                 else if (i == '3')
3356                 {
3357                         int k;
3358
3359                         /* Prompt */
3360 #ifdef JP
3361                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤Î³Îǧ", 16, 0);
3362 #else
3363                         prt("Command: Query a macro", 16, 0);
3364 #endif
3365
3366
3367                         /* Prompt */
3368 #ifdef JP
3369                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3370 #else
3371                         prt("Trigger: ", 18, 0);
3372 #endif
3373
3374
3375                         /* Get a macro trigger */
3376                         do_cmd_macro_aux(buf);
3377
3378                         /* Acquire action */
3379                         k = macro_find_exact(buf);
3380
3381                         /* Nothing found */
3382                         if (k < 0)
3383                         {
3384                                 /* Prompt */
3385 #ifdef JP
3386                                 msg_print("¤½¤Î¥­¡¼¤Ë¤Ï¥Þ¥¯¥í¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
3387 #else
3388                                 msg_print("Found no macro.");
3389 #endif
3390
3391                         }
3392
3393                         /* Found one */
3394                         else
3395                         {
3396                                 /* Obtain the action */
3397                                 strcpy(macro__buf, macro__act[k]);
3398
3399                                 /* Analyze the current action */
3400                                 ascii_to_text(buf, macro__buf);
3401
3402                                 /* Display the current action */
3403                                 prt(buf, 22, 0);
3404
3405                                 /* Prompt */
3406 #ifdef JP
3407                                 msg_print("¥Þ¥¯¥í¤ò³Îǧ¤·¤Þ¤·¤¿¡£");
3408 #else
3409                                 msg_print("Found a macro.");
3410 #endif
3411
3412                         }
3413                 }
3414
3415                 /* Create a macro */
3416                 else if (i == '4')
3417                 {
3418                         /* Prompt */
3419 #ifdef JP
3420                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤ÎºîÀ®", 16, 0);
3421 #else
3422                         prt("Command: Create a macro", 16, 0);
3423 #endif
3424
3425
3426                         /* Prompt */
3427 #ifdef JP
3428                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3429 #else
3430                         prt("Trigger: ", 18, 0);
3431 #endif
3432
3433
3434                         /* Get a macro trigger */
3435                         do_cmd_macro_aux(buf);
3436
3437                         /* Clear */
3438                         clear_from(20);
3439
3440                         /* Help message */
3441 #ifdef JP
3442                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3443 #else
3444                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3445 #endif
3446
3447                         /* Prompt */
3448 #ifdef JP
3449                         prt("¥Þ¥¯¥í¹ÔÆ°: ", 20, 0);
3450 #else
3451                         prt("Action: ", 20, 0);
3452 #endif
3453
3454
3455                         /* Convert to text */
3456                         ascii_to_text(tmp, macro__buf);
3457
3458                         /* Get an encoded action */
3459                         if (askfor(tmp, 80))
3460                         {
3461                                 /* Convert to ascii */
3462                                 text_to_ascii(macro__buf, tmp);
3463
3464                                 /* Link the macro */
3465                                 macro_add(buf, macro__buf);
3466
3467                                 /* Prompt */
3468 #ifdef JP
3469                                 msg_print("¥Þ¥¯¥í¤òÄɲä·¤Þ¤·¤¿¡£");
3470 #else
3471                                 msg_print("Added a macro.");
3472 #endif
3473
3474                         }
3475                 }
3476
3477                 /* Remove a macro */
3478                 else if (i == '5')
3479                 {
3480                         /* Prompt */
3481 #ifdef JP
3482                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¤Îºï½ü", 16, 0);
3483 #else
3484                         prt("Command: Remove a macro", 16, 0);
3485 #endif
3486
3487
3488                         /* Prompt */
3489 #ifdef JP
3490                         prt("¥È¥ê¥¬¡¼¥­¡¼: ", 18, 0);
3491 #else
3492                         prt("Trigger: ", 18, 0);
3493 #endif
3494
3495
3496                         /* Get a macro trigger */
3497                         do_cmd_macro_aux(buf);
3498
3499                         /* Link the macro */
3500                         macro_add(buf, buf);
3501
3502                         /* Prompt */
3503 #ifdef JP
3504                         msg_print("¥Þ¥¯¥í¤òºï½ü¤·¤Þ¤·¤¿¡£");
3505 #else
3506                         msg_print("Removed a macro.");
3507 #endif
3508
3509                 }
3510
3511                 /* Save keymaps */
3512                 else if (i == '6')
3513                 {
3514                         /* Prompt */
3515 #ifdef JP
3516                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃÖ¤ò¥Õ¥¡¥¤¥ë¤ËÄɲ乤ë", 16, 0);
3517 #else
3518                         prt("Command: Append keymaps to a file", 16, 0);
3519 #endif
3520
3521
3522                         /* Prompt */
3523 #ifdef JP
3524                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3525 #else
3526                         prt("File: ", 18, 0);
3527 #endif
3528
3529
3530                         /* Default filename */
3531                         sprintf(tmp, "%s.prf", player_base);
3532
3533                         /* Ask for a file */
3534                         if (!askfor(tmp, 80)) continue;
3535
3536                         /* Dump the macros */
3537                         (void)keymap_dump(tmp);
3538
3539                         /* Prompt */
3540 #ifdef JP
3541                         msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
3542 #else
3543                         msg_print("Appended keymaps.");
3544 #endif
3545
3546                 }
3547
3548                 /* Query a keymap */
3549                 else if (i == '7')
3550                 {
3551                         cptr act;
3552
3553                         /* Prompt */
3554 #ifdef JP
3555                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤γÎǧ", 16, 0);
3556 #else
3557                         prt("Command: Query a keymap", 16, 0);
3558 #endif
3559
3560
3561                         /* Prompt */
3562 #ifdef JP
3563                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3564 #else
3565                         prt("Keypress: ", 18, 0);
3566 #endif
3567
3568
3569                         /* Get a keymap trigger */
3570                         do_cmd_macro_aux_keymap(buf);
3571
3572                         /* Look up the keymap */
3573                         act = keymap_act[mode][(byte)(buf[0])];
3574
3575                         /* Nothing found */
3576                         if (!act)
3577                         {
3578                                 /* Prompt */
3579 #ifdef JP
3580                                 msg_print("¥­¡¼ÇÛÃÖ¤ÏÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
3581 #else
3582                                 msg_print("Found no keymap.");
3583 #endif
3584
3585                         }
3586
3587                         /* Found one */
3588                         else
3589                         {
3590                                 /* Obtain the action */
3591                                 strcpy(macro__buf, act);
3592
3593                                 /* Analyze the current action */
3594                                 ascii_to_text(buf, macro__buf);
3595
3596                                 /* Display the current action */
3597                                 prt(buf, 22, 0);
3598
3599                                 /* Prompt */
3600 #ifdef JP
3601                                 msg_print("¥­¡¼ÇÛÃÖ¤ò³Îǧ¤·¤Þ¤·¤¿¡£");
3602 #else
3603                                 msg_print("Found a keymap.");
3604 #endif
3605
3606                         }
3607                 }
3608
3609                 /* Create a keymap */
3610                 else if (i == '8')
3611                 {
3612                         /* Prompt */
3613 #ifdef JP
3614                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤κîÀ®", 16, 0);
3615 #else
3616                         prt("Command: Create a keymap", 16, 0);
3617 #endif
3618
3619
3620                         /* Prompt */
3621 #ifdef JP
3622                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3623 #else
3624                         prt("Keypress: ", 18, 0);
3625 #endif
3626
3627
3628                         /* Get a keymap trigger */
3629                         do_cmd_macro_aux_keymap(buf);
3630
3631                         /* Clear */
3632                         clear_from(20);
3633
3634                         /* Help message */
3635 #ifdef JP
3636                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3637 #else
3638                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3639 #endif
3640
3641                         /* Prompt */
3642 #ifdef JP
3643                         prt("¹ÔÆ°: ", 20, 0);
3644 #else
3645                         prt("Action: ", 20, 0);
3646 #endif
3647
3648
3649                         /* Convert to text */
3650                         ascii_to_text(tmp, macro__buf);
3651
3652                         /* Get an encoded action */
3653                         if (askfor(tmp, 80))
3654                         {
3655                                 /* Convert to ascii */
3656                                 text_to_ascii(macro__buf, tmp);
3657
3658                                 /* Free old keymap */
3659                                 string_free(keymap_act[mode][(byte)(buf[0])]);
3660
3661                                 /* Make new keymap */
3662                                 keymap_act[mode][(byte)(buf[0])] = string_make(macro__buf);
3663
3664                                 /* Prompt */
3665 #ifdef JP
3666                                 msg_print("¥­¡¼ÇÛÃÖ¤òÄɲä·¤Þ¤·¤¿¡£");
3667 #else
3668                                 msg_print("Added a keymap.");
3669 #endif
3670
3671                         }
3672                 }
3673
3674                 /* Remove a keymap */
3675                 else if (i == '9')
3676                 {
3677                         /* Prompt */
3678 #ifdef JP
3679                         prt("¥³¥Þ¥ó¥É: ¥­¡¼ÇÛÃ֤κï½ü", 16, 0);
3680 #else
3681                         prt("Command: Remove a keymap", 16, 0);
3682 #endif
3683
3684
3685                         /* Prompt */
3686 #ifdef JP
3687                         prt("²¡¤¹¥­¡¼: ", 18, 0);
3688 #else
3689                         prt("Keypress: ", 18, 0);
3690 #endif
3691
3692
3693                         /* Get a keymap trigger */
3694                         do_cmd_macro_aux_keymap(buf);
3695
3696                         /* Free old keymap */
3697                         string_free(keymap_act[mode][(byte)(buf[0])]);
3698
3699                         /* Make new keymap */
3700                         keymap_act[mode][(byte)(buf[0])] = NULL;
3701
3702                         /* Prompt */
3703 #ifdef JP
3704                         msg_print("¥­¡¼ÇÛÃÖ¤òºï½ü¤·¤Þ¤·¤¿¡£");
3705 #else
3706                         msg_print("Removed a keymap.");
3707 #endif
3708
3709                 }
3710
3711                 /* Enter a new action */
3712                 else if (i == '0')
3713                 {
3714                         /* Prompt */
3715 #ifdef JP
3716                         prt("¥³¥Þ¥ó¥É: ¥Þ¥¯¥í¹ÔÆ°¤ÎÆþÎÏ", 16, 0);
3717 #else
3718                         prt("Command: Enter a new action", 16, 0);
3719 #endif
3720
3721                         /* Clear */
3722                         clear_from(20);
3723
3724                         /* Help message */
3725 #ifdef JP
3726                         c_prt(TERM_L_RED, "¥«¡¼¥½¥ë¥­¡¼¤Îº¸±¦¤Ç¥«¡¼¥½¥ë°ÌÃÖ¤ò°ÜÆ°¡£Backspace¤«Delete¤Ç°ìʸ»úºï½ü¡£", 22, 0);
3727 #else
3728                         c_prt(TERM_L_RED, "Press Left/Right arrow keys to move cursor. Backspace/Delete to delete a char.", 22, 0);
3729 #endif
3730
3731                         /* Prompt */
3732 #ifdef JP
3733                         prt("¥Þ¥¯¥í¹ÔÆ°: ", 20, 0);
3734 #else
3735                         prt("Action: ", 20, 0);
3736 #endif
3737
3738                         /* Hack -- limit the value */
3739                         tmp[80] = '\0';
3740
3741                         /* Get an encoded action */
3742                         if (!askfor(buf, 80)) continue;
3743
3744                         /* Extract an action */
3745                         text_to_ascii(macro__buf, buf);
3746                 }
3747
3748 #endif /* ALLOW_MACROS */
3749
3750                 /* Oops */
3751                 else
3752                 {
3753                         /* Oops */
3754                         bell();
3755                 }
3756
3757                 /* Flush messages */
3758                 msg_print(NULL);
3759         }
3760
3761         /* Load screen */
3762         screen_load();
3763 }
3764
3765
3766 static cptr lighting_level_str[F_LIT_MAX] =
3767 {
3768 #ifdef JP
3769         "ɸ½à¿§",
3770         "ÌÀ¿§",
3771         "°Å¿§",
3772 #else
3773         "standard",
3774         "brightly lit",
3775         "darkened",
3776 #endif
3777 };
3778
3779
3780 static bool cmd_visuals_aux(int i, int *num, int max)
3781 {
3782         if (iscntrl(i))
3783         {
3784                 char str[10] = "";
3785                 int tmp;
3786
3787                 sprintf(str, "%d", *num);
3788
3789                 if (!get_string(format("Input new number(0-%d): ", max-1), str, 4))
3790                         return FALSE;
3791
3792                 tmp = strtol(str, NULL, 0);
3793                 if (tmp >= 0 && tmp < max)
3794                         *num = tmp;
3795         }
3796         else if (isupper(i))
3797                 *num = (*num + max - 1) % max;
3798         else
3799                 *num = (*num + 1) % max;
3800
3801         return TRUE;
3802 }
3803
3804 static void print_visuals_menu(cptr choice_msg)
3805 {
3806 #ifdef JP
3807         prt("[ ²èÌÌɽ¼¨¤ÎÀßÄê ]", 1, 0);
3808 #else
3809         prt("Interact with Visuals", 1, 0);
3810 #endif
3811
3812         /* Give some choices */
3813 #ifdef JP
3814         prt("(0) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 3, 5);
3815 #else
3816         prt("(0) Load a user pref file", 3, 5);
3817 #endif
3818
3819 #ifdef ALLOW_VISUALS
3820 #ifdef JP
3821         prt("(1) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 4, 5);
3822         prt("(2) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
3823         prt("(3) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 6, 5);
3824         prt("(4) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 7, 5);
3825         prt("(5) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 8, 5);
3826         prt("(6) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¿ôÃÍÁàºî)", 9, 5);
3827         prt("(7) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 10, 5);
3828         prt("(8) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 11, 5);
3829         prt("(9) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë (¥·¥ó¥Ü¥ë¥¨¥Ç¥£¥¿)", 12, 5);
3830 #else
3831         prt("(1) Dump monster attr/chars", 4, 5);
3832         prt("(2) Dump object attr/chars", 5, 5);
3833         prt("(3) Dump feature attr/chars", 6, 5);
3834         prt("(4) Change monster attr/chars (numeric operation)", 7, 5);
3835         prt("(5) Change object attr/chars (numeric operation)", 8, 5);
3836         prt("(6) Change feature attr/chars (numeric operation)", 9, 5);
3837         prt("(7) Change monster attr/chars (visual mode)", 10, 5);
3838         prt("(8) Change object attr/chars (visual mode)", 11, 5);
3839         prt("(9) Change feature attr/chars (visual mode)", 12, 5);
3840 #endif
3841
3842 #endif /* ALLOW_VISUALS */
3843
3844 #ifdef JP
3845         prt("(R) ²èÌÌɽ¼¨ÊýË¡¤Î½é´ü²½", 13, 5);
3846 #else
3847         prt("(R) Reset visuals", 13, 5);
3848 #endif
3849
3850         /* Prompt */
3851 #ifdef JP
3852         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg ? choice_msg : ""), 15, 0);
3853 #else
3854         prt(format("Command: %s", choice_msg ? choice_msg : ""), 15, 0);
3855 #endif
3856 }
3857
3858 static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int direct_r_idx);
3859 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int direct_k_idx);
3860 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int direct_f_idx, int *lighting_level);
3861
3862 /*
3863  * Interact with "visuals"
3864  */
3865 void do_cmd_visuals(void)
3866 {
3867         int i;
3868         char tmp[160];
3869         char buf[1024];
3870         bool need_redraw = FALSE;
3871         const char *empty_symbol = "<< ? >>";
3872
3873         if (use_bigtile) empty_symbol = "<< ?? >>";
3874
3875         /* File type is "TEXT" */
3876         FILE_TYPE(FILE_TYPE_TEXT);
3877
3878         /* Save the screen */
3879         screen_save();
3880
3881         /* Interact until done */
3882         while (1)
3883         {
3884                 /* Clear screen */
3885                 Term_clear();
3886
3887                 /* Ask for a choice */
3888                 print_visuals_menu(NULL);
3889
3890                 /* Prompt */
3891                 i = inkey();
3892
3893                 /* Done */
3894                 if (i == ESCAPE) break;
3895
3896                 switch (i)
3897                 {
3898                 /* Load a 'pref' file */
3899                 case '0':
3900                         /* Prompt */
3901 #ifdef JP
3902                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 15, 0);
3903 #else
3904                         prt("Command: Load a user pref file", 15, 0);
3905 #endif
3906
3907                         /* Prompt */
3908 #ifdef JP
3909                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3910 #else
3911                         prt("File: ", 17, 0);
3912 #endif
3913
3914                         /* Default filename */
3915                         sprintf(tmp, "%s.prf", player_base);
3916
3917                         /* Query */
3918                         if (!askfor(tmp, 70)) continue;
3919
3920                         /* Process the given filename */
3921                         (void)process_pref_file(tmp);
3922
3923                         need_redraw = TRUE;
3924                         break;
3925
3926 #ifdef ALLOW_VISUALS
3927
3928                 /* Dump monster attr/chars */
3929                 case '1':
3930                 {
3931                         static cptr mark = "Monster attr/chars";
3932
3933                         /* Prompt */
3934 #ifdef JP
3935                         prt("¥³¥Þ¥ó¥É: ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3936 #else
3937                         prt("Command: Dump monster attr/chars", 15, 0);
3938 #endif
3939
3940                         /* Prompt */
3941 #ifdef JP
3942                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3943 #else
3944                         prt("File: ", 17, 0);
3945 #endif
3946
3947                         /* Default filename */
3948                         sprintf(tmp, "%s.prf", player_base);
3949
3950                         /* Get a filename */
3951                         if (!askfor(tmp, 70)) continue;
3952
3953                         /* Build the filename */
3954                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3955
3956                         /* Append to the file */
3957                         if (!open_auto_dump(buf, mark)) continue;
3958
3959                         /* Start dumping */
3960 #ifdef JP
3961                         auto_dump_printf("\n# ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3962 #else
3963                         auto_dump_printf("\n# Monster attr/char definitions\n\n");
3964 #endif
3965
3966                         /* Dump monsters */
3967                         for (i = 0; i < max_r_idx; i++)
3968                         {
3969                                 monster_race *r_ptr = &r_info[i];
3970
3971                                 /* Skip non-entries */
3972                                 if (!r_ptr->name) continue;
3973
3974                                 /* Dump a comment */
3975                                 auto_dump_printf("# %s\n", (r_name + r_ptr->name));
3976
3977                                 /* Dump the monster attr/char info */
3978                                 auto_dump_printf("R:%d:0x%02X/0x%02X\n\n", i,
3979                                         (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char));
3980                         }
3981
3982                         /* Close */
3983                         close_auto_dump();
3984
3985                         /* Message */
3986 #ifdef JP
3987                         msg_print("¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3988 #else
3989                         msg_print("Dumped monster attr/chars.");
3990 #endif
3991
3992                         break;
3993                 }
3994
3995                 /* Dump object attr/chars */
3996                 case '2':
3997                 {
3998                         static cptr mark = "Object attr/chars";
3999
4000                         /* Prompt */
4001 #ifdef JP
4002                         prt("¥³¥Þ¥ó¥É: ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
4003 #else
4004                         prt("Command: Dump object attr/chars", 15, 0);
4005 #endif
4006
4007                         /* Prompt */
4008 #ifdef JP
4009                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
4010 #else
4011                         prt("File: ", 17, 0);
4012 #endif
4013
4014                         /* Default filename */
4015                         sprintf(tmp, "%s.prf", player_base);
4016
4017                         /* Get a filename */
4018                         if (!askfor(tmp, 70)) continue;
4019
4020                         /* Build the filename */
4021                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4022
4023                         /* Append to the file */
4024                         if (!open_auto_dump(buf, mark)) continue;
4025
4026                         /* Start dumping */
4027 #ifdef JP
4028                         auto_dump_printf("\n# ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
4029 #else
4030                         auto_dump_printf("\n# Object attr/char definitions\n\n");
4031 #endif
4032
4033                         /* Dump objects */
4034                         for (i = 0; i < max_k_idx; i++)
4035                         {
4036                                 char o_name[80];
4037                                 object_kind *k_ptr = &k_info[i];
4038
4039                                 /* Skip non-entries */
4040                                 if (!k_ptr->name) continue;
4041
4042                                 if (!k_ptr->flavor)
4043                                 {
4044                                         /* Tidy name */
4045                                         strip_name(o_name, i);
4046                                 }
4047                                 else
4048                                 {
4049                                         object_type forge;
4050
4051                                         /* Prepare dummy object */
4052                                         object_prep(&forge, i);
4053
4054                                         /* Get un-shuffled flavor name */
4055                                         object_desc(o_name, &forge, OD_FORCE_FLAVOR);
4056                                 }
4057
4058                                 /* Dump a comment */
4059                                 auto_dump_printf("# %s\n", o_name);
4060
4061                                 /* Dump the object attr/char info */
4062                                 auto_dump_printf("K:%d:0x%02X/0x%02X\n\n", i,
4063                                         (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char));
4064                         }
4065
4066                         /* Close */
4067                         close_auto_dump();
4068
4069                         /* Message */
4070 #ifdef JP
4071                         msg_print("¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4072 #else
4073                         msg_print("Dumped object attr/chars.");
4074 #endif
4075
4076                         break;
4077                 }
4078
4079                 /* Dump feature attr/chars */
4080                 case '3':
4081                 {
4082                         static cptr mark = "Feature attr/chars";
4083
4084                         /* Prompt */
4085 #ifdef JP
4086                         prt("¥³¥Þ¥ó¥É: ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
4087 #else
4088                         prt("Command: Dump feature attr/chars", 15, 0);
4089 #endif
4090
4091                         /* Prompt */
4092 #ifdef JP
4093                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
4094 #else
4095                         prt("File: ", 17, 0);
4096 #endif
4097
4098                         /* Default filename */
4099                         sprintf(tmp, "%s.prf", player_base);
4100
4101                         /* Get a filename */
4102                         if (!askfor(tmp, 70)) continue;
4103
4104                         /* Build the filename */
4105                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4106
4107                         /* Append to the file */
4108                         if (!open_auto_dump(buf, mark)) continue;
4109
4110                         /* Start dumping */
4111 #ifdef JP
4112                         auto_dump_printf("\n# ÃÏ·Á¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
4113 #else
4114                         auto_dump_printf("\n# Feature attr/char definitions\n\n");
4115 #endif
4116
4117                         /* Dump features */
4118                         for (i = 0; i < max_f_idx; i++)
4119                         {
4120                                 feature_type *f_ptr = &f_info[i];
4121
4122                                 /* Skip non-entries */
4123                                 if (!f_ptr->name) continue;
4124
4125                                 /* Skip mimiccing features */
4126                                 if (f_ptr->mimic != i) continue;
4127
4128                                 /* Dump a comment */
4129                                 auto_dump_printf("# %s\n", (f_name + f_ptr->name));
4130
4131                                 /* Dump the feature attr/char info */
4132                                 auto_dump_printf("F:%d:0x%02X/0x%02X:0x%02X/0x%02X:0x%02X/0x%02X\n\n", i,
4133                                         (byte)(f_ptr->x_attr[F_LIT_STANDARD]), (byte)(f_ptr->x_char[F_LIT_STANDARD]),
4134                                         (byte)(f_ptr->x_attr[F_LIT_LITE]), (byte)(f_ptr->x_char[F_LIT_LITE]),
4135                                         (byte)(f_ptr->x_attr[F_LIT_DARK]), (byte)(f_ptr->x_char[F_LIT_DARK]));
4136                         }
4137
4138                         /* Close */
4139                         close_auto_dump();
4140
4141                         /* Message */
4142 #ifdef JP
4143                         msg_print("ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4144 #else
4145                         msg_print("Dumped feature attr/chars.");
4146 #endif
4147
4148                         break;
4149                 }
4150
4151                 /* Modify monster attr/chars (numeric operation) */
4152                 case '4':
4153                 {
4154 #ifdef JP
4155                         static cptr choice_msg = "¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4156 #else
4157                         static cptr choice_msg = "Change monster attr/chars";
4158 #endif
4159                         static int r = 0;
4160
4161 #ifdef JP
4162                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4163 #else
4164                         prt(format("Command: %s", choice_msg), 15, 0);
4165 #endif
4166
4167                         /* Hack -- query until done */
4168                         while (1)
4169                         {
4170                                 monster_race *r_ptr = &r_info[r];
4171                                 char c;
4172                                 int t;
4173
4174                                 byte da = r_ptr->d_attr;
4175                                 byte dc = r_ptr->d_char;
4176                                 byte ca = r_ptr->x_attr;
4177                                 byte cc = r_ptr->x_char;
4178
4179                                 /* Label the object */
4180 #ifdef JP
4181                                 Term_putstr(5, 17, -1, TERM_WHITE,
4182                                             format("¥â¥ó¥¹¥¿¡¼ = %d, Ì¾Á° = %-40.40s",
4183                                                    r, (r_name + r_ptr->name)));
4184 #else
4185                                 Term_putstr(5, 17, -1, TERM_WHITE,
4186                                             format("Monster = %d, Name = %-40.40s",
4187                                                    r, (r_name + r_ptr->name)));
4188 #endif
4189
4190                                 /* Label the Default values */
4191 #ifdef JP
4192                                 Term_putstr(10, 19, -1, TERM_WHITE,
4193                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3u / %3u", da, dc));
4194 #else
4195                                 Term_putstr(10, 19, -1, TERM_WHITE,
4196                                             format("Default attr/char = %3u / %3u", da, dc));
4197 #endif
4198
4199                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4200                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4201
4202                                 /* Label the Current values */
4203 #ifdef JP
4204                                 Term_putstr(10, 20, -1, TERM_WHITE,
4205                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3u / %3u", ca, cc));
4206 #else
4207                                 Term_putstr(10, 20, -1, TERM_WHITE,
4208                                             format("Current attr/char = %3u / %3u", ca, cc));
4209 #endif
4210
4211                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4212                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4213
4214                                 /* Prompt */
4215 #ifdef JP
4216                                 Term_putstr(0, 22, -1, TERM_WHITE,
4217                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4218 #else
4219                                 Term_putstr(0, 22, -1, TERM_WHITE,
4220                                             "Command (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4221 #endif
4222
4223                                 /* Get a command */
4224                                 i = inkey();
4225
4226                                 /* All done */
4227                                 if (i == ESCAPE) break;
4228
4229                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4230                                 else if (isupper(i)) c = 'a' + i - 'A';
4231                                 else c = i;
4232
4233                                 switch (c)
4234                                 {
4235                                 case 'n':
4236                                         {
4237                                                 int prev_r = r;
4238                                                 do
4239                                                 {
4240                                                         if (!cmd_visuals_aux(i, &r, max_r_idx))
4241                                                         {
4242                                                                 r = prev_r;
4243                                                                 break;
4244                                                         }
4245                                                 }
4246                                                 while (!r_info[r].name);
4247                                         }
4248                                         break;
4249                                 case 'a':
4250                                         t = (int)r_ptr->x_attr;
4251                                         (void)cmd_visuals_aux(i, &t, 256);
4252                                         r_ptr->x_attr = (byte)t;
4253                                         need_redraw = TRUE;
4254                                         break;
4255                                 case 'c':
4256                                         t = (int)r_ptr->x_char;
4257                                         (void)cmd_visuals_aux(i, &t, 256);
4258                                         r_ptr->x_char = (byte)t;
4259                                         need_redraw = TRUE;
4260                                         break;
4261                                 case 'v':
4262                                         do_cmd_knowledge_monsters(&need_redraw, TRUE, r);
4263
4264                                         /* Clear screen */
4265                                         Term_clear();
4266                                         print_visuals_menu(choice_msg);
4267                                         break;
4268                                 }
4269                         }
4270
4271                         break;
4272                 }
4273
4274                 /* Modify object attr/chars (numeric operation) */
4275                 case '5':
4276                 {
4277 #ifdef JP
4278                         static cptr choice_msg = "¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4279 #else
4280                         static cptr choice_msg = "Change object attr/chars";
4281 #endif
4282                         static int k = 0;
4283
4284 #ifdef JP
4285                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4286 #else
4287                         prt(format("Command: %s", choice_msg), 15, 0);
4288 #endif
4289
4290                         /* Hack -- query until done */
4291                         while (1)
4292                         {
4293                                 object_kind *k_ptr = &k_info[k];
4294                                 char c;
4295                                 int t;
4296
4297                                 byte da = k_ptr->d_attr;
4298                                 byte dc = k_ptr->d_char;
4299                                 byte ca = k_ptr->x_attr;
4300                                 byte cc = k_ptr->x_char;
4301
4302                                 /* Label the object */
4303 #ifdef JP
4304                                 Term_putstr(5, 17, -1, TERM_WHITE,
4305                                             format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
4306                                                    k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
4307 #else
4308                                 Term_putstr(5, 17, -1, TERM_WHITE,
4309                                             format("Object = %d, Name = %-40.40s",
4310                                                    k, k_name + (!k_ptr->flavor ? k_ptr->name : k_ptr->flavor_name)));
4311 #endif
4312
4313                                 /* Label the Default values */
4314 #ifdef JP
4315                                 Term_putstr(10, 19, -1, TERM_WHITE,
4316                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4317 #else
4318                                 Term_putstr(10, 19, -1, TERM_WHITE,
4319                                             format("Default attr/char = %3d / %3d", da, dc));
4320 #endif
4321
4322                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4323                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4324
4325                                 /* Label the Current values */
4326 #ifdef JP
4327                                 Term_putstr(10, 20, -1, TERM_WHITE,
4328                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4329 #else
4330                                 Term_putstr(10, 20, -1, TERM_WHITE,
4331                                             format("Current attr/char = %3d / %3d", ca, cc));
4332 #endif
4333
4334                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4335                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4336
4337                                 /* Prompt */
4338 #ifdef JP
4339                                 Term_putstr(0, 22, -1, TERM_WHITE,
4340                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4341 #else
4342                                 Term_putstr(0, 22, -1, TERM_WHITE,
4343                                             "Command (n/N/^N/a/A/^A/c/C/^C/v/V/^V): ");
4344 #endif
4345
4346                                 /* Get a command */
4347                                 i = inkey();
4348
4349                                 /* All done */
4350                                 if (i == ESCAPE) break;
4351
4352                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4353                                 else if (isupper(i)) c = 'a' + i - 'A';
4354                                 else c = i;
4355
4356                                 switch (c)
4357                                 {
4358                                 case 'n':
4359                                         {
4360                                                 int prev_k = k;
4361                                                 do
4362                                                 {
4363                                                         if (!cmd_visuals_aux(i, &k, max_k_idx))
4364                                                         {
4365                                                                 k = prev_k;
4366                                                                 break;
4367                                                         }
4368                                                 }
4369                                                 while (!k_info[k].name);
4370                                         }
4371                                         break;
4372                                 case 'a':
4373                                         t = (int)k_ptr->x_attr;
4374                                         (void)cmd_visuals_aux(i, &t, 256);
4375                                         k_ptr->x_attr = (byte)t;
4376                                         need_redraw = TRUE;
4377                                         break;
4378                                 case 'c':
4379                                         t = (int)k_ptr->x_char;
4380                                         (void)cmd_visuals_aux(i, &t, 256);
4381                                         k_ptr->x_char = (byte)t;
4382                                         need_redraw = TRUE;
4383                                         break;
4384                                 case 'v':
4385                                         do_cmd_knowledge_objects(&need_redraw, TRUE, k);
4386
4387                                         /* Clear screen */
4388                                         Term_clear();
4389                                         print_visuals_menu(choice_msg);
4390                                         break;
4391                                 }
4392                         }
4393
4394                         break;
4395                 }
4396
4397                 /* Modify feature attr/chars (numeric operation) */
4398                 case '6':
4399                 {
4400 #ifdef JP
4401                         static cptr choice_msg = "ÃÏ·Á¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹";
4402 #else
4403                         static cptr choice_msg = "Change feature attr/chars";
4404 #endif
4405                         static int f = 0;
4406                         static int lighting_level = F_LIT_STANDARD;
4407
4408 #ifdef JP
4409                         prt(format("¥³¥Þ¥ó¥É: %s", choice_msg), 15, 0);
4410 #else
4411                         prt(format("Command: %s", choice_msg), 15, 0);
4412 #endif
4413
4414                         /* Hack -- query until done */
4415                         while (1)
4416                         {
4417                                 feature_type *f_ptr = &f_info[f];
4418                                 char c;
4419                                 int t;
4420
4421                                 byte da = f_ptr->d_attr[lighting_level];
4422                                 byte dc = f_ptr->d_char[lighting_level];
4423                                 byte ca = f_ptr->x_attr[lighting_level];
4424                                 byte cc = f_ptr->x_char[lighting_level];
4425
4426                                 /* Label the object */
4427                                 prt("", 17, 5);
4428 #ifdef JP
4429                                 Term_putstr(5, 17, -1, TERM_WHITE,
4430                                             format("ÃÏ·Á = %d, Ì¾Á° = %s, ÌÀÅÙ = %s",
4431                                                    f, (f_name + f_ptr->name), lighting_level_str[lighting_level]));
4432 #else
4433                                 Term_putstr(5, 17, -1, TERM_WHITE,
4434                                             format("Terrain = %d, Name = %s, Lighting = %s",
4435                                                    f, (f_name + f_ptr->name), lighting_level_str[lighting_level]));
4436 #endif
4437
4438                                 /* Label the Default values */
4439 #ifdef JP
4440                                 Term_putstr(10, 19, -1, TERM_WHITE,
4441                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4442 #else
4443                                 Term_putstr(10, 19, -1, TERM_WHITE,
4444                                             format("Default attr/char = %3d / %3d", da, dc));
4445 #endif
4446
4447                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4448
4449                                 Term_queue_bigchar(43, 19, da, dc, 0, 0);
4450
4451                                 /* Label the Current values */
4452 #ifdef JP
4453                                 Term_putstr(10, 20, -1, TERM_WHITE,
4454                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4455 #else
4456                                 Term_putstr(10, 20, -1, TERM_WHITE,
4457                                             format("Current attr/char = %3d / %3d", ca, cc));
4458 #endif
4459
4460                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4461                                 Term_queue_bigchar(43, 20, ca, cc, 0, 0);
4462
4463                                 /* Prompt */
4464 #ifdef JP
4465                                 Term_putstr(0, 22, -1, TERM_WHITE,
4466                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C/l/L/^L/d/D/^D/v/V/^V): ");
4467 #else
4468                                 Term_putstr(0, 22, -1, TERM_WHITE,
4469                                             "Command (n/N/^N/a/A/^A/c/C/^C/l/L/^L/d/D/^D/v/V/^V): ");
4470 #endif
4471
4472                                 /* Get a command */
4473                                 i = inkey();
4474
4475                                 /* All done */
4476                                 if (i == ESCAPE) break;
4477
4478                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4479                                 else if (isupper(i)) c = 'a' + i - 'A';
4480                                 else c = i;
4481
4482                                 switch (c)
4483                                 {
4484                                 case 'n':
4485                                         {
4486                                                 int prev_f = f;
4487                                                 do
4488                                                 {
4489                                                         if (!cmd_visuals_aux(i, &f, max_f_idx))
4490                                                         {
4491                                                                 f = prev_f;
4492                                                                 break;
4493                                                         }
4494                                                 }
4495                                                 while (!f_info[f].name || (f_info[f].mimic != f));
4496                                         }
4497                                         break;
4498                                 case 'a':
4499                                         t = (int)f_ptr->x_attr[lighting_level];
4500                                         (void)cmd_visuals_aux(i, &t, 256);
4501                                         f_ptr->x_attr[lighting_level] = (byte)t;
4502                                         need_redraw = TRUE;
4503                                         break;
4504                                 case 'c':
4505                                         t = (int)f_ptr->x_char[lighting_level];
4506                                         (void)cmd_visuals_aux(i, &t, 256);
4507                                         f_ptr->x_char[lighting_level] = (byte)t;
4508                                         need_redraw = TRUE;
4509                                         break;
4510                                 case 'l':
4511                                         (void)cmd_visuals_aux(i, &lighting_level, F_LIT_MAX);
4512                                         break;
4513                                 case 'd':
4514                                         apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
4515                                         need_redraw = TRUE;
4516                                         break;
4517                                 case 'v':
4518                                         do_cmd_knowledge_features(&need_redraw, TRUE, f, &lighting_level);
4519
4520                                         /* Clear screen */
4521                                         Term_clear();
4522                                         print_visuals_menu(choice_msg);
4523                                         break;
4524                                 }
4525                         }
4526
4527                         break;
4528                 }
4529
4530                 /* Modify monster attr/chars (visual mode) */
4531                 case '7':
4532                         do_cmd_knowledge_monsters(&need_redraw, TRUE, -1);
4533                         break;
4534
4535                 /* Modify object attr/chars (visual mode) */
4536                 case '8':
4537                         do_cmd_knowledge_objects(&need_redraw, TRUE, -1);
4538                         break;
4539
4540                 /* Modify feature attr/chars (visual mode) */
4541                 case '9':
4542                 {
4543                         int lighting_level = F_LIT_STANDARD;
4544                         do_cmd_knowledge_features(&need_redraw, TRUE, -1, &lighting_level);
4545                         break;
4546                 }
4547
4548 #endif /* ALLOW_VISUALS */
4549
4550                 /* Reset visuals */
4551                 case 'R':
4552                 case 'r':
4553                         /* Reset */
4554                         reset_visuals();
4555
4556                         /* Message */
4557 #ifdef JP
4558                         msg_print("²èÌ̾å¤Î[¿§/ʸ»ú]¤ò½é´üÃͤ˥ꥻ¥Ã¥È¤·¤Þ¤·¤¿¡£");
4559 #else
4560                         msg_print("Visual attr/char tables reset.");
4561 #endif
4562
4563                         need_redraw = TRUE;
4564                         break;
4565
4566                 /* Unknown option */
4567                 default:
4568                         bell();
4569                         break;
4570                 }
4571
4572                 /* Flush messages */
4573                 msg_print(NULL);
4574         }
4575
4576         /* Restore the screen */
4577         screen_load();
4578
4579         if (need_redraw) do_cmd_redraw();
4580 }
4581
4582
4583 /*
4584  * Interact with "colors"
4585  */
4586 void do_cmd_colors(void)
4587 {
4588         int i;
4589
4590         char tmp[160];
4591
4592         char buf[1024];
4593
4594
4595         /* File type is "TEXT" */
4596         FILE_TYPE(FILE_TYPE_TEXT);
4597
4598
4599         /* Save the screen */
4600         screen_save();
4601
4602
4603         /* Interact until done */
4604         while (1)
4605         {
4606                 /* Clear screen */
4607                 Term_clear();
4608
4609                 /* Ask for a choice */
4610 #ifdef JP
4611                 prt("[ ¥«¥é¡¼¤ÎÀßÄê ]", 2, 0);
4612 #else
4613                 prt("Interact with Colors", 2, 0);
4614 #endif
4615
4616
4617                 /* Give some choices */
4618 #ifdef JP
4619                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
4620 #else
4621                 prt("(1) Load a user pref file", 4, 5);
4622 #endif
4623
4624 #ifdef ALLOW_COLORS
4625 #ifdef JP
4626                 prt("(2) ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
4627                 prt("(3) ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤¹¤ë", 6, 5);
4628 #else
4629                 prt("(2) Dump colors", 5, 5);
4630                 prt("(3) Modify colors", 6, 5);
4631 #endif
4632
4633 #endif
4634
4635                 /* Prompt */
4636 #ifdef JP
4637                 prt("¥³¥Þ¥ó¥É: ", 8, 0);
4638 #else
4639                 prt("Command: ", 8, 0);
4640 #endif
4641
4642
4643                 /* Prompt */
4644                 i = inkey();
4645
4646                 /* Done */
4647                 if (i == ESCAPE) break;
4648
4649                 /* Load a 'pref' file */
4650                 if (i == '1')
4651                 {
4652                         /* Prompt */
4653 #ifdef JP
4654                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹", 8, 0);
4655 #else
4656                         prt("Command: Load a user pref file", 8, 0);
4657 #endif
4658
4659
4660                         /* Prompt */
4661 #ifdef JP
4662                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4663 #else
4664                         prt("File: ", 10, 0);
4665 #endif
4666
4667
4668                         /* Default file */
4669                         sprintf(tmp, "%s.prf", player_base);
4670
4671                         /* Query */
4672                         if (!askfor(tmp, 70)) continue;
4673
4674                         /* Process the given filename */
4675                         (void)process_pref_file(tmp);
4676
4677                         /* Mega-Hack -- react to changes */
4678                         Term_xtra(TERM_XTRA_REACT, 0);
4679
4680                         /* Mega-Hack -- redraw */
4681                         Term_redraw();
4682                 }
4683
4684 #ifdef ALLOW_COLORS
4685
4686                 /* Dump colors */
4687                 else if (i == '2')
4688                 {
4689                         static cptr mark = "Colors";
4690
4691                         /* Prompt */
4692 #ifdef JP
4693                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 8, 0);
4694 #else
4695                         prt("Command: Dump colors", 8, 0);
4696 #endif
4697
4698
4699                         /* Prompt */
4700 #ifdef JP
4701                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4702 #else
4703                         prt("File: ", 10, 0);
4704 #endif
4705
4706
4707                         /* Default filename */
4708                         sprintf(tmp, "%s.prf", player_base);
4709
4710                         /* Get a filename */
4711                         if (!askfor(tmp, 70)) continue;
4712
4713                         /* Build the filename */
4714                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4715
4716                         /* Append to the file */
4717                         if (!open_auto_dump(buf, mark)) continue;
4718
4719                         /* Start dumping */
4720 #ifdef JP
4721                         auto_dump_printf("\n# ¥«¥é¡¼¤ÎÀßÄê\n\n");
4722 #else
4723                         auto_dump_printf("\n# Color redefinitions\n\n");
4724 #endif
4725
4726                         /* Dump colors */
4727                         for (i = 0; i < 256; i++)
4728                         {
4729                                 int kv = angband_color_table[i][0];
4730                                 int rv = angband_color_table[i][1];
4731                                 int gv = angband_color_table[i][2];
4732                                 int bv = angband_color_table[i][3];
4733
4734 #ifdef JP
4735                                 cptr name = "̤ÃÎ";
4736 #else
4737                                 cptr name = "unknown";
4738 #endif
4739
4740
4741                                 /* Skip non-entries */
4742                                 if (!kv && !rv && !gv && !bv) continue;
4743
4744                                 /* Extract the color name */
4745                                 if (i < 16) name = color_names[i];
4746
4747                                 /* Dump a comment */
4748 #ifdef JP
4749                                 auto_dump_printf("# ¥«¥é¡¼ '%s'\n", name);
4750 #else
4751                                 auto_dump_printf("# Color '%s'\n", name);
4752 #endif
4753
4754                                 /* Dump the monster attr/char info */
4755                                 auto_dump_printf("V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
4756                                         i, kv, rv, gv, bv);
4757                         }
4758
4759                         /* Close */
4760                         close_auto_dump();
4761
4762                         /* Message */
4763 #ifdef JP
4764                         msg_print("¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4765 #else
4766                         msg_print("Dumped color redefinitions.");
4767 #endif
4768
4769                 }
4770
4771                 /* Edit colors */
4772                 else if (i == '3')
4773                 {
4774                         static byte a = 0;
4775
4776                         /* Prompt */
4777 #ifdef JP
4778                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤·¤Þ¤¹", 8, 0);
4779 #else
4780                         prt("Command: Modify colors", 8, 0);
4781 #endif
4782
4783
4784                         /* Hack -- query until done */
4785                         while (1)
4786                         {
4787                                 cptr name;
4788                                 byte j;
4789
4790                                 /* Clear */
4791                                 clear_from(10);
4792
4793                                 /* Exhibit the normal colors */
4794                                 for (j = 0; j < 16; j++)
4795                                 {
4796                                         /* Exhibit this color */
4797                                         Term_putstr(j*4, 20, -1, a, "###");
4798
4799                                         /* Exhibit all colors */
4800                                         Term_putstr(j*4, 22, -1, j, format("%3d", j));
4801                                 }
4802
4803                                 /* Describe the color */
4804 #ifdef JP
4805                                 name = ((a < 16) ? color_names[a] : "̤ÄêµÁ");
4806 #else
4807                                 name = ((a < 16) ? color_names[a] : "undefined");
4808 #endif
4809
4810
4811                                 /* Describe the color */
4812 #ifdef JP
4813                                 Term_putstr(5, 10, -1, TERM_WHITE,
4814                                             format("¥«¥é¡¼ = %d, Ì¾Á° = %s", a, name));
4815 #else
4816                                 Term_putstr(5, 10, -1, TERM_WHITE,
4817                                             format("Color = %d, Name = %s", a, name));
4818 #endif
4819
4820
4821                                 /* Label the Current values */
4822                                 Term_putstr(5, 12, -1, TERM_WHITE,
4823                                             format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
4824                                                    angband_color_table[a][0],
4825                                                    angband_color_table[a][1],
4826                                                    angband_color_table[a][2],
4827                                                    angband_color_table[a][3]));
4828
4829                                 /* Prompt */
4830 #ifdef JP
4831                                 Term_putstr(0, 14, -1, TERM_WHITE,
4832                                             "¥³¥Þ¥ó¥É (n/N/k/K/r/R/g/G/b/B): ");
4833 #else
4834                                 Term_putstr(0, 14, -1, TERM_WHITE,
4835                                             "Command (n/N/k/K/r/R/g/G/b/B): ");
4836 #endif
4837
4838
4839                                 /* Get a command */
4840                                 i = inkey();
4841
4842                                 /* All done */
4843                                 if (i == ESCAPE) break;
4844
4845                                 /* Analyze */
4846                                 if (i == 'n') a = (byte)(a + 1);
4847                                 if (i == 'N') a = (byte)(a - 1);
4848                                 if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1);
4849                                 if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1);
4850                                 if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1);
4851                                 if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1);
4852                                 if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1);
4853                                 if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1);
4854                                 if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1);
4855                                 if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1);
4856
4857                                 /* Hack -- react to changes */
4858                                 Term_xtra(TERM_XTRA_REACT, 0);
4859
4860                                 /* Hack -- redraw */
4861                                 Term_redraw();
4862                         }
4863                 }
4864
4865 #endif
4866
4867                 /* Unknown option */
4868                 else
4869                 {
4870                         bell();
4871                 }
4872
4873                 /* Flush messages */
4874                 msg_print(NULL);
4875         }
4876
4877
4878         /* Restore the screen */
4879         screen_load();
4880 }
4881
4882
4883 /*
4884  * Note something in the message recall
4885  */
4886 void do_cmd_note(void)
4887 {
4888         char buf[80];
4889
4890         /* Default */
4891         strcpy(buf, "");
4892
4893         /* Input */
4894 #ifdef JP
4895         if (!get_string("¥á¥â: ", buf, 60)) return;
4896 #else
4897         if (!get_string("Note: ", buf, 60)) return;
4898 #endif
4899
4900
4901         /* Ignore empty notes */
4902         if (!buf[0] || (buf[0] == ' ')) return;
4903
4904         /* Add the note to the message recall */
4905 #ifdef JP
4906         msg_format("¥á¥â: %s", buf);
4907 #else
4908         msg_format("Note: %s", buf);
4909 #endif
4910
4911 }
4912
4913
4914 /*
4915  * Mention the current version
4916  */
4917 void do_cmd_version(void)
4918 {
4919
4920         /* Silly message */
4921 #ifdef JP
4922         msg_format("ÊѶòÈÚÅÜ(Hengband) %d.%d.%d",
4923                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4924 #else
4925         msg_format("You are playing Hengband %d.%d.%d.",
4926                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4927 #endif
4928 }
4929
4930
4931
4932 /*
4933  * Array of feeling strings
4934  */
4935 static cptr do_cmd_feeling_text[11] =
4936 {
4937 #ifdef JP
4938         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4939 #else
4940         "Looks like any other level.",
4941 #endif
4942
4943 #ifdef JP
4944         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4945 #else
4946         "You feel there is something special about this level.",
4947 #endif
4948
4949 #ifdef JP
4950         "¶²¤í¤·¤¤»à¤Î¸¸¤¬ÌܤËÉ⤫¤Ó¡¢µ¤À䤷¤½¤¦¤Ë¤Ê¤Ã¤¿¡ª",
4951 #else
4952         "You nearly faint as horrible visions of death fill your mind!",
4953 #endif
4954
4955 #ifdef JP
4956         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4957 #else
4958         "This level looks very dangerous.",
4959 #endif
4960
4961 #ifdef JP
4962         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4963 #else
4964         "You have a very bad feeling...",
4965 #endif
4966
4967 #ifdef JP
4968         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4969 #else
4970         "You have a bad feeling...",
4971 #endif
4972
4973 #ifdef JP
4974         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4975 #else
4976         "You feel nervous.",
4977 #endif
4978
4979 #ifdef JP
4980         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4981 #else
4982         "You feel your luck is turning...",
4983 #endif
4984
4985 #ifdef JP
4986         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4987 #else
4988         "You don't like the look of this place.",
4989 #endif
4990
4991 #ifdef JP
4992         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4993 #else
4994         "This level looks reasonably safe.",
4995 #endif
4996
4997 #ifdef JP
4998         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4999 #else
5000         "What a boring place..."
5001 #endif
5002
5003 };
5004
5005 static cptr do_cmd_feeling_text_combat[11] =
5006 {
5007 #ifdef JP
5008         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
5009 #else
5010         "Looks like any other level.",
5011 #endif
5012
5013 #ifdef JP
5014         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
5015 #else
5016         "You feel there is something special about this level.",
5017 #endif
5018
5019 #ifdef JP
5020         "º£Ìë¤â¤Þ¤¿¡¢Ã¯¤«¤¬Ì¿¤òÍî¤È¤¹...",
5021 #else
5022         "You nearly faint as horrible visions of death fill your mind!",
5023 #endif
5024
5025 #ifdef JP
5026         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
5027 #else
5028         "This level looks very dangerous.",
5029 #endif
5030
5031 #ifdef JP
5032         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
5033 #else
5034         "You have a very bad feeling...",
5035 #endif
5036
5037 #ifdef JP
5038         "°­¤¤Í½´¶¤¬¤¹¤ë...",
5039 #else
5040         "You have a bad feeling...",
5041 #endif
5042
5043 #ifdef JP
5044         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
5045 #else
5046         "You feel nervous.",
5047 #endif
5048
5049 #ifdef JP
5050         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
5051 #else
5052         "You feel your luck is turning...",
5053 #endif
5054
5055 #ifdef JP
5056         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
5057 #else
5058         "You don't like the look of this place.",
5059 #endif
5060
5061 #ifdef JP
5062         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
5063 #else
5064         "This level looks reasonably safe.",
5065 #endif
5066
5067 #ifdef JP
5068         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
5069 #else
5070         "What a boring place..."
5071 #endif
5072
5073 };
5074
5075 static cptr do_cmd_feeling_text_lucky[11] =
5076 {
5077 #ifdef JP
5078         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
5079         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
5080         "¤³¤Î³¬¤Ï¤³¤Î¾å¤Ê¤¯ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë¡£",
5081         "ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë...",
5082         "¤È¤Æ¤âÎɤ¤´¶¤¸¤¬¤¹¤ë...",
5083         "Îɤ¤´¶¤¸¤¬¤¹¤ë...",
5084         "¤Á¤ç¤Ã¤È¹¬±¿¤Ê´¶¤¸¤¬¤¹¤ë...",
5085         "¿¾¯¤Ï±¿¤¬¸þ¤¤¤Æ¤­¤¿¤«...",
5086         "¸«¤¿´¶¤¸°­¤¯¤Ï¤Ê¤¤...",
5087         "Á´Á³ÂÌÌܤȤ¤¤¦¤³¤È¤Ï¤Ê¤¤¤¬...",
5088         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
5089 #else
5090         "Looks like any other level.",
5091         "You feel there is something special about this level.",
5092         "You have a superb feeling about this level.",
5093         "You have an excellent feeling...",
5094         "You have a very good feeling...",
5095         "You have a good feeling...",
5096         "You feel strangely lucky...",
5097         "You feel your luck is turning...",
5098         "You like the look of this place...",
5099         "This level can't be all bad...",
5100         "What a boring place..."
5101 #endif
5102 };
5103
5104
5105 /*
5106  * Note that "feeling" is set to zero unless some time has passed.
5107  * Note that this is done when the level is GENERATED, not entered.
5108  */
5109 void do_cmd_feeling(void)
5110 {
5111         /* No useful feeling in quests */
5112         if (p_ptr->inside_quest && !random_quest_number(dun_level))
5113         {
5114 #ifdef JP
5115                 msg_print("ŵ·¿Åª¤Ê¥¯¥¨¥¹¥È¤Î¥À¥ó¥¸¥ç¥ó¤Î¤è¤¦¤À¡£");
5116 #else
5117                 msg_print("Looks like a typical quest level.");
5118 #endif
5119
5120                 return;
5121         }
5122
5123         /* No useful feeling in town */
5124         else if (p_ptr->town_num && !dun_level)
5125         {
5126 #ifdef JP
5127                 if (!strcmp(town[p_ptr->town_num].name, "¹ÓÌî"))
5128 #else
5129                 if (!strcmp(town[p_ptr->town_num].name, "wilderness"))
5130 #endif
5131                 {
5132 #ifdef JP
5133                         msg_print("²¿¤«¤¢¤ê¤½¤¦¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
5134 #else
5135                         msg_print("Looks like a strange wilderness.");
5136 #endif
5137
5138                         return;
5139                 }
5140                 else
5141                 {
5142 #ifdef JP
5143                         msg_print("ŵ·¿Åª¤ÊÄ®¤Î¤è¤¦¤À¡£");
5144 #else
5145                         msg_print("Looks like a typical town.");
5146 #endif
5147
5148                         return;
5149                 }
5150         }
5151
5152         /* No useful feeling in the wilderness */
5153         else if (!dun_level)
5154         {
5155 #ifdef JP
5156                 msg_print("ŵ·¿Åª¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
5157 #else
5158                 msg_print("Looks like a typical wilderness.");
5159 #endif
5160
5161                 return;
5162         }
5163
5164         /* Display the feeling */
5165         if (p_ptr->muta3 & MUT3_GOOD_LUCK)
5166                 msg_print(do_cmd_feeling_text_lucky[p_ptr->feeling]);
5167         else if (p_ptr->pseikaku == SEIKAKU_COMBAT ||
5168                  inventory[INVEN_BOW].name1 == ART_CRIMSON)
5169                 msg_print(do_cmd_feeling_text_combat[p_ptr->feeling]);
5170         else
5171                 msg_print(do_cmd_feeling_text[p_ptr->feeling]);
5172 }
5173
5174
5175
5176 /*
5177  * Description of each monster group.
5178  */
5179 static cptr monster_group_text[] = 
5180 {
5181 #ifdef JP
5182         "¥æ¥Ë¡¼¥¯",     /* "Uniques" */
5183         "¾èÇϲÄǽ¤Ê¥â¥ó¥¹¥¿¡¼", /* "Riding" */
5184         "¾Þ¶â¼ó", /* "Wanted */
5185         "¥¢¥ó¥Ð¡¼¤Î²¦Â²", /* "Ambertite" */
5186         "¥¢¥ê",
5187         "¥³¥¦¥â¥ê",
5188         "¥à¥«¥Ç",
5189         "¥É¥é¥´¥ó",
5190         "ÌܶÌ",
5191         "¥Í¥³",
5192         "¥´¡¼¥ì¥à",
5193         "ɸ½à¿Í´Ö·¿À¸Êª",
5194         "¥Ù¥È¥Ù¥È",
5195         "¥¼¥ê¡¼",
5196         "¥³¥Ü¥ë¥É",
5197         "¿åÀ³À¸Êª",
5198         "¥â¥ë¥É",
5199         "¥Ê¡¼¥¬",
5200         "¥ª¡¼¥¯",
5201         "¿Í´Ö",
5202         "»Í­½Ã",
5203         "¥Í¥º¥ß",
5204         "¥¹¥±¥ë¥È¥ó",
5205         "¥Ç¡¼¥â¥ó",
5206         "¥Ü¥ë¥Æ¥Ã¥¯¥¹",
5207         "¥¤¥â¥à¥·/Âç·²",
5208         /* "unused", */
5209         "¥¤¡¼¥¯",
5210         "¥¾¥ó¥Ó/¥ß¥¤¥é",
5211         "Å·»È",
5212         "Ļ",
5213         "¸¤",
5214         /* "¸ÅÂå¥É¥é¥´¥ó/¥ï¥¤¥¢¡¼¥à", */
5215         "¥¨¥ì¥á¥ó¥¿¥ë",
5216         "¥È¥ó¥Ü",
5217         "¥´¡¼¥¹¥È",
5218         "»¨¼ï",
5219         "º«Ãî",
5220         "¥Ø¥Ó",
5221         "¥­¥é¡¼¡¦¥Ó¡¼¥È¥ë",
5222         "¥ê¥Ã¥Á",
5223         "¿¼ó¤Îà¨ÃîÎà",
5224         "Ææ¤ÎÀ¸Êª",
5225         "¥ª¡¼¥¬",
5226         "µðÂç¿Í´Ö·¿À¸Êª",
5227         "¥¯¥¤¥ë¥¹¥ë¥°",
5228         "à¨ÃîÎà/ξÀ¸Îà",
5229         "ÃØéá/¥µ¥½¥ê/¥À¥Ë",
5230         "¥È¥í¥ë",
5231         /* "¾åµé¥Ç¡¼¥â¥ó", */
5232         "¥Ð¥ó¥Ñ¥¤¥¢",
5233         "¥ï¥¤¥È/¥ì¥¤¥¹/Åù",
5234         "¥¾¡¼¥ó/¥¶¥ì¥ó/Åù",
5235         "¥¤¥¨¥Æ¥£",
5236         "¥Ï¥¦¥ó¥É",
5237         "¥ß¥ß¥Ã¥¯",
5238         "ÊÉ/¿¢Êª/µ¤ÂÎ",
5239         "¤ª¤Ð¤±¥­¥Î¥³",
5240         "µåÂÎ",
5241         "¥×¥ì¥¤¥ä¡¼",
5242 #else
5243         "Uniques",
5244         "Ridable monsters",
5245         "Wanted monsters",
5246         "Ambertite",
5247         "Ant",
5248         "Bat",
5249         "Centipede",
5250         "Dragon",
5251         "Floating Eye",
5252         "Feline",
5253         "Golem",
5254         "Hobbit/Elf/Dwarf",
5255         "Icky Thing",
5256         "Jelly",
5257         "Kobold",
5258         "Aquatic monster",
5259         "Mold",
5260         "Naga",
5261         "Orc",
5262         "Person/Human",
5263         "Quadruped",
5264         "Rodent",
5265         "Skeleton",
5266         "Demon",
5267         "Vortex",
5268         "Worm/Worm-Mass",
5269         /* "unused", */
5270         "Yeek",
5271         "Zombie/Mummy",
5272         "Angel",
5273         "Bird",
5274         "Canine",
5275         /* "Ancient Dragon/Wyrm", */
5276         "Elemental",
5277         "Dragon Fly",
5278         "Ghost",
5279         "Hybrid",
5280         "Insect",
5281         "Snake",
5282         "Killer Beetle",
5283         "Lich",
5284         "Multi-Headed Reptile",
5285         "Mystery Living",
5286         "Ogre",
5287         "Giant Humanoid",
5288         "Quylthulg",
5289         "Reptile/Amphibian",
5290         "Spider/Scorpion/Tick",
5291         "Troll",
5292         /* "Major Demon", */
5293         "Vampire",
5294         "Wight/Wraith/etc",
5295         "Xorn/Xaren/etc",
5296         "Yeti",
5297         "Zephyr Hound",
5298         "Mimic",
5299         "Wall/Plant/Gas",
5300         "Mushroom patch",
5301         "Ball",
5302         "Player",
5303 #endif
5304         NULL
5305 };
5306
5307
5308 /*
5309  * Symbols of monsters in each group. Note the "Uniques" group
5310  * is handled differently.
5311  */
5312 static cptr monster_group_char[] =
5313 {
5314         (char *) -1L,
5315         (char *) -2L,
5316         (char *) -3L,
5317         (char *) -4L,
5318         "a",
5319         "b",
5320         "c",
5321         "dD",
5322         "e",
5323         "f",
5324         "g",
5325         "h",
5326         "i",
5327         "j",
5328         "k",
5329         "l",
5330         "m",
5331         "n",
5332         "o",
5333         "pt",
5334         "q",
5335         "r",
5336         "s",
5337         "uU",
5338         "v",
5339         "w",
5340         /* "x", */
5341         "y",
5342         "z",
5343         "A",
5344         "B",
5345         "C",
5346         /* "D", */
5347         "E",
5348         "F",
5349         "G",
5350         "H",
5351         "I",
5352         "J",
5353         "K",
5354         "L",
5355         "M",
5356         "N",
5357         "O",
5358         "P",
5359         "Q",
5360         "R",
5361         "S",
5362         "T",
5363         /* "U", */
5364         "V",
5365         "W",
5366         "X",
5367         "Y",
5368         "Z",
5369         "!$&()+./=>?[\\]`{|~",
5370         "#%",
5371         ",",
5372         "*",
5373         "@",
5374         NULL
5375 };
5376
5377
5378 /*
5379  * hook function to sort monsters by level
5380  */
5381 static bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
5382 {
5383         u16b *who = (u16b*)(u);
5384
5385         int w1 = who[a];
5386         int w2 = who[b];
5387
5388         monster_race *r_ptr1 = &r_info[w1];
5389         monster_race *r_ptr2 = &r_info[w2];
5390
5391         /* Unused */
5392         (void)v;
5393
5394         if (r_ptr2->level > r_ptr1->level) return TRUE;
5395         if (r_ptr1->level > r_ptr2->level) return FALSE;
5396
5397         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return TRUE;
5398         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return FALSE;
5399         return w1 <= w2;
5400 }
5401
5402 /*
5403  * Build a list of monster indexes in the given group. Return the number
5404  * of monsters in the group.
5405  *
5406  * mode & 0x01 : check for non-empty group
5407  * mode & 0x02 : visual operation only
5408  */
5409 static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
5410 {
5411         int i, mon_cnt = 0;
5412         int dummy_why;
5413
5414         /* Get a list of x_char in this group */
5415         cptr group_char = monster_group_char[grp_cur];
5416
5417         /* XXX Hack -- Check if this is the "Uniques" group */
5418         bool grp_unique = (monster_group_char[grp_cur] == (char *) -1L);
5419
5420         /* XXX Hack -- Check if this is the "Riding" group */
5421         bool grp_riding = (monster_group_char[grp_cur] == (char *) -2L);
5422
5423         /* XXX Hack -- Check if this is the "Wanted" group */
5424         bool grp_wanted = (monster_group_char[grp_cur] == (char *) -3L);
5425
5426         /* XXX Hack -- Check if this is the "Amberite" group */
5427         bool grp_amberite = (monster_group_char[grp_cur] == (char *) -4L);
5428
5429
5430         /* Check every race */
5431         for (i = 0; i < max_r_idx; i++)
5432         {
5433                 /* Access the race */
5434                 monster_race *r_ptr = &r_info[i];
5435
5436                 /* Skip empty race */
5437                 if (!r_ptr->name) continue ;
5438
5439                 /* Require known monsters */
5440                 if (!(mode & 0x02) && !cheat_know && !r_ptr->r_sights) continue;
5441
5442                 if (grp_unique)
5443                 {
5444                         if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
5445                 }
5446
5447                 else if (grp_riding)
5448                 {
5449                         if (!(r_ptr->flags7 & RF7_RIDING)) continue;
5450                 }
5451
5452                 else if (grp_wanted)
5453                 {
5454                         bool wanted = FALSE;
5455                         int j;
5456                         for (j = 0; j < MAX_KUBI; j++)
5457                         {
5458                                 if (kubi_r_idx[j] == i || kubi_r_idx[j] - 10000 == i ||
5459                                         (p_ptr->today_mon && p_ptr->today_mon == i))
5460                                 {
5461                                         wanted = TRUE;
5462                                         break;
5463                                 }
5464                         }
5465                         if (!wanted) continue;
5466                 }
5467
5468                 else if (grp_amberite)
5469                 {
5470                         if (!(r_ptr->flags3 & RF3_AMBERITE)) continue;
5471                 }
5472
5473                 else
5474                 {
5475                         /* Check for race in the group */
5476                         if (!my_strchr(group_char, r_ptr->d_char)) continue;
5477                 }
5478
5479                 /* Add the race */
5480                 mon_idx[mon_cnt++] = i;
5481
5482                 /* XXX Hack -- Just checking for non-empty group */
5483                 if (mode & 0x01) break;
5484         }
5485
5486         /* Terminate the list */
5487         mon_idx[mon_cnt] = -1;
5488
5489         /* Select the sort method */
5490         ang_sort_comp = ang_sort_comp_monster_level;
5491         ang_sort_swap = ang_sort_swap_hook;
5492
5493         /* Sort by monster level */
5494         ang_sort(mon_idx, &dummy_why, mon_cnt);
5495
5496         /* Return the number of races */
5497         return mon_cnt;
5498 }
5499
5500
5501 /*
5502  * Description of each monster group.
5503  */
5504 static cptr object_group_text[] = 
5505 {
5506 #ifdef JP
5507         "¥­¥Î¥³",       /* "Mushrooms" */
5508         "Ìô",           /* "Potions" */
5509         "Ìý¤Ä¤Ü",       /* "Flasks" */
5510         "´¬Êª",         /* "Scrolls" */
5511         "»ØÎØ",         /* "Rings" */
5512         "¥¢¥ß¥å¥ì¥Ã¥È", /* "Amulets" */
5513         "ū",           /* "Whistle" */
5514         "¸÷¸»",         /* "Lanterns" */
5515         "ËâË¡ËÀ",       /* "Wands" */
5516         "¾ó",           /* "Staffs" */
5517         "¥í¥Ã¥É",       /* "Rods" */
5518         "¥«¡¼¥É",       /* "Cards" */
5519         "¥­¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë",
5520         "ÍÓÈé»æ",       
5521         "¤¯¤µ¤Ó",
5522         "Ȣ",
5523         "¿Í·Á",
5524         "Áü",
5525         "¥´¥ß",
5526         "¶õ¤Î¥Ó¥ó",
5527         "¹ü",
5528         "»àÂÎ",
5529         "Åá·õÎà",       /* "Swords" */
5530         "Æß´ï",         /* "Blunt Weapons" */
5531         "ĹÊÁÉð´ï",     /* "Polearms" */
5532         "ºÎ·¡Æ»¶ñ",     /* "Diggers" */
5533         "Èô¤ÓÆ»¶ñ",     /* "Bows" */
5534         "ÃÆ",
5535         "Ìð",
5536         "¥Ü¥ë¥È",
5537         "·ÚÁõ³»",       /* "Soft Armor" */
5538         "½ÅÁõ³»",       /* "Hard Armor" */
5539         "¥É¥é¥´¥ó³»",   /* "Dragon Armor" */
5540         "½â",   /* "Shields" */
5541         "¥¯¥í¡¼¥¯",     /* "Cloaks" */
5542         "äƼê", /* "Gloves" */
5543         "¥Ø¥ë¥á¥Ã¥È",   /* "Helms" */
5544         "´§",   /* "Crowns" */
5545         "¥Ö¡¼¥Ä",       /* "Boots" */
5546         "ËâË¡½ñ",
5547         "ºâÊõ",
5548         "²¿¤«",
5549 #else
5550         "Mushrooms",
5551         "Potions",
5552         "Flasks",
5553         "Scrolls",
5554         "Rings",
5555         "Amulets",
5556         "Whistle",
5557         "Lanterns",
5558         "Wands",
5559         "Staves",
5560         "Rods",
5561         "Cards",
5562         "Capture Balls",
5563         "Parchments",
5564         "Spikes",
5565         "Boxs",
5566         "Figurines",
5567         "Statues",
5568         "Junks",
5569         "Bottles",
5570         "Skeletons",
5571         "Corpses",
5572         "Swords",
5573         "Blunt Weapons",
5574         "Polearms",
5575         "Diggers",
5576         "Bows",
5577         "Shots",
5578         "Arrows",
5579         "Bolts",
5580         "Soft Armor",
5581         "Hard Armor",
5582         "Dragon Armor",
5583         "Shields",
5584         "Cloaks",
5585         "Gloves",
5586         "Helms",
5587         "Crowns",
5588         "Boots",
5589         "Spellbooks",
5590         "Treasure",
5591         "Something",
5592 #endif
5593         NULL
5594 };
5595
5596
5597 /*
5598  * TVALs of items in each group
5599  */
5600 static byte object_group_tval[] = 
5601 {
5602         TV_FOOD,
5603         TV_POTION,
5604         TV_FLASK,
5605         TV_SCROLL,
5606         TV_RING,
5607         TV_AMULET,
5608         TV_WHISTLE,
5609         TV_LITE,
5610         TV_WAND,
5611         TV_STAFF,
5612         TV_ROD,
5613         TV_CARD,
5614         TV_CAPTURE,
5615         TV_PARCHMENT,
5616         TV_SPIKE,
5617         TV_CHEST,
5618         TV_FIGURINE,
5619         TV_STATUE,
5620         TV_JUNK,
5621         TV_BOTTLE,
5622         TV_SKELETON,
5623         TV_CORPSE,
5624         TV_SWORD,
5625         TV_HAFTED,
5626         TV_POLEARM,
5627         TV_DIGGING,
5628         TV_BOW,
5629         TV_SHOT,
5630         TV_ARROW,
5631         TV_BOLT,
5632         TV_SOFT_ARMOR,
5633         TV_HARD_ARMOR,
5634         TV_DRAG_ARMOR,
5635         TV_SHIELD,
5636         TV_CLOAK,
5637         TV_GLOVES,
5638         TV_HELM,
5639         TV_CROWN,
5640         TV_BOOTS,
5641         TV_LIFE_BOOK, /* Hack -- all spellbooks */
5642         TV_GOLD,
5643         0,
5644         0,
5645 };
5646
5647
5648 /*
5649  * Build a list of object indexes in the given group. Return the number
5650  * of objects in the group.
5651  *
5652  * mode & 0x01 : check for non-empty group
5653  * mode & 0x02 : visual operation only
5654  */
5655 static int collect_objects(int grp_cur, int object_idx[], byte mode)
5656 {
5657         int i, j, k, object_cnt = 0;
5658
5659         /* Get a list of x_char in this group */
5660         byte group_tval = object_group_tval[grp_cur];
5661
5662         /* Check every object */
5663         for (i = 0; i < max_k_idx; i++)
5664         {
5665                 /* Access the object */
5666                 object_kind *k_ptr = &k_info[i];
5667
5668                 /* Skip empty objects */
5669                 if (!k_ptr->name) continue;
5670
5671                 if (mode & 0x02)
5672                 {
5673                         /* Any objects will be displayed */
5674                 }
5675                 else
5676                 {
5677                         if (!p_ptr->wizard)
5678                         {
5679                                 /* Skip non-flavoured objects */
5680                                 if (!k_ptr->flavor) continue;
5681
5682                                 /* Require objects ever seen */
5683                                 if (!k_ptr->aware) continue;
5684                         }
5685
5686                         /* Skip items with no distribution (special artifacts) */
5687                         for (j = 0, k = 0; j < 4; j++) k += k_ptr->chance[j];
5688                         if (!k) continue;
5689                 }
5690
5691                 /* Check for objects in the group */
5692                 if (TV_LIFE_BOOK == group_tval)
5693                 {
5694                         /* Hack -- All spell books */
5695                         if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HEX_BOOK)
5696                         {
5697                                 /* Add the object */
5698                                 object_idx[object_cnt++] = i;
5699                         }
5700                         else continue;
5701                 }
5702                 else if (k_ptr->tval == group_tval)
5703                 {
5704                         /* Add the object */
5705                         object_idx[object_cnt++] = i;
5706                 }
5707                 else continue;
5708
5709                 /* XXX Hack -- Just checking for non-empty group */
5710                 if (mode & 0x01) break;
5711         }
5712
5713         /* Terminate the list */
5714         object_idx[object_cnt] = -1;
5715
5716         /* Return the number of objects */
5717         return object_cnt;
5718 }
5719
5720
5721 /*
5722  * Description of each feature group.
5723  */
5724 static cptr feature_group_text[] = 
5725 {
5726         "terrains",
5727         NULL
5728 };
5729
5730
5731 /*
5732  * Build a list of feature indexes in the given group. Return the number
5733  * of features in the group.
5734  *
5735  * mode & 0x01 : check for non-empty group
5736  */
5737 static int collect_features(int grp_cur, int *feat_idx, byte mode)
5738 {
5739         int i, feat_cnt = 0;
5740
5741         /* Unused;  There is a single group. */
5742         (void)grp_cur;
5743
5744         /* Check every feature */
5745         for (i = 0; i < max_f_idx; i++)
5746         {
5747                 /* Access the index */
5748                 feature_type *f_ptr = &f_info[i];
5749
5750                 /* Skip empty index */
5751                 if (!f_ptr->name) continue;
5752
5753                 /* Skip mimiccing features */
5754                 if (f_ptr->mimic != i) continue;
5755
5756                 /* Add the index */
5757                 feat_idx[feat_cnt++] = i;
5758
5759                 /* XXX Hack -- Just checking for non-empty group */
5760                 if (mode & 0x01) break;
5761         }
5762
5763         /* Terminate the list */
5764         feat_idx[feat_cnt] = -1;
5765
5766         /* Return the number of races */
5767         return feat_cnt;
5768 }
5769
5770
5771 #if 0
5772 /*
5773  * Build a list of monster indexes in the given group. Return the number
5774  * of monsters in the group.
5775  */
5776 static int collect_artifacts(int grp_cur, int object_idx[])
5777 {
5778         int i, object_cnt = 0;
5779
5780         /* Get a list of x_char in this group */
5781         byte group_tval = object_group_tval[grp_cur];
5782
5783         /* Check every object */
5784         for (i = 0; i < max_a_idx; i++)
5785         {
5786                 /* Access the artifact */
5787                 artifact_type *a_ptr = &a_info[i];
5788
5789                 /* Skip empty artifacts */
5790                 if (!a_ptr->name) continue;
5791
5792                 /* Skip "uncreated" artifacts */
5793                 if (!a_ptr->cur_num) continue;
5794
5795                 /* Check for race in the group */
5796                 if (a_ptr->tval == group_tval)
5797                 {
5798                         /* Add the race */
5799                         object_idx[object_cnt++] = i;
5800                 }
5801         }
5802
5803         /* Terminate the list */
5804         object_idx[object_cnt] = 0;
5805
5806         /* Return the number of races */
5807         return object_cnt;
5808 }
5809 #endif /* 0 */
5810
5811
5812 /*
5813  * Encode the screen colors
5814  */
5815 static char hack[17] = "dwsorgbuDWvyRGBU";
5816
5817
5818 /*
5819  * Hack -- load a screen dump from a file
5820  */
5821 void do_cmd_load_screen(void)
5822 {
5823         int i, y, x;
5824
5825         byte a = 0;
5826         char c = ' ';
5827
5828         bool okay = TRUE;
5829
5830         FILE *fff;
5831
5832         char buf[1024];
5833
5834         int wid, hgt;
5835
5836         Term_get_size(&wid, &hgt);
5837
5838         /* Build the filename */
5839         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
5840
5841         /* Append to the file */
5842         fff = my_fopen(buf, "r");
5843
5844         /* Oops */
5845         if (!fff) {
5846 #ifdef JP
5847                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
5848 #else
5849                 msg_format("Failed to open %s.", buf);
5850 #endif
5851                 msg_print(NULL);
5852                 return;
5853         }
5854
5855
5856         /* Save the screen */
5857         screen_save();
5858
5859         /* Clear the screen */
5860         Term_clear();
5861
5862
5863         /* Load the screen */
5864         for (y = 0; okay; y++)
5865         {
5866                 /* Get a line of data including control code */
5867                 if (!fgets(buf, 1024, fff)) okay = FALSE;
5868
5869                 /* Get the blank line */
5870                 if (buf[0] == '\n' || buf[0] == '\0') break;
5871
5872                 /* Ignore too large screen image */
5873                 if (y >= hgt) continue;
5874
5875                 /* Show each row */
5876                 for (x = 0; x < wid - 1; x++)
5877                 {
5878                         /* End of line */
5879                         if (buf[x] == '\n' || buf[x] == '\0') break;
5880
5881                         /* Put the attr/char */
5882                         Term_draw(x, y, TERM_WHITE, buf[x]);
5883                 }
5884         }
5885
5886         /* Dump the screen */
5887         for (y = 0; okay; y++)
5888         {
5889                 /* Get a line of data including control code */
5890                 if (!fgets(buf, 1024, fff)) okay = FALSE;
5891
5892                 /* Get the blank line */
5893                 if (buf[0] == '\n' || buf[0] == '\0') break;
5894
5895                 /* Ignore too large screen image */
5896                 if (y >= hgt) continue;
5897
5898                 /* Dump each row */
5899                 for (x = 0; x < wid - 1; x++)
5900                 {
5901                         /* End of line */
5902                         if (buf[x] == '\n' || buf[x] == '\0') break;
5903
5904                         /* Get the attr/char */
5905                         (void)(Term_what(x, y, &a, &c));
5906
5907                         /* Look up the attr */
5908                         for (i = 0; i < 16; i++)
5909                         {
5910                                 /* Use attr matches */
5911                                 if (hack[i] == buf[x]) a = i;
5912                         }
5913
5914                         /* Put the attr/char */
5915                         Term_draw(x, y, a, c);
5916                 }
5917         }
5918
5919
5920         /* Close it */
5921         my_fclose(fff);
5922
5923
5924         /* Message */
5925 #ifdef JP
5926         prt("¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤µ¤ì¤¿²èÌÌ(µ­Ç°»£±Æ)¤ò¥í¡¼¥É¤·¤Þ¤·¤¿¡£", 0, 0);
5927 #else
5928         msg_print("Screen dump loaded.");
5929 #endif
5930
5931         flush();
5932         inkey();
5933
5934
5935         /* Restore the screen */
5936         screen_load();
5937 }
5938
5939
5940
5941
5942 cptr inven_res_label = 
5943 #ifdef JP
5944  "                               »ÀÅŲÐÎäÆǸ÷°ÇÇ˹ì¹ö°øÆÙÎô ÌÕÉÝÍðáãÆ©Ì¿´¶¾ÃÉüÉâ";
5945 #else
5946  "                               AcElFiCoPoLiDkShSoNtNxCaDi BlFeCfFaSeHlEpSdRgLv";
5947 #endif
5948
5949
5950 #ifdef JP
5951 #define IM_FLAG_STR  "¡ö"
5952 #define HAS_FLAG_STR "¡Ü"
5953 #define NO_FLAG_STR  "¡¦"
5954 #else
5955 #define IM_FLAG_STR  "* "
5956 #define HAS_FLAG_STR "+ "
5957 #define NO_FLAG_STR  ". "
5958 #endif
5959
5960 #define print_im_or_res_flag(IM, RES) \
5961 { \
5962         fputs(have_flag(flgs, (IM)) ? IM_FLAG_STR : \
5963               (have_flag(flgs, (RES)) ? HAS_FLAG_STR : NO_FLAG_STR), fff); \
5964 }
5965
5966 #define print_flag(TR) \
5967 { \
5968         fputs(have_flag(flgs, (TR)) ? HAS_FLAG_STR : NO_FLAG_STR, fff); \
5969 }
5970
5971
5972 /* XTRA HACK RESLIST */
5973 static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr, int *j, byte tval, char *where)
5974 {
5975         char o_name[MAX_NLEN];
5976         u32b flgs[TR_FLAG_SIZE];
5977
5978         if (!o_ptr->k_idx) return;
5979         if (o_ptr->tval != tval) return;
5980
5981         /* Identified items only */
5982         if (!object_is_known(o_ptr)) return;
5983
5984         /*
5985          * HACK:Ring of Lordly protection and Dragon equipment
5986          * have random resistances.
5987          */
5988         if ((object_is_wearable(o_ptr) && object_is_ego(o_ptr))
5989             || ((tval == TV_AMULET) && (o_ptr->sval == SV_AMULET_RESISTANCE))
5990             || ((tval == TV_RING) && (o_ptr->sval == SV_RING_LORDLY))
5991             || ((tval == TV_SHIELD) && (o_ptr->sval == SV_DRAGON_SHIELD))
5992             || ((tval == TV_HELM) && (o_ptr->sval == SV_DRAGON_HELM))
5993             || ((tval == TV_GLOVES) && (o_ptr->sval == SV_SET_OF_DRAGON_GLOVES))
5994             || ((tval == TV_BOOTS) && (o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE))
5995             || object_is_artifact(o_ptr))
5996         {
5997                 int i = 0;
5998                 object_desc(o_name, o_ptr, OD_NAME_ONLY);
5999
6000                 while (o_name[i] && (i < 26))
6001                 {
6002 #ifdef JP
6003                         if (iskanji(o_name[i])) i++;
6004 #endif
6005                         i++;
6006                 }
6007
6008                 if (i < 28)
6009                 {
6010                         while (i < 28)
6011                         {
6012                                 o_name[i] = ' '; i++;
6013                         }
6014                 }
6015                 o_name[i] = '\0';
6016
6017                 fprintf(fff, "%s %s", where, o_name);
6018
6019                 if (!(o_ptr->ident & (IDENT_MENTAL)))
6020                 {
6021 #ifdef JP
6022                         fputs("-------ÉÔÌÀ--------------- -------ÉÔÌÀ---------\n", fff);
6023 #else
6024                         fputs("-------unknown------------ -------unknown------\n", fff);
6025 #endif
6026                 }
6027                 else
6028                 {
6029                         object_flags_known(o_ptr, flgs);
6030
6031                         print_im_or_res_flag(TR_IM_ACID, TR_RES_ACID);
6032                         print_im_or_res_flag(TR_IM_ELEC, TR_RES_ELEC);
6033                         print_im_or_res_flag(TR_IM_FIRE, TR_RES_FIRE);
6034                         print_im_or_res_flag(TR_IM_COLD, TR_RES_COLD);
6035                         print_flag(TR_RES_POIS);
6036                         print_flag(TR_RES_LITE);
6037                         print_flag(TR_RES_DARK);
6038                         print_flag(TR_RES_SHARDS);
6039                         print_flag(TR_RES_SOUND);
6040                         print_flag(TR_RES_NETHER);
6041                         print_flag(TR_RES_NEXUS);
6042                         print_flag(TR_RES_CHAOS);
6043                         print_flag(TR_RES_DISEN);
6044
6045                         fputs(" ", fff);
6046
6047                         print_flag(TR_RES_BLIND);
6048                         print_flag(TR_RES_FEAR);
6049                         print_flag(TR_RES_CONF);
6050                         print_flag(TR_FREE_ACT);
6051                         print_flag(TR_SEE_INVIS);
6052                         print_flag(TR_HOLD_LIFE);
6053                         print_flag(TR_TELEPATHY);
6054                         print_flag(TR_SLOW_DIGEST);
6055                         print_flag(TR_REGEN);
6056                         print_flag(TR_LEVITATION);
6057
6058                         fputc('\n', fff);
6059                 }
6060                 (*j)++;
6061                 if (*j == 9)
6062                 {
6063                         *j = 0;
6064                         fprintf(fff, "%s\n", inven_res_label);
6065                 }
6066         }
6067 }
6068
6069 /*
6070  * Display *ID* ed weapons/armors's resistances
6071  */
6072 static void do_cmd_knowledge_inven(void)
6073 {
6074         FILE *fff;
6075
6076         char file_name[1024];
6077
6078         store_type  *st_ptr;
6079
6080         byte tval;
6081         int i = 0;
6082         int j = 0;
6083
6084         char  where[32];
6085
6086         /* Open a new file */
6087         fff = my_fopen_temp(file_name, 1024);
6088         if (!fff)
6089         {
6090 #ifdef JP
6091             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6092 #else
6093             msg_format("Failed to create temporary file %s.", file_name);
6094 #endif
6095             msg_print(NULL);
6096             return;
6097         }
6098         fprintf(fff, "%s\n", inven_res_label);
6099
6100         for (tval = TV_WEARABLE_BEGIN; tval <= TV_WEARABLE_END; tval++)
6101         {
6102                 if (j != 0)
6103                 {
6104                         for (; j < 9; j++) fputc('\n', fff);
6105                         j = 0;
6106                         fprintf(fff, "%s\n", inven_res_label);
6107                 }
6108
6109 #ifdef JP
6110                 strcpy(where, "Áõ");
6111 #else
6112                 strcpy(where, "E ");
6113 #endif
6114                 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
6115                 {
6116                         do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
6117                 }
6118
6119 #ifdef JP
6120                 strcpy(where, "»ý");
6121 #else
6122                 strcpy(where, "I ");
6123 #endif
6124                 for (i = 0; i < INVEN_PACK; i++)
6125                 {
6126                         do_cmd_knowledge_inven_aux(fff, &inventory[i], &j, tval, where);
6127                 }
6128
6129                 st_ptr = &town[1].store[STORE_HOME];
6130 #ifdef JP
6131                 strcpy(where, "²È");
6132 #else
6133                 strcpy(where, "H ");
6134 #endif
6135
6136                 for (i = 0; i < st_ptr->stock_num; i++)
6137                 {
6138                         do_cmd_knowledge_inven_aux(fff, &st_ptr->stock[i], &j, tval, where);
6139                 }
6140         }
6141
6142         /* Close the file */
6143         my_fclose(fff);
6144
6145         /* Display the file contents */
6146 #ifdef JP
6147         show_file(TRUE, file_name, "*´ÕÄê*ºÑ¤ßÉð´ï/Ëɶñ¤ÎÂÑÀ­¥ê¥¹¥È", 0, 0);
6148 #else
6149         show_file(TRUE, file_name, "Resistances of *identified* equipment", 0, 0);
6150 #endif
6151
6152         /* Remove the file */
6153         fd_kill(file_name);
6154 }
6155
6156
6157 void do_cmd_save_screen_html_aux(char *filename, int message)
6158 {
6159         int y, x, i;
6160
6161         byte a = 0, old_a = 0;
6162         char c = ' ';
6163
6164         FILE *fff, *tmpfff;
6165         char buf[2048];
6166
6167         int yomikomu = 0;
6168         cptr tags[4] = {
6169                 "HEADER_START:",
6170                 "HEADER_END:",
6171                 "FOOTER_START:",
6172                 "FOOTER_END:",
6173         };
6174
6175         cptr html_head[] = {
6176                 "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
6177                 "<pre>",
6178                 0,
6179         };
6180         cptr html_foot[] = {
6181                 "</pre>\n",
6182                 "</body>\n</html>\n",
6183                 0,
6184         };
6185
6186         int wid, hgt;
6187
6188         Term_get_size(&wid, &hgt);
6189
6190         /* File type is "TEXT" */
6191         FILE_TYPE(FILE_TYPE_TEXT);
6192
6193         /* Append to the file */
6194         fff = my_fopen(filename, "w");
6195
6196         /* Oops */
6197         if (!fff) {
6198                 if (message) {
6199 #ifdef JP
6200                     msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", filename);
6201 #else
6202                     msg_format("Failed to open file %s.", filename);
6203 #endif
6204                     msg_print(NULL);
6205                 }
6206                 
6207                 return;
6208         }
6209
6210         /* Save the screen */
6211         if (message)
6212                 screen_save();
6213
6214         /* Build the filename */
6215         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
6216         tmpfff = my_fopen(buf, "r");
6217         if (!tmpfff) {
6218                 for (i = 0; html_head[i]; i++)
6219                         fputs(html_head[i], fff);
6220         }
6221         else {
6222                 yomikomu = 0;
6223                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
6224                         if (!yomikomu) {
6225                                 if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
6226                                         yomikomu = 1;
6227                         }
6228                         else {
6229                                 if (strncmp(buf, tags[1], strlen(tags[1])) == 0)
6230                                         break;
6231                                 fprintf(fff, "%s\n", buf);
6232                         }
6233                 }
6234         }
6235
6236         /* Dump the screen */
6237         for (y = 0; y < hgt; y++)
6238         {
6239                 /* Start the row */
6240                 if (y != 0)
6241                         fprintf(fff, "\n");
6242
6243                 /* Dump each row */
6244                 for (x = 0; x < wid - 1; x++)
6245                 {
6246                         int rv, gv, bv;
6247                         cptr cc = NULL;
6248                         /* Get the attr/char */
6249                         (void)(Term_what(x, y, &a, &c));
6250
6251                         switch (c)
6252                         {
6253                         case '&': cc = "&amp;"; break;
6254                         case '<': cc = "&lt;"; break;
6255                         case '>': cc = "&gt;"; break;
6256 #ifdef WINDOWS
6257                         case 0x1f: c = '.'; break;
6258                         case 0x7f: c = (a == 0x09) ? '%' : '#'; break;
6259 #endif
6260                         }
6261
6262                         a = a & 0x0F;
6263                         if ((y == 0 && x == 0) || a != old_a) {
6264                                 rv = angband_color_table[a][1];
6265                                 gv = angband_color_table[a][2];
6266                                 bv = angband_color_table[a][3];
6267                                 fprintf(fff, "%s<font color=\"#%02x%02x%02x\">", 
6268                                         ((y == 0 && x == 0) ? "" : "</font>"), rv, gv, bv);
6269                                 old_a = a;
6270                         }
6271                         if (cc)
6272                                 fprintf(fff, "%s", cc);
6273                         else
6274                                 fprintf(fff, "%c", c);
6275                 }
6276         }
6277         fprintf(fff, "</font>");
6278
6279         if (!tmpfff) {
6280                 for (i = 0; html_foot[i]; i++)
6281                         fputs(html_foot[i], fff);
6282         }
6283         else {
6284                 rewind(tmpfff);
6285                 yomikomu = 0;
6286                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
6287                         if (!yomikomu) {
6288                                 if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
6289                                         yomikomu = 1;
6290                         }
6291                         else {
6292                                 if (strncmp(buf, tags[3], strlen(tags[3])) == 0)
6293                                         break;
6294                                 fprintf(fff, "%s\n", buf);
6295                         }
6296                 }
6297                 my_fclose(tmpfff);
6298         }
6299
6300         /* Skip a line */
6301         fprintf(fff, "\n");
6302
6303         /* Close it */
6304         my_fclose(fff);
6305
6306         /* Message */
6307         if (message) {
6308 #ifdef JP
6309         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6310 #else
6311                 msg_print("Screen dump saved.");
6312 #endif
6313                 msg_print(NULL);
6314         }
6315
6316         /* Restore the screen */
6317         if (message)
6318                 screen_load();
6319 }
6320
6321 /*
6322  * Hack -- save a screen dump to a file
6323  */
6324 static void do_cmd_save_screen_html(void)
6325 {
6326         char buf[1024], tmp[256] = "screen.html";
6327
6328 #ifdef JP
6329         if (!get_string("¥Õ¥¡¥¤¥ë̾: ", tmp, 80))
6330 #else
6331         if (!get_string("File name: ", tmp, 80))
6332 #endif
6333                 return;
6334
6335         /* Build the filename */
6336         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
6337
6338         msg_print(NULL);
6339
6340         do_cmd_save_screen_html_aux(buf, 1);
6341 }
6342
6343
6344 /*
6345  * Redefinable "save_screen" action
6346  */
6347 void (*screendump_aux)(void) = NULL;
6348
6349
6350 /*
6351  * Hack -- save a screen dump to a file
6352  */
6353 void do_cmd_save_screen(void)
6354 {
6355         bool old_use_graphics = use_graphics;
6356         bool html_dump = FALSE;
6357
6358         int wid, hgt;
6359
6360 #ifdef JP
6361         prt("µ­Ç°»£±Æ¤·¤Þ¤¹¤«¡© [(y)es/(h)tml/(n)o] ", 0, 0);
6362 #else
6363         prt("Save screen dump? [(y)es/(h)tml/(n)o] ", 0, 0);
6364 #endif
6365         while(TRUE)
6366         {
6367                 char c = inkey();
6368                 if (c == 'Y' || c == 'y')
6369                         break;
6370                 else if (c == 'H' || c == 'h')
6371                 {
6372                         html_dump = TRUE;
6373                         break;
6374                 }
6375                 else
6376                 {
6377                         prt("", 0, 0);
6378                         return;
6379                 }
6380         }
6381
6382         Term_get_size(&wid, &hgt);
6383
6384         if (old_use_graphics)
6385         {
6386                 use_graphics = FALSE;
6387                 reset_visuals();
6388
6389                 /* Redraw everything */
6390                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6391
6392                 /* Hack -- update */
6393                 handle_stuff();
6394         }
6395
6396         if (html_dump)
6397         {
6398                 do_cmd_save_screen_html();
6399                 do_cmd_redraw();
6400         }
6401
6402         /* Do we use a special screendump function ? */
6403         else if (screendump_aux)
6404         {
6405                 /* Dump the screen to a graphics file */
6406                 (*screendump_aux)();
6407         }
6408         else /* Dump the screen as text */
6409         {
6410                 int y, x;
6411
6412                 byte a = 0;
6413                 char c = ' ';
6414
6415                 FILE *fff;
6416
6417                 char buf[1024];
6418
6419                 /* Build the filename */
6420                 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
6421
6422                 /* File type is "TEXT" */
6423                 FILE_TYPE(FILE_TYPE_TEXT);
6424
6425                 /* Append to the file */
6426                 fff = my_fopen(buf, "w");
6427
6428                 /* Oops */
6429                 if (!fff)
6430                 {
6431 #ifdef JP
6432                         msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
6433 #else
6434                         msg_format("Failed to open file %s.", buf);
6435 #endif
6436                         msg_print(NULL);
6437                         return;
6438                 }
6439
6440
6441                 /* Save the screen */
6442                 screen_save();
6443
6444
6445                 /* Dump the screen */
6446                 for (y = 0; y < hgt; y++)
6447                 {
6448                         /* Dump each row */
6449                         for (x = 0; x < wid - 1; x++)
6450                         {
6451                                 /* Get the attr/char */
6452                                 (void)(Term_what(x, y, &a, &c));
6453
6454                                 /* Dump it */
6455                                 buf[x] = c;
6456                         }
6457
6458                         /* Terminate */
6459                         buf[x] = '\0';
6460
6461                         /* End the row */
6462                         fprintf(fff, "%s\n", buf);
6463                 }
6464
6465                 /* Skip a line */
6466                 fprintf(fff, "\n");
6467
6468
6469                 /* Dump the screen */
6470                 for (y = 0; y < hgt; y++)
6471                 {
6472                         /* Dump each row */
6473                         for (x = 0; x < wid - 1; x++)
6474                         {
6475                                 /* Get the attr/char */
6476                                 (void)(Term_what(x, y, &a, &c));
6477
6478                                 /* Dump it */
6479                                 buf[x] = hack[a&0x0F];
6480                         }
6481
6482                         /* Terminate */
6483                         buf[x] = '\0';
6484
6485                         /* End the row */
6486                         fprintf(fff, "%s\n", buf);
6487                 }
6488
6489                 /* Skip a line */
6490                 fprintf(fff, "\n");
6491
6492
6493                 /* Close it */
6494                 my_fclose(fff);
6495
6496                 /* Message */
6497 #ifdef JP
6498         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6499 #else
6500                 msg_print("Screen dump saved.");
6501 #endif
6502
6503                 msg_print(NULL);
6504
6505
6506                 /* Restore the screen */
6507                 screen_load();
6508         }
6509
6510         if (old_use_graphics)
6511         {
6512                 use_graphics = TRUE;
6513                 reset_visuals();
6514
6515                 /* Redraw everything */
6516                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6517
6518                 /* Hack -- update */
6519                 handle_stuff();
6520         }
6521 }
6522
6523
6524 /*
6525  * Sorting hook -- Comp function -- see below
6526  *
6527  * We use "u" to point to array of monster indexes,
6528  * and "v" to select the type of sorting to perform on "u".
6529  */
6530 static bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
6531 {
6532         u16b *who = (u16b*)(u);
6533
6534         u16b *why = (u16b*)(v);
6535
6536         int w1 = who[a];
6537         int w2 = who[b];
6538
6539         int z1, z2;
6540
6541         /* Sort by total kills */
6542         if (*why >= 3)
6543         {
6544                 /* Extract total kills */
6545                 z1 = a_info[w1].tval;
6546                 z2 = a_info[w2].tval;
6547
6548                 /* Compare total kills */
6549                 if (z1 < z2) return (TRUE);
6550                 if (z1 > z2) return (FALSE);
6551         }
6552
6553
6554         /* Sort by monster level */
6555         if (*why >= 2)
6556         {
6557                 /* Extract levels */
6558                 z1 = a_info[w1].sval;
6559                 z2 = a_info[w2].sval;
6560
6561                 /* Compare levels */
6562                 if (z1 < z2) return (TRUE);
6563                 if (z1 > z2) return (FALSE);
6564         }
6565
6566
6567         /* Sort by monster experience */
6568         if (*why >= 1)
6569         {
6570                 /* Extract experience */
6571                 z1 = a_info[w1].level;
6572                 z2 = a_info[w2].level;
6573
6574                 /* Compare experience */
6575                 if (z1 < z2) return (TRUE);
6576                 if (z1 > z2) return (FALSE);
6577         }
6578
6579
6580         /* Compare indexes */
6581         return (w1 <= w2);
6582 }
6583
6584
6585 /*
6586  * Sorting hook -- Swap function -- see below
6587  *
6588  * We use "u" to point to array of monster indexes,
6589  * and "v" to select the type of sorting to perform.
6590  */
6591 static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
6592 {
6593         u16b *who = (u16b*)(u);
6594
6595         u16b holder;
6596
6597         /* Unused */
6598         (void)v;
6599
6600         /* Swap */
6601         holder = who[a];
6602         who[a] = who[b];
6603         who[b] = holder;
6604 }
6605
6606
6607 /*
6608  * Check the status of "artifacts"
6609  */
6610 static void do_cmd_knowledge_artifacts(void)
6611 {
6612         int i, k, z, x, y, n = 0;
6613         u16b why = 3;
6614         s16b *who;
6615
6616         FILE *fff;
6617
6618         char file_name[1024];
6619
6620         char base_name[MAX_NLEN];
6621
6622         bool *okay;
6623
6624         /* Open a new file */
6625         fff = my_fopen_temp(file_name, 1024);
6626
6627         if (!fff) {
6628 #ifdef JP
6629             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6630 #else
6631             msg_format("Failed to create temporary file %s.", file_name);
6632 #endif
6633             msg_print(NULL);
6634             return;
6635         }
6636
6637         /* Allocate the "who" array */
6638         C_MAKE(who, max_a_idx, s16b);
6639
6640         /* Allocate the "okay" array */
6641         C_MAKE(okay, max_a_idx, bool);
6642
6643         /* Scan the artifacts */
6644         for (k = 0; k < max_a_idx; k++)
6645         {
6646                 artifact_type *a_ptr = &a_info[k];
6647
6648                 /* Default */
6649                 okay[k] = FALSE;
6650
6651                 /* Skip "empty" artifacts */
6652                 if (!a_ptr->name) continue;
6653
6654                 /* Skip "uncreated" artifacts */
6655                 if (!a_ptr->cur_num) continue;
6656
6657                 /* Assume okay */
6658                 okay[k] = TRUE;
6659         }
6660
6661         /* Check the dungeon */
6662         for (y = 0; y < cur_hgt; y++)
6663         {
6664                 for (x = 0; x < cur_wid; x++)
6665                 {
6666                         cave_type *c_ptr = &cave[y][x];
6667
6668                         s16b this_o_idx, next_o_idx = 0;
6669
6670                         /* Scan all objects in the grid */
6671                         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
6672                         {
6673                                 object_type *o_ptr;
6674
6675                                 /* Acquire object */
6676                                 o_ptr = &o_list[this_o_idx];
6677
6678                                 /* Acquire next object */
6679                                 next_o_idx = o_ptr->next_o_idx;
6680
6681                                 /* Ignore non-artifacts */
6682                                 if (!object_is_fixed_artifact(o_ptr)) continue;
6683
6684                                 /* Ignore known items */
6685                                 if (object_is_known(o_ptr)) continue;
6686
6687                                 /* Note the artifact */
6688                                 okay[o_ptr->name1] = FALSE;
6689                         }
6690                 }
6691         }
6692
6693         /* Check the inventory and equipment */
6694         for (i = 0; i < INVEN_TOTAL; i++)
6695         {
6696                 object_type *o_ptr = &inventory[i];
6697
6698                 /* Ignore non-objects */
6699                 if (!o_ptr->k_idx) continue;
6700
6701                 /* Ignore non-artifacts */
6702                 if (!object_is_fixed_artifact(o_ptr)) continue;
6703
6704                 /* Ignore known items */
6705                 if (object_is_known(o_ptr)) continue;
6706
6707                 /* Note the artifact */
6708                 okay[o_ptr->name1] = FALSE;
6709         }
6710
6711         for (k = 0; k < max_a_idx; k++)
6712         {
6713                 if (okay[k]) who[n++] = k;
6714         }
6715
6716         /* Select the sort method */
6717         ang_sort_comp = ang_sort_art_comp;
6718         ang_sort_swap = ang_sort_art_swap;
6719
6720         /* Sort the array by dungeon depth of monsters */
6721         ang_sort(who, &why, n);
6722
6723         /* Scan the artifacts */
6724         for (k = 0; k < n; k++)
6725         {
6726                 artifact_type *a_ptr = &a_info[who[k]];
6727
6728                 /* Paranoia */
6729 #ifdef JP
6730                 strcpy(base_name, "̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à");
6731 #else
6732                 strcpy(base_name, "Unknown Artifact");
6733 #endif
6734
6735
6736                 /* Obtain the base object type */
6737                 z = lookup_kind(a_ptr->tval, a_ptr->sval);
6738
6739                 /* Real object */
6740                 if (z)
6741                 {
6742                         object_type forge;
6743                         object_type *q_ptr;
6744
6745                         /* Get local object */
6746                         q_ptr = &forge;
6747
6748                         /* Create fake object */
6749                         object_prep(q_ptr, z);
6750
6751                         /* Make it an artifact */
6752                         q_ptr->name1 = (byte)who[k];
6753
6754                         /* Display as if known */
6755                         q_ptr->ident |= IDENT_STORE;
6756
6757                         /* Describe the artifact */
6758                         object_desc(base_name, q_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
6759                 }
6760
6761                 /* Hack -- Build the artifact name */
6762 #ifdef JP
6763                 fprintf(fff, "     %s\n", base_name);
6764 #else
6765                 fprintf(fff, "     The %s\n", base_name);
6766 #endif
6767
6768         }
6769
6770         /* Free the "who" array */
6771         C_KILL(who, max_a_idx, s16b);
6772
6773         /* Free the "okay" array */
6774         C_KILL(okay, max_a_idx, bool);
6775
6776         /* Close the file */
6777         my_fclose(fff);
6778
6779         /* Display the file contents */
6780 #ifdef JP
6781         show_file(TRUE, file_name, "´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à", 0, 0);
6782 #else
6783         show_file(TRUE, file_name, "Artifacts Seen", 0, 0);
6784 #endif
6785
6786
6787         /* Remove the file */
6788         fd_kill(file_name);
6789 }
6790
6791
6792 /*
6793  * Display known uniques
6794  * With "XTRA HACK UNIQHIST" (Originally from XAngband)
6795  */
6796 static void do_cmd_knowledge_uniques(void)
6797 {
6798         int i, k, n = 0;
6799         u16b why = 2;
6800         s16b *who;
6801
6802         FILE *fff;
6803
6804         char file_name[1024];
6805
6806         int n_alive[10];
6807         int n_alive_surface = 0;
6808         int n_alive_over100 = 0;
6809         int n_alive_total = 0;
6810         int max_lev = -1;
6811
6812         for (i = 0; i < 10; i++) n_alive[i] = 0;
6813
6814         /* Open a new file */
6815         fff = my_fopen_temp(file_name, 1024);
6816
6817         if (!fff)
6818         {
6819 #ifdef JP
6820             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6821 #else
6822             msg_format("Failed to create temporary file %s.", file_name);
6823 #endif
6824             msg_print(NULL);
6825             return;
6826         }
6827
6828         /* Allocate the "who" array */
6829         C_MAKE(who, max_r_idx, s16b);
6830
6831         /* Scan the monsters */
6832         for (i = 1; i < max_r_idx; i++)
6833         {
6834                 monster_race *r_ptr = &r_info[i];
6835                 int          lev;
6836
6837                 if (!r_ptr->name) continue;
6838
6839                 /* Require unique monsters */
6840                 if (!(r_ptr->flags1 & RF1_UNIQUE)) continue;
6841
6842                 /* Only display "known" uniques */
6843                 if (!cheat_know && !r_ptr->r_sights) continue;
6844
6845                 /* Only print rarity <= 100 uniques */
6846                 if (!r_ptr->rarity || ((r_ptr->rarity > 100) && !(r_ptr->flags1 & RF1_QUESTOR))) continue;
6847
6848                 /* Only "alive" uniques */
6849                 if (r_ptr->max_num == 0) continue;
6850
6851                 if (r_ptr->level)
6852                 {
6853                         lev = (r_ptr->level - 1) / 10;
6854                         if (lev < 10)
6855                         {
6856                                 n_alive[lev]++;
6857                                 if (max_lev < lev) max_lev = lev;
6858                         }
6859                         else n_alive_over100++;
6860                 }
6861                 else n_alive_surface++;
6862
6863                 /* Collect "appropriate" monsters */
6864                 who[n++] = i;
6865         }
6866
6867         /* Select the sort method */
6868         ang_sort_comp = ang_sort_comp_hook;
6869         ang_sort_swap = ang_sort_swap_hook;
6870
6871         /* Sort the array by dungeon depth of monsters */
6872         ang_sort(who, &why, n);
6873
6874         if (n_alive_surface)
6875         {
6876 #ifdef JP
6877                 fprintf(fff, "     ÃϾ堠À¸Â¸: %3dÂÎ\n", n_alive_surface);
6878 #else
6879                 fprintf(fff, "      Surface  alive: %3d\n", n_alive_surface);
6880 #endif
6881                 n_alive_total += n_alive_surface;
6882         }
6883         for (i = 0; i <= max_lev; i++)
6884         {
6885 #ifdef JP
6886                 fprintf(fff, "%3d-%3d³¬  À¸Â¸: %3dÂÎ\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
6887 #else
6888                 fprintf(fff, "Level %3d-%3d  alive: %3d\n", 1 + i * 10, 10 + i * 10, n_alive[i]);
6889 #endif
6890                 n_alive_total += n_alive[i];
6891         }
6892         if (n_alive_over100)
6893         {
6894 #ifdef JP
6895                 fprintf(fff, "101-   ³¬  À¸Â¸: %3dÂÎ\n", n_alive_over100);
6896 #else
6897                 fprintf(fff, "Level 101-     alive: %3d\n", n_alive_over100);
6898 #endif
6899                 n_alive_total += n_alive_over100;
6900         }
6901
6902         if (n_alive_total)
6903         {
6904 #ifdef JP
6905                 fputs("---------  -----------\n", fff);
6906                 fprintf(fff, "     ¹ç·×  À¸Â¸: %3dÂÎ\n\n", n_alive_total);
6907 #else
6908                 fputs("-------------  ----------\n", fff);
6909                 fprintf(fff, "        Total  alive: %3d\n\n", n_alive_total);
6910 #endif
6911         }
6912         else
6913         {
6914 #ifdef JP
6915                 fputs("¸½ºß¤Ï´ûÃΤÎÀ¸Â¸¥æ¥Ë¡¼¥¯¤Ï¤¤¤Þ¤»¤ó¡£\n", fff);
6916 #else
6917                 fputs("No known uniques alive.\n", fff);
6918 #endif
6919         }
6920
6921         /* Scan the monster races */
6922         for (k = 0; k < n; k++)
6923         {
6924                 monster_race *r_ptr = &r_info[who[k]];
6925
6926                 /* Print a message */
6927 #ifdef JP
6928                 fprintf(fff, "     %s (¥ì¥Ù¥ë%d)\n", r_name + r_ptr->name, r_ptr->level);
6929 #else
6930                 fprintf(fff, "     %s (level %d)\n", r_name + r_ptr->name, r_ptr->level);
6931 #endif
6932         }
6933
6934         /* Free the "who" array */
6935         C_KILL(who, max_r_idx, s16b);
6936
6937         /* Close the file */
6938         my_fclose(fff);
6939
6940         /* Display the file contents */
6941 #ifdef JP
6942         show_file(TRUE, file_name, "¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼", 0, 0);
6943 #else
6944         show_file(TRUE, file_name, "Alive Uniques", 0, 0);
6945 #endif
6946
6947
6948         /* Remove the file */
6949         fd_kill(file_name);
6950 }
6951
6952
6953 /*
6954  * Display weapon-exp
6955  */
6956 static void do_cmd_knowledge_weapon_exp(void)
6957 {
6958         int i, j, num, weapon_exp;
6959
6960         FILE *fff;
6961
6962         char file_name[1024];
6963         char tmp[30];
6964
6965         /* Open a new file */
6966         fff = my_fopen_temp(file_name, 1024);
6967         if (!fff) {
6968 #ifdef JP
6969             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6970 #else
6971             msg_format("Failed to create temporary file %s.", file_name);
6972 #endif
6973             msg_print(NULL);
6974             return;
6975         }
6976
6977         for (i = 0; i < 5; i++)
6978         {
6979                 for (num = 0; num < 64; num++)
6980                 {
6981                         for (j = 0; j < max_k_idx; j++)
6982                         {
6983                                 object_kind *k_ptr = &k_info[j];
6984
6985                                 if ((k_ptr->tval == TV_SWORD - i) && (k_ptr->sval == num))
6986                                 {
6987                                         if ((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
6988
6989                                         weapon_exp = p_ptr->weapon_exp[4 - i][num];
6990                                         strip_name(tmp, j);
6991                                         fprintf(fff, "%-25s ", tmp);
6992                                         if (weapon_exp >= s_info[p_ptr->pclass].w_max[4 - i][num]) fprintf(fff, "!");
6993                                         else fprintf(fff, " ");
6994                                         fprintf(fff, "%s", exp_level_str[weapon_exp_level(weapon_exp)]);
6995                                         if (cheat_xtra) fprintf(fff, " %d", weapon_exp);
6996                                         fprintf(fff, "\n");
6997                                         break;
6998                                 }
6999                         }
7000                 }
7001         }
7002
7003         /* Close the file */
7004         my_fclose(fff);
7005
7006         /* Display the file contents */
7007 #ifdef JP
7008         show_file(TRUE, file_name, "Éð´ï¤Î·Ð¸³ÃÍ", 0, 0);
7009 #else
7010         show_file(TRUE, file_name, "Weapon Proficiency", 0, 0);
7011 #endif
7012
7013
7014         /* Remove the file */
7015         fd_kill(file_name);
7016 }
7017
7018
7019 /*!
7020  * @brief ËâË¡¤Î·Ð¸³Ãͤòɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó
7021  * Display spell-exp
7022  * @return ¤Ê¤·
7023  */
7024 static void do_cmd_knowledge_spell_exp(void)
7025 {
7026         int i = 0, spell_exp, exp_level;
7027
7028         FILE *fff;
7029         const magic_type *s_ptr;
7030
7031         char file_name[1024];
7032
7033         /* Open a new file */
7034         fff = my_fopen_temp(file_name, 1024);
7035         if (!fff) {
7036 #ifdef JP
7037             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7038 #else
7039             msg_format("Failed to create temporary file %s.", file_name);
7040 #endif
7041             msg_print(NULL);
7042             return;
7043         }
7044
7045         if (p_ptr->realm1 != REALM_NONE)
7046         {
7047 #ifdef JP
7048                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm1]);
7049 #else
7050                 fprintf(fff, "%s Spellbook\n", realm_names[p_ptr->realm1]);
7051 #endif
7052                 for (i = 0; i < 32; i++)
7053                 {
7054                         if (!is_magic(p_ptr->realm1))
7055                         {
7056                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
7057                         }
7058                         else
7059                         {
7060                                 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
7061                         }
7062                         if (s_ptr->slevel >= 99) continue;
7063                         spell_exp = p_ptr->spell_exp[i];
7064                         exp_level = spell_exp_level(spell_exp);
7065                         fprintf(fff, "%-25s ", do_spell(p_ptr->realm1, i, SPELL_NAME));
7066                         if (p_ptr->realm1 == REALM_HISSATSU)
7067                                 fprintf(fff, "[--]");
7068                         else
7069                         {
7070                                 if (exp_level >= EXP_LEVEL_MASTER) fprintf(fff, "!");
7071                                 else fprintf(fff, " ");
7072                                 fprintf(fff, "%s", exp_level_str[exp_level]);
7073                         }
7074                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
7075                         fprintf(fff, "\n");
7076                 }
7077         }
7078
7079         if (p_ptr->realm2 != REALM_NONE)
7080         {
7081 #ifdef JP
7082                 fprintf(fff, "%s¤ÎËâË¡½ñ\n", realm_names[p_ptr->realm2]);
7083 #else
7084                 fprintf(fff, "\n%s Spellbook\n", realm_names[p_ptr->realm2]);
7085 #endif
7086                 for (i = 0; i < 32; i++)
7087                 {
7088                         if (!is_magic(p_ptr->realm1))
7089                         {
7090                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
7091                         }
7092                         else
7093                         {
7094                                 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][i];
7095                         }
7096                         if (s_ptr->slevel >= 99) continue;
7097
7098                         spell_exp = p_ptr->spell_exp[i + 32];
7099                         exp_level = spell_exp_level(spell_exp);
7100                         fprintf(fff, "%-25s ", do_spell(p_ptr->realm2, i, SPELL_NAME));
7101                         if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
7102                         else fprintf(fff, " ");
7103                         fprintf(fff, "%s", exp_level_str[exp_level]);
7104                         if (cheat_xtra) fprintf(fff, " %d", spell_exp);
7105                         fprintf(fff, "\n");
7106                 }
7107         }
7108
7109         /* Close the file */
7110         my_fclose(fff);
7111
7112         /* Display the file contents */
7113 #ifdef JP
7114         show_file(TRUE, file_name, "ËâË¡¤Î·Ð¸³ÃÍ", 0, 0);
7115 #else
7116         show_file(TRUE, file_name, "Spell Proficiency", 0, 0);
7117 #endif
7118
7119
7120         /* Remove the file */
7121         fd_kill(file_name);
7122 }
7123
7124
7125 /*!
7126  * @brief ¥¹¥­¥ë¾ðÊó¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
7127  * Display skill-exp
7128  * @return ¤Ê¤·
7129  */
7130 static void do_cmd_knowledge_skill_exp(void)
7131 {
7132         int i = 0, skill_exp;
7133
7134         FILE *fff;
7135
7136         char file_name[1024];
7137 #ifdef JP
7138         char skill_name[3][17]={"¥Þ¡¼¥·¥ã¥ë¥¢¡¼¥Ä", "ÆóÅáή          ", "¾èÇÏ            "};
7139 #else
7140         char skill_name[3][20]={"Martial Arts    ", "Dual Wielding   ", "Riding          "};
7141 #endif
7142
7143         /* Open a new file */
7144         fff = my_fopen_temp(file_name, 1024);
7145         if (!fff) {
7146 #ifdef JP
7147             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7148 #else
7149             msg_format("Failed to create temporary file %s.", file_name);
7150 #endif
7151             msg_print(NULL);
7152             return;
7153         }
7154
7155         for (i = 0; i < 3; i++)
7156         {
7157                 skill_exp = p_ptr->skill_exp[i];
7158                 fprintf(fff, "%-20s ", skill_name[i]);
7159                 if (skill_exp >= s_info[p_ptr->pclass].s_max[i]) fprintf(fff, "!");
7160                 else fprintf(fff, " ");
7161                 fprintf(fff, "%s", exp_level_str[(i == GINOU_RIDING) ? riding_exp_level(skill_exp) : weapon_exp_level(skill_exp)]);
7162                 if (cheat_xtra) fprintf(fff, " %d", skill_exp);
7163                 fprintf(fff, "\n");
7164         }
7165
7166         /* Close the file */
7167         my_fclose(fff);
7168
7169         /* Display the file contents */
7170 #ifdef JP
7171         show_file(TRUE, file_name, "µ»Ç½¤Î·Ð¸³ÃÍ", 0, 0);
7172 #else
7173         show_file(TRUE, file_name, "Miscellaneous Proficiency", 0, 0);
7174 #endif
7175
7176
7177         /* Remove the file */
7178         fd_kill(file_name);
7179 }
7180
7181
7182 /*!
7183  * @brief ±Ññ¸ì¡¢¶ç¡¢Àâ¤òÊ£¿ô·Á¤òÊÑ´¹¤¹¤ë / Pluralize a monster name
7184  * @param Name ÊÑ´¹¤·¤¿¤¤Ê¸»úÎó¤Î»²¾È¥Ý¥¤¥ó¥¿
7185  * @return ¤Ê¤·
7186  */
7187 void plural_aux(char *Name)
7188 {
7189         int NameLen = strlen(Name);
7190
7191         if (my_strstr(Name, "Disembodied hand"))
7192         {
7193                 strcpy(Name, "Disembodied hands that strangled people");
7194         }
7195         else if (my_strstr(Name, "Colour out of space"))
7196         {
7197                 strcpy(Name, "Colours out of space");
7198         }
7199         else if (my_strstr(Name, "stairway to hell"))
7200         {
7201                 strcpy(Name, "stairways to hell");
7202         }
7203         else if (my_strstr(Name, "Dweller on the threshold"))
7204         {
7205                 strcpy(Name, "Dwellers on the threshold");
7206         }
7207         else if (my_strstr(Name, " of "))
7208         {
7209                 cptr aider = my_strstr(Name, " of ");
7210                 char dummy[80];
7211                 int i = 0;
7212                 cptr ctr = Name;
7213
7214                 while (ctr < aider)
7215                 {
7216                         dummy[i] = *ctr;
7217                         ctr++; i++;
7218                 }
7219
7220                 if (dummy[i-1] == 's')
7221                 {
7222                         strcpy(&(dummy[i]), "es");
7223                         i++;
7224                 }
7225                 else
7226                 {
7227                         strcpy(&(dummy[i]), "s");
7228                 }
7229
7230                 strcpy(&(dummy[i+1]), aider);
7231                 strcpy(Name, dummy);
7232         }
7233         else if (my_strstr(Name, "coins"))
7234         {
7235                 char dummy[80];
7236                 strcpy(dummy, "piles of ");
7237                 strcat(dummy, Name);
7238                 strcpy(Name, dummy);
7239                 return;
7240         }
7241         else if (my_strstr(Name, "Manes"))
7242         {
7243                 return;
7244         }
7245         else if (streq(&(Name[NameLen - 2]), "ey"))
7246         {
7247                 strcpy(&(Name[NameLen - 2]), "eys");
7248         }
7249         else if (Name[NameLen - 1] == 'y')
7250         {
7251                 strcpy(&(Name[NameLen - 1]), "ies");
7252         }
7253         else if (streq(&(Name[NameLen - 4]), "ouse"))
7254         {
7255                 strcpy(&(Name[NameLen - 4]), "ice");
7256         }
7257         else if (streq(&(Name[NameLen - 2]), "us"))
7258         {
7259                 strcpy(&(Name[NameLen - 2]), "i");
7260         }
7261         else if (streq(&(Name[NameLen - 6]), "kelman"))
7262         {
7263                 strcpy(&(Name[NameLen - 6]), "kelmen");
7264         }
7265         else if (streq(&(Name[NameLen - 8]), "wordsman"))
7266         {
7267                 strcpy(&(Name[NameLen - 8]), "wordsmen");
7268         }
7269         else if (streq(&(Name[NameLen - 7]), "oodsman"))
7270         {
7271                 strcpy(&(Name[NameLen - 7]), "oodsmen");
7272         }
7273         else if (streq(&(Name[NameLen - 7]), "eastman"))
7274         {
7275                 strcpy(&(Name[NameLen - 7]), "eastmen");
7276         }
7277         else if (streq(&(Name[NameLen - 8]), "izardman"))
7278         {
7279                 strcpy(&(Name[NameLen - 8]), "izardmen");
7280         }
7281         else if (streq(&(Name[NameLen - 5]), "geist"))
7282         {
7283                 strcpy(&(Name[NameLen - 5]), "geister");
7284         }
7285         else if (streq(&(Name[NameLen - 2]), "ex"))
7286         {
7287                 strcpy(&(Name[NameLen - 2]), "ices");
7288         }
7289         else if (streq(&(Name[NameLen - 2]), "lf"))
7290         {
7291                 strcpy(&(Name[NameLen - 2]), "lves");
7292         }
7293         else if (suffix(Name, "ch") ||
7294                  suffix(Name, "sh") ||
7295                          suffix(Name, "nx") ||
7296                          suffix(Name, "s") ||
7297                          suffix(Name, "o"))
7298         {
7299                 strcpy(&(Name[NameLen]), "es");
7300         }
7301         else
7302         {
7303                 strcpy(&(Name[NameLen]), "s");
7304         }
7305 }
7306
7307 /*!
7308  * @brief ¸½ºß¤Î¥Ú¥Ã¥È¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
7309  * Display current pets
7310  * @return ¤Ê¤·
7311  */
7312 static void do_cmd_knowledge_pets(void)
7313 {
7314         int             i;
7315         FILE            *fff;
7316         monster_type    *m_ptr;
7317         char            pet_name[80];
7318         int             t_friends = 0;
7319         int             show_upkeep = 0;
7320         char            file_name[1024];
7321
7322
7323         /* Open a new file */
7324         fff = my_fopen_temp(file_name, 1024);
7325         if (!fff) {
7326 #ifdef JP
7327             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7328 #else
7329             msg_format("Failed to create temporary file %s.", file_name);
7330 #endif
7331             msg_print(NULL);
7332             return;
7333         }
7334
7335         /* Process the monsters (backwards) */
7336         for (i = m_max - 1; i >= 1; i--)
7337         {
7338                 /* Access the monster */
7339                 m_ptr = &m_list[i];
7340
7341                 /* Ignore "dead" monsters */
7342                 if (!m_ptr->r_idx) continue;
7343
7344                 /* Calculate "upkeep" for pets */
7345                 if (is_pet(m_ptr))
7346                 {
7347                         t_friends++;
7348                         monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
7349                         fprintf(fff, "%s (%s)\n", pet_name, look_mon_desc(m_ptr, 0x00));
7350                 }
7351         }
7352
7353         show_upkeep = calculate_upkeep();
7354
7355         fprintf(fff, "----------------------------------------------\n");
7356 #ifdef JP
7357         fprintf(fff, "    ¹ç·×: %d ÂΤΥڥåÈ\n", t_friends);
7358         fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
7359 #else
7360         fprintf(fff, "   Total: %d pet%s.\n",
7361                 t_friends, (t_friends == 1 ? "" : "s"));
7362         fprintf(fff, "   Upkeep: %d%% mana.\n", show_upkeep);
7363 #endif
7364
7365
7366
7367         /* Close the file */
7368         my_fclose(fff);
7369
7370         /* Display the file contents */
7371 #ifdef JP
7372         show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
7373 #else
7374         show_file(TRUE, file_name, "Current Pets", 0, 0);
7375 #endif
7376
7377
7378         /* Remove the file */
7379         fd_kill(file_name);
7380 }
7381
7382
7383 /*!
7384  * @brief ¸½ºß¤Î¥Ú¥Ã¥È¤òɽ¼¨¤¹¤ë¥³¥Þ¥ó¥É¤Î¥á¥¤¥ó¥ë¡¼¥Á¥ó /
7385  * Total kill count
7386  * @return ¤Ê¤·
7387  * @note the player ghosts are ignored.  XXX XXX XXX
7388  */
7389 static void do_cmd_knowledge_kill_count(void)
7390 {
7391         int i, k, n = 0;
7392         u16b why = 2;
7393         s16b *who;
7394
7395         FILE *fff;
7396
7397         char file_name[1024];
7398
7399         s32b Total = 0;
7400
7401
7402         /* Open a new file */
7403         fff = my_fopen_temp(file_name, 1024);
7404
7405         if (!fff) {
7406 #ifdef JP
7407             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7408 #else
7409             msg_format("Failed to create temporary file %s.", file_name);
7410 #endif
7411             msg_print(NULL);
7412             return;
7413         }
7414
7415         /* Allocate the "who" array */
7416         C_MAKE(who, max_r_idx, s16b);
7417
7418         {
7419                 /* Monsters slain */
7420                 int kk;
7421
7422                 for (kk = 1; kk < max_r_idx; kk++)
7423                 {
7424                         monster_race *r_ptr = &r_info[kk];
7425
7426                         if (r_ptr->flags1 & (RF1_UNIQUE))
7427                         {
7428                                 bool dead = (r_ptr->max_num == 0);
7429
7430                                 if (dead)
7431                                 {
7432                                         Total++;
7433                                 }
7434                         }
7435                         else
7436                         {
7437                                 s16b This = r_ptr->r_pkills;
7438
7439                                 if (This > 0)
7440                                 {
7441                                         Total += This;
7442                                 }
7443                         }
7444                 }
7445
7446                 if (Total < 1)
7447 #ifdef JP
7448                         fprintf(fff,"¤¢¤Ê¤¿¤Ï¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Ê¤¤¡£\n\n");
7449 #else
7450                         fprintf(fff,"You have defeated no enemies yet.\n\n");
7451 #endif
7452                 else
7453 #ifdef JP
7454                         fprintf(fff,"¤¢¤Ê¤¿¤Ï%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", (long int)Total);
7455 #else
7456                         fprintf(fff,"You have defeated %ld %s.\n\n", (long int)Total, (Total == 1) ? "enemy" : "enemies");
7457 #endif
7458         }
7459
7460         Total = 0;
7461
7462         /* Scan the monsters */
7463         for (i = 1; i < max_r_idx; i++)
7464         {
7465                 monster_race *r_ptr = &r_info[i];
7466
7467                 /* Use that monster */
7468                 if (r_ptr->name) who[n++] = i;
7469         }
7470
7471         /* Select the sort method */
7472         ang_sort_comp = ang_sort_comp_hook;
7473         ang_sort_swap = ang_sort_swap_hook;
7474
7475         /* Sort the array by dungeon depth of monsters */
7476         ang_sort(who, &why, n);
7477
7478         /* Scan the monster races */
7479         for (k = 0; k < n; k++)
7480         {
7481                 monster_race *r_ptr = &r_info[who[k]];
7482
7483                 if (r_ptr->flags1 & (RF1_UNIQUE))
7484                 {
7485                         bool dead = (r_ptr->max_num == 0);
7486
7487                         if (dead)
7488                         {
7489                                 /* Print a message */
7490                                 fprintf(fff, "     %s\n",
7491                                     (r_name + r_ptr->name));
7492                                 Total++;
7493                         }
7494                 }
7495                 else
7496                 {
7497                         s16b This = r_ptr->r_pkills;
7498
7499                         if (This > 0)
7500                         {
7501 #ifdef JP
7502                                 /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita */
7503                                 if (my_strchr("pt", r_ptr->d_char))
7504                                         fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
7505                                 else
7506                                         fprintf(fff, "     %3d ÂΤΠ%s\n", This, r_name + r_ptr->name);
7507 #else
7508                                 if (This < 2)
7509                                 {
7510                                         if (my_strstr(r_name + r_ptr->name, "coins"))
7511                                         {
7512                                                 fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
7513                                         }
7514                                         else
7515                                         {
7516                                                 fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
7517                                         }
7518                                 }
7519                                 else
7520                                 {
7521                                         char ToPlural[80];
7522                                         strcpy(ToPlural, (r_name + r_ptr->name));
7523                                         plural_aux(ToPlural);
7524                                         fprintf(fff, "     %d %s\n", This, ToPlural);
7525                                 }
7526 #endif
7527
7528
7529                                 Total += This;
7530                         }
7531                 }
7532         }
7533
7534         fprintf(fff,"----------------------------------------------\n");
7535 #ifdef JP
7536         fprintf(fff,"    ¹ç·×: %lu ÂΤòÅݤ·¤¿¡£\n", (unsigned long int)Total);
7537 #else
7538         fprintf(fff,"   Total: %lu creature%s killed.\n",
7539                 (unsigned long int)Total, (Total == 1 ? "" : "s"));
7540 #endif
7541
7542
7543         /* Free the "who" array */
7544         C_KILL(who, max_r_idx, s16b);
7545
7546         /* Close the file */
7547         my_fclose(fff);
7548
7549         /* Display the file contents */
7550 #ifdef JP
7551         show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
7552 #else
7553         show_file(TRUE, file_name, "Kill Count", 0, 0);
7554 #endif
7555
7556
7557         /* Remove the file */
7558         fd_kill(file_name);
7559 }
7560
7561
7562 /*!
7563  * @brief ¥â¥ó¥¹¥¿¡¼¾ðÊó¥ê¥¹¥ÈÃæ¤Î¥°¥ë¡¼¥×¤òɽ¼¨¤¹¤ë /
7564  * Display the object groups.
7565  * @param col ³«»Ï¹Ô
7566  * @param row ³«»ÏÎó
7567  * @param wid É½¼¨Ê¸»ú¿ôÉý
7568  * @param per_page ¥ê¥¹¥È¤Îɽ¼¨¹Ô
7569  * @param grp_idx ¥°¥ë¡¼¥×¤ÎIDÇÛÎó
7570  * @param group_text ¥°¥ë¡¼¥×̾¤Îʸ»úÎóÇÛÎó
7571  * @param grp_cur ¸½ºß¤ÎÁªÂòID
7572  * @param grp_top ¸½ºß¤ÎÁªÂò¥ê¥¹¥ÈºÇ¾åÉôID
7573  * @return ¤Ê¤·
7574  */
7575 static void display_group_list(int col, int row, int wid, int per_page,
7576         int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
7577 {
7578         int i;
7579
7580         /* Display lines until done */
7581         for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
7582         {
7583                 /* Get the group index */
7584                 int grp = grp_idx[grp_top + i];
7585
7586                 /* Choose a color */
7587                 byte attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
7588
7589                 /* Erase the entire line */
7590                 Term_erase(col, row + i, wid);
7591
7592                 /* Display the group label */
7593                 c_put_str(attr, group_text[grp], row + i, col);
7594         }
7595 }
7596
7597
7598 /* 
7599  * Move the cursor in a browser window 
7600  */
7601 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt, 
7602                                                    int *list_cur, int list_cnt)
7603 {
7604         int d;
7605         int col = *column;
7606         int grp = *grp_cur;
7607         int list = *list_cur;
7608
7609         /* Extract direction */
7610         if (ch == ' ')
7611         {
7612                 /* Hack -- scroll up full screen */
7613                 d = 3;
7614         }
7615         else if (ch == '-')
7616         {
7617                 /* Hack -- scroll down full screen */
7618                 d = 9;
7619         }
7620         else
7621         {
7622                 d = get_keymap_dir(ch);
7623         }
7624
7625         if (!d) return;
7626
7627         /* Diagonals - hack */
7628         if ((ddx[d] > 0) && ddy[d])
7629         {
7630                 int browser_rows;
7631                 int wid, hgt;
7632
7633                 /* Get size */
7634                 Term_get_size(&wid, &hgt);
7635
7636                 browser_rows = hgt - 8;
7637
7638                 /* Browse group list */
7639                 if (!col)
7640                 {
7641                         int old_grp = grp;
7642
7643                         /* Move up or down */
7644                         grp += ddy[d] * (browser_rows - 1);
7645
7646                         /* Verify */
7647                         if (grp >= grp_cnt)     grp = grp_cnt - 1;
7648                         if (grp < 0) grp = 0;
7649                         if (grp != old_grp)     list = 0;
7650                 }
7651
7652                 /* Browse sub-list list */
7653                 else
7654                 {
7655                         /* Move up or down */
7656                         list += ddy[d] * browser_rows;
7657
7658                         /* Verify */
7659                         if (list >= list_cnt) list = list_cnt - 1;
7660                         if (list < 0) list = 0;
7661                 }
7662
7663                 (*grp_cur) = grp;
7664                 (*list_cur) = list;
7665
7666                 return;
7667         }
7668
7669         if (ddx[d])
7670         {
7671                 col += ddx[d];
7672                 if (col < 0) col = 0;
7673                 if (col > 1) col = 1;
7674
7675                 (*column) = col;
7676
7677                 return;
7678         }
7679
7680         /* Browse group list */
7681         if (!col)
7682         {
7683                 int old_grp = grp;
7684
7685                 /* Move up or down */
7686                 grp += ddy[d];
7687
7688                 /* Verify */
7689                 if (grp >= grp_cnt)     grp = grp_cnt - 1;
7690                 if (grp < 0) grp = 0;
7691                 if (grp != old_grp)     list = 0;
7692         }
7693
7694         /* Browse sub-list list */
7695         else
7696         {
7697                 /* Move up or down */
7698                 list += ddy[d];
7699
7700                 /* Verify */
7701                 if (list >= list_cnt) list = list_cnt - 1;
7702                 if (list < 0) list = 0;
7703         }
7704
7705         (*grp_cur) = grp;
7706         (*list_cur) = list;
7707 }
7708
7709
7710 /*
7711  * Display visuals.
7712  */
7713 static void display_visual_list(int col, int row, int height, int width, byte attr_top, byte char_left)
7714 {
7715         int i, j;
7716
7717         /* Clear the display lines */
7718         for (i = 0; i < height; i++)
7719         {
7720                 Term_erase(col, row + i, width);
7721         }
7722
7723         /* Bigtile mode uses double width */
7724         if (use_bigtile) width /= 2;
7725
7726         /* Display lines until done */
7727         for (i = 0; i < height; i++)
7728         {
7729                 /* Display columns until done */
7730                 for (j = 0; j < width; j++)
7731                 {
7732                         byte a;
7733                         char c;
7734                         int x = col + j;
7735                         int y = row + i;
7736                         int ia, ic;
7737
7738                         /* Bigtile mode uses double width */
7739                         if (use_bigtile) x += j;
7740
7741                         ia = attr_top + i;
7742                         ic = char_left + j;
7743
7744                         /* Ignore illegal characters */
7745                         if (ia > 0x7f || ic > 0xff || ic < ' ' ||
7746                             (!use_graphics && ic > 0x7f))
7747                                 continue;
7748
7749                         a = (byte)ia;
7750                         c = (char)ic;
7751
7752                         /* Force correct code for both ASCII character and tile */
7753                         if (c & 0x80) a |= 0x80;
7754
7755                         /* Display symbol */
7756                         Term_queue_bigchar(x, y, a, c, 0, 0);
7757                 }
7758         }
7759 }
7760
7761
7762 /*
7763  * Place the cursor at the collect position for visual mode
7764  */
7765 static void place_visual_list_cursor(int col, int row, byte a, byte c, byte attr_top, byte char_left)
7766 {
7767         int i = (a & 0x7f) - attr_top;
7768         int j = c - char_left;
7769
7770         int x = col + j;
7771         int y = row + i;
7772
7773         /* Bigtile mode uses double width */
7774         if (use_bigtile) x += j;
7775
7776         /* Place the cursor */
7777         Term_gotoxy(x, y);
7778 }
7779
7780
7781 /*
7782  *  Clipboard variables for copy&paste in visual mode
7783  */
7784 static byte attr_idx = 0;
7785 static byte char_idx = 0;
7786
7787 /* Hack -- for feature lighting */
7788 static byte attr_idx_feat[F_LIT_MAX];
7789 static byte char_idx_feat[F_LIT_MAX];
7790
7791 /*
7792  *  Do visual mode command -- Change symbols
7793  */
7794 static bool visual_mode_command(char ch, bool *visual_list_ptr,
7795                                 int height, int width,
7796                                 byte *attr_top_ptr, byte *char_left_ptr,
7797                                 byte *cur_attr_ptr, byte *cur_char_ptr, bool *need_redraw)
7798 {
7799         static byte attr_old = 0, char_old = 0;
7800
7801         switch (ch)
7802         {
7803         case ESCAPE:
7804                 if (*visual_list_ptr)
7805                 {
7806                         /* Cancel change */
7807                         *cur_attr_ptr = attr_old;
7808                         *cur_char_ptr = char_old;
7809                         *visual_list_ptr = FALSE;
7810
7811                         return TRUE;
7812                 }
7813                 break;
7814
7815         case '\n':
7816         case '\r':
7817                 if (*visual_list_ptr)
7818                 {
7819                         /* Accept change */
7820                         *visual_list_ptr = FALSE;
7821                         *need_redraw = TRUE;
7822
7823                         return TRUE;
7824                 }
7825                 break;
7826
7827         case 'V':
7828         case 'v':
7829                 if (!*visual_list_ptr)
7830                 {
7831                         *visual_list_ptr = TRUE;
7832
7833                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7834                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7835
7836                         attr_old = *cur_attr_ptr;
7837                         char_old = *cur_char_ptr;
7838
7839                         return TRUE;
7840                 }
7841                 break;
7842
7843         case 'C':
7844         case 'c':
7845                 {
7846                         int i;
7847
7848                         /* Set the visual */
7849                         attr_idx = *cur_attr_ptr;
7850                         char_idx = *cur_char_ptr;
7851
7852                         /* Hack -- for feature lighting */
7853                         for (i = 0; i < F_LIT_MAX; i++)
7854                         {
7855                                 attr_idx_feat[i] = 0;
7856                                 char_idx_feat[i] = 0;
7857                         }
7858                 }
7859                 return TRUE;
7860
7861         case 'P':
7862         case 'p':
7863                 if (attr_idx || (!(char_idx & 0x80) && char_idx)) /* Allow TERM_DARK text */
7864                 {
7865                         /* Set the char */
7866                         *cur_attr_ptr = attr_idx;
7867                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7868                         if (!*visual_list_ptr) *need_redraw = TRUE;
7869                 }
7870
7871                 if (char_idx)
7872                 {
7873                         /* Set the char */
7874                         *cur_char_ptr = char_idx;
7875                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7876                         if (!*visual_list_ptr) *need_redraw = TRUE;
7877                 }
7878
7879                 return TRUE;
7880
7881         default:
7882                 if (*visual_list_ptr)
7883                 {
7884                         int eff_width;
7885                         int d = get_keymap_dir(ch);
7886                         byte a = (*cur_attr_ptr & 0x7f);
7887                         byte c = *cur_char_ptr;
7888
7889                         if (use_bigtile) eff_width = width / 2;
7890                         else eff_width = width;
7891
7892                         /* Restrict direction */
7893                         if ((a == 0) && (ddy[d] < 0)) d = 0;
7894                         if ((c == 0) && (ddx[d] < 0)) d = 0;
7895                         if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
7896                         if ((c == 0xff) && (ddx[d] > 0)) d = 0;
7897
7898                         a += ddy[d];
7899                         c += ddx[d];
7900
7901                         /* Force correct code for both ASCII character and tile */
7902                         if (c & 0x80) a |= 0x80;
7903
7904                         /* Set the visual */
7905                         *cur_attr_ptr = a;
7906                         *cur_char_ptr = c;
7907
7908
7909                         /* Move the frame */
7910                         if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
7911                         if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
7912                         if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
7913                         if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
7914                         return TRUE;
7915                 }
7916                 break;
7917         }
7918
7919         /* Visual mode command is not used */
7920         return FALSE;
7921 }
7922
7923
7924 /*
7925  * Display the monsters in a group.
7926  */
7927 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
7928         int mon_cur, int mon_top, bool visual_only)
7929 {
7930         int i;
7931
7932         /* Display lines until done */
7933         for (i = 0; i < per_page && (mon_idx[mon_top + i] >= 0); i++)
7934         {
7935                 byte attr;
7936
7937                 /* Get the race index */
7938                 int r_idx = mon_idx[mon_top + i] ;
7939
7940                 /* Access the race */
7941                 monster_race *r_ptr = &r_info[r_idx];
7942
7943                 /* Choose a color */
7944                 attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
7945
7946                 /* Display the name */
7947                 c_prt(attr, (r_name + r_ptr->name), row + i, col);
7948
7949                 /* Hack -- visual_list mode */
7950                 if (per_page == 1)
7951                 {
7952                         c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 56 : 61);
7953                 }
7954                 if (p_ptr->wizard || visual_only)
7955                 {
7956                         c_prt(attr, format("%d", r_idx), row + i, 62);
7957                 }
7958
7959                 /* Erase chars before overwritten by the race letter */
7960                 Term_erase(69, row + i, 255);
7961
7962                 /* Display symbol */
7963                 Term_queue_bigchar(use_bigtile ? 69 : 70, row + i, r_ptr->x_attr, r_ptr->x_char, 0, 0);
7964
7965                 if (!visual_only)
7966                 {
7967                         /* Display kills */
7968                         if (!(r_ptr->flags1 & RF1_UNIQUE)) put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
7969 #ifdef JP
7970                         else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "»àË´" : "À¸Â¸"), row + i, 74);
7971 #else
7972                         else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? " dead" : "alive"), row + i, 73);
7973 #endif
7974                 }
7975         }
7976
7977         /* Clear remaining lines */
7978         for (; i < per_page; i++)
7979         {
7980                 Term_erase(col, row + i, 255);
7981         }
7982 }
7983
7984
7985 /*
7986  * Display known monsters.
7987  */
7988 static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, int direct_r_idx)
7989 {
7990         int i, len, max;
7991         int grp_cur, grp_top, old_grp_cur;
7992         int mon_cur, mon_top;
7993         int grp_cnt, grp_idx[100];
7994         int mon_cnt;
7995         s16b *mon_idx;
7996
7997         int column = 0;
7998         bool flag;
7999         bool redraw;
8000
8001         bool visual_list = FALSE;
8002         byte attr_top = 0, char_left = 0;
8003
8004         int browser_rows;
8005         int wid, hgt;
8006
8007         byte mode;
8008
8009         /* Get size */
8010         Term_get_size(&wid, &hgt);
8011
8012         browser_rows = hgt - 8;
8013
8014         /* Allocate the "mon_idx" array */
8015         C_MAKE(mon_idx, max_r_idx, s16b);
8016
8017         max = 0;
8018         grp_cnt = 0;
8019
8020         if (direct_r_idx < 0)
8021         {
8022                 mode = visual_only ? 0x03 : 0x01;
8023
8024                 /* Check every group */
8025                 for (i = 0; monster_group_text[i] != NULL; i++)
8026                 {
8027                         /* Measure the label */
8028                         len = strlen(monster_group_text[i]);
8029
8030                         /* Save the maximum length */
8031                         if (len > max) max = len;
8032
8033                         /* See if any monsters are known */
8034                         if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, mode))
8035                         {
8036                                 /* Build a list of groups with known monsters */
8037                                 grp_idx[grp_cnt++] = i;
8038                         }
8039                 }
8040
8041                 mon_cnt = 0;
8042         }
8043         else
8044         {
8045                 mon_idx[0] = direct_r_idx;
8046                 mon_cnt = 1;
8047
8048                 /* Terminate the list */
8049                 mon_idx[1] = -1;
8050
8051                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8052                         &attr_top, &char_left, &r_info[direct_r_idx].x_attr, &r_info[direct_r_idx].x_char, need_redraw);
8053         }
8054
8055         /* Terminate the list */
8056         grp_idx[grp_cnt] = -1;
8057
8058         old_grp_cur = -1;
8059         grp_cur = grp_top = 0;
8060         mon_cur = mon_top = 0;
8061
8062         flag = FALSE;
8063         redraw = TRUE;
8064
8065         mode = visual_only ? 0x02 : 0x00;
8066
8067         while (!flag)
8068         {
8069                 char ch;
8070                 monster_race *r_ptr;
8071
8072                 if (redraw)
8073                 {
8074                         clear_from(0);
8075
8076 #ifdef JP
8077                         prt(format("%s - ¥â¥ó¥¹¥¿¡¼", !visual_only ? "Ãμ±" : "ɽ¼¨"), 2, 0);
8078                         if (direct_r_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8079                         prt("̾Á°", 4, max + 3);
8080                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8081                         prt("ʸ»ú", 4, 67);
8082                         if (!visual_only) prt("»¦³²¿ô", 4, 72);
8083 #else
8084                         prt(format("%s - monsters", !visual_only ? "Knowledge" : "Visuals"), 2, 0);
8085                         if (direct_r_idx < 0) prt("Group", 4, 0);
8086                         prt("Name", 4, max + 3);
8087                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8088                         prt("Sym", 4, 68);
8089                         if (!visual_only) prt("Kills", 4, 73);
8090 #endif
8091
8092                         for (i = 0; i < 78; i++)
8093                         {
8094                                 Term_putch(i, 5, TERM_WHITE, '=');
8095                         }
8096
8097                         if (direct_r_idx < 0)
8098                         {
8099                                 for (i = 0; i < browser_rows; i++)
8100                                 {
8101                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8102                                 }
8103                         }
8104
8105                         redraw = FALSE;
8106                 }
8107
8108                 if (direct_r_idx < 0)
8109                 {
8110                         /* Scroll group list */
8111                         if (grp_cur < grp_top) grp_top = grp_cur;
8112                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8113
8114                         /* Display a list of monster groups */
8115                         display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
8116
8117                         if (old_grp_cur != grp_cur)
8118                         {
8119                                 old_grp_cur = grp_cur;
8120
8121                                 /* Get a list of monsters in the current group */
8122                                 mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, mode);
8123                         }
8124
8125                         /* Scroll monster list */
8126                         while (mon_cur < mon_top)
8127                                 mon_top = MAX(0, mon_top - browser_rows/2);
8128                         while (mon_cur >= mon_top + browser_rows)
8129                                 mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows/2);
8130                 }
8131
8132                 if (!visual_list)
8133                 {
8134                         /* Display a list of monsters in the current group */
8135                         display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top, visual_only);
8136                 }
8137                 else
8138                 {
8139                         mon_top = mon_cur;
8140
8141                         /* Display a monster name */
8142                         display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top, visual_only);
8143
8144                         /* Display visual list below first monster */
8145                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8146                 }
8147
8148                 /* Prompt */
8149 #ifdef JP
8150                 prt(format("<Êý¸þ>%s%s%s, ESC",
8151                         (!visual_list && !visual_only) ? ", 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë" : "",
8152                         visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8153                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8154                         hgt - 1, 0);
8155 #else
8156                 prt(format("<dir>%s%s%s, ESC",
8157                         (!visual_list && !visual_only) ? ", 'r' to recall" : "",
8158                         visual_list ? ", ENTER to accept" : ", 'v' for visuals",
8159                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8160                         hgt - 1, 0);
8161 #endif
8162
8163                 /* Get the current monster */
8164                 r_ptr = &r_info[mon_idx[mon_cur]];
8165
8166                 if (!visual_only)
8167                 {
8168                         /* Mega Hack -- track this monster race */
8169                         if (mon_cnt) monster_race_track(mon_idx[mon_cur]);
8170
8171                         /* Hack -- handle stuff */
8172                         handle_stuff();
8173                 }
8174
8175                 if (visual_list)
8176                 {
8177                         place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
8178                 }
8179                 else if (!column)
8180                 {
8181                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8182                 }
8183                 else
8184                 {
8185                         Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
8186                 }
8187
8188                 ch = inkey();
8189
8190                 /* Do visual mode command if needed */
8191                 if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &r_ptr->x_attr, &r_ptr->x_char, need_redraw))
8192                 {
8193                         if (direct_r_idx >= 0)
8194                         {
8195                                 switch (ch)
8196                                 {
8197                                 case '\n':
8198                                 case '\r':
8199                                 case ESCAPE:
8200                                         flag = TRUE;
8201                                         break;
8202                                 }
8203                         }
8204                         continue;
8205                 }
8206
8207                 switch (ch)
8208                 {
8209                         case ESCAPE:
8210                         {
8211                                 flag = TRUE;
8212                                 break;
8213                         }
8214
8215                         case 'R':
8216                         case 'r':
8217                         {
8218                                 /* Recall on screen */
8219                                 if (!visual_list && !visual_only && (mon_idx[mon_cur] > 0))
8220                                 {
8221                                         screen_roff(mon_idx[mon_cur], 0);
8222
8223                                         (void)inkey();
8224
8225                                         redraw = TRUE;
8226                                 }
8227                                 break;
8228                         }
8229
8230                         default:
8231                         {
8232                                 /* Move the cursor */
8233                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
8234
8235                                 break;
8236                         }
8237                 }
8238         }
8239
8240         /* Free the "mon_idx" array */
8241         C_KILL(mon_idx, max_r_idx, s16b);
8242 }
8243
8244
8245 /*
8246  * Display the objects in a group.
8247  */
8248 static void display_object_list(int col, int row, int per_page, int object_idx[],
8249         int object_cur, int object_top, bool visual_only)
8250 {
8251         int i;
8252
8253         /* Display lines until done */
8254         for (i = 0; i < per_page && (object_idx[object_top + i] >= 0); i++)
8255         {
8256                 char o_name[80];
8257                 byte a, c;
8258                 object_kind *flavor_k_ptr;
8259
8260                 /* Get the object index */
8261                 int k_idx = object_idx[object_top + i];
8262
8263                 /* Access the object */
8264                 object_kind *k_ptr = &k_info[k_idx];
8265
8266                 /* Choose a color */
8267                 byte attr = ((k_ptr->aware || visual_only) ? TERM_WHITE : TERM_SLATE);
8268                 byte cursor = ((k_ptr->aware || visual_only) ? TERM_L_BLUE : TERM_BLUE);
8269
8270
8271                 if (!visual_only && k_ptr->flavor)
8272                 {
8273                         /* Appearance of this object is shuffled */
8274                         flavor_k_ptr = &k_info[k_ptr->flavor];
8275                 }
8276                 else
8277                 {
8278                         /* Appearance of this object is very normal */
8279                         flavor_k_ptr = k_ptr;
8280                 }
8281
8282
8283
8284                 attr = ((i + object_top == object_cur) ? cursor : attr);
8285
8286                 if (!k_ptr->flavor || (!visual_only && k_ptr->aware))
8287                 {
8288                         /* Tidy name */
8289                         strip_name(o_name, k_idx);
8290                 }
8291                 else
8292                 {
8293                         /* Flavor name */
8294                         strcpy(o_name, k_name + flavor_k_ptr->flavor_name);
8295                 }
8296
8297                 /* Display the name */
8298                 c_prt(attr, o_name, row + i, col);
8299
8300                 /* Hack -- visual_list mode */
8301                 if (per_page == 1)
8302                 {
8303                         c_prt(attr, format("%02x/%02x", flavor_k_ptr->x_attr, flavor_k_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 64 : 68);
8304                 }
8305                 if (p_ptr->wizard || visual_only)
8306                 {
8307                         c_prt(attr, format("%d", k_idx), row + i, 70);
8308                 }
8309
8310                 a = flavor_k_ptr->x_attr;
8311                 c = flavor_k_ptr->x_char;
8312
8313                 /* Display symbol */
8314                 Term_queue_bigchar(use_bigtile ? 76 : 77, row + i, a, c, 0, 0);
8315         }
8316
8317         /* Clear remaining lines */
8318         for (; i < per_page; i++)
8319         {
8320                 Term_erase(col, row + i, 255);
8321         }
8322 }
8323
8324 /*
8325  * Describe fake object
8326  */
8327 static void desc_obj_fake(int k_idx)
8328 {
8329         object_type *o_ptr;
8330         object_type object_type_body;
8331
8332         /* Get local object */
8333         o_ptr = &object_type_body;
8334
8335         /* Wipe the object */
8336         object_wipe(o_ptr);
8337
8338         /* Create the artifact */
8339         object_prep(o_ptr, k_idx);
8340
8341         /* It's fully know */
8342         o_ptr->ident |= IDENT_KNOWN;
8343
8344         /* Track the object */
8345         /* object_actual_track(o_ptr); */
8346
8347         /* Hack - mark as fake */
8348         /* term_obj_real = FALSE; */
8349
8350         /* Hack -- Handle stuff */
8351         handle_stuff();
8352
8353         if (!screen_object(o_ptr, SCROBJ_FAKE_OBJECT | SCROBJ_FORCE_DETAIL))
8354         {
8355 #ifdef JP
8356                 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
8357 #else
8358                 msg_print("You see nothing special.");
8359 #endif
8360                 msg_print(NULL);
8361         }
8362 }
8363
8364
8365
8366 /*
8367  * Display known objects
8368  */
8369 static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, int direct_k_idx)
8370 {
8371         int i, len, max;
8372         int grp_cur, grp_top, old_grp_cur;
8373         int object_old, object_cur, object_top;
8374         int grp_cnt, grp_idx[100];
8375         int object_cnt;
8376         int *object_idx;
8377
8378         int column = 0;
8379         bool flag;
8380         bool redraw;
8381
8382         bool visual_list = FALSE;
8383         byte attr_top = 0, char_left = 0;
8384
8385         int browser_rows;
8386         int wid, hgt;
8387
8388         byte mode;
8389
8390         /* Get size */
8391         Term_get_size(&wid, &hgt);
8392
8393         browser_rows = hgt - 8;
8394
8395         /* Allocate the "object_idx" array */
8396         C_MAKE(object_idx, max_k_idx, int);
8397
8398         max = 0;
8399         grp_cnt = 0;
8400
8401         if (direct_k_idx < 0)
8402         {
8403                 mode = visual_only ? 0x03 : 0x01;
8404
8405                 /* Check every group */
8406                 for (i = 0; object_group_text[i] != NULL; i++)
8407                 {
8408                         /* Measure the label */
8409                         len = strlen(object_group_text[i]);
8410
8411                         /* Save the maximum length */
8412                         if (len > max) max = len;
8413
8414                         /* See if any monsters are known */
8415                         if (collect_objects(i, object_idx, mode))
8416                         {
8417                                 /* Build a list of groups with known monsters */
8418                                 grp_idx[grp_cnt++] = i;
8419                         }
8420                 }
8421
8422                 object_old = -1;
8423                 object_cnt = 0;
8424         }
8425         else
8426         {
8427                 object_kind *k_ptr = &k_info[direct_k_idx];
8428                 object_kind *flavor_k_ptr;
8429
8430                 if (!visual_only && k_ptr->flavor)
8431                 {
8432                         /* Appearance of this object is shuffled */
8433                         flavor_k_ptr = &k_info[k_ptr->flavor];
8434                 }
8435                 else
8436                 {
8437                         /* Appearance of this object is very normal */
8438                         flavor_k_ptr = k_ptr;
8439                 }
8440
8441                 object_idx[0] = direct_k_idx;
8442                 object_old = direct_k_idx;
8443                 object_cnt = 1;
8444
8445                 /* Terminate the list */
8446                 object_idx[1] = -1;
8447
8448                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8449                         &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw);
8450         }
8451
8452         /* Terminate the list */
8453         grp_idx[grp_cnt] = -1;
8454
8455         old_grp_cur = -1;
8456         grp_cur = grp_top = 0;
8457         object_cur = object_top = 0;
8458
8459         flag = FALSE;
8460         redraw = TRUE;
8461
8462         mode = visual_only ? 0x02 : 0x00;
8463
8464         while (!flag)
8465         {
8466                 char ch;
8467                 object_kind *k_ptr, *flavor_k_ptr;
8468
8469                 if (redraw)
8470                 {
8471                         clear_from(0);
8472
8473 #ifdef JP
8474                         prt(format("%s - ¥¢¥¤¥Æ¥à", !visual_only ? "Ãμ±" : "ɽ¼¨"), 2, 0);
8475                         if (direct_k_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8476                         prt("̾Á°", 4, max + 3);
8477                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 70);
8478                         prt("ʸ»ú", 4, 74);
8479 #else
8480                         prt(format("%s - objects", !visual_only ? "Knowledge" : "Visuals"), 2, 0);
8481                         if (direct_k_idx < 0) prt("Group", 4, 0);
8482                         prt("Name", 4, max + 3);
8483                         if (p_ptr->wizard || visual_only) prt("Idx", 4, 70);
8484                         prt("Sym", 4, 75);
8485 #endif
8486
8487                         for (i = 0; i < 78; i++)
8488                         {
8489                                 Term_putch(i, 5, TERM_WHITE, '=');
8490                         }
8491
8492                         if (direct_k_idx < 0)
8493                         {
8494                                 for (i = 0; i < browser_rows; i++)
8495                                 {
8496                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8497                                 }
8498                         }
8499
8500                         redraw = FALSE;
8501                 }
8502
8503                 if (direct_k_idx < 0)
8504                 {
8505                         /* Scroll group list */
8506                         if (grp_cur < grp_top) grp_top = grp_cur;
8507                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8508
8509                         /* Display a list of object groups */
8510                         display_group_list(0, 6, max, browser_rows, grp_idx, object_group_text, grp_cur, grp_top);
8511
8512                         if (old_grp_cur != grp_cur)
8513                         {
8514                                 old_grp_cur = grp_cur;
8515
8516                                 /* Get a list of objects in the current group */
8517                                 object_cnt = collect_objects(grp_idx[grp_cur], object_idx, mode);
8518                         }
8519
8520                         /* Scroll object list */
8521                         while (object_cur < object_top)
8522                                 object_top = MAX(0, object_top - browser_rows/2);
8523                         while (object_cur >= object_top + browser_rows)
8524                                 object_top = MIN(object_cnt - browser_rows, object_top + browser_rows/2);
8525                 }
8526
8527                 if (!visual_list)
8528                 {
8529                         /* Display a list of objects in the current group */
8530                         display_object_list(max + 3, 6, browser_rows, object_idx, object_cur, object_top, visual_only);
8531                 }
8532                 else
8533                 {
8534                         object_top = object_cur;
8535
8536                         /* Display a list of objects in the current group */
8537                         display_object_list(max + 3, 6, 1, object_idx, object_cur, object_top, visual_only);
8538
8539                         /* Display visual list below first object */
8540                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8541                 }
8542
8543                 /* Get the current object */
8544                 k_ptr = &k_info[object_idx[object_cur]];
8545
8546                 if (!visual_only && k_ptr->flavor)
8547                 {
8548                         /* Appearance of this object is shuffled */
8549                         flavor_k_ptr = &k_info[k_ptr->flavor];
8550                 }
8551                 else
8552                 {
8553                         /* Appearance of this object is very normal */
8554                         flavor_k_ptr = k_ptr;
8555                 }
8556
8557                 /* Prompt */
8558 #ifdef JP
8559                 prt(format("<Êý¸þ>%s%s%s, ESC",
8560                         (!visual_list && !visual_only) ? ", 'r'¤Ç¾ÜºÙ¤ò¸«¤ë" : "",
8561                         visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8562                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8563                         hgt - 1, 0);
8564 #else
8565                 prt(format("<dir>%s%s%s, ESC",
8566                         (!visual_list && !visual_only) ? ", 'r' to recall" : "",
8567                         visual_list ? ", ENTER to accept" : ", 'v' for visuals",
8568                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8569                         hgt - 1, 0);
8570 #endif
8571
8572                 if (!visual_only)
8573                 {
8574                         /* Mega Hack -- track this object */
8575                         if (object_cnt) object_kind_track(object_idx[object_cur]);
8576
8577                         /* The "current" object changed */
8578                         if (object_old != object_idx[object_cur])
8579                         {
8580                                 /* Hack -- handle stuff */
8581                                 handle_stuff();
8582
8583                                 /* Remember the "current" object */
8584                                 object_old = object_idx[object_cur];
8585                         }
8586                 }
8587
8588                 if (visual_list)
8589                 {
8590                         place_visual_list_cursor(max + 3, 7, flavor_k_ptr->x_attr, flavor_k_ptr->x_char, attr_top, char_left);
8591                 }
8592                 else if (!column)
8593                 {
8594                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8595                 }
8596                 else
8597                 {
8598                         Term_gotoxy(max + 3, 6 + (object_cur - object_top));
8599                 }
8600
8601                 ch = inkey();
8602
8603                 /* Do visual mode command if needed */
8604                 if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, &flavor_k_ptr->x_attr, &flavor_k_ptr->x_char, need_redraw))
8605                 {
8606                         if (direct_k_idx >= 0)
8607                         {
8608                                 switch (ch)
8609                                 {
8610                                 case '\n':
8611                                 case '\r':
8612                                 case ESCAPE:
8613                                         flag = TRUE;
8614                                         break;
8615                                 }
8616                         }
8617                         continue;
8618                 }
8619
8620                 switch (ch)
8621                 {
8622                         case ESCAPE:
8623                         {
8624                                 flag = TRUE;
8625                                 break;
8626                         }
8627
8628                         case 'R':
8629                         case 'r':
8630                         {
8631                                 /* Recall on screen */
8632                                 if (!visual_list && !visual_only && (grp_cnt > 0))
8633                                 {
8634                                         desc_obj_fake(object_idx[object_cur]);
8635                                         redraw = TRUE;
8636                                 }
8637                                 break;
8638                         }
8639
8640                         default:
8641                         {
8642                                 /* Move the cursor */
8643                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &object_cur, object_cnt);
8644                                 break;
8645                         }
8646                 }
8647         }
8648
8649         /* Free the "object_idx" array */
8650         C_KILL(object_idx, max_k_idx, int);
8651 }
8652
8653
8654 /*
8655  * Display the features in a group.
8656  */
8657 static void display_feature_list(int col, int row, int per_page, int *feat_idx,
8658         int feat_cur, int feat_top, bool visual_only, int lighting_level)
8659 {
8660         int lit_col[F_LIT_MAX], i, j;
8661         int f_idx_col = use_bigtile ? 62 : 64;
8662
8663         /* Correct columns 1 and 4 */
8664         lit_col[F_LIT_STANDARD] = use_bigtile ? (71 - F_LIT_MAX) : 71;
8665         for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
8666                 lit_col[i] = lit_col[F_LIT_STANDARD] + 2 + (i - F_LIT_NS_BEGIN) * 2 + (use_bigtile ? i : 0);
8667
8668         /* Display lines until done */
8669         for (i = 0; i < per_page && (feat_idx[feat_top + i] >= 0); i++)
8670         {
8671                 byte attr;
8672
8673                 /* Get the index */
8674                 int f_idx = feat_idx[feat_top + i];
8675
8676                 /* Access the index */
8677                 feature_type *f_ptr = &f_info[f_idx];
8678
8679                 int row_i = row + i;
8680
8681                 /* Choose a color */
8682                 attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
8683
8684                 /* Display the name */
8685                 c_prt(attr, f_name + f_ptr->name, row_i, col);
8686
8687                 /* Hack -- visual_list mode */
8688                 if (per_page == 1)
8689                 {
8690                         /* Display lighting level */
8691                         c_prt(attr, format("(%s)", lighting_level_str[lighting_level]), row_i, col + 1 + strlen(f_name + f_ptr->name));
8692
8693                         c_prt(attr, format("%02x/%02x", f_ptr->x_attr[lighting_level], f_ptr->x_char[lighting_level]), row_i, f_idx_col - ((p_ptr->wizard || visual_only) ? 6 : 2));
8694                 }
8695                 if (p_ptr->wizard || visual_only)
8696                 {
8697                         c_prt(attr, format("%d", f_idx), row_i, f_idx_col);
8698                 }
8699
8700                 /* Display symbol */
8701                 Term_queue_bigchar(lit_col[F_LIT_STANDARD], row_i, f_ptr->x_attr[F_LIT_STANDARD], f_ptr->x_char[F_LIT_STANDARD], 0, 0);
8702
8703                 Term_putch(lit_col[F_LIT_NS_BEGIN], row_i, TERM_SLATE, '(');
8704                 for (j = F_LIT_NS_BEGIN + 1; j < F_LIT_MAX; j++)
8705                 {
8706                         Term_putch(lit_col[j], row_i, TERM_SLATE, '/');
8707                 }
8708                 Term_putch(lit_col[F_LIT_MAX - 1] + (use_bigtile ? 3 : 2), row_i, TERM_SLATE, ')');
8709
8710                 /* Mega-hack -- Use non-standard colour */
8711                 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
8712                 {
8713                         Term_queue_bigchar(lit_col[j] + 1, row_i, f_ptr->x_attr[j], f_ptr->x_char[j], 0, 0);
8714                 }
8715         }
8716
8717         /* Clear remaining lines */
8718         for (; i < per_page; i++)
8719         {
8720                 Term_erase(col, row + i, 255);
8721         }
8722 }
8723
8724
8725 /*
8726  * Interact with feature visuals.
8727  */
8728 static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, int direct_f_idx, int *lighting_level)
8729 {
8730         int i, len, max;
8731         int grp_cur, grp_top, old_grp_cur;
8732         int feat_cur, feat_top;
8733         int grp_cnt, grp_idx[100];
8734         int feat_cnt;
8735         int *feat_idx;
8736
8737         int column = 0;
8738         bool flag;
8739         bool redraw;
8740
8741         bool visual_list = FALSE;
8742         byte attr_top = 0, char_left = 0;
8743
8744         int browser_rows;
8745         int wid, hgt;
8746
8747         byte attr_old[F_LIT_MAX];
8748         byte char_old[F_LIT_MAX];
8749         byte *cur_attr_ptr, *cur_char_ptr;
8750
8751         (void)C_WIPE(attr_old, F_LIT_MAX, byte);
8752         (void)C_WIPE(char_old, F_LIT_MAX, byte);
8753
8754         /* Get size */
8755         Term_get_size(&wid, &hgt);
8756
8757         browser_rows = hgt - 8;
8758
8759         /* Allocate the "feat_idx" array */
8760         C_MAKE(feat_idx, max_f_idx, int);
8761
8762         max = 0;
8763         grp_cnt = 0;
8764
8765         if (direct_f_idx < 0)
8766         {
8767                 /* Check every group */
8768                 for (i = 0; feature_group_text[i] != NULL; i++)
8769                 {
8770                         /* Measure the label */
8771                         len = strlen(feature_group_text[i]);
8772
8773                         /* Save the maximum length */
8774                         if (len > max) max = len;
8775
8776                         /* See if any features are known */
8777                         if (collect_features(i, feat_idx, 0x01))
8778                         {
8779                                 /* Build a list of groups with known features */
8780                                 grp_idx[grp_cnt++] = i;
8781                         }
8782                 }
8783
8784                 feat_cnt = 0;
8785         }
8786         else
8787         {
8788                 feature_type *f_ptr = &f_info[direct_f_idx];
8789
8790                 feat_idx[0] = direct_f_idx;
8791                 feat_cnt = 1;
8792
8793                 /* Terminate the list */
8794                 feat_idx[1] = -1;
8795
8796                 (void)visual_mode_command('v', &visual_list, browser_rows - 1, wid - (max + 3),
8797                         &attr_top, &char_left, &f_ptr->x_attr[*lighting_level], &f_ptr->x_char[*lighting_level], need_redraw);
8798
8799                 for (i = 0; i < F_LIT_MAX; i++)
8800                 {
8801                         attr_old[i] = f_ptr->x_attr[i];
8802                         char_old[i] = f_ptr->x_char[i];
8803                 }
8804         }
8805
8806         /* Terminate the list */
8807         grp_idx[grp_cnt] = -1;
8808
8809         old_grp_cur = -1;
8810         grp_cur = grp_top = 0;
8811         feat_cur = feat_top = 0;
8812
8813         flag = FALSE;
8814         redraw = TRUE;
8815
8816         while (!flag)
8817         {
8818                 char ch;
8819                 feature_type *f_ptr;
8820
8821                 if (redraw)
8822                 {
8823                         clear_from(0);
8824
8825 #ifdef JP
8826                         prt("ɽ¼¨ - ÃÏ·Á", 2, 0);
8827                         if (direct_f_idx < 0) prt("¥°¥ë¡¼¥×", 4, 0);
8828                         prt("̾Á°", 4, max + 3);
8829                         if (use_bigtile)
8830                         {
8831                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8832                                 prt("ʸ»ú ( l/ d)", 4, 66);
8833                         }
8834                         else
8835                         {
8836                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 64);
8837                                 prt("ʸ»ú (l/d)", 4, 68);
8838                         }
8839 #else
8840                         prt("Visuals - features", 2, 0);
8841                         if (direct_f_idx < 0) prt("Group", 4, 0);
8842                         prt("Name", 4, max + 3);
8843                         if (use_bigtile)
8844                         {
8845                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 62);
8846                                 prt("Sym ( l/ d)", 4, 67);
8847                         }
8848                         else
8849                         {
8850                                 if (p_ptr->wizard || visual_only) prt("Idx", 4, 64);
8851                                 prt("Sym (l/d)", 4, 69);
8852                         }
8853 #endif
8854
8855                         for (i = 0; i < 78; i++)
8856                         {
8857                                 Term_putch(i, 5, TERM_WHITE, '=');
8858                         }
8859
8860                         if (direct_f_idx < 0)
8861                         {
8862                                 for (i = 0; i < browser_rows; i++)
8863                                 {
8864                                         Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8865                                 }
8866                         }
8867
8868                         redraw = FALSE;
8869                 }
8870
8871                 if (direct_f_idx < 0)
8872                 {
8873                         /* Scroll group list */
8874                         if (grp_cur < grp_top) grp_top = grp_cur;
8875                         if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8876
8877                         /* Display a list of feature groups */
8878                         display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
8879
8880                         if (old_grp_cur != grp_cur)
8881                         {
8882                                 old_grp_cur = grp_cur;
8883
8884                                 /* Get a list of features in the current group */
8885                                 feat_cnt = collect_features(grp_idx[grp_cur], feat_idx, 0x00);
8886                         }
8887
8888                         /* Scroll feature list */
8889                         while (feat_cur < feat_top)
8890                                 feat_top = MAX(0, feat_top - browser_rows/2);
8891                         while (feat_cur >= feat_top + browser_rows)
8892                                 feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows/2);
8893                 }
8894
8895                 if (!visual_list)
8896                 {
8897                         /* Display a list of features in the current group */
8898                         display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top, visual_only, F_LIT_STANDARD);
8899                 }
8900                 else
8901                 {
8902                         feat_top = feat_cur;
8903
8904                         /* Display a list of features in the current group */
8905                         display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top, visual_only, *lighting_level);
8906
8907                         /* Display visual list below first object */
8908                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8909                 }
8910
8911                 /* Prompt */
8912 #ifdef JP
8913                 prt(format("<Êý¸þ>%s, 'd'¤Çɸ½à¸÷¸»¸ú²Ì%s, ESC",
8914                         visual_list ? ", ENTER¤Ç·èÄê, 'a'¤ÇÂоÝÌÀÅÙÊѹ¹" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹",
8915                         (attr_idx || char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"),
8916                         hgt - 1, 0);
8917 #else
8918                 prt(format("<dir>%s, 'd' for default lighting%s, ESC",
8919                         visual_list ? ", ENTER to accept, 'a' for lighting level" : ", 'v' for visuals",
8920                         (attr_idx || char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"),
8921                         hgt - 1, 0);
8922 #endif
8923
8924                 /* Get the current feature */
8925                 f_ptr = &f_info[feat_idx[feat_cur]];
8926                 cur_attr_ptr = &f_ptr->x_attr[*lighting_level];
8927                 cur_char_ptr = &f_ptr->x_char[*lighting_level];
8928
8929                 if (visual_list)
8930                 {
8931                         place_visual_list_cursor(max + 3, 7, *cur_attr_ptr, *cur_char_ptr, attr_top, char_left);
8932                 }
8933                 else if (!column)
8934                 {
8935                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8936                 }
8937                 else
8938                 {
8939                         Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
8940                 }
8941
8942                 ch = inkey();
8943
8944                 if (visual_list && ((ch == 'A') || (ch == 'a')))
8945                 {
8946                         int prev_lighting_level = *lighting_level;
8947
8948                         if (ch == 'A')
8949                         {
8950                                 if (*lighting_level <= 0) *lighting_level = F_LIT_MAX - 1;
8951                                 else (*lighting_level)--;
8952                         }
8953                         else
8954                         {
8955                                 if (*lighting_level >= F_LIT_MAX - 1) *lighting_level = 0;
8956                                 else (*lighting_level)++;
8957                         }
8958
8959                         if (f_ptr->x_attr[prev_lighting_level] != f_ptr->x_attr[*lighting_level])
8960                                 attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
8961
8962                         if (f_ptr->x_char[prev_lighting_level] != f_ptr->x_char[*lighting_level])
8963                                 char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
8964
8965                         continue;
8966                 }
8967
8968                 else if ((ch == 'D') || (ch == 'd'))
8969                 {
8970                         byte prev_x_attr = f_ptr->x_attr[*lighting_level];
8971                         byte prev_x_char = f_ptr->x_char[*lighting_level];
8972
8973                         apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
8974
8975                         if (visual_list)
8976                         {
8977                                 if (prev_x_attr != f_ptr->x_attr[*lighting_level])
8978                                          attr_top = MAX(0, (f_ptr->x_attr[*lighting_level] & 0x7f) - 5);
8979
8980                                 if (prev_x_char != f_ptr->x_char[*lighting_level])
8981                                         char_left = MAX(0, f_ptr->x_char[*lighting_level] - 10);
8982                         }
8983                         else *need_redraw = TRUE;
8984
8985                         continue;
8986                 }
8987
8988                 /* Do visual mode command if needed */
8989                 else if (visual_mode_command(ch, &visual_list, browser_rows-1, wid - (max + 3), &attr_top, &char_left, cur_attr_ptr, cur_char_ptr, need_redraw))
8990                 {
8991                         switch (ch)
8992                         {
8993                         /* Restore previous visual settings */
8994                         case ESCAPE:
8995                                 for (i = 0; i < F_LIT_MAX; i++)
8996                                 {
8997                                         f_ptr->x_attr[i] = attr_old[i];
8998                                         f_ptr->x_char[i] = char_old[i];
8999                                 }
9000
9001                                 /* Fall through */
9002
9003                         case '\n':
9004                         case '\r':
9005                                 if (direct_f_idx >= 0) flag = TRUE;
9006                                 else *lighting_level = F_LIT_STANDARD;
9007                                 break;
9008
9009                         /* Preserve current visual settings */
9010                         case 'V':
9011                         case 'v':
9012                                 for (i = 0; i < F_LIT_MAX; i++)
9013                                 {
9014                                         attr_old[i] = f_ptr->x_attr[i];
9015                                         char_old[i] = f_ptr->x_char[i];
9016                                 }
9017                                 *lighting_level = F_LIT_STANDARD;
9018                                 break;
9019
9020                         case 'C':
9021                         case 'c':
9022                                 if (!visual_list)
9023                                 {
9024                                         for (i = 0; i < F_LIT_MAX; i++)
9025                                         {
9026                                                 attr_idx_feat[i] = f_ptr->x_attr[i];
9027                                                 char_idx_feat[i] = f_ptr->x_char[i];
9028                                         }
9029                                 }
9030                                 break;
9031
9032                         case 'P':
9033                         case 'p':
9034                                 if (!visual_list)
9035                                 {
9036                                         /* Allow TERM_DARK text */
9037                                         for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++)
9038                                         {
9039                                                 if (attr_idx_feat[i] || (!(char_idx_feat[i] & 0x80) && char_idx_feat[i])) f_ptr->x_attr[i] = attr_idx_feat[i];
9040                                                 if (char_idx_feat[i]) f_ptr->x_char[i] = char_idx_feat[i];
9041                                         }
9042                                 }
9043                                 break;
9044                         }
9045                         continue;
9046                 }
9047
9048                 switch (ch)
9049                 {
9050                         case ESCAPE:
9051                         {
9052                                 flag = TRUE;
9053                                 break;
9054                         }
9055
9056                         default:
9057                         {
9058                                 /* Move the cursor */
9059                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
9060                                 break;
9061                         }
9062                 }
9063         }
9064
9065         /* Free the "feat_idx" array */
9066         C_KILL(feat_idx, max_f_idx, int);
9067 }
9068
9069
9070 /*
9071  * List wanted monsters
9072  */
9073 static void do_cmd_knowledge_kubi(void)
9074 {
9075         int i;
9076         FILE *fff;
9077         
9078         char file_name[1024];
9079         
9080         
9081         /* Open a new file */
9082         fff = my_fopen_temp(file_name, 1024);
9083         if (!fff) {
9084 #ifdef JP
9085             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9086 #else
9087             msg_format("Failed to create temporary file %s.", file_name);
9088 #endif
9089             msg_print(NULL);
9090             return;
9091         }
9092         
9093         if (fff)
9094         {
9095                 bool listed = FALSE;
9096
9097 #ifdef JP
9098                 fprintf(fff, "º£Æü¤Î¥¿¡¼¥²¥Ã¥È : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "ÉÔÌÀ"));
9099                 fprintf(fff, "\n");
9100                 fprintf(fff, "¾Þ¶â¼ó¥ê¥¹¥È\n");
9101 #else
9102                 fprintf(fff, "Today target : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "unknown"));
9103                 fprintf(fff, "\n");
9104                 fprintf(fff, "List of wanted monsters\n");
9105 #endif
9106                 fprintf(fff, "----------------------------------------------\n");
9107
9108                 for (i = 0; i < MAX_KUBI; i++)
9109                 {
9110                         if (kubi_r_idx[i] <= 10000)
9111                         {
9112                                 fprintf(fff,"%s\n", r_name + r_info[kubi_r_idx[i]].name);
9113
9114                                 listed = TRUE;
9115                         }
9116                 }
9117
9118                 if (!listed)
9119                 {
9120 #ifdef JP
9121                         fprintf(fff,"\n%s\n", "¾Þ¶â¼ó¤Ï¤â¤¦»Ä¤Ã¤Æ¤¤¤Þ¤»¤ó¡£");
9122 #else
9123                         fprintf(fff,"\n%s\n", "There is no more wanted monster.");
9124 #endif
9125                 }
9126         }
9127         
9128         /* Close the file */
9129         my_fclose(fff);
9130         
9131         /* Display the file contents */
9132 #ifdef JP
9133         show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
9134 #else
9135         show_file(TRUE, file_name, "Wanted monsters", 0, 0);
9136 #endif
9137
9138         
9139         /* Remove the file */
9140         fd_kill(file_name);
9141 }
9142
9143 /*
9144  * List virtues & status
9145  */
9146 static void do_cmd_knowledge_virtues(void)
9147 {
9148         FILE *fff;
9149         
9150         char file_name[1024];
9151         
9152         
9153         /* Open a new file */
9154         fff = my_fopen_temp(file_name, 1024);
9155         if (!fff) {
9156 #ifdef JP
9157             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9158 #else
9159             msg_format("Failed to create temporary file %s.", file_name);
9160 #endif
9161             msg_print(NULL);
9162             return;
9163         }
9164         
9165         if (fff)
9166         {
9167 #ifdef JP
9168                 fprintf(fff, "¸½ºß¤Î°À­ : %s\n\n", your_alignment());
9169 #else
9170                 fprintf(fff, "Your alighnment : %s\n\n", your_alignment());
9171 #endif
9172                 dump_virtues(fff);
9173         }
9174         
9175         /* Close the file */
9176         my_fclose(fff);
9177         
9178         /* Display the file contents */
9179 #ifdef JP
9180         show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
9181 #else
9182         show_file(TRUE, file_name, "Virtues", 0, 0);
9183 #endif
9184
9185         
9186         /* Remove the file */
9187         fd_kill(file_name);
9188 }
9189
9190 /*
9191 * Dungeon
9192 *
9193 */
9194 static void do_cmd_knowledge_dungeon(void)
9195 {
9196         FILE *fff;
9197         
9198         char file_name[1024];
9199         int i;
9200         
9201         
9202         /* Open a new file */
9203         fff = my_fopen_temp(file_name, 1024);
9204         if (!fff) {
9205 #ifdef JP
9206             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9207 #else
9208             msg_format("Failed to create temporary file %s.", file_name);
9209 #endif
9210             msg_print(NULL);
9211             return;
9212         }
9213         
9214         if (fff)
9215         {
9216                 for (i = 1; i < max_d_idx; i++)
9217                 {
9218                         bool seiha = FALSE;
9219
9220                         if (!d_info[i].maxdepth) continue;
9221                         if (!max_dlv[i]) continue;
9222                         if (d_info[i].final_guardian)
9223                         {
9224                                 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
9225                         }
9226                         else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
9227 #ifdef JP
9228                         fprintf(fff,"%c%-12s :  %3d ³¬\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
9229 #else
9230                         fprintf(fff,"%c%-16s :  level %3d\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
9231 #endif
9232                 }
9233         }
9234         
9235         /* Close the file */
9236         my_fclose(fff);
9237         
9238         /* Display the file contents */
9239 #ifdef JP
9240         show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
9241 #else
9242         show_file(TRUE, file_name, "Dungeon", 0, 0);
9243 #endif
9244
9245         
9246         /* Remove the file */
9247         fd_kill(file_name);
9248 }
9249
9250 /*
9251 * List virtues & status
9252 *
9253 */
9254 static void do_cmd_knowledge_stat(void)
9255 {
9256         FILE *fff;
9257         
9258         char file_name[1024];
9259         int percent, v_nr;
9260         
9261         /* Open a new file */
9262         fff = my_fopen_temp(file_name, 1024);
9263         if (!fff) {
9264 #ifdef JP
9265             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9266 #else
9267             msg_format("Failed to create temporary file %s.", file_name);
9268 #endif
9269             msg_print(NULL);
9270             return;
9271         }
9272         
9273         if (fff)
9274         {
9275                 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
9276                         (2 * p_ptr->hitdie +
9277                         ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
9278
9279 #ifdef JP
9280                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
9281                 else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
9282                 fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
9283 #else
9284                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
9285                 else fprintf(fff, "Your current Life Rating is ???.\n\n");
9286                 fprintf(fff, "Limits of maximum stats\n\n");
9287 #endif
9288                 for (v_nr = 0; v_nr < 6; v_nr++)
9289                 {
9290                         if ((p_ptr->knowledge & KNOW_STAT) || p_ptr->stat_max[v_nr] == p_ptr->stat_max_max[v_nr]) fprintf(fff, "%s 18/%d\n", stat_names[v_nr], p_ptr->stat_max_max[v_nr]-18);
9291                         else fprintf(fff, "%s ???\n", stat_names[v_nr]);
9292                 }
9293         }
9294
9295         dump_yourself(fff);
9296
9297         /* Close the file */
9298         my_fclose(fff);
9299         
9300         /* Display the file contents */
9301 #ifdef JP
9302         show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
9303 #else
9304         show_file(TRUE, file_name, "HP-rate & Max stat", 0, 0);
9305 #endif
9306
9307         
9308         /* Remove the file */
9309         fd_kill(file_name);
9310 }
9311
9312
9313 /*
9314  * Print all active quests
9315  */
9316 static void do_cmd_knowledge_quests_current(FILE *fff)
9317 {
9318         char tmp_str[120];
9319         char rand_tmp_str[120] = "\0";
9320         char name[80];
9321         monster_race *r_ptr;
9322         int i;
9323         int rand_level = 100;
9324         int total = 0;
9325
9326 #ifdef JP
9327         fprintf(fff, "¡Ô¿ë¹ÔÃæ¤Î¥¯¥¨¥¹¥È¡Õ\n");
9328 #else
9329         fprintf(fff, "< Current Quest >\n");
9330 #endif
9331
9332         for (i = 1; i < max_quests; i++)
9333         {
9334                 if ((quest[i].status == QUEST_STATUS_TAKEN) ||
9335                         ((quest[i].status == QUEST_STATUS_STAGE_COMPLETED) && (quest[i].type == QUEST_TYPE_TOWER)) ||
9336                         (quest[i].status == QUEST_STATUS_COMPLETED))
9337                 {
9338                         /* Set the quest number temporary */
9339                         int old_quest = p_ptr->inside_quest;
9340                         int j;
9341
9342                         /* Clear the text */
9343                         for (j = 0; j < 10; j++) quest_text[j][0] = '\0';
9344                         quest_text_line = 0;
9345
9346                         p_ptr->inside_quest = i;
9347
9348                         /* Get the quest text */
9349                         init_flags = INIT_SHOW_TEXT;
9350
9351                         process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9352
9353                         /* Reset the old quest number */
9354                         p_ptr->inside_quest = old_quest;
9355
9356                         /* No info from "silent" quests */
9357                         if (quest[i].flags & QUEST_FLAG_SILENT) continue;
9358
9359                         total++;
9360
9361                         if (quest[i].type != QUEST_TYPE_RANDOM)
9362                         {
9363                                 char note[80] = "\0";
9364
9365                                 if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_STAGE_COMPLETED)
9366                                 {
9367                                         switch (quest[i].type)
9368                                         {
9369                                         case QUEST_TYPE_KILL_LEVEL:
9370                                         case QUEST_TYPE_KILL_ANY_LEVEL:
9371                                                 r_ptr = &r_info[quest[i].r_idx];
9372                                                 strcpy(name, r_name + r_ptr->name);
9373                                                 if (quest[i].max_num > 1)
9374                                                 {
9375 #ifdef JP
9376                                                         sprintf(note," - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
9377                                                                 quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
9378 #else
9379                                                         plural_aux(name);
9380                                                         sprintf(note," - kill %d %s, have killed %d.",
9381                                                                 quest[i].max_num, name, quest[i].cur_num);
9382 #endif
9383                                                 }
9384                                                 else
9385 #ifdef JP
9386                                                         sprintf(note," - %s¤òÅݤ¹¡£",name);
9387 #else
9388                                                         sprintf(note," - kill %s.",name);
9389 #endif
9390                                                 break;
9391
9392                                         case QUEST_TYPE_FIND_ARTIFACT:
9393                                                 if (quest[i].k_idx)
9394                                                 {
9395                                                         artifact_type *a_ptr = &a_info[quest[i].k_idx];
9396                                                         object_type forge;
9397                                                         object_type *q_ptr = &forge;
9398                                                         int k_idx = lookup_kind(a_ptr->tval, a_ptr->sval);
9399                                                         object_prep(q_ptr, k_idx);
9400                                                         q_ptr->name1 = quest[i].k_idx;
9401                                                         q_ptr->ident = IDENT_STORE;
9402                                                         object_desc(name, q_ptr, OD_NAME_ONLY);
9403                                                 }
9404 #ifdef JP
9405                                                 sprintf(note,"\n   - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
9406 #else
9407                                                 sprintf(note,"\n   - Find out %s.", name);
9408 #endif
9409                                                 break;
9410                                         case QUEST_TYPE_FIND_EXIT:
9411 #ifdef JP
9412                                                 sprintf(note," - ½Ð¸ý¤ËÅþ㤹¤ë¡£");
9413 #else
9414                                                 sprintf(note," - Reach to Exit.");
9415 #endif
9416                                                 break;
9417
9418                                         case QUEST_TYPE_KILL_NUMBER:
9419 #ifdef JP
9420                                                 sprintf(note," - %d ÂΤΥâ¥ó¥¹¥¿¡¼¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",
9421                                                         quest[i].max_num, quest[i].max_num - quest[i].cur_num);
9422 #else
9423                                                 sprintf(note," - Kill %d monsters, have killed %d.",
9424                                                         quest[i].max_num, quest[i].cur_num);
9425 #endif
9426                                                 break;
9427
9428                                         case QUEST_TYPE_KILL_ALL:
9429                                         case QUEST_TYPE_TOWER:
9430 #ifdef JP
9431                                                 sprintf(note," - Á´¤Æ¤Î¥â¥ó¥¹¥¿¡¼¤òÅݤ¹¡£");
9432 #else
9433                                                 sprintf(note," - Kill all monsters.");
9434 #endif
9435                                                 break;
9436                                         }
9437                                 }
9438
9439                                 /* Print the quest info */
9440 #ifdef JP
9441                                 sprintf(tmp_str, "  %s (´í¸±ÅÙ:%d³¬ÁêÅö)%s\n",
9442                                         quest[i].name, quest[i].level, note);
9443 #else
9444                                 sprintf(tmp_str, "  %s (Danger level: %d)%s\n",
9445                                         quest[i].name, quest[i].level, note);
9446 #endif
9447
9448                                 fputs(tmp_str, fff);
9449
9450                                 if (quest[i].status == QUEST_STATUS_COMPLETED)
9451                                 {
9452 #ifdef JP
9453                                         sprintf(tmp_str, "    ¥¯¥¨¥¹¥ÈãÀ® - ¤Þ¤ÀÊó½·¤ò¼õ¤±¤È¤Ã¤Æ¤Ê¤¤¡£\n");
9454 #else
9455                                         sprintf(tmp_str, "    Quest Completed - Unrewarded\n");
9456 #endif
9457                                         fputs(tmp_str, fff);
9458                                 }
9459                                 else
9460                                 {
9461                                         j = 0;
9462
9463                                         while (quest_text[j][0] && j < 10)
9464                                         {
9465                                                 fprintf(fff, "    %s\n", quest_text[j]);
9466                                                 j++;
9467                                         }
9468                                 }
9469                         }
9470                         else if (quest[i].level < rand_level) /* QUEST_TYPE_RANDOM */
9471                         {
9472                                 /* New random */
9473                                 rand_level = quest[i].level;
9474
9475                                 if (max_dlv[DUNGEON_ANGBAND] >= rand_level)
9476                                 {
9477                                         /* Print the quest info */
9478                                         r_ptr = &r_info[quest[i].r_idx];
9479                                         strcpy(name, r_name + r_ptr->name);
9480
9481                                         if (quest[i].max_num > 1)
9482                                         {
9483 #ifdef JP
9484                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
9485                                                         quest[i].name, quest[i].level,
9486                                                         quest[i].max_num, name, quest[i].max_num - quest[i].cur_num);
9487 #else
9488                                                 plural_aux(name);
9489
9490                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
9491                                                         quest[i].name, quest[i].level,
9492                                                         quest[i].max_num, name, quest[i].cur_num);
9493 #endif
9494                                         }
9495                                         else
9496                                         {
9497 #ifdef JP
9498                                                 sprintf(rand_tmp_str,"  %s (%d ³¬) - %s¤òÅݤ¹¡£\n",
9499                                                         quest[i].name, quest[i].level, name);
9500 #else
9501                                                 sprintf(rand_tmp_str,"  %s (Dungeon level: %d)\n  Kill %s.\n",
9502                                                         quest[i].name, quest[i].level, name);
9503 #endif
9504                                         }
9505                                 }
9506                         }
9507                 }
9508         }
9509
9510         /* Print the current random quest  */
9511         if (rand_tmp_str[0]) fputs(rand_tmp_str, fff);
9512
9513 #ifdef JP
9514         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9515 #else
9516         if (!total) fprintf(fff, "  Nothing.\n");
9517 #endif
9518 }
9519
9520
9521 static bool do_cmd_knowledge_quests_aux(FILE *fff, int q_idx)
9522 {
9523         char tmp_str[120];
9524         char playtime_str[16];
9525         quest_type* const q_ptr = &quest[q_idx];
9526
9527         if (is_fixed_quest_idx(q_idx))
9528         {
9529                 /* Set the quest number temporary */
9530                 int old_quest = p_ptr->inside_quest;
9531
9532                 p_ptr->inside_quest = q_idx;
9533
9534                 /* Get the quest */
9535                 init_flags = INIT_NAME_ONLY;
9536
9537                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
9538
9539                 /* Reset the old quest number */
9540                 p_ptr->inside_quest = old_quest;
9541
9542                 /* No info from "silent" quests */
9543                 if (q_ptr->flags & QUEST_FLAG_SILENT) return FALSE;
9544         }
9545
9546         strnfmt(playtime_str, sizeof(playtime_str), "%02d:%02d:%02d",
9547                 q_ptr->comptime/(60*60), (q_ptr->comptime/60)%60, q_ptr->comptime%60);
9548
9549         if (!is_fixed_quest_idx(q_idx) && q_ptr->r_idx)
9550         {
9551                 /* Print the quest info */
9552                 if (q_ptr->complev == 0)
9553                 {
9554                         sprintf(tmp_str,
9555                                 _("  %-35s (%3d³¬)            -   ÉÔÀᄀ - %s\n",
9556                                   "  %-35s (Dungeon level: %3d) - Unearned - %s\n") ,
9557                                 r_name+r_info[q_ptr->r_idx].name,
9558                                 q_ptr->level, playtime_str);
9559                 }
9560                 else
9561                 {
9562                         sprintf(tmp_str,
9563                                 _("  %-35s (%3d³¬)            - ¥ì¥Ù¥ë%2d - %s\n",
9564                                   "  %-35s (Dungeon level: %3d) - level %2d - %s\n") ,
9565                                 r_name+r_info[q_ptr->r_idx].name,
9566                                 q_ptr->level,
9567                                 q_ptr->complev,
9568                                 playtime_str);
9569                 }
9570         }
9571         else
9572         {
9573                 /* Print the quest info */
9574                 sprintf(tmp_str,
9575                         _("  %-35s (´í¸±ÅÙ:%3d³¬ÁêÅö) - ¥ì¥Ù¥ë%2d - %s\n",
9576                           "  %-35s (Danger  level: %3d) - level %2d - %s\n") ,
9577                         q_ptr->name, q_ptr->level, q_ptr->complev, playtime_str);
9578         }
9579
9580         fputs(tmp_str, fff);
9581
9582         return TRUE;
9583 }
9584
9585 /*
9586  * Print all finished quests
9587  */
9588 void do_cmd_knowledge_quests_completed(FILE *fff, int quest_num[])
9589 {
9590         int i;
9591         int total = 0;
9592
9593 #ifdef JP
9594         fprintf(fff, "¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
9595 #else
9596         fprintf(fff, "< Completed Quest >\n");
9597 #endif
9598         for (i = 1; i < max_quests; i++)
9599         {
9600                 int q_idx = quest_num[i];
9601                 quest_type* const q_ptr = &quest[q_idx];
9602
9603                 if (q_ptr->status == QUEST_STATUS_FINISHED &&
9604                     do_cmd_knowledge_quests_aux(fff, q_idx))
9605                 {
9606                         ++ total;
9607                 }
9608         }
9609 #ifdef JP
9610         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9611 #else
9612         if (!total) fprintf(fff, "  Nothing.\n");
9613 #endif
9614 }
9615
9616
9617 /*
9618  * Print all failed quests
9619  */
9620 void do_cmd_knowledge_quests_failed(FILE *fff, int quest_num[])
9621 {
9622         int i;
9623         int total = 0;
9624
9625 #ifdef JP
9626         fprintf(fff, "¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
9627 #else
9628         fprintf(fff, "< Failed Quest >\n");
9629 #endif
9630         for (i = 1; i < max_quests; i++)
9631         {
9632                 int q_idx = quest_num[i];
9633                 quest_type* const q_ptr = &quest[q_idx];
9634
9635                 if (((q_ptr->status == QUEST_STATUS_FAILED_DONE) || (q_ptr->status == QUEST_STATUS_FAILED)) &&
9636                     do_cmd_knowledge_quests_aux(fff, q_idx))
9637                 {
9638                         ++ total;
9639                 }
9640         }
9641 #ifdef JP
9642         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9643 #else
9644         if (!total) fprintf(fff, "  Nothing.\n");
9645 #endif
9646 }
9647
9648
9649 /*
9650  * Print all random quests
9651  */
9652 static void do_cmd_knowledge_quests_wiz_random(FILE *fff)
9653 {
9654         char tmp_str[120];
9655         int i;
9656         int total = 0;
9657
9658 #ifdef JP
9659         fprintf(fff, "¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
9660 #else
9661         fprintf(fff, "< Remaining Random Quest >\n");
9662 #endif
9663         for (i = 1; i < max_quests; i++)
9664         {
9665                 /* No info from "silent" quests */
9666                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
9667
9668                 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
9669                 {
9670                         total++;
9671
9672                         /* Print the quest info */
9673 #ifdef JP
9674                         sprintf(tmp_str, "  %s (%d³¬, %s)\n",
9675                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
9676 #else
9677                         sprintf(tmp_str, "  %s (%d, %s)\n",
9678                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
9679 #endif
9680                         fputs(tmp_str, fff);
9681                 }
9682         }
9683 #ifdef JP
9684         if (!total) fprintf(fff, "  ¤Ê¤·\n");
9685 #else
9686         if (!total) fprintf(fff, "  Nothing.\n");
9687 #endif
9688 }
9689
9690
9691 bool ang_sort_comp_quest_num(vptr u, vptr v, int a, int b)
9692 {
9693         int *q_num = (int *)u;
9694         quest_type *qa = &quest[q_num[a]];
9695         quest_type *qb = &quest[q_num[b]];
9696
9697         /* Unused */
9698         (void)v;
9699
9700         return (qa->comptime <= qb->comptime);
9701 }
9702
9703 void ang_sort_swap_quest_num(vptr u, vptr v, int a, int b)
9704 {
9705         int *q_num = (int *)u;
9706         int tmp;
9707
9708         /* Unused */
9709         (void)v;
9710
9711         tmp = q_num[a];
9712         q_num[a] = q_num[b];
9713         q_num[b] = tmp;
9714 }
9715
9716
9717 /*
9718  * Print quest status of all active quests
9719  */
9720 static void do_cmd_knowledge_quests(void)
9721 {
9722         FILE *fff;
9723         char file_name[1024];
9724         int *quest_num, dummy, i;
9725
9726         /* Open a new file */
9727         fff = my_fopen_temp(file_name, 1024);
9728         if (!fff)
9729         {
9730 #ifdef JP
9731             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9732 #else
9733             msg_format("Failed to create temporary file %s.", file_name);
9734 #endif
9735             msg_print(NULL);
9736             return;
9737         }
9738
9739         /* Allocate Memory */
9740         C_MAKE(quest_num, max_quests, int);
9741
9742         /* Sort by compete level */
9743         for (i = 1; i < max_quests; i++) quest_num[i] = i;
9744         ang_sort_comp = ang_sort_comp_quest_num;
9745         ang_sort_swap = ang_sort_swap_quest_num;
9746         ang_sort(quest_num, &dummy, max_quests);
9747
9748         /* Dump Quest Information */
9749         do_cmd_knowledge_quests_current(fff);
9750         fputc('\n', fff);
9751         do_cmd_knowledge_quests_completed(fff, quest_num);
9752         fputc('\n', fff);
9753         do_cmd_knowledge_quests_failed(fff, quest_num);
9754         if (p_ptr->wizard)
9755         {
9756                 fputc('\n', fff);
9757                 do_cmd_knowledge_quests_wiz_random(fff);
9758         }
9759
9760         /* Close the file */
9761         my_fclose(fff);
9762
9763         /* Display the file contents */
9764 #ifdef JP
9765         show_file(TRUE, file_name, "¥¯¥¨¥¹¥ÈãÀ®¾õ¶·", 0, 0);
9766 #else
9767         show_file(TRUE, file_name, "Quest status", 0, 0);
9768 #endif
9769
9770         /* Remove the file */
9771         fd_kill(file_name);
9772
9773         /* Free Memory */
9774         C_KILL(quest_num, max_quests, int);
9775 }
9776
9777
9778 /*
9779  * List my home
9780  */
9781 static void do_cmd_knowledge_home(void)
9782 {
9783         FILE *fff;
9784
9785         int i;
9786         char file_name[1024];
9787         store_type  *st_ptr;
9788         char o_name[MAX_NLEN];
9789         cptr            paren = ")";
9790
9791         process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
9792
9793         /* Open a new file */
9794         fff = my_fopen_temp(file_name, 1024);
9795         if (!fff) {
9796 #ifdef JP
9797                 msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9798 #else
9799                 msg_format("Failed to create temporary file %s.", file_name);
9800 #endif
9801                 msg_print(NULL);
9802                 return;
9803         }
9804
9805         if (fff)
9806         {
9807                 /* Print all homes in the different towns */
9808                 st_ptr = &town[1].store[STORE_HOME];
9809
9810                 /* Home -- if anything there */
9811                 if (st_ptr->stock_num)
9812                 {
9813 #ifdef JP
9814                         int x = 1;
9815 #endif
9816                         /* Header with name of the town */
9817 #ifdef JP
9818                         fprintf(fff, "  [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
9819 #else
9820                         fprintf(fff, "  [Home Inventory]\n");
9821 #endif
9822
9823                         /* Dump all available items */
9824                         for (i = 0; i < st_ptr->stock_num; i++)
9825                         {
9826 #ifdef JP
9827                                 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
9828                                 object_desc(o_name, &st_ptr->stock[i], 0);
9829                                 if (strlen(o_name) <= 80-3)
9830                                 {
9831                                         fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9832                                 }
9833                                 else
9834                                 {
9835                                         int n;
9836                                         char *t;
9837                                         for (n = 0, t = o_name; n < 80-3; n++, t++)
9838                                                 if(iskanji(*t)) {t++; n++;}
9839                                         if (n == 81-3) n = 79-3; /* ºÇ¸å¤¬´Á»úȾʬ */
9840
9841                                         fprintf(fff, "%c%s %.*s\n", I2A(i%12), paren, n, o_name);
9842                                         fprintf(fff, "   %.77s\n", o_name+n);
9843                                 }
9844 #else
9845                                 object_desc(o_name, &st_ptr->stock[i], 0);
9846                                 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9847 #endif
9848
9849                         }
9850
9851                         /* Add an empty line */
9852                         fprintf(fff, "\n\n");
9853                 }
9854         }
9855
9856         /* Close the file */
9857         my_fclose(fff);
9858
9859         /* Display the file contents */
9860 #ifdef JP
9861         show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
9862 #else
9863         show_file(TRUE, file_name, "Home Inventory", 0, 0);
9864 #endif
9865
9866
9867         /* Remove the file */
9868         fd_kill(file_name);
9869 }
9870
9871
9872 /*
9873  * Check the status of "autopick"
9874  */
9875 static void do_cmd_knowledge_autopick(void)
9876 {
9877         int k;
9878         FILE *fff;
9879         char file_name[1024];
9880
9881         /* Open a new file */
9882         fff = my_fopen_temp(file_name, 1024);
9883
9884         if (!fff)
9885         {
9886 #ifdef JP
9887             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9888 #else
9889             msg_format("Failed to create temporary file %s.", file_name);
9890 #endif
9891             msg_print(NULL);
9892             return;
9893         }
9894
9895         if (!max_autopick)
9896         {
9897 #ifdef JP
9898             fprintf(fff, "¼«Æ°Ç˲õ/½¦¤¤¤Ë¤Ï²¿¤âÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
9899 #else
9900             fprintf(fff, "No preference for auto picker/destroyer.");
9901 #endif
9902         }
9903         else
9904         {
9905 #ifdef JP
9906             fprintf(fff, "   ¼«Æ°½¦¤¤/Ç˲õ¤Ë¤Ï¸½ºß %d¹ÔÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n\n", max_autopick);
9907 #else
9908             fprintf(fff, "   There are %d registered lines for auto picker/destroyer.\n\n", max_autopick);
9909 #endif
9910         }
9911
9912         for (k = 0; k < max_autopick; k++)
9913         {
9914                 cptr tmp;
9915                 byte act = autopick_list[k].action;
9916                 if (act & DONT_AUTOPICK)
9917                 {
9918 #ifdef JP
9919                         tmp = "ÊüÃÖ";
9920 #else
9921                         tmp = "Leave";
9922 #endif
9923                 }
9924                 else if (act & DO_AUTODESTROY)
9925                 {
9926 #ifdef JP
9927                         tmp = "Ç˲õ";
9928 #else
9929                         tmp = "Destroy";
9930 #endif
9931                 }
9932                 else if (act & DO_AUTOPICK)
9933                 {
9934 #ifdef JP
9935                         tmp = "½¦¤¦";
9936 #else
9937                         tmp = "Pickup";
9938 #endif
9939                 }
9940                 else /* if (act & DO_QUERY_AUTOPICK) */ /* Obvious */
9941                 {
9942 #ifdef JP
9943                         tmp = "³Îǧ";
9944 #else
9945                         tmp = "Query";
9946 #endif
9947                 }
9948
9949                 if (act & DO_DISPLAY)
9950                         fprintf(fff, "%11s", format("[%s]", tmp));
9951                 else
9952                         fprintf(fff, "%11s", format("(%s)", tmp));
9953
9954                 tmp = autopick_line_from_entry(&autopick_list[k]);
9955                 fprintf(fff, " %s", tmp);
9956                 string_free(tmp);
9957                 fprintf(fff, "\n");
9958         }
9959         /* Close the file */
9960         my_fclose(fff);
9961         /* Display the file contents */
9962 #ifdef JP
9963         show_file(TRUE, file_name, "¼«Æ°½¦¤¤/Ç˲õ ÀßÄê¥ê¥¹¥È", 0, 0);
9964 #else
9965         show_file(TRUE, file_name, "Auto-picker/Destroyer", 0, 0);
9966 #endif
9967
9968         /* Remove the file */
9969         fd_kill(file_name);
9970 }
9971
9972
9973 /*
9974  * Interact with "knowledge"
9975  */
9976 void do_cmd_knowledge(void)
9977 {
9978         int i, p = 0;
9979         bool need_redraw = FALSE;
9980
9981         /* File type is "TEXT" */
9982         FILE_TYPE(FILE_TYPE_TEXT);
9983
9984         /* Save the screen */
9985         screen_save();
9986
9987         /* Interact until done */
9988         while (1)
9989         {
9990                 /* Clear screen */
9991                 Term_clear();
9992
9993                 /* Ask for a choice */
9994 #ifdef JP
9995                 prt(format("%d/2 ¥Ú¡¼¥¸", (p+1)), 2, 65);
9996                 prt("¸½ºß¤ÎÃ챤ò³Îǧ¤¹¤ë", 3, 0);
9997 #else
9998                 prt(format("page %d/2", (p+1)), 2, 65);
9999                 prt("Display current knowledge", 3, 0);
10000 #endif
10001
10002                 /* Give some choices */
10003 #ifdef JP
10004                 if (p == 0)
10005                 {
10006                         prt("(1) ´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à                 ¤Î°ìÍ÷", 6, 5);
10007                         prt("(2) ´ûÃΤΥ¢¥¤¥Æ¥à                       ¤Î°ìÍ÷", 7, 5);
10008                         prt("(3) ´ûÃΤÎÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ ¤Î°ìÍ÷", 8, 5);
10009                         prt("(4) ´ûÃΤΥâ¥ó¥¹¥¿¡¼                     ¤Î°ìÍ÷", 9, 5);
10010                         prt("(5) Åݤ·¤¿Å¨¤Î¿ô                         ¤Î°ìÍ÷", 10, 5);
10011                         if (!vanilla_town) prt("(6) ¾Þ¶â¼ó                               ¤Î°ìÍ÷", 11, 5);
10012                         prt("(7) ¸½ºß¤Î¥Ú¥Ã¥È                         ¤Î°ìÍ÷", 12, 5);
10013                         prt("(8) ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à                     ¤Î°ìÍ÷", 13, 5);
10014                         prt("(9) *´ÕÄê*ºÑ¤ßÁõÈ÷¤ÎÂÑÀ­                 ¤Î°ìÍ÷", 14, 5);
10015                         prt("(0) ÃÏ·Á¤Îɽ¼¨Ê¸»ú/¥¿¥¤¥ë                ¤Î°ìÍ÷", 15, 5);
10016                 }
10017                 else
10018                 {
10019                         prt("(a) ¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó                     ¤Î°ìÍ÷", 6, 5);
10020                         prt("(b) ÆÍÁ³ÊÑ°Û                             ¤Î°ìÍ÷", 7, 5);
10021                         prt("(c) Éð´ï¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 8, 5);
10022                         prt("(d) ËâË¡¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 9, 5);
10023                         prt("(e) µ»Ç½¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 10, 5);
10024                         prt("(f) ¥×¥ì¥¤¥ä¡¼¤ÎÆÁ                       ¤Î°ìÍ÷", 11, 5);
10025                         prt("(g) Æþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó                     ¤Î°ìÍ÷", 12, 5);
10026                         prt("(h) ¼Â¹ÔÃæ¤Î¥¯¥¨¥¹¥È                     ¤Î°ìÍ÷", 13, 5);
10027                         prt("(i) ¸½ºß¤Î¼«Æ°½¦¤¤/Ç˲õÀßÄê              ¤Î°ìÍ÷", 14, 5);
10028                 }
10029 #else
10030                 if (p == 0)
10031                 {
10032                         prt("(1) Display known artifacts", 6, 5);
10033                         prt("(2) Display known objects", 7, 5);
10034                         prt("(3) Display remaining uniques", 8, 5);
10035                         prt("(4) Display known monster", 9, 5);
10036                         prt("(5) Display kill count", 10, 5);
10037                         if (!vanilla_town) prt("(6) Display wanted monsters", 11, 5);
10038                         prt("(7) Display current pets", 12, 5);
10039                         prt("(8) Display home inventory", 13, 5);
10040                         prt("(9) Display *identified* equip.", 14, 5);
10041                         prt("(0) Display terrain symbols.", 15, 5);
10042                 }
10043                 else
10044                 {
10045                         prt("(a) Display about yourself", 6, 5);
10046                         prt("(b) Display mutations", 7, 5);
10047                         prt("(c) Display weapon proficiency", 8, 5);
10048                         prt("(d) Display spell proficiency", 9, 5);
10049                         prt("(e) Display misc. proficiency", 10, 5);
10050                         prt("(f) Display virtues", 11, 5);
10051                         prt("(g) Display dungeons", 12, 5);
10052                         prt("(h) Display current quests", 13, 5);
10053                         prt("(i) Display auto pick/destroy", 14, 5);
10054                 }
10055 #endif
10056                 /* Prompt */
10057 #ifdef JP
10058                 prt("-³¤¯-", 17, 8);
10059                 prt("ESC) È´¤±¤ë", 21, 1);
10060                 prt("SPACE) ¼¡¥Ú¡¼¥¸", 21, 30);
10061                 /*prt("-) Á°¥Ú¡¼¥¸", 21, 60);*/
10062                 prt("¥³¥Þ¥ó¥É:", 20, 0);
10063 #else
10064                 prt("-more-", 17, 8);
10065                 prt("ESC) Exit menu", 21, 1);
10066                 prt("SPACE) Next page", 21, 30);
10067                 /*prt("-) Previous page", 21, 60);*/
10068                 prt("Command: ", 20, 0);
10069 #endif
10070
10071                 /* Prompt */
10072                 i = inkey();
10073
10074                 /* Done */
10075                 if (i == ESCAPE) break;
10076                 switch (i)
10077                 {
10078                 case ' ': /* Page change */
10079                 case '-':
10080                         p = 1 - p;
10081                         break;
10082                 case '1': /* Artifacts */
10083                         do_cmd_knowledge_artifacts();
10084                         break;
10085                 case '2': /* Objects */
10086                         do_cmd_knowledge_objects(&need_redraw, FALSE, -1);
10087                         break;
10088                 case '3': /* Uniques */
10089                         do_cmd_knowledge_uniques();
10090                         break;
10091                 case '4': /* Monsters */
10092                         do_cmd_knowledge_monsters(&need_redraw, FALSE, -1);
10093                         break;
10094                 case '5': /* Kill count  */
10095                         do_cmd_knowledge_kill_count();
10096                         break;
10097                 case '6': /* wanted */
10098                         if (!vanilla_town) do_cmd_knowledge_kubi();
10099                         break;
10100                 case '7': /* Pets */
10101                         do_cmd_knowledge_pets();
10102                         break;
10103                 case '8': /* Home */
10104                         do_cmd_knowledge_home();
10105                         break;
10106                 case '9': /* Resist list */
10107                         do_cmd_knowledge_inven();
10108                         break;
10109                 case '0': /* Feature list */
10110                         {
10111                                 int lighting_level = F_LIT_STANDARD;
10112                                 do_cmd_knowledge_features(&need_redraw, FALSE, -1, &lighting_level);
10113                         }
10114                         break;
10115                 /* Next page */
10116                 case 'a': /* Max stat */
10117                         do_cmd_knowledge_stat();
10118                         break;
10119                 case 'b': /* Mutations */
10120                         do_cmd_knowledge_mutations();
10121                         break;
10122                 case 'c': /* weapon-exp */
10123                         do_cmd_knowledge_weapon_exp();
10124                         break;
10125                 case 'd': /* spell-exp */
10126                         do_cmd_knowledge_spell_exp();
10127                         break;
10128                 case 'e': /* skill-exp */
10129                         do_cmd_knowledge_skill_exp();
10130                         break;
10131                 case 'f': /* Virtues */
10132                         do_cmd_knowledge_virtues();
10133                         break;
10134                 case 'g': /* Dungeon */
10135                         do_cmd_knowledge_dungeon();
10136                         break;
10137                 case 'h': /* Quests */
10138                         do_cmd_knowledge_quests();
10139                         break;
10140                 case 'i': /* Autopick */
10141                         do_cmd_knowledge_autopick();
10142                         break;
10143                 default: /* Unknown option */
10144                         bell();
10145                 }
10146
10147                 /* Flush messages */
10148                 msg_print(NULL);
10149         }
10150
10151         /* Restore the screen */
10152         screen_load();
10153
10154         if (need_redraw) do_cmd_redraw();
10155 }
10156
10157
10158 /*
10159  * Check on the status of an active quest
10160  */
10161 void do_cmd_checkquest(void)
10162 {
10163         /* File type is "TEXT" */
10164         FILE_TYPE(FILE_TYPE_TEXT);
10165
10166         /* Save the screen */
10167         screen_save();
10168
10169         /* Quest info */
10170         do_cmd_knowledge_quests();
10171
10172         /* Restore the screen */
10173         screen_load();
10174 }
10175
10176
10177 /*
10178  * Display the time and date
10179  */
10180 void do_cmd_time(void)
10181 {
10182         int day, hour, min, full, start, end, num;
10183         char desc[1024];
10184
10185         char buf[1024];
10186         char day_buf[10];
10187
10188         FILE *fff;
10189
10190         extract_day_hour_min(&day, &hour, &min);
10191
10192         full = hour * 100 + min;
10193
10194         start = 9999;
10195         end = -9999;
10196
10197         num = 0;
10198
10199 #ifdef JP
10200         strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
10201 #else
10202         strcpy(desc, "It is a strange time.");
10203 #endif
10204
10205
10206         if (day < MAX_DAYS) sprintf(day_buf, "%d", day);
10207         else strcpy(day_buf, "*****");
10208
10209         /* Message */
10210 #ifdef JP
10211         msg_format("%sÆüÌÜ, »þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
10212                    day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
10213                    min, (hour < 12) ? "AM" : "PM");
10214 #else
10215         msg_format("This is day %s. The time is %d:%02d %s.",
10216                    day_buf, (hour % 12 == 0) ? 12 : (hour % 12),
10217                    min, (hour < 12) ? "AM" : "PM");
10218 #endif
10219
10220
10221         /* Find the path */
10222         if (!randint0(10) || p_ptr->image)
10223         {
10224 #ifdef JP
10225                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
10226 #else
10227                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
10228 #endif
10229
10230         }
10231         else
10232         {
10233 #ifdef JP
10234                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
10235 #else
10236                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
10237 #endif
10238
10239         }
10240
10241         /* Open this file */
10242         fff = my_fopen(buf, "rt");
10243
10244         /* Oops */
10245         if (!fff) return;
10246
10247         /* Find this time */
10248         while (!my_fgets(fff, buf, sizeof(buf)))
10249         {
10250                 /* Ignore comments */
10251                 if (!buf[0] || (buf[0] == '#')) continue;
10252
10253                 /* Ignore invalid lines */
10254                 if (buf[1] != ':') continue;
10255
10256                 /* Process 'Start' */
10257                 if (buf[0] == 'S')
10258                 {
10259                         /* Extract the starting time */
10260                         start = atoi(buf + 2);
10261
10262                         /* Assume valid for an hour */
10263                         end = start + 59;
10264
10265                         /* Next... */
10266                         continue;
10267                 }
10268
10269                 /* Process 'End' */
10270                 if (buf[0] == 'E')
10271                 {
10272                         /* Extract the ending time */
10273                         end = atoi(buf + 2);
10274
10275                         /* Next... */
10276                         continue;
10277                 }
10278
10279                 /* Ignore incorrect range */
10280                 if ((start > full) || (full > end)) continue;
10281
10282                 /* Process 'Description' */
10283                 if (buf[0] == 'D')
10284                 {
10285                         num++;
10286
10287                         /* Apply the randomizer */
10288                         if (!randint0(num)) strcpy(desc, buf + 2);
10289
10290                         /* Next... */
10291                         continue;
10292                 }
10293         }
10294
10295         /* Message */
10296         msg_print(desc);
10297
10298         /* Close the file */
10299         my_fclose(fff);
10300 }