OSDN Git Service

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