4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: code dealing with files (and death) */
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 },
330 {"GF_WATER_FLOW", GF_WATER_FLOW },
331 {"GF_CRUSADE", GF_CRUSADE },
332 {"GF_STASIS_EVIL", GF_STASIS_EVIL },
333 {"GF_WOUNDS", GF_WOUNDS },
339 * Parse a sub-file of the "extra info" (format shown below)
341 * Each "action" line has an "action symbol" in the first column,
342 * followed by a colon, followed by some command specific info,
343 * usually in the form of "tokens" separated by colons or slashes.
345 * Blank lines, lines starting with white space, and lines starting
346 * with pound signs ("#") are ignored (as comments).
348 * Note the use of "tokenize()" to allow the use of both colons and
349 * slashes as delimeters, while still allowing final tokens which
350 * may contain any characters including "delimiters".
352 * Note the use of "strtol()" to allow all "integers" to be encoded
353 * in decimal, hexidecimal, or octal form.
355 * Note that "monster zero" is used for the "player" attr/char, "object
356 * zero" will be used for the "stack" attr/char, and "feature zero" is
357 * used for the "nothing" attr/char.
359 * Parse another file recursively, see below for details
362 * Specify the attr/char values for "monsters" by race index
365 * Specify the attr/char values for "objects" by kind index
368 * Specify the attr/char values for "features" by feature index
371 * Specify the attr/char values for unaware "objects" by kind tval
374 * Specify the attr/char values for inventory "objects" by kind tval
377 * Define a macro action, given an encoded macro action
380 * Create a normal macro, given an encoded macro trigger
383 * Create a command macro, given an encoded macro trigger
386 * Create a keyset mapping
387 * S:<key>:<key>:<dir>
389 * Turn an option off, given its name
392 * Turn an option on, given its name
395 * Specify visual information, given an index, and some data
396 * V:<num>:<kv>:<rv>:<gv>:<bv>
398 * Specify the set of colors to use when drawing a zapped spell
401 * Specify a macro trigger template and macro trigger names.
402 * T:<template>:<modifier chr>:<modifier name1>:<modifier name2>:...
403 * T:<trigger>:<keycode>:<shift-keycode>
407 errr process_pref_file_command(char *buf)
414 /* Require "?:*" format */
415 if (buf[1] != ':') return 1;
420 /* Mega-Hack -- read external player's history file */
421 /* Process "H:<history>" */
423 add_history_from_pref_line(buf + 2);
426 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
428 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
431 i = (huge)strtol(zz[0], NULL, 0);
432 n1 = strtol(zz[1], NULL, 0);
433 n2 = strtol(zz[2], NULL, 0);
434 if (i >= max_r_idx) return 1;
436 if (n1 || (!(n2 & 0x80) && n2)) r_ptr->x_attr = n1; /* Allow ATTR_DARK text */
437 if (n2) r_ptr->x_char = n2;
442 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
444 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
447 i = (huge)strtol(zz[0], NULL, 0);
448 n1 = strtol(zz[1], NULL, 0);
449 n2 = strtol(zz[2], NULL, 0);
450 if (i >= max_k_idx) return 1;
452 if (n1 || (!(n2 & 0x80) && n2)) k_ptr->x_attr = n1; /* Allow ATTR_DARK text */
453 if (n2) k_ptr->x_char = n2;
458 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
459 /* "F:<num>:<a>/<c>" */
460 /* "F:<num>:<a>/<c>:LIT" */
461 /* "F:<num>:<a>/<c>:<la>/<lc>:<da>/<dc>:<Da>/<Dc>" */
465 int num = tokenize(buf + 2, 9, zz, TOKENIZE_CHECKQUOTE);
467 if ((num != 3) && (num != 4) && (num != 9)) return 1;
468 else if ((num == 4) && !streq(zz[3], "LIT")) return 1;
470 i = (huge)strtol(zz[0], NULL, 0);
471 if (i >= max_f_idx) return 1;
474 n1 = strtol(zz[1], NULL, 0);
475 n2 = strtol(zz[2], NULL, 0);
476 if (n1 || (!(n2 & 0x80) && n2)) /* Allow ATTR_DARK text */
478 for (j = 0; j < F_LIT_MAX; j++) f_ptr->x_attr[j] = n1;
482 for (j = 0; j < F_LIT_MAX; j++) f_ptr->x_char[j] = n2;
485 /* Mega-hack -- feat supports lighting */
488 /* No lighting support */
492 /* Use default lighting */
494 if (is_ascii_graphics(f_ptr->x_attr[F_LIT_STANDARD]))
496 f_ptr->x_attr[F_LIT_LITE] = lighting_colours[f_ptr->x_attr[F_LIT_STANDARD]][0];
497 f_ptr->x_attr[F_LIT_DARK] = lighting_colours[f_ptr->x_attr[F_LIT_STANDARD]][1];
498 f_ptr->x_attr[F_LIT_DARKDARK] = lighting_colours[lighting_colours[f_ptr->x_attr[F_LIT_STANDARD]][1]][1];
502 f_ptr->x_char[F_LIT_LITE] += 2;
503 f_ptr->x_char[F_LIT_DARK]++;
504 f_ptr->x_char[F_LIT_DARKDARK]++;
508 /* Use desired lighting */
510 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
512 n1 = strtol(zz[j * 2 + 1], NULL, 0);
513 n2 = strtol(zz[j * 2 + 2], NULL, 0);
514 if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[j] = n1; /* Allow ATTR_DARK text */
515 if (n2) f_ptr->x_char[j] = n2;
522 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
524 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
526 j = (byte)strtol(zz[0], NULL, 0);
527 n1 = strtol(zz[1], NULL, 0);
528 n2 = strtol(zz[2], NULL, 0);
529 misc_to_attr[j] = n1;
530 misc_to_char[j] = n2;
535 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
537 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
539 j = (huge)strtol(zz[0], NULL, 0);
540 n1 = strtol(zz[1], NULL, 0);
541 n2 = strtol(zz[2], NULL, 0);
542 for (i = 1; i < max_k_idx; i++)
544 object_kind *k_ptr = &k_info[i];
545 if (k_ptr->tval == j)
547 if (n1) k_ptr->d_attr = n1;
548 if (n2) k_ptr->d_char = n2;
555 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
557 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
559 j = (byte)strtol(zz[0], NULL, 0) % 128;
560 n1 = strtol(zz[1], NULL, 0);
561 if (n1) tval_to_attr[j] = n1;
566 /* Process "A:<str>" -- save an "action" for later */
568 text_to_ascii(macro__buf, buf+2);
571 /* Process "P:<str>" -- normal macro */
576 text_to_ascii(tmp, buf+2);
577 macro_add(tmp, macro__buf);
581 /* Process "C:<str>" -- create keymap */
587 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return 1;
589 mode = strtol(zz[0], NULL, 0);
590 if ((mode < 0) || (mode >= KEYMAP_MODES)) return 1;
592 text_to_ascii(tmp, zz[1]);
593 if (!tmp[0] || tmp[1]) return 1;
596 string_free(keymap_act[mode][i]);
598 keymap_act[mode][i] = string_make(macro__buf);
603 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
605 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
607 i = (byte)strtol(zz[0], NULL, 0);
608 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
609 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
610 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
611 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
616 /* Process "X:<str>" -- turn option off */
617 /* Process "Y:<str>" -- turn option on */
620 for (i = 0; option_info[i].o_desc; i++)
622 if (option_info[i].o_var &&
623 option_info[i].o_text &&
624 streq(option_info[i].o_text, buf + 2))
626 int os = option_info[i].o_set;
627 int ob = option_info[i].o_bit;
629 if ((p_ptr->playing || character_xtra) &&
630 (OPT_PAGE_BIRTH == option_info[i].o_page) && !p_ptr->wizard)
633 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
635 msg_format("Birth options can not changed! '%s'", buf);
644 option_flag[os] &= ~(1L << ob);
645 (*option_info[i].o_var) = FALSE;
650 option_flag[os] |= (1L << ob);
651 (*option_info[i].o_var) = TRUE;
657 /* don't know that option. ignore it.*/
659 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
661 msg_format("Ignored invalid option: %s", buf);
666 /* Process "Z:<type>:<str>" -- set spell color */
670 char *t = my_strchr(buf + 2, ':');
678 for (i = 0; gf_desc[i].name; i++)
680 /* Match this type */
681 if (streq(gf_desc[i].name, buf + 2))
683 /* Remember this color set */
684 gf_color[gf_desc[i].num] = quark_add(t);
694 /* Initialize macro trigger names and a template */
695 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
696 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
699 int tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
701 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
707 if (macro_template != NULL)
709 num = strlen(macro_modifier_chr);
711 /* Kill the template string */
712 string_free(macro_template);
713 macro_template = NULL;
715 /* Kill flag characters of modifier keys */
716 string_free(macro_modifier_chr);
718 /* Kill corresponding modifier names */
719 for (i = 0; i < num; i++)
721 string_free(macro_modifier_name[i]);
724 /* Kill trigger name strings */
725 for (i = 0; i < max_macrotrigger; i++)
727 string_free(macro_trigger_name[i]);
728 string_free(macro_trigger_keycode[0][i]);
729 string_free(macro_trigger_keycode[1][i]);
732 max_macrotrigger = 0;
735 if (*zz[0] == '\0') return 0; /* clear template */
737 /* Number of modifier flags */
740 /* Limit the number */
741 num = MIN(MAX_MACRO_MOD, num);
743 /* Stop if number of modifier is not correct */
744 if (2 + num != tok) return 1;
746 /* Get a template string */
747 macro_template = string_make(zz[0]);
749 /* Get flag characters of modifier keys */
750 macro_modifier_chr = string_make(zz[1]);
752 /* Get corresponding modifier names */
753 for (i = 0; i < num; i++)
755 macro_modifier_name[i] = string_make(zz[2+i]);
759 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
765 if (max_macrotrigger >= MAX_MACRO_TRIG)
768 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
770 msg_print("Too many macro triggers!");
774 m = max_macrotrigger;
777 /* Take into account the escape character */
787 /* Get a trigger name */
788 macro_trigger_name[m] = string_make(buf);
790 /* Get the corresponding key code */
791 macro_trigger_keycode[0][m] = string_make(zz[1]);
795 /* Key code of a combination of it with the shift key */
796 macro_trigger_keycode[1][m] = string_make(zz[2]);
800 macro_trigger_keycode[1][m] = string_make(zz[1]);
815 * Helper function for "process_pref_file()"
818 * v: output buffer array
824 cptr process_pref_file_expr(cptr *sp, char *fp)
840 while (isspace(*s)) s++;
855 t = process_pref_file_expr(&s, &f);
864 else if (streq(t, "IOR"))
867 while (*s && (f != b2))
869 t = process_pref_file_expr(&s, &f);
870 if (*t && !streq(t, "0")) v = "1";
875 else if (streq(t, "AND"))
878 while (*s && (f != b2))
880 t = process_pref_file_expr(&s, &f);
881 if (*t && streq(t, "0")) v = "0";
886 else if (streq(t, "NOT"))
889 while (*s && (f != b2))
891 t = process_pref_file_expr(&s, &f);
892 if (*t && streq(t, "1")) v = "0";
897 else if (streq(t, "EQU"))
902 t = process_pref_file_expr(&s, &f);
904 while (*s && (f != b2))
906 p = process_pref_file_expr(&s, &f);
907 if (streq(t, p)) v = "1";
912 else if (streq(t, "LEQ"))
917 t = process_pref_file_expr(&s, &f);
919 while (*s && (f != b2))
922 t = process_pref_file_expr(&s, &f);
923 if (*t && atoi(p) > atoi(t)) v = "0";
928 else if (streq(t, "GEQ"))
933 t = process_pref_file_expr(&s, &f);
935 while (*s && (f != b2))
938 t = process_pref_file_expr(&s, &f);
940 /* Compare two numbers instead of string */
941 if (*t && atoi(p) < atoi(t)) v = "0";
948 while (*s && (f != b2))
950 t = process_pref_file_expr(&s, &f);
955 if (f != b2) v = "?x?x?";
957 /* Extract final and Terminate */
958 if ((f = *s) != '\0') s++;
967 /* Accept all printables except spaces and brackets */
968 for (i = 0; isprint(*s) && !my_strchr(" []", *s); i++)
974 /* Extract final and Terminate */
975 if ((f = *s) != '\0') s++;
981 if (streq(b+1, "SYS"))
986 else if (streq(b+1, "KEYBOARD"))
988 v = ANGBAND_KEYBOARD;
992 else if (streq(b+1, "GRAF"))
997 /* Monochrome mode */
998 else if (streq(b+1, "MONOCHROME"))
1007 else if (streq(b+1, "RACE"))
1010 v = rp_ptr->E_title;
1017 else if (streq(b+1, "CLASS"))
1020 v = cp_ptr->E_title;
1027 else if (streq(b+1, "PLAYER"))
1033 else if (streq(b+1, "REALM1"))
1036 v = E_realm_names[p_ptr->realm1];
1038 v = realm_names[p_ptr->realm1];
1043 else if (streq(b+1, "REALM2"))
1046 v = E_realm_names[p_ptr->realm2];
1048 v = realm_names[p_ptr->realm2];
1053 else if (streq(b+1, "LEVEL"))
1055 sprintf(tmp, "%02d", p_ptr->lev);
1059 /* Autopick auto-register is in-use or not? */
1060 else if (streq(b+1, "AUTOREGISTER"))
1062 if (p_ptr->autopick_autoregister)
1087 #define PREF_TYPE_NORMAL 0
1088 #define PREF_TYPE_AUTOPICK 1
1089 #define PREF_TYPE_HISTPREF 2
1092 * Open the "user pref file" and parse it.
1094 static errr process_pref_file_aux(cptr name, int preftype)
1106 bool bypass = FALSE;
1110 fp = my_fopen(name, "r");
1113 if (!fp) return (-1);
1115 /* Process the file */
1116 while (0 == my_fgets(fp, buf, sizeof(buf)))
1121 /* Skip "empty" lines */
1122 if (!buf[0]) continue;
1124 /* Skip "blank" lines */
1126 if (!iskanji(buf[0]))
1128 if (isspace(buf[0])) continue;
1131 if (buf[0] == '#') continue;
1138 /* Process "?:<expr>" */
1139 if ((buf[0] == '?') && (buf[1] == ':'))
1148 /* Parse the expr */
1149 v = process_pref_file_expr(&s, &f);
1152 bypass = (streq(v, "0") ? TRUE : FALSE);
1158 /* Apply conditionals */
1159 if (bypass) continue;
1162 /* Process "%:<file>" */
1165 static int depth_count = 0;
1167 /* Ignore if deeper than 20 level */
1168 if (depth_count > 20) continue;
1170 /* Count depth level */
1173 /* Process that file if allowed */
1176 case PREF_TYPE_AUTOPICK:
1177 (void)process_autopick_file(buf + 2);
1179 case PREF_TYPE_HISTPREF:
1180 (void)process_histpref_file(buf + 2);
1183 (void)process_pref_file(buf + 2);
1187 /* Set back depth level */
1195 /* Process the line */
1196 err = process_pref_file_command(buf);
1198 /* This is not original pref line... */
1201 if (preftype != PREF_TYPE_AUTOPICK)
1203 err = process_autopick_file_command(buf);
1211 /* Print error message */
1212 /* ToDo: Add better error messages */
1214 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1215 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1217 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1218 msg_format("Parsing '%s'", old);
1223 /* Close the file */
1233 * Process the "user pref file" with the given name
1235 * See the functions above for a list of legal "commands".
1237 * We also accept the special "?" and "%" directives, which
1238 * allow conditional evaluation and filename inclusion.
1240 errr process_pref_file(cptr name)
1246 /* Build the filename */
1247 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
1249 /* Process the system pref file */
1250 err1 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1252 /* Stop at parser errors, but not at non-existing file */
1253 if (err1 > 0) return err1;
1256 /* Build the filename */
1257 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
1259 /* Process the user pref file */
1260 err2 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1263 /* User file does not exist, but read system pref file */
1264 if (err2 < 0 && !err1)
1267 /* Result of user file processing */
1276 * Operating hours for ANGBAND (defaults to non-work hours)
1278 static char days[7][29] =
1280 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1281 "MON:XXXXXXXX.........XXXXXXX",
1282 "TUE:XXXXXXXX.........XXXXXXX",
1283 "WED:XXXXXXXX.........XXXXXXX",
1284 "THU:XXXXXXXX.........XXXXXXX",
1285 "FRI:XXXXXXXX.........XXXXXXX",
1286 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1290 * Restict usage (defaults to no restrictions)
1292 static bool check_time_flag = FALSE;
1300 errr check_time(void)
1308 /* No restrictions */
1309 if (!check_time_flag) return (0);
1311 /* Check for time violation */
1312 c = time((time_t *)0);
1316 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1327 * Initialize CHECK_TIME
1329 errr check_time_init(void)
1339 /* Build the filename */
1340 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
1343 fp = my_fopen(buf, "r");
1345 /* No file, no restrictions */
1346 if (!fp) return (0);
1348 /* Assume restrictions */
1349 check_time_flag = TRUE;
1351 /* Parse the file */
1352 while (0 == my_fgets(fp, buf, sizeof(buf)))
1354 /* Skip comments and blank lines */
1355 if (!buf[0] || (buf[0] == '#')) continue;
1357 /* Chop the buffer */
1360 /* Extract the info */
1361 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1362 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1363 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1364 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1365 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1366 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1367 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1383 #ifndef MAXHOSTNAMELEN
1384 # define MAXHOSTNAMELEN 64
1387 typedef struct statstime statstime;
1393 unsigned int v_pgpgin;
1394 unsigned int v_pgpgout;
1395 unsigned int v_pswpin;
1396 unsigned int v_pswpout;
1397 unsigned int v_intr;
1403 unsigned int v_swtch;
1405 struct timeval boottime;
1406 struct timeval curtime;
1410 * Maximal load (if any).
1412 static int check_load_value = 0;
1420 errr check_load(void)
1425 struct statstime st;
1427 /* Success if not checking */
1428 if (!check_load_value) return (0);
1430 /* Check the load */
1431 if (0 == rstat("localhost", &st))
1433 long val1 = (long)(st.avenrun[2]);
1434 long val2 = (long)(check_load_value) * FSCALE;
1436 /* Check for violation */
1437 if (val1 >= val2) return (1);
1448 * Initialize CHECK_LOAD
1450 errr check_load_init(void)
1459 char temphost[MAXHOSTNAMELEN+1];
1460 char thishost[MAXHOSTNAMELEN+1];
1463 /* Build the filename */
1464 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
1466 /* Open the "load" file */
1467 fp = my_fopen(buf, "r");
1469 /* No file, no restrictions */
1470 if (!fp) return (0);
1473 check_load_value = 100;
1475 /* Get the host name */
1476 (void)gethostname(thishost, (sizeof thishost) - 1);
1479 while (0 == my_fgets(fp, buf, sizeof(buf)))
1483 /* Skip comments and blank lines */
1484 if (!buf[0] || (buf[0] == '#')) continue;
1486 /* Parse, or ignore */
1487 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1489 /* Skip other hosts */
1490 if (!streq(temphost, thishost) &&
1491 !streq(temphost, "localhost")) continue;
1493 /* Use that value */
1494 check_load_value = value;
1500 /* Close the file */
1510 #define ENTRY_BARE_HAND 0
1511 #define ENTRY_TWO_HANDS 1
1512 #define ENTRY_RIGHT_HAND1 2
1513 #define ENTRY_LEFT_HAND1 3
1514 #define ENTRY_LEFT_HAND2 4
1515 #define ENTRY_RIGHT_HAND2 5
1516 #define ENTRY_POSTURE 6
1517 #define ENTRY_SHOOT_HIT_DAM 7
1518 #define ENTRY_SHOOT_POWER 8
1519 #define ENTRY_SPEED 9
1520 #define ENTRY_BASE_AC 10
1521 #define ENTRY_LEVEL 11
1522 #define ENTRY_CUR_EXP 12
1523 #define ENTRY_MAX_EXP 13
1524 #define ENTRY_EXP_TO_ADV 14
1525 #define ENTRY_GOLD 15
1526 #define ENTRY_DAY 16
1529 #define ENTRY_PLAY_TIME 19
1530 #define ENTRY_SKILL_FIGHT 20
1531 #define ENTRY_SKILL_SHOOT 21
1532 #define ENTRY_SKILL_SAVING 22
1533 #define ENTRY_SKILL_STEALTH 23
1534 #define ENTRY_SKILL_PERCEP 24
1535 #define ENTRY_SKILL_SEARCH 25
1536 #define ENTRY_SKILL_DISARM 26
1537 #define ENTRY_SKILL_DEVICE 27
1538 #define ENTRY_BLOWS 28
1539 #define ENTRY_SHOTS 29
1540 #define ENTRY_AVG_DMG 30
1541 #define ENTRY_INFRA 31
1543 #define ENTRY_NAME 32
1544 #define ENTRY_SEX 33
1545 #define ENTRY_RACE 34
1546 #define ENTRY_CLASS 35
1547 #define ENTRY_REALM 36
1548 #define ENTRY_PATRON 37
1549 #define ENTRY_AGE 38
1550 #define ENTRY_HEIGHT 39
1551 #define ENTRY_WEIGHT 40
1552 #define ENTRY_SOCIAL 41
1553 #define ENTRY_ALIGN 42
1555 #define ENTRY_EXP_ANDR 43
1556 #define ENTRY_EXP_TO_ADV_ANDR 44
1565 } disp_player_line[]
1568 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1569 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1570 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1571 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1572 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1573 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1575 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1576 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1577 { 1, 20, 25, "²Ã®"},
1578 { 1, 19, 25, "£Á£Ã"},
1579 {29, 13, 21, "¥ì¥Ù¥ë"},
1580 {29, 14, 21, "·Ð¸³ÃÍ"},
1581 {29, 15, 21, "ºÇÂç·Ð¸³"},
1582 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1583 {29, 17, 21, "½ê»ý¶â"},
1584 {29, 19, 21, "ÆüÉÕ"},
1585 {29, 10, 21, "£È£Ð"},
1586 {29, 11, 21, "£Í£Ð"},
1587 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1588 {53, 10, -1, "ÂǷ⹶·â :"},
1589 {53, 11, -1, "¼Í·â¹¶·â :"},
1590 {53, 12, -1, "ËâË¡Ëɸæ :"},
1591 {53, 13, -1, "±£Ì©¹ÔÆ° :"},
1592 {53, 15, -1, "ÃγР:"},
1593 {53, 16, -1, "õº÷ :"},
1594 {53, 17, -1, "²ò½ü :"},
1595 {53, 18, -1, "ËâË¡Æ»¶ñ :"},
1596 { 1, 12, 25, "ÂÇ·â²ó¿ô"},
1597 { 1, 17, 25, "¼Í·â²ó¿ô"},
1598 { 1, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1599 {53, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1600 {26, 1, -1, "̾Á° : "},
1601 { 1, 3, -1, "ÀÊÌ : "},
1602 { 1, 4, -1, "¼ï² : "},
1603 { 1, 5, -1, "¿¦¶È : "},
1604 { 1, 6, -1, "ËâË¡ : "},
1605 { 1, 7, -1, "¼é¸îËâ¿À : "},
1606 {29, 3, 21, "ǯÎð"},
1607 {29, 4, 21, "¿ÈĹ"},
1608 {29, 5, 21, "ÂνÅ"},
1609 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1610 {29, 7, 21, "°À"},
1611 {29, 14, 21, "¶¯²½ÅÙ"},
1612 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1616 { 1, 10, 25, "Bare hand"},
1617 { 1, 10, 25, "Two hands"},
1618 { 1, 10, 25, "Right hand"},
1619 { 1, 10, 25, "Left hand"},
1620 { 1, 11, 25, "Left hand"},
1621 { 1, 11, 25, "Right hand"},
1622 { 1, 11, 25, "Posture"},
1623 { 1, 15, 25, "Shooting"},
1624 { 1, 16, 25, "Multiplier"},
1625 { 1, 20, 25, "Speed"},
1627 {29, 13, 21, "Level"},
1628 {29, 14, 21, "Experience"},
1629 {29, 15, 21, "Max Exp"},
1630 {29, 16, 21, "Exp to Adv"},
1631 {29, 17, 21, "Gold"},
1632 {29, 19, 21, "Time"},
1633 {29, 10, 21, "Hit point"},
1634 {29, 11, 21, "SP (Mana)"},
1635 {29, 20, 21, "Play time"},
1636 {53, 10, -1, "Fighting : "},
1637 {53, 11, -1, "Bows/Throw : "},
1638 {53, 12, -1, "SavingThrow: "},
1639 {53, 13, -1, "Stealth : "},
1640 {53, 15, -1, "Perception : "},
1641 {53, 16, -1, "Searching : "},
1642 {53, 17, -1, "Disarming : "},
1643 {53, 18, -1, "MagicDevice: "},
1644 { 1, 12, 25, "Blows/Round"},
1645 { 1, 17, 25, "Shots/Round"},
1646 { 1, 13, 25, "AverageDmg/Rnd"},
1647 {53, 20, -1, "Infra-Vision: "},
1648 {26, 1, -1, "Name : "},
1649 { 1, 3, -1, "Sex : "},
1650 { 1, 4, -1, "Race : "},
1651 { 1, 5, -1, "Class : "},
1652 { 1, 6, -1, "Magic : "},
1653 { 1, 7, -1, "Patron : "},
1655 {29, 4, 21, "Height"},
1656 {29, 5, 21, "Weight"},
1657 {29, 6, 21, "Social Class"},
1658 {29, 7, 21, "Align"},
1659 {29, 14, 21, "Construction"},
1660 {29, 16, 21, "Const to Adv"},
1664 static void display_player_one_line(int entry, cptr val, byte attr)
1668 int row = disp_player_line[entry].row;
1669 int col = disp_player_line[entry].col;
1670 int len = disp_player_line[entry].len;
1671 cptr head = disp_player_line[entry].header;
1673 int head_len = strlen(head);
1675 Term_putstr(col, row, -1, TERM_WHITE, head);
1682 int val_len = len - head_len;
1683 sprintf(buf, "%*.*s", val_len, val_len, val);
1684 Term_putstr(col + head_len, row, -1, attr, buf);
1688 Term_putstr(col + head_len, row, -1, attr, val);
1696 * Prints the following information on the screen.
1698 static void display_player_middle(void)
1701 int show_tohit, show_todam;
1708 show_tohit = p_ptr->dis_to_h[0];
1709 show_todam = p_ptr->dis_to_d[0];
1711 o_ptr = &inventory[INVEN_RARM];
1713 /* Hack -- add in weapon info if known */
1714 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1715 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1718 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1720 /* Dump the bonuses to hit/dam */
1721 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1722 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1723 else if(p_ptr->ryoute)
1724 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1725 else if (left_hander)
1726 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1728 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1733 show_tohit = p_ptr->dis_to_h[1];
1734 show_todam = p_ptr->dis_to_d[1];
1736 o_ptr = &inventory[INVEN_LARM];
1738 /* Hack -- add in weapon info if known */
1739 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1740 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1743 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1745 /* Dump the bonuses to hit/dam */
1747 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1749 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1751 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
1754 if (p_ptr->special_defense & KAMAE_MASK)
1756 for (i = 0; i < MAX_KAMAE; i++)
1758 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1762 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1764 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1769 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1771 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1776 o_ptr = &inventory[INVEN_BOW];
1779 show_tohit = p_ptr->dis_to_h_b;
1782 /* Apply weapon bonuses */
1783 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1784 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1786 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1787 show_tohit += p_ptr->weapon_exp[0][o_ptr->sval] / 400;
1789 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
1792 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1794 if (inventory[INVEN_BOW].k_idx)
1796 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1798 /* Get extra "power" from "extra might" */
1799 if (p_ptr->xtra_might) tmul++;
1801 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1805 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1807 /* Dump the armor class */
1808 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1816 i = p_ptr->pspeed-110;
1818 /* Hack -- Visually "undo" the Search Mode Slowdown */
1819 if (p_ptr->action == ACTION_SEARCH) i += 10;
1824 attr = TERM_L_GREEN;
1838 attr = TERM_L_UMBER;
1845 if (IS_FAST()) tmp_speed += 10;
1846 if (p_ptr->slow) tmp_speed -= 10;
1847 if (p_ptr->lightspeed) tmp_speed = 99;
1851 if (m_list[p_ptr->riding].fast) tmp_speed += 10;
1852 if (m_list[p_ptr->riding].slow) tmp_speed -= 10;
1858 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1861 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1863 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1874 sprintf(buf, "(%+d)", i);
1877 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1879 sprintf(buf, "Riding (%+d)", i);
1883 display_player_one_line(ENTRY_SPEED, buf, attr);
1886 /* Dump character level */
1887 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1889 /* Dump experience */
1890 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1891 else e = ENTRY_CUR_EXP;
1893 if (p_ptr->exp >= p_ptr->max_exp)
1894 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1896 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1898 /* Dump max experience */
1899 if (p_ptr->prace == RACE_ANDROID)
1902 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1904 /* Dump exp to advance */
1905 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
1906 else e = ENTRY_EXP_TO_ADV;
1908 if (p_ptr->lev >= PY_MAX_LEVEL)
1909 display_player_one_line(e, "*****", TERM_L_GREEN);
1910 else if (p_ptr->prace == RACE_ANDROID)
1911 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1913 display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1916 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1921 extract_day_hour_min(&day, &hour, &min);
1931 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1933 /* Dump hit point */
1934 if (p_ptr->chp >= p_ptr->mhp)
1935 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1936 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1937 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1939 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1941 /* Dump mana power */
1942 if (p_ptr->csp >= p_ptr->msp)
1943 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1944 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
1945 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1947 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1949 /* Dump play time */
1950 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1955 * Hack -- pass color info around this file
1957 static byte likert_color = TERM_WHITE;
1961 * Returns a "rating" of x depending on y
1963 static cptr likert(int x, int y)
1965 static char dummy[20] = "";
1970 /* Negative value */
1973 likert_color = TERM_L_DARK;
1981 /* Analyze the value */
1986 likert_color = TERM_RED;
1994 likert_color = TERM_L_RED;
2003 likert_color = TERM_ORANGE;
2011 likert_color = TERM_YELLOW;
2019 likert_color = TERM_YELLOW;
2028 likert_color = TERM_L_GREEN;
2040 likert_color = TERM_GREEN;
2051 likert_color = TERM_BLUE;
2059 likert_color = TERM_VIOLET;
2061 sprintf(dummy, "ÅÁÀâŪ[%d]", (int)((((x / y) - 17) * 5) / 2));
2063 sprintf(dummy, "Legendary[%d]", (int)((((x / y) - 17) * 5) / 2));
2071 * Prints ratings on certain abilities
2073 * This code is "imitated" elsewhere to "dump" a character sheet.
2075 static void display_player_various(void)
2077 int tmp, damage[2], blows1, blows2, i, basedam;
2078 int xthn, xthb, xfos, xsrh;
2079 int xdis, xdev, xsav, xstl;
2082 u32b flgs[TR_FLAG_SIZE];
2083 int shots, shot_frac;
2087 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2088 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2089 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2090 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2091 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2093 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2095 /* Shooting Skill (with current bow and normal missile) */
2096 o_ptr = &inventory[INVEN_BOW];
2097 tmp = p_ptr->to_h_b + o_ptr->to_h;
2098 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2100 /* If the player is wielding one? */
2103 s16b energy_fire = bow_energy(o_ptr->sval);
2105 /* Calculate shots per round */
2106 shots = p_ptr->num_fire * 100;
2107 shot_frac = (shots * 100 / energy_fire) % 100;
2108 shots = shots / energy_fire;
2109 if (o_ptr->name1 == ART_CRIMSON)
2113 if (p_ptr->pclass == CLASS_ARCHER)
2115 /* Extra shot at level 10 */
2116 if (p_ptr->lev >= 10) shots++;
2118 /* Extra shot at level 30 */
2119 if (p_ptr->lev >= 30) shots++;
2121 /* Extra shot at level 45 */
2122 if (p_ptr->lev >= 45) shots++;
2132 for(i = 0; i < 2; i++)
2134 damage[i] = p_ptr->dis_to_d[i] * 100;
2135 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
2137 int level = p_ptr->lev;
2143 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2144 if (p_ptr->special_defense & KAMAE_BYAKKO)
2145 basedam = monk_ave_damage[level][1];
2146 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2147 basedam = monk_ave_damage[level][2];
2149 basedam = monk_ave_damage[level][0];
2153 o_ptr = &inventory[INVEN_RARM + i];
2155 /* Average damage per round */
2158 if (object_is_known(o_ptr)) damage[i] += o_ptr->to_d * 100;
2159 basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
2160 object_flags_known(o_ptr, flgs);
2161 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2167 else if (have_flag(flgs, TR_VORPAL))
2169 /* vorpal flag only */
2173 if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2174 basedam = basedam * 7 / 2;
2178 damage[i] += basedam;
2179 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2180 if (damage[i] < 0) damage[i] = 0;
2182 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2183 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2185 /* Basic abilities */
2187 xdis = p_ptr->skill_dis;
2188 xdev = p_ptr->skill_dev;
2189 xsav = p_ptr->skill_sav;
2190 xstl = p_ptr->skill_stl;
2191 xsrh = p_ptr->skill_srh;
2192 xfos = p_ptr->skill_fos;
2195 desc = likert(xthn, 12);
2196 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2198 desc = likert(xthb, 12);
2199 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2201 desc = likert(xsav, 7);
2202 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2204 /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
2205 desc = likert((xstl > 0) ? xstl : -1, 1);
2206 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2208 desc = likert(xfos, 6);
2209 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2211 desc = likert(xsrh, 6);
2212 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2214 desc = likert(xdis, 8);
2215 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2217 desc = likert(xdev, 6);
2218 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2221 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2223 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2225 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2228 if ((damage[0]+damage[1]) == 0)
2231 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2233 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2235 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2241 * Obtain the "flags" for the player as if he was an item
2243 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2248 for (i = 0; i < TR_FLAG_SIZE; i++)
2252 switch (p_ptr->pclass)
2255 if (p_ptr->lev > 44)
2256 add_flag(flgs, TR_REGEN);
2258 if (p_ptr->lev > 29)
2259 add_flag(flgs, TR_RES_FEAR);
2262 if (p_ptr->lev > 39)
2263 add_flag(flgs, TR_RES_FEAR);
2265 case CLASS_CHAOS_WARRIOR:
2266 if (p_ptr->lev > 29)
2267 add_flag(flgs, TR_RES_CHAOS);
2268 if (p_ptr->lev > 39)
2269 add_flag(flgs, TR_RES_FEAR);
2272 case CLASS_FORCETRAINER:
2273 if ((p_ptr->lev > 9) && !heavy_armor())
2274 add_flag(flgs, TR_SPEED);
2275 if ((p_ptr->lev>24) && !heavy_armor())
2276 add_flag(flgs, TR_FREE_ACT);
2280 add_flag(flgs, TR_SPEED);
2283 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2284 add_flag(flgs, TR_SPEED);
2286 add_flag(flgs, TR_FREE_ACT);
2288 add_flag(flgs, TR_SLOW_DIGEST);
2289 add_flag(flgs, TR_RES_FEAR);
2290 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2291 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2292 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2294 case CLASS_MINDCRAFTER:
2296 add_flag(flgs, TR_RES_FEAR);
2297 if (p_ptr->lev > 19)
2298 add_flag(flgs, TR_SUST_WIS);
2299 if (p_ptr->lev > 29)
2300 add_flag(flgs, TR_RES_CONF);
2301 if (p_ptr->lev > 39)
2302 add_flag(flgs, TR_TELEPATHY);
2305 add_flag(flgs, TR_RES_SOUND);
2307 case CLASS_BERSERKER:
2308 add_flag(flgs, TR_SUST_STR);
2309 add_flag(flgs, TR_SUST_DEX);
2310 add_flag(flgs, TR_SUST_CON);
2311 add_flag(flgs, TR_REGEN);
2312 add_flag(flgs, TR_FREE_ACT);
2313 add_flag(flgs, TR_SPEED);
2314 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2316 case CLASS_MIRROR_MASTER:
2317 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2320 break; /* Do nothing */
2324 if (p_ptr->mimic_form)
2326 switch(p_ptr->mimic_form)
2329 add_flag(flgs, TR_HOLD_LIFE);
2330 add_flag(flgs, TR_RES_CHAOS);
2331 add_flag(flgs, TR_RES_NETHER);
2332 add_flag(flgs, TR_RES_FIRE);
2333 add_flag(flgs, TR_SEE_INVIS);
2334 add_flag(flgs, TR_SPEED);
2336 case MIMIC_DEMON_LORD:
2337 add_flag(flgs, TR_HOLD_LIFE);
2338 add_flag(flgs, TR_RES_CHAOS);
2339 add_flag(flgs, TR_RES_NETHER);
2340 add_flag(flgs, TR_RES_FIRE);
2341 add_flag(flgs, TR_RES_COLD);
2342 add_flag(flgs, TR_RES_ELEC);
2343 add_flag(flgs, TR_RES_ACID);
2344 add_flag(flgs, TR_RES_POIS);
2345 add_flag(flgs, TR_RES_CONF);
2346 add_flag(flgs, TR_RES_DISEN);
2347 add_flag(flgs, TR_RES_NEXUS);
2348 add_flag(flgs, TR_RES_FEAR);
2349 add_flag(flgs, TR_IM_FIRE);
2350 add_flag(flgs, TR_SH_FIRE);
2351 add_flag(flgs, TR_SEE_INVIS);
2352 add_flag(flgs, TR_TELEPATHY);
2353 add_flag(flgs, TR_FEATHER);
2354 add_flag(flgs, TR_SPEED);
2357 add_flag(flgs, TR_HOLD_LIFE);
2358 add_flag(flgs, TR_RES_DARK);
2359 add_flag(flgs, TR_RES_NETHER);
2360 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2361 add_flag(flgs, TR_RES_POIS);
2362 add_flag(flgs, TR_RES_COLD);
2363 add_flag(flgs, TR_SEE_INVIS);
2364 add_flag(flgs, TR_SPEED);
2370 switch (p_ptr->prace)
2373 add_flag(flgs, TR_RES_LITE);
2376 add_flag(flgs, TR_HOLD_LIFE);
2379 add_flag(flgs, TR_FREE_ACT);
2382 add_flag(flgs, TR_RES_BLIND);
2385 add_flag(flgs, TR_RES_DARK);
2387 case RACE_HALF_TROLL:
2388 add_flag(flgs, TR_SUST_STR);
2389 if (p_ptr->lev > 14)
2391 add_flag(flgs, TR_REGEN);
2392 if (p_ptr->pclass == CLASS_WARRIOR)
2394 add_flag(flgs, TR_SLOW_DIGEST);
2396 * Let's not make Regeneration a disadvantage
2397 * for the poor warriors who can never learn
2398 * a spell that satisfies hunger (actually
2399 * neither can rogues, but half-trolls are not
2400 * supposed to play rogues)
2406 add_flag(flgs, TR_SUST_CON);
2407 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2410 add_flag(flgs, TR_RES_LITE);
2411 add_flag(flgs, TR_SEE_INVIS);
2413 case RACE_BARBARIAN:
2414 add_flag(flgs, TR_RES_FEAR);
2416 case RACE_HALF_OGRE:
2417 add_flag(flgs, TR_SUST_STR);
2418 add_flag(flgs, TR_RES_DARK);
2420 case RACE_HALF_GIANT:
2421 add_flag(flgs, TR_RES_SHARDS);
2422 add_flag(flgs, TR_SUST_STR);
2424 case RACE_HALF_TITAN:
2425 add_flag(flgs, TR_RES_CHAOS);
2428 add_flag(flgs, TR_RES_SOUND);
2431 add_flag(flgs, TR_RES_ACID);
2432 if (p_ptr->lev > 19)
2433 add_flag(flgs, TR_IM_ACID);
2436 add_flag(flgs, TR_RES_CONF);
2437 add_flag(flgs, TR_RES_ACID);
2439 add_flag(flgs, TR_SPEED);
2442 add_flag(flgs, TR_RES_POIS);
2445 add_flag(flgs, TR_RES_DISEN);
2446 add_flag(flgs, TR_RES_DARK);
2449 add_flag(flgs, TR_RES_DARK);
2450 if (p_ptr->lev > 19)
2451 add_flag(flgs, TR_SEE_INVIS);
2453 case RACE_DRACONIAN:
2454 add_flag(flgs, TR_FEATHER);
2456 add_flag(flgs, TR_RES_FIRE);
2458 add_flag(flgs, TR_RES_COLD);
2459 if (p_ptr->lev > 14)
2460 add_flag(flgs, TR_RES_ACID);
2461 if (p_ptr->lev > 19)
2462 add_flag(flgs, TR_RES_ELEC);
2463 if (p_ptr->lev > 34)
2464 add_flag(flgs, TR_RES_POIS);
2466 case RACE_MIND_FLAYER:
2467 add_flag(flgs, TR_SUST_INT);
2468 add_flag(flgs, TR_SUST_WIS);
2469 if (p_ptr->lev > 14)
2470 add_flag(flgs, TR_SEE_INVIS);
2471 if (p_ptr->lev > 29)
2472 add_flag(flgs, TR_TELEPATHY);
2475 add_flag(flgs, TR_RES_FIRE);
2477 add_flag(flgs, TR_SEE_INVIS);
2480 add_flag(flgs, TR_SEE_INVIS);
2481 add_flag(flgs, TR_FREE_ACT);
2482 add_flag(flgs, TR_RES_POIS);
2483 add_flag(flgs, TR_SLOW_DIGEST);
2484 if (p_ptr->lev > 34)
2485 add_flag(flgs, TR_HOLD_LIFE);
2488 add_flag(flgs, TR_SEE_INVIS);
2489 add_flag(flgs, TR_RES_SHARDS);
2490 add_flag(flgs, TR_HOLD_LIFE);
2491 add_flag(flgs, TR_RES_POIS);
2493 add_flag(flgs, TR_RES_COLD);
2496 add_flag(flgs, TR_SEE_INVIS);
2497 add_flag(flgs, TR_HOLD_LIFE);
2498 add_flag(flgs, TR_RES_NETHER);
2499 add_flag(flgs, TR_RES_POIS);
2500 add_flag(flgs, TR_SLOW_DIGEST);
2502 add_flag(flgs, TR_RES_COLD);
2505 add_flag(flgs, TR_HOLD_LIFE);
2506 add_flag(flgs, TR_RES_DARK);
2507 add_flag(flgs, TR_RES_NETHER);
2508 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2509 add_flag(flgs, TR_RES_POIS);
2510 add_flag(flgs, TR_RES_COLD);
2513 add_flag(flgs, TR_FEATHER);
2514 add_flag(flgs, TR_FREE_ACT);
2515 add_flag(flgs, TR_RES_COLD);
2516 add_flag(flgs, TR_SEE_INVIS);
2517 add_flag(flgs, TR_HOLD_LIFE);
2518 add_flag(flgs, TR_RES_NETHER);
2519 add_flag(flgs, TR_RES_POIS);
2520 add_flag(flgs, TR_SLOW_DIGEST);
2522 if (p_ptr->lev > 34)
2523 add_flag(flgs, TR_TELEPATHY);
2526 add_flag(flgs, TR_RES_LITE);
2527 add_flag(flgs, TR_FEATHER);
2529 add_flag(flgs, TR_SPEED);
2532 add_flag(flgs, TR_RES_SOUND);
2533 add_flag(flgs, TR_RES_CONF);
2536 add_flag(flgs, TR_FEATHER);
2537 add_flag(flgs, TR_SEE_INVIS);
2540 add_flag(flgs, TR_RES_FIRE);
2541 add_flag(flgs, TR_RES_NETHER);
2542 add_flag(flgs, TR_HOLD_LIFE);
2544 add_flag(flgs, TR_SEE_INVIS);
2547 add_flag(flgs, TR_SUST_CON);
2550 add_flag(flgs, TR_FEATHER);
2553 add_flag(flgs, TR_RES_CONF);
2556 add_flag(flgs, TR_FREE_ACT);
2557 add_flag(flgs, TR_RES_POIS);
2558 add_flag(flgs, TR_SLOW_DIGEST);
2559 add_flag(flgs, TR_HOLD_LIFE);
2569 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2571 remove_flag(flgs, TR_REGEN);
2574 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2575 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2576 (p_ptr->muta3 & MUT3_SHORT_LEG))
2578 add_flag(flgs, TR_SPEED);
2581 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2583 add_flag(flgs, TR_SH_ELEC);
2586 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2588 add_flag(flgs, TR_SH_FIRE);
2589 add_flag(flgs, TR_LITE);
2592 if (p_ptr->muta3 & MUT3_WINGS)
2594 add_flag(flgs, TR_FEATHER);
2597 if (p_ptr->muta3 & MUT3_FEARLESS)
2599 add_flag(flgs, TR_RES_FEAR);
2602 if (p_ptr->muta3 & MUT3_REGEN)
2604 add_flag(flgs, TR_REGEN);
2607 if (p_ptr->muta3 & MUT3_ESP)
2609 add_flag(flgs, TR_TELEPATHY);
2612 if (p_ptr->muta3 & MUT3_MOTION)
2614 add_flag(flgs, TR_FREE_ACT);
2618 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2619 add_flag(flgs, TR_AGGRAVATE);
2620 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2622 add_flag(flgs, TR_RES_BLIND);
2623 add_flag(flgs, TR_RES_CONF);
2624 add_flag(flgs, TR_HOLD_LIFE);
2625 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2627 add_flag(flgs, TR_SPEED);
2629 if (p_ptr->special_defense & KATA_FUUJIN)
2630 add_flag(flgs, TR_REFLECT);
2631 if (p_ptr->special_defense & KAMAE_GENBU)
2632 add_flag(flgs, TR_REFLECT);
2633 if (p_ptr->special_defense & KAMAE_SUZAKU)
2634 add_flag(flgs, TR_FEATHER);
2635 if (p_ptr->special_defense & KAMAE_SEIRYU)
2637 add_flag(flgs, TR_RES_FIRE);
2638 add_flag(flgs, TR_RES_COLD);
2639 add_flag(flgs, TR_RES_ACID);
2640 add_flag(flgs, TR_RES_ELEC);
2641 add_flag(flgs, TR_RES_POIS);
2642 add_flag(flgs, TR_FEATHER);
2643 add_flag(flgs, TR_SH_FIRE);
2644 add_flag(flgs, TR_SH_ELEC);
2645 add_flag(flgs, TR_SH_COLD);
2647 if (p_ptr->special_defense & KATA_MUSOU)
2649 add_flag(flgs, TR_RES_FEAR);
2650 add_flag(flgs, TR_RES_LITE);
2651 add_flag(flgs, TR_RES_DARK);
2652 add_flag(flgs, TR_RES_BLIND);
2653 add_flag(flgs, TR_RES_CONF);
2654 add_flag(flgs, TR_RES_SOUND);
2655 add_flag(flgs, TR_RES_SHARDS);
2656 add_flag(flgs, TR_RES_NETHER);
2657 add_flag(flgs, TR_RES_NEXUS);
2658 add_flag(flgs, TR_RES_CHAOS);
2659 add_flag(flgs, TR_RES_DISEN);
2660 add_flag(flgs, TR_REFLECT);
2661 add_flag(flgs, TR_HOLD_LIFE);
2662 add_flag(flgs, TR_FREE_ACT);
2663 add_flag(flgs, TR_SH_FIRE);
2664 add_flag(flgs, TR_SH_ELEC);
2665 add_flag(flgs, TR_SH_COLD);
2666 add_flag(flgs, TR_FEATHER);
2667 add_flag(flgs, TR_LITE);
2668 add_flag(flgs, TR_SEE_INVIS);
2669 add_flag(flgs, TR_TELEPATHY);
2670 add_flag(flgs, TR_SLOW_DIGEST);
2671 add_flag(flgs, TR_REGEN);
2672 add_flag(flgs, TR_SUST_STR);
2673 add_flag(flgs, TR_SUST_INT);
2674 add_flag(flgs, TR_SUST_WIS);
2675 add_flag(flgs, TR_SUST_DEX);
2676 add_flag(flgs, TR_SUST_CON);
2677 add_flag(flgs, TR_SUST_CHR);
2682 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
2687 for (i = 0; i < TR_FLAG_SIZE; i++)
2690 if (IS_HERO() || p_ptr->shero)
2691 add_flag(flgs, TR_RES_FEAR);
2692 if (p_ptr->tim_invis)
2693 add_flag(flgs, TR_SEE_INVIS);
2694 if (p_ptr->tim_regen)
2695 add_flag(flgs, TR_REGEN);
2697 add_flag(flgs, TR_TELEPATHY);
2698 if (IS_FAST() || p_ptr->slow)
2699 add_flag(flgs, TR_SPEED);
2701 if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
2702 add_flag(flgs, TR_RES_ACID);
2703 if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
2704 add_flag(flgs, TR_RES_ELEC);
2705 if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
2706 add_flag(flgs, TR_RES_FIRE);
2707 if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
2708 add_flag(flgs, TR_RES_COLD);
2709 if (IS_OPPOSE_POIS())
2710 add_flag(flgs, TR_RES_POIS);
2712 if (p_ptr->special_attack & ATTACK_ACID)
2713 add_flag(flgs, TR_BRAND_ACID);
2714 if (p_ptr->special_attack & ATTACK_ELEC)
2715 add_flag(flgs, TR_BRAND_ELEC);
2716 if (p_ptr->special_attack & ATTACK_FIRE)
2717 add_flag(flgs, TR_BRAND_FIRE);
2718 if (p_ptr->special_attack & ATTACK_COLD)
2719 add_flag(flgs, TR_BRAND_COLD);
2720 if (p_ptr->special_attack & ATTACK_POIS)
2721 add_flag(flgs, TR_BRAND_POIS);
2722 if (p_ptr->special_defense & DEFENSE_ACID)
2723 add_flag(flgs, TR_IM_ACID);
2724 if (p_ptr->special_defense & DEFENSE_ELEC)
2725 add_flag(flgs, TR_IM_ELEC);
2726 if (p_ptr->special_defense & DEFENSE_FIRE)
2727 add_flag(flgs, TR_IM_FIRE);
2728 if (p_ptr->special_defense & DEFENSE_COLD)
2729 add_flag(flgs, TR_IM_COLD);
2730 if (p_ptr->wraith_form)
2731 add_flag(flgs, TR_REFLECT);
2733 if (p_ptr->tim_reflect)
2734 add_flag(flgs, TR_REFLECT);
2736 if (p_ptr->magicdef)
2738 add_flag(flgs, TR_RES_BLIND);
2739 add_flag(flgs, TR_RES_CONF);
2740 add_flag(flgs, TR_REFLECT);
2741 add_flag(flgs, TR_FREE_ACT);
2742 add_flag(flgs, TR_FEATHER);
2744 if (p_ptr->tim_res_nether)
2746 add_flag(flgs, TR_RES_NETHER);
2748 if (p_ptr->tim_sh_fire)
2750 add_flag(flgs, TR_SH_FIRE);
2754 add_flag(flgs, TR_RES_FEAR);
2755 add_flag(flgs, TR_RES_LITE);
2756 add_flag(flgs, TR_RES_DARK);
2757 add_flag(flgs, TR_RES_BLIND);
2758 add_flag(flgs, TR_RES_CONF);
2759 add_flag(flgs, TR_RES_SOUND);
2760 add_flag(flgs, TR_RES_SHARDS);
2761 add_flag(flgs, TR_RES_NETHER);
2762 add_flag(flgs, TR_RES_NEXUS);
2763 add_flag(flgs, TR_RES_CHAOS);
2764 add_flag(flgs, TR_RES_DISEN);
2765 add_flag(flgs, TR_REFLECT);
2766 add_flag(flgs, TR_HOLD_LIFE);
2767 add_flag(flgs, TR_FREE_ACT);
2768 add_flag(flgs, TR_SH_FIRE);
2769 add_flag(flgs, TR_SH_ELEC);
2770 add_flag(flgs, TR_SH_COLD);
2771 add_flag(flgs, TR_FEATHER);
2772 add_flag(flgs, TR_LITE);
2773 add_flag(flgs, TR_SEE_INVIS);
2774 add_flag(flgs, TR_TELEPATHY);
2775 add_flag(flgs, TR_SLOW_DIGEST);
2776 add_flag(flgs, TR_REGEN);
2777 add_flag(flgs, TR_SUST_STR);
2778 add_flag(flgs, TR_SUST_INT);
2779 add_flag(flgs, TR_SUST_WIS);
2780 add_flag(flgs, TR_SUST_DEX);
2781 add_flag(flgs, TR_SUST_CON);
2782 add_flag(flgs, TR_SUST_CHR);
2787 /* Mode flags for displaying player flags */
2788 #define DP_CURSE 0x01
2796 static void display_player_equippy(int y, int x, u16b mode)
2805 /* Weapon flags need only two column */
2806 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2807 else max_i = INVEN_TOTAL;
2809 /* Dump equippy chars */
2810 for (i = INVEN_RARM; i < max_i; i++)
2813 o_ptr = &inventory[i];
2815 a = object_attr(o_ptr);
2816 c = object_char(o_ptr);
2818 /* Clear the part of the screen */
2819 if (!equippy_chars || !o_ptr->k_idx)
2826 Term_putch(x + i - INVEN_RARM, y, a, c);
2831 void print_equippy(void)
2833 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2840 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2845 for (i = 0; i < TR_FLAG_SIZE; i++)
2848 /* Check equipment */
2849 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2851 u32b o_flgs[TR_FLAG_SIZE];
2856 o_ptr = &inventory[i];
2858 if (!o_ptr->k_idx) continue;
2861 object_flags_known(o_ptr, o_flgs);
2863 if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2864 if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2865 if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2866 if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2870 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2875 for (i = 0; i < TR_FLAG_SIZE; i++)
2878 if (prace_is_(RACE_SPECTRE))
2879 add_flag(flgs, TR_RES_NETHER);
2880 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2881 add_flag(flgs, TR_RES_DARK);
2882 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2883 add_flag(flgs, TR_RES_FIRE);
2884 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2885 add_flag(flgs, TR_RES_ACID);
2888 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2893 for (i = 0; i < TR_FLAG_SIZE; i++)
2896 if (p_ptr->special_defense & DEFENSE_ACID)
2897 add_flag(flgs, TR_RES_ACID);
2898 if (p_ptr->special_defense & DEFENSE_ELEC)
2899 add_flag(flgs, TR_RES_ELEC);
2900 if (p_ptr->special_defense & DEFENSE_FIRE)
2901 add_flag(flgs, TR_RES_FIRE);
2902 if (p_ptr->special_defense & DEFENSE_COLD)
2903 add_flag(flgs, TR_RES_COLD);
2904 if (p_ptr->wraith_form)
2905 add_flag(flgs, TR_RES_DARK);
2908 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2913 for (i = 0; i < TR_FLAG_SIZE; i++)
2916 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2918 add_flag(flgs, TR_RES_ACID);
2919 add_flag(flgs, TR_RES_ELEC);
2920 add_flag(flgs, TR_RES_FIRE);
2921 add_flag(flgs, TR_RES_COLD);
2923 if (prace_is_(RACE_ANDROID))
2924 add_flag(flgs, TR_RES_ELEC);
2925 if (prace_is_(RACE_ENT))
2926 add_flag(flgs, TR_RES_FIRE);
2927 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2928 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2929 add_flag(flgs, TR_RES_LITE);
2934 * A struct for storing misc. flags
2937 u32b player_flags[TR_FLAG_SIZE];
2938 u32b tim_player_flags[TR_FLAG_SIZE];
2939 u32b player_imm[TR_FLAG_SIZE];
2940 u32b tim_player_imm[TR_FLAG_SIZE];
2941 u32b player_vuln[TR_FLAG_SIZE];
2942 u32b known_obj_imm[TR_FLAG_SIZE];
2947 * Helper function, see below
2949 static void display_flag_aux(int row, int col, cptr header,
2950 int flag1, all_player_flags *f, u16b mode)
2956 if (have_flag(f->player_vuln, flag1) &&
2957 !(have_flag(f->known_obj_imm, flag1) ||
2958 have_flag(f->player_imm, flag1) ||
2959 have_flag(f->tim_player_imm, flag1)))
2963 if (!(mode & DP_IMM)) c_put_str(TERM_WHITE, header, row, col);
2966 col += strlen(header) + 1;
2968 /* Weapon flags need only two column */
2969 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2970 else max_i = INVEN_TOTAL;
2972 /* Check equipment */
2973 for (i = INVEN_RARM; i < max_i; i++)
2975 u32b flgs[TR_FLAG_SIZE];
2979 o_ptr = &inventory[i];
2982 object_flags_known(o_ptr, flgs);
2985 if (!(mode & DP_IMM))
2986 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2989 if (mode & DP_CURSE)
2991 if ((mode & DP_CURSE) && (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE)))
2992 c_put_str(TERM_WHITE, "+", row, col);
2993 if ((mode & DP_CURSE) && (o_ptr->curse_flags & TRC_PERMA_CURSE))
2994 c_put_str(TERM_WHITE, "*", row, col);
2998 if (have_flag(flgs, flag1))
2999 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
3000 (mode & DP_IMM) ? "*" : "+", row, col);
3007 /* Assume that player flag is already written */
3008 if (mode & DP_IMM) return;
3011 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3014 if (have_flag(f->player_flags, flag1)) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3016 /* Timed player flags */
3017 if (have_flag(f->tim_player_flags, flag1)) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3020 if (have_flag(f->tim_player_imm, flag1)) c_put_str(TERM_YELLOW, "*", row, col);
3021 if (have_flag(f->player_imm, flag1)) c_put_str(TERM_WHITE, "*", row, col);
3024 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3029 * Special display, part 1
3031 static void display_player_flag_info(void)
3038 /* Extract flags and store */
3039 player_flags(f.player_flags);
3040 tim_player_flags(f.tim_player_flags);
3041 player_immunity(f.player_imm);
3042 tim_player_immunity(f.tim_player_imm);
3043 known_obj_immunity(f.known_obj_imm);
3044 player_vuln_flags(f.player_vuln);
3051 display_player_equippy(row-2, col+8, 0);
3052 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3055 display_flag_aux(row+0, col, "ÂÑ»À :", TR_RES_ACID, &f, 0);
3056 display_flag_aux(row+0, col, "ÂÑ»À :", TR_IM_ACID, &f, DP_IMM);
3057 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_RES_ELEC, &f, 0);
3058 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_IM_ELEC, &f, DP_IMM);
3059 display_flag_aux(row+2, col, "ÂѲбê:", TR_RES_FIRE, &f, 0);
3060 display_flag_aux(row+2, col, "ÂѲбê:", TR_IM_FIRE, &f, DP_IMM);
3061 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_RES_COLD, &f, 0);
3062 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_IM_COLD, &f, DP_IMM);
3063 display_flag_aux(row+4, col, "ÂÑÆÇ :", TR_RES_POIS, &f, 0);
3064 display_flag_aux(row+5, col, "ÂÑÁ®¸÷:", TR_RES_LITE, &f, 0);
3065 display_flag_aux(row+6, col, "ÂѰŹõ:", TR_RES_DARK, &f, 0);
3066 display_flag_aux(row+7, col, "ÂÑÇËÊÒ:", TR_RES_SHARDS, &f, 0);
3067 display_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", TR_RES_BLIND, &f, 0);
3068 display_flag_aux(row+9, col, "ÂѺ®Íð:", TR_RES_CONF, &f, 0);
3070 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3071 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3072 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3073 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3074 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3075 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3076 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3077 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3078 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3079 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3080 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3081 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3082 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3083 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3092 display_player_equippy(row-2, col+8, 0);
3094 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3097 display_flag_aux(row+0, col, "Âѹ첻:", TR_RES_SOUND, &f, 0);
3098 display_flag_aux(row+1, col, "ÂÑÃϹö:", TR_RES_NETHER, &f, 0);
3099 display_flag_aux(row+2, col, "ÂÑ°øº®:", TR_RES_NEXUS, &f, 0);
3100 display_flag_aux(row+3, col, "ÂÑ¥«¥ª:", TR_RES_CHAOS, &f, 0);
3101 display_flag_aux(row+4, col, "ÂÑÎô²½:", TR_RES_DISEN, &f, 0);
3102 display_flag_aux(row+5, col, "ÂѶ²ÉÝ:", TR_RES_FEAR, &f, 0);
3103 display_flag_aux(row+6, col, "È¿¼Í :", TR_REFLECT, &f, 0);
3104 display_flag_aux(row+7, col, "²Ð±ê¥ª:", TR_SH_FIRE, &f, 0);
3105 display_flag_aux(row+8, col, "Åŵ¤¥ª:", TR_SH_ELEC, &f, 0);
3106 display_flag_aux(row+9, col, "Î䵤¥ª:", TR_SH_COLD, &f, 0);
3108 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3109 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3110 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3111 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3112 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3113 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3114 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3115 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3116 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3117 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3126 display_player_equippy(row-2, col+12, 0);
3128 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3131 display_flag_aux(row+0, col, "²Ã® :", TR_SPEED, &f, 0);
3132 display_flag_aux(row+1, col, "ÂÑËãáã :", TR_FREE_ACT, &f, 0);
3133 display_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", TR_SEE_INVIS, &f, 0);
3134 display_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", TR_HOLD_LIFE, &f, 0);
3135 display_flag_aux(row+4, col, "·Ù¹ð :", TR_WARNING, &f, 0);
3136 display_flag_aux(row+5, col, "Ãپò½ :", TR_SLOW_DIGEST, &f, 0);
3137 display_flag_aux(row+6, col, "µÞ²óÉü :", TR_REGEN, &f, 0);
3138 display_flag_aux(row+7, col, "ÉâÍ· :", TR_FEATHER, &f, 0);
3139 display_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", TR_LITE, &f, 0);
3140 display_flag_aux(row+9, col, "¼ö¤¤ :", 0, &f, DP_CURSE);
3142 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3143 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3144 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3145 display_flag_aux(row+3, col, "Hold Life :", TR_HOLD_LIFE, &f, 0);
3146 display_flag_aux(row+4, col, "Warning :", TR_WARNING, &f, 0);
3147 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3148 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3149 display_flag_aux(row+7, col, "Levitation:", TR_FEATHER, &f, 0);
3150 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE, &f, 0);
3151 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3158 * Special display, part 2
3160 static void display_player_other_flag_info(void)
3167 /* Extract flags and store */
3168 player_flags(f.player_flags);
3169 tim_player_flags(f.tim_player_flags);
3170 player_immunity(f.player_imm);
3171 tim_player_immunity(f.tim_player_imm);
3172 known_obj_immunity(f.known_obj_imm);
3173 player_vuln_flags(f.player_vuln);
3180 display_player_equippy(row-2, col+12, DP_WP);
3182 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3185 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_SLAY_EVIL, &f, DP_WP);
3186 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3187 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_SLAY_UNDEAD, &f, DP_WP);
3188 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3189 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_SLAY_DEMON, &f, DP_WP);
3190 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3191 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_SLAY_DRAGON, &f, DP_WP);
3192 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3193 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_SLAY_HUMAN, &f, DP_WP);
3194 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3195 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_SLAY_ANIMAL, &f, DP_WP);
3196 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3197 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_SLAY_ORC, &f, DP_WP);
3198 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3199 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_SLAY_TROLL, &f, DP_WP);
3200 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3201 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_SLAY_GIANT, &f, DP_WP);
3202 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3203 display_flag_aux(row+ 9, col, "Íϲò :", TR_BRAND_ACID, &f, DP_WP);
3204 display_flag_aux(row+10, col, "ÅÅ·â :", TR_BRAND_ELEC, &f, DP_WP);
3205 display_flag_aux(row+11, col, "¾Æ´þ :", TR_BRAND_FIRE, &f, DP_WP);
3206 display_flag_aux(row+12, col, "Åà·ë :", TR_BRAND_COLD, &f, DP_WP);
3207 display_flag_aux(row+13, col, "ÆÇ»¦ :", TR_BRAND_POIS, &f, DP_WP);
3208 display_flag_aux(row+14, col, "ÀÚ¤ìÌ£ :", TR_VORPAL, &f, DP_WP);
3209 display_flag_aux(row+15, col, "ÃÏ¿Ì :", TR_IMPACT, &f, DP_WP);
3210 display_flag_aux(row+16, col, "µÛ·ì :", TR_VAMPIRIC, &f, DP_WP);
3211 display_flag_aux(row+17, col, "¥«¥ª¥¹¸ú²Ì:", TR_CHAOTIC, &f, DP_WP);
3212 display_flag_aux(row+18, col, "ÍýÎÏ :", TR_FORCE_WEAPON, &f, DP_WP);
3214 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3215 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3216 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3217 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3218 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3219 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3220 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3221 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3222 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3223 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3224 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3225 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3226 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3227 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3228 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3229 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3230 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3231 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3232 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3233 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3234 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3235 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3236 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3237 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3238 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3239 display_flag_aux(row+16, col, "Vampiric :", TR_VAMPIRIC, &f, DP_WP);
3240 display_flag_aux(row+17, col, "Chaotic :", TR_CHAOTIC, &f, DP_WP);
3241 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3250 display_player_equippy(row-2, col+12, 0);
3251 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3254 display_flag_aux(row+ 0, col, "¥Æ¥ì¥Ñ¥·¡¼:", TR_TELEPATHY, &f, 0);
3255 display_flag_aux(row+ 1, col, "¼Ù°ESP :", TR_ESP_EVIL, &f, 0);
3256 display_flag_aux(row+ 2, col, "̵À¸ÊªESP :", TR_ESP_NONLIVING, &f, 0);
3257 display_flag_aux(row+ 3, col, "Á±ÎÉESP :", TR_ESP_GOOD, &f, 0);
3258 display_flag_aux(row+ 4, col, "ÉÔ»àESP :", TR_ESP_UNDEAD, &f, 0);
3259 display_flag_aux(row+ 5, col, "°ËâESP :", TR_ESP_DEMON, &f, 0);
3260 display_flag_aux(row+ 6, col, "ζESP :", TR_ESP_DRAGON, &f, 0);
3261 display_flag_aux(row+ 7, col, "¿Í´ÖESP :", TR_ESP_HUMAN, &f, 0);
3262 display_flag_aux(row+ 8, col, "ưʪESP :", TR_ESP_ANIMAL, &f, 0);
3263 display_flag_aux(row+ 9, col, "¥ª¡¼¥¯ESP :", TR_ESP_ORC, &f, 0);
3264 display_flag_aux(row+10, col, "¥È¥í¥ëESP :", TR_ESP_TROLL, &f, 0);
3265 display_flag_aux(row+11, col, "µð¿ÍESP :", TR_ESP_GIANT, &f, 0);
3267 display_flag_aux(row+13, col, "ÏÓÎÏ°Ý»ý :", TR_SUST_STR, &f, 0);
3268 display_flag_aux(row+14, col, "ÃÎÎÏ°Ý»ý :", TR_SUST_INT, &f, 0);
3269 display_flag_aux(row+15, col, "¸¤µ°Ý»ý :", TR_SUST_WIS, &f, 0);
3270 display_flag_aux(row+16, col, "´ïÍÑ°Ý»ý :", TR_SUST_DEX, &f, 0);
3271 display_flag_aux(row+17, col, "Âѵװݻý :", TR_SUST_CON, &f, 0);
3272 display_flag_aux(row+18, col, "Ì¥ÎÏ°Ý»ý :", TR_SUST_CHR, &f, 0);
3274 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3275 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3276 display_flag_aux(row+ 2, col, "ESP Noliv.:", TR_ESP_NONLIVING, &f, 0);
3277 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3278 display_flag_aux(row+ 4, col, "ESP Undead:", TR_ESP_UNDEAD, &f, 0);
3279 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3280 display_flag_aux(row+ 6, col, "ESP Dragon:", TR_ESP_DRAGON, &f, 0);
3281 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3282 display_flag_aux(row+ 8, col, "ESP Animal:", TR_ESP_ANIMAL, &f, 0);
3283 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3284 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3285 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3287 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3288 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3289 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3290 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3291 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3292 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3299 col = col + 12 + 17;
3301 display_player_equippy(row-2, col+14, 0);
3303 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3306 display_flag_aux(row+ 0, col, "Äɲù¶·â :", TR_BLOWS, &f, 0);
3307 display_flag_aux(row+ 1, col, "ºÎ·¡ :", TR_TUNNEL, &f, 0);
3308 display_flag_aux(row+ 2, col, "ÀÖ³°Àþ»ëÎÏ :", TR_INFRA, &f, 0);
3309 display_flag_aux(row+ 3, col, "ËâË¡Æ»¶ñ»ÙÇÛ:", TR_MAGIC_MASTERY, &f, 0);
3310 display_flag_aux(row+ 4, col, "±£Ì© :", TR_STEALTH, &f, 0);
3311 display_flag_aux(row+ 5, col, "õº÷ :", TR_SEARCH, &f, 0);
3313 display_flag_aux(row+ 7, col, "¾èÇÏ :", TR_RIDING, &f, 0);
3314 display_flag_aux(row+ 8, col, "ÅêÚ³ :", TR_THROW, &f, 0);
3315 display_flag_aux(row+ 9, col, "½ËÊ¡ :", TR_BLESSED, &f, 0);
3316 display_flag_aux(row+10, col, "È¿¥Æ¥ì¥Ý¡¼¥È:", TR_NO_TELE, &f, 0);
3317 display_flag_aux(row+11, col, "È¿ËâË¡ :", TR_NO_MAGIC, &f, 0);
3318 display_flag_aux(row+12, col, "¾ÃÈñËâÎϸº¾¯:", TR_DEC_MANA, &f, 0);
3320 display_flag_aux(row+14, col, "·Ð¸³Ã͸º¾¯ :", TR_DRAIN_EXP, &f, 0);
3321 display_flag_aux(row+15, col, "Íð¥Æ¥ì¥Ý¡¼¥È:", TR_TELEPORT, &f, 0);
3322 display_flag_aux(row+16, col, "È¿´¶ :", TR_AGGRAVATE, &f, 0);
3323 display_flag_aux(row+17, col, "ÂÀ¸Å¤Î±åÇ° :", TR_TY_CURSE, &f, 0);
3325 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3326 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3327 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3328 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3329 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3330 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3332 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3333 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3334 display_flag_aux(row+ 9, col, "Blessed :", TR_BLESSED, &f, 0);
3335 display_flag_aux(row+10, col, "No Teleport :", TR_NO_TELE, &f, 0);
3336 display_flag_aux(row+11, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3337 display_flag_aux(row+12, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3339 display_flag_aux(row+14, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3340 display_flag_aux(row+15, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3341 display_flag_aux(row+16, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3342 display_flag_aux(row+17, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3349 * Special display, part 2a
3351 static void display_player_misc_info(void)
3356 /* Display basics */
3358 put_str("̾Á° :", 1, 26);
3359 put_str("ÀÊÌ :", 3, 1);
3360 put_str("¼ï² :", 4, 1);
3361 put_str("¿¦¶È :", 5, 1);
3363 put_str("Name :", 1, 26);
3364 put_str("Sex :", 3, 1);
3365 put_str("Race :", 4, 1);
3366 put_str("Class :", 5, 1);
3369 strcpy(tmp,ap_ptr->title);
3376 strcat(tmp,player_name);
3378 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3379 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3380 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3381 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3383 /* Display extras */
3385 put_str("¥ì¥Ù¥ë:", 6, 1);
3386 put_str("£È£Ð :", 7, 1);
3387 put_str("£Í£Ð :", 8, 1);
3389 put_str("Level :", 6, 1);
3390 put_str("Hits :", 7, 1);
3391 put_str("Mana :", 8, 1);
3395 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3396 c_put_str(TERM_L_BLUE, buf, 6, 9);
3397 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3398 c_put_str(TERM_L_BLUE, buf, 7, 9);
3399 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3400 c_put_str(TERM_L_BLUE, buf, 8, 9);
3405 * Special display, part 2b
3407 * How to print out the modifications and sustains.
3408 * Positive mods with no sustain will be light green.
3409 * Positive mods with a sustain will be dark green.
3410 * Sustains (with no modification) will be a dark green 's'.
3411 * Negative mods (from a curse) will be red.
3412 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3413 * No mod, no sustain, will be a slate '.'
3415 static void display_player_stat_info(void)
3422 u32b flgs[TR_FLAG_SIZE];
3436 /* Print out the labels for the columns */
3438 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3439 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3440 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3441 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3442 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3444 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3445 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3446 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3447 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3448 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3452 /* Display the stats */
3453 for (i = 0; i < 6; i++)
3457 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3458 else r_adj = rp_ptr->r_adj[i];
3460 /* Calculate equipment adjustment */
3463 /* Icky formula to deal with the 18 barrier */
3464 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3465 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3466 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3467 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3468 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3469 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3471 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3472 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3474 if (prace_is_(RACE_ENT))
3480 if (p_ptr->lev > 25) r_adj++;
3481 if (p_ptr->lev > 40) r_adj++;
3482 if (p_ptr->lev > 45) r_adj++;
3485 if (p_ptr->lev > 25) r_adj--;
3486 if (p_ptr->lev > 40) r_adj--;
3487 if (p_ptr->lev > 45) r_adj--;
3493 e_adj -= cp_ptr->c_adj[i];
3494 e_adj -= ap_ptr->a_adj[i];
3496 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3497 /* Reduced name of stat */
3498 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3500 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3503 /* Internal "natural" max value. Maxes at 18/100 */
3504 /* This is useful to see if you are maxed out */
3505 cnv_stat(p_ptr->stat_max[i], buf);
3506 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3509 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3511 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3514 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3516 /* Race, class, and equipment modifiers */
3517 (void)sprintf(buf, "%3d", r_adj);
3518 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3519 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3520 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3521 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3522 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3523 (void)sprintf(buf, "%3d", (int)e_adj);
3524 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3526 /* Actual maximal modified value */
3527 cnv_stat(p_ptr->stat_top[i], buf);
3528 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3530 /* Only display stat_use if not maximal */
3531 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3533 cnv_stat(p_ptr->stat_use[i], buf);
3534 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3539 col = stat_col + 41;
3541 /* Header and Footer */
3542 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3544 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3546 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3550 /* Process equipment */
3551 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3554 o_ptr = &inventory[i];
3556 /* Acquire "known" flags */
3557 object_flags_known(o_ptr, flgs);
3559 /* Initialize color based of sign of pval. */
3560 for (stat = 0; stat < 6; stat++)
3567 if (have_flag(flgs, stat))
3573 if (o_ptr->pval > 0)
3579 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3582 if (have_flag(flgs, stat + TR_SUST_STR))
3584 /* Dark green for sustained stats */
3589 if (o_ptr->pval < 0)
3595 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3600 else if (have_flag(flgs, stat + TR_SUST_STR))
3602 /* Dark green "s" */
3607 /* Dump proper character */
3608 Term_putch(col, row + stat+1, a, c);
3619 for (stat = 0; stat < 6; stat++)
3626 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3632 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3633 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3634 if (p_ptr->tsuyoshi) dummy += 4;
3636 else if (stat == A_WIS || stat == A_INT)
3638 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3639 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3641 else if (stat == A_DEX)
3643 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3644 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3645 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3647 else if (stat == A_CON)
3649 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3650 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3651 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3652 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3653 if (p_ptr->tsuyoshi) dummy += 4;
3655 else if (stat == A_CHR)
3657 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3658 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3659 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3660 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3661 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3662 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3678 if (dummy < 10) c = '0' + dummy;
3688 if (dummy > -10) c = '0' - dummy;
3695 if (have_flag(flgs, stat + TR_SUST_STR))
3697 /* Dark green "s" */
3704 Term_putch(col, row + stat+1, a, c);
3710 * Display the character on the screen (various modes)
3712 * The top one and bottom two lines are left blank.
3714 * Mode 0 = standard display with skills
3715 * Mode 1 = standard display with history
3716 * Mode 2 = summary of various things
3717 * Mode 3 = summary of various things (part 2)
3718 * Mode 4 = mutations
3720 void display_player(int mode)
3729 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3738 if ((mode == 0) || (mode == 1))
3740 /* Name, Sex, Race, Class */
3742 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3744 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3747 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3748 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3749 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3750 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3755 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3757 strcpy(tmp, realm_names[p_ptr->realm1]);
3758 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3761 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3762 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3764 /* Age, Height, Weight, Social */
3765 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
3767 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
3768 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3769 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3770 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3772 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3773 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3774 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3775 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3777 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3780 /* Display the stats */
3781 for (i = 0; i < 6; i++)
3783 /* Special treatment of "injured" stats */
3784 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3788 /* Use lowercase stat name */
3789 put_str(stat_names_reduced[i], 3 + i, 53);
3791 /* Get the current stat */
3792 value = p_ptr->stat_use[i];
3794 /* Obtain the current stat (modified) */
3795 cnv_stat(value, buf);
3797 /* Display the current stat (modified) */
3798 c_put_str(TERM_YELLOW, buf, 3 + i, 60);
3800 /* Acquire the max stat */
3801 value = p_ptr->stat_top[i];
3803 /* Obtain the maximum stat (modified) */
3804 cnv_stat(value, buf);
3806 /* Display the maximum stat (modified) */
3807 c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
3810 /* Normal treatment of "normal" stats */
3813 /* Assume uppercase stat name */
3814 put_str(stat_names[i], 3 + i, 53);
3816 /* Obtain the current stat (modified) */
3817 cnv_stat(p_ptr->stat_use[i], buf);
3819 /* Display the current stat (modified) */
3820 c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
3823 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3826 c_put_str(TERM_WHITE, "!", 3 + i, 58);
3828 c_put_str(TERM_WHITE, "!", 3 + i, 58-2);
3833 /* Display "history" info */
3839 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
3841 put_str("(Character Background)", 11, 25);
3844 for (i = 0; i < 4; i++)
3846 put_str(p_ptr->history[i], i + 12, 10);
3851 if (p_ptr->is_dead && p_ptr->total_winner)
3854 strcpy(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£");
3856 strcpy(statmsg, "...You retired from the adventure after the winning.");
3859 else if (p_ptr->is_dead)
3864 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), p_ptr->died_from);
3866 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3869 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3871 /* Get the quest text */
3872 /* Bewere that INIT_ASSIGN resets the cur_num. */
3873 init_flags = INIT_ASSIGN;
3875 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3878 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3880 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3886 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
3888 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3892 else if (character_dungeon)
3897 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
3899 sprintf(statmsg, "...Now, you are in %s.", map_name());
3902 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3904 /* Clear the text */
3905 /* Must be done before doing INIT_SHOW_TEXT */
3906 for (i = 0; i < 10; i++)
3908 quest_text[i][0] = '\0';
3910 quest_text_line = 0;
3912 /* Get the quest text */
3913 init_flags = INIT_SHOW_TEXT;
3915 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3918 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
3920 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
3926 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
3928 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
3935 char temp[64*2], *t;
3936 roff_to_buf(statmsg, 60, temp, sizeof(temp));
3938 for(i=0 ; i<2 ; i++)
3944 put_str(t, i + 5 + 12, 10);
3952 /* Display "various" info */
3955 display_player_middle();
3956 display_player_various();
3963 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
3966 display_player_misc_info();
3967 display_player_stat_info();
3968 display_player_flag_info();
3974 display_player_other_flag_info();
3979 do_cmd_knowledge_mutations();
3987 static void dump_aux_display_player(FILE *fff)
3994 /* Display player */
3997 /* Dump part of the screen */
3998 for (y = 1; y < 22; y++)
4001 for (x = 0; x < 79; x++)
4003 /* Get the attr/char */
4004 (void)(Term_what(x, y, &a, &c));
4010 /* End the string */
4013 /* Kill trailing spaces */
4014 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4018 fprintf(fff, "%s\n", buf);
4020 fprintf(fff, "%s\n", buf);
4025 /* Display history */
4028 /* Dump part of the screen */
4029 for (y = 10; y < 19; y++)
4032 for (x = 0; x < 79; x++)
4034 /* Get the attr/char */
4035 (void)(Term_what(x, y, &a, &c));
4041 /* End the string */
4044 /* Kill trailing spaces */
4045 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4048 fprintf(fff, "%s\n", buf);
4053 /* Display flags (part 1) */
4056 /* Dump part of the screen */
4057 for (y = 2; y < 22; y++)
4060 for (x = 0; x < 79; x++)
4062 /* Get the attr/char */
4063 (void)(Term_what(x, y, &a, &c));
4065 /* Dump it (Ignore equippy tile graphic) */
4072 /* End the string */
4075 /* Kill trailing spaces */
4076 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4079 fprintf(fff, "%s\n", buf);
4084 /* Display flags (part 2) */
4087 /* Dump part of the screen */
4088 for (y = 1; y < 22; y++)
4091 for (x = 0; x < 79; x++)
4093 /* Get the attr/char */
4094 (void)(Term_what(x, y, &a, &c));
4096 /* Dump it (Ignore equippy tile graphic) */
4103 /* End the string */
4106 /* Kill trailing spaces */
4107 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4110 fprintf(fff, "%s\n", buf);
4113 for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
4116 for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
4124 static void dump_aux_pet(FILE *fff)
4130 for (i = m_max - 1; i >= 1; i--)
4132 monster_type *m_ptr = &m_list[i];
4134 if (!m_ptr->r_idx) continue;
4135 if (!is_pet(m_ptr)) continue;
4136 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4140 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4142 fprintf(fff, "\n [leading pets]\n\n");
4146 monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
4147 fprintf(fff, "%s\n", pet_name);
4150 if (pet) fprintf(fff, "\n");
4157 static void dump_aux_class_special(FILE *fff)
4159 if (p_ptr->pclass == CLASS_BLUE_MAGE)
4166 int spellnum[MAX_MONSPELLS];
4167 s32b f4 = 0, f5 = 0, f6 = 0;
4172 for (i=0;i<60;i++) { p[i][0] = '\0'; }
4175 strcat(p[col], "\n [³Ø½¬ºÑ¤ß¤ÎÀÄËâË¡]\n");
4177 strcat(p[col], "\n [Learned blue magic]\n");
4184 set_rf_masks(&f4, &f5, &f6, j);
4187 case MONSPELL_TYPE_BOLT:
4189 strcat(p[col], "\n [¥Ü¥ë¥È·¿]\n");
4191 strcat(p[col], "\n [Bolt type]\n");
4195 case MONSPELL_TYPE_BALL:
4197 strcat(p[col], "\n [¥Ü¡¼¥ë·¿]\n");
4199 strcat(p[col], "\n [Ball type]\n");
4203 case MONSPELL_TYPE_BREATH:
4205 strcat(p[col], "\n [¥Ö¥ì¥¹·¿]\n");
4207 strcat(p[col], "\n [ Breath ]\n");
4211 case MONSPELL_TYPE_SUMMON:
4213 strcat(p[col], "\n [¾¤´ËâË¡]\n");
4215 strcat(p[col], "\n [Summonning]\n");
4219 case MONSPELL_TYPE_OTHER:
4221 strcat(p[col], "\n [ ¤½¤Î¾ ]\n");
4223 strcat(p[col], "\n [Other type]\n");
4228 for (i = 0, num = 0; i < 32; i++)
4230 if ((0x00000001 << i) & f4) spellnum[num++] = i;
4234 if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
4238 if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
4243 strcat(p[col], " ");
4245 for (i = 0; i < num; i++)
4247 if (p_ptr->magic_num2[spellnum[i]])
4250 /* Dump blue magic */
4251 l1 = strlen(p[col]);
4252 l2 = strlen(monster_powers_short[spellnum[i]]);
4253 if ((l1 + l2) >= 75)
4255 strcat(p[col], "\n");
4257 strcat(p[col], " ");
4259 strcat(p[col], monster_powers_short[spellnum[i]]);
4260 strcat(p[col], ", ");
4267 strcat(p[col], "¤Ê¤·");
4269 strcat(p[col], "None");
4274 if (p[col][strlen(p[col])-2] == ',')
4276 p[col][strlen(p[col])-2] = '\0';
4280 p[col][strlen(p[col])-10] = '\0';
4284 strcat(p[col], "\n");
4287 for (i=0;i<=col;i++)
4298 static void dump_aux_quest(FILE *fff)
4306 fprintf(fff, "\n\n [¥¯¥¨¥¹¥È¾ðÊó]\n");
4308 fprintf(fff, "\n\n [Quest information]\n");
4311 /* Allocate Memory */
4312 C_MAKE(quest_num, max_quests, int);
4314 /* Sort by compete level */
4315 for (i = 1; i < max_quests; i++) quest_num[i] = i;
4316 ang_sort_comp = ang_sort_comp_quest_num;
4317 ang_sort_swap = ang_sort_swap_quest_num;
4318 ang_sort(quest_num, &dummy, max_quests);
4320 /* Dump Quest Information */
4322 do_cmd_knowledge_quests_completed(fff, quest_num);
4324 do_cmd_knowledge_quests_failed(fff, quest_num);
4327 C_KILL(quest_num, max_quests, int);
4334 static void dump_aux_last_message(FILE *fff)
4338 if (!p_ptr->total_winner)
4343 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4345 fprintf(fff, "\n [Last messages]\n\n");
4347 for (i = MIN(message_num(), 30); i >= 0; i--)
4349 fprintf(fff,"> %s\n",message_str((s16b)i));
4354 /* Hack -- *Winning* message */
4355 else if (p_ptr->last_message)
4358 fprintf(fff, "\n [*¾¡Íø*¥á¥Ã¥»¡¼¥¸]\n\n");
4360 fprintf(fff, "\n [*Winning* message]\n\n");
4362 fprintf(fff," %s\n", p_ptr->last_message);
4371 static void dump_aux_recall(FILE *fff)
4376 fprintf(fff, "\n\n [µ¢´Ô¾ì½ê]\n\n");
4378 fprintf(fff, "\n\n [Recall Depth]\n\n");
4381 for (y = 1; y < max_d_idx; y++)
4385 if (!d_info[y].maxdepth) continue;
4386 if (!max_dlv[y]) continue;
4387 if (d_info[y].final_guardian)
4389 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4391 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4394 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4396 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4405 static void dump_aux_options(FILE *fff)
4408 fprintf(fff, "\n [¥ª¥×¥·¥ç¥óÀßÄê]\n");
4410 fprintf(fff, "\n [Option settings]\n");
4416 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4418 fprintf(fff, "\n Preserve Mode: ON");
4423 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4425 fprintf(fff, "\n Preserve Mode: OFF");
4429 if (ironman_small_levels)
4431 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4433 fprintf(fff, "\n Small Levels: ALWAYS");
4436 else if (always_small_levels)
4438 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4440 fprintf(fff, "\n Small Levels: ON");
4443 else if (small_levels)
4445 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4447 fprintf(fff, "\n Small Levels: ENABLED");
4452 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4454 fprintf(fff, "\n Small Levels: OFF");
4460 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4462 fprintf(fff, "\n Vanilla Town: ON");
4467 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4469 fprintf(fff, "\n Lite Town: ON");
4475 fprintf(fff, "\n Ź¤Ê¤·: ON");
4477 fprintf(fff, "\n No Shops: ON");
4481 if (ironman_downward)
4483 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4485 fprintf(fff, "\n Diving Only: ON");
4491 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°: ON");
4493 fprintf(fff, "\n Unusual Rooms: ON");
4497 if (ironman_nightmare)
4499 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4501 fprintf(fff, "\n Nightmare Mode: ON");
4505 if (ironman_empty_levels)
4507 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4509 fprintf(fff, "\n Arena Levels: ALWAYS");
4512 else if (empty_levels)
4514 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ENABLED");
4516 fprintf(fff, "\n Arena Levels: ENABLED");
4521 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4523 fprintf(fff, "\n Arena Levels: OFF");
4531 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤¤¤Þ¤¹¡£");
4533 fprintf(fff, "\n You have done something illegal.");
4543 static void dump_aux_arena(FILE *fff)
4545 if (lite_town || vanilla_town) return;
4547 if (p_ptr->arena_number < 0)
4549 if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
4552 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4554 fprintf(fff, "\n Arena: Defeated\n");
4560 fprintf(fff, "\n Æ®µ»¾ì: %d²óÀï¤Ç%s¤ÎÁ°¤ËÇÔËÌ\n", -p_ptr->arena_number,
4561 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
4563 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
4564 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
4565 -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
4569 else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
4572 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4574 fprintf(fff, "\n Arena: True Champion\n");
4577 else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
4580 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4582 fprintf(fff, "\n Arena: Champion\n");
4588 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4590 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");
4601 static void dump_aux_monsters(FILE *fff)
4603 /* Monsters slain */
4606 unsigned long uniq_total = 0;
4607 unsigned long norm_total = 0;
4610 /* Sort by monster level */
4614 fprintf(fff, "\n [Åݤ·¤¿¥â¥ó¥¹¥¿¡¼]\n\n");
4616 fprintf(fff, "\n [Defeated monsters]\n\n");
4619 /* Allocate the "who" array */
4620 C_MAKE(who, max_r_idx, s16b);
4622 /* Count monster kills */
4623 for (k = 1; k < max_r_idx; k++)
4625 monster_race *r_ptr = &r_info[k];
4627 /* Ignore unused index */
4628 if (!r_ptr->name) continue;
4630 /* Unique monsters */
4631 if (r_ptr->flags1 & RF1_UNIQUE)
4633 bool dead = (r_ptr->max_num == 0);
4638 /* Add a unique monster to the list */
4639 who[uniq_total++] = k;
4643 /* Normal monsters */
4646 if (r_ptr->r_pkills > 0)
4648 norm_total += r_ptr->r_pkills;
4654 /* No monsters is defeated */
4658 fprintf(fff,"¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4660 fprintf(fff,"You have defeated no enemies yet.\n");
4664 /* Defeated more than one normal monsters */
4665 else if (uniq_total == 0)
4668 fprintf(fff,"%luÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", norm_total);
4670 fprintf(fff,"You have defeated %lu %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
4674 /* Defeated more than one unique monsters */
4675 else /* if (uniq_total > 0) */
4678 fprintf(fff, "%luÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ò´Þ¤à¡¢¹ç·×%luÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", uniq_total, norm_total);
4680 fprintf(fff, "You have defeated %lu %s including %lu unique monster%s in total.\n", norm_total, norm_total == 1 ? "enemy" : "enemies", uniq_total, (uniq_total == 1 ? "" : "s"));
4684 /* Select the sort method */
4685 ang_sort_comp = ang_sort_comp_hook;
4686 ang_sort_swap = ang_sort_swap_hook;
4688 /* Sort the array by dungeon depth of monsters */
4689 ang_sort(who, &why, uniq_total);
4692 fprintf(fff, "\n¡Ô¾å°Ì%luÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¡Õ\n", MIN(uniq_total, 10));
4694 fprintf(fff, "\n< Unique monsters top %lu >\n", MIN(uniq_total, 10));
4698 for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
4700 monster_race *r_ptr = &r_info[who[k]];
4703 fprintf(fff, " %-40s (¥ì¥Ù¥ë%3d)\n", (r_name + r_ptr->name), r_ptr->level);
4705 fprintf(fff, " %-40s (level %3d)\n", (r_name + r_ptr->name), r_ptr->level);
4711 /* Free the "who" array */
4712 C_KILL(who, max_r_idx, s16b);
4719 static void dump_aux_race_history(FILE *fff)
4721 if (p_ptr->old_race1 || p_ptr->old_race2)
4726 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4728 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4730 for (i = 0; i < MAX_RACES; i++)
4732 if (p_ptr->start_race == i) continue;
4735 if (!(p_ptr->old_race1 & 1L << i)) continue;
4739 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4742 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4744 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4754 static void dump_aux_realm_history(FILE *fff)
4756 if (p_ptr->old_realm)
4760 for (i = 0; i < MAX_MAGIC; i++)
4762 if (!(p_ptr->old_realm & 1L << i)) continue;
4764 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4766 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4776 static void dump_aux_virtues(FILE *fff)
4779 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4781 fprintf(fff, "\n\n [Virtues]\n\n");
4785 fprintf(fff, "°À : %s\n", your_alignment());
4787 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4798 static void dump_aux_mutations(FILE *fff)
4800 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4803 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4805 fprintf(fff, "\n\n [Mutations]\n\n");
4808 dump_mutations(fff);
4811 /* Skip some lines */
4812 fprintf(fff, "\n\n");
4819 static void dump_aux_equipment_inventory(FILE *fff)
4822 char o_name[MAX_NLEN];
4824 /* Dump the equipment */
4828 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷]\n\n");
4830 fprintf(fff, " [Character Equipment]\n\n");
4833 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4835 object_desc(o_name, &inventory[i], 0);
4836 if ((i == INVEN_LARM) && p_ptr->ryoute)
4838 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4840 strcpy(o_name, "(wielding with two-hands)");
4843 fprintf(fff, "%c) %s\n",
4844 index_to_label(i), o_name);
4846 fprintf(fff, "\n\n");
4849 /* Dump the inventory */
4851 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ]\n\n");
4853 fprintf(fff, " [Character Inventory]\n\n");
4856 for (i = 0; i < INVEN_PACK; i++)
4858 /* Don't dump the empty slots */
4859 if (!inventory[i].k_idx) break;
4861 /* Dump the inventory slots */
4862 object_desc(o_name, &inventory[i], 0);
4863 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
4866 /* Add an empty line */
4867 fprintf(fff, "\n\n");
4874 static void dump_aux_home_museum(FILE *fff)
4876 char o_name[MAX_NLEN];
4879 /* Do we need it?? */
4880 /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
4882 /* Print the home */
4883 st_ptr = &town[1].store[STORE_HOME];
4885 /* Home -- if anything there */
4886 if (st_ptr->stock_num)
4892 fprintf(fff, " [²æ¤¬²È¤Î¥¢¥¤¥Æ¥à]\n");
4894 fprintf(fff, " [Home Inventory]\n");
4897 /* Dump all available items */
4898 for (i = 0; i < st_ptr->stock_num; i++)
4902 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4904 fprintf(fff, "\n ( page %d )\n", x++);
4906 object_desc(o_name, &st_ptr->stock[i], 0);
4907 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4910 /* Add an empty line */
4911 fprintf(fff, "\n\n");
4915 /* Print the home */
4916 st_ptr = &town[1].store[STORE_MUSEUM];
4918 /* Home -- if anything there */
4919 if (st_ptr->stock_num)
4925 fprintf(fff, " [Çîʪ´Û¤Î¥¢¥¤¥Æ¥à]\n");
4927 fprintf(fff, " [Museum]\n");
4930 /* Dump all available items */
4931 for (i = 0; i < st_ptr->stock_num; i++)
4934 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4935 object_desc(o_name, &st_ptr->stock[i], 0);
4936 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4938 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4939 object_desc(o_name, &st_ptr->stock[i], 0);
4940 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4945 /* Add an empty line */
4946 fprintf(fff, "\n\n");
4952 * Output the character dump to a file
4954 errr make_character_dump(FILE *fff)
4957 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4958 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4960 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4961 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4966 dump_aux_display_player(fff);
4967 dump_aux_last_message(fff);
4968 dump_aux_options(fff);
4969 dump_aux_recall(fff);
4970 dump_aux_quest(fff);
4971 dump_aux_arena(fff);
4972 dump_aux_monsters(fff);
4973 dump_aux_virtues(fff);
4974 dump_aux_race_history(fff);
4975 dump_aux_realm_history(fff);
4976 dump_aux_class_special(fff);
4977 dump_aux_mutations(fff);
4979 dump_aux_equipment_inventory(fff);
4980 dump_aux_home_museum(fff);
4983 fprintf(fff, " [¥Á¥§¥Ã¥¯¥µ¥à: \"%s\"]\n\n", get_check_sum());
4985 fprintf(fff, " [Check Sum: \"%s\"]\n\n", get_check_sum());
4992 * Hack -- Dump a character description file
4994 * XXX XXX XXX Allow the "full" flag to dump additional info,
4995 * and trigger its usage from various places in the code.
4997 errr file_character(cptr name)
5003 /* Build the filename */
5004 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
5006 /* File type is "TEXT" */
5007 FILE_TYPE(FILE_TYPE_TEXT);
5009 /* Check for existing file */
5010 fd = fd_open(buf, O_RDONLY);
5017 /* Close the file */
5022 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
5024 (void)sprintf(out_val, "Replace existing file %s? ", buf);
5029 if (get_check_strict(out_val, CHECK_NO_HISTORY)) fd = -1;
5032 /* Open the non-existing file */
5033 if (fd < 0) fff = my_fopen(buf, "w");
5040 prt("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", 0, 0);
5042 prt("Character dump failed!", 0, 0);
5051 (void)make_character_dump(fff);
5059 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
5061 msg_print("Character dump successful.");
5072 * Display single line of on-line help file
5074 * You can insert some special color tag to change text color.
5076 * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
5078 * A colored segment is between "[[[[y|" and the last "|".
5079 * You can use any single character in place of the "|".
5081 static void show_file_aux_line(cptr str, int cy, cptr shower)
5083 static const char tag_str[] = "[[[[";
5084 byte color = TERM_WHITE;
5092 /* Make a lower case version of str for searching */
5097 /* Initial cursor position */
5098 Term_gotoxy(cx, cy);
5100 for (i = 0; str[i];)
5102 int len = strlen(&str[i]);
5103 int showercol = len + 1;
5104 int bracketcol = len + 1;
5108 /* Search for a shower string in the line */
5111 ptr = my_strstr(&lcstr[i], shower);
5112 if (ptr) showercol = ptr - &lcstr[i];
5115 /* Search for a color segment tag */
5116 ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
5117 if (ptr) bracketcol = ptr - &str[i];
5119 /* A color tag is found */
5120 if (bracketcol < endcol) endcol = bracketcol;
5122 /* The shower string is found before the color tag */
5123 if (showercol < endcol) endcol = showercol;
5125 /* Print a segment of the line */
5126 Term_addstr(endcol, color, &str[i]);
5130 /* Shower string? */
5131 if (endcol == showercol)
5133 int showerlen = strlen(shower);
5135 /* Print the shower string in yellow */
5136 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
5141 /* Colored segment? */
5142 else if (endcol == bracketcol)
5146 /* Found the end of colored segment */
5149 /* Now looking for an another tag_str */
5152 /* Set back to the default color */
5157 /* Found a tag_str, and get a tag color */
5158 i += sizeof(tag_str)-1;
5161 color = color_char_to_attr(str[i]);
5163 /* Illegal color tag */
5164 if (color == 255 || str[i+1] == '\0')
5166 /* Illegal color tag */
5169 /* Print the broken tag as a string */
5170 Term_addstr(-1, TERM_WHITE, tag_str);
5171 cx += sizeof(tag_str)-1;
5175 /* Skip the color tag */
5178 /* Now looking for a close tag */
5181 /* Skip the close-tag-indicator */
5187 } /* for (i = 0; str[i];) */
5189 /* Clear rest of line */
5190 Term_erase(cx, cy, 255);
5195 * Recursive file perusal.
5197 * Process various special text in the input file, including
5198 * the "menu" structures used by the "help file" system.
5200 * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
5202 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
5206 /* Number of "real" lines passed by */
5209 /* Number of "real" lines in the file */
5212 /* Backup value for "line" */
5215 /* This screen has sub-screens */
5218 /* Current help file */
5221 /* Find this string (if any) */
5224 /* Jump to this tag */
5227 /* Hold strings to find/show */
5228 char finder_str[81];
5229 char shower_str[81];
5231 /* String to show */
5235 char filename[1024];
5237 /* Describe this thing */
5243 /* General buffer */
5246 /* Sub-menu information */
5249 bool reverse = (line < 0);
5253 Term_get_size(&wid, &hgt);
5257 strcpy(finder_str, "");
5260 strcpy(shower_str, "");
5263 strcpy(caption, "");
5265 /* Wipe the hooks */
5266 for (i = 0; i < 68; i++)
5271 /* Copy the filename */
5272 strcpy(filename, name);
5274 n = strlen(filename);
5276 /* Extract the tag from the filename */
5277 for (i = 0; i < n; i++)
5279 if (filename[i] == '#')
5282 tag = filename + i + 1;
5287 /* Redirect the name */
5290 /* Hack XXX XXX XXX */
5294 strcpy(caption, what);
5296 /* Access the "file" */
5300 fff = my_fopen(path, "r");
5303 /* Look in "help" */
5308 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5310 sprintf(caption, "Help file '%s'", name);
5314 /* Build the filename */
5315 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5318 fff = my_fopen(path, "r");
5321 /* Look in "info" */
5326 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5328 sprintf(caption, "Info file '%s'", name);
5332 /* Build the filename */
5333 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5336 fff = my_fopen(path, "r");
5339 /* Look in "info" */
5342 /* Build the filename */
5343 path_build(path, sizeof(path), ANGBAND_DIR, name);
5345 for (i = 0; path[i]; i++)
5346 if ('\\' == path[i])
5347 path[i] = PATH_SEP[0];
5351 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5353 sprintf(caption, "Info file '%s'", name);
5357 fff = my_fopen(path, "r");
5365 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5367 msg_format("Cannot open '%s'.", name);
5377 /* Pre-Parse the file */
5382 /* Read a line or stop */
5383 if (my_fgets(fff, buf, sizeof(buf))) break;
5385 /* XXX Parse "menu" items */
5386 if (prefix(str, "***** "))
5388 /* Notice "menu" requests */
5389 if ((str[6] == '[') && isalpha(str[7]))
5391 /* Extract the menu item */
5392 int k = str[7] - 'A';
5394 /* This is a menu file */
5397 if ((str[8] == ']') && (str[9] == ' '))
5399 /* Extract the menu item */
5400 strncpy(hook[k], str + 10, 31);
5402 /* Make sure it's null-terminated */
5406 /* Notice "tag" requests */
5407 else if (str[6] == '<')
5409 size_t len = strlen(str);
5411 if (str[len - 1] == '>')
5413 str[len - 1] = '\0';
5414 if (tag && streq(str + 7, tag)) line = next;
5422 /* Count the "real" lines */
5426 /* Save the number of "real" lines */
5429 /* start from bottom when reverse mode */
5430 if (line == -1) line = ((size-1)/rows)*rows;
5435 /* Display the file */
5438 /* Restart when necessary */
5439 if (line >= size - rows) line = size - rows;
5440 if (line < 0) line = 0;
5442 /* Re-open the file if needed */
5448 /* Hack -- Re-Open the file */
5449 fff = my_fopen(path, "r");
5452 if (!fff) return (FALSE);
5454 /* File has been restarted */
5458 /* Goto the selected line */
5462 if (my_fgets(fff, buf, sizeof(buf))) break;
5464 /* Skip tags/links */
5465 if (prefix(buf, "***** ")) continue;
5467 /* Count the lines */
5471 /* Dump the next 20, or rows, lines of the file */
5472 for (i = 0; i < rows; )
5476 /* Hack -- track the "first" line */
5477 if (!i) line = next;
5479 /* Get a line of the file or stop */
5480 if (my_fgets(fff, buf, sizeof(buf))) break;
5482 /* Hack -- skip "special" lines */
5483 if (prefix(buf, "***** ")) continue;
5485 /* Count the "real" lines */
5488 /* Hack -- keep searching */
5493 /* Make a lower case version of str for searching */
5494 strcpy(lc_buf, str);
5495 str_tolower(lc_buf);
5497 if (!my_strstr(lc_buf, find)) continue;
5500 /* Hack -- stop searching */
5504 show_file_aux_line(str, i + 2, shower);
5506 /* Count the printed lines */
5512 /* Clear rest of line */
5513 Term_erase(0, i + 2, 255);
5518 /* Hack -- failed search */
5528 /* Show a general "title" */
5533 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5535 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5538 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5539 caption, line, size), 0, 0);
5549 caption, line, size), 0, 0);
5552 /* Prompt -- small files */
5557 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5559 prt("[Press ESC to exit.]", hgt - 1, 0);
5564 /* Prompt -- large files */
5569 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5571 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5573 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5577 /* Get a special key code */
5578 skey = inkey_special(TRUE);
5580 /* Show the help for the help */
5583 /* Hack - prevent silly recursion */
5585 if (strcmp(name, "jhelpinfo.txt") != 0)
5586 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5588 if (strcmp(name, "helpinfo.txt") != 0)
5589 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5593 /* Hack -- try showing */
5598 prt("¶¯Ä´: ", hgt - 1, 0);
5600 prt("Show: ", hgt - 1, 0);
5603 (void)askfor(shower_str, 80);
5605 /* Make it lowercase */
5606 str_tolower(shower_str);
5609 shower = shower_str;
5612 /* Hack -- try finding */
5613 if (skey == '/' || skey == KTRL('s'))
5617 prt("¸¡º÷: ", hgt - 1, 0);
5619 prt("Find: ", hgt - 1, 0);
5623 if (askfor(finder_str, 80))
5630 /* Make finder lowercase */
5631 str_tolower(finder_str);
5634 shower = finder_str;
5638 /* Hack -- go to a specific line */
5643 prt("¹Ô: ", hgt - 1, 0);
5645 prt("Goto Line: ", hgt - 1, 0);
5650 if (askfor(tmp, 80))
5656 /* Hack -- go to the top line */
5657 if (skey == SKEY_TOP)
5662 /* Hack -- go to the bottom line */
5663 if (skey == SKEY_BOTTOM)
5665 line = ((size-1)/rows)*rows;
5668 /* Hack -- go to a specific file */
5673 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5674 strcpy(tmp, "jhelp.hlp");
5676 prt("Goto File: ", hgt - 1, 0);
5677 strcpy(tmp, "help.hlp");
5681 if (askfor(tmp, 80))
5683 if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
5687 /* Allow backing up */
5690 line = line + (reverse ? rows : -rows);
5691 if (line < 0) line = 0;
5695 if (skey == SKEY_PGUP)
5698 if (line < 0) line = 0;
5701 /* Advance a single line */
5702 if ((skey == '\n') || (skey == '\r'))
5704 line = line + (reverse ? -1 : 1);
5705 if (line < 0) line = 0;
5709 /* Move up / down */
5710 if (skey == '8' || skey == SKEY_UP)
5713 if (line < 0) line = 0;
5716 if (skey == '2' || skey == SKEY_DOWN) line++;
5718 /* Advance one page */
5721 line = line + (reverse ? -rows : rows);
5722 if (line < 0) line = 0;
5726 if (skey == SKEY_PGDOWN)
5731 /* Recurse on numbers */
5736 if (!(skey & SKEY_MASK) && isalpha(skey))
5739 if ((key > -1) && hook[key][0])
5741 /* Recurse on that file */
5742 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5747 /* Hack, dump to file */
5757 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5759 if (!get_string("File name: ", xtmp, 80))
5768 /* Build the filename */
5769 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5771 /* Hack -- Re-Open the file */
5772 fff = my_fopen(path, "r");
5774 ffp = my_fopen(buff, "w");
5780 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5782 msg_print("Failed to open file.");
5789 sprintf(xtmp, "%s: %s", player_name, what);
5790 my_fputs(ffp, xtmp, 80);
5791 my_fputs(ffp, "\n", 80);
5793 while (!my_fgets(fff, buff, sizeof(buff)))
5794 my_fputs(ffp, buff, 80);
5800 /* Hack -- Re-Open the file */
5801 fff = my_fopen(path, "r");
5804 /* Return to last screen */
5805 if (skey == ESCAPE) break;
5806 if (skey == '<') break;
5808 /* Exit on the ^q */
5809 if (skey == KTRL('q')) skey = 'q';
5811 /* Exit on the q key */
5812 if (skey == 'q') break;
5815 /* Close the file */
5819 if (skey == 'q') return (FALSE);
5827 * Peruse the On-Line-Help
5829 void do_cmd_help(void)
5834 /* Peruse the main help file */
5836 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5838 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5848 * Process the player name.
5849 * Extract a clean "base name".
5850 * Build the savefile name if needed.
5852 void process_player_name(bool sf)
5855 char old_player_base[32] = "";
5857 if (character_generated) strcpy(old_player_base, player_base);
5859 /* Cannot be too long */
5860 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5862 if (strlen(player_name) > 8)
5864 if (strlen(player_name) > 15)
5869 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5871 quit_fmt("The name '%s' is too long!", player_name);
5877 /* Cannot contain "icky" characters */
5878 for (i = 0; player_name[i]; i++)
5880 /* No control characters */
5882 if (iskanji(player_name[i])){i++;continue;}
5883 if (iscntrl( (unsigned char)player_name[i]))
5885 if (iscntrl(player_name[i]))
5889 /* Illegal characters */
5891 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5893 quit_fmt("The name '%s' contains control chars!", player_name);
5902 /* Extract "useful" letters */
5903 for (i = 0; player_name[i]; i++)
5906 unsigned char c = player_name[i];
5908 char c = player_name[i];
5912 /* Convert "dot" to "underscore" */
5913 if (c == '.') c = '_';
5915 /* Accept all the letters */
5916 player_base[k++] = c;
5921 /* Extract "useful" letters */
5922 for (i = 0; player_name[i]; i++)
5925 unsigned char c = player_name[i];
5927 char c = player_name[i];
5930 /* Accept some letters */
5933 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5934 player_base[k++] = c;
5936 player_base[k++] = player_name[i];
5939 else if (iskana(c)) player_base[k++] = c;
5943 /* Convert path separator to underscore */
5944 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5945 player_base[k++] = '_';
5946 i += strlen(PATH_SEP);
5949 /* Convert space, dot, and underscore to underscore */
5950 else if (my_strchr(". _", c)) player_base[k++] = '_';
5952 else if (isprint(c)) player_base[k++] = c;
5960 /* Hack -- max length */
5966 player_base[k] = '\0';
5968 /* Require a "base" name */
5969 if (!player_base[0]) strcpy(player_base, "PLAYER");
5972 #ifdef SAVEFILE_MUTABLE
5978 if (!savefile_base[0] && savefile[0])
5985 t = my_strstr(s, PATH_SEP);
5990 strcpy(savefile_base, s);
5993 if (!savefile_base[0] || !savefile[0])
5996 /* Change the savefile name */
6001 strcpy(savefile_base, player_base);
6003 #ifdef SAVEFILE_USE_UID
6004 /* Rename the savefile, using the player_uid and player_base */
6005 (void)sprintf(temp, "%d.%s", player_uid, player_base);
6007 /* Rename the savefile, using the player_base */
6008 (void)sprintf(temp, "%s", player_base);
6012 /* Hack -- support "flat directory" usage on VM/ESA */
6013 (void)sprintf(temp, "%s.sv", player_base);
6016 /* Build the filename */
6017 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
6020 /* Load an autopick preference file */
6021 if (character_generated)
6023 if (!streq(old_player_base, player_base)) autopick_load_pref(FALSE);
6029 * Gets a name for the character, reacting to name changes.
6031 * Assumes that "display_player(0)" has just been called
6033 * Perhaps we should NOT ask for a name (at "birth()") on
6034 * Unix machines? XXX XXX
6036 * What a horrible name for a global function. XXX XXX XXX
6042 /* Save the player name */
6043 strcpy(tmp, player_name);
6045 /* Prompt for a new name */
6047 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
6049 if (get_string("Enter a name for your character: ", tmp, 15))
6053 strcpy(player_name, tmp);
6055 else if (0 == strlen(player_name))
6057 /* Use default name */
6058 strcpy(player_name, "PLAYER");
6061 strcpy(tmp,ap_ptr->title);
6068 strcat(tmp,player_name);
6070 /* Re-Draw the name (in light blue) */
6071 Term_erase(34, 1, 255);
6072 c_put_str(TERM_L_BLUE, tmp, 1, 34);
6074 /* Erase the prompt, etc */
6081 * Hack -- commit suicide
6083 void do_cmd_suicide(void)
6090 /* Verify Retirement */
6091 if (p_ptr->total_winner)
6095 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
6097 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
6102 /* Verify Suicide */
6107 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
6109 if (!get_check("Do you really want to commit suicide? ")) return;
6114 if (!p_ptr->noscore)
6116 /* Special Verification for suicide */
6118 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
6120 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
6126 if (i != '@') return;
6129 /* Initialize "last message" buffer */
6130 if (p_ptr->last_message) string_free(p_ptr->last_message);
6131 p_ptr->last_message = NULL;
6133 /* Hack -- Note *winning* message */
6134 if (p_ptr->total_winner && last_words)
6136 char buf[1024] = "";
6139 while (!get_string("*¾¡Íø*¥á¥Ã¥»¡¼¥¸: ", buf, sizeof buf)) ;
6141 while (!get_string("*Winning* message: ", buf, sizeof buf)) ;
6146 p_ptr->last_message = string_make(buf);
6147 msg_print(p_ptr->last_message);
6152 p_ptr->playing = FALSE;
6154 /* Kill the player */
6155 p_ptr->is_dead = TRUE;
6158 p_ptr->leaving = TRUE;
6160 if (!p_ptr->total_winner)
6163 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
6164 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
6166 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
6167 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
6169 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
6172 /* Cause of death */
6174 (void)strcpy(p_ptr->died_from, "ÅÓÃ潪λ");
6176 (void)strcpy(p_ptr->died_from, "Quitting");
6186 void do_cmd_save_game(int is_autosave)
6188 /* Autosaves do not disturb */
6192 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
6194 msg_print("Autosaving the game...");
6200 /* Disturb the player */
6204 /* Clear messages */
6212 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6214 prt("Saving game...", 0, 0);
6221 /* The player is not dead */
6223 (void)strcpy(p_ptr->died_from, "(¥»¡¼¥Ö)");
6225 (void)strcpy(p_ptr->died_from, "(saved)");
6229 /* Forbid suspend */
6230 signals_ignore_tstp();
6232 /* Save the player */
6236 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6238 prt("Saving game... done.", 0, 0);
6243 /* Save failed (oops) */
6247 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6249 prt("Saving game... failed!", 0, 0);
6254 /* Allow suspend again */
6255 signals_handle_tstp();
6260 /* Note that the player is not dead */
6262 (void)strcpy(p_ptr->died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6264 (void)strcpy(p_ptr->died_from, "(alive and well)");
6267 /* HACK -- don't get sanity blast on updating view */
6273 /* HACK -- reset the hackish flag */
6279 * Save the game and exit
6281 void do_cmd_save_and_exit(void)
6283 p_ptr->playing = FALSE;
6286 p_ptr->leaving = TRUE;
6288 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6290 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6296 * Hack -- Calculates the total number of points earned -JWT-
6298 long total_points(void)
6302 u32b point, point_h, point_l;
6303 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6305 if (!preserve_mode) mult += 10;
6306 if (!autoroller) mult += 10;
6307 if (!smart_learn) mult -= 20;
6308 if (smart_cheat) mult += 30;
6309 if (ironman_shops) mult += 50;
6310 if (ironman_small_levels) mult += 10;
6311 if (ironman_empty_levels) mult += 20;
6312 if (!powerup_home) mult += 50;
6313 if (ironman_rooms) mult += 100;
6314 if (ironman_nightmare) mult += 100;
6316 if (mult < 5) mult = 5;
6318 for (i = 0; i < max_d_idx; i++)
6319 if(max_dlv[i] > max_dl)
6320 max_dl = max_dlv[i];
6322 point_l = (p_ptr->max_max_exp + (100 * max_dl));
6323 point_h = point_l / 0x10000L;
6324 point_l = point_l % 0x10000L;
6327 point_h += point_l / 0x10000L;
6328 point_l %= 0x10000L;
6330 point_l += ((point_h % 100) << 16);
6334 point = (point_h << 16) + (point_l);
6335 if (p_ptr->arena_number >= 0)
6336 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6338 if (ironman_downward) point *= 2;
6339 if (p_ptr->pclass == CLASS_BERSERKER)
6341 if ( p_ptr->prace == RACE_SPECTRE )
6345 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6348 if (p_ptr->total_winner) point = 2;
6350 if (easy_band) point = (0 - point);
6358 * Centers a string within a 31 character string -JWT-
6360 static void center_string(char *buf, cptr str)
6367 /* Necessary border */
6371 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6377 * Save a "bones" file for a dead character
6379 * Note that we will not use these files until Angband 2.8.0, and
6380 * then we will only use the name and level on which death occured.
6382 * Should probably attempt some form of locking...
6384 static void make_bones(void)
6391 /* Ignore wizards and borgs */
6392 if (!(p_ptr->noscore & 0x00FF))
6394 /* Ignore people who die in town */
6399 /* XXX XXX XXX "Bones" name */
6400 sprintf(tmp, "bone.%03d", dun_level);
6402 /* Build the filename */
6403 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6405 /* Attempt to open the bones file */
6406 fp = my_fopen(str, "r");
6408 /* Close it right away */
6409 if (fp) my_fclose(fp);
6411 /* Do not over-write a previous ghost */
6414 /* File type is "TEXT" */
6415 FILE_TYPE(FILE_TYPE_TEXT);
6417 /* Grab permissions */
6420 /* Try to write a new "Bones File" */
6421 fp = my_fopen(str, "w");
6423 /* Drop permissions */
6426 /* Not allowed to write it? Weird. */
6430 fprintf(fp, "%s\n", player_name);
6431 fprintf(fp, "%d\n", p_ptr->mhp);
6432 fprintf(fp, "%d\n", p_ptr->prace);
6433 fprintf(fp, "%d\n", p_ptr->pclass);
6435 /* Close and save the Bones file */
6444 * Redefinable "print_tombstone" action
6446 bool (*tombstone_aux)(void) = NULL;
6450 * Display a "tomb-stone"
6452 static void print_tomb(void)
6456 /* Do we use a special tombstone ? */
6459 /* Use tombstone hook */
6460 done = (*tombstone_aux)();
6463 /* Print the text-tombstone */
6477 time_t ct = time((time_t)0);
6483 /* Build the filename */
6485 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead_j.txt");
6487 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead.txt");
6491 /* Open the News file */
6492 fp = my_fopen(buf, "r");
6499 /* Dump the file to the screen */
6500 while (0 == my_fgets(fp, buf, sizeof(buf)))
6502 /* Display and advance */
6503 put_str(buf, i++, 0);
6512 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6526 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6529 center_string(buf, player_name);
6530 put_str(buf, 6, 11);
6533 center_string(buf, "the");
6534 put_str(buf, 7, 11);
6537 center_string(buf, p);
6538 put_str(buf, 8, 11);
6541 center_string(buf, cp_ptr->title);
6543 put_str(buf, 10, 11);
6546 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6548 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6551 center_string(buf, tmp);
6552 put_str(buf, 11, 11);
6555 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6557 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6560 center_string(buf, tmp);
6561 put_str(buf, 12, 11);
6564 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6566 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6569 center_string(buf, tmp);
6570 put_str(buf, 13, 11);
6573 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6574 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6576 strcpy(tmp, "<¼«»¦>");
6580 if (streq(p_ptr->died_from, "ripe"))
6582 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6584 else if (streq(p_ptr->died_from, "Seppuku"))
6586 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6590 strcpy(tmp, p_ptr->died_from);
6593 center_string(buf, tmp);
6594 put_str(buf, 14, 11);
6596 if(!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6598 if( dun_level == 0 )
6600 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6601 if(streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6603 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6607 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6612 if(streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6614 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6618 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6621 center_string(buf, tmp);
6622 put_str(buf, 15, 11);
6625 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6626 center_string(buf, tmp);
6627 put_str(buf, 14, 11);
6630 if (strlen(p_ptr->died_from) > 24)
6632 strncpy(dummy, p_ptr->died_from, 24);
6634 (void)sprintf(tmp, "by %s.", dummy);
6637 (void)sprintf(tmp, "by %s.", p_ptr->died_from);
6639 center_string(buf, tmp);
6640 put_str(buf, 15, 11);
6645 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6646 center_string(buf, tmp);
6647 put_str(buf, 17, 11);
6650 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6652 msg_format("Goodbye, %s!", player_name);
6660 * Display some character info
6662 static void show_info(void)
6668 /* Hack -- Know everything in the inven/equip */
6669 for (i = 0; i < INVEN_TOTAL; i++)
6671 o_ptr = &inventory[i];
6673 /* Skip non-objects */
6674 if (!o_ptr->k_idx) continue;
6676 /* Aware and Known */
6677 object_aware(o_ptr);
6678 object_known(o_ptr);
6681 for (i = 1; i < max_towns; i++)
6683 st_ptr = &town[i].store[STORE_HOME];
6685 /* Hack -- Know everything in the home */
6686 for (j = 0; j < st_ptr->stock_num; j++)
6688 o_ptr = &st_ptr->stock[j];
6690 /* Skip non-objects */
6691 if (!o_ptr->k_idx) continue;
6693 /* Aware and Known */
6694 object_aware(o_ptr);
6695 object_known(o_ptr);
6699 /* Hack -- Recalculate bonuses */
6700 p_ptr->update |= (PU_BONUS);
6705 /* Flush all input keys */
6708 /* Flush messages */
6712 /* Describe options */
6714 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6715 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6717 prt("You may now dump a character record to one or more files.", 21, 0);
6718 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6722 /* Dump character records as requested */
6729 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6731 put_str("Filename: ", 23, 0);
6736 strcpy(out_val, "");
6738 /* Ask for filename (or abort) */
6739 if (!askfor(out_val, 60)) return;
6741 /* Return means "show on screen" */
6742 if (!out_val[0]) break;
6747 /* Dump a character file */
6748 (void)file_character(out_val);
6756 /* Display player */
6759 /* Prompt for inventory */
6761 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6763 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6767 /* Allow abort at this point */
6768 if (inkey() == ESCAPE) return;
6771 /* Show equipment and inventory */
6773 /* Equipment -- if any */
6777 item_tester_full = TRUE;
6778 (void)show_equip(0);
6780 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6782 prt("You are using: -more-", 0, 0);
6785 if (inkey() == ESCAPE) return;
6788 /* Inventory -- if any */
6792 item_tester_full = TRUE;
6793 (void)show_inven(0);
6795 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6797 prt("You are carrying: -more-", 0, 0);
6800 if (inkey() == ESCAPE) return;
6803 /* Homes in the different towns */
6804 for (l = 1; l < max_towns; l++)
6806 st_ptr = &town[l].store[STORE_HOME];
6808 /* Home -- if anything there */
6809 if (st_ptr->stock_num)
6811 /* Display contents of the home */
6812 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6818 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6820 char o_name[MAX_NLEN];
6824 o_ptr = &st_ptr->stock[i];
6826 /* Print header, clear line */
6827 sprintf(tmp_val, "%c) ", I2A(j));
6828 prt(tmp_val, j+2, 4);
6830 /* Display object description */
6831 object_desc(o_name, o_ptr, 0);
6832 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6837 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6839 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6844 if (inkey() == ESCAPE) return;
6851 static bool check_score(void)
6857 if (highscore_fd < 0)
6860 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6862 msg_print("Score file unavailable.");
6869 #ifndef SCORE_WIZARDS
6870 /* Wizard-mode pre-empts scoring */
6871 if (p_ptr->noscore & 0x000F)
6874 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6876 msg_print("Score not registered for wizards.");
6885 /* Borg-mode pre-empts scoring */
6886 if (p_ptr->noscore & 0x00F0)
6889 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6891 msg_print("Score not registered for borgs.");
6899 #ifndef SCORE_CHEATERS
6900 /* Cheaters are not scored */
6901 if (p_ptr->noscore & 0xFF00)
6904 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6906 msg_print("Score not registered for cheaters.");
6916 if (!p_ptr->total_winner && streq(p_ptr->died_from, "¶¯À©½ªÎ»"))
6918 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Interrupting"))
6923 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6925 msg_print("Score not registered due to interruption.");
6934 if (!p_ptr->total_winner && streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6936 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Quitting"))
6941 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6943 msg_print("Score not registered due to quitting.");
6953 * Close up the current game (player may or may not be dead)
6955 * This function is called only from "main.c" and "signals.c".
6957 void close_game(void)
6960 bool do_send = TRUE;
6962 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6967 /* Flush the messages */
6970 /* Flush the input */
6974 /* No suspending now */
6975 signals_ignore_tstp();
6978 /* Hack -- Character is now "icky" */
6979 character_icky = TRUE;
6982 /* Build the filename */
6983 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6985 /* Grab permissions */
6988 /* Open the high score file, for reading/writing */
6989 highscore_fd = fd_open(buf, O_RDWR);
6991 /* Drop permissions */
6997 /* Handle retirement */
6998 if (p_ptr->total_winner) kingly();
7002 if (!cheat_save || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
7004 if (!cheat_save || get_check("Save death? "))
7009 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7011 if (!save_player()) msg_print("death save failed!");
7014 else do_send = FALSE;
7021 /* Show more info */
7029 if ((!send_world_score(do_send)))
7032 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7034 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7037 p_ptr->wait_report_score = TRUE;
7038 p_ptr->is_dead = FALSE;
7040 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7042 if (!save_player()) msg_print("death save failed!");
7046 if (!p_ptr->wait_report_score)
7049 else if (highscore_fd >= 0)
7051 display_scores_aux(0, 10, -1, NULL);
7054 /* Dump bones file */
7063 do_cmd_save_game(FALSE);
7065 /* Prompt for scores XXX XXX XXX */
7067 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
7069 prt("Press Return (or Escape).", 0, 40);
7073 /* Predict score (or ESCAPE) */
7074 if (inkey() != ESCAPE) predict_score();
7078 /* Shut the high score file */
7079 (void)fd_close(highscore_fd);
7081 /* Forget the high score fd */
7084 /* Kill all temporal files */
7085 clear_saved_floor_files();
7087 /* Allow suspending now */
7088 signals_handle_tstp();
7093 * Handle abrupt death of the visual system
7095 * This routine is called only in very rare situations, and only
7096 * by certain visual systems, when they experience fatal errors.
7098 * XXX XXX Hack -- clear the death flag when creating a HANGUP
7099 * save file so that player can see tombstone when restart.
7101 void exit_game_panic(void)
7103 /* If nothing important has happened, just quit */
7105 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
7107 if (!character_generated || character_saved) quit("panic");
7110 /* Mega-Hack -- see "msg_print()" */
7113 /* Clear the top line */
7116 /* Hack -- turn off some things */
7119 /* Mega-Hack -- Delay death */
7120 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
7122 /* Hardcode panic save */
7123 p_ptr->panic_save = 1;
7125 /* Forbid suspend */
7126 signals_ignore_tstp();
7128 /* Indicate panic save */
7130 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7132 (void)strcpy(p_ptr->died_from, "(panic save)");
7136 /* Panic save, or get worried */
7138 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7140 if (!save_player()) quit("panic save failed!");
7144 /* Successful panic save */
7146 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7148 quit("panic save succeeded!");
7154 * Get a random line from a file
7155 * Based on the monster speech patch by Matt Graham,
7157 errr get_rnd_line(cptr file_name, int entry, char *output)
7165 /* Build the filename */
7166 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
7169 fp = my_fopen(buf, "r");
7174 /* Find the entry of the monster */
7177 /* Get a line from the file */
7178 if (my_fgets(fp, buf, sizeof(buf)) == 0)
7180 /* Count the lines */
7183 /* Look for lines starting with 'N:' */
7184 if ((buf[0] == 'N') && (buf[1] == ':'))
7186 /* Allow default lines */
7192 else if (buf[2] == 'M')
7194 if (r_info[entry].flags1 & RF1_MALE) break;
7196 else if (buf[2] == 'F')
7198 if (r_info[entry].flags1 & RF1_FEMALE) break;
7200 /* Get the monster number */
7201 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7203 /* Is it the right number? */
7204 if (test == entry) break;
7208 /* Error while converting the number */
7209 msg_format("Error in line %d of %s!", line_num, file_name);
7217 /* Reached end of file */
7223 /* Get the random line */
7224 for (counter = 0; ; counter++)
7228 test = my_fgets(fp, buf, sizeof(buf));
7230 /* Count the lines */
7231 /* line_num++; No more needed */
7235 /* Ignore lines starting with 'N:' */
7236 if ((buf[0] == 'N') && (buf[1] == ':')) continue;
7238 if (buf[0] != '#') break;
7247 if (one_in_(counter + 1)) strcpy(output, buf);
7250 /* Close the file */
7254 return counter ? 0 : -1;
7259 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7264 for (i = 0; i < count; i++)
7266 result = get_rnd_line(file_name, entry, output);
7269 for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
7277 * Process file for auto picker/destroyer.
7279 errr process_autopick_file(cptr name)
7285 /* Build the filename */
7286 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7288 err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
7296 * Process file for player's history editor.
7298 errr process_histpref_file(cptr name)
7302 bool old_character_xtra = character_xtra;
7304 /* Build the filename */
7305 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7307 /* Hack -- prevent modification birth options in this file */
7308 character_xtra = TRUE;
7310 err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
7312 character_xtra = old_character_xtra;
7319 static errr counts_seek(int fd, u32b where, bool flag)
7322 char temp1[128], temp2[128];
7323 u32b zero_header[3] = {0L, 0L, 0L};
7326 #ifdef SAVEFILE_USE_UID
7327 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7329 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7331 for (i = 0; temp1[i]; i++)
7332 temp1[i] ^= (i+1) * 63;
7337 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7339 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7344 fd_seek(fd, seekpoint);
7345 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7346 fd_write(fd, (char*)(temp1), sizeof(temp1));
7350 if (strcmp(temp1, temp2) == 0)
7353 seekpoint += 128 + 3 * sizeof(u32b);
7356 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7359 u32b counts_read(int where)
7366 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7368 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7370 fd = fd_open(buf, O_RDONLY);
7372 if (counts_seek(fd, where, FALSE) ||
7373 fd_read(fd, (char*)(&count), sizeof(u32b)))
7381 errr counts_write(int where, u32b count)
7388 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7390 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7393 /* Grab permissions */
7396 fd = fd_open(buf, O_RDWR);
7398 /* Drop permissions */
7403 /* File type is "DATA" */
7404 FILE_TYPE(FILE_TYPE_DATA);
7406 /* Grab permissions */
7409 /* Create a new high score file */
7410 fd = fd_make(buf, 0644);
7412 /* Drop permissions */
7416 /* Grab permissions */
7419 err = fd_lock(fd, F_WRLCK);
7421 /* Drop permissions */
7426 counts_seek(fd, where, TRUE);
7427 fd_write(fd, (char*)(&count), sizeof(u32b));
7429 /* Grab permissions */
7432 err = fd_lock(fd, F_UNLCK);
7434 /* Drop permissions */
7445 #ifdef HANDLE_SIGNALS
7452 * Handle signals -- suspend
7454 * Actually suspend the game, and then resume cleanly
7456 static void handle_signal_suspend(int sig)
7458 /* Disable handler */
7459 (void)signal(sig, SIG_IGN);
7466 /* Suspend the "Term" */
7467 Term_xtra(TERM_XTRA_ALIVE, 0);
7469 /* Suspend ourself */
7470 (void)kill(0, SIGSTOP);
7472 /* Resume the "Term" */
7473 Term_xtra(TERM_XTRA_ALIVE, 1);
7475 /* Redraw the term */
7478 /* Flush the term */
7483 /* Restore handler */
7484 (void)signal(sig, handle_signal_suspend);
7489 * Handle signals -- simple (interrupt and quit)
7491 * This function was causing a *huge* number of problems, so it has
7492 * been simplified greatly. We keep a global variable which counts
7493 * the number of times the user attempts to kill the process, and
7494 * we commit suicide if the user does this a certain number of times.
7496 * We attempt to give "feedback" to the user as he approaches the
7497 * suicide thresh-hold, but without penalizing accidental keypresses.
7499 * To prevent messy accidents, we should reset this global variable
7500 * whenever the user enters a keypress, or something like that.
7502 static void handle_signal_simple(int sig)
7504 /* Disable handler */
7505 (void)signal(sig, SIG_IGN);
7508 /* Nothing to save, just quit */
7509 if (!character_generated || character_saved) quit(NULL);
7512 /* Count the signals */
7516 /* Terminate dead characters */
7519 /* Mark the savefile */
7521 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»");
7523 (void)strcpy(p_ptr->died_from, "Abortion");
7542 /* Allow suicide (after 5) */
7543 else if (signal_count >= 5)
7545 /* Cause of "death" */
7547 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»Ãæ");
7549 (void)strcpy(p_ptr->died_from, "Interrupting");
7558 p_ptr->playing = FALSE;
7561 p_ptr->is_dead = TRUE;
7564 p_ptr->leaving = TRUE;
7578 /* Give warning (after 4) */
7579 else if (signal_count >= 4)
7582 Term_xtra(TERM_XTRA_NOISE, 0);
7584 /* Clear the top line */
7585 Term_erase(0, 0, 255);
7587 /* Display the cause */
7589 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7591 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7599 /* Give warning (after 2) */
7600 else if (signal_count >= 2)
7603 Term_xtra(TERM_XTRA_NOISE, 0);
7606 /* Restore handler */
7607 (void)signal(sig, handle_signal_simple);
7612 * Handle signal -- abort, kill, etc
7614 static void handle_signal_abort(int sig)
7618 Term_get_size(&wid, &hgt);
7621 /* Disable handler */
7622 (void)signal(sig, SIG_IGN);
7625 /* Nothing to save, just quit */
7626 if (!character_generated || character_saved) quit(NULL);
7633 /* Clear the bottom line */
7634 Term_erase(0, hgt - 1, 255);
7636 /* Give a warning */
7637 Term_putstr(0, hgt - 1, -1, TERM_RED,
7639 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7641 "A gruesome software bug LEAPS out at you!");
7647 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7649 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7657 p_ptr->panic_save = 1;
7661 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7663 (void)strcpy(p_ptr->died_from, "(panic save)");
7667 /* Forbid suspend */
7668 signals_ignore_tstp();
7670 /* Attempt to save */
7674 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7676 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7685 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7687 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7697 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7699 quit("software bug");
7708 * Ignore SIGTSTP signals (keyboard suspend)
7710 void signals_ignore_tstp(void)
7714 (void)signal(SIGTSTP, SIG_IGN);
7720 * Handle SIGTSTP signals (keyboard suspend)
7722 void signals_handle_tstp(void)
7726 (void)signal(SIGTSTP, handle_signal_suspend);
7733 * Prepare to handle the relevant signals
7735 void signals_init(void)
7739 (void)signal(SIGHUP, SIG_IGN);
7744 (void)signal(SIGTSTP, handle_signal_suspend);
7749 (void)signal(SIGINT, handle_signal_simple);
7753 (void)signal(SIGQUIT, handle_signal_simple);
7758 (void)signal(SIGFPE, handle_signal_abort);
7762 (void)signal(SIGILL, handle_signal_abort);
7766 (void)signal(SIGTRAP, handle_signal_abort);
7770 (void)signal(SIGIOT, handle_signal_abort);
7774 (void)signal(SIGKILL, handle_signal_abort);
7778 (void)signal(SIGBUS, handle_signal_abort);
7782 (void)signal(SIGSEGV, handle_signal_abort);
7786 (void)signal(SIGTERM, handle_signal_abort);
7790 (void)signal(SIGPIPE, handle_signal_abort);
7794 (void)signal(SIGEMT, handle_signal_abort);
7798 (void)signal(SIGDANGER, handle_signal_abort);
7802 (void)signal(SIGSYS, handle_signal_abort);
7806 (void)signal(SIGXCPU, handle_signal_abort);
7810 (void)signal(SIGPWR, handle_signal_abort);
7816 #else /* HANDLE_SIGNALS */
7822 void signals_ignore_tstp(void)
7829 void signals_handle_tstp(void)
7836 void signals_init(void)
7839 #endif /* HANDLE_SIGNALS */