OSDN Git Service

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