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