OSDN Git Service

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