OSDN Git Service

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