OSDN Git Service

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