OSDN Git Service

gccで -Wunused を付けても警告が出ないように無視している関数の引数等を(void)で明記。
[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);
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         const char *empty_symbol = "<< ? >>";
3432
3433         if (use_bigtile) empty_symbol = "<< ?? >>";
3434
3435         /* File type is "TEXT" */
3436         FILE_TYPE(FILE_TYPE_TEXT);
3437
3438
3439         /* Save the screen */
3440         screen_save();
3441
3442
3443         /* Interact until done */
3444         while (1)
3445         {
3446                 /* Clear screen */
3447                 Term_clear();
3448
3449                 /* Ask for a choice */
3450 #ifdef JP
3451                 prt("²èÌÌɽ¼¨¤ÎÀßÄê", 2, 0);
3452 #else
3453                 prt("Interact with Visuals", 2, 0);
3454 #endif
3455
3456
3457                 /* Give some choices */
3458 #ifdef JP
3459                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
3460 #else
3461                 prt("(1) Load a user pref file", 4, 5);
3462 #endif
3463
3464 #ifdef ALLOW_VISUALS
3465 #ifdef JP
3466                 prt("(2) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
3467                 prt("(3) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 6, 5);
3468                 prt("(4) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 7, 5);
3469                 prt("(5) (̤»ÈÍÑ)", 8, 5);
3470                 prt("(6) ¥â¥ó¥¹¥¿¡¼¤Î ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë", 9, 5);
3471                 prt("(7) ¥¢¥¤¥Æ¥à¤Î   ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë", 10, 5);
3472                 prt("(8) ÃÏ·Á¤Î       ¿§/ʸ»ú ¤òÊѹ¹¤¹¤ë", 11, 5);
3473                 prt("(9) (̤»ÈÍÑ)", 12, 5);
3474 #else
3475                 prt("(2) Dump monster attr/chars", 5, 5);
3476                 prt("(3) Dump object attr/chars", 6, 5);
3477                 prt("(4) Dump feature attr/chars", 7, 5);
3478                 prt("(5) (unused)", 8, 5);
3479                 prt("(6) Change monster attr/chars", 9, 5);
3480                 prt("(7) Change object attr/chars", 10, 5);
3481                 prt("(8) Change feature attr/chars", 11, 5);
3482                 prt("(9) (unused)", 12, 5);
3483 #endif
3484
3485 #endif
3486 #ifdef JP
3487                 prt("(0) ²èÌÌɽ¼¨ÊýË¡¤Î½é´ü²½", 13, 5);
3488 #else
3489                 prt("(0) Reset visuals", 13, 5);
3490 #endif
3491
3492
3493                 /* Prompt */
3494 #ifdef JP
3495                 prt("¥³¥Þ¥ó¥É:", 18, 0);
3496 #else
3497                 prt("Command: ", 15, 0);
3498 #endif
3499
3500
3501                 /* Prompt */
3502                 i = inkey();
3503
3504                 /* Done */
3505                 if (i == ESCAPE) break;
3506
3507                 /* Load a 'pref' file */
3508                 else if (i == '1')
3509                 {
3510                         /* Prompt */
3511 #ifdef JP
3512                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 15, 0);
3513 #else
3514                         prt("Command: Load a user pref file", 15, 0);
3515 #endif
3516
3517
3518                         /* Prompt */
3519 #ifdef JP
3520                         prt("¥Õ¥¡¥¤¥ë: ", 18, 0);
3521 #else
3522                         prt("File: ", 17, 0);
3523 #endif
3524
3525
3526                         /* Default filename */
3527                         sprintf(tmp, "%s.prf", player_name);
3528
3529                         /* Query */
3530                         if (!askfor_aux(tmp, 70)) continue;
3531
3532                         /* Process the given filename */
3533                         (void)process_pref_file(tmp);
3534                 }
3535
3536 #ifdef ALLOW_VISUALS
3537
3538                 /* Dump monster attr/chars */
3539                 else if (i == '2')
3540                 {
3541                         static cptr mark = "Monster attr/chars";
3542                         int line_num;
3543
3544                         /* Prompt */
3545 #ifdef JP
3546                         prt("¥³¥Þ¥ó¥É: ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3547 #else
3548                         prt("Command: Dump monster attr/chars", 15, 0);
3549 #endif
3550
3551
3552                         /* Prompt */
3553 #ifdef JP
3554                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3555 #else
3556                         prt("File: ", 17, 0);
3557 #endif
3558
3559
3560                         /* Default filename */
3561                         sprintf(tmp, "%s.prf", player_name);
3562                         
3563                         /* Get a filename */
3564                         if (!askfor_aux(tmp, 70)) continue;
3565
3566                         /* Build the filename */
3567                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3568
3569                         /* Append to the file */
3570                         fff = open_auto_dump(buf, mark, &line_num);
3571                         if (!fff) continue;
3572
3573                         /* Start dumping */
3574 #ifdef JP
3575                         fprintf(fff, "\n# ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3576 #else
3577                         fprintf(fff, "\n# Monster attr/char definitions\n\n");
3578 #endif
3579                         line_num += 3;
3580
3581                         /* Dump monsters */
3582                         for (i = 1; i < max_r_idx; i++)
3583                         {
3584                                 monster_race *r_ptr = &r_info[i];
3585
3586                                 /* Skip non-entries */
3587                                 if (!r_ptr->name) continue;
3588
3589                                 /* Dump a comment */
3590                                 fprintf(fff, "# %s\n", (r_name + r_ptr->name));
3591                                 line_num++;
3592
3593                                 /* Dump the monster attr/char info */
3594                                 fprintf(fff, "R:%d:0x%02X/0x%02X\n\n", i,
3595                                         (byte)(r_ptr->x_attr), (byte)(r_ptr->x_char));
3596                                 line_num += 2;
3597                         }
3598
3599                         /* Close */
3600                         close_auto_dump(fff, mark, line_num);
3601
3602                         /* Message */
3603 #ifdef JP
3604                         msg_print("¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3605 #else
3606                         msg_print("Dumped monster attr/chars.");
3607 #endif
3608
3609                 }
3610
3611                 /* Dump object attr/chars */
3612                 else if (i == '3')
3613                 {
3614                         static cptr mark = "Object attr/chars";
3615                         int line_num;
3616
3617                         /* Prompt */
3618 #ifdef JP
3619                         prt("¥³¥Þ¥ó¥É: ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3620 #else
3621                         prt("Command: Dump object attr/chars", 15, 0);
3622 #endif
3623
3624
3625                         /* Prompt */
3626 #ifdef JP
3627                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3628 #else
3629                         prt("File: ", 17, 0);
3630 #endif
3631
3632
3633                         /* Default filename */
3634                         sprintf(tmp, "%s.prf", player_name);
3635
3636                         /* Get a filename */
3637                         if (!askfor_aux(tmp, 70)) continue;
3638
3639                         /* Build the filename */
3640                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3641
3642                         /* Append to the file */
3643                         fff = open_auto_dump(buf, mark, &line_num);
3644                         if (!fff) continue;
3645
3646                         /* Start dumping */
3647 #ifdef JP
3648                         fprintf(fff, "\n# ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3649 #else
3650                         fprintf(fff, "\n# Object attr/char definitions\n\n");
3651 #endif
3652                         line_num += 3;
3653
3654                         /* Dump objects */
3655                         for (i = 1; i < max_k_idx; i++)
3656                         {
3657                                 char o_name[80];
3658                                 object_kind *k_ptr = &k_info[i];
3659
3660                                 /* Skip non-entries */
3661                                 if (!k_ptr->name) continue;
3662
3663                                 /* Skip entries with flavor */
3664                                 if (k_ptr->flavor) continue;
3665
3666                                 /* Tidy name */
3667                                 strip_name(o_name, i);
3668
3669                                 /* Dump a comment */
3670                                 fprintf(fff, "# %s\n", o_name);
3671                                 line_num++;
3672
3673                                 /* Dump the object attr/char info */
3674                                 fprintf(fff, "K:%d:0x%02X/0x%02X\n\n", i,
3675                                         (byte)(k_ptr->x_attr), (byte)(k_ptr->x_char));
3676                                 line_num += 2;
3677                         }
3678
3679                         /* Close */
3680                         close_auto_dump(fff, mark, line_num);
3681
3682                         /* Message */
3683 #ifdef JP
3684                         msg_print("¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3685 #else
3686                         msg_print("Dumped object attr/chars.");
3687 #endif
3688
3689                 }
3690
3691                 /* Dump feature attr/chars */
3692                 else if (i == '4')
3693                 {
3694                         static cptr mark = "Feature attr/chars";
3695                         int line_num;
3696
3697                         /* Prompt */
3698 #ifdef JP
3699                         prt("¥³¥Þ¥ó¥É: ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 15, 0);
3700 #else
3701                         prt("Command: Dump feature attr/chars", 15, 0);
3702 #endif
3703
3704
3705                         /* Prompt */
3706 #ifdef JP
3707                         prt("¥Õ¥¡¥¤¥ë: ", 17, 0);
3708 #else
3709                         prt("File: ", 17, 0);
3710 #endif
3711
3712
3713                         /* Default filename */
3714                         sprintf(tmp, "%s.prf", player_name);
3715
3716                         /* Get a filename */
3717                         if (!askfor_aux(tmp, 70)) continue;
3718
3719                         /* Build the filename */
3720                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
3721
3722                         /* Append to the file */
3723                         fff = open_auto_dump(buf, mark, &line_num);
3724                         if (!fff) continue;
3725
3726                         /* Start dumping */
3727 #ifdef JP
3728                         fprintf(fff, "\n# ÃÏ·Á¤Î[¿§/ʸ»ú]¤ÎÀßÄê\n\n");
3729 #else
3730                         fprintf(fff, "\n# Feature attr/char definitions\n\n");
3731 #endif
3732                         line_num += 3;
3733
3734                         /* Dump features */
3735                         for (i = 1; i < max_f_idx; i++)
3736                         {
3737                                 feature_type *f_ptr = &f_info[i];
3738
3739                                 /* Skip non-entries */
3740                                 if (!f_ptr->name) continue;
3741
3742                                 /* Skip mimiccing features */
3743                                 if (f_ptr->mimic != i) continue;
3744
3745                                 /* Dump a comment */
3746                                 fprintf(fff, "# %s\n", (f_name + f_ptr->name));
3747                                 line_num++;
3748
3749                                 /* Dump the feature attr/char info */
3750                                 fprintf(fff, "F:%d:0x%02X/0x%02X\n\n", i,
3751                                         (byte)(f_ptr->x_attr), (byte)(f_ptr->x_char));
3752                                 line_num += 2;
3753                         }
3754
3755                         /* Close */
3756                         close_auto_dump(fff, mark, line_num);
3757
3758                         /* Message */
3759 #ifdef JP
3760                         msg_print("ÃÏ·Á¤Î[¿§/ʸ»ú]¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
3761 #else
3762                         msg_print("Dumped feature attr/chars.");
3763 #endif
3764
3765                 }
3766
3767                 /* Modify monster attr/chars */
3768                 else if (i == '6')
3769                 {
3770                         static int r = 0;
3771
3772                         /* Prompt */
3773 #ifdef JP
3774                         prt("¥³¥Þ¥ó¥É: ¥â¥ó¥¹¥¿¡¼¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹", 15, 0);
3775 #else
3776                         prt("Command: Change monster attr/chars", 15, 0);
3777 #endif
3778
3779
3780                         /* Hack -- query until done */
3781                         while (1)
3782                         {
3783                                 monster_race *r_ptr = &r_info[r];
3784                                 byte a, a2;
3785                                 char c, c2;
3786                                 int t;
3787
3788                                 byte da = (r_ptr->d_attr);
3789                                 byte dc = (r_ptr->d_char);
3790                                 byte ca = (r_ptr->x_attr);
3791                                 byte cc = (r_ptr->x_char);
3792
3793                                 /* Label the object */
3794 #ifdef JP
3795                                 Term_putstr(5, 17, -1, TERM_WHITE,
3796                                             format("¥â¥ó¥¹¥¿¡¼ = %d, Ì¾Á° = %-40.40s",
3797                                                    r, (r_name + r_ptr->name)));
3798 #else
3799                                 Term_putstr(5, 17, -1, TERM_WHITE,
3800                                             format("Monster = %d, Name = %-40.40s",
3801                                                    r, (r_name + r_ptr->name)));
3802 #endif
3803
3804
3805                                 /* Label the Default values */
3806 #ifdef JP
3807                                 Term_putstr(10, 19, -1, TERM_WHITE,
3808                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3u / %3u", da, dc));
3809 #else
3810                                 Term_putstr(10, 19, -1, TERM_WHITE,
3811                                             format("Default attr/char = %3u / %3u", da, dc));
3812 #endif
3813
3814                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
3815
3816                                 a = da;
3817                                 c = dc;
3818                                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
3819
3820                                 Term_putch(43, 19, a, c);
3821                                 if (use_bigtile) Term_putch(43 + 1, 19, a2, c2);
3822
3823                                 /* Label the Current values */
3824 #ifdef JP
3825                                 Term_putstr(10, 20, -1, TERM_WHITE,
3826                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3u / %3u", ca, cc));
3827 #else
3828                                 Term_putstr(10, 20, -1, TERM_WHITE,
3829                                             format("Current attr/char = %3u / %3u", ca, cc));
3830 #endif
3831
3832                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
3833
3834                                 a = ca;
3835                                 c = cc;
3836                                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
3837
3838                                 Term_putch(43, 20, a, c);
3839                                 if (use_bigtile) Term_putch(43 + 1, 20, a2, c2);
3840
3841
3842                                 /* Prompt */
3843 #ifdef JP
3844                                 Term_putstr(0, 22, -1, TERM_WHITE,
3845                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
3846 #else
3847                                 Term_putstr(0, 22, -1, TERM_WHITE,
3848                                             "Command (n/N/^N/a/A/^A/c/C/^C): ");
3849 #endif
3850
3851                                 /* Get a command */
3852                                 i = inkey();
3853
3854                                 /* All done */
3855                                 if (i == ESCAPE) break;
3856
3857                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
3858                                 else if (isupper(i)) c = 'a' + i - 'A';
3859                                 else c = i;
3860
3861                                 switch (c)
3862                                 {
3863                                 case 'n':
3864                                         cmd_visuals_aux(i, &r, max_r_idx);
3865                                         break;
3866                                 case 'a':
3867                                         t = (int)r_ptr->x_attr;
3868                                         cmd_visuals_aux(i, &t, 256);
3869                                         r_ptr->x_attr = (byte)t;
3870                                         break;
3871                                 case 'c':
3872                                         t = (int)r_ptr->x_char;
3873                                         cmd_visuals_aux(i, &t, 256);
3874                                         r_ptr->x_char = (byte)t;
3875                                         break;
3876                                 }
3877                         }
3878                 }
3879
3880                 /* Modify object attr/chars */
3881                 else if (i == '7')
3882                 {
3883                         static int k = 0;
3884
3885                         /* Prompt */
3886 #ifdef JP
3887                         prt("¥³¥Þ¥ó¥É: ¥¢¥¤¥Æ¥à¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹", 15, 0);
3888 #else
3889                         prt("Command: Change object attr/chars", 15, 0);
3890 #endif
3891
3892
3893                         /* Hack -- query until done */
3894                         while (1)
3895                         {
3896                                 object_kind *k_ptr = &k_info[k];
3897                                 byte a, a2;
3898                                 char c, c2;
3899                                 int t;
3900
3901                                 byte da = (byte)k_ptr->d_attr;
3902                                 byte dc = (byte)k_ptr->d_char;
3903                                 byte ca = (byte)k_ptr->x_attr;
3904                                 byte cc = (byte)k_ptr->x_char;
3905
3906                                 /* Label the object */
3907 #ifdef JP
3908                                 Term_putstr(5, 17, -1, TERM_WHITE,
3909                                             format("¥¢¥¤¥Æ¥à = %d, Ì¾Á° = %-40.40s",
3910                                                    k, (k_name + k_ptr->name)));
3911 #else
3912                                 Term_putstr(5, 17, -1, TERM_WHITE,
3913                                             format("Object = %d, Name = %-40.40s",
3914                                                    k, (k_name + k_ptr->name)));
3915 #endif
3916
3917
3918                                 /* Label the Default values */
3919 #ifdef JP
3920                                 Term_putstr(10, 19, -1, TERM_WHITE,
3921                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
3922 #else
3923                                 Term_putstr(10, 19, -1, TERM_WHITE,
3924                                             format("Default attr/char = %3d / %3d", da, dc));
3925 #endif
3926
3927                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
3928                                 a = da;
3929                                 c = dc;
3930                                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
3931
3932                                 Term_putch(43, 19, a, c);
3933                                 if (use_bigtile) Term_putch(43 + 1, 19, a2, c2);
3934
3935
3936                                 /* Label the Current values */
3937 #ifdef JP
3938                                 Term_putstr(10, 20, -1, TERM_WHITE,
3939                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
3940 #else
3941                                 Term_putstr(10, 20, -1, TERM_WHITE,
3942                                             format("Current attr/char = %3d / %3d", ca, cc));
3943 #endif
3944
3945                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
3946                                 a = ca;
3947                                 c = cc;
3948                                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
3949
3950                                 Term_putch(43, 20, a, c);
3951                                 if (use_bigtile) Term_putch(43 + 1, 20, a2, c2);
3952
3953
3954                                 /* Prompt */
3955 #ifdef JP
3956                                 Term_putstr(0, 22, -1, TERM_WHITE,
3957                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
3958 #else
3959                                 Term_putstr(0, 22, -1, TERM_WHITE,
3960                                             "Command (n/N/^N/a/A/^A/c/C/^C): ");
3961 #endif
3962
3963                                 /* Get a command */
3964                                 i = inkey();
3965
3966                                 /* All done */
3967                                 if (i == ESCAPE) break;
3968
3969                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
3970                                 else if (isupper(i)) c = 'a' + i - 'A';
3971                                 else c = i;
3972
3973                                 switch (c)
3974                                 {
3975                                 case 'n':
3976                                         cmd_visuals_aux(i, &k, max_k_idx);
3977                                         break;
3978                                 case 'a':
3979                                         t = (int)k_info[k].x_attr;
3980                                         cmd_visuals_aux(i, &t, 256);
3981                                         k_info[k].x_attr = (byte)t;
3982                                         break;
3983                                 case 'c':
3984                                         t = (int)k_info[k].x_char;
3985                                         cmd_visuals_aux(i, &t, 256);
3986                                         k_info[k].x_char = (byte)t;
3987                                         break;
3988                                 }
3989                         }
3990                 }
3991
3992                 /* Modify feature attr/chars */
3993                 else if (i == '8')
3994                 {
3995                         static int f = 0;
3996
3997                         /* Prompt */
3998 #ifdef JP
3999                         prt("¥³¥Þ¥ó¥É: ÃÏ·Á¤Î[¿§/ʸ»ú]¤òÊѹ¹¤·¤Þ¤¹", 15, 0);
4000 #else
4001                         prt("Command: Change feature attr/chars", 15, 0);
4002 #endif
4003
4004
4005                         /* Hack -- query until done */
4006                         while (1)
4007                         {
4008                                 feature_type *f_ptr = &f_info[f];
4009                                 byte a, a2;
4010                                 char c, c2;
4011                                 int t;
4012
4013                                 byte da = (byte)f_ptr->d_attr;
4014                                 byte dc = (byte)f_ptr->d_char;
4015                                 byte ca = (byte)f_ptr->x_attr;
4016                                 byte cc = (byte)f_ptr->x_char;
4017
4018                                 /* Label the object */
4019 #ifdef JP
4020                                 Term_putstr(5, 17, -1, TERM_WHITE,
4021                                             format("ÃÏ·Á = %d, Ì¾Á° = %-40.40s",
4022                                                    f, (f_name + f_ptr->name)));
4023 #else
4024                                 Term_putstr(5, 17, -1, TERM_WHITE,
4025                                             format("Terrain = %d, Name = %-40.40s",
4026                                                    f, (f_name + f_ptr->name)));
4027 #endif
4028
4029
4030                                 /* Label the Default values */
4031 #ifdef JP
4032                                 Term_putstr(10, 19, -1, TERM_WHITE,
4033                                             format("½é´üÃÍ  ¿§ / Ê¸»ú = %3d / %3d", da, dc));
4034 #else
4035                                 Term_putstr(10, 19, -1, TERM_WHITE,
4036                                             format("Default attr/char = %3d / %3d", da, dc));
4037 #endif
4038
4039                                 Term_putstr(40, 19, -1, TERM_WHITE, empty_symbol);
4040                                 a = da;
4041                                 c = dc;
4042                                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
4043
4044                                 Term_putch(43, 19, a, c);
4045                                 if (use_bigtile) Term_putch(43 + 1, 19, a2, c2);
4046
4047
4048                                 /* Label the Current values */
4049 #ifdef JP
4050                                 Term_putstr(10, 20, -1, TERM_WHITE,
4051                                             format("¸½ºßÃÍ  ¿§ / Ê¸»ú = %3d / %3d", ca, cc));
4052 #else
4053                                 Term_putstr(10, 20, -1, TERM_WHITE,
4054                                             format("Current attr/char = %3d / %3d", ca, cc));
4055 #endif
4056
4057                                 Term_putstr(40, 20, -1, TERM_WHITE, empty_symbol);
4058                                 a = ca;
4059                                 c = cc;
4060                                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
4061
4062                                 Term_putch(43, 20, a, c);
4063                                 if (use_bigtile) Term_putch(43 + 1, 20, a2, c2);
4064
4065
4066                                 /* Prompt */
4067 #ifdef JP
4068                                 Term_putstr(0, 22, -1, TERM_WHITE,
4069                                             "¥³¥Þ¥ó¥É (n/N/^N/a/A/^A/c/C/^C): ");
4070 #else
4071                                 Term_putstr(0, 22, -1, TERM_WHITE,
4072                                             "Command (n/N/^N/a/A/^A/c/C/^C): ");
4073 #endif
4074
4075                                 /* Get a command */
4076                                 i = inkey();
4077
4078                                 /* All done */
4079                                 if (i == ESCAPE) break;
4080
4081                                 if (iscntrl(i)) c = 'a' + i - KTRL('A');
4082                                 else if (isupper(i)) c = 'a' + i - 'A';
4083                                 else c = i;
4084
4085                                 switch (c)
4086                                 {
4087                                 case 'n':
4088                                         cmd_visuals_aux(i, &f, max_f_idx);
4089                                         break;
4090                                 case 'a':
4091                                         t = (int)f_info[f].x_attr;
4092                                         cmd_visuals_aux(i, &t, 256);
4093                                         f_info[f].x_attr = (byte)t;
4094                                         break;
4095                                 case 'c':
4096                                         t = (int)f_info[f].x_char;
4097                                         cmd_visuals_aux(i, &t, 256);
4098                                         f_info[f].x_char = (byte)t;
4099                                         break;
4100                                 }
4101                         }
4102                 }
4103
4104 #endif
4105
4106                 /* Reset visuals */
4107                 else if (i == '0')
4108                 {
4109                         /* Reset */
4110                         reset_visuals();
4111
4112                         /* Message */
4113 #ifdef JP
4114                         msg_print("²èÌ̾å¤Î[¿§/ʸ»ú]¤ò½é´üÃͤ˥ꥻ¥Ã¥È¤·¤Þ¤·¤¿¡£");
4115 #else
4116                         msg_print("Visual attr/char tables reset.");
4117 #endif
4118
4119                 }
4120
4121                 /* Unknown option */
4122                 else
4123                 {
4124                         bell();
4125                 }
4126
4127                 /* Flush messages */
4128                 msg_print(NULL);
4129         }
4130
4131
4132         /* Restore the screen */
4133         screen_load();
4134 }
4135
4136
4137 /*
4138  * Interact with "colors"
4139  */
4140 void do_cmd_colors(void)
4141 {
4142         int i;
4143
4144         FILE *fff;
4145
4146         char tmp[160];
4147
4148         char buf[1024];
4149
4150
4151         /* File type is "TEXT" */
4152         FILE_TYPE(FILE_TYPE_TEXT);
4153
4154
4155         /* Save the screen */
4156         screen_save();
4157
4158
4159         /* Interact until done */
4160         while (1)
4161         {
4162                 /* Clear screen */
4163                 Term_clear();
4164
4165                 /* Ask for a choice */
4166 #ifdef JP
4167                 prt("[ ¥«¥é¡¼¤ÎÀßÄê ]", 2, 0);
4168 #else
4169                 prt("Interact with Colors", 2, 0);
4170 #endif
4171
4172
4173                 /* Give some choices */
4174 #ifdef JP
4175                 prt("(1) ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤Î¥í¡¼¥É", 4, 5);
4176 #else
4177                 prt("(1) Load a user pref file", 4, 5);
4178 #endif
4179
4180 #ifdef ALLOW_COLORS
4181 #ifdef JP
4182                 prt("(2) ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤¹", 5, 5);
4183                 prt("(3) ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤¹¤ë", 6, 5);
4184 #else
4185                 prt("(2) Dump colors", 5, 5);
4186                 prt("(3) Modify colors", 6, 5);
4187 #endif
4188
4189 #endif
4190
4191                 /* Prompt */
4192 #ifdef JP
4193                 prt("¥³¥Þ¥ó¥É: ", 8, 0);
4194 #else
4195                 prt("Command: ", 8, 0);
4196 #endif
4197
4198
4199                 /* Prompt */
4200                 i = inkey();
4201
4202                 /* Done */
4203                 if (i == ESCAPE) break;
4204
4205                 /* Load a 'pref' file */
4206                 if (i == '1')
4207                 {
4208                         /* Prompt */
4209 #ifdef JP
4210                         prt("¥³¥Þ¥ó¥É: ¥æ¡¼¥¶¡¼ÀßÄê¥Õ¥¡¥¤¥ë¤ò¥í¡¼¥É¤·¤Þ¤¹", 8, 0);
4211 #else
4212                         prt("Command: Load a user pref file", 8, 0);
4213 #endif
4214
4215
4216                         /* Prompt */
4217 #ifdef JP
4218                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4219 #else
4220                         prt("File: ", 10, 0);
4221 #endif
4222
4223
4224                         /* Default file */
4225                         sprintf(tmp, "%s.prf", player_name);
4226
4227                         /* Query */
4228                         if (!askfor_aux(tmp, 70)) continue;
4229
4230                         /* Process the given filename */
4231                         (void)process_pref_file(tmp);
4232
4233                         /* Mega-Hack -- react to changes */
4234                         Term_xtra(TERM_XTRA_REACT, 0);
4235
4236                         /* Mega-Hack -- redraw */
4237                         Term_redraw();
4238                 }
4239
4240 #ifdef ALLOW_COLORS
4241
4242                 /* Dump colors */
4243                 else if (i == '2')
4244                 {
4245                         static cptr mark = "Colors";
4246                         int line_num;
4247
4248                         /* Prompt */
4249 #ifdef JP
4250                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤¹", 8, 0);
4251 #else
4252                         prt("Command: Dump colors", 8, 0);
4253 #endif
4254
4255
4256                         /* Prompt */
4257 #ifdef JP
4258                         prt("¥Õ¥¡¥¤¥ë: ", 10, 0);
4259 #else
4260                         prt("File: ", 10, 0);
4261 #endif
4262
4263
4264                         /* Default filename */
4265                         sprintf(tmp, "%s.prf", player_name);
4266
4267                         /* Get a filename */
4268                         if (!askfor_aux(tmp, 70)) continue;
4269
4270                         /* Build the filename */
4271                         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
4272
4273                         /* Append to the file */
4274                         fff = open_auto_dump(buf, mark, &line_num);
4275                         if (!fff) continue;
4276
4277                         /* Start dumping */
4278 #ifdef JP
4279                         fprintf(fff, "\n# ¥«¥é¡¼¤ÎÀßÄê\n\n");
4280 #else
4281                         fprintf(fff, "\n# Color redefinitions\n\n");
4282 #endif
4283                         line_num += 3;
4284
4285                         /* Dump colors */
4286                         for (i = 0; i < 256; i++)
4287                         {
4288                                 int kv = angband_color_table[i][0];
4289                                 int rv = angband_color_table[i][1];
4290                                 int gv = angband_color_table[i][2];
4291                                 int bv = angband_color_table[i][3];
4292
4293 #ifdef JP
4294                                 cptr name = "̤ÃÎ";
4295 #else
4296                                 cptr name = "unknown";
4297 #endif
4298
4299
4300                                 /* Skip non-entries */
4301                                 if (!kv && !rv && !gv && !bv) continue;
4302
4303                                 /* Extract the color name */
4304                                 if (i < 16) name = color_names[i];
4305
4306                                 /* Dump a comment */
4307 #ifdef JP
4308                                 fprintf(fff, "# ¥«¥é¡¼ '%s'\n", name);
4309 #else
4310                                 fprintf(fff, "# Color '%s'\n", name);
4311 #endif
4312                                 line_num++;
4313
4314                                 /* Dump the monster attr/char info */
4315                                 fprintf(fff, "V:%d:0x%02X:0x%02X:0x%02X:0x%02X\n\n",
4316                                         i, kv, rv, gv, bv);
4317                                 line_num += 2;
4318                         }
4319
4320                         /* Close */
4321                         close_auto_dump(fff, mark, line_num);
4322
4323                         /* Message */
4324 #ifdef JP
4325                         msg_print("¥«¥é¡¼¤ÎÀßÄê¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
4326 #else
4327                         msg_print("Dumped color redefinitions.");
4328 #endif
4329
4330                 }
4331
4332                 /* Edit colors */
4333                 else if (i == '3')
4334                 {
4335                         static byte a = 0;
4336
4337                         /* Prompt */
4338 #ifdef JP
4339                         prt("¥³¥Þ¥ó¥É: ¥«¥é¡¼¤ÎÀßÄê¤òÊѹ¹¤·¤Þ¤¹", 8, 0);
4340 #else
4341                         prt("Command: Modify colors", 8, 0);
4342 #endif
4343
4344
4345                         /* Hack -- query until done */
4346                         while (1)
4347                         {
4348                                 cptr name;
4349                                 byte j;
4350
4351                                 /* Clear */
4352                                 clear_from(10);
4353
4354                                 /* Exhibit the normal colors */
4355                                 for (j = 0; j < 16; j++)
4356                                 {
4357                                         /* Exhibit this color */
4358                                         Term_putstr(j*4, 20, -1, a, "###");
4359
4360                                         /* Exhibit all colors */
4361                                         Term_putstr(j*4, 22, -1, j, format("%3d", j));
4362                                 }
4363
4364                                 /* Describe the color */
4365 #ifdef JP
4366                                 name = ((a < 16) ? color_names[a] : "̤ÄêµÁ");
4367 #else
4368                                 name = ((a < 16) ? color_names[a] : "undefined");
4369 #endif
4370
4371
4372                                 /* Describe the color */
4373 #ifdef JP
4374                                 Term_putstr(5, 10, -1, TERM_WHITE,
4375                                             format("¥«¥é¡¼ = %d, Ì¾Á° = %s", a, name));
4376 #else
4377                                 Term_putstr(5, 10, -1, TERM_WHITE,
4378                                             format("Color = %d, Name = %s", a, name));
4379 #endif
4380
4381
4382                                 /* Label the Current values */
4383                                 Term_putstr(5, 12, -1, TERM_WHITE,
4384                                             format("K = 0x%02x / R,G,B = 0x%02x,0x%02x,0x%02x",
4385                                                    angband_color_table[a][0],
4386                                                    angband_color_table[a][1],
4387                                                    angband_color_table[a][2],
4388                                                    angband_color_table[a][3]));
4389
4390                                 /* Prompt */
4391 #ifdef JP
4392                                 Term_putstr(0, 14, -1, TERM_WHITE,
4393                                             "¥³¥Þ¥ó¥É (n/N/k/K/r/R/g/G/b/B): ");
4394 #else
4395                                 Term_putstr(0, 14, -1, TERM_WHITE,
4396                                             "Command (n/N/k/K/r/R/g/G/b/B): ");
4397 #endif
4398
4399
4400                                 /* Get a command */
4401                                 i = inkey();
4402
4403                                 /* All done */
4404                                 if (i == ESCAPE) break;
4405
4406                                 /* Analyze */
4407                                 if (i == 'n') a = (byte)(a + 1);
4408                                 if (i == 'N') a = (byte)(a - 1);
4409                                 if (i == 'k') angband_color_table[a][0] = (byte)(angband_color_table[a][0] + 1);
4410                                 if (i == 'K') angband_color_table[a][0] = (byte)(angband_color_table[a][0] - 1);
4411                                 if (i == 'r') angband_color_table[a][1] = (byte)(angband_color_table[a][1] + 1);
4412                                 if (i == 'R') angband_color_table[a][1] = (byte)(angband_color_table[a][1] - 1);
4413                                 if (i == 'g') angband_color_table[a][2] = (byte)(angband_color_table[a][2] + 1);
4414                                 if (i == 'G') angband_color_table[a][2] = (byte)(angband_color_table[a][2] - 1);
4415                                 if (i == 'b') angband_color_table[a][3] = (byte)(angband_color_table[a][3] + 1);
4416                                 if (i == 'B') angband_color_table[a][3] = (byte)(angband_color_table[a][3] - 1);
4417
4418                                 /* Hack -- react to changes */
4419                                 Term_xtra(TERM_XTRA_REACT, 0);
4420
4421                                 /* Hack -- redraw */
4422                                 Term_redraw();
4423                         }
4424                 }
4425
4426 #endif
4427
4428                 /* Unknown option */
4429                 else
4430                 {
4431                         bell();
4432                 }
4433
4434                 /* Flush messages */
4435                 msg_print(NULL);
4436         }
4437
4438
4439         /* Restore the screen */
4440         screen_load();
4441 }
4442
4443
4444 /*
4445  * Note something in the message recall
4446  */
4447 void do_cmd_note(void)
4448 {
4449         char buf[80];
4450
4451         /* Default */
4452         strcpy(buf, "");
4453
4454         /* Input */
4455 #ifdef JP
4456         if (!get_string("¥á¥â: ", buf, 60)) return;
4457 #else
4458         if (!get_string("Note: ", buf, 60)) return;
4459 #endif
4460
4461
4462         /* Ignore empty notes */
4463         if (!buf[0] || (buf[0] == ' ')) return;
4464
4465         /* Add the note to the message recall */
4466 #ifdef JP
4467         msg_format("¥á¥â: %s", buf);
4468 #else
4469         msg_format("Note: %s", buf);
4470 #endif
4471
4472 }
4473
4474
4475 /*
4476  * Mention the current version
4477  */
4478 void do_cmd_version(void)
4479 {
4480
4481         /* Silly message */
4482 #ifdef JP
4483         msg_format("ÊѶòÈÚÅÜ(Hengband) %d.%d.%d",
4484                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4485 #else
4486         msg_format("You are playing Hengband %d.%d.%d.",
4487                     FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4488 #endif
4489 }
4490
4491
4492
4493 /*
4494  * Array of feeling strings
4495  */
4496 static cptr do_cmd_feeling_text[11] =
4497 {
4498 #ifdef JP
4499         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4500 #else
4501         "Looks like any other level.",
4502 #endif
4503
4504 #ifdef JP
4505         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4506 #else
4507         "You feel there is something special about this level.",
4508 #endif
4509
4510 #ifdef JP
4511         "¶²¤í¤·¤¤»à¤Î¸¸¤¬ÌܤËÉ⤫¤Ó¡¢µ¤À䤷¤½¤¦¤Ë¤Ê¤Ã¤¿¡ª",
4512 #else
4513         "You nearly faint as horrible visions of death fill your mind!",
4514 #endif
4515
4516 #ifdef JP
4517         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4518 #else
4519         "This level looks very dangerous.",
4520 #endif
4521
4522 #ifdef JP
4523         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4524 #else
4525         "You have a very bad feeling...",
4526 #endif
4527
4528 #ifdef JP
4529         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4530 #else
4531         "You have a bad feeling...",
4532 #endif
4533
4534 #ifdef JP
4535         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4536 #else
4537         "You feel nervous.",
4538 #endif
4539
4540 #ifdef JP
4541         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4542 #else
4543         "You feel your luck is turning...",
4544 #endif
4545
4546 #ifdef JP
4547         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4548 #else
4549         "You don't like the look of this place.",
4550 #endif
4551
4552 #ifdef JP
4553         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4554 #else
4555         "This level looks reasonably safe.",
4556 #endif
4557
4558 #ifdef JP
4559         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4560 #else
4561         "What a boring place..."
4562 #endif
4563
4564 };
4565
4566 static cptr do_cmd_feeling_text_combat[11] =
4567 {
4568 #ifdef JP
4569         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4570 #else
4571         "Looks like any other level.",
4572 #endif
4573
4574 #ifdef JP
4575         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4576 #else
4577         "You feel there is something special about this level.",
4578 #endif
4579
4580 #ifdef JP
4581         "º£Ìë¤â¤Þ¤¿¡¢Ã¯¤«¤¬Ì¿¤òÍî¤È¤¹...",
4582 #else
4583         "You nearly faint as horrible visions of death fill your mind!",
4584 #endif
4585
4586 #ifdef JP
4587         "¤³¤Î³¬¤Ï¤È¤Æ¤â´í¸±¤Ê¤è¤¦¤À¡£",
4588 #else
4589         "This level looks very dangerous.",
4590 #endif
4591
4592 #ifdef JP
4593         "¤È¤Æ¤â°­¤¤Í½´¶¤¬¤¹¤ë...",
4594 #else
4595         "You have a very bad feeling...",
4596 #endif
4597
4598 #ifdef JP
4599         "°­¤¤Í½´¶¤¬¤¹¤ë...",
4600 #else
4601         "You have a bad feeling...",
4602 #endif
4603
4604 #ifdef JP
4605         "²¿¤«¶ÛÄ¥¤¹¤ë¡£",
4606 #else
4607         "You feel nervous.",
4608 #endif
4609
4610 #ifdef JP
4611         "¾¯¤·ÉÔ±¿¤Êµ¤¤¬¤¹¤ë...",
4612 #else
4613         "You feel your luck is turning...",
4614 #endif
4615
4616 #ifdef JP
4617         "¤³¤Î¾ì½ê¤Ï¹¥¤­¤Ë¤Ê¤ì¤Ê¤¤¡£",
4618 #else
4619         "You don't like the look of this place.",
4620 #endif
4621
4622 #ifdef JP
4623         "¤³¤Î³¬¤Ï¤½¤ì¤Ê¤ê¤Ë°ÂÁ´¤Ê¤è¤¦¤À¡£",
4624 #else
4625         "This level looks reasonably safe.",
4626 #endif
4627
4628 #ifdef JP
4629         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4630 #else
4631         "What a boring place..."
4632 #endif
4633
4634 };
4635
4636 static cptr do_cmd_feeling_text_lucky[11] =
4637 {
4638 #ifdef JP
4639         "¤³¤Î³¬¤ÎÊ·°Ïµ¤¤ò´¶¤¸¤È¤ì¤Ê¤«¤Ã¤¿...",
4640         "¤³¤Î³¬¤Ë¤Ï²¿¤«ÆÃÊ̤ʤâ¤Î¤¬¤¢¤ë¤è¤¦¤Êµ¤¤¬¤¹¤ë¡£",
4641         "¤³¤Î³¬¤Ï¤³¤Î¾å¤Ê¤¯ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë¡£",
4642         "ÁÇÀ²¤é¤·¤¤´¶¤¸¤¬¤¹¤ë...",
4643         "¤È¤Æ¤âÎɤ¤´¶¤¸¤¬¤¹¤ë...",
4644         "Îɤ¤´¶¤¸¤¬¤¹¤ë...",
4645         "¤Á¤ç¤Ã¤È¹¬±¿¤Ê´¶¤¸¤¬¤¹¤ë...",
4646         "¿¾¯¤Ï±¿¤¬¸þ¤¤¤Æ¤­¤¿¤«...",
4647         "¸«¤¿´¶¤¸°­¤¯¤Ï¤Ê¤¤...",
4648         "Á´Á³ÂÌÌܤȤ¤¤¦¤³¤È¤Ï¤Ê¤¤¤¬...",
4649         "¤Ê¤ó¤ÆÂà¶þ¤Ê¤È¤³¤í¤À..."
4650 #else
4651         "Looks like any other level.",
4652         "You feel there is something special about this level.",
4653         "You have a superb feeling about this level.",
4654         "You have an excellent feeling...",
4655         "You have a very good feeling...",
4656         "You have a good feeling...",
4657         "You feel strangely lucky...",
4658         "You feel your luck is turning...",
4659         "You like the look of this place...",
4660         "This level can't be all bad...",
4661         "What a boring place..."
4662 #endif
4663 };
4664
4665
4666 /*
4667  * Note that "feeling" is set to zero unless some time has passed.
4668  * Note that this is done when the level is GENERATED, not entered.
4669  */
4670 void do_cmd_feeling(void)
4671 {
4672         /* Verify the feeling */
4673         if (feeling > 10) feeling = 10;
4674
4675         /* No useful feeling in quests */
4676         if (p_ptr->inside_quest && !random_quest_number(dun_level))
4677         {
4678 #ifdef JP
4679                 msg_print("ŵ·¿Åª¤Ê¥¯¥¨¥¹¥È¤Î¥À¥ó¥¸¥ç¥ó¤Î¤è¤¦¤À¡£");
4680 #else
4681                 msg_print("Looks like a typical quest level.");
4682 #endif
4683
4684                 return;
4685         }
4686
4687         /* No useful feeling in town */
4688         else if (p_ptr->town_num && !dun_level)
4689         {
4690 #ifdef JP
4691                 if (!strcmp(town[p_ptr->town_num].name, "¹ÓÌî"))
4692 #else
4693                 if (!strcmp(town[p_ptr->town_num].name, "wilderness"))
4694 #endif
4695                 {
4696 #ifdef JP
4697                         msg_print("²¿¤«¤¢¤ê¤½¤¦¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
4698 #else
4699                         msg_print("Looks like a strange wilderness.");
4700 #endif
4701
4702                         return;
4703                 }
4704                 else
4705                 {
4706 #ifdef JP
4707                         msg_print("ŵ·¿Åª¤ÊÄ®¤Î¤è¤¦¤À¡£");
4708 #else
4709                         msg_print("Looks like a typical town.");
4710 #endif
4711
4712                         return;
4713                 }
4714         }
4715
4716         /* No useful feeling in the wilderness */
4717         else if (!dun_level)
4718         {
4719 #ifdef JP
4720                 msg_print("ŵ·¿Åª¤Ê¹ÓÌî¤Î¤è¤¦¤À¡£");
4721 #else
4722                 msg_print("Looks like a typical wilderness.");
4723 #endif
4724
4725                 return;
4726         }
4727
4728         /* Display the feeling */
4729         if (turn - old_turn >= (150 - dun_level)*TURNS_PER_TICK || cheat_xtra)
4730         {
4731                 if (p_ptr->muta3 & MUT3_GOOD_LUCK) msg_print(do_cmd_feeling_text_lucky[feeling]);
4732                 else {
4733                                         if((p_ptr->pseikaku == SEIKAKU_COMBAT) || (inventory[INVEN_BOW].name1 == ART_CRIMSON)){
4734                                                 msg_print(do_cmd_feeling_text_combat[feeling]);
4735                                         }else
4736                                                 msg_print(do_cmd_feeling_text[feeling]);
4737                                 }
4738         }
4739         else
4740         {
4741                 msg_print(do_cmd_feeling_text[0]);
4742         }
4743 }
4744
4745
4746
4747 /*
4748  * Description of each monster group.
4749  */
4750 static cptr monster_group_text[] = 
4751 {
4752 #ifdef JP
4753         "¥æ¥Ë¡¼¥¯",     /* "Uniques" */
4754         "¥¢¥ê",
4755         "¥³¥¦¥â¥ê",
4756         "¥à¥«¥Ç",
4757         "¥É¥é¥´¥ó",
4758         "ÌܶÌ",
4759         "¥Í¥³",
4760         "¥´¡¼¥ì¥à",
4761         "ɸ½à¿Í´Ö·¿À¸Êª",
4762         "¥Ù¥È¥Ù¥È",
4763         "¥¼¥ê¡¼",
4764         "¥³¥Ü¥ë¥É",
4765         "¿åÀ³À¸Êª",
4766         "¥â¥ë¥É",
4767         "¥Ê¡¼¥¬",
4768         "¥ª¡¼¥¯",
4769         "¿Í´Ö",
4770         "»Í­½Ã",
4771         "¥Í¥º¥ß",
4772         "¥¹¥±¥ë¥È¥ó",
4773         "¥Ç¡¼¥â¥ó",
4774         "¥Ü¥ë¥Æ¥Ã¥¯¥¹",
4775         "¥¤¥â¥à¥·/Âç·²",
4776         /* "unused", */
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         "¤ª¤Ð¤±¥­¥Î¥³",
4807 #else
4808         "Uniques",
4809         "Ant",
4810         "Bat",
4811         "Centipede",
4812         "Dragon",
4813         "Floating Eye",
4814         "Feline",
4815         "Golem",
4816         "Hobbit/Elf/Dwarf",
4817         "Icky Thing",
4818         "Jelly",
4819         "Kobold",
4820         "Aquatic monster",
4821         "Mold",
4822         "Naga",
4823         "Orc",
4824         "Person/Human",
4825         "Quadruped",
4826         "Rodent",
4827         "Skeleton",
4828         "Demon",
4829         "Vortex",
4830         "Worm/Worm-Mass",
4831         /* "unused", */
4832         "Yeek",
4833         "Zombie/Mummy",
4834         "Angel",
4835         "Bird",
4836         "Canine",
4837         /* "Ancient Dragon/Wyrm", */
4838         "Elemental",
4839         "Dragon Fly",
4840         "Ghost",
4841         "Hybrid",
4842         "Insect",
4843         "Snake",
4844         "Killer Beetle",
4845         "Lich",
4846         "Multi-Headed Reptile",
4847         "Mystery Living",
4848         "Ogre",
4849         "Giant Humanoid",
4850         "Quylthulg",
4851         "Reptile/Amphibian",
4852         "Spider/Scorpion/Tick",
4853         "Troll",
4854         /* "Major Demon", */
4855         "Vampire",
4856         "Wight/Wraith/etc",
4857         "Xorn/Xaren/etc",
4858         "Yeti",
4859         "Zephyr Hound",
4860         "Mimic",
4861         "Mushroom patch",
4862 #endif
4863         NULL
4864 };
4865
4866
4867 /*
4868  * Symbols of monsters in each group. Note the "Uniques" group
4869  * is handled differently.
4870  */
4871 static cptr monster_group_char[] = 
4872 {
4873         (char *) -1L,
4874         "a",
4875         "b",
4876         "c",
4877         "dD",
4878         "e",
4879         "f",
4880         "g",
4881         "h",
4882         "i",
4883         "j",
4884         "k",
4885         "l",
4886         "m",
4887         "n",
4888         "o",
4889         "pt",
4890         "q",
4891         "r",
4892         "s",
4893         "uU",
4894         "v",
4895         "w",
4896         /* "x", */
4897         "y",
4898         "z",
4899         "A",
4900         "B",
4901         "C",
4902         /* "D", */
4903         "E",
4904         "F",
4905         "G",
4906         "H",
4907         "I",
4908         "J",
4909         "K",
4910         "L",
4911         "M",
4912         "N",
4913         "O",
4914         "P",
4915         "Q",
4916         "R",
4917         "S",
4918         "T",
4919         /* "U", */
4920         "V",
4921         "W",
4922         "X",
4923         "Y",
4924         "Z",
4925         "$!?=.|~[]",
4926         ",",
4927         NULL
4928 };
4929
4930
4931 /*
4932  * hook function to sort monsters by level
4933  */
4934 static bool ang_sort_comp_monster_level(vptr u, vptr v, int a, int b)
4935 {
4936         u16b *who = (u16b*)(u);
4937
4938         int w1 = who[a];
4939         int w2 = who[b];
4940
4941         monster_race *r_ptr1 = &r_info[w1];
4942         monster_race *r_ptr2 = &r_info[w2];
4943
4944         /* Unused */
4945         (void)v;
4946
4947         if (r_ptr2->level > r_ptr1->level) return TRUE;
4948         if (r_ptr1->level > r_ptr2->level) return FALSE;
4949
4950         if ((r_ptr2->flags1 & RF1_UNIQUE) && !(r_ptr1->flags1 & RF1_UNIQUE)) return TRUE;
4951         if ((r_ptr1->flags1 & RF1_UNIQUE) && !(r_ptr2->flags1 & RF1_UNIQUE)) return FALSE;
4952         return w1 <= w2;
4953 }
4954
4955 /*
4956  * Build a list of monster indexes in the given group. Return the number
4957  * of monsters in the group.
4958  *
4959  * mode & 0x01 : check for non-empty group
4960  * mode & 0x02 : cheat?
4961  */
4962 static int collect_monsters(int grp_cur, s16b mon_idx[], byte mode)
4963 {
4964         int i, mon_cnt = 0;
4965         int dummy_why;
4966
4967         /* Get a list of x_char in this group */
4968         cptr group_char = monster_group_char[grp_cur];
4969
4970         /* XXX Hack -- Check if this is the "Uniques" group */
4971         bool grp_unique = (monster_group_char[grp_cur] == (char *) -1L);
4972
4973         /* Check every race */
4974         for (i = 0; i < max_r_idx; i++)
4975         {
4976                 /* Access the race */
4977                 monster_race *r_ptr = &r_info[i];
4978
4979                 /* Skip empty race */
4980                 if (!r_ptr->name) continue ;
4981
4982                 /* Require known monsters */
4983                 if (!(mode & 0x02) && !cheat_know && !r_ptr->r_sights ) continue;
4984
4985                 if (grp_unique && !(r_ptr->flags1 & RF1_UNIQUE)) continue;
4986
4987                 /* Check for race in the group */
4988                 if (grp_unique || strchr(group_char, r_ptr->d_char))
4989                 {
4990                         /* Add the race */
4991                         mon_idx[mon_cnt++] = i;
4992
4993                         /* XXX Hack -- Just checking for non-empty group */
4994                         if (mode & 0x01) break;
4995                 }
4996         }
4997
4998         /* Terminate the list */
4999         mon_idx[mon_cnt] = 0;
5000
5001         /* Select the sort method */
5002         ang_sort_comp = ang_sort_comp_monster_level;
5003         ang_sort_swap = ang_sort_swap_hook;
5004
5005         /* Sort by monster level */
5006         ang_sort(mon_idx, &dummy_why, mon_cnt);
5007
5008         /* Return the number of races */
5009         return mon_cnt;
5010 }
5011
5012
5013 /*
5014  * Description of each monster group.
5015  */
5016 static cptr object_group_text[] = 
5017 {
5018 #ifdef JP
5019         "¥­¥Î¥³",       /* "Mushrooms" */
5020         "Ìô",           /* "Potions" */
5021         "Ìý¤Ä¤Ü",       /* "Flasks" */
5022         "´¬Êª",         /* "Scrolls" */
5023         "»ØÎØ",         /* "Rings" */
5024         "¥¢¥ß¥å¥ì¥Ã¥È", /* "Amulets" */
5025         "ū",           /* "Whistle" */
5026         "¸÷¸»",         /* "Lanterns" */
5027         "ËâË¡ËÀ",       /* "Wands" */
5028         "¾ó",           /* "Staffs" */
5029         "¥í¥Ã¥É",       /* "Rods" */
5030         "¥«¡¼¥É",       /* "Cards" */
5031         "¥­¥ã¥×¥Á¥ã¡¼¡¦¥Ü¡¼¥ë",
5032         "ÍÓÈé»æ",       
5033         "¤¯¤µ¤Ó",
5034         "Ȣ",
5035         "¿Í·Á",
5036         "Áü",
5037         "¥´¥ß",
5038         "¶õ¤Î¥Ó¥ó",
5039         "¹ü",
5040         "Åá·õÎà",       /* "Swords" */
5041         "Æß´ï",         /* "Blunt Weapons" */
5042         "ĹÊÁÉð´ï",     /* "Polearms" */
5043         "ºÎ·¡Æ»¶ñ",     /* "Diggers" */
5044         "Èô¤ÓÆ»¶ñ",     /* "Bows" */
5045         "ÃÆ",
5046         "Ìð",
5047         "¥Ü¥ë¥È",
5048         "·ÚÁõ³»",       /* "Soft Armor" */
5049         "½ÅÁõ³»",       /* "Hard Armor" */
5050         "¥É¥é¥´¥ó³»",   /* "Dragon Armor" */
5051         "½â",   /* "Shields" */
5052         "¥¯¥í¡¼¥¯",     /* "Cloaks" */
5053         "äƼê", /* "Gloves" */
5054         "¥Ø¥ë¥á¥Ã¥È",   /* "Helms" */
5055         "´§",   /* "Crowns" */
5056         "¥Ö¡¼¥Ä",       /* "Boots" */
5057         "ËâË¡½ñ",
5058 #else
5059         "Mushrooms",
5060         "Potions",
5061         "Flasks",
5062         "Scrolls",
5063         "Rings",
5064         "Amulets",
5065         "Whistle",
5066         "Lanterns",
5067         "Wands",
5068         "Staves",
5069         "Rods",
5070         "Cards",
5071         "Capture Balls",
5072         "Parchements",
5073         "Spikes",
5074         "Boxs",
5075         "Figurines",
5076         "Statues",
5077         "Junks",
5078         "Bottles",
5079         "Skeletons",
5080         "Swords",
5081         "Blunt Weapons",
5082         "Polearms",
5083         "Diggers",
5084         "Bows",
5085         "Shots",
5086         "Arrows",
5087         "Bolts",
5088         "Soft Armor",
5089         "Hard Armor",
5090         "Dragon Armor",
5091         "Shields",
5092         "Cloaks",
5093         "Gloves",
5094         "Helms",
5095         "Crowns",
5096         "Boots",
5097         "Spellbooks",
5098 #endif
5099         NULL
5100 };
5101
5102
5103 /*
5104  * TVALs of items in each group
5105  */
5106 static byte object_group_tval[] = 
5107 {
5108         TV_FOOD,
5109         TV_POTION,
5110         TV_FLASK,
5111         TV_SCROLL,
5112         TV_RING,
5113         TV_AMULET,
5114         TV_WHISTLE,
5115         TV_LITE,
5116         TV_WAND,
5117         TV_STAFF,
5118         TV_ROD,
5119         TV_CARD,
5120         TV_CAPTURE,
5121         TV_PARCHEMENT,
5122         TV_SPIKE,
5123         TV_CHEST,
5124         TV_FIGURINE,
5125         TV_STATUE,
5126         TV_JUNK,
5127         TV_BOTTLE,
5128         TV_SKELETON,
5129         TV_SWORD,
5130         TV_HAFTED,
5131         TV_POLEARM,
5132         TV_DIGGING,
5133         TV_BOW,
5134         TV_SHOT,
5135         TV_ARROW,
5136         TV_BOLT,
5137         TV_SOFT_ARMOR,
5138         TV_HARD_ARMOR,
5139         TV_DRAG_ARMOR,
5140         TV_SHIELD,
5141         TV_CLOAK,
5142         TV_GLOVES,
5143         TV_HELM,
5144         TV_CROWN,
5145         TV_BOOTS,
5146         TV_LIFE_BOOK, /* Hack -- all spellbooks */
5147         0
5148 };
5149
5150
5151 /*
5152  * Build a list of monster indexes in the given group. Return the number
5153  * of monsters in the group.
5154  */
5155 static int collect_objects(int grp_cur, int object_idx[])
5156 {
5157         int i, j, k, object_cnt = 0;
5158
5159         /* Get a list of x_char in this group */
5160         byte group_tval = object_group_tval[grp_cur];
5161
5162         /* Check every object */
5163         for (i = 0; i < max_k_idx; i++)
5164         {
5165                 /* Access the race */
5166                 object_kind *k_ptr = &k_info[i];
5167
5168                 /* Skip empty objects */
5169                 if (!k_ptr->name) continue;
5170
5171                 /* Skip non-flavoured objects */
5172                 if (!k_ptr->flavor && !p_ptr->wizard) continue;
5173
5174                 /* Skip items with no distribution (special artifacts) */
5175                 for (j = 0, k = 0; j < 4; j++) k += k_ptr->chance[j];
5176                 if (!(k))  continue; 
5177
5178                 /* Require objects ever seen*/
5179                 if (!k_ptr->aware && !p_ptr->wizard) continue;
5180
5181                 /* Check for race in the group */
5182                 if (TV_LIFE_BOOK == group_tval)
5183                 {
5184                         /* Hack -- All spell books */
5185                         if (TV_LIFE_BOOK <= k_ptr->tval && k_ptr->tval <= TV_HISSATSU_BOOK)
5186                         {
5187                                 /* Add the race */
5188                                 object_idx[object_cnt++] = i;
5189                         }
5190                 }
5191                 else if (k_ptr->tval == group_tval)
5192                 {
5193                         /* Add the race */
5194                         object_idx[object_cnt++] = i;
5195                 }
5196         }
5197
5198         /* Terminate the list */
5199         object_idx[object_cnt] = 0;
5200
5201         /* Return the number of races */
5202         return object_cnt;
5203 }
5204
5205
5206 /*
5207  * Description of each feature group.
5208  */
5209 static cptr feature_group_text[] = 
5210 {
5211         "terrains",
5212         NULL
5213 };
5214
5215
5216 /*
5217  * Build a list of feature indexes in the given group. Return the number
5218  * of features in the group.
5219  */
5220 static int collect_features(int grp_cur, int *feat_idx)
5221 {
5222         int i, feat_cnt = 0;
5223
5224         /* Unused;  There is a single group. */
5225         (void)grp_cur;
5226
5227         /* Check every feature */
5228         for (i = 1; i < max_f_idx; i++)
5229         {
5230                 /* Access the index */
5231                 feature_type *f_ptr = &f_info[i];
5232
5233                 /* Skip empty index */
5234                 if (!f_ptr->name) continue;
5235
5236                 /* Skip mimiccing features */
5237                 if (f_ptr->mimic != i) continue;
5238
5239                 /* Add the index */
5240                 feat_idx[feat_cnt++] = i;
5241         }
5242
5243         /* Terminate the list */
5244         feat_idx[feat_cnt] = 0;
5245
5246         /* Return the number of races */
5247         return feat_cnt;
5248 }
5249
5250
5251 #if 0
5252 /*
5253  * Build a list of monster indexes in the given group. Return the number
5254  * of monsters in the group.
5255  */
5256 static int collect_artifacts(int grp_cur, int object_idx[])
5257 {
5258         int i, object_cnt = 0;
5259
5260         /* Get a list of x_char in this group */
5261         byte group_tval = object_group_tval[grp_cur];
5262
5263         /* Check every object */
5264         for (i = 0; i < max_a_idx; i++)
5265         {
5266                 /* Access the artifact */
5267                 artifact_type *a_ptr = &a_info[i];
5268
5269                 /* Skip empty artifacts */
5270                 if (!a_ptr->name) continue;
5271
5272                 /* Skip "uncreated" artifacts */
5273                 if (!a_ptr->cur_num) continue;
5274
5275                 /* Check for race in the group */
5276                 if (a_ptr->tval == group_tval)
5277                 {
5278                         /* Add the race */
5279                         object_idx[object_cnt++] = i;
5280                 }
5281         }
5282
5283         /* Terminate the list */
5284         object_idx[object_cnt] = 0;
5285
5286         /* Return the number of races */
5287         return object_cnt;
5288 }
5289 #endif /* 0 */
5290
5291
5292 /*
5293  * Encode the screen colors
5294  */
5295 static char hack[17] = "dwsorgbuDWvyRGBU";
5296
5297
5298 static errr photo_fgets(FILE *fff, char *buf, huge n)
5299 {
5300         huge i = 0;
5301
5302         char *s;
5303
5304         char tmp[1024];
5305
5306         /* Read a line */
5307         if (fgets(tmp, 1024, fff))
5308         {
5309                 /* Convert weirdness */
5310                 for (s = tmp; *s; s++)
5311                 {
5312                         /* Handle newline */
5313                         if (*s == '\n')
5314                         {
5315                                 /* Terminate */
5316                                 buf[i] = '\0';
5317
5318                                 /* Success */
5319                                 return (0);
5320                         }
5321
5322                         /* Handle tabs */
5323                         else if (*s == '\t')
5324                         {
5325                                 /* Hack -- require room */
5326                                 if (i + 8 >= n) break;
5327
5328                                 /* Append a space */
5329                                 buf[i++] = ' ';
5330
5331                                 /* Append some more spaces */
5332                                 while (!(i % 8)) buf[i++] = ' ';
5333                         }
5334
5335 #ifdef JP
5336                         else if (iskanji(*s))
5337                         {
5338                                 if (!s[1]) break;
5339                                 buf[i++] = *s++;
5340                                 buf[i++] = *s;
5341                         }
5342 # ifndef EUC
5343         /* È¾³Ñ¤«¤Ê¤ËÂбþ */
5344                         else if ((((int)*s & 0xff) > 0xa1) && (((int)*s & 0xff ) < 0xdf))
5345                         {
5346                                 buf[i++] = *s;
5347                                 if (i >= n) break;
5348                         }
5349 # endif
5350 #endif
5351                         /* Handle printables */
5352                         else
5353                         {
5354                                 /* Copy */
5355                                 buf[i++] = *s;
5356
5357                                 /* Check length */
5358                                 if (i >= n) break;
5359                         }
5360                 }
5361         }
5362
5363         /* Nothing */
5364         buf[0] = '\0';
5365
5366         /* Failure */
5367         return (1);
5368 }
5369
5370
5371 /*
5372  * Hack -- load a screen dump from a file
5373  */
5374 void do_cmd_load_screen(void)
5375 {
5376         int i, y, x;
5377
5378         byte a = 0;
5379         char c = ' ';
5380
5381         bool okay = TRUE;
5382
5383         FILE *fff;
5384
5385         char buf[1024];
5386
5387         int wid, hgt;
5388
5389         Term_get_size(&wid, &hgt);
5390
5391         /* Hack -- drop permissions */
5392         safe_setuid_drop();
5393
5394         /* Build the filename */
5395         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
5396
5397         /* Append to the file */
5398         fff = my_fopen(buf, "r");
5399
5400         /* Oops */
5401         if (!fff) {
5402 #ifdef JP
5403                 msg_format("%s ¤ò³«¤¯¤³¤È¤¬¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
5404 #else
5405                 msg_format("Failed to open %s.", buf);
5406 #endif
5407                 msg_print(NULL);
5408                 return;
5409         }
5410
5411
5412         /* Save the screen */
5413         screen_save();
5414
5415         /* Clear the screen */
5416         Term_clear();
5417
5418
5419         /* Load the screen */
5420         for (y = 0; okay && (y < hgt); y++)
5421         {
5422                 /* Get a line of data */
5423                 if (photo_fgets(fff, buf, 1024)) okay = FALSE;
5424
5425                 /* Show each row */
5426                 for (x = 0; x < wid - 1; x++)
5427                 {
5428                         /* Put the attr/char */
5429                         Term_draw(x, y, TERM_WHITE, buf[x]);
5430                 }
5431         }
5432
5433         /* Get the blank line */
5434         if (my_fgets(fff, buf, sizeof(buf))) okay = FALSE;
5435
5436
5437         /* Dump the screen */
5438         for (y = 0; okay && (y < hgt); y++)
5439         {
5440                 /* Get a line of data */
5441                 if (photo_fgets(fff, buf, 1024)) okay = FALSE;
5442
5443                 /* Dump each row */
5444                 for (x = 0; x < wid - 1; x++)
5445                 {
5446                         /* Get the attr/char */
5447                         (void)(Term_what(x, y, &a, &c));
5448
5449                         /* Look up the attr */
5450                         for (i = 0; i < 16; i++)
5451                         {
5452                                 /* Use attr matches */
5453                                 if (hack[i] == buf[x]) a = i;
5454                         }
5455
5456                         /* Put the attr/char */
5457                         Term_draw(x, y, a, c);
5458                 }
5459         }
5460
5461
5462         /* Get the blank line */
5463         if (my_fgets(fff, buf, sizeof(buf))) okay = FALSE;
5464
5465
5466         /* Close it */
5467         my_fclose(fff);
5468
5469         /* Hack -- grab permissions */
5470         safe_setuid_grab();
5471                 
5472
5473         /* Message */
5474 #ifdef JP
5475         prt("¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤µ¤ì¤¿²èÌÌ(µ­Ç°»£±Æ)¤ò¥í¡¼¥É¤·¤Þ¤·¤¿¡£", 0, 0);
5476 #else
5477         msg_print("Screen dump loaded.");
5478 #endif
5479
5480         flush();
5481         inkey();
5482
5483
5484         /* Restore the screen */
5485         screen_load();
5486 }
5487
5488
5489
5490
5491 cptr inven_res_label = 
5492 #ifdef JP
5493  "                               »ÀÅŲÐÎäÆǸ÷°ÇÇ˹ì¹ö°øÆÙÎô ÌÕÉÝÍðáãÆ©Ì¿´¶¾ÃÉüÉâ";
5494 #else
5495  "                               AcElFiCoPoLiDkShSoNtNxCaDi BlFeCfFaSeHlEpSdRgLv";
5496 #endif
5497
5498 /* XTRA HACK RESLIST */
5499 static void do_cmd_knowledge_inven_aux(FILE *fff, object_type *o_ptr, 
5500                                        int *j, byte tval, char *where)
5501 {
5502   char o_name[MAX_NLEN];
5503   u32b flgs[TR_FLAG_SIZE];
5504
5505   if (!o_ptr->k_idx)return;
5506   if (o_ptr->tval != tval)return;
5507
5508        /* 
5509         * HACK:Ring of Lordly protection and Dragon shield/helm
5510         * have random resistances.
5511         */
5512   if ( ((o_ptr->tval >= TV_BOW && o_ptr->tval<= TV_DRAG_ARMOR && o_ptr->name2)
5513        || (o_ptr->tval == TV_RING && o_ptr->sval == SV_RING_LORDLY) 
5514        || (o_ptr->tval == TV_SHIELD && o_ptr->sval == SV_DRAGON_SHIELD) 
5515        || (o_ptr->tval == TV_HELM && o_ptr->sval == SV_DRAGON_HELM) 
5516        || (o_ptr->tval == TV_GLOVES && o_ptr->sval == SV_SET_OF_DRAGON_GLOVES) 
5517        || (o_ptr->tval == TV_BOOTS && o_ptr->sval == SV_PAIR_OF_DRAGON_GREAVE) 
5518        || o_ptr->art_name || o_ptr->name1) && object_known_p(o_ptr))
5519     {
5520       int i = 0;
5521       object_desc(o_name, o_ptr, TRUE, 0);
5522
5523       while ( o_name[i] && i < 26 ){
5524 #ifdef JP
5525         if (iskanji(o_name[i])) i++;
5526 #endif
5527         i++;
5528       }
5529       if(i<28) while(i<28){o_name[i]=' ';i++;}
5530       o_name[i]=0;
5531       
5532       fprintf(fff,"%s %s", where, o_name);
5533
5534       if (!(o_ptr->ident & (IDENT_MENTAL))) 
5535         {
5536 #ifdef JP
5537           fprintf(fff, "-------ÉÔÌÀ--------------- -------ÉÔÌÀ---------\n");
5538 #else
5539           fprintf(fff, "-------unknown------------ -------unknown------\n");
5540 #endif
5541         }
5542       else {
5543         object_flags_known(o_ptr, flgs);
5544       
5545 #ifdef JP
5546         if (have_flag(flgs, TR_IM_ACID)) fprintf(fff,"¡ö");
5547         else if (have_flag(flgs, TR_RES_ACID)) fprintf(fff,"¡Ü");
5548         else fprintf(fff,"¡¦");
5549
5550         if (have_flag(flgs, TR_IM_ELEC)) fprintf(fff,"¡ö");
5551         else if (have_flag(flgs, TR_RES_ELEC)) fprintf(fff,"¡Ü");
5552         else fprintf(fff,"¡¦");
5553
5554         if (have_flag(flgs, TR_IM_FIRE)) fprintf(fff,"¡ö");
5555         else if (have_flag(flgs, TR_RES_FIRE)) fprintf(fff,"¡Ü");
5556         else fprintf(fff,"¡¦");
5557
5558         if (have_flag(flgs, TR_IM_COLD)) fprintf(fff,"¡ö");
5559         else if (have_flag(flgs, TR_RES_COLD)) fprintf(fff,"¡Ü");
5560         else fprintf(fff,"¡¦");
5561         
5562         if (have_flag(flgs, TR_RES_POIS)) fprintf(fff,"¡Ü");
5563         else fprintf(fff,"¡¦");
5564         
5565         if (have_flag(flgs, TR_RES_LITE)) fprintf(fff,"¡Ü");
5566         else fprintf(fff,"¡¦");
5567         
5568         if (have_flag(flgs, TR_RES_DARK)) fprintf(fff,"¡Ü");
5569         else fprintf(fff,"¡¦");
5570         
5571         if (have_flag(flgs, TR_RES_SHARDS)) fprintf(fff,"¡Ü");
5572         else fprintf(fff,"¡¦");
5573         
5574         if (have_flag(flgs, TR_RES_SOUND)) fprintf(fff,"¡Ü");
5575         else fprintf(fff,"¡¦");
5576         
5577         if (have_flag(flgs, TR_RES_NETHER)) fprintf(fff,"¡Ü");
5578         else fprintf(fff,"¡¦");
5579         
5580         if (have_flag(flgs, TR_RES_NEXUS)) fprintf(fff,"¡Ü");
5581         else fprintf(fff,"¡¦");
5582         
5583         if (have_flag(flgs, TR_RES_CHAOS)) fprintf(fff,"¡Ü");
5584         else fprintf(fff,"¡¦");
5585         
5586         if (have_flag(flgs, TR_RES_DISEN)) fprintf(fff,"¡Ü");
5587         else fprintf(fff,"¡¦");
5588         
5589         fprintf(fff," ");
5590         
5591         if (have_flag(flgs, TR_RES_BLIND)) fprintf(fff,"¡Ü");
5592         else fprintf(fff,"¡¦");
5593         
5594         if (have_flag(flgs, TR_RES_FEAR)) fprintf(fff,"¡Ü");
5595         else fprintf(fff,"¡¦");
5596         
5597         if (have_flag(flgs, TR_RES_CONF)) fprintf(fff,"¡Ü");
5598         else fprintf(fff,"¡¦");
5599         
5600         if (have_flag(flgs, TR_FREE_ACT)) fprintf(fff,"¡Ü");
5601         else fprintf(fff,"¡¦");
5602         
5603         if (have_flag(flgs, TR_SEE_INVIS)) fprintf(fff,"¡Ü");
5604         else fprintf(fff,"¡¦");
5605         
5606         if (have_flag(flgs, TR_HOLD_LIFE)) fprintf(fff,"¡Ü");
5607         else fprintf(fff,"¡¦");
5608
5609         if (have_flag(flgs, TR_TELEPATHY)) fprintf(fff,"¡Ü");
5610         else fprintf(fff,"¡¦");
5611
5612         if (have_flag(flgs, TR_SLOW_DIGEST)) fprintf(fff,"¡Ü");
5613         else fprintf(fff,"¡¦");
5614
5615
5616         if (have_flag(flgs, TR_REGEN)) fprintf(fff,"¡Ü");
5617         else fprintf(fff,"¡¦");
5618
5619         if (have_flag(flgs, TR_FEATHER)) fprintf(fff,"¡Ü");
5620         else fprintf(fff,"¡¦");
5621 #else
5622         if (have_flag(flgs, TR_IM_ACID)) fprintf(fff,"* ");
5623         else if (have_flag(flgs, TR_RES_ACID)) fprintf(fff,"+ ");
5624         else fprintf(fff,". ");
5625
5626         if (have_flag(flgs, TR_IM_ELEC)) fprintf(fff,"* ");
5627         else if (have_flag(flgs, TR_RES_ELEC)) fprintf(fff,"+ ");
5628         else fprintf(fff,". ");
5629
5630         if (have_flag(flgs, TR_IM_FIRE)) fprintf(fff,"* ");
5631         else if (have_flag(flgs, TR_RES_FIRE)) fprintf(fff,"+ ");
5632         else fprintf(fff,". ");
5633
5634         if (have_flag(flgs, TR_IM_COLD)) fprintf(fff,"* ");
5635         else if (have_flag(flgs, TR_RES_COLD)) fprintf(fff,"+ ");
5636         else fprintf(fff,". ");
5637         
5638         if (have_flag(flgs, TR_RES_POIS)) fprintf(fff,"+ ");
5639         else fprintf(fff,". ");
5640         
5641         if (have_flag(flgs, TR_RES_LITE)) fprintf(fff,"+ ");
5642         else fprintf(fff,". ");
5643         
5644         if (have_flag(flgs, TR_RES_DARK)) fprintf(fff,"+ ");
5645         else fprintf(fff,". ");
5646         
5647         if (have_flag(flgs, TR_RES_SHARDS)) fprintf(fff,"+ ");
5648         else fprintf(fff,". ");
5649         
5650         if (have_flag(flgs, TR_RES_SOUND)) fprintf(fff,"+ ");
5651         else fprintf(fff,". ");
5652         
5653         if (have_flag(flgs, TR_RES_NETHER)) fprintf(fff,"+ ");
5654         else fprintf(fff,". ");
5655         
5656         if (have_flag(flgs, TR_RES_NEXUS)) fprintf(fff,"+ ");
5657         else fprintf(fff,". ");
5658         
5659         if (have_flag(flgs, TR_RES_CHAOS)) fprintf(fff,"+ ");
5660         else fprintf(fff,". ");
5661         
5662         if (have_flag(flgs, TR_RES_DISEN)) fprintf(fff,"+ ");
5663         else fprintf(fff,". ");
5664         
5665         fprintf(fff," ");
5666         
5667         if (have_flag(flgs, TR_RES_BLIND)) fprintf(fff,"+ ");
5668         else fprintf(fff,". ");
5669         
5670         if (have_flag(flgs, TR_RES_FEAR)) fprintf(fff,"+ ");
5671         else fprintf(fff,". ");
5672         
5673         if (have_flag(flgs, TR_RES_CONF)) fprintf(fff,"+ ");
5674         else fprintf(fff,". ");
5675         
5676         if (have_flag(flgs, TR_FREE_ACT)) fprintf(fff,"+ ");
5677         else fprintf(fff,". ");
5678         
5679         if (have_flag(flgs, TR_SEE_INVIS)) fprintf(fff,"+ ");
5680         else fprintf(fff,". ");
5681         
5682         if (have_flag(flgs, TR_HOLD_LIFE)) fprintf(fff,"+ ");
5683         else fprintf(fff,". ");
5684
5685         if (have_flag(flgs, TR_TELEPATHY)) fprintf(fff,"+ ");
5686         else fprintf(fff,". ");
5687
5688         if (have_flag(flgs, TR_SLOW_DIGEST)) fprintf(fff,"+ ");
5689         else fprintf(fff,". ");
5690
5691
5692         if (have_flag(flgs, TR_REGEN)) fprintf(fff,"+ ");
5693         else fprintf(fff,". ");
5694
5695         if (have_flag(flgs, TR_FEATHER)) fprintf(fff,"+ ");
5696         else fprintf(fff,". ");
5697 #endif  
5698         fprintf(fff,"\n");
5699       }
5700       (*j)++;
5701       if(*j==9)
5702         { 
5703           *j=0;
5704           fprintf(fff,"%s\n", inven_res_label);
5705         }
5706     }
5707 }
5708
5709 /*
5710  * Display *ID* ed weapons/armors's resistances
5711  */
5712 static void do_cmd_knowledge_inven(void)
5713 {
5714
5715         FILE *fff;
5716
5717         char file_name[1024];
5718  
5719         store_type  *st_ptr;
5720         object_type *o_ptr;
5721
5722         byte tval;
5723         int i=0;
5724         int j=0;
5725
5726         char  where[32];
5727
5728         /* Open a new file */
5729         fff = my_fopen_temp(file_name, 1024);
5730         if (!fff) {
5731 #ifdef JP
5732             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
5733 #else
5734             msg_format("Failed to create temporally file %s.", file_name);
5735 #endif
5736             msg_print(NULL);
5737             return;
5738         }
5739         fprintf(fff,"%s\n",inven_res_label);
5740
5741         for (tval=TV_BOW; tval <= TV_RING; tval++){
5742
5743           if (j!=0) {
5744               for (;j<9;j++) fprintf(fff, "\n");
5745               j=0;
5746               fprintf(fff,"%s\n",inven_res_label);              
5747           }
5748           
5749 #ifdef JP
5750           strcpy(where, "Áõ");
5751 #else
5752           strcpy(where, "E ");
5753 #endif
5754           for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
5755             {
5756               o_ptr = &inventory[i];
5757               do_cmd_knowledge_inven_aux(fff, o_ptr, &j, tval, where);
5758             }
5759           
5760 #ifdef JP
5761           strcpy(where, "»ý");
5762 #else
5763           strcpy(where, "I ");
5764 #endif
5765           for (i = 0; i < INVEN_PACK; i++)
5766             {
5767               o_ptr = &inventory[i];
5768               do_cmd_knowledge_inven_aux(fff, o_ptr, &j, tval, where);
5769             }
5770           
5771           
5772           /* Print all homes in the different towns */
5773           st_ptr = &town[1].store[STORE_HOME];
5774 #ifdef JP
5775           strcpy(where, "²È");
5776 #else
5777           strcpy(where, "H ");
5778 #endif
5779               
5780           /* Dump all available items */
5781           for (i = 0; i < st_ptr->stock_num; i++)
5782             {
5783               o_ptr = &st_ptr->stock[i];
5784               do_cmd_knowledge_inven_aux(fff, o_ptr, &j, tval, where);
5785             }
5786         }
5787           
5788         /* Close the file */
5789         my_fclose(fff);
5790
5791         /* Display the file contents */
5792 #ifdef JP
5793         show_file(TRUE, file_name, "*´ÕÄê*ºÑ¤ßÉð´ï/Ëɶñ¤ÎÂÑÀ­¥ê¥¹¥È", 0, 0);
5794 #else
5795         show_file(TRUE, file_name, "Resistances of *identified* equipment", 0, 0);
5796 #endif
5797
5798         /* Remove the file */
5799         fd_kill(file_name);
5800 }
5801
5802
5803 void do_cmd_save_screen_html_aux(char *filename, int message)
5804 {
5805         int y, x, i;
5806
5807         byte a = 0, old_a = 0;
5808         char c = ' ';
5809
5810         FILE *fff, *tmpfff;
5811         char buf[2048];
5812
5813         int yomikomu = 0;
5814         cptr tags[4] = {
5815                 "HEADER_START:",
5816                 "HEADER_END:",
5817                 "FOOTER_START:",
5818                 "FOOTER_END:",
5819         };
5820
5821         cptr html_head[] = {
5822                 "<html>\n<body text=\"#ffffff\" bgcolor=\"#000000\">\n",
5823                 "<pre>",
5824                 0,
5825         };
5826         cptr html_foot[] = {
5827                 "</pre>\n",
5828                 "</body>\n</html>\n",
5829                 0,
5830         };
5831
5832         int wid, hgt;
5833
5834         Term_get_size(&wid, &hgt);
5835
5836         /* File type is "TEXT" */
5837         FILE_TYPE(FILE_TYPE_TEXT);
5838
5839         /* Append to the file */
5840         fff = my_fopen(filename, "w");
5841
5842         /* Oops */
5843         if (!fff) {
5844                 if (message) {
5845 #ifdef JP
5846                     msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", filename);
5847 #else
5848                     msg_format("Failed to open file %s.", filename);
5849 #endif
5850                     msg_print(NULL);
5851                 }
5852                 
5853                 return;
5854         }
5855
5856         /* Save the screen */
5857         if (message)
5858                 screen_save();
5859
5860         /* Build the filename */
5861         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "htmldump.prf");
5862         tmpfff = my_fopen(buf, "r");
5863         if (!tmpfff) {
5864                 for (i = 0; html_head[i]; i++)
5865                         fprintf(fff, html_head[i]);
5866         }
5867         else {
5868                 yomikomu = 0;
5869                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
5870                         if (!yomikomu) {
5871                                 if (strncmp(buf, tags[0], strlen(tags[0])) == 0)
5872                                         yomikomu = 1;
5873                         }
5874                         else {
5875                                 if (strncmp(buf, tags[1], strlen(tags[1])) == 0)
5876                                         break;
5877                                 fprintf(fff, "%s\n", buf);
5878                         }
5879                 }
5880         }
5881
5882         /* Dump the screen */
5883         for (y = 0; y < hgt; y++)
5884         {
5885                 /* Start the row */
5886                 if (y != 0)
5887                         fprintf(fff, "\n");
5888
5889                 /* Dump each row */
5890                 for (x = 0; x < wid - 1; x++)
5891                 {
5892                         int rv, gv, bv;
5893                         cptr cc = NULL;
5894                         /* Get the attr/char */
5895                         (void)(Term_what(x, y, &a, &c));
5896
5897                         switch (c)
5898                         {
5899                         case '&': cc = "&amp;"; break;
5900                         case '<': cc = "&lt;"; break;
5901                         case '>': cc = "&gt;"; break;
5902 #ifdef WINDOWS
5903                         case 0x1f: c = '.'; break;
5904                         case 0x7f: c = (a == 0x09) ? '%' : '#'; break;
5905 #endif
5906                         }
5907
5908                         a = a & 0x0F;
5909                         if ((y == 0 && x == 0) || a != old_a) {
5910                                 rv = angband_color_table[a][1];
5911                                 gv = angband_color_table[a][2];
5912                                 bv = angband_color_table[a][3];
5913                                 fprintf(fff, "%s<font color=\"#%02x%02x%02x\">", 
5914                                         ((y == 0 && x == 0) ? "" : "</font>"), rv, gv, bv);
5915                                 old_a = a;
5916                         }
5917                         if (cc)
5918                                 fprintf(fff, "%s", cc);
5919                         else
5920                                 fprintf(fff, "%c", c);
5921                 }
5922         }
5923         fprintf(fff, "</font>");
5924
5925         if (!tmpfff) {
5926                 for (i = 0; html_foot[i]; i++)
5927                         fprintf(fff, html_foot[i]);
5928         }
5929         else {
5930                 rewind(tmpfff);
5931                 yomikomu = 0;
5932                 while (!my_fgets(tmpfff, buf, sizeof(buf))) {
5933                         if (!yomikomu) {
5934                                 if (strncmp(buf, tags[2], strlen(tags[2])) == 0)
5935                                         yomikomu = 1;
5936                         }
5937                         else {
5938                                 if (strncmp(buf, tags[3], strlen(tags[3])) == 0)
5939                                         break;
5940                                 fprintf(fff, "%s\n", buf);
5941                         }
5942                 }
5943                 my_fclose(tmpfff);
5944         }
5945
5946         /* Skip a line */
5947         fprintf(fff, "\n");
5948
5949         /* Close it */
5950         my_fclose(fff);
5951
5952         /* Message */
5953         if (message) {
5954 #ifdef JP
5955         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
5956 #else
5957                 msg_print("Screen dump saved.");
5958 #endif
5959                 msg_print(NULL);
5960         }
5961
5962         /* Restore the screen */
5963         if (message)
5964                 screen_load();
5965 }
5966
5967 /*
5968  * Hack -- save a screen dump to a file
5969  */
5970 static void do_cmd_save_screen_html(void)
5971 {
5972         char buf[1024], tmp[256] = "screen.html";
5973
5974 #ifdef JP
5975         if (!get_string("¥Õ¥¡¥¤¥ë̾: ", tmp, 80))
5976 #else
5977         if (!get_string("File name: ", tmp, 80))
5978 #endif
5979                 return;
5980
5981         /* Build the filename */
5982         path_build(buf, sizeof(buf), ANGBAND_DIR_USER, tmp);
5983
5984         msg_print(NULL);
5985
5986         /* Hack -- drop permissions */
5987         safe_setuid_drop();
5988
5989         do_cmd_save_screen_html_aux(buf, 1);
5990
5991         /* Hack -- grab permissions */
5992         safe_setuid_grab();
5993 }
5994
5995
5996 /*
5997  * Redefinable "save_screen" action
5998  */
5999 void (*screendump_aux)(void) = NULL;
6000
6001
6002 /*
6003  * Hack -- save a screen dump to a file
6004  */
6005 void do_cmd_save_screen(void)
6006 {
6007         bool old_use_graphics = use_graphics;
6008         bool html_dump = FALSE;
6009
6010         int wid, hgt;
6011
6012 #ifdef JP
6013         prt("µ­Ç°»£±Æ¤·¤Þ¤¹¤«¡© [(y)es/(h)tml/(n)o] ", 0, 0);
6014 #else
6015         prt("Save screen dump? [(y)es/(h)tml/(n)o] ", 0, 0);
6016 #endif
6017         while(TRUE)
6018         {
6019                 char c = inkey();
6020                 if (c == 'Y' || c == 'y')
6021                         break;
6022                 else if (c == 'H' || c == 'h')
6023                 {
6024                         html_dump = TRUE;
6025                         break;
6026                 }
6027                 else
6028                 {
6029                         prt("", 0, 0);
6030                         return;
6031                 }
6032         }
6033
6034         Term_get_size(&wid, &hgt);
6035
6036         if (old_use_graphics)
6037         {
6038                 use_graphics = FALSE;
6039                 reset_visuals();
6040
6041                 /* Redraw everything */
6042                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6043
6044                 /* Hack -- update */
6045                 handle_stuff();
6046         }
6047
6048         if (html_dump)
6049         {
6050                 do_cmd_save_screen_html();
6051                 do_cmd_redraw();
6052         }
6053
6054         /* Do we use a special screendump function ? */
6055         else if (screendump_aux)
6056         {
6057                 /* Dump the screen to a graphics file */
6058                 (*screendump_aux)();
6059         }
6060         else /* Dump the screen as text */
6061         {
6062                 int y, x;
6063
6064                 byte a = 0;
6065                 char c = ' ';
6066
6067                 FILE *fff;
6068
6069                 char buf[1024];
6070
6071
6072                 /* Hack -- drop permissions */
6073                 safe_setuid_drop();
6074
6075                 /* Build the filename */
6076                 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, "dump.txt");
6077
6078                 /* File type is "TEXT" */
6079                 FILE_TYPE(FILE_TYPE_TEXT);
6080
6081                 /* Append to the file */
6082                 fff = my_fopen(buf, "w");
6083
6084                 /* Oops */
6085                 if (!fff)
6086                 {
6087                         /* Hack -- grab permissions */
6088                         safe_setuid_grab();
6089 #ifdef JP
6090                         msg_format("¥Õ¥¡¥¤¥ë %s ¤ò³«¤±¤Þ¤»¤ó¤Ç¤·¤¿¡£", buf);
6091 #else
6092                         msg_format("Failed to open file %s.", buf);
6093 #endif
6094                         msg_print(NULL);
6095                         return;
6096                 }
6097
6098
6099                 /* Save the screen */
6100                 screen_save();
6101
6102
6103                 /* Dump the screen */
6104                 for (y = 0; y < hgt; y++)
6105                 {
6106                         /* Dump each row */
6107                         for (x = 0; x < wid - 1; x++)
6108                         {
6109                                 /* Get the attr/char */
6110                                 (void)(Term_what(x, y, &a, &c));
6111
6112                                 /* Dump it */
6113                                 buf[x] = c;
6114                         }
6115
6116                         /* Terminate */
6117                         buf[x] = '\0';
6118
6119                         /* End the row */
6120                         fprintf(fff, "%s\n", buf);
6121                 }
6122
6123                 /* Skip a line */
6124                 fprintf(fff, "\n");
6125
6126
6127                 /* Dump the screen */
6128                 for (y = 0; y < hgt; y++)
6129                 {
6130                         /* Dump each row */
6131                         for (x = 0; x < wid - 1; x++)
6132                         {
6133                                 /* Get the attr/char */
6134                                 (void)(Term_what(x, y, &a, &c));
6135
6136                                 /* Dump it */
6137                                 buf[x] = hack[a&0x0F];
6138                         }
6139
6140                         /* Terminate */
6141                         buf[x] = '\0';
6142
6143                         /* End the row */
6144                         fprintf(fff, "%s\n", buf);
6145                 }
6146
6147                 /* Skip a line */
6148                 fprintf(fff, "\n");
6149
6150
6151                 /* Close it */
6152                 my_fclose(fff);
6153
6154                 /* Hack -- grab permissions */
6155                 safe_setuid_grab();
6156
6157                 /* Message */
6158 #ifdef JP
6159         msg_print("²èÌÌ(µ­Ç°»£±Æ)¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤­½Ð¤·¤Þ¤·¤¿¡£");
6160 #else
6161                 msg_print("Screen dump saved.");
6162 #endif
6163
6164                 msg_print(NULL);
6165
6166
6167                 /* Restore the screen */
6168                 screen_load();
6169         }
6170
6171         if (old_use_graphics)
6172         {
6173                 use_graphics = TRUE;
6174                 reset_visuals();
6175
6176                 /* Redraw everything */
6177                 p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
6178
6179                 /* Hack -- update */
6180                 handle_stuff();
6181         }
6182 }
6183
6184
6185 /*
6186  * Sorting hook -- Comp function -- see below
6187  *
6188  * We use "u" to point to array of monster indexes,
6189  * and "v" to select the type of sorting to perform on "u".
6190  */
6191 static bool ang_sort_art_comp(vptr u, vptr v, int a, int b)
6192 {
6193         u16b *who = (u16b*)(u);
6194
6195         u16b *why = (u16b*)(v);
6196
6197         int w1 = who[a];
6198         int w2 = who[b];
6199
6200         int z1, z2;
6201
6202         /* Sort by total kills */
6203         if (*why >= 3)
6204         {
6205                 /* Extract total kills */
6206                 z1 = a_info[w1].tval;
6207                 z2 = a_info[w2].tval;
6208
6209                 /* Compare total kills */
6210                 if (z1 < z2) return (TRUE);
6211                 if (z1 > z2) return (FALSE);
6212         }
6213
6214
6215         /* Sort by monster level */
6216         if (*why >= 2)
6217         {
6218                 /* Extract levels */
6219                 z1 = a_info[w1].sval;
6220                 z2 = a_info[w2].sval;
6221
6222                 /* Compare levels */
6223                 if (z1 < z2) return (TRUE);
6224                 if (z1 > z2) return (FALSE);
6225         }
6226
6227
6228         /* Sort by monster experience */
6229         if (*why >= 1)
6230         {
6231                 /* Extract experience */
6232                 z1 = a_info[w1].level;
6233                 z2 = a_info[w2].level;
6234
6235                 /* Compare experience */
6236                 if (z1 < z2) return (TRUE);
6237                 if (z1 > z2) return (FALSE);
6238         }
6239
6240
6241         /* Compare indexes */
6242         return (w1 <= w2);
6243 }
6244
6245
6246 /*
6247  * Sorting hook -- Swap function -- see below
6248  *
6249  * We use "u" to point to array of monster indexes,
6250  * and "v" to select the type of sorting to perform.
6251  */
6252 static void ang_sort_art_swap(vptr u, vptr v, int a, int b)
6253 {
6254         u16b *who = (u16b*)(u);
6255
6256         u16b holder;
6257
6258         /* Unused */
6259         (void)v;
6260
6261         /* Swap */
6262         holder = who[a];
6263         who[a] = who[b];
6264         who[b] = holder;
6265 }
6266
6267
6268 /*
6269  * Check the status of "artifacts"
6270  */
6271 static void do_cmd_knowledge_artifacts(void)
6272 {
6273         int i, k, z, x, y, n = 0;
6274         u16b why = 3;
6275         s16b *who;
6276
6277         FILE *fff;
6278
6279         char file_name[1024];
6280
6281         char base_name[MAX_NLEN];
6282
6283         bool *okay;
6284
6285         /* Open a new file */
6286         fff = my_fopen_temp(file_name, 1024);
6287
6288         if (!fff) {
6289 #ifdef JP
6290             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6291 #else
6292             msg_format("Failed to create temporary file %s.", file_name);
6293 #endif
6294             msg_print(NULL);
6295             return;
6296         }
6297
6298         /* Allocate the "who" array */
6299         C_MAKE(who, max_a_idx, s16b);
6300
6301         /* Allocate the "okay" array */
6302         C_MAKE(okay, max_a_idx, bool);
6303
6304         /* Scan the artifacts */
6305         for (k = 0; k < max_a_idx; k++)
6306         {
6307                 artifact_type *a_ptr = &a_info[k];
6308
6309                 /* Default */
6310                 okay[k] = FALSE;
6311
6312                 /* Skip "empty" artifacts */
6313                 if (!a_ptr->name) continue;
6314
6315                 /* Skip "uncreated" artifacts */
6316                 if (!a_ptr->cur_num) continue;
6317
6318                 /* Assume okay */
6319                 okay[k] = TRUE;
6320         }
6321
6322         /* Check the dungeon */
6323         for (y = 0; y < cur_hgt; y++)
6324         {
6325                 for (x = 0; x < cur_wid; x++)
6326                 {
6327                         cave_type *c_ptr = &cave[y][x];
6328
6329                         s16b this_o_idx, next_o_idx = 0;
6330
6331                         /* Scan all objects in the grid */
6332                         for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
6333                         {
6334                                 object_type *o_ptr;
6335
6336                                 /* Acquire object */
6337                                 o_ptr = &o_list[this_o_idx];
6338
6339                                 /* Acquire next object */
6340                                 next_o_idx = o_ptr->next_o_idx;
6341
6342                                 /* Ignore non-artifacts */
6343                                 if (!artifact_p(o_ptr)) continue;
6344
6345                                 /* Ignore known items */
6346                                 if (object_known_p(o_ptr)) continue;
6347
6348                                 /* Note the artifact */
6349                                 okay[o_ptr->name1] = FALSE;
6350                         }
6351                 }
6352         }
6353
6354         /* Check the inventory and equipment */
6355         for (i = 0; i < INVEN_TOTAL; i++)
6356         {
6357                 object_type *o_ptr = &inventory[i];
6358
6359                 /* Ignore non-objects */
6360                 if (!o_ptr->k_idx) continue;
6361
6362                 /* Ignore non-artifacts */
6363                 if (!artifact_p(o_ptr)) continue;
6364
6365                 /* Ignore known items */
6366                 if (object_known_p(o_ptr)) continue;
6367
6368                 /* Note the artifact */
6369                 okay[o_ptr->name1] = FALSE;
6370         }
6371
6372         for (k = 0; k < max_a_idx; k++)
6373         {
6374                 if (okay[k]) who[n++] = k;
6375         }
6376
6377         /* Select the sort method */
6378         ang_sort_comp = ang_sort_art_comp;
6379         ang_sort_swap = ang_sort_art_swap;
6380
6381         /* Sort the array by dungeon depth of monsters */
6382         ang_sort(who, &why, n);
6383
6384         /* Scan the artifacts */
6385         for (k = 0; k < n; k++)
6386         {
6387                 artifact_type *a_ptr = &a_info[who[k]];
6388
6389                 /* Paranoia */
6390 #ifdef JP
6391                 strcpy(base_name, "̤ÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à");
6392 #else
6393                 strcpy(base_name, "Unknown Artifact");
6394 #endif
6395
6396
6397                 /* Obtain the base object type */
6398                 z = lookup_kind(a_ptr->tval, a_ptr->sval);
6399
6400                 /* Real object */
6401                 if (z)
6402                 {
6403                         object_type forge;
6404                         object_type *q_ptr;
6405
6406                         /* Get local object */
6407                         q_ptr = &forge;
6408
6409                         /* Create fake object */
6410                         object_prep(q_ptr, z);
6411
6412                         /* Make it an artifact */
6413                         q_ptr->name1 = (byte)who[k];
6414
6415                         /* Describe the artifact */
6416                         object_desc_store(base_name, q_ptr, FALSE, 0);
6417                 }
6418
6419                 /* Hack -- Build the artifact name */
6420 #ifdef JP
6421                 fprintf(fff, "     %s\n", base_name);
6422 #else
6423                 fprintf(fff, "     The %s\n", base_name);
6424 #endif
6425
6426         }
6427
6428         /* Free the "who" array */
6429         C_KILL(who, max_a_idx, s16b);
6430
6431         /* Free the "okay" array */
6432         C_KILL(okay, max_a_idx, bool);
6433
6434         /* Close the file */
6435         my_fclose(fff);
6436
6437         /* Display the file contents */
6438 #ifdef JP
6439         show_file(TRUE, file_name, "´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à", 0, 0);
6440 #else
6441         show_file(TRUE, file_name, "Artifacts Seen", 0, 0);
6442 #endif
6443
6444
6445         /* Remove the file */
6446         fd_kill(file_name);
6447 }
6448
6449
6450 /*
6451  * Display known uniques
6452  */
6453 static void do_cmd_knowledge_uniques(void)
6454 {
6455         int i, k, n = 0;
6456         u16b why = 2;
6457         s16b *who;
6458
6459         FILE *fff;
6460
6461         char file_name[1024];
6462
6463         /* Open a new file */
6464         fff = my_fopen_temp(file_name, 1024);
6465
6466         if (!fff) {
6467 #ifdef JP
6468             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6469 #else
6470             msg_format("Failed to create temporary file %s.", file_name);
6471 #endif
6472             msg_print(NULL);
6473             return;
6474         }
6475
6476         /* Allocate the "who" array */
6477         C_MAKE(who, max_r_idx, s16b);
6478
6479         /* Scan the monsters */
6480         for (i = 1; i < max_r_idx; i++)
6481         {
6482                 monster_race *r_ptr = &r_info[i];
6483
6484                 /* Use that monster */
6485                 if (r_ptr->name) who[n++] = i;
6486         }
6487
6488         /* Select the sort method */
6489         ang_sort_comp = ang_sort_comp_hook;
6490         ang_sort_swap = ang_sort_swap_hook;
6491
6492         /* Sort the array by dungeon depth of monsters */
6493         ang_sort(who, &why, n);
6494
6495         /* Scan the monster races */
6496         for (k = 0; k < n; k++)
6497         {
6498                 monster_race *r_ptr = &r_info[who[k]];
6499
6500                 /* Only print Uniques */
6501                 if (r_ptr->flags1 & (RF1_UNIQUE))
6502                 {
6503                         bool dead = (r_ptr->max_num == 0);
6504
6505                         if (dead) continue;
6506
6507                         /* Only display "known" uniques */
6508                         if (dead || cheat_know || r_ptr->r_sights)
6509                         {
6510                                 /* Print a message */
6511 #ifdef JP
6512                                 fprintf(fff, "     %s¤Ï¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¡£\n",
6513                                         (r_name + r_ptr->name));
6514 #else
6515                                 fprintf(fff, "     %s is alive\n",
6516                                         (r_name + r_ptr->name));
6517 #endif
6518
6519                         }
6520                 }
6521         }
6522
6523         /* Free the "who" array */
6524         C_KILL(who, max_r_idx, s16b);
6525
6526         /* Close the file */
6527         my_fclose(fff);
6528
6529         /* Display the file contents */
6530 #ifdef JP
6531         show_file(TRUE, file_name, "¤Þ¤ÀÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼", 0, 0);
6532 #else
6533         show_file(TRUE, file_name, "Alive Uniques", 0, 0);
6534 #endif
6535
6536
6537         /* Remove the file */
6538         fd_kill(file_name);
6539 }
6540
6541
6542 /*
6543  * Display weapon-exp
6544  */
6545 static void do_cmd_knowledge_weapon_exp(void)
6546 {
6547         int i,j, num, shougou;
6548
6549         FILE *fff;
6550
6551         char file_name[1024];
6552         char tmp[30];
6553
6554         /* Open a new file */
6555         fff = my_fopen_temp(file_name, 1024);
6556         if (!fff) {
6557 #ifdef JP
6558             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6559 #else
6560             msg_format("Failed to create temporary file %s.", file_name);
6561 #endif
6562             msg_print(NULL);
6563             return;
6564         }
6565
6566         for(i = 0; i < 5; i++)
6567         {
6568                 for (num = 0; num < 64; num++)
6569                 {
6570                         for (j = 0; j < max_k_idx; j++)
6571                         {
6572                                 object_kind *k_ptr = &k_info[j];
6573
6574                                 if ((k_ptr->tval == TV_SWORD-i) && (k_ptr->sval == num))
6575                                 {
6576                                         if((k_ptr->tval == TV_BOW) && (k_ptr->sval == SV_CRIMSON)) continue;
6577
6578                                         if(p_ptr->weapon_exp[4-i][num]<4000) shougou=0;
6579                                         else if(p_ptr->weapon_exp[4-i][num]<6000) shougou=1;
6580                                         else if(p_ptr->weapon_exp[4-i][num]<7000) shougou=2;
6581                                         else if(p_ptr->weapon_exp[4-i][num]<8000) shougou=3;
6582                                         else shougou=4;
6583                                         strip_name(tmp, j);
6584                                         fprintf(fff,"%-25s ",tmp);
6585                                         if (p_ptr->weapon_exp[4-i][num] >= s_info[p_ptr->pclass].w_max[4-i][num]) fprintf(fff,"!");
6586                                         else fprintf(fff," ");
6587                                         fprintf(fff,"%s",shougou_moji[shougou]);
6588                                         if (cheat_xtra) fprintf(fff," %d",p_ptr->weapon_exp[4-i][num]);
6589                                         fprintf(fff,"\n");
6590                                         break;
6591                                 }
6592                         }
6593                 }
6594         }
6595
6596         /* Close the file */
6597         my_fclose(fff);
6598
6599         /* Display the file contents */
6600 #ifdef JP
6601         show_file(TRUE, file_name, "Éð´ï¤Î·Ð¸³ÃÍ", 0, 0);
6602 #else
6603         show_file(TRUE, file_name, "Weapon Proficiency", 0, 0);
6604 #endif
6605
6606
6607         /* Remove the file */
6608         fd_kill(file_name);
6609 }
6610
6611
6612 /*
6613  * Display spell-exp
6614  */
6615 static void do_cmd_knowledge_spell_exp(void)
6616 {
6617         int i=0, shougou;
6618
6619         FILE *fff;
6620         magic_type *s_ptr;
6621
6622         char file_name[1024];
6623
6624         /* Open a new file */
6625         fff = my_fopen_temp(file_name, 1024);
6626         if (!fff) {
6627 #ifdef JP
6628             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6629 #else
6630             msg_format("Failed to create temporary file %s.", file_name);
6631 #endif
6632             msg_print(NULL);
6633             return;
6634         }
6635
6636         if(p_ptr->realm1 != REALM_NONE)
6637         {
6638 #ifdef JP
6639                 fprintf(fff,"%s¤ÎËâË¡½ñ\n",realm_names[p_ptr->realm1]);
6640 #else
6641                 fprintf(fff,"%s Spellbook\n",realm_names[p_ptr->realm1]);
6642 #endif
6643                 for (i = 0; i < 32; i++)
6644                 {
6645                         if (!is_magic(p_ptr->realm1))
6646                         {
6647                                 s_ptr = &technic_info[p_ptr->realm1 - MIN_TECHNIC][i];
6648                         }
6649                         else
6650                         {
6651                                 s_ptr = &mp_ptr->info[p_ptr->realm1 - 1][i];
6652                         }
6653                         if(s_ptr->slevel == 99) continue;
6654                         if(p_ptr->spell_exp[i]<900) shougou=0;
6655                         else if(p_ptr->spell_exp[i]<1200) shougou=1;
6656                         else if(p_ptr->spell_exp[i]<1400) shougou=2;
6657                         else if(p_ptr->spell_exp[i]<1600) shougou=3;
6658                         else shougou=4;
6659                         fprintf(fff,"%-25s ",spell_names[technic2magic(p_ptr->realm1)-1][i]);
6660                         if (p_ptr->realm1 == REALM_HISSATSU)
6661                                 fprintf(fff,"[--]");
6662                         else
6663                         {
6664                                 if (shougou == 4) fprintf(fff,"!");
6665                                 else fprintf(fff," ");
6666                                 fprintf(fff,"%s",shougou_moji[shougou]);
6667                         }
6668                         if (cheat_xtra) fprintf(fff," %d",p_ptr->spell_exp[i]);
6669                         fprintf(fff,"\n");
6670                 }
6671         }
6672
6673         if(p_ptr->realm2 != REALM_NONE)
6674         {
6675                 fprintf(fff,"\n%s Spellbook\n",realm_names[p_ptr->realm2]);
6676                 for (i = 0; i < 32; i++)
6677                 {
6678                         if (!is_magic(p_ptr->realm1))
6679                         {
6680                                 s_ptr = &technic_info[p_ptr->realm2 - MIN_TECHNIC][i];
6681                         }
6682                         else
6683                         {
6684                                 s_ptr = &mp_ptr->info[p_ptr->realm2 - 1][i];
6685                         }
6686                         if(s_ptr->slevel == 99) continue;
6687
6688                         if(p_ptr->spell_exp[i+32]<900) shougou=0;
6689                         else if(p_ptr->spell_exp[i+32]<1200) shougou=1;
6690                         else if(p_ptr->spell_exp[i+32]<1400) shougou=2;
6691                         else shougou=3;
6692                         fprintf(fff,"%-25s ",spell_names[technic2magic(p_ptr->realm2)-1][i]);
6693                         if (shougou == 3) fprintf(fff,"!");
6694                         else fprintf(fff," ");
6695                         fprintf(fff,"%s",shougou_moji[shougou]);
6696                         if (cheat_xtra) fprintf(fff," %d",p_ptr->spell_exp[i+32]);
6697                         fprintf(fff,"\n");
6698                 }
6699         }
6700
6701         /* Close the file */
6702         my_fclose(fff);
6703
6704         /* Display the file contents */
6705 #ifdef JP
6706         show_file(TRUE, file_name, "ËâË¡¤Î·Ð¸³ÃÍ", 0, 0);
6707 #else
6708         show_file(TRUE, file_name, "Spell Proficiency", 0, 0);
6709 #endif
6710
6711
6712         /* Remove the file */
6713         fd_kill(file_name);
6714 }
6715
6716
6717 /*
6718  * Display skill-exp
6719  */
6720 static void do_cmd_knowledge_skill_exp(void)
6721 {
6722         int i=0, shougou;
6723
6724         FILE *fff;
6725
6726         char file_name[1024];
6727 #ifdef JP
6728         char skill_name[3][17]={"¥Þ¡¼¥·¥ã¥ë¥¢¡¼¥Ä", "ÆóÅáή          ", "¾èÇÏ            "};
6729 #else
6730         char skill_name[3][20]={"Martial Arts    ", "Dual Wielding   ", "Riding          "};
6731 #endif
6732
6733         /* Open a new file */
6734         fff = my_fopen_temp(file_name, 1024);
6735         if (!fff) {
6736 #ifdef JP
6737             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6738 #else
6739             msg_format("Failed to create temporary file %s.", file_name);
6740 #endif
6741             msg_print(NULL);
6742             return;
6743         }
6744
6745         for (i = 0; i < 3; i++)
6746         {
6747                 if(i == GINOU_RIDING)
6748                 {
6749                         if(p_ptr->skill_exp[i]<500) shougou=0;
6750                         else if(p_ptr->skill_exp[i]<2000) shougou=1;
6751                         else if(p_ptr->skill_exp[i]<5000) shougou=2;
6752                         else if(p_ptr->skill_exp[i]<8000) shougou=3;
6753                         else shougou=4;
6754                 }
6755                 else
6756                 {
6757                         if(p_ptr->skill_exp[i]<4000) shougou=0;
6758                         else if(p_ptr->skill_exp[i]<6000) shougou=1;
6759                         else if(p_ptr->skill_exp[i]<7000) shougou=2;
6760                         else if(p_ptr->skill_exp[i]<8000) shougou=3;
6761                         else shougou=4;
6762                 }
6763                 fprintf(fff,"%-20s ",skill_name[i]);
6764                 if (p_ptr->skill_exp[i] == s_info[p_ptr->pclass].s_max[i]) fprintf(fff,"!");
6765                 else fprintf(fff," ");
6766                 fprintf(fff,"%s",shougou_moji[shougou]);
6767                 if (cheat_xtra) fprintf(fff," %d",p_ptr->skill_exp[i]);
6768                 fprintf(fff,"\n");
6769         }
6770
6771         /* Close the file */
6772         my_fclose(fff);
6773
6774         /* Display the file contents */
6775 #ifdef JP
6776         show_file(TRUE, file_name, "µ»Ç½¤Î·Ð¸³ÃÍ", 0, 0);
6777 #else
6778         show_file(TRUE, file_name, "Miscellaneous Proficiency", 0, 0);
6779 #endif
6780
6781
6782         /* Remove the file */
6783         fd_kill(file_name);
6784 }
6785
6786
6787 /*
6788  * Pluralize a monster name
6789  */
6790 void plural_aux(char *Name)
6791 {
6792         int NameLen = strlen(Name);
6793
6794         if (strstr(Name, "Disembodied hand"))
6795         {
6796                 strcpy(Name, "Disembodied hands that strangled people");
6797         }
6798         else if (strstr(Name, "Colour out of space"))
6799         {
6800                 strcpy(Name, "Colours out of space");
6801         }
6802         else if (strstr(Name, "stairway to hell"))
6803         {
6804                 strcpy(Name, "stairways to hell");
6805         }
6806         else if (strstr(Name, "Dweller on the threshold"))
6807         {
6808                 strcpy(Name, "Dwellers on the threshold");
6809         }
6810         else if (strstr(Name, " of "))
6811         {
6812                 cptr aider = strstr(Name, " of ");
6813                 char dummy[80];
6814                 int i = 0;
6815                 cptr ctr = Name;
6816
6817                 while (ctr < aider)
6818                 {
6819                         dummy[i] = *ctr;
6820                         ctr++; i++;
6821                 }
6822
6823                 if (dummy[i-1] == 's')
6824                 {
6825                         strcpy(&(dummy[i]), "es");
6826                         i++;
6827                 }
6828                 else
6829                 {
6830                         strcpy(&(dummy[i]), "s");
6831                 }
6832
6833                 strcpy(&(dummy[i+1]), aider);
6834                 strcpy(Name, dummy);
6835         }
6836         else if (strstr(Name, "coins"))
6837         {
6838                 char dummy[80];
6839                 strcpy(dummy, "piles of ");
6840                 strcat(dummy, Name);
6841                 strcpy(Name, dummy);
6842                 return;
6843         }
6844         else if (strstr(Name, "Manes"))
6845         {
6846                 return;
6847         }
6848         else if (streq(&(Name[NameLen - 2]), "ey"))
6849         {
6850                 strcpy(&(Name[NameLen - 2]), "eys");
6851         }
6852         else if (Name[NameLen - 1] == 'y')
6853         {
6854                 strcpy(&(Name[NameLen - 1]), "ies");
6855         }
6856         else if (streq(&(Name[NameLen - 4]), "ouse"))
6857         {
6858                 strcpy(&(Name[NameLen - 4]), "ice");
6859         }
6860         else if (streq(&(Name[NameLen - 2]), "us"))
6861         {
6862                 strcpy(&(Name[NameLen - 2]), "i");
6863         }
6864         else if (streq(&(Name[NameLen - 6]), "kelman"))
6865         {
6866                 strcpy(&(Name[NameLen - 6]), "kelmen");
6867         }
6868         else if (streq(&(Name[NameLen - 8]), "wordsman"))
6869         {
6870                 strcpy(&(Name[NameLen - 8]), "wordsmen");
6871         }
6872         else if (streq(&(Name[NameLen - 7]), "oodsman"))
6873         {
6874                 strcpy(&(Name[NameLen - 7]), "oodsmen");
6875         }
6876         else if (streq(&(Name[NameLen - 7]), "eastman"))
6877         {
6878                 strcpy(&(Name[NameLen - 7]), "eastmen");
6879         }
6880         else if (streq(&(Name[NameLen - 8]), "izardman"))
6881         {
6882                 strcpy(&(Name[NameLen - 8]), "izardmen");
6883         }
6884         else if (streq(&(Name[NameLen - 5]), "geist"))
6885         {
6886                 strcpy(&(Name[NameLen - 5]), "geister");
6887         }
6888         else if (streq(&(Name[NameLen - 2]), "ex"))
6889         {
6890                 strcpy(&(Name[NameLen - 2]), "ices");
6891         }
6892         else if (streq(&(Name[NameLen - 2]), "lf"))
6893         {
6894                 strcpy(&(Name[NameLen - 2]), "lves");
6895         }
6896         else if (suffix(Name, "ch") ||
6897                  suffix(Name, "sh") ||
6898                          suffix(Name, "nx") ||
6899                          suffix(Name, "s") ||
6900                          suffix(Name, "o"))
6901         {
6902                 strcpy(&(Name[NameLen]), "es");
6903         }
6904         else
6905         {
6906                 strcpy(&(Name[NameLen]), "s");
6907         }
6908 }
6909
6910 /*
6911  * Display current pets
6912  */
6913 static void do_cmd_knowledge_pets(void)
6914 {
6915         int             i;
6916         FILE            *fff;
6917         monster_type    *m_ptr;
6918         int             t_friends = 0;
6919         int             show_upkeep = 0;
6920         char            file_name[1024];
6921
6922
6923         /* Open a new file */
6924         fff = my_fopen_temp(file_name, 1024);
6925         if (!fff) {
6926 #ifdef JP
6927             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
6928 #else
6929             msg_format("Failed to create temporary file %s.", file_name);
6930 #endif
6931             msg_print(NULL);
6932             return;
6933         }
6934
6935         /* Process the monsters (backwards) */
6936         for (i = m_max - 1; i >= 1; i--)
6937         {
6938                 monster_race *r_ptr;
6939                 /* Access the monster */
6940                 m_ptr = &m_list[i];
6941
6942                 /* Ignore "dead" monsters */
6943                 if (!m_ptr->r_idx) continue;
6944                 r_ptr = &r_info[m_ptr->r_idx];
6945
6946                 /* Calculate "upkeep" for pets */
6947                 if (is_pet(m_ptr))
6948                 {
6949                         char pet_name[80];
6950                         t_friends++;
6951                         monster_desc(pet_name, m_ptr, 0x88);
6952                         fprintf(fff, "%s (%s)", pet_name, look_mon_desc(i, 0x00));
6953                         if (p_ptr->riding == i)
6954 #ifdef JP
6955                                 fprintf(fff, " ¾èÇÏÃæ");
6956 #else
6957                                 fprintf(fff, " Riding");
6958 #endif
6959                         fprintf(fff, "\n");
6960                 }
6961         }
6962
6963         show_upkeep = calculate_upkeep();
6964
6965         fprintf(fff, "----------------------------------------------\n");
6966 #ifdef JP
6967         fprintf(fff, "    ¹ç·×: %d É¤¤Î¥Ú¥Ã¥È\n", t_friends);
6968         fprintf(fff, " °Ý»ý¥³¥¹¥È: %d%% MP\n", show_upkeep);
6969 #else
6970         fprintf(fff, "   Total: %d pet%s.\n",
6971                 t_friends, (t_friends == 1 ? "" : "s"));
6972         fprintf(fff, "   Upkeep: %d%% mana.\n", show_upkeep);
6973 #endif
6974
6975
6976
6977         /* Close the file */
6978         my_fclose(fff);
6979
6980         /* Display the file contents */
6981 #ifdef JP
6982         show_file(TRUE, file_name, "¸½ºß¤Î¥Ú¥Ã¥È", 0, 0);
6983 #else
6984         show_file(TRUE, file_name, "Current Pets", 0, 0);
6985 #endif
6986
6987
6988         /* Remove the file */
6989         fd_kill(file_name);
6990 }
6991
6992
6993 /*
6994  * Total kill count
6995  *
6996  * Note that the player ghosts are ignored.  XXX XXX XXX
6997  */
6998 static void do_cmd_knowledge_kill_count(void)
6999 {
7000         int i, k, n = 0;
7001         u16b why = 2;
7002         s16b *who;
7003
7004         FILE *fff;
7005
7006         char file_name[1024];
7007
7008         s32b Total = 0;
7009
7010
7011         /* Open a new file */
7012         fff = my_fopen_temp(file_name, 1024);
7013
7014         if (!fff) {
7015 #ifdef JP
7016             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
7017 #else
7018             msg_format("Failed to create temporary file %s.", file_name);
7019 #endif
7020             msg_print(NULL);
7021             return;
7022         }
7023
7024         /* Allocate the "who" array */
7025         C_MAKE(who, max_r_idx, s16b);
7026
7027         {
7028                 /* Monsters slain */
7029                 int kk;
7030
7031                 for (kk = 1; kk < max_r_idx; kk++)
7032                 {
7033                         monster_race *r_ptr = &r_info[kk];
7034
7035                         if (r_ptr->flags1 & (RF1_UNIQUE))
7036                         {
7037                                 bool dead = (r_ptr->max_num == 0);
7038
7039                                 if (dead)
7040                                 {
7041                                         Total++;
7042                                 }
7043                         }
7044                         else
7045                         {
7046                                 s16b This = r_ptr->r_pkills;
7047
7048                                 if (This > 0)
7049                                 {
7050                                         Total += This;
7051                                 }
7052                         }
7053                 }
7054
7055                 if (Total < 1)
7056 #ifdef JP
7057                         fprintf(fff,"¤¢¤Ê¤¿¤Ï¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Ê¤¤¡£\n\n");
7058 #else
7059                         fprintf(fff,"You have defeated no enemies yet.\n\n");
7060 #endif
7061
7062                 else if (Total == 1)
7063 #ifdef JP
7064                         fprintf(fff,"¤¢¤Ê¤¿¤Ï°ìɤ¤ÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n");
7065 #else
7066                         fprintf(fff,"You have defeated one enemy.\n\n");
7067 #endif
7068
7069                 else
7070 #ifdef JP
7071                         fprintf(fff,"¤¢¤Ê¤¿¤Ï %lu É¤¤ÎŨ¤òÅݤ·¤Æ¤¤¤ë¡£\n\n", Total);
7072 #else
7073                         fprintf(fff,"You have defeated %lu enemies.\n\n", Total);
7074 #endif
7075
7076         }
7077
7078         Total = 0;
7079
7080         /* Scan the monsters */
7081         for (i = 1; i < max_r_idx; i++)
7082         {
7083                 monster_race *r_ptr = &r_info[i];
7084
7085                 /* Use that monster */
7086                 if (r_ptr->name) who[n++] = i;
7087         }
7088
7089         /* Select the sort method */
7090         ang_sort_comp = ang_sort_comp_hook;
7091         ang_sort_swap = ang_sort_swap_hook;
7092
7093         /* Sort the array by dungeon depth of monsters */
7094         ang_sort(who, &why, n);
7095
7096         /* Scan the monster races */
7097         for (k = 0; k < n; k++)
7098         {
7099                 monster_race *r_ptr = &r_info[who[k]];
7100
7101                 if (r_ptr->flags1 & (RF1_UNIQUE))
7102                 {
7103                         bool dead = (r_ptr->max_num == 0);
7104
7105                         if (dead)
7106                         {
7107                                 /* Print a message */
7108                                 fprintf(fff, "     %s\n",
7109                                     (r_name + r_ptr->name));
7110                                 Total++;
7111                         }
7112                 }
7113                 else
7114                 {
7115                         s16b This = r_ptr->r_pkills;
7116
7117                         if (This > 0)
7118                         {
7119 #ifdef JP
7120                                 /* p,t¤Ï¿Í¤È¿ô¤¨¤ë by ita*/
7121                                 if(strchr("pt",r_ptr->d_char))
7122                                         fprintf(fff, "     %3d ¿Í¤Î %s\n", This, r_name + r_ptr->name);
7123                                 else
7124                                         fprintf(fff, "     %3d É¤¤Î %s\n", This, r_name + r_ptr->name);
7125 #else
7126                                 if (This < 2)
7127                                 {
7128                                         if (strstr(r_name + r_ptr->name, "coins"))
7129                                         {
7130                                                 fprintf(fff, "     1 pile of %s\n", (r_name + r_ptr->name));
7131                                         }
7132                                         else
7133                                         {
7134                                                 fprintf(fff, "     1 %s\n", (r_name + r_ptr->name));
7135                                         }
7136                                 }
7137                                 else
7138                                 {
7139                                         char ToPlural[80];
7140                                         strcpy(ToPlural, (r_name + r_ptr->name));
7141                                         plural_aux(ToPlural);
7142                                         fprintf(fff, "     %d %s\n", This, ToPlural);
7143                                 }
7144 #endif
7145
7146
7147                                 Total += This;
7148                         }
7149                 }
7150         }
7151
7152         fprintf(fff,"----------------------------------------------\n");
7153 #ifdef JP
7154         fprintf(fff,"    ¹ç·×: %lu É¤¤òÅݤ·¤¿¡£\n", Total);
7155 #else
7156         fprintf(fff,"   Total: %lu creature%s killed.\n",
7157                 Total, (Total == 1 ? "" : "s"));
7158 #endif
7159
7160
7161         /* Free the "who" array */
7162         C_KILL(who, max_r_idx, s16b);
7163
7164         /* Close the file */
7165         my_fclose(fff);
7166
7167         /* Display the file contents */
7168 #ifdef JP
7169         show_file(TRUE, file_name, "Åݤ·¤¿Å¨¤Î¿ô", 0, 0);
7170 #else
7171         show_file(TRUE, file_name, "Kill Count", 0, 0);
7172 #endif
7173
7174
7175         /* Remove the file */
7176         fd_kill(file_name);
7177 }
7178
7179
7180 /*
7181  * Display the object groups.
7182  */
7183 static void display_group_list(int col, int row, int wid, int per_page,
7184         int grp_idx[], cptr group_text[], int grp_cur, int grp_top)
7185 {
7186         int i;
7187
7188         /* Display lines until done */
7189         for (i = 0; i < per_page && (grp_idx[i] >= 0); i++)
7190         {
7191                 /* Get the group index */
7192                 int grp = grp_idx[grp_top + i];
7193
7194                 /* Choose a color */
7195                 byte attr = (grp_top + i == grp_cur) ? TERM_L_BLUE : TERM_WHITE;
7196
7197                 /* Erase the entire line */
7198                 Term_erase(col, row + i, wid);
7199
7200                 /* Display the group label */
7201                 c_put_str(attr, group_text[grp], row + i, col);
7202         }
7203 }
7204
7205
7206 /* 
7207  * Move the cursor in a browser window 
7208  */
7209 static void browser_cursor(char ch, int *column, int *grp_cur, int grp_cnt, 
7210                                                    int *list_cur, int list_cnt)
7211 {
7212         int d;
7213         int col = *column;
7214         int grp = *grp_cur;
7215         int list = *list_cur;
7216
7217         /* Extract direction */
7218         if (ch == ' ')
7219         {
7220                 /* Hack -- scroll up full screen */
7221                 d = 3;
7222         }
7223         else if (ch == '-')
7224         {
7225                 /* Hack -- scroll down full screen */
7226                 d = 9;
7227         }
7228         else
7229         {
7230                 d = get_keymap_dir(ch);
7231         }
7232
7233         if (!d) return;
7234
7235         /* Diagonals - hack */
7236         if ((ddx[d] > 0) && ddy[d])
7237         {
7238                 int browser_rows;
7239                 int wid, hgt;
7240
7241                 /* Get size */
7242                 Term_get_size(&wid, &hgt);
7243
7244                 browser_rows = hgt - 8;
7245
7246                 /* Browse group list */
7247                 if (!col)
7248                 {
7249                         int old_grp = grp;
7250
7251                         /* Move up or down */
7252                         grp += ddy[d] * (browser_rows - 1);
7253
7254                         /* Verify */
7255                         if (grp >= grp_cnt)     grp = grp_cnt - 1;
7256                         if (grp < 0) grp = 0;
7257                         if (grp != old_grp)     list = 0;
7258                 }
7259
7260                 /* Browse sub-list list */
7261                 else
7262                 {
7263                         /* Move up or down */
7264                         list += ddy[d] * browser_rows;
7265
7266                         /* Verify */
7267                         if (list >= list_cnt) list = list_cnt - 1;
7268                         if (list < 0) list = 0;
7269                 }
7270
7271                 (*grp_cur) = grp;
7272                 (*list_cur) = list;
7273
7274                 return;
7275         }
7276
7277         if (ddx[d])
7278         {
7279                 col += ddx[d];
7280                 if (col < 0) col = 0;
7281                 if (col > 1) col = 1;
7282
7283                 (*column) = col;
7284
7285                 return;
7286         }
7287
7288         /* Browse group list */
7289         if (!col)
7290         {
7291                 int old_grp = grp;
7292
7293                 /* Move up or down */
7294                 grp += ddy[d];
7295
7296                 /* Verify */
7297                 if (grp >= grp_cnt)     grp = grp_cnt - 1;
7298                 if (grp < 0) grp = 0;
7299                 if (grp != old_grp)     list = 0;
7300         }
7301
7302         /* Browse sub-list list */
7303         else
7304         {
7305                 /* Move up or down */
7306                 list += ddy[d];
7307
7308                 /* Verify */
7309                 if (list >= list_cnt) list = list_cnt - 1;
7310                 if (list < 0) list = 0;
7311         }
7312
7313         (*grp_cur) = grp;
7314         (*list_cur) = list;
7315 }
7316
7317
7318 /*
7319  * Display visuals.
7320  */
7321 static void display_visual_list(int col, int row, int height, int width, byte attr_top, byte char_left)
7322 {
7323         int i, j;
7324
7325         /* Clear the display lines */
7326         for (i = 0; i < height; i++)
7327         {
7328                 Term_erase(col, row + i, width);
7329         }
7330
7331         /* Bigtile mode uses double width */
7332         if (use_bigtile) width /= 2;
7333
7334         /* Display lines until done */
7335         for (i = 0; i < height; i++)
7336         {
7337                 /* Display columns until done */
7338                 for (j = 0; j < width; j++)
7339                 {
7340                         byte a, a2;
7341                         char c, c2;
7342                         int x = col + j;
7343                         int y = row + i;
7344                         int ia, ic;
7345
7346                         /* Bigtile mode uses double width */
7347                         if (use_bigtile) x += j;
7348
7349                         ia = attr_top + i;
7350                         ic = char_left + j;
7351
7352                         /* Ignore illegal characters */
7353                         if (ia > 0x7f || ic > 0xff || ic < ' ' ||
7354                             (!use_graphics && ic > 0x7f))
7355                                 continue;
7356
7357                         a = (byte)ia;
7358                         c = (char)ic;
7359
7360                         /* Force correct code for both ASCII character and tile */
7361                         if (c & 0x80) a |= 0x80;
7362
7363                         if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
7364
7365                         /* Display symbol */
7366                         Term_putch(x, y, a, c);
7367
7368                         /* Second byte */
7369                         if (use_bigtile) Term_putch(x + 1, y, a2, c2);
7370                 }
7371         }
7372 }
7373
7374
7375 /*
7376  * Place the cursor at the collect position for visual mode
7377  */
7378 static void place_visual_list_cursor(int col, int row, byte a, byte c, byte attr_top, byte char_left)
7379 {
7380         int i = (a & 0x7f) - attr_top;
7381         int j = c - char_left;
7382
7383         int x = col + j;
7384         int y = row + i;
7385
7386         /* Bigtile mode uses double width */
7387         if (use_bigtile) x += j;
7388
7389         /* Place the cursor */
7390         Term_gotoxy(x, y);
7391 }
7392
7393
7394 /*
7395  *  Clipboard variables for copy&paste in visual mode
7396  */
7397 static byte attr_idx = 0;
7398 static byte char_idx = 0;
7399
7400 /*
7401  *  Do visual mode command -- Change symbols
7402  */
7403 static bool visual_mode_command(char ch, bool *visual_list_ptr, 
7404                                 int height, int width, 
7405                                 byte *attr_top_ptr, byte *char_left_ptr, 
7406                                 byte *cur_attr_ptr, byte *cur_char_ptr)
7407 {
7408         static byte attr_old = 0, char_old = 0;
7409
7410         switch (ch)
7411         {
7412         case ESCAPE:
7413                 if (*visual_list_ptr)
7414                 {
7415                         /* Cancel change */
7416                         *cur_attr_ptr = attr_old;
7417                         *cur_char_ptr = char_old;
7418                         *visual_list_ptr = FALSE;
7419
7420                         return TRUE;
7421                 }
7422
7423                 break;
7424
7425         case '\n':
7426         case '\r':
7427                 if (*visual_list_ptr)
7428                 {
7429                         /* Accept change */
7430                         *visual_list_ptr = FALSE;
7431
7432                         return TRUE;
7433                 }
7434                 break;
7435
7436         case 'V':
7437         case 'v':
7438                 if (!*visual_list_ptr)
7439                 {
7440                         *visual_list_ptr = TRUE;
7441
7442                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7443                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7444
7445                         attr_old = *cur_attr_ptr;
7446                         char_old = *cur_char_ptr;
7447
7448                         return TRUE;
7449                 }
7450                 break;
7451
7452         case 'C':
7453         case 'c':
7454                 /* Set the visual */
7455                 attr_idx = *cur_attr_ptr;
7456                 char_idx = *cur_char_ptr;
7457
7458                 return TRUE;
7459
7460         case 'P':
7461         case 'p':
7462                 if (attr_idx)
7463                 {
7464                         /* Set the char */
7465                         *cur_attr_ptr = attr_idx;
7466                         *attr_top_ptr = MAX(0, (*cur_attr_ptr & 0x7f) - 5);
7467                 }
7468
7469                 if (char_idx)
7470                 {
7471                         /* Set the char */
7472                         *cur_char_ptr = char_idx;
7473                         *char_left_ptr = MAX(0, *cur_char_ptr - 10);
7474                 }
7475
7476                 return TRUE;
7477
7478         default:
7479                 if (*visual_list_ptr)
7480                 {
7481                         int eff_width;
7482                         int d = get_keymap_dir(ch);
7483                         byte a = (*cur_attr_ptr & 0x7f);
7484                         byte c = *cur_char_ptr;
7485
7486                         if (use_bigtile) eff_width = width / 2;
7487                         else eff_width = width;
7488                                         
7489                         /* Restrict direction */
7490                         if ((a == 0) && (ddy[d] < 0)) d = 0;
7491                         if ((c == 0) && (ddx[d] < 0)) d = 0;
7492                         if ((a == 0x7f) && (ddy[d] > 0)) d = 0;
7493                         if ((c == 0xff) && (ddx[d] > 0)) d = 0;
7494
7495                         a += ddy[d];
7496                         c += ddx[d];
7497
7498                         /* Force correct code for both ASCII character and tile */
7499                         if (c & 0x80) a |= 0x80;
7500
7501                         /* Set the visual */
7502                         *cur_attr_ptr = a;
7503                         *cur_char_ptr = c;
7504
7505
7506                         /* Move the frame */
7507                         if ((ddx[d] < 0) && *char_left_ptr > MAX(0, (int)c - 10)) (*char_left_ptr)--;
7508                         if ((ddx[d] > 0) && *char_left_ptr + eff_width < MIN(0xff, (int)c + 10)) (*char_left_ptr)++;
7509                         if ((ddy[d] < 0) && *attr_top_ptr > MAX(0, (int)(a & 0x7f) - 4)) (*attr_top_ptr)--;
7510                         if ((ddy[d] > 0) && *attr_top_ptr + height < MIN(0x7f, (a & 0x7f) + 4)) (*attr_top_ptr)++;
7511                         return TRUE;
7512                 }
7513                                 
7514                 break;
7515         }
7516
7517         /* Visual mode command is not used */
7518         return FALSE;
7519 }
7520
7521
7522 /*
7523  * Display the monsters in a group.
7524  */
7525 static void display_monster_list(int col, int row, int per_page, s16b mon_idx[],
7526         int mon_cur, int mon_top)
7527 {
7528         int i;
7529
7530         /* Display lines until done */
7531         for (i = 0; i < per_page && mon_idx[mon_top + i]; i++)
7532         {
7533                 byte attr;
7534                 byte a, a2;
7535                 char c, c2;
7536
7537                 /* Get the race index */
7538                 int r_idx = mon_idx[mon_top + i] ;
7539
7540                 /* Access the race */
7541                 monster_race *r_ptr = &r_info[r_idx];
7542
7543
7544                 /* Choose a color */
7545                 attr = ((i + mon_top == mon_cur) ? TERM_L_BLUE : TERM_WHITE);
7546
7547                 /* Display the name */
7548                 c_prt(attr, (r_name + r_ptr->name), row + i, col);
7549
7550                 /* Hack -- visual_list mode */
7551                 if (per_page == 1)
7552                 {
7553                         c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, 60);
7554                 }
7555                 else if (p_ptr->wizard) 
7556                 {
7557                         c_prt(attr, format("%d", r_idx), row + i, 60);
7558                 }
7559
7560                 a = r_ptr->x_attr;
7561                 c = r_ptr->x_char;
7562                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
7563
7564                 /* Display symbol */
7565                 Term_putch(70, row + i, a, c);
7566
7567                 /* Second byte */
7568                 if (use_bigtile) Term_putch(70 + 1, row + i, a2, c2);
7569
7570                 /* Display kills */
7571                 if (!(r_ptr->flags1 & RF1_UNIQUE)) put_str(format("%5d", r_ptr->r_pkills), row + i, 73);
7572 #ifdef JP
7573                 else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "»àË´" : "À¸Â¸"), row + i, 73);
7574 #else
7575                 else c_put_str((r_ptr->max_num == 0 ? TERM_L_DARK : TERM_WHITE), (r_ptr->max_num == 0 ? "dead" : "alive"), row + i, 73);
7576 #endif
7577         
7578         }
7579
7580         /* Clear remaining lines */
7581         for (; i < per_page; i++)
7582         {
7583                 Term_erase(col, row + i, 255);
7584         }
7585 }
7586
7587
7588 /*
7589  * Display known monsters.
7590  */
7591 static void do_cmd_knowledge_monsters(void)
7592 {
7593         int i, len, max;
7594         int grp_cur, grp_top, old_grp_cur;
7595         int mon_cur, mon_top;
7596         int grp_cnt, grp_idx[100];
7597         int mon_cnt;
7598         s16b *mon_idx;
7599         
7600         int column = 0;
7601         bool flag;
7602         bool redraw;
7603
7604         bool visual_list = FALSE;
7605         byte attr_top = 0, char_left = 0;
7606
7607         int browser_rows;
7608         int wid, hgt;
7609
7610         /* Get size */
7611         Term_get_size(&wid, &hgt);
7612
7613         browser_rows = hgt - 8;
7614
7615         /* Allocate the "mon_idx" array */
7616         C_MAKE(mon_idx, max_r_idx, s16b);
7617
7618         max = 0;
7619         grp_cnt = 0;
7620
7621         /* Check every group */
7622         for (i = 0; monster_group_text[i] != NULL; i++)
7623         {
7624                 /* Measure the label */
7625                 len = strlen(monster_group_text[i]);
7626
7627                 /* Save the maximum length */
7628                 if (len > max) max = len;
7629
7630                 /* See if any monsters are known */
7631                 if ((monster_group_char[i] == ((char *) -1L)) || collect_monsters(i, mon_idx, 0x01))
7632                 {
7633                         /* Build a list of groups with known monsters */
7634                         grp_idx[grp_cnt++] = i;
7635                 }
7636         }
7637
7638         /* Terminate the list */
7639         grp_idx[grp_cnt] = -1;
7640
7641         old_grp_cur = -1;
7642         grp_cur = grp_top = 0;
7643         mon_cur = mon_top = 0;
7644         mon_cnt = 0;
7645
7646         flag = FALSE;
7647         redraw = TRUE;
7648
7649         while (!flag)
7650         {
7651                 char ch;
7652                 monster_race *r_ptr;
7653
7654                 if (redraw)
7655                 {
7656                         clear_from(0);
7657                 
7658 #ifdef JP
7659                         prt("Ãμ± - ¥â¥ó¥¹¥¿¡¼", 2, 0);
7660                         prt("¥°¥ë¡¼¥×", 4, 0);
7661                         prt("̾Á°", 4, max + 3);
7662                         if (p_ptr->wizard) prt("Idx", 4, 60);
7663                         prt("ʸ»ú »¦³²¿ô", 4, 67);
7664 #else
7665                         prt("Knowledge - Monsters", 2, 0);
7666                         prt("Group", 4, 0);
7667                         prt("Name", 4, max + 3);
7668                         if (p_ptr->wizard) prt("Idx", 4, 60);
7669                         prt("Sym   Kills", 4, 67);
7670 #endif
7671
7672                         for (i = 0; i < 78; i++)
7673                         {
7674                                 Term_putch(i, 5, TERM_WHITE, '=');
7675                         }
7676
7677                         for (i = 0; i < browser_rows; i++)
7678                         {
7679                                 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
7680                         }
7681
7682                         redraw = FALSE;
7683                 }
7684
7685                 /* Scroll group list */
7686                 if (grp_cur < grp_top) grp_top = grp_cur;
7687                 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
7688
7689                 /* Display a list of monster groups */
7690                 display_group_list(0, 6, max, browser_rows, grp_idx, monster_group_text, grp_cur, grp_top);
7691
7692                 if (old_grp_cur != grp_cur)
7693                 {
7694                         old_grp_cur = grp_cur;
7695
7696                         /* Get a list of monsters in the current group */
7697                         mon_cnt = collect_monsters(grp_idx[grp_cur], mon_idx, 0x00);
7698                 }
7699
7700                 /* Scroll monster list */
7701                 while (mon_cur < mon_top)
7702                         mon_top = MAX(0, mon_top - browser_rows/2);
7703                 while (mon_cur >= mon_top + browser_rows)
7704                         mon_top = MIN(mon_cnt - browser_rows, mon_top + browser_rows/2);
7705
7706                 if (!visual_list)
7707                 {
7708                         /* Display a list of monsters in the current group */
7709                         display_monster_list(max + 3, 6, browser_rows, mon_idx, mon_cur, mon_top);
7710                 }
7711                 else
7712                 {
7713                         mon_top = mon_cur;
7714
7715                         /* Display a monster name */
7716                         display_monster_list(max + 3, 6, 1, mon_idx, mon_cur, mon_top);
7717
7718                         /* Display visual list below first monster */
7719                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
7720                 }
7721
7722                 /* Prompt */
7723 #ifdef JP
7724                 prt(format("<Êý¸þ>, 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë%s%s, ESC", visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
7725 #else
7726                 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);
7727 #endif
7728
7729                 /* Get the current monster */
7730                 r_ptr = &r_info[mon_idx[mon_cur]];
7731
7732                 /* Mega Hack -- track this monster race */
7733                 if (mon_cnt) monster_race_track(mon_idx[mon_cur]);
7734
7735                 /* Hack -- handle stuff */
7736                 handle_stuff();
7737
7738                 if (visual_list)
7739                 {
7740                         place_visual_list_cursor(max + 3, 7, r_ptr->x_attr, r_ptr->x_char, attr_top, char_left);
7741                 }
7742                 else if (!column)
7743                 {
7744                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
7745                 }
7746                 else
7747                 {
7748                         Term_gotoxy(max + 3, 6 + (mon_cur - mon_top));
7749                 }
7750         
7751                 ch = inkey();
7752
7753                 /* Do visual mode command if needed */
7754                 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;
7755
7756                 switch (ch)
7757                 {
7758                         case ESCAPE:
7759                         {
7760                                 flag = TRUE;
7761                                 break;
7762                         }
7763
7764                         case 'R':
7765                         case 'r':
7766                         {
7767                                 /* Recall on screen */
7768                                 if (mon_idx[mon_cur])
7769                                 {
7770                                         screen_roff(mon_idx[mon_cur], 0);
7771
7772                                         (void)inkey();
7773         
7774                                         redraw = TRUE;
7775                                 }
7776                                 break;
7777                         }
7778
7779                         default:
7780                         {
7781                                 /* Move the cursor */
7782                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &mon_cur, mon_cnt);
7783
7784                                 break;
7785                         }
7786                 }
7787         }
7788
7789         /* Free the "mon_idx" array */
7790         C_KILL(mon_idx, max_r_idx, s16b);
7791 }
7792
7793
7794 /*
7795  * Display the objects in a group.
7796  */
7797 static void display_object_list(int col, int row, int per_page, int object_idx[],
7798         int object_cur, int object_top)
7799 {
7800         int i;
7801
7802         /* Display lines until done */
7803         for (i = 0; i < per_page && object_idx[object_top + i]; i++)
7804         {
7805                 char o_name[80];
7806                 byte a, a2;
7807                 char c, c2;
7808
7809                 /* Get the object index */
7810                 int k_idx = object_idx[object_top + i];
7811
7812                 /* Access the object */
7813                 object_kind *k_ptr = &k_info[k_idx];
7814
7815                 /* Choose a color */
7816                 byte attr = (k_ptr->aware ? TERM_WHITE : TERM_SLATE);
7817                 byte cursor = (k_ptr->aware ? TERM_L_BLUE : TERM_BLUE);
7818
7819                 attr = ((i + object_top == object_cur) ? cursor : attr);
7820                 
7821                 /* Tidy name */
7822                 strip_name(o_name, k_idx);
7823
7824                 /* Display the name */
7825                 c_prt(attr, o_name, row + i, col);
7826
7827                 /* Hack -- visual_list mode */
7828                 if (per_page == 1)
7829                 {
7830                         c_prt(attr, format("%02x/%02x", k_ptr->x_attr, k_ptr->x_char), row + i, 60);
7831                 }
7832                 else if (p_ptr->wizard)
7833                 {
7834                         c_prt(attr, format ("%d", k_idx), row + i, 70);
7835                 }
7836
7837                 a = k_ptr->flavor ? misc_to_attr[k_ptr->flavor] : k_ptr->x_attr;
7838                 c = k_ptr->flavor ? misc_to_char[k_ptr->flavor] : k_ptr->x_char;
7839
7840                 /* Symbol is unknown */ 
7841                 if (!k_ptr->aware && !p_ptr->wizard)
7842                 {
7843                         c = ' ';
7844                         a = TERM_DARK;
7845                 }
7846
7847                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
7848
7849                 /* Display symbol */
7850                 Term_putch(76, row + i, a, c);
7851
7852                 /* Second byte */
7853                 if (use_bigtile) Term_putch(76 + 1, row + i, a2, c2);
7854         }
7855
7856         /* Clear remaining lines */
7857         for (; i < per_page; i++)
7858         {
7859                 Term_erase(col, row + i, 255);
7860         }
7861 }
7862
7863 /*
7864  * Describe fake object
7865  */
7866 static void desc_obj_fake(int k_idx)
7867 {
7868         object_type *o_ptr;
7869         object_type object_type_body;
7870
7871         /* Get local object */
7872         o_ptr = &object_type_body;
7873
7874         /* Wipe the object */
7875         object_wipe(o_ptr);
7876
7877         /* Create the artifact */
7878         object_prep(o_ptr, k_idx);
7879
7880         /* It's fully know */
7881         o_ptr->ident |= IDENT_KNOWN;
7882
7883         /* Track the object */
7884         /* object_actual_track(o_ptr); */
7885
7886         /* Hack - mark as fake */
7887         /* term_obj_real = FALSE; */
7888
7889         /* Hack -- Handle stuff */
7890         handle_stuff();
7891
7892         if (!screen_object(o_ptr, FALSE))
7893         {
7894 #ifdef JP
7895                 msg_print("ÆäËÊѤï¤Ã¤¿¤È¤³¤í¤Ï¤Ê¤¤¤è¤¦¤À¡£");
7896 #else
7897                 msg_print("You see nothing special.");
7898 #endif
7899                 msg_print(NULL);
7900         }
7901 }
7902
7903
7904
7905 /*
7906  * Display known objects
7907  */
7908 static void do_cmd_knowledge_objects(void)
7909 {
7910         int i, len, max;
7911         int grp_cur, grp_top, old_grp_cur;
7912         int object_old, object_cur, object_top;
7913         int grp_cnt, grp_idx[100];
7914         int object_cnt;
7915         int *object_idx;
7916
7917         int column = 0;
7918         bool flag;
7919         bool redraw;
7920
7921         bool visual_list = FALSE;
7922         byte attr_top = 0, char_left = 0;
7923
7924         int browser_rows;
7925         int wid, hgt;
7926
7927         /* Get size */
7928         Term_get_size(&wid, &hgt);
7929
7930         browser_rows = hgt - 8;
7931
7932         /* Allocate the "object_idx" array */
7933         C_MAKE(object_idx, max_k_idx, int);
7934
7935         max = 0;
7936         grp_cnt = 0;
7937
7938         /* Check every group */
7939         for (i = 0; object_group_text[i] != NULL; i++)
7940         {
7941                 /* Measure the label */
7942                 len = strlen(object_group_text[i]);
7943
7944                 /* Save the maximum length */
7945                 if (len > max) max = len;
7946
7947                 /* See if any monsters are known */
7948                 if (collect_objects(i, object_idx))
7949                 {
7950                         /* Build a list of groups with known monsters */
7951                         grp_idx[grp_cnt++] = i;
7952                 }
7953         }
7954
7955         /* Terminate the list */
7956         grp_idx[grp_cnt] = -1;
7957
7958         old_grp_cur = -1;
7959         grp_cur = grp_top = 0;
7960         object_cur = object_top = 0;
7961         object_old = -1;
7962         object_cnt = 0;
7963
7964         flag = FALSE;
7965         redraw = TRUE;
7966
7967         while (!flag)
7968         {
7969                 char ch;
7970                 object_kind *k_ptr;
7971
7972                 if (redraw)
7973                 {
7974                         clear_from(0);
7975                 
7976 #ifdef JP
7977                         prt("Ãμ± - ¥¢¥¤¥Æ¥à", 2, 0);
7978                         prt("¥°¥ë¡¼¥×", 4, 0);
7979                         prt("̾Á°", 4, max + 3);
7980                         if (p_ptr->wizard) prt("Idx", 4, 70);
7981                         prt("ʸ»ú", 4, 75);
7982 #else
7983                         prt("Knowledge - objects", 2, 0);
7984                         prt("Group", 4, 0);
7985                         prt("Name", 4, max + 3);
7986                         if (p_ptr->wizard) prt("Idx", 4, 70);
7987                         prt("Sym", 4, 75);
7988 #endif
7989
7990                         for (i = 0; i < 78; i++)
7991                         {
7992                                 Term_putch(i, 5, TERM_WHITE, '=');
7993                         }
7994
7995                         for (i = 0; i < browser_rows; i++)
7996                         {
7997                                 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
7998                         }
7999
8000                         redraw = FALSE;
8001                 }
8002
8003                 /* Scroll group list */
8004                 if (grp_cur < grp_top) grp_top = grp_cur;
8005                 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8006
8007                 /* Display a list of object groups */
8008                 display_group_list(0, 6, max, browser_rows, grp_idx, object_group_text, grp_cur, grp_top);
8009
8010                 if (old_grp_cur != grp_cur)
8011                 {
8012                         old_grp_cur = grp_cur;
8013
8014                         /* Get a list of objects in the current group */
8015                         object_cnt = collect_objects(grp_idx[grp_cur], object_idx);
8016                 }
8017
8018                 /* Scroll object list */
8019                 while (object_cur < object_top)
8020                         object_top = MAX(0, object_top - browser_rows/2);
8021                 while (object_cur >= object_top + browser_rows)
8022                         object_top = MIN(object_cnt - browser_rows, object_top + browser_rows/2);
8023
8024                 if (!visual_list)
8025                 {
8026                         /* Display a list of objects in the current group */
8027                         display_object_list(max + 3, 6, browser_rows, object_idx, object_cur, object_top);
8028                 }
8029                 else
8030                 {
8031                         object_top = object_cur;
8032
8033                         /* Display a list of objects in the current group */
8034                         display_object_list(max + 3, 6, 1, object_idx, object_cur, object_top);
8035
8036                         /* Display visual list below first object */
8037                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8038                 }
8039
8040                 /* Get the current object */
8041                 k_ptr = &k_info[object_idx[object_cur]];
8042
8043                 /* Mega Hack -- track this object */
8044                 if (object_cnt) object_kind_track(object_idx[object_cur]);
8045
8046                 /* Prompt */
8047 #ifdef JP
8048                 prt(format("<Êý¸þ>, 'r'¤Ç»×¤¤½Ð¤ò¸«¤ë%s%s, ESC", k_ptr->flavor ? "" : visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
8049 #else
8050                 prt(format("<dir>, 'r' to recall%s%s, ESC", k_ptr->flavor ? "" : visual_list ? ", ENTER to accept" : ", 'v' for visuals", (attr_idx||char_idx) ? ", 'c', 'p' to paste" : ", 'c' to copy"), hgt - 1, 0);
8051 #endif
8052
8053                 /* The "current" object changed */
8054                 if (object_old != object_idx[object_cur])
8055                 {
8056                         /* Hack -- handle stuff */
8057                         handle_stuff();
8058
8059                         /* Remember the "current" object */
8060                         object_old = object_idx[object_cur];
8061                 }
8062
8063                 if (visual_list)
8064                 {
8065                         place_visual_list_cursor(max + 3, 7, k_ptr->x_attr, k_ptr->x_char, attr_top, char_left);
8066                 }
8067                 else if (!column)
8068                 {
8069                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8070                 }
8071                 else
8072                 {
8073                         Term_gotoxy(max + 3, 6 + (object_cur - object_top));
8074                 }
8075         
8076                 ch = inkey();
8077
8078                 /* Do visual mode command if needed */
8079                 /* Symbol of objects with flavor cannot be changed */
8080                 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;
8081
8082                 switch (ch)
8083                 {
8084                         case ESCAPE:
8085                         {
8086                                 flag = TRUE;
8087                                 break;
8088                         }
8089
8090                         case 'R':
8091                         case 'r':
8092                         {
8093                                 /* Recall on screen */
8094                                 if (grp_cnt > 0)
8095                                         desc_obj_fake(object_idx[object_cur]);
8096
8097                                 redraw = TRUE;
8098                                 break;
8099                         }
8100
8101                         default:
8102                         {
8103                                 /* Move the cursor */
8104                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &object_cur, object_cnt);
8105                                 break;
8106                         }
8107                 }
8108         }
8109
8110         /* Free the "object_idx" array */
8111         C_KILL(object_idx, max_k_idx, int);
8112 }
8113
8114
8115
8116 /*
8117  * Display the features in a group.
8118  */
8119 static void display_feature_list(int col, int row, int per_page, int *feat_idx,
8120         int feat_cur, int feat_top)
8121 {
8122         int i;
8123
8124         /* Display lines until done */
8125         for (i = 0; i < per_page && feat_idx[feat_top + i]; i++)
8126         {
8127                 byte a, a2;
8128                 char c, c2;
8129                 byte attr;
8130
8131                 /* Get the index */
8132                 int f_idx = feat_idx[feat_top + i];
8133
8134                 /* Access the index */
8135                 feature_type *f_ptr = &f_info[f_idx];
8136
8137                 /* Choose a color */
8138                 attr = ((i + feat_top == feat_cur) ? TERM_L_BLUE : TERM_WHITE);
8139
8140                 /* Display the name */
8141                 c_prt(attr, f_name + f_ptr->name, row + i, col);
8142
8143                 /* Hack -- visual_list mode */
8144                 if (per_page == 1)
8145                 {
8146                         c_prt(attr, format("%02x/%02x", f_ptr->x_attr, f_ptr->x_char), row + i, 60);
8147                 }
8148
8149                 a = f_ptr->x_attr;
8150                 c = f_ptr->x_char;
8151
8152                 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
8153
8154                 /* Display symbol */
8155                 Term_putch(68, row + i, a, c);
8156
8157                 /* Second byte */
8158                 if (use_bigtile) Term_putch(68 + 1, row + i, a2, c2);
8159         }
8160
8161         /* Clear remaining lines */
8162         for (; i < per_page; i++)
8163         {
8164                 Term_erase(col, row + i, 255);
8165         }
8166 }
8167
8168
8169 /*
8170  * Interact with feature visuals.
8171  */
8172 static void do_cmd_knowledge_features(void)
8173 {
8174         int i, len, max;
8175         int grp_cur, grp_top, old_grp_cur;
8176         int feat_cur, feat_top;
8177         int grp_cnt, grp_idx[100];
8178         int feat_cnt;
8179         int *feat_idx;
8180         
8181         int column = 0;
8182         bool flag;
8183         bool redraw;
8184
8185         bool visual_list = FALSE;
8186         byte attr_top = 0, char_left = 0;
8187
8188         int browser_rows;
8189         int wid, hgt;
8190
8191         /* Get size */
8192         Term_get_size(&wid, &hgt);
8193
8194         browser_rows = hgt - 8;
8195
8196         /* Allocate the "feat_idx" array */
8197         C_MAKE(feat_idx, max_f_idx, int);
8198
8199         max = 0;
8200         grp_cnt = 0;
8201
8202         /* Check every group */
8203         for (i = 0; feature_group_text[i] != NULL; i++)
8204         {
8205                 /* Measure the label */
8206                 len = strlen(feature_group_text[i]);
8207
8208                 /* Save the maximum length */
8209                 if (len > max) max = len;
8210
8211                 /* See if any features are known */
8212                 if (collect_features(i, feat_idx))
8213                 {
8214                         /* Build a list of groups with known features */
8215                         grp_idx[grp_cnt++] = i;
8216                 }
8217         }
8218
8219         /* Terminate the list */
8220         grp_idx[grp_cnt] = -1;
8221
8222         old_grp_cur = -1;
8223         grp_cur = grp_top = 0;
8224         feat_cur = feat_top = 0;
8225         feat_cnt = 0;
8226
8227         flag = FALSE;
8228         redraw = TRUE;
8229
8230         while ((!flag) && (grp_cnt))
8231         {
8232                 char ch;
8233                 feature_type *f_ptr;
8234
8235                 if (redraw)
8236                 {
8237                         clear_from(0);
8238                 
8239                         prt("Visuals - features", 2, 0);
8240                         prt("Group", 4, 0);
8241                         prt("Name", 4, max + 3);
8242                         prt("Sym", 4, 67);
8243
8244                         for (i = 0; i < 78; i++)
8245                         {
8246                                 Term_putch(i, 5, TERM_WHITE, '=');
8247                         }
8248
8249                         for (i = 0; i < browser_rows; i++)
8250                         {
8251                                 Term_putch(max + 1, 6 + i, TERM_WHITE, '|');
8252                         }
8253
8254                         redraw = FALSE;
8255                 }
8256
8257                 /* Scroll group list */
8258                 if (grp_cur < grp_top) grp_top = grp_cur;
8259                 if (grp_cur >= grp_top + browser_rows) grp_top = grp_cur - browser_rows + 1;
8260
8261                 /* Display a list of feature groups */
8262                 display_group_list(0, 6, max, browser_rows, grp_idx, feature_group_text, grp_cur, grp_top);
8263
8264                 if (old_grp_cur != grp_cur)
8265                 {
8266                         old_grp_cur = grp_cur;
8267
8268                         /* Get a list of features in the current group */
8269                         feat_cnt = collect_features(grp_idx[grp_cur], feat_idx);
8270                 }
8271
8272                 /* Scroll feature list */
8273                 while (feat_cur < feat_top)
8274                         feat_top = MAX(0, feat_top - browser_rows/2);
8275                 while (feat_cur >= feat_top + browser_rows)
8276                         feat_top = MIN(feat_cnt - browser_rows, feat_top + browser_rows/2);
8277
8278                 if (!visual_list)
8279                 {
8280                         /* Display a list of features in the current group */
8281                         display_feature_list(max + 3, 6, browser_rows, feat_idx, feat_cur, feat_top);
8282                 }
8283                 else
8284                 {
8285                         feat_top = feat_cur;
8286
8287                         /* Display a list of features in the current group */
8288                         display_feature_list(max + 3, 6, 1, feat_idx, feat_cur, feat_top);
8289
8290                         /* Display visual list below first object */
8291                         display_visual_list(max + 3, 7, browser_rows-1, wid - (max + 3), attr_top, char_left);
8292                 }
8293
8294                 /* Prompt */
8295 #ifdef JP
8296                 prt(format("<Êý¸þ>%s%s, ESC", visual_list ? ", ENTER¤Ç·èÄê" : ", 'v'¤Ç¥·¥ó¥Ü¥ëÊѹ¹", (attr_idx||char_idx) ? ", 'c', 'p'¤Ç¥Ú¡¼¥¹¥È" : ", 'c'¤Ç¥³¥Ô¡¼"), hgt - 1, 0);
8297 #else
8298                 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);
8299 #endif
8300
8301                 /* Get the current feature */
8302                 f_ptr = &f_info[feat_idx[feat_cur]];
8303
8304                 if (visual_list)
8305                 {
8306                         place_visual_list_cursor(max + 3, 7, f_ptr->x_attr, f_ptr->x_char, attr_top, char_left);
8307                 }
8308                 else if (!column)
8309                 {
8310                         Term_gotoxy(0, 6 + (grp_cur - grp_top));
8311                 }
8312                 else
8313                 {
8314                         Term_gotoxy(max + 3, 6 + (feat_cur - feat_top));
8315                 }
8316         
8317                 ch = inkey();
8318
8319                 /* Do visual mode command if needed */
8320                 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;
8321
8322                 switch (ch)
8323                 {
8324                         case ESCAPE:
8325                         {
8326                                 flag = TRUE;
8327                                 break;
8328                         }
8329
8330                         default:
8331                         {
8332                                 /* Move the cursor */
8333                                 browser_cursor(ch, &column, &grp_cur, grp_cnt, &feat_cur, feat_cnt);
8334                                 break;
8335                         }
8336                 }
8337         }
8338
8339         /* Prompt */
8340         if (!grp_cnt) msg_print("No features known.");
8341
8342         /* Free the "feat_idx" array */
8343         C_KILL(feat_idx, max_f_idx, int);
8344 }
8345
8346
8347 /*
8348  * List wanted monsters
8349  */
8350 static void do_cmd_knowledge_kubi(void)
8351 {
8352         int i;
8353         FILE *fff;
8354         
8355         char file_name[1024];
8356         
8357         
8358         /* Open a new file */
8359         fff = my_fopen_temp(file_name, 1024);
8360         if (!fff) {
8361 #ifdef JP
8362             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8363 #else
8364             msg_format("Failed to create temporary file %s.", file_name);
8365 #endif
8366             msg_print(NULL);
8367             return;
8368         }
8369         
8370         if (fff)
8371         {
8372 #ifdef JP
8373                 fprintf(fff, "º£Æü¤Î¥¿¡¼¥²¥Ã¥È : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "ÉÔÌÀ"));
8374                 fprintf(fff, "\n");
8375                 fprintf(fff, "¾Þ¶â¼ó¥ê¥¹¥È\n");
8376 #else
8377                 fprintf(fff, "Today target : %s\n", (p_ptr->today_mon ? r_name + r_info[p_ptr->today_mon].name : "unknown"));
8378                 fprintf(fff, "\n");
8379                 fprintf(fff, "List of wanted monsters\n");
8380 #endif
8381                 for (i = 0; i < MAX_KUBI; i++)
8382                 {
8383                         fprintf(fff,"%-40s ---- ",r_name + r_info[(kubi_r_idx[i] > 10000 ? kubi_r_idx[i] - 10000 : kubi_r_idx[i])].name);
8384                         if (kubi_r_idx[i] > 10000)
8385 #ifdef JP
8386                                 fprintf(fff, "ºÑ\n");
8387 #else
8388                                 fprintf(fff, "done\n");
8389 #endif
8390                         else
8391                                 fprintf(fff, "$%d\n", 300 * (r_info[kubi_r_idx[i]].level + 1));
8392                 }
8393         }
8394         
8395         /* Close the file */
8396         my_fclose(fff);
8397         
8398         /* Display the file contents */
8399 #ifdef JP
8400         show_file(TRUE, file_name, "¾Þ¶â¼ó¤Î°ìÍ÷", 0, 0);
8401 #else
8402         show_file(TRUE, file_name, "Wanted monsters", 0, 0);
8403 #endif
8404
8405         
8406         /* Remove the file */
8407         fd_kill(file_name);
8408 }
8409
8410 /*
8411  * List virtues & status
8412  */
8413 static void do_cmd_knowledge_virtues(void)
8414 {
8415         FILE *fff;
8416         
8417         char file_name[1024];
8418         
8419         
8420         /* Open a new file */
8421         fff = my_fopen_temp(file_name, 1024);
8422         if (!fff) {
8423 #ifdef JP
8424             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8425 #else
8426             msg_format("Failed to create temporary file %s.", file_name);
8427 #endif
8428             msg_print(NULL);
8429             return;
8430         }
8431         
8432         if (fff)
8433         {
8434 #ifdef JP
8435                 fprintf(fff, "¸½ºß¤Î°À­ : %s\n\n", your_alignment());
8436 #else
8437                 fprintf(fff, "Your alighnment : %s\n\n", your_alignment());
8438 #endif
8439                 dump_virtues(fff);
8440         }
8441         
8442         /* Close the file */
8443         my_fclose(fff);
8444         
8445         /* Display the file contents */
8446 #ifdef JP
8447         show_file(TRUE, file_name, "Ȭ¤Ä¤ÎÆÁ", 0, 0);
8448 #else
8449         show_file(TRUE, file_name, "Virtues", 0, 0);
8450 #endif
8451
8452         
8453         /* Remove the file */
8454         fd_kill(file_name);
8455 }
8456
8457 /*
8458 * Dungeon
8459 *
8460 */
8461 static void do_cmd_knowledge_dungeon(void)
8462 {
8463         FILE *fff;
8464         
8465         char file_name[1024];
8466         int i;
8467         
8468         
8469         /* Open a new file */
8470         fff = my_fopen_temp(file_name, 1024);
8471         if (!fff) {
8472 #ifdef JP
8473             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8474 #else
8475             msg_format("Failed to create temporary file %s.", file_name);
8476 #endif
8477             msg_print(NULL);
8478             return;
8479         }
8480         
8481         if (fff)
8482         {
8483                 for (i = 1; i < max_d_idx; i++)
8484                 {
8485                         bool seiha = FALSE;
8486
8487                         if (!d_info[i].maxdepth) continue;
8488                         if (!max_dlv[i]) continue;
8489                         if (d_info[i].final_guardian)
8490                         {
8491                                 if (!r_info[d_info[i].final_guardian].max_num) seiha = TRUE;
8492                         }
8493                         else if (max_dlv[i] == d_info[i].maxdepth) seiha = TRUE;
8494 #ifdef JP
8495                         fprintf(fff,"%c%-12s :  %3d ³¬\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
8496 #else
8497                         fprintf(fff,"%c%-16s :  level %3d\n", seiha ? '!' : ' ', d_name + d_info[i].name, max_dlv[i]);
8498 #endif
8499                 }
8500         }
8501         
8502         /* Close the file */
8503         my_fclose(fff);
8504         
8505         /* Display the file contents */
8506 #ifdef JP
8507         show_file(TRUE, file_name, "º£¤Þ¤Ç¤ËÆþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó", 0, 0);
8508 #else
8509         show_file(TRUE, file_name, "Dungeon", 0, 0);
8510 #endif
8511
8512         
8513         /* Remove the file */
8514         fd_kill(file_name);
8515 }
8516
8517 /*
8518 * List virtues & status
8519 *
8520 */
8521 static void do_cmd_knowledge_stat(void)
8522 {
8523         FILE *fff;
8524         
8525         char file_name[1024];
8526         int percent, v_nr;
8527         
8528         /* Open a new file */
8529         fff = my_fopen_temp(file_name, 1024);
8530         if (!fff) {
8531 #ifdef JP
8532             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8533 #else
8534             msg_format("Failed to create temporary file %s.", file_name);
8535 #endif
8536             msg_print(NULL);
8537             return;
8538         }
8539         
8540         if (fff)
8541         {
8542                 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
8543                         (2 * p_ptr->hitdie +
8544                         ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
8545
8546 #ifdef JP
8547                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : %d/100\n\n", percent);
8548                 else fprintf(fff, "¸½ºß¤ÎÂÎÎÏ¥é¥ó¥¯ : ???\n\n");
8549                 fprintf(fff, "ǽÎϤκÇÂçÃÍ\n\n");
8550 #else
8551                 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
8552                 else fprintf(fff, "Your current Life Rating is ???.\n\n");
8553                 fprintf(fff, "Limits of maximum stats\n\n");
8554 #endif
8555                 for (v_nr = 0; v_nr < 6; v_nr++)
8556                 {
8557                         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);
8558                         else fprintf(fff, "%s ???\n", stat_names[v_nr]);
8559                 }
8560         }
8561
8562         dump_yourself(fff);
8563
8564         /* Close the file */
8565         my_fclose(fff);
8566         
8567         /* Display the file contents */
8568 #ifdef JP
8569         show_file(TRUE, file_name, "¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó", 0, 0);
8570 #else
8571         show_file(TRUE, file_name, "HP-rate & Max stat", 0, 0);
8572 #endif
8573
8574         
8575         /* Remove the file */
8576         fd_kill(file_name);
8577 }
8578
8579
8580 /*
8581  * Print quest status of all active quests
8582  */
8583 static void do_cmd_knowledge_quests(void)
8584 {
8585         FILE *fff;
8586         char file_name[1024];
8587         char tmp_str[120];
8588         char rand_tmp_str[120] = "\0";
8589         char name[80];
8590         monster_race *r_ptr;
8591         int i;
8592         int rand_level = 100;
8593         int total = 0;
8594
8595         /* Open a new file */
8596         fff = my_fopen_temp(file_name, 1024);
8597         if (!fff) {
8598 #ifdef JP
8599             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8600 #else
8601             msg_format("Failed to create temporary file %s.", file_name);
8602 #endif
8603             msg_print(NULL);
8604             return;
8605         }
8606
8607 #ifdef JP
8608         fprintf(fff, "¡Ô¿ë¹ÔÃæ¤Î¥¯¥¨¥¹¥È¡Õ\n");
8609 #else
8610         fprintf(fff, "< Current Quest >\n");
8611 #endif
8612
8613         for (i = 1; i < max_quests; i++)
8614         {
8615                 if (quest[i].status == QUEST_STATUS_TAKEN || quest[i].status == QUEST_STATUS_COMPLETED)
8616                 {
8617                         int old_quest;
8618                         int j;
8619
8620                         /* Clear the text */
8621                         for (j = 0; j < 10; j++)
8622                         {
8623                                 quest_text[j][0] = '\0';
8624                         }
8625
8626                         quest_text_line = 0;
8627
8628                         /* Set the quest number temporary */
8629                         old_quest = p_ptr->inside_quest;
8630                         p_ptr->inside_quest = i;
8631
8632                         /* Get the quest text */
8633                         init_flags = INIT_SHOW_TEXT;
8634
8635                         process_dungeon_file("q_info.txt", 0, 0, 0, 0);
8636
8637                         /* Reset the old quest number */
8638                         p_ptr->inside_quest = old_quest;
8639
8640                         /* No info from "silent" quests */
8641                         if (quest[i].flags & QUEST_FLAG_SILENT) continue;
8642
8643                         total++;
8644
8645                         if (quest[i].type != QUEST_TYPE_RANDOM)
8646                         {
8647                                 char note[80] = "\0";
8648
8649                                 if (quest[i].status == QUEST_STATUS_TAKEN)
8650                                 {
8651                                         if (quest[i].type == QUEST_TYPE_KILL_LEVEL || quest[i].type == QUEST_TYPE_KILL_ANY_LEVEL)
8652                                         {
8653                                                 r_ptr = &r_info[quest[i].r_idx];
8654                                                 strcpy(name, r_name + r_ptr->name);
8655                                                 if (quest[i].max_num > 1)
8656                                                 {
8657 #ifdef JP
8658                                                         sprintf(note," - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",quest[i].max_num, name, quest[i].max_num-quest[i].cur_num);
8659 #else
8660                                                         plural_aux(name);
8661                                                         sprintf(note," - kill %d %s, have killed %d.",quest[i].max_num, name, quest[i].cur_num);
8662 #endif
8663                                                 }
8664                                                 else
8665 #ifdef JP
8666                                                         sprintf(note," - %s¤òÅݤ¹¡£",name);
8667 #else
8668                                                         sprintf(note," - kill %s.",name);
8669 #endif
8670                                         }
8671                                         else if (quest[i].type == QUEST_TYPE_KILL_NUMBER)
8672                                         {
8673 #ifdef JP
8674                                                 sprintf(note," - %d ÂΤΥâ¥ó¥¹¥¿¡¼¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)",quest[i].max_num, quest[i].max_num-quest[i].cur_num);
8675 #else
8676                                                 sprintf(note," - Kill %d monsters, have killed %d.",quest[i].max_num, quest[i].cur_num);
8677 #endif
8678                                         }
8679                                         else if (quest[i].type == QUEST_TYPE_FIND_ARTIFACT)
8680                                         {
8681                                                 strcpy(name, a_name + a_info[quest[i].k_idx].name);
8682 #ifdef JP
8683                                                 sprintf(note," - %s¤ò¸«¤Ä¤±½Ð¤¹¡£", name);
8684 #else
8685                                                 sprintf(note," - Find out %s.", name);
8686 #endif
8687                                         }
8688                                         else if (quest[i].type == QUEST_TYPE_FIND_EXIT)
8689 #ifdef JP
8690                                                 sprintf(note," - Ãµº÷¤¹¤ë¡£");
8691 #else
8692                                                 sprintf(note," - Search.");
8693 #endif
8694                                         else if (quest[i].type == QUEST_TYPE_KILL_ALL)
8695 #ifdef JP
8696                                                 sprintf(note," - Á´¤Æ¤Î¥â¥ó¥¹¥¿¡¼¤òÅݤ¹¡£");
8697 #else
8698                                                 sprintf(note," - Kill all monsters.");
8699 #endif
8700                                 }
8701
8702                                 /* Print the quest info */
8703 #ifdef JP
8704                                 sprintf(tmp_str, "%s (´í¸±ÅÙ:%d³¬ÁêÅö)%s\n",
8705                                         quest[i].name, quest[i].level, note);
8706 #else
8707                                 sprintf(tmp_str, "%s (Danger level: %d)%s\n",
8708                                         quest[i].name, quest[i].level, note);
8709 #endif
8710
8711                                 fprintf(fff, tmp_str);
8712
8713                                 if (quest[i].status == QUEST_STATUS_COMPLETED)
8714                                 {
8715 #ifdef JP
8716                                         sprintf(tmp_str, "  ¥¯¥¨¥¹¥ÈãÀ® - ¤Þ¤ÀÊó½·¤ò¼õ¤±¤È¤Ã¤Æ¤Ê¤¤¡£\n");
8717 #else
8718                                         sprintf(tmp_str, "  Quest Completed - Unrewarded\n");
8719 #endif
8720
8721                                         fprintf(fff, tmp_str);
8722                                 }
8723                                 else
8724                                 {
8725                                         j = 0;
8726
8727                                         while (quest_text[j][0] && j < 10)
8728                                         {
8729                                                 fprintf(fff, "  %s\n", quest_text[j]);
8730                                                 j++;
8731                                         }
8732                                 }
8733                         }
8734                         else if ((quest[i].type == QUEST_TYPE_RANDOM) &&
8735                                  (quest[i].level < rand_level))
8736                         {
8737                                 /* New random */
8738                                 rand_level = quest[i].level;
8739
8740                                 if (max_dlv[DUNGEON_ANGBAND] >= rand_level)
8741                                 {
8742                                         /* Print the quest info */
8743                                         r_ptr = &r_info[quest[i].r_idx];
8744                                         strcpy(name, r_name + r_ptr->name);
8745
8746                                         if (quest[i].max_num > 1)
8747                                         {
8748 #ifdef JP
8749                                                 sprintf(rand_tmp_str,"%s (%d ³¬) - %d ÂΤÎ%s¤òÅݤ¹¡£(¤¢¤È %d ÂÎ)\n",
8750                                                         quest[i].name, quest[i].level,
8751                                                         quest[i].max_num, name, quest[i].max_num-quest[i].cur_num);
8752 #else
8753                                                 plural_aux(name);
8754
8755                                                 sprintf(rand_tmp_str,"%s (Dungeon level: %d)\n  Kill %d %s, have killed %d.\n",
8756                                                         quest[i].name, quest[i].level,
8757                                                         quest[i].max_num, name, quest[i].cur_num);
8758 #endif
8759                                         }
8760                                         else
8761                                         {
8762 #ifdef JP
8763                                                 sprintf(rand_tmp_str,"%s (%d ³¬) - %s¤òÅݤ¹¡£\n",
8764                                                         quest[i].name, quest[i].level, name);
8765 #else
8766                                                 sprintf(rand_tmp_str,"%s (Dungeon level: %d)\n  Kill %s.\n",
8767                                                         quest[i].name, quest[i].level, name);
8768 #endif
8769                                         }
8770                                 }
8771                         }
8772                 }
8773         }
8774
8775         /* Print the current random quest  */
8776         if (rand_tmp_str[0]) fprintf(fff, rand_tmp_str);
8777
8778 #ifdef JP
8779         if (!total) fprintf(fff, "¤Ê¤·\n");
8780 #else
8781         if (!total) fprintf(fff, "Nothing.\n");
8782 #endif
8783
8784 #ifdef JP
8785         fprintf(fff, "\n¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
8786 #else
8787         fprintf(fff, "\n< Completed Quest >\n");
8788 #endif
8789         total = 0;
8790         for (i = 1; i < max_quests; i++)
8791         {
8792                 if (quest[i].status == QUEST_STATUS_FINISHED)
8793                 {
8794                         if (i < MIN_RANDOM_QUEST)
8795                         {
8796                                 int old_quest;
8797
8798                                 /* Set the quest number temporary */
8799                                 old_quest = p_ptr->inside_quest;
8800                                 p_ptr->inside_quest = i;
8801
8802                                 /* Get the quest */
8803                                 init_flags = INIT_ASSIGN;
8804
8805                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
8806
8807                                 /* Reset the old quest number */
8808                                 p_ptr->inside_quest = old_quest;
8809
8810                                 /* No info from "silent" quests */
8811                                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
8812                         }
8813
8814                         total++;
8815
8816                         if ((i >= MIN_RANDOM_QUEST) && quest[i].r_idx)
8817                         {
8818                                 /* Print the quest info */
8819
8820                                 if (quest[i].complev == 0)
8821                                 {
8822                                         sprintf(tmp_str, 
8823 #ifdef JP
8824                                                 "%s (%d³¬) - ÉÔÀᄀ\n",
8825 #else
8826                                                 "%s (Dungeon level: %d) - (Cancelled)\n",
8827 #endif
8828                                                 r_name+r_info[quest[i].r_idx].name,
8829                                                 quest[i].level);
8830                                 }
8831                                 else
8832                                 {
8833                                         sprintf(tmp_str, 
8834 #ifdef JP
8835                                                 "%s (%d³¬) - ¥ì¥Ù¥ë%d\n",
8836 #else
8837                                                 "%s (Dungeon level: %d) - level %d\n",
8838 #endif
8839                                                 r_name+r_info[quest[i].r_idx].name,
8840                                                 quest[i].level,
8841                                                 quest[i].complev);
8842                                 }
8843                         }
8844                         else
8845                         {
8846                                 /* Print the quest info */
8847 #ifdef JP
8848                                 sprintf(tmp_str, "%s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
8849                                         quest[i].name, quest[i].level, quest[i].complev);
8850 #else
8851                                 sprintf(tmp_str, "%s (Danger level: %d) - level %d\n",
8852                                         quest[i].name, quest[i].level, quest[i].complev);
8853 #endif
8854                         }
8855
8856                         fprintf(fff, tmp_str);
8857                 }
8858         }
8859 #ifdef JP
8860         if (!total) fprintf(fff, "¤Ê¤·\n");
8861 #else
8862         if (!total) fprintf(fff, "Nothing.\n");
8863 #endif
8864
8865 #ifdef JP
8866         fprintf(fff, "\n¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
8867 #else
8868         fprintf(fff, "\n< Failed Quest >\n");
8869 #endif
8870         total = 0;
8871         for (i = 1; i < max_quests; i++)
8872         {
8873                 if ((quest[i].status == QUEST_STATUS_FAILED_DONE) || (quest[i].status == QUEST_STATUS_FAILED))
8874                 {
8875                         if (i < MIN_RANDOM_QUEST)
8876                         {
8877                                 int old_quest;
8878
8879                                 /* Set the quest number temporary */
8880                                 old_quest = p_ptr->inside_quest;
8881                                 p_ptr->inside_quest = i;
8882
8883                                 /* Get the quest text */
8884                                 init_flags = INIT_ASSIGN;
8885
8886                                 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
8887
8888                                 /* Reset the old quest number */
8889                                 p_ptr->inside_quest = old_quest;
8890
8891                                 /* No info from "silent" quests */
8892                                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
8893                         }
8894
8895                         total++;
8896
8897                         if ((i >= MIN_RANDOM_QUEST) && quest[i].r_idx)
8898                         {
8899                                 /* Print the quest info */
8900 #ifdef JP
8901                                 sprintf(tmp_str, "%s (%d³¬) - ¥ì¥Ù¥ë%d\n",
8902                                         r_name+r_info[quest[i].r_idx].name, quest[i].level, quest[i].complev);
8903 #else
8904                                 sprintf(tmp_str, "%s (Dungeon level: %d) - level %d\n",
8905                                         r_name+r_info[quest[i].r_idx].name, quest[i].level, quest[i].complev);
8906 #endif
8907                         }
8908                         else
8909                         {
8910                                 /* Print the quest info */
8911 #ifdef JP
8912                                 sprintf(tmp_str, "%s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
8913                                         quest[i].name, quest[i].level, quest[i].complev);
8914 #else
8915                                 sprintf(tmp_str, "%s (Danger level: %d) - level %d\n",
8916                                         quest[i].name, quest[i].level, quest[i].complev);
8917 #endif
8918                         }
8919                         fprintf(fff, tmp_str);
8920                 }
8921         }
8922 #ifdef JP
8923         if (!total) fprintf(fff, "¤Ê¤·\n");
8924 #else
8925         if (!total) fprintf(fff, "Nothing.\n");
8926 #endif
8927
8928         if (p_ptr->wizard) {
8929 #ifdef JP
8930         fprintf(fff, "\n¡Ô»Ä¤ê¤Î¥é¥ó¥À¥à¥¯¥¨¥¹¥È¡Õ\n");
8931 #else
8932         fprintf(fff, "\n< Remaining Random Quest >\n");
8933 #endif
8934         total = 0;
8935         for (i = 1; i < max_quests; i++)
8936         {
8937                 /* No info from "silent" quests */
8938                 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
8939
8940                 if ((quest[i].type == QUEST_TYPE_RANDOM) && (quest[i].status == QUEST_STATUS_TAKEN))
8941                 {
8942                         total++;
8943
8944                         /* Print the quest info */
8945 #ifdef JP
8946                         sprintf(tmp_str, "%s (%d³¬, %s)\n",
8947                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
8948 #else
8949                         sprintf(tmp_str, "%s (%d, %s)\n",
8950                                 quest[i].name, quest[i].level, r_name+r_info[quest[i].r_idx].name);
8951 #endif
8952                         fprintf(fff, tmp_str);
8953                 }
8954         }
8955 #ifdef JP
8956         if (!total) fprintf(fff, "¤Ê¤·\n");
8957 #else
8958         if (!total) fprintf(fff, "Nothing.\n");
8959 #endif
8960         }       
8961
8962         /* Close the file */
8963         my_fclose(fff);
8964
8965         /* Display the file contents */
8966 #ifdef JP
8967         show_file(TRUE, file_name, "¥¯¥¨¥¹¥ÈãÀ®¾õ¶·", 0, 0);
8968 #else
8969         show_file(TRUE, file_name, "Quest status", 0, 0);
8970 #endif
8971
8972
8973         /* Remove the file */
8974         fd_kill(file_name);
8975 }
8976
8977
8978
8979 /*
8980  * List my home
8981  */
8982 static void do_cmd_knowledge_home(void)
8983 {
8984         FILE *fff;
8985         
8986         int i, x;
8987         char file_name[1024];
8988         store_type  *st_ptr;
8989         char o_name[MAX_NLEN];
8990         cptr            paren = ")";
8991
8992         process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
8993
8994         /* Open a new file */
8995         fff = my_fopen_temp(file_name, 1024);
8996         if (!fff) {
8997 #ifdef JP
8998             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
8999 #else
9000             msg_format("Failed to create temporary file %s.", file_name);
9001 #endif
9002             msg_print(NULL);
9003             return;
9004         }
9005         
9006         if (fff)
9007         {
9008                 /* Print all homes in the different towns */
9009                 st_ptr = &town[1].store[STORE_HOME];
9010
9011                 /* Home -- if anything there */
9012                 if (st_ptr->stock_num)
9013                 {
9014                         /* Header with name of the town */
9015 #ifdef JP
9016                         fprintf(fff, "  [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
9017 #else
9018                         fprintf(fff, "  [Home Inventory]\n");
9019 #endif
9020                                 x = 1;
9021
9022                         /* Dump all available items */
9023                         for (i = 0; i < st_ptr->stock_num; i++)
9024                         {
9025 #ifdef JP
9026                                 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
9027                                 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
9028                                 if (strlen(o_name) <= 80-3)
9029                                 {
9030                                         fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9031                                 }
9032                                 else
9033                                 {
9034                                         int n;
9035                                         char *t;
9036                                         for (n = 0, t = o_name; n < 80-3; n++, t++)
9037                                                 if(iskanji(*t)) {t++; n++;}
9038                                         if (n == 81-3) n = 79-3; /* ºÇ¸å¤¬´Á»úȾʬ */
9039
9040                                         fprintf(fff, "%c%s %.*s\n", I2A(i%12), paren, n, o_name);
9041                                         fprintf(fff, "   %.77s\n", o_name+n);
9042                                 }
9043 #else
9044                                 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
9045                                 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
9046 #endif
9047
9048                         }
9049
9050                         /* Add an empty line */
9051                         fprintf(fff, "\n\n");
9052                 }
9053         }
9054         
9055         /* Close the file */
9056         my_fclose(fff);
9057         
9058         /* Display the file contents */
9059 #ifdef JP
9060         show_file(TRUE, file_name, "²æ¤¬²È¤Î¥¢¥¤¥Æ¥à", 0, 0);
9061 #else
9062         show_file(TRUE, file_name, "Home Inventory", 0, 0);
9063 #endif
9064
9065         
9066         /* Remove the file */
9067         fd_kill(file_name);
9068 }
9069
9070
9071 /*
9072  * Check the status of "autopick"
9073  */
9074 static void do_cmd_knowledge_autopick(void)
9075 {
9076         int k;
9077         FILE *fff;
9078         char file_name[1024];
9079
9080         /* Open a new file */
9081         fff = my_fopen_temp(file_name, 1024);
9082
9083         if (!fff)
9084         {
9085 #ifdef JP
9086             msg_format("°ì»þ¥Õ¥¡¥¤¥ë %s ¤òºîÀ®¤Ç¤­¤Þ¤»¤ó¤Ç¤·¤¿¡£", file_name);
9087 #else
9088             msg_format("Failed to create temporary file %s.", file_name);
9089 #endif
9090             msg_print(NULL);
9091             return;
9092         }
9093
9094         if (!max_autopick)
9095         {
9096 #ifdef JP
9097             fprintf(fff, "¼«Æ°Ç˲õ/½¦¤¤¤Ë¤Ï²¿¤âÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£");
9098 #else
9099             fprintf(fff, "No preference for auto picker/destroyer.");
9100 #endif
9101         }
9102         else
9103         {
9104 #ifdef JP
9105             fprintf(fff, "   ¼«Æ°½¦¤¤/Ç˲õ¤Ë¤Ï¸½ºß %d¹ÔÅÐÏ¿¤µ¤ì¤Æ¤¤¤Þ¤¹¡£\n\n", max_autopick);
9106 #else
9107             fprintf(fff, "   There are %d registered lines for auto picker/destroyer.\n\n", max_autopick);
9108 #endif
9109         }
9110
9111         for (k = 0; k < max_autopick; k++)
9112         {
9113                 cptr tmp;
9114                 byte act = autopick_list[k].action;
9115                 if (act & DONT_AUTOPICK)
9116                 {
9117 #ifdef JP
9118                         tmp = "ÊüÃÖ";
9119 #else
9120                         tmp = "Leave";
9121 #endif
9122                 }
9123                 else if (act & DO_AUTODESTROY)
9124                 {
9125 #ifdef JP
9126                         tmp = "Ç˲õ";
9127 #else
9128                         tmp = "Destroy";
9129 #endif
9130                 }
9131                 else if (act & DO_AUTOPICK)
9132                 {
9133 #ifdef JP
9134                         tmp = "½¦¤¦";
9135 #else
9136                         tmp = "Pickup";
9137 #endif
9138                 }
9139                 else /* if (act & DO_QUERY_AUTOPICK) */ /* Obvious */
9140                 {
9141 #ifdef JP
9142                         tmp = "³Îǧ";
9143 #else
9144                         tmp = "Query";
9145 #endif
9146                 }
9147
9148                 if (act & DO_DISPLAY)
9149                         fprintf(fff, "%11s", format("[%s]", tmp));
9150                 else
9151                         fprintf(fff, "%11s", format("(%s)", tmp));
9152
9153                 tmp = autopick_line_from_entry(&autopick_list[k]);
9154                 fprintf(fff, " %s", tmp);
9155                 string_free(tmp);
9156                 fprintf(fff, "\n");
9157         }
9158         /* Close the file */
9159         my_fclose(fff);
9160         /* Display the file contents */
9161 #ifdef JP
9162         show_file(TRUE, file_name, "¼«Æ°½¦¤¤/Ç˲õ ÀßÄê¥ê¥¹¥È", 0, 0);
9163 #else
9164         show_file(TRUE, file_name, "Auto-picker/Destroyer", 0, 0);
9165 #endif
9166
9167         /* Remove the file */
9168         fd_kill(file_name);
9169 }
9170
9171
9172 /*
9173  * Interact with "knowledge"
9174  */
9175 void do_cmd_knowledge(void)
9176 {
9177         int i,p=0;
9178         /* File type is "TEXT" */
9179         FILE_TYPE(FILE_TYPE_TEXT);
9180         /* Save the screen */
9181         screen_save();
9182         /* Interact until done */
9183         while (1)
9184         {
9185                 /* Clear screen */
9186                 Term_clear();
9187                 /* Ask for a choice */
9188 #ifdef JP
9189                 prt(format("%d/2 ¥Ú¡¼¥¸", (p+1)), 2, 65);
9190                 prt("¸½ºß¤ÎÃ챤ò³Îǧ¤¹¤ë", 3, 0);
9191 #else
9192                 prt(format("page %d/2", (p+1)), 2, 65);
9193                 prt("Display current knowledge", 3, 0);
9194 #endif
9195
9196                 /* Give some choices */
9197 #ifdef JP
9198                 if (p == 0) {
9199                         prt("(1) ´ûÃΤÎÅÁÀâ¤Î¥¢¥¤¥Æ¥à                 ¤Î°ìÍ÷", 6, 5);
9200                         prt("(2) ´ûÃΤΥ¢¥¤¥Æ¥à                       ¤Î°ìÍ÷", 7, 5);
9201                         prt("(3) ´ûÃΤÎÀ¸¤­¤Æ¤¤¤ë¥æ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼ ¤Î°ìÍ÷", 8, 5);
9202                         prt("(4) ´ûÃΤΥâ¥ó¥¹¥¿¡¼                     ¤Î°ìÍ÷", 9, 5);
9203                         prt("(5) Åݤ·¤¿Å¨¤Î¿ô                         ¤Î°ìÍ÷", 10, 5);
9204                         prt("(6) ¾Þ¶â¼ó                               ¤Î°ìÍ÷", 11, 5);
9205                         prt("(7) ¸½ºß¤Î¥Ú¥Ã¥È                         ¤Î°ìÍ÷", 12, 5);
9206                         prt("(8) ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à                     ¤Î°ìÍ÷", 13, 5);
9207                         prt("(9) *´ÕÄê*ºÑ¤ßÁõÈ÷¤ÎÂÑÀ­                 ¤Î°ìÍ÷", 14, 5);
9208                         prt("(0) ÃÏ·Á¤Îɽ¼¨Ê¸»ú/¥¿¥¤¥ë                ¤Î°ìÍ÷", 15, 5);
9209                 } else {
9210                         prt("(a) ¼«Ê¬¤Ë´Ø¤¹¤ë¾ðÊó                     ¤Î°ìÍ÷", 6, 5);
9211                         prt("(b) ÆÍÁ³ÊÑ°Û                             ¤Î°ìÍ÷", 7, 5);
9212                         prt("(c) Éð´ï¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 8, 5);
9213                         prt("(d) ËâË¡¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 9, 5);
9214                         prt("(e) µ»Ç½¤Î·Ð¸³ÃÍ                         ¤Î°ìÍ÷", 10, 5);
9215                         prt("(f) ¥×¥ì¥¤¥ä¡¼¤ÎÆÁ                       ¤Î°ìÍ÷", 11, 5);
9216                         prt("(g) Æþ¤Ã¤¿¥À¥ó¥¸¥ç¥ó                     ¤Î°ìÍ÷", 12, 5);
9217                         prt("(h) ¼Â¹ÔÃæ¤Î¥¯¥¨¥¹¥È                     ¤Î°ìÍ÷", 13, 5);
9218                         prt("(i) ¸½ºß¤Î¼«Æ°½¦¤¤/Ç˲õÀßÄê              ¤Î°ìÍ÷", 14, 5);
9219                 }
9220 #else
9221                 if (p == 0) {
9222                         prt("(1) Display known artifacts", 6, 5);
9223                         prt("(2) Display known objects", 7, 5);
9224                         prt("(3) Display remaining uniques", 8, 5);
9225                         prt("(4) Display known monster", 9, 5);
9226                         prt("(5) Display kill count", 10, 5);
9227                         prt("(6) Display wanted monsters", 11, 5);
9228                         prt("(7) Display current pets", 12, 5);
9229                         prt("(8) Display home inventory", 13, 5);
9230                         prt("(9) Display *identified* equip.", 14, 5);
9231                         prt("(0) Display terrain symbols.", 15, 5);
9232                 } else {
9233                         prt("(a) Display about yourself", 6, 5);
9234                         prt("(b) Display mutations", 7, 5);
9235                         prt("(c) Display weapon proficiency", 8, 5);
9236                         prt("(d) Display spell proficiency", 9, 5);
9237                         prt("(e) Display misc. proficiency", 10, 5);
9238                         prt("(f) Display virtues", 11, 5);
9239                         prt("(g) Display dungeons", 12, 5);
9240                         prt("(h) Display current quests", 13, 5);
9241                         prt("(i) Display auto pick/destroy", 14, 5);
9242                 }
9243 #endif
9244                 /* Prompt */
9245 #ifdef JP
9246                 prt("-³¤¯-", 17, 8);
9247                 prt("ESC) È´¤±¤ë", 21, 1);
9248                 prt("SPACE) ¼¡¥Ú¡¼¥¸", 21, 30);
9249                 /*prt("-) Á°¥Ú¡¼¥¸", 21, 60);*/
9250                 prt("¥³¥Þ¥ó¥É:", 20, 0);
9251 #else
9252                 prt("-more-", 17, 8);
9253                 prt("ESC) Exit menu", 21, 1);
9254                 prt("SPACE) Next page", 21, 30);
9255                 /*prt("-) Previous page", 21, 60);*/
9256                 prt("Command: ", 20, 0);
9257 #endif
9258
9259                 /* Prompt */
9260                 i = inkey();
9261                 /* Done */
9262                 if (i == ESCAPE) break;
9263                 switch (i)
9264                 {
9265                 case ' ': /* Page change */
9266                 case '-':
9267                         p = 1 - p;
9268                         break;
9269                 case '1': /* Artifacts */
9270                         do_cmd_knowledge_artifacts();
9271                         break;
9272                 case '2': /* Objects */
9273                         do_cmd_knowledge_objects();
9274                         break;
9275                 case '3': /* Uniques */
9276                         do_cmd_knowledge_uniques();
9277                         break;
9278                 case '4': /* Monsters */
9279                         do_cmd_knowledge_monsters();
9280                         break;
9281                 case '5': /* Kill count  */
9282                         do_cmd_knowledge_kill_count();
9283                         break;
9284                 case '6': /* wanted */
9285                         do_cmd_knowledge_kubi();
9286                         break;
9287                 case '7': /* Pets */
9288                         do_cmd_knowledge_pets();
9289                         break;
9290                 case '8': /* Home */
9291                         do_cmd_knowledge_home();
9292                         break;
9293                 case '9': /* Resist list */
9294                         do_cmd_knowledge_inven();
9295                         break;
9296                 case '0': /* Feature list */
9297                         do_cmd_knowledge_features();
9298                         break;
9299                 /* Next page */
9300                 case 'a': /* Max stat */
9301                         do_cmd_knowledge_stat();
9302                         break;
9303                 case 'b': /* Mutations */
9304                         do_cmd_knowledge_mutations();
9305                         break;
9306                 case 'c': /* weapon-exp */
9307                         do_cmd_knowledge_weapon_exp();
9308                         break;
9309                 case 'd': /* spell-exp */
9310                         do_cmd_knowledge_spell_exp();
9311                         break;
9312                 case 'e': /* skill-exp */
9313                         do_cmd_knowledge_skill_exp();
9314                         break;
9315                 case 'f': /* Virtues */
9316                         do_cmd_knowledge_virtues();
9317                         break;
9318                 case 'g': /* Dungeon */
9319                         do_cmd_knowledge_dungeon();
9320                         break;
9321                 case 'h': /* Quests */
9322                         do_cmd_knowledge_quests();
9323                         break;
9324                 case 'i': /* Autopick */
9325                         do_cmd_knowledge_autopick();
9326                         break;
9327                 default: /* Unknown option */
9328                         bell();
9329                 }
9330                 /* Flush messages */
9331                 msg_print(NULL);
9332         }
9333         /* Restore the screen */
9334         screen_load();
9335 }
9336
9337
9338 /*
9339  * Check on the status of an active quest
9340  */
9341 void do_cmd_checkquest(void)
9342 {
9343         /* File type is "TEXT" */
9344         FILE_TYPE(FILE_TYPE_TEXT);
9345
9346         /* Save the screen */
9347         screen_save();
9348
9349         /* Quest info */
9350         do_cmd_knowledge_quests();
9351
9352         /* Restore the screen */
9353         screen_load();
9354 }
9355
9356
9357 /*
9358  * Display the time and date
9359  */
9360 void do_cmd_time(void)
9361 {
9362         int day, hour, min, full, start, end, num;
9363         char desc[1024];
9364
9365         char buf[1024];
9366
9367         FILE *fff;
9368
9369         extract_day_hour_min(&day, &hour, &min);
9370
9371         full = hour * 100 + min;
9372
9373         start = 9999;
9374         end = -9999;
9375
9376         num = 0;
9377
9378 #ifdef JP
9379         strcpy(desc, "ÊѤʻþ¹ï¤À¡£");
9380 #else
9381         strcpy(desc, "It is a strange time.");
9382 #endif
9383
9384
9385         /* Message */
9386 #ifdef JP
9387         msg_format("%d ÆüÌÜ,»þ¹ï¤Ï%d:%02d %s¤Ç¤¹¡£",
9388                    day, (hour % 12 == 0) ? 12 : (hour % 12),
9389                    min, (hour < 12) ? "AM" : "PM");
9390 #else
9391         msg_format("This is day %d. The time is %d:%02d %s.",
9392                    day, (hour % 12 == 0) ? 12 : (hour % 12),
9393                    min, (hour < 12) ? "AM" : "PM");
9394 #endif
9395
9396
9397         /* Find the path */
9398         if (!randint0(10) || p_ptr->image)
9399         {
9400 #ifdef JP
9401                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun_j.txt");
9402 #else
9403                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timefun.txt");
9404 #endif
9405
9406         }
9407         else
9408         {
9409 #ifdef JP
9410                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm_j.txt");
9411 #else
9412                 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "timenorm.txt");
9413 #endif
9414
9415         }
9416
9417         /* Open this file */
9418         fff = my_fopen(buf, "rt");
9419
9420         /* Oops */
9421         if (!fff) return;
9422
9423         /* Find this time */
9424         while (!my_fgets(fff, buf, sizeof(buf)))
9425         {
9426                 /* Ignore comments */
9427                 if (!buf[0] || (buf[0] == '#')) continue;
9428
9429                 /* Ignore invalid lines */
9430                 if (buf[1] != ':') continue;
9431
9432                 /* Process 'Start' */
9433                 if (buf[0] == 'S')
9434                 {
9435                         /* Extract the starting time */
9436                         start = atoi(buf + 2);
9437
9438                         /* Assume valid for an hour */
9439                         end = start + 59;
9440
9441                         /* Next... */
9442                         continue;
9443                 }
9444
9445                 /* Process 'End' */
9446                 if (buf[0] == 'E')
9447                 {
9448                         /* Extract the ending time */
9449                         end = atoi(buf + 2);
9450
9451                         /* Next... */
9452                         continue;
9453                 }
9454
9455                 /* Ignore incorrect range */
9456                 if ((start > full) || (full > end)) continue;
9457
9458                 /* Process 'Description' */
9459                 if (buf[0] == 'D')
9460                 {
9461                         num++;
9462
9463                         /* Apply the randomizer */
9464                         if (!randint0(num)) strcpy(desc, buf + 2);
9465
9466                         /* Next... */
9467                         continue;
9468                 }
9469         }
9470
9471         /* Message */
9472         msg_print(desc);
9473
9474         /* Close the file */
9475         my_fclose(fff);
9476 }