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 TERM_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 TERM_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>" */
465 int num = tokenize(buf + 2, F_LIT_MAX * 2 + 1, zz, TOKENIZE_CHECKQUOTE);
467 if ((num != 3) && (num != 4) && (num != F_LIT_MAX * 2 + 1)) 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)) f_ptr->x_attr[F_LIT_STANDARD] = n1; /* Allow TERM_DARK text */
477 if (n2) f_ptr->x_char[F_LIT_STANDARD] = n2;
479 /* Mega-hack -- feat supports lighting */
482 /* No lighting support */
484 n1 = f_ptr->x_attr[F_LIT_STANDARD];
485 n2 = f_ptr->x_char[F_LIT_STANDARD];
486 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
488 f_ptr->x_attr[j] = n1;
489 f_ptr->x_char[j] = n2;
493 /* Use default lighting */
495 apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
498 /* Use desired lighting */
499 case F_LIT_MAX * 2 + 1:
500 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
502 n1 = strtol(zz[j * 2 + 1], NULL, 0);
503 n2 = strtol(zz[j * 2 + 2], NULL, 0);
504 if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[j] = n1; /* Allow TERM_DARK text */
505 if (n2) f_ptr->x_char[j] = n2;
512 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
514 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
516 j = (byte)strtol(zz[0], NULL, 0);
517 n1 = strtol(zz[1], NULL, 0);
518 n2 = strtol(zz[2], NULL, 0);
519 misc_to_attr[j] = n1;
520 misc_to_char[j] = n2;
525 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
527 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
529 j = (huge)strtol(zz[0], NULL, 0);
530 n1 = strtol(zz[1], NULL, 0);
531 n2 = strtol(zz[2], NULL, 0);
532 for (i = 1; i < max_k_idx; i++)
534 object_kind *k_ptr = &k_info[i];
535 if (k_ptr->tval == j)
537 if (n1) k_ptr->d_attr = n1;
538 if (n2) k_ptr->d_char = n2;
545 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
547 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
549 j = (byte)strtol(zz[0], NULL, 0) % 128;
550 n1 = strtol(zz[1], NULL, 0);
551 if (n1) tval_to_attr[j] = n1;
556 /* Process "A:<str>" -- save an "action" for later */
558 text_to_ascii(macro__buf, buf+2);
561 /* Process "P:<str>" -- normal macro */
566 text_to_ascii(tmp, buf+2);
567 macro_add(tmp, macro__buf);
571 /* Process "C:<str>" -- create keymap */
577 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return 1;
579 mode = strtol(zz[0], NULL, 0);
580 if ((mode < 0) || (mode >= KEYMAP_MODES)) return 1;
582 text_to_ascii(tmp, zz[1]);
583 if (!tmp[0] || tmp[1]) return 1;
586 string_free(keymap_act[mode][i]);
588 keymap_act[mode][i] = string_make(macro__buf);
593 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
595 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
597 i = (byte)strtol(zz[0], NULL, 0);
598 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
599 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
600 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
601 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
606 /* Process "X:<str>" -- turn option off */
607 /* Process "Y:<str>" -- turn option on */
610 for (i = 0; option_info[i].o_desc; i++)
612 if (option_info[i].o_var &&
613 option_info[i].o_text &&
614 streq(option_info[i].o_text, buf + 2))
616 int os = option_info[i].o_set;
617 int ob = option_info[i].o_bit;
619 if ((p_ptr->playing || character_xtra) &&
620 (OPT_PAGE_BIRTH == option_info[i].o_page) && !p_ptr->wizard)
623 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
625 msg_format("Birth options can not changed! '%s'", buf);
634 option_flag[os] &= ~(1L << ob);
635 (*option_info[i].o_var) = FALSE;
640 option_flag[os] |= (1L << ob);
641 (*option_info[i].o_var) = TRUE;
647 /* don't know that option. ignore it.*/
649 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
651 msg_format("Ignored invalid option: %s", buf);
656 /* Process "Z:<type>:<str>" -- set spell color */
660 char *t = my_strchr(buf + 2, ':');
668 for (i = 0; gf_desc[i].name; i++)
670 /* Match this type */
671 if (streq(gf_desc[i].name, buf + 2))
673 /* Remember this color set */
674 gf_color[gf_desc[i].num] = quark_add(t);
684 /* Initialize macro trigger names and a template */
685 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
686 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
689 int tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
691 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
697 if (macro_template != NULL)
699 num = strlen(macro_modifier_chr);
701 /* Kill the template string */
702 string_free(macro_template);
703 macro_template = NULL;
705 /* Kill flag characters of modifier keys */
706 string_free(macro_modifier_chr);
708 /* Kill corresponding modifier names */
709 for (i = 0; i < num; i++)
711 string_free(macro_modifier_name[i]);
714 /* Kill trigger name strings */
715 for (i = 0; i < max_macrotrigger; i++)
717 string_free(macro_trigger_name[i]);
718 string_free(macro_trigger_keycode[0][i]);
719 string_free(macro_trigger_keycode[1][i]);
722 max_macrotrigger = 0;
725 if (*zz[0] == '\0') return 0; /* clear template */
727 /* Number of modifier flags */
730 /* Limit the number */
731 num = MIN(MAX_MACRO_MOD, num);
733 /* Stop if number of modifier is not correct */
734 if (2 + num != tok) return 1;
736 /* Get a template string */
737 macro_template = string_make(zz[0]);
739 /* Get flag characters of modifier keys */
740 macro_modifier_chr = string_make(zz[1]);
742 /* Get corresponding modifier names */
743 for (i = 0; i < num; i++)
745 macro_modifier_name[i] = string_make(zz[2+i]);
749 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
755 if (max_macrotrigger >= MAX_MACRO_TRIG)
758 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
760 msg_print("Too many macro triggers!");
764 m = max_macrotrigger;
767 /* Take into account the escape character */
777 /* Get a trigger name */
778 macro_trigger_name[m] = string_make(buf);
780 /* Get the corresponding key code */
781 macro_trigger_keycode[0][m] = string_make(zz[1]);
785 /* Key code of a combination of it with the shift key */
786 macro_trigger_keycode[1][m] = string_make(zz[2]);
790 macro_trigger_keycode[1][m] = string_make(zz[1]);
805 * Helper function for "process_pref_file()"
808 * v: output buffer array
814 cptr process_pref_file_expr(char **sp, char *fp)
831 while (isspace(*s)) s++;
849 t = process_pref_file_expr(&s, &f);
858 else if (streq(t, "IOR"))
861 while (*s && (f != b2))
863 t = process_pref_file_expr(&s, &f);
864 if (*t && !streq(t, "0")) v = "1";
869 else if (streq(t, "AND"))
872 while (*s && (f != b2))
874 t = process_pref_file_expr(&s, &f);
875 if (*t && streq(t, "0")) v = "0";
880 else if (streq(t, "NOT"))
883 while (*s && (f != b2))
885 t = process_pref_file_expr(&s, &f);
886 if (*t && streq(t, "1")) v = "0";
891 else if (streq(t, "EQU"))
896 t = process_pref_file_expr(&s, &f);
898 while (*s && (f != b2))
900 p = process_pref_file_expr(&s, &f);
901 if (streq(t, p)) v = "1";
906 else if (streq(t, "LEQ"))
911 t = process_pref_file_expr(&s, &f);
913 while (*s && (f != b2))
916 t = process_pref_file_expr(&s, &f);
917 if (*t && atoi(p) > atoi(t)) v = "0";
922 else if (streq(t, "GEQ"))
927 t = process_pref_file_expr(&s, &f);
929 while (*s && (f != b2))
932 t = process_pref_file_expr(&s, &f);
934 /* Compare two numbers instead of string */
935 if (*t && atoi(p) < atoi(t)) v = "0";
942 while (*s && (f != b2))
944 t = process_pref_file_expr(&s, &f);
949 if (f != b2) v = "?x?x?";
951 /* Extract final and Terminate */
952 if ((f = *s) != '\0') *s++ = '\0';
958 /* Accept all printables except spaces and brackets */
960 while ((iskanji(*s) || isprint(*s)) && !my_strchr(" []", *s))
962 if (iskanji(*s)) s++;
966 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
969 /* Extract final and Terminate */
970 if ((f = *s) != '\0') *s++ = '\0';
976 if (streq(b+1, "SYS"))
981 else if (streq(b+1, "KEYBOARD"))
983 v = ANGBAND_KEYBOARD;
987 else if (streq(b+1, "GRAF"))
992 /* Monochrome mode */
993 else if (streq(b+1, "MONOCHROME"))
1002 else if (streq(b+1, "RACE"))
1005 v = rp_ptr->E_title;
1012 else if (streq(b+1, "CLASS"))
1015 v = cp_ptr->E_title;
1022 else if (streq(b+1, "PLAYER"))
1028 else if (streq(b+1, "REALM1"))
1031 v = E_realm_names[p_ptr->realm1];
1033 v = realm_names[p_ptr->realm1];
1038 else if (streq(b+1, "REALM2"))
1041 v = E_realm_names[p_ptr->realm2];
1043 v = realm_names[p_ptr->realm2];
1048 else if (streq(b+1, "LEVEL"))
1050 sprintf(tmp, "%02d", p_ptr->lev);
1054 /* Autopick auto-register is in-use or not? */
1055 else if (streq(b+1, "AUTOREGISTER"))
1057 if (p_ptr->autopick_autoregister)
1082 #define PREF_TYPE_NORMAL 0
1083 #define PREF_TYPE_AUTOPICK 1
1084 #define PREF_TYPE_HISTPREF 2
1087 * Open the "user pref file" and parse it.
1089 static errr process_pref_file_aux(cptr name, int preftype)
1101 bool bypass = FALSE;
1105 fp = my_fopen(name, "r");
1108 if (!fp) return (-1);
1110 /* Process the file */
1111 while (0 == my_fgets(fp, buf, sizeof(buf)))
1116 /* Skip "empty" lines */
1117 if (!buf[0]) continue;
1119 /* Skip "blank" lines */
1121 if (!iskanji(buf[0]))
1123 if (isspace(buf[0])) continue;
1126 if (buf[0] == '#') continue;
1133 /* Process "?:<expr>" */
1134 if ((buf[0] == '?') && (buf[1] == ':'))
1143 /* Parse the expr */
1144 v = process_pref_file_expr(&s, &f);
1147 bypass = (streq(v, "0") ? TRUE : FALSE);
1153 /* Apply conditionals */
1154 if (bypass) continue;
1157 /* Process "%:<file>" */
1160 static int depth_count = 0;
1162 /* Ignore if deeper than 20 level */
1163 if (depth_count > 20) continue;
1165 /* Count depth level */
1168 /* Process that file if allowed */
1171 case PREF_TYPE_AUTOPICK:
1172 (void)process_autopick_file(buf + 2);
1174 case PREF_TYPE_HISTPREF:
1175 (void)process_histpref_file(buf + 2);
1178 (void)process_pref_file(buf + 2);
1182 /* Set back depth level */
1190 /* Process the line */
1191 err = process_pref_file_command(buf);
1193 /* This is not original pref line... */
1196 if (preftype != PREF_TYPE_AUTOPICK)
1198 err = process_autopick_file_command(buf);
1206 /* Print error message */
1207 /* ToDo: Add better error messages */
1209 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1210 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1212 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1213 msg_format("Parsing '%s'", old);
1218 /* Close the file */
1228 * Process the "user pref file" with the given name
1230 * See the functions above for a list of legal "commands".
1232 * We also accept the special "?" and "%" directives, which
1233 * allow conditional evaluation and filename inclusion.
1235 errr process_pref_file(cptr name)
1241 /* Build the filename */
1242 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
1244 /* Process the system pref file */
1245 err1 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1247 /* Stop at parser errors, but not at non-existing file */
1248 if (err1 > 0) return err1;
1251 /* Build the filename */
1252 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
1254 /* Process the user pref file */
1255 err2 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1258 /* User file does not exist, but read system pref file */
1259 if (err2 < 0 && !err1)
1262 /* Result of user file processing */
1271 * Operating hours for ANGBAND (defaults to non-work hours)
1273 static char days[7][29] =
1275 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1276 "MON:XXXXXXXX.........XXXXXXX",
1277 "TUE:XXXXXXXX.........XXXXXXX",
1278 "WED:XXXXXXXX.........XXXXXXX",
1279 "THU:XXXXXXXX.........XXXXXXX",
1280 "FRI:XXXXXXXX.........XXXXXXX",
1281 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1285 * Restict usage (defaults to no restrictions)
1287 static bool check_time_flag = FALSE;
1295 errr check_time(void)
1303 /* No restrictions */
1304 if (!check_time_flag) return (0);
1306 /* Check for time violation */
1307 c = time((time_t *)0);
1311 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1322 * Initialize CHECK_TIME
1324 errr check_time_init(void)
1334 /* Build the filename */
1335 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
1338 fp = my_fopen(buf, "r");
1340 /* No file, no restrictions */
1341 if (!fp) return (0);
1343 /* Assume restrictions */
1344 check_time_flag = TRUE;
1346 /* Parse the file */
1347 while (0 == my_fgets(fp, buf, sizeof(buf)))
1349 /* Skip comments and blank lines */
1350 if (!buf[0] || (buf[0] == '#')) continue;
1352 /* Chop the buffer */
1355 /* Extract the info */
1356 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1357 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1358 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1359 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1360 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1361 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1362 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1378 #ifndef MAXHOSTNAMELEN
1379 # define MAXHOSTNAMELEN 64
1382 typedef struct statstime statstime;
1388 unsigned int v_pgpgin;
1389 unsigned int v_pgpgout;
1390 unsigned int v_pswpin;
1391 unsigned int v_pswpout;
1392 unsigned int v_intr;
1398 unsigned int v_swtch;
1400 struct timeval boottime;
1401 struct timeval curtime;
1405 * Maximal load (if any).
1407 static int check_load_value = 0;
1415 errr check_load(void)
1420 struct statstime st;
1422 /* Success if not checking */
1423 if (!check_load_value) return (0);
1425 /* Check the load */
1426 if (0 == rstat("localhost", &st))
1428 long val1 = (long)(st.avenrun[2]);
1429 long val2 = (long)(check_load_value) * FSCALE;
1431 /* Check for violation */
1432 if (val1 >= val2) return (1);
1443 * Initialize CHECK_LOAD
1445 errr check_load_init(void)
1454 char temphost[MAXHOSTNAMELEN+1];
1455 char thishost[MAXHOSTNAMELEN+1];
1458 /* Build the filename */
1459 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
1461 /* Open the "load" file */
1462 fp = my_fopen(buf, "r");
1464 /* No file, no restrictions */
1465 if (!fp) return (0);
1468 check_load_value = 100;
1470 /* Get the host name */
1471 (void)gethostname(thishost, (sizeof thishost) - 1);
1474 while (0 == my_fgets(fp, buf, sizeof(buf)))
1478 /* Skip comments and blank lines */
1479 if (!buf[0] || (buf[0] == '#')) continue;
1481 /* Parse, or ignore */
1482 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1484 /* Skip other hosts */
1485 if (!streq(temphost, thishost) &&
1486 !streq(temphost, "localhost")) continue;
1488 /* Use that value */
1489 check_load_value = value;
1495 /* Close the file */
1505 #define ENTRY_BARE_HAND 0
1506 #define ENTRY_TWO_HANDS 1
1507 #define ENTRY_RIGHT_HAND1 2
1508 #define ENTRY_LEFT_HAND1 3
1509 #define ENTRY_LEFT_HAND2 4
1510 #define ENTRY_RIGHT_HAND2 5
1511 #define ENTRY_POSTURE 6
1512 #define ENTRY_SHOOT_HIT_DAM 7
1513 #define ENTRY_SHOOT_POWER 8
1514 #define ENTRY_SPEED 9
1515 #define ENTRY_BASE_AC 10
1516 #define ENTRY_LEVEL 11
1517 #define ENTRY_CUR_EXP 12
1518 #define ENTRY_MAX_EXP 13
1519 #define ENTRY_EXP_TO_ADV 14
1520 #define ENTRY_GOLD 15
1521 #define ENTRY_DAY 16
1524 #define ENTRY_PLAY_TIME 19
1525 #define ENTRY_SKILL_FIGHT 20
1526 #define ENTRY_SKILL_SHOOT 21
1527 #define ENTRY_SKILL_SAVING 22
1528 #define ENTRY_SKILL_STEALTH 23
1529 #define ENTRY_SKILL_PERCEP 24
1530 #define ENTRY_SKILL_SEARCH 25
1531 #define ENTRY_SKILL_DISARM 26
1532 #define ENTRY_SKILL_DEVICE 27
1533 #define ENTRY_BLOWS 28
1534 #define ENTRY_SHOTS 29
1535 #define ENTRY_AVG_DMG 30
1536 #define ENTRY_INFRA 31
1538 #define ENTRY_NAME 32
1539 #define ENTRY_SEX 33
1540 #define ENTRY_RACE 34
1541 #define ENTRY_CLASS 35
1542 #define ENTRY_REALM 36
1543 #define ENTRY_PATRON 37
1544 #define ENTRY_AGE 38
1545 #define ENTRY_HEIGHT 39
1546 #define ENTRY_WEIGHT 40
1547 #define ENTRY_SOCIAL 41
1548 #define ENTRY_ALIGN 42
1550 #define ENTRY_EXP_ANDR 43
1551 #define ENTRY_EXP_TO_ADV_ANDR 44
1560 } disp_player_line[]
1563 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1564 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1565 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1566 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1567 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1568 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1570 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1571 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1572 { 1, 20, 25, "²Ã®"},
1573 { 1, 19, 25, "£Á£Ã"},
1574 {29, 13, 21, "¥ì¥Ù¥ë"},
1575 {29, 14, 21, "·Ð¸³ÃÍ"},
1576 {29, 15, 21, "ºÇÂç·Ð¸³"},
1577 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1578 {29, 17, 21, "½ê»ý¶â"},
1579 {29, 19, 21, "ÆüÉÕ"},
1580 {29, 10, 21, "£È£Ð"},
1581 {29, 11, 21, "£Í£Ð"},
1582 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1583 {53, 10, -1, "ÂǷ⹶·â :"},
1584 {53, 11, -1, "¼Í·â¹¶·â :"},
1585 {53, 12, -1, "ËâË¡Ëɸæ :"},
1586 {53, 13, -1, "±£Ì©¹ÔÆ° :"},
1587 {53, 15, -1, "ÃγР:"},
1588 {53, 16, -1, "õº÷ :"},
1589 {53, 17, -1, "²ò½ü :"},
1590 {53, 18, -1, "ËâË¡Æ»¶ñ :"},
1591 { 1, 12, 25, "ÂÇ·â²ó¿ô"},
1592 { 1, 17, 25, "¼Í·â²ó¿ô"},
1593 { 1, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1594 {53, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1595 {26, 1, -1, "̾Á° : "},
1596 { 1, 3, -1, "ÀÊÌ : "},
1597 { 1, 4, -1, "¼ï² : "},
1598 { 1, 5, -1, "¿¦¶È : "},
1599 { 1, 6, -1, "ËâË¡ : "},
1600 { 1, 7, -1, "¼é¸îËâ¿À : "},
1601 {29, 3, 21, "ǯÎð"},
1602 {29, 4, 21, "¿ÈĹ"},
1603 {29, 5, 21, "ÂνÅ"},
1604 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1605 {29, 7, 21, "°À"},
1606 {29, 14, 21, "¶¯²½ÅÙ"},
1607 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1611 { 1, 10, 25, "Bare hand"},
1612 { 1, 10, 25, "Two hands"},
1613 { 1, 10, 25, "Right hand"},
1614 { 1, 10, 25, "Left hand"},
1615 { 1, 11, 25, "Left hand"},
1616 { 1, 11, 25, "Right hand"},
1617 { 1, 11, 25, "Posture"},
1618 { 1, 15, 25, "Shooting"},
1619 { 1, 16, 25, "Multiplier"},
1620 { 1, 20, 25, "Speed"},
1622 {29, 13, 21, "Level"},
1623 {29, 14, 21, "Experience"},
1624 {29, 15, 21, "Max Exp"},
1625 {29, 16, 21, "Exp to Adv"},
1626 {29, 17, 21, "Gold"},
1627 {29, 19, 21, "Time"},
1628 {29, 10, 21, "Hit point"},
1629 {29, 11, 21, "SP (Mana)"},
1630 {29, 20, 21, "Play time"},
1631 {53, 10, -1, "Fighting : "},
1632 {53, 11, -1, "Bows/Throw : "},
1633 {53, 12, -1, "SavingThrow: "},
1634 {53, 13, -1, "Stealth : "},
1635 {53, 15, -1, "Perception : "},
1636 {53, 16, -1, "Searching : "},
1637 {53, 17, -1, "Disarming : "},
1638 {53, 18, -1, "MagicDevice: "},
1639 { 1, 12, 25, "Blows/Round"},
1640 { 1, 17, 25, "Shots/Round"},
1641 { 1, 13, 25, "AverageDmg/Rnd"},
1642 {53, 20, -1, "Infra-Vision: "},
1643 {26, 1, -1, "Name : "},
1644 { 1, 3, -1, "Sex : "},
1645 { 1, 4, -1, "Race : "},
1646 { 1, 5, -1, "Class : "},
1647 { 1, 6, -1, "Magic : "},
1648 { 1, 7, -1, "Patron : "},
1650 {29, 4, 21, "Height"},
1651 {29, 5, 21, "Weight"},
1652 {29, 6, 21, "Social Class"},
1653 {29, 7, 21, "Align"},
1654 {29, 14, 21, "Construction"},
1655 {29, 16, 21, "Const to Adv"},
1659 static void display_player_one_line(int entry, cptr val, byte attr)
1663 int row = disp_player_line[entry].row;
1664 int col = disp_player_line[entry].col;
1665 int len = disp_player_line[entry].len;
1666 cptr head = disp_player_line[entry].header;
1668 int head_len = strlen(head);
1670 Term_putstr(col, row, -1, TERM_WHITE, head);
1677 int val_len = len - head_len;
1678 sprintf(buf, "%*.*s", val_len, val_len, val);
1679 Term_putstr(col + head_len, row, -1, attr, buf);
1683 Term_putstr(col + head_len, row, -1, attr, val);
1690 static void display_player_melee_bonus(int hand, int hand_entry)
1693 int show_tohit = p_ptr->dis_to_h[hand];
1694 int show_todam = p_ptr->dis_to_d[hand];
1695 object_type *o_ptr = &inventory[INVEN_RARM + hand];
1697 /* Hack -- add in weapon info if known */
1698 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1699 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1702 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1704 /* Dump the bonuses to hit/dam */
1705 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1706 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1707 else if (p_ptr->ryoute)
1708 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1710 display_player_one_line(hand_entry, buf, TERM_L_BLUE);
1715 * Prints the following information on the screen.
1717 static void display_player_middle(void)
1722 int show_tohit = p_ptr->dis_to_h_b;
1726 object_type *o_ptr = &inventory[INVEN_BOW];
1733 display_player_melee_bonus(0, left_hander ? ENTRY_LEFT_HAND1 : ENTRY_RIGHT_HAND1);
1736 if (p_ptr->hidarite)
1738 display_player_melee_bonus(1, left_hander ? ENTRY_RIGHT_HAND2: ENTRY_LEFT_HAND2);
1740 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
1743 if (p_ptr->special_defense & KAMAE_MASK)
1745 for (i = 0; i < MAX_KAMAE; i++)
1747 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1751 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1753 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1758 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1760 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1764 /* Apply weapon bonuses */
1765 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1766 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1768 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1769 show_tohit += p_ptr->weapon_exp[0][o_ptr->sval] / 400;
1771 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
1774 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1776 if (inventory[INVEN_BOW].k_idx)
1778 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1780 /* Get extra "power" from "extra might" */
1781 if (p_ptr->xtra_might) tmul++;
1783 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1787 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1789 /* Dump the armor class */
1790 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1798 i = p_ptr->pspeed-110;
1800 /* Hack -- Visually "undo" the Search Mode Slowdown */
1801 if (p_ptr->action == ACTION_SEARCH) i += 10;
1806 attr = TERM_L_GREEN;
1820 attr = TERM_L_UMBER;
1827 if (IS_FAST()) tmp_speed += 10;
1828 if (p_ptr->slow) tmp_speed -= 10;
1829 if (p_ptr->lightspeed) tmp_speed = 99;
1833 if (MON_FAST(&m_list[p_ptr->riding])) tmp_speed += 10;
1834 if (MON_SLOW(&m_list[p_ptr->riding])) tmp_speed -= 10;
1840 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1843 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1845 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1856 sprintf(buf, "(%+d)", i);
1859 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1861 sprintf(buf, "Riding (%+d)", i);
1865 display_player_one_line(ENTRY_SPEED, buf, attr);
1868 /* Dump character level */
1869 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1871 /* Dump experience */
1872 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1873 else e = ENTRY_CUR_EXP;
1875 if (p_ptr->exp >= p_ptr->max_exp)
1876 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1878 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1880 /* Dump max experience */
1881 if (p_ptr->prace == RACE_ANDROID)
1884 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1886 /* Dump exp to advance */
1887 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
1888 else e = ENTRY_EXP_TO_ADV;
1890 if (p_ptr->lev >= PY_MAX_LEVEL)
1891 display_player_one_line(e, "*****", TERM_L_GREEN);
1892 else if (p_ptr->prace == RACE_ANDROID)
1893 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1895 display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1898 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1903 extract_day_hour_min(&day, &hour, &min);
1906 if (day < MAX_DAYS) sprintf(buf, "%dÆüÌÜ %2d:%02d", day, hour, min);
1907 else sprintf(buf, "*****ÆüÌÜ %2d:%02d", hour, min);
1909 if (day < MAX_DAYS) sprintf(buf, "Day %d %2d:%02d", day, hour, min);
1910 else sprintf(buf, "Day ***** %2d:%02d", hour, min);
1913 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1915 /* Dump hit point */
1916 if (p_ptr->chp >= p_ptr->mhp)
1917 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1918 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1919 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1921 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1923 /* Dump mana power */
1924 if (p_ptr->csp >= p_ptr->msp)
1925 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1926 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
1927 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1929 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1931 /* Dump play time */
1932 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1937 * Hack -- pass color info around this file
1939 static byte likert_color = TERM_WHITE;
1943 * Returns a "rating" of x depending on y
1945 static cptr likert(int x, int y)
1947 static char dummy[20] = "";
1952 /* Negative value */
1955 likert_color = TERM_L_DARK;
1963 /* Analyze the value */
1968 likert_color = TERM_RED;
1976 likert_color = TERM_L_RED;
1985 likert_color = TERM_ORANGE;
1993 likert_color = TERM_YELLOW;
2001 likert_color = TERM_YELLOW;
2010 likert_color = TERM_L_GREEN;
2022 likert_color = TERM_GREEN;
2033 likert_color = TERM_BLUE;
2041 likert_color = TERM_VIOLET;
2043 sprintf(dummy, "ÅÁÀâŪ[%d]", (int)((((x / y) - 17) * 5) / 2));
2045 sprintf(dummy, "Legendary[%d]", (int)((((x / y) - 17) * 5) / 2));
2053 * Prints ratings on certain abilities
2055 * This code is "imitated" elsewhere to "dump" a character sheet.
2057 static void display_player_various(void)
2059 int tmp, damage[2], blows1, blows2, i, basedam;
2060 int xthn, xthb, xfos, xsrh;
2061 int xdis, xdev, xsav, xstl;
2064 u32b flgs[TR_FLAG_SIZE];
2065 int shots, shot_frac;
2069 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2070 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2071 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2072 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2073 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2075 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2077 /* Shooting Skill (with current bow and normal missile) */
2078 o_ptr = &inventory[INVEN_BOW];
2079 tmp = p_ptr->to_h_b + o_ptr->to_h;
2080 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2082 /* If the player is wielding one? */
2085 s16b energy_fire = bow_energy(o_ptr->sval);
2087 /* Calculate shots per round */
2088 shots = p_ptr->num_fire * 100;
2089 shot_frac = (shots * 100 / energy_fire) % 100;
2090 shots = shots / energy_fire;
2091 if (o_ptr->name1 == ART_CRIMSON)
2095 if (p_ptr->pclass == CLASS_ARCHER)
2097 /* Extra shot at level 10 */
2098 if (p_ptr->lev >= 10) shots++;
2100 /* Extra shot at level 30 */
2101 if (p_ptr->lev >= 30) shots++;
2103 /* Extra shot at level 45 */
2104 if (p_ptr->lev >= 45) shots++;
2114 for(i = 0; i < 2; i++)
2116 damage[i] = p_ptr->dis_to_d[i] * 100;
2117 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
2119 int level = p_ptr->lev;
2125 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2126 if (p_ptr->special_defense & KAMAE_BYAKKO)
2127 basedam = monk_ave_damage[level][1];
2128 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2129 basedam = monk_ave_damage[level][2];
2131 basedam = monk_ave_damage[level][0];
2135 o_ptr = &inventory[INVEN_RARM + i];
2137 /* Average damage per round */
2140 if (object_is_known(o_ptr)) damage[i] += o_ptr->to_d * 100;
2141 basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
2142 object_flags_known(o_ptr, flgs);
2143 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2149 else if (have_flag(flgs, TR_VORPAL))
2151 /* vorpal flag only */
2155 if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2156 basedam = basedam * 7 / 2;
2160 damage[i] += basedam;
2161 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2162 if (damage[i] < 0) damage[i] = 0;
2164 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2165 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2167 /* Basic abilities */
2169 xdis = p_ptr->skill_dis;
2170 xdev = p_ptr->skill_dev;
2171 xsav = p_ptr->skill_sav;
2172 xstl = p_ptr->skill_stl;
2173 xsrh = p_ptr->skill_srh;
2174 xfos = p_ptr->skill_fos;
2177 desc = likert(xthn, 12);
2178 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2180 desc = likert(xthb, 12);
2181 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2183 desc = likert(xsav, 7);
2184 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2186 /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
2187 desc = likert((xstl > 0) ? xstl : -1, 1);
2188 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2190 desc = likert(xfos, 6);
2191 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2193 desc = likert(xsrh, 6);
2194 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2196 desc = likert(xdis, 8);
2197 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2199 desc = likert(xdev, 6);
2200 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2203 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2205 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2207 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2210 if ((damage[0]+damage[1]) == 0)
2213 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2215 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2217 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2223 * Obtain the "flags" for the player as if he was an item
2225 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2230 for (i = 0; i < TR_FLAG_SIZE; i++)
2234 switch (p_ptr->pclass)
2237 if (p_ptr->lev > 44)
2238 add_flag(flgs, TR_REGEN);
2240 if (p_ptr->lev > 29)
2241 add_flag(flgs, TR_RES_FEAR);
2244 if (p_ptr->lev > 39)
2245 add_flag(flgs, TR_RES_FEAR);
2247 case CLASS_CHAOS_WARRIOR:
2248 if (p_ptr->lev > 29)
2249 add_flag(flgs, TR_RES_CHAOS);
2250 if (p_ptr->lev > 39)
2251 add_flag(flgs, TR_RES_FEAR);
2254 case CLASS_FORCETRAINER:
2255 if ((p_ptr->lev > 9) && !heavy_armor())
2256 add_flag(flgs, TR_SPEED);
2257 if ((p_ptr->lev>24) && !heavy_armor())
2258 add_flag(flgs, TR_FREE_ACT);
2262 add_flag(flgs, TR_SPEED);
2265 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
2266 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
2267 add_flag(flgs, TR_SPEED);
2269 add_flag(flgs, TR_FREE_ACT);
2271 add_flag(flgs, TR_SLOW_DIGEST);
2272 add_flag(flgs, TR_RES_FEAR);
2273 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2274 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2275 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2277 case CLASS_MINDCRAFTER:
2279 add_flag(flgs, TR_RES_FEAR);
2280 if (p_ptr->lev > 19)
2281 add_flag(flgs, TR_SUST_WIS);
2282 if (p_ptr->lev > 29)
2283 add_flag(flgs, TR_RES_CONF);
2284 if (p_ptr->lev > 39)
2285 add_flag(flgs, TR_TELEPATHY);
2288 add_flag(flgs, TR_RES_SOUND);
2290 case CLASS_BERSERKER:
2291 add_flag(flgs, TR_SUST_STR);
2292 add_flag(flgs, TR_SUST_DEX);
2293 add_flag(flgs, TR_SUST_CON);
2294 add_flag(flgs, TR_REGEN);
2295 add_flag(flgs, TR_FREE_ACT);
2296 add_flag(flgs, TR_SPEED);
2297 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2299 case CLASS_MIRROR_MASTER:
2300 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2303 break; /* Do nothing */
2307 if (p_ptr->mimic_form)
2309 switch(p_ptr->mimic_form)
2312 add_flag(flgs, TR_HOLD_LIFE);
2313 add_flag(flgs, TR_RES_CHAOS);
2314 add_flag(flgs, TR_RES_NETHER);
2315 add_flag(flgs, TR_RES_FIRE);
2316 add_flag(flgs, TR_SEE_INVIS);
2317 add_flag(flgs, TR_SPEED);
2319 case MIMIC_DEMON_LORD:
2320 add_flag(flgs, TR_HOLD_LIFE);
2321 add_flag(flgs, TR_RES_CHAOS);
2322 add_flag(flgs, TR_RES_NETHER);
2323 add_flag(flgs, TR_RES_FIRE);
2324 add_flag(flgs, TR_RES_COLD);
2325 add_flag(flgs, TR_RES_ELEC);
2326 add_flag(flgs, TR_RES_ACID);
2327 add_flag(flgs, TR_RES_POIS);
2328 add_flag(flgs, TR_RES_CONF);
2329 add_flag(flgs, TR_RES_DISEN);
2330 add_flag(flgs, TR_RES_NEXUS);
2331 add_flag(flgs, TR_RES_FEAR);
2332 add_flag(flgs, TR_IM_FIRE);
2333 add_flag(flgs, TR_SH_FIRE);
2334 add_flag(flgs, TR_SEE_INVIS);
2335 add_flag(flgs, TR_TELEPATHY);
2336 add_flag(flgs, TR_LEVITATION);
2337 add_flag(flgs, TR_SPEED);
2340 add_flag(flgs, TR_HOLD_LIFE);
2341 add_flag(flgs, TR_RES_DARK);
2342 add_flag(flgs, TR_RES_NETHER);
2343 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2344 add_flag(flgs, TR_RES_POIS);
2345 add_flag(flgs, TR_RES_COLD);
2346 add_flag(flgs, TR_SEE_INVIS);
2347 add_flag(flgs, TR_SPEED);
2353 switch (p_ptr->prace)
2356 add_flag(flgs, TR_RES_LITE);
2359 add_flag(flgs, TR_HOLD_LIFE);
2362 add_flag(flgs, TR_FREE_ACT);
2365 add_flag(flgs, TR_RES_BLIND);
2368 add_flag(flgs, TR_RES_DARK);
2370 case RACE_HALF_TROLL:
2371 add_flag(flgs, TR_SUST_STR);
2372 if (p_ptr->lev > 14)
2374 add_flag(flgs, TR_REGEN);
2375 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
2377 add_flag(flgs, TR_SLOW_DIGEST);
2379 * Let's not make Regeneration a disadvantage
2380 * for the poor warriors who can never learn
2381 * a spell that satisfies hunger (actually
2382 * neither can rogues, but half-trolls are not
2383 * supposed to play rogues)
2389 add_flag(flgs, TR_SUST_CON);
2390 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2393 add_flag(flgs, TR_RES_LITE);
2394 add_flag(flgs, TR_SEE_INVIS);
2396 case RACE_BARBARIAN:
2397 add_flag(flgs, TR_RES_FEAR);
2399 case RACE_HALF_OGRE:
2400 add_flag(flgs, TR_SUST_STR);
2401 add_flag(flgs, TR_RES_DARK);
2403 case RACE_HALF_GIANT:
2404 add_flag(flgs, TR_RES_SHARDS);
2405 add_flag(flgs, TR_SUST_STR);
2407 case RACE_HALF_TITAN:
2408 add_flag(flgs, TR_RES_CHAOS);
2411 add_flag(flgs, TR_RES_SOUND);
2414 add_flag(flgs, TR_RES_ACID);
2415 if (p_ptr->lev > 19)
2416 add_flag(flgs, TR_IM_ACID);
2419 add_flag(flgs, TR_RES_CONF);
2420 add_flag(flgs, TR_RES_ACID);
2422 add_flag(flgs, TR_SPEED);
2425 add_flag(flgs, TR_RES_POIS);
2428 add_flag(flgs, TR_RES_DISEN);
2429 add_flag(flgs, TR_RES_DARK);
2432 add_flag(flgs, TR_RES_DARK);
2433 if (p_ptr->lev > 19)
2434 add_flag(flgs, TR_SEE_INVIS);
2436 case RACE_DRACONIAN:
2437 add_flag(flgs, TR_LEVITATION);
2439 add_flag(flgs, TR_RES_FIRE);
2441 add_flag(flgs, TR_RES_COLD);
2442 if (p_ptr->lev > 14)
2443 add_flag(flgs, TR_RES_ACID);
2444 if (p_ptr->lev > 19)
2445 add_flag(flgs, TR_RES_ELEC);
2446 if (p_ptr->lev > 34)
2447 add_flag(flgs, TR_RES_POIS);
2449 case RACE_MIND_FLAYER:
2450 add_flag(flgs, TR_SUST_INT);
2451 add_flag(flgs, TR_SUST_WIS);
2452 if (p_ptr->lev > 14)
2453 add_flag(flgs, TR_SEE_INVIS);
2454 if (p_ptr->lev > 29)
2455 add_flag(flgs, TR_TELEPATHY);
2458 add_flag(flgs, TR_RES_FIRE);
2460 add_flag(flgs, TR_SEE_INVIS);
2463 add_flag(flgs, TR_SEE_INVIS);
2464 add_flag(flgs, TR_FREE_ACT);
2465 add_flag(flgs, TR_RES_POIS);
2466 add_flag(flgs, TR_SLOW_DIGEST);
2467 if (p_ptr->lev > 34)
2468 add_flag(flgs, TR_HOLD_LIFE);
2471 add_flag(flgs, TR_SEE_INVIS);
2472 add_flag(flgs, TR_RES_SHARDS);
2473 add_flag(flgs, TR_HOLD_LIFE);
2474 add_flag(flgs, TR_RES_POIS);
2476 add_flag(flgs, TR_RES_COLD);
2479 add_flag(flgs, TR_SEE_INVIS);
2480 add_flag(flgs, TR_HOLD_LIFE);
2481 add_flag(flgs, TR_RES_NETHER);
2482 add_flag(flgs, TR_RES_POIS);
2483 add_flag(flgs, TR_SLOW_DIGEST);
2485 add_flag(flgs, TR_RES_COLD);
2488 add_flag(flgs, TR_HOLD_LIFE);
2489 add_flag(flgs, TR_RES_DARK);
2490 add_flag(flgs, TR_RES_NETHER);
2491 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2492 add_flag(flgs, TR_RES_POIS);
2493 add_flag(flgs, TR_RES_COLD);
2496 add_flag(flgs, TR_LEVITATION);
2497 add_flag(flgs, TR_FREE_ACT);
2498 add_flag(flgs, TR_RES_COLD);
2499 add_flag(flgs, TR_SEE_INVIS);
2500 add_flag(flgs, TR_HOLD_LIFE);
2501 add_flag(flgs, TR_RES_NETHER);
2502 add_flag(flgs, TR_RES_POIS);
2503 add_flag(flgs, TR_SLOW_DIGEST);
2505 if (p_ptr->lev > 34)
2506 add_flag(flgs, TR_TELEPATHY);
2509 add_flag(flgs, TR_RES_LITE);
2510 add_flag(flgs, TR_LEVITATION);
2512 add_flag(flgs, TR_SPEED);
2515 add_flag(flgs, TR_RES_SOUND);
2516 add_flag(flgs, TR_RES_CONF);
2519 add_flag(flgs, TR_LEVITATION);
2520 add_flag(flgs, TR_SEE_INVIS);
2523 add_flag(flgs, TR_RES_FIRE);
2524 add_flag(flgs, TR_RES_NETHER);
2525 add_flag(flgs, TR_HOLD_LIFE);
2527 add_flag(flgs, TR_SEE_INVIS);
2530 add_flag(flgs, TR_SUST_CON);
2533 add_flag(flgs, TR_LEVITATION);
2536 add_flag(flgs, TR_RES_CONF);
2539 add_flag(flgs, TR_FREE_ACT);
2540 add_flag(flgs, TR_RES_POIS);
2541 add_flag(flgs, TR_SLOW_DIGEST);
2542 add_flag(flgs, TR_HOLD_LIFE);
2552 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2554 remove_flag(flgs, TR_REGEN);
2557 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2558 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2559 (p_ptr->muta3 & MUT3_SHORT_LEG))
2561 add_flag(flgs, TR_SPEED);
2564 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2566 add_flag(flgs, TR_SH_ELEC);
2569 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2571 add_flag(flgs, TR_SH_FIRE);
2572 add_flag(flgs, TR_LITE);
2575 if (p_ptr->muta3 & MUT3_WINGS)
2577 add_flag(flgs, TR_LEVITATION);
2580 if (p_ptr->muta3 & MUT3_FEARLESS)
2582 add_flag(flgs, TR_RES_FEAR);
2585 if (p_ptr->muta3 & MUT3_REGEN)
2587 add_flag(flgs, TR_REGEN);
2590 if (p_ptr->muta3 & MUT3_ESP)
2592 add_flag(flgs, TR_TELEPATHY);
2595 if (p_ptr->muta3 & MUT3_MOTION)
2597 add_flag(flgs, TR_FREE_ACT);
2601 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2602 add_flag(flgs, TR_AGGRAVATE);
2603 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2605 add_flag(flgs, TR_RES_BLIND);
2606 add_flag(flgs, TR_RES_CONF);
2607 add_flag(flgs, TR_HOLD_LIFE);
2608 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2610 add_flag(flgs, TR_SPEED);
2612 if (p_ptr->special_defense & KATA_FUUJIN)
2613 add_flag(flgs, TR_REFLECT);
2614 if (p_ptr->special_defense & KAMAE_GENBU)
2615 add_flag(flgs, TR_REFLECT);
2616 if (p_ptr->special_defense & KAMAE_SUZAKU)
2617 add_flag(flgs, TR_LEVITATION);
2618 if (p_ptr->special_defense & KAMAE_SEIRYU)
2620 add_flag(flgs, TR_RES_FIRE);
2621 add_flag(flgs, TR_RES_COLD);
2622 add_flag(flgs, TR_RES_ACID);
2623 add_flag(flgs, TR_RES_ELEC);
2624 add_flag(flgs, TR_RES_POIS);
2625 add_flag(flgs, TR_LEVITATION);
2626 add_flag(flgs, TR_SH_FIRE);
2627 add_flag(flgs, TR_SH_ELEC);
2628 add_flag(flgs, TR_SH_COLD);
2630 if (p_ptr->special_defense & KATA_MUSOU)
2632 add_flag(flgs, TR_RES_FEAR);
2633 add_flag(flgs, TR_RES_LITE);
2634 add_flag(flgs, TR_RES_DARK);
2635 add_flag(flgs, TR_RES_BLIND);
2636 add_flag(flgs, TR_RES_CONF);
2637 add_flag(flgs, TR_RES_SOUND);
2638 add_flag(flgs, TR_RES_SHARDS);
2639 add_flag(flgs, TR_RES_NETHER);
2640 add_flag(flgs, TR_RES_NEXUS);
2641 add_flag(flgs, TR_RES_CHAOS);
2642 add_flag(flgs, TR_RES_DISEN);
2643 add_flag(flgs, TR_REFLECT);
2644 add_flag(flgs, TR_HOLD_LIFE);
2645 add_flag(flgs, TR_FREE_ACT);
2646 add_flag(flgs, TR_SH_FIRE);
2647 add_flag(flgs, TR_SH_ELEC);
2648 add_flag(flgs, TR_SH_COLD);
2649 add_flag(flgs, TR_LEVITATION);
2650 add_flag(flgs, TR_LITE);
2651 add_flag(flgs, TR_SEE_INVIS);
2652 add_flag(flgs, TR_TELEPATHY);
2653 add_flag(flgs, TR_SLOW_DIGEST);
2654 add_flag(flgs, TR_REGEN);
2655 add_flag(flgs, TR_SUST_STR);
2656 add_flag(flgs, TR_SUST_INT);
2657 add_flag(flgs, TR_SUST_WIS);
2658 add_flag(flgs, TR_SUST_DEX);
2659 add_flag(flgs, TR_SUST_CON);
2660 add_flag(flgs, TR_SUST_CHR);
2665 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
2670 for (i = 0; i < TR_FLAG_SIZE; i++)
2673 if (IS_HERO() || p_ptr->shero)
2674 add_flag(flgs, TR_RES_FEAR);
2675 if (p_ptr->tim_invis)
2676 add_flag(flgs, TR_SEE_INVIS);
2677 if (p_ptr->tim_regen)
2678 add_flag(flgs, TR_REGEN);
2680 add_flag(flgs, TR_TELEPATHY);
2681 if (IS_FAST() || p_ptr->slow)
2682 add_flag(flgs, TR_SPEED);
2684 if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
2685 add_flag(flgs, TR_RES_ACID);
2686 if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
2687 add_flag(flgs, TR_RES_ELEC);
2688 if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
2689 add_flag(flgs, TR_RES_FIRE);
2690 if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
2691 add_flag(flgs, TR_RES_COLD);
2692 if (IS_OPPOSE_POIS())
2693 add_flag(flgs, TR_RES_POIS);
2695 if (p_ptr->special_attack & ATTACK_ACID)
2696 add_flag(flgs, TR_BRAND_ACID);
2697 if (p_ptr->special_attack & ATTACK_ELEC)
2698 add_flag(flgs, TR_BRAND_ELEC);
2699 if (p_ptr->special_attack & ATTACK_FIRE)
2700 add_flag(flgs, TR_BRAND_FIRE);
2701 if (p_ptr->special_attack & ATTACK_COLD)
2702 add_flag(flgs, TR_BRAND_COLD);
2703 if (p_ptr->special_attack & ATTACK_POIS)
2704 add_flag(flgs, TR_BRAND_POIS);
2705 if (p_ptr->special_defense & DEFENSE_ACID)
2706 add_flag(flgs, TR_IM_ACID);
2707 if (p_ptr->special_defense & DEFENSE_ELEC)
2708 add_flag(flgs, TR_IM_ELEC);
2709 if (p_ptr->special_defense & DEFENSE_FIRE)
2710 add_flag(flgs, TR_IM_FIRE);
2711 if (p_ptr->special_defense & DEFENSE_COLD)
2712 add_flag(flgs, TR_IM_COLD);
2713 if (p_ptr->wraith_form)
2714 add_flag(flgs, TR_REFLECT);
2716 if (p_ptr->tim_reflect)
2717 add_flag(flgs, TR_REFLECT);
2719 if (p_ptr->magicdef)
2721 add_flag(flgs, TR_RES_BLIND);
2722 add_flag(flgs, TR_RES_CONF);
2723 add_flag(flgs, TR_REFLECT);
2724 add_flag(flgs, TR_FREE_ACT);
2725 add_flag(flgs, TR_LEVITATION);
2727 if (p_ptr->tim_res_nether)
2729 add_flag(flgs, TR_RES_NETHER);
2731 if (p_ptr->tim_sh_fire)
2733 add_flag(flgs, TR_SH_FIRE);
2737 add_flag(flgs, TR_RES_FEAR);
2738 add_flag(flgs, TR_RES_LITE);
2739 add_flag(flgs, TR_RES_DARK);
2740 add_flag(flgs, TR_RES_BLIND);
2741 add_flag(flgs, TR_RES_CONF);
2742 add_flag(flgs, TR_RES_SOUND);
2743 add_flag(flgs, TR_RES_SHARDS);
2744 add_flag(flgs, TR_RES_NETHER);
2745 add_flag(flgs, TR_RES_NEXUS);
2746 add_flag(flgs, TR_RES_CHAOS);
2747 add_flag(flgs, TR_RES_DISEN);
2748 add_flag(flgs, TR_REFLECT);
2749 add_flag(flgs, TR_HOLD_LIFE);
2750 add_flag(flgs, TR_FREE_ACT);
2751 add_flag(flgs, TR_SH_FIRE);
2752 add_flag(flgs, TR_SH_ELEC);
2753 add_flag(flgs, TR_SH_COLD);
2754 add_flag(flgs, TR_LEVITATION);
2755 add_flag(flgs, TR_LITE);
2756 add_flag(flgs, TR_SEE_INVIS);
2757 add_flag(flgs, TR_TELEPATHY);
2758 add_flag(flgs, TR_SLOW_DIGEST);
2759 add_flag(flgs, TR_REGEN);
2760 add_flag(flgs, TR_SUST_STR);
2761 add_flag(flgs, TR_SUST_INT);
2762 add_flag(flgs, TR_SUST_WIS);
2763 add_flag(flgs, TR_SUST_DEX);
2764 add_flag(flgs, TR_SUST_CON);
2765 add_flag(flgs, TR_SUST_CHR);
2770 /* Mode flags for displaying player flags */
2771 #define DP_CURSE 0x01
2779 static void display_player_equippy(int y, int x, u16b mode)
2788 /* Weapon flags need only two column */
2789 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2790 else max_i = INVEN_TOTAL;
2792 /* Dump equippy chars */
2793 for (i = INVEN_RARM; i < max_i; i++)
2796 o_ptr = &inventory[i];
2798 a = object_attr(o_ptr);
2799 c = object_char(o_ptr);
2801 /* Clear the part of the screen */
2802 if (!equippy_chars || !o_ptr->k_idx)
2809 Term_putch(x + i - INVEN_RARM, y, a, c);
2814 void print_equippy(void)
2816 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2823 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2828 for (i = 0; i < TR_FLAG_SIZE; i++)
2831 /* Check equipment */
2832 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2834 u32b o_flgs[TR_FLAG_SIZE];
2839 o_ptr = &inventory[i];
2841 if (!o_ptr->k_idx) continue;
2844 object_flags_known(o_ptr, o_flgs);
2846 if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2847 if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2848 if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2849 if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2853 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2858 for (i = 0; i < TR_FLAG_SIZE; i++)
2861 if (prace_is_(RACE_SPECTRE))
2862 add_flag(flgs, TR_RES_NETHER);
2863 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2864 add_flag(flgs, TR_RES_DARK);
2865 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2866 add_flag(flgs, TR_RES_FIRE);
2867 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2868 add_flag(flgs, TR_RES_ACID);
2871 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2876 for (i = 0; i < TR_FLAG_SIZE; i++)
2879 if (p_ptr->special_defense & DEFENSE_ACID)
2880 add_flag(flgs, TR_RES_ACID);
2881 if (p_ptr->special_defense & DEFENSE_ELEC)
2882 add_flag(flgs, TR_RES_ELEC);
2883 if (p_ptr->special_defense & DEFENSE_FIRE)
2884 add_flag(flgs, TR_RES_FIRE);
2885 if (p_ptr->special_defense & DEFENSE_COLD)
2886 add_flag(flgs, TR_RES_COLD);
2887 if (p_ptr->wraith_form)
2888 add_flag(flgs, TR_RES_DARK);
2891 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2896 for (i = 0; i < TR_FLAG_SIZE; i++)
2899 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2901 add_flag(flgs, TR_RES_ACID);
2902 add_flag(flgs, TR_RES_ELEC);
2903 add_flag(flgs, TR_RES_FIRE);
2904 add_flag(flgs, TR_RES_COLD);
2906 if (prace_is_(RACE_ANDROID))
2907 add_flag(flgs, TR_RES_ELEC);
2908 if (prace_is_(RACE_ENT))
2909 add_flag(flgs, TR_RES_FIRE);
2910 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2911 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2912 add_flag(flgs, TR_RES_LITE);
2917 * A struct for storing misc. flags
2920 u32b player_flags[TR_FLAG_SIZE];
2921 u32b tim_player_flags[TR_FLAG_SIZE];
2922 u32b player_imm[TR_FLAG_SIZE];
2923 u32b tim_player_imm[TR_FLAG_SIZE];
2924 u32b player_vuln[TR_FLAG_SIZE];
2925 u32b known_obj_imm[TR_FLAG_SIZE];
2930 * Helper function, see below
2932 static void display_flag_aux(int row, int col, cptr header,
2933 int flag1, all_player_flags *f, u16b mode)
2939 if (have_flag(f->player_vuln, flag1) &&
2940 !(have_flag(f->known_obj_imm, flag1) ||
2941 have_flag(f->player_imm, flag1) ||
2942 have_flag(f->tim_player_imm, flag1)))
2946 if (!(mode & DP_IMM)) c_put_str(TERM_WHITE, header, row, col);
2949 col += strlen(header) + 1;
2951 /* Weapon flags need only two column */
2952 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2953 else max_i = INVEN_TOTAL;
2955 /* Check equipment */
2956 for (i = INVEN_RARM; i < max_i; i++)
2958 u32b flgs[TR_FLAG_SIZE];
2962 o_ptr = &inventory[i];
2965 object_flags_known(o_ptr, flgs);
2968 if (!(mode & DP_IMM))
2969 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2972 if (mode & DP_CURSE)
2974 if ((mode & DP_CURSE) && (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE)))
2975 c_put_str(TERM_WHITE, "+", row, col);
2976 if ((mode & DP_CURSE) && (o_ptr->curse_flags & TRC_PERMA_CURSE))
2977 c_put_str(TERM_WHITE, "*", row, col);
2981 if (have_flag(flgs, flag1))
2982 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
2983 (mode & DP_IMM) ? "*" : "+", row, col);
2990 /* Assume that player flag is already written */
2991 if (mode & DP_IMM) return;
2994 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2997 if (have_flag(f->player_flags, flag1)) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2999 /* Timed player flags */
3000 if (have_flag(f->tim_player_flags, flag1)) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3003 if (have_flag(f->tim_player_imm, flag1)) c_put_str(TERM_YELLOW, "*", row, col);
3004 if (have_flag(f->player_imm, flag1)) c_put_str(TERM_WHITE, "*", row, col);
3007 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3012 * Special display, part 1
3014 static void display_player_flag_info(void)
3021 /* Extract flags and store */
3022 player_flags(f.player_flags);
3023 tim_player_flags(f.tim_player_flags);
3024 player_immunity(f.player_imm);
3025 tim_player_immunity(f.tim_player_imm);
3026 known_obj_immunity(f.known_obj_imm);
3027 player_vuln_flags(f.player_vuln);
3034 display_player_equippy(row-2, col+8, 0);
3035 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3038 display_flag_aux(row+0, col, "ÂÑ»À :", TR_RES_ACID, &f, 0);
3039 display_flag_aux(row+0, col, "ÂÑ»À :", TR_IM_ACID, &f, DP_IMM);
3040 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_RES_ELEC, &f, 0);
3041 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_IM_ELEC, &f, DP_IMM);
3042 display_flag_aux(row+2, col, "ÂѲбê:", TR_RES_FIRE, &f, 0);
3043 display_flag_aux(row+2, col, "ÂѲбê:", TR_IM_FIRE, &f, DP_IMM);
3044 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_RES_COLD, &f, 0);
3045 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_IM_COLD, &f, DP_IMM);
3046 display_flag_aux(row+4, col, "ÂÑÆÇ :", TR_RES_POIS, &f, 0);
3047 display_flag_aux(row+5, col, "ÂÑÁ®¸÷:", TR_RES_LITE, &f, 0);
3048 display_flag_aux(row+6, col, "ÂѰŹõ:", TR_RES_DARK, &f, 0);
3049 display_flag_aux(row+7, col, "ÂÑÇËÊÒ:", TR_RES_SHARDS, &f, 0);
3050 display_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", TR_RES_BLIND, &f, 0);
3051 display_flag_aux(row+9, col, "ÂѺ®Íð:", TR_RES_CONF, &f, 0);
3053 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3054 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3055 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3056 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3057 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3058 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3059 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3060 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3061 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3062 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3063 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3064 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3065 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3066 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3075 display_player_equippy(row-2, col+8, 0);
3077 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3080 display_flag_aux(row+0, col, "Âѹ첻:", TR_RES_SOUND, &f, 0);
3081 display_flag_aux(row+1, col, "ÂÑÃϹö:", TR_RES_NETHER, &f, 0);
3082 display_flag_aux(row+2, col, "ÂÑ°øº®:", TR_RES_NEXUS, &f, 0);
3083 display_flag_aux(row+3, col, "ÂÑ¥«¥ª:", TR_RES_CHAOS, &f, 0);
3084 display_flag_aux(row+4, col, "ÂÑÎô²½:", TR_RES_DISEN, &f, 0);
3085 display_flag_aux(row+5, col, "ÂѶ²ÉÝ:", TR_RES_FEAR, &f, 0);
3086 display_flag_aux(row+6, col, "È¿¼Í :", TR_REFLECT, &f, 0);
3087 display_flag_aux(row+7, col, "²Ð±ê¥ª:", TR_SH_FIRE, &f, 0);
3088 display_flag_aux(row+8, col, "Åŵ¤¥ª:", TR_SH_ELEC, &f, 0);
3089 display_flag_aux(row+9, col, "Î䵤¥ª:", TR_SH_COLD, &f, 0);
3091 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3092 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3093 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3094 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3095 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3096 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3097 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3098 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3099 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3100 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3109 display_player_equippy(row-2, col+12, 0);
3111 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3114 display_flag_aux(row+0, col, "²Ã® :", TR_SPEED, &f, 0);
3115 display_flag_aux(row+1, col, "ÂÑËãáã :", TR_FREE_ACT, &f, 0);
3116 display_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", TR_SEE_INVIS, &f, 0);
3117 display_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", TR_HOLD_LIFE, &f, 0);
3118 display_flag_aux(row+4, col, "·Ù¹ð :", TR_WARNING, &f, 0);
3119 display_flag_aux(row+5, col, "Ãپò½ :", TR_SLOW_DIGEST, &f, 0);
3120 display_flag_aux(row+6, col, "µÞ²óÉü :", TR_REGEN, &f, 0);
3121 display_flag_aux(row+7, col, "ÉâÍ· :", TR_LEVITATION, &f, 0);
3122 display_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", TR_LITE, &f, 0);
3123 display_flag_aux(row+9, col, "¼ö¤¤ :", 0, &f, DP_CURSE);
3125 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3126 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3127 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3128 display_flag_aux(row+3, col, "Hold Life :", TR_HOLD_LIFE, &f, 0);
3129 display_flag_aux(row+4, col, "Warning :", TR_WARNING, &f, 0);
3130 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3131 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3132 display_flag_aux(row+7, col, "Levitation:", TR_LEVITATION, &f, 0);
3133 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE, &f, 0);
3134 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3141 * Special display, part 2
3143 static void display_player_other_flag_info(void)
3150 /* Extract flags and store */
3151 player_flags(f.player_flags);
3152 tim_player_flags(f.tim_player_flags);
3153 player_immunity(f.player_imm);
3154 tim_player_immunity(f.tim_player_imm);
3155 known_obj_immunity(f.known_obj_imm);
3156 player_vuln_flags(f.player_vuln);
3163 display_player_equippy(row-2, col+12, DP_WP);
3165 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3168 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_SLAY_EVIL, &f, DP_WP);
3169 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3170 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_SLAY_UNDEAD, &f, DP_WP);
3171 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3172 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_SLAY_DEMON, &f, DP_WP);
3173 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3174 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_SLAY_DRAGON, &f, DP_WP);
3175 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3176 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_SLAY_HUMAN, &f, DP_WP);
3177 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3178 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_SLAY_ANIMAL, &f, DP_WP);
3179 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3180 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_SLAY_ORC, &f, DP_WP);
3181 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3182 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_SLAY_TROLL, &f, DP_WP);
3183 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3184 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_SLAY_GIANT, &f, DP_WP);
3185 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3186 display_flag_aux(row+ 9, col, "Íϲò :", TR_BRAND_ACID, &f, DP_WP);
3187 display_flag_aux(row+10, col, "ÅÅ·â :", TR_BRAND_ELEC, &f, DP_WP);
3188 display_flag_aux(row+11, col, "¾Æ´þ :", TR_BRAND_FIRE, &f, DP_WP);
3189 display_flag_aux(row+12, col, "Åà·ë :", TR_BRAND_COLD, &f, DP_WP);
3190 display_flag_aux(row+13, col, "ÆÇ»¦ :", TR_BRAND_POIS, &f, DP_WP);
3191 display_flag_aux(row+14, col, "ÀÚ¤ìÌ£ :", TR_VORPAL, &f, DP_WP);
3192 display_flag_aux(row+15, col, "ÃÏ¿Ì :", TR_IMPACT, &f, DP_WP);
3193 display_flag_aux(row+16, col, "µÛ·ì :", TR_VAMPIRIC, &f, DP_WP);
3194 display_flag_aux(row+17, col, "¥«¥ª¥¹¸ú²Ì:", TR_CHAOTIC, &f, DP_WP);
3195 display_flag_aux(row+18, col, "ÍýÎÏ :", TR_FORCE_WEAPON, &f, DP_WP);
3197 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3198 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3199 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3200 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3201 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3202 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3203 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3204 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3205 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3206 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3207 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3208 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3209 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3210 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3211 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3212 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3213 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3214 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3215 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3216 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3217 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3218 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3219 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3220 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3221 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3222 display_flag_aux(row+16, col, "Vampiric :", TR_VAMPIRIC, &f, DP_WP);
3223 display_flag_aux(row+17, col, "Chaotic :", TR_CHAOTIC, &f, DP_WP);
3224 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3233 display_player_equippy(row-2, col+12, 0);
3234 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3237 display_flag_aux(row+ 0, col, "¥Æ¥ì¥Ñ¥·¡¼:", TR_TELEPATHY, &f, 0);
3238 display_flag_aux(row+ 1, col, "¼Ù°ESP :", TR_ESP_EVIL, &f, 0);
3239 display_flag_aux(row+ 2, col, "̵À¸ÊªESP :", TR_ESP_NONLIVING, &f, 0);
3240 display_flag_aux(row+ 3, col, "Á±ÎÉESP :", TR_ESP_GOOD, &f, 0);
3241 display_flag_aux(row+ 4, col, "ÉÔ»àESP :", TR_ESP_UNDEAD, &f, 0);
3242 display_flag_aux(row+ 5, col, "°ËâESP :", TR_ESP_DEMON, &f, 0);
3243 display_flag_aux(row+ 6, col, "ζESP :", TR_ESP_DRAGON, &f, 0);
3244 display_flag_aux(row+ 7, col, "¿Í´ÖESP :", TR_ESP_HUMAN, &f, 0);
3245 display_flag_aux(row+ 8, col, "ưʪESP :", TR_ESP_ANIMAL, &f, 0);
3246 display_flag_aux(row+ 9, col, "¥ª¡¼¥¯ESP :", TR_ESP_ORC, &f, 0);
3247 display_flag_aux(row+10, col, "¥È¥í¥ëESP :", TR_ESP_TROLL, &f, 0);
3248 display_flag_aux(row+11, col, "µð¿ÍESP :", TR_ESP_GIANT, &f, 0);
3250 display_flag_aux(row+13, col, "ÏÓÎÏ°Ý»ý :", TR_SUST_STR, &f, 0);
3251 display_flag_aux(row+14, col, "ÃÎÎÏ°Ý»ý :", TR_SUST_INT, &f, 0);
3252 display_flag_aux(row+15, col, "¸¤µ°Ý»ý :", TR_SUST_WIS, &f, 0);
3253 display_flag_aux(row+16, col, "´ïÍÑ°Ý»ý :", TR_SUST_DEX, &f, 0);
3254 display_flag_aux(row+17, col, "Âѵװݻý :", TR_SUST_CON, &f, 0);
3255 display_flag_aux(row+18, col, "Ì¥ÎÏ°Ý»ý :", TR_SUST_CHR, &f, 0);
3257 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3258 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3259 display_flag_aux(row+ 2, col, "ESP Noliv.:", TR_ESP_NONLIVING, &f, 0);
3260 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3261 display_flag_aux(row+ 4, col, "ESP Undead:", TR_ESP_UNDEAD, &f, 0);
3262 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3263 display_flag_aux(row+ 6, col, "ESP Dragon:", TR_ESP_DRAGON, &f, 0);
3264 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3265 display_flag_aux(row+ 8, col, "ESP Animal:", TR_ESP_ANIMAL, &f, 0);
3266 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3267 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3268 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3270 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3271 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3272 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3273 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3274 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3275 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3282 col = col + 12 + 17;
3284 display_player_equippy(row-2, col+14, 0);
3286 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3289 display_flag_aux(row+ 0, col, "Äɲù¶·â :", TR_BLOWS, &f, 0);
3290 display_flag_aux(row+ 1, col, "ºÎ·¡ :", TR_TUNNEL, &f, 0);
3291 display_flag_aux(row+ 2, col, "ÀÖ³°Àþ»ëÎÏ :", TR_INFRA, &f, 0);
3292 display_flag_aux(row+ 3, col, "ËâË¡Æ»¶ñ»ÙÇÛ:", TR_MAGIC_MASTERY, &f, 0);
3293 display_flag_aux(row+ 4, col, "±£Ì© :", TR_STEALTH, &f, 0);
3294 display_flag_aux(row+ 5, col, "õº÷ :", TR_SEARCH, &f, 0);
3296 display_flag_aux(row+ 7, col, "¾èÇÏ :", TR_RIDING, &f, 0);
3297 display_flag_aux(row+ 8, col, "ÅêÚ³ :", TR_THROW, &f, 0);
3298 display_flag_aux(row+ 9, col, "½ËÊ¡ :", TR_BLESSED, &f, 0);
3299 display_flag_aux(row+10, col, "È¿¥Æ¥ì¥Ý¡¼¥È:", TR_NO_TELE, &f, 0);
3300 display_flag_aux(row+11, col, "È¿ËâË¡ :", TR_NO_MAGIC, &f, 0);
3301 display_flag_aux(row+12, col, "¾ÃÈñËâÎϸº¾¯:", TR_DEC_MANA, &f, 0);
3303 display_flag_aux(row+14, col, "·Ð¸³Ã͸º¾¯ :", TR_DRAIN_EXP, &f, 0);
3304 display_flag_aux(row+15, col, "Íð¥Æ¥ì¥Ý¡¼¥È:", TR_TELEPORT, &f, 0);
3305 display_flag_aux(row+16, col, "È¿´¶ :", TR_AGGRAVATE, &f, 0);
3306 display_flag_aux(row+17, col, "ÂÀ¸Å¤Î±åÇ° :", TR_TY_CURSE, &f, 0);
3308 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3309 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3310 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3311 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3312 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3313 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3315 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3316 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3317 display_flag_aux(row+ 9, col, "Blessed :", TR_BLESSED, &f, 0);
3318 display_flag_aux(row+10, col, "No Teleport :", TR_NO_TELE, &f, 0);
3319 display_flag_aux(row+11, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3320 display_flag_aux(row+12, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3322 display_flag_aux(row+14, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3323 display_flag_aux(row+15, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3324 display_flag_aux(row+16, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3325 display_flag_aux(row+17, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3332 * Special display, part 2a
3334 static void display_player_misc_info(void)
3339 /* Display basics */
3341 put_str("̾Á° :", 1, 26);
3342 put_str("ÀÊÌ :", 3, 1);
3343 put_str("¼ï² :", 4, 1);
3344 put_str("¿¦¶È :", 5, 1);
3346 put_str("Name :", 1, 26);
3347 put_str("Sex :", 3, 1);
3348 put_str("Race :", 4, 1);
3349 put_str("Class :", 5, 1);
3352 strcpy(tmp,ap_ptr->title);
3359 strcat(tmp,player_name);
3361 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3362 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3363 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3364 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3366 /* Display extras */
3368 put_str("¥ì¥Ù¥ë:", 6, 1);
3369 put_str("£È£Ð :", 7, 1);
3370 put_str("£Í£Ð :", 8, 1);
3372 put_str("Level :", 6, 1);
3373 put_str("Hits :", 7, 1);
3374 put_str("Mana :", 8, 1);
3378 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3379 c_put_str(TERM_L_BLUE, buf, 6, 9);
3380 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3381 c_put_str(TERM_L_BLUE, buf, 7, 9);
3382 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3383 c_put_str(TERM_L_BLUE, buf, 8, 9);
3388 * Special display, part 2b
3390 * How to print out the modifications and sustains.
3391 * Positive mods with no sustain will be light green.
3392 * Positive mods with a sustain will be dark green.
3393 * Sustains (with no modification) will be a dark green 's'.
3394 * Negative mods (from a curse) will be red.
3395 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3396 * No mod, no sustain, will be a slate '.'
3398 static void display_player_stat_info(void)
3405 u32b flgs[TR_FLAG_SIZE];
3419 /* Print out the labels for the columns */
3421 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3422 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3423 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3424 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3425 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3427 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3428 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3429 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3430 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3431 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3435 /* Display the stats */
3436 for (i = 0; i < 6; i++)
3440 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3441 else r_adj = rp_ptr->r_adj[i];
3443 /* Calculate equipment adjustment */
3446 /* Icky formula to deal with the 18 barrier */
3447 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3448 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3449 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3450 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3451 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3452 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3454 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3455 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3457 if (prace_is_(RACE_ENT))
3463 if (p_ptr->lev > 25) r_adj++;
3464 if (p_ptr->lev > 40) r_adj++;
3465 if (p_ptr->lev > 45) r_adj++;
3468 if (p_ptr->lev > 25) r_adj--;
3469 if (p_ptr->lev > 40) r_adj--;
3470 if (p_ptr->lev > 45) r_adj--;
3476 e_adj -= cp_ptr->c_adj[i];
3477 e_adj -= ap_ptr->a_adj[i];
3479 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3480 /* Reduced name of stat */
3481 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3483 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3486 /* Internal "natural" max value. Maxes at 18/100 */
3487 /* This is useful to see if you are maxed out */
3488 cnv_stat(p_ptr->stat_max[i], buf);
3489 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3492 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3494 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3497 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3499 /* Race, class, and equipment modifiers */
3500 (void)sprintf(buf, "%3d", r_adj);
3501 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3502 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3503 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3504 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3505 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3506 (void)sprintf(buf, "%3d", (int)e_adj);
3507 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3509 /* Actual maximal modified value */
3510 cnv_stat(p_ptr->stat_top[i], buf);
3511 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3513 /* Only display stat_use if not maximal */
3514 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3516 cnv_stat(p_ptr->stat_use[i], buf);
3517 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3522 col = stat_col + 41;
3524 /* Header and Footer */
3525 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3527 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3529 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3533 /* Process equipment */
3534 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3537 o_ptr = &inventory[i];
3539 /* Acquire "known" flags */
3540 object_flags_known(o_ptr, flgs);
3542 /* Initialize color based of sign of pval. */
3543 for (stat = 0; stat < 6; stat++)
3550 if (have_flag(flgs, stat))
3556 if (o_ptr->pval > 0)
3562 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3565 if (have_flag(flgs, stat + TR_SUST_STR))
3567 /* Dark green for sustained stats */
3572 if (o_ptr->pval < 0)
3578 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3583 else if (have_flag(flgs, stat + TR_SUST_STR))
3585 /* Dark green "s" */
3590 /* Dump proper character */
3591 Term_putch(col, row + stat+1, a, c);
3602 for (stat = 0; stat < 6; stat++)
3609 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3615 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3616 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3617 if (p_ptr->tsuyoshi) dummy += 4;
3619 else if (stat == A_WIS || stat == A_INT)
3621 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3622 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3624 else if (stat == A_DEX)
3626 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3627 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3628 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3630 else if (stat == A_CON)
3632 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3633 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3634 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3635 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3636 if (p_ptr->tsuyoshi) dummy += 4;
3638 else if (stat == A_CHR)
3640 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3641 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3642 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3643 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3644 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3645 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3661 if (dummy < 10) c = '0' + dummy;
3671 if (dummy > -10) c = '0' - dummy;
3678 if (have_flag(flgs, stat + TR_SUST_STR))
3680 /* Dark green "s" */
3687 Term_putch(col, row + stat+1, a, c);
3693 * Display the character on the screen (various modes)
3695 * The top one and bottom two lines are left blank.
3697 * Mode 0 = standard display with skills
3698 * Mode 1 = standard display with history
3699 * Mode 2 = summary of various things
3700 * Mode 3 = summary of various things (part 2)
3701 * Mode 4 = mutations
3703 void display_player(int mode)
3712 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3721 if ((mode == 0) || (mode == 1))
3723 /* Name, Sex, Race, Class */
3725 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3727 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3730 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3731 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3732 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3733 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3738 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3740 strcpy(tmp, realm_names[p_ptr->realm1]);
3741 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3744 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3745 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3747 /* Age, Height, Weight, Social */
3748 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
3750 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
3751 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3752 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3753 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3755 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3756 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3757 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3758 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3760 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3763 /* Display the stats */
3764 for (i = 0; i < 6; i++)
3766 /* Special treatment of "injured" stats */
3767 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3771 /* Use lowercase stat name */
3772 put_str(stat_names_reduced[i], 3 + i, 53);
3774 /* Get the current stat */
3775 value = p_ptr->stat_use[i];
3777 /* Obtain the current stat (modified) */
3778 cnv_stat(value, buf);
3780 /* Display the current stat (modified) */
3781 c_put_str(TERM_YELLOW, buf, 3 + i, 60);
3783 /* Acquire the max stat */
3784 value = p_ptr->stat_top[i];
3786 /* Obtain the maximum stat (modified) */
3787 cnv_stat(value, buf);
3789 /* Display the maximum stat (modified) */
3790 c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
3793 /* Normal treatment of "normal" stats */
3796 /* Assume uppercase stat name */
3797 put_str(stat_names[i], 3 + i, 53);
3799 /* Obtain the current stat (modified) */
3800 cnv_stat(p_ptr->stat_use[i], buf);
3802 /* Display the current stat (modified) */
3803 c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
3806 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3809 c_put_str(TERM_WHITE, "!", 3 + i, 58);
3811 c_put_str(TERM_WHITE, "!", 3 + i, 58-2);
3816 /* Display "history" info */
3822 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
3824 put_str("(Character Background)", 11, 25);
3827 for (i = 0; i < 4; i++)
3829 put_str(p_ptr->history[i], i + 12, 10);
3836 if (p_ptr->total_winner)
3839 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å%s¤·¤¿¡£", streq(p_ptr->died_from, "Seppuku") ? "ÀÚÊ¢" : "°úÂà");
3841 sprintf(statmsg, "...You %s after the winning.", streq(p_ptr->died_from, "Seppuku") ? "did Seppuku" : "retired from the adventure");
3844 else if (!dun_level)
3847 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), p_ptr->died_from);
3849 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3852 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3854 /* Get the quest text */
3855 /* Bewere that INIT_ASSIGN resets the cur_num. */
3856 init_flags = INIT_ASSIGN;
3858 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3861 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3863 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3869 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
3871 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3875 else if (character_dungeon)
3880 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
3882 sprintf(statmsg, "...Now, you are in %s.", map_name());
3885 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3887 /* Clear the text */
3888 /* Must be done before doing INIT_SHOW_TEXT */
3889 for (i = 0; i < 10; i++)
3891 quest_text[i][0] = '\0';
3893 quest_text_line = 0;
3895 /* Get the quest text */
3896 init_flags = INIT_SHOW_TEXT;
3898 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3901 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
3903 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
3909 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
3911 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
3918 char temp[64*2], *t;
3919 roff_to_buf(statmsg, 60, temp, sizeof(temp));
3921 for(i=0 ; i<2 ; i++)
3927 put_str(t, i + 5 + 12, 10);
3935 /* Display "various" info */
3938 display_player_middle();
3939 display_player_various();
3946 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
3949 display_player_misc_info();
3950 display_player_stat_info();
3951 display_player_flag_info();
3957 display_player_other_flag_info();
3962 do_cmd_knowledge_mutations();
3970 static void dump_aux_display_player(FILE *fff)
3977 /* Display player */
3980 /* Dump part of the screen */
3981 for (y = 1; y < 22; y++)
3984 for (x = 0; x < 79; x++)
3986 /* Get the attr/char */
3987 (void)(Term_what(x, y, &a, &c));
3993 /* End the string */
3996 /* Kill trailing spaces */
3997 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4001 fprintf(fff, "%s\n", buf);
4003 fprintf(fff, "%s\n", buf);
4008 /* Display history */
4011 /* Dump part of the screen */
4012 for (y = 10; y < 19; y++)
4015 for (x = 0; x < 79; x++)
4017 /* Get the attr/char */
4018 (void)(Term_what(x, y, &a, &c));
4024 /* End the string */
4027 /* Kill trailing spaces */
4028 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4031 fprintf(fff, "%s\n", buf);
4036 /* Display flags (part 1) */
4039 /* Dump part of the screen */
4040 for (y = 2; y < 22; y++)
4043 for (x = 0; x < 79; x++)
4045 /* Get the attr/char */
4046 (void)(Term_what(x, y, &a, &c));
4048 /* Dump it (Ignore equippy tile graphic) */
4055 /* End the string */
4058 /* Kill trailing spaces */
4059 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4062 fprintf(fff, "%s\n", buf);
4067 /* Display flags (part 2) */
4070 /* Dump part of the screen */
4071 for (y = 1; y < 22; y++)
4074 for (x = 0; x < 79; x++)
4076 /* Get the attr/char */
4077 (void)(Term_what(x, y, &a, &c));
4079 /* Dump it (Ignore equippy tile graphic) */
4086 /* End the string */
4089 /* Kill trailing spaces */
4090 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4093 fprintf(fff, "%s\n", buf);
4096 for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
4099 for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
4107 static void dump_aux_pet(FILE *fff)
4111 bool pet_settings = FALSE;
4114 for (i = m_max - 1; i >= 1; i--)
4116 monster_type *m_ptr = &m_list[i];
4118 if (!m_ptr->r_idx) continue;
4119 if (!is_pet(m_ptr)) continue;
4120 pet_settings = TRUE;
4121 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4125 fprintf(fff, "\n\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4127 fprintf(fff, "\n\n [Leading Pets]\n\n");
4131 monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
4132 fprintf(fff, "%s\n", pet_name);
4138 fprintf(fff, "\n\n [¥Ú¥Ã¥È¤Ø¤ÎÌ¿Îá]\n");
4140 fprintf(fff, "\n\n [Command for Pets]\n");
4144 fprintf(fff, "\n ¥É¥¢¤ò³«¤±¤ë: %s", (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4146 fprintf(fff, "\n Pets open doors: %s", (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4150 fprintf(fff, "\n ¥¢¥¤¥Æ¥à¤ò½¦¤¦: %s", (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4152 fprintf(fff, "\n Pets pick up items: %s", (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4156 fprintf(fff, "\n ¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4158 fprintf(fff, "\n Allow teleport: %s", (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4162 fprintf(fff, "\n ¹¶·âËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4164 fprintf(fff, "\n Allow cast attack spell: %s", (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4168 fprintf(fff, "\n ¾¤´ËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4170 fprintf(fff, "\n Allow cast summon spell: %s", (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4174 fprintf(fff, "\n ¥×¥ì¥¤¥ä¡¼¤ò´¬¤¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4176 fprintf(fff, "\n Allow involve player in area spell: %s", (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4187 static void dump_aux_class_special(FILE *fff)
4189 if (p_ptr->pclass == CLASS_BLUE_MAGE)
4196 int spellnum[MAX_MONSPELLS];
4197 s32b f4 = 0, f5 = 0, f6 = 0;
4202 for (i=0;i<60;i++) { p[i][0] = '\0'; }
4205 strcat(p[col], "\n\n [³Ø½¬ºÑ¤ß¤ÎÀÄËâË¡]\n");
4207 strcat(p[col], "\n\n [Learned Blue Magic]\n");
4214 set_rf_masks(&f4, &f5, &f6, j);
4217 case MONSPELL_TYPE_BOLT:
4219 strcat(p[col], "\n [¥Ü¥ë¥È·¿]\n");
4221 strcat(p[col], "\n [Bolt Type]\n");
4225 case MONSPELL_TYPE_BALL:
4227 strcat(p[col], "\n [¥Ü¡¼¥ë·¿]\n");
4229 strcat(p[col], "\n [Ball Type]\n");
4233 case MONSPELL_TYPE_BREATH:
4235 strcat(p[col], "\n [¥Ö¥ì¥¹·¿]\n");
4237 strcat(p[col], "\n [ Breath ]\n");
4241 case MONSPELL_TYPE_SUMMON:
4243 strcat(p[col], "\n [¾¤´ËâË¡]\n");
4245 strcat(p[col], "\n [Summonning]\n");
4249 case MONSPELL_TYPE_OTHER:
4251 strcat(p[col], "\n [ ¤½¤Î¾ ]\n");
4253 strcat(p[col], "\n [Other Type]\n");
4258 for (i = 0, num = 0; i < 32; i++)
4260 if ((0x00000001 << i) & f4) spellnum[num++] = i;
4264 if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
4268 if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
4273 strcat(p[col], " ");
4275 for (i = 0; i < num; i++)
4277 if (p_ptr->magic_num2[spellnum[i]])
4280 /* Dump blue magic */
4281 l1 = strlen(p[col]);
4282 l2 = strlen(monster_powers_short[spellnum[i]]);
4283 if ((l1 + l2) >= 75)
4285 strcat(p[col], "\n");
4287 strcat(p[col], " ");
4289 strcat(p[col], monster_powers_short[spellnum[i]]);
4290 strcat(p[col], ", ");
4297 strcat(p[col], "¤Ê¤·");
4299 strcat(p[col], "None");
4304 if (p[col][strlen(p[col])-2] == ',')
4306 p[col][strlen(p[col])-2] = '\0';
4310 p[col][strlen(p[col])-10] = '\0';
4314 strcat(p[col], "\n");
4317 for (i=0;i<=col;i++)
4328 static void dump_aux_quest(FILE *fff)
4336 fprintf(fff, "\n\n [¥¯¥¨¥¹¥È¾ðÊó]\n");
4338 fprintf(fff, "\n\n [Quest Information]\n");
4341 /* Allocate Memory */
4342 C_MAKE(quest_num, max_quests, int);
4344 /* Sort by compete level */
4345 for (i = 1; i < max_quests; i++) quest_num[i] = i;
4346 ang_sort_comp = ang_sort_comp_quest_num;
4347 ang_sort_swap = ang_sort_swap_quest_num;
4348 ang_sort(quest_num, &dummy, max_quests);
4350 /* Dump Quest Information */
4352 do_cmd_knowledge_quests_completed(fff, quest_num);
4354 do_cmd_knowledge_quests_failed(fff, quest_num);
4358 C_KILL(quest_num, max_quests, int);
4365 static void dump_aux_last_message(FILE *fff)
4369 if (!p_ptr->total_winner)
4374 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4376 fprintf(fff, "\n [Last Messages]\n\n");
4378 for (i = MIN(message_num(), 30); i >= 0; i--)
4380 fprintf(fff,"> %s\n",message_str((s16b)i));
4385 /* Hack -- *Winning* message */
4386 else if (p_ptr->last_message)
4389 fprintf(fff, "\n [*¾¡Íø*¥á¥Ã¥»¡¼¥¸]\n\n");
4391 fprintf(fff, "\n [*Winning* Message]\n\n");
4393 fprintf(fff," %s\n", p_ptr->last_message);
4403 static void dump_aux_recall(FILE *fff)
4408 fprintf(fff, "\n [µ¢´Ô¾ì½ê]\n\n");
4410 fprintf(fff, "\n [Recall Depth]\n\n");
4413 for (y = 1; y < max_d_idx; y++)
4417 if (!d_info[y].maxdepth) continue;
4418 if (!max_dlv[y]) continue;
4419 if (d_info[y].final_guardian)
4421 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4423 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4426 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4428 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4437 static void dump_aux_options(FILE *fff)
4440 fprintf(fff, "\n [¥ª¥×¥·¥ç¥óÀßÄê]\n");
4442 fprintf(fff, "\n [Option Settings]\n");
4448 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4450 fprintf(fff, "\n Preserve Mode: ON");
4455 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4457 fprintf(fff, "\n Preserve Mode: OFF");
4461 if (ironman_small_levels)
4463 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4465 fprintf(fff, "\n Small Levels: ALWAYS");
4468 else if (always_small_levels)
4470 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4472 fprintf(fff, "\n Small Levels: ON");
4475 else if (small_levels)
4477 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4479 fprintf(fff, "\n Small Levels: ENABLED");
4484 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4486 fprintf(fff, "\n Small Levels: OFF");
4492 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4494 fprintf(fff, "\n Vanilla Town: ON");
4499 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4501 fprintf(fff, "\n Lite Town: ON");
4507 fprintf(fff, "\n Ź¤Ê¤·: ON");
4509 fprintf(fff, "\n No Shops: ON");
4513 if (ironman_downward)
4515 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4517 fprintf(fff, "\n Diving Only: ON");
4523 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°: ON");
4525 fprintf(fff, "\n Unusual Rooms: ON");
4529 if (ironman_nightmare)
4531 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4533 fprintf(fff, "\n Nightmare Mode: ON");
4537 if (ironman_empty_levels)
4539 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4541 fprintf(fff, "\n Arena Levels: ALWAYS");
4544 else if (empty_levels)
4546 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ENABLED");
4548 fprintf(fff, "\n Arena Levels: ENABLED");
4553 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4555 fprintf(fff, "\n Arena Levels: OFF");
4563 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤¤¤Þ¤¹¡£\n");
4565 fprintf(fff, "\n You have done something illegal.\n");
4575 static void dump_aux_arena(FILE *fff)
4577 if (lite_town || vanilla_town) return;
4579 if (p_ptr->arena_number < 0)
4581 if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
4584 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4586 fprintf(fff, "\n Arena: Defeated\n");
4592 fprintf(fff, "\n Æ®µ»¾ì: %d²óÀï¤Ç%s¤ÎÁ°¤ËÇÔËÌ\n", -p_ptr->arena_number,
4593 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
4595 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
4596 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
4597 -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
4601 else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
4604 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4606 fprintf(fff, "\n Arena: True Champion\n");
4609 else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
4612 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4614 fprintf(fff, "\n Arena: Champion\n");
4620 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4622 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");
4633 static void dump_aux_monsters(FILE *fff)
4635 /* Monsters slain */
4638 long uniq_total = 0;
4639 long norm_total = 0;
4642 /* Sort by monster level */
4646 fprintf(fff, "\n [Åݤ·¤¿¥â¥ó¥¹¥¿¡¼]\n\n");
4648 fprintf(fff, "\n [Defeated Monsters]\n\n");
4651 /* Allocate the "who" array */
4652 C_MAKE(who, max_r_idx, s16b);
4654 /* Count monster kills */
4655 for (k = 1; k < max_r_idx; k++)
4657 monster_race *r_ptr = &r_info[k];
4659 /* Ignore unused index */
4660 if (!r_ptr->name) continue;
4662 /* Unique monsters */
4663 if (r_ptr->flags1 & RF1_UNIQUE)
4665 bool dead = (r_ptr->max_num == 0);
4670 /* Add a unique monster to the list */
4671 who[uniq_total++] = k;
4675 /* Normal monsters */
4678 if (r_ptr->r_pkills > 0)
4680 norm_total += r_ptr->r_pkills;
4686 /* No monsters is defeated */
4690 fprintf(fff,"¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4692 fprintf(fff,"You have defeated no enemies yet.\n");
4696 /* Defeated more than one normal monsters */
4697 else if (uniq_total == 0)
4700 fprintf(fff,"%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", norm_total);
4702 fprintf(fff,"You have defeated %ld %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
4706 /* Defeated more than one unique monsters */
4707 else /* if (uniq_total > 0) */
4710 fprintf(fff, "%ldÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ò´Þ¤à¡¢¹ç·×%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", uniq_total, norm_total);
4712 fprintf(fff, "You have defeated %ld %s including %ld unique monster%s in total.\n", norm_total, norm_total == 1 ? "enemy" : "enemies", uniq_total, (uniq_total == 1 ? "" : "s"));
4716 /* Select the sort method */
4717 ang_sort_comp = ang_sort_comp_hook;
4718 ang_sort_swap = ang_sort_swap_hook;
4720 /* Sort the array by dungeon depth of monsters */
4721 ang_sort(who, &why, uniq_total);
4724 fprintf(fff, "\n¡Ô¾å°Ì%ldÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¡Õ\n", MIN(uniq_total, 10));
4726 fprintf(fff, "\n< Unique monsters top %ld >\n", MIN(uniq_total, 10));
4730 for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
4732 monster_race *r_ptr = &r_info[who[k]];
4735 fprintf(fff, " %-40s (¥ì¥Ù¥ë%3d)\n", (r_name + r_ptr->name), r_ptr->level);
4737 fprintf(fff, " %-40s (level %3d)\n", (r_name + r_ptr->name), r_ptr->level);
4743 /* Free the "who" array */
4744 C_KILL(who, max_r_idx, s16b);
4751 static void dump_aux_race_history(FILE *fff)
4753 if (p_ptr->old_race1 || p_ptr->old_race2)
4758 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4760 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4762 for (i = 0; i < MAX_RACES; i++)
4764 if (p_ptr->start_race == i) continue;
4767 if (!(p_ptr->old_race1 & 1L << i)) continue;
4771 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4774 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4776 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4788 static void dump_aux_realm_history(FILE *fff)
4790 if (p_ptr->old_realm)
4795 for (i = 0; i < MAX_MAGIC; i++)
4797 if (!(p_ptr->old_realm & 1L << i)) continue;
4799 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4801 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4812 static void dump_aux_virtues(FILE *fff)
4815 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4817 fprintf(fff, "\n\n [Virtues]\n\n");
4821 fprintf(fff, "°À : %s\n", your_alignment());
4823 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4834 static void dump_aux_mutations(FILE *fff)
4836 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4839 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4841 fprintf(fff, "\n\n [Mutations]\n\n");
4844 dump_mutations(fff);
4852 static void dump_aux_equipment_inventory(FILE *fff)
4855 char o_name[MAX_NLEN];
4857 /* Dump the equipment */
4861 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷]\n\n");
4863 fprintf(fff, " [Character Equipment]\n\n");
4866 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4868 object_desc(o_name, &inventory[i], 0);
4869 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
4871 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4873 strcpy(o_name, "(wielding with two-hands)");
4876 fprintf(fff, "%c) %s\n",
4877 index_to_label(i), o_name);
4879 fprintf(fff, "\n\n");
4882 /* Dump the inventory */
4884 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ]\n\n");
4886 fprintf(fff, " [Character Inventory]\n\n");
4889 for (i = 0; i < INVEN_PACK; i++)
4891 /* Don't dump the empty slots */
4892 if (!inventory[i].k_idx) break;
4894 /* Dump the inventory slots */
4895 object_desc(o_name, &inventory[i], 0);
4896 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
4899 /* Add an empty line */
4900 fprintf(fff, "\n\n");
4907 static void dump_aux_home_museum(FILE *fff)
4909 char o_name[MAX_NLEN];
4912 /* Do we need it?? */
4913 /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
4915 /* Print the home */
4916 st_ptr = &town[1].store[STORE_HOME];
4918 /* Home -- if anything there */
4919 if (st_ptr->stock_num)
4925 fprintf(fff, " [²æ¤¬²È¤Î¥¢¥¤¥Æ¥à]\n");
4927 fprintf(fff, " [Home Inventory]\n");
4930 /* Dump all available items */
4931 for (i = 0; i < st_ptr->stock_num; i++)
4935 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4937 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);
4943 /* Add an empty line */
4944 fprintf(fff, "\n\n");
4948 /* Print the home */
4949 st_ptr = &town[1].store[STORE_MUSEUM];
4951 /* Home -- if anything there */
4952 if (st_ptr->stock_num)
4958 fprintf(fff, " [Çîʪ´Û¤Î¥¢¥¤¥Æ¥à]\n");
4960 fprintf(fff, " [Museum]\n");
4963 /* Dump all available items */
4964 for (i = 0; i < st_ptr->stock_num; i++)
4967 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4968 object_desc(o_name, &st_ptr->stock[i], 0);
4969 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4971 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4972 object_desc(o_name, &st_ptr->stock[i], 0);
4973 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4978 /* Add an empty line */
4979 fprintf(fff, "\n\n");
4985 * Output the character dump to a file
4987 errr make_character_dump(FILE *fff)
4990 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4991 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4993 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4994 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4999 dump_aux_display_player(fff);
5000 dump_aux_last_message(fff);
5001 dump_aux_options(fff);
5002 dump_aux_recall(fff);
5003 dump_aux_quest(fff);
5004 dump_aux_arena(fff);
5005 dump_aux_monsters(fff);
5006 dump_aux_virtues(fff);
5007 dump_aux_race_history(fff);
5008 dump_aux_realm_history(fff);
5009 dump_aux_class_special(fff);
5010 dump_aux_mutations(fff);
5013 dump_aux_equipment_inventory(fff);
5014 dump_aux_home_museum(fff);
5017 fprintf(fff, " [¥Á¥§¥Ã¥¯¥µ¥à: \"%s\"]\n\n", get_check_sum());
5019 fprintf(fff, " [Check Sum: \"%s\"]\n\n", get_check_sum());
5026 * Hack -- Dump a character description file
5028 * XXX XXX XXX Allow the "full" flag to dump additional info,
5029 * and trigger its usage from various places in the code.
5031 errr file_character(cptr name)
5037 /* Build the filename */
5038 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
5040 /* File type is "TEXT" */
5041 FILE_TYPE(FILE_TYPE_TEXT);
5043 /* Check for existing file */
5044 fd = fd_open(buf, O_RDONLY);
5051 /* Close the file */
5056 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
5058 (void)sprintf(out_val, "Replace existing file %s? ", buf);
5063 if (get_check_strict(out_val, CHECK_NO_HISTORY)) fd = -1;
5066 /* Open the non-existing file */
5067 if (fd < 0) fff = my_fopen(buf, "w");
5074 prt("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", 0, 0);
5076 prt("Character dump failed!", 0, 0);
5085 (void)make_character_dump(fff);
5093 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
5095 msg_print("Character dump successful.");
5106 * Display single line of on-line help file
5108 * You can insert some special color tag to change text color.
5110 * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
5112 * A colored segment is between "[[[[y|" and the last "|".
5113 * You can use any single character in place of the "|".
5115 static void show_file_aux_line(cptr str, int cy, cptr shower)
5117 static const char tag_str[] = "[[[[";
5118 byte color = TERM_WHITE;
5126 /* Make a lower case version of str for searching */
5131 /* Initial cursor position */
5132 Term_gotoxy(cx, cy);
5134 for (i = 0; str[i];)
5136 int len = strlen(&str[i]);
5137 int showercol = len + 1;
5138 int bracketcol = len + 1;
5142 /* Search for a shower string in the line */
5145 ptr = my_strstr(&lcstr[i], shower);
5146 if (ptr) showercol = ptr - &lcstr[i];
5149 /* Search for a color segment tag */
5150 ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
5151 if (ptr) bracketcol = ptr - &str[i];
5153 /* A color tag is found */
5154 if (bracketcol < endcol) endcol = bracketcol;
5156 /* The shower string is found before the color tag */
5157 if (showercol < endcol) endcol = showercol;
5159 /* Print a segment of the line */
5160 Term_addstr(endcol, color, &str[i]);
5164 /* Shower string? */
5165 if (endcol == showercol)
5167 int showerlen = strlen(shower);
5169 /* Print the shower string in yellow */
5170 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
5175 /* Colored segment? */
5176 else if (endcol == bracketcol)
5180 /* Found the end of colored segment */
5183 /* Now looking for an another tag_str */
5186 /* Set back to the default color */
5191 /* Found a tag_str, and get a tag color */
5192 i += sizeof(tag_str)-1;
5195 color = color_char_to_attr(str[i]);
5197 /* Illegal color tag */
5198 if (color == 255 || str[i+1] == '\0')
5200 /* Illegal color tag */
5203 /* Print the broken tag as a string */
5204 Term_addstr(-1, TERM_WHITE, tag_str);
5205 cx += sizeof(tag_str)-1;
5209 /* Skip the color tag */
5212 /* Now looking for a close tag */
5215 /* Skip the close-tag-indicator */
5221 } /* for (i = 0; str[i];) */
5223 /* Clear rest of line */
5224 Term_erase(cx, cy, 255);
5229 * Recursive file perusal.
5231 * Process various special text in the input file, including
5232 * the "menu" structures used by the "help file" system.
5234 * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
5236 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
5240 /* Number of "real" lines passed by */
5243 /* Number of "real" lines in the file */
5246 /* Backup value for "line" */
5249 /* This screen has sub-screens */
5252 /* Current help file */
5255 /* Find this string (if any) */
5258 /* Jump to this tag */
5261 /* Hold strings to find/show */
5262 char finder_str[81];
5263 char shower_str[81];
5265 /* String to show */
5269 char filename[1024];
5271 /* Describe this thing */
5277 /* General buffer */
5280 /* Sub-menu information */
5283 bool reverse = (line < 0);
5287 Term_get_size(&wid, &hgt);
5291 strcpy(finder_str, "");
5294 strcpy(shower_str, "");
5297 strcpy(caption, "");
5299 /* Wipe the hooks */
5300 for (i = 0; i < 68; i++)
5305 /* Copy the filename */
5306 strcpy(filename, name);
5308 n = strlen(filename);
5310 /* Extract the tag from the filename */
5311 for (i = 0; i < n; i++)
5313 if (filename[i] == '#')
5316 tag = filename + i + 1;
5321 /* Redirect the name */
5324 /* Hack XXX XXX XXX */
5328 strcpy(caption, what);
5330 /* Access the "file" */
5334 fff = my_fopen(path, "r");
5337 /* Look in "help" */
5342 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5344 sprintf(caption, "Help file '%s'", name);
5348 /* Build the filename */
5349 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5352 fff = my_fopen(path, "r");
5355 /* Look in "info" */
5360 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5362 sprintf(caption, "Info file '%s'", name);
5366 /* Build the filename */
5367 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5370 fff = my_fopen(path, "r");
5373 /* Look in "info" */
5376 /* Build the filename */
5377 path_build(path, sizeof(path), ANGBAND_DIR, name);
5379 for (i = 0; path[i]; i++)
5380 if ('\\' == path[i])
5381 path[i] = PATH_SEP[0];
5385 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5387 sprintf(caption, "Info file '%s'", name);
5391 fff = my_fopen(path, "r");
5399 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5401 msg_format("Cannot open '%s'.", name);
5411 /* Pre-Parse the file */
5416 /* Read a line or stop */
5417 if (my_fgets(fff, buf, sizeof(buf))) break;
5419 /* XXX Parse "menu" items */
5420 if (prefix(str, "***** "))
5422 /* Notice "menu" requests */
5423 if ((str[6] == '[') && isalpha(str[7]))
5425 /* Extract the menu item */
5426 int k = str[7] - 'A';
5428 /* This is a menu file */
5431 if ((str[8] == ']') && (str[9] == ' '))
5433 /* Extract the menu item */
5434 strncpy(hook[k], str + 10, 31);
5436 /* Make sure it's null-terminated */
5440 /* Notice "tag" requests */
5441 else if (str[6] == '<')
5443 size_t len = strlen(str);
5445 if (str[len - 1] == '>')
5447 str[len - 1] = '\0';
5448 if (tag && streq(str + 7, tag)) line = next;
5456 /* Count the "real" lines */
5460 /* Save the number of "real" lines */
5463 /* start from bottom when reverse mode */
5464 if (line == -1) line = ((size-1)/rows)*rows;
5469 /* Display the file */
5472 /* Restart when necessary */
5473 if (line >= size - rows) line = size - rows;
5474 if (line < 0) line = 0;
5476 /* Re-open the file if needed */
5482 /* Hack -- Re-Open the file */
5483 fff = my_fopen(path, "r");
5486 if (!fff) return (FALSE);
5488 /* File has been restarted */
5492 /* Goto the selected line */
5496 if (my_fgets(fff, buf, sizeof(buf))) break;
5498 /* Skip tags/links */
5499 if (prefix(buf, "***** ")) continue;
5501 /* Count the lines */
5505 /* Dump the next 20, or rows, lines of the file */
5506 for (i = 0; i < rows; )
5510 /* Hack -- track the "first" line */
5511 if (!i) line = next;
5513 /* Get a line of the file or stop */
5514 if (my_fgets(fff, buf, sizeof(buf))) break;
5516 /* Hack -- skip "special" lines */
5517 if (prefix(buf, "***** ")) continue;
5519 /* Count the "real" lines */
5522 /* Hack -- keep searching */
5527 /* Make a lower case version of str for searching */
5528 strcpy(lc_buf, str);
5529 str_tolower(lc_buf);
5531 if (!my_strstr(lc_buf, find)) continue;
5534 /* Hack -- stop searching */
5538 show_file_aux_line(str, i + 2, shower);
5540 /* Count the printed lines */
5546 /* Clear rest of line */
5547 Term_erase(0, i + 2, 255);
5552 /* Hack -- failed search */
5562 /* Show a general "title" */
5567 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5569 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5572 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5573 caption, line, size), 0, 0);
5583 caption, line, size), 0, 0);
5586 /* Prompt -- small files */
5591 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5593 prt("[Press ESC to exit.]", hgt - 1, 0);
5598 /* Prompt -- large files */
5603 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5605 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5607 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5611 /* Get a special key code */
5612 skey = inkey_special(TRUE);
5614 /* Show the help for the help */
5617 /* Hack - prevent silly recursion */
5619 if (strcmp(name, "jhelpinfo.txt") != 0)
5620 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5622 if (strcmp(name, "helpinfo.txt") != 0)
5623 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5627 /* Hack -- try showing */
5632 prt("¶¯Ä´: ", hgt - 1, 0);
5634 prt("Show: ", hgt - 1, 0);
5637 (void)askfor(shower_str, 80);
5639 /* Make it lowercase */
5640 str_tolower(shower_str);
5643 shower = shower_str;
5646 /* Hack -- try finding */
5647 if (skey == '/' || skey == KTRL('s'))
5651 prt("¸¡º÷: ", hgt - 1, 0);
5653 prt("Find: ", hgt - 1, 0);
5657 if (askfor(finder_str, 80))
5664 /* Make finder lowercase */
5665 str_tolower(finder_str);
5668 shower = finder_str;
5672 /* Hack -- go to a specific line */
5677 prt("¹Ô: ", hgt - 1, 0);
5679 prt("Goto Line: ", hgt - 1, 0);
5684 if (askfor(tmp, 80))
5690 /* Hack -- go to the top line */
5691 if (skey == SKEY_TOP)
5696 /* Hack -- go to the bottom line */
5697 if (skey == SKEY_BOTTOM)
5699 line = ((size-1)/rows)*rows;
5702 /* Hack -- go to a specific file */
5707 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5708 strcpy(tmp, "jhelp.hlp");
5710 prt("Goto File: ", hgt - 1, 0);
5711 strcpy(tmp, "help.hlp");
5715 if (askfor(tmp, 80))
5717 if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
5721 /* Allow backing up */
5724 line = line + (reverse ? rows : -rows);
5725 if (line < 0) line = 0;
5729 if (skey == SKEY_PGUP)
5732 if (line < 0) line = 0;
5735 /* Advance a single line */
5736 if ((skey == '\n') || (skey == '\r'))
5738 line = line + (reverse ? -1 : 1);
5739 if (line < 0) line = 0;
5743 /* Move up / down */
5744 if (skey == '8' || skey == SKEY_UP)
5747 if (line < 0) line = 0;
5750 if (skey == '2' || skey == SKEY_DOWN) line++;
5752 /* Advance one page */
5755 line = line + (reverse ? -rows : rows);
5756 if (line < 0) line = 0;
5760 if (skey == SKEY_PGDOWN)
5765 /* Recurse on numbers */
5770 if (!(skey & SKEY_MASK) && isalpha(skey))
5773 if ((key > -1) && hook[key][0])
5775 /* Recurse on that file */
5776 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5781 /* Hack, dump to file */
5791 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5793 if (!get_string("File name: ", xtmp, 80))
5802 /* Build the filename */
5803 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5805 /* Hack -- Re-Open the file */
5806 fff = my_fopen(path, "r");
5808 ffp = my_fopen(buff, "w");
5814 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5816 msg_print("Failed to open file.");
5823 sprintf(xtmp, "%s: %s", player_name, what ? what : caption);
5824 my_fputs(ffp, xtmp, 80);
5825 my_fputs(ffp, "\n", 80);
5827 while (!my_fgets(fff, buff, sizeof(buff)))
5828 my_fputs(ffp, buff, 80);
5834 /* Hack -- Re-Open the file */
5835 fff = my_fopen(path, "r");
5838 /* Return to last screen */
5839 if (skey == ESCAPE) break;
5840 if (skey == '<') break;
5842 /* Exit on the ^q */
5843 if (skey == KTRL('q')) skey = 'q';
5845 /* Exit on the q key */
5846 if (skey == 'q') break;
5849 /* Close the file */
5853 if (skey == 'q') return (FALSE);
5861 * Peruse the On-Line-Help
5863 void do_cmd_help(void)
5868 /* Peruse the main help file */
5870 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5872 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5882 * Process the player name.
5883 * Extract a clean "base name".
5884 * Build the savefile name if needed.
5886 void process_player_name(bool sf)
5889 char old_player_base[32] = "";
5891 if (character_generated) strcpy(old_player_base, player_base);
5893 /* Cannot be too long */
5894 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5896 if (strlen(player_name) > 8)
5898 if (strlen(player_name) > 15)
5903 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5905 quit_fmt("The name '%s' is too long!", player_name);
5911 /* Cannot contain "icky" characters */
5912 for (i = 0; player_name[i]; i++)
5914 /* No control characters */
5916 if (iskanji(player_name[i])){i++;continue;}
5917 if (iscntrl( (unsigned char)player_name[i]))
5919 if (iscntrl(player_name[i]))
5923 /* Illegal characters */
5925 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5927 quit_fmt("The name '%s' contains control chars!", player_name);
5936 /* Extract "useful" letters */
5937 for (i = 0; player_name[i]; i++)
5940 unsigned char c = player_name[i];
5942 char c = player_name[i];
5946 /* Convert "dot" to "underscore" */
5947 if (c == '.') c = '_';
5949 /* Accept all the letters */
5950 player_base[k++] = c;
5955 /* Extract "useful" letters */
5956 for (i = 0; player_name[i]; i++)
5959 unsigned char c = player_name[i];
5961 char c = player_name[i];
5964 /* Accept some letters */
5967 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5968 player_base[k++] = c;
5970 player_base[k++] = player_name[i];
5973 else if (iskana(c)) player_base[k++] = c;
5977 /* Convert path separator to underscore */
5978 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5979 player_base[k++] = '_';
5980 i += strlen(PATH_SEP);
5983 /* Convert space, dot, and underscore to underscore */
5984 else if (my_strchr(". _", c)) player_base[k++] = '_';
5986 else if (isprint(c)) player_base[k++] = c;
5994 /* Hack -- max length */
6000 player_base[k] = '\0';
6002 /* Require a "base" name */
6003 if (!player_base[0]) strcpy(player_base, "PLAYER");
6006 #ifdef SAVEFILE_MUTABLE
6012 if (!savefile_base[0] && savefile[0])
6019 t = my_strstr(s, PATH_SEP);
6024 strcpy(savefile_base, s);
6027 if (!savefile_base[0] || !savefile[0])
6030 /* Change the savefile name */
6035 strcpy(savefile_base, player_base);
6037 #ifdef SAVEFILE_USE_UID
6038 /* Rename the savefile, using the player_uid and player_base */
6039 (void)sprintf(temp, "%d.%s", player_uid, player_base);
6041 /* Rename the savefile, using the player_base */
6042 (void)sprintf(temp, "%s", player_base);
6046 /* Hack -- support "flat directory" usage on VM/ESA */
6047 (void)sprintf(temp, "%s.sv", player_base);
6050 /* Build the filename */
6051 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
6054 /* Load an autopick preference file */
6055 if (character_generated)
6057 if (!streq(old_player_base, player_base)) autopick_load_pref(FALSE);
6063 * Gets a name for the character, reacting to name changes.
6065 * Assumes that "display_player(0)" has just been called
6067 * Perhaps we should NOT ask for a name (at "birth()") on
6068 * Unix machines? XXX XXX
6070 * What a horrible name for a global function. XXX XXX XXX
6076 /* Save the player name */
6077 strcpy(tmp, player_name);
6079 /* Prompt for a new name */
6081 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
6083 if (get_string("Enter a name for your character: ", tmp, 15))
6087 strcpy(player_name, tmp);
6089 else if (0 == strlen(player_name))
6091 /* Use default name */
6092 strcpy(player_name, "PLAYER");
6095 strcpy(tmp,ap_ptr->title);
6102 strcat(tmp,player_name);
6104 /* Re-Draw the name (in light blue) */
6105 Term_erase(34, 1, 255);
6106 c_put_str(TERM_L_BLUE, tmp, 1, 34);
6108 /* Erase the prompt, etc */
6115 * Hack -- commit suicide
6117 void do_cmd_suicide(void)
6124 /* Verify Retirement */
6125 if (p_ptr->total_winner)
6129 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
6131 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
6136 /* Verify Suicide */
6141 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
6143 if (!get_check("Do you really want to commit suicide? ")) return;
6148 if (!p_ptr->noscore)
6150 /* Special Verification for suicide */
6152 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
6154 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
6160 if (i != '@') return;
6163 /* Initialize "last message" buffer */
6164 if (p_ptr->last_message) string_free(p_ptr->last_message);
6165 p_ptr->last_message = NULL;
6167 /* Hack -- Note *winning* message */
6168 if (p_ptr->total_winner && last_words)
6170 char buf[1024] = "";
6175 while (!get_string("*¾¡Íø*¥á¥Ã¥»¡¼¥¸: ", buf, sizeof buf)) ;
6177 while (!get_string("*Winning* message: ", buf, sizeof buf)) ;
6181 while (!get_check_strict("¤è¤í¤·¤¤¤Ç¤¹¤«¡©", CHECK_NO_HISTORY));
6183 while (!get_check_strict("Are you sure? ", CHECK_NO_HISTORY));
6188 p_ptr->last_message = string_make(buf);
6189 msg_print(p_ptr->last_message);
6194 p_ptr->playing = FALSE;
6196 /* Kill the player */
6197 p_ptr->is_dead = TRUE;
6200 p_ptr->leaving = TRUE;
6202 if (!p_ptr->total_winner)
6205 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
6206 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
6208 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
6209 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
6211 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
6214 /* Cause of death */
6216 (void)strcpy(p_ptr->died_from, "ÅÓÃ潪λ");
6218 (void)strcpy(p_ptr->died_from, "Quitting");
6228 void do_cmd_save_game(int is_autosave)
6230 /* Autosaves do not disturb */
6234 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
6236 msg_print("Autosaving the game...");
6242 /* Disturb the player */
6246 /* Clear messages */
6254 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6256 prt("Saving game...", 0, 0);
6263 /* The player is not dead */
6265 (void)strcpy(p_ptr->died_from, "(¥»¡¼¥Ö)");
6267 (void)strcpy(p_ptr->died_from, "(saved)");
6271 /* Forbid suspend */
6272 signals_ignore_tstp();
6274 /* Save the player */
6278 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6280 prt("Saving game... done.", 0, 0);
6285 /* Save failed (oops) */
6289 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6291 prt("Saving game... failed!", 0, 0);
6296 /* Allow suspend again */
6297 signals_handle_tstp();
6302 /* Note that the player is not dead */
6304 (void)strcpy(p_ptr->died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6306 (void)strcpy(p_ptr->died_from, "(alive and well)");
6309 /* HACK -- don't get sanity blast on updating view */
6315 /* Initialize monster process */
6318 /* HACK -- reset the hackish flag */
6324 * Save the game and exit
6326 void do_cmd_save_and_exit(void)
6328 p_ptr->playing = FALSE;
6331 p_ptr->leaving = TRUE;
6333 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6335 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6341 * Hack -- Calculates the total number of points earned -JWT-
6343 long total_points(void)
6347 u32b point, point_h, point_l;
6348 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6350 if (!preserve_mode) mult += 10;
6351 if (!autoroller) mult += 10;
6352 if (!smart_learn) mult -= 20;
6353 if (smart_cheat) mult += 30;
6354 if (ironman_shops) mult += 50;
6355 if (ironman_small_levels) mult += 10;
6356 if (ironman_empty_levels) mult += 20;
6357 if (!powerup_home) mult += 50;
6358 if (ironman_rooms) mult += 100;
6359 if (ironman_nightmare) mult += 100;
6361 if (mult < 5) mult = 5;
6363 for (i = 0; i < max_d_idx; i++)
6364 if(max_dlv[i] > max_dl)
6365 max_dl = max_dlv[i];
6367 point_l = (p_ptr->max_max_exp + (100 * max_dl));
6368 point_h = point_l / 0x10000L;
6369 point_l = point_l % 0x10000L;
6372 point_h += point_l / 0x10000L;
6373 point_l %= 0x10000L;
6375 point_l += ((point_h % 100) << 16);
6379 point = (point_h << 16) + (point_l);
6380 if (p_ptr->arena_number >= 0)
6381 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6383 if (ironman_downward) point *= 2;
6384 if (p_ptr->pclass == CLASS_BERSERKER)
6386 if ( p_ptr->prace == RACE_SPECTRE )
6390 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6393 if (p_ptr->total_winner) point = 2;
6395 if (easy_band) point = (0 - point);
6401 #define GRAVE_LINE_WIDTH 31
6404 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
6406 static void center_string(char *buf, cptr str)
6413 /* Necessary border */
6414 j = GRAVE_LINE_WIDTH / 2 - i / 2;
6417 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
6423 * Save a "bones" file for a dead character
6425 * Note that we will not use these files until Angband 2.8.0, and
6426 * then we will only use the name and level on which death occured.
6428 * Should probably attempt some form of locking...
6430 static void make_bones(void)
6437 /* Ignore wizards and borgs */
6438 if (!(p_ptr->noscore & 0x00FF))
6440 /* Ignore people who die in town */
6445 /* XXX XXX XXX "Bones" name */
6446 sprintf(tmp, "bone.%03d", dun_level);
6448 /* Build the filename */
6449 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6451 /* Attempt to open the bones file */
6452 fp = my_fopen(str, "r");
6454 /* Close it right away */
6455 if (fp) my_fclose(fp);
6457 /* Do not over-write a previous ghost */
6460 /* File type is "TEXT" */
6461 FILE_TYPE(FILE_TYPE_TEXT);
6463 /* Grab permissions */
6466 /* Try to write a new "Bones File" */
6467 fp = my_fopen(str, "w");
6469 /* Drop permissions */
6472 /* Not allowed to write it? Weird. */
6476 fprintf(fp, "%s\n", player_name);
6477 fprintf(fp, "%d\n", p_ptr->mhp);
6478 fprintf(fp, "%d\n", p_ptr->prace);
6479 fprintf(fp, "%d\n", p_ptr->pclass);
6481 /* Close and save the Bones file */
6490 * Redefinable "print_tombstone" action
6492 bool (*tombstone_aux)(void) = NULL;
6496 * Display a "tomb-stone"
6498 static void print_tomb(void)
6502 /* Do we use a special tombstone ? */
6505 /* Use tombstone hook */
6506 done = (*tombstone_aux)();
6509 /* Print the text-tombstone */
6518 time_t ct = time((time_t)0);
6526 /* Build the filename */
6528 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead_j.txt");
6530 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead.txt");
6533 /* Open the News file */
6534 fp = my_fopen(buf, "r");
6541 /* Dump the file to the screen */
6542 while (0 == my_fgets(fp, buf, sizeof(buf)))
6544 /* Display and advance */
6545 put_str(buf, i++, 0);
6553 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6566 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6569 center_string(buf, player_name);
6570 put_str(buf, 6, 11);
6573 center_string(buf, "the");
6574 put_str(buf, 7, 11);
6577 center_string(buf, p);
6578 put_str(buf, 8, 11);
6580 center_string(buf, cp_ptr->title);
6581 put_str(buf, 10, 11);
6584 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6586 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6588 center_string(buf, tmp);
6589 put_str(buf, 11, 11);
6592 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6594 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6596 center_string(buf, tmp);
6597 put_str(buf, 12, 11);
6600 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6602 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6604 center_string(buf, tmp);
6605 put_str(buf, 13, 11);
6608 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6609 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6611 strcpy(tmp, "<¼«»¦>");
6613 else if (streq(p_ptr->died_from, "ripe"))
6615 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6617 else if (streq(p_ptr->died_from, "Seppuku"))
6619 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6623 roff_to_buf(p_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6624 t = tmp + strlen(tmp) + 1;
6627 strcpy(dummy, t); /* 2nd line */
6628 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6630 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
6633 else if (my_strstr(tmp, "¡Ø") && suffix(dummy, "¡Ù"))
6636 char *name_head = my_strstr(tmp, "¡Ø");
6637 sprintf(dummy2, "%s%s", name_head, dummy);
6638 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6640 strcpy(dummy, dummy2);
6644 else if (my_strstr(tmp, "¡Ö") && suffix(dummy, "¡×"))
6647 char *name_head = my_strstr(tmp, "¡Ö");
6648 sprintf(dummy2, "%s%s", name_head, dummy);
6649 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6651 strcpy(dummy, dummy2);
6655 center_string(buf, dummy);
6656 put_str(buf, 15, 11);
6660 center_string(buf, tmp);
6661 put_str(buf, 14, 11);
6663 if (!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6667 cptr town = p_ptr->town_num ? "³¹" : "¹ÓÌî";
6668 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6670 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6674 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6679 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6681 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6685 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6688 center_string(buf, tmp);
6689 put_str(buf, 15 + extra_line, 11);
6692 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6693 center_string(buf, tmp);
6694 put_str(buf, 14, 11);
6696 roff_to_buf(format("by %s.", p_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6697 center_string(buf, tmp);
6698 put_str(buf, 15, 11);
6699 t = tmp + strlen(tmp) + 1;
6702 strcpy(dummy, t); /* 2nd line */
6703 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6705 int dummy_len = strlen(dummy);
6706 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
6708 center_string(buf, dummy);
6709 put_str(buf, 16, 11);
6713 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6714 center_string(buf, tmp);
6715 put_str(buf, 17, 11);
6718 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6720 msg_format("Goodbye, %s!", player_name);
6727 * Display some character info
6729 static void show_info(void)
6735 /* Hack -- Know everything in the inven/equip */
6736 for (i = 0; i < INVEN_TOTAL; i++)
6738 o_ptr = &inventory[i];
6740 /* Skip non-objects */
6741 if (!o_ptr->k_idx) continue;
6743 /* Aware and Known */
6744 object_aware(o_ptr);
6745 object_known(o_ptr);
6748 for (i = 1; i < max_towns; i++)
6750 st_ptr = &town[i].store[STORE_HOME];
6752 /* Hack -- Know everything in the home */
6753 for (j = 0; j < st_ptr->stock_num; j++)
6755 o_ptr = &st_ptr->stock[j];
6757 /* Skip non-objects */
6758 if (!o_ptr->k_idx) continue;
6760 /* Aware and Known */
6761 object_aware(o_ptr);
6762 object_known(o_ptr);
6766 /* Hack -- Recalculate bonuses */
6767 p_ptr->update |= (PU_BONUS);
6772 /* Flush all input keys */
6775 /* Flush messages */
6779 /* Describe options */
6781 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6782 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6784 prt("You may now dump a character record to one or more files.", 21, 0);
6785 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6789 /* Dump character records as requested */
6796 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6798 put_str("Filename: ", 23, 0);
6803 strcpy(out_val, "");
6805 /* Ask for filename (or abort) */
6806 if (!askfor(out_val, 60)) return;
6808 /* Return means "show on screen" */
6809 if (!out_val[0]) break;
6814 /* Dump a character file */
6815 (void)file_character(out_val);
6823 /* Display player */
6826 /* Prompt for inventory */
6828 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6830 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6834 /* Allow abort at this point */
6835 if (inkey() == ESCAPE) return;
6838 /* Show equipment and inventory */
6840 /* Equipment -- if any */
6844 item_tester_full = TRUE;
6845 (void)show_equip(0);
6847 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6849 prt("You are using: -more-", 0, 0);
6852 if (inkey() == ESCAPE) return;
6855 /* Inventory -- if any */
6859 item_tester_full = TRUE;
6860 (void)show_inven(0);
6862 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6864 prt("You are carrying: -more-", 0, 0);
6867 if (inkey() == ESCAPE) return;
6870 /* Homes in the different towns */
6871 for (l = 1; l < max_towns; l++)
6873 st_ptr = &town[l].store[STORE_HOME];
6875 /* Home -- if anything there */
6876 if (st_ptr->stock_num)
6878 /* Display contents of the home */
6879 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6885 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6887 char o_name[MAX_NLEN];
6891 o_ptr = &st_ptr->stock[i];
6893 /* Print header, clear line */
6894 sprintf(tmp_val, "%c) ", I2A(j));
6895 prt(tmp_val, j+2, 4);
6897 /* Display object description */
6898 object_desc(o_name, o_ptr, 0);
6899 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6904 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6906 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6911 if (inkey() == ESCAPE) return;
6918 static bool check_score(void)
6924 if (highscore_fd < 0)
6927 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6929 msg_print("Score file unavailable.");
6936 #ifndef SCORE_WIZARDS
6937 /* Wizard-mode pre-empts scoring */
6938 if (p_ptr->noscore & 0x000F)
6941 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6943 msg_print("Score not registered for wizards.");
6952 /* Borg-mode pre-empts scoring */
6953 if (p_ptr->noscore & 0x00F0)
6956 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6958 msg_print("Score not registered for borgs.");
6966 #ifndef SCORE_CHEATERS
6967 /* Cheaters are not scored */
6968 if (p_ptr->noscore & 0xFF00)
6971 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6973 msg_print("Score not registered for cheaters.");
6983 if (!p_ptr->total_winner && streq(p_ptr->died_from, "¶¯À©½ªÎ»"))
6985 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Interrupting"))
6990 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6992 msg_print("Score not registered due to interruption.");
7001 if (!p_ptr->total_winner && streq(p_ptr->died_from, "ÅÓÃ潪λ"))
7003 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Quitting"))
7008 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
7010 msg_print("Score not registered due to quitting.");
7020 * Close up the current game (player may or may not be dead)
7022 * This function is called only from "main.c" and "signals.c".
7024 void close_game(void)
7027 bool do_send = TRUE;
7029 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
7034 /* Flush the messages */
7037 /* Flush the input */
7041 /* No suspending now */
7042 signals_ignore_tstp();
7045 /* Hack -- Character is now "icky" */
7046 character_icky = TRUE;
7049 /* Build the filename */
7050 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
7052 /* Grab permissions */
7055 /* Open the high score file, for reading/writing */
7056 highscore_fd = fd_open(buf, O_RDWR);
7058 /* Drop permissions */
7064 /* Handle retirement */
7065 if (p_ptr->total_winner) kingly();
7069 if (!cheat_save || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
7071 if (!cheat_save || get_check("Save death? "))
7076 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7078 if (!save_player()) msg_print("death save failed!");
7081 else do_send = FALSE;
7088 /* Show more info */
7096 if ((!send_world_score(do_send)))
7099 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7101 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7104 p_ptr->wait_report_score = TRUE;
7105 p_ptr->is_dead = FALSE;
7107 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7109 if (!save_player()) msg_print("death save failed!");
7113 if (!p_ptr->wait_report_score)
7116 else if (highscore_fd >= 0)
7118 display_scores_aux(0, 10, -1, NULL);
7121 /* Dump bones file */
7130 do_cmd_save_game(FALSE);
7132 /* Prompt for scores XXX XXX XXX */
7134 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
7136 prt("Press Return (or Escape).", 0, 40);
7140 /* Predict score (or ESCAPE) */
7141 if (inkey() != ESCAPE) predict_score();
7145 /* Shut the high score file */
7146 (void)fd_close(highscore_fd);
7148 /* Forget the high score fd */
7151 /* Kill all temporal files */
7152 clear_saved_floor_files();
7154 /* Allow suspending now */
7155 signals_handle_tstp();
7160 * Handle abrupt death of the visual system
7162 * This routine is called only in very rare situations, and only
7163 * by certain visual systems, when they experience fatal errors.
7165 * XXX XXX Hack -- clear the death flag when creating a HANGUP
7166 * save file so that player can see tombstone when restart.
7168 void exit_game_panic(void)
7170 /* If nothing important has happened, just quit */
7172 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
7174 if (!character_generated || character_saved) quit("panic");
7177 /* Mega-Hack -- see "msg_print()" */
7180 /* Clear the top line */
7183 /* Hack -- turn off some things */
7186 /* Mega-Hack -- Delay death */
7187 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
7189 /* Hardcode panic save */
7190 p_ptr->panic_save = 1;
7192 /* Forbid suspend */
7193 signals_ignore_tstp();
7195 /* Indicate panic save */
7197 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7199 (void)strcpy(p_ptr->died_from, "(panic save)");
7203 /* Panic save, or get worried */
7205 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7207 if (!save_player()) quit("panic save failed!");
7211 /* Successful panic save */
7213 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7215 quit("panic save succeeded!");
7221 * Get a random line from a file
7222 * Based on the monster speech patch by Matt Graham,
7224 errr get_rnd_line(cptr file_name, int entry, char *output)
7232 /* Build the filename */
7233 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
7236 fp = my_fopen(buf, "r");
7241 /* Find the entry of the monster */
7244 /* Get a line from the file */
7245 if (my_fgets(fp, buf, sizeof(buf)) == 0)
7247 /* Count the lines */
7250 /* Look for lines starting with 'N:' */
7251 if ((buf[0] == 'N') && (buf[1] == ':'))
7253 /* Allow default lines */
7259 else if (buf[2] == 'M')
7261 if (r_info[entry].flags1 & RF1_MALE) break;
7263 else if (buf[2] == 'F')
7265 if (r_info[entry].flags1 & RF1_FEMALE) break;
7267 /* Get the monster number */
7268 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7270 /* Is it the right number? */
7271 if (test == entry) break;
7275 /* Error while converting the number */
7276 msg_format("Error in line %d of %s!", line_num, file_name);
7284 /* Reached end of file */
7290 /* Get the random line */
7291 for (counter = 0; ; counter++)
7295 test = my_fgets(fp, buf, sizeof(buf));
7297 /* Count the lines */
7298 /* line_num++; No more needed */
7302 /* Ignore lines starting with 'N:' */
7303 if ((buf[0] == 'N') && (buf[1] == ':')) continue;
7305 if (buf[0] != '#') break;
7314 if (one_in_(counter + 1)) strcpy(output, buf);
7317 /* Close the file */
7321 return counter ? 0 : -1;
7326 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7331 for (i = 0; i < count; i++)
7333 result = get_rnd_line(file_name, entry, output);
7336 for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
7344 * Process file for auto picker/destroyer.
7346 errr process_autopick_file(cptr name)
7352 /* Build the filename */
7353 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7355 err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
7363 * Process file for player's history editor.
7365 errr process_histpref_file(cptr name)
7369 bool old_character_xtra = character_xtra;
7371 /* Build the filename */
7372 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7374 /* Hack -- prevent modification birth options in this file */
7375 character_xtra = TRUE;
7377 err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
7379 character_xtra = old_character_xtra;
7386 static errr counts_seek(int fd, u32b where, bool flag)
7389 char temp1[128], temp2[128];
7390 u32b zero_header[3] = {0L, 0L, 0L};
7393 #ifdef SAVEFILE_USE_UID
7394 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7396 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7398 for (i = 0; temp1[i]; i++)
7399 temp1[i] ^= (i+1) * 63;
7404 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7406 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7411 fd_seek(fd, seekpoint);
7412 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7413 fd_write(fd, (char*)(temp1), sizeof(temp1));
7417 if (strcmp(temp1, temp2) == 0)
7420 seekpoint += 128 + 3 * sizeof(u32b);
7423 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7426 u32b counts_read(int where)
7433 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7435 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7437 fd = fd_open(buf, O_RDONLY);
7439 if (counts_seek(fd, where, FALSE) ||
7440 fd_read(fd, (char*)(&count), sizeof(u32b)))
7448 errr counts_write(int where, u32b count)
7455 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7457 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7460 /* Grab permissions */
7463 fd = fd_open(buf, O_RDWR);
7465 /* Drop permissions */
7470 /* File type is "DATA" */
7471 FILE_TYPE(FILE_TYPE_DATA);
7473 /* Grab permissions */
7476 /* Create a new high score file */
7477 fd = fd_make(buf, 0644);
7479 /* Drop permissions */
7483 /* Grab permissions */
7486 err = fd_lock(fd, F_WRLCK);
7488 /* Drop permissions */
7493 counts_seek(fd, where, TRUE);
7494 fd_write(fd, (char*)(&count), sizeof(u32b));
7496 /* Grab permissions */
7499 err = fd_lock(fd, F_UNLCK);
7501 /* Drop permissions */
7512 #ifdef HANDLE_SIGNALS
7519 * Handle signals -- suspend
7521 * Actually suspend the game, and then resume cleanly
7523 static void handle_signal_suspend(int sig)
7525 /* Disable handler */
7526 (void)signal(sig, SIG_IGN);
7533 /* Suspend the "Term" */
7534 Term_xtra(TERM_XTRA_ALIVE, 0);
7536 /* Suspend ourself */
7537 (void)kill(0, SIGSTOP);
7539 /* Resume the "Term" */
7540 Term_xtra(TERM_XTRA_ALIVE, 1);
7542 /* Redraw the term */
7545 /* Flush the term */
7550 /* Restore handler */
7551 (void)signal(sig, handle_signal_suspend);
7556 * Handle signals -- simple (interrupt and quit)
7558 * This function was causing a *huge* number of problems, so it has
7559 * been simplified greatly. We keep a global variable which counts
7560 * the number of times the user attempts to kill the process, and
7561 * we commit suicide if the user does this a certain number of times.
7563 * We attempt to give "feedback" to the user as he approaches the
7564 * suicide thresh-hold, but without penalizing accidental keypresses.
7566 * To prevent messy accidents, we should reset this global variable
7567 * whenever the user enters a keypress, or something like that.
7569 static void handle_signal_simple(int sig)
7571 /* Disable handler */
7572 (void)signal(sig, SIG_IGN);
7575 /* Nothing to save, just quit */
7576 if (!character_generated || character_saved) quit(NULL);
7579 /* Count the signals */
7583 /* Terminate dead characters */
7586 /* Mark the savefile */
7588 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»");
7590 (void)strcpy(p_ptr->died_from, "Abortion");
7609 /* Allow suicide (after 5) */
7610 else if (signal_count >= 5)
7612 /* Cause of "death" */
7614 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»Ãæ");
7616 (void)strcpy(p_ptr->died_from, "Interrupting");
7625 p_ptr->playing = FALSE;
7628 p_ptr->is_dead = TRUE;
7631 p_ptr->leaving = TRUE;
7645 /* Give warning (after 4) */
7646 else if (signal_count >= 4)
7649 Term_xtra(TERM_XTRA_NOISE, 0);
7651 /* Clear the top line */
7652 Term_erase(0, 0, 255);
7654 /* Display the cause */
7656 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7658 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7666 /* Give warning (after 2) */
7667 else if (signal_count >= 2)
7670 Term_xtra(TERM_XTRA_NOISE, 0);
7673 /* Restore handler */
7674 (void)signal(sig, handle_signal_simple);
7679 * Handle signal -- abort, kill, etc
7681 static void handle_signal_abort(int sig)
7685 Term_get_size(&wid, &hgt);
7687 /* Disable handler */
7688 (void)signal(sig, SIG_IGN);
7691 /* Nothing to save, just quit */
7692 if (!character_generated || character_saved) quit(NULL);
7699 /* Clear the bottom line */
7700 Term_erase(0, hgt - 1, 255);
7702 /* Give a warning */
7703 Term_putstr(0, hgt - 1, -1, TERM_RED,
7705 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7707 "A gruesome software bug LEAPS out at you!");
7713 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7715 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7720 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥à°Û¾ï½ªÎ»----");
7722 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Panic Save and Abort Game ----");
7729 p_ptr->panic_save = 1;
7733 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7735 (void)strcpy(p_ptr->died_from, "(panic save)");
7739 /* Forbid suspend */
7740 signals_ignore_tstp();
7742 /* Attempt to save */
7746 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7748 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7757 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7759 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7769 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7771 quit("software bug");
7780 * Ignore SIGTSTP signals (keyboard suspend)
7782 void signals_ignore_tstp(void)
7786 (void)signal(SIGTSTP, SIG_IGN);
7792 * Handle SIGTSTP signals (keyboard suspend)
7794 void signals_handle_tstp(void)
7798 (void)signal(SIGTSTP, handle_signal_suspend);
7805 * Prepare to handle the relevant signals
7807 void signals_init(void)
7811 (void)signal(SIGHUP, SIG_IGN);
7816 (void)signal(SIGTSTP, handle_signal_suspend);
7821 (void)signal(SIGINT, handle_signal_simple);
7825 (void)signal(SIGQUIT, handle_signal_simple);
7830 (void)signal(SIGFPE, handle_signal_abort);
7834 (void)signal(SIGILL, handle_signal_abort);
7838 (void)signal(SIGTRAP, handle_signal_abort);
7842 (void)signal(SIGIOT, handle_signal_abort);
7846 (void)signal(SIGKILL, handle_signal_abort);
7850 (void)signal(SIGBUS, handle_signal_abort);
7854 (void)signal(SIGSEGV, handle_signal_abort);
7858 (void)signal(SIGTERM, handle_signal_abort);
7862 (void)signal(SIGPIPE, handle_signal_abort);
7866 (void)signal(SIGEMT, handle_signal_abort);
7870 (void)signal(SIGDANGER, handle_signal_abort);
7874 (void)signal(SIGSYS, handle_signal_abort);
7878 (void)signal(SIGXCPU, handle_signal_abort);
7882 (void)signal(SIGPWR, handle_signal_abort);
7888 #else /* HANDLE_SIGNALS */
7894 void signals_ignore_tstp(void)
7901 void signals_handle_tstp(void)
7908 void signals_init(void)
7911 #endif /* HANDLE_SIGNALS */