OSDN Git Service

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