OSDN Git Service

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