OSDN Git Service

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