OSDN Git Service

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