OSDN Git Service

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