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 /* Require "?:*" format */
411 if (buf[1] != ':') return (1);
414 /* Process "%:<fname>" */
417 /* Attempt to Process the given file */
418 return (process_pref_file(buf + 2));
422 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
425 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
428 i = (huge)strtol(zz[0], NULL, 0);
429 n1 = strtol(zz[1], NULL, 0);
430 n2 = strtol(zz[2], NULL, 0);
431 if (i >= max_r_idx) return (1);
433 if (n1) r_ptr->x_attr = n1;
434 if (n2) r_ptr->x_char = n2;
439 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
440 else if (buf[0] == 'K')
442 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
445 i = (huge)strtol(zz[0], NULL, 0);
446 n1 = strtol(zz[1], NULL, 0);
447 n2 = strtol(zz[2], NULL, 0);
448 if (i >= max_k_idx) return (1);
450 if (n1) k_ptr->x_attr = n1;
451 if (n2) k_ptr->x_char = n2;
456 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
457 else if (buf[0] == 'F')
459 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
462 i = (huge)strtol(zz[0], NULL, 0);
463 n1 = strtol(zz[1], NULL, 0);
464 n2 = strtol(zz[2], NULL, 0);
465 if (i >= max_f_idx) return (1);
467 if (n1) f_ptr->x_attr = n1;
468 if (n2) f_ptr->x_char = n2;
473 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
474 else if (buf[0] == 'S')
476 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
478 j = (byte)strtol(zz[0], NULL, 0);
479 n1 = strtol(zz[1], NULL, 0);
480 n2 = strtol(zz[2], NULL, 0);
481 misc_to_attr[j] = n1;
482 misc_to_char[j] = n2;
487 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
488 else if (buf[0] == 'U')
490 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
492 j = (huge)strtol(zz[0], NULL, 0);
493 n1 = strtol(zz[1], NULL, 0);
494 n2 = strtol(zz[2], NULL, 0);
495 for (i = 1; i < max_k_idx; i++)
497 object_kind *k_ptr = &k_info[i];
498 if (k_ptr->tval == j)
500 if (n1) k_ptr->d_attr = n1;
501 if (n2) k_ptr->d_char = n2;
508 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
509 else if (buf[0] == 'E')
511 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
513 j = (byte)strtol(zz[0], NULL, 0) % 128;
514 n1 = strtol(zz[1], NULL, 0);
515 if (n1) tval_to_attr[j] = n1;
521 /* Process "A:<str>" -- save an "action" for later */
522 else if (buf[0] == 'A')
524 text_to_ascii(macro__buf, buf+2);
528 /* Process "P:<str>" -- normal macro */
529 else if (buf[0] == 'P')
532 text_to_ascii(tmp, buf+2);
533 macro_add(tmp, macro__buf);
538 /* Process "C:<str>" -- create keymap */
539 else if (buf[0] == 'C')
545 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return (1);
547 mode = strtol(zz[0], NULL, 0);
548 if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1);
550 text_to_ascii(tmp, zz[1]);
551 if (!tmp[0] || tmp[1]) return (1);
554 string_free(keymap_act[mode][i]);
556 keymap_act[mode][i] = string_make(macro__buf);
562 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
563 else if (buf[0] == 'V')
565 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
567 i = (byte)strtol(zz[0], NULL, 0);
568 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
569 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
570 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
571 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
577 /* Process "X:<str>" -- turn option off */
578 else if (buf[0] == 'X')
580 for (i = 0; option_info[i].o_desc; i++)
582 int os = option_info[i].o_set;
583 int ob = option_info[i].o_bit;
585 if (option_info[i].o_var &&
586 option_info[i].o_text &&
587 streq(option_info[i].o_text, buf + 2) &&
588 (!alive || option_info[i].o_page !=6))
591 option_flag[os] &= ~(1L << ob);
592 (*option_info[i].o_var) = FALSE;
598 /* Process "Y:<str>" -- turn option on */
599 else if (buf[0] == 'Y')
601 for (i = 0; option_info[i].o_desc; i++)
603 int os = option_info[i].o_set;
604 int ob = option_info[i].o_bit;
606 if (option_info[i].o_var &&
607 option_info[i].o_text &&
608 streq(option_info[i].o_text, buf + 2) &&
609 (!alive || option_info[i].o_page !=6))
612 option_flag[os] |= (1L << ob);
613 (*option_info[i].o_var) = TRUE;
619 /* Process "Z:<type>:<str>" -- set spell color */
620 else if (buf[0] == 'Z')
623 char *t = strchr(buf + 2, ':');
631 for (i = 0; gf_desc[i].name; i++)
633 /* Match this type */
634 if (streq(gf_desc[i].name, buf + 2))
636 /* Remember this color set */
637 gf_color[gf_desc[i].num] = quark_add(t);
644 /* set macro trigger names and a template */
645 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
646 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
647 else if (buf[0] == 'T')
650 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
656 if (macro_template != NULL)
658 free(macro_template);
659 macro_template = NULL;
660 for (i = 0; i < max_macrotrigger; i++)
661 free(macro_trigger_name[i]);
662 max_macrotrigger = 0;
665 if (*zz[0] == '\0') return 0; /* clear template */
667 if (2 + num != tok) return 1; /* error */
669 len = strlen(zz[0])+1+num+1;
670 for (i = 0; i < num; i++)
671 len += strlen(zz[2+i])+1;
672 macro_template = malloc(len);
674 strcpy(macro_template, zz[0]);
676 macro_template + strlen(macro_template) + 1;
677 strcpy(macro_modifier_chr, zz[1]);
678 macro_modifier_name[0] =
679 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
680 for (i = 0; i < num; i++)
682 strcpy(macro_modifier_name[i], zz[2+i]);
683 macro_modifier_name[i+1] = macro_modifier_name[i] +
684 strlen(macro_modifier_name[i]) + 1;
691 if (max_macrotrigger >= MAX_MACRO_TRIG)
694 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
696 msg_print("Too many macro triggers!");
700 m = max_macrotrigger;
703 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
705 len += strlen(zz[2]) + 1;
706 macro_trigger_name[m] = malloc(len);
708 t = macro_trigger_name[m];
717 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
718 strlen(macro_trigger_name[m]) + 1;
719 strcpy(macro_trigger_keycode[0][m], zz[1]);
722 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
723 strlen(macro_trigger_keycode[0][m]) + 1;
724 strcpy(macro_trigger_keycode[1][m], zz[2]);
728 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
740 * Helper function for "process_pref_file()"
743 * v: output buffer array
749 static cptr process_pref_file_expr(char **sp, char *fp)
766 while (isspace(*s)) s++;
784 t = process_pref_file_expr(&s, &f);
793 else if (streq(t, "IOR"))
796 while (*s && (f != b2))
798 t = process_pref_file_expr(&s, &f);
799 if (*t && !streq(t, "0")) v = "1";
804 else if (streq(t, "AND"))
807 while (*s && (f != b2))
809 t = process_pref_file_expr(&s, &f);
810 if (*t && streq(t, "0")) v = "0";
815 else if (streq(t, "NOT"))
818 while (*s && (f != b2))
820 t = process_pref_file_expr(&s, &f);
821 if (*t && streq(t, "1")) v = "0";
826 else if (streq(t, "EQU"))
831 t = process_pref_file_expr(&s, &f);
833 while (*s && (f != b2))
836 t = process_pref_file_expr(&s, &f);
837 if (*t && !streq(p, t)) v = "0";
842 else if (streq(t, "LEQ"))
847 t = process_pref_file_expr(&s, &f);
849 while (*s && (f != b2))
852 t = process_pref_file_expr(&s, &f);
853 if (*t && (strcmp(p, t) > 0)) v = "0";
858 else if (streq(t, "GEQ"))
863 t = process_pref_file_expr(&s, &f);
865 while (*s && (f != b2))
868 t = process_pref_file_expr(&s, &f);
869 if (*t && (strcmp(p, t) < 0)) v = "0";
876 while (*s && (f != b2))
878 t = process_pref_file_expr(&s, &f);
883 if (f != b2) v = "?x?x?";
885 /* Extract final and Terminate */
886 if ((f = *s) != '\0') *s++ = '\0';
892 /* Accept all printables except spaces and brackets */
893 while (isprint(*s) && !strchr(" []", *s)) ++s;
895 /* Extract final and Terminate */
896 if ((f = *s) != '\0') *s++ = '\0';
902 if (streq(b+1, "SYS"))
907 else if (streq(b+1, "KEYBOARD"))
909 v = ANGBAND_KEYBOARD;
913 else if (streq(b+1, "GRAF"))
918 /* Monochrome mode */
919 else if (streq(b+1, "MONOCHROME"))
928 else if (streq(b+1, "RACE"))
938 else if (streq(b+1, "CLASS"))
948 else if (streq(b+1, "REALM1"))
951 v = E_realm_names[p_ptr->realm1];
953 v = realm_names[p_ptr->realm1];
958 else if (streq(b+1, "REALM2"))
961 v = E_realm_names[p_ptr->realm2];
963 v = realm_names[p_ptr->realm2];
968 else if (streq(b+1, "PLAYER"))
974 else if (streq(b+1, "REALM1"))
977 v = E_realm_names[p_ptr->realm1];
979 v = realm_names[p_ptr->realm1];
984 else if (streq(b+1, "REALM2"))
987 v = E_realm_names[p_ptr->realm2];
989 v = realm_names[p_ptr->realm2];
994 else if (streq(b+1, "LEVEL"))
996 sprintf(tmp, "%02d", p_ptr->lev);
1021 * Process line for auto picker/destroyer.
1023 static errr process_pickpref_file_line(char *buf)
1029 /* Nuke illegal char */
1030 for(i = 0; buf[i]; i++)
1033 if (iskanji(buf[i]))
1039 if (isspace(buf[i]) && buf[i] != ' ')
1046 act = DO_AUTOPICK | DO_DISPLAY;
1051 act &= ~DO_AUTOPICK;
1052 act |= DO_AUTODESTROY;
1057 act &= ~DO_AUTOPICK;
1058 act |= DONT_AUTOPICK;
1070 /* don't mind upper or lower case */
1072 for (i = 0; s[i]; i++)
1082 s[i] = tolower(s[i]);
1084 /* Auto-inscription? */
1093 /* Skip empty line */
1096 if (max_autopick == MAX_AUTOPICK)
1099 /* Already has the same entry? */
1100 for(i = 0; i < max_autopick; i++)
1101 if(!strcmp(s, autopick_name[i]))
1104 autopick_name[max_autopick] = string_make(s);
1105 autopick_action[max_autopick] = act;
1107 autopick_insc[max_autopick] = string_make(s2);
1115 * Open the "user pref file" and parse it.
1117 static errr process_pref_file_aux(cptr name, bool read_pickpref)
1129 bool bypass = FALSE;
1133 fp = my_fopen(name, "r");
1136 if (!fp) return (-1);
1138 /* Process the file */
1139 while (0 == my_fgets(fp, buf, 1024))
1144 /* Skip "empty" lines */
1145 if (!buf[0]) continue;
1147 /* Skip "blank" lines */
1149 if (!iskanji(buf[0]))
1151 if (isspace(buf[0])) continue;
1154 if (buf[0] == '#') continue;
1161 /* Process "?:<expr>" */
1162 if ((buf[0] == '?') && (buf[1] == ':'))
1171 /* Parse the expr */
1172 v = process_pref_file_expr(&s, &f);
1175 bypass = (streq(v, "0") ? TRUE : FALSE);
1181 /* Apply conditionals */
1182 if (bypass) continue;
1185 /* Process "%:<file>" */
1188 /* Process that file if allowed */
1190 (void)process_pickpref_file(buf + 2);
1192 (void)process_pref_file(buf + 2);
1199 /* Process the line */
1200 err = process_pref_file_command(buf);
1202 /* This is not original pref line... */
1207 err = process_pickpref_file_line(buf);
1215 /* Print error message */
1216 /* ToDo: Add better error messages */
1218 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1219 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1221 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1222 msg_format("Parsing '%s'", old);
1227 /* Close the file */
1237 * Process the "user pref file" with the given name
1239 * See the functions above for a list of legal "commands".
1241 * We also accept the special "?" and "%" directives, which
1242 * allow conditional evaluation and filename inclusion.
1244 errr process_pref_file(cptr name)
1250 /* Build the filename */
1251 path_build(buf, 1024, ANGBAND_DIR_PREF, name);
1253 /* Process the pref file */
1254 err = process_pref_file_aux(buf, FALSE);
1256 /* Stop at parser errors, but not at non-existing file */
1259 /* Build the filename */
1260 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1262 /* Process the pref file */
1263 err = process_pref_file_aux(buf, FALSE);
1275 * Operating hours for ANGBAND (defaults to non-work hours)
1277 static char days[7][29] =
1279 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1280 "MON:XXXXXXXX.........XXXXXXX",
1281 "TUE:XXXXXXXX.........XXXXXXX",
1282 "WED:XXXXXXXX.........XXXXXXX",
1283 "THU:XXXXXXXX.........XXXXXXX",
1284 "FRI:XXXXXXXX.........XXXXXXX",
1285 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1289 * Restict usage (defaults to no restrictions)
1291 static bool check_time_flag = FALSE;
1299 errr check_time(void)
1307 /* No restrictions */
1308 if (!check_time_flag) return (0);
1310 /* Check for time violation */
1311 c = time((time_t *)0);
1315 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1326 * Initialize CHECK_TIME
1328 errr check_time_init(void)
1338 /* Build the filename */
1339 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1342 fp = my_fopen(buf, "r");
1344 /* No file, no restrictions */
1345 if (!fp) return (0);
1347 /* Assume restrictions */
1348 check_time_flag = TRUE;
1350 /* Parse the file */
1351 while (0 == my_fgets(fp, buf, 80))
1353 /* Skip comments and blank lines */
1354 if (!buf[0] || (buf[0] == '#')) continue;
1356 /* Chop the buffer */
1359 /* Extract the info */
1360 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1361 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1362 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1363 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1364 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1365 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1366 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1382 #ifndef MAXHOSTNAMELEN
1383 # define MAXHOSTNAMELEN 64
1386 typedef struct statstime statstime;
1392 unsigned int v_pgpgin;
1393 unsigned int v_pgpgout;
1394 unsigned int v_pswpin;
1395 unsigned int v_pswpout;
1396 unsigned int v_intr;
1402 unsigned int v_swtch;
1404 struct timeval boottime;
1405 struct timeval curtime;
1409 * Maximal load (if any).
1411 static int check_load_value = 0;
1419 errr check_load(void)
1424 struct statstime st;
1426 /* Success if not checking */
1427 if (!check_load_value) return (0);
1429 /* Check the load */
1430 if (0 == rstat("localhost", &st))
1432 long val1 = (long)(st.avenrun[2]);
1433 long val2 = (long)(check_load_value) * FSCALE;
1435 /* Check for violation */
1436 if (val1 >= val2) return (1);
1447 * Initialize CHECK_LOAD
1449 errr check_load_init(void)
1458 char temphost[MAXHOSTNAMELEN+1];
1459 char thishost[MAXHOSTNAMELEN+1];
1462 /* Build the filename */
1463 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1465 /* Open the "load" file */
1466 fp = my_fopen(buf, "r");
1468 /* No file, no restrictions */
1469 if (!fp) return (0);
1472 check_load_value = 100;
1474 /* Get the host name */
1475 (void)gethostname(thishost, (sizeof thishost) - 1);
1478 while (0 == my_fgets(fp, buf, 1024))
1482 /* Skip comments and blank lines */
1483 if (!buf[0] || (buf[0] == '#')) continue;
1485 /* Parse, or ignore */
1486 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1488 /* Skip other hosts */
1489 if (!streq(temphost, thishost) &&
1490 !streq(temphost, "localhost")) continue;
1492 /* Use that value */
1493 check_load_value = value;
1499 /* Close the file */
1510 * Print long number with header at given row, column
1511 * Use the color for the number, not the header
1513 static void prt_lnum(cptr header, s32b num, int row, int col, byte color)
1515 int len = strlen(header);
1517 put_str(header, row, col);
1518 (void)sprintf(out_val, "%9ld", (long)num);
1519 c_put_str(color, out_val, row, col + len);
1524 * Print number with header at given row, column
1526 static void prt_num(cptr header, int num, int row, int col, byte color)
1528 int len = strlen(header);
1530 put_str(header, row, col);
1531 put_str(" ", row, col + len);
1532 (void)sprintf(out_val, "%6ld", (long)num);
1533 c_put_str(color, out_val, row, col + len + 3);
1539 * £È£Ð / ºÇÂç ¤Î¤è¤¦¤Êɽ¼¨
1542 static void prt_num_max( int num, int max , int row, int col, byte color1, byte color2 )
1545 (void)sprintf(out_val, "%5ld", (long)num);
1546 c_put_str(color1, out_val, row, col );
1547 put_str("/",row, col+6);
1548 (void)sprintf(out_val, "%5ld", (long)max);
1549 c_put_str(color2, out_val, row, col+8 );
1553 * xx ºÐ ¤È¤« xx kg ¤Ê¤É¤Îɽ¼¨ÍÑ cptr tailer ¤Ëñ°Ì¤¬Æþ¤ë¡£
1555 static void prt_num2(cptr header, cptr tailer, int num, int row, int col, byte color)
1557 int len = strlen(header);
1559 put_str(header, row, col);
1560 put_str(" ", row, col + len);
1561 (void)sprintf(out_val, "%6ld", (long)num);
1562 c_put_str(color, out_val, row, col + len + 3);
1563 put_str(tailer, row, col + len + 3+6);
1567 * Prints the following information on the screen.
1569 * For this to look right, the following should be spaced the
1570 * same as in the prt_lnum code... -CFT
1572 static void display_player_middle(void)
1578 int show_tohit, show_todam;
1584 show_tohit = p_ptr->dis_to_h[0];
1585 show_todam = p_ptr->dis_to_d[0];
1587 o_ptr = &inventory[INVEN_RARM];
1589 /* Hack -- add in weapon info if known */
1590 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1591 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1594 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1596 /* Dump the bonuses to hit/dam */
1598 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1599 Term_putstr(1, 9, -1, TERM_WHITE, "ÂǷ⽤Àµ(³ÊÆ®)");
1600 else if(p_ptr->ryoute)
1601 Term_putstr(1, 9, -1, TERM_WHITE, "ÂǷ⽤Àµ(ξ¼ê)");
1603 Term_putstr(1, 9, -1, TERM_WHITE, (left_hander ? "ÂǷ⽤Àµ(º¸¼ê)" : "ÂǷ⽤Àµ(±¦¼ê)"));
1605 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1606 Term_putstr(1, 9, -1, TERM_WHITE, "Melee(bare h.)");
1607 else if(p_ptr->ryoute)
1608 Term_putstr(1, 9, -1, TERM_WHITE, "Melee(2hands)");
1610 Term_putstr(1, 9, -1, TERM_WHITE, (left_hander ? "Melee(Left)" : "Melee(Right)"));
1612 Term_putstr(15, 9, -1, TERM_L_BLUE, format("%11s", buf));
1617 show_tohit = p_ptr->dis_to_h[1];
1618 show_todam = p_ptr->dis_to_d[1];
1620 o_ptr = &inventory[INVEN_LARM];
1622 /* Hack -- add in weapon info if known */
1623 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1624 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1627 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1629 /* Dump the bonuses to hit/dam */
1631 Term_putstr(1, 10, -1, TERM_WHITE, (left_hander ? "ÂǷ⽤Àµ(±¦¼ê)" : "ÂǷ⽤Àµ(º¸¼ê)"));
1633 Term_putstr(1, 10, -1, TERM_WHITE, "Melee(Left)");
1635 Term_putstr(15, 10, -1, TERM_L_BLUE, format("%11s", buf));
1637 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1640 if (p_ptr->special_defense & KAMAE_MASK)
1642 for (i = 0; i < MAX_KAMAE; i++)
1644 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1647 if (i < MAX_KAMAE) Term_putstr(16, 10, -1, TERM_YELLOW, format("%s¤Î¹½¤¨", kamae_shurui[i].desc));
1649 if (i < MAX_KAMAE) Term_putstr(10, 10, -1, TERM_YELLOW, format("%11.11s form", kamae_shurui[i].desc));
1654 Term_putstr(18, 10, -1, TERM_YELLOW, "¹½¤¨¤Ê¤·");
1656 Term_putstr(16, 10, -1, TERM_YELLOW, "no posture");
1661 o_ptr = &inventory[INVEN_BOW];
1664 show_tohit = p_ptr->dis_to_h_b;
1667 /* Apply weapon bonuses */
1668 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1669 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1671 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1674 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1676 Term_putstr(1, 11, -1, TERM_WHITE, "¼Í·â¹¶·â½¤Àµ");
1678 Term_putstr(1, 11, -1, TERM_WHITE, "Shoot");
1680 Term_putstr(15, 11, -1, TERM_L_BLUE, format("%11s", buf));
1683 if (inventory[INVEN_BOW].k_idx)
1685 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1687 /* Get extra "power" from "extra might" */
1688 if (p_ptr->xtra_might) tmul++;
1690 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1692 sprintf(buf, "x%d.%02d", tmul/100, tmul%100);
1694 Term_putstr(1, 12, -1, TERM_WHITE, "¼Í·âÉð´ïÇÜΨ");
1696 Term_putstr(1, 12, -1, TERM_WHITE, "Shoot Power");
1698 Term_putstr(15, 12, -1, TERM_L_BLUE, format("%11s", buf));
1700 /* Dump the armor class bonus */
1702 prt_num("AC ½¤Àµ ", p_ptr->dis_to_a, 13, 1, TERM_L_BLUE);
1704 prt_num("+ To AC ", p_ptr->dis_to_a, 13, 1, TERM_L_BLUE);
1708 /* Dump the total armor class */
1710 prt_num("´ðËÜ AC ", p_ptr->dis_ac, 14, 1, TERM_L_BLUE);
1712 prt_num("Base AC ", p_ptr->dis_ac, 14, 1, TERM_L_BLUE);
1716 prt_num("¥ì¥Ù¥ë ", (int)p_ptr->lev, 9, 28, TERM_L_GREEN);
1718 prt_num("Level ", (int)p_ptr->lev, 9, 28, TERM_L_GREEN);
1721 if (p_ptr->prace == RACE_ANDROID)
1724 put_str("·Ð¸³ÃÍ ", 10, 28);
1726 put_str("Experience ", 10, 28);
1728 c_put_str(TERM_L_GREEN, " *****", 10, 28+11);
1730 else if (p_ptr->exp >= p_ptr->max_exp)
1733 prt_lnum("·Ð¸³ÃÍ ", p_ptr->exp, 10, 28, TERM_L_GREEN);
1735 prt_lnum("Experience ", p_ptr->exp, 10, 28, TERM_L_GREEN);
1742 prt_lnum("·Ð¸³ÃÍ ", p_ptr->exp, 10, 28, TERM_YELLOW);
1744 prt_lnum("Experience ", p_ptr->exp, 10, 28, TERM_YELLOW);
1749 if (p_ptr->prace == RACE_ANDROID)
1752 put_str("ºÇÂç·Ð¸³ ", 11, 28);
1754 put_str("Max Exo ", 11, 28);
1756 c_put_str(TERM_L_GREEN, " *****", 11, 28+11);
1760 prt_lnum("ºÇÂç·Ð¸³ ", p_ptr->max_exp, 11, 28, TERM_L_GREEN);
1762 prt_lnum("Max Exp ", p_ptr->max_exp, 11, 28, TERM_L_GREEN);
1766 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1769 put_str("¼¡¥ì¥Ù¥ë ", 12, 28);
1770 c_put_str(TERM_L_GREEN, " *****", 12, 28+11);
1772 put_str("Exp to Adv", 12, 28);
1773 c_put_str(TERM_L_GREEN, " *****", 12, 28+11);
1780 prt_lnum("¼¡¥ì¥Ù¥ë ",
1782 prt_lnum("Exp to Adv ",
1785 (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L),
1786 12, 28, TERM_L_GREEN);
1790 prt_lnum("½ê»ý¶â ", p_ptr->au, 13, 28, TERM_L_GREEN);
1792 prt_lnum("Gold ", p_ptr->au, 13, 28, TERM_L_GREEN);
1796 prt_lnum("¥¿¡¼¥ó¿ô ", MAX(turn_real(turn),0), 14, 28, TERM_L_GREEN );
1798 prt_lnum("Total turn ", MAX(turn_real(turn),0), 14, 28, TERM_L_GREEN );
1803 put_str(" £È£Ð / ºÇÂç ", 9, 52);
1804 if (p_ptr->chp >= p_ptr->mhp)
1805 statcolor = TERM_L_GREEN;
1807 if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1808 statcolor = TERM_YELLOW;
1811 prt_num_max( p_ptr->chp , p_ptr->mhp, 10, 56, statcolor , TERM_L_GREEN);
1814 prt_num("Max Hit Points ", p_ptr->mhp, 9, 52, TERM_L_GREEN);
1816 if (p_ptr->chp >= p_ptr->mhp)
1818 prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_L_GREEN);
1820 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1822 prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_YELLOW);
1826 prt_num("Cur Hit Points ", p_ptr->chp, 10, 52, TERM_RED);
1833 put_str(" £Í£Ð / ºÇÂç ", 11, 52);
1834 if (p_ptr->csp >= p_ptr->msp)
1835 statcolor = TERM_L_GREEN;
1837 if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1838 statcolor = TERM_YELLOW;
1841 prt_num_max( p_ptr->csp , p_ptr->msp, 12, 56, statcolor , TERM_L_GREEN);
1843 prt_num("Max SP (Mana) ", p_ptr->msp, 11, 52, TERM_L_GREEN);
1845 if (p_ptr->csp >= p_ptr->msp)
1847 prt_num("Cur SP (Mana) ", p_ptr->csp, 12, 52, TERM_L_GREEN);
1849 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1851 prt_num("Cur SP (Mana) ", p_ptr->csp, 12, 52, TERM_YELLOW);
1855 prt_num("Cur SP (Mana) ", p_ptr->csp, 12, 52, TERM_RED);
1859 sprintf(buf, "%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60);
1861 Term_putstr(52, 14, -1, TERM_WHITE, "¥×¥ì¥¤»þ´Ö");
1863 Term_putstr(52, 14, -1, TERM_WHITE, "Playtime");
1865 Term_putstr(63, 14, -1, TERM_L_GREEN, format("%11s", buf));
1871 * Hack -- pass color info around this file
1873 static byte likert_color = TERM_WHITE;
1877 * Returns a "rating" of x depending on y
1879 static cptr likert(int x, int y)
1881 static char dummy[20] = "";
1886 /* Negative value */
1889 likert_color = TERM_L_DARK;
1893 return ("Very Bad");
1898 /* Analyze the value */
1904 likert_color = TERM_RED;
1914 likert_color = TERM_L_RED;
1925 likert_color = TERM_ORANGE;
1935 likert_color = TERM_YELLOW;
1945 likert_color = TERM_YELLOW;
1947 return ("ÂçÊÑÎɤ¤");
1949 return ("Very Good");
1956 likert_color = TERM_L_GREEN;
1960 return ("Excellent");
1970 likert_color = TERM_GREEN;
1983 likert_color = TERM_BLUE;
1985 return ("¥«¥ª¥¹¥é¥ó¥¯");
1987 return ("Chaos Rank");
1993 likert_color = TERM_VIOLET;
1995 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
1997 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2007 * Prints ratings on certain abilities
2009 * This code is "imitated" elsewhere to "dump" a character sheet.
2011 static void display_player_various(void)
2013 int tmp, damage[2], blows1, blows2, i, basedam;
2014 int xthn, xthb, xfos, xsrh;
2015 int xdis, xdev, xsav, xstl;
2019 int shots, shot_frac;
2023 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2024 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2025 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2026 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2027 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2029 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2031 /* Shooting Skill (with current bow and normal missile) */
2032 o_ptr = &inventory[INVEN_BOW];
2033 tmp = p_ptr->to_h_b + o_ptr->to_h;
2034 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2036 /* If the player is wielding one? */
2039 s16b energy_fire = bow_energy(o_ptr->sval);
2041 /* Calculate shots per round */
2042 shots = p_ptr->num_fire * 100;
2043 shot_frac = (shots * 100 / energy_fire) % 100;
2044 shots = shots / energy_fire;
2045 if (o_ptr->name1 == ART_CRIMSON)
2049 if (p_ptr->pclass == CLASS_ARCHER)
2051 /* Extra shot at level 10 */
2052 if (p_ptr->lev >= 10) shots++;
2054 /* Extra shot at level 30 */
2055 if (p_ptr->lev >= 30) shots++;
2057 /* Extra shot at level 45 */
2058 if (p_ptr->lev >= 45) shots++;
2068 for(i = 0; i< 2; i++)
2070 damage[i] = p_ptr->dis_to_d[i]*100;
2071 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2073 int level = p_ptr->lev;
2079 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2080 if (p_ptr->special_defense & KAMAE_BYAKKO)
2081 basedam = monk_ave_damage[level][1];
2082 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2083 basedam = monk_ave_damage[level][2];
2085 basedam = monk_ave_damage[level][0];
2089 /* Average damage per round */
2090 o_ptr = &inventory[INVEN_RARM+i];
2091 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2092 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2093 object_flags(o_ptr, &f1, &f2, &f3);
2094 if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
2100 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2102 /* vorpal flag only */
2106 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)))
2107 basedam = basedam * 7 / 2;
2108 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2109 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2111 damage[i] += basedam;
2112 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2113 if (damage[i] < 0) damage[i] = 0;
2115 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2116 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2118 /* Basic abilities */
2120 xdis = p_ptr->skill_dis;
2121 xdev = p_ptr->skill_dev;
2122 xsav = p_ptr->skill_sav;
2123 xstl = p_ptr->skill_stl;
2124 xsrh = p_ptr->skill_srh;
2125 xfos = p_ptr->skill_fos;
2129 put_str("ÂǷ⹶·âǽÎÏ :", 17, 1);
2131 put_str("Fighting :", 17, 1);
2134 desc = likert(xthn, 12);
2135 c_put_str(likert_color, desc, 17, 15);
2138 put_str("¼Í·â¹¶·âǽÎÏ :", 18, 1);
2140 put_str("Bows/Throw :", 18, 1);
2143 desc = likert(xthb, 12);
2144 c_put_str(likert_color, desc, 18, 15);
2147 put_str("ËâË¡ËɸæǽÎÏ :", 19, 1);
2149 put_str("Saving Throw:", 19, 1);
2152 desc = likert(xsav, 7);
2153 c_put_str(likert_color, desc, 19, 15);
2156 put_str("±£Ì©¹ÔưǽÎÏ :", 20, 1);
2158 put_str("Stealth :", 20, 1);
2161 desc = likert(xstl, 1);
2162 c_put_str(likert_color, desc, 20, 15);
2166 put_str("ÃγÐǽÎÏ :", 17, 28);
2168 put_str("Perception :", 17, 28);
2171 desc = likert(xfos, 6);
2172 c_put_str(likert_color, desc, 17, 42);
2175 put_str("õº÷ǽÎÏ :", 18, 28);
2177 put_str("Searching :", 18, 28);
2180 desc = likert(xsrh, 6);
2181 c_put_str(likert_color, desc, 18, 42);
2184 put_str("²ò½üǽÎÏ :", 19, 28);
2186 put_str("Disarming :", 19, 28);
2189 desc = likert(xdis, 8);
2190 c_put_str(likert_color, desc, 19, 42);
2193 put_str("ËâË¡Æ»¶ñ»ÈÍÑ :", 20, 28);
2195 put_str("Magic Device:", 20, 28);
2198 desc = likert(xdev, 6);
2199 c_put_str(likert_color, desc, 20, 42);
2203 put_str("ÂÇ·â²ó¿ô :", 17, 55);
2205 put_str("Blows/Round:", 17, 55);
2209 put_str(format("%d+%d", blows1, blows2), 17, 69);
2211 put_str(format("%d+%d+%d", blows1, blows2, muta_att), 17, 69);
2214 put_str("¼Í·â²ó¿ô :", 18, 55);
2216 put_str("Shots/Round:", 18, 55);
2219 put_str(format("%d.%02d", shots, shot_frac), 18, 69);
2222 put_str("Ê¿¶Ñ¥À¥á¡¼¥¸:", 19, 55);
2224 put_str("Wpn.dmg/Rnd:", 19, 55); /* From PsiAngband */
2228 if ((damage[0]+damage[1]) == 0)
2231 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2233 put_str(desc, 19, 69);
2236 put_str("ÀÖ³°Àþ»ëÎÏ :", 20, 55);
2238 put_str("Infra-Vision:", 20, 55);
2242 put_str(format("%d feet", p_ptr->see_infra * 10), 20, 69);
2244 put_str(format("%d feet", p_ptr->see_infra * 10), 20, 69);
2252 * Obtain the "flags" for the player as if he was an item
2254 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2257 (*f1) = (*f2) = (*f3) = 0L;
2260 switch (p_ptr->pclass)
2263 if (p_ptr->lev > 44)
2264 (*f3) |= (TR3_REGEN);
2266 if (p_ptr->lev > 29)
2267 (*f2) |= (TR2_RES_FEAR);
2270 if (p_ptr->lev > 39)
2271 (*f2) |= (TR2_RES_FEAR);
2273 case CLASS_CHAOS_WARRIOR:
2274 if (p_ptr->lev > 29)
2275 (*f2) |= (TR2_RES_CHAOS);
2276 if (p_ptr->lev > 39)
2277 (*f2) |= (TR2_RES_FEAR);
2280 case CLASS_FORCETRAINER:
2281 if ((p_ptr->lev > 9) && !heavy_armor())
2283 if ((p_ptr->lev>24) && !heavy_armor())
2284 (*f2) |= (TR2_FREE_ACT);
2291 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2294 (*f2) |= (TR2_FREE_ACT);
2296 (*f3) |= TR3_SLOW_DIGEST;
2297 (*f2) |= TR2_RES_FEAR;
2298 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2299 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2300 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2302 case CLASS_MINDCRAFTER:
2304 (*f2) |= (TR2_RES_FEAR);
2305 if (p_ptr->lev > 19)
2306 (*f2) |= (TR2_SUST_WIS);
2307 if (p_ptr->lev > 29)
2308 (*f2) |= (TR2_RES_CONF);
2309 if (p_ptr->lev > 39)
2310 (*f3) |= (TR3_TELEPATHY);
2313 (*f2) |= (TR2_RES_SOUND);
2315 case CLASS_BERSERKER:
2316 (*f2) |= (TR2_SUST_STR);
2317 (*f2) |= (TR2_SUST_DEX);
2318 (*f2) |= (TR2_SUST_CON);
2319 (*f3) |= (TR3_REGEN);
2320 (*f2) |= (TR2_FREE_ACT);
2321 (*f1) |= (TR1_SPEED);
2322 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2324 case CLASS_MIRROR_MASTER:
2325 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2328 break; /* Do nothing */
2332 if (p_ptr->mimic_form)
2334 switch(p_ptr->mimic_form)
2337 (*f2) |= (TR2_HOLD_LIFE);
2338 (*f2) |= (TR2_RES_CHAOS);
2339 (*f2) |= (TR2_RES_NETHER);
2340 (*f2) |= (TR2_RES_FIRE);
2341 (*f3) |= (TR3_SEE_INVIS);
2342 (*f1) |= (TR1_SPEED);
2344 case MIMIC_DEMON_LORD:
2345 (*f2) |= (TR2_HOLD_LIFE);
2346 (*f2) |= (TR2_RES_CHAOS);
2347 (*f2) |= (TR2_RES_NETHER);
2348 (*f2) |= (TR2_RES_FIRE);
2349 (*f2) |= (TR2_RES_COLD);
2350 (*f2) |= (TR2_RES_ELEC);
2351 (*f2) |= (TR2_RES_ACID);
2352 (*f2) |= (TR2_RES_POIS);
2353 (*f2) |= (TR2_RES_CONF);
2354 (*f2) |= (TR2_RES_DISEN);
2355 (*f2) |= (TR2_RES_NEXUS);
2356 (*f2) |= (TR2_RES_FEAR);
2357 (*f2) |= (TR2_IM_FIRE);
2358 (*f3) |= (TR3_SH_FIRE);
2359 (*f3) |= (TR3_SEE_INVIS);
2360 (*f3) |= (TR3_TELEPATHY);
2361 (*f3) |= (TR3_FEATHER);
2362 (*f1) |= (TR1_SPEED);
2365 (*f2) |= (TR2_HOLD_LIFE);
2366 (*f2) |= (TR2_RES_DARK);
2367 (*f2) |= (TR2_RES_NETHER);
2368 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2369 (*f2) |= (TR2_RES_POIS);
2370 (*f2) |= (TR2_RES_COLD);
2371 (*f3) |= (TR3_SEE_INVIS);
2372 (*f1) |= (TR1_SPEED);
2378 switch (p_ptr->prace)
2381 (*f2) |= (TR2_RES_LITE);
2384 (*f2) |= (TR2_SUST_DEX);
2387 (*f2) |= (TR2_FREE_ACT);
2390 (*f2) |= (TR2_RES_BLIND);
2393 (*f2) |= (TR2_RES_DARK);
2395 case RACE_HALF_TROLL:
2396 (*f2) |= (TR2_SUST_STR);
2397 if (p_ptr->lev > 14)
2399 (*f3) |= (TR3_REGEN);
2400 if (p_ptr->pclass == CLASS_WARRIOR)
2402 (*f3) |= (TR3_SLOW_DIGEST);
2404 * Let's not make Regeneration a disadvantage
2405 * for the poor warriors who can never learn
2406 * a spell that satisfies hunger (actually
2407 * neither can rogues, but half-trolls are not
2408 * supposed to play rogues)
2414 (*f2) |= (TR2_SUST_CON);
2415 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2418 (*f2) |= (TR2_RES_LITE);
2419 (*f3) |= (TR3_SEE_INVIS);
2421 case RACE_BARBARIAN:
2422 (*f2) |= (TR2_RES_FEAR);
2424 case RACE_HALF_OGRE:
2425 (*f2) |= (TR2_SUST_STR);
2426 (*f2) |= (TR2_RES_DARK);
2428 case RACE_HALF_GIANT:
2429 (*f2) |= (TR2_RES_SHARDS);
2430 (*f2) |= (TR2_SUST_STR);
2432 case RACE_HALF_TITAN:
2433 (*f2) |= (TR2_RES_CHAOS);
2436 (*f2) |= (TR2_RES_SOUND);
2439 (*f2) |= (TR2_RES_ACID);
2440 if (p_ptr->lev > 19)
2441 (*f2) |= (TR2_IM_ACID);
2444 (*f2) |= (TR2_RES_CONF);
2445 (*f2) |= (TR2_RES_ACID);
2450 (*f2) |= (TR2_RES_POIS);
2453 (*f2) |= (TR2_RES_DISEN);
2454 (*f2) |= (TR2_RES_DARK);
2457 (*f2) |= (TR2_RES_DARK);
2458 if (p_ptr->lev > 19)
2459 (*f3) |= (TR3_SEE_INVIS);
2461 case RACE_DRACONIAN:
2462 (*f3) |= TR3_FEATHER;
2464 (*f2) |= (TR2_RES_FIRE);
2466 (*f2) |= (TR2_RES_COLD);
2467 if (p_ptr->lev > 14)
2468 (*f2) |= (TR2_RES_ACID);
2469 if (p_ptr->lev > 19)
2470 (*f2) |= (TR2_RES_ELEC);
2471 if (p_ptr->lev > 34)
2472 (*f2) |= (TR2_RES_POIS);
2474 case RACE_MIND_FLAYER:
2475 (*f2) |= (TR2_SUST_INT);
2476 (*f2) |= (TR2_SUST_WIS);
2477 if (p_ptr->lev > 14)
2478 (*f3) |= (TR3_SEE_INVIS);
2479 if (p_ptr->lev > 29)
2480 (*f3) |= (TR3_TELEPATHY);
2483 (*f2) |= (TR2_RES_FIRE);
2485 (*f3) |= (TR3_SEE_INVIS);
2488 (*f3) |= (TR3_SEE_INVIS);
2489 (*f2) |= (TR2_FREE_ACT);
2490 (*f2) |= (TR2_RES_POIS);
2491 (*f3) |= (TR3_SLOW_DIGEST);
2492 if (p_ptr->lev > 34)
2493 (*f2) |= (TR2_HOLD_LIFE);
2496 (*f3) |= (TR3_SEE_INVIS);
2497 (*f2) |= (TR2_RES_SHARDS);
2498 (*f2) |= (TR2_HOLD_LIFE);
2499 (*f2) |= (TR2_RES_POIS);
2501 (*f2) |= (TR2_RES_COLD);
2504 (*f3) |= (TR3_SEE_INVIS);
2505 (*f2) |= (TR2_HOLD_LIFE);
2506 (*f2) |= (TR2_RES_NETHER);
2507 (*f2) |= (TR2_RES_POIS);
2508 (*f3) |= (TR3_SLOW_DIGEST);
2510 (*f2) |= (TR2_RES_COLD);
2513 (*f2) |= (TR2_HOLD_LIFE);
2514 (*f2) |= (TR2_RES_DARK);
2515 (*f2) |= (TR2_RES_NETHER);
2516 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2517 (*f2) |= (TR2_RES_POIS);
2518 (*f2) |= (TR2_RES_COLD);
2521 (*f3) |= (TR3_FEATHER);
2522 (*f2) |= (TR2_FREE_ACT);
2523 (*f2) |= (TR2_RES_COLD);
2524 (*f3) |= (TR3_SEE_INVIS);
2525 (*f2) |= (TR2_HOLD_LIFE);
2526 (*f2) |= (TR2_RES_NETHER);
2527 (*f2) |= (TR2_RES_POIS);
2528 (*f3) |= (TR3_SLOW_DIGEST);
2530 if (p_ptr->lev > 34)
2531 (*f3) |= TR3_TELEPATHY;
2534 (*f2) |= (TR2_RES_LITE);
2535 (*f3) |= (TR3_FEATHER);
2537 (*f1) |= (TR1_SPEED);
2540 (*f2) |= (TR2_RES_SOUND);
2541 (*f2) |= (TR2_RES_CONF);
2544 (*f3) |= (TR3_FEATHER);
2545 (*f3) |= (TR3_SEE_INVIS);
2548 (*f2) |= (TR2_RES_FIRE);
2549 (*f2) |= (TR2_RES_NETHER);
2550 (*f2) |= (TR2_HOLD_LIFE);
2552 (*f3) |= (TR3_SEE_INVIS);
2555 (*f2) |= (TR2_SUST_CON);
2558 (*f3) |= (TR3_FEATHER);
2561 (*f2) |= (TR2_RES_CONF);
2564 (*f2) |= (TR2_FREE_ACT);
2565 (*f2) |= (TR2_RES_POIS);
2566 (*f3) |= (TR3_SLOW_DIGEST);
2567 (*f2) |= (TR2_HOLD_LIFE);
2577 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2579 (*f3) &= ~(TR3_REGEN);
2582 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2583 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2584 (p_ptr->muta3 & MUT3_SHORT_LEG))
2589 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2591 (*f3) |= TR3_SH_ELEC;
2594 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2596 (*f3) |= TR3_SH_FIRE;
2600 if (p_ptr->muta3 & MUT3_WINGS)
2602 (*f3) |= TR3_FEATHER;
2605 if (p_ptr->muta3 & MUT3_FEARLESS)
2607 (*f2) |= (TR2_RES_FEAR);
2610 if (p_ptr->muta3 & MUT3_REGEN)
2615 if (p_ptr->muta3 & MUT3_ESP)
2617 (*f3) |= TR3_TELEPATHY;
2620 if (p_ptr->muta3 & MUT3_MOTION)
2622 (*f2) |= TR2_FREE_ACT;
2626 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2627 (*f3) |= TR3_AGGRAVATE;
2628 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2630 (*f2) |= (TR2_RES_BLIND);
2631 (*f2) |= (TR2_RES_CONF);
2632 (*f2) |= (TR2_HOLD_LIFE);
2633 (*f3) |= (TR3_LITE);
2635 (*f1) |= (TR1_SPEED);
2637 if (p_ptr->special_defense & KATA_FUUJIN)
2638 (*f2) |= TR2_REFLECT;
2639 if (p_ptr->special_defense & KAMAE_GENBU)
2640 (*f2) |= TR2_REFLECT;
2641 if (p_ptr->special_defense & KAMAE_SUZAKU)
2642 (*f3) |= TR3_FEATHER;
2643 if (p_ptr->special_defense & KAMAE_SEIRYU)
2645 (*f2) |= (TR2_RES_FIRE);
2646 (*f2) |= (TR2_RES_COLD);
2647 (*f2) |= (TR2_RES_ACID);
2648 (*f2) |= (TR2_RES_ELEC);
2649 (*f2) |= (TR2_RES_POIS);
2650 (*f3) |= (TR3_FEATHER);
2651 (*f3) |= (TR3_SH_FIRE);
2652 (*f3) |= (TR3_SH_ELEC);
2653 (*f3) |= (TR3_SH_COLD);
2655 if (p_ptr->special_defense & KATA_MUSOU)
2657 (*f2) |= TR2_RES_FEAR;
2658 (*f2) |= TR2_RES_LITE;
2659 (*f2) |= TR2_RES_DARK;
2660 (*f2) |= TR2_RES_BLIND;
2661 (*f2) |= TR2_RES_CONF;
2662 (*f2) |= TR2_RES_SOUND;
2663 (*f2) |= TR2_RES_SHARDS;
2664 (*f2) |= TR2_RES_NETHER;
2665 (*f2) |= TR2_RES_NEXUS;
2666 (*f2) |= TR2_RES_CHAOS;
2667 (*f2) |= TR2_RES_DISEN;
2668 (*f2) |= TR2_REFLECT;
2669 (*f2) |= TR2_HOLD_LIFE;
2670 (*f2) |= TR2_FREE_ACT;
2671 (*f3) |= TR3_SH_FIRE;
2672 (*f3) |= TR3_SH_ELEC;
2673 (*f3) |= TR3_SH_COLD;
2674 (*f3) |= TR3_FEATHER;
2676 (*f3) |= TR3_SEE_INVIS;
2677 (*f3) |= TR3_TELEPATHY;
2678 (*f3) |= TR3_SLOW_DIGEST;
2680 (*f2) |= (TR2_SUST_STR);
2681 (*f2) |= (TR2_SUST_INT);
2682 (*f2) |= (TR2_SUST_WIS);
2683 (*f2) |= (TR2_SUST_DEX);
2684 (*f2) |= (TR2_SUST_CON);
2685 (*f2) |= (TR2_SUST_CHR);
2690 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2693 (*f1) = (*f2) = (*f3) = 0L;
2695 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2696 (*f2) |= TR2_RES_FEAR;
2697 if (p_ptr->tim_invis)
2698 (*f3) |= TR3_SEE_INVIS;
2699 if (p_ptr->tim_regen)
2701 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2702 (*f3) |= TR3_TELEPATHY;
2703 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2705 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2707 (*f2) |= (TR2_RES_FIRE);
2708 (*f2) |= (TR2_RES_COLD);
2709 (*f2) |= (TR2_RES_ACID);
2710 (*f2) |= (TR2_RES_ELEC);
2711 (*f2) |= (TR2_RES_POIS);
2715 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2716 (*f2) |= TR2_RES_ACID;
2717 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2718 (*f2) |= TR2_RES_ELEC;
2719 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2720 (*f2) |= TR2_RES_FIRE;
2721 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2722 (*f2) |= TR2_RES_COLD;
2726 if (p_ptr->oppose_acid)
2727 (*f2) |= TR2_RES_ACID;
2728 if (p_ptr->oppose_elec)
2729 (*f2) |= TR2_RES_ELEC;
2730 if (p_ptr->oppose_fire)
2731 (*f2) |= TR2_RES_FIRE;
2732 if (p_ptr->oppose_cold)
2733 (*f2) |= TR2_RES_COLD;
2735 if (p_ptr->oppose_pois)
2736 (*f2) |= TR2_RES_POIS;
2737 if (p_ptr->special_attack & ATTACK_ACID)
2738 (*f1) |= TR1_BRAND_ACID;
2739 if (p_ptr->special_attack & ATTACK_ELEC)
2740 (*f1) |= TR1_BRAND_ELEC;
2741 if (p_ptr->special_attack & ATTACK_FIRE)
2742 (*f1) |= TR1_BRAND_FIRE;
2743 if (p_ptr->special_attack & ATTACK_COLD)
2744 (*f1) |= TR1_BRAND_COLD;
2745 if (p_ptr->special_attack & ATTACK_POIS)
2746 (*f1) |= TR1_BRAND_POIS;
2747 if (p_ptr->special_defense & DEFENSE_ACID)
2748 (*f2) |= TR2_IM_ACID;
2749 if (p_ptr->special_defense & DEFENSE_ELEC)
2750 (*f2) |= TR2_IM_ELEC;
2751 if (p_ptr->special_defense & DEFENSE_FIRE)
2752 (*f2) |= TR2_IM_FIRE;
2753 if (p_ptr->special_defense & DEFENSE_COLD)
2754 (*f2) |= TR2_IM_COLD;
2755 if (p_ptr->wraith_form)
2756 (*f2) |= TR2_REFLECT;
2758 if (p_ptr->tim_reflect){
2759 (*f2) |= TR2_REFLECT;
2762 if (p_ptr->magicdef)
2764 (*f2) |= TR2_RES_BLIND;
2765 (*f2) |= TR2_RES_CONF;
2766 (*f2) |= TR2_REFLECT;
2767 (*f2) |= TR2_FREE_ACT;
2768 (*f3) |= TR3_FEATHER;
2770 if (p_ptr->tim_res_nether)
2772 (*f2) |= TR2_RES_NETHER;
2774 if (p_ptr->tim_sh_fire)
2776 (*f3) |= TR3_SH_FIRE;
2780 (*f2) |= TR2_RES_FEAR;
2781 (*f2) |= TR2_RES_LITE;
2782 (*f2) |= TR2_RES_DARK;
2783 (*f2) |= TR2_RES_BLIND;
2784 (*f2) |= TR2_RES_CONF;
2785 (*f2) |= TR2_RES_SOUND;
2786 (*f2) |= TR2_RES_SHARDS;
2787 (*f2) |= TR2_RES_NETHER;
2788 (*f2) |= TR2_RES_NEXUS;
2789 (*f2) |= TR2_RES_CHAOS;
2790 (*f2) |= TR2_RES_DISEN;
2791 (*f2) |= TR2_REFLECT;
2792 (*f2) |= TR2_HOLD_LIFE;
2793 (*f2) |= TR2_FREE_ACT;
2794 (*f3) |= TR3_SH_FIRE;
2795 (*f3) |= TR3_SH_ELEC;
2796 (*f3) |= TR3_SH_COLD;
2797 (*f3) |= TR3_FEATHER;
2799 (*f3) |= TR3_SEE_INVIS;
2800 (*f3) |= TR3_TELEPATHY;
2801 (*f3) |= TR3_SLOW_DIGEST;
2803 (*f2) |= (TR2_SUST_STR);
2804 (*f2) |= (TR2_SUST_INT);
2805 (*f2) |= (TR2_SUST_WIS);
2806 (*f2) |= (TR2_SUST_DEX);
2807 (*f2) |= (TR2_SUST_CON);
2808 (*f2) |= (TR2_SUST_CHR);
2816 static void display_player_equippy(int y, int x)
2826 /* Dump equippy chars */
2827 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2830 o_ptr = &inventory[i];
2832 a = object_attr(o_ptr);
2833 c = object_char(o_ptr);
2835 /* Clear the part of the screen */
2836 if (!equippy_chars || !o_ptr->k_idx)
2843 Term_putch(x + i - INVEN_RARM, y, a, c);
2848 void print_equippy(void)
2850 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2857 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2862 (*f1) = (*f2) = (*f3) = 0L;
2864 /* Check equipment */
2865 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2867 u32b o_f1, o_f2, o_f3;
2872 o_ptr = &inventory[i];
2874 if (!o_ptr->k_idx) continue;
2877 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2879 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2880 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2881 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2882 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2886 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2889 (*f1) = (*f2) = (*f3) = 0L;
2891 if (prace_is_(RACE_SPECTRE))
2892 (*f2) |= TR2_RES_NETHER;
2893 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2894 (*f2) |= TR2_RES_DARK;
2895 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2896 (*f2) |= TR2_RES_FIRE;
2897 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2898 (*f2) |= TR2_RES_ACID;
2901 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2904 (*f1) = (*f2) = (*f3) = 0L;
2906 if (p_ptr->special_defense & DEFENSE_ACID)
2907 (*f2) |= TR2_RES_ACID;
2908 if (p_ptr->special_defense & DEFENSE_ELEC)
2909 (*f2) |= TR2_RES_ELEC;
2910 if (p_ptr->special_defense & DEFENSE_FIRE)
2911 (*f2) |= TR2_RES_FIRE;
2912 if (p_ptr->special_defense & DEFENSE_COLD)
2913 (*f2) |= TR2_RES_COLD;
2914 if (p_ptr->wraith_form)
2915 (*f2) |= TR2_RES_DARK;
2918 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2921 (*f1) = (*f2) = (*f3) = 0L;
2923 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2925 (*f2) |= TR2_RES_ACID;
2926 (*f2) |= TR2_RES_ELEC;
2927 (*f2) |= TR2_RES_FIRE;
2928 (*f2) |= TR2_RES_COLD;
2930 if (prace_is_(RACE_ANDROID))
2931 (*f2) |= TR2_RES_ELEC;
2932 if (prace_is_(RACE_ENT))
2933 (*f2) |= TR2_RES_FIRE;
2934 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2935 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2936 (*f2) |= TR2_RES_LITE;
2940 * Helper function, see below
2942 static void display_player_flag_aux(int row, int col, char *header,
2943 int n, u32b flag1, u32b flag2,
2944 u32b im_f[], u32b vul_f)
2950 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2954 c_put_str(TERM_WHITE, header, row, col);
2957 col += strlen(header) + 1;
2959 /* Check equipment */
2960 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2963 f[0] = f[1] = f[2] = 0L;
2966 o_ptr = &inventory[i];
2969 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2972 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2975 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2976 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
2983 player_flags(&f[0], &f[1], &f[2]);
2986 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2989 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2991 /* Timed player flags */
2992 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
2995 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
2998 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
2999 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
3002 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3007 * Special display, part 1
3009 static void display_player_flag_info(void)
3014 u32b im_f[3][3], vul_f[3];
3016 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
3017 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
3018 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
3020 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3027 display_player_equippy(row-2, col+8);
3028 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3031 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3032 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3033 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3034 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3035 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3036 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3037 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3038 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3039 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3040 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3042 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3043 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3044 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3045 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3046 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3047 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3048 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3049 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3050 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3051 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3060 display_player_equippy(row-2, col+8);
3062 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3065 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3066 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3067 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3068 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3069 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3070 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3071 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3072 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3073 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3074 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3076 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3077 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3078 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3079 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3080 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3081 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3082 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3083 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3084 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3085 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3094 display_player_equippy(row-2, col+12);
3096 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3099 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3100 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3101 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3102 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3103 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3104 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3105 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3106 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3107 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3108 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3110 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3111 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3112 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3113 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3114 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3115 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3116 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3117 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3118 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3119 display_player_flag_aux(row+9, col, "Cursed :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3126 * Special display, part 2a
3128 static void display_player_misc_info(void)
3133 /* Display basics */
3135 put_str("̾Á° :", 1, 26);
3136 put_str("ÀÊÌ :", 3, 1);
3137 put_str("¼ï² :", 4, 1);
3138 put_str("¿¦¶È :", 5, 1);
3140 put_str("Name :", 1, 26);
3141 put_str("Sex :", 3, 1);
3142 put_str("Race :", 4, 1);
3143 put_str("Class :", 5, 1);
3146 strcpy(tmp,ap_ptr->title);
3153 strcat(tmp,player_name);
3155 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3156 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3157 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3158 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3160 /* Display extras */
3162 put_str("¥ì¥Ù¥ë:", 6, 1);
3163 put_str("£È£Ð :", 7, 1);
3164 put_str("£Í£Ð :", 8, 1);
3166 put_str("Level :", 6, 1);
3167 put_str("Hits :", 7, 1);
3168 put_str("Mana :", 8, 1);
3172 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3173 c_put_str(TERM_L_BLUE, buf, 6, 9);
3174 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3175 c_put_str(TERM_L_BLUE, buf, 7, 9);
3176 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3177 c_put_str(TERM_L_BLUE, buf, 8, 9);
3182 * Special display, part 2b
3184 * How to print out the modifications and sustains.
3185 * Positive mods with no sustain will be light green.
3186 * Positive mods with a sustain will be dark green.
3187 * Sustains (with no modification) will be a dark green 's'.
3188 * Negative mods (from a curse) will be red.
3189 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3190 * No mod, no sustain, will be a slate '.'
3192 static void display_player_stat_info(void)
3214 /* Print out the labels for the columns */
3216 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3217 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3218 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3219 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3220 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+33);
3222 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3223 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3224 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3225 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3226 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3230 /* Display the stats */
3231 for (i = 0; i < 6; i++)
3235 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3236 else r_adj = rp_ptr->r_adj[i];
3238 /* Calculate equipment adjustment */
3241 /* Icky formula to deal with the 18 barrier */
3242 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3243 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3244 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3245 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3246 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3247 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3249 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3250 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3252 if (prace_is_(RACE_ENT))
3258 if (p_ptr->lev > 25) r_adj++;
3259 if (p_ptr->lev > 40) r_adj++;
3260 if (p_ptr->lev > 45) r_adj++;
3263 if (p_ptr->lev > 25) r_adj--;
3264 if (p_ptr->lev > 40) r_adj--;
3265 if (p_ptr->lev > 45) r_adj--;
3271 e_adj -= cp_ptr->c_adj[i];
3272 e_adj -= ap_ptr->a_adj[i];
3274 /* Reduced name of stat */
3276 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3278 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3282 /* Internal "natural" max value. Maxes at 18/100 */
3283 /* This is useful to see if you are maxed out */
3284 cnv_stat(p_ptr->stat_max[i], buf);
3285 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3287 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3289 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3291 /* Race, class, and equipment modifiers */
3292 (void)sprintf(buf, "%3d", r_adj);
3293 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3294 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3295 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3296 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3297 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3298 (void)sprintf(buf, "%3d", (int)e_adj);
3299 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3301 /* Actual maximal modified value */
3302 cnv_stat(p_ptr->stat_top[i], buf);
3303 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3305 /* Only display stat_use if not maximal */
3306 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3308 cnv_stat(p_ptr->stat_use[i], buf);
3309 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3314 col = stat_col + 41;
3316 /* Header and Footer */
3317 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3319 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3321 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3325 /* Process equipment */
3326 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3329 o_ptr = &inventory[i];
3332 k_idx = o_ptr->k_idx;
3334 /* Acquire "known" flags */
3335 object_flags_known(o_ptr, &f1, &f2, &f3);
3337 /* Initialize color based of sign of pval. */
3338 for (stat = 0; stat < 6; stat++)
3351 if (o_ptr->pval > 0)
3357 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3362 /* Dark green for sustained stats */
3367 if (o_ptr->pval < 0)
3373 if (o_ptr->pval < 10) c = '0' - o_ptr->pval;
3378 else if (f2 & 1 << stat)
3380 /* Dark green "s" */
3385 /* Dump proper character */
3386 Term_putch(col, row + stat+1, a, c);
3394 player_flags(&f1, &f2, &f3);
3397 for (stat = 0; stat < 6; stat++)
3404 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3410 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3411 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3412 if (p_ptr->tsuyoshi) dummy += 4;
3414 else if (stat == A_WIS || stat == A_INT)
3416 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3417 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3419 else if (stat == A_DEX)
3421 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3422 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3423 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3425 else if (stat == A_CON)
3427 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3428 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3429 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3430 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3431 if (p_ptr->tsuyoshi) dummy += 4;
3433 else if (stat == A_CHR)
3435 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3436 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3437 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3438 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3439 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3440 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3456 if (dummy < 10) c = '0' + dummy;
3466 if (dummy < 10) c = '0' - dummy;
3475 /* Dark green "s" */
3482 Term_putch(col, row + stat+1, a, c);
3490 static cptr object_flag_names[96] =
3731 * Summarize resistances
3733 static void display_player_ben(void)
3746 for (i = 0; i < 6; i++) b[i] = 0;
3749 /* Scan equipment */
3750 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3753 o_ptr = &inventory[i];
3755 /* Known object flags */
3756 object_flags_known(o_ptr, &f1, &f2, &f3);
3759 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3761 f3 &= ~(TR3_AGGRAVATE);
3766 b[0] |= (f1 & 0xFFFF);
3768 b[2] |= (f2 & 0xFFFF);
3770 b[4] |= (f3 & 0xFFFF);
3776 player_flags(&f1, &f2, &f3);
3779 b[0] |= (f1 & 0xFFFF);
3781 b[2] |= (f2 & 0xFFFF);
3783 b[4] |= (f3 & 0xFFFF);
3787 tim_player_flags(&f1, &f2, &f3, FALSE);
3790 b[0] |= (f1 & 0xFFFF);
3792 b[2] |= (f2 & 0xFFFF);
3794 b[4] |= (f3 & 0xFFFF);
3796 color[0] = (u16b)(f1 & 0xFFFF);
3797 color[1] = (u16b)(f1 >> 16);
3798 color[2] = (u16b)(f2 & 0xFFFF);
3799 color[3] = (u16b)(f2 >> 16);
3800 color[4] = (u16b)(f3 & 0xFFFF);
3801 color[5] = (u16b)(f3 >> 16);
3804 for (x = 0; x < 6; x++)
3807 for (y = 0; y < 16; y++)
3809 byte a = TERM_SLATE;
3812 cptr name = object_flag_names[16*x+y];
3815 if (!name) continue;
3818 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3821 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3826 if (color[x] & (1<<y))
3839 Term_putch(x * 13 + 11, y + 4, a, c);
3846 * Summarize resistances
3848 static void display_player_ben_one(int mode)
3860 /* Scan equipment */
3861 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3864 n = (i - INVEN_RARM);
3867 o_ptr = &inventory[i];
3869 object_flags_known(o_ptr, &f1, &f2, &f3);
3871 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3873 f3 &= ~(TR3_AGGRAVATE);
3878 b[n][0] = (u16b)(f1 & 0xFFFF);
3879 b[n][1] = (u16b)(f1 >> 16);
3880 b[n][2] = (u16b)(f2 & 0xFFFF);
3881 b[n][3] = (u16b)(f2 >> 16);
3882 b[n][4] = (u16b)(f3 & 0xFFFF);
3883 b[n][5] = (u16b)(f3 >> 16);
3891 player_flags(&f1, &f2, &f3);
3894 b[n][0] = (u16b)(f1 & 0xFFFF);
3895 b[n][1] = (u16b)(f1 >> 16);
3896 b[n][2] = (u16b)(f2 & 0xFFFF);
3897 b[n][3] = (u16b)(f2 >> 16);
3898 b[n][4] = (u16b)(f3 & 0xFFFF);
3899 b[n][5] = (u16b)(f3 >> 16);
3902 tim_player_flags(&f1, &f2, &f3, FALSE);
3905 b[n][0] |= (f1 & 0xFFFF);
3906 b[n][1] |= (f1 >> 16);
3907 b[n][2] |= (f2 & 0xFFFF);
3908 b[n][3] |= (f2 >> 16);
3909 b[n][4] |= (f3 & 0xFFFF);
3910 b[n][5] |= (f3 >> 16);
3911 color[0] = (u16b)(f1 & 0xFFFF);
3912 color[1] = (u16b)(f1 >> 16);
3913 color[2] = (u16b)(f2 & 0xFFFF);
3914 color[3] = (u16b)(f2 >> 16);
3915 color[4] = (u16b)(f3 & 0xFFFF);
3916 color[5] = (u16b)(f3 >> 16);
3920 for (x = 0; x < 3; x++)
3923 display_player_equippy(2, x * 26 + 11);
3926 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3929 for (y = 0; y < 16; y++)
3931 cptr name = object_flag_names[48*mode+16*x+y];
3934 if (!name) continue;
3937 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3940 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3943 for (n = 0; n < 13; n++)
3945 byte a = TERM_SLATE;
3949 if (b[n][3*mode+x] & (1<<y))
3951 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3964 Term_putch(x * 26 + 11 + n, y + 4, a, c);
3972 * Display the character on the screen (various modes)
3974 * The top two and bottom two lines are left blank.
3976 * Mode 0 = standard display with skills
3977 * Mode 1 = standard display with history
3978 * Mode 2 = summary of various things
3979 * Mode 3 = current flags (combined)
3980 * Mode 4 = current flags (part 1)
3981 * Mode 5 = current flags (part 2)
3982 * Mode 6 = mutations
3984 void display_player(int mode)
3993 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
4002 if ((mode == 0) || (mode == 1))
4004 /* Name, Sex, Race, Class */
4006 put_str("̾Á° :", 1,26);
4007 put_str("ÀÊÌ :", 3, 1);
4008 put_str("¼ï² :", 4, 1);
4009 put_str("¿¦¶È :", 5, 1);
4011 put_str("Name :", 1,26);
4012 put_str("Sex :", 3, 1);
4013 put_str("Race :", 4, 1);
4014 put_str("Class :", 5, 1);
4017 if (p_ptr->realm1 || p_ptr->realm2)
4019 put_str("ËâË¡ :", 6, 1);
4021 put_str("Magic :", 6, 1);
4024 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4026 put_str("¼é¸îËâ¿À :", 7, 1);
4028 put_str("Patron :", 7, 1);
4031 strcpy(tmp,ap_ptr->title);
4038 strcat(tmp,player_name);
4040 c_put_str(TERM_L_BLUE, tmp, 1, 34);
4041 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 15);
4042 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 15);
4043 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 15);
4045 c_put_str(TERM_L_BLUE, realm_names[p_ptr->realm1], 6, 15);
4046 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4047 c_put_str(TERM_L_BLUE, chaos_patrons[p_ptr->chaos_patron], 7, 15);
4049 else if (p_ptr->realm2)
4050 c_put_str(TERM_L_BLUE, realm_names[p_ptr->realm2], 7, 15);
4052 /* Age, Height, Weight, Social */
4054 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4055 /* ¹¹¤ËÆüËܸìÈǤÎÄɲäȤ·¤Æñ°Ì¤âɽ¼¨¤·¤Þ¤¹ */
4056 /* Ãæ±û¤Î¥«¥é¥à¤ÏÆüËܸì¤òɽ¼¨¤¹¤ë¤Ë¤Ï¶¹¤¤¤Î¤Ç¡¢º¸¤Ë4¤ÄÆ°¤«¤·¤Þ¤¹¡£ */
4057 prt_num2("ǯÎð ", "ºÍ",(int)p_ptr->age, 3, 32-2, TERM_L_BLUE);
4058 prt_num2("¿ÈĹ ","cm",(int)((p_ptr->ht*254)/100) , 4, 32-2, TERM_L_BLUE);
4059 prt_num2("ÂνŠ", "kg",(int)((p_ptr->wt*4536)/10000) , 5, 32-2, TERM_L_BLUE);
4060 prt_num("¼Ò²ñŪÃÏ°Ì ", (int)p_ptr->sc , 6, 32-2, TERM_L_BLUE);
4062 prt_num("Age ", (int)p_ptr->age, 3, 32, TERM_L_BLUE);
4063 prt_num("Height ", (int)p_ptr->ht , 4, 32, TERM_L_BLUE);
4064 prt_num("Weight ", (int)p_ptr->wt , 5, 32, TERM_L_BLUE);
4065 prt_num("Social Class ", (int)p_ptr->sc , 6, 32, TERM_L_BLUE);
4069 /* Display the stats */
4070 for (i = 0; i < 6; i++)
4072 /* Special treatment of "injured" stats */
4073 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4077 /* Use lowercase stat name */
4078 put_str(stat_names_reduced[i], 2 + i, 59);
4080 /* Get the current stat */
4081 value = p_ptr->stat_use[i];
4083 /* Obtain the current stat (modified) */
4084 cnv_stat(value, buf);
4086 /* Display the current stat (modified) */
4087 c_put_str(TERM_YELLOW, buf, 2 + i, 66);
4089 /* Acquire the max stat */
4090 value = p_ptr->stat_top[i];
4092 /* Obtain the maximum stat (modified) */
4093 cnv_stat(value, buf);
4095 /* Display the maximum stat (modified) */
4096 c_put_str(TERM_L_GREEN, buf, 2 + i, 73);
4099 /* Normal treatment of "normal" stats */
4102 /* Assume uppercase stat name */
4103 put_str(stat_names[i], 2 + i, 59);
4105 /* Obtain the current stat (modified) */
4106 cnv_stat(p_ptr->stat_use[i], buf);
4108 /* Display the current stat (modified) */
4109 c_put_str(TERM_L_GREEN, buf, 2 + i, 66);
4112 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4114 c_put_str(TERM_WHITE, "!", 2+i, 64);
4119 display_player_middle();
4121 /* Display "history" info */
4125 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 16, 25);
4127 put_str("(Character Background)", 16, 25);
4131 for (i = 0; i < 4; i++)
4133 put_str(history[i], i + 17, 10);
4137 /* Display "various" info */
4141 put_str(" (¤½¤Î¾¤ÎǽÎÏ) ", 16, 25);
4143 put_str("(Miscellaneous Abilities)", 16, 25);
4147 display_player_various();
4154 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4157 display_player_misc_info();
4158 display_player_stat_info();
4159 display_player_flag_info();
4165 display_player_ben();
4170 do_cmd_knowledge_mutations();
4176 display_player_ben_one(mode % 2);
4180 errr make_character_dump(FILE *fff)
4187 char o_name[MAX_NLEN];
4192 #ifndef FAKE_VERSION
4194 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4195 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4198 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4199 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4201 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4202 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4209 /* Display player */
4212 /* Dump part of the screen */
4213 for (y = 1; y < 22; y++)
4216 for (x = 0; x < 79; x++)
4218 /* Get the attr/char */
4219 (void)(Term_what(x, y, &a, &c));
4225 /* End the string */
4228 /* Kill trailing spaces */
4229 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4233 fprintf(fff, "%s\n", buf);
4235 fprintf(fff, "%s\n", buf);
4240 /* Display history */
4243 /* Dump part of the screen */
4244 for (y = 16; y < 21; y++)
4247 for (x = 0; x < 79; x++)
4249 /* Get the attr/char */
4250 (void)(Term_what(x, y, &a, &c));
4256 /* End the string */
4259 /* Kill trailing spaces */
4260 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4263 fprintf(fff, "%s\n", buf);
4267 /* Display history */
4270 /* Dump part of the screen */
4271 for (y = 2; y < 22; y++)
4274 for (x = 0; x < 79; x++)
4276 /* Get the attr/char */
4277 (void)(Term_what(x, y, &a, &c));
4283 /* End the string */
4286 /* Kill trailing spaces */
4287 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4290 fprintf(fff, "%s\n", buf);
4293 for (i = 0; i < p_ptr->count / 80; i++)
4296 for (i = 0; i < p_ptr->count % 80; i++)
4301 for (i = m_max - 1; i >= 1; i--)
4303 monster_type *m_ptr = &m_list[i];
4306 if (!m_ptr->r_idx) continue;
4307 if (!is_pet(m_ptr)) continue;
4308 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4312 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4314 fprintf(fff, "\n [leading pets]\n\n");
4318 monster_desc(pet_name, m_ptr, 0x88);
4319 fprintf(fff, "%s", pet_name);
4320 if (p_ptr->riding == i)
4322 fprintf(fff, " ¾èÇÏÃæ");
4324 fprintf(fff, " riding");
4328 if (pet) fprintf(fff, "\n");
4331 if (death && !total_winner)
4334 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4336 fprintf(fff, "\n [Last messages]\n\n");
4338 for (i = MIN(message_num(), 15); i >= 0; i--)
4340 fprintf(fff,"> %s\n",message_str((s16b)i));
4346 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4348 fprintf(fff, "\n [Miscellaneous information]\n");
4352 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4354 fprintf(fff, "\n Recall Depth:\n");
4356 for (y = 1; y < max_d_idx; y++)
4360 if (!d_info[y].maxdepth) continue;
4361 if (!max_dlv[y]) continue;
4362 if (d_info[y].final_guardian)
4364 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4366 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4369 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4371 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4377 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4379 fprintf(fff, "\n Preserve Mode: ON");
4384 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4386 fprintf(fff, "\n Preserve Mode: OFF");
4390 if (ironman_autoscum)
4392 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4394 fprintf(fff, "\n Autoscum: ALWAYS");
4399 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4401 fprintf(fff, "\n Autoscum: ON");
4406 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4408 fprintf(fff, "\n Autoscum: OFF");
4412 if (ironman_small_levels)
4414 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4416 fprintf(fff, "\n Small Levels: ALWAYS");
4419 else if (always_small_levels)
4421 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4423 fprintf(fff, "\n Small Levels: ON");
4426 else if (small_levels)
4428 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4430 fprintf(fff, "\n Small Levels: ENABLED");
4435 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4437 fprintf(fff, "\n Small Levels: OFF");
4443 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4445 fprintf(fff, "\n Vanilla Town: ON");
4450 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4452 fprintf(fff, "\n Lite Town: ON");
4458 fprintf(fff, "\n Ź¤Ê¤·: ON");
4460 fprintf(fff, "\n No Shops: ON");
4464 if (ironman_downward)
4466 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4468 fprintf(fff, "\n Diving only: ON");
4474 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4476 fprintf(fff, "\n Unusual rooms: ON");
4480 if (ironman_nightmare)
4482 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4484 fprintf(fff, "\n Nightmare Mode: ON");
4488 if (ironman_empty_levels)
4490 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4492 fprintf(fff, "\n Arena Levels: ALWAYS");
4495 else if (empty_levels)
4497 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4499 fprintf(fff, "\n Arena Levels: ENABLED");
4504 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4506 fprintf(fff, "\n Arena Levels: OFF");
4511 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4513 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4516 if (p_ptr->arena_number == 99)
4519 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4521 fprintf(fff, "\n Arena: defeated\n");
4524 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4527 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4529 fprintf(fff, "\n Arena: True Champion\n");
4532 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4535 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4537 fprintf(fff, "\n Arena: Champion\n");
4543 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4545 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");
4551 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4553 fprintf(fff, "\n You have done something illegal.");
4557 if (stupid_monsters)
4559 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4561 fprintf(fff, "\n Your opponents are behaving stupidly.");
4567 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4569 fprintf(fff, "\n You possess munchkinish power over death.");
4574 /* Monsters slain */
4579 for (k = 1; k < max_r_idx; k++)
4581 monster_race *r_ptr = &r_info[k];
4583 if (r_ptr->flags1 & RF1_UNIQUE)
4585 bool dead = (r_ptr->max_num == 0);
4593 s16b This = r_ptr->r_pkills;
4603 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4605 fprintf(fff,"\n You have defeated no enemies yet.\n");
4608 else if (Total == 1)
4610 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4612 fprintf(fff,"\n You have defeated one enemy.\n");
4617 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4619 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4625 if (p_ptr->old_race1 || p_ptr->old_race2)
4628 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4630 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4632 for (i = 0; i < MAX_RACES; i++)
4634 if (p_ptr->start_race == i) continue;
4637 if (!(p_ptr->old_race1 & 1L << i)) continue;
4641 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4644 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4646 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4651 if (p_ptr->old_realm)
4653 for (i = 0; i < MAX_MAGIC; i++)
4655 if (!(p_ptr->old_realm & 1L << i)) continue;
4657 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4659 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4665 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4667 fprintf(fff, "\n\n [Virtues]\n\n");
4671 if (p_ptr->align > 150) disp_align = "ÂçÁ±";
4672 else if (p_ptr->align > 50) disp_align = "ÃæÁ±";
4673 else if (p_ptr->align > 10) disp_align = "¾®Á±";
4674 else if (p_ptr->align > -11) disp_align = "ÃæΩ";
4675 else if (p_ptr->align > -51) disp_align = "¾®°";
4676 else if (p_ptr->align > -151) disp_align = "Ãæ°";
4677 else disp_align = "Âç°";
4678 fprintf(fff, "°À : %s\n", disp_align);
4680 if (p_ptr->align > 150) disp_align = "lawful";
4681 else if (p_ptr->align > 50) disp_align = "good";
4682 else if (p_ptr->align > 10) disp_align = "neutral good";
4683 else if (p_ptr->align > -11) disp_align = "neutral";
4684 else if (p_ptr->align > -51) disp_align = "neutral evil";
4685 else if (p_ptr->align > -151) disp_align = "evil";
4686 else disp_align = "chaotic";
4687 fprintf(fff, "Your alighnment : %s\n", disp_align);
4692 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4695 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4697 fprintf(fff, "\n\n [Mutations]\n\n");
4700 dump_mutations(fff);
4704 /* Skip some lines */
4705 fprintf(fff, "\n\n");
4708 /* Dump the equipment */
4712 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4714 fprintf(fff, " [Character Equipment]\n\n");
4717 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4719 object_desc(o_name, &inventory[i], TRUE, 3);
4720 if ((i == INVEN_LARM) && p_ptr->ryoute)
4722 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4724 strcpy(o_name, "(wielding with two-hands)");
4726 fprintf(fff, "%c%s %s\n",
4727 index_to_label(i), paren, o_name);
4729 fprintf(fff, "\n\n");
4732 /* Dump the inventory */
4734 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4736 fprintf(fff, " [Character Inventory]\n\n");
4739 for (i = 0; i < INVEN_PACK; i++)
4741 /* Don't dump the empty slots */
4742 if (!inventory[i].k_idx) break;
4744 /* Dump the inventory slots */
4745 object_desc(o_name, &inventory[i], TRUE, 3);
4746 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4749 /* Add an empty line */
4750 fprintf(fff, "\n\n");
4752 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4754 /* Print all homes in the different towns */
4755 st_ptr = &town[1].store[STORE_HOME];
4757 /* Home -- if anything there */
4758 if (st_ptr->stock_num)
4760 /* Header with name of the town */
4762 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4764 fprintf(fff, " [Home Inventory]\n");
4768 /* Dump all available items */
4769 for (i = 0; i < st_ptr->stock_num; i++)
4773 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4775 fprintf(fff, "\n ( page %d )\n", x++);
4777 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4778 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4781 /* Add an empty line */
4782 fprintf(fff, "\n\n");
4786 /* Print all homes in the different towns */
4787 st_ptr = &town[1].store[STORE_MUSEUM];
4789 /* Home -- if anything there */
4790 if (st_ptr->stock_num)
4792 /* Header with name of the town */
4794 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4796 fprintf(fff, " [Museum]\n");
4800 /* Dump all available items */
4801 for (i = 0; i < st_ptr->stock_num; i++)
4804 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4805 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4806 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4808 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4809 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4810 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4815 /* Add an empty line */
4816 fprintf(fff, "\n\n");
4823 * Hack -- Dump a character description file
4825 * XXX XXX XXX Allow the "full" flag to dump additional info,
4826 * and trigger its usage from various places in the code.
4828 errr file_character(cptr name, bool full)
4837 /* Build the filename */
4838 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4840 /* File type is "TEXT" */
4841 FILE_TYPE(FILE_TYPE_TEXT);
4843 /* Check for existing file */
4844 fd = fd_open(buf, O_RDONLY);
4851 /* Close the file */
4856 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4858 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4863 if (get_check(out_val)) fd = -1;
4866 /* Open the non-existing file */
4867 if (fd < 0) fff = my_fopen(buf, "w");
4878 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4880 msg_format("Character dump failed!");
4889 (void)make_character_dump(fff);
4897 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4899 msg_print("Character dump successful.");
4910 * Recursive file perusal.
4912 * Return FALSE on "ESCAPE", otherwise TRUE.
4914 * Process various special text in the input file, including
4915 * the "menu" structures used by the "help file" system.
4917 * XXX XXX XXX Consider using a temporary file.
4919 * XXX XXX XXX Allow the user to "save" the current file.
4921 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4925 /* Number of "real" lines passed by */
4928 /* Number of "real" lines in the file */
4931 /* Backup value for "line" */
4937 /* This screen has sub-screens */
4940 /* Current help file */
4943 /* Find this string (if any) */
4946 /* Jump to this tag */
4949 /* Hold a string to find */
4952 /* Hold a string to show */
4956 char filename[1024];
4958 /* Describe this thing */
4964 /* General buffer */
4967 /* Lower case version of the buffer, for searching */
4970 /* Aux pointer for making lc_buf (and find!) lowercase */
4973 /* Sub-menu information */
4976 /* Tags for in-file references */
4979 bool reverse = (line < 0);
4988 strcpy(caption, "");
4990 /* Wipe the hooks */
4991 for (i = 0; i < 68; i++)
4996 /* Copy the filename */
4997 strcpy(filename, name);
4999 n = strlen(filename);
5001 /* Extract the tag from the filename */
5002 for (i = 0; i < n; i++)
5004 if (filename[i] == '#')
5007 tag = filename + i + 1;
5012 /* Redirect the name */
5015 /* Hack XXX XXX XXX */
5019 strcpy(caption, what);
5021 /* Access the "file" */
5025 fff = my_fopen(path, "r");
5028 /* Look in "help" */
5033 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5035 sprintf(caption, "Help file '%s'", name);
5039 /* Build the filename */
5040 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5043 fff = my_fopen(path, "r");
5046 /* Look in "info" */
5051 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5053 sprintf(caption, "Info file '%s'", name);
5057 /* Build the filename */
5058 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5061 fff = my_fopen(path, "r");
5069 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5071 msg_format("Cannot open '%s'.", name);
5081 /* Pre-Parse the file */
5084 /* Read a line or stop */
5085 if (my_fgets(fff, buf, 1024)) break;
5087 /* XXX Parse "menu" items */
5088 if (prefix(buf, "***** "))
5090 /* Notice "menu" requests */
5091 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5093 /* This is a menu file */
5096 /* Extract the menu item */
5097 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5099 if ((buf[8] == ']') && (buf[9] == ' '))
5101 /* Extract the menu item */
5102 strcpy(hook[k], buf + 10);
5105 /* Notice "tag" requests */
5106 else if ((buf[6] == '<') && (isdigit(buf[7]) || isalpha(buf[7])) &&
5109 /* Extract the menu item */
5110 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5112 /* Extract the menu item */
5120 /* Count the "real" lines */
5124 /* Save the number of "real" lines */
5127 if (line == -1) line = ((size-1)/20)*20;
5129 /* Go to the tagged line */
5131 line = tags[isdigit(tag[0]) ? D2I(tag[0]) : tag[0] - 'A' + 10];
5133 /* Display the file */
5139 /* Restart when necessary */
5140 if (line >= size) line = 0;
5143 /* Re-open the file if needed */
5149 /* Hack -- Re-Open the file */
5150 fff = my_fopen(path, "r");
5153 if (!fff) return (FALSE);
5155 /* File has been restarted */
5159 /* Goto the selected line */
5163 if (my_fgets(fff, buf, 1024)) break;
5165 /* Skip tags/links */
5166 if (prefix(buf, "***** ")) continue;
5168 /* Count the lines */
5172 /* Dump the next 20 lines of the file */
5173 for (i = 0; i < 20; )
5175 /* Hack -- track the "first" line */
5176 if (!i) line = next;
5178 /* Get a line of the file or stop */
5179 if (my_fgets(fff, buf, 1024)) break;
5181 /* Hack -- skip "special" lines */
5182 if (prefix(buf, "***** ")) continue;
5184 /* Count the "real" lines */
5187 /* Make a lower case version of buf for searching */
5188 strcpy(lc_buf, buf);
5190 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5193 if (iskanji(*lc_buf_ptr))
5197 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5200 /* Hack -- keep searching */
5201 if (find && !i && !strstr(lc_buf, find)) continue;
5203 /* Hack -- stop searching */
5207 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5209 /* Hilite "shower" */
5214 /* Display matches */
5215 while ((str = strstr(str, shower)) != NULL)
5217 int len = strlen(shower);
5219 /* Display the match */
5220 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5227 /* Count the printed lines */
5231 /* Hack -- failed search */
5241 /* Show a general "title" */
5245 prt(format("[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5247 prt(format("[Hengband %d.%d.%d, %s, Line %d/%d]",
5250 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5251 caption, line, size), 0, 0);
5256 prt(format("[%s, %d/%d]",
5258 prt(format("[%s, Line %d/%d]",
5260 caption, line, size), 0, 0);
5263 /* Prompt -- menu screen */
5268 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", 23, 0);
5270 prt("[Press a Number, or ESC to exit.]", 23, 0);
5275 /* Prompt -- small files */
5276 else if (size <= 20)
5280 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5282 prt("[Press ESC to exit.]", 23, 0);
5287 /* Prompt -- large files */
5292 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5294 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5296 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", 23, 0);
5300 /* Get a keypress */
5303 /* Hack -- return to last screen */
5304 if (k == '<') break;
5306 /* Show the help for the help */
5309 /* Hack - prevent silly recursion */
5311 if (strcmp(name, "jhelpinfo.txt") != 0)
5312 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5314 if (strcmp(name, "helpinfo.txt") != 0)
5315 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5319 /* Hack -- try showing */
5324 prt("¶¯Ä´: ", 23, 0);
5326 prt("Show: ", 23, 0);
5329 (void)askfor_aux(shower, 80);
5332 /* Hack -- try finding */
5337 prt("¸¡º÷: ", 23, 0);
5339 prt("Find: ", 23, 0);
5343 if (askfor_aux(finder, 80))
5350 /* Make finder lowercase */
5351 for (cnt = 0; finder[cnt] != 0; cnt++)
5354 if (iskanji(finder[cnt]))
5358 finder[cnt] = tolower(finder[cnt]);
5362 strcpy(shower, finder);
5366 /* Hack -- go to a specific line */
5373 prt("Goto Line: ", 23, 0);
5378 if (askfor_aux(tmp, 80))
5384 /* Hack -- go to a specific file */
5389 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", 23, 0);
5390 strcpy(tmp, "jhelp.hlp");
5392 prt("Goto File: ", 23, 0);
5393 strcpy(tmp, "help.hlp");
5397 if (askfor_aux(tmp, 80))
5399 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
5403 /* Hack -- Allow backing up */
5406 line = line + (reverse ? 20 : -20);
5407 if (line < 0) line = ((size-1)/20)*20;
5410 /* Hack -- Advance a single line */
5411 if ((k == '\n') || (k == '\r'))
5413 line = line + (reverse ? -1 : 1);
5414 if (line < 0) line = ((size-1)/20)*20;
5417 /* Advance one page */
5420 line = line + (reverse ? -20 : 20);
5421 if (line < 0) line = ((size-1)/20)*20;
5425 /* ÆüËܸìÈǤÇÄɲ䵤줿¥Ø¥ë¥×¤Îɽ¼¨ */
5426 /* ¤¢¤Þ¤ê¤è¤¤½èÍý¤Î»ÅÊý¤È¤Ï»×¤¨¤Ê¤¤¡¦¡¦¡¦¤¹¤Þ¤ó */
5428 /* ´Ê°×¥³¥Þ¥ó¥É°ìÍ÷ */
5429 if (menu && (k == 'c' || k == 'C'))
5432 switch (rogue_like_commands)
5436 strcpy(tmp, "j_com_r.txt");
5437 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
5442 strcpy(tmp, "j_com_o.txt");
5443 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = ESCAPE;
5450 /* Recurse on numbers */
5455 if (isdigit(k)) key = D2I(k);
5456 else if (isalpha(k)) key = k - 'A' + 10;
5458 if ((key > -1) && hook[key][0])
5460 /* Recurse on that file */
5461 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5466 /* Hack, dump to file */
5476 if (get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5478 if (get_string("File name: ", xtmp, 80))
5482 if (xtmp[0] && (xtmp[0] != ' '))
5491 /* Build the filename */
5492 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5497 /* Hack -- Re-Open the file */
5498 fff = my_fopen(path, "r");
5500 ffp = my_fopen(buff, "w");
5506 msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
5508 msg_print("Failed to open file.");
5515 sprintf(xtmp, "%s: %s", player_name, what);
5516 my_fputs(ffp, xtmp, 80);
5517 my_fputs(ffp, "\n", 80);
5519 while (!my_fgets(fff, buff, 80))
5520 my_fputs(ffp, buff, 80);
5526 /* Hack -- Re-Open the file */
5527 fff = my_fopen(path, "r");
5530 /* Exit on escape */
5531 if (k == ESCAPE) break;
5534 /* Close the file */
5538 if (k == ESCAPE) return (FALSE);
5546 * Peruse the On-Line-Help
5548 void do_cmd_help(void)
5553 /* Peruse the main help file */
5555 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5557 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5567 * Process the player name.
5568 * Extract a clean "base name".
5569 * Build the savefile name if needed.
5571 void process_player_name(bool sf)
5576 /* Cannot be too long */
5577 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5579 if (strlen(player_name) > 8)
5581 if (strlen(player_name) > 15)
5586 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5588 quit_fmt("The name '%s' is too long!", player_name);
5594 /* Cannot contain "icky" characters */
5595 for (i = 0; player_name[i]; i++)
5597 /* No control characters */
5599 if (iskanji(player_name[i])){i++;continue;}
5600 if (iscntrl( (unsigned char)player_name[i]))
5602 if (iscntrl(player_name[i]))
5606 /* Illegal characters */
5608 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5610 quit_fmt("The name '%s' contains control chars!", player_name);
5619 /* Extract "useful" letters */
5620 for (i = 0; player_name[i]; i++)
5623 unsigned char c = player_name[i];
5625 char c = player_name[i];
5629 /* Convert "dot" to "underscore" */
5630 if (c == '.') c = '_';
5632 /* Accept all the letters */
5633 player_base[k++] = c;
5638 /* Extract "useful" letters */
5639 for (i = 0; player_name[i]; i++)
5642 unsigned char c = player_name[i];
5644 char c = player_name[i];
5647 /* Accept some letters */
5650 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5651 player_base[k++] = c;
5653 player_base[k++] = player_name[i];
5656 else if (iskana(c)) player_base[k++] = c;
5660 /* Convert path separator to underscore */
5661 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5662 player_base[k++] = '_';
5663 i += strlen(PATH_SEP);
5666 /* Convert space, dot, and underscore to underscore */
5667 else if (strchr(". _", c)) player_base[k++] = '_';
5669 else if (isprint(c)) player_base[k++] = c;
5675 #if defined(WINDOWS) || defined(MSDOS)
5677 /* Hack -- max length */
5683 player_base[k] = '\0';
5685 /* Require a "base" name */
5686 if (!player_base[0]) strcpy(player_base, "PLAYER");
5689 #ifdef SAVEFILE_MUTABLE
5695 if (!savefile_base[0] && savefile[0])
5702 t = strstr(s, PATH_SEP);
5707 strcpy(savefile_base, s);
5710 if (!savefile_base[0] || !savefile[0])
5713 /* Change the savefile name */
5718 strcpy(savefile_base, player_base);
5720 #ifdef SAVEFILE_USE_UID
5721 /* Rename the savefile, using the player_uid and player_base */
5722 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5724 /* Rename the savefile, using the player_base */
5725 (void)sprintf(temp, "%s", player_base);
5729 /* Hack -- support "flat directory" usage on VM/ESA */
5730 (void)sprintf(temp, "%s.sv", player_base);
5733 /* Build the filename */
5734 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5740 * Gets a name for the character, reacting to name changes.
5742 * Assumes that "display_player(0)" has just been called
5744 * Perhaps we should NOT ask for a name (at "birth()") on
5745 * Unix machines? XXX XXX
5747 * What a horrible name for a global function. XXX XXX XXX
5753 /* Save the player name */
5754 strcpy(tmp, player_name);
5756 /* Prompt for a new name */
5758 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5760 if (get_string("Enter a name for your character: ", tmp, 15))
5764 strcpy(player_name, tmp);
5766 else if (0 == strlen(player_name))
5768 /* Use default name */
5769 strcpy(player_name, "PLAYER");
5772 /* Process the player name */
5773 process_player_name(FALSE);
5775 strcpy(tmp,ap_ptr->title);
5782 strcat(tmp,player_name);
5784 /* Re-Draw the name (in light blue) */
5785 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5787 /* Erase the prompt, etc */
5794 * Hack -- commit suicide
5796 void do_cmd_suicide(void)
5803 /* Verify Retirement */
5808 if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
5810 if (!get_check("Do you want to retire? ")) return;
5815 /* Verify Suicide */
5820 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5822 if (!get_check("Do you really want to commit suicide? ")) return;
5829 /* Special Verification for suicide */
5831 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5833 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5839 if (i != '@') return;
5845 /* Kill the player */
5849 p_ptr->leaving = TRUE;
5854 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5855 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5857 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5858 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5860 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5863 /* Cause of death */
5865 (void)strcpy(died_from, "ÅÓÃ潪λ");
5867 (void)strcpy(died_from, "Quitting");
5877 void do_cmd_save_game(int is_autosave)
5879 /* Autosaves do not disturb */
5883 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5885 msg_print("Autosaving the game...");
5891 /* Disturb the player */
5895 /* Clear messages */
5903 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
5905 prt("Saving game...", 0, 0);
5912 /* The player is not dead */
5914 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
5916 (void)strcpy(died_from, "(saved)");
5920 /* Forbid suspend */
5921 signals_ignore_tstp();
5923 /* Save the player */
5927 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
5929 prt("Saving game... done.", 0, 0);
5934 /* Save failed (oops) */
5938 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
5940 prt("Saving game... failed!", 0, 0);
5945 /* Allow suspend again */
5946 signals_handle_tstp();
5951 /* Note that the player is not dead */
5953 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
5955 (void)strcpy(died_from, "(alive and well)");
5962 * Save the game and exit
5964 void do_cmd_save_and_exit(void)
5969 p_ptr->leaving = TRUE;
5971 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
5973 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
5979 * Hack -- Calculates the total number of points earned -JWT-
5981 long total_points(void)
5985 u32b point, point_h, point_l;
5986 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
5988 if (stupid_monsters) mult -= 70;
5989 if (!preserve_mode) mult += 10;
5990 if (!autoroller) mult += 10;
5991 if (!smart_learn) mult -= 20;
5992 if (!terrain_streams) mult -= 20;
5993 if (smart_cheat) mult += 30;
5994 if (ironman_shops) mult += 50;
5995 if (ironman_small_levels) mult += 10;
5996 if (ironman_empty_levels) mult += 20;
5997 if (!powerup_home) mult += 50;
5998 if (ironman_rooms) mult += 100;
5999 if (ironman_nightmare) mult += 100;
6001 if (mult < 5) mult = 5;
6003 for (i = 0; i < max_d_idx; i++)
6004 if(max_dlv[i] > max_dl)
6005 max_dl = max_dlv[i];
6007 point_l = (p_ptr->max_exp + (100 * max_dl));
6008 point_h = point_l / 0x10000L;
6009 point_l = point_l % 0x10000L;
6012 point_h += point_l / 0x10000L;
6013 point_l %= 0x10000L;
6015 point_l += ((point_h % 100) << 16);
6019 point = (point_h << 16) + (point_l);
6020 if (p_ptr->arena_number < 99)
6021 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6023 if (ironman_downward) point *= 2;
6024 if (p_ptr->pclass == CLASS_BERSERKER)
6026 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6030 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6033 if (total_winner) point = 2;
6035 if (easy_band) point = (0 - point);
6043 * Centers a string within a 31 character string -JWT-
6045 static void center_string(char *buf, cptr str)
6052 /* Necessary border */
6056 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6062 * Save a "bones" file for a dead character
6064 * Note that we will not use these files until Angband 2.8.0, and
6065 * then we will only use the name and level on which death occured.
6067 * Should probably attempt some form of locking...
6069 static void make_bones(void)
6076 /* Ignore wizards and borgs */
6077 if (!(noscore & 0x00FF))
6079 /* Ignore people who die in town */
6084 /* XXX XXX XXX "Bones" name */
6085 sprintf(tmp, "bone.%03d", dun_level);
6087 /* Build the filename */
6088 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6090 /* Attempt to open the bones file */
6091 fp = my_fopen(str, "r");
6093 /* Close it right away */
6094 if (fp) my_fclose(fp);
6096 /* Do not over-write a previous ghost */
6099 /* File type is "TEXT" */
6100 FILE_TYPE(FILE_TYPE_TEXT);
6102 /* Try to write a new "Bones File" */
6103 fp = my_fopen(str, "w");
6105 /* Not allowed to write it? Weird. */
6109 fprintf(fp, "%s\n", player_name);
6110 fprintf(fp, "%d\n", p_ptr->mhp);
6111 fprintf(fp, "%d\n", p_ptr->prace);
6112 fprintf(fp, "%d\n", p_ptr->pclass);
6114 /* Close and save the Bones file */
6123 * Redefinable "print_tombstone" action
6125 bool (*tombstone_aux)(void) = NULL;
6129 * Display a "tomb-stone"
6131 static void print_tomb(void)
6135 /* Do we use a special tombstone ? */
6138 /* Use tombstone hook */
6139 done = (*tombstone_aux)();
6142 /* Print the text-tombstone */
6156 time_t ct = time((time_t)0);
6162 /* Build the filename */
6164 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6166 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6170 /* Open the News file */
6171 fp = my_fopen(buf, "r");
6178 /* Dump the file to the screen */
6179 while (0 == my_fgets(fp, buf, 1024))
6181 /* Display and advance */
6182 put_str(buf, i++, 0);
6191 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6205 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6208 center_string(buf, player_name);
6209 put_str(buf, 6, 11);
6212 center_string(buf, "the");
6213 put_str(buf, 7, 11);
6216 center_string(buf, p);
6217 put_str(buf, 8, 11);
6220 center_string(buf, cp_ptr->title);
6222 put_str(buf, 10, 11);
6225 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6227 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6230 center_string(buf, tmp);
6231 put_str(buf, 11, 11);
6234 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6236 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6239 center_string(buf, tmp);
6240 put_str(buf, 12, 11);
6243 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6245 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6248 center_string(buf, tmp);
6249 put_str(buf, 13, 11);
6252 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6253 if (streq(died_from, "ÅÓÃ潪λ"))
6255 strcpy(tmp, "<¼«»¦>");
6259 if (streq(died_from, "ripe"))
6261 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6263 else if (streq(died_from, "Seppuku"))
6265 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6269 strcpy(tmp, died_from);
6272 center_string(buf, tmp);
6273 put_str(buf, 14, 11);
6275 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6277 if( dun_level == 0 )
6279 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6280 if(streq(died_from, "ÅÓÃ潪λ"))
6282 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6286 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6291 if(streq(died_from, "ÅÓÃ潪λ"))
6293 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6297 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6300 center_string(buf, tmp);
6301 put_str(buf, 15, 11);
6304 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6305 center_string(buf, tmp);
6306 put_str(buf, 14, 11);
6309 if (strlen(died_from) > 24)
6311 strncpy(dummy, died_from, 24);
6313 (void)sprintf(tmp, "by %s.", dummy);
6316 (void)sprintf(tmp, "by %s.", died_from);
6318 center_string(buf, tmp);
6319 put_str(buf, 15, 11);
6324 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6325 center_string(buf, tmp);
6326 put_str(buf, 17, 11);
6329 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6331 msg_format("Goodbye, %s!", player_name);
6339 * Display some character info
6341 static void show_info(void)
6347 /* Hack -- Know everything in the inven/equip */
6348 for (i = 0; i < INVEN_TOTAL; i++)
6350 o_ptr = &inventory[i];
6352 /* Skip non-objects */
6353 if (!o_ptr->k_idx) continue;
6355 /* Aware and Known */
6356 object_aware(o_ptr);
6357 object_known(o_ptr);
6360 for (i = 1; i < max_towns; i++)
6362 st_ptr = &town[i].store[STORE_HOME];
6364 /* Hack -- Know everything in the home */
6365 for (j = 0; j < st_ptr->stock_num; j++)
6367 o_ptr = &st_ptr->stock[j];
6369 /* Skip non-objects */
6370 if (!o_ptr->k_idx) continue;
6372 /* Aware and Known */
6373 object_aware(o_ptr);
6374 object_known(o_ptr);
6378 /* Hack -- Recalculate bonuses */
6379 p_ptr->update |= (PU_BONUS);
6384 /* Flush all input keys */
6387 /* Flush messages */
6391 /* Describe options */
6393 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6394 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6396 prt("You may now dump a character record to one or more files.", 21, 0);
6397 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6401 /* Dump character records as requested */
6408 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6410 put_str("Filename: ", 23, 0);
6415 strcpy(out_val, "");
6417 /* Ask for filename (or abort) */
6418 if (!askfor_aux(out_val, 60)) return;
6420 /* Return means "show on screen" */
6421 if (!out_val[0]) break;
6426 /* Dump a character file */
6427 (void)file_character(out_val, TRUE);
6435 /* Display player */
6438 /* Prompt for inventory */
6440 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6442 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6446 /* Allow abort at this point */
6447 if (inkey() == ESCAPE) return;
6450 /* Show equipment and inventory */
6452 /* Equipment -- if any */
6456 item_tester_full = TRUE;
6457 (void)show_equip(0);
6459 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6461 prt("You are using: -more-", 0, 0);
6464 if (inkey() == ESCAPE) return;
6467 /* Inventory -- if any */
6471 item_tester_full = TRUE;
6472 (void)show_inven(0);
6474 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6476 prt("You are carrying: -more-", 0, 0);
6479 if (inkey() == ESCAPE) return;
6482 /* Homes in the different towns */
6483 for (l = 1; l < max_towns; l++)
6485 st_ptr = &town[l].store[STORE_HOME];
6487 /* Home -- if anything there */
6488 if (st_ptr->stock_num)
6490 /* Display contents of the home */
6491 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6497 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6499 char o_name[MAX_NLEN];
6503 o_ptr = &st_ptr->stock[i];
6505 /* Print header, clear line */
6506 sprintf(tmp_val, "%c) ", I2A(j));
6507 prt(tmp_val, j+2, 4);
6509 /* Display object description */
6510 object_desc(o_name, o_ptr, TRUE, 3);
6511 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6516 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6518 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6523 if (inkey() == ESCAPE) return;
6530 static bool check_score(void)
6536 if (highscore_fd < 0)
6539 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6541 msg_print("Score file unavailable.");
6548 #ifndef SCORE_WIZARDS
6549 /* Wizard-mode pre-empts scoring */
6550 if (noscore & 0x000F)
6553 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6555 msg_print("Score not registered for wizards.");
6564 /* Borg-mode pre-empts scoring */
6565 if (noscore & 0x00F0)
6568 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6570 msg_print("Score not registered for borgs.");
6578 #ifndef SCORE_CHEATERS
6579 /* Cheaters are not scored */
6580 if (noscore & 0xFF00)
6583 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6585 msg_print("Score not registered for cheaters.");
6595 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6597 if (!total_winner && streq(died_from, "Interrupting"))
6602 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6604 msg_print("Score not registered due to interruption.");
6613 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6615 if (!total_winner && streq(died_from, "Quitting"))
6620 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6622 msg_print("Score not registered due to quitting.");
6632 * Close up the current game (player may or may not be dead)
6634 * This function is called only from "main.c" and "signals.c".
6636 void close_game(void)
6639 bool do_send = TRUE;
6641 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6646 /* Flush the messages */
6649 /* Flush the input */
6653 /* No suspending now */
6654 signals_ignore_tstp();
6657 /* Hack -- Character is now "icky" */
6658 character_icky = TRUE;
6661 /* Build the filename */
6662 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6664 /* Open the high score file, for reading/writing */
6665 highscore_fd = fd_open(buf, O_RDWR);
6671 /* Handle retirement */
6672 if (total_winner) kingly();
6676 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6678 if (!munchkin_death || get_check("Save death? "))
6683 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6685 if (!save_player()) msg_print("death save failed!");
6688 else do_send = FALSE;
6695 /* Show more info */
6703 if ((!send_world_score(do_send)))
6706 if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
6708 if (get_check("Stand by for later score registration? "))
6711 wait_report_score = TRUE;
6714 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6716 if (!save_player()) msg_print("death save failed!");
6720 if (!wait_report_score)
6723 else if (highscore_fd >= 0)
6725 display_scores_aux(0, 10, -1, NULL);
6728 /* Dump bones file */
6737 do_cmd_save_game(FALSE);
6739 /* Prompt for scores XXX XXX XXX */
6741 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6743 prt("Press Return (or Escape).", 0, 40);
6747 /* Predict score (or ESCAPE) */
6748 if (inkey() != ESCAPE) predict_score();
6752 /* Shut the high score file */
6753 (void)fd_close(highscore_fd);
6755 /* Forget the high score fd */
6759 /* Allow suspending now */
6760 signals_handle_tstp();
6765 * Handle abrupt death of the visual system
6767 * This routine is called only in very rare situations, and only
6768 * by certain visual systems, when they experience fatal errors.
6770 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6771 * save file so that player can see tombstone when restart.
6773 void exit_game_panic(void)
6775 /* If nothing important has happened, just quit */
6777 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6779 if (!character_generated || character_saved) quit("panic");
6783 /* Mega-Hack -- see "msg_print()" */
6786 /* Clear the top line */
6789 /* Hack -- turn off some things */
6792 /* Mega-Hack -- Delay death */
6793 if (p_ptr->chp < 0) death = FALSE;
6795 /* Hardcode panic save */
6798 /* Forbid suspend */
6799 signals_ignore_tstp();
6801 /* Indicate panic save */
6803 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6805 (void)strcpy(died_from, "(panic save)");
6809 /* Panic save, or get worried */
6811 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6813 if (!save_player()) quit("panic save failed!");
6817 /* Successful panic save */
6819 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6821 quit("panic save succeeded!");
6828 * Get a random line from a file
6829 * Based on the monster speech patch by Matt Graham,
6831 errr get_rnd_line(cptr file_name, int entry, char *output)
6835 int line, counter, test, numentries;
6840 /* Build the filename */
6841 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6844 fp = my_fopen(buf, "r");
6847 if (!fp) return (-1);
6849 /* Find the entry of the monster */
6852 /* Get a line from the file */
6853 if (my_fgets(fp, buf, 1024) == 0)
6855 /* Count the lines */
6858 /* Look for lines starting with 'N:' */
6859 if ((buf[0] == 'N') && (buf[1] == ':'))
6861 /* Allow default lines */
6868 else if (buf[2] == 'M')
6870 if (r_info[entry].flags1 & RF1_MALE)
6876 else if (buf[2] == 'F')
6878 if (r_info[entry].flags1 & RF1_FEMALE)
6884 /* Get the monster number */
6885 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6887 /* Is it the right monster? */
6896 /* Error while converting the monster number */
6897 msg_format("Error in line %d of %s!",
6898 line_num, file_name);
6906 /* Reached end of file */
6913 /* Get the number of entries */
6917 if (my_fgets(fp, buf, 1024) == 0)
6919 /* Count the lines */
6922 /* Look for the number of entries */
6923 if (isdigit(buf[0]))
6925 /* Get the number of entries */
6926 numentries = atoi(buf);
6932 /* Count the lines */
6935 /* Reached end of file without finding the number */
6936 msg_format("Error in line %d of %s!",
6937 line_num, file_name);
6946 /* Grab an appropriate line number */
6947 line = rand_int(numentries);
6949 /* Get the random line */
6950 for (counter = 0; counter <= line; counter++)
6952 /* Count the lines */
6957 test = my_fgets(fp, buf, 1024);
6958 if(test || buf[0] != '#')
6964 /* Found the line */
6965 if (counter == line) break;
6969 /* Error - End of file */
6970 msg_format("Error in line %d of %s!",
6971 line_num, file_name);
6979 strcpy(output, buf);
6986 /* Close the file */
6995 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
6999 for (i=0;i<count;i++){
7000 result=get_rnd_line(file_name, entry, output);
7003 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7011 * Process file for auto picker/destroyer.
7013 errr process_pickpref_file(cptr name)
7019 /* Build the filename */
7020 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7022 err = process_pref_file_aux(buf, TRUE);
7028 static errr counts_seek(int fd, u32b where, bool flag)
7031 char temp1[128], temp2[128];
7032 u32b zero_header[3] = {0L, 0L, 0L};
7035 #ifdef SAVEFILE_USE_UID
7036 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7038 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7040 for (i = 0; temp1[i]; i++)
7041 temp1[i] ^= (i+1) * 63;
7046 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7048 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7053 fd_seek(fd, seekpoint);
7054 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7055 fd_write(fd, (char*)(temp1), sizeof(temp1));
7059 if (strcmp(temp1, temp2) == 0)
7062 seekpoint += 128 + 3 * sizeof(u32b);
7065 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7068 u32b counts_read(int where)
7075 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7077 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7079 fd = fd_open(buf, O_RDONLY);
7081 if (counts_seek(fd, where, FALSE) ||
7082 fd_read(fd, (char*)(&count), sizeof(u32b)))
7090 errr counts_write(int where, u32b count)
7096 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7098 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7100 fd = fd_open(buf, O_RDWR);
7103 /* File type is "DATA" */
7104 FILE_TYPE(FILE_TYPE_DATA);
7106 /* Create a new high score file */
7107 fd = fd_make(buf, 0644);
7110 if (fd_lock(fd, F_WRLCK)) return 1;
7112 counts_seek(fd, where, TRUE);
7113 fd_write(fd, (char*)(&count), sizeof(u32b));
7115 if (fd_lock(fd, F_UNLCK)) return 1;
7123 #ifdef HANDLE_SIGNALS
7130 * Handle signals -- suspend
7132 * Actually suspend the game, and then resume cleanly
7134 static void handle_signal_suspend(int sig)
7136 /* Disable handler */
7137 (void)signal(sig, SIG_IGN);
7144 /* Suspend the "Term" */
7145 Term_xtra(TERM_XTRA_ALIVE, 0);
7147 /* Suspend ourself */
7148 (void)kill(0, SIGSTOP);
7150 /* Resume the "Term" */
7151 Term_xtra(TERM_XTRA_ALIVE, 1);
7153 /* Redraw the term */
7156 /* Flush the term */
7161 /* Restore handler */
7162 (void)signal(sig, handle_signal_suspend);
7167 * Handle signals -- simple (interrupt and quit)
7169 * This function was causing a *huge* number of problems, so it has
7170 * been simplified greatly. We keep a global variable which counts
7171 * the number of times the user attempts to kill the process, and
7172 * we commit suicide if the user does this a certain number of times.
7174 * We attempt to give "feedback" to the user as he approaches the
7175 * suicide thresh-hold, but without penalizing accidental keypresses.
7177 * To prevent messy accidents, we should reset this global variable
7178 * whenever the user enters a keypress, or something like that.
7180 static void handle_signal_simple(int sig)
7182 /* Disable handler */
7183 (void)signal(sig, SIG_IGN);
7186 /* Nothing to save, just quit */
7187 if (!character_generated || character_saved) quit(NULL);
7190 /* Count the signals */
7194 /* Terminate dead characters */
7197 /* Mark the savefile */
7199 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7201 (void)strcpy(died_from, "Abortion");
7220 /* Allow suicide (after 5) */
7221 else if (signal_count >= 5)
7223 /* Cause of "death" */
7225 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7227 (void)strcpy(died_from, "Interrupting");
7242 p_ptr->leaving = TRUE;
7256 /* Give warning (after 4) */
7257 else if (signal_count >= 4)
7260 Term_xtra(TERM_XTRA_NOISE, 0);
7262 /* Clear the top line */
7263 Term_erase(0, 0, 255);
7265 /* Display the cause */
7267 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7269 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7277 /* Give warning (after 2) */
7278 else if (signal_count >= 2)
7281 Term_xtra(TERM_XTRA_NOISE, 0);
7284 /* Restore handler */
7285 (void)signal(sig, handle_signal_simple);
7290 * Handle signal -- abort, kill, etc
7292 static void handle_signal_abort(int sig)
7294 /* Disable handler */
7295 (void)signal(sig, SIG_IGN);
7298 /* Nothing to save, just quit */
7299 if (!character_generated || character_saved) quit(NULL);
7306 /* Clear the bottom line */
7307 Term_erase(0, 23, 255);
7309 /* Give a warning */
7310 Term_putstr(0, 23, -1, TERM_RED,
7312 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7314 "A gruesome software bug LEAPS out at you!");
7320 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7322 Term_putstr(45, 23, -1, TERM_RED, "Panic save...");
7334 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7336 (void)strcpy(died_from, "(panic save)");
7340 /* Forbid suspend */
7341 signals_ignore_tstp();
7343 /* Attempt to save */
7347 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7349 Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
7358 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7360 Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
7370 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7372 quit("software bug");
7381 * Ignore SIGTSTP signals (keyboard suspend)
7383 void signals_ignore_tstp(void)
7387 (void)signal(SIGTSTP, SIG_IGN);
7393 * Handle SIGTSTP signals (keyboard suspend)
7395 void signals_handle_tstp(void)
7399 (void)signal(SIGTSTP, handle_signal_suspend);
7406 * Prepare to handle the relevant signals
7408 void signals_init(void)
7412 (void)signal(SIGHUP, SIG_IGN);
7417 (void)signal(SIGTSTP, handle_signal_suspend);
7422 (void)signal(SIGINT, handle_signal_simple);
7426 (void)signal(SIGQUIT, handle_signal_simple);
7431 (void)signal(SIGFPE, handle_signal_abort);
7435 (void)signal(SIGILL, handle_signal_abort);
7439 (void)signal(SIGTRAP, handle_signal_abort);
7443 (void)signal(SIGIOT, handle_signal_abort);
7447 (void)signal(SIGKILL, handle_signal_abort);
7451 (void)signal(SIGBUS, handle_signal_abort);
7455 (void)signal(SIGSEGV, handle_signal_abort);
7459 (void)signal(SIGTERM, handle_signal_abort);
7463 (void)signal(SIGPIPE, handle_signal_abort);
7467 (void)signal(SIGEMT, handle_signal_abort);
7471 (void)signal(SIGDANGER, handle_signal_abort);
7475 (void)signal(SIGSYS, handle_signal_abort);
7479 (void)signal(SIGXCPU, handle_signal_abort);
7483 (void)signal(SIGPWR, handle_signal_abort);
7489 #else /* HANDLE_SIGNALS */
7495 void signals_ignore_tstp(void)
7502 void signals_handle_tstp(void)
7509 void signals_init(void)
7512 #endif /* HANDLE_SIGNALS */