3 /* Purpose: code dealing with files (and death) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
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.
17 * You may or may not want to use the following "#undef".
19 /* #undef _POSIX_SAVED_IDS */
23 * Hack -- drop permissions
25 void safe_setuid_drop(void)
32 # ifdef SAFE_SETUID_POSIX
34 if (setuid(getuid()) != 0)
37 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
39 quit("setuid(): cannot set permissions correctly!");
43 if (setgid(getgid()) != 0)
46 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
48 quit("setgid(): cannot set permissions correctly!");
55 if (setreuid(geteuid(), getuid()) != 0)
58 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
60 quit("setreuid(): cannot set permissions correctly!");
64 if (setregid(getegid(), getgid()) != 0)
67 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
69 quit("setregid(): cannot set permissions correctly!");
84 * Hack -- grab permissions
86 void safe_setuid_grab(void)
93 # ifdef SAFE_SETUID_POSIX
95 if (setuid(player_euid) != 0)
98 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
100 quit("setuid(): cannot set permissions correctly!");
104 if (setgid(player_egid) != 0)
107 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
109 quit("setgid(): cannot set permissions correctly!");
116 if (setreuid(geteuid(), getuid()) != 0)
119 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
121 quit("setreuid(): cannot set permissions correctly!");
125 if (setregid(getegid(), getgid()) != 0)
128 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
130 quit("setregid(): cannot set permissions correctly!");
135 # endif /* SAFE_SETUID_POSIX */
137 # endif /* SAFE_SETUID */
145 * Extract the first few "tokens" from a buffer
147 * This function uses "colon" and "slash" as the delimeter characters.
149 * We never extract more than "num" tokens. The "last" token may include
150 * "delimeter" characters, allowing the buffer to include a "string" token.
152 * We save pointers to the tokens in "tokens", and return the number found.
154 * Hack -- Attempt to handle the 'c' character formalism
156 * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
158 * Hack -- We will always extract at least one token
160 s16b tokenize(char *buf, s16b num, char **tokens, int mode)
172 /* Scan the string */
175 /* Found a delimiter */
176 if ((*t == ':') || (*t == '/')) break;
178 /* Handle single quotes */
179 if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
184 /* Handle backslash */
187 /* Require a character */
193 /* Hack -- Require a close quote */
194 if (*t != '\'') *t = '\'';
197 /* Handle back-slash */
204 /* Nuke and advance */
222 /* A number with a name */
223 typedef struct named_num named_num;
227 cptr name; /* The name of this thing */
228 int num; /* A number associated with it */
232 /* Index of spell type names */
233 static named_num gf_desc[] =
235 {"GF_ELEC", GF_ELEC },
236 {"GF_POIS", GF_POIS },
237 {"GF_ACID", GF_ACID },
238 {"GF_COLD", GF_COLD },
239 {"GF_FIRE", GF_FIRE },
240 {"GF_PSY_SPEAR", GF_PSY_SPEAR },
241 {"GF_MISSILE", GF_MISSILE },
242 {"GF_ARROW", GF_ARROW },
243 {"GF_PLASMA", GF_PLASMA },
244 {"GF_WATER", GF_WATER },
245 {"GF_LITE", GF_LITE },
246 {"GF_DARK", GF_DARK },
247 {"GF_LITE_WEAK", GF_LITE_WEAK },
248 {"GF_DARK_WEAK", GF_DARK_WEAK },
249 {"GF_SHARDS", GF_SHARDS },
250 {"GF_SOUND", GF_SOUND },
251 {"GF_CONFUSION", GF_CONFUSION },
252 {"GF_FORCE", GF_FORCE },
253 {"GF_INERTIA", GF_INERTIA },
254 {"GF_MANA", GF_MANA },
255 {"GF_METEOR", GF_METEOR },
257 {"GF_CHAOS", GF_CHAOS },
258 {"GF_NETHER", GF_NETHER },
259 {"GF_DISENCHANT", GF_DISENCHANT },
260 {"GF_NEXUS", GF_NEXUS },
261 {"GF_TIME", GF_TIME },
262 {"GF_GRAVITY", GF_GRAVITY },
263 {"GF_KILL_WALL", GF_KILL_WALL },
264 {"GF_KILL_DOOR", GF_KILL_DOOR },
265 {"GF_KILL_TRAP", GF_KILL_TRAP },
266 {"GF_MAKE_WALL", GF_MAKE_WALL },
267 {"GF_MAKE_DOOR", GF_MAKE_DOOR },
268 {"GF_MAKE_TRAP", GF_MAKE_TRAP },
269 {"GF_MAKE_TREE", GF_MAKE_TREE },
270 {"GF_OLD_CLONE", GF_OLD_CLONE },
271 {"GF_OLD_POLY", GF_OLD_POLY },
272 {"GF_OLD_HEAL", GF_OLD_HEAL },
273 {"GF_OLD_SPEED", GF_OLD_SPEED },
274 {"GF_OLD_SLOW", GF_OLD_SLOW },
275 {"GF_OLD_CONF", GF_OLD_CONF },
276 {"GF_OLD_SLEEP", GF_OLD_SLEEP },
277 {"GF_OLD_DRAIN", GF_OLD_DRAIN },
278 {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD },
279 {"GF_AWAY_EVIL", GF_AWAY_EVIL },
280 {"GF_AWAY_ALL", GF_AWAY_ALL },
281 {"GF_TURN_UNDEAD", GF_TURN_UNDEAD },
282 {"GF_TURN_EVIL", GF_TURN_EVIL },
283 {"GF_TURN_ALL", GF_TURN_ALL },
284 {"GF_DISP_UNDEAD", GF_DISP_UNDEAD },
285 {"GF_DISP_EVIL", GF_DISP_EVIL },
286 {"GF_DISP_ALL", GF_DISP_ALL },
287 {"GF_DISP_DEMON", GF_DISP_DEMON },
288 {"GF_DISP_LIVING", GF_DISP_LIVING },
289 {"GF_ROCKET", GF_ROCKET },
290 {"GF_NUKE", GF_NUKE },
291 {"GF_MAKE_GLYPH", GF_MAKE_GLYPH },
292 {"GF_STASIS", GF_STASIS },
293 {"GF_STONE_WALL", GF_STONE_WALL },
294 {"GF_DEATH_RAY", GF_DEATH_RAY },
295 {"GF_STUN", GF_STUN },
296 {"GF_HOLY_FIRE", GF_HOLY_FIRE },
297 {"GF_HELL_FIRE", GF_HELL_FIRE },
298 {"GF_DISINTEGRATE", GF_DISINTEGRATE },
299 {"GF_CHARM", GF_CHARM },
300 {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD },
301 {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL },
303 {"GF_PSI_DRAIN", GF_PSI_DRAIN },
304 {"GF_TELEKINESIS", GF_TELEKINESIS },
305 {"GF_JAM_DOOR", GF_JAM_DOOR },
306 {"GF_DOMINATION", GF_DOMINATION },
307 {"GF_DISP_GOOD", GF_DISP_GOOD },
308 {"GF_DRAIN_MANA", GF_DRAIN_MANA },
309 {"GF_MIND_BLAST", GF_MIND_BLAST },
310 {"GF_BRAIN_SMASH", GF_BRAIN_SMASH },
311 {"GF_CAUSE_1", GF_CAUSE_1 },
312 {"GF_CAUSE_2", GF_CAUSE_2 },
313 {"GF_CAUSE_3", GF_CAUSE_3 },
314 {"GF_CAUSE_4", GF_CAUSE_4 },
315 {"GF_HAND_DOOM", GF_HAND_DOOM },
316 {"GF_CAPTURE", GF_CAPTURE },
317 {"GF_ANIM_DEAD", GF_ANIM_DEAD },
318 {"GF_CONTROL_LIVING", GF_CONTROL_LIVING },
319 {"GF_IDENTIFY", GF_IDENTIFY },
320 {"GF_ATTACK", GF_ATTACK },
321 {"GF_ENGETSU", GF_ENGETSU },
322 {"GF_GENOCIDE", GF_GENOCIDE },
323 {"GF_PHOTO", GF_PHOTO },
324 {"GF_CONTROL_DEMON", GF_CONTROL_DEMON },
325 {"GF_LAVA_FLOW", GF_LAVA_FLOW },
326 {"GF_BLOOD_CURSE", GF_BLOOD_CURSE },
327 {"GF_SEEKER", GF_SEEKER },
328 {"GF_SUPER_RAY", GF_SUPER_RAY },
329 {"GF_STAR_HEAL", GF_STAR_HEAL },
335 * Parse a sub-file of the "extra info" (format shown below)
337 * Each "action" line has an "action symbol" in the first column,
338 * followed by a colon, followed by some command specific info,
339 * usually in the form of "tokens" separated by colons or slashes.
341 * Blank lines, lines starting with white space, and lines starting
342 * with pound signs ("#") are ignored (as comments).
344 * Note the use of "tokenize()" to allow the use of both colons and
345 * slashes as delimeters, while still allowing final tokens which
346 * may contain any characters including "delimiters".
348 * Note the use of "strtol()" to allow all "integers" to be encoded
349 * in decimal, hexidecimal, or octal form.
351 * Note that "monster zero" is used for the "player" attr/char, "object
352 * zero" will be used for the "stack" attr/char, and "feature zero" is
353 * used for the "nothing" attr/char.
355 * Parse another file recursively, see below for details
358 * Specify the attr/char values for "monsters" by race index
361 * Specify the attr/char values for "objects" by kind index
364 * Specify the attr/char values for "features" by feature index
367 * Specify the attr/char values for unaware "objects" by kind tval
370 * Specify the attr/char values for inventory "objects" by kind tval
373 * Define a macro action, given an encoded macro action
376 * Create a normal macro, given an encoded macro trigger
379 * Create a command macro, given an encoded macro trigger
382 * Create a keyset mapping
383 * S:<key>:<key>:<dir>
385 * Turn an option off, given its name
388 * Turn an option on, given its name
391 * Specify visual information, given an index, and some data
392 * V:<num>:<kv>:<rv>:<gv>:<bv>
394 * Specify the set of colors to use when drawing a zapped spell
397 * Specify a macro trigger template and macro trigger names.
398 * T:<template>:<modifier chr>:<modifier name1>:<modifier name2>:...
399 * T:<trigger>:<keycode>:<shift-keycode>
403 errr process_pref_file_command(char *buf)
410 /* Skip "empty" lines */
411 if (!buf[0]) return (0);
413 /* Skip "blank" lines */
414 if (isspace(buf[0])) return (0);
417 if (buf[0] == '#') return (0);
419 /* Require "?:*" format */
420 if (buf[1] != ':') return (1);
423 /* Process "%:<fname>" */
426 /* Attempt to Process the given file */
427 return (process_pref_file(buf + 2));
431 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
434 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
437 i = (huge)strtol(zz[0], NULL, 0);
438 n1 = strtol(zz[1], NULL, 0);
439 n2 = strtol(zz[2], NULL, 0);
440 if (i >= max_r_idx) return (1);
442 if (n1) r_ptr->x_attr = n1;
443 if (n2) r_ptr->x_char = n2;
448 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
449 else if (buf[0] == 'K')
451 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
454 i = (huge)strtol(zz[0], NULL, 0);
455 n1 = strtol(zz[1], NULL, 0);
456 n2 = strtol(zz[2], NULL, 0);
457 if (i >= max_k_idx) return (1);
459 if (n1) k_ptr->x_attr = n1;
460 if (n2) k_ptr->x_char = n2;
465 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
466 else if (buf[0] == 'F')
468 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
471 i = (huge)strtol(zz[0], NULL, 0);
472 n1 = strtol(zz[1], NULL, 0);
473 n2 = strtol(zz[2], NULL, 0);
474 if (i >= max_f_idx) return (1);
476 if (n1) f_ptr->x_attr = n1;
477 if (n2) f_ptr->x_char = n2;
482 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
483 else if (buf[0] == 'S')
485 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
487 j = (byte)strtol(zz[0], NULL, 0);
488 n1 = strtol(zz[1], NULL, 0);
489 n2 = strtol(zz[2], NULL, 0);
490 misc_to_attr[j] = n1;
491 misc_to_char[j] = n2;
496 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
497 else if (buf[0] == 'U')
499 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
501 j = (huge)strtol(zz[0], NULL, 0);
502 n1 = strtol(zz[1], NULL, 0);
503 n2 = strtol(zz[2], NULL, 0);
504 for (i = 1; i < max_k_idx; i++)
506 object_kind *k_ptr = &k_info[i];
507 if (k_ptr->tval == j)
509 if (n1) k_ptr->d_attr = n1;
510 if (n2) k_ptr->d_char = n2;
517 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
518 else if (buf[0] == 'E')
520 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
522 j = (byte)strtol(zz[0], NULL, 0) % 128;
523 n1 = strtol(zz[1], NULL, 0);
524 if (n1) tval_to_attr[j] = n1;
530 /* Process "A:<str>" -- save an "action" for later */
531 else if (buf[0] == 'A')
533 text_to_ascii(macro__buf, buf+2);
537 /* Process "P:<str>" -- normal macro */
538 else if (buf[0] == 'P')
541 text_to_ascii(tmp, buf+2);
542 macro_add(tmp, macro__buf);
547 /* Process "C:<str>" -- create keymap */
548 else if (buf[0] == 'C')
554 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return (1);
556 mode = strtol(zz[0], NULL, 0);
557 if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1);
559 text_to_ascii(tmp, zz[1]);
560 if (!tmp[0] || tmp[1]) return (1);
563 string_free(keymap_act[mode][i]);
565 keymap_act[mode][i] = string_make(macro__buf);
571 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
572 else if (buf[0] == 'V')
574 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
576 i = (byte)strtol(zz[0], NULL, 0);
577 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
578 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
579 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
580 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
586 /* Process "X:<str>" -- turn option off */
587 else if (buf[0] == 'X')
589 for (i = 0; option_info[i].o_desc; i++)
591 int os = option_info[i].o_set;
592 int ob = option_info[i].o_bit;
594 if (option_info[i].o_var &&
595 option_info[i].o_text &&
596 streq(option_info[i].o_text, buf + 2) &&
597 (!alive || option_info[i].o_page !=6))
600 option_flag[os] &= ~(1L << ob);
601 (*option_info[i].o_var) = FALSE;
607 /* Process "Y:<str>" -- turn option on */
608 else if (buf[0] == 'Y')
610 for (i = 0; option_info[i].o_desc; i++)
612 int os = option_info[i].o_set;
613 int ob = option_info[i].o_bit;
615 if (option_info[i].o_var &&
616 option_info[i].o_text &&
617 streq(option_info[i].o_text, buf + 2) &&
618 (!alive || option_info[i].o_page !=6))
621 option_flag[os] |= (1L << ob);
622 (*option_info[i].o_var) = TRUE;
628 /* Process "Z:<type>:<str>" -- set spell color */
629 else if (buf[0] == 'Z')
632 char *t = strchr(buf + 2, ':');
640 for (i = 0; gf_desc[i].name; i++)
642 /* Match this type */
643 if (streq(gf_desc[i].name, buf + 2))
645 /* Remember this color set */
646 gf_color[gf_desc[i].num] = quark_add(t);
653 /* set macro trigger names and a template */
654 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
655 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
656 else if (buf[0] == 'T')
659 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
665 if (macro_template != NULL)
667 free(macro_template);
668 macro_template = NULL;
669 for (i = 0; i < max_macrotrigger; i++)
670 free(macro_trigger_name[i]);
671 max_macrotrigger = 0;
674 if (*zz[0] == '\0') return 0; /* clear template */
676 if (2 + num != tok) return 1; /* error */
678 len = strlen(zz[0])+1+num+1;
679 for (i = 0; i < num; i++)
680 len += strlen(zz[2+i])+1;
681 macro_template = malloc(len);
683 strcpy(macro_template, zz[0]);
685 macro_template + strlen(macro_template) + 1;
686 strcpy(macro_modifier_chr, zz[1]);
687 macro_modifier_name[0] =
688 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
689 for (i = 0; i < num; i++)
691 strcpy(macro_modifier_name[i], zz[2+i]);
692 macro_modifier_name[i+1] = macro_modifier_name[i] +
693 strlen(macro_modifier_name[i]) + 1;
700 if (max_macrotrigger >= MAX_MACRO_TRIG)
703 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
705 msg_print("Too many macro triggers!");
709 m = max_macrotrigger;
712 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
714 len += strlen(zz[2]) + 1;
715 macro_trigger_name[m] = malloc(len);
717 t = macro_trigger_name[m];
726 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
727 strlen(macro_trigger_name[m]) + 1;
728 strcpy(macro_trigger_keycode[0][m], zz[1]);
731 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
732 strlen(macro_trigger_keycode[0][m]) + 1;
733 strcpy(macro_trigger_keycode[1][m], zz[2]);
737 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
749 * Helper function for "process_pref_file()"
752 * v: output buffer array
758 static cptr process_pref_file_expr(char **sp, char *fp)
775 while (isspace(*s)) s++;
793 t = process_pref_file_expr(&s, &f);
802 else if (streq(t, "IOR"))
805 while (*s && (f != b2))
807 t = process_pref_file_expr(&s, &f);
808 if (*t && !streq(t, "0")) v = "1";
813 else if (streq(t, "AND"))
816 while (*s && (f != b2))
818 t = process_pref_file_expr(&s, &f);
819 if (*t && streq(t, "0")) v = "0";
824 else if (streq(t, "NOT"))
827 while (*s && (f != b2))
829 t = process_pref_file_expr(&s, &f);
830 if (*t && streq(t, "1")) v = "0";
835 else if (streq(t, "EQU"))
840 t = process_pref_file_expr(&s, &f);
842 while (*s && (f != b2))
845 t = process_pref_file_expr(&s, &f);
846 if (*t && !streq(p, t)) v = "0";
851 else if (streq(t, "LEQ"))
856 t = process_pref_file_expr(&s, &f);
858 while (*s && (f != b2))
861 t = process_pref_file_expr(&s, &f);
862 if (*t && (strcmp(p, t) > 0)) v = "0";
867 else if (streq(t, "GEQ"))
872 t = process_pref_file_expr(&s, &f);
874 while (*s && (f != b2))
877 t = process_pref_file_expr(&s, &f);
878 if (*t && (strcmp(p, t) < 0)) v = "0";
885 while (*s && (f != b2))
887 t = process_pref_file_expr(&s, &f);
892 if (f != b2) v = "?x?x?";
894 /* Extract final and Terminate */
895 if ((f = *s) != '\0') *s++ = '\0';
901 /* Accept all printables except spaces and brackets */
902 while (isprint(*s) && !strchr(" []", *s)) ++s;
904 /* Extract final and Terminate */
905 if ((f = *s) != '\0') *s++ = '\0';
911 if (streq(b+1, "SYS"))
916 else if (streq(b+1, "KEYBOARD"))
918 v = ANGBAND_KEYBOARD;
922 else if (streq(b+1, "GRAF"))
927 /* Monochrome mode */
928 else if (streq(b+1, "MONOCHROME"))
937 else if (streq(b+1, "RACE"))
947 else if (streq(b+1, "CLASS"))
957 else if (streq(b+1, "REALM1"))
960 v = E_realm_names[p_ptr->realm1];
962 v = realm_names[p_ptr->realm1];
967 else if (streq(b+1, "REALM2"))
970 v = E_realm_names[p_ptr->realm2];
972 v = realm_names[p_ptr->realm2];
977 else if (streq(b+1, "PLAYER"))
983 else if (streq(b+1, "REALM1"))
986 v = E_realm_names[p_ptr->realm1];
988 v = realm_names[p_ptr->realm1];
993 else if (streq(b+1, "REALM2"))
996 v = E_realm_names[p_ptr->realm2];
998 v = realm_names[p_ptr->realm2];
1003 else if (streq(b+1, "LEVEL"))
1005 sprintf(tmp, "%02d", p_ptr->lev);
1029 * Open the "user pref file" and parse it.
1031 static errr process_pref_file_aux(cptr name)
1043 bool bypass = FALSE;
1047 fp = my_fopen(name, "r");
1050 if (!fp) return (-1);
1052 /* Process the file */
1053 while (0 == my_fgets(fp, buf, 1024))
1059 /* Skip "empty" lines */
1060 if (!buf[0]) continue;
1062 /* Skip "blank" lines */
1063 if (isspace(buf[0])) continue;
1066 if (buf[0] == '#') continue;
1073 /* Process "?:<expr>" */
1074 if ((buf[0] == '?') && (buf[1] == ':'))
1083 /* Parse the expr */
1084 v = process_pref_file_expr(&s, &f);
1087 bypass = (streq(v, "0") ? TRUE : FALSE);
1093 /* Apply conditionals */
1094 if (bypass) continue;
1097 /* Process "%:<file>" */
1100 /* Process that file if allowed */
1101 (void)process_pref_file(buf + 2);
1108 /* Process the line */
1109 err = process_pref_file_command(buf);
1119 /* Print error message */
1120 /* ToDo: Add better error messages */
1122 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1123 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1125 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1126 msg_format("Parsing '%s'", old);
1131 /* Close the file */
1141 * Process the "user pref file" with the given name
1143 * See the functions above for a list of legal "commands".
1145 * We also accept the special "?" and "%" directives, which
1146 * allow conditional evaluation and filename inclusion.
1148 errr process_pref_file(cptr name)
1154 /* Build the filename */
1155 path_build(buf, 1024, ANGBAND_DIR_PREF, name);
1157 /* Process the pref file */
1158 err = process_pref_file_aux(buf);
1160 /* Stop at parser errors, but not at non-existing file */
1163 /* Build the filename */
1164 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1166 /* Process the pref file */
1167 err = process_pref_file_aux(buf);
1179 * Operating hours for ANGBAND (defaults to non-work hours)
1181 static char days[7][29] =
1183 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1184 "MON:XXXXXXXX.........XXXXXXX",
1185 "TUE:XXXXXXXX.........XXXXXXX",
1186 "WED:XXXXXXXX.........XXXXXXX",
1187 "THU:XXXXXXXX.........XXXXXXX",
1188 "FRI:XXXXXXXX.........XXXXXXX",
1189 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1193 * Restict usage (defaults to no restrictions)
1195 static bool check_time_flag = FALSE;
1203 errr check_time(void)
1211 /* No restrictions */
1212 if (!check_time_flag) return (0);
1214 /* Check for time violation */
1215 c = time((time_t *)0);
1219 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1230 * Initialize CHECK_TIME
1232 errr check_time_init(void)
1242 /* Build the filename */
1243 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1246 fp = my_fopen(buf, "r");
1248 /* No file, no restrictions */
1249 if (!fp) return (0);
1251 /* Assume restrictions */
1252 check_time_flag = TRUE;
1254 /* Parse the file */
1255 while (0 == my_fgets(fp, buf, 80))
1257 /* Skip comments and blank lines */
1258 if (!buf[0] || (buf[0] == '#')) continue;
1260 /* Chop the buffer */
1263 /* Extract the info */
1264 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1265 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1266 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1267 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1268 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1269 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1270 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1286 #ifndef MAXHOSTNAMELEN
1287 # define MAXHOSTNAMELEN 64
1290 typedef struct statstime statstime;
1296 unsigned int v_pgpgin;
1297 unsigned int v_pgpgout;
1298 unsigned int v_pswpin;
1299 unsigned int v_pswpout;
1300 unsigned int v_intr;
1306 unsigned int v_swtch;
1308 struct timeval boottime;
1309 struct timeval curtime;
1313 * Maximal load (if any).
1315 static int check_load_value = 0;
1323 errr check_load(void)
1328 struct statstime st;
1330 /* Success if not checking */
1331 if (!check_load_value) return (0);
1333 /* Check the load */
1334 if (0 == rstat("localhost", &st))
1336 long val1 = (long)(st.avenrun[2]);
1337 long val2 = (long)(check_load_value) * FSCALE;
1339 /* Check for violation */
1340 if (val1 >= val2) return (1);
1351 * Initialize CHECK_LOAD
1353 errr check_load_init(void)
1362 char temphost[MAXHOSTNAMELEN+1];
1363 char thishost[MAXHOSTNAMELEN+1];
1366 /* Build the filename */
1367 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1369 /* Open the "load" file */
1370 fp = my_fopen(buf, "r");
1372 /* No file, no restrictions */
1373 if (!fp) return (0);
1376 check_load_value = 100;
1378 /* Get the host name */
1379 (void)gethostname(thishost, (sizeof thishost) - 1);
1382 while (0 == my_fgets(fp, buf, 1024))
1386 /* Skip comments and blank lines */
1387 if (!buf[0] || (buf[0] == '#')) continue;
1389 /* Parse, or ignore */
1390 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1392 /* Skip other hosts */
1393 if (!streq(temphost, thishost) &&
1394 !streq(temphost, "localhost")) continue;
1396 /* Use that value */
1397 check_load_value = value;
1403 /* Close the file */
1414 * Print long number with header at given row, column
1415 * Use the color for the number, not the header
1417 static void prt_lnum(cptr header, s32b num, int row, int col, byte color)
1419 int len = strlen(header);
1421 put_str(header, row, col);
1422 (void)sprintf(out_val, "%9ld", (long)num);
1423 c_put_str(color, out_val, row, col + len);
1428 * Print number with header at given row, column
1430 static void prt_num(cptr header, int num, int row, int col, byte color)
1432 int len = strlen(header);
1434 put_str(header, row, col);
1435 put_str(" ", row, col + len);
1436 (void)sprintf(out_val, "%6ld", (long)num);
1437 c_put_str(color, out_val, row, col + len + 3);
1443 * £È£Ð / ºÇÂç ¤Î¤è¤¦¤Êɽ¼¨
1446 static void prt_num_max( int num, int max , int row, int col, byte color1, byte color2 )
1449 (void)sprintf(out_val, "%5ld", (long)num);
1450 c_put_str(color1, out_val, row, col );
1451 put_str("/",row, col+6);
1452 (void)sprintf(out_val, "%5ld", (long)max);
1453 c_put_str(color2, out_val, row, col+8 );
1457 * xx ºÐ ¤È¤« xx kg ¤Ê¤É¤Îɽ¼¨ÍÑ cptr tailer ¤Ëñ°Ì¤¬Æþ¤ë¡£
1459 static void prt_num2(cptr header, cptr tailer, int num, int row, int col, byte color)
1461 int len = strlen(header);
1463 put_str(header, row, col);
1464 put_str(" ", row, col + len);
1465 (void)sprintf(out_val, "%6ld", (long)num);
1466 c_put_str(color, out_val, row, col + len + 3);
1467 put_str(tailer, row, col + len + 3+6);
1471 * Prints the following information on the screen.
1473 * For this to look right, the following should be spaced the
1474 * same as in the prt_lnum code... -CFT
1476 static void display_player_middle(void)
1482 int show_tohit, show_todam;
1488 show_tohit = p_ptr->dis_to_h[0];
1489 show_todam = p_ptr->dis_to_d[0];
1491 o_ptr = &inventory[INVEN_RARM];
1493 /* Hack -- add in weapon info if known */
1494 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1495 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1498 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1500 /* Dump the bonuses to hit/dam */
1502 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1503 Term_putstr(1, 9, -1, TERM_WHITE, "ÂǷ⽤Àµ(³ÊÆ®)");
1504 else if(p_ptr->ryoute)
1505 Term_putstr(1, 9, -1, TERM_WHITE, "ÂǷ⽤Àµ(ξ¼ê)");
1507 Term_putstr(1, 9, -1, TERM_WHITE, (left_hander ? "ÂǷ⽤Àµ(º¸¼ê)" : "ÂǷ⽤Àµ(±¦¼ê)"));
1509 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1510 Term_putstr(1, 9, -1, TERM_WHITE, "Melee(bare h.)");
1511 else if(p_ptr->ryoute)
1512 Term_putstr(1, 9, -1, TERM_WHITE, "Melee(2hands)");
1514 Term_putstr(1, 9, -1, TERM_WHITE, (left_hander ? "Melee(Left)" : "Melee(Right)"));
1516 Term_putstr(15, 9, -1, TERM_L_BLUE, format("%11s", buf));
1521 show_tohit = p_ptr->dis_to_h[1];
1522 show_todam = p_ptr->dis_to_d[1];
1524 o_ptr = &inventory[INVEN_LARM];
1526 /* Hack -- add in weapon info if known */
1527 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1528 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1531 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1533 /* Dump the bonuses to hit/dam */
1535 Term_putstr(1, 10, -1, TERM_WHITE, (left_hander ? "ÂǷ⽤Àµ(±¦¼ê)" : "ÂǷ⽤Àµ(º¸¼ê)"));
1537 Term_putstr(1, 10, -1, TERM_WHITE, "Melee(Left)");
1539 Term_putstr(15, 10, -1, TERM_L_BLUE, format("%11s", buf));
1541 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1544 if (p_ptr->special_defense & KAMAE_MASK)
1546 for (i = 0; i < MAX_KAMAE; i++)
1548 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1551 if (i < MAX_KAMAE) Term_putstr(16, 10, -1, TERM_YELLOW, format("%s¤Î¹½¤¨", kamae_shurui[i].desc));
1553 if (i < MAX_KAMAE) Term_putstr(10, 10, -1, TERM_YELLOW, format("%11.11s form", kamae_shurui[i].desc));
1558 Term_putstr(18, 10, -1, TERM_YELLOW, "¹½¤¨¤Ê¤·");
1560 Term_putstr(16, 10, -1, TERM_YELLOW, "no posture");
1565 o_ptr = &inventory[INVEN_BOW];
1568 show_tohit = p_ptr->dis_to_h_b;
1571 /* Apply weapon bonuses */
1572 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1573 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1575 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1578 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1580 Term_putstr(1, 11, -1, TERM_WHITE, "¼Í·â¹¶·â½¤Àµ");
1582 Term_putstr(1, 11, -1, TERM_WHITE, "Shoot");
1584 Term_putstr(15, 11, -1, TERM_L_BLUE, format("%11s", buf));
1587 if (inventory[INVEN_BOW].k_idx)
1589 switch (inventory[INVEN_BOW].sval)
1591 /* Sling and ammo */
1598 /* Short Bow and Arrow */
1605 /* Long Bow and Arrow */
1613 /* Light Crossbow and Bolt */
1620 /* Heavy Crossbow and Bolt */
1627 /* Long Bow and Arrow */
1634 /* Get extra "power" from "extra might" */
1635 if (p_ptr->xtra_might) tmul++;
1637 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1639 sprintf(buf, "x%d.%02d", tmul/100, tmul%100);
1641 Term_putstr(1, 12, -1, TERM_WHITE, "¼Í·âÉð´ïÇÜΨ");
1643 Term_putstr(1, 12, -1, TERM_WHITE, "Shoot Power");
1645 Term_putstr(15, 12, -1, TERM_L_BLUE, format("%11s", buf));
1647 /* Dump the armor class bonus */
1649 prt_num("AC ½¤Àµ ", p_ptr->dis_to_a, 13, 1, TERM_L_BLUE);
1651 prt_num("+ To AC ", p_ptr->dis_to_a, 13, 1, TERM_L_BLUE);
1655 /* Dump the total armor class */
1657 prt_num("´ðËÜ AC ", p_ptr->dis_ac, 14, 1, TERM_L_BLUE);
1659 prt_num("Base AC ", p_ptr->dis_ac, 14, 1, TERM_L_BLUE);
1663 prt_num("¥ì¥Ù¥ë ", (int)p_ptr->lev, 9, 28, TERM_L_GREEN);
1665 prt_num("Level ", (int)p_ptr->lev, 9, 28, TERM_L_GREEN);
1668 if (p_ptr->prace == RACE_ANDROID)
1670 put_str("·Ð¸³ÃÍ ", 10, 28);
1671 c_put_str(TERM_L_GREEN, " *****", 10, 28+11);
1673 else if (p_ptr->exp >= p_ptr->max_exp)
1676 prt_lnum("·Ð¸³ÃÍ ", p_ptr->exp, 10, 28, TERM_L_GREEN);
1678 prt_lnum("Experience ", p_ptr->exp, 10, 28, TERM_L_GREEN);
1685 prt_lnum("·Ð¸³ÃÍ ", p_ptr->exp, 10, 28, TERM_YELLOW);
1687 prt_lnum("Experience ", p_ptr->exp, 10, 28, TERM_YELLOW);
1692 if (p_ptr->prace == RACE_ANDROID)
1694 put_str("ºÇÂç·Ð¸³ ", 11, 28);
1695 c_put_str(TERM_L_GREEN, " *****", 11, 28+11);
1699 prt_lnum("ºÇÂç·Ð¸³ ", p_ptr->max_exp, 11, 28, TERM_L_GREEN);
1701 prt_lnum("Max Exp ", p_ptr->max_exp, 11, 28, TERM_L_GREEN);
1705 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1708 put_str("¼¡¥ì¥Ù¥ë ", 12, 28);
1709 c_put_str(TERM_L_GREEN, " *****", 12, 28+11);
1711 put_str("Exp to Adv.", 12, 28);
1712 c_put_str(TERM_L_GREEN, " *****", 12, 28+11);
1719 prt_lnum("¼¡¥ì¥Ù¥ë ",
1721 prt_lnum("Exp to Adv.",
1724 (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L),
1725 12, 28, TERM_L_GREEN);
1729 prt_lnum("½ê»ý¶â ", p_ptr->au, 13, 28, TERM_L_GREEN);
1731 prt_lnum("Gold ", p_ptr->au, 13, 28, TERM_L_GREEN);
1735 prt_lnum("¥¿¡¼¥ó¿ô ", MAX(turn_real(turn),0), 14, 28, TERM_L_GREEN );
1737 prt_lnum("Total turn ", MAX(turn_real(turn),0), 14, 28, TERM_L_GREEN );
1742 put_str(" £È£Ð / ºÇÂç ", 9, 52);
1743 if (p_ptr->chp >= p_ptr->mhp)
1744 statcolor = TERM_L_GREEN;
1746 if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1747 statcolor = TERM_YELLOW;
1750 prt_num_max( p_ptr->chp , p_ptr->mhp, 10, 56, statcolor , TERM_L_GREEN);
1753 prt_num("Max Hit Points ", p_ptr->mhp, 9, 52, TERM_L_GREEN);
1755 if (p_ptr->chp >= p_ptr->mhp)
1757 prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_L_GREEN);
1759 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1761 prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_YELLOW);
1765 prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_RED);
1772 put_str(" £Í£Ð / ºÇÂç ", 11, 52);
1773 if (p_ptr->csp >= p_ptr->msp)
1774 statcolor = TERM_L_GREEN;
1776 if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1777 statcolor = TERM_YELLOW;
1780 prt_num_max( p_ptr->csp , p_ptr->msp, 12, 56, statcolor , TERM_L_GREEN);
1782 prt_num("Max SP (Mana) ", p_ptr->msp, 11, 52, TERM_L_GREEN);
1784 if (p_ptr->csp >= p_ptr->msp)
1786 prt_num("Cur SP (Mana) ", p_ptr->csp, 12, 52, TERM_L_GREEN);
1788 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1790 prt_num("Cur SP (Mana) ", p_ptr->csp, 12, 52, TERM_YELLOW);
1794 prt_num("Cur SP (Mana) ", p_ptr->csp, 12, 52, TERM_RED);
1798 sprintf(buf, "%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60);
1800 Term_putstr(52, 14, -1, TERM_WHITE, "¥×¥ì¥¤»þ´Ö");
1802 Term_putstr(52, 14, -1, TERM_WHITE, "Playtime");
1804 Term_putstr(63, 14, -1, TERM_L_GREEN, format("%11s", buf));
1810 * Hack -- pass color info around this file
1812 static byte likert_color = TERM_WHITE;
1816 * Returns a "rating" of x depending on y
1818 static cptr likert(int x, int y)
1820 static char dummy[20] = "";
1825 /* Negative value */
1828 likert_color = TERM_L_DARK;
1832 return ("Very Bad");
1837 /* Analyze the value */
1843 likert_color = TERM_RED;
1853 likert_color = TERM_L_RED;
1864 likert_color = TERM_ORANGE;
1874 likert_color = TERM_YELLOW;
1884 likert_color = TERM_YELLOW;
1886 return ("ÂçÊÑÎɤ¤");
1888 return ("Very Good");
1895 likert_color = TERM_L_GREEN;
1899 return ("Excellent");
1909 likert_color = TERM_GREEN;
1922 likert_color = TERM_BLUE;
1924 return ("¥«¥ª¥¹¥é¥ó¥¯");
1926 return ("Chaos Rank");
1932 likert_color = TERM_VIOLET;
1934 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
1936 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
1946 * Prints ratings on certain abilities
1948 * This code is "imitated" elsewhere to "dump" a character sheet.
1950 static void display_player_various(void)
1952 int tmp, damage[2], blows1, blows2, i, basedam;
1953 int xthn, xthb, xfos, xsrh;
1954 int xdis, xdev, xsav, xstl;
1958 int energy_fire = 100;
1959 int shots, shot_frac;
1963 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
1964 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
1965 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
1966 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
1967 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
1969 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
1971 /* Shooting Skill (with current bow and normal missile) */
1972 o_ptr = &inventory[INVEN_BOW];
1973 tmp = p_ptr->to_h_b + o_ptr->to_h;
1974 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
1976 /* If the player is wielding one? */
1979 /* Analyze the launcher */
1980 switch (o_ptr->sval)
1982 /* Sling and ammo */
1989 /* Short Bow and Arrow */
1992 energy_fire = 10000;
1996 /* Long Bow and Arrow */
1999 energy_fire = 10000;
2009 /* Light Crossbow and Bolt */
2012 energy_fire = 12000;
2016 /* Heavy Crossbow and Bolt */
2019 energy_fire = 13333;
2023 /* Calculate shots per round */
2024 shots = p_ptr->num_fire * 100;
2025 shot_frac = (shots * 100 / energy_fire) % 100;
2026 shots = shots / energy_fire;
2027 if (o_ptr->name1 == ART_CRIMSON)
2031 if (p_ptr->pclass == CLASS_ARCHER)
2033 /* Extra shot at level 10 */
2034 if (p_ptr->lev >= 10) shots++;
2036 /* Extra shot at level 30 */
2037 if (p_ptr->lev >= 30) shots++;
2039 /* Extra shot at level 45 */
2040 if (p_ptr->lev >= 45) shots++;
2050 for(i = 0; i< 2; i++)
2052 damage[i] = p_ptr->dis_to_d[i]*100;
2053 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2055 int level = p_ptr->lev;
2061 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2062 if (p_ptr->special_defense & KAMAE_BYAKKO)
2063 basedam = monk_ave_damage[level][1];
2064 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2065 basedam = monk_ave_damage[level][2];
2067 basedam = monk_ave_damage[level][0];
2071 /* Average damage per round */
2072 o_ptr = &inventory[INVEN_RARM+i];
2073 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2074 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2075 object_flags(o_ptr, &f1, &f2, &f3);
2076 if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
2082 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2084 /* vorpal flag only */
2088 if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2089 basedam = basedam * 7 / 2;
2090 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2091 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2093 damage[i] += basedam;
2094 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2095 if (damage[i] < 0) damage[i] = 0;
2097 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2098 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2100 /* Basic abilities */
2102 xdis = p_ptr->skill_dis;
2103 xdev = p_ptr->skill_dev;
2104 xsav = p_ptr->skill_sav;
2105 xstl = p_ptr->skill_stl;
2106 xsrh = p_ptr->skill_srh;
2107 xfos = p_ptr->skill_fos;
2111 put_str("ÂǷ⹶·âǽÎÏ :", 17, 1);
2113 put_str("Fighting :", 17, 1);
2116 desc = likert(xthn, 12);
2117 c_put_str(likert_color, desc, 17, 15);
2120 put_str("¼Í·â¹¶·âǽÎÏ :", 18, 1);
2122 put_str("Bows/Throw :", 18, 1);
2125 desc = likert(xthb, 12);
2126 c_put_str(likert_color, desc, 18, 15);
2129 put_str("ËâË¡ËɸæǽÎÏ :", 19, 1);
2131 put_str("Saving Throw:", 19, 1);
2134 desc = likert(xsav, 7);
2135 c_put_str(likert_color, desc, 19, 15);
2138 put_str("±£Ì©¹ÔưǽÎÏ :", 20, 1);
2140 put_str("Stealth :", 20, 1);
2143 desc = likert(xstl, 1);
2144 c_put_str(likert_color, desc, 20, 15);
2148 put_str("ÃγÐǽÎÏ :", 17, 28);
2150 put_str("Perception :", 17, 28);
2153 desc = likert(xfos, 6);
2154 c_put_str(likert_color, desc, 17, 42);
2157 put_str("õº÷ǽÎÏ :", 18, 28);
2159 put_str("Searching :", 18, 28);
2162 desc = likert(xsrh, 6);
2163 c_put_str(likert_color, desc, 18, 42);
2166 put_str("²ò½üǽÎÏ :", 19, 28);
2168 put_str("Disarming :", 19, 28);
2171 desc = likert(xdis, 8);
2172 c_put_str(likert_color, desc, 19, 42);
2175 put_str("ËâË¡Æ»¶ñ»ÈÍÑ :", 20, 28);
2177 put_str("Magic Device:", 20, 28);
2180 desc = likert(xdev, 6);
2181 c_put_str(likert_color, desc, 20, 42);
2185 put_str("ÂÇ·â²ó¿ô :", 17, 55);
2187 put_str("Blows/Round:", 17, 55);
2191 put_str(format("%d+%d", blows1, blows2), 17, 69);
2193 put_str(format("%d+%d+%d", blows1, blows2, muta_att), 17, 69);
2196 put_str("¼Í·â²ó¿ô :", 18, 55);
2198 put_str("Shots/Round:", 18, 55);
2201 put_str(format("%d.%02d", shots, shot_frac), 18, 69);
2204 put_str("Ê¿¶Ñ¥À¥á¡¼¥¸:", 19, 55);
2206 put_str("Wpn.dmg/Rnd:", 19, 55); /* From PsiAngband */
2210 if ((damage[0]+damage[1]) == 0)
2213 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2215 put_str(desc, 19, 69);
2218 put_str("ÀÖ³°Àþ»ëÎÏ :", 20, 55);
2220 put_str("Infra-Vision:", 20, 55);
2224 put_str(format("%d feet", p_ptr->see_infra * 10), 20, 69);
2226 put_str(format("%d feet", p_ptr->see_infra * 10), 20, 69);
2234 * Obtain the "flags" for the player as if he was an item
2236 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2239 (*f1) = (*f2) = (*f3) = 0L;
2242 switch (p_ptr->pclass)
2245 if (p_ptr->lev > 44)
2246 (*f3) |= (TR3_REGEN);
2248 if (p_ptr->lev > 29)
2249 (*f2) |= (TR2_RES_FEAR);
2252 if (p_ptr->lev > 39)
2253 (*f2) |= (TR2_RES_FEAR);
2255 case CLASS_CHAOS_WARRIOR:
2256 if (p_ptr->lev > 29)
2257 (*f2) |= (TR2_RES_CHAOS);
2258 if (p_ptr->lev > 39)
2259 (*f2) |= (TR2_RES_FEAR);
2262 case CLASS_FORCETRAINER:
2263 if ((p_ptr->lev > 9) && !heavy_armor())
2265 if ((p_ptr->lev>24) && !heavy_armor())
2266 (*f2) |= (TR2_FREE_ACT);
2273 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2276 (*f2) |= (TR2_FREE_ACT);
2278 (*f3) |= TR3_SLOW_DIGEST;
2279 (*f2) |= TR2_RES_FEAR;
2280 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2281 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2282 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2284 case CLASS_MINDCRAFTER:
2286 (*f2) |= (TR2_RES_FEAR);
2287 if (p_ptr->lev > 19)
2288 (*f2) |= (TR2_SUST_WIS);
2289 if (p_ptr->lev > 29)
2290 (*f2) |= (TR2_RES_CONF);
2291 if (p_ptr->lev > 39)
2292 (*f3) |= (TR3_TELEPATHY);
2295 (*f2) |= (TR2_RES_SOUND);
2297 case CLASS_BERSERKER:
2298 (*f2) |= (TR2_SUST_STR);
2299 (*f2) |= (TR2_SUST_DEX);
2300 (*f2) |= (TR2_SUST_CON);
2301 (*f3) |= (TR3_REGEN);
2302 (*f2) |= (TR2_FREE_ACT);
2303 (*f1) |= (TR1_SPEED);
2304 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2306 case CLASS_MIRROR_MASTER:
2307 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2310 break; /* Do nothing */
2314 if (p_ptr->mimic_form)
2316 switch(p_ptr->mimic_form)
2319 (*f2) |= (TR2_HOLD_LIFE);
2320 (*f2) |= (TR2_RES_CHAOS);
2321 (*f2) |= (TR2_RES_NETHER);
2322 (*f2) |= (TR2_RES_FIRE);
2323 (*f3) |= (TR3_SEE_INVIS);
2324 (*f1) |= (TR1_SPEED);
2326 case MIMIC_DEMON_LORD:
2327 (*f2) |= (TR2_HOLD_LIFE);
2328 (*f2) |= (TR2_RES_CHAOS);
2329 (*f2) |= (TR2_RES_NETHER);
2330 (*f2) |= (TR2_RES_FIRE);
2331 (*f2) |= (TR2_RES_COLD);
2332 (*f2) |= (TR2_RES_ELEC);
2333 (*f2) |= (TR2_RES_ACID);
2334 (*f2) |= (TR2_RES_POIS);
2335 (*f2) |= (TR2_RES_CONF);
2336 (*f2) |= (TR2_RES_DISEN);
2337 (*f2) |= (TR2_RES_NEXUS);
2338 (*f2) |= (TR2_RES_FEAR);
2339 (*f2) |= (TR2_IM_FIRE);
2340 (*f3) |= (TR3_SH_FIRE);
2341 (*f3) |= (TR3_SEE_INVIS);
2342 (*f3) |= (TR3_TELEPATHY);
2343 (*f3) |= (TR3_FEATHER);
2344 (*f1) |= (TR1_SPEED);
2347 (*f2) |= (TR2_HOLD_LIFE);
2348 (*f2) |= (TR2_RES_DARK);
2349 (*f2) |= (TR2_RES_NETHER);
2350 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2351 (*f2) |= (TR2_RES_POIS);
2352 (*f2) |= (TR2_RES_COLD);
2353 (*f3) |= (TR3_SEE_INVIS);
2354 (*f1) |= (TR1_SPEED);
2360 switch (p_ptr->prace)
2363 (*f2) |= (TR2_RES_LITE);
2366 (*f2) |= (TR2_SUST_DEX);
2369 (*f2) |= (TR2_FREE_ACT);
2372 (*f2) |= (TR2_RES_BLIND);
2375 (*f2) |= (TR2_RES_DARK);
2377 case RACE_HALF_TROLL:
2378 (*f2) |= (TR2_SUST_STR);
2379 if (p_ptr->lev > 14)
2381 (*f3) |= (TR3_REGEN);
2382 if (p_ptr->pclass == CLASS_WARRIOR)
2384 (*f3) |= (TR3_SLOW_DIGEST);
2386 * Let's not make Regeneration a disadvantage
2387 * for the poor warriors who can never learn
2388 * a spell that satisfies hunger (actually
2389 * neither can rogues, but half-trolls are not
2390 * supposed to play rogues)
2396 (*f2) |= (TR2_SUST_CON);
2397 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2400 (*f2) |= (TR2_RES_LITE);
2401 (*f3) |= (TR3_SEE_INVIS);
2403 case RACE_BARBARIAN:
2404 (*f2) |= (TR2_RES_FEAR);
2406 case RACE_HALF_OGRE:
2407 (*f2) |= (TR2_SUST_STR);
2408 (*f2) |= (TR2_RES_DARK);
2410 case RACE_HALF_GIANT:
2411 (*f2) |= (TR2_RES_SHARDS);
2412 (*f2) |= (TR2_SUST_STR);
2414 case RACE_HALF_TITAN:
2415 (*f2) |= (TR2_RES_CHAOS);
2418 (*f2) |= (TR2_RES_SOUND);
2421 (*f2) |= (TR2_RES_ACID);
2422 if (p_ptr->lev > 19)
2423 (*f2) |= (TR2_IM_ACID);
2426 (*f2) |= (TR2_RES_CONF);
2427 (*f2) |= (TR2_RES_ACID);
2432 (*f2) |= (TR2_RES_POIS);
2435 (*f2) |= (TR2_RES_DISEN);
2436 (*f2) |= (TR2_RES_DARK);
2439 (*f2) |= (TR2_RES_DARK);
2440 if (p_ptr->lev > 19)
2441 (*f3) |= (TR3_SEE_INVIS);
2443 case RACE_DRACONIAN:
2444 (*f3) |= TR3_FEATHER;
2446 (*f2) |= (TR2_RES_FIRE);
2448 (*f2) |= (TR2_RES_COLD);
2449 if (p_ptr->lev > 14)
2450 (*f2) |= (TR2_RES_ACID);
2451 if (p_ptr->lev > 19)
2452 (*f2) |= (TR2_RES_ELEC);
2453 if (p_ptr->lev > 34)
2454 (*f2) |= (TR2_RES_POIS);
2456 case RACE_MIND_FLAYER:
2457 (*f2) |= (TR2_SUST_INT);
2458 (*f2) |= (TR2_SUST_WIS);
2459 if (p_ptr->lev > 14)
2460 (*f3) |= (TR3_SEE_INVIS);
2461 if (p_ptr->lev > 29)
2462 (*f3) |= (TR3_TELEPATHY);
2465 (*f2) |= (TR2_RES_FIRE);
2467 (*f3) |= (TR3_SEE_INVIS);
2470 (*f3) |= (TR3_SEE_INVIS);
2471 (*f2) |= (TR2_FREE_ACT);
2472 (*f2) |= (TR2_RES_POIS);
2473 (*f3) |= (TR3_SLOW_DIGEST);
2474 if (p_ptr->lev > 34)
2475 (*f2) |= (TR2_HOLD_LIFE);
2478 (*f3) |= (TR3_SEE_INVIS);
2479 (*f2) |= (TR2_RES_SHARDS);
2480 (*f2) |= (TR2_HOLD_LIFE);
2481 (*f2) |= (TR2_RES_POIS);
2483 (*f2) |= (TR2_RES_COLD);
2486 (*f3) |= (TR3_SEE_INVIS);
2487 (*f2) |= (TR2_HOLD_LIFE);
2488 (*f2) |= (TR2_RES_NETHER);
2489 (*f2) |= (TR2_RES_POIS);
2490 (*f3) |= (TR3_SLOW_DIGEST);
2492 (*f2) |= (TR2_RES_COLD);
2495 (*f2) |= (TR2_HOLD_LIFE);
2496 (*f2) |= (TR2_RES_DARK);
2497 (*f2) |= (TR2_RES_NETHER);
2498 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2499 (*f2) |= (TR2_RES_POIS);
2500 (*f2) |= (TR2_RES_COLD);
2503 (*f3) |= (TR3_FEATHER);
2504 (*f2) |= (TR2_FREE_ACT);
2505 (*f2) |= (TR2_RES_COLD);
2506 (*f3) |= (TR3_SEE_INVIS);
2507 (*f2) |= (TR2_HOLD_LIFE);
2508 (*f2) |= (TR2_RES_NETHER);
2509 (*f2) |= (TR2_RES_POIS);
2510 (*f3) |= (TR3_SLOW_DIGEST);
2512 if (p_ptr->lev > 34)
2513 (*f3) |= TR3_TELEPATHY;
2516 (*f2) |= (TR2_RES_LITE);
2517 (*f3) |= (TR3_FEATHER);
2519 (*f1) |= (TR1_SPEED);
2522 (*f2) |= (TR2_RES_SOUND);
2523 (*f2) |= (TR2_RES_CONF);
2526 (*f3) |= (TR3_FEATHER);
2527 (*f3) |= (TR3_SEE_INVIS);
2530 (*f2) |= (TR2_RES_FIRE);
2531 (*f2) |= (TR2_RES_NETHER);
2532 (*f2) |= (TR2_HOLD_LIFE);
2534 (*f3) |= (TR3_SEE_INVIS);
2537 (*f2) |= (TR2_SUST_CON);
2540 (*f3) |= (TR3_FEATHER);
2543 (*f2) |= (TR2_RES_CONF);
2546 (*f2) |= (TR2_FREE_ACT);
2547 (*f2) |= (TR2_RES_POIS);
2548 (*f3) |= (TR3_SLOW_DIGEST);
2549 (*f2) |= (TR2_HOLD_LIFE);
2559 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2561 (*f3) &= ~(TR3_REGEN);
2564 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2565 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2566 (p_ptr->muta3 & MUT3_SHORT_LEG))
2571 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2573 (*f3) |= TR3_SH_ELEC;
2576 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2578 (*f3) |= TR3_SH_FIRE;
2582 if (p_ptr->muta3 & MUT3_WINGS)
2584 (*f3) |= TR3_FEATHER;
2587 if (p_ptr->muta3 & MUT3_FEARLESS)
2589 (*f2) |= (TR2_RES_FEAR);
2592 if (p_ptr->muta3 & MUT3_REGEN)
2597 if (p_ptr->muta3 & MUT3_ESP)
2599 (*f3) |= TR3_TELEPATHY;
2602 if (p_ptr->muta3 & MUT3_MOTION)
2604 (*f2) |= TR2_FREE_ACT;
2608 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2609 (*f3) |= TR3_AGGRAVATE;
2610 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2612 (*f2) |= (TR2_RES_BLIND);
2613 (*f2) |= (TR2_RES_CONF);
2614 (*f2) |= (TR2_HOLD_LIFE);
2615 (*f3) |= (TR3_LITE);
2617 (*f1) |= (TR1_SPEED);
2619 if (p_ptr->special_defense & KATA_FUUJIN)
2620 (*f2) |= TR2_REFLECT;
2621 if (p_ptr->special_defense & KAMAE_GENBU)
2622 (*f2) |= TR2_REFLECT;
2623 if (p_ptr->special_defense & KAMAE_SUZAKU)
2624 (*f3) |= TR3_FEATHER;
2625 if (p_ptr->special_defense & KAMAE_SEIRYU)
2627 (*f2) |= (TR2_RES_FIRE);
2628 (*f2) |= (TR2_RES_COLD);
2629 (*f2) |= (TR2_RES_ACID);
2630 (*f2) |= (TR2_RES_ELEC);
2631 (*f2) |= (TR2_RES_POIS);
2632 (*f3) |= (TR3_FEATHER);
2633 (*f3) |= (TR3_SH_FIRE);
2634 (*f3) |= (TR3_SH_ELEC);
2635 (*f3) |= (TR3_SH_COLD);
2637 if (p_ptr->special_defense & KATA_MUSOU)
2639 (*f2) |= TR2_RES_FEAR;
2640 (*f2) |= TR2_RES_LITE;
2641 (*f2) |= TR2_RES_DARK;
2642 (*f2) |= TR2_RES_BLIND;
2643 (*f2) |= TR2_RES_CONF;
2644 (*f2) |= TR2_RES_SOUND;
2645 (*f2) |= TR2_RES_SHARDS;
2646 (*f2) |= TR2_RES_NETHER;
2647 (*f2) |= TR2_RES_NEXUS;
2648 (*f2) |= TR2_RES_CHAOS;
2649 (*f2) |= TR2_RES_DISEN;
2650 (*f2) |= TR2_REFLECT;
2651 (*f2) |= TR2_HOLD_LIFE;
2652 (*f2) |= TR2_FREE_ACT;
2653 (*f3) |= TR3_SH_FIRE;
2654 (*f3) |= TR3_SH_ELEC;
2655 (*f3) |= TR3_SH_COLD;
2656 (*f3) |= TR3_FEATHER;
2658 (*f3) |= TR3_SEE_INVIS;
2659 (*f3) |= TR3_TELEPATHY;
2660 (*f3) |= TR3_SLOW_DIGEST;
2662 (*f2) |= (TR2_SUST_STR);
2663 (*f2) |= (TR2_SUST_INT);
2664 (*f2) |= (TR2_SUST_WIS);
2665 (*f2) |= (TR2_SUST_DEX);
2666 (*f2) |= (TR2_SUST_CON);
2667 (*f2) |= (TR2_SUST_CHR);
2672 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2675 (*f1) = (*f2) = (*f3) = 0L;
2677 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2678 (*f2) |= TR2_RES_FEAR;
2679 if (p_ptr->tim_invis)
2680 (*f3) |= TR3_SEE_INVIS;
2681 if (p_ptr->tim_regen)
2683 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2684 (*f3) |= TR3_TELEPATHY;
2685 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2687 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2689 (*f2) |= (TR2_RES_FIRE);
2690 (*f2) |= (TR2_RES_COLD);
2691 (*f2) |= (TR2_RES_ACID);
2692 (*f2) |= (TR2_RES_ELEC);
2693 (*f2) |= (TR2_RES_POIS);
2697 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2698 (*f2) |= TR2_RES_ACID;
2699 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2700 (*f2) |= TR2_RES_ELEC;
2701 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2702 (*f2) |= TR2_RES_FIRE;
2703 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2704 (*f2) |= TR2_RES_COLD;
2708 if (p_ptr->oppose_acid)
2709 (*f2) |= TR2_RES_ACID;
2710 if (p_ptr->oppose_elec)
2711 (*f2) |= TR2_RES_ELEC;
2712 if (p_ptr->oppose_fire)
2713 (*f2) |= TR2_RES_FIRE;
2714 if (p_ptr->oppose_cold)
2715 (*f2) |= TR2_RES_COLD;
2717 if (p_ptr->oppose_pois)
2718 (*f2) |= TR2_RES_POIS;
2719 if (p_ptr->special_attack & ATTACK_ACID)
2720 (*f1) |= TR1_BRAND_ACID;
2721 if (p_ptr->special_attack & ATTACK_ELEC)
2722 (*f1) |= TR1_BRAND_ELEC;
2723 if (p_ptr->special_attack & ATTACK_FIRE)
2724 (*f1) |= TR1_BRAND_FIRE;
2725 if (p_ptr->special_attack & ATTACK_COLD)
2726 (*f1) |= TR1_BRAND_COLD;
2727 if (p_ptr->special_attack & ATTACK_POIS)
2728 (*f1) |= TR1_BRAND_POIS;
2729 if (p_ptr->special_defense & DEFENSE_ACID)
2730 (*f2) |= TR2_IM_ACID;
2731 if (p_ptr->special_defense & DEFENSE_ELEC)
2732 (*f2) |= TR2_IM_ELEC;
2733 if (p_ptr->special_defense & DEFENSE_FIRE)
2734 (*f2) |= TR2_IM_FIRE;
2735 if (p_ptr->special_defense & DEFENSE_COLD)
2736 (*f2) |= TR2_IM_COLD;
2737 if (p_ptr->wraith_form)
2738 (*f2) |= TR2_REFLECT;
2740 if (p_ptr->tim_reflect){
2741 (*f2) |= TR2_REFLECT;
2744 if (p_ptr->magicdef)
2746 (*f2) |= TR2_RES_BLIND;
2747 (*f2) |= TR2_RES_CONF;
2748 (*f2) |= TR2_REFLECT;
2749 (*f2) |= TR2_FREE_ACT;
2750 (*f3) |= TR3_FEATHER;
2752 if (p_ptr->tim_res_nether)
2754 (*f2) |= TR2_RES_NETHER;
2756 if (p_ptr->tim_sh_fire)
2758 (*f3) |= TR3_SH_FIRE;
2762 (*f2) |= TR2_RES_FEAR;
2763 (*f2) |= TR2_RES_LITE;
2764 (*f2) |= TR2_RES_DARK;
2765 (*f2) |= TR2_RES_BLIND;
2766 (*f2) |= TR2_RES_CONF;
2767 (*f2) |= TR2_RES_SOUND;
2768 (*f2) |= TR2_RES_SHARDS;
2769 (*f2) |= TR2_RES_NETHER;
2770 (*f2) |= TR2_RES_NEXUS;
2771 (*f2) |= TR2_RES_CHAOS;
2772 (*f2) |= TR2_RES_DISEN;
2773 (*f2) |= TR2_REFLECT;
2774 (*f2) |= TR2_HOLD_LIFE;
2775 (*f2) |= TR2_FREE_ACT;
2776 (*f3) |= TR3_SH_FIRE;
2777 (*f3) |= TR3_SH_ELEC;
2778 (*f3) |= TR3_SH_COLD;
2779 (*f3) |= TR3_FEATHER;
2781 (*f3) |= TR3_SEE_INVIS;
2782 (*f3) |= TR3_TELEPATHY;
2783 (*f3) |= TR3_SLOW_DIGEST;
2785 (*f2) |= (TR2_SUST_STR);
2786 (*f2) |= (TR2_SUST_INT);
2787 (*f2) |= (TR2_SUST_WIS);
2788 (*f2) |= (TR2_SUST_DEX);
2789 (*f2) |= (TR2_SUST_CON);
2790 (*f2) |= (TR2_SUST_CHR);
2798 static void display_player_equippy(int y, int x)
2808 /* Dump equippy chars */
2809 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2812 o_ptr = &inventory[i];
2814 a = object_attr(o_ptr);
2815 c = object_char(o_ptr);
2817 /* Clear the part of the screen */
2818 if (!equippy_chars || !o_ptr->k_idx)
2825 Term_putch(x + i - INVEN_RARM, y, a, c);
2830 void print_equippy(void)
2832 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2839 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2844 (*f1) = (*f2) = (*f3) = 0L;
2846 /* Check equipment */
2847 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2849 u32b o_f1, o_f2, o_f3;
2854 o_ptr = &inventory[i];
2856 if (!o_ptr->k_idx) continue;
2859 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2861 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2862 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2863 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2864 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2868 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2871 (*f1) = (*f2) = (*f3) = 0L;
2873 if (prace_is_(RACE_SPECTRE))
2874 (*f2) |= TR2_RES_NETHER;
2875 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2876 (*f2) |= TR2_RES_DARK;
2877 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2878 (*f2) |= TR2_RES_FIRE;
2879 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2880 (*f2) |= TR2_RES_ACID;
2883 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2886 (*f1) = (*f2) = (*f3) = 0L;
2888 if (p_ptr->special_defense & DEFENSE_ACID)
2889 (*f2) |= TR2_RES_ACID;
2890 if (p_ptr->special_defense & DEFENSE_ELEC)
2891 (*f2) |= TR2_RES_ELEC;
2892 if (p_ptr->special_defense & DEFENSE_FIRE)
2893 (*f2) |= TR2_RES_FIRE;
2894 if (p_ptr->special_defense & DEFENSE_COLD)
2895 (*f2) |= TR2_RES_COLD;
2896 if (p_ptr->wraith_form)
2897 (*f2) |= TR2_RES_DARK;
2900 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2903 (*f1) = (*f2) = (*f3) = 0L;
2905 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2907 (*f2) |= TR2_RES_ACID;
2908 (*f2) |= TR2_RES_ELEC;
2909 (*f2) |= TR2_RES_FIRE;
2910 (*f2) |= TR2_RES_COLD;
2912 if (prace_is_(RACE_ANDROID))
2913 (*f2) |= TR2_RES_ELEC;
2914 if (prace_is_(RACE_ENT))
2915 (*f2) |= TR2_RES_FIRE;
2916 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2917 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2918 (*f2) |= TR2_RES_LITE;
2922 * Helper function, see below
2924 static void display_player_flag_aux(int row, int col, char *header,
2925 int n, u32b flag1, u32b flag2,
2926 u32b im_f[], u32b vul_f)
2932 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2936 c_put_str(TERM_WHITE, header, row, col);
2939 col += strlen(header) + 1;
2941 /* Check equipment */
2942 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2945 f[0] = f[1] = f[2] = 0L;
2948 o_ptr = &inventory[i];
2951 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2954 c_put_str(vuln ? TERM_RED : TERM_SLATE, ".", row, col);
2957 if (f[n - 1] & flag1) c_put_str(vuln ? TERM_L_RED : TERM_WHITE, "+", row, col);
2958 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
2965 player_flags(&f[0], &f[1], &f[2]);
2968 c_put_str(vuln ? TERM_RED : TERM_SLATE, ".", row, col);
2971 if (f[n-1] & flag1) c_put_str(vuln ? TERM_L_RED : TERM_WHITE, "+", row, col);
2973 /* Timed player flags */
2974 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
2977 if (f[n-1] & flag1) c_put_str(vuln ? TERM_ORANGE : TERM_YELLOW, "#", row, col);
2980 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
2981 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
2984 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
2989 * Special display, part 1
2991 static void display_player_flag_info(void)
2996 u32b im_f[3][3], vul_f[3];
2998 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
2999 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
3000 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
3002 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3009 display_player_equippy(row-2, col+8);
3010 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3013 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3014 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3015 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3016 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3017 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3018 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3019 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3020 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3021 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3022 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3024 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3025 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3026 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3027 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3028 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3029 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3030 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3031 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3032 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3033 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3042 display_player_equippy(row-2, col+8);
3044 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3047 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3048 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3049 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3050 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3051 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3052 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3053 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3054 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3055 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3056 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3058 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3059 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3060 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3061 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3062 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3063 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3064 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3065 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3066 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3067 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3076 display_player_equippy(row-2, col+12);
3078 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3081 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3082 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3083 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3084 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3085 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3086 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3087 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3088 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3089 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3090 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3092 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3093 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3094 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3095 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3096 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3097 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3098 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3099 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3100 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3101 display_player_flag_aux(row+9, col, "Cursed :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3108 * Special display, part 2a
3110 static void display_player_misc_info(void)
3115 /* Display basics */
3117 put_str("̾Á° :", 1, 26);
3118 put_str("ÀÊÌ :", 3, 1);
3119 put_str("¼ï² :", 4, 1);
3120 put_str("¿¦¶È :", 5, 1);
3122 put_str("Name :", 1, 26);
3123 put_str("Sex :", 3, 1);
3124 put_str("Race :", 4, 1);
3125 put_str("Class :", 5, 1);
3128 strcpy(tmp,ap_ptr->title);
3135 strcat(tmp,player_name);
3137 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3138 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3139 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3140 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3142 /* Display extras */
3144 put_str("¥ì¥Ù¥ë:", 6, 1);
3145 put_str("£È£Ð :", 7, 1);
3146 put_str("£Í£Ð :", 8, 1);
3148 put_str("Level :", 6, 1);
3149 put_str("Hits :", 7, 1);
3150 put_str("Mana :", 8, 1);
3154 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3155 c_put_str(TERM_L_BLUE, buf, 6, 9);
3156 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3157 c_put_str(TERM_L_BLUE, buf, 7, 9);
3158 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3159 c_put_str(TERM_L_BLUE, buf, 8, 9);
3164 * Special display, part 2b
3166 * How to print out the modifications and sustains.
3167 * Positive mods with no sustain will be light green.
3168 * Positive mods with a sustain will be dark green.
3169 * Sustains (with no modification) will be a dark green 's'.
3170 * Negative mods (from a curse) will be red.
3171 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3172 * No mod, no sustain, will be a slate '.'
3174 static void display_player_stat_info(void)
3196 /* Print out the labels for the columns */
3198 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3199 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3200 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3201 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3202 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+33);
3204 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3205 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3206 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3207 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3208 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3212 /* Display the stats */
3213 for (i = 0; i < 6; i++)
3217 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3218 else r_adj = rp_ptr->r_adj[i];
3220 /* Calculate equipment adjustment */
3223 /* Icky formula to deal with the 18 barrier */
3224 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3225 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3226 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3227 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3228 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3229 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3231 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3232 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3234 if (prace_is_(RACE_ENT))
3240 if (p_ptr->lev > 25) r_adj++;
3241 if (p_ptr->lev > 40) r_adj++;
3242 if (p_ptr->lev > 45) r_adj++;
3245 if (p_ptr->lev > 25) r_adj--;
3246 if (p_ptr->lev > 40) r_adj--;
3247 if (p_ptr->lev > 45) r_adj--;
3253 e_adj -= cp_ptr->c_adj[i];
3254 e_adj -= ap_ptr->a_adj[i];
3256 /* Reduced name of stat */
3258 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3260 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3264 /* Internal "natural" max value. Maxes at 18/100 */
3265 /* This is useful to see if you are maxed out */
3266 cnv_stat(p_ptr->stat_max[i], buf);
3267 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3269 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3271 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3273 /* Race, class, and equipment modifiers */
3274 (void)sprintf(buf, "%3d", r_adj);
3275 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3276 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3277 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3278 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3279 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3280 (void)sprintf(buf, "%3d", (int)e_adj);
3281 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3283 /* Actual maximal modified value */
3284 cnv_stat(p_ptr->stat_top[i], buf);
3285 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3287 /* Only display stat_use if not maximal */
3288 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3290 cnv_stat(p_ptr->stat_use[i], buf);
3291 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3296 col = stat_col + 41;
3298 /* Header and Footer */
3299 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3301 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3303 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3307 /* Process equipment */
3308 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3311 o_ptr = &inventory[i];
3314 k_idx = o_ptr->k_idx;
3316 /* Acquire "known" flags */
3317 object_flags_known(o_ptr, &f1, &f2, &f3);
3319 /* Initialize color based of sign of pval. */
3320 for (stat = 0; stat < 6; stat++)
3333 if (o_ptr->pval > 0)
3339 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3344 /* Dark green for sustained stats */
3349 if (o_ptr->pval < 0)
3355 if (o_ptr->pval < 10) c = '0' - o_ptr->pval;
3360 else if (f2 & 1 << stat)
3362 /* Dark green "s" */
3367 /* Dump proper character */
3368 Term_putch(col, row + stat+1, a, c);
3376 player_flags(&f1, &f2, &f3);
3379 for (stat = 0; stat < 6; stat++)
3386 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3392 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3393 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3394 if (p_ptr->tsuyoshi) dummy += 4;
3396 else if (stat == A_WIS || stat == A_INT)
3398 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3399 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3401 else if (stat == A_DEX)
3403 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3404 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3405 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3407 else if (stat == A_CON)
3409 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3410 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3411 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3412 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3413 if (p_ptr->tsuyoshi) dummy += 4;
3415 else if (stat == A_CHR)
3417 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3418 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3419 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3420 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3421 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3422 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3438 if (dummy < 10) c = '0' + dummy;
3448 if (dummy < 10) c = '0' - dummy;
3457 /* Dark green "s" */
3464 Term_putch(col, row + stat+1, a, c);
3472 static cptr object_flag_names[96] =
3713 * Summarize resistances
3715 static void display_player_ben(void)
3728 for (i = 0; i < 6; i++) b[i] = 0;
3731 /* Scan equipment */
3732 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3735 o_ptr = &inventory[i];
3737 /* Known object flags */
3738 object_flags_known(o_ptr, &f1, &f2, &f3);
3741 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3743 f3 &= ~(TR3_AGGRAVATE);
3748 b[0] |= (f1 & 0xFFFF);
3750 b[2] |= (f2 & 0xFFFF);
3752 b[4] |= (f3 & 0xFFFF);
3758 player_flags(&f1, &f2, &f3);
3761 b[0] |= (f1 & 0xFFFF);
3763 b[2] |= (f2 & 0xFFFF);
3765 b[4] |= (f3 & 0xFFFF);
3769 tim_player_flags(&f1, &f2, &f3, FALSE);
3772 b[0] |= (f1 & 0xFFFF);
3774 b[2] |= (f2 & 0xFFFF);
3776 b[4] |= (f3 & 0xFFFF);
3778 color[0] = (f1 & 0xFFFF);
3779 color[1] = (f1 >> 16);
3780 color[2] = (f2 & 0xFFFF);
3781 color[3] = (f2 >> 16);
3782 color[4] = (f3 & 0xFFFF);
3783 color[5] = (f3 >> 16);
3786 for (x = 0; x < 6; x++)
3789 for (y = 0; y < 16; y++)
3791 byte a = TERM_SLATE;
3794 cptr name = object_flag_names[16*x+y];
3797 if (!name) continue;
3800 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3803 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3808 if (color[x] & (1<<y))
3821 Term_putch(x * 13 + 11, y + 4, a, c);
3828 * Summarize resistances
3830 static void display_player_ben_one(int mode)
3842 /* Scan equipment */
3843 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3846 n = (i - INVEN_RARM);
3849 o_ptr = &inventory[i];
3851 object_flags_known(o_ptr, &f1, &f2, &f3);
3853 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3855 f3 &= ~(TR3_AGGRAVATE);
3860 b[n][0] = (u16b)(f1 & 0xFFFF);
3861 b[n][1] = (u16b)(f1 >> 16);
3862 b[n][2] = (u16b)(f2 & 0xFFFF);
3863 b[n][3] = (u16b)(f2 >> 16);
3864 b[n][4] = (u16b)(f3 & 0xFFFF);
3865 b[n][5] = (u16b)(f3 >> 16);
3873 player_flags(&f1, &f2, &f3);
3876 b[n][0] = (u16b)(f1 & 0xFFFF);
3877 b[n][1] = (u16b)(f1 >> 16);
3878 b[n][2] = (u16b)(f2 & 0xFFFF);
3879 b[n][3] = (u16b)(f2 >> 16);
3880 b[n][4] = (u16b)(f3 & 0xFFFF);
3881 b[n][5] = (u16b)(f3 >> 16);
3884 tim_player_flags(&f1, &f2, &f3, FALSE);
3887 b[n][0] |= (f1 & 0xFFFF);
3888 b[n][1] |= (f1 >> 16);
3889 b[n][2] |= (f2 & 0xFFFF);
3890 b[n][3] |= (f2 >> 16);
3891 b[n][4] |= (f3 & 0xFFFF);
3892 b[n][5] |= (f3 >> 16);
3893 color[0] = (f1 & 0xFFFF);
3894 color[1] = (f1 >> 16);
3895 color[2] = (f2 & 0xFFFF);
3896 color[3] = (f2 >> 16);
3897 color[4] = (f3 & 0xFFFF);
3898 color[5] = (f3 >> 16);
3902 for (x = 0; x < 3; x++)
3905 display_player_equippy(2, x * 26 + 11);
3908 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3911 for (y = 0; y < 16; y++)
3913 cptr name = object_flag_names[48*mode+16*x+y];
3916 if (!name) continue;
3919 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3922 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3925 for (n = 0; n < 13; n++)
3927 byte a = TERM_SLATE;
3931 if (b[n][3*mode+x] & (1<<y))
3933 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3946 Term_putch(x * 26 + 11 + n, y + 4, a, c);
3954 * Display the character on the screen (various modes)
3956 * The top two and bottom two lines are left blank.
3958 * Mode 0 = standard display with skills
3959 * Mode 1 = standard display with history
3960 * Mode 2 = summary of various things
3961 * Mode 3 = current flags (combined)
3962 * Mode 4 = current flags (part 1)
3963 * Mode 5 = current flags (part 2)
3964 * Mode 6 = mutations
3966 void display_player(int mode)
3975 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
3984 if ((mode == 0) || (mode == 1))
3986 /* Name, Sex, Race, Class */
3988 put_str("̾Á° :", 1,26);
3989 put_str("ÀÊÌ :", 3, 1);
3990 put_str("¼ï² :", 4, 1);
3991 put_str("¿¦¶È :", 5, 1);
3993 put_str("Name :", 1,26);
3994 put_str("Sex :", 3, 1);
3995 put_str("Race :", 4, 1);
3996 put_str("Class :", 5, 1);
3999 if (p_ptr->realm1 || p_ptr->realm2)
4001 put_str("ËâË¡ :", 6, 1);
4003 put_str("Magic :", 6, 1);
4006 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4008 put_str("¼é¸îËâ¿À :", 7, 1);
4010 put_str("Patron :", 7, 1);
4013 strcpy(tmp,ap_ptr->title);
4020 strcat(tmp,player_name);
4022 c_put_str(TERM_L_BLUE, tmp, 1, 34);
4023 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 15);
4024 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 15);
4025 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 15);
4027 c_put_str(TERM_L_BLUE, realm_names[p_ptr->realm1], 6, 15);
4028 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4029 c_put_str(TERM_L_BLUE, chaos_patrons[p_ptr->chaos_patron], 7, 15);
4031 else if (p_ptr->realm2)
4032 c_put_str(TERM_L_BLUE, realm_names[p_ptr->realm2], 7, 15);
4034 /* Age, Height, Weight, Social */
4036 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4037 /* ¹¹¤ËÆüËܸìÈǤÎÄɲäȤ·¤Æñ°Ì¤âɽ¼¨¤·¤Þ¤¹ */
4038 /* Ãæ±û¤Î¥«¥é¥à¤ÏÆüËܸì¤òɽ¼¨¤¹¤ë¤Ë¤Ï¶¹¤¤¤Î¤Ç¡¢º¸¤Ë4¤ÄÆ°¤«¤·¤Þ¤¹¡£ */
4039 prt_num2("ǯÎð ", "ºÍ",(int)p_ptr->age, 3, 32-2, TERM_L_BLUE);
4040 prt_num2("¿ÈĹ ","cm",(int)((p_ptr->ht*254)/100) , 4, 32-2, TERM_L_BLUE);
4041 prt_num2("ÂνŠ", "kg",(int)((p_ptr->wt*4536)/10000) , 5, 32-2, TERM_L_BLUE);
4042 prt_num("¼Ò²ñŪÃÏ°Ì ", (int)p_ptr->sc , 6, 32-2, TERM_L_BLUE);
4044 prt_num("Age ", (int)p_ptr->age, 3, 32, TERM_L_BLUE);
4045 prt_num("Height ", (int)p_ptr->ht , 4, 32, TERM_L_BLUE);
4046 prt_num("Weight ", (int)p_ptr->wt , 5, 32, TERM_L_BLUE);
4047 prt_num("Social Class ", (int)p_ptr->sc , 6, 32, TERM_L_BLUE);
4051 /* Display the stats */
4052 for (i = 0; i < 6; i++)
4054 /* Special treatment of "injured" stats */
4055 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4059 /* Use lowercase stat name */
4060 put_str(stat_names_reduced[i], 2 + i, 59);
4062 /* Get the current stat */
4063 value = p_ptr->stat_use[i];
4065 /* Obtain the current stat (modified) */
4066 cnv_stat(value, buf);
4068 /* Display the current stat (modified) */
4069 c_put_str(TERM_YELLOW, buf, 2 + i, 66);
4071 /* Acquire the max stat */
4072 value = p_ptr->stat_top[i];
4074 /* Obtain the maximum stat (modified) */
4075 cnv_stat(value, buf);
4077 /* Display the maximum stat (modified) */
4078 c_put_str(TERM_L_GREEN, buf, 2 + i, 73);
4081 /* Normal treatment of "normal" stats */
4084 /* Assume uppercase stat name */
4085 put_str(stat_names[i], 2 + i, 59);
4087 /* Obtain the current stat (modified) */
4088 cnv_stat(p_ptr->stat_use[i], buf);
4090 /* Display the current stat (modified) */
4091 c_put_str(TERM_L_GREEN, buf, 2 + i, 66);
4094 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4096 c_put_str(TERM_WHITE, "!", 2+i, 64);
4101 display_player_middle();
4103 /* Display "history" info */
4107 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 16, 25);
4109 put_str("(Character Background)", 16, 25);
4113 for (i = 0; i < 4; i++)
4115 put_str(history[i], i + 17, 10);
4119 /* Display "various" info */
4123 put_str(" (¤½¤Î¾¤ÎǽÎÏ) ", 16, 25);
4125 put_str("(Miscellaneous Abilities)", 16, 25);
4129 display_player_various();
4136 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4139 display_player_misc_info();
4140 display_player_stat_info();
4141 display_player_flag_info();
4147 display_player_ben();
4152 do_cmd_knowledge_mutations();
4158 display_player_ben_one(mode % 2);
4162 errr make_character_dump(FILE *fff)
4169 char o_name[MAX_NLEN];
4174 #ifndef FAKE_VERSION
4176 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4177 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4180 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4181 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4183 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4184 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4191 /* Display player */
4194 /* Dump part of the screen */
4195 for (y = 1; y < 22; y++)
4198 for (x = 0; x < 79; x++)
4200 /* Get the attr/char */
4201 (void)(Term_what(x, y, &a, &c));
4207 /* End the string */
4210 /* Kill trailing spaces */
4211 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4215 fprintf(fff, "%s\n", buf);
4217 fprintf(fff, "%s\n", buf);
4222 /* Display history */
4225 /* Dump part of the screen */
4226 for (y = 16; y < 21; y++)
4229 for (x = 0; x < 79; x++)
4231 /* Get the attr/char */
4232 (void)(Term_what(x, y, &a, &c));
4238 /* End the string */
4241 /* Kill trailing spaces */
4242 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4245 fprintf(fff, "%s\n", buf);
4249 /* Display history */
4252 /* Dump part of the screen */
4253 for (y = 2; y < 22; y++)
4256 for (x = 0; x < 79; x++)
4258 /* Get the attr/char */
4259 (void)(Term_what(x, y, &a, &c));
4265 /* End the string */
4268 /* Kill trailing spaces */
4269 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4272 fprintf(fff, "%s\n", buf);
4275 for (i = 0; i < p_ptr->count / 80; i++)
4278 for (i = 0; i < p_ptr->count % 80; i++)
4283 for (i = m_max - 1; i >= 1; i--)
4285 monster_type *m_ptr = &m_list[i];
4288 if (!m_ptr->r_idx) continue;
4289 if (!is_pet(m_ptr)) continue;
4290 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4294 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4296 fprintf(fff, "\n [leading pets]\n\n");
4300 monster_desc(pet_name, m_ptr, 0x88);
4301 fprintf(fff, "%s", pet_name);
4302 if (p_ptr->riding == i)
4304 fprintf(fff, " ¾èÇÏÃæ");
4306 fprintf(fff, " riding");
4310 if (pet) fprintf(fff, "\n");
4313 if (death && !total_winner)
4316 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4318 fprintf(fff, "\n [Last messages]\n\n");
4320 for (i = MIN(message_num(), 15); i >= 0; i--)
4322 fprintf(fff,"> %s\n",message_str((s16b)i));
4328 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4330 fprintf(fff, "\n [Miscellaneous information]\n");
4334 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4336 fprintf(fff, "\n Recall Depth:\n");
4338 for (y = 1; y < max_d_idx; y++)
4342 if (!d_info[y].maxdepth) continue;
4343 if (!max_dlv[y]) continue;
4344 if (d_info[y].final_guardian)
4346 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4348 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4351 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4353 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4359 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4361 fprintf(fff, "\n Preserve Mode: ON");
4366 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4368 fprintf(fff, "\n Preserve Mode: OFF");
4372 if (ironman_autoscum)
4374 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4376 fprintf(fff, "\n Autoscum: ALWAYS");
4381 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4383 fprintf(fff, "\n Autoscum: ON");
4388 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4390 fprintf(fff, "\n Autoscum: OFF");
4394 if (ironman_small_levels)
4396 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4398 fprintf(fff, "\n Small Levels: ALWAYS");
4401 else if (always_small_levels)
4403 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4405 fprintf(fff, "\n Small Levels: ON");
4408 else if (small_levels)
4410 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4412 fprintf(fff, "\n Small Levels: ENABLED");
4417 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4419 fprintf(fff, "\n Small Levels: OFF");
4425 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4427 fprintf(fff, "\n Vanilla Town: ON");
4432 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4434 fprintf(fff, "\n Lite Town: ON");
4440 fprintf(fff, "\n Ź¤Ê¤·: ON");
4442 fprintf(fff, "\n No Shops: ON");
4446 if (ironman_downward)
4448 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4450 fprintf(fff, "\n Diving only: ON");
4456 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4458 fprintf(fff, "\n Unusual rooms: ON");
4462 if (ironman_nightmare)
4464 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4466 fprintf(fff, "\n Nightmare Mode: ON");
4470 if (ironman_empty_levels)
4472 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4474 fprintf(fff, "\n Arena Levels: ALWAYS");
4477 else if (empty_levels)
4479 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4481 fprintf(fff, "\n Arena Levels: ENABLED");
4486 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4488 fprintf(fff, "\n Arena Levels: OFF");
4493 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4495 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4498 if (p_ptr->arena_number == 99)
4501 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4503 fprintf(fff, "\n Arena: defeated\n");
4506 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4509 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4511 fprintf(fff, "\n Arena: True Champion\n");
4514 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4517 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4519 fprintf(fff, "\n Arena: Champion\n");
4525 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4527 fprintf(fff, "\n Arena: %2d victor%s\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number), (p_ptr->arena_number>1) ? "ies" : "y");
4533 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4535 fprintf(fff, "\n You have done something illegal.");
4539 if (stupid_monsters)
4541 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4543 fprintf(fff, "\n Your opponents are behaving stupidly.");
4549 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4551 fprintf(fff, "\n You possess munchkinish power over death.");
4556 /* Monsters slain */
4561 for (k = 1; k < max_r_idx; k++)
4563 monster_race *r_ptr = &r_info[k];
4565 if (r_ptr->flags1 & RF1_UNIQUE)
4567 bool dead = (r_ptr->max_num == 0);
4575 s16b This = r_ptr->r_pkills;
4585 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4587 fprintf(fff,"\n You have defeated no enemies yet.\n");
4590 else if (Total == 1)
4592 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4594 fprintf(fff,"\n You have defeated one enemy.\n");
4599 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4601 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4607 if (p_ptr->old_race1 || p_ptr->old_race2)
4610 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4612 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4614 for (i = 0; i < MAX_RACES; i++)
4616 if (p_ptr->start_race == i) continue;
4619 if (!(p_ptr->old_race1 & 1L << i)) continue;
4623 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4626 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4628 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4633 if (p_ptr->old_realm)
4635 for (i = 0; i < MAX_MAGIC; i++)
4637 if (!(p_ptr->old_realm & 1L << i)) continue;
4639 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4641 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4647 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4649 fprintf(fff, "\n\n [Virtues]\n\n");
4653 if (p_ptr->align > 150) disp_align = "ÂçÁ±";
4654 else if (p_ptr->align > 50) disp_align = "ÃæÁ±";
4655 else if (p_ptr->align > 10) disp_align = "¾®Á±";
4656 else if (p_ptr->align > -11) disp_align = "ÃæΩ";
4657 else if (p_ptr->align > -51) disp_align = "¾®°";
4658 else if (p_ptr->align > -151) disp_align = "Ãæ°";
4659 else disp_align = "Âç°";
4660 fprintf(fff, "°À : %s\n", disp_align);
4662 if (p_ptr->align > 150) disp_align = "lawful";
4663 else if (p_ptr->align > 50) disp_align = "good";
4664 else if (p_ptr->align > 10) disp_align = "neutral good";
4665 else if (p_ptr->align > -11) disp_align = "neutral";
4666 else if (p_ptr->align > -51) disp_align = "neutral evil";
4667 else if (p_ptr->align > -151) disp_align = "evil";
4668 else disp_align = "chaotic";
4669 fprintf(fff, "Your alighnment : %s\n", disp_align);
4674 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4677 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4679 fprintf(fff, "\n\n [Mutations]\n\n");
4682 dump_mutations(fff);
4686 /* Skip some lines */
4687 fprintf(fff, "\n\n");
4690 /* Dump the equipment */
4694 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4696 fprintf(fff, " [Character Equipment]\n\n");
4699 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4701 object_desc(o_name, &inventory[i], TRUE, 3);
4702 if ((i == INVEN_LARM) && p_ptr->ryoute)
4704 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4706 strcpy(o_name, "(wielding with two-hands)");
4708 fprintf(fff, "%c%s %s\n",
4709 index_to_label(i), paren, o_name);
4711 fprintf(fff, "\n\n");
4714 /* Dump the inventory */
4716 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4718 fprintf(fff, " [Character Inventory]\n\n");
4721 for (i = 0; i < INVEN_PACK; i++)
4723 /* Don't dump the empty slots */
4724 if (!inventory[i].k_idx) break;
4726 /* Dump the inventory slots */
4727 object_desc(o_name, &inventory[i], TRUE, 3);
4728 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4731 /* Add an empty line */
4732 fprintf(fff, "\n\n");
4734 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4736 /* Print all homes in the different towns */
4737 st_ptr = &town[1].store[STORE_HOME];
4739 /* Home -- if anything there */
4740 if (st_ptr->stock_num)
4742 /* Header with name of the town */
4744 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4746 fprintf(fff, " [Home Inventory]\n");
4750 /* Dump all available items */
4751 for (i = 0; i < st_ptr->stock_num; i++)
4755 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4757 fprintf(fff, "\n ( page %d )\n", x++);
4759 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4760 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4763 /* Add an empty line */
4764 fprintf(fff, "\n\n");
4768 /* Print all homes in the different towns */
4769 st_ptr = &town[1].store[STORE_MUSEUM];
4771 /* Home -- if anything there */
4772 if (st_ptr->stock_num)
4774 /* Header with name of the town */
4776 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4778 fprintf(fff, " [Museum]\n");
4782 /* Dump all available items */
4783 for (i = 0; i < st_ptr->stock_num; i++)
4786 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4787 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4788 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4790 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4791 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4792 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4797 /* Add an empty line */
4798 fprintf(fff, "\n\n");
4805 * Hack -- Dump a character description file
4807 * XXX XXX XXX Allow the "full" flag to dump additional info,
4808 * and trigger its usage from various places in the code.
4810 errr file_character(cptr name, bool full)
4819 /* Build the filename */
4820 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4822 /* File type is "TEXT" */
4823 FILE_TYPE(FILE_TYPE_TEXT);
4825 /* Check for existing file */
4826 fd = fd_open(buf, O_RDONLY);
4833 /* Close the file */
4838 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4840 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4845 if (get_check(out_val)) fd = -1;
4848 /* Open the non-existing file */
4849 if (fd < 0) fff = my_fopen(buf, "w");
4860 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4862 msg_format("Character dump failed!");
4871 (void)make_character_dump(fff);
4879 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4881 msg_print("Character dump successful.");
4892 * Recursive file perusal.
4894 * Return FALSE on "ESCAPE", otherwise TRUE.
4896 * Process various special text in the input file, including
4897 * the "menu" structures used by the "help file" system.
4899 * XXX XXX XXX Consider using a temporary file.
4901 * XXX XXX XXX Allow the user to "save" the current file.
4903 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4907 /* Number of "real" lines passed by */
4910 /* Number of "real" lines in the file */
4913 /* Backup value for "line" */
4919 /* This screen has sub-screens */
4922 /* Current help file */
4925 /* Find this string (if any) */
4928 /* Jump to this tag */
4931 /* Hold a string to find */
4934 /* Hold a string to show */
4938 char filename[1024];
4940 /* Describe this thing */
4946 /* General buffer */
4949 /* Lower case version of the buffer, for searching */
4952 /* Aux pointer for making lc_buf (and find!) lowercase */
4955 /* Sub-menu information */
4958 /* Tags for in-file references */
4961 bool reverse = (line < 0);
4970 strcpy(caption, "");
4972 /* Wipe the hooks */
4973 for (i = 0; i < 68; i++)
4978 /* Copy the filename */
4979 strcpy(filename, name);
4981 n = strlen(filename);
4983 /* Extract the tag from the filename */
4984 for (i = 0; i < n; i++)
4986 if (filename[i] == '#')
4989 tag = filename + i + 1;
4994 /* Redirect the name */
4997 /* Hack XXX XXX XXX */
5001 strcpy(caption, what);
5003 /* Access the "file" */
5007 fff = my_fopen(path, "r");
5010 /* Look in "help" */
5015 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5017 sprintf(caption, "Help file '%s'", name);
5021 /* Build the filename */
5022 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5025 fff = my_fopen(path, "r");
5028 /* Look in "info" */
5033 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5035 sprintf(caption, "Info file '%s'", name);
5039 /* Build the filename */
5040 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5043 fff = my_fopen(path, "r");
5051 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5053 msg_format("Cannot open '%s'.", name);
5063 /* Pre-Parse the file */
5066 /* Read a line or stop */
5067 if (my_fgets(fff, buf, 1024)) break;
5069 /* XXX Parse "menu" items */
5070 if (prefix(buf, "***** "))
5072 /* Notice "menu" requests */
5073 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5075 /* This is a menu file */
5078 /* Extract the menu item */
5079 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5081 if ((buf[8] == ']') && (buf[9] == ' '))
5083 /* Extract the menu item */
5084 strcpy(hook[k], buf + 10);
5087 /* Notice "tag" requests */
5088 else if ((buf[6] == '<') && (isdigit(buf[7]) || isalpha(buf[7])) &&
5091 /* Extract the menu item */
5092 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5094 /* Extract the menu item */
5102 /* Count the "real" lines */
5106 /* Save the number of "real" lines */
5109 if (line == -1) line = ((size-1)/20)*20;
5111 /* Go to the tagged line */
5113 line = tags[isdigit(tag[0]) ? D2I(tag[0]) : tag[0] - 'A' + 10];
5115 /* Display the file */
5121 /* Restart when necessary */
5122 if (line >= size) line = 0;
5125 /* Re-open the file if needed */
5131 /* Hack -- Re-Open the file */
5132 fff = my_fopen(path, "r");
5135 if (!fff) return (FALSE);
5137 /* File has been restarted */
5141 /* Goto the selected line */
5145 if (my_fgets(fff, buf, 1024)) break;
5147 /* Skip tags/links */
5148 if (prefix(buf, "***** ")) continue;
5150 /* Count the lines */
5154 /* Dump the next 20 lines of the file */
5155 for (i = 0; i < 20; )
5157 /* Hack -- track the "first" line */
5158 if (!i) line = next;
5160 /* Get a line of the file or stop */
5161 if (my_fgets(fff, buf, 1024)) break;
5163 /* Hack -- skip "special" lines */
5164 if (prefix(buf, "***** ")) continue;
5166 /* Count the "real" lines */
5169 /* Make a lower case version of buf for searching */
5170 strcpy(lc_buf, buf);
5172 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5174 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5177 /* Hack -- keep searching */
5178 if (find && !i && !strstr(lc_buf, find)) continue;
5180 /* Hack -- stop searching */
5184 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5186 /* Hilite "shower" */
5191 /* Display matches */
5192 while ((str = strstr(str, shower)) != NULL)
5194 int len = strlen(shower);
5196 /* Display the match */
5197 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5204 /* Count the printed lines */
5208 /* Hack -- failed search */
5218 /* Show a general "title" */
5222 prt(format("[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5224 prt(format("[Hengband %d.%d.%d, %s, Line %d/%d]",
5227 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5228 caption, line, size), 0, 0);
5233 prt(format("[%s, %d/%d]",
5235 prt(format("[%s, Line %d/%d]",
5237 caption, line, size), 0, 0);
5240 /* Prompt -- menu screen */
5245 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", 23, 0);
5247 prt("[Press a Number, or ESC to exit.]", 23, 0);
5252 /* Prompt -- small files */
5253 else if (size <= 20)
5257 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5259 prt("[Press ESC to exit.]", 23, 0);
5264 /* Prompt -- large files */
5269 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5271 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5273 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", 23, 0);
5277 /* Get a keypress */
5280 /* Hack -- return to last screen */
5281 if (k == '<') break;
5283 /* Show the help for the help */
5286 /* Hack - prevent silly recursion */
5288 if (strcmp(name, "jhelpinfo.txt") != 0)
5289 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5291 if (strcmp(name, "helpinfo.txt") != 0)
5292 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5296 /* Hack -- try showing */
5301 prt("¶¯Ä´: ", 23, 0);
5303 prt("Show: ", 23, 0);
5306 (void)askfor_aux(shower, 80);
5309 /* Hack -- try finding */
5314 prt("¸¡º÷: ", 23, 0);
5316 prt("Find: ", 23, 0);
5320 if (askfor_aux(finder, 80))
5327 /* Make finder lowercase */
5328 for (cnt = 0; finder[cnt] != 0; cnt++)
5330 finder[cnt] = tolower(finder[cnt]);
5334 strcpy(shower, finder);
5338 /* Hack -- go to a specific line */
5345 prt("Goto Line: ", 23, 0);
5350 if (askfor_aux(tmp, 80))
5356 /* Hack -- go to a specific file */
5361 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", 23, 0);
5362 strcpy(tmp, "jhelp.hlp");
5364 prt("Goto File: ", 23, 0);
5365 strcpy(tmp, "help.hlp");
5369 if (askfor_aux(tmp, 80))
5371 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
5375 /* Hack -- Allow backing up */
5378 line = line + (reverse ? 20 : -20);
5379 if (line < 0) line = ((size-1)/20)*20;
5382 /* Hack -- Advance a single line */
5383 if ((k == '\n') || (k == '\r'))
5385 line = line + (reverse ? -1 : 1);
5386 if (line < 0) line = ((size-1)/20)*20;
5389 /* Advance one page */
5392 line = line + (reverse ? -20 : 20);
5393 if (line < 0) line = ((size-1)/20)*20;
5397 /* ÆüËܸìÈǤÇÄɲ䵤줿¥Ø¥ë¥×¤Îɽ¼¨ */
5398 /* ¤¢¤Þ¤ê¤è¤¤½èÍý¤Î»ÅÊý¤È¤Ï»×¤¨¤Ê¤¤¡¦¡¦¡¦¤¹¤Þ¤ó */
5400 /* ´Ê°×¥³¥Þ¥ó¥É°ìÍ÷ */
5401 if (menu && (k == 'c' || k == 'C'))
5404 switch (rogue_like_commands)
5408 strcpy(tmp, "j_com_r.txt");
5409 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
5414 strcpy(tmp, "j_com_o.txt");
5415 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
5422 /* Recurse on numbers */
5427 if (isdigit(k)) key = D2I(k);
5428 else if (isalpha(k)) key = k - 'A' + 10;
5430 if ((key > -1) && hook[key][0])
5432 /* Recurse on that file */
5433 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5438 /* Hack, dump to file */
5448 if (get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5450 if (get_string("File name: ", xtmp, 80))
5454 if (xtmp[0] && (xtmp[0] != ' '))
5463 /* Build the filename */
5464 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5469 /* Hack -- Re-Open the file */
5470 fff = my_fopen(path, "r");
5472 ffp = my_fopen(buff, "w");
5478 msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
5480 msg_print("Failed to open file.");
5487 sprintf(xtmp, "%s: %s", player_name, what);
5488 my_fputs(ffp, xtmp, 80);
5489 my_fputs(ffp, "\n", 80);
5491 while (!my_fgets(fff, buff, 80))
5492 my_fputs(ffp, buff, 80);
5498 /* Hack -- Re-Open the file */
5499 fff = my_fopen(path, "r");
5502 /* Exit on escape */
5503 if (k == ESCAPE) break;
5506 /* Close the file */
5510 if (k == ESCAPE) return (FALSE);
5518 * Peruse the On-Line-Help
5520 void do_cmd_help(void)
5525 /* Peruse the main help file */
5527 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5529 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5539 * Process the player name.
5540 * Extract a clean "base name".
5541 * Build the savefile name if needed.
5543 void process_player_name(bool sf)
5548 /* Cannot be too long */
5549 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5551 if (strlen(player_name) > 8)
5553 if (strlen(player_name) > 15)
5558 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5560 quit_fmt("The name '%s' is too long!", player_name);
5566 /* Cannot contain "icky" characters */
5567 for (i = 0; player_name[i]; i++)
5569 /* No control characters */
5571 if (iskanji(player_name[i])){i++;continue;}
5572 if (iscntrl( (unsigned char)player_name[i]))
5574 if (iscntrl(player_name[i]))
5578 /* Illegal characters */
5580 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5582 quit_fmt("The name '%s' contains control chars!", player_name);
5591 /* Extract "useful" letters */
5592 for (i = 0; player_name[i]; i++)
5595 unsigned char c = player_name[i];
5597 char c = player_name[i];
5601 /* Convert "dot" to "underscore" */
5602 if (c == '.') c = '_';
5604 /* Accept all the letters */
5605 player_base[k++] = c;
5610 /* Extract "useful" letters */
5611 for (i = 0; player_name[i]; i++)
5614 unsigned char c = player_name[i];
5616 char c = player_name[i];
5619 /* Accept some letters */
5622 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5623 player_base[k++] = c;
5625 player_base[k++] = player_name[i];
5628 else if (iskana(c)) player_base[k++] = c;
5632 /* Convert path separator to underscore */
5633 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5634 player_base[k++] = '_';
5635 i += strlen(PATH_SEP);
5638 /* Convert space, dot, and underscore to underscore */
5639 else if (strchr(". _", c)) player_base[k++] = '_';
5641 else if (isprint(c)) player_base[k++] = c;
5647 #if defined(WINDOWS) || defined(MSDOS)
5649 /* Hack -- max length */
5655 player_base[k] = '\0';
5657 /* Require a "base" name */
5658 if (!player_base[0]) strcpy(player_base, "PLAYER");
5661 #ifdef SAVEFILE_MUTABLE
5667 if (!savefile_base[0] && savefile[0])
5674 t = strstr(s, PATH_SEP);
5679 strcpy(savefile_base, s);
5682 if (!savefile_base[0] || !savefile[0])
5685 /* Change the savefile name */
5690 strcpy(savefile_base, player_base);
5692 #ifdef SAVEFILE_USE_UID
5693 /* Rename the savefile, using the player_uid and player_base */
5694 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5696 /* Rename the savefile, using the player_base */
5697 (void)sprintf(temp, "%s", player_base);
5701 /* Hack -- support "flat directory" usage on VM/ESA */
5702 (void)sprintf(temp, "%s.sv", player_base);
5705 /* Build the filename */
5706 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5712 * Gets a name for the character, reacting to name changes.
5714 * Assumes that "display_player(0)" has just been called
5716 * Perhaps we should NOT ask for a name (at "birth()") on
5717 * Unix machines? XXX XXX
5719 * What a horrible name for a global function. XXX XXX XXX
5725 /* Save the player name */
5726 strcpy(tmp, player_name);
5728 /* Prompt for a new name */
5730 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5732 if (get_string("Enter a name for your character: ", tmp, 15))
5736 strcpy(player_name, tmp);
5738 /* Process the player name */
5739 process_player_name(FALSE);
5741 else if (strlen(player_name))
5743 /* Process the player name */
5744 process_player_name(FALSE);
5747 strcpy(tmp,ap_ptr->title);
5754 strcat(tmp,player_name);
5756 /* Re-Draw the name (in light blue) */
5757 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5759 /* Erase the prompt, etc */
5766 * Hack -- commit suicide
5768 void do_cmd_suicide(void)
5775 /* Verify Retirement */
5780 if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
5782 if (!get_check("Do you want to retire? ")) return;
5787 /* Verify Suicide */
5792 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5794 if (!get_check("Do you really want to commit suicide? ")) return;
5801 /* Special Verification for suicide */
5803 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5805 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5811 if (i != '@') return;
5817 /* Kill the player */
5821 p_ptr->leaving = TRUE;
5826 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5827 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5829 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5830 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5832 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5835 /* Cause of death */
5837 (void)strcpy(died_from, "ÅÓÃ潪λ");
5839 (void)strcpy(died_from, "Quitting");
5849 void do_cmd_save_game(int is_autosave)
5851 /* Autosaves do not disturb */
5855 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5857 msg_print("Autosaving the game...");
5863 /* Disturb the player */
5867 /* Clear messages */
5875 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
5877 prt("Saving game...", 0, 0);
5884 /* The player is not dead */
5886 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
5888 (void)strcpy(died_from, "(saved)");
5892 /* Forbid suspend */
5893 signals_ignore_tstp();
5895 /* Save the player */
5899 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
5901 prt("Saving game... done.", 0, 0);
5906 /* Save failed (oops) */
5910 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
5912 prt("Saving game... failed!", 0, 0);
5917 /* Allow suspend again */
5918 signals_handle_tstp();
5923 /* Note that the player is not dead */
5925 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
5927 (void)strcpy(died_from, "(alive and well)");
5934 * Save the game and exit
5936 void do_cmd_save_and_exit(void)
5941 p_ptr->leaving = TRUE;
5943 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
5945 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
5951 * Hack -- Calculates the total number of points earned -JWT-
5953 long total_points(void)
5957 u32b point, point_h, point_l;
5958 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
5960 if (stupid_monsters) mult -= 70;
5961 if (!preserve_mode) mult += 10;
5962 if (!autoroller) mult += 10;
5963 if (!smart_learn) mult -= 20;
5964 if (!terrain_streams) mult -= 20;
5965 if (smart_cheat) mult += 30;
5966 if (ironman_shops) mult += 50;
5967 if (ironman_small_levels) mult += 10;
5968 if (ironman_empty_levels) mult += 20;
5969 if (!powerup_home) mult += 50;
5970 if (ironman_rooms) mult += 100;
5971 if (ironman_nightmare) mult += 100;
5973 if (mult < 5) mult = 5;
5975 for (i = 0; i < max_d_idx; i++)
5976 if(max_dlv[i] > max_dl)
5977 max_dl = max_dlv[i];
5979 point_l = (p_ptr->max_exp + (100 * max_dl));
5980 point_h = point_l / 0x10000L;
5981 point_l = point_l % 0x10000L;
5984 point_h += point_l / 0x10000L;
5985 point_l %= 0x10000L;
5987 point_l += ((point_h % 100) << 16);
5991 point = (point_h << 16) + (point_l);
5992 if (p_ptr->arena_number < 99)
5993 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
5995 if (ironman_downward) point *= 2;
5996 if (p_ptr->pclass == CLASS_BERSERKER)
5998 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6002 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6005 if (total_winner) point = 2;
6007 if (easy_band) point = (0 - point);
6015 * Centers a string within a 31 character string -JWT-
6017 static void center_string(char *buf, cptr str)
6024 /* Necessary border */
6028 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6034 * Save a "bones" file for a dead character
6036 * Note that we will not use these files until Angband 2.8.0, and
6037 * then we will only use the name and level on which death occured.
6039 * Should probably attempt some form of locking...
6041 static void make_bones(void)
6048 /* Ignore wizards and borgs */
6049 if (!(noscore & 0x00FF))
6051 /* Ignore people who die in town */
6056 /* XXX XXX XXX "Bones" name */
6057 sprintf(tmp, "bone.%03d", dun_level);
6059 /* Build the filename */
6060 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6062 /* Attempt to open the bones file */
6063 fp = my_fopen(str, "r");
6065 /* Close it right away */
6066 if (fp) my_fclose(fp);
6068 /* Do not over-write a previous ghost */
6071 /* File type is "TEXT" */
6072 FILE_TYPE(FILE_TYPE_TEXT);
6074 /* Try to write a new "Bones File" */
6075 fp = my_fopen(str, "w");
6077 /* Not allowed to write it? Weird. */
6081 fprintf(fp, "%s\n", player_name);
6082 fprintf(fp, "%d\n", p_ptr->mhp);
6083 fprintf(fp, "%d\n", p_ptr->prace);
6084 fprintf(fp, "%d\n", p_ptr->pclass);
6086 /* Close and save the Bones file */
6095 * Redefinable "print_tombstone" action
6097 bool (*tombstone_aux)(void) = NULL;
6101 * Display a "tomb-stone"
6103 static void print_tomb(void)
6107 /* Do we use a special tombstone ? */
6110 /* Use tombstone hook */
6111 done = (*tombstone_aux)();
6114 /* Print the text-tombstone */
6128 time_t ct = time((time_t)0);
6134 /* Build the filename */
6136 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6138 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6142 /* Open the News file */
6143 fp = my_fopen(buf, "r");
6150 /* Dump the file to the screen */
6151 while (0 == my_fgets(fp, buf, 1024))
6153 /* Display and advance */
6154 put_str(buf, i++, 0);
6163 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6177 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6180 center_string(buf, player_name);
6181 put_str(buf, 6, 11);
6184 center_string(buf, "the");
6185 put_str(buf, 7, 11);
6188 center_string(buf, p);
6189 put_str(buf, 8, 11);
6192 center_string(buf, cp_ptr->title);
6194 put_str(buf, 10, 11);
6197 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6199 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6202 center_string(buf, tmp);
6203 put_str(buf, 11, 11);
6206 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6208 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6211 center_string(buf, tmp);
6212 put_str(buf, 12, 11);
6215 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6217 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6220 center_string(buf, tmp);
6221 put_str(buf, 13, 11);
6224 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6225 if (streq(died_from, "ÅÓÃ潪λ"))
6227 strcpy(tmp, "<¼«»¦>");
6231 if (streq(died_from, "ripe"))
6233 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6235 else if (streq(died_from, "Seppuku"))
6237 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6241 strcpy(tmp, died_from);
6244 center_string(buf, tmp);
6245 put_str(buf, 14, 11);
6247 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6249 if( dun_level == 0 )
6251 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6252 if(streq(died_from, "ÅÓÃ潪λ"))
6254 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6258 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6263 if(streq(died_from, "ÅÓÃ潪λ"))
6265 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6269 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6272 center_string(buf, tmp);
6273 put_str(buf, 15, 11);
6276 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6277 center_string(buf, tmp);
6278 put_str(buf, 14, 11);
6281 if (strlen(died_from) > 24)
6283 strncpy(dummy, died_from, 24);
6285 (void)sprintf(tmp, "by %s.", dummy);
6288 (void)sprintf(tmp, "by %s.", died_from);
6290 center_string(buf, tmp);
6291 put_str(buf, 15, 11);
6296 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6297 center_string(buf, tmp);
6298 put_str(buf, 17, 11);
6301 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6303 msg_format("Goodbye, %s!", player_name);
6311 * Display some character info
6313 static void show_info(void)
6319 /* Hack -- Know everything in the inven/equip */
6320 for (i = 0; i < INVEN_TOTAL; i++)
6322 o_ptr = &inventory[i];
6324 /* Skip non-objects */
6325 if (!o_ptr->k_idx) continue;
6327 /* Aware and Known */
6328 object_aware(o_ptr);
6329 object_known(o_ptr);
6332 for (i = 1; i < max_towns; i++)
6334 st_ptr = &town[i].store[STORE_HOME];
6336 /* Hack -- Know everything in the home */
6337 for (j = 0; j < st_ptr->stock_num; j++)
6339 o_ptr = &st_ptr->stock[j];
6341 /* Skip non-objects */
6342 if (!o_ptr->k_idx) continue;
6344 /* Aware and Known */
6345 object_aware(o_ptr);
6346 object_known(o_ptr);
6350 /* Hack -- Recalculate bonuses */
6351 p_ptr->update |= (PU_BONUS);
6356 /* Flush all input keys */
6359 /* Flush messages */
6363 /* Describe options */
6365 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6366 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6368 prt("You may now dump a character record to one or more files.", 21, 0);
6369 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6373 /* Dump character records as requested */
6380 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6382 put_str("Filename: ", 23, 0);
6387 strcpy(out_val, "");
6389 /* Ask for filename (or abort) */
6390 if (!askfor_aux(out_val, 60)) return;
6392 /* Return means "show on screen" */
6393 if (!out_val[0]) break;
6398 /* Dump a character file */
6399 (void)file_character(out_val, TRUE);
6407 /* Display player */
6410 /* Prompt for inventory */
6412 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6414 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6418 /* Allow abort at this point */
6419 if (inkey() == ESCAPE) return;
6422 /* Show equipment and inventory */
6424 /* Equipment -- if any */
6428 item_tester_full = TRUE;
6429 (void)show_equip(0);
6431 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6433 prt("You are using: -more-", 0, 0);
6436 if (inkey() == ESCAPE) return;
6439 /* Inventory -- if any */
6443 item_tester_full = TRUE;
6444 (void)show_inven(0);
6446 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6448 prt("You are carrying: -more-", 0, 0);
6451 if (inkey() == ESCAPE) return;
6454 /* Homes in the different towns */
6455 for (l = 1; l < max_towns; l++)
6457 st_ptr = &town[l].store[STORE_HOME];
6459 /* Home -- if anything there */
6460 if (st_ptr->stock_num)
6462 /* Display contents of the home */
6463 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6469 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6471 char o_name[MAX_NLEN];
6475 o_ptr = &st_ptr->stock[i];
6477 /* Print header, clear line */
6478 sprintf(tmp_val, "%c) ", I2A(j));
6479 prt(tmp_val, j+2, 4);
6481 /* Display object description */
6482 object_desc(o_name, o_ptr, TRUE, 3);
6483 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6488 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6490 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6495 if (inkey() == ESCAPE) return;
6502 static bool check_score(void)
6508 if (highscore_fd < 0)
6511 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6513 msg_print("Score file unavailable.");
6520 #ifndef SCORE_WIZARDS
6521 /* Wizard-mode pre-empts scoring */
6522 if (noscore & 0x000F)
6525 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6527 msg_print("Score not registered for wizards.");
6536 /* Borg-mode pre-empts scoring */
6537 if (noscore & 0x00F0)
6540 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6542 msg_print("Score not registered for borgs.");
6550 #ifndef SCORE_CHEATERS
6551 /* Cheaters are not scored */
6552 if (noscore & 0xFF00)
6555 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6557 msg_print("Score not registered for cheaters.");
6567 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6569 if (!total_winner && streq(died_from, "Interrupting"))
6574 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6576 msg_print("Score not registered due to interruption.");
6585 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6587 if (!total_winner && streq(died_from, "Quitting"))
6592 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6594 msg_print("Score not registered due to quitting.");
6604 * Close up the current game (player may or may not be dead)
6606 * This function is called only from "main.c" and "signals.c".
6608 void close_game(void)
6611 bool do_send = TRUE;
6613 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6618 /* Flush the messages */
6621 /* Flush the input */
6625 /* No suspending now */
6626 signals_ignore_tstp();
6629 /* Hack -- Character is now "icky" */
6630 character_icky = TRUE;
6633 /* Build the filename */
6634 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6636 /* Open the high score file, for reading/writing */
6637 highscore_fd = fd_open(buf, O_RDWR);
6643 /* Handle retirement */
6644 if (total_winner) kingly();
6648 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6650 if (!munchkin_death || get_check("Save death? "))
6655 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6657 if (!save_player()) msg_print("death save failed!");
6660 else do_send = FALSE;
6667 /* Show more info */
6675 if ((!send_world_score(do_send)))
6678 if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
6680 if (get_check("Stand by for later score registration? "))
6683 wait_report_score = TRUE;
6686 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6688 if (!save_player()) msg_print("death save failed!");
6692 if (!wait_report_score)
6695 else if (highscore_fd >= 0)
6697 display_scores_aux(0, 10, -1, NULL);
6700 /* Dump bones file */
6709 do_cmd_save_game(FALSE);
6711 /* Prompt for scores XXX XXX XXX */
6713 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6715 prt("Press Return (or Escape).", 0, 40);
6719 /* Predict score (or ESCAPE) */
6720 if (inkey() != ESCAPE) predict_score();
6724 /* Shut the high score file */
6725 (void)fd_close(highscore_fd);
6727 /* Forget the high score fd */
6731 /* Allow suspending now */
6732 signals_handle_tstp();
6737 * Handle abrupt death of the visual system
6739 * This routine is called only in very rare situations, and only
6740 * by certain visual systems, when they experience fatal errors.
6742 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6743 * save file so that player can see tombstone when restart.
6745 void exit_game_panic(void)
6747 /* If nothing important has happened, just quit */
6749 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6751 if (!character_generated || character_saved) quit("panic");
6755 /* Mega-Hack -- see "msg_print()" */
6758 /* Clear the top line */
6761 /* Hack -- turn off some things */
6764 /* Mega-Hack -- Delay death */
6765 if (p_ptr->chp < 0) death = FALSE;
6767 /* Hardcode panic save */
6770 /* Forbid suspend */
6771 signals_ignore_tstp();
6773 /* Indicate panic save */
6775 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6777 (void)strcpy(died_from, "(panic save)");
6781 /* Panic save, or get worried */
6783 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6785 if (!save_player()) quit("panic save failed!");
6789 /* Successful panic save */
6791 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6793 quit("panic save succeeded!");
6800 * Get a random line from a file
6801 * Based on the monster speech patch by Matt Graham,
6803 errr get_rnd_line(cptr file_name, int entry, char *output)
6807 int line, counter, test, numentries;
6812 /* Build the filename */
6813 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6816 fp = my_fopen(buf, "r");
6819 if (!fp) return (-1);
6821 /* Find the entry of the monster */
6824 /* Get a line from the file */
6825 if (my_fgets(fp, buf, 1024) == 0)
6827 /* Count the lines */
6830 /* Look for lines starting with 'N:' */
6831 if ((buf[0] == 'N') && (buf[1] == ':'))
6833 /* Allow default lines */
6840 else if (buf[2] == 'M')
6842 if (r_info[entry].flags1 & RF1_MALE)
6848 else if (buf[2] == 'F')
6850 if (r_info[entry].flags1 & RF1_FEMALE)
6856 /* Get the monster number */
6857 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6859 /* Is it the right monster? */
6868 /* Error while converting the monster number */
6869 msg_format("Error in line %d of %s!",
6870 line_num, file_name);
6878 /* Reached end of file */
6885 /* Get the number of entries */
6889 if (my_fgets(fp, buf, 1024) == 0)
6891 /* Count the lines */
6894 /* Look for the number of entries */
6895 if (isdigit(buf[0]))
6897 /* Get the number of entries */
6898 numentries = atoi(buf);
6904 /* Count the lines */
6907 /* Reached end of file without finding the number */
6908 msg_format("Error in line %d of %s!",
6909 line_num, file_name);
6918 /* Grab an appropriate line number */
6919 line = rand_int(numentries);
6921 /* Get the random line */
6922 for (counter = 0; counter <= line; counter++)
6924 /* Count the lines */
6929 test=my_fgets(fp, buf, 1024);
6930 if(test || buf[0]!='#')break;
6934 /* Try to read the line */
6935 if (my_fgets(fp, buf, 1024) == 0)
6939 /* Found the line */
6940 if (counter == line) break;
6944 /* Error - End of file */
6945 msg_format("Error in line %d of %s!",
6946 line_num, file_name);
6954 strcpy(output, buf);
6961 /* Close the file */
6970 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
6974 for (i=0;i<count;i++){
6975 result=get_rnd_line(file_name, entry, output);
6978 for(j=0 ; j<strlen(output) ; j++) kanji|=iskanji( output[j] );
6987 errr process_pickpref_file(cptr name)
6991 char buf[1024] , *s, *s2, isnew;
6999 bool bypass = FALSE;
7001 /* Build the filename */
7002 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7005 fp = my_fopen(buf, "r");
7008 if (!fp) return (-1);
7011 /* Process the file */
7012 while (0 == my_fgets(fp, buf, 1024))
7017 /* Skip "empty" lines */
7018 if (buf[0] == '\0') continue;
7021 if (buf[0] == '#') continue;
7023 /* Process "?:<expr>" */
7024 if ((buf[0] == '?') && (buf[1] == ':'))
7033 /* Parse the expr */
7034 v = process_pref_file_expr(&s, &f);
7037 bypass = (streq(v, "0") ? TRUE : FALSE);
7043 /* Apply conditionals */
7044 if (bypass) continue;
7046 /* Process "%:<file>" */
7049 /* Process that file if allowed */
7050 (void)process_pickpref_file(buf + 2);
7056 /* Nuke illegal char */
7057 for(i=0 ; buf[i]; i++)
7060 if (iskanji(buf[i]))
7066 if (isspace(buf[i]) && buf[i] != ' ')
7073 if(buf[0] == '!' || buf[0] == '~') s++;
7075 /* Auto-inscription? */
7077 if (s2) {*s2=0; s2++;}
7079 /* Skip empty line */
7080 if (*s == 0) continue;
7082 /* don't mind upper or lower case */
7083 for (i = 0; s[i]; i++)
7094 else if (isupper(s[i]))
7095 s[i] = tolower(s[i]);
7098 /* Already has the same entry? */
7100 for(i=0;i<max_autopick;i++)
7101 if( !strcmp(s,autopick_name[i]) ){isnew=0;break;}
7103 if(isnew==0) continue;
7104 autopick_name [max_autopick] = malloc(strlen(s) + 1);
7105 strcpy(autopick_name [max_autopick], s);
7108 autopick_action[max_autopick] = DONT_AUTOPICK;
7111 autopick_action[max_autopick] = DO_AUTODESTROY;
7114 autopick_action[max_autopick] = DO_AUTOPICK;
7118 autopick_insc[max_autopick] = malloc(strlen(s2) + 1);
7119 strcpy(autopick_insc[max_autopick], s2);
7121 autopick_insc[max_autopick]=NULL;
7124 if(max_autopick==MAX_AUTOPICK) break;
7127 /* Close the file */
7133 static errr counts_seek(int fd, s32b where, bool flag)
7136 char temp1[128], temp2[128];
7137 s32b zero_header[3] = {0L, 0L, 0L};
7140 #ifdef SAVEFILE_USE_UID
7141 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7143 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7145 for (i = 0; temp1[i]; i++)
7146 temp1[i] ^= (i+1) * 63;
7151 if (fd_seek(fd, seekpoint + 3 * sizeof(s32b)))
7153 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7158 fd_seek(fd, seekpoint);
7159 fd_write(fd, (char*)zero_header, 3*sizeof(s32b));
7160 fd_write(fd, (char*)(temp1), sizeof(temp1));
7164 if (strcmp(temp1, temp2) == 0)
7167 seekpoint += 128 + 3 * sizeof(s32b);
7170 return fd_seek(fd, seekpoint + where * sizeof(s32b));
7173 s32b counts_read(int where)
7180 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7182 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7184 fd = fd_open(buf, O_RDONLY);
7186 if (counts_seek(fd, where, FALSE) ||
7187 fd_read(fd, (char*)(&count), sizeof(s32b)))
7195 errr counts_write(int where, s32b count)
7201 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7203 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7205 fd = fd_open(buf, O_RDWR);
7208 /* File type is "DATA" */
7209 FILE_TYPE(FILE_TYPE_DATA);
7211 /* Create a new high score file */
7212 fd = fd_make(buf, 0644);
7215 if (fd_lock(fd, F_WRLCK)) return 1;
7217 counts_seek(fd, where, TRUE);
7218 fd_write(fd, (char*)(&count), sizeof(s32b));
7220 if (fd_lock(fd, F_UNLCK)) return 1;
7228 #ifdef HANDLE_SIGNALS
7235 * Handle signals -- suspend
7237 * Actually suspend the game, and then resume cleanly
7239 static void handle_signal_suspend(int sig)
7241 /* Disable handler */
7242 (void)signal(sig, SIG_IGN);
7249 /* Suspend the "Term" */
7250 Term_xtra(TERM_XTRA_ALIVE, 0);
7252 /* Suspend ourself */
7253 (void)kill(0, SIGSTOP);
7255 /* Resume the "Term" */
7256 Term_xtra(TERM_XTRA_ALIVE, 1);
7258 /* Redraw the term */
7261 /* Flush the term */
7266 /* Restore handler */
7267 (void)signal(sig, handle_signal_suspend);
7272 * Handle signals -- simple (interrupt and quit)
7274 * This function was causing a *huge* number of problems, so it has
7275 * been simplified greatly. We keep a global variable which counts
7276 * the number of times the user attempts to kill the process, and
7277 * we commit suicide if the user does this a certain number of times.
7279 * We attempt to give "feedback" to the user as he approaches the
7280 * suicide thresh-hold, but without penalizing accidental keypresses.
7282 * To prevent messy accidents, we should reset this global variable
7283 * whenever the user enters a keypress, or something like that.
7285 static void handle_signal_simple(int sig)
7287 /* Disable handler */
7288 (void)signal(sig, SIG_IGN);
7291 /* Nothing to save, just quit */
7292 if (!character_generated || character_saved) quit(NULL);
7295 /* Count the signals */
7299 /* Terminate dead characters */
7302 /* Mark the savefile */
7304 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7306 (void)strcpy(died_from, "Abortion");
7325 /* Allow suicide (after 5) */
7326 else if (signal_count >= 5)
7328 /* Cause of "death" */
7330 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7332 (void)strcpy(died_from, "Interrupting");
7347 p_ptr->leaving = TRUE;
7361 /* Give warning (after 4) */
7362 else if (signal_count >= 4)
7365 Term_xtra(TERM_XTRA_NOISE, 0);
7367 /* Clear the top line */
7368 Term_erase(0, 0, 255);
7370 /* Display the cause */
7372 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7374 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7382 /* Give warning (after 2) */
7383 else if (signal_count >= 2)
7386 Term_xtra(TERM_XTRA_NOISE, 0);
7389 /* Restore handler */
7390 (void)signal(sig, handle_signal_simple);
7395 * Handle signal -- abort, kill, etc
7397 static void handle_signal_abort(int sig)
7399 /* Disable handler */
7400 (void)signal(sig, SIG_IGN);
7403 /* Nothing to save, just quit */
7404 if (!character_generated || character_saved) quit(NULL);
7411 /* Clear the bottom line */
7412 Term_erase(0, 23, 255);
7414 /* Give a warning */
7415 Term_putstr(0, 23, -1, TERM_RED,
7417 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7419 "A gruesome software bug LEAPS out at you!");
7425 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7427 Term_putstr(45, 23, -1, TERM_RED, "Panic save...");
7439 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7441 (void)strcpy(died_from, "(panic save)");
7445 /* Forbid suspend */
7446 signals_ignore_tstp();
7448 /* Attempt to save */
7452 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7454 Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
7463 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7465 Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
7475 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7477 quit("software bug");
7486 * Ignore SIGTSTP signals (keyboard suspend)
7488 void signals_ignore_tstp(void)
7492 (void)signal(SIGTSTP, SIG_IGN);
7498 * Handle SIGTSTP signals (keyboard suspend)
7500 void signals_handle_tstp(void)
7504 (void)signal(SIGTSTP, handle_signal_suspend);
7511 * Prepare to handle the relevant signals
7513 void signals_init(void)
7517 (void)signal(SIGHUP, SIG_IGN);
7522 (void)signal(SIGTSTP, handle_signal_suspend);
7527 (void)signal(SIGINT, handle_signal_simple);
7531 (void)signal(SIGQUIT, handle_signal_simple);
7536 (void)signal(SIGFPE, handle_signal_abort);
7540 (void)signal(SIGILL, handle_signal_abort);
7544 (void)signal(SIGTRAP, handle_signal_abort);
7548 (void)signal(SIGIOT, handle_signal_abort);
7552 (void)signal(SIGKILL, handle_signal_abort);
7556 (void)signal(SIGBUS, handle_signal_abort);
7560 (void)signal(SIGSEGV, handle_signal_abort);
7564 (void)signal(SIGTERM, handle_signal_abort);
7568 (void)signal(SIGPIPE, handle_signal_abort);
7572 (void)signal(SIGEMT, handle_signal_abort);
7576 (void)signal(SIGDANGER, handle_signal_abort);
7580 (void)signal(SIGSYS, handle_signal_abort);
7584 (void)signal(SIGXCPU, handle_signal_abort);
7588 (void)signal(SIGPWR, handle_signal_abort);
7594 #else /* HANDLE_SIGNALS */
7600 void signals_ignore_tstp(void)
7607 void signals_handle_tstp(void)
7614 void signals_init(void)
7617 #endif /* HANDLE_SIGNALS */