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))
589 if (alive && 6 == option_info[i].o_page)
592 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
594 msg_format("Startup options can not changed! '%s'", buf);
601 option_flag[os] &= ~(1L << ob);
602 (*option_info[i].o_var) = FALSE;
607 /* don't know that option. ignore it.*/
609 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
611 msg_format("Ignored invalid option: %s", buf);
617 /* Process "Y:<str>" -- turn option on */
618 else if (buf[0] == 'Y')
620 for (i = 0; option_info[i].o_desc; i++)
622 int os = option_info[i].o_set;
623 int ob = option_info[i].o_bit;
625 if (option_info[i].o_var &&
626 option_info[i].o_text &&
627 streq(option_info[i].o_text, buf + 2))
629 if (alive && 6 == option_info[i].o_page)
632 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
634 msg_format("Startup options can not changed! '%s'", buf);
641 option_flag[os] |= (1L << ob);
642 (*option_info[i].o_var) = TRUE;
647 /* don't know that option. ignore it.*/
649 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
651 msg_format("Ignored invalid option: %s", buf);
657 /* Process "Z:<type>:<str>" -- set spell color */
658 else if (buf[0] == 'Z')
661 char *t = strchr(buf + 2, ':');
669 for (i = 0; gf_desc[i].name; i++)
671 /* Match this type */
672 if (streq(gf_desc[i].name, buf + 2))
674 /* Remember this color set */
675 gf_color[gf_desc[i].num] = quark_add(t);
682 /* set macro trigger names and a template */
683 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
684 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
685 else if (buf[0] == 'T')
688 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
694 if (macro_template != NULL)
696 free(macro_template);
697 macro_template = NULL;
698 for (i = 0; i < max_macrotrigger; i++)
699 free(macro_trigger_name[i]);
700 max_macrotrigger = 0;
703 if (*zz[0] == '\0') return 0; /* clear template */
705 if (2 + num != tok) return 1; /* error */
707 len = strlen(zz[0])+1+num+1;
708 for (i = 0; i < num; i++)
709 len += strlen(zz[2+i])+1;
710 macro_template = malloc(len);
712 strcpy(macro_template, zz[0]);
714 macro_template + strlen(macro_template) + 1;
715 strcpy(macro_modifier_chr, zz[1]);
716 macro_modifier_name[0] =
717 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
718 for (i = 0; i < num; i++)
720 strcpy(macro_modifier_name[i], zz[2+i]);
721 macro_modifier_name[i+1] = macro_modifier_name[i] +
722 strlen(macro_modifier_name[i]) + 1;
729 if (max_macrotrigger >= MAX_MACRO_TRIG)
732 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
734 msg_print("Too many macro triggers!");
738 m = max_macrotrigger;
741 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
743 len += strlen(zz[2]) + 1;
744 macro_trigger_name[m] = malloc(len);
746 t = macro_trigger_name[m];
755 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
756 strlen(macro_trigger_name[m]) + 1;
757 strcpy(macro_trigger_keycode[0][m], zz[1]);
760 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
761 strlen(macro_trigger_keycode[0][m]) + 1;
762 strcpy(macro_trigger_keycode[1][m], zz[2]);
766 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
778 * Helper function for "process_pref_file()"
781 * v: output buffer array
787 static cptr process_pref_file_expr(char **sp, char *fp)
804 while (isspace(*s)) s++;
822 t = process_pref_file_expr(&s, &f);
831 else if (streq(t, "IOR"))
834 while (*s && (f != b2))
836 t = process_pref_file_expr(&s, &f);
837 if (*t && !streq(t, "0")) v = "1";
842 else if (streq(t, "AND"))
845 while (*s && (f != b2))
847 t = process_pref_file_expr(&s, &f);
848 if (*t && streq(t, "0")) v = "0";
853 else if (streq(t, "NOT"))
856 while (*s && (f != b2))
858 t = process_pref_file_expr(&s, &f);
859 if (*t && streq(t, "1")) v = "0";
864 else if (streq(t, "EQU"))
869 t = process_pref_file_expr(&s, &f);
871 while (*s && (f != b2))
874 t = process_pref_file_expr(&s, &f);
875 if (*t && !streq(p, t)) v = "0";
880 else if (streq(t, "LEQ"))
885 t = process_pref_file_expr(&s, &f);
887 while (*s && (f != b2))
890 t = process_pref_file_expr(&s, &f);
891 if (*t && (strcmp(p, t) > 0)) v = "0";
896 else if (streq(t, "GEQ"))
901 t = process_pref_file_expr(&s, &f);
903 while (*s && (f != b2))
906 t = process_pref_file_expr(&s, &f);
907 if (*t && (strcmp(p, t) < 0)) v = "0";
914 while (*s && (f != b2))
916 t = process_pref_file_expr(&s, &f);
921 if (f != b2) v = "?x?x?";
923 /* Extract final and Terminate */
924 if ((f = *s) != '\0') *s++ = '\0';
930 /* Accept all printables except spaces and brackets */
931 while (isprint(*s) && !strchr(" []", *s)) ++s;
933 /* Extract final and Terminate */
934 if ((f = *s) != '\0') *s++ = '\0';
940 if (streq(b+1, "SYS"))
945 else if (streq(b+1, "KEYBOARD"))
947 v = ANGBAND_KEYBOARD;
951 else if (streq(b+1, "GRAF"))
956 /* Monochrome mode */
957 else if (streq(b+1, "MONOCHROME"))
966 else if (streq(b+1, "RACE"))
976 else if (streq(b+1, "CLASS"))
986 else if (streq(b+1, "PLAYER"))
992 else if (streq(b+1, "REALM1"))
995 v = E_realm_names[p_ptr->realm1];
997 v = realm_names[p_ptr->realm1];
1002 else if (streq(b+1, "REALM2"))
1005 v = E_realm_names[p_ptr->realm2];
1007 v = realm_names[p_ptr->realm2];
1012 else if (streq(b+1, "LEVEL"))
1014 sprintf(tmp, "%02d", p_ptr->lev);
1039 * Process line for auto picker/destroyer.
1041 static errr process_pickpref_file_line(char *buf)
1047 /* Nuke illegal char */
1048 for(i = 0; buf[i]; i++)
1051 if (iskanji(buf[i]))
1057 if (isspace(buf[i]) && buf[i] != ' ')
1064 act = DO_AUTOPICK | DO_DISPLAY;
1069 act &= ~DO_AUTOPICK;
1070 act |= DO_AUTODESTROY;
1075 act &= ~DO_AUTOPICK;
1076 act |= DONT_AUTOPICK;
1088 /* don't mind upper or lower case */
1090 for (i = 0; s[i]; i++)
1100 s[i] = tolower(s[i]);
1102 /* Auto-inscription? */
1111 /* Skip empty line */
1114 if (max_autopick == MAX_AUTOPICK)
1117 /* Already has the same entry? */
1118 for(i = 0; i < max_autopick; i++)
1119 if(!strcmp(s, autopick_name[i]))
1122 autopick_name[max_autopick] = string_make(s);
1123 autopick_action[max_autopick] = act;
1125 autopick_insc[max_autopick] = string_make(s2);
1133 * Open the "user pref file" and parse it.
1135 static errr process_pref_file_aux(cptr name, bool read_pickpref)
1147 bool bypass = FALSE;
1151 fp = my_fopen(name, "r");
1154 if (!fp) return (-1);
1156 /* Process the file */
1157 while (0 == my_fgets(fp, buf, 1024))
1162 /* Skip "empty" lines */
1163 if (!buf[0]) continue;
1165 /* Skip "blank" lines */
1167 if (!iskanji(buf[0]))
1169 if (isspace(buf[0])) continue;
1172 if (buf[0] == '#') continue;
1179 /* Process "?:<expr>" */
1180 if ((buf[0] == '?') && (buf[1] == ':'))
1189 /* Parse the expr */
1190 v = process_pref_file_expr(&s, &f);
1193 bypass = (streq(v, "0") ? TRUE : FALSE);
1199 /* Apply conditionals */
1200 if (bypass) continue;
1203 /* Process "%:<file>" */
1206 /* Process that file if allowed */
1208 (void)process_pickpref_file(buf + 2);
1210 (void)process_pref_file(buf + 2);
1217 /* Process the line */
1218 err = process_pref_file_command(buf);
1220 /* This is not original pref line... */
1225 err = process_pickpref_file_line(buf);
1233 /* Print error message */
1234 /* ToDo: Add better error messages */
1236 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1237 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1239 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1240 msg_format("Parsing '%s'", old);
1245 /* Close the file */
1255 * Process the "user pref file" with the given name
1257 * See the functions above for a list of legal "commands".
1259 * We also accept the special "?" and "%" directives, which
1260 * allow conditional evaluation and filename inclusion.
1262 errr process_pref_file(cptr name)
1268 /* Build the filename */
1269 path_build(buf, 1024, ANGBAND_DIR_PREF, name);
1271 /* Process the system pref file */
1272 err1 = process_pref_file_aux(buf, FALSE);
1274 /* Stop at parser errors, but not at non-existing file */
1275 if (err1 > 0) return err1;
1281 /* Build the filename */
1282 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1284 /* Process the user pref file */
1285 err2 = process_pref_file_aux(buf, FALSE);
1291 /* User file does not exist, but read system pref file */
1292 if (err2 < 0 && !err1)
1295 /* Result of user file processing */
1304 * Operating hours for ANGBAND (defaults to non-work hours)
1306 static char days[7][29] =
1308 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1309 "MON:XXXXXXXX.........XXXXXXX",
1310 "TUE:XXXXXXXX.........XXXXXXX",
1311 "WED:XXXXXXXX.........XXXXXXX",
1312 "THU:XXXXXXXX.........XXXXXXX",
1313 "FRI:XXXXXXXX.........XXXXXXX",
1314 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1318 * Restict usage (defaults to no restrictions)
1320 static bool check_time_flag = FALSE;
1328 errr check_time(void)
1336 /* No restrictions */
1337 if (!check_time_flag) return (0);
1339 /* Check for time violation */
1340 c = time((time_t *)0);
1344 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1355 * Initialize CHECK_TIME
1357 errr check_time_init(void)
1367 /* Build the filename */
1368 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1371 fp = my_fopen(buf, "r");
1373 /* No file, no restrictions */
1374 if (!fp) return (0);
1376 /* Assume restrictions */
1377 check_time_flag = TRUE;
1379 /* Parse the file */
1380 while (0 == my_fgets(fp, buf, 80))
1382 /* Skip comments and blank lines */
1383 if (!buf[0] || (buf[0] == '#')) continue;
1385 /* Chop the buffer */
1388 /* Extract the info */
1389 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1390 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1391 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1392 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1393 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1394 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1395 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1411 #ifndef MAXHOSTNAMELEN
1412 # define MAXHOSTNAMELEN 64
1415 typedef struct statstime statstime;
1421 unsigned int v_pgpgin;
1422 unsigned int v_pgpgout;
1423 unsigned int v_pswpin;
1424 unsigned int v_pswpout;
1425 unsigned int v_intr;
1431 unsigned int v_swtch;
1433 struct timeval boottime;
1434 struct timeval curtime;
1438 * Maximal load (if any).
1440 static int check_load_value = 0;
1448 errr check_load(void)
1453 struct statstime st;
1455 /* Success if not checking */
1456 if (!check_load_value) return (0);
1458 /* Check the load */
1459 if (0 == rstat("localhost", &st))
1461 long val1 = (long)(st.avenrun[2]);
1462 long val2 = (long)(check_load_value) * FSCALE;
1464 /* Check for violation */
1465 if (val1 >= val2) return (1);
1476 * Initialize CHECK_LOAD
1478 errr check_load_init(void)
1487 char temphost[MAXHOSTNAMELEN+1];
1488 char thishost[MAXHOSTNAMELEN+1];
1491 /* Build the filename */
1492 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1494 /* Open the "load" file */
1495 fp = my_fopen(buf, "r");
1497 /* No file, no restrictions */
1498 if (!fp) return (0);
1501 check_load_value = 100;
1503 /* Get the host name */
1504 (void)gethostname(thishost, (sizeof thishost) - 1);
1507 while (0 == my_fgets(fp, buf, 1024))
1511 /* Skip comments and blank lines */
1512 if (!buf[0] || (buf[0] == '#')) continue;
1514 /* Parse, or ignore */
1515 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1517 /* Skip other hosts */
1518 if (!streq(temphost, thishost) &&
1519 !streq(temphost, "localhost")) continue;
1521 /* Use that value */
1522 check_load_value = value;
1528 /* Close the file */
1538 #define ENTRY_BARE_HAND 0
1539 #define ENTRY_TWO_HANDS 1
1540 #define ENTRY_RIGHT_HAND1 2
1541 #define ENTRY_LEFT_HAND1 3
1542 #define ENTRY_LEFT_HAND2 4
1543 #define ENTRY_RIGHT_HAND2 5
1544 #define ENTRY_POSTURE 6
1545 #define ENTRY_SHOOT_HIT_DAM 7
1546 #define ENTRY_SHOOT_POWER 8
1547 #define ENTRY_SPEED 9
1548 #define ENTRY_BASE_AC 10
1549 #define ENTRY_LEVEL 11
1550 #define ENTRY_CUR_EXP 12
1551 #define ENTRY_MAX_EXP 13
1552 #define ENTRY_EXP_TO_ADV 14
1553 #define ENTRY_GOLD 15
1554 #define ENTRY_DAY 16
1557 #define ENTRY_PLAY_TIME 19
1558 #define ENTRY_SKILL_FIGHT 20
1559 #define ENTRY_SKILL_SHOOT 21
1560 #define ENTRY_SKILL_SAVING 22
1561 #define ENTRY_SKILL_STEALTH 23
1562 #define ENTRY_SKILL_PERCEP 24
1563 #define ENTRY_SKILL_SEARCH 25
1564 #define ENTRY_SKILL_DISARM 26
1565 #define ENTRY_SKILL_DEVICE 27
1566 #define ENTRY_BLOWS 28
1567 #define ENTRY_SHOTS 29
1568 #define ENTRY_AVG_DMG 30
1569 #define ENTRY_INFRA 31
1571 #define ENTRY_NAME 32
1572 #define ENTRY_SEX 33
1573 #define ENTRY_RACE 34
1574 #define ENTRY_CLASS 35
1575 #define ENTRY_REALM 36
1576 #define ENTRY_PATRON 37
1577 #define ENTRY_AGE 38
1578 #define ENTRY_HEIGHT 39
1579 #define ENTRY_WEIGHT 40
1580 #define ENTRY_SOCIAL 41
1581 #define ENTRY_ALIGN 42
1590 } disp_player_line[]
1593 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1594 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1595 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1596 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1597 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1598 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1600 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1601 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1602 {01, 20, 25, "²Ã®"},
1603 { 1, 19, 25, "£Á£Ã"},
1604 {29, 13, 21, "¥ì¥Ù¥ë"},
1605 {29, 14, 21, "·Ð¸³ÃÍ"},
1606 {29, 15, 21, "ºÇÂç·Ð¸³"},
1607 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1608 {29, 17, 21, "½ê»ý¶â"},
1609 {29, 19, 21, "ÆüÉÕ"},
1610 {29, 10, 21, "£È£Ð"},
1611 {29, 11, 21, "£Í£Ð"},
1612 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1613 {54, 10, -1, "ÂǷ⹶·â :"},
1614 {54, 11, -1, "¼Í·â¹¶·â :"},
1615 {54, 12, -1, "ËâË¡Ëɸæ :"},
1616 {54, 13, -1, "±£Ì©¹ÔÆ° :"},
1617 {54, 15, -1, "ÃγР:"},
1618 {54, 16, -1, "õº÷ :"},
1619 {54, 17, -1, "²ò½ü :"},
1620 {54, 18, -1, "ËâË¡Æ»¶ñ :"},
1621 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1622 {01, 17, 25, "¼Í·â²ó¿ô"},
1623 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1624 {54, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1625 {26, 1, -1, "̾Á° : "},
1626 { 1, 3, -1, "ÀÊÌ : "},
1627 { 1, 4, -1, "¼ï² : "},
1628 { 1, 5, -1, "¿¦¶È : "},
1629 { 1, 6, -1, "ËâË¡ : "},
1630 { 1, 7, -1, "¼é¸îËâ¿À : "},
1631 {29, 3, 21, "ǯÎð"},
1632 {29, 4, 21, "¿ÈĹ"},
1633 {29, 5, 21, "ÂνÅ"},
1634 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1635 {29, 7, 21, "°À"},
1639 { 1, 10, 25, "Bare hand"},
1640 { 1, 10, 25, "Two hands"},
1641 { 1, 10, 25, "Right hand"},
1642 { 1, 10, 25, "Left hand"},
1643 { 1, 11, 25, "Left hand"},
1644 { 1, 11, 25, "Right hand"},
1645 { 1, 11, 25, "Posture"},
1646 { 1, 15, 25, "Shooting"},
1647 { 1, 16, 25, "Multiplier"},
1648 {01, 20, 25, "Speed"},
1650 {29, 13, 21, "Level"},
1651 {29, 14, 21, "Experience"},
1652 {29, 15, 21, "Max Exp"},
1653 {29, 16, 21, "Exp to Adv"},
1654 {29, 17, 21, "Gold"},
1655 {29, 19, 21, "Time"},
1656 {29, 10, 21, "Hit point"},
1657 {29, 11, 21, "SP (Mana)"},
1658 {29, 20, 21, "Play time"},
1659 {54, 10, -1, "Fighting : "},
1660 {54, 11, -1, "Bows/Throw : "},
1661 {54, 12, -1, "Saving Throw: "},
1662 {54, 13, -1, "Stealth : "},
1663 {54, 15, -1, "Perception : "},
1664 {54, 16, -1, "Searching : "},
1665 {54, 17, -1, "Disarming : "},
1666 {54, 18, -1, "Magic Device: "},
1667 {01, 12, 25, "Blows/Round"},
1668 {01, 17, 25, "Shots/Round"},
1669 {01, 13, 25, "AverageDmg/Rnd"},
1670 {54, 20, -1, "Infra-Vision: "},
1671 {26, 1, -1, "Name : "},
1672 { 1, 3, -1, "Sex : "},
1673 { 1, 4, -1, "Race : "},
1674 { 1, 5, -1, "Class : "},
1675 { 1, 6, -1, "Magic : "},
1676 { 1, 7, -1, "Patron : "},
1678 {29, 4, 21, "Height"},
1679 {29, 5, 21, "Weight"},
1680 {29, 6, 21, "Social Class"},
1681 {29, 7, 21, "Align"},
1685 static void display_player_one_line(int entry, cptr val, byte attr)
1689 int row = disp_player_line[entry].row;
1690 int col = disp_player_line[entry].col;
1691 int len = disp_player_line[entry].len;
1692 cptr head = disp_player_line[entry].header;
1694 int head_len = strlen(head);
1696 Term_putstr(col, row, -1, TERM_WHITE, head);
1703 int val_len = len - head_len;
1704 sprintf(buf, "%*.*s", val_len, val_len, val);
1705 Term_putstr(col + head_len, row, -1, attr, buf);
1709 Term_putstr(col + head_len, row, -1, attr, val);
1717 * Prints the following information on the screen.
1719 static void display_player_middle(void)
1722 int show_tohit, show_todam;
1728 show_tohit = p_ptr->dis_to_h[0];
1729 show_todam = p_ptr->dis_to_d[0];
1731 o_ptr = &inventory[INVEN_RARM];
1733 /* Hack -- add in weapon info if known */
1734 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1735 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1738 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1740 /* Dump the bonuses to hit/dam */
1741 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1742 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1743 else if(p_ptr->ryoute)
1744 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1745 else if (left_hander)
1746 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1748 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1753 show_tohit = p_ptr->dis_to_h[1];
1754 show_todam = p_ptr->dis_to_d[1];
1756 o_ptr = &inventory[INVEN_LARM];
1758 /* Hack -- add in weapon info if known */
1759 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1760 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1763 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1765 /* Dump the bonuses to hit/dam */
1767 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1769 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1771 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1774 if (p_ptr->special_defense & KAMAE_MASK)
1776 for (i = 0; i < MAX_KAMAE; i++)
1778 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1782 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1784 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1789 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1791 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1796 o_ptr = &inventory[INVEN_BOW];
1799 show_tohit = p_ptr->dis_to_h_b;
1802 /* Apply weapon bonuses */
1803 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1804 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1806 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1807 show_tohit += (weapon_exp[0][o_ptr->sval])/400;
1809 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1812 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1814 if (inventory[INVEN_BOW].k_idx)
1816 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1818 /* Get extra "power" from "extra might" */
1819 if (p_ptr->xtra_might) tmul++;
1821 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1825 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1827 /* Dump the armor class */
1828 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1832 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1837 i = p_ptr->pspeed-110;
1839 /* Hack -- Visually "undo" the Search Mode Slowdown */
1840 if (p_ptr->action == ACTION_SEARCH) i += 10;
1845 attr = TERM_L_GREEN;
1859 attr = TERM_L_UMBER;
1866 if (is_fast) tmp_speed += 10;
1867 if (p_ptr->slow) tmp_speed -= 10;
1868 if (p_ptr->lightspeed) tmp_speed = 99;
1872 if (m_list[p_ptr->riding].fast) tmp_speed += 10;
1873 if (m_list[p_ptr->riding].slow) tmp_speed -= 10;
1879 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1882 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1884 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1895 sprintf(buf, "(%+d)", i);
1898 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1900 sprintf(buf, "Riding (%+d)", i);
1904 display_player_one_line(ENTRY_SPEED, buf, attr);
1907 /* Dump character level */
1908 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1910 /* Dump experience */
1911 if (p_ptr->prace == RACE_ANDROID)
1912 display_player_one_line(ENTRY_CUR_EXP, "*****", TERM_L_GREEN);
1913 else if (p_ptr->exp >= p_ptr->max_exp)
1914 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_L_GREEN);
1916 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_YELLOW);
1918 /* Dump max experience */
1919 if (p_ptr->prace == RACE_ANDROID)
1920 display_player_one_line(ENTRY_MAX_EXP, "*****", TERM_L_GREEN);
1922 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1924 /* Dump exp to advance */
1925 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1926 display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
1928 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1931 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1935 s32b len = 20L * TOWN_DAWN;
1936 s32b tick = turn % len + len / 4;
1940 "%ldÆüÌÜ %2ld:%02ld",
1942 "Day %ld %2ld:%02ld",
1944 ((p_ptr->prace == RACE_VAMPIRE) ||
1945 (p_ptr->prace == RACE_SKELETON) ||
1946 (p_ptr->prace == RACE_ZOMBIE) ||
1947 (p_ptr->prace == RACE_SPECTRE))
1948 ? (turn - (15L * TOWN_DAWN)) / len + 1
1949 : (turn + (5L * TOWN_DAWN))/ len + 1,
1950 (24 * tick / len) % 24,
1951 (1440 * tick / len) % 60);
1953 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1955 /* Dump hit point */
1956 if (p_ptr->chp >= p_ptr->mhp)
1957 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1958 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1959 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1961 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1963 /* Dump mana power */
1964 if (p_ptr->csp >= p_ptr->msp)
1965 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1966 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1967 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1969 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1971 /* Dump play time */
1972 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1977 * Hack -- pass color info around this file
1979 static byte likert_color = TERM_WHITE;
1983 * Returns a "rating" of x depending on y
1985 static cptr likert(int x, int y)
1987 static char dummy[20] = "";
1992 /* Negative value */
1995 likert_color = TERM_L_DARK;
1999 return ("Very Bad");
2004 /* Analyze the value */
2010 likert_color = TERM_RED;
2020 likert_color = TERM_L_RED;
2031 likert_color = TERM_ORANGE;
2041 likert_color = TERM_YELLOW;
2051 likert_color = TERM_YELLOW;
2053 return ("ÂçÊÑÎɤ¤");
2055 return ("Very Good");
2062 likert_color = TERM_L_GREEN;
2066 return ("Excellent");
2076 likert_color = TERM_GREEN;
2089 likert_color = TERM_BLUE;
2091 return ("¥«¥ª¥¹¥é¥ó¥¯");
2093 return ("Chaos Rank");
2099 likert_color = TERM_VIOLET;
2101 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2103 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2113 * Prints ratings on certain abilities
2115 * This code is "imitated" elsewhere to "dump" a character sheet.
2117 static void display_player_various(void)
2119 int tmp, damage[2], blows1, blows2, i, basedam;
2120 int xthn, xthb, xfos, xsrh;
2121 int xdis, xdev, xsav, xstl;
2125 int shots, shot_frac;
2129 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2130 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2131 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2132 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2133 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2135 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2137 /* Shooting Skill (with current bow and normal missile) */
2138 o_ptr = &inventory[INVEN_BOW];
2139 tmp = p_ptr->to_h_b + o_ptr->to_h;
2140 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2142 /* If the player is wielding one? */
2145 s16b energy_fire = bow_energy(o_ptr->sval);
2147 /* Calculate shots per round */
2148 shots = p_ptr->num_fire * 100;
2149 shot_frac = (shots * 100 / energy_fire) % 100;
2150 shots = shots / energy_fire;
2151 if (o_ptr->name1 == ART_CRIMSON)
2155 if (p_ptr->pclass == CLASS_ARCHER)
2157 /* Extra shot at level 10 */
2158 if (p_ptr->lev >= 10) shots++;
2160 /* Extra shot at level 30 */
2161 if (p_ptr->lev >= 30) shots++;
2163 /* Extra shot at level 45 */
2164 if (p_ptr->lev >= 45) shots++;
2174 for(i = 0; i< 2; i++)
2176 damage[i] = p_ptr->dis_to_d[i]*100;
2177 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2179 int level = p_ptr->lev;
2185 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2186 if (p_ptr->special_defense & KAMAE_BYAKKO)
2187 basedam = monk_ave_damage[level][1];
2188 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2189 basedam = monk_ave_damage[level][2];
2191 basedam = monk_ave_damage[level][0];
2195 /* Average damage per round */
2196 o_ptr = &inventory[INVEN_RARM+i];
2197 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2198 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2199 object_flags(o_ptr, &f1, &f2, &f3);
2200 if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
2206 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2208 /* vorpal flag only */
2212 if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2213 basedam = basedam * 7 / 2;
2214 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2215 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2217 damage[i] += basedam;
2218 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2219 if (damage[i] < 0) damage[i] = 0;
2221 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2222 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2224 /* Basic abilities */
2226 xdis = p_ptr->skill_dis;
2227 xdev = p_ptr->skill_dev;
2228 xsav = p_ptr->skill_sav;
2229 xstl = p_ptr->skill_stl;
2230 xsrh = p_ptr->skill_srh;
2231 xfos = p_ptr->skill_fos;
2234 desc = likert(xthn, 12);
2235 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2237 desc = likert(xthb, 12);
2238 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2240 desc = likert(xsav, 7);
2241 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2243 desc = likert(xstl, 1);
2244 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2246 desc = likert(xfos, 6);
2247 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2249 desc = likert(xsrh, 6);
2250 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2252 desc = likert(xdis, 8);
2253 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2255 desc = likert(xdev, 6);
2256 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2259 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2261 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2263 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2266 if ((damage[0]+damage[1]) == 0)
2269 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2271 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2273 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2279 * Obtain the "flags" for the player as if he was an item
2281 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2284 (*f1) = (*f2) = (*f3) = 0L;
2287 switch (p_ptr->pclass)
2290 if (p_ptr->lev > 44)
2291 (*f3) |= (TR3_REGEN);
2293 if (p_ptr->lev > 29)
2294 (*f2) |= (TR2_RES_FEAR);
2297 if (p_ptr->lev > 39)
2298 (*f2) |= (TR2_RES_FEAR);
2300 case CLASS_CHAOS_WARRIOR:
2301 if (p_ptr->lev > 29)
2302 (*f2) |= (TR2_RES_CHAOS);
2303 if (p_ptr->lev > 39)
2304 (*f2) |= (TR2_RES_FEAR);
2307 case CLASS_FORCETRAINER:
2308 if ((p_ptr->lev > 9) && !heavy_armor())
2310 if ((p_ptr->lev>24) && !heavy_armor())
2311 (*f2) |= (TR2_FREE_ACT);
2318 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2321 (*f2) |= (TR2_FREE_ACT);
2323 (*f3) |= TR3_SLOW_DIGEST;
2324 (*f2) |= TR2_RES_FEAR;
2325 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2326 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2327 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2329 case CLASS_MINDCRAFTER:
2331 (*f2) |= (TR2_RES_FEAR);
2332 if (p_ptr->lev > 19)
2333 (*f2) |= (TR2_SUST_WIS);
2334 if (p_ptr->lev > 29)
2335 (*f2) |= (TR2_RES_CONF);
2336 if (p_ptr->lev > 39)
2337 (*f3) |= (TR3_TELEPATHY);
2340 (*f2) |= (TR2_RES_SOUND);
2342 case CLASS_BERSERKER:
2343 (*f2) |= (TR2_SUST_STR);
2344 (*f2) |= (TR2_SUST_DEX);
2345 (*f2) |= (TR2_SUST_CON);
2346 (*f3) |= (TR3_REGEN);
2347 (*f2) |= (TR2_FREE_ACT);
2348 (*f1) |= (TR1_SPEED);
2349 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2351 case CLASS_MIRROR_MASTER:
2352 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2355 break; /* Do nothing */
2359 if (p_ptr->mimic_form)
2361 switch(p_ptr->mimic_form)
2364 (*f2) |= (TR2_HOLD_LIFE);
2365 (*f2) |= (TR2_RES_CHAOS);
2366 (*f2) |= (TR2_RES_NETHER);
2367 (*f2) |= (TR2_RES_FIRE);
2368 (*f3) |= (TR3_SEE_INVIS);
2369 (*f1) |= (TR1_SPEED);
2371 case MIMIC_DEMON_LORD:
2372 (*f2) |= (TR2_HOLD_LIFE);
2373 (*f2) |= (TR2_RES_CHAOS);
2374 (*f2) |= (TR2_RES_NETHER);
2375 (*f2) |= (TR2_RES_FIRE);
2376 (*f2) |= (TR2_RES_COLD);
2377 (*f2) |= (TR2_RES_ELEC);
2378 (*f2) |= (TR2_RES_ACID);
2379 (*f2) |= (TR2_RES_POIS);
2380 (*f2) |= (TR2_RES_CONF);
2381 (*f2) |= (TR2_RES_DISEN);
2382 (*f2) |= (TR2_RES_NEXUS);
2383 (*f2) |= (TR2_RES_FEAR);
2384 (*f2) |= (TR2_IM_FIRE);
2385 (*f3) |= (TR3_SH_FIRE);
2386 (*f3) |= (TR3_SEE_INVIS);
2387 (*f3) |= (TR3_TELEPATHY);
2388 (*f3) |= (TR3_FEATHER);
2389 (*f1) |= (TR1_SPEED);
2392 (*f2) |= (TR2_HOLD_LIFE);
2393 (*f2) |= (TR2_RES_DARK);
2394 (*f2) |= (TR2_RES_NETHER);
2395 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2396 (*f2) |= (TR2_RES_POIS);
2397 (*f2) |= (TR2_RES_COLD);
2398 (*f3) |= (TR3_SEE_INVIS);
2399 (*f1) |= (TR1_SPEED);
2405 switch (p_ptr->prace)
2408 (*f2) |= (TR2_RES_LITE);
2411 (*f2) |= (TR2_SUST_DEX);
2414 (*f2) |= (TR2_FREE_ACT);
2417 (*f2) |= (TR2_RES_BLIND);
2420 (*f2) |= (TR2_RES_DARK);
2422 case RACE_HALF_TROLL:
2423 (*f2) |= (TR2_SUST_STR);
2424 if (p_ptr->lev > 14)
2426 (*f3) |= (TR3_REGEN);
2427 if (p_ptr->pclass == CLASS_WARRIOR)
2429 (*f3) |= (TR3_SLOW_DIGEST);
2431 * Let's not make Regeneration a disadvantage
2432 * for the poor warriors who can never learn
2433 * a spell that satisfies hunger (actually
2434 * neither can rogues, but half-trolls are not
2435 * supposed to play rogues)
2441 (*f2) |= (TR2_SUST_CON);
2442 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2445 (*f2) |= (TR2_RES_LITE);
2446 (*f3) |= (TR3_SEE_INVIS);
2448 case RACE_BARBARIAN:
2449 (*f2) |= (TR2_RES_FEAR);
2451 case RACE_HALF_OGRE:
2452 (*f2) |= (TR2_SUST_STR);
2453 (*f2) |= (TR2_RES_DARK);
2455 case RACE_HALF_GIANT:
2456 (*f2) |= (TR2_RES_SHARDS);
2457 (*f2) |= (TR2_SUST_STR);
2459 case RACE_HALF_TITAN:
2460 (*f2) |= (TR2_RES_CHAOS);
2463 (*f2) |= (TR2_RES_SOUND);
2466 (*f2) |= (TR2_RES_ACID);
2467 if (p_ptr->lev > 19)
2468 (*f2) |= (TR2_IM_ACID);
2471 (*f2) |= (TR2_RES_CONF);
2472 (*f2) |= (TR2_RES_ACID);
2477 (*f2) |= (TR2_RES_POIS);
2480 (*f2) |= (TR2_RES_DISEN);
2481 (*f2) |= (TR2_RES_DARK);
2484 (*f2) |= (TR2_RES_DARK);
2485 if (p_ptr->lev > 19)
2486 (*f3) |= (TR3_SEE_INVIS);
2488 case RACE_DRACONIAN:
2489 (*f3) |= TR3_FEATHER;
2491 (*f2) |= (TR2_RES_FIRE);
2493 (*f2) |= (TR2_RES_COLD);
2494 if (p_ptr->lev > 14)
2495 (*f2) |= (TR2_RES_ACID);
2496 if (p_ptr->lev > 19)
2497 (*f2) |= (TR2_RES_ELEC);
2498 if (p_ptr->lev > 34)
2499 (*f2) |= (TR2_RES_POIS);
2501 case RACE_MIND_FLAYER:
2502 (*f2) |= (TR2_SUST_INT);
2503 (*f2) |= (TR2_SUST_WIS);
2504 if (p_ptr->lev > 14)
2505 (*f3) |= (TR3_SEE_INVIS);
2506 if (p_ptr->lev > 29)
2507 (*f3) |= (TR3_TELEPATHY);
2510 (*f2) |= (TR2_RES_FIRE);
2512 (*f3) |= (TR3_SEE_INVIS);
2515 (*f3) |= (TR3_SEE_INVIS);
2516 (*f2) |= (TR2_FREE_ACT);
2517 (*f2) |= (TR2_RES_POIS);
2518 (*f3) |= (TR3_SLOW_DIGEST);
2519 if (p_ptr->lev > 34)
2520 (*f2) |= (TR2_HOLD_LIFE);
2523 (*f3) |= (TR3_SEE_INVIS);
2524 (*f2) |= (TR2_RES_SHARDS);
2525 (*f2) |= (TR2_HOLD_LIFE);
2526 (*f2) |= (TR2_RES_POIS);
2528 (*f2) |= (TR2_RES_COLD);
2531 (*f3) |= (TR3_SEE_INVIS);
2532 (*f2) |= (TR2_HOLD_LIFE);
2533 (*f2) |= (TR2_RES_NETHER);
2534 (*f2) |= (TR2_RES_POIS);
2535 (*f3) |= (TR3_SLOW_DIGEST);
2537 (*f2) |= (TR2_RES_COLD);
2540 (*f2) |= (TR2_HOLD_LIFE);
2541 (*f2) |= (TR2_RES_DARK);
2542 (*f2) |= (TR2_RES_NETHER);
2543 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2544 (*f2) |= (TR2_RES_POIS);
2545 (*f2) |= (TR2_RES_COLD);
2548 (*f3) |= (TR3_FEATHER);
2549 (*f2) |= (TR2_FREE_ACT);
2550 (*f2) |= (TR2_RES_COLD);
2551 (*f3) |= (TR3_SEE_INVIS);
2552 (*f2) |= (TR2_HOLD_LIFE);
2553 (*f2) |= (TR2_RES_NETHER);
2554 (*f2) |= (TR2_RES_POIS);
2555 (*f3) |= (TR3_SLOW_DIGEST);
2557 if (p_ptr->lev > 34)
2558 (*f3) |= TR3_TELEPATHY;
2561 (*f2) |= (TR2_RES_LITE);
2562 (*f3) |= (TR3_FEATHER);
2564 (*f1) |= (TR1_SPEED);
2567 (*f2) |= (TR2_RES_SOUND);
2568 (*f2) |= (TR2_RES_CONF);
2571 (*f3) |= (TR3_FEATHER);
2572 (*f3) |= (TR3_SEE_INVIS);
2575 (*f2) |= (TR2_RES_FIRE);
2576 (*f2) |= (TR2_RES_NETHER);
2577 (*f2) |= (TR2_HOLD_LIFE);
2579 (*f3) |= (TR3_SEE_INVIS);
2582 (*f2) |= (TR2_SUST_CON);
2585 (*f3) |= (TR3_FEATHER);
2588 (*f2) |= (TR2_RES_CONF);
2591 (*f2) |= (TR2_FREE_ACT);
2592 (*f2) |= (TR2_RES_POIS);
2593 (*f3) |= (TR3_SLOW_DIGEST);
2594 (*f2) |= (TR2_HOLD_LIFE);
2604 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2606 (*f3) &= ~(TR3_REGEN);
2609 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2610 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2611 (p_ptr->muta3 & MUT3_SHORT_LEG))
2616 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2618 (*f3) |= TR3_SH_ELEC;
2621 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2623 (*f3) |= TR3_SH_FIRE;
2627 if (p_ptr->muta3 & MUT3_WINGS)
2629 (*f3) |= TR3_FEATHER;
2632 if (p_ptr->muta3 & MUT3_FEARLESS)
2634 (*f2) |= (TR2_RES_FEAR);
2637 if (p_ptr->muta3 & MUT3_REGEN)
2642 if (p_ptr->muta3 & MUT3_ESP)
2644 (*f3) |= TR3_TELEPATHY;
2647 if (p_ptr->muta3 & MUT3_MOTION)
2649 (*f2) |= TR2_FREE_ACT;
2653 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2654 (*f3) |= TR3_AGGRAVATE;
2655 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2657 (*f2) |= (TR2_RES_BLIND);
2658 (*f2) |= (TR2_RES_CONF);
2659 (*f2) |= (TR2_HOLD_LIFE);
2660 (*f3) |= (TR3_LITE);
2662 (*f1) |= (TR1_SPEED);
2664 if (p_ptr->special_defense & KATA_FUUJIN)
2665 (*f2) |= TR2_REFLECT;
2666 if (p_ptr->special_defense & KAMAE_GENBU)
2667 (*f2) |= TR2_REFLECT;
2668 if (p_ptr->special_defense & KAMAE_SUZAKU)
2669 (*f3) |= TR3_FEATHER;
2670 if (p_ptr->special_defense & KAMAE_SEIRYU)
2672 (*f2) |= (TR2_RES_FIRE);
2673 (*f2) |= (TR2_RES_COLD);
2674 (*f2) |= (TR2_RES_ACID);
2675 (*f2) |= (TR2_RES_ELEC);
2676 (*f2) |= (TR2_RES_POIS);
2677 (*f3) |= (TR3_FEATHER);
2678 (*f3) |= (TR3_SH_FIRE);
2679 (*f3) |= (TR3_SH_ELEC);
2680 (*f3) |= (TR3_SH_COLD);
2682 if (p_ptr->special_defense & KATA_MUSOU)
2684 (*f2) |= TR2_RES_FEAR;
2685 (*f2) |= TR2_RES_LITE;
2686 (*f2) |= TR2_RES_DARK;
2687 (*f2) |= TR2_RES_BLIND;
2688 (*f2) |= TR2_RES_CONF;
2689 (*f2) |= TR2_RES_SOUND;
2690 (*f2) |= TR2_RES_SHARDS;
2691 (*f2) |= TR2_RES_NETHER;
2692 (*f2) |= TR2_RES_NEXUS;
2693 (*f2) |= TR2_RES_CHAOS;
2694 (*f2) |= TR2_RES_DISEN;
2695 (*f2) |= TR2_REFLECT;
2696 (*f2) |= TR2_HOLD_LIFE;
2697 (*f2) |= TR2_FREE_ACT;
2698 (*f3) |= TR3_SH_FIRE;
2699 (*f3) |= TR3_SH_ELEC;
2700 (*f3) |= TR3_SH_COLD;
2701 (*f3) |= TR3_FEATHER;
2703 (*f3) |= TR3_SEE_INVIS;
2704 (*f3) |= TR3_TELEPATHY;
2705 (*f3) |= TR3_SLOW_DIGEST;
2707 (*f2) |= (TR2_SUST_STR);
2708 (*f2) |= (TR2_SUST_INT);
2709 (*f2) |= (TR2_SUST_WIS);
2710 (*f2) |= (TR2_SUST_DEX);
2711 (*f2) |= (TR2_SUST_CON);
2712 (*f2) |= (TR2_SUST_CHR);
2717 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2720 (*f1) = (*f2) = (*f3) = 0L;
2722 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2723 (*f2) |= TR2_RES_FEAR;
2724 if (p_ptr->tim_invis)
2725 (*f3) |= TR3_SEE_INVIS;
2726 if (p_ptr->tim_regen)
2728 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2729 (*f3) |= TR3_TELEPATHY;
2730 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2732 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2734 (*f2) |= (TR2_RES_FIRE);
2735 (*f2) |= (TR2_RES_COLD);
2736 (*f2) |= (TR2_RES_ACID);
2737 (*f2) |= (TR2_RES_ELEC);
2738 (*f2) |= (TR2_RES_POIS);
2742 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2743 (*f2) |= TR2_RES_ACID;
2744 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2745 (*f2) |= TR2_RES_ELEC;
2746 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2747 (*f2) |= TR2_RES_FIRE;
2748 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2749 (*f2) |= TR2_RES_COLD;
2753 if (p_ptr->oppose_acid)
2754 (*f2) |= TR2_RES_ACID;
2755 if (p_ptr->oppose_elec)
2756 (*f2) |= TR2_RES_ELEC;
2757 if (p_ptr->oppose_fire)
2758 (*f2) |= TR2_RES_FIRE;
2759 if (p_ptr->oppose_cold)
2760 (*f2) |= TR2_RES_COLD;
2762 if (p_ptr->oppose_pois)
2763 (*f2) |= TR2_RES_POIS;
2764 if (p_ptr->special_attack & ATTACK_ACID)
2765 (*f1) |= TR1_BRAND_ACID;
2766 if (p_ptr->special_attack & ATTACK_ELEC)
2767 (*f1) |= TR1_BRAND_ELEC;
2768 if (p_ptr->special_attack & ATTACK_FIRE)
2769 (*f1) |= TR1_BRAND_FIRE;
2770 if (p_ptr->special_attack & ATTACK_COLD)
2771 (*f1) |= TR1_BRAND_COLD;
2772 if (p_ptr->special_attack & ATTACK_POIS)
2773 (*f1) |= TR1_BRAND_POIS;
2774 if (p_ptr->special_defense & DEFENSE_ACID)
2775 (*f2) |= TR2_IM_ACID;
2776 if (p_ptr->special_defense & DEFENSE_ELEC)
2777 (*f2) |= TR2_IM_ELEC;
2778 if (p_ptr->special_defense & DEFENSE_FIRE)
2779 (*f2) |= TR2_IM_FIRE;
2780 if (p_ptr->special_defense & DEFENSE_COLD)
2781 (*f2) |= TR2_IM_COLD;
2782 if (p_ptr->wraith_form)
2783 (*f2) |= TR2_REFLECT;
2785 if (p_ptr->tim_reflect){
2786 (*f2) |= TR2_REFLECT;
2789 if (p_ptr->magicdef)
2791 (*f2) |= TR2_RES_BLIND;
2792 (*f2) |= TR2_RES_CONF;
2793 (*f2) |= TR2_REFLECT;
2794 (*f2) |= TR2_FREE_ACT;
2795 (*f3) |= TR3_FEATHER;
2797 if (p_ptr->tim_res_nether)
2799 (*f2) |= TR2_RES_NETHER;
2801 if (p_ptr->tim_sh_fire)
2803 (*f3) |= TR3_SH_FIRE;
2807 (*f2) |= TR2_RES_FEAR;
2808 (*f2) |= TR2_RES_LITE;
2809 (*f2) |= TR2_RES_DARK;
2810 (*f2) |= TR2_RES_BLIND;
2811 (*f2) |= TR2_RES_CONF;
2812 (*f2) |= TR2_RES_SOUND;
2813 (*f2) |= TR2_RES_SHARDS;
2814 (*f2) |= TR2_RES_NETHER;
2815 (*f2) |= TR2_RES_NEXUS;
2816 (*f2) |= TR2_RES_CHAOS;
2817 (*f2) |= TR2_RES_DISEN;
2818 (*f2) |= TR2_REFLECT;
2819 (*f2) |= TR2_HOLD_LIFE;
2820 (*f2) |= TR2_FREE_ACT;
2821 (*f3) |= TR3_SH_FIRE;
2822 (*f3) |= TR3_SH_ELEC;
2823 (*f3) |= TR3_SH_COLD;
2824 (*f3) |= TR3_FEATHER;
2826 (*f3) |= TR3_SEE_INVIS;
2827 (*f3) |= TR3_TELEPATHY;
2828 (*f3) |= TR3_SLOW_DIGEST;
2830 (*f2) |= (TR2_SUST_STR);
2831 (*f2) |= (TR2_SUST_INT);
2832 (*f2) |= (TR2_SUST_WIS);
2833 (*f2) |= (TR2_SUST_DEX);
2834 (*f2) |= (TR2_SUST_CON);
2835 (*f2) |= (TR2_SUST_CHR);
2843 static void display_player_equippy(int y, int x)
2853 /* Dump equippy chars */
2854 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2857 o_ptr = &inventory[i];
2859 a = object_attr(o_ptr);
2860 c = object_char(o_ptr);
2862 /* Clear the part of the screen */
2863 if (!equippy_chars || !o_ptr->k_idx)
2870 Term_putch(x + i - INVEN_RARM, y, a, c);
2875 void print_equippy(void)
2877 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2884 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2889 (*f1) = (*f2) = (*f3) = 0L;
2891 /* Check equipment */
2892 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2894 u32b o_f1, o_f2, o_f3;
2899 o_ptr = &inventory[i];
2901 if (!o_ptr->k_idx) continue;
2904 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2906 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2907 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2908 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2909 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2913 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2916 (*f1) = (*f2) = (*f3) = 0L;
2918 if (prace_is_(RACE_SPECTRE))
2919 (*f2) |= TR2_RES_NETHER;
2920 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2921 (*f2) |= TR2_RES_DARK;
2922 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2923 (*f2) |= TR2_RES_FIRE;
2924 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2925 (*f2) |= TR2_RES_ACID;
2928 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2931 (*f1) = (*f2) = (*f3) = 0L;
2933 if (p_ptr->special_defense & DEFENSE_ACID)
2934 (*f2) |= TR2_RES_ACID;
2935 if (p_ptr->special_defense & DEFENSE_ELEC)
2936 (*f2) |= TR2_RES_ELEC;
2937 if (p_ptr->special_defense & DEFENSE_FIRE)
2938 (*f2) |= TR2_RES_FIRE;
2939 if (p_ptr->special_defense & DEFENSE_COLD)
2940 (*f2) |= TR2_RES_COLD;
2941 if (p_ptr->wraith_form)
2942 (*f2) |= TR2_RES_DARK;
2945 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2948 (*f1) = (*f2) = (*f3) = 0L;
2950 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2952 (*f2) |= TR2_RES_ACID;
2953 (*f2) |= TR2_RES_ELEC;
2954 (*f2) |= TR2_RES_FIRE;
2955 (*f2) |= TR2_RES_COLD;
2957 if (prace_is_(RACE_ANDROID))
2958 (*f2) |= TR2_RES_ELEC;
2959 if (prace_is_(RACE_ENT))
2960 (*f2) |= TR2_RES_FIRE;
2961 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2962 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2963 (*f2) |= TR2_RES_LITE;
2967 * Helper function, see below
2969 static void display_player_flag_aux(int row, int col, char *header,
2970 int n, u32b flag1, u32b flag2,
2971 u32b im_f[], u32b vul_f)
2977 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2981 c_put_str(TERM_WHITE, header, row, col);
2984 col += strlen(header) + 1;
2986 /* Check equipment */
2987 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2990 f[0] = f[1] = f[2] = 0L;
2993 o_ptr = &inventory[i];
2996 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2999 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3002 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3003 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
3010 player_flags(&f[0], &f[1], &f[2]);
3013 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3016 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3018 /* Timed player flags */
3019 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
3022 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3025 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
3026 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
3029 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3034 * Special display, part 1
3036 static void display_player_flag_info(void)
3041 u32b im_f[3][3], vul_f[3];
3043 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
3044 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
3045 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
3047 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3054 display_player_equippy(row-2, col+8);
3055 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3058 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3059 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3060 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3061 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3062 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3063 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3064 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3065 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3066 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3067 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3069 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3070 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3071 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3072 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3073 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3074 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3075 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3076 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3077 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3078 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3087 display_player_equippy(row-2, col+8);
3089 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3092 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3093 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3094 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3095 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3096 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3097 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3098 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3099 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3100 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3101 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3103 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3104 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3105 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3106 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3107 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3108 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3109 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3110 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3111 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3112 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3121 display_player_equippy(row-2, col+12);
3123 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3126 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3127 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3128 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3129 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3130 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3131 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3132 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3133 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3134 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3135 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3137 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3138 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3139 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3140 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3141 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3142 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3143 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3144 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3145 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3146 display_player_flag_aux(row+9, col, "Cursed :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3153 * Special display, part 2a
3155 static void display_player_misc_info(void)
3160 /* Display basics */
3162 put_str("̾Á° :", 1, 26);
3163 put_str("ÀÊÌ :", 3, 1);
3164 put_str("¼ï² :", 4, 1);
3165 put_str("¿¦¶È :", 5, 1);
3167 put_str("Name :", 1, 26);
3168 put_str("Sex :", 3, 1);
3169 put_str("Race :", 4, 1);
3170 put_str("Class :", 5, 1);
3173 strcpy(tmp,ap_ptr->title);
3180 strcat(tmp,player_name);
3182 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3183 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3184 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3185 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3187 /* Display extras */
3189 put_str("¥ì¥Ù¥ë:", 6, 1);
3190 put_str("£È£Ð :", 7, 1);
3191 put_str("£Í£Ð :", 8, 1);
3193 put_str("Level :", 6, 1);
3194 put_str("Hits :", 7, 1);
3195 put_str("Mana :", 8, 1);
3199 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3200 c_put_str(TERM_L_BLUE, buf, 6, 9);
3201 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3202 c_put_str(TERM_L_BLUE, buf, 7, 9);
3203 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3204 c_put_str(TERM_L_BLUE, buf, 8, 9);
3209 * Special display, part 2b
3211 * How to print out the modifications and sustains.
3212 * Positive mods with no sustain will be light green.
3213 * Positive mods with a sustain will be dark green.
3214 * Sustains (with no modification) will be a dark green 's'.
3215 * Negative mods (from a curse) will be red.
3216 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3217 * No mod, no sustain, will be a slate '.'
3219 static void display_player_stat_info(void)
3241 /* Print out the labels for the columns */
3243 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3244 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3245 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3246 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3247 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3249 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3250 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3251 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3252 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3253 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3257 /* Display the stats */
3258 for (i = 0; i < 6; i++)
3262 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3263 else r_adj = rp_ptr->r_adj[i];
3265 /* Calculate equipment adjustment */
3268 /* Icky formula to deal with the 18 barrier */
3269 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3270 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3271 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3272 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3273 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3274 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3276 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3277 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3279 if (prace_is_(RACE_ENT))
3285 if (p_ptr->lev > 25) r_adj++;
3286 if (p_ptr->lev > 40) r_adj++;
3287 if (p_ptr->lev > 45) r_adj++;
3290 if (p_ptr->lev > 25) r_adj--;
3291 if (p_ptr->lev > 40) r_adj--;
3292 if (p_ptr->lev > 45) r_adj--;
3298 e_adj -= cp_ptr->c_adj[i];
3299 e_adj -= ap_ptr->a_adj[i];
3301 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3302 /* Reduced name of stat */
3303 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3305 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3308 /* Internal "natural" max value. Maxes at 18/100 */
3309 /* This is useful to see if you are maxed out */
3310 cnv_stat(p_ptr->stat_max[i], buf);
3311 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3314 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3316 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3319 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3321 /* Race, class, and equipment modifiers */
3322 (void)sprintf(buf, "%3d", r_adj);
3323 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3324 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3325 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3326 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3327 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3328 (void)sprintf(buf, "%3d", (int)e_adj);
3329 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3331 /* Actual maximal modified value */
3332 cnv_stat(p_ptr->stat_top[i], buf);
3333 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3335 /* Only display stat_use if not maximal */
3336 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3338 cnv_stat(p_ptr->stat_use[i], buf);
3339 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3344 col = stat_col + 41;
3346 /* Header and Footer */
3347 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3349 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3351 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3355 /* Process equipment */
3356 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3359 o_ptr = &inventory[i];
3362 k_idx = o_ptr->k_idx;
3364 /* Acquire "known" flags */
3365 object_flags_known(o_ptr, &f1, &f2, &f3);
3367 /* Initialize color based of sign of pval. */
3368 for (stat = 0; stat < 6; stat++)
3381 if (o_ptr->pval > 0)
3387 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3392 /* Dark green for sustained stats */
3397 if (o_ptr->pval < 0)
3403 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3408 else if (f2 & 1 << stat)
3410 /* Dark green "s" */
3415 /* Dump proper character */
3416 Term_putch(col, row + stat+1, a, c);
3424 player_flags(&f1, &f2, &f3);
3427 for (stat = 0; stat < 6; stat++)
3434 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3440 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3441 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3442 if (p_ptr->tsuyoshi) dummy += 4;
3444 else if (stat == A_WIS || stat == A_INT)
3446 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3447 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3449 else if (stat == A_DEX)
3451 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3452 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3453 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3455 else if (stat == A_CON)
3457 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3458 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3459 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3460 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3461 if (p_ptr->tsuyoshi) dummy += 4;
3463 else if (stat == A_CHR)
3465 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3466 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3467 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3468 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3469 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3470 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3486 if (dummy < 10) c = '0' + dummy;
3496 if (dummy > -10) c = '0' - dummy;
3505 /* Dark green "s" */
3512 Term_putch(col, row + stat+1, a, c);
3520 static cptr object_flag_names[96] =
3761 * Summarize resistances
3763 static void display_player_ben(void)
3776 for (i = 0; i < 6; i++) b[i] = 0;
3779 /* Scan equipment */
3780 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3783 o_ptr = &inventory[i];
3785 /* Known object flags */
3786 object_flags_known(o_ptr, &f1, &f2, &f3);
3789 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3791 f3 &= ~(TR3_AGGRAVATE);
3796 b[0] |= (f1 & 0xFFFF);
3798 b[2] |= (f2 & 0xFFFF);
3800 b[4] |= (f3 & 0xFFFF);
3806 player_flags(&f1, &f2, &f3);
3809 b[0] |= (f1 & 0xFFFF);
3811 b[2] |= (f2 & 0xFFFF);
3813 b[4] |= (f3 & 0xFFFF);
3817 tim_player_flags(&f1, &f2, &f3, FALSE);
3820 b[0] |= (f1 & 0xFFFF);
3822 b[2] |= (f2 & 0xFFFF);
3824 b[4] |= (f3 & 0xFFFF);
3826 color[0] = (u16b)(f1 & 0xFFFF);
3827 color[1] = (u16b)(f1 >> 16);
3828 color[2] = (u16b)(f2 & 0xFFFF);
3829 color[3] = (u16b)(f2 >> 16);
3830 color[4] = (u16b)(f3 & 0xFFFF);
3831 color[5] = (u16b)(f3 >> 16);
3834 for (x = 0; x < 6; x++)
3837 for (y = 0; y < 16; y++)
3839 byte a = TERM_SLATE;
3842 cptr name = object_flag_names[16*x+y];
3845 if (!name) continue;
3848 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3851 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3856 if (color[x] & (1<<y))
3869 Term_putch(x * 13 + 11, y + 4, a, c);
3876 * Summarize resistances
3878 static void display_player_ben_one(int mode)
3890 /* Scan equipment */
3891 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3894 n = (i - INVEN_RARM);
3897 o_ptr = &inventory[i];
3899 object_flags_known(o_ptr, &f1, &f2, &f3);
3901 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3903 f3 &= ~(TR3_AGGRAVATE);
3908 b[n][0] = (u16b)(f1 & 0xFFFF);
3909 b[n][1] = (u16b)(f1 >> 16);
3910 b[n][2] = (u16b)(f2 & 0xFFFF);
3911 b[n][3] = (u16b)(f2 >> 16);
3912 b[n][4] = (u16b)(f3 & 0xFFFF);
3913 b[n][5] = (u16b)(f3 >> 16);
3921 player_flags(&f1, &f2, &f3);
3924 b[n][0] = (u16b)(f1 & 0xFFFF);
3925 b[n][1] = (u16b)(f1 >> 16);
3926 b[n][2] = (u16b)(f2 & 0xFFFF);
3927 b[n][3] = (u16b)(f2 >> 16);
3928 b[n][4] = (u16b)(f3 & 0xFFFF);
3929 b[n][5] = (u16b)(f3 >> 16);
3932 tim_player_flags(&f1, &f2, &f3, FALSE);
3935 b[n][0] |= (f1 & 0xFFFF);
3936 b[n][1] |= (f1 >> 16);
3937 b[n][2] |= (f2 & 0xFFFF);
3938 b[n][3] |= (f2 >> 16);
3939 b[n][4] |= (f3 & 0xFFFF);
3940 b[n][5] |= (f3 >> 16);
3941 color[0] = (u16b)(f1 & 0xFFFF);
3942 color[1] = (u16b)(f1 >> 16);
3943 color[2] = (u16b)(f2 & 0xFFFF);
3944 color[3] = (u16b)(f2 >> 16);
3945 color[4] = (u16b)(f3 & 0xFFFF);
3946 color[5] = (u16b)(f3 >> 16);
3950 for (x = 0; x < 3; x++)
3953 display_player_equippy(2, x * 26 + 11);
3956 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3959 for (y = 0; y < 16; y++)
3961 cptr name = object_flag_names[48*mode+16*x+y];
3964 if (!name) continue;
3967 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3970 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3973 for (n = 0; n < 13; n++)
3975 byte a = TERM_SLATE;
3979 if (b[n][3*mode+x] & (1<<y))
3981 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3994 Term_putch(x * 26 + 11 + n, y + 4, a, c);
4002 * Display the character on the screen (various modes)
4004 * The top two and bottom two lines are left blank.
4006 * Mode 0 = standard display with skills
4007 * Mode 1 = standard display with history
4008 * Mode 2 = summary of various things
4009 * Mode 3 = current flags (combined)
4010 * Mode 4 = current flags (part 1)
4011 * Mode 5 = current flags (part 2)
4012 * Mode 6 = mutations
4014 void display_player(int mode)
4023 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
4032 if ((mode == 0) || (mode == 1))
4034 /* Name, Sex, Race, Class */
4036 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
4038 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
4041 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
4042 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
4043 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
4044 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
4049 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
4051 strcpy(tmp, realm_names[p_ptr->realm1]);
4052 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
4055 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4056 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
4058 /* Age, Height, Weight, Social */
4059 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4061 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
4062 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
4063 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
4064 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
4066 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
4067 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
4068 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
4069 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
4071 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
4074 /* Display the stats */
4075 for (i = 0; i < 6; i++)
4077 /* Special treatment of "injured" stats */
4078 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4082 /* Use lowercase stat name */
4083 put_str(stat_names_reduced[i], 3 + i, 54);
4085 /* Get the current stat */
4086 value = p_ptr->stat_use[i];
4088 /* Obtain the current stat (modified) */
4089 cnv_stat(value, buf);
4091 /* Display the current stat (modified) */
4092 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
4094 /* Acquire the max stat */
4095 value = p_ptr->stat_top[i];
4097 /* Obtain the maximum stat (modified) */
4098 cnv_stat(value, buf);
4100 /* Display the maximum stat (modified) */
4101 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
4104 /* Normal treatment of "normal" stats */
4107 /* Assume uppercase stat name */
4108 put_str(stat_names[i], 3 + i, 54);
4110 /* Obtain the current stat (modified) */
4111 cnv_stat(p_ptr->stat_use[i], buf);
4113 /* Display the current stat (modified) */
4114 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
4117 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4120 c_put_str(TERM_WHITE, "!", 3+i, 59);
4122 c_put_str(TERM_WHITE, "!", 3+i, 59-2);
4127 /* Display "history" info */
4131 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
4133 put_str("(Character Background)", 11, 25);
4136 for (i = 0; i < 4; i++)
4138 put_str(history[i], i + 12, 10);
4142 if (death && total_winner)
4145 put_str("¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£", 5 + 12, 10);
4147 put_str("...You retired from the adventure after the winning.", 5 + 12, 10);
4154 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
4157 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï ¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç»à¤ó¤À¡£", quest[p_ptr->inside_quest].name), 5 + 12, 10);
4159 put_str(format("...You died in the quest '%s'.", quest[p_ptr->inside_quest].name), 5 + 12, 10);
4165 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Î %d ³¬¤Ç»à¤ó¤À¡£", map_name(), dun_level), 5 + 12, 10);
4167 put_str(format("...You died on level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4173 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Ç»à¤ó¤À¡£", map_name()), 5 + 12, 10);
4175 put_str(format("...You died in %s.", map_name()), 5 + 12, 10);
4178 else if (character_dungeon)
4182 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
4185 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name), 5 + 12, 10);
4187 put_str(format("...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name), 5 + 12, 10);
4193 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level), 5 + 12, 10);
4195 put_str(format("...Now, you are exploring level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4201 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name()), 5 + 12, 10);
4203 put_str(format("...Now, you are in %s.", map_name()), 5 + 12, 10);
4208 /* Display "various" info */
4211 display_player_middle();
4212 display_player_various();
4219 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4222 display_player_misc_info();
4223 display_player_stat_info();
4224 display_player_flag_info();
4230 display_player_ben();
4235 do_cmd_knowledge_mutations();
4241 display_player_ben_one(mode % 2);
4245 errr make_character_dump(FILE *fff)
4252 char o_name[MAX_NLEN];
4256 #ifndef FAKE_VERSION
4258 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4259 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4262 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4263 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4265 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4266 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4273 /* Display player */
4276 /* Dump part of the screen */
4277 for (y = 1; y < 22; y++)
4280 for (x = 0; x < 79; x++)
4282 /* Get the attr/char */
4283 (void)(Term_what(x, y, &a, &c));
4289 /* End the string */
4292 /* Kill trailing spaces */
4293 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4297 fprintf(fff, "%s\n", buf);
4299 fprintf(fff, "%s\n", buf);
4304 /* Display history */
4307 /* Dump part of the screen */
4308 for (y = 10; y < 18; y++)
4311 for (x = 0; x < 79; x++)
4313 /* Get the attr/char */
4314 (void)(Term_what(x, y, &a, &c));
4320 /* End the string */
4323 /* Kill trailing spaces */
4324 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4327 fprintf(fff, "%s\n", buf);
4331 /* Display history */
4334 /* Dump part of the screen */
4335 for (y = 2; y < 22; y++)
4338 for (x = 0; x < 79; x++)
4340 /* Get the attr/char */
4341 (void)(Term_what(x, y, &a, &c));
4343 /* Dump it (Ignore equippy tile graphic) */
4350 /* End the string */
4353 /* Kill trailing spaces */
4354 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4357 fprintf(fff, "%s\n", buf);
4360 for (i = 0; i < p_ptr->count / 80; i++)
4363 for (i = 0; i < p_ptr->count % 80; i++)
4369 for (i = m_max - 1; i >= 1; i--)
4371 monster_type *m_ptr = &m_list[i];
4374 if (!m_ptr->r_idx) continue;
4375 if (!is_pet(m_ptr)) continue;
4376 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4380 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4382 fprintf(fff, "\n [leading pets]\n\n");
4386 monster_desc(pet_name, m_ptr, 0x88);
4387 fprintf(fff, "%s", pet_name);
4388 if (p_ptr->riding == i)
4390 fprintf(fff, " ¾èÇÏÃæ");
4392 fprintf(fff, " (riding)");
4396 if (pet) fprintf(fff, "\n");
4399 if (death && !total_winner)
4402 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4404 fprintf(fff, "\n [Last messages]\n\n");
4406 for (i = MIN(message_num(), 30); i >= 0; i--)
4408 fprintf(fff,"> %s\n",message_str((s16b)i));
4414 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4416 fprintf(fff, "\n [Miscellaneous information]\n");
4420 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4422 fprintf(fff, "\n Recall Depth:\n");
4424 for (y = 1; y < max_d_idx; y++)
4428 if (!d_info[y].maxdepth) continue;
4429 if (!max_dlv[y]) continue;
4430 if (d_info[y].final_guardian)
4432 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4434 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4437 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4439 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4445 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4447 fprintf(fff, "\n Preserve Mode: ON");
4452 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4454 fprintf(fff, "\n Preserve Mode: OFF");
4458 if (ironman_autoscum)
4460 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4462 fprintf(fff, "\n Autoscum: ALWAYS");
4467 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4469 fprintf(fff, "\n Autoscum: ON");
4474 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4476 fprintf(fff, "\n Autoscum: OFF");
4480 if (ironman_small_levels)
4482 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4484 fprintf(fff, "\n Small Levels: ALWAYS");
4487 else if (always_small_levels)
4489 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4491 fprintf(fff, "\n Small Levels: ON");
4494 else if (small_levels)
4496 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4498 fprintf(fff, "\n Small Levels: ENABLED");
4503 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4505 fprintf(fff, "\n Small Levels: OFF");
4511 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4513 fprintf(fff, "\n Vanilla Town: ON");
4518 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4520 fprintf(fff, "\n Lite Town: ON");
4526 fprintf(fff, "\n Ź¤Ê¤·: ON");
4528 fprintf(fff, "\n No Shops: ON");
4532 if (ironman_downward)
4534 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4536 fprintf(fff, "\n Diving only: ON");
4542 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4544 fprintf(fff, "\n Unusual rooms: ON");
4548 if (ironman_nightmare)
4550 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4552 fprintf(fff, "\n Nightmare Mode: ON");
4556 if (ironman_empty_levels)
4558 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4560 fprintf(fff, "\n Arena Levels: ALWAYS");
4563 else if (empty_levels)
4565 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4567 fprintf(fff, "\n Arena Levels: ENABLED");
4572 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4574 fprintf(fff, "\n Arena Levels: OFF");
4579 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4581 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4584 if (p_ptr->arena_number == 99)
4587 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4589 fprintf(fff, "\n Arena: defeated\n");
4592 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4595 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4597 fprintf(fff, "\n Arena: True Champion\n");
4600 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4603 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4605 fprintf(fff, "\n Arena: Champion\n");
4611 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4613 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");
4619 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4621 fprintf(fff, "\n You have done something illegal.");
4625 if (stupid_monsters)
4627 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4629 fprintf(fff, "\n Your opponents are behaving stupidly.");
4635 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4637 fprintf(fff, "\n You possess munchkinish power over death.");
4642 /* Monsters slain */
4647 for (k = 1; k < max_r_idx; k++)
4649 monster_race *r_ptr = &r_info[k];
4651 if (r_ptr->flags1 & RF1_UNIQUE)
4653 bool dead = (r_ptr->max_num == 0);
4661 s16b This = r_ptr->r_pkills;
4671 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4673 fprintf(fff,"\n You have defeated no enemies yet.\n");
4676 else if (Total == 1)
4678 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4680 fprintf(fff,"\n You have defeated one enemy.\n");
4685 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4687 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4693 if (p_ptr->old_race1 || p_ptr->old_race2)
4696 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4698 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4700 for (i = 0; i < MAX_RACES; i++)
4702 if (p_ptr->start_race == i) continue;
4705 if (!(p_ptr->old_race1 & 1L << i)) continue;
4709 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4712 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4714 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4719 if (p_ptr->old_realm)
4721 for (i = 0; i < MAX_MAGIC; i++)
4723 if (!(p_ptr->old_realm & 1L << i)) continue;
4725 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4727 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4733 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4735 fprintf(fff, "\n\n [Virtues]\n\n");
4739 fprintf(fff, "°À : %s\n", your_alignment());
4741 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4746 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4749 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4751 fprintf(fff, "\n\n [Mutations]\n\n");
4754 dump_mutations(fff);
4758 /* Skip some lines */
4759 fprintf(fff, "\n\n");
4762 /* Dump the equipment */
4766 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4768 fprintf(fff, " [Character Equipment]\n\n");
4771 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4773 object_desc(o_name, &inventory[i], TRUE, 3);
4774 if ((i == INVEN_LARM) && p_ptr->ryoute)
4776 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4778 strcpy(o_name, "(wielding with two-hands)");
4780 fprintf(fff, "%c%s %s\n",
4781 index_to_label(i), paren, o_name);
4783 fprintf(fff, "\n\n");
4786 /* Dump the inventory */
4788 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4790 fprintf(fff, " [Character Inventory]\n\n");
4793 for (i = 0; i < INVEN_PACK; i++)
4795 /* Don't dump the empty slots */
4796 if (!inventory[i].k_idx) break;
4798 /* Dump the inventory slots */
4799 object_desc(o_name, &inventory[i], TRUE, 3);
4800 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4803 /* Add an empty line */
4804 fprintf(fff, "\n\n");
4806 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4808 /* Print all homes in the different towns */
4809 st_ptr = &town[1].store[STORE_HOME];
4811 /* Home -- if anything there */
4812 if (st_ptr->stock_num)
4814 /* Header with name of the town */
4816 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4818 fprintf(fff, " [Home Inventory]\n");
4822 /* Dump all available items */
4823 for (i = 0; i < st_ptr->stock_num; i++)
4827 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4829 fprintf(fff, "\n ( page %d )\n", x++);
4831 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4832 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4835 /* Add an empty line */
4836 fprintf(fff, "\n\n");
4840 /* Print all homes in the different towns */
4841 st_ptr = &town[1].store[STORE_MUSEUM];
4843 /* Home -- if anything there */
4844 if (st_ptr->stock_num)
4846 /* Header with name of the town */
4848 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4850 fprintf(fff, " [Museum]\n");
4854 /* Dump all available items */
4855 for (i = 0; i < st_ptr->stock_num; i++)
4858 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4859 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4860 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4862 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4863 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4864 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4869 /* Add an empty line */
4870 fprintf(fff, "\n\n");
4877 * Hack -- Dump a character description file
4879 * XXX XXX XXX Allow the "full" flag to dump additional info,
4880 * and trigger its usage from various places in the code.
4882 errr file_character(cptr name, bool full)
4891 /* Build the filename */
4892 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4894 /* File type is "TEXT" */
4895 FILE_TYPE(FILE_TYPE_TEXT);
4897 /* Check for existing file */
4898 fd = fd_open(buf, O_RDONLY);
4905 /* Close the file */
4910 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4912 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4917 if (get_check(out_val)) fd = -1;
4920 /* Open the non-existing file */
4921 if (fd < 0) fff = my_fopen(buf, "w");
4928 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4930 msg_format("Character dump failed!");
4939 (void)make_character_dump(fff);
4949 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4951 msg_print("Character dump successful.");
4961 typedef struct file_tag
4968 typedef struct file_tags
4975 static void add_tag(file_tags *the_tags, cptr name, int line)
4977 if (the_tags->index < 64)
4979 file_tag *tag = &(the_tags->tags[the_tags->index]);
4981 /* Set the name and end it with '\0' */
4982 strncpy(tag->name, name, 31);
4983 tag->name[31] = '\0';
4985 /* Set the line-number */
4986 tag->line_number = line;
4988 /* Increase the number of tags */
4994 static int get_line(file_tags *the_tags, cptr name)
4998 /* Search for the tag */
4999 for (i = 0; i < the_tags->index; i++)
5001 if (streq(the_tags->tags[i].name, name))
5003 return the_tags->tags[i].line_number;
5013 * Recursive file perusal.
5015 * Return FALSE on 'Q', otherwise TRUE.
5017 * Process various special text in the input file, including
5018 * the "menu" structures used by the "help file" system.
5020 * XXX XXX XXX Consider using a temporary file.
5022 * XXX XXX XXX Allow the user to "save" the current file.
5024 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
5028 /* Number of "real" lines passed by */
5031 /* Number of "real" lines in the file */
5034 /* Backup value for "line" */
5040 /* This screen has sub-screens */
5043 /* Current help file */
5046 /* Find this string (if any) */
5049 /* Jump to this tag */
5052 /* Hold a string to find */
5055 /* Hold a string to show */
5059 char filename[1024];
5061 /* Describe this thing */
5067 /* General buffer */
5070 /* Lower case version of the buffer, for searching */
5073 /* Aux pointer for making lc_buf (and find!) lowercase */
5076 /* Sub-menu information */
5079 /* Tags for in-file references */
5082 bool reverse = (line < 0);
5086 Term_get_size(&wid, &hgt);
5096 strcpy(caption, "");
5098 /* Wipe the hooks */
5099 for (i = 0; i < 68; i++)
5107 /* Copy the filename */
5108 strcpy(filename, name);
5110 n = strlen(filename);
5112 /* Extract the tag from the filename */
5113 for (i = 0; i < n; i++)
5115 if (filename[i] == '#')
5118 tag = filename + i + 1;
5123 /* Redirect the name */
5126 /* Hack XXX XXX XXX */
5130 strcpy(caption, what);
5132 /* Access the "file" */
5136 fff = my_fopen(path, "r");
5139 /* Look in "help" */
5144 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5146 sprintf(caption, "Help file '%s'", name);
5150 /* Build the filename */
5151 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5154 fff = my_fopen(path, "r");
5157 /* Look in "info" */
5162 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5164 sprintf(caption, "Info file '%s'", name);
5168 /* Build the filename */
5169 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5172 fff = my_fopen(path, "r");
5175 /* Look in "info" */
5178 /* Build the filename */
5179 path_build(path, 1024, ANGBAND_DIR, name);
5181 for (i = 0; path[i]; i++)
5182 if ('\\' == path[i])
5183 path[i] = PATH_SEP[0];
5187 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5189 sprintf(caption, "Info file '%s'", name);
5193 fff = my_fopen(path, "r");
5201 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5203 msg_format("Cannot open '%s'.", name);
5213 /* Pre-Parse the file */
5216 /* Read a line or stop */
5217 if (my_fgets(fff, buf, 1024)) break;
5219 /* XXX Parse "menu" items */
5220 if (prefix(buf, "***** "))
5222 /* Notice "menu" requests */
5223 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5225 /* This is a menu file */
5228 /* Extract the menu item */
5229 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5231 if ((buf[8] == ']') && (buf[9] == ' '))
5233 /* Extract the menu item */
5234 strncpy(hook[k], buf + 10, 31);
5236 /* Make sure it's null-terminated */
5240 /* Notice "tag" requests */
5241 else if (buf[6] == '<')
5243 buf[strlen(buf) - 1] = '\0';
5244 add_tag(&tags, buf + 7, next);
5251 /* Count the "real" lines */
5255 /* Save the number of "real" lines */
5258 /* start from bottom when reverse mode */
5259 if (line == -1) line = ((size-1)/rows)*rows;
5261 /* Go to the tagged line */
5262 if (tag) line = get_line(&tags, tag);
5264 /* Display the file */
5270 /* Restart when necessary */
5271 if (line >= size) line = 0;
5274 /* Re-open the file if needed */
5280 /* Hack -- Re-Open the file */
5281 fff = my_fopen(path, "r");
5284 if (!fff) return (FALSE);
5286 /* File has been restarted */
5290 /* Goto the selected line */
5294 if (my_fgets(fff, buf, 1024)) break;
5296 /* Skip tags/links */
5297 if (prefix(buf, "***** ")) continue;
5299 /* Count the lines */
5303 /* Dump the next rows lines of the file */
5304 for (i = 0; i < rows; )
5306 /* Hack -- track the "first" line */
5307 if (!i) line = next;
5309 /* Get a line of the file or stop */
5310 if (my_fgets(fff, buf, 1024)) break;
5312 /* Hack -- skip "special" lines */
5313 if (prefix(buf, "***** ")) continue;
5315 /* Count the "real" lines */
5318 /* Make a lower case version of buf for searching */
5319 strcpy(lc_buf, buf);
5321 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5324 if (iskanji(*lc_buf_ptr))
5328 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5331 /* Hack -- keep searching */
5332 if (find && !i && !strstr(lc_buf, find)) continue;
5334 /* Hack -- stop searching */
5338 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5340 /* Hilite "shower" */
5345 /* Display matches */
5346 while ((str = strstr(str, shower)) != NULL)
5348 int len = strlen(shower);
5350 /* Display the match */
5351 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5358 /* Count the printed lines */
5362 /* Hack -- failed search */
5372 /* Show a general "title" */
5377 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5379 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5382 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5383 caption, line, size), 0, 0);
5393 caption, line, size), 0, 0);
5396 /* Prompt -- menu screen */
5401 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", hgt - 1, 0);
5403 prt("[Press a Number, or ESC to exit.]", hgt - 1, 0);
5408 /* Prompt -- small files */
5409 else if (size <= rows)
5413 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5415 prt("[Press ESC to exit.]", hgt - 1, 0);
5420 /* Prompt -- large files */
5425 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5427 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5429 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5433 /* Get a keypress */
5436 /* Hack -- return to last screen */
5437 if (k == '<') break;
5439 /* Show the help for the help */
5442 /* Hack - prevent silly recursion */
5444 if (strcmp(name, "jhelpinfo.txt") != 0)
5445 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5447 if (strcmp(name, "helpinfo.txt") != 0)
5448 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5452 /* Hack -- try showing */
5457 prt("¶¯Ä´: ", hgt - 1, 0);
5459 prt("Show: ", hgt - 1, 0);
5462 (void)askfor_aux(shower, 80);
5465 /* Hack -- try finding */
5470 prt("¸¡º÷: ", hgt - 1, 0);
5472 prt("Find: ", hgt - 1, 0);
5476 if (askfor_aux(finder, 80))
5483 /* Make finder lowercase */
5484 for (cnt = 0; finder[cnt] != 0; cnt++)
5487 if (iskanji(finder[cnt]))
5491 finder[cnt] = tolower(finder[cnt]);
5495 strcpy(shower, finder);
5499 /* Hack -- go to a specific line */
5504 prt("¹Ô: ", hgt - 1, 0);
5506 prt("Goto Line: ", hgt - 1, 0);
5511 if (askfor_aux(tmp, 80))
5517 /* Hack -- go to a specific file */
5522 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5523 strcpy(tmp, "jhelp.hlp");
5525 prt("Goto File: ", hgt - 1, 0);
5526 strcpy(tmp, "help.hlp");
5530 if (askfor_aux(tmp, 80))
5532 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5536 /* Hack -- Allow backing up */
5539 line = line + (reverse ? rows : -rows);
5540 if (line < 0) line = ((size-1)/rows)*rows;
5543 /* Hack -- Advance a single line */
5544 if ((k == '\n') || (k == '\r'))
5546 line = line + (reverse ? -1 : 1);
5547 if (line < 0) line = ((size-1)/rows)*rows;
5550 /* Advance one page */
5553 line = line + (reverse ? -rows : rows);
5554 if (line < 0) line = ((size-1)/rows)*rows;
5557 /* Recurse on numbers */
5562 if (isdigit(k)) key = D2I(k);
5563 else if (isalpha(k)) key = k - 'A' + 10;
5565 if ((key > -1) && hook[key][0])
5567 /* Recurse on that file */
5568 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5573 /* Hack, dump to file */
5583 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5585 if (!get_string("File name: ", xtmp, 80))
5597 /* Build the filename */
5598 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5600 /* Hack -- Re-Open the file */
5601 fff = my_fopen(path, "r");
5603 ffp = my_fopen(buff, "w");
5609 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5611 msg_print("Failed to open file.");
5618 sprintf(xtmp, "%s: %s", player_name, what);
5619 my_fputs(ffp, xtmp, 80);
5620 my_fputs(ffp, "\n", 80);
5622 while (!my_fgets(fff, buff, 80))
5623 my_fputs(ffp, buff, 80);
5632 /* Hack -- Re-Open the file */
5633 fff = my_fopen(path, "r");
5636 /* Exit on escape */
5637 if (k == ESCAPE) break;
5638 if (k == 'q') break;
5641 /* Close the file */
5645 if (k == 'q') return (FALSE);
5653 * Peruse the On-Line-Help
5655 void do_cmd_help(void)
5660 /* Peruse the main help file */
5662 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5664 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5674 * Process the player name.
5675 * Extract a clean "base name".
5676 * Build the savefile name if needed.
5678 void process_player_name(bool sf)
5683 /* Cannot be too long */
5684 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5686 if (strlen(player_name) > 8)
5688 if (strlen(player_name) > 15)
5693 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5695 quit_fmt("The name '%s' is too long!", player_name);
5701 /* Cannot contain "icky" characters */
5702 for (i = 0; player_name[i]; i++)
5704 /* No control characters */
5706 if (iskanji(player_name[i])){i++;continue;}
5707 if (iscntrl( (unsigned char)player_name[i]))
5709 if (iscntrl(player_name[i]))
5713 /* Illegal characters */
5715 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5717 quit_fmt("The name '%s' contains control chars!", player_name);
5726 /* Extract "useful" letters */
5727 for (i = 0; player_name[i]; i++)
5730 unsigned char c = player_name[i];
5732 char c = player_name[i];
5736 /* Convert "dot" to "underscore" */
5737 if (c == '.') c = '_';
5739 /* Accept all the letters */
5740 player_base[k++] = c;
5745 /* Extract "useful" letters */
5746 for (i = 0; player_name[i]; i++)
5749 unsigned char c = player_name[i];
5751 char c = player_name[i];
5754 /* Accept some letters */
5757 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5758 player_base[k++] = c;
5760 player_base[k++] = player_name[i];
5763 else if (iskana(c)) player_base[k++] = c;
5767 /* Convert path separator to underscore */
5768 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5769 player_base[k++] = '_';
5770 i += strlen(PATH_SEP);
5773 /* Convert space, dot, and underscore to underscore */
5774 else if (strchr(". _", c)) player_base[k++] = '_';
5776 else if (isprint(c)) player_base[k++] = c;
5784 /* Hack -- max length */
5790 player_base[k] = '\0';
5792 /* Require a "base" name */
5793 if (!player_base[0]) strcpy(player_base, "PLAYER");
5796 #ifdef SAVEFILE_MUTABLE
5802 if (!savefile_base[0] && savefile[0])
5809 t = strstr(s, PATH_SEP);
5814 strcpy(savefile_base, s);
5817 if (!savefile_base[0] || !savefile[0])
5820 /* Change the savefile name */
5825 strcpy(savefile_base, player_base);
5827 #ifdef SAVEFILE_USE_UID
5828 /* Rename the savefile, using the player_uid and player_base */
5829 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5831 /* Rename the savefile, using the player_base */
5832 (void)sprintf(temp, "%s", player_base);
5836 /* Hack -- support "flat directory" usage on VM/ESA */
5837 (void)sprintf(temp, "%s.sv", player_base);
5840 /* Build the filename */
5841 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5847 * Gets a name for the character, reacting to name changes.
5849 * Assumes that "display_player(0)" has just been called
5851 * Perhaps we should NOT ask for a name (at "birth()") on
5852 * Unix machines? XXX XXX
5854 * What a horrible name for a global function. XXX XXX XXX
5860 /* Save the player name */
5861 strcpy(tmp, player_name);
5863 /* Prompt for a new name */
5865 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5867 if (get_string("Enter a name for your character: ", tmp, 15))
5871 strcpy(player_name, tmp);
5873 else if (0 == strlen(player_name))
5875 /* Use default name */
5876 strcpy(player_name, "PLAYER");
5879 /* Process the player name */
5880 process_player_name(FALSE);
5882 strcpy(tmp,ap_ptr->title);
5889 strcat(tmp,player_name);
5891 /* Re-Draw the name (in light blue) */
5892 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5894 /* Erase the prompt, etc */
5901 * Hack -- commit suicide
5903 void do_cmd_suicide(void)
5910 /* Verify Retirement */
5915 if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
5917 if (!get_check("Do you want to retire? ")) return;
5922 /* Verify Suicide */
5927 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5929 if (!get_check("Do you really want to commit suicide? ")) return;
5936 /* Special Verification for suicide */
5938 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5940 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5946 if (i != '@') return;
5952 /* Kill the player */
5956 p_ptr->leaving = TRUE;
5961 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5962 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5964 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5965 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5967 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5970 /* Cause of death */
5972 (void)strcpy(died_from, "ÅÓÃ潪λ");
5974 (void)strcpy(died_from, "Quitting");
5984 void do_cmd_save_game(int is_autosave)
5986 /* Autosaves do not disturb */
5990 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5992 msg_print("Autosaving the game...");
5998 /* Disturb the player */
6002 /* Clear messages */
6010 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6012 prt("Saving game...", 0, 0);
6019 /* The player is not dead */
6021 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
6023 (void)strcpy(died_from, "(saved)");
6027 /* Forbid suspend */
6028 signals_ignore_tstp();
6030 /* Save the player */
6034 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6036 prt("Saving game... done.", 0, 0);
6041 /* Save failed (oops) */
6045 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6047 prt("Saving game... failed!", 0, 0);
6052 /* Allow suspend again */
6053 signals_handle_tstp();
6058 /* Note that the player is not dead */
6060 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6062 (void)strcpy(died_from, "(alive and well)");
6069 * Save the game and exit
6071 void do_cmd_save_and_exit(void)
6076 p_ptr->leaving = TRUE;
6078 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6080 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6086 * Hack -- Calculates the total number of points earned -JWT-
6088 long total_points(void)
6092 u32b point, point_h, point_l;
6093 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6095 if (stupid_monsters) mult -= 70;
6096 if (!preserve_mode) mult += 10;
6097 if (!autoroller) mult += 10;
6098 if (!smart_learn) mult -= 20;
6099 if (!terrain_streams) mult -= 20;
6100 if (smart_cheat) mult += 30;
6101 if (ironman_shops) mult += 50;
6102 if (ironman_small_levels) mult += 10;
6103 if (ironman_empty_levels) mult += 20;
6104 if (!powerup_home) mult += 50;
6105 if (ironman_rooms) mult += 100;
6106 if (ironman_nightmare) mult += 100;
6108 if (mult < 5) mult = 5;
6110 for (i = 0; i < max_d_idx; i++)
6111 if(max_dlv[i] > max_dl)
6112 max_dl = max_dlv[i];
6114 point_l = (p_ptr->max_exp + (100 * max_dl));
6115 point_h = point_l / 0x10000L;
6116 point_l = point_l % 0x10000L;
6119 point_h += point_l / 0x10000L;
6120 point_l %= 0x10000L;
6122 point_l += ((point_h % 100) << 16);
6126 point = (point_h << 16) + (point_l);
6127 if (p_ptr->arena_number < 99)
6128 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6130 if (ironman_downward) point *= 2;
6131 if (p_ptr->pclass == CLASS_BERSERKER)
6133 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6137 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6140 if (total_winner) point = 2;
6142 if (easy_band) point = (0 - point);
6150 * Centers a string within a 31 character string -JWT-
6152 static void center_string(char *buf, cptr str)
6159 /* Necessary border */
6163 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6169 * Save a "bones" file for a dead character
6171 * Note that we will not use these files until Angband 2.8.0, and
6172 * then we will only use the name and level on which death occured.
6174 * Should probably attempt some form of locking...
6176 static void make_bones(void)
6183 /* Ignore wizards and borgs */
6184 if (!(noscore & 0x00FF))
6186 /* Ignore people who die in town */
6191 /* XXX XXX XXX "Bones" name */
6192 sprintf(tmp, "bone.%03d", dun_level);
6194 /* Build the filename */
6195 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6197 /* Attempt to open the bones file */
6198 fp = my_fopen(str, "r");
6200 /* Close it right away */
6201 if (fp) my_fclose(fp);
6203 /* Do not over-write a previous ghost */
6206 /* File type is "TEXT" */
6207 FILE_TYPE(FILE_TYPE_TEXT);
6209 /* Try to write a new "Bones File" */
6210 fp = my_fopen(str, "w");
6212 /* Not allowed to write it? Weird. */
6216 fprintf(fp, "%s\n", player_name);
6217 fprintf(fp, "%d\n", p_ptr->mhp);
6218 fprintf(fp, "%d\n", p_ptr->prace);
6219 fprintf(fp, "%d\n", p_ptr->pclass);
6221 /* Close and save the Bones file */
6230 * Redefinable "print_tombstone" action
6232 bool (*tombstone_aux)(void) = NULL;
6236 * Display a "tomb-stone"
6238 static void print_tomb(void)
6242 /* Do we use a special tombstone ? */
6245 /* Use tombstone hook */
6246 done = (*tombstone_aux)();
6249 /* Print the text-tombstone */
6263 time_t ct = time((time_t)0);
6269 /* Build the filename */
6271 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6273 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6277 /* Open the News file */
6278 fp = my_fopen(buf, "r");
6285 /* Dump the file to the screen */
6286 while (0 == my_fgets(fp, buf, 1024))
6288 /* Display and advance */
6289 put_str(buf, i++, 0);
6298 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6312 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6315 center_string(buf, player_name);
6316 put_str(buf, 6, 11);
6319 center_string(buf, "the");
6320 put_str(buf, 7, 11);
6323 center_string(buf, p);
6324 put_str(buf, 8, 11);
6327 center_string(buf, cp_ptr->title);
6329 put_str(buf, 10, 11);
6332 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6334 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6337 center_string(buf, tmp);
6338 put_str(buf, 11, 11);
6341 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6343 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6346 center_string(buf, tmp);
6347 put_str(buf, 12, 11);
6350 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6352 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6355 center_string(buf, tmp);
6356 put_str(buf, 13, 11);
6359 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6360 if (streq(died_from, "ÅÓÃ潪λ"))
6362 strcpy(tmp, "<¼«»¦>");
6366 if (streq(died_from, "ripe"))
6368 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6370 else if (streq(died_from, "Seppuku"))
6372 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6376 strcpy(tmp, died_from);
6379 center_string(buf, tmp);
6380 put_str(buf, 14, 11);
6382 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6384 if( dun_level == 0 )
6386 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6387 if(streq(died_from, "ÅÓÃ潪λ"))
6389 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6393 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6398 if(streq(died_from, "ÅÓÃ潪λ"))
6400 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6404 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6407 center_string(buf, tmp);
6408 put_str(buf, 15, 11);
6411 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6412 center_string(buf, tmp);
6413 put_str(buf, 14, 11);
6416 if (strlen(died_from) > 24)
6418 strncpy(dummy, died_from, 24);
6420 (void)sprintf(tmp, "by %s.", dummy);
6423 (void)sprintf(tmp, "by %s.", died_from);
6425 center_string(buf, tmp);
6426 put_str(buf, 15, 11);
6431 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6432 center_string(buf, tmp);
6433 put_str(buf, 17, 11);
6436 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6438 msg_format("Goodbye, %s!", player_name);
6446 * Display some character info
6448 static void show_info(void)
6454 /* Hack -- Know everything in the inven/equip */
6455 for (i = 0; i < INVEN_TOTAL; i++)
6457 o_ptr = &inventory[i];
6459 /* Skip non-objects */
6460 if (!o_ptr->k_idx) continue;
6462 /* Aware and Known */
6463 object_aware(o_ptr);
6464 object_known(o_ptr);
6467 for (i = 1; i < max_towns; i++)
6469 st_ptr = &town[i].store[STORE_HOME];
6471 /* Hack -- Know everything in the home */
6472 for (j = 0; j < st_ptr->stock_num; j++)
6474 o_ptr = &st_ptr->stock[j];
6476 /* Skip non-objects */
6477 if (!o_ptr->k_idx) continue;
6479 /* Aware and Known */
6480 object_aware(o_ptr);
6481 object_known(o_ptr);
6485 /* Hack -- Recalculate bonuses */
6486 p_ptr->update |= (PU_BONUS);
6491 /* Flush all input keys */
6494 /* Flush messages */
6498 /* Describe options */
6500 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6501 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6503 prt("You may now dump a character record to one or more files.", 21, 0);
6504 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6508 /* Dump character records as requested */
6515 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6517 put_str("Filename: ", 23, 0);
6522 strcpy(out_val, "");
6524 /* Ask for filename (or abort) */
6525 if (!askfor_aux(out_val, 60)) return;
6527 /* Return means "show on screen" */
6528 if (!out_val[0]) break;
6533 /* Dump a character file */
6534 (void)file_character(out_val, TRUE);
6542 /* Display player */
6545 /* Prompt for inventory */
6547 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6549 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6553 /* Allow abort at this point */
6554 if (inkey() == ESCAPE) return;
6557 /* Show equipment and inventory */
6559 /* Equipment -- if any */
6563 item_tester_full = TRUE;
6564 (void)show_equip(0);
6566 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6568 prt("You are using: -more-", 0, 0);
6571 if (inkey() == ESCAPE) return;
6574 /* Inventory -- if any */
6578 item_tester_full = TRUE;
6579 (void)show_inven(0);
6581 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6583 prt("You are carrying: -more-", 0, 0);
6586 if (inkey() == ESCAPE) return;
6589 /* Homes in the different towns */
6590 for (l = 1; l < max_towns; l++)
6592 st_ptr = &town[l].store[STORE_HOME];
6594 /* Home -- if anything there */
6595 if (st_ptr->stock_num)
6597 /* Display contents of the home */
6598 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6604 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6606 char o_name[MAX_NLEN];
6610 o_ptr = &st_ptr->stock[i];
6612 /* Print header, clear line */
6613 sprintf(tmp_val, "%c) ", I2A(j));
6614 prt(tmp_val, j+2, 4);
6616 /* Display object description */
6617 object_desc(o_name, o_ptr, TRUE, 3);
6618 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6623 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6625 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6630 if (inkey() == ESCAPE) return;
6637 static bool check_score(void)
6643 if (highscore_fd < 0)
6646 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6648 msg_print("Score file unavailable.");
6655 #ifndef SCORE_WIZARDS
6656 /* Wizard-mode pre-empts scoring */
6657 if (noscore & 0x000F)
6660 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6662 msg_print("Score not registered for wizards.");
6671 /* Borg-mode pre-empts scoring */
6672 if (noscore & 0x00F0)
6675 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6677 msg_print("Score not registered for borgs.");
6685 #ifndef SCORE_CHEATERS
6686 /* Cheaters are not scored */
6687 if (noscore & 0xFF00)
6690 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6692 msg_print("Score not registered for cheaters.");
6702 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6704 if (!total_winner && streq(died_from, "Interrupting"))
6709 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6711 msg_print("Score not registered due to interruption.");
6720 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6722 if (!total_winner && streq(died_from, "Quitting"))
6727 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6729 msg_print("Score not registered due to quitting.");
6739 * Close up the current game (player may or may not be dead)
6741 * This function is called only from "main.c" and "signals.c".
6743 void close_game(void)
6746 bool do_send = TRUE;
6748 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6753 /* Flush the messages */
6756 /* Flush the input */
6760 /* No suspending now */
6761 signals_ignore_tstp();
6764 /* Hack -- Character is now "icky" */
6765 character_icky = TRUE;
6768 /* Build the filename */
6769 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6771 /* Open the high score file, for reading/writing */
6772 highscore_fd = fd_open(buf, O_RDWR);
6778 /* Handle retirement */
6779 if (total_winner) kingly();
6783 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6785 if (!munchkin_death || get_check("Save death? "))
6790 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6792 if (!save_player()) msg_print("death save failed!");
6795 else do_send = FALSE;
6802 /* Show more info */
6810 if ((!send_world_score(do_send)))
6813 if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
6815 if (get_check("Stand by for later score registration? "))
6818 wait_report_score = TRUE;
6821 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6823 if (!save_player()) msg_print("death save failed!");
6827 if (!wait_report_score)
6830 else if (highscore_fd >= 0)
6832 display_scores_aux(0, 10, -1, NULL);
6835 /* Dump bones file */
6844 do_cmd_save_game(FALSE);
6846 /* Prompt for scores XXX XXX XXX */
6848 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6850 prt("Press Return (or Escape).", 0, 40);
6854 /* Predict score (or ESCAPE) */
6855 if (inkey() != ESCAPE) predict_score();
6859 /* Shut the high score file */
6860 (void)fd_close(highscore_fd);
6862 /* Forget the high score fd */
6866 /* Allow suspending now */
6867 signals_handle_tstp();
6872 * Handle abrupt death of the visual system
6874 * This routine is called only in very rare situations, and only
6875 * by certain visual systems, when they experience fatal errors.
6877 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6878 * save file so that player can see tombstone when restart.
6880 void exit_game_panic(void)
6882 /* If nothing important has happened, just quit */
6884 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6886 if (!character_generated || character_saved) quit("panic");
6890 /* Mega-Hack -- see "msg_print()" */
6893 /* Clear the top line */
6896 /* Hack -- turn off some things */
6899 /* Mega-Hack -- Delay death */
6900 if (p_ptr->chp < 0) death = FALSE;
6902 /* Hardcode panic save */
6905 /* Forbid suspend */
6906 signals_ignore_tstp();
6908 /* Indicate panic save */
6910 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6912 (void)strcpy(died_from, "(panic save)");
6916 /* Panic save, or get worried */
6918 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6920 if (!save_player()) quit("panic save failed!");
6924 /* Successful panic save */
6926 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6928 quit("panic save succeeded!");
6935 * Get a random line from a file
6936 * Based on the monster speech patch by Matt Graham,
6938 errr get_rnd_line(cptr file_name, int entry, char *output)
6942 int line, counter, test, numentries;
6947 /* Build the filename */
6948 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6951 fp = my_fopen(buf, "r");
6954 if (!fp) return (-1);
6956 /* Find the entry of the monster */
6959 /* Get a line from the file */
6960 if (my_fgets(fp, buf, 1024) == 0)
6962 /* Count the lines */
6965 /* Look for lines starting with 'N:' */
6966 if ((buf[0] == 'N') && (buf[1] == ':'))
6968 /* Allow default lines */
6975 else if (buf[2] == 'M')
6977 if (r_info[entry].flags1 & RF1_MALE)
6983 else if (buf[2] == 'F')
6985 if (r_info[entry].flags1 & RF1_FEMALE)
6991 /* Get the monster number */
6992 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6994 /* Is it the right monster? */
7003 /* Error while converting the monster number */
7004 msg_format("Error in line %d of %s!",
7005 line_num, file_name);
7013 /* Reached end of file */
7020 /* Get the number of entries */
7024 if (my_fgets(fp, buf, 1024) == 0)
7026 /* Count the lines */
7029 /* Look for the number of entries */
7030 if (isdigit(buf[0]))
7032 /* Get the number of entries */
7033 numentries = atoi(buf);
7039 /* Count the lines */
7042 /* Reached end of file without finding the number */
7043 msg_format("Error in line %d of %s!",
7044 line_num, file_name);
7053 /* Grab an appropriate line number */
7054 line = randint0(numentries);
7056 /* Get the random line */
7057 for (counter = 0; counter <= line; counter++)
7059 /* Count the lines */
7064 test = my_fgets(fp, buf, 1024);
7065 if(test || buf[0] != '#')
7071 /* Found the line */
7072 if (counter == line) break;
7076 /* Error - End of file */
7077 msg_format("Error in line %d of %s!",
7078 line_num, file_name);
7086 strcpy(output, buf);
7093 /* Close the file */
7102 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7106 for (i=0;i<count;i++){
7107 result=get_rnd_line(file_name, entry, output);
7110 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7118 * Process file for auto picker/destroyer.
7120 errr process_pickpref_file(cptr name)
7129 /* Build the filename */
7130 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7132 err = process_pref_file_aux(buf, TRUE);
7141 static errr counts_seek(int fd, u32b where, bool flag)
7144 char temp1[128], temp2[128];
7145 u32b zero_header[3] = {0L, 0L, 0L};
7148 #ifdef SAVEFILE_USE_UID
7149 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7151 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7153 for (i = 0; temp1[i]; i++)
7154 temp1[i] ^= (i+1) * 63;
7159 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7161 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7166 fd_seek(fd, seekpoint);
7167 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7168 fd_write(fd, (char*)(temp1), sizeof(temp1));
7172 if (strcmp(temp1, temp2) == 0)
7175 seekpoint += 128 + 3 * sizeof(u32b);
7178 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7181 u32b counts_read(int where)
7188 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7190 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7192 fd = fd_open(buf, O_RDONLY);
7194 if (counts_seek(fd, where, FALSE) ||
7195 fd_read(fd, (char*)(&count), sizeof(u32b)))
7203 errr counts_write(int where, u32b count)
7209 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7211 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7213 fd = fd_open(buf, O_RDWR);
7216 /* File type is "DATA" */
7217 FILE_TYPE(FILE_TYPE_DATA);
7219 /* Create a new high score file */
7220 fd = fd_make(buf, 0644);
7223 if (fd_lock(fd, F_WRLCK)) return 1;
7225 counts_seek(fd, where, TRUE);
7226 fd_write(fd, (char*)(&count), sizeof(u32b));
7228 if (fd_lock(fd, F_UNLCK)) return 1;
7236 #ifdef HANDLE_SIGNALS
7243 * Handle signals -- suspend
7245 * Actually suspend the game, and then resume cleanly
7247 static void handle_signal_suspend(int sig)
7249 /* Disable handler */
7250 (void)signal(sig, SIG_IGN);
7257 /* Suspend the "Term" */
7258 Term_xtra(TERM_XTRA_ALIVE, 0);
7260 /* Suspend ourself */
7261 (void)kill(0, SIGSTOP);
7263 /* Resume the "Term" */
7264 Term_xtra(TERM_XTRA_ALIVE, 1);
7266 /* Redraw the term */
7269 /* Flush the term */
7274 /* Restore handler */
7275 (void)signal(sig, handle_signal_suspend);
7280 * Handle signals -- simple (interrupt and quit)
7282 * This function was causing a *huge* number of problems, so it has
7283 * been simplified greatly. We keep a global variable which counts
7284 * the number of times the user attempts to kill the process, and
7285 * we commit suicide if the user does this a certain number of times.
7287 * We attempt to give "feedback" to the user as he approaches the
7288 * suicide thresh-hold, but without penalizing accidental keypresses.
7290 * To prevent messy accidents, we should reset this global variable
7291 * whenever the user enters a keypress, or something like that.
7293 static void handle_signal_simple(int sig)
7295 /* Disable handler */
7296 (void)signal(sig, SIG_IGN);
7299 /* Nothing to save, just quit */
7300 if (!character_generated || character_saved) quit(NULL);
7303 /* Count the signals */
7307 /* Terminate dead characters */
7310 /* Mark the savefile */
7312 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7314 (void)strcpy(died_from, "Abortion");
7333 /* Allow suicide (after 5) */
7334 else if (signal_count >= 5)
7336 /* Cause of "death" */
7338 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7340 (void)strcpy(died_from, "Interrupting");
7355 p_ptr->leaving = TRUE;
7369 /* Give warning (after 4) */
7370 else if (signal_count >= 4)
7373 Term_xtra(TERM_XTRA_NOISE, 0);
7375 /* Clear the top line */
7376 Term_erase(0, 0, 255);
7378 /* Display the cause */
7380 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7382 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7390 /* Give warning (after 2) */
7391 else if (signal_count >= 2)
7394 Term_xtra(TERM_XTRA_NOISE, 0);
7397 /* Restore handler */
7398 (void)signal(sig, handle_signal_simple);
7403 * Handle signal -- abort, kill, etc
7405 static void handle_signal_abort(int sig)
7409 Term_get_size(&wid, &hgt);
7412 /* Disable handler */
7413 (void)signal(sig, SIG_IGN);
7416 /* Nothing to save, just quit */
7417 if (!character_generated || character_saved) quit(NULL);
7424 /* Clear the bottom line */
7425 Term_erase(0, hgt - 1, 255);
7427 /* Give a warning */
7428 Term_putstr(0, hgt - 1, -1, TERM_RED,
7430 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7432 "A gruesome software bug LEAPS out at you!");
7438 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7440 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7452 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7454 (void)strcpy(died_from, "(panic save)");
7458 /* Forbid suspend */
7459 signals_ignore_tstp();
7461 /* Attempt to save */
7465 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7467 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7476 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7478 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7488 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7490 quit("software bug");
7499 * Ignore SIGTSTP signals (keyboard suspend)
7501 void signals_ignore_tstp(void)
7505 (void)signal(SIGTSTP, SIG_IGN);
7511 * Handle SIGTSTP signals (keyboard suspend)
7513 void signals_handle_tstp(void)
7517 (void)signal(SIGTSTP, handle_signal_suspend);
7524 * Prepare to handle the relevant signals
7526 void signals_init(void)
7530 (void)signal(SIGHUP, SIG_IGN);
7535 (void)signal(SIGTSTP, handle_signal_suspend);
7540 (void)signal(SIGINT, handle_signal_simple);
7544 (void)signal(SIGQUIT, handle_signal_simple);
7549 (void)signal(SIGFPE, handle_signal_abort);
7553 (void)signal(SIGILL, handle_signal_abort);
7557 (void)signal(SIGTRAP, handle_signal_abort);
7561 (void)signal(SIGIOT, handle_signal_abort);
7565 (void)signal(SIGKILL, handle_signal_abort);
7569 (void)signal(SIGBUS, handle_signal_abort);
7573 (void)signal(SIGSEGV, handle_signal_abort);
7577 (void)signal(SIGTERM, handle_signal_abort);
7581 (void)signal(SIGPIPE, handle_signal_abort);
7585 (void)signal(SIGEMT, handle_signal_abort);
7589 (void)signal(SIGDANGER, handle_signal_abort);
7593 (void)signal(SIGSYS, handle_signal_abort);
7597 (void)signal(SIGXCPU, handle_signal_abort);
7601 (void)signal(SIGPWR, handle_signal_abort);
7607 #else /* HANDLE_SIGNALS */
7613 void signals_ignore_tstp(void)
7620 void signals_handle_tstp(void)
7627 void signals_init(void)
7630 #endif /* HANDLE_SIGNALS */