OSDN Git Service

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