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(cptr *sp, char *fp)
830 while (isspace(*s)) s++;
845 t = process_pref_file_expr(&s, &f);
854 else if (streq(t, "IOR"))
857 while (*s && (f != b2))
859 t = process_pref_file_expr(&s, &f);
860 if (*t && !streq(t, "0")) v = "1";
865 else if (streq(t, "AND"))
868 while (*s && (f != b2))
870 t = process_pref_file_expr(&s, &f);
871 if (*t && streq(t, "0")) v = "0";
876 else if (streq(t, "NOT"))
879 while (*s && (f != b2))
881 t = process_pref_file_expr(&s, &f);
882 if (*t && streq(t, "1")) v = "0";
887 else if (streq(t, "EQU"))
892 t = process_pref_file_expr(&s, &f);
894 while (*s && (f != b2))
896 p = process_pref_file_expr(&s, &f);
897 if (streq(t, p)) v = "1";
902 else if (streq(t, "LEQ"))
907 t = process_pref_file_expr(&s, &f);
909 while (*s && (f != b2))
912 t = process_pref_file_expr(&s, &f);
913 if (*t && atoi(p) > atoi(t)) v = "0";
918 else if (streq(t, "GEQ"))
923 t = process_pref_file_expr(&s, &f);
925 while (*s && (f != b2))
928 t = process_pref_file_expr(&s, &f);
930 /* Compare two numbers instead of string */
931 if (*t && atoi(p) < atoi(t)) v = "0";
938 while (*s && (f != b2))
940 t = process_pref_file_expr(&s, &f);
945 if (f != b2) v = "?x?x?";
947 /* Extract final and Terminate */
948 if ((f = *s) != '\0') s++;
957 /* Accept all printables except spaces and brackets */
959 for (i = 0; (iskanji(*s) || isprint(*s)) && !my_strchr(" []", *s); i++)
961 if (iskanji(*s)) b[i++] = *s++;
965 for (i = 0; isprint(*s) && !my_strchr(" []", *s); i++) b[i] = *s++;
971 /* Extract final and Terminate */
972 if ((f = *s) != '\0') s++;
978 if (streq(b+1, "SYS"))
983 else if (streq(b+1, "KEYBOARD"))
985 v = ANGBAND_KEYBOARD;
989 else if (streq(b+1, "GRAF"))
994 /* Monochrome mode */
995 else if (streq(b+1, "MONOCHROME"))
1004 else if (streq(b+1, "RACE"))
1007 v = rp_ptr->E_title;
1014 else if (streq(b+1, "CLASS"))
1017 v = cp_ptr->E_title;
1024 else if (streq(b+1, "PLAYER"))
1030 else if (streq(b+1, "REALM1"))
1033 v = E_realm_names[p_ptr->realm1];
1035 v = realm_names[p_ptr->realm1];
1040 else if (streq(b+1, "REALM2"))
1043 v = E_realm_names[p_ptr->realm2];
1045 v = realm_names[p_ptr->realm2];
1050 else if (streq(b+1, "LEVEL"))
1052 sprintf(tmp, "%02d", p_ptr->lev);
1056 /* Autopick auto-register is in-use or not? */
1057 else if (streq(b+1, "AUTOREGISTER"))
1059 if (p_ptr->autopick_autoregister)
1084 #define PREF_TYPE_NORMAL 0
1085 #define PREF_TYPE_AUTOPICK 1
1086 #define PREF_TYPE_HISTPREF 2
1089 * Open the "user pref file" and parse it.
1091 static errr process_pref_file_aux(cptr name, int preftype)
1103 bool bypass = FALSE;
1107 fp = my_fopen(name, "r");
1110 if (!fp) return (-1);
1112 /* Process the file */
1113 while (0 == my_fgets(fp, buf, sizeof(buf)))
1118 /* Skip "empty" lines */
1119 if (!buf[0]) continue;
1121 /* Skip "blank" lines */
1123 if (!iskanji(buf[0]))
1125 if (isspace(buf[0])) continue;
1128 if (buf[0] == '#') continue;
1135 /* Process "?:<expr>" */
1136 if ((buf[0] == '?') && (buf[1] == ':'))
1145 /* Parse the expr */
1146 v = process_pref_file_expr(&s, &f);
1149 bypass = (streq(v, "0") ? TRUE : FALSE);
1155 /* Apply conditionals */
1156 if (bypass) continue;
1159 /* Process "%:<file>" */
1162 static int depth_count = 0;
1164 /* Ignore if deeper than 20 level */
1165 if (depth_count > 20) continue;
1167 /* Count depth level */
1170 /* Process that file if allowed */
1173 case PREF_TYPE_AUTOPICK:
1174 (void)process_autopick_file(buf + 2);
1176 case PREF_TYPE_HISTPREF:
1177 (void)process_histpref_file(buf + 2);
1180 (void)process_pref_file(buf + 2);
1184 /* Set back depth level */
1192 /* Process the line */
1193 err = process_pref_file_command(buf);
1195 /* This is not original pref line... */
1198 if (preftype != PREF_TYPE_AUTOPICK)
1200 err = process_autopick_file_command(buf);
1208 /* Print error message */
1209 /* ToDo: Add better error messages */
1211 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1212 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1214 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1215 msg_format("Parsing '%s'", old);
1220 /* Close the file */
1230 * Process the "user pref file" with the given name
1232 * See the functions above for a list of legal "commands".
1234 * We also accept the special "?" and "%" directives, which
1235 * allow conditional evaluation and filename inclusion.
1237 errr process_pref_file(cptr name)
1243 /* Build the filename */
1244 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
1246 /* Process the system pref file */
1247 err1 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1249 /* Stop at parser errors, but not at non-existing file */
1250 if (err1 > 0) return err1;
1253 /* Build the filename */
1254 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
1256 /* Process the user pref file */
1257 err2 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1260 /* User file does not exist, but read system pref file */
1261 if (err2 < 0 && !err1)
1264 /* Result of user file processing */
1273 * Operating hours for ANGBAND (defaults to non-work hours)
1275 static char days[7][29] =
1277 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1278 "MON:XXXXXXXX.........XXXXXXX",
1279 "TUE:XXXXXXXX.........XXXXXXX",
1280 "WED:XXXXXXXX.........XXXXXXX",
1281 "THU:XXXXXXXX.........XXXXXXX",
1282 "FRI:XXXXXXXX.........XXXXXXX",
1283 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1287 * Restict usage (defaults to no restrictions)
1289 static bool check_time_flag = FALSE;
1297 errr check_time(void)
1305 /* No restrictions */
1306 if (!check_time_flag) return (0);
1308 /* Check for time violation */
1309 c = time((time_t *)0);
1313 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1324 * Initialize CHECK_TIME
1326 errr check_time_init(void)
1336 /* Build the filename */
1337 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
1340 fp = my_fopen(buf, "r");
1342 /* No file, no restrictions */
1343 if (!fp) return (0);
1345 /* Assume restrictions */
1346 check_time_flag = TRUE;
1348 /* Parse the file */
1349 while (0 == my_fgets(fp, buf, sizeof(buf)))
1351 /* Skip comments and blank lines */
1352 if (!buf[0] || (buf[0] == '#')) continue;
1354 /* Chop the buffer */
1357 /* Extract the info */
1358 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1359 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1360 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1361 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1362 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1363 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1364 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1380 #ifndef MAXHOSTNAMELEN
1381 # define MAXHOSTNAMELEN 64
1384 typedef struct statstime statstime;
1390 unsigned int v_pgpgin;
1391 unsigned int v_pgpgout;
1392 unsigned int v_pswpin;
1393 unsigned int v_pswpout;
1394 unsigned int v_intr;
1400 unsigned int v_swtch;
1402 struct timeval boottime;
1403 struct timeval curtime;
1407 * Maximal load (if any).
1409 static int check_load_value = 0;
1417 errr check_load(void)
1422 struct statstime st;
1424 /* Success if not checking */
1425 if (!check_load_value) return (0);
1427 /* Check the load */
1428 if (0 == rstat("localhost", &st))
1430 long val1 = (long)(st.avenrun[2]);
1431 long val2 = (long)(check_load_value) * FSCALE;
1433 /* Check for violation */
1434 if (val1 >= val2) return (1);
1445 * Initialize CHECK_LOAD
1447 errr check_load_init(void)
1456 char temphost[MAXHOSTNAMELEN+1];
1457 char thishost[MAXHOSTNAMELEN+1];
1460 /* Build the filename */
1461 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
1463 /* Open the "load" file */
1464 fp = my_fopen(buf, "r");
1466 /* No file, no restrictions */
1467 if (!fp) return (0);
1470 check_load_value = 100;
1472 /* Get the host name */
1473 (void)gethostname(thishost, (sizeof thishost) - 1);
1476 while (0 == my_fgets(fp, buf, sizeof(buf)))
1480 /* Skip comments and blank lines */
1481 if (!buf[0] || (buf[0] == '#')) continue;
1483 /* Parse, or ignore */
1484 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1486 /* Skip other hosts */
1487 if (!streq(temphost, thishost) &&
1488 !streq(temphost, "localhost")) continue;
1490 /* Use that value */
1491 check_load_value = value;
1497 /* Close the file */
1507 #define ENTRY_BARE_HAND 0
1508 #define ENTRY_TWO_HANDS 1
1509 #define ENTRY_RIGHT_HAND1 2
1510 #define ENTRY_LEFT_HAND1 3
1511 #define ENTRY_LEFT_HAND2 4
1512 #define ENTRY_RIGHT_HAND2 5
1513 #define ENTRY_POSTURE 6
1514 #define ENTRY_SHOOT_HIT_DAM 7
1515 #define ENTRY_SHOOT_POWER 8
1516 #define ENTRY_SPEED 9
1517 #define ENTRY_BASE_AC 10
1518 #define ENTRY_LEVEL 11
1519 #define ENTRY_CUR_EXP 12
1520 #define ENTRY_MAX_EXP 13
1521 #define ENTRY_EXP_TO_ADV 14
1522 #define ENTRY_GOLD 15
1523 #define ENTRY_DAY 16
1526 #define ENTRY_PLAY_TIME 19
1527 #define ENTRY_SKILL_FIGHT 20
1528 #define ENTRY_SKILL_SHOOT 21
1529 #define ENTRY_SKILL_SAVING 22
1530 #define ENTRY_SKILL_STEALTH 23
1531 #define ENTRY_SKILL_PERCEP 24
1532 #define ENTRY_SKILL_SEARCH 25
1533 #define ENTRY_SKILL_DISARM 26
1534 #define ENTRY_SKILL_DEVICE 27
1535 #define ENTRY_BLOWS 28
1536 #define ENTRY_SHOTS 29
1537 #define ENTRY_AVG_DMG 30
1538 #define ENTRY_INFRA 31
1540 #define ENTRY_NAME 32
1541 #define ENTRY_SEX 33
1542 #define ENTRY_RACE 34
1543 #define ENTRY_CLASS 35
1544 #define ENTRY_REALM 36
1545 #define ENTRY_PATRON 37
1546 #define ENTRY_AGE 38
1547 #define ENTRY_HEIGHT 39
1548 #define ENTRY_WEIGHT 40
1549 #define ENTRY_SOCIAL 41
1550 #define ENTRY_ALIGN 42
1552 #define ENTRY_EXP_ANDR 43
1553 #define ENTRY_EXP_TO_ADV_ANDR 44
1562 } disp_player_line[]
1565 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1566 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1567 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1568 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1569 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1570 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1572 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1573 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1574 { 1, 20, 25, "²Ã®"},
1575 { 1, 19, 25, "£Á£Ã"},
1576 {29, 13, 21, "¥ì¥Ù¥ë"},
1577 {29, 14, 21, "·Ð¸³ÃÍ"},
1578 {29, 15, 21, "ºÇÂç·Ð¸³"},
1579 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1580 {29, 17, 21, "½ê»ý¶â"},
1581 {29, 19, 21, "ÆüÉÕ"},
1582 {29, 10, 21, "£È£Ð"},
1583 {29, 11, 21, "£Í£Ð"},
1584 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1585 {53, 10, -1, "ÂǷ⹶·â :"},
1586 {53, 11, -1, "¼Í·â¹¶·â :"},
1587 {53, 12, -1, "ËâË¡Ëɸæ :"},
1588 {53, 13, -1, "±£Ì©¹ÔÆ° :"},
1589 {53, 15, -1, "ÃγР:"},
1590 {53, 16, -1, "õº÷ :"},
1591 {53, 17, -1, "²ò½ü :"},
1592 {53, 18, -1, "ËâË¡Æ»¶ñ :"},
1593 { 1, 12, 25, "ÂÇ·â²ó¿ô"},
1594 { 1, 17, 25, "¼Í·â²ó¿ô"},
1595 { 1, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1596 {53, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1597 {26, 1, -1, "̾Á° : "},
1598 { 1, 3, -1, "ÀÊÌ : "},
1599 { 1, 4, -1, "¼ï² : "},
1600 { 1, 5, -1, "¿¦¶È : "},
1601 { 1, 6, -1, "ËâË¡ : "},
1602 { 1, 7, -1, "¼é¸îËâ¿À : "},
1603 {29, 3, 21, "ǯÎð"},
1604 {29, 4, 21, "¿ÈĹ"},
1605 {29, 5, 21, "ÂνÅ"},
1606 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1607 {29, 7, 21, "°À"},
1608 {29, 14, 21, "¶¯²½ÅÙ"},
1609 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1613 { 1, 10, 25, "Bare hand"},
1614 { 1, 10, 25, "Two hands"},
1615 { 1, 10, 25, "Right hand"},
1616 { 1, 10, 25, "Left hand"},
1617 { 1, 11, 25, "Left hand"},
1618 { 1, 11, 25, "Right hand"},
1619 { 1, 11, 25, "Posture"},
1620 { 1, 15, 25, "Shooting"},
1621 { 1, 16, 25, "Multiplier"},
1622 { 1, 20, 25, "Speed"},
1624 {29, 13, 21, "Level"},
1625 {29, 14, 21, "Experience"},
1626 {29, 15, 21, "Max Exp"},
1627 {29, 16, 21, "Exp to Adv"},
1628 {29, 17, 21, "Gold"},
1629 {29, 19, 21, "Time"},
1630 {29, 10, 21, "Hit point"},
1631 {29, 11, 21, "SP (Mana)"},
1632 {29, 20, 21, "Play time"},
1633 {53, 10, -1, "Fighting : "},
1634 {53, 11, -1, "Bows/Throw : "},
1635 {53, 12, -1, "SavingThrow: "},
1636 {53, 13, -1, "Stealth : "},
1637 {53, 15, -1, "Perception : "},
1638 {53, 16, -1, "Searching : "},
1639 {53, 17, -1, "Disarming : "},
1640 {53, 18, -1, "MagicDevice: "},
1641 { 1, 12, 25, "Blows/Round"},
1642 { 1, 17, 25, "Shots/Round"},
1643 { 1, 13, 25, "AverageDmg/Rnd"},
1644 {53, 20, -1, "Infra-Vision: "},
1645 {26, 1, -1, "Name : "},
1646 { 1, 3, -1, "Sex : "},
1647 { 1, 4, -1, "Race : "},
1648 { 1, 5, -1, "Class : "},
1649 { 1, 6, -1, "Magic : "},
1650 { 1, 7, -1, "Patron : "},
1652 {29, 4, 21, "Height"},
1653 {29, 5, 21, "Weight"},
1654 {29, 6, 21, "Social Class"},
1655 {29, 7, 21, "Align"},
1656 {29, 14, 21, "Construction"},
1657 {29, 16, 21, "Const to Adv"},
1661 static void display_player_one_line(int entry, cptr val, byte attr)
1665 int row = disp_player_line[entry].row;
1666 int col = disp_player_line[entry].col;
1667 int len = disp_player_line[entry].len;
1668 cptr head = disp_player_line[entry].header;
1670 int head_len = strlen(head);
1672 Term_putstr(col, row, -1, TERM_WHITE, head);
1679 int val_len = len - head_len;
1680 sprintf(buf, "%*.*s", val_len, val_len, val);
1681 Term_putstr(col + head_len, row, -1, attr, buf);
1685 Term_putstr(col + head_len, row, -1, attr, val);
1692 static void display_player_melee_bonus(int hand, int hand_entry)
1695 int show_tohit = p_ptr->dis_to_h[hand];
1696 int show_todam = p_ptr->dis_to_d[hand];
1697 object_type *o_ptr = &inventory[INVEN_RARM + hand];
1699 /* Hack -- add in weapon info if known */
1700 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1701 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1704 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1706 /* Dump the bonuses to hit/dam */
1707 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1708 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1709 else if (p_ptr->ryoute)
1710 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1712 display_player_one_line(hand_entry, buf, TERM_L_BLUE);
1717 * Prints the following information on the screen.
1719 static void display_player_middle(void)
1724 int show_tohit = p_ptr->dis_to_h_b;
1728 object_type *o_ptr = &inventory[INVEN_BOW];
1735 display_player_melee_bonus(0, left_hander ? ENTRY_LEFT_HAND1 : ENTRY_RIGHT_HAND1);
1738 if (p_ptr->hidarite)
1740 display_player_melee_bonus(1, left_hander ? ENTRY_RIGHT_HAND2: ENTRY_LEFT_HAND2);
1742 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
1745 if (p_ptr->special_defense & KAMAE_MASK)
1747 for (i = 0; i < MAX_KAMAE; i++)
1749 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1753 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1755 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1760 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1762 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1766 /* Apply weapon bonuses */
1767 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1768 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1770 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1771 show_tohit += p_ptr->weapon_exp[0][o_ptr->sval] / 400;
1773 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
1776 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1778 if (inventory[INVEN_BOW].k_idx)
1780 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1782 /* Get extra "power" from "extra might" */
1783 if (p_ptr->xtra_might) tmul++;
1785 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1789 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1791 /* Dump the armor class */
1792 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1800 i = p_ptr->pspeed-110;
1802 /* Hack -- Visually "undo" the Search Mode Slowdown */
1803 if (p_ptr->action == ACTION_SEARCH) i += 10;
1808 attr = TERM_L_GREEN;
1822 attr = TERM_L_UMBER;
1829 if (IS_FAST()) tmp_speed += 10;
1830 if (p_ptr->slow) tmp_speed -= 10;
1831 if (p_ptr->lightspeed) tmp_speed = 99;
1835 if (MON_FAST(&m_list[p_ptr->riding])) tmp_speed += 10;
1836 if (MON_SLOW(&m_list[p_ptr->riding])) tmp_speed -= 10;
1842 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1845 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1847 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1858 sprintf(buf, "(%+d)", i);
1861 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1863 sprintf(buf, "Riding (%+d)", i);
1867 display_player_one_line(ENTRY_SPEED, buf, attr);
1870 /* Dump character level */
1871 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1873 /* Dump experience */
1874 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1875 else e = ENTRY_CUR_EXP;
1877 if (p_ptr->exp >= p_ptr->max_exp)
1878 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1880 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1882 /* Dump max experience */
1883 if (p_ptr->prace == RACE_ANDROID)
1886 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1888 /* Dump exp to advance */
1889 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
1890 else e = ENTRY_EXP_TO_ADV;
1892 if (p_ptr->lev >= PY_MAX_LEVEL)
1893 display_player_one_line(e, "*****", TERM_L_GREEN);
1894 else if (p_ptr->prace == RACE_ANDROID)
1895 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1897 display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1900 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1905 extract_day_hour_min(&day, &hour, &min);
1908 if (day < MAX_DAYS) sprintf(buf, "%dÆüÌÜ %2d:%02d", day, hour, min);
1909 else sprintf(buf, "*****ÆüÌÜ %2d:%02d", hour, min);
1911 if (day < MAX_DAYS) sprintf(buf, "Day %d %2d:%02d", day, hour, min);
1912 else sprintf(buf, "Day ***** %2d:%02d", hour, min);
1915 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1917 /* Dump hit point */
1918 if (p_ptr->chp >= p_ptr->mhp)
1919 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1920 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1921 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1923 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1925 /* Dump mana power */
1926 if (p_ptr->csp >= p_ptr->msp)
1927 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1928 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
1929 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1931 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1933 /* Dump play time */
1934 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1939 * Hack -- pass color info around this file
1941 static byte likert_color = TERM_WHITE;
1945 * Returns a "rating" of x depending on y
1947 static cptr likert(int x, int y)
1949 static char dummy[20] = "";
1954 /* Negative value */
1957 likert_color = TERM_L_DARK;
1965 /* Analyze the value */
1970 likert_color = TERM_RED;
1978 likert_color = TERM_L_RED;
1987 likert_color = TERM_ORANGE;
1995 likert_color = TERM_YELLOW;
2003 likert_color = TERM_YELLOW;
2012 likert_color = TERM_L_GREEN;
2024 likert_color = TERM_GREEN;
2035 likert_color = TERM_BLUE;
2043 likert_color = TERM_VIOLET;
2045 sprintf(dummy, "ÅÁÀâŪ[%d]", (int)((((x / y) - 17) * 5) / 2));
2047 sprintf(dummy, "Legendary[%d]", (int)((((x / y) - 17) * 5) / 2));
2055 * Prints ratings on certain abilities
2057 * This code is "imitated" elsewhere to "dump" a character sheet.
2059 static void display_player_various(void)
2061 int tmp, damage[2], blows1, blows2, i, basedam;
2062 int xthn, xthb, xfos, xsrh;
2063 int xdis, xdev, xsav, xstl;
2066 u32b flgs[TR_FLAG_SIZE];
2067 int shots, shot_frac;
2071 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2072 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2073 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2074 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2075 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2077 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2079 /* Shooting Skill (with current bow and normal missile) */
2080 o_ptr = &inventory[INVEN_BOW];
2081 tmp = p_ptr->to_h_b + o_ptr->to_h;
2082 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2084 /* If the player is wielding one? */
2087 s16b energy_fire = bow_energy(o_ptr->sval);
2089 /* Calculate shots per round */
2090 shots = p_ptr->num_fire * 100;
2091 shot_frac = (shots * 100 / energy_fire) % 100;
2092 shots = shots / energy_fire;
2093 if (o_ptr->name1 == ART_CRIMSON)
2097 if (p_ptr->pclass == CLASS_ARCHER)
2099 /* Extra shot at level 10 */
2100 if (p_ptr->lev >= 10) shots++;
2102 /* Extra shot at level 30 */
2103 if (p_ptr->lev >= 30) shots++;
2105 /* Extra shot at level 45 */
2106 if (p_ptr->lev >= 45) shots++;
2116 for(i = 0; i < 2; i++)
2118 damage[i] = p_ptr->dis_to_d[i] * 100;
2119 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
2121 int level = p_ptr->lev;
2127 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2128 if (p_ptr->special_defense & KAMAE_BYAKKO)
2129 basedam = monk_ave_damage[level][1];
2130 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2131 basedam = monk_ave_damage[level][2];
2133 basedam = monk_ave_damage[level][0];
2137 o_ptr = &inventory[INVEN_RARM + i];
2139 /* Average damage per round */
2142 if (object_is_known(o_ptr)) damage[i] += o_ptr->to_d * 100;
2143 basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
2144 object_flags_known(o_ptr, flgs);
2145 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2151 else if (have_flag(flgs, TR_VORPAL))
2153 /* vorpal flag only */
2157 if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2158 basedam = basedam * 7 / 2;
2162 damage[i] += basedam;
2163 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2164 if (damage[i] < 0) damage[i] = 0;
2166 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2167 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2169 /* Basic abilities */
2171 xdis = p_ptr->skill_dis;
2172 xdev = p_ptr->skill_dev;
2173 xsav = p_ptr->skill_sav;
2174 xstl = p_ptr->skill_stl;
2175 xsrh = p_ptr->skill_srh;
2176 xfos = p_ptr->skill_fos;
2179 desc = likert(xthn, 12);
2180 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2182 desc = likert(xthb, 12);
2183 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2185 desc = likert(xsav, 7);
2186 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2188 /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
2189 desc = likert((xstl > 0) ? xstl : -1, 1);
2190 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2192 desc = likert(xfos, 6);
2193 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2195 desc = likert(xsrh, 6);
2196 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2198 desc = likert(xdis, 8);
2199 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2201 desc = likert(xdev, 6);
2202 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2205 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2207 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2209 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2212 if ((damage[0]+damage[1]) == 0)
2215 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2217 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2219 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2225 * Obtain the "flags" for the player as if he was an item
2227 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2232 for (i = 0; i < TR_FLAG_SIZE; i++)
2236 switch (p_ptr->pclass)
2239 if (p_ptr->lev > 44)
2240 add_flag(flgs, TR_REGEN);
2242 if (p_ptr->lev > 29)
2243 add_flag(flgs, TR_RES_FEAR);
2246 if (p_ptr->lev > 39)
2247 add_flag(flgs, TR_RES_FEAR);
2249 case CLASS_CHAOS_WARRIOR:
2250 if (p_ptr->lev > 29)
2251 add_flag(flgs, TR_RES_CHAOS);
2252 if (p_ptr->lev > 39)
2253 add_flag(flgs, TR_RES_FEAR);
2256 case CLASS_FORCETRAINER:
2257 if ((p_ptr->lev > 9) && !heavy_armor())
2258 add_flag(flgs, TR_SPEED);
2259 if ((p_ptr->lev>24) && !heavy_armor())
2260 add_flag(flgs, TR_FREE_ACT);
2264 add_flag(flgs, TR_SPEED);
2267 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
2268 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
2269 add_flag(flgs, TR_SPEED);
2271 add_flag(flgs, TR_FREE_ACT);
2273 add_flag(flgs, TR_SLOW_DIGEST);
2274 add_flag(flgs, TR_RES_FEAR);
2275 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2276 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2277 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2279 case CLASS_MINDCRAFTER:
2281 add_flag(flgs, TR_RES_FEAR);
2282 if (p_ptr->lev > 19)
2283 add_flag(flgs, TR_SUST_WIS);
2284 if (p_ptr->lev > 29)
2285 add_flag(flgs, TR_RES_CONF);
2286 if (p_ptr->lev > 39)
2287 add_flag(flgs, TR_TELEPATHY);
2290 add_flag(flgs, TR_RES_SOUND);
2292 case CLASS_BERSERKER:
2293 add_flag(flgs, TR_SUST_STR);
2294 add_flag(flgs, TR_SUST_DEX);
2295 add_flag(flgs, TR_SUST_CON);
2296 add_flag(flgs, TR_REGEN);
2297 add_flag(flgs, TR_FREE_ACT);
2298 add_flag(flgs, TR_SPEED);
2299 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2301 case CLASS_MIRROR_MASTER:
2302 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2305 break; /* Do nothing */
2309 if (p_ptr->mimic_form)
2311 switch(p_ptr->mimic_form)
2314 add_flag(flgs, TR_HOLD_LIFE);
2315 add_flag(flgs, TR_RES_CHAOS);
2316 add_flag(flgs, TR_RES_NETHER);
2317 add_flag(flgs, TR_RES_FIRE);
2318 add_flag(flgs, TR_SEE_INVIS);
2319 add_flag(flgs, TR_SPEED);
2321 case MIMIC_DEMON_LORD:
2322 add_flag(flgs, TR_HOLD_LIFE);
2323 add_flag(flgs, TR_RES_CHAOS);
2324 add_flag(flgs, TR_RES_NETHER);
2325 add_flag(flgs, TR_RES_FIRE);
2326 add_flag(flgs, TR_RES_COLD);
2327 add_flag(flgs, TR_RES_ELEC);
2328 add_flag(flgs, TR_RES_ACID);
2329 add_flag(flgs, TR_RES_POIS);
2330 add_flag(flgs, TR_RES_CONF);
2331 add_flag(flgs, TR_RES_DISEN);
2332 add_flag(flgs, TR_RES_NEXUS);
2333 add_flag(flgs, TR_RES_FEAR);
2334 add_flag(flgs, TR_IM_FIRE);
2335 add_flag(flgs, TR_SH_FIRE);
2336 add_flag(flgs, TR_SEE_INVIS);
2337 add_flag(flgs, TR_TELEPATHY);
2338 add_flag(flgs, TR_LEVITATION);
2339 add_flag(flgs, TR_SPEED);
2342 add_flag(flgs, TR_HOLD_LIFE);
2343 add_flag(flgs, TR_RES_DARK);
2344 add_flag(flgs, TR_RES_NETHER);
2345 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2346 add_flag(flgs, TR_RES_POIS);
2347 add_flag(flgs, TR_RES_COLD);
2348 add_flag(flgs, TR_SEE_INVIS);
2349 add_flag(flgs, TR_SPEED);
2355 switch (p_ptr->prace)
2358 add_flag(flgs, TR_RES_LITE);
2361 add_flag(flgs, TR_HOLD_LIFE);
2364 add_flag(flgs, TR_FREE_ACT);
2367 add_flag(flgs, TR_RES_BLIND);
2370 add_flag(flgs, TR_RES_DARK);
2372 case RACE_HALF_TROLL:
2373 add_flag(flgs, TR_SUST_STR);
2374 if (p_ptr->lev > 14)
2376 add_flag(flgs, TR_REGEN);
2377 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
2379 add_flag(flgs, TR_SLOW_DIGEST);
2381 * Let's not make Regeneration a disadvantage
2382 * for the poor warriors who can never learn
2383 * a spell that satisfies hunger (actually
2384 * neither can rogues, but half-trolls are not
2385 * supposed to play rogues)
2391 add_flag(flgs, TR_SUST_CON);
2392 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2395 add_flag(flgs, TR_RES_LITE);
2396 add_flag(flgs, TR_SEE_INVIS);
2398 case RACE_BARBARIAN:
2399 add_flag(flgs, TR_RES_FEAR);
2401 case RACE_HALF_OGRE:
2402 add_flag(flgs, TR_SUST_STR);
2403 add_flag(flgs, TR_RES_DARK);
2405 case RACE_HALF_GIANT:
2406 add_flag(flgs, TR_RES_SHARDS);
2407 add_flag(flgs, TR_SUST_STR);
2409 case RACE_HALF_TITAN:
2410 add_flag(flgs, TR_RES_CHAOS);
2413 add_flag(flgs, TR_RES_SOUND);
2416 add_flag(flgs, TR_RES_ACID);
2417 if (p_ptr->lev > 19)
2418 add_flag(flgs, TR_IM_ACID);
2421 add_flag(flgs, TR_RES_CONF);
2422 add_flag(flgs, TR_RES_ACID);
2424 add_flag(flgs, TR_SPEED);
2427 add_flag(flgs, TR_RES_POIS);
2430 add_flag(flgs, TR_RES_DISEN);
2431 add_flag(flgs, TR_RES_DARK);
2434 add_flag(flgs, TR_RES_DARK);
2435 if (p_ptr->lev > 19)
2436 add_flag(flgs, TR_SEE_INVIS);
2438 case RACE_DRACONIAN:
2439 add_flag(flgs, TR_LEVITATION);
2441 add_flag(flgs, TR_RES_FIRE);
2443 add_flag(flgs, TR_RES_COLD);
2444 if (p_ptr->lev > 14)
2445 add_flag(flgs, TR_RES_ACID);
2446 if (p_ptr->lev > 19)
2447 add_flag(flgs, TR_RES_ELEC);
2448 if (p_ptr->lev > 34)
2449 add_flag(flgs, TR_RES_POIS);
2451 case RACE_MIND_FLAYER:
2452 add_flag(flgs, TR_SUST_INT);
2453 add_flag(flgs, TR_SUST_WIS);
2454 if (p_ptr->lev > 14)
2455 add_flag(flgs, TR_SEE_INVIS);
2456 if (p_ptr->lev > 29)
2457 add_flag(flgs, TR_TELEPATHY);
2460 add_flag(flgs, TR_RES_FIRE);
2462 add_flag(flgs, TR_SEE_INVIS);
2465 add_flag(flgs, TR_SEE_INVIS);
2466 add_flag(flgs, TR_FREE_ACT);
2467 add_flag(flgs, TR_RES_POIS);
2468 add_flag(flgs, TR_SLOW_DIGEST);
2469 if (p_ptr->lev > 34)
2470 add_flag(flgs, TR_HOLD_LIFE);
2473 add_flag(flgs, TR_SEE_INVIS);
2474 add_flag(flgs, TR_RES_SHARDS);
2475 add_flag(flgs, TR_HOLD_LIFE);
2476 add_flag(flgs, TR_RES_POIS);
2478 add_flag(flgs, TR_RES_COLD);
2481 add_flag(flgs, TR_SEE_INVIS);
2482 add_flag(flgs, TR_HOLD_LIFE);
2483 add_flag(flgs, TR_RES_NETHER);
2484 add_flag(flgs, TR_RES_POIS);
2485 add_flag(flgs, TR_SLOW_DIGEST);
2487 add_flag(flgs, TR_RES_COLD);
2490 add_flag(flgs, TR_HOLD_LIFE);
2491 add_flag(flgs, TR_RES_DARK);
2492 add_flag(flgs, TR_RES_NETHER);
2493 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2494 add_flag(flgs, TR_RES_POIS);
2495 add_flag(flgs, TR_RES_COLD);
2498 add_flag(flgs, TR_LEVITATION);
2499 add_flag(flgs, TR_FREE_ACT);
2500 add_flag(flgs, TR_RES_COLD);
2501 add_flag(flgs, TR_SEE_INVIS);
2502 add_flag(flgs, TR_HOLD_LIFE);
2503 add_flag(flgs, TR_RES_NETHER);
2504 add_flag(flgs, TR_RES_POIS);
2505 add_flag(flgs, TR_SLOW_DIGEST);
2507 if (p_ptr->lev > 34)
2508 add_flag(flgs, TR_TELEPATHY);
2511 add_flag(flgs, TR_RES_LITE);
2512 add_flag(flgs, TR_LEVITATION);
2514 add_flag(flgs, TR_SPEED);
2517 add_flag(flgs, TR_RES_SOUND);
2518 add_flag(flgs, TR_RES_CONF);
2521 add_flag(flgs, TR_LEVITATION);
2522 add_flag(flgs, TR_SEE_INVIS);
2525 add_flag(flgs, TR_RES_FIRE);
2526 add_flag(flgs, TR_RES_NETHER);
2527 add_flag(flgs, TR_HOLD_LIFE);
2529 add_flag(flgs, TR_SEE_INVIS);
2532 add_flag(flgs, TR_SUST_CON);
2535 add_flag(flgs, TR_LEVITATION);
2538 add_flag(flgs, TR_RES_CONF);
2541 add_flag(flgs, TR_FREE_ACT);
2542 add_flag(flgs, TR_RES_POIS);
2543 add_flag(flgs, TR_SLOW_DIGEST);
2544 add_flag(flgs, TR_HOLD_LIFE);
2554 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2556 remove_flag(flgs, TR_REGEN);
2559 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2560 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2561 (p_ptr->muta3 & MUT3_SHORT_LEG))
2563 add_flag(flgs, TR_SPEED);
2566 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2568 add_flag(flgs, TR_SH_ELEC);
2571 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2573 add_flag(flgs, TR_SH_FIRE);
2574 add_flag(flgs, TR_LITE);
2577 if (p_ptr->muta3 & MUT3_WINGS)
2579 add_flag(flgs, TR_LEVITATION);
2582 if (p_ptr->muta3 & MUT3_FEARLESS)
2584 add_flag(flgs, TR_RES_FEAR);
2587 if (p_ptr->muta3 & MUT3_REGEN)
2589 add_flag(flgs, TR_REGEN);
2592 if (p_ptr->muta3 & MUT3_ESP)
2594 add_flag(flgs, TR_TELEPATHY);
2597 if (p_ptr->muta3 & MUT3_MOTION)
2599 add_flag(flgs, TR_FREE_ACT);
2603 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2604 add_flag(flgs, TR_AGGRAVATE);
2605 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2607 add_flag(flgs, TR_RES_BLIND);
2608 add_flag(flgs, TR_RES_CONF);
2609 add_flag(flgs, TR_HOLD_LIFE);
2610 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2612 add_flag(flgs, TR_SPEED);
2614 if (p_ptr->special_defense & KATA_FUUJIN)
2615 add_flag(flgs, TR_REFLECT);
2616 if (p_ptr->special_defense & KAMAE_GENBU)
2617 add_flag(flgs, TR_REFLECT);
2618 if (p_ptr->special_defense & KAMAE_SUZAKU)
2619 add_flag(flgs, TR_LEVITATION);
2620 if (p_ptr->special_defense & KAMAE_SEIRYU)
2622 add_flag(flgs, TR_RES_FIRE);
2623 add_flag(flgs, TR_RES_COLD);
2624 add_flag(flgs, TR_RES_ACID);
2625 add_flag(flgs, TR_RES_ELEC);
2626 add_flag(flgs, TR_RES_POIS);
2627 add_flag(flgs, TR_LEVITATION);
2628 add_flag(flgs, TR_SH_FIRE);
2629 add_flag(flgs, TR_SH_ELEC);
2630 add_flag(flgs, TR_SH_COLD);
2632 if (p_ptr->special_defense & KATA_MUSOU)
2634 add_flag(flgs, TR_RES_FEAR);
2635 add_flag(flgs, TR_RES_LITE);
2636 add_flag(flgs, TR_RES_DARK);
2637 add_flag(flgs, TR_RES_BLIND);
2638 add_flag(flgs, TR_RES_CONF);
2639 add_flag(flgs, TR_RES_SOUND);
2640 add_flag(flgs, TR_RES_SHARDS);
2641 add_flag(flgs, TR_RES_NETHER);
2642 add_flag(flgs, TR_RES_NEXUS);
2643 add_flag(flgs, TR_RES_CHAOS);
2644 add_flag(flgs, TR_RES_DISEN);
2645 add_flag(flgs, TR_REFLECT);
2646 add_flag(flgs, TR_HOLD_LIFE);
2647 add_flag(flgs, TR_FREE_ACT);
2648 add_flag(flgs, TR_SH_FIRE);
2649 add_flag(flgs, TR_SH_ELEC);
2650 add_flag(flgs, TR_SH_COLD);
2651 add_flag(flgs, TR_LEVITATION);
2652 add_flag(flgs, TR_LITE);
2653 add_flag(flgs, TR_SEE_INVIS);
2654 add_flag(flgs, TR_TELEPATHY);
2655 add_flag(flgs, TR_SLOW_DIGEST);
2656 add_flag(flgs, TR_REGEN);
2657 add_flag(flgs, TR_SUST_STR);
2658 add_flag(flgs, TR_SUST_INT);
2659 add_flag(flgs, TR_SUST_WIS);
2660 add_flag(flgs, TR_SUST_DEX);
2661 add_flag(flgs, TR_SUST_CON);
2662 add_flag(flgs, TR_SUST_CHR);
2667 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
2672 for (i = 0; i < TR_FLAG_SIZE; i++)
2675 if (IS_HERO() || p_ptr->shero)
2676 add_flag(flgs, TR_RES_FEAR);
2677 if (p_ptr->tim_invis)
2678 add_flag(flgs, TR_SEE_INVIS);
2679 if (p_ptr->tim_regen)
2680 add_flag(flgs, TR_REGEN);
2682 add_flag(flgs, TR_TELEPATHY);
2683 if (IS_FAST() || p_ptr->slow)
2684 add_flag(flgs, TR_SPEED);
2686 if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
2687 add_flag(flgs, TR_RES_ACID);
2688 if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
2689 add_flag(flgs, TR_RES_ELEC);
2690 if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
2691 add_flag(flgs, TR_RES_FIRE);
2692 if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
2693 add_flag(flgs, TR_RES_COLD);
2694 if (IS_OPPOSE_POIS())
2695 add_flag(flgs, TR_RES_POIS);
2697 if (p_ptr->special_attack & ATTACK_ACID)
2698 add_flag(flgs, TR_BRAND_ACID);
2699 if (p_ptr->special_attack & ATTACK_ELEC)
2700 add_flag(flgs, TR_BRAND_ELEC);
2701 if (p_ptr->special_attack & ATTACK_FIRE)
2702 add_flag(flgs, TR_BRAND_FIRE);
2703 if (p_ptr->special_attack & ATTACK_COLD)
2704 add_flag(flgs, TR_BRAND_COLD);
2705 if (p_ptr->special_attack & ATTACK_POIS)
2706 add_flag(flgs, TR_BRAND_POIS);
2707 if (p_ptr->special_defense & DEFENSE_ACID)
2708 add_flag(flgs, TR_IM_ACID);
2709 if (p_ptr->special_defense & DEFENSE_ELEC)
2710 add_flag(flgs, TR_IM_ELEC);
2711 if (p_ptr->special_defense & DEFENSE_FIRE)
2712 add_flag(flgs, TR_IM_FIRE);
2713 if (p_ptr->special_defense & DEFENSE_COLD)
2714 add_flag(flgs, TR_IM_COLD);
2715 if (p_ptr->wraith_form)
2716 add_flag(flgs, TR_REFLECT);
2718 if (p_ptr->tim_reflect)
2719 add_flag(flgs, TR_REFLECT);
2721 if (p_ptr->magicdef)
2723 add_flag(flgs, TR_RES_BLIND);
2724 add_flag(flgs, TR_RES_CONF);
2725 add_flag(flgs, TR_REFLECT);
2726 add_flag(flgs, TR_FREE_ACT);
2727 add_flag(flgs, TR_LEVITATION);
2729 if (p_ptr->tim_res_nether)
2731 add_flag(flgs, TR_RES_NETHER);
2733 if (p_ptr->tim_sh_fire)
2735 add_flag(flgs, TR_SH_FIRE);
2739 add_flag(flgs, TR_RES_FEAR);
2740 add_flag(flgs, TR_RES_LITE);
2741 add_flag(flgs, TR_RES_DARK);
2742 add_flag(flgs, TR_RES_BLIND);
2743 add_flag(flgs, TR_RES_CONF);
2744 add_flag(flgs, TR_RES_SOUND);
2745 add_flag(flgs, TR_RES_SHARDS);
2746 add_flag(flgs, TR_RES_NETHER);
2747 add_flag(flgs, TR_RES_NEXUS);
2748 add_flag(flgs, TR_RES_CHAOS);
2749 add_flag(flgs, TR_RES_DISEN);
2750 add_flag(flgs, TR_REFLECT);
2751 add_flag(flgs, TR_HOLD_LIFE);
2752 add_flag(flgs, TR_FREE_ACT);
2753 add_flag(flgs, TR_SH_FIRE);
2754 add_flag(flgs, TR_SH_ELEC);
2755 add_flag(flgs, TR_SH_COLD);
2756 add_flag(flgs, TR_LEVITATION);
2757 add_flag(flgs, TR_LITE);
2758 add_flag(flgs, TR_SEE_INVIS);
2759 add_flag(flgs, TR_TELEPATHY);
2760 add_flag(flgs, TR_SLOW_DIGEST);
2761 add_flag(flgs, TR_REGEN);
2762 add_flag(flgs, TR_SUST_STR);
2763 add_flag(flgs, TR_SUST_INT);
2764 add_flag(flgs, TR_SUST_WIS);
2765 add_flag(flgs, TR_SUST_DEX);
2766 add_flag(flgs, TR_SUST_CON);
2767 add_flag(flgs, TR_SUST_CHR);
2772 /* Mode flags for displaying player flags */
2773 #define DP_CURSE 0x01
2781 static void display_player_equippy(int y, int x, u16b mode)
2790 /* Weapon flags need only two column */
2791 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2792 else max_i = INVEN_TOTAL;
2794 /* Dump equippy chars */
2795 for (i = INVEN_RARM; i < max_i; i++)
2798 o_ptr = &inventory[i];
2800 a = object_attr(o_ptr);
2801 c = object_char(o_ptr);
2803 /* Clear the part of the screen */
2804 if (!equippy_chars || !o_ptr->k_idx)
2811 Term_putch(x + i - INVEN_RARM, y, a, c);
2816 void print_equippy(void)
2818 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2825 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2830 for (i = 0; i < TR_FLAG_SIZE; i++)
2833 /* Check equipment */
2834 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2836 u32b o_flgs[TR_FLAG_SIZE];
2841 o_ptr = &inventory[i];
2843 if (!o_ptr->k_idx) continue;
2846 object_flags_known(o_ptr, o_flgs);
2848 if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2849 if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2850 if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2851 if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2855 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2860 for (i = 0; i < TR_FLAG_SIZE; i++)
2863 if (prace_is_(RACE_SPECTRE))
2864 add_flag(flgs, TR_RES_NETHER);
2865 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2866 add_flag(flgs, TR_RES_DARK);
2867 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2868 add_flag(flgs, TR_RES_FIRE);
2869 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2870 add_flag(flgs, TR_RES_ACID);
2873 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2878 for (i = 0; i < TR_FLAG_SIZE; i++)
2881 if (p_ptr->special_defense & DEFENSE_ACID)
2882 add_flag(flgs, TR_RES_ACID);
2883 if (p_ptr->special_defense & DEFENSE_ELEC)
2884 add_flag(flgs, TR_RES_ELEC);
2885 if (p_ptr->special_defense & DEFENSE_FIRE)
2886 add_flag(flgs, TR_RES_FIRE);
2887 if (p_ptr->special_defense & DEFENSE_COLD)
2888 add_flag(flgs, TR_RES_COLD);
2889 if (p_ptr->wraith_form)
2890 add_flag(flgs, TR_RES_DARK);
2893 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2898 for (i = 0; i < TR_FLAG_SIZE; i++)
2901 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2903 add_flag(flgs, TR_RES_ACID);
2904 add_flag(flgs, TR_RES_ELEC);
2905 add_flag(flgs, TR_RES_FIRE);
2906 add_flag(flgs, TR_RES_COLD);
2908 if (prace_is_(RACE_ANDROID))
2909 add_flag(flgs, TR_RES_ELEC);
2910 if (prace_is_(RACE_ENT))
2911 add_flag(flgs, TR_RES_FIRE);
2912 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2913 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2914 add_flag(flgs, TR_RES_LITE);
2919 * A struct for storing misc. flags
2922 u32b player_flags[TR_FLAG_SIZE];
2923 u32b tim_player_flags[TR_FLAG_SIZE];
2924 u32b player_imm[TR_FLAG_SIZE];
2925 u32b tim_player_imm[TR_FLAG_SIZE];
2926 u32b player_vuln[TR_FLAG_SIZE];
2927 u32b known_obj_imm[TR_FLAG_SIZE];
2932 * Helper function, see below
2934 static void display_flag_aux(int row, int col, cptr header,
2935 int flag1, all_player_flags *f, u16b mode)
2941 if (have_flag(f->player_vuln, flag1) &&
2942 !(have_flag(f->known_obj_imm, flag1) ||
2943 have_flag(f->player_imm, flag1) ||
2944 have_flag(f->tim_player_imm, flag1)))
2948 if (!(mode & DP_IMM)) c_put_str(TERM_WHITE, header, row, col);
2951 col += strlen(header) + 1;
2953 /* Weapon flags need only two column */
2954 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2955 else max_i = INVEN_TOTAL;
2957 /* Check equipment */
2958 for (i = INVEN_RARM; i < max_i; i++)
2960 u32b flgs[TR_FLAG_SIZE];
2964 o_ptr = &inventory[i];
2967 object_flags_known(o_ptr, flgs);
2970 if (!(mode & DP_IMM))
2971 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2974 if (mode & DP_CURSE)
2976 if ((mode & DP_CURSE) && (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE)))
2977 c_put_str(TERM_WHITE, "+", row, col);
2978 if ((mode & DP_CURSE) && (o_ptr->curse_flags & TRC_PERMA_CURSE))
2979 c_put_str(TERM_WHITE, "*", row, col);
2983 if (have_flag(flgs, flag1))
2984 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
2985 (mode & DP_IMM) ? "*" : "+", row, col);
2992 /* Assume that player flag is already written */
2993 if (mode & DP_IMM) return;
2996 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2999 if (have_flag(f->player_flags, flag1)) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3001 /* Timed player flags */
3002 if (have_flag(f->tim_player_flags, flag1)) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3005 if (have_flag(f->tim_player_imm, flag1)) c_put_str(TERM_YELLOW, "*", row, col);
3006 if (have_flag(f->player_imm, flag1)) c_put_str(TERM_WHITE, "*", row, col);
3009 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3014 * Special display, part 1
3016 static void display_player_flag_info(void)
3023 /* Extract flags and store */
3024 player_flags(f.player_flags);
3025 tim_player_flags(f.tim_player_flags);
3026 player_immunity(f.player_imm);
3027 tim_player_immunity(f.tim_player_imm);
3028 known_obj_immunity(f.known_obj_imm);
3029 player_vuln_flags(f.player_vuln);
3036 display_player_equippy(row-2, col+8, 0);
3037 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3040 display_flag_aux(row+0, col, "ÂÑ»À :", TR_RES_ACID, &f, 0);
3041 display_flag_aux(row+0, col, "ÂÑ»À :", TR_IM_ACID, &f, DP_IMM);
3042 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_RES_ELEC, &f, 0);
3043 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_IM_ELEC, &f, DP_IMM);
3044 display_flag_aux(row+2, col, "ÂѲбê:", TR_RES_FIRE, &f, 0);
3045 display_flag_aux(row+2, col, "ÂѲбê:", TR_IM_FIRE, &f, DP_IMM);
3046 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_RES_COLD, &f, 0);
3047 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_IM_COLD, &f, DP_IMM);
3048 display_flag_aux(row+4, col, "ÂÑÆÇ :", TR_RES_POIS, &f, 0);
3049 display_flag_aux(row+5, col, "ÂÑÁ®¸÷:", TR_RES_LITE, &f, 0);
3050 display_flag_aux(row+6, col, "ÂѰŹõ:", TR_RES_DARK, &f, 0);
3051 display_flag_aux(row+7, col, "ÂÑÇËÊÒ:", TR_RES_SHARDS, &f, 0);
3052 display_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", TR_RES_BLIND, &f, 0);
3053 display_flag_aux(row+9, col, "ÂѺ®Íð:", TR_RES_CONF, &f, 0);
3055 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3056 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3057 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3058 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3059 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3060 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3061 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3062 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3063 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3064 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3065 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3066 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3067 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3068 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3077 display_player_equippy(row-2, col+8, 0);
3079 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3082 display_flag_aux(row+0, col, "Âѹ첻:", TR_RES_SOUND, &f, 0);
3083 display_flag_aux(row+1, col, "ÂÑÃϹö:", TR_RES_NETHER, &f, 0);
3084 display_flag_aux(row+2, col, "ÂÑ°øº®:", TR_RES_NEXUS, &f, 0);
3085 display_flag_aux(row+3, col, "ÂÑ¥«¥ª:", TR_RES_CHAOS, &f, 0);
3086 display_flag_aux(row+4, col, "ÂÑÎô²½:", TR_RES_DISEN, &f, 0);
3087 display_flag_aux(row+5, col, "ÂѶ²ÉÝ:", TR_RES_FEAR, &f, 0);
3088 display_flag_aux(row+6, col, "È¿¼Í :", TR_REFLECT, &f, 0);
3089 display_flag_aux(row+7, col, "²Ð±ê¥ª:", TR_SH_FIRE, &f, 0);
3090 display_flag_aux(row+8, col, "Åŵ¤¥ª:", TR_SH_ELEC, &f, 0);
3091 display_flag_aux(row+9, col, "Î䵤¥ª:", TR_SH_COLD, &f, 0);
3093 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3094 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3095 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3096 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3097 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3098 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3099 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3100 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3101 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3102 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3111 display_player_equippy(row-2, col+12, 0);
3113 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3116 display_flag_aux(row+0, col, "²Ã® :", TR_SPEED, &f, 0);
3117 display_flag_aux(row+1, col, "ÂÑËãáã :", TR_FREE_ACT, &f, 0);
3118 display_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", TR_SEE_INVIS, &f, 0);
3119 display_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", TR_HOLD_LIFE, &f, 0);
3120 display_flag_aux(row+4, col, "·Ù¹ð :", TR_WARNING, &f, 0);
3121 display_flag_aux(row+5, col, "Ãپò½ :", TR_SLOW_DIGEST, &f, 0);
3122 display_flag_aux(row+6, col, "µÞ²óÉü :", TR_REGEN, &f, 0);
3123 display_flag_aux(row+7, col, "ÉâÍ· :", TR_LEVITATION, &f, 0);
3124 display_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", TR_LITE, &f, 0);
3125 display_flag_aux(row+9, col, "¼ö¤¤ :", 0, &f, DP_CURSE);
3127 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3128 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3129 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3130 display_flag_aux(row+3, col, "Hold Life :", TR_HOLD_LIFE, &f, 0);
3131 display_flag_aux(row+4, col, "Warning :", TR_WARNING, &f, 0);
3132 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3133 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3134 display_flag_aux(row+7, col, "Levitation:", TR_LEVITATION, &f, 0);
3135 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE, &f, 0);
3136 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3143 * Special display, part 2
3145 static void display_player_other_flag_info(void)
3152 /* Extract flags and store */
3153 player_flags(f.player_flags);
3154 tim_player_flags(f.tim_player_flags);
3155 player_immunity(f.player_imm);
3156 tim_player_immunity(f.tim_player_imm);
3157 known_obj_immunity(f.known_obj_imm);
3158 player_vuln_flags(f.player_vuln);
3165 display_player_equippy(row-2, col+12, DP_WP);
3167 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3170 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_SLAY_EVIL, &f, DP_WP);
3171 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3172 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_SLAY_UNDEAD, &f, DP_WP);
3173 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3174 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_SLAY_DEMON, &f, DP_WP);
3175 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3176 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_SLAY_DRAGON, &f, DP_WP);
3177 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3178 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_SLAY_HUMAN, &f, DP_WP);
3179 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3180 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_SLAY_ANIMAL, &f, DP_WP);
3181 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3182 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_SLAY_ORC, &f, DP_WP);
3183 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3184 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_SLAY_TROLL, &f, DP_WP);
3185 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3186 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_SLAY_GIANT, &f, DP_WP);
3187 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3188 display_flag_aux(row+ 9, col, "Íϲò :", TR_BRAND_ACID, &f, DP_WP);
3189 display_flag_aux(row+10, col, "ÅÅ·â :", TR_BRAND_ELEC, &f, DP_WP);
3190 display_flag_aux(row+11, col, "¾Æ´þ :", TR_BRAND_FIRE, &f, DP_WP);
3191 display_flag_aux(row+12, col, "Åà·ë :", TR_BRAND_COLD, &f, DP_WP);
3192 display_flag_aux(row+13, col, "ÆÇ»¦ :", TR_BRAND_POIS, &f, DP_WP);
3193 display_flag_aux(row+14, col, "ÀÚ¤ìÌ£ :", TR_VORPAL, &f, DP_WP);
3194 display_flag_aux(row+15, col, "ÃÏ¿Ì :", TR_IMPACT, &f, DP_WP);
3195 display_flag_aux(row+16, col, "µÛ·ì :", TR_VAMPIRIC, &f, DP_WP);
3196 display_flag_aux(row+17, col, "¥«¥ª¥¹¸ú²Ì:", TR_CHAOTIC, &f, DP_WP);
3197 display_flag_aux(row+18, col, "ÍýÎÏ :", TR_FORCE_WEAPON, &f, DP_WP);
3199 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3200 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3201 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3202 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3203 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3204 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3205 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3206 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3207 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3208 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3209 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3210 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3211 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3212 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3213 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3214 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3215 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3216 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3217 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3218 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3219 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3220 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3221 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3222 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3223 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3224 display_flag_aux(row+16, col, "Vampiric :", TR_VAMPIRIC, &f, DP_WP);
3225 display_flag_aux(row+17, col, "Chaotic :", TR_CHAOTIC, &f, DP_WP);
3226 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3235 display_player_equippy(row-2, col+12, 0);
3236 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3239 display_flag_aux(row+ 0, col, "¥Æ¥ì¥Ñ¥·¡¼:", TR_TELEPATHY, &f, 0);
3240 display_flag_aux(row+ 1, col, "¼Ù°ESP :", TR_ESP_EVIL, &f, 0);
3241 display_flag_aux(row+ 2, col, "̵À¸ÊªESP :", TR_ESP_NONLIVING, &f, 0);
3242 display_flag_aux(row+ 3, col, "Á±ÎÉESP :", TR_ESP_GOOD, &f, 0);
3243 display_flag_aux(row+ 4, col, "ÉÔ»àESP :", TR_ESP_UNDEAD, &f, 0);
3244 display_flag_aux(row+ 5, col, "°ËâESP :", TR_ESP_DEMON, &f, 0);
3245 display_flag_aux(row+ 6, col, "ζESP :", TR_ESP_DRAGON, &f, 0);
3246 display_flag_aux(row+ 7, col, "¿Í´ÖESP :", TR_ESP_HUMAN, &f, 0);
3247 display_flag_aux(row+ 8, col, "ưʪESP :", TR_ESP_ANIMAL, &f, 0);
3248 display_flag_aux(row+ 9, col, "¥ª¡¼¥¯ESP :", TR_ESP_ORC, &f, 0);
3249 display_flag_aux(row+10, col, "¥È¥í¥ëESP :", TR_ESP_TROLL, &f, 0);
3250 display_flag_aux(row+11, col, "µð¿ÍESP :", TR_ESP_GIANT, &f, 0);
3252 display_flag_aux(row+13, col, "ÏÓÎÏ°Ý»ý :", TR_SUST_STR, &f, 0);
3253 display_flag_aux(row+14, col, "ÃÎÎÏ°Ý»ý :", TR_SUST_INT, &f, 0);
3254 display_flag_aux(row+15, col, "¸¤µ°Ý»ý :", TR_SUST_WIS, &f, 0);
3255 display_flag_aux(row+16, col, "´ïÍÑ°Ý»ý :", TR_SUST_DEX, &f, 0);
3256 display_flag_aux(row+17, col, "Âѵװݻý :", TR_SUST_CON, &f, 0);
3257 display_flag_aux(row+18, col, "Ì¥ÎÏ°Ý»ý :", TR_SUST_CHR, &f, 0);
3259 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3260 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3261 display_flag_aux(row+ 2, col, "ESP Noliv.:", TR_ESP_NONLIVING, &f, 0);
3262 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3263 display_flag_aux(row+ 4, col, "ESP Undead:", TR_ESP_UNDEAD, &f, 0);
3264 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3265 display_flag_aux(row+ 6, col, "ESP Dragon:", TR_ESP_DRAGON, &f, 0);
3266 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3267 display_flag_aux(row+ 8, col, "ESP Animal:", TR_ESP_ANIMAL, &f, 0);
3268 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3269 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3270 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3272 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3273 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3274 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3275 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3276 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3277 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3284 col = col + 12 + 17;
3286 display_player_equippy(row-2, col+14, 0);
3288 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3291 display_flag_aux(row+ 0, col, "Äɲù¶·â :", TR_BLOWS, &f, 0);
3292 display_flag_aux(row+ 1, col, "ºÎ·¡ :", TR_TUNNEL, &f, 0);
3293 display_flag_aux(row+ 2, col, "ÀÖ³°Àþ»ëÎÏ :", TR_INFRA, &f, 0);
3294 display_flag_aux(row+ 3, col, "ËâË¡Æ»¶ñ»ÙÇÛ:", TR_MAGIC_MASTERY, &f, 0);
3295 display_flag_aux(row+ 4, col, "±£Ì© :", TR_STEALTH, &f, 0);
3296 display_flag_aux(row+ 5, col, "õº÷ :", TR_SEARCH, &f, 0);
3298 display_flag_aux(row+ 7, col, "¾èÇÏ :", TR_RIDING, &f, 0);
3299 display_flag_aux(row+ 8, col, "ÅêÚ³ :", TR_THROW, &f, 0);
3300 display_flag_aux(row+ 9, col, "½ËÊ¡ :", TR_BLESSED, &f, 0);
3301 display_flag_aux(row+10, col, "È¿¥Æ¥ì¥Ý¡¼¥È:", TR_NO_TELE, &f, 0);
3302 display_flag_aux(row+11, col, "È¿ËâË¡ :", TR_NO_MAGIC, &f, 0);
3303 display_flag_aux(row+12, col, "¾ÃÈñËâÎϸº¾¯:", TR_DEC_MANA, &f, 0);
3305 display_flag_aux(row+14, col, "·Ð¸³Ã͸º¾¯ :", TR_DRAIN_EXP, &f, 0);
3306 display_flag_aux(row+15, col, "Íð¥Æ¥ì¥Ý¡¼¥È:", TR_TELEPORT, &f, 0);
3307 display_flag_aux(row+16, col, "È¿´¶ :", TR_AGGRAVATE, &f, 0);
3308 display_flag_aux(row+17, col, "ÂÀ¸Å¤Î±åÇ° :", TR_TY_CURSE, &f, 0);
3310 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3311 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3312 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3313 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3314 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3315 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3317 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3318 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3319 display_flag_aux(row+ 9, col, "Blessed :", TR_BLESSED, &f, 0);
3320 display_flag_aux(row+10, col, "No Teleport :", TR_NO_TELE, &f, 0);
3321 display_flag_aux(row+11, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3322 display_flag_aux(row+12, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3324 display_flag_aux(row+14, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3325 display_flag_aux(row+15, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3326 display_flag_aux(row+16, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3327 display_flag_aux(row+17, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3334 * Special display, part 2a
3336 static void display_player_misc_info(void)
3341 /* Display basics */
3343 put_str("̾Á° :", 1, 26);
3344 put_str("ÀÊÌ :", 3, 1);
3345 put_str("¼ï² :", 4, 1);
3346 put_str("¿¦¶È :", 5, 1);
3348 put_str("Name :", 1, 26);
3349 put_str("Sex :", 3, 1);
3350 put_str("Race :", 4, 1);
3351 put_str("Class :", 5, 1);
3354 strcpy(tmp,ap_ptr->title);
3361 strcat(tmp,player_name);
3363 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3364 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3365 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3366 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3368 /* Display extras */
3370 put_str("¥ì¥Ù¥ë:", 6, 1);
3371 put_str("£È£Ð :", 7, 1);
3372 put_str("£Í£Ð :", 8, 1);
3374 put_str("Level :", 6, 1);
3375 put_str("Hits :", 7, 1);
3376 put_str("Mana :", 8, 1);
3380 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3381 c_put_str(TERM_L_BLUE, buf, 6, 9);
3382 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3383 c_put_str(TERM_L_BLUE, buf, 7, 9);
3384 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3385 c_put_str(TERM_L_BLUE, buf, 8, 9);
3390 * Special display, part 2b
3392 * How to print out the modifications and sustains.
3393 * Positive mods with no sustain will be light green.
3394 * Positive mods with a sustain will be dark green.
3395 * Sustains (with no modification) will be a dark green 's'.
3396 * Negative mods (from a curse) will be red.
3397 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3398 * No mod, no sustain, will be a slate '.'
3400 static void display_player_stat_info(void)
3407 u32b flgs[TR_FLAG_SIZE];
3421 /* Print out the labels for the columns */
3423 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3424 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3425 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3426 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3427 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3429 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3430 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3431 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3432 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3433 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3437 /* Display the stats */
3438 for (i = 0; i < 6; i++)
3442 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3443 else r_adj = rp_ptr->r_adj[i];
3445 /* Calculate equipment adjustment */
3448 /* Icky formula to deal with the 18 barrier */
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]) / 10;
3451 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3452 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3453 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3454 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3456 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3457 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3459 if (prace_is_(RACE_ENT))
3465 if (p_ptr->lev > 25) r_adj++;
3466 if (p_ptr->lev > 40) r_adj++;
3467 if (p_ptr->lev > 45) r_adj++;
3470 if (p_ptr->lev > 25) r_adj--;
3471 if (p_ptr->lev > 40) r_adj--;
3472 if (p_ptr->lev > 45) r_adj--;
3478 e_adj -= cp_ptr->c_adj[i];
3479 e_adj -= ap_ptr->a_adj[i];
3481 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3482 /* Reduced name of stat */
3483 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3485 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3488 /* Internal "natural" max value. Maxes at 18/100 */
3489 /* This is useful to see if you are maxed out */
3490 cnv_stat(p_ptr->stat_max[i], buf);
3491 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3494 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3496 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3499 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3501 /* Race, class, and equipment modifiers */
3502 (void)sprintf(buf, "%3d", r_adj);
3503 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3504 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3505 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3506 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3507 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3508 (void)sprintf(buf, "%3d", (int)e_adj);
3509 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3511 /* Actual maximal modified value */
3512 cnv_stat(p_ptr->stat_top[i], buf);
3513 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3515 /* Only display stat_use if not maximal */
3516 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3518 cnv_stat(p_ptr->stat_use[i], buf);
3519 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3524 col = stat_col + 41;
3526 /* Header and Footer */
3527 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3529 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3531 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3535 /* Process equipment */
3536 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3539 o_ptr = &inventory[i];
3541 /* Acquire "known" flags */
3542 object_flags_known(o_ptr, flgs);
3544 /* Initialize color based of sign of pval. */
3545 for (stat = 0; stat < 6; stat++)
3552 if (have_flag(flgs, stat))
3558 if (o_ptr->pval > 0)
3564 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3567 if (have_flag(flgs, stat + TR_SUST_STR))
3569 /* Dark green for sustained stats */
3574 if (o_ptr->pval < 0)
3580 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3585 else if (have_flag(flgs, stat + TR_SUST_STR))
3587 /* Dark green "s" */
3592 /* Dump proper character */
3593 Term_putch(col, row + stat+1, a, c);
3604 for (stat = 0; stat < 6; stat++)
3611 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3617 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3618 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3619 if (p_ptr->tsuyoshi) dummy += 4;
3621 else if (stat == A_WIS || stat == A_INT)
3623 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3624 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3626 else if (stat == A_DEX)
3628 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3629 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3630 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3632 else if (stat == A_CON)
3634 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3635 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3636 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3637 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3638 if (p_ptr->tsuyoshi) dummy += 4;
3640 else if (stat == A_CHR)
3642 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3643 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3644 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3645 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3646 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3647 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3663 if (dummy < 10) c = '0' + dummy;
3673 if (dummy > -10) c = '0' - dummy;
3680 if (have_flag(flgs, stat + TR_SUST_STR))
3682 /* Dark green "s" */
3689 Term_putch(col, row + stat+1, a, c);
3695 * Display the character on the screen (various modes)
3697 * The top one and bottom two lines are left blank.
3699 * Mode 0 = standard display with skills
3700 * Mode 1 = standard display with history
3701 * Mode 2 = summary of various things
3702 * Mode 3 = summary of various things (part 2)
3703 * Mode 4 = mutations
3705 void display_player(int mode)
3714 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3723 if ((mode == 0) || (mode == 1))
3725 /* Name, Sex, Race, Class */
3727 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3729 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3732 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3733 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3734 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3735 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3740 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3742 strcpy(tmp, realm_names[p_ptr->realm1]);
3743 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3746 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3747 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3749 /* Age, Height, Weight, Social */
3750 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
3752 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
3753 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3754 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3755 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3757 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3758 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3759 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3760 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3762 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3765 /* Display the stats */
3766 for (i = 0; i < 6; i++)
3768 /* Special treatment of "injured" stats */
3769 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3773 /* Use lowercase stat name */
3774 put_str(stat_names_reduced[i], 3 + i, 53);
3776 /* Get the current stat */
3777 value = p_ptr->stat_use[i];
3779 /* Obtain the current stat (modified) */
3780 cnv_stat(value, buf);
3782 /* Display the current stat (modified) */
3783 c_put_str(TERM_YELLOW, buf, 3 + i, 60);
3785 /* Acquire the max stat */
3786 value = p_ptr->stat_top[i];
3788 /* Obtain the maximum stat (modified) */
3789 cnv_stat(value, buf);
3791 /* Display the maximum stat (modified) */
3792 c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
3795 /* Normal treatment of "normal" stats */
3798 /* Assume uppercase stat name */
3799 put_str(stat_names[i], 3 + i, 53);
3801 /* Obtain the current stat (modified) */
3802 cnv_stat(p_ptr->stat_use[i], buf);
3804 /* Display the current stat (modified) */
3805 c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
3808 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3811 c_put_str(TERM_WHITE, "!", 3 + i, 58);
3813 c_put_str(TERM_WHITE, "!", 3 + i, 58-2);
3818 /* Display "history" info */
3824 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
3826 put_str("(Character Background)", 11, 25);
3829 for (i = 0; i < 4; i++)
3831 put_str(p_ptr->history[i], i + 12, 10);
3838 if (p_ptr->total_winner)
3841 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å%s¤·¤¿¡£", streq(p_ptr->died_from, "Seppuku") ? "ÀÚÊ¢" : "°úÂà");
3843 sprintf(statmsg, "...You %s after the winning.", streq(p_ptr->died_from, "Seppuku") ? "did Seppuku" : "retired from the adventure");
3846 else if (!dun_level)
3849 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), p_ptr->died_from);
3851 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3854 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3856 /* Get the quest text */
3857 /* Bewere that INIT_ASSIGN resets the cur_num. */
3858 init_flags = INIT_ASSIGN;
3860 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3863 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3865 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3871 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
3873 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3877 else if (character_dungeon)
3882 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
3884 sprintf(statmsg, "...Now, you are in %s.", map_name());
3887 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3889 /* Clear the text */
3890 /* Must be done before doing INIT_SHOW_TEXT */
3891 for (i = 0; i < 10; i++)
3893 quest_text[i][0] = '\0';
3895 quest_text_line = 0;
3897 /* Get the quest text */
3898 init_flags = INIT_SHOW_TEXT;
3900 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3903 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
3905 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
3911 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
3913 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
3920 char temp[64*2], *t;
3921 roff_to_buf(statmsg, 60, temp, sizeof(temp));
3923 for(i=0 ; i<2 ; i++)
3929 put_str(t, i + 5 + 12, 10);
3937 /* Display "various" info */
3940 display_player_middle();
3941 display_player_various();
3948 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
3951 display_player_misc_info();
3952 display_player_stat_info();
3953 display_player_flag_info();
3959 display_player_other_flag_info();
3964 do_cmd_knowledge_mutations();
3972 static void dump_aux_display_player(FILE *fff)
3979 /* Display player */
3982 /* Dump part of the screen */
3983 for (y = 1; y < 22; y++)
3986 for (x = 0; x < 79; x++)
3988 /* Get the attr/char */
3989 (void)(Term_what(x, y, &a, &c));
3995 /* End the string */
3998 /* Kill trailing spaces */
3999 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4003 fprintf(fff, "%s\n", buf);
4005 fprintf(fff, "%s\n", buf);
4010 /* Display history */
4013 /* Dump part of the screen */
4014 for (y = 10; y < 19; y++)
4017 for (x = 0; x < 79; x++)
4019 /* Get the attr/char */
4020 (void)(Term_what(x, y, &a, &c));
4026 /* End the string */
4029 /* Kill trailing spaces */
4030 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4033 fprintf(fff, "%s\n", buf);
4038 /* Display flags (part 1) */
4041 /* Dump part of the screen */
4042 for (y = 2; y < 22; y++)
4045 for (x = 0; x < 79; x++)
4047 /* Get the attr/char */
4048 (void)(Term_what(x, y, &a, &c));
4050 /* Dump it (Ignore equippy tile graphic) */
4057 /* End the string */
4060 /* Kill trailing spaces */
4061 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4064 fprintf(fff, "%s\n", buf);
4069 /* Display flags (part 2) */
4072 /* Dump part of the screen */
4073 for (y = 1; y < 22; y++)
4076 for (x = 0; x < 79; x++)
4078 /* Get the attr/char */
4079 (void)(Term_what(x, y, &a, &c));
4081 /* Dump it (Ignore equippy tile graphic) */
4088 /* End the string */
4091 /* Kill trailing spaces */
4092 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4095 fprintf(fff, "%s\n", buf);
4098 for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
4101 for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
4109 static void dump_aux_pet(FILE *fff)
4113 bool pet_settings = FALSE;
4116 for (i = m_max - 1; i >= 1; i--)
4118 monster_type *m_ptr = &m_list[i];
4120 if (!m_ptr->r_idx) continue;
4121 if (!is_pet(m_ptr)) continue;
4122 pet_settings = TRUE;
4123 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4127 fprintf(fff, "\n\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4129 fprintf(fff, "\n\n [Leading Pets]\n\n");
4133 monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
4134 fprintf(fff, "%s\n", pet_name);
4140 fprintf(fff, "\n\n [¥Ú¥Ã¥È¤Ø¤ÎÌ¿Îá]\n");
4142 fprintf(fff, "\n\n [Command for Pets]\n");
4146 fprintf(fff, "\n ¥É¥¢¤ò³«¤±¤ë: %s", (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4148 fprintf(fff, "\n Pets open doors: %s", (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4152 fprintf(fff, "\n ¥¢¥¤¥Æ¥à¤ò½¦¤¦: %s", (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4154 fprintf(fff, "\n Pets pick up items: %s", (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4158 fprintf(fff, "\n ¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4160 fprintf(fff, "\n Allow teleport: %s", (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4164 fprintf(fff, "\n ¹¶·âËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4166 fprintf(fff, "\n Allow cast attack spell: %s", (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4170 fprintf(fff, "\n ¾¤´ËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4172 fprintf(fff, "\n Allow cast summon spell: %s", (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4176 fprintf(fff, "\n ¥×¥ì¥¤¥ä¡¼¤ò´¬¤¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4178 fprintf(fff, "\n Allow involve player in area spell: %s", (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4189 static void dump_aux_class_special(FILE *fff)
4191 if (p_ptr->pclass == CLASS_BLUE_MAGE)
4198 int spellnum[MAX_MONSPELLS];
4199 s32b f4 = 0, f5 = 0, f6 = 0;
4204 for (i=0;i<60;i++) { p[i][0] = '\0'; }
4207 strcat(p[col], "\n\n [³Ø½¬ºÑ¤ß¤ÎÀÄËâË¡]\n");
4209 strcat(p[col], "\n\n [Learned Blue Magic]\n");
4216 set_rf_masks(&f4, &f5, &f6, j);
4219 case MONSPELL_TYPE_BOLT:
4221 strcat(p[col], "\n [¥Ü¥ë¥È·¿]\n");
4223 strcat(p[col], "\n [Bolt Type]\n");
4227 case MONSPELL_TYPE_BALL:
4229 strcat(p[col], "\n [¥Ü¡¼¥ë·¿]\n");
4231 strcat(p[col], "\n [Ball Type]\n");
4235 case MONSPELL_TYPE_BREATH:
4237 strcat(p[col], "\n [¥Ö¥ì¥¹·¿]\n");
4239 strcat(p[col], "\n [ Breath ]\n");
4243 case MONSPELL_TYPE_SUMMON:
4245 strcat(p[col], "\n [¾¤´ËâË¡]\n");
4247 strcat(p[col], "\n [Summonning]\n");
4251 case MONSPELL_TYPE_OTHER:
4253 strcat(p[col], "\n [ ¤½¤Î¾ ]\n");
4255 strcat(p[col], "\n [Other Type]\n");
4260 for (i = 0, num = 0; i < 32; i++)
4262 if ((0x00000001 << i) & f4) spellnum[num++] = i;
4266 if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
4270 if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
4275 strcat(p[col], " ");
4277 for (i = 0; i < num; i++)
4279 if (p_ptr->magic_num2[spellnum[i]])
4282 /* Dump blue magic */
4283 l1 = strlen(p[col]);
4284 l2 = strlen(monster_powers_short[spellnum[i]]);
4285 if ((l1 + l2) >= 75)
4287 strcat(p[col], "\n");
4289 strcat(p[col], " ");
4291 strcat(p[col], monster_powers_short[spellnum[i]]);
4292 strcat(p[col], ", ");
4299 strcat(p[col], "¤Ê¤·");
4301 strcat(p[col], "None");
4306 if (p[col][strlen(p[col])-2] == ',')
4308 p[col][strlen(p[col])-2] = '\0';
4312 p[col][strlen(p[col])-10] = '\0';
4316 strcat(p[col], "\n");
4319 for (i=0;i<=col;i++)
4330 static void dump_aux_quest(FILE *fff)
4338 fprintf(fff, "\n\n [¥¯¥¨¥¹¥È¾ðÊó]\n");
4340 fprintf(fff, "\n\n [Quest Information]\n");
4343 /* Allocate Memory */
4344 C_MAKE(quest_num, max_quests, int);
4346 /* Sort by compete level */
4347 for (i = 1; i < max_quests; i++) quest_num[i] = i;
4348 ang_sort_comp = ang_sort_comp_quest_num;
4349 ang_sort_swap = ang_sort_swap_quest_num;
4350 ang_sort(quest_num, &dummy, max_quests);
4352 /* Dump Quest Information */
4354 do_cmd_knowledge_quests_completed(fff, quest_num);
4356 do_cmd_knowledge_quests_failed(fff, quest_num);
4360 C_KILL(quest_num, max_quests, int);
4367 static void dump_aux_last_message(FILE *fff)
4371 if (!p_ptr->total_winner)
4376 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4378 fprintf(fff, "\n [Last Messages]\n\n");
4380 for (i = MIN(message_num(), 30); i >= 0; i--)
4382 fprintf(fff,"> %s\n",message_str((s16b)i));
4387 /* Hack -- *Winning* message */
4388 else if (p_ptr->last_message)
4391 fprintf(fff, "\n [*¾¡Íø*¥á¥Ã¥»¡¼¥¸]\n\n");
4393 fprintf(fff, "\n [*Winning* Message]\n\n");
4395 fprintf(fff," %s\n", p_ptr->last_message);
4405 static void dump_aux_recall(FILE *fff)
4410 fprintf(fff, "\n [µ¢´Ô¾ì½ê]\n\n");
4412 fprintf(fff, "\n [Recall Depth]\n\n");
4415 for (y = 1; y < max_d_idx; y++)
4419 if (!d_info[y].maxdepth) continue;
4420 if (!max_dlv[y]) continue;
4421 if (d_info[y].final_guardian)
4423 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4425 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4428 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4430 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4439 static void dump_aux_options(FILE *fff)
4442 fprintf(fff, "\n [¥ª¥×¥·¥ç¥óÀßÄê]\n");
4444 fprintf(fff, "\n [Option Settings]\n");
4450 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4452 fprintf(fff, "\n Preserve Mode: ON");
4457 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4459 fprintf(fff, "\n Preserve Mode: OFF");
4463 if (ironman_small_levels)
4465 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4467 fprintf(fff, "\n Small Levels: ALWAYS");
4470 else if (always_small_levels)
4472 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4474 fprintf(fff, "\n Small Levels: ON");
4477 else if (small_levels)
4479 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4481 fprintf(fff, "\n Small Levels: ENABLED");
4486 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4488 fprintf(fff, "\n Small Levels: OFF");
4494 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4496 fprintf(fff, "\n Vanilla Town: ON");
4501 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4503 fprintf(fff, "\n Lite Town: ON");
4509 fprintf(fff, "\n Ź¤Ê¤·: ON");
4511 fprintf(fff, "\n No Shops: ON");
4515 if (ironman_downward)
4517 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4519 fprintf(fff, "\n Diving Only: ON");
4525 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°: ON");
4527 fprintf(fff, "\n Unusual Rooms: ON");
4531 if (ironman_nightmare)
4533 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4535 fprintf(fff, "\n Nightmare Mode: ON");
4539 if (ironman_empty_levels)
4541 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4543 fprintf(fff, "\n Arena Levels: ALWAYS");
4546 else if (empty_levels)
4548 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ENABLED");
4550 fprintf(fff, "\n Arena Levels: ENABLED");
4555 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4557 fprintf(fff, "\n Arena Levels: OFF");
4565 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤¤¤Þ¤¹¡£\n");
4567 fprintf(fff, "\n You have done something illegal.\n");
4577 static void dump_aux_arena(FILE *fff)
4579 if (lite_town || vanilla_town) return;
4581 if (p_ptr->arena_number < 0)
4583 if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
4586 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4588 fprintf(fff, "\n Arena: Defeated\n");
4594 fprintf(fff, "\n Æ®µ»¾ì: %d²óÀï¤Ç%s¤ÎÁ°¤ËÇÔËÌ\n", -p_ptr->arena_number,
4595 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
4597 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
4598 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
4599 -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
4603 else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
4606 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4608 fprintf(fff, "\n Arena: True Champion\n");
4611 else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
4614 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4616 fprintf(fff, "\n Arena: Champion\n");
4622 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4624 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");
4635 static void dump_aux_monsters(FILE *fff)
4637 /* Monsters slain */
4640 long uniq_total = 0;
4641 long norm_total = 0;
4644 /* Sort by monster level */
4648 fprintf(fff, "\n [Åݤ·¤¿¥â¥ó¥¹¥¿¡¼]\n\n");
4650 fprintf(fff, "\n [Defeated Monsters]\n\n");
4653 /* Allocate the "who" array */
4654 C_MAKE(who, max_r_idx, s16b);
4656 /* Count monster kills */
4657 for (k = 1; k < max_r_idx; k++)
4659 monster_race *r_ptr = &r_info[k];
4661 /* Ignore unused index */
4662 if (!r_ptr->name) continue;
4664 /* Unique monsters */
4665 if (r_ptr->flags1 & RF1_UNIQUE)
4667 bool dead = (r_ptr->max_num == 0);
4672 /* Add a unique monster to the list */
4673 who[uniq_total++] = k;
4677 /* Normal monsters */
4680 if (r_ptr->r_pkills > 0)
4682 norm_total += r_ptr->r_pkills;
4688 /* No monsters is defeated */
4692 fprintf(fff,"¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4694 fprintf(fff,"You have defeated no enemies yet.\n");
4698 /* Defeated more than one normal monsters */
4699 else if (uniq_total == 0)
4702 fprintf(fff,"%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", norm_total);
4704 fprintf(fff,"You have defeated %ld %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
4708 /* Defeated more than one unique monsters */
4709 else /* if (uniq_total > 0) */
4712 fprintf(fff, "%ldÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ò´Þ¤à¡¢¹ç·×%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", uniq_total, norm_total);
4714 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"));
4718 /* Select the sort method */
4719 ang_sort_comp = ang_sort_comp_hook;
4720 ang_sort_swap = ang_sort_swap_hook;
4722 /* Sort the array by dungeon depth of monsters */
4723 ang_sort(who, &why, uniq_total);
4726 fprintf(fff, "\n¡Ô¾å°Ì%ldÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¡Õ\n", MIN(uniq_total, 10));
4728 fprintf(fff, "\n< Unique monsters top %ld >\n", MIN(uniq_total, 10));
4732 for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
4734 monster_race *r_ptr = &r_info[who[k]];
4737 fprintf(fff, " %-40s (¥ì¥Ù¥ë%3d)\n", (r_name + r_ptr->name), r_ptr->level);
4739 fprintf(fff, " %-40s (level %3d)\n", (r_name + r_ptr->name), r_ptr->level);
4745 /* Free the "who" array */
4746 C_KILL(who, max_r_idx, s16b);
4753 static void dump_aux_race_history(FILE *fff)
4755 if (p_ptr->old_race1 || p_ptr->old_race2)
4760 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4762 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4764 for (i = 0; i < MAX_RACES; i++)
4766 if (p_ptr->start_race == i) continue;
4769 if (!(p_ptr->old_race1 & 1L << i)) continue;
4773 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4776 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4778 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4790 static void dump_aux_realm_history(FILE *fff)
4792 if (p_ptr->old_realm)
4797 for (i = 0; i < MAX_MAGIC; i++)
4799 if (!(p_ptr->old_realm & 1L << i)) continue;
4801 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4803 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4814 static void dump_aux_virtues(FILE *fff)
4817 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4819 fprintf(fff, "\n\n [Virtues]\n\n");
4823 fprintf(fff, "°À : %s\n", your_alignment());
4825 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4836 static void dump_aux_mutations(FILE *fff)
4838 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4841 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4843 fprintf(fff, "\n\n [Mutations]\n\n");
4846 dump_mutations(fff);
4854 static void dump_aux_equipment_inventory(FILE *fff)
4857 char o_name[MAX_NLEN];
4859 /* Dump the equipment */
4863 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷]\n\n");
4865 fprintf(fff, " [Character Equipment]\n\n");
4868 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4870 object_desc(o_name, &inventory[i], 0);
4871 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
4873 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4875 strcpy(o_name, "(wielding with two-hands)");
4878 fprintf(fff, "%c) %s\n",
4879 index_to_label(i), o_name);
4881 fprintf(fff, "\n\n");
4884 /* Dump the inventory */
4886 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ]\n\n");
4888 fprintf(fff, " [Character Inventory]\n\n");
4891 for (i = 0; i < INVEN_PACK; i++)
4893 /* Don't dump the empty slots */
4894 if (!inventory[i].k_idx) break;
4896 /* Dump the inventory slots */
4897 object_desc(o_name, &inventory[i], 0);
4898 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
4901 /* Add an empty line */
4902 fprintf(fff, "\n\n");
4909 static void dump_aux_home_museum(FILE *fff)
4911 char o_name[MAX_NLEN];
4914 /* Do we need it?? */
4915 /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
4917 /* Print the home */
4918 st_ptr = &town[1].store[STORE_HOME];
4920 /* Home -- if anything there */
4921 if (st_ptr->stock_num)
4927 fprintf(fff, " [²æ¤¬²È¤Î¥¢¥¤¥Æ¥à]\n");
4929 fprintf(fff, " [Home Inventory]\n");
4932 /* Dump all available items */
4933 for (i = 0; i < st_ptr->stock_num; i++)
4937 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4939 fprintf(fff, "\n ( page %d )\n", x++);
4941 object_desc(o_name, &st_ptr->stock[i], 0);
4942 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4945 /* Add an empty line */
4946 fprintf(fff, "\n\n");
4950 /* Print the home */
4951 st_ptr = &town[1].store[STORE_MUSEUM];
4953 /* Home -- if anything there */
4954 if (st_ptr->stock_num)
4960 fprintf(fff, " [Çîʪ´Û¤Î¥¢¥¤¥Æ¥à]\n");
4962 fprintf(fff, " [Museum]\n");
4965 /* Dump all available items */
4966 for (i = 0; i < st_ptr->stock_num; i++)
4969 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4970 object_desc(o_name, &st_ptr->stock[i], 0);
4971 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4973 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4974 object_desc(o_name, &st_ptr->stock[i], 0);
4975 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4980 /* Add an empty line */
4981 fprintf(fff, "\n\n");
4987 * Output the character dump to a file
4989 errr make_character_dump(FILE *fff)
4992 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4993 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4995 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4996 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
5001 dump_aux_display_player(fff);
5002 dump_aux_last_message(fff);
5003 dump_aux_options(fff);
5004 dump_aux_recall(fff);
5005 dump_aux_quest(fff);
5006 dump_aux_arena(fff);
5007 dump_aux_monsters(fff);
5008 dump_aux_virtues(fff);
5009 dump_aux_race_history(fff);
5010 dump_aux_realm_history(fff);
5011 dump_aux_class_special(fff);
5012 dump_aux_mutations(fff);
5015 dump_aux_equipment_inventory(fff);
5016 dump_aux_home_museum(fff);
5019 fprintf(fff, " [¥Á¥§¥Ã¥¯¥µ¥à: \"%s\"]\n\n", get_check_sum());
5021 fprintf(fff, " [Check Sum: \"%s\"]\n\n", get_check_sum());
5028 * Hack -- Dump a character description file
5030 * XXX XXX XXX Allow the "full" flag to dump additional info,
5031 * and trigger its usage from various places in the code.
5033 errr file_character(cptr name)
5039 /* Build the filename */
5040 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
5042 /* File type is "TEXT" */
5043 FILE_TYPE(FILE_TYPE_TEXT);
5045 /* Check for existing file */
5046 fd = fd_open(buf, O_RDONLY);
5053 /* Close the file */
5058 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
5060 (void)sprintf(out_val, "Replace existing file %s? ", buf);
5065 if (get_check_strict(out_val, CHECK_NO_HISTORY)) fd = -1;
5068 /* Open the non-existing file */
5069 if (fd < 0) fff = my_fopen(buf, "w");
5076 prt("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", 0, 0);
5078 prt("Character dump failed!", 0, 0);
5087 (void)make_character_dump(fff);
5095 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
5097 msg_print("Character dump successful.");
5108 * Display single line of on-line help file
5110 * You can insert some special color tag to change text color.
5112 * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
5114 * A colored segment is between "[[[[y|" and the last "|".
5115 * You can use any single character in place of the "|".
5117 static void show_file_aux_line(cptr str, int cy, cptr shower)
5119 static const char tag_str[] = "[[[[";
5120 byte color = TERM_WHITE;
5128 /* Make a lower case version of str for searching */
5133 /* Initial cursor position */
5134 Term_gotoxy(cx, cy);
5136 for (i = 0; str[i];)
5138 int len = strlen(&str[i]);
5139 int showercol = len + 1;
5140 int bracketcol = len + 1;
5144 /* Search for a shower string in the line */
5147 ptr = my_strstr(&lcstr[i], shower);
5148 if (ptr) showercol = ptr - &lcstr[i];
5151 /* Search for a color segment tag */
5152 ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
5153 if (ptr) bracketcol = ptr - &str[i];
5155 /* A color tag is found */
5156 if (bracketcol < endcol) endcol = bracketcol;
5158 /* The shower string is found before the color tag */
5159 if (showercol < endcol) endcol = showercol;
5161 /* Print a segment of the line */
5162 Term_addstr(endcol, color, &str[i]);
5166 /* Shower string? */
5167 if (endcol == showercol)
5169 int showerlen = strlen(shower);
5171 /* Print the shower string in yellow */
5172 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
5177 /* Colored segment? */
5178 else if (endcol == bracketcol)
5182 /* Found the end of colored segment */
5185 /* Now looking for an another tag_str */
5188 /* Set back to the default color */
5193 /* Found a tag_str, and get a tag color */
5194 i += sizeof(tag_str)-1;
5197 color = color_char_to_attr(str[i]);
5199 /* Illegal color tag */
5200 if (color == 255 || str[i+1] == '\0')
5202 /* Illegal color tag */
5205 /* Print the broken tag as a string */
5206 Term_addstr(-1, TERM_WHITE, tag_str);
5207 cx += sizeof(tag_str)-1;
5211 /* Skip the color tag */
5214 /* Now looking for a close tag */
5217 /* Skip the close-tag-indicator */
5223 } /* for (i = 0; str[i];) */
5225 /* Clear rest of line */
5226 Term_erase(cx, cy, 255);
5231 * Recursive file perusal.
5233 * Process various special text in the input file, including
5234 * the "menu" structures used by the "help file" system.
5236 * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
5238 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
5242 /* Number of "real" lines passed by */
5245 /* Number of "real" lines in the file */
5248 /* Backup value for "line" */
5251 /* This screen has sub-screens */
5254 /* Current help file */
5257 /* Find this string (if any) */
5260 /* Jump to this tag */
5263 /* Hold strings to find/show */
5264 char finder_str[81];
5265 char shower_str[81];
5267 /* String to show */
5271 char filename[1024];
5273 /* Describe this thing */
5279 /* General buffer */
5282 /* Sub-menu information */
5285 bool reverse = (line < 0);
5289 Term_get_size(&wid, &hgt);
5293 strcpy(finder_str, "");
5296 strcpy(shower_str, "");
5299 strcpy(caption, "");
5301 /* Wipe the hooks */
5302 for (i = 0; i < 68; i++)
5307 /* Copy the filename */
5308 strcpy(filename, name);
5310 n = strlen(filename);
5312 /* Extract the tag from the filename */
5313 for (i = 0; i < n; i++)
5315 if (filename[i] == '#')
5318 tag = filename + i + 1;
5323 /* Redirect the name */
5326 /* Hack XXX XXX XXX */
5330 strcpy(caption, what);
5332 /* Access the "file" */
5336 fff = my_fopen(path, "r");
5339 /* Look in "help" */
5344 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5346 sprintf(caption, "Help file '%s'", name);
5350 /* Build the filename */
5351 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5354 fff = my_fopen(path, "r");
5357 /* Look in "info" */
5362 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5364 sprintf(caption, "Info file '%s'", name);
5368 /* Build the filename */
5369 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5372 fff = my_fopen(path, "r");
5375 /* Look in "info" */
5378 /* Build the filename */
5379 path_build(path, sizeof(path), ANGBAND_DIR, name);
5381 for (i = 0; path[i]; i++)
5382 if ('\\' == path[i])
5383 path[i] = PATH_SEP[0];
5387 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5389 sprintf(caption, "Info file '%s'", name);
5393 fff = my_fopen(path, "r");
5401 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5403 msg_format("Cannot open '%s'.", name);
5413 /* Pre-Parse the file */
5418 /* Read a line or stop */
5419 if (my_fgets(fff, buf, sizeof(buf))) break;
5421 /* XXX Parse "menu" items */
5422 if (prefix(str, "***** "))
5424 /* Notice "menu" requests */
5425 if ((str[6] == '[') && isalpha(str[7]))
5427 /* Extract the menu item */
5428 int k = str[7] - 'A';
5430 /* This is a menu file */
5433 if ((str[8] == ']') && (str[9] == ' '))
5435 /* Extract the menu item */
5436 strncpy(hook[k], str + 10, 31);
5438 /* Make sure it's null-terminated */
5442 /* Notice "tag" requests */
5443 else if (str[6] == '<')
5445 size_t len = strlen(str);
5447 if (str[len - 1] == '>')
5449 str[len - 1] = '\0';
5450 if (tag && streq(str + 7, tag)) line = next;
5458 /* Count the "real" lines */
5462 /* Save the number of "real" lines */
5465 /* start from bottom when reverse mode */
5466 if (line == -1) line = ((size-1)/rows)*rows;
5471 /* Display the file */
5474 /* Restart when necessary */
5475 if (line >= size - rows) line = size - rows;
5476 if (line < 0) line = 0;
5478 /* Re-open the file if needed */
5484 /* Hack -- Re-Open the file */
5485 fff = my_fopen(path, "r");
5488 if (!fff) return (FALSE);
5490 /* File has been restarted */
5494 /* Goto the selected line */
5498 if (my_fgets(fff, buf, sizeof(buf))) break;
5500 /* Skip tags/links */
5501 if (prefix(buf, "***** ")) continue;
5503 /* Count the lines */
5507 /* Dump the next 20, or rows, lines of the file */
5508 for (i = 0; i < rows; )
5512 /* Hack -- track the "first" line */
5513 if (!i) line = next;
5515 /* Get a line of the file or stop */
5516 if (my_fgets(fff, buf, sizeof(buf))) break;
5518 /* Hack -- skip "special" lines */
5519 if (prefix(buf, "***** ")) continue;
5521 /* Count the "real" lines */
5524 /* Hack -- keep searching */
5529 /* Make a lower case version of str for searching */
5530 strcpy(lc_buf, str);
5531 str_tolower(lc_buf);
5533 if (!my_strstr(lc_buf, find)) continue;
5536 /* Hack -- stop searching */
5540 show_file_aux_line(str, i + 2, shower);
5542 /* Count the printed lines */
5548 /* Clear rest of line */
5549 Term_erase(0, i + 2, 255);
5554 /* Hack -- failed search */
5564 /* Show a general "title" */
5569 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5571 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5574 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5575 caption, line, size), 0, 0);
5585 caption, line, size), 0, 0);
5588 /* Prompt -- small files */
5593 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5595 prt("[Press ESC to exit.]", hgt - 1, 0);
5600 /* Prompt -- large files */
5605 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5607 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5609 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5613 /* Get a special key code */
5614 skey = inkey_special(TRUE);
5616 /* Show the help for the help */
5619 /* Hack - prevent silly recursion */
5621 if (strcmp(name, "jhelpinfo.txt") != 0)
5622 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5624 if (strcmp(name, "helpinfo.txt") != 0)
5625 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5629 /* Hack -- try showing */
5634 prt("¶¯Ä´: ", hgt - 1, 0);
5636 prt("Show: ", hgt - 1, 0);
5639 (void)askfor(shower_str, 80);
5641 /* Make it lowercase */
5642 str_tolower(shower_str);
5645 shower = shower_str;
5648 /* Hack -- try finding */
5649 if (skey == '/' || skey == KTRL('s'))
5653 prt("¸¡º÷: ", hgt - 1, 0);
5655 prt("Find: ", hgt - 1, 0);
5659 if (askfor(finder_str, 80))
5666 /* Make finder lowercase */
5667 str_tolower(finder_str);
5670 shower = finder_str;
5674 /* Hack -- go to a specific line */
5679 prt("¹Ô: ", hgt - 1, 0);
5681 prt("Goto Line: ", hgt - 1, 0);
5686 if (askfor(tmp, 80))
5692 /* Hack -- go to the top line */
5693 if (skey == SKEY_TOP)
5698 /* Hack -- go to the bottom line */
5699 if (skey == SKEY_BOTTOM)
5701 line = ((size-1)/rows)*rows;
5704 /* Hack -- go to a specific file */
5709 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5710 strcpy(tmp, "jhelp.hlp");
5712 prt("Goto File: ", hgt - 1, 0);
5713 strcpy(tmp, "help.hlp");
5717 if (askfor(tmp, 80))
5719 if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
5723 /* Allow backing up */
5726 line = line + (reverse ? rows : -rows);
5727 if (line < 0) line = 0;
5731 if (skey == SKEY_PGUP)
5734 if (line < 0) line = 0;
5737 /* Advance a single line */
5738 if ((skey == '\n') || (skey == '\r'))
5740 line = line + (reverse ? -1 : 1);
5741 if (line < 0) line = 0;
5745 /* Move up / down */
5746 if (skey == '8' || skey == SKEY_UP)
5749 if (line < 0) line = 0;
5752 if (skey == '2' || skey == SKEY_DOWN) line++;
5754 /* Advance one page */
5757 line = line + (reverse ? -rows : rows);
5758 if (line < 0) line = 0;
5762 if (skey == SKEY_PGDOWN)
5767 /* Recurse on numbers */
5772 if (!(skey & SKEY_MASK) && isalpha(skey))
5775 if ((key > -1) && hook[key][0])
5777 /* Recurse on that file */
5778 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5783 /* Hack, dump to file */
5793 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5795 if (!get_string("File name: ", xtmp, 80))
5804 /* Build the filename */
5805 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5807 /* Hack -- Re-Open the file */
5808 fff = my_fopen(path, "r");
5810 ffp = my_fopen(buff, "w");
5816 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5818 msg_print("Failed to open file.");
5825 sprintf(xtmp, "%s: %s", player_name, what ? what : caption);
5826 my_fputs(ffp, xtmp, 80);
5827 my_fputs(ffp, "\n", 80);
5829 while (!my_fgets(fff, buff, sizeof(buff)))
5830 my_fputs(ffp, buff, 80);
5836 /* Hack -- Re-Open the file */
5837 fff = my_fopen(path, "r");
5840 /* Return to last screen */
5841 if (skey == ESCAPE) break;
5842 if (skey == '<') break;
5844 /* Exit on the ^q */
5845 if (skey == KTRL('q')) skey = 'q';
5847 /* Exit on the q key */
5848 if (skey == 'q') break;
5851 /* Close the file */
5855 if (skey == 'q') return (FALSE);
5863 * Peruse the On-Line-Help
5865 void do_cmd_help(void)
5870 /* Peruse the main help file */
5872 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5874 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5884 * Process the player name.
5885 * Extract a clean "base name".
5886 * Build the savefile name if needed.
5888 void process_player_name(bool sf)
5891 char old_player_base[32] = "";
5893 if (character_generated) strcpy(old_player_base, player_base);
5895 /* Cannot be too long */
5896 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5898 if (strlen(player_name) > 8)
5900 if (strlen(player_name) > 15)
5905 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5907 quit_fmt("The name '%s' is too long!", player_name);
5913 /* Cannot contain "icky" characters */
5914 for (i = 0; player_name[i]; i++)
5916 /* No control characters */
5918 if (iskanji(player_name[i])){i++;continue;}
5919 if (iscntrl( (unsigned char)player_name[i]))
5921 if (iscntrl(player_name[i]))
5925 /* Illegal characters */
5927 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5929 quit_fmt("The name '%s' contains control chars!", player_name);
5938 /* Extract "useful" letters */
5939 for (i = 0; player_name[i]; i++)
5942 unsigned char c = player_name[i];
5944 char c = player_name[i];
5948 /* Convert "dot" to "underscore" */
5949 if (c == '.') c = '_';
5951 /* Accept all the letters */
5952 player_base[k++] = c;
5957 /* Extract "useful" letters */
5958 for (i = 0; player_name[i]; i++)
5961 unsigned char c = player_name[i];
5963 char c = player_name[i];
5966 /* Accept some letters */
5969 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5970 player_base[k++] = c;
5972 player_base[k++] = player_name[i];
5975 else if (iskana(c)) player_base[k++] = c;
5979 /* Convert path separator to underscore */
5980 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5981 player_base[k++] = '_';
5982 i += strlen(PATH_SEP);
5985 /* Convert space, dot, and underscore to underscore */
5986 else if (my_strchr(". _", c)) player_base[k++] = '_';
5988 else if (isprint(c)) player_base[k++] = c;
5996 /* Hack -- max length */
6002 player_base[k] = '\0';
6004 /* Require a "base" name */
6005 if (!player_base[0]) strcpy(player_base, "PLAYER");
6008 #ifdef SAVEFILE_MUTABLE
6014 if (!savefile_base[0] && savefile[0])
6021 t = my_strstr(s, PATH_SEP);
6026 strcpy(savefile_base, s);
6029 if (!savefile_base[0] || !savefile[0])
6032 /* Change the savefile name */
6037 strcpy(savefile_base, player_base);
6039 #ifdef SAVEFILE_USE_UID
6040 /* Rename the savefile, using the player_uid and player_base */
6041 (void)sprintf(temp, "%d.%s", player_uid, player_base);
6043 /* Rename the savefile, using the player_base */
6044 (void)sprintf(temp, "%s", player_base);
6048 /* Hack -- support "flat directory" usage on VM/ESA */
6049 (void)sprintf(temp, "%s.sv", player_base);
6052 /* Build the filename */
6053 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
6056 /* Load an autopick preference file */
6057 if (character_generated)
6059 if (!streq(old_player_base, player_base)) autopick_load_pref(FALSE);
6065 * Gets a name for the character, reacting to name changes.
6067 * Assumes that "display_player(0)" has just been called
6069 * Perhaps we should NOT ask for a name (at "birth()") on
6070 * Unix machines? XXX XXX
6072 * What a horrible name for a global function. XXX XXX XXX
6078 /* Save the player name */
6079 strcpy(tmp, player_name);
6081 /* Prompt for a new name */
6083 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
6085 if (get_string("Enter a name for your character: ", tmp, 15))
6089 strcpy(player_name, tmp);
6091 else if (0 == strlen(player_name))
6093 /* Use default name */
6094 strcpy(player_name, "PLAYER");
6097 strcpy(tmp,ap_ptr->title);
6104 strcat(tmp,player_name);
6106 /* Re-Draw the name (in light blue) */
6107 Term_erase(34, 1, 255);
6108 c_put_str(TERM_L_BLUE, tmp, 1, 34);
6110 /* Erase the prompt, etc */
6117 * Hack -- commit suicide
6119 void do_cmd_suicide(void)
6126 /* Verify Retirement */
6127 if (p_ptr->total_winner)
6131 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
6133 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
6138 /* Verify Suicide */
6143 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
6145 if (!get_check("Do you really want to commit suicide? ")) return;
6150 if (!p_ptr->noscore)
6152 /* Special Verification for suicide */
6154 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
6156 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
6162 if (i != '@') return;
6165 /* Initialize "last message" buffer */
6166 if (p_ptr->last_message) string_free(p_ptr->last_message);
6167 p_ptr->last_message = NULL;
6169 /* Hack -- Note *winning* message */
6170 if (p_ptr->total_winner && last_words)
6172 char buf[1024] = "";
6177 while (!get_string("*¾¡Íø*¥á¥Ã¥»¡¼¥¸: ", buf, sizeof buf)) ;
6179 while (!get_string("*Winning* message: ", buf, sizeof buf)) ;
6183 while (!get_check_strict("¤è¤í¤·¤¤¤Ç¤¹¤«¡©", CHECK_NO_HISTORY));
6185 while (!get_check_strict("Are you sure? ", CHECK_NO_HISTORY));
6190 p_ptr->last_message = string_make(buf);
6191 msg_print(p_ptr->last_message);
6196 p_ptr->playing = FALSE;
6198 /* Kill the player */
6199 p_ptr->is_dead = TRUE;
6202 p_ptr->leaving = TRUE;
6204 if (!p_ptr->total_winner)
6207 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
6208 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
6210 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
6211 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
6213 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
6216 /* Cause of death */
6218 (void)strcpy(p_ptr->died_from, "ÅÓÃ潪λ");
6220 (void)strcpy(p_ptr->died_from, "Quitting");
6230 void do_cmd_save_game(int is_autosave)
6232 /* Autosaves do not disturb */
6236 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
6238 msg_print("Autosaving the game...");
6244 /* Disturb the player */
6248 /* Clear messages */
6256 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6258 prt("Saving game...", 0, 0);
6265 /* The player is not dead */
6267 (void)strcpy(p_ptr->died_from, "(¥»¡¼¥Ö)");
6269 (void)strcpy(p_ptr->died_from, "(saved)");
6273 /* Forbid suspend */
6274 signals_ignore_tstp();
6276 /* Save the player */
6280 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6282 prt("Saving game... done.", 0, 0);
6287 /* Save failed (oops) */
6291 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6293 prt("Saving game... failed!", 0, 0);
6298 /* Allow suspend again */
6299 signals_handle_tstp();
6304 /* Note that the player is not dead */
6306 (void)strcpy(p_ptr->died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6308 (void)strcpy(p_ptr->died_from, "(alive and well)");
6311 /* HACK -- don't get sanity blast on updating view */
6317 /* Initialize monster process */
6320 /* HACK -- reset the hackish flag */
6326 * Save the game and exit
6328 void do_cmd_save_and_exit(void)
6330 p_ptr->playing = FALSE;
6333 p_ptr->leaving = TRUE;
6335 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6337 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6343 * Hack -- Calculates the total number of points earned -JWT-
6345 long total_points(void)
6349 u32b point, point_h, point_l;
6350 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6352 if (!preserve_mode) mult += 10;
6353 if (!autoroller) mult += 10;
6354 if (!smart_learn) mult -= 20;
6355 if (smart_cheat) mult += 30;
6356 if (ironman_shops) mult += 50;
6357 if (ironman_small_levels) mult += 10;
6358 if (ironman_empty_levels) mult += 20;
6359 if (!powerup_home) mult += 50;
6360 if (ironman_rooms) mult += 100;
6361 if (ironman_nightmare) mult += 100;
6363 if (mult < 5) mult = 5;
6365 for (i = 0; i < max_d_idx; i++)
6366 if(max_dlv[i] > max_dl)
6367 max_dl = max_dlv[i];
6369 point_l = (p_ptr->max_max_exp + (100 * max_dl));
6370 point_h = point_l / 0x10000L;
6371 point_l = point_l % 0x10000L;
6374 point_h += point_l / 0x10000L;
6375 point_l %= 0x10000L;
6377 point_l += ((point_h % 100) << 16);
6381 point = (point_h << 16) + (point_l);
6382 if (p_ptr->arena_number >= 0)
6383 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6385 if (ironman_downward) point *= 2;
6386 if (p_ptr->pclass == CLASS_BERSERKER)
6388 if ( p_ptr->prace == RACE_SPECTRE )
6392 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6395 if (p_ptr->total_winner) point = 2;
6397 if (easy_band) point = (0 - point);
6403 #define GRAVE_LINE_WIDTH 31
6406 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
6408 static void center_string(char *buf, cptr str)
6415 /* Necessary border */
6416 j = GRAVE_LINE_WIDTH / 2 - i / 2;
6419 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
6425 * Save a "bones" file for a dead character
6427 * Note that we will not use these files until Angband 2.8.0, and
6428 * then we will only use the name and level on which death occured.
6430 * Should probably attempt some form of locking...
6432 static void make_bones(void)
6439 /* Ignore wizards and borgs */
6440 if (!(p_ptr->noscore & 0x00FF))
6442 /* Ignore people who die in town */
6447 /* XXX XXX XXX "Bones" name */
6448 sprintf(tmp, "bone.%03d", dun_level);
6450 /* Build the filename */
6451 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6453 /* Attempt to open the bones file */
6454 fp = my_fopen(str, "r");
6456 /* Close it right away */
6457 if (fp) my_fclose(fp);
6459 /* Do not over-write a previous ghost */
6462 /* File type is "TEXT" */
6463 FILE_TYPE(FILE_TYPE_TEXT);
6465 /* Grab permissions */
6468 /* Try to write a new "Bones File" */
6469 fp = my_fopen(str, "w");
6471 /* Drop permissions */
6474 /* Not allowed to write it? Weird. */
6478 fprintf(fp, "%s\n", player_name);
6479 fprintf(fp, "%d\n", p_ptr->mhp);
6480 fprintf(fp, "%d\n", p_ptr->prace);
6481 fprintf(fp, "%d\n", p_ptr->pclass);
6483 /* Close and save the Bones file */
6492 * Redefinable "print_tombstone" action
6494 bool (*tombstone_aux)(void) = NULL;
6498 * Display a "tomb-stone"
6500 static void print_tomb(void)
6504 /* Do we use a special tombstone ? */
6507 /* Use tombstone hook */
6508 done = (*tombstone_aux)();
6511 /* Print the text-tombstone */
6520 time_t ct = time((time_t)0);
6528 /* Build the filename */
6530 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead_j.txt");
6532 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead.txt");
6535 /* Open the News file */
6536 fp = my_fopen(buf, "r");
6543 /* Dump the file to the screen */
6544 while (0 == my_fgets(fp, buf, sizeof(buf)))
6546 /* Display and advance */
6547 put_str(buf, i++, 0);
6555 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6568 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6571 center_string(buf, player_name);
6572 put_str(buf, 6, 11);
6575 center_string(buf, "the");
6576 put_str(buf, 7, 11);
6579 center_string(buf, p);
6580 put_str(buf, 8, 11);
6582 center_string(buf, cp_ptr->title);
6583 put_str(buf, 10, 11);
6586 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6588 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6590 center_string(buf, tmp);
6591 put_str(buf, 11, 11);
6594 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6596 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6598 center_string(buf, tmp);
6599 put_str(buf, 12, 11);
6602 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6604 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6606 center_string(buf, tmp);
6607 put_str(buf, 13, 11);
6610 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6611 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6613 strcpy(tmp, "<¼«»¦>");
6615 else if (streq(p_ptr->died_from, "ripe"))
6617 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6619 else if (streq(p_ptr->died_from, "Seppuku"))
6621 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6625 roff_to_buf(p_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6626 t = tmp + strlen(tmp) + 1;
6629 strcpy(dummy, t); /* 2nd line */
6630 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6632 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
6635 else if (my_strstr(tmp, "¡Ø") && suffix(dummy, "¡Ù"))
6638 char *name_head = my_strstr(tmp, "¡Ø");
6639 sprintf(dummy2, "%s%s", name_head, dummy);
6640 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6642 strcpy(dummy, dummy2);
6646 else if (my_strstr(tmp, "¡Ö") && suffix(dummy, "¡×"))
6649 char *name_head = my_strstr(tmp, "¡Ö");
6650 sprintf(dummy2, "%s%s", name_head, dummy);
6651 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6653 strcpy(dummy, dummy2);
6657 center_string(buf, dummy);
6658 put_str(buf, 15, 11);
6662 center_string(buf, tmp);
6663 put_str(buf, 14, 11);
6665 if (!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6669 cptr town = p_ptr->town_num ? "³¹" : "¹ÓÌî";
6670 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6672 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6676 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6681 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6683 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6687 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6690 center_string(buf, tmp);
6691 put_str(buf, 15 + extra_line, 11);
6694 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6695 center_string(buf, tmp);
6696 put_str(buf, 14, 11);
6698 roff_to_buf(format("by %s.", p_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6699 center_string(buf, tmp);
6700 put_str(buf, 15, 11);
6701 t = tmp + strlen(tmp) + 1;
6704 strcpy(dummy, t); /* 2nd line */
6705 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6707 int dummy_len = strlen(dummy);
6708 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
6710 center_string(buf, dummy);
6711 put_str(buf, 16, 11);
6715 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6716 center_string(buf, tmp);
6717 put_str(buf, 17, 11);
6720 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6722 msg_format("Goodbye, %s!", player_name);
6729 * Display some character info
6731 static void show_info(void)
6737 /* Hack -- Know everything in the inven/equip */
6738 for (i = 0; i < INVEN_TOTAL; i++)
6740 o_ptr = &inventory[i];
6742 /* Skip non-objects */
6743 if (!o_ptr->k_idx) continue;
6745 /* Aware and Known */
6746 object_aware(o_ptr);
6747 object_known(o_ptr);
6750 for (i = 1; i < max_towns; i++)
6752 st_ptr = &town[i].store[STORE_HOME];
6754 /* Hack -- Know everything in the home */
6755 for (j = 0; j < st_ptr->stock_num; j++)
6757 o_ptr = &st_ptr->stock[j];
6759 /* Skip non-objects */
6760 if (!o_ptr->k_idx) continue;
6762 /* Aware and Known */
6763 object_aware(o_ptr);
6764 object_known(o_ptr);
6768 /* Hack -- Recalculate bonuses */
6769 p_ptr->update |= (PU_BONUS);
6774 /* Flush all input keys */
6777 /* Flush messages */
6781 /* Describe options */
6783 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6784 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6786 prt("You may now dump a character record to one or more files.", 21, 0);
6787 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6791 /* Dump character records as requested */
6798 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6800 put_str("Filename: ", 23, 0);
6805 strcpy(out_val, "");
6807 /* Ask for filename (or abort) */
6808 if (!askfor(out_val, 60)) return;
6810 /* Return means "show on screen" */
6811 if (!out_val[0]) break;
6816 /* Dump a character file */
6817 (void)file_character(out_val);
6825 /* Display player */
6828 /* Prompt for inventory */
6830 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6832 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6836 /* Allow abort at this point */
6837 if (inkey() == ESCAPE) return;
6840 /* Show equipment and inventory */
6842 /* Equipment -- if any */
6846 item_tester_full = TRUE;
6847 (void)show_equip(0);
6849 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6851 prt("You are using: -more-", 0, 0);
6854 if (inkey() == ESCAPE) return;
6857 /* Inventory -- if any */
6861 item_tester_full = TRUE;
6862 (void)show_inven(0);
6864 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6866 prt("You are carrying: -more-", 0, 0);
6869 if (inkey() == ESCAPE) return;
6872 /* Homes in the different towns */
6873 for (l = 1; l < max_towns; l++)
6875 st_ptr = &town[l].store[STORE_HOME];
6877 /* Home -- if anything there */
6878 if (st_ptr->stock_num)
6880 /* Display contents of the home */
6881 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6887 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6889 char o_name[MAX_NLEN];
6893 o_ptr = &st_ptr->stock[i];
6895 /* Print header, clear line */
6896 sprintf(tmp_val, "%c) ", I2A(j));
6897 prt(tmp_val, j+2, 4);
6899 /* Display object description */
6900 object_desc(o_name, o_ptr, 0);
6901 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6906 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6908 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6913 if (inkey() == ESCAPE) return;
6920 static bool check_score(void)
6926 if (highscore_fd < 0)
6929 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6931 msg_print("Score file unavailable.");
6938 #ifndef SCORE_WIZARDS
6939 /* Wizard-mode pre-empts scoring */
6940 if (p_ptr->noscore & 0x000F)
6943 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6945 msg_print("Score not registered for wizards.");
6954 /* Borg-mode pre-empts scoring */
6955 if (p_ptr->noscore & 0x00F0)
6958 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6960 msg_print("Score not registered for borgs.");
6968 #ifndef SCORE_CHEATERS
6969 /* Cheaters are not scored */
6970 if (p_ptr->noscore & 0xFF00)
6973 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6975 msg_print("Score not registered for cheaters.");
6985 if (!p_ptr->total_winner && streq(p_ptr->died_from, "¶¯À©½ªÎ»"))
6987 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Interrupting"))
6992 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6994 msg_print("Score not registered due to interruption.");
7003 if (!p_ptr->total_winner && streq(p_ptr->died_from, "ÅÓÃ潪λ"))
7005 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Quitting"))
7010 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
7012 msg_print("Score not registered due to quitting.");
7022 * Close up the current game (player may or may not be dead)
7024 * This function is called only from "main.c" and "signals.c".
7026 void close_game(void)
7029 bool do_send = TRUE;
7031 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
7036 /* Flush the messages */
7039 /* Flush the input */
7043 /* No suspending now */
7044 signals_ignore_tstp();
7047 /* Hack -- Character is now "icky" */
7048 character_icky = TRUE;
7051 /* Build the filename */
7052 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
7054 /* Grab permissions */
7057 /* Open the high score file, for reading/writing */
7058 highscore_fd = fd_open(buf, O_RDWR);
7060 /* Drop permissions */
7066 /* Handle retirement */
7067 if (p_ptr->total_winner) kingly();
7071 if (!cheat_save || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
7073 if (!cheat_save || get_check("Save death? "))
7078 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7080 if (!save_player()) msg_print("death save failed!");
7083 else do_send = FALSE;
7090 /* Show more info */
7098 if ((!send_world_score(do_send)))
7101 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7103 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7106 p_ptr->wait_report_score = TRUE;
7107 p_ptr->is_dead = FALSE;
7109 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7111 if (!save_player()) msg_print("death save failed!");
7115 if (!p_ptr->wait_report_score)
7118 else if (highscore_fd >= 0)
7120 display_scores_aux(0, 10, -1, NULL);
7123 /* Dump bones file */
7132 do_cmd_save_game(FALSE);
7134 /* Prompt for scores XXX XXX XXX */
7136 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
7138 prt("Press Return (or Escape).", 0, 40);
7142 /* Predict score (or ESCAPE) */
7143 if (inkey() != ESCAPE) predict_score();
7147 /* Shut the high score file */
7148 (void)fd_close(highscore_fd);
7150 /* Forget the high score fd */
7153 /* Kill all temporal files */
7154 clear_saved_floor_files();
7156 /* Allow suspending now */
7157 signals_handle_tstp();
7162 * Handle abrupt death of the visual system
7164 * This routine is called only in very rare situations, and only
7165 * by certain visual systems, when they experience fatal errors.
7167 * XXX XXX Hack -- clear the death flag when creating a HANGUP
7168 * save file so that player can see tombstone when restart.
7170 void exit_game_panic(void)
7172 /* If nothing important has happened, just quit */
7174 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
7176 if (!character_generated || character_saved) quit("panic");
7179 /* Mega-Hack -- see "msg_print()" */
7182 /* Clear the top line */
7185 /* Hack -- turn off some things */
7188 /* Mega-Hack -- Delay death */
7189 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
7191 /* Hardcode panic save */
7192 p_ptr->panic_save = 1;
7194 /* Forbid suspend */
7195 signals_ignore_tstp();
7197 /* Indicate panic save */
7199 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7201 (void)strcpy(p_ptr->died_from, "(panic save)");
7205 /* Panic save, or get worried */
7207 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7209 if (!save_player()) quit("panic save failed!");
7213 /* Successful panic save */
7215 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7217 quit("panic save succeeded!");
7223 * Get a random line from a file
7224 * Based on the monster speech patch by Matt Graham,
7226 errr get_rnd_line(cptr file_name, int entry, char *output)
7234 /* Build the filename */
7235 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
7238 fp = my_fopen(buf, "r");
7243 /* Find the entry of the monster */
7246 /* Get a line from the file */
7247 if (my_fgets(fp, buf, sizeof(buf)) == 0)
7249 /* Count the lines */
7252 /* Look for lines starting with 'N:' */
7253 if ((buf[0] == 'N') && (buf[1] == ':'))
7255 /* Allow default lines */
7261 else if (buf[2] == 'M')
7263 if (r_info[entry].flags1 & RF1_MALE) break;
7265 else if (buf[2] == 'F')
7267 if (r_info[entry].flags1 & RF1_FEMALE) break;
7269 /* Get the monster number */
7270 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7272 /* Is it the right number? */
7273 if (test == entry) break;
7277 /* Error while converting the number */
7278 msg_format("Error in line %d of %s!", line_num, file_name);
7286 /* Reached end of file */
7292 /* Get the random line */
7293 for (counter = 0; ; counter++)
7297 test = my_fgets(fp, buf, sizeof(buf));
7299 /* Count the lines */
7300 /* line_num++; No more needed */
7304 /* Ignore lines starting with 'N:' */
7305 if ((buf[0] == 'N') && (buf[1] == ':')) continue;
7307 if (buf[0] != '#') break;
7316 if (one_in_(counter + 1)) strcpy(output, buf);
7319 /* Close the file */
7323 return counter ? 0 : -1;
7328 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7333 for (i = 0; i < count; i++)
7335 result = get_rnd_line(file_name, entry, output);
7338 for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
7346 * Process file for auto picker/destroyer.
7348 errr process_autopick_file(cptr name)
7354 /* Build the filename */
7355 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7357 err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
7365 * Process file for player's history editor.
7367 errr process_histpref_file(cptr name)
7371 bool old_character_xtra = character_xtra;
7373 /* Build the filename */
7374 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7376 /* Hack -- prevent modification birth options in this file */
7377 character_xtra = TRUE;
7379 err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
7381 character_xtra = old_character_xtra;
7388 static errr counts_seek(int fd, u32b where, bool flag)
7391 char temp1[128], temp2[128];
7392 u32b zero_header[3] = {0L, 0L, 0L};
7395 #ifdef SAVEFILE_USE_UID
7396 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7398 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7400 for (i = 0; temp1[i]; i++)
7401 temp1[i] ^= (i+1) * 63;
7406 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7408 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7413 fd_seek(fd, seekpoint);
7414 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7415 fd_write(fd, (char*)(temp1), sizeof(temp1));
7419 if (strcmp(temp1, temp2) == 0)
7422 seekpoint += 128 + 3 * sizeof(u32b);
7425 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7428 u32b counts_read(int where)
7435 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7437 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7439 fd = fd_open(buf, O_RDONLY);
7441 if (counts_seek(fd, where, FALSE) ||
7442 fd_read(fd, (char*)(&count), sizeof(u32b)))
7450 errr counts_write(int where, u32b count)
7457 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7459 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7462 /* Grab permissions */
7465 fd = fd_open(buf, O_RDWR);
7467 /* Drop permissions */
7472 /* File type is "DATA" */
7473 FILE_TYPE(FILE_TYPE_DATA);
7475 /* Grab permissions */
7478 /* Create a new high score file */
7479 fd = fd_make(buf, 0644);
7481 /* Drop permissions */
7485 /* Grab permissions */
7488 err = fd_lock(fd, F_WRLCK);
7490 /* Drop permissions */
7495 counts_seek(fd, where, TRUE);
7496 fd_write(fd, (char*)(&count), sizeof(u32b));
7498 /* Grab permissions */
7501 err = fd_lock(fd, F_UNLCK);
7503 /* Drop permissions */
7514 #ifdef HANDLE_SIGNALS
7521 * Handle signals -- suspend
7523 * Actually suspend the game, and then resume cleanly
7525 static void handle_signal_suspend(int sig)
7527 /* Disable handler */
7528 (void)signal(sig, SIG_IGN);
7535 /* Suspend the "Term" */
7536 Term_xtra(TERM_XTRA_ALIVE, 0);
7538 /* Suspend ourself */
7539 (void)kill(0, SIGSTOP);
7541 /* Resume the "Term" */
7542 Term_xtra(TERM_XTRA_ALIVE, 1);
7544 /* Redraw the term */
7547 /* Flush the term */
7552 /* Restore handler */
7553 (void)signal(sig, handle_signal_suspend);
7558 * Handle signals -- simple (interrupt and quit)
7560 * This function was causing a *huge* number of problems, so it has
7561 * been simplified greatly. We keep a global variable which counts
7562 * the number of times the user attempts to kill the process, and
7563 * we commit suicide if the user does this a certain number of times.
7565 * We attempt to give "feedback" to the user as he approaches the
7566 * suicide thresh-hold, but without penalizing accidental keypresses.
7568 * To prevent messy accidents, we should reset this global variable
7569 * whenever the user enters a keypress, or something like that.
7571 static void handle_signal_simple(int sig)
7573 /* Disable handler */
7574 (void)signal(sig, SIG_IGN);
7577 /* Nothing to save, just quit */
7578 if (!character_generated || character_saved) quit(NULL);
7581 /* Count the signals */
7585 /* Terminate dead characters */
7588 /* Mark the savefile */
7590 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»");
7592 (void)strcpy(p_ptr->died_from, "Abortion");
7611 /* Allow suicide (after 5) */
7612 else if (signal_count >= 5)
7614 /* Cause of "death" */
7616 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»Ãæ");
7618 (void)strcpy(p_ptr->died_from, "Interrupting");
7627 p_ptr->playing = FALSE;
7630 p_ptr->is_dead = TRUE;
7633 p_ptr->leaving = TRUE;
7647 /* Give warning (after 4) */
7648 else if (signal_count >= 4)
7651 Term_xtra(TERM_XTRA_NOISE, 0);
7653 /* Clear the top line */
7654 Term_erase(0, 0, 255);
7656 /* Display the cause */
7658 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7660 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7668 /* Give warning (after 2) */
7669 else if (signal_count >= 2)
7672 Term_xtra(TERM_XTRA_NOISE, 0);
7675 /* Restore handler */
7676 (void)signal(sig, handle_signal_simple);
7681 * Handle signal -- abort, kill, etc
7683 static void handle_signal_abort(int sig)
7687 Term_get_size(&wid, &hgt);
7689 /* Disable handler */
7690 (void)signal(sig, SIG_IGN);
7693 /* Nothing to save, just quit */
7694 if (!character_generated || character_saved) quit(NULL);
7701 /* Clear the bottom line */
7702 Term_erase(0, hgt - 1, 255);
7704 /* Give a warning */
7705 Term_putstr(0, hgt - 1, -1, TERM_RED,
7707 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7709 "A gruesome software bug LEAPS out at you!");
7715 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7717 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7722 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥à°Û¾ï½ªÎ»----");
7724 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Panic Save and Abort Game ----");
7731 p_ptr->panic_save = 1;
7735 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7737 (void)strcpy(p_ptr->died_from, "(panic save)");
7741 /* Forbid suspend */
7742 signals_ignore_tstp();
7744 /* Attempt to save */
7748 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7750 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7759 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7761 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7771 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7773 quit("software bug");
7782 * Ignore SIGTSTP signals (keyboard suspend)
7784 void signals_ignore_tstp(void)
7788 (void)signal(SIGTSTP, SIG_IGN);
7794 * Handle SIGTSTP signals (keyboard suspend)
7796 void signals_handle_tstp(void)
7800 (void)signal(SIGTSTP, handle_signal_suspend);
7807 * Prepare to handle the relevant signals
7809 void signals_init(void)
7813 (void)signal(SIGHUP, SIG_IGN);
7818 (void)signal(SIGTSTP, handle_signal_suspend);
7823 (void)signal(SIGINT, handle_signal_simple);
7827 (void)signal(SIGQUIT, handle_signal_simple);
7832 (void)signal(SIGFPE, handle_signal_abort);
7836 (void)signal(SIGILL, handle_signal_abort);
7840 (void)signal(SIGTRAP, handle_signal_abort);
7844 (void)signal(SIGIOT, handle_signal_abort);
7848 (void)signal(SIGKILL, handle_signal_abort);
7852 (void)signal(SIGBUS, handle_signal_abort);
7856 (void)signal(SIGSEGV, handle_signal_abort);
7860 (void)signal(SIGTERM, handle_signal_abort);
7864 (void)signal(SIGPIPE, handle_signal_abort);
7868 (void)signal(SIGEMT, handle_signal_abort);
7872 (void)signal(SIGDANGER, handle_signal_abort);
7876 (void)signal(SIGSYS, handle_signal_abort);
7880 (void)signal(SIGXCPU, handle_signal_abort);
7884 (void)signal(SIGPWR, handle_signal_abort);
7890 #else /* HANDLE_SIGNALS */
7896 void signals_ignore_tstp(void)
7903 void signals_handle_tstp(void)
7910 void signals_init(void)
7913 #endif /* HANDLE_SIGNALS */