4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: code dealing with files (and death) */
17 * You may or may not want to use the following "#undef".
19 /* #undef _POSIX_SAVED_IDS */
23 * Hack -- drop permissions
25 void safe_setuid_drop(void)
32 # ifdef SAFE_SETUID_POSIX
34 if (setuid(getuid()) != 0)
37 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
39 quit("setuid(): cannot set permissions correctly!");
43 if (setgid(getgid()) != 0)
46 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
48 quit("setgid(): cannot set permissions correctly!");
55 if (setreuid(geteuid(), getuid()) != 0)
58 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
60 quit("setreuid(): cannot set permissions correctly!");
64 if (setregid(getegid(), getgid()) != 0)
67 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
69 quit("setregid(): cannot set permissions correctly!");
84 * Hack -- grab permissions
86 void safe_setuid_grab(void)
93 # ifdef SAFE_SETUID_POSIX
95 if (setuid(player_euid) != 0)
98 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
100 quit("setuid(): cannot set permissions correctly!");
104 if (setgid(player_egid) != 0)
107 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
109 quit("setgid(): cannot set permissions correctly!");
116 if (setreuid(geteuid(), getuid()) != 0)
119 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
121 quit("setreuid(): cannot set permissions correctly!");
125 if (setregid(getegid(), getgid()) != 0)
128 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
130 quit("setregid(): cannot set permissions correctly!");
135 # endif /* SAFE_SETUID_POSIX */
137 # endif /* SAFE_SETUID */
145 * Extract the first few "tokens" from a buffer
147 * This function uses "colon" and "slash" as the delimeter characters.
149 * We never extract more than "num" tokens. The "last" token may include
150 * "delimeter" characters, allowing the buffer to include a "string" token.
152 * We save pointers to the tokens in "tokens", and return the number found.
154 * Hack -- Attempt to handle the 'c' character formalism
156 * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
158 * Hack -- We will always extract at least one token
160 s16b tokenize(char *buf, s16b num, char **tokens, int mode)
172 /* Scan the string */
175 /* Found a delimiter */
176 if ((*t == ':') || (*t == '/')) break;
178 /* Handle single quotes */
179 if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
184 /* Handle backslash */
187 /* Require a character */
193 /* Hack -- Require a close quote */
194 if (*t != '\'') *t = '\'';
197 /* Handle back-slash */
204 /* Nuke and advance */
222 /* A number with a name */
223 typedef struct named_num named_num;
227 cptr name; /* The name of this thing */
228 int num; /* A number associated with it */
232 /* Index of spell type names */
233 static named_num gf_desc[] =
235 {"GF_ELEC", GF_ELEC },
236 {"GF_POIS", GF_POIS },
237 {"GF_ACID", GF_ACID },
238 {"GF_COLD", GF_COLD },
239 {"GF_FIRE", GF_FIRE },
240 {"GF_PSY_SPEAR", GF_PSY_SPEAR },
241 {"GF_MISSILE", GF_MISSILE },
242 {"GF_ARROW", GF_ARROW },
243 {"GF_PLASMA", GF_PLASMA },
244 {"GF_WATER", GF_WATER },
245 {"GF_LITE", GF_LITE },
246 {"GF_DARK", GF_DARK },
247 {"GF_LITE_WEAK", GF_LITE_WEAK },
248 {"GF_DARK_WEAK", GF_DARK_WEAK },
249 {"GF_SHARDS", GF_SHARDS },
250 {"GF_SOUND", GF_SOUND },
251 {"GF_CONFUSION", GF_CONFUSION },
252 {"GF_FORCE", GF_FORCE },
253 {"GF_INERTIA", GF_INERTIA },
254 {"GF_MANA", GF_MANA },
255 {"GF_METEOR", GF_METEOR },
257 {"GF_CHAOS", GF_CHAOS },
258 {"GF_NETHER", GF_NETHER },
259 {"GF_DISENCHANT", GF_DISENCHANT },
260 {"GF_NEXUS", GF_NEXUS },
261 {"GF_TIME", GF_TIME },
262 {"GF_GRAVITY", GF_GRAVITY },
263 {"GF_KILL_WALL", GF_KILL_WALL },
264 {"GF_KILL_DOOR", GF_KILL_DOOR },
265 {"GF_KILL_TRAP", GF_KILL_TRAP },
266 {"GF_MAKE_WALL", GF_MAKE_WALL },
267 {"GF_MAKE_DOOR", GF_MAKE_DOOR },
268 {"GF_MAKE_TRAP", GF_MAKE_TRAP },
269 {"GF_MAKE_TREE", GF_MAKE_TREE },
270 {"GF_OLD_CLONE", GF_OLD_CLONE },
271 {"GF_OLD_POLY", GF_OLD_POLY },
272 {"GF_OLD_HEAL", GF_OLD_HEAL },
273 {"GF_OLD_SPEED", GF_OLD_SPEED },
274 {"GF_OLD_SLOW", GF_OLD_SLOW },
275 {"GF_OLD_CONF", GF_OLD_CONF },
276 {"GF_OLD_SLEEP", GF_OLD_SLEEP },
277 {"GF_OLD_DRAIN", GF_OLD_DRAIN },
278 {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD },
279 {"GF_AWAY_EVIL", GF_AWAY_EVIL },
280 {"GF_AWAY_ALL", GF_AWAY_ALL },
281 {"GF_TURN_UNDEAD", GF_TURN_UNDEAD },
282 {"GF_TURN_EVIL", GF_TURN_EVIL },
283 {"GF_TURN_ALL", GF_TURN_ALL },
284 {"GF_DISP_UNDEAD", GF_DISP_UNDEAD },
285 {"GF_DISP_EVIL", GF_DISP_EVIL },
286 {"GF_DISP_ALL", GF_DISP_ALL },
287 {"GF_DISP_DEMON", GF_DISP_DEMON },
288 {"GF_DISP_LIVING", GF_DISP_LIVING },
289 {"GF_ROCKET", GF_ROCKET },
290 {"GF_NUKE", GF_NUKE },
291 {"GF_MAKE_GLYPH", GF_MAKE_GLYPH },
292 {"GF_STASIS", GF_STASIS },
293 {"GF_STONE_WALL", GF_STONE_WALL },
294 {"GF_DEATH_RAY", GF_DEATH_RAY },
295 {"GF_STUN", GF_STUN },
296 {"GF_HOLY_FIRE", GF_HOLY_FIRE },
297 {"GF_HELL_FIRE", GF_HELL_FIRE },
298 {"GF_DISINTEGRATE", GF_DISINTEGRATE },
299 {"GF_CHARM", GF_CHARM },
300 {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD },
301 {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL },
303 {"GF_PSI_DRAIN", GF_PSI_DRAIN },
304 {"GF_TELEKINESIS", GF_TELEKINESIS },
305 {"GF_JAM_DOOR", GF_JAM_DOOR },
306 {"GF_DOMINATION", GF_DOMINATION },
307 {"GF_DISP_GOOD", GF_DISP_GOOD },
308 {"GF_DRAIN_MANA", GF_DRAIN_MANA },
309 {"GF_MIND_BLAST", GF_MIND_BLAST },
310 {"GF_BRAIN_SMASH", GF_BRAIN_SMASH },
311 {"GF_CAUSE_1", GF_CAUSE_1 },
312 {"GF_CAUSE_2", GF_CAUSE_2 },
313 {"GF_CAUSE_3", GF_CAUSE_3 },
314 {"GF_CAUSE_4", GF_CAUSE_4 },
315 {"GF_HAND_DOOM", GF_HAND_DOOM },
316 {"GF_CAPTURE", GF_CAPTURE },
317 {"GF_ANIM_DEAD", GF_ANIM_DEAD },
318 {"GF_CONTROL_LIVING", GF_CONTROL_LIVING },
319 {"GF_IDENTIFY", GF_IDENTIFY },
320 {"GF_ATTACK", GF_ATTACK },
321 {"GF_ENGETSU", GF_ENGETSU },
322 {"GF_GENOCIDE", GF_GENOCIDE },
323 {"GF_PHOTO", GF_PHOTO },
324 {"GF_CONTROL_DEMON", GF_CONTROL_DEMON },
325 {"GF_LAVA_FLOW", GF_LAVA_FLOW },
326 {"GF_BLOOD_CURSE", GF_BLOOD_CURSE },
327 {"GF_SEEKER", GF_SEEKER },
328 {"GF_SUPER_RAY", GF_SUPER_RAY },
329 {"GF_STAR_HEAL", GF_STAR_HEAL },
330 {"GF_WATER_FLOW", GF_WATER_FLOW },
331 {"GF_CRUSADE", GF_CRUSADE },
332 {"GF_STASIS_EVIL", GF_STASIS_EVIL },
333 {"GF_WOUNDS", GF_WOUNDS },
339 * Parse a sub-file of the "extra info" (format shown below)
341 * Each "action" line has an "action symbol" in the first column,
342 * followed by a colon, followed by some command specific info,
343 * usually in the form of "tokens" separated by colons or slashes.
345 * Blank lines, lines starting with white space, and lines starting
346 * with pound signs ("#") are ignored (as comments).
348 * Note the use of "tokenize()" to allow the use of both colons and
349 * slashes as delimeters, while still allowing final tokens which
350 * may contain any characters including "delimiters".
352 * Note the use of "strtol()" to allow all "integers" to be encoded
353 * in decimal, hexidecimal, or octal form.
355 * Note that "monster zero" is used for the "player" attr/char, "object
356 * zero" will be used for the "stack" attr/char, and "feature zero" is
357 * used for the "nothing" attr/char.
359 * Parse another file recursively, see below for details
362 * Specify the attr/char values for "monsters" by race index
365 * Specify the attr/char values for "objects" by kind index
368 * Specify the attr/char values for "features" by feature index
371 * Specify the attr/char values for unaware "objects" by kind tval
374 * Specify the attr/char values for inventory "objects" by kind tval
377 * Define a macro action, given an encoded macro action
380 * Create a normal macro, given an encoded macro trigger
383 * Create a command macro, given an encoded macro trigger
386 * Create a keyset mapping
387 * S:<key>:<key>:<dir>
389 * Turn an option off, given its name
392 * Turn an option on, given its name
395 * Specify visual information, given an index, and some data
396 * V:<num>:<kv>:<rv>:<gv>:<bv>
398 * Specify the set of colors to use when drawing a zapped spell
401 * Specify a macro trigger template and macro trigger names.
402 * T:<template>:<modifier chr>:<modifier name1>:<modifier name2>:...
403 * T:<trigger>:<keycode>:<shift-keycode>
407 errr process_pref_file_command(char *buf)
414 /* Require "?:*" format */
415 if (buf[1] != ':') return 1;
420 /* Mega-Hack -- read external player's history file */
421 /* Process "H:<history>" */
423 add_history_from_pref_line(buf + 2);
426 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
428 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
431 i = (huge)strtol(zz[0], NULL, 0);
432 n1 = strtol(zz[1], NULL, 0);
433 n2 = strtol(zz[2], NULL, 0);
434 if (i >= max_r_idx) return 1;
436 if (n1 || (!(n2 & 0x80) && n2)) r_ptr->x_attr = n1; /* Allow TERM_DARK text */
437 if (n2) r_ptr->x_char = n2;
442 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
444 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
447 i = (huge)strtol(zz[0], NULL, 0);
448 n1 = strtol(zz[1], NULL, 0);
449 n2 = strtol(zz[2], NULL, 0);
450 if (i >= max_k_idx) return 1;
452 if (n1 || (!(n2 & 0x80) && n2)) k_ptr->x_attr = n1; /* Allow TERM_DARK text */
453 if (n2) k_ptr->x_char = n2;
458 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
459 /* "F:<num>:<a>/<c>" */
460 /* "F:<num>:<a>/<c>:LIT" */
461 /* "F:<num>:<a>/<c>:<la>/<lc>:<da>/<dc>" */
465 int num = tokenize(buf + 2, F_LIT_MAX * 2 + 1, zz, TOKENIZE_CHECKQUOTE);
467 if ((num != 3) && (num != 4) && (num != F_LIT_MAX * 2 + 1)) return 1;
468 else if ((num == 4) && !streq(zz[3], "LIT")) return 1;
470 i = (huge)strtol(zz[0], NULL, 0);
471 if (i >= max_f_idx) return 1;
474 n1 = strtol(zz[1], NULL, 0);
475 n2 = strtol(zz[2], NULL, 0);
476 if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[F_LIT_STANDARD] = n1; /* Allow TERM_DARK text */
477 if (n2) f_ptr->x_char[F_LIT_STANDARD] = n2;
479 /* Mega-hack -- feat supports lighting */
482 /* No lighting support */
484 n1 = f_ptr->x_attr[F_LIT_STANDARD];
485 n2 = f_ptr->x_char[F_LIT_STANDARD];
486 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
488 f_ptr->x_attr[j] = n1;
489 f_ptr->x_char[j] = n2;
493 /* Use default lighting */
495 apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
498 /* Use desired lighting */
499 case F_LIT_MAX * 2 + 1:
500 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
502 n1 = strtol(zz[j * 2 + 1], NULL, 0);
503 n2 = strtol(zz[j * 2 + 2], NULL, 0);
504 if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[j] = n1; /* Allow TERM_DARK text */
505 if (n2) f_ptr->x_char[j] = n2;
512 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
514 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
516 j = (byte)strtol(zz[0], NULL, 0);
517 n1 = strtol(zz[1], NULL, 0);
518 n2 = strtol(zz[2], NULL, 0);
519 misc_to_attr[j] = n1;
520 misc_to_char[j] = n2;
525 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
527 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
529 j = (huge)strtol(zz[0], NULL, 0);
530 n1 = strtol(zz[1], NULL, 0);
531 n2 = strtol(zz[2], NULL, 0);
532 for (i = 1; i < max_k_idx; i++)
534 object_kind *k_ptr = &k_info[i];
535 if (k_ptr->tval == j)
537 if (n1) k_ptr->d_attr = n1;
538 if (n2) k_ptr->d_char = n2;
545 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
547 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
549 j = (byte)strtol(zz[0], NULL, 0) % 128;
550 n1 = strtol(zz[1], NULL, 0);
551 if (n1) tval_to_attr[j] = n1;
556 /* Process "A:<str>" -- save an "action" for later */
558 text_to_ascii(macro__buf, buf+2);
561 /* Process "P:<str>" -- normal macro */
566 text_to_ascii(tmp, buf+2);
567 macro_add(tmp, macro__buf);
571 /* Process "C:<str>" -- create keymap */
577 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return 1;
579 mode = strtol(zz[0], NULL, 0);
580 if ((mode < 0) || (mode >= KEYMAP_MODES)) return 1;
582 text_to_ascii(tmp, zz[1]);
583 if (!tmp[0] || tmp[1]) return 1;
586 string_free(keymap_act[mode][i]);
588 keymap_act[mode][i] = string_make(macro__buf);
593 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
595 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
597 i = (byte)strtol(zz[0], NULL, 0);
598 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
599 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
600 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
601 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
606 /* Process "X:<str>" -- turn option off */
607 /* Process "Y:<str>" -- turn option on */
610 for (i = 0; option_info[i].o_desc; i++)
612 if (option_info[i].o_var &&
613 option_info[i].o_text &&
614 streq(option_info[i].o_text, buf + 2))
616 int os = option_info[i].o_set;
617 int ob = option_info[i].o_bit;
619 if ((p_ptr->playing || character_xtra) &&
620 (OPT_PAGE_BIRTH == option_info[i].o_page) && !p_ptr->wizard)
623 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
625 msg_format("Birth options can not changed! '%s'", buf);
634 option_flag[os] &= ~(1L << ob);
635 (*option_info[i].o_var) = FALSE;
640 option_flag[os] |= (1L << ob);
641 (*option_info[i].o_var) = TRUE;
647 /* don't know that option. ignore it.*/
649 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
651 msg_format("Ignored invalid option: %s", buf);
656 /* Process "Z:<type>:<str>" -- set spell color */
660 char *t = my_strchr(buf + 2, ':');
668 for (i = 0; gf_desc[i].name; i++)
670 /* Match this type */
671 if (streq(gf_desc[i].name, buf + 2))
673 /* Remember this color set */
674 gf_color[gf_desc[i].num] = quark_add(t);
684 /* Initialize macro trigger names and a template */
685 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
686 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
689 int tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
691 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
697 if (macro_template != NULL)
699 num = strlen(macro_modifier_chr);
701 /* Kill the template string */
702 string_free(macro_template);
703 macro_template = NULL;
705 /* Kill flag characters of modifier keys */
706 string_free(macro_modifier_chr);
708 /* Kill corresponding modifier names */
709 for (i = 0; i < num; i++)
711 string_free(macro_modifier_name[i]);
714 /* Kill trigger name strings */
715 for (i = 0; i < max_macrotrigger; i++)
717 string_free(macro_trigger_name[i]);
718 string_free(macro_trigger_keycode[0][i]);
719 string_free(macro_trigger_keycode[1][i]);
722 max_macrotrigger = 0;
725 if (*zz[0] == '\0') return 0; /* clear template */
727 /* Number of modifier flags */
730 /* Limit the number */
731 num = MIN(MAX_MACRO_MOD, num);
733 /* Stop if number of modifier is not correct */
734 if (2 + num != tok) return 1;
736 /* Get a template string */
737 macro_template = string_make(zz[0]);
739 /* Get flag characters of modifier keys */
740 macro_modifier_chr = string_make(zz[1]);
742 /* Get corresponding modifier names */
743 for (i = 0; i < num; i++)
745 macro_modifier_name[i] = string_make(zz[2+i]);
749 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
755 if (max_macrotrigger >= MAX_MACRO_TRIG)
758 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
760 msg_print("Too many macro triggers!");
764 m = max_macrotrigger;
767 /* Take into account the escape character */
777 /* Get a trigger name */
778 macro_trigger_name[m] = string_make(buf);
780 /* Get the corresponding key code */
781 macro_trigger_keycode[0][m] = string_make(zz[1]);
785 /* Key code of a combination of it with the shift key */
786 macro_trigger_keycode[1][m] = string_make(zz[2]);
790 macro_trigger_keycode[1][m] = string_make(zz[1]);
805 * Helper function for "process_pref_file()"
808 * v: output buffer array
814 cptr process_pref_file_expr(char **sp, char *fp)
831 while (isspace(*s)) s++;
849 t = process_pref_file_expr(&s, &f);
858 else if (streq(t, "IOR"))
861 while (*s && (f != b2))
863 t = process_pref_file_expr(&s, &f);
864 if (*t && !streq(t, "0")) v = "1";
869 else if (streq(t, "AND"))
872 while (*s && (f != b2))
874 t = process_pref_file_expr(&s, &f);
875 if (*t && streq(t, "0")) v = "0";
880 else if (streq(t, "NOT"))
883 while (*s && (f != b2))
885 t = process_pref_file_expr(&s, &f);
886 if (*t && streq(t, "1")) v = "0";
891 else if (streq(t, "EQU"))
896 t = process_pref_file_expr(&s, &f);
898 while (*s && (f != b2))
900 p = process_pref_file_expr(&s, &f);
901 if (streq(t, p)) v = "1";
906 else if (streq(t, "LEQ"))
911 t = process_pref_file_expr(&s, &f);
913 while (*s && (f != b2))
916 t = process_pref_file_expr(&s, &f);
917 if (*t && atoi(p) > atoi(t)) v = "0";
922 else if (streq(t, "GEQ"))
927 t = process_pref_file_expr(&s, &f);
929 while (*s && (f != b2))
932 t = process_pref_file_expr(&s, &f);
934 /* Compare two numbers instead of string */
935 if (*t && atoi(p) < atoi(t)) v = "0";
942 while (*s && (f != b2))
944 t = process_pref_file_expr(&s, &f);
949 if (f != b2) v = "?x?x?";
951 /* Extract final and Terminate */
952 if ((f = *s) != '\0') *s++ = '\0';
958 /* Accept all printables except spaces and brackets */
960 while ((iskanji(*s) || isprint(*s)) && !my_strchr(" []", *s))
962 if (iskanji(*s)) s++;
966 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
969 /* Extract final and Terminate */
970 if ((f = *s) != '\0') *s++ = '\0';
976 if (streq(b+1, "SYS"))
981 else if (streq(b+1, "KEYBOARD"))
983 v = ANGBAND_KEYBOARD;
987 else if (streq(b+1, "GRAF"))
992 /* Monochrome mode */
993 else if (streq(b+1, "MONOCHROME"))
1002 else if (streq(b+1, "RACE"))
1005 v = rp_ptr->E_title;
1012 else if (streq(b+1, "CLASS"))
1015 v = cp_ptr->E_title;
1022 else if (streq(b+1, "PLAYER"))
1024 static char tmp_player_name[32];
1026 for (pn = player_name, tpn = tmp_player_name; *pn; pn++, tpn++)
1036 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
1039 v = tmp_player_name;
1043 else if (streq(b+1, "REALM1"))
1046 v = E_realm_names[p_ptr->realm1];
1048 v = realm_names[p_ptr->realm1];
1053 else if (streq(b+1, "REALM2"))
1056 v = E_realm_names[p_ptr->realm2];
1058 v = realm_names[p_ptr->realm2];
1063 else if (streq(b+1, "LEVEL"))
1065 sprintf(tmp, "%02d", p_ptr->lev);
1069 /* Autopick auto-register is in-use or not? */
1070 else if (streq(b+1, "AUTOREGISTER"))
1072 if (p_ptr->autopick_autoregister)
1097 #define PREF_TYPE_NORMAL 0
1098 #define PREF_TYPE_AUTOPICK 1
1099 #define PREF_TYPE_HISTPREF 2
1102 * Open the "user pref file" and parse it.
1104 static errr process_pref_file_aux(cptr name, int preftype)
1116 bool bypass = FALSE;
1120 fp = my_fopen(name, "r");
1123 if (!fp) return (-1);
1125 /* Process the file */
1126 while (0 == my_fgets(fp, buf, sizeof(buf)))
1131 /* Skip "empty" lines */
1132 if (!buf[0]) continue;
1134 /* Skip "blank" lines */
1136 if (!iskanji(buf[0]))
1138 if (isspace(buf[0])) continue;
1141 if (buf[0] == '#') continue;
1148 /* Process "?:<expr>" */
1149 if ((buf[0] == '?') && (buf[1] == ':'))
1158 /* Parse the expr */
1159 v = process_pref_file_expr(&s, &f);
1162 bypass = (streq(v, "0") ? TRUE : FALSE);
1168 /* Apply conditionals */
1169 if (bypass) continue;
1172 /* Process "%:<file>" */
1175 static int depth_count = 0;
1177 /* Ignore if deeper than 20 level */
1178 if (depth_count > 20) continue;
1180 /* Count depth level */
1183 /* Process that file if allowed */
1186 case PREF_TYPE_AUTOPICK:
1187 (void)process_autopick_file(buf + 2);
1189 case PREF_TYPE_HISTPREF:
1190 (void)process_histpref_file(buf + 2);
1193 (void)process_pref_file(buf + 2);
1197 /* Set back depth level */
1205 /* Process the line */
1206 err = process_pref_file_command(buf);
1208 /* This is not original pref line... */
1211 if (preftype != PREF_TYPE_AUTOPICK)
1213 err = process_autopick_file_command(buf);
1221 /* Print error message */
1222 /* ToDo: Add better error messages */
1224 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1225 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1227 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1228 msg_format("Parsing '%s'", old);
1233 /* Close the file */
1243 * Process the "user pref file" with the given name
1245 * See the functions above for a list of legal "commands".
1247 * We also accept the special "?" and "%" directives, which
1248 * allow conditional evaluation and filename inclusion.
1250 errr process_pref_file(cptr name)
1256 /* Build the filename */
1257 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
1259 /* Process the system pref file */
1260 err1 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1262 /* Stop at parser errors, but not at non-existing file */
1263 if (err1 > 0) return err1;
1266 /* Build the filename */
1267 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
1269 /* Process the user pref file */
1270 err2 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1273 /* User file does not exist, but read system pref file */
1274 if (err2 < 0 && !err1)
1277 /* Result of user file processing */
1286 * Operating hours for ANGBAND (defaults to non-work hours)
1288 static char days[7][29] =
1290 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1291 "MON:XXXXXXXX.........XXXXXXX",
1292 "TUE:XXXXXXXX.........XXXXXXX",
1293 "WED:XXXXXXXX.........XXXXXXX",
1294 "THU:XXXXXXXX.........XXXXXXX",
1295 "FRI:XXXXXXXX.........XXXXXXX",
1296 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1300 * Restict usage (defaults to no restrictions)
1302 static bool check_time_flag = FALSE;
1310 errr check_time(void)
1318 /* No restrictions */
1319 if (!check_time_flag) return (0);
1321 /* Check for time violation */
1322 c = time((time_t *)0);
1326 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1337 * Initialize CHECK_TIME
1339 errr check_time_init(void)
1349 /* Build the filename */
1350 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
1353 fp = my_fopen(buf, "r");
1355 /* No file, no restrictions */
1356 if (!fp) return (0);
1358 /* Assume restrictions */
1359 check_time_flag = TRUE;
1361 /* Parse the file */
1362 while (0 == my_fgets(fp, buf, sizeof(buf)))
1364 /* Skip comments and blank lines */
1365 if (!buf[0] || (buf[0] == '#')) continue;
1367 /* Chop the buffer */
1370 /* Extract the info */
1371 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1372 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1373 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1374 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1375 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1376 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1377 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1393 #ifndef MAXHOSTNAMELEN
1394 # define MAXHOSTNAMELEN 64
1397 typedef struct statstime statstime;
1403 unsigned int v_pgpgin;
1404 unsigned int v_pgpgout;
1405 unsigned int v_pswpin;
1406 unsigned int v_pswpout;
1407 unsigned int v_intr;
1413 unsigned int v_swtch;
1415 struct timeval boottime;
1416 struct timeval curtime;
1420 * Maximal load (if any).
1422 static int check_load_value = 0;
1430 errr check_load(void)
1435 struct statstime st;
1437 /* Success if not checking */
1438 if (!check_load_value) return (0);
1440 /* Check the load */
1441 if (0 == rstat("localhost", &st))
1443 long val1 = (long)(st.avenrun[2]);
1444 long val2 = (long)(check_load_value) * FSCALE;
1446 /* Check for violation */
1447 if (val1 >= val2) return (1);
1458 * Initialize CHECK_LOAD
1460 errr check_load_init(void)
1469 char temphost[MAXHOSTNAMELEN+1];
1470 char thishost[MAXHOSTNAMELEN+1];
1473 /* Build the filename */
1474 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
1476 /* Open the "load" file */
1477 fp = my_fopen(buf, "r");
1479 /* No file, no restrictions */
1480 if (!fp) return (0);
1483 check_load_value = 100;
1485 /* Get the host name */
1486 (void)gethostname(thishost, (sizeof thishost) - 1);
1489 while (0 == my_fgets(fp, buf, sizeof(buf)))
1493 /* Skip comments and blank lines */
1494 if (!buf[0] || (buf[0] == '#')) continue;
1496 /* Parse, or ignore */
1497 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1499 /* Skip other hosts */
1500 if (!streq(temphost, thishost) &&
1501 !streq(temphost, "localhost")) continue;
1503 /* Use that value */
1504 check_load_value = value;
1510 /* Close the file */
1520 #define ENTRY_BARE_HAND 0
1521 #define ENTRY_TWO_HANDS 1
1522 #define ENTRY_RIGHT_HAND1 2
1523 #define ENTRY_LEFT_HAND1 3
1524 #define ENTRY_LEFT_HAND2 4
1525 #define ENTRY_RIGHT_HAND2 5
1526 #define ENTRY_POSTURE 6
1527 #define ENTRY_SHOOT_HIT_DAM 7
1528 #define ENTRY_SHOOT_POWER 8
1529 #define ENTRY_SPEED 9
1530 #define ENTRY_BASE_AC 10
1531 #define ENTRY_LEVEL 11
1532 #define ENTRY_CUR_EXP 12
1533 #define ENTRY_MAX_EXP 13
1534 #define ENTRY_EXP_TO_ADV 14
1535 #define ENTRY_GOLD 15
1536 #define ENTRY_DAY 16
1539 #define ENTRY_PLAY_TIME 19
1540 #define ENTRY_SKILL_FIGHT 20
1541 #define ENTRY_SKILL_SHOOT 21
1542 #define ENTRY_SKILL_SAVING 22
1543 #define ENTRY_SKILL_STEALTH 23
1544 #define ENTRY_SKILL_PERCEP 24
1545 #define ENTRY_SKILL_SEARCH 25
1546 #define ENTRY_SKILL_DISARM 26
1547 #define ENTRY_SKILL_DEVICE 27
1548 #define ENTRY_BLOWS 28
1549 #define ENTRY_SHOTS 29
1550 #define ENTRY_AVG_DMG 30
1551 #define ENTRY_INFRA 31
1553 #define ENTRY_NAME 32
1554 #define ENTRY_SEX 33
1555 #define ENTRY_RACE 34
1556 #define ENTRY_CLASS 35
1557 #define ENTRY_REALM 36
1558 #define ENTRY_PATRON 37
1559 #define ENTRY_AGE 38
1560 #define ENTRY_HEIGHT 39
1561 #define ENTRY_WEIGHT 40
1562 #define ENTRY_SOCIAL 41
1563 #define ENTRY_ALIGN 42
1565 #define ENTRY_EXP_ANDR 43
1566 #define ENTRY_EXP_TO_ADV_ANDR 44
1575 } disp_player_line[]
1578 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1579 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1580 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1581 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1582 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1583 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1585 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1586 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1587 { 1, 20, 25, "²Ã®"},
1588 { 1, 19, 25, "£Á£Ã"},
1589 {29, 13, 21, "¥ì¥Ù¥ë"},
1590 {29, 14, 21, "·Ð¸³ÃÍ"},
1591 {29, 15, 21, "ºÇÂç·Ð¸³"},
1592 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1593 {29, 17, 21, "½ê»ý¶â"},
1594 {29, 19, 21, "ÆüÉÕ"},
1595 {29, 10, 21, "£È£Ð"},
1596 {29, 11, 21, "£Í£Ð"},
1597 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1598 {53, 10, -1, "ÂǷ⹶·â :"},
1599 {53, 11, -1, "¼Í·â¹¶·â :"},
1600 {53, 12, -1, "ËâË¡Ëɸæ :"},
1601 {53, 13, -1, "±£Ì©¹ÔÆ° :"},
1602 {53, 15, -1, "ÃγР:"},
1603 {53, 16, -1, "õº÷ :"},
1604 {53, 17, -1, "²ò½ü :"},
1605 {53, 18, -1, "ËâË¡Æ»¶ñ :"},
1606 { 1, 12, 25, "ÂÇ·â²ó¿ô"},
1607 { 1, 17, 25, "¼Í·â²ó¿ô"},
1608 { 1, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1609 {53, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1610 {26, 1, -1, "̾Á° : "},
1611 { 1, 3, -1, "ÀÊÌ : "},
1612 { 1, 4, -1, "¼ï² : "},
1613 { 1, 5, -1, "¿¦¶È : "},
1614 { 1, 6, -1, "ËâË¡ : "},
1615 { 1, 7, -1, "¼é¸îËâ¿À : "},
1616 {29, 3, 21, "ǯÎð"},
1617 {29, 4, 21, "¿ÈĹ"},
1618 {29, 5, 21, "ÂνÅ"},
1619 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1620 {29, 7, 21, "°À"},
1621 {29, 14, 21, "¶¯²½ÅÙ"},
1622 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1626 { 1, 10, 25, "Bare hand"},
1627 { 1, 10, 25, "Two hands"},
1628 { 1, 10, 25, "Right hand"},
1629 { 1, 10, 25, "Left hand"},
1630 { 1, 11, 25, "Left hand"},
1631 { 1, 11, 25, "Right hand"},
1632 { 1, 11, 25, "Posture"},
1633 { 1, 15, 25, "Shooting"},
1634 { 1, 16, 25, "Multiplier"},
1635 { 1, 20, 25, "Speed"},
1637 {29, 13, 21, "Level"},
1638 {29, 14, 21, "Experience"},
1639 {29, 15, 21, "Max Exp"},
1640 {29, 16, 21, "Exp to Adv"},
1641 {29, 17, 21, "Gold"},
1642 {29, 19, 21, "Time"},
1643 {29, 10, 21, "Hit point"},
1644 {29, 11, 21, "SP (Mana)"},
1645 {29, 20, 21, "Play time"},
1646 {53, 10, -1, "Fighting : "},
1647 {53, 11, -1, "Bows/Throw : "},
1648 {53, 12, -1, "SavingThrow: "},
1649 {53, 13, -1, "Stealth : "},
1650 {53, 15, -1, "Perception : "},
1651 {53, 16, -1, "Searching : "},
1652 {53, 17, -1, "Disarming : "},
1653 {53, 18, -1, "MagicDevice: "},
1654 { 1, 12, 25, "Blows/Round"},
1655 { 1, 17, 25, "Shots/Round"},
1656 { 1, 13, 25, "AverageDmg/Rnd"},
1657 {53, 20, -1, "Infra-Vision: "},
1658 {26, 1, -1, "Name : "},
1659 { 1, 3, -1, "Sex : "},
1660 { 1, 4, -1, "Race : "},
1661 { 1, 5, -1, "Class : "},
1662 { 1, 6, -1, "Magic : "},
1663 { 1, 7, -1, "Patron : "},
1665 {29, 4, 21, "Height"},
1666 {29, 5, 21, "Weight"},
1667 {29, 6, 21, "Social Class"},
1668 {29, 7, 21, "Align"},
1669 {29, 14, 21, "Construction"},
1670 {29, 16, 21, "Const to Adv"},
1674 static void display_player_one_line(int entry, cptr val, byte attr)
1678 int row = disp_player_line[entry].row;
1679 int col = disp_player_line[entry].col;
1680 int len = disp_player_line[entry].len;
1681 cptr head = disp_player_line[entry].header;
1683 int head_len = strlen(head);
1685 Term_putstr(col, row, -1, TERM_WHITE, head);
1692 int val_len = len - head_len;
1693 sprintf(buf, "%*.*s", val_len, val_len, val);
1694 Term_putstr(col + head_len, row, -1, attr, buf);
1698 Term_putstr(col + head_len, row, -1, attr, val);
1705 static void display_player_melee_bonus(int hand, int hand_entry)
1708 int show_tohit = p_ptr->dis_to_h[hand];
1709 int show_todam = p_ptr->dis_to_d[hand];
1710 object_type *o_ptr = &inventory[INVEN_RARM + hand];
1712 /* Hack -- add in weapon info if known */
1713 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1714 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1717 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1719 /* Dump the bonuses to hit/dam */
1720 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1721 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1722 else if (p_ptr->ryoute)
1723 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1725 display_player_one_line(hand_entry, buf, TERM_L_BLUE);
1730 * Prints the following information on the screen.
1732 static void display_player_middle(void)
1737 int show_tohit = p_ptr->dis_to_h_b;
1741 object_type *o_ptr = &inventory[INVEN_BOW];
1748 display_player_melee_bonus(0, left_hander ? ENTRY_LEFT_HAND1 : ENTRY_RIGHT_HAND1);
1751 if (p_ptr->hidarite)
1753 display_player_melee_bonus(1, left_hander ? ENTRY_RIGHT_HAND2: ENTRY_LEFT_HAND2);
1755 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
1758 if (p_ptr->special_defense & KAMAE_MASK)
1760 for (i = 0; i < MAX_KAMAE; i++)
1762 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1766 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1768 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1773 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1775 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1779 /* Apply weapon bonuses */
1780 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1781 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1783 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1784 show_tohit += p_ptr->weapon_exp[0][o_ptr->sval] / 400;
1786 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
1789 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1791 if (inventory[INVEN_BOW].k_idx)
1793 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1795 /* Get extra "power" from "extra might" */
1796 if (p_ptr->xtra_might) tmul++;
1798 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1802 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1804 /* Dump the armor class */
1805 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1813 i = p_ptr->pspeed-110;
1815 /* Hack -- Visually "undo" the Search Mode Slowdown */
1816 if (p_ptr->action == ACTION_SEARCH) i += 10;
1821 attr = TERM_L_GREEN;
1835 attr = TERM_L_UMBER;
1842 if (IS_FAST()) tmp_speed += 10;
1843 if (p_ptr->slow) tmp_speed -= 10;
1844 if (p_ptr->lightspeed) tmp_speed = 99;
1848 if (MON_FAST(&m_list[p_ptr->riding])) tmp_speed += 10;
1849 if (MON_SLOW(&m_list[p_ptr->riding])) tmp_speed -= 10;
1855 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1858 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1860 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1871 sprintf(buf, "(%+d)", i);
1874 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1876 sprintf(buf, "Riding (%+d)", i);
1880 display_player_one_line(ENTRY_SPEED, buf, attr);
1883 /* Dump character level */
1884 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1886 /* Dump experience */
1887 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1888 else e = ENTRY_CUR_EXP;
1890 if (p_ptr->exp >= p_ptr->max_exp)
1891 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1893 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1895 /* Dump max experience */
1896 if (p_ptr->prace == RACE_ANDROID)
1899 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1901 /* Dump exp to advance */
1902 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
1903 else e = ENTRY_EXP_TO_ADV;
1905 if (p_ptr->lev >= PY_MAX_LEVEL)
1906 display_player_one_line(e, "*****", TERM_L_GREEN);
1907 else if (p_ptr->prace == RACE_ANDROID)
1908 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1910 display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1913 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1918 extract_day_hour_min(&day, &hour, &min);
1921 if (day < MAX_DAYS) sprintf(buf, "%dÆüÌÜ %2d:%02d", day, hour, min);
1922 else sprintf(buf, "*****ÆüÌÜ %2d:%02d", hour, min);
1924 if (day < MAX_DAYS) sprintf(buf, "Day %d %2d:%02d", day, hour, min);
1925 else sprintf(buf, "Day ***** %2d:%02d", hour, min);
1928 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1930 /* Dump hit point */
1931 if (p_ptr->chp >= p_ptr->mhp)
1932 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1933 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1934 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1936 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1938 /* Dump mana power */
1939 if (p_ptr->csp >= p_ptr->msp)
1940 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1941 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
1942 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1944 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1946 /* Dump play time */
1947 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1952 * Hack -- pass color info around this file
1954 static byte likert_color = TERM_WHITE;
1958 * Returns a "rating" of x depending on y
1960 static cptr likert(int x, int y)
1962 static char dummy[20] = "";
1967 /* Negative value */
1970 likert_color = TERM_L_DARK;
1978 /* Analyze the value */
1983 likert_color = TERM_RED;
1991 likert_color = TERM_L_RED;
2000 likert_color = TERM_ORANGE;
2008 likert_color = TERM_YELLOW;
2016 likert_color = TERM_YELLOW;
2025 likert_color = TERM_L_GREEN;
2037 likert_color = TERM_GREEN;
2048 likert_color = TERM_BLUE;
2056 likert_color = TERM_VIOLET;
2058 sprintf(dummy, "ÅÁÀâŪ[%d]", (int)((((x / y) - 17) * 5) / 2));
2060 sprintf(dummy, "Legendary[%d]", (int)((((x / y) - 17) * 5) / 2));
2068 * Prints ratings on certain abilities
2070 * This code is "imitated" elsewhere to "dump" a character sheet.
2072 static void display_player_various(void)
2074 int tmp, damage[2], blows1, blows2, i, basedam;
2075 int xthn, xthb, xfos, xsrh;
2076 int xdis, xdev, xsav, xstl;
2079 u32b flgs[TR_FLAG_SIZE];
2080 int shots, shot_frac;
2084 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2085 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2086 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2087 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2088 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2090 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2092 /* Shooting Skill (with current bow and normal missile) */
2093 o_ptr = &inventory[INVEN_BOW];
2094 tmp = p_ptr->to_h_b + o_ptr->to_h;
2095 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2097 /* If the player is wielding one? */
2100 s16b energy_fire = bow_energy(o_ptr->sval);
2102 /* Calculate shots per round */
2103 shots = p_ptr->num_fire * 100;
2104 shot_frac = (shots * 100 / energy_fire) % 100;
2105 shots = shots / energy_fire;
2106 if (o_ptr->name1 == ART_CRIMSON)
2110 if (p_ptr->pclass == CLASS_ARCHER)
2112 /* Extra shot at level 10 */
2113 if (p_ptr->lev >= 10) shots++;
2115 /* Extra shot at level 30 */
2116 if (p_ptr->lev >= 30) shots++;
2118 /* Extra shot at level 45 */
2119 if (p_ptr->lev >= 45) shots++;
2129 for(i = 0; i < 2; i++)
2131 damage[i] = p_ptr->dis_to_d[i] * 100;
2132 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
2134 int level = p_ptr->lev;
2140 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2141 if (p_ptr->special_defense & KAMAE_BYAKKO)
2142 basedam = monk_ave_damage[level][1];
2143 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2144 basedam = monk_ave_damage[level][2];
2146 basedam = monk_ave_damage[level][0];
2150 o_ptr = &inventory[INVEN_RARM + i];
2152 /* Average damage per round */
2155 if (object_is_known(o_ptr)) damage[i] += o_ptr->to_d * 100;
2156 basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
2157 object_flags_known(o_ptr, flgs);
2158 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2164 else if (have_flag(flgs, TR_VORPAL))
2166 /* vorpal flag only */
2170 if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2171 basedam = basedam * 7 / 2;
2175 damage[i] += basedam;
2176 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2177 if (damage[i] < 0) damage[i] = 0;
2179 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2180 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2182 /* Basic abilities */
2184 xdis = p_ptr->skill_dis;
2185 xdev = p_ptr->skill_dev;
2186 xsav = p_ptr->skill_sav;
2187 xstl = p_ptr->skill_stl;
2188 xsrh = p_ptr->skill_srh;
2189 xfos = p_ptr->skill_fos;
2192 desc = likert(xthn, 12);
2193 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2195 desc = likert(xthb, 12);
2196 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2198 desc = likert(xsav, 7);
2199 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2201 /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
2202 desc = likert((xstl > 0) ? xstl : -1, 1);
2203 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2205 desc = likert(xfos, 6);
2206 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2208 desc = likert(xsrh, 6);
2209 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2211 desc = likert(xdis, 8);
2212 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2214 desc = likert(xdev, 6);
2215 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2218 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2220 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2222 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2225 if ((damage[0]+damage[1]) == 0)
2228 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2230 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2232 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2238 * Obtain the "flags" for the player as if he was an item
2240 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2245 for (i = 0; i < TR_FLAG_SIZE; i++)
2249 switch (p_ptr->pclass)
2252 if (p_ptr->lev > 44)
2253 add_flag(flgs, TR_REGEN);
2255 if (p_ptr->lev > 29)
2256 add_flag(flgs, TR_RES_FEAR);
2259 if (p_ptr->lev > 39)
2260 add_flag(flgs, TR_RES_FEAR);
2262 case CLASS_CHAOS_WARRIOR:
2263 if (p_ptr->lev > 29)
2264 add_flag(flgs, TR_RES_CHAOS);
2265 if (p_ptr->lev > 39)
2266 add_flag(flgs, TR_RES_FEAR);
2269 case CLASS_FORCETRAINER:
2270 if ((p_ptr->lev > 9) && !heavy_armor())
2271 add_flag(flgs, TR_SPEED);
2272 if ((p_ptr->lev>24) && !heavy_armor())
2273 add_flag(flgs, TR_FREE_ACT);
2277 add_flag(flgs, TR_SPEED);
2280 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
2281 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
2282 add_flag(flgs, TR_SPEED);
2284 add_flag(flgs, TR_FREE_ACT);
2286 add_flag(flgs, TR_SLOW_DIGEST);
2287 add_flag(flgs, TR_RES_FEAR);
2288 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2289 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2290 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2292 case CLASS_MINDCRAFTER:
2294 add_flag(flgs, TR_RES_FEAR);
2295 if (p_ptr->lev > 19)
2296 add_flag(flgs, TR_SUST_WIS);
2297 if (p_ptr->lev > 29)
2298 add_flag(flgs, TR_RES_CONF);
2299 if (p_ptr->lev > 39)
2300 add_flag(flgs, TR_TELEPATHY);
2303 add_flag(flgs, TR_RES_SOUND);
2305 case CLASS_BERSERKER:
2306 add_flag(flgs, TR_SUST_STR);
2307 add_flag(flgs, TR_SUST_DEX);
2308 add_flag(flgs, TR_SUST_CON);
2309 add_flag(flgs, TR_REGEN);
2310 add_flag(flgs, TR_FREE_ACT);
2311 add_flag(flgs, TR_SPEED);
2312 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2314 case CLASS_MIRROR_MASTER:
2315 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2318 break; /* Do nothing */
2322 if (p_ptr->mimic_form)
2324 switch(p_ptr->mimic_form)
2327 add_flag(flgs, TR_HOLD_LIFE);
2328 add_flag(flgs, TR_RES_CHAOS);
2329 add_flag(flgs, TR_RES_NETHER);
2330 add_flag(flgs, TR_RES_FIRE);
2331 add_flag(flgs, TR_SEE_INVIS);
2332 add_flag(flgs, TR_SPEED);
2334 case MIMIC_DEMON_LORD:
2335 add_flag(flgs, TR_HOLD_LIFE);
2336 add_flag(flgs, TR_RES_CHAOS);
2337 add_flag(flgs, TR_RES_NETHER);
2338 add_flag(flgs, TR_RES_FIRE);
2339 add_flag(flgs, TR_RES_COLD);
2340 add_flag(flgs, TR_RES_ELEC);
2341 add_flag(flgs, TR_RES_ACID);
2342 add_flag(flgs, TR_RES_POIS);
2343 add_flag(flgs, TR_RES_CONF);
2344 add_flag(flgs, TR_RES_DISEN);
2345 add_flag(flgs, TR_RES_NEXUS);
2346 add_flag(flgs, TR_RES_FEAR);
2347 add_flag(flgs, TR_IM_FIRE);
2348 add_flag(flgs, TR_SH_FIRE);
2349 add_flag(flgs, TR_SEE_INVIS);
2350 add_flag(flgs, TR_TELEPATHY);
2351 add_flag(flgs, TR_LEVITATION);
2352 add_flag(flgs, TR_SPEED);
2355 add_flag(flgs, TR_HOLD_LIFE);
2356 add_flag(flgs, TR_RES_DARK);
2357 add_flag(flgs, TR_RES_NETHER);
2358 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2359 add_flag(flgs, TR_RES_POIS);
2360 add_flag(flgs, TR_RES_COLD);
2361 add_flag(flgs, TR_SEE_INVIS);
2362 add_flag(flgs, TR_SPEED);
2368 switch (p_ptr->prace)
2371 add_flag(flgs, TR_RES_LITE);
2374 add_flag(flgs, TR_HOLD_LIFE);
2377 add_flag(flgs, TR_FREE_ACT);
2380 add_flag(flgs, TR_RES_BLIND);
2383 add_flag(flgs, TR_RES_DARK);
2385 case RACE_HALF_TROLL:
2386 add_flag(flgs, TR_SUST_STR);
2387 if (p_ptr->lev > 14)
2389 add_flag(flgs, TR_REGEN);
2390 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
2392 add_flag(flgs, TR_SLOW_DIGEST);
2394 * Let's not make Regeneration a disadvantage
2395 * for the poor warriors who can never learn
2396 * a spell that satisfies hunger (actually
2397 * neither can rogues, but half-trolls are not
2398 * supposed to play rogues)
2404 add_flag(flgs, TR_SUST_CON);
2405 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2408 add_flag(flgs, TR_RES_LITE);
2409 add_flag(flgs, TR_SEE_INVIS);
2411 case RACE_BARBARIAN:
2412 add_flag(flgs, TR_RES_FEAR);
2414 case RACE_HALF_OGRE:
2415 add_flag(flgs, TR_SUST_STR);
2416 add_flag(flgs, TR_RES_DARK);
2418 case RACE_HALF_GIANT:
2419 add_flag(flgs, TR_RES_SHARDS);
2420 add_flag(flgs, TR_SUST_STR);
2422 case RACE_HALF_TITAN:
2423 add_flag(flgs, TR_RES_CHAOS);
2426 add_flag(flgs, TR_RES_SOUND);
2429 add_flag(flgs, TR_RES_ACID);
2430 if (p_ptr->lev > 19)
2431 add_flag(flgs, TR_IM_ACID);
2434 add_flag(flgs, TR_RES_CONF);
2435 add_flag(flgs, TR_RES_ACID);
2437 add_flag(flgs, TR_SPEED);
2440 add_flag(flgs, TR_RES_POIS);
2443 add_flag(flgs, TR_RES_DISEN);
2444 add_flag(flgs, TR_RES_DARK);
2447 add_flag(flgs, TR_RES_DARK);
2448 if (p_ptr->lev > 19)
2449 add_flag(flgs, TR_SEE_INVIS);
2451 case RACE_DRACONIAN:
2452 add_flag(flgs, TR_LEVITATION);
2454 add_flag(flgs, TR_RES_FIRE);
2456 add_flag(flgs, TR_RES_COLD);
2457 if (p_ptr->lev > 14)
2458 add_flag(flgs, TR_RES_ACID);
2459 if (p_ptr->lev > 19)
2460 add_flag(flgs, TR_RES_ELEC);
2461 if (p_ptr->lev > 34)
2462 add_flag(flgs, TR_RES_POIS);
2464 case RACE_MIND_FLAYER:
2465 add_flag(flgs, TR_SUST_INT);
2466 add_flag(flgs, TR_SUST_WIS);
2467 if (p_ptr->lev > 14)
2468 add_flag(flgs, TR_SEE_INVIS);
2469 if (p_ptr->lev > 29)
2470 add_flag(flgs, TR_TELEPATHY);
2473 add_flag(flgs, TR_RES_FIRE);
2475 add_flag(flgs, TR_SEE_INVIS);
2478 add_flag(flgs, TR_SEE_INVIS);
2479 add_flag(flgs, TR_FREE_ACT);
2480 add_flag(flgs, TR_RES_POIS);
2481 add_flag(flgs, TR_SLOW_DIGEST);
2482 if (p_ptr->lev > 34)
2483 add_flag(flgs, TR_HOLD_LIFE);
2486 add_flag(flgs, TR_SEE_INVIS);
2487 add_flag(flgs, TR_RES_SHARDS);
2488 add_flag(flgs, TR_HOLD_LIFE);
2489 add_flag(flgs, TR_RES_POIS);
2491 add_flag(flgs, TR_RES_COLD);
2494 add_flag(flgs, TR_SEE_INVIS);
2495 add_flag(flgs, TR_HOLD_LIFE);
2496 add_flag(flgs, TR_RES_NETHER);
2497 add_flag(flgs, TR_RES_POIS);
2498 add_flag(flgs, TR_SLOW_DIGEST);
2500 add_flag(flgs, TR_RES_COLD);
2503 add_flag(flgs, TR_HOLD_LIFE);
2504 add_flag(flgs, TR_RES_DARK);
2505 add_flag(flgs, TR_RES_NETHER);
2506 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2507 add_flag(flgs, TR_RES_POIS);
2508 add_flag(flgs, TR_RES_COLD);
2511 add_flag(flgs, TR_LEVITATION);
2512 add_flag(flgs, TR_FREE_ACT);
2513 add_flag(flgs, TR_RES_COLD);
2514 add_flag(flgs, TR_SEE_INVIS);
2515 add_flag(flgs, TR_HOLD_LIFE);
2516 add_flag(flgs, TR_RES_NETHER);
2517 add_flag(flgs, TR_RES_POIS);
2518 add_flag(flgs, TR_SLOW_DIGEST);
2520 if (p_ptr->lev > 34)
2521 add_flag(flgs, TR_TELEPATHY);
2524 add_flag(flgs, TR_RES_LITE);
2525 add_flag(flgs, TR_LEVITATION);
2527 add_flag(flgs, TR_SPEED);
2530 add_flag(flgs, TR_RES_SOUND);
2531 add_flag(flgs, TR_RES_CONF);
2534 add_flag(flgs, TR_LEVITATION);
2535 add_flag(flgs, TR_SEE_INVIS);
2538 add_flag(flgs, TR_RES_FIRE);
2539 add_flag(flgs, TR_RES_NETHER);
2540 add_flag(flgs, TR_HOLD_LIFE);
2542 add_flag(flgs, TR_SEE_INVIS);
2545 add_flag(flgs, TR_SUST_CON);
2548 add_flag(flgs, TR_LEVITATION);
2551 add_flag(flgs, TR_RES_CONF);
2554 add_flag(flgs, TR_FREE_ACT);
2555 add_flag(flgs, TR_RES_POIS);
2556 add_flag(flgs, TR_SLOW_DIGEST);
2557 add_flag(flgs, TR_HOLD_LIFE);
2567 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2569 remove_flag(flgs, TR_REGEN);
2572 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2573 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2574 (p_ptr->muta3 & MUT3_SHORT_LEG))
2576 add_flag(flgs, TR_SPEED);
2579 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2581 add_flag(flgs, TR_SH_ELEC);
2584 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2586 add_flag(flgs, TR_SH_FIRE);
2587 add_flag(flgs, TR_LITE);
2590 if (p_ptr->muta3 & MUT3_WINGS)
2592 add_flag(flgs, TR_LEVITATION);
2595 if (p_ptr->muta3 & MUT3_FEARLESS)
2597 add_flag(flgs, TR_RES_FEAR);
2600 if (p_ptr->muta3 & MUT3_REGEN)
2602 add_flag(flgs, TR_REGEN);
2605 if (p_ptr->muta3 & MUT3_ESP)
2607 add_flag(flgs, TR_TELEPATHY);
2610 if (p_ptr->muta3 & MUT3_MOTION)
2612 add_flag(flgs, TR_FREE_ACT);
2616 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2617 add_flag(flgs, TR_AGGRAVATE);
2618 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2620 add_flag(flgs, TR_RES_BLIND);
2621 add_flag(flgs, TR_RES_CONF);
2622 add_flag(flgs, TR_HOLD_LIFE);
2623 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2625 add_flag(flgs, TR_SPEED);
2627 if (p_ptr->special_defense & KATA_FUUJIN)
2628 add_flag(flgs, TR_REFLECT);
2629 if (p_ptr->special_defense & KAMAE_GENBU)
2630 add_flag(flgs, TR_REFLECT);
2631 if (p_ptr->special_defense & KAMAE_SUZAKU)
2632 add_flag(flgs, TR_LEVITATION);
2633 if (p_ptr->special_defense & KAMAE_SEIRYU)
2635 add_flag(flgs, TR_RES_FIRE);
2636 add_flag(flgs, TR_RES_COLD);
2637 add_flag(flgs, TR_RES_ACID);
2638 add_flag(flgs, TR_RES_ELEC);
2639 add_flag(flgs, TR_RES_POIS);
2640 add_flag(flgs, TR_LEVITATION);
2641 add_flag(flgs, TR_SH_FIRE);
2642 add_flag(flgs, TR_SH_ELEC);
2643 add_flag(flgs, TR_SH_COLD);
2645 if (p_ptr->special_defense & KATA_MUSOU)
2647 add_flag(flgs, TR_RES_FEAR);
2648 add_flag(flgs, TR_RES_LITE);
2649 add_flag(flgs, TR_RES_DARK);
2650 add_flag(flgs, TR_RES_BLIND);
2651 add_flag(flgs, TR_RES_CONF);
2652 add_flag(flgs, TR_RES_SOUND);
2653 add_flag(flgs, TR_RES_SHARDS);
2654 add_flag(flgs, TR_RES_NETHER);
2655 add_flag(flgs, TR_RES_NEXUS);
2656 add_flag(flgs, TR_RES_CHAOS);
2657 add_flag(flgs, TR_RES_DISEN);
2658 add_flag(flgs, TR_REFLECT);
2659 add_flag(flgs, TR_HOLD_LIFE);
2660 add_flag(flgs, TR_FREE_ACT);
2661 add_flag(flgs, TR_SH_FIRE);
2662 add_flag(flgs, TR_SH_ELEC);
2663 add_flag(flgs, TR_SH_COLD);
2664 add_flag(flgs, TR_LEVITATION);
2665 add_flag(flgs, TR_LITE);
2666 add_flag(flgs, TR_SEE_INVIS);
2667 add_flag(flgs, TR_TELEPATHY);
2668 add_flag(flgs, TR_SLOW_DIGEST);
2669 add_flag(flgs, TR_REGEN);
2670 add_flag(flgs, TR_SUST_STR);
2671 add_flag(flgs, TR_SUST_INT);
2672 add_flag(flgs, TR_SUST_WIS);
2673 add_flag(flgs, TR_SUST_DEX);
2674 add_flag(flgs, TR_SUST_CON);
2675 add_flag(flgs, TR_SUST_CHR);
2680 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
2685 for (i = 0; i < TR_FLAG_SIZE; i++)
2688 if (IS_HERO() || p_ptr->shero)
2689 add_flag(flgs, TR_RES_FEAR);
2690 if (p_ptr->tim_invis)
2691 add_flag(flgs, TR_SEE_INVIS);
2692 if (p_ptr->tim_regen)
2693 add_flag(flgs, TR_REGEN);
2695 add_flag(flgs, TR_TELEPATHY);
2696 if (IS_FAST() || p_ptr->slow)
2697 add_flag(flgs, TR_SPEED);
2699 if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
2700 add_flag(flgs, TR_RES_ACID);
2701 if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
2702 add_flag(flgs, TR_RES_ELEC);
2703 if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
2704 add_flag(flgs, TR_RES_FIRE);
2705 if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
2706 add_flag(flgs, TR_RES_COLD);
2707 if (IS_OPPOSE_POIS())
2708 add_flag(flgs, TR_RES_POIS);
2710 if (p_ptr->special_attack & ATTACK_ACID)
2711 add_flag(flgs, TR_BRAND_ACID);
2712 if (p_ptr->special_attack & ATTACK_ELEC)
2713 add_flag(flgs, TR_BRAND_ELEC);
2714 if (p_ptr->special_attack & ATTACK_FIRE)
2715 add_flag(flgs, TR_BRAND_FIRE);
2716 if (p_ptr->special_attack & ATTACK_COLD)
2717 add_flag(flgs, TR_BRAND_COLD);
2718 if (p_ptr->special_attack & ATTACK_POIS)
2719 add_flag(flgs, TR_BRAND_POIS);
2720 if (p_ptr->special_defense & DEFENSE_ACID)
2721 add_flag(flgs, TR_IM_ACID);
2722 if (p_ptr->special_defense & DEFENSE_ELEC)
2723 add_flag(flgs, TR_IM_ELEC);
2724 if (p_ptr->special_defense & DEFENSE_FIRE)
2725 add_flag(flgs, TR_IM_FIRE);
2726 if (p_ptr->special_defense & DEFENSE_COLD)
2727 add_flag(flgs, TR_IM_COLD);
2728 if (p_ptr->wraith_form)
2729 add_flag(flgs, TR_REFLECT);
2731 if (p_ptr->tim_reflect)
2732 add_flag(flgs, TR_REFLECT);
2734 if (p_ptr->magicdef)
2736 add_flag(flgs, TR_RES_BLIND);
2737 add_flag(flgs, TR_RES_CONF);
2738 add_flag(flgs, TR_REFLECT);
2739 add_flag(flgs, TR_FREE_ACT);
2740 add_flag(flgs, TR_LEVITATION);
2742 if (p_ptr->tim_res_nether)
2744 add_flag(flgs, TR_RES_NETHER);
2746 if (p_ptr->tim_sh_fire)
2748 add_flag(flgs, TR_SH_FIRE);
2752 add_flag(flgs, TR_RES_FEAR);
2753 add_flag(flgs, TR_RES_LITE);
2754 add_flag(flgs, TR_RES_DARK);
2755 add_flag(flgs, TR_RES_BLIND);
2756 add_flag(flgs, TR_RES_CONF);
2757 add_flag(flgs, TR_RES_SOUND);
2758 add_flag(flgs, TR_RES_SHARDS);
2759 add_flag(flgs, TR_RES_NETHER);
2760 add_flag(flgs, TR_RES_NEXUS);
2761 add_flag(flgs, TR_RES_CHAOS);
2762 add_flag(flgs, TR_RES_DISEN);
2763 add_flag(flgs, TR_REFLECT);
2764 add_flag(flgs, TR_HOLD_LIFE);
2765 add_flag(flgs, TR_FREE_ACT);
2766 add_flag(flgs, TR_SH_FIRE);
2767 add_flag(flgs, TR_SH_ELEC);
2768 add_flag(flgs, TR_SH_COLD);
2769 add_flag(flgs, TR_LEVITATION);
2770 add_flag(flgs, TR_LITE);
2771 add_flag(flgs, TR_SEE_INVIS);
2772 add_flag(flgs, TR_TELEPATHY);
2773 add_flag(flgs, TR_SLOW_DIGEST);
2774 add_flag(flgs, TR_REGEN);
2775 add_flag(flgs, TR_SUST_STR);
2776 add_flag(flgs, TR_SUST_INT);
2777 add_flag(flgs, TR_SUST_WIS);
2778 add_flag(flgs, TR_SUST_DEX);
2779 add_flag(flgs, TR_SUST_CON);
2780 add_flag(flgs, TR_SUST_CHR);
2785 /* Mode flags for displaying player flags */
2786 #define DP_CURSE 0x01
2794 static void display_player_equippy(int y, int x, u16b mode)
2803 /* Weapon flags need only two column */
2804 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2805 else max_i = INVEN_TOTAL;
2807 /* Dump equippy chars */
2808 for (i = INVEN_RARM; i < max_i; i++)
2811 o_ptr = &inventory[i];
2813 a = object_attr(o_ptr);
2814 c = object_char(o_ptr);
2816 /* Clear the part of the screen */
2817 if (!equippy_chars || !o_ptr->k_idx)
2824 Term_putch(x + i - INVEN_RARM, y, a, c);
2829 void print_equippy(void)
2831 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2838 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2843 for (i = 0; i < TR_FLAG_SIZE; i++)
2846 /* Check equipment */
2847 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2849 u32b o_flgs[TR_FLAG_SIZE];
2854 o_ptr = &inventory[i];
2856 if (!o_ptr->k_idx) continue;
2859 object_flags_known(o_ptr, o_flgs);
2861 if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2862 if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2863 if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2864 if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2868 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2873 for (i = 0; i < TR_FLAG_SIZE; i++)
2876 if (prace_is_(RACE_SPECTRE))
2877 add_flag(flgs, TR_RES_NETHER);
2878 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2879 add_flag(flgs, TR_RES_DARK);
2880 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2881 add_flag(flgs, TR_RES_FIRE);
2882 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2883 add_flag(flgs, TR_RES_ACID);
2886 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2891 for (i = 0; i < TR_FLAG_SIZE; i++)
2894 if (p_ptr->special_defense & DEFENSE_ACID)
2895 add_flag(flgs, TR_RES_ACID);
2896 if (p_ptr->special_defense & DEFENSE_ELEC)
2897 add_flag(flgs, TR_RES_ELEC);
2898 if (p_ptr->special_defense & DEFENSE_FIRE)
2899 add_flag(flgs, TR_RES_FIRE);
2900 if (p_ptr->special_defense & DEFENSE_COLD)
2901 add_flag(flgs, TR_RES_COLD);
2902 if (p_ptr->wraith_form)
2903 add_flag(flgs, TR_RES_DARK);
2906 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2911 for (i = 0; i < TR_FLAG_SIZE; i++)
2914 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2916 add_flag(flgs, TR_RES_ACID);
2917 add_flag(flgs, TR_RES_ELEC);
2918 add_flag(flgs, TR_RES_FIRE);
2919 add_flag(flgs, TR_RES_COLD);
2921 if (prace_is_(RACE_ANDROID))
2922 add_flag(flgs, TR_RES_ELEC);
2923 if (prace_is_(RACE_ENT))
2924 add_flag(flgs, TR_RES_FIRE);
2925 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2926 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2927 add_flag(flgs, TR_RES_LITE);
2932 * A struct for storing misc. flags
2935 u32b player_flags[TR_FLAG_SIZE];
2936 u32b tim_player_flags[TR_FLAG_SIZE];
2937 u32b player_imm[TR_FLAG_SIZE];
2938 u32b tim_player_imm[TR_FLAG_SIZE];
2939 u32b player_vuln[TR_FLAG_SIZE];
2940 u32b known_obj_imm[TR_FLAG_SIZE];
2945 * Helper function, see below
2947 static void display_flag_aux(int row, int col, cptr header,
2948 int flag1, all_player_flags *f, u16b mode)
2954 if (have_flag(f->player_vuln, flag1) &&
2955 !(have_flag(f->known_obj_imm, flag1) ||
2956 have_flag(f->player_imm, flag1) ||
2957 have_flag(f->tim_player_imm, flag1)))
2961 if (!(mode & DP_IMM)) c_put_str(TERM_WHITE, header, row, col);
2964 col += strlen(header) + 1;
2966 /* Weapon flags need only two column */
2967 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2968 else max_i = INVEN_TOTAL;
2970 /* Check equipment */
2971 for (i = INVEN_RARM; i < max_i; i++)
2973 u32b flgs[TR_FLAG_SIZE];
2977 o_ptr = &inventory[i];
2980 object_flags_known(o_ptr, flgs);
2983 if (!(mode & DP_IMM))
2984 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2987 if (mode & DP_CURSE)
2989 if ((mode & DP_CURSE) && (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE)))
2990 c_put_str(TERM_WHITE, "+", row, col);
2991 if ((mode & DP_CURSE) && (o_ptr->curse_flags & TRC_PERMA_CURSE))
2992 c_put_str(TERM_WHITE, "*", row, col);
2996 if (have_flag(flgs, flag1))
2997 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
2998 (mode & DP_IMM) ? "*" : "+", row, col);
3005 /* Assume that player flag is already written */
3006 if (mode & DP_IMM) return;
3009 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3012 if (have_flag(f->player_flags, flag1)) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3014 /* Timed player flags */
3015 if (have_flag(f->tim_player_flags, flag1)) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3018 if (have_flag(f->tim_player_imm, flag1)) c_put_str(TERM_YELLOW, "*", row, col);
3019 if (have_flag(f->player_imm, flag1)) c_put_str(TERM_WHITE, "*", row, col);
3022 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3027 * Special display, part 1
3029 static void display_player_flag_info(void)
3036 /* Extract flags and store */
3037 player_flags(f.player_flags);
3038 tim_player_flags(f.tim_player_flags);
3039 player_immunity(f.player_imm);
3040 tim_player_immunity(f.tim_player_imm);
3041 known_obj_immunity(f.known_obj_imm);
3042 player_vuln_flags(f.player_vuln);
3049 display_player_equippy(row-2, col+8, 0);
3050 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3053 display_flag_aux(row+0, col, "ÂÑ»À :", TR_RES_ACID, &f, 0);
3054 display_flag_aux(row+0, col, "ÂÑ»À :", TR_IM_ACID, &f, DP_IMM);
3055 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_RES_ELEC, &f, 0);
3056 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_IM_ELEC, &f, DP_IMM);
3057 display_flag_aux(row+2, col, "ÂѲбê:", TR_RES_FIRE, &f, 0);
3058 display_flag_aux(row+2, col, "ÂѲбê:", TR_IM_FIRE, &f, DP_IMM);
3059 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_RES_COLD, &f, 0);
3060 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_IM_COLD, &f, DP_IMM);
3061 display_flag_aux(row+4, col, "ÂÑÆÇ :", TR_RES_POIS, &f, 0);
3062 display_flag_aux(row+5, col, "ÂÑÁ®¸÷:", TR_RES_LITE, &f, 0);
3063 display_flag_aux(row+6, col, "ÂѰŹõ:", TR_RES_DARK, &f, 0);
3064 display_flag_aux(row+7, col, "ÂÑÇËÊÒ:", TR_RES_SHARDS, &f, 0);
3065 display_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", TR_RES_BLIND, &f, 0);
3066 display_flag_aux(row+9, col, "ÂѺ®Íð:", TR_RES_CONF, &f, 0);
3068 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3069 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3070 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3071 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3072 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3073 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3074 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3075 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3076 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3077 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3078 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3079 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3080 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3081 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3090 display_player_equippy(row-2, col+8, 0);
3092 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3095 display_flag_aux(row+0, col, "Âѹ첻:", TR_RES_SOUND, &f, 0);
3096 display_flag_aux(row+1, col, "ÂÑÃϹö:", TR_RES_NETHER, &f, 0);
3097 display_flag_aux(row+2, col, "ÂÑ°øº®:", TR_RES_NEXUS, &f, 0);
3098 display_flag_aux(row+3, col, "ÂÑ¥«¥ª:", TR_RES_CHAOS, &f, 0);
3099 display_flag_aux(row+4, col, "ÂÑÎô²½:", TR_RES_DISEN, &f, 0);
3100 display_flag_aux(row+5, col, "ÂѶ²ÉÝ:", TR_RES_FEAR, &f, 0);
3101 display_flag_aux(row+6, col, "È¿¼Í :", TR_REFLECT, &f, 0);
3102 display_flag_aux(row+7, col, "²Ð±ê¥ª:", TR_SH_FIRE, &f, 0);
3103 display_flag_aux(row+8, col, "Åŵ¤¥ª:", TR_SH_ELEC, &f, 0);
3104 display_flag_aux(row+9, col, "Î䵤¥ª:", TR_SH_COLD, &f, 0);
3106 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3107 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3108 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3109 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3110 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3111 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3112 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3113 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3114 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3115 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3124 display_player_equippy(row-2, col+12, 0);
3126 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3129 display_flag_aux(row+0, col, "²Ã® :", TR_SPEED, &f, 0);
3130 display_flag_aux(row+1, col, "ÂÑËãáã :", TR_FREE_ACT, &f, 0);
3131 display_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", TR_SEE_INVIS, &f, 0);
3132 display_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", TR_HOLD_LIFE, &f, 0);
3133 display_flag_aux(row+4, col, "·Ù¹ð :", TR_WARNING, &f, 0);
3134 display_flag_aux(row+5, col, "Ãپò½ :", TR_SLOW_DIGEST, &f, 0);
3135 display_flag_aux(row+6, col, "µÞ²óÉü :", TR_REGEN, &f, 0);
3136 display_flag_aux(row+7, col, "ÉâÍ· :", TR_LEVITATION, &f, 0);
3137 display_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", TR_LITE, &f, 0);
3138 display_flag_aux(row+9, col, "¼ö¤¤ :", 0, &f, DP_CURSE);
3140 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3141 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3142 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3143 display_flag_aux(row+3, col, "Hold Life :", TR_HOLD_LIFE, &f, 0);
3144 display_flag_aux(row+4, col, "Warning :", TR_WARNING, &f, 0);
3145 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3146 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3147 display_flag_aux(row+7, col, "Levitation:", TR_LEVITATION, &f, 0);
3148 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE, &f, 0);
3149 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3156 * Special display, part 2
3158 static void display_player_other_flag_info(void)
3165 /* Extract flags and store */
3166 player_flags(f.player_flags);
3167 tim_player_flags(f.tim_player_flags);
3168 player_immunity(f.player_imm);
3169 tim_player_immunity(f.tim_player_imm);
3170 known_obj_immunity(f.known_obj_imm);
3171 player_vuln_flags(f.player_vuln);
3178 display_player_equippy(row-2, col+12, DP_WP);
3180 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3183 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_SLAY_EVIL, &f, DP_WP);
3184 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3185 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_SLAY_UNDEAD, &f, DP_WP);
3186 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3187 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_SLAY_DEMON, &f, DP_WP);
3188 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3189 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_SLAY_DRAGON, &f, DP_WP);
3190 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3191 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_SLAY_HUMAN, &f, DP_WP);
3192 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3193 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_SLAY_ANIMAL, &f, DP_WP);
3194 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3195 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_SLAY_ORC, &f, DP_WP);
3196 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3197 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_SLAY_TROLL, &f, DP_WP);
3198 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3199 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_SLAY_GIANT, &f, DP_WP);
3200 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3201 display_flag_aux(row+ 9, col, "Íϲò :", TR_BRAND_ACID, &f, DP_WP);
3202 display_flag_aux(row+10, col, "ÅÅ·â :", TR_BRAND_ELEC, &f, DP_WP);
3203 display_flag_aux(row+11, col, "¾Æ´þ :", TR_BRAND_FIRE, &f, DP_WP);
3204 display_flag_aux(row+12, col, "Åà·ë :", TR_BRAND_COLD, &f, DP_WP);
3205 display_flag_aux(row+13, col, "ÆÇ»¦ :", TR_BRAND_POIS, &f, DP_WP);
3206 display_flag_aux(row+14, col, "ÀÚ¤ìÌ£ :", TR_VORPAL, &f, DP_WP);
3207 display_flag_aux(row+15, col, "ÃÏ¿Ì :", TR_IMPACT, &f, DP_WP);
3208 display_flag_aux(row+16, col, "µÛ·ì :", TR_VAMPIRIC, &f, DP_WP);
3209 display_flag_aux(row+17, col, "¥«¥ª¥¹¸ú²Ì:", TR_CHAOTIC, &f, DP_WP);
3210 display_flag_aux(row+18, col, "ÍýÎÏ :", TR_FORCE_WEAPON, &f, DP_WP);
3212 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3213 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3214 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3215 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3216 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3217 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3218 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3219 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3220 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3221 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3222 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3223 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3224 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3225 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3226 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3227 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3228 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3229 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3230 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3231 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3232 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3233 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3234 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3235 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3236 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3237 display_flag_aux(row+16, col, "Vampiric :", TR_VAMPIRIC, &f, DP_WP);
3238 display_flag_aux(row+17, col, "Chaotic :", TR_CHAOTIC, &f, DP_WP);
3239 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3248 display_player_equippy(row-2, col+12, 0);
3249 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3252 display_flag_aux(row+ 0, col, "¥Æ¥ì¥Ñ¥·¡¼:", TR_TELEPATHY, &f, 0);
3253 display_flag_aux(row+ 1, col, "¼Ù°ESP :", TR_ESP_EVIL, &f, 0);
3254 display_flag_aux(row+ 2, col, "̵À¸ÊªESP :", TR_ESP_NONLIVING, &f, 0);
3255 display_flag_aux(row+ 3, col, "Á±ÎÉESP :", TR_ESP_GOOD, &f, 0);
3256 display_flag_aux(row+ 4, col, "ÉÔ»àESP :", TR_ESP_UNDEAD, &f, 0);
3257 display_flag_aux(row+ 5, col, "°ËâESP :", TR_ESP_DEMON, &f, 0);
3258 display_flag_aux(row+ 6, col, "ζESP :", TR_ESP_DRAGON, &f, 0);
3259 display_flag_aux(row+ 7, col, "¿Í´ÖESP :", TR_ESP_HUMAN, &f, 0);
3260 display_flag_aux(row+ 8, col, "ưʪESP :", TR_ESP_ANIMAL, &f, 0);
3261 display_flag_aux(row+ 9, col, "¥ª¡¼¥¯ESP :", TR_ESP_ORC, &f, 0);
3262 display_flag_aux(row+10, col, "¥È¥í¥ëESP :", TR_ESP_TROLL, &f, 0);
3263 display_flag_aux(row+11, col, "µð¿ÍESP :", TR_ESP_GIANT, &f, 0);
3265 display_flag_aux(row+13, col, "ÏÓÎÏ°Ý»ý :", TR_SUST_STR, &f, 0);
3266 display_flag_aux(row+14, col, "ÃÎÎÏ°Ý»ý :", TR_SUST_INT, &f, 0);
3267 display_flag_aux(row+15, col, "¸¤µ°Ý»ý :", TR_SUST_WIS, &f, 0);
3268 display_flag_aux(row+16, col, "´ïÍÑ°Ý»ý :", TR_SUST_DEX, &f, 0);
3269 display_flag_aux(row+17, col, "Âѵװݻý :", TR_SUST_CON, &f, 0);
3270 display_flag_aux(row+18, col, "Ì¥ÎÏ°Ý»ý :", TR_SUST_CHR, &f, 0);
3272 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3273 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3274 display_flag_aux(row+ 2, col, "ESP Noliv.:", TR_ESP_NONLIVING, &f, 0);
3275 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3276 display_flag_aux(row+ 4, col, "ESP Undead:", TR_ESP_UNDEAD, &f, 0);
3277 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3278 display_flag_aux(row+ 6, col, "ESP Dragon:", TR_ESP_DRAGON, &f, 0);
3279 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3280 display_flag_aux(row+ 8, col, "ESP Animal:", TR_ESP_ANIMAL, &f, 0);
3281 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3282 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3283 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3285 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3286 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3287 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3288 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3289 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3290 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3297 col = col + 12 + 17;
3299 display_player_equippy(row-2, col+14, 0);
3301 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3304 display_flag_aux(row+ 0, col, "Äɲù¶·â :", TR_BLOWS, &f, 0);
3305 display_flag_aux(row+ 1, col, "ºÎ·¡ :", TR_TUNNEL, &f, 0);
3306 display_flag_aux(row+ 2, col, "ÀÖ³°Àþ»ëÎÏ :", TR_INFRA, &f, 0);
3307 display_flag_aux(row+ 3, col, "ËâË¡Æ»¶ñ»ÙÇÛ:", TR_MAGIC_MASTERY, &f, 0);
3308 display_flag_aux(row+ 4, col, "±£Ì© :", TR_STEALTH, &f, 0);
3309 display_flag_aux(row+ 5, col, "õº÷ :", TR_SEARCH, &f, 0);
3311 display_flag_aux(row+ 7, col, "¾èÇÏ :", TR_RIDING, &f, 0);
3312 display_flag_aux(row+ 8, col, "ÅêÚ³ :", TR_THROW, &f, 0);
3313 display_flag_aux(row+ 9, col, "½ËÊ¡ :", TR_BLESSED, &f, 0);
3314 display_flag_aux(row+10, col, "È¿¥Æ¥ì¥Ý¡¼¥È:", TR_NO_TELE, &f, 0);
3315 display_flag_aux(row+11, col, "È¿ËâË¡ :", TR_NO_MAGIC, &f, 0);
3316 display_flag_aux(row+12, col, "¾ÃÈñËâÎϸº¾¯:", TR_DEC_MANA, &f, 0);
3318 display_flag_aux(row+14, col, "·Ð¸³Ã͸º¾¯ :", TR_DRAIN_EXP, &f, 0);
3319 display_flag_aux(row+15, col, "Íð¥Æ¥ì¥Ý¡¼¥È:", TR_TELEPORT, &f, 0);
3320 display_flag_aux(row+16, col, "È¿´¶ :", TR_AGGRAVATE, &f, 0);
3321 display_flag_aux(row+17, col, "ÂÀ¸Å¤Î±åÇ° :", TR_TY_CURSE, &f, 0);
3323 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3324 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3325 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3326 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3327 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3328 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3330 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3331 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3332 display_flag_aux(row+ 9, col, "Blessed :", TR_BLESSED, &f, 0);
3333 display_flag_aux(row+10, col, "No Teleport :", TR_NO_TELE, &f, 0);
3334 display_flag_aux(row+11, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3335 display_flag_aux(row+12, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3337 display_flag_aux(row+14, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3338 display_flag_aux(row+15, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3339 display_flag_aux(row+16, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3340 display_flag_aux(row+17, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3347 * Special display, part 2a
3349 static void display_player_misc_info(void)
3354 /* Display basics */
3356 put_str("̾Á° :", 1, 26);
3357 put_str("ÀÊÌ :", 3, 1);
3358 put_str("¼ï² :", 4, 1);
3359 put_str("¿¦¶È :", 5, 1);
3361 put_str("Name :", 1, 26);
3362 put_str("Sex :", 3, 1);
3363 put_str("Race :", 4, 1);
3364 put_str("Class :", 5, 1);
3367 strcpy(tmp,ap_ptr->title);
3374 strcat(tmp,player_name);
3376 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3377 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3378 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3379 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3381 /* Display extras */
3383 put_str("¥ì¥Ù¥ë:", 6, 1);
3384 put_str("£È£Ð :", 7, 1);
3385 put_str("£Í£Ð :", 8, 1);
3387 put_str("Level :", 6, 1);
3388 put_str("Hits :", 7, 1);
3389 put_str("Mana :", 8, 1);
3393 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3394 c_put_str(TERM_L_BLUE, buf, 6, 9);
3395 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3396 c_put_str(TERM_L_BLUE, buf, 7, 9);
3397 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3398 c_put_str(TERM_L_BLUE, buf, 8, 9);
3403 * Special display, part 2b
3405 * How to print out the modifications and sustains.
3406 * Positive mods with no sustain will be light green.
3407 * Positive mods with a sustain will be dark green.
3408 * Sustains (with no modification) will be a dark green 's'.
3409 * Negative mods (from a curse) will be red.
3410 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3411 * No mod, no sustain, will be a slate '.'
3413 static void display_player_stat_info(void)
3420 u32b flgs[TR_FLAG_SIZE];
3434 /* Print out the labels for the columns */
3436 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3437 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3438 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3439 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3440 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3442 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3443 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3444 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3445 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3446 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3450 /* Display the stats */
3451 for (i = 0; i < 6; i++)
3455 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3456 else r_adj = rp_ptr->r_adj[i];
3458 /* Calculate equipment adjustment */
3461 /* Icky formula to deal with the 18 barrier */
3462 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3463 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3464 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3465 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3466 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3467 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3469 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3470 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3472 if (prace_is_(RACE_ENT))
3478 if (p_ptr->lev > 25) r_adj++;
3479 if (p_ptr->lev > 40) r_adj++;
3480 if (p_ptr->lev > 45) r_adj++;
3483 if (p_ptr->lev > 25) r_adj--;
3484 if (p_ptr->lev > 40) r_adj--;
3485 if (p_ptr->lev > 45) r_adj--;
3491 e_adj -= cp_ptr->c_adj[i];
3492 e_adj -= ap_ptr->a_adj[i];
3494 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3495 /* Reduced name of stat */
3496 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3498 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3501 /* Internal "natural" max value. Maxes at 18/100 */
3502 /* This is useful to see if you are maxed out */
3503 cnv_stat(p_ptr->stat_max[i], buf);
3504 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3507 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3509 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3512 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3514 /* Race, class, and equipment modifiers */
3515 (void)sprintf(buf, "%3d", r_adj);
3516 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3517 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3518 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3519 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3520 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3521 (void)sprintf(buf, "%3d", (int)e_adj);
3522 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3524 /* Actual maximal modified value */
3525 cnv_stat(p_ptr->stat_top[i], buf);
3526 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3528 /* Only display stat_use if not maximal */
3529 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3531 cnv_stat(p_ptr->stat_use[i], buf);
3532 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3537 col = stat_col + 41;
3539 /* Header and Footer */
3540 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3542 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3544 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3548 /* Process equipment */
3549 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3552 o_ptr = &inventory[i];
3554 /* Acquire "known" flags */
3555 object_flags_known(o_ptr, flgs);
3557 /* Initialize color based of sign of pval. */
3558 for (stat = 0; stat < 6; stat++)
3565 if (have_flag(flgs, stat))
3571 if (o_ptr->pval > 0)
3577 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3580 if (have_flag(flgs, stat + TR_SUST_STR))
3582 /* Dark green for sustained stats */
3587 if (o_ptr->pval < 0)
3593 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3598 else if (have_flag(flgs, stat + TR_SUST_STR))
3600 /* Dark green "s" */
3605 /* Dump proper character */
3606 Term_putch(col, row + stat+1, a, c);
3617 for (stat = 0; stat < 6; stat++)
3624 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3630 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3631 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3632 if (p_ptr->tsuyoshi) dummy += 4;
3634 else if (stat == A_WIS || stat == A_INT)
3636 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3637 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3639 else if (stat == A_DEX)
3641 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3642 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3643 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3645 else if (stat == A_CON)
3647 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3648 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3649 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3650 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3651 if (p_ptr->tsuyoshi) dummy += 4;
3653 else if (stat == A_CHR)
3655 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3656 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3657 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3658 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3659 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3660 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3676 if (dummy < 10) c = '0' + dummy;
3686 if (dummy > -10) c = '0' - dummy;
3693 if (have_flag(flgs, stat + TR_SUST_STR))
3695 /* Dark green "s" */
3702 Term_putch(col, row + stat+1, a, c);
3708 * Display the character on the screen (various modes)
3710 * The top one and bottom two lines are left blank.
3712 * Mode 0 = standard display with skills
3713 * Mode 1 = standard display with history
3714 * Mode 2 = summary of various things
3715 * Mode 3 = summary of various things (part 2)
3716 * Mode 4 = mutations
3718 void display_player(int mode)
3727 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3736 if ((mode == 0) || (mode == 1))
3738 /* Name, Sex, Race, Class */
3740 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3742 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3745 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3746 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3747 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3748 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3753 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3755 strcpy(tmp, realm_names[p_ptr->realm1]);
3756 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3759 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3760 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3762 /* Age, Height, Weight, Social */
3763 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
3765 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
3766 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3767 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3768 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3770 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3771 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3772 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3773 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3775 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3778 /* Display the stats */
3779 for (i = 0; i < 6; i++)
3781 /* Special treatment of "injured" stats */
3782 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3786 /* Use lowercase stat name */
3787 put_str(stat_names_reduced[i], 3 + i, 53);
3789 /* Get the current stat */
3790 value = p_ptr->stat_use[i];
3792 /* Obtain the current stat (modified) */
3793 cnv_stat(value, buf);
3795 /* Display the current stat (modified) */
3796 c_put_str(TERM_YELLOW, buf, 3 + i, 60);
3798 /* Acquire the max stat */
3799 value = p_ptr->stat_top[i];
3801 /* Obtain the maximum stat (modified) */
3802 cnv_stat(value, buf);
3804 /* Display the maximum stat (modified) */
3805 c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
3808 /* Normal treatment of "normal" stats */
3811 /* Assume uppercase stat name */
3812 put_str(stat_names[i], 3 + i, 53);
3814 /* Obtain the current stat (modified) */
3815 cnv_stat(p_ptr->stat_use[i], buf);
3817 /* Display the current stat (modified) */
3818 c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
3821 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3824 c_put_str(TERM_WHITE, "!", 3 + i, 58);
3826 c_put_str(TERM_WHITE, "!", 3 + i, 58-2);
3831 /* Display "history" info */
3837 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
3839 put_str("(Character Background)", 11, 25);
3842 for (i = 0; i < 4; i++)
3844 put_str(p_ptr->history[i], i + 12, 10);
3851 if (p_ptr->total_winner)
3854 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å%s¤·¤¿¡£", streq(p_ptr->died_from, "Seppuku") ? "ÀÚÊ¢" : "°úÂà");
3856 sprintf(statmsg, "...You %s after the winning.", streq(p_ptr->died_from, "Seppuku") ? "did Seppuku" : "retired from the adventure");
3859 else if (!dun_level)
3862 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), p_ptr->died_from);
3864 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3867 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3869 /* Get the quest text */
3870 /* Bewere that INIT_ASSIGN resets the cur_num. */
3871 init_flags = INIT_ASSIGN;
3873 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3876 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3878 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3884 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
3886 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3890 else if (character_dungeon)
3895 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
3897 sprintf(statmsg, "...Now, you are in %s.", map_name());
3900 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3902 /* Clear the text */
3903 /* Must be done before doing INIT_SHOW_TEXT */
3904 for (i = 0; i < 10; i++)
3906 quest_text[i][0] = '\0';
3908 quest_text_line = 0;
3910 /* Get the quest text */
3911 init_flags = INIT_SHOW_TEXT;
3913 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3916 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
3918 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
3924 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
3926 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
3933 char temp[64*2], *t;
3934 roff_to_buf(statmsg, 60, temp, sizeof(temp));
3936 for(i=0 ; i<2 ; i++)
3942 put_str(t, i + 5 + 12, 10);
3950 /* Display "various" info */
3953 display_player_middle();
3954 display_player_various();
3961 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
3964 display_player_misc_info();
3965 display_player_stat_info();
3966 display_player_flag_info();
3972 display_player_other_flag_info();
3977 do_cmd_knowledge_mutations();
3985 static void dump_aux_display_player(FILE *fff)
3992 /* Display player */
3995 /* Dump part of the screen */
3996 for (y = 1; y < 22; y++)
3999 for (x = 0; x < 79; x++)
4001 /* Get the attr/char */
4002 (void)(Term_what(x, y, &a, &c));
4008 /* End the string */
4011 /* Kill trailing spaces */
4012 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4016 fprintf(fff, "%s\n", buf);
4018 fprintf(fff, "%s\n", buf);
4023 /* Display history */
4026 /* Dump part of the screen */
4027 for (y = 10; y < 19; y++)
4030 for (x = 0; x < 79; x++)
4032 /* Get the attr/char */
4033 (void)(Term_what(x, y, &a, &c));
4039 /* End the string */
4042 /* Kill trailing spaces */
4043 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4046 fprintf(fff, "%s\n", buf);
4051 /* Display flags (part 1) */
4054 /* Dump part of the screen */
4055 for (y = 2; y < 22; y++)
4058 for (x = 0; x < 79; x++)
4060 /* Get the attr/char */
4061 (void)(Term_what(x, y, &a, &c));
4063 /* Dump it (Ignore equippy tile graphic) */
4070 /* End the string */
4073 /* Kill trailing spaces */
4074 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4077 fprintf(fff, "%s\n", buf);
4082 /* Display flags (part 2) */
4085 /* Dump part of the screen */
4086 for (y = 1; y < 22; y++)
4089 for (x = 0; x < 79; x++)
4091 /* Get the attr/char */
4092 (void)(Term_what(x, y, &a, &c));
4094 /* Dump it (Ignore equippy tile graphic) */
4101 /* End the string */
4104 /* Kill trailing spaces */
4105 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4108 fprintf(fff, "%s\n", buf);
4111 for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
4114 for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
4122 static void dump_aux_pet(FILE *fff)
4126 bool pet_settings = FALSE;
4129 for (i = m_max - 1; i >= 1; i--)
4131 monster_type *m_ptr = &m_list[i];
4133 if (!m_ptr->r_idx) continue;
4134 if (!is_pet(m_ptr)) continue;
4135 pet_settings = TRUE;
4136 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4140 fprintf(fff, "\n\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4142 fprintf(fff, "\n\n [Leading Pets]\n\n");
4146 monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
4147 fprintf(fff, "%s\n", pet_name);
4153 fprintf(fff, "\n\n [¥Ú¥Ã¥È¤Ø¤ÎÌ¿Îá]\n");
4155 fprintf(fff, "\n\n [Command for Pets]\n");
4159 fprintf(fff, "\n ¥É¥¢¤ò³«¤±¤ë: %s", (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4161 fprintf(fff, "\n Pets open doors: %s", (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4165 fprintf(fff, "\n ¥¢¥¤¥Æ¥à¤ò½¦¤¦: %s", (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4167 fprintf(fff, "\n Pets pick up items: %s", (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4171 fprintf(fff, "\n ¥Æ¥ì¥Ý¡¼¥È·ÏËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4173 fprintf(fff, "\n Allow teleport: %s", (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4177 fprintf(fff, "\n ¹¶·âËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4179 fprintf(fff, "\n Allow cast attack spell: %s", (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4183 fprintf(fff, "\n ¾¤´ËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4185 fprintf(fff, "\n Allow cast summon spell: %s", (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4189 fprintf(fff, "\n ¥×¥ì¥¤¥ä¡¼¤ò´¬¤¹þ¤àÈÏ°ÏËâË¡¤ò»È¤¦: %s", (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4191 fprintf(fff, "\n Allow involve player in area spell: %s", (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4202 static void dump_aux_class_special(FILE *fff)
4204 if (p_ptr->pclass == CLASS_BLUE_MAGE)
4211 int spellnum[MAX_MONSPELLS];
4212 s32b f4 = 0, f5 = 0, f6 = 0;
4217 for (i=0;i<60;i++) { p[i][0] = '\0'; }
4220 strcat(p[col], "\n\n [³Ø½¬ºÑ¤ß¤ÎÀÄËâË¡]\n");
4222 strcat(p[col], "\n\n [Learned Blue Magic]\n");
4229 set_rf_masks(&f4, &f5, &f6, j);
4232 case MONSPELL_TYPE_BOLT:
4234 strcat(p[col], "\n [¥Ü¥ë¥È·¿]\n");
4236 strcat(p[col], "\n [Bolt Type]\n");
4240 case MONSPELL_TYPE_BALL:
4242 strcat(p[col], "\n [¥Ü¡¼¥ë·¿]\n");
4244 strcat(p[col], "\n [Ball Type]\n");
4248 case MONSPELL_TYPE_BREATH:
4250 strcat(p[col], "\n [¥Ö¥ì¥¹·¿]\n");
4252 strcat(p[col], "\n [ Breath ]\n");
4256 case MONSPELL_TYPE_SUMMON:
4258 strcat(p[col], "\n [¾¤´ËâË¡]\n");
4260 strcat(p[col], "\n [Summonning]\n");
4264 case MONSPELL_TYPE_OTHER:
4266 strcat(p[col], "\n [ ¤½¤Î¾ ]\n");
4268 strcat(p[col], "\n [Other Type]\n");
4273 for (i = 0, num = 0; i < 32; i++)
4275 if ((0x00000001 << i) & f4) spellnum[num++] = i;
4279 if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
4283 if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
4288 strcat(p[col], " ");
4290 for (i = 0; i < num; i++)
4292 if (p_ptr->magic_num2[spellnum[i]])
4295 /* Dump blue magic */
4296 l1 = strlen(p[col]);
4297 l2 = strlen(monster_powers_short[spellnum[i]]);
4298 if ((l1 + l2) >= 75)
4300 strcat(p[col], "\n");
4302 strcat(p[col], " ");
4304 strcat(p[col], monster_powers_short[spellnum[i]]);
4305 strcat(p[col], ", ");
4312 strcat(p[col], "¤Ê¤·");
4314 strcat(p[col], "None");
4319 if (p[col][strlen(p[col])-2] == ',')
4321 p[col][strlen(p[col])-2] = '\0';
4325 p[col][strlen(p[col])-10] = '\0';
4329 strcat(p[col], "\n");
4332 for (i=0;i<=col;i++)
4343 static void dump_aux_quest(FILE *fff)
4351 fprintf(fff, "\n\n [¥¯¥¨¥¹¥È¾ðÊó]\n");
4353 fprintf(fff, "\n\n [Quest Information]\n");
4356 /* Allocate Memory */
4357 C_MAKE(quest_num, max_quests, int);
4359 /* Sort by compete level */
4360 for (i = 1; i < max_quests; i++) quest_num[i] = i;
4361 ang_sort_comp = ang_sort_comp_quest_num;
4362 ang_sort_swap = ang_sort_swap_quest_num;
4363 ang_sort(quest_num, &dummy, max_quests);
4365 /* Dump Quest Information */
4367 do_cmd_knowledge_quests_completed(fff, quest_num);
4369 do_cmd_knowledge_quests_failed(fff, quest_num);
4373 C_KILL(quest_num, max_quests, int);
4380 static void dump_aux_last_message(FILE *fff)
4384 if (!p_ptr->total_winner)
4389 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4391 fprintf(fff, "\n [Last Messages]\n\n");
4393 for (i = MIN(message_num(), 30); i >= 0; i--)
4395 fprintf(fff,"> %s\n",message_str((s16b)i));
4400 /* Hack -- *Winning* message */
4401 else if (p_ptr->last_message)
4404 fprintf(fff, "\n [*¾¡Íø*¥á¥Ã¥»¡¼¥¸]\n\n");
4406 fprintf(fff, "\n [*Winning* Message]\n\n");
4408 fprintf(fff," %s\n", p_ptr->last_message);
4418 static void dump_aux_recall(FILE *fff)
4423 fprintf(fff, "\n [µ¢´Ô¾ì½ê]\n\n");
4425 fprintf(fff, "\n [Recall Depth]\n\n");
4428 for (y = 1; y < max_d_idx; y++)
4432 if (!d_info[y].maxdepth) continue;
4433 if (!max_dlv[y]) continue;
4434 if (d_info[y].final_guardian)
4436 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4438 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4441 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4443 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4452 static void dump_aux_options(FILE *fff)
4455 fprintf(fff, "\n [¥ª¥×¥·¥ç¥óÀßÄê]\n");
4457 fprintf(fff, "\n [Option Settings]\n");
4463 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4465 fprintf(fff, "\n Preserve Mode: ON");
4470 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4472 fprintf(fff, "\n Preserve Mode: OFF");
4476 if (ironman_small_levels)
4478 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4480 fprintf(fff, "\n Small Levels: ALWAYS");
4483 else if (always_small_levels)
4485 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4487 fprintf(fff, "\n Small Levels: ON");
4490 else if (small_levels)
4492 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4494 fprintf(fff, "\n Small Levels: ENABLED");
4499 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4501 fprintf(fff, "\n Small Levels: OFF");
4507 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4509 fprintf(fff, "\n Vanilla Town: ON");
4514 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4516 fprintf(fff, "\n Lite Town: ON");
4522 fprintf(fff, "\n Ź¤Ê¤·: ON");
4524 fprintf(fff, "\n No Shops: ON");
4528 if (ironman_downward)
4530 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4532 fprintf(fff, "\n Diving Only: ON");
4538 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°: ON");
4540 fprintf(fff, "\n Unusual Rooms: ON");
4544 if (ironman_nightmare)
4546 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4548 fprintf(fff, "\n Nightmare Mode: ON");
4552 if (ironman_empty_levels)
4554 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4556 fprintf(fff, "\n Arena Levels: ALWAYS");
4559 else if (empty_levels)
4561 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ENABLED");
4563 fprintf(fff, "\n Arena Levels: ENABLED");
4568 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4570 fprintf(fff, "\n Arena Levels: OFF");
4578 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤¤¤Þ¤¹¡£\n");
4580 fprintf(fff, "\n You have done something illegal.\n");
4590 static void dump_aux_arena(FILE *fff)
4592 if (lite_town || vanilla_town) return;
4594 if (p_ptr->arena_number < 0)
4596 if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
4599 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4601 fprintf(fff, "\n Arena: Defeated\n");
4607 fprintf(fff, "\n Æ®µ»¾ì: %d²óÀï¤Ç%s¤ÎÁ°¤ËÇÔËÌ\n", -p_ptr->arena_number,
4608 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
4610 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
4611 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
4612 -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
4616 else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
4619 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4621 fprintf(fff, "\n Arena: True Champion\n");
4624 else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
4627 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4629 fprintf(fff, "\n Arena: Champion\n");
4635 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4637 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");
4648 static void dump_aux_monsters(FILE *fff)
4650 /* Monsters slain */
4653 long uniq_total = 0;
4654 long norm_total = 0;
4657 /* Sort by monster level */
4661 fprintf(fff, "\n [Åݤ·¤¿¥â¥ó¥¹¥¿¡¼]\n\n");
4663 fprintf(fff, "\n [Defeated Monsters]\n\n");
4666 /* Allocate the "who" array */
4667 C_MAKE(who, max_r_idx, s16b);
4669 /* Count monster kills */
4670 for (k = 1; k < max_r_idx; k++)
4672 monster_race *r_ptr = &r_info[k];
4674 /* Ignore unused index */
4675 if (!r_ptr->name) continue;
4677 /* Unique monsters */
4678 if (r_ptr->flags1 & RF1_UNIQUE)
4680 bool dead = (r_ptr->max_num == 0);
4685 /* Add a unique monster to the list */
4686 who[uniq_total++] = k;
4690 /* Normal monsters */
4693 if (r_ptr->r_pkills > 0)
4695 norm_total += r_ptr->r_pkills;
4701 /* No monsters is defeated */
4705 fprintf(fff,"¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4707 fprintf(fff,"You have defeated no enemies yet.\n");
4711 /* Defeated more than one normal monsters */
4712 else if (uniq_total == 0)
4715 fprintf(fff,"%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", norm_total);
4717 fprintf(fff,"You have defeated %ld %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
4721 /* Defeated more than one unique monsters */
4722 else /* if (uniq_total > 0) */
4725 fprintf(fff, "%ldÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¤ò´Þ¤à¡¢¹ç·×%ldÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", uniq_total, norm_total);
4727 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"));
4731 /* Select the sort method */
4732 ang_sort_comp = ang_sort_comp_hook;
4733 ang_sort_swap = ang_sort_swap_hook;
4735 /* Sort the array by dungeon depth of monsters */
4736 ang_sort(who, &why, uniq_total);
4739 fprintf(fff, "\n¡Ô¾å°Ì%ldÂΤΥæ¥Ë¡¼¥¯¡¦¥â¥ó¥¹¥¿¡¼¡Õ\n", MIN(uniq_total, 10));
4741 fprintf(fff, "\n< Unique monsters top %ld >\n", MIN(uniq_total, 10));
4745 for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
4747 monster_race *r_ptr = &r_info[who[k]];
4750 fprintf(fff, " %-40s (¥ì¥Ù¥ë%3d)\n", (r_name + r_ptr->name), r_ptr->level);
4752 fprintf(fff, " %-40s (level %3d)\n", (r_name + r_ptr->name), r_ptr->level);
4758 /* Free the "who" array */
4759 C_KILL(who, max_r_idx, s16b);
4766 static void dump_aux_race_history(FILE *fff)
4768 if (p_ptr->old_race1 || p_ptr->old_race2)
4773 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4775 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4777 for (i = 0; i < MAX_RACES; i++)
4779 if (p_ptr->start_race == i) continue;
4782 if (!(p_ptr->old_race1 & 1L << i)) continue;
4786 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4789 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4791 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4803 static void dump_aux_realm_history(FILE *fff)
4805 if (p_ptr->old_realm)
4810 for (i = 0; i < MAX_MAGIC; i++)
4812 if (!(p_ptr->old_realm & 1L << i)) continue;
4814 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4816 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4827 static void dump_aux_virtues(FILE *fff)
4830 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4832 fprintf(fff, "\n\n [Virtues]\n\n");
4836 fprintf(fff, "°À : %s\n", your_alignment());
4838 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4849 static void dump_aux_mutations(FILE *fff)
4851 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4854 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4856 fprintf(fff, "\n\n [Mutations]\n\n");
4859 dump_mutations(fff);
4867 static void dump_aux_equipment_inventory(FILE *fff)
4870 char o_name[MAX_NLEN];
4872 /* Dump the equipment */
4876 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷]\n\n");
4878 fprintf(fff, " [Character Equipment]\n\n");
4881 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4883 object_desc(o_name, &inventory[i], 0);
4884 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
4886 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4888 strcpy(o_name, "(wielding with two-hands)");
4891 fprintf(fff, "%c) %s\n",
4892 index_to_label(i), o_name);
4894 fprintf(fff, "\n\n");
4897 /* Dump the inventory */
4899 fprintf(fff, " [¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ]\n\n");
4901 fprintf(fff, " [Character Inventory]\n\n");
4904 for (i = 0; i < INVEN_PACK; i++)
4906 /* Don't dump the empty slots */
4907 if (!inventory[i].k_idx) break;
4909 /* Dump the inventory slots */
4910 object_desc(o_name, &inventory[i], 0);
4911 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
4914 /* Add an empty line */
4915 fprintf(fff, "\n\n");
4922 static void dump_aux_home_museum(FILE *fff)
4924 char o_name[MAX_NLEN];
4927 /* Do we need it?? */
4928 /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
4930 /* Print the home */
4931 st_ptr = &town[1].store[STORE_HOME];
4933 /* Home -- if anything there */
4934 if (st_ptr->stock_num)
4940 fprintf(fff, " [²æ¤¬²È¤Î¥¢¥¤¥Æ¥à]\n");
4942 fprintf(fff, " [Home Inventory]\n");
4945 /* Dump all available items */
4946 for (i = 0; i < st_ptr->stock_num; i++)
4950 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4952 fprintf(fff, "\n ( page %d )\n", x++);
4954 object_desc(o_name, &st_ptr->stock[i], 0);
4955 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4958 /* Add an empty line */
4959 fprintf(fff, "\n\n");
4963 /* Print the home */
4964 st_ptr = &town[1].store[STORE_MUSEUM];
4966 /* Home -- if anything there */
4967 if (st_ptr->stock_num)
4973 fprintf(fff, " [Çîʪ´Û¤Î¥¢¥¤¥Æ¥à]\n");
4975 fprintf(fff, " [Museum]\n");
4978 /* Dump all available items */
4979 for (i = 0; i < st_ptr->stock_num; i++)
4982 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4983 object_desc(o_name, &st_ptr->stock[i], 0);
4984 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4986 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4987 object_desc(o_name, &st_ptr->stock[i], 0);
4988 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4993 /* Add an empty line */
4994 fprintf(fff, "\n\n");
5000 * Output the character dump to a file
5002 errr make_character_dump(FILE *fff)
5005 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
5006 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
5008 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
5009 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
5014 dump_aux_display_player(fff);
5015 dump_aux_last_message(fff);
5016 dump_aux_options(fff);
5017 dump_aux_recall(fff);
5018 dump_aux_quest(fff);
5019 dump_aux_arena(fff);
5020 dump_aux_monsters(fff);
5021 dump_aux_virtues(fff);
5022 dump_aux_race_history(fff);
5023 dump_aux_realm_history(fff);
5024 dump_aux_class_special(fff);
5025 dump_aux_mutations(fff);
5028 dump_aux_equipment_inventory(fff);
5029 dump_aux_home_museum(fff);
5032 fprintf(fff, " [¥Á¥§¥Ã¥¯¥µ¥à: \"%s\"]\n\n", get_check_sum());
5034 fprintf(fff, " [Check Sum: \"%s\"]\n\n", get_check_sum());
5041 * Hack -- Dump a character description file
5043 * XXX XXX XXX Allow the "full" flag to dump additional info,
5044 * and trigger its usage from various places in the code.
5046 errr file_character(cptr name)
5052 /* Build the filename */
5053 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
5055 /* File type is "TEXT" */
5056 FILE_TYPE(FILE_TYPE_TEXT);
5058 /* Check for existing file */
5059 fd = fd_open(buf, O_RDONLY);
5066 /* Close the file */
5071 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
5073 (void)sprintf(out_val, "Replace existing file %s? ", buf);
5078 if (get_check_strict(out_val, CHECK_NO_HISTORY)) fd = -1;
5081 /* Open the non-existing file */
5082 if (fd < 0) fff = my_fopen(buf, "w");
5089 prt("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª", 0, 0);
5091 prt("Character dump failed!", 0, 0);
5100 (void)make_character_dump(fff);
5108 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
5110 msg_print("Character dump successful.");
5121 * Display single line of on-line help file
5123 * You can insert some special color tag to change text color.
5125 * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
5127 * A colored segment is between "[[[[y|" and the last "|".
5128 * You can use any single character in place of the "|".
5130 static void show_file_aux_line(cptr str, int cy, cptr shower)
5132 static const char tag_str[] = "[[[[";
5133 byte color = TERM_WHITE;
5141 /* Make a lower case version of str for searching */
5146 /* Initial cursor position */
5147 Term_gotoxy(cx, cy);
5149 for (i = 0; str[i];)
5151 int len = strlen(&str[i]);
5152 int showercol = len + 1;
5153 int bracketcol = len + 1;
5157 /* Search for a shower string in the line */
5160 ptr = my_strstr(&lcstr[i], shower);
5161 if (ptr) showercol = ptr - &lcstr[i];
5164 /* Search for a color segment tag */
5165 ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
5166 if (ptr) bracketcol = ptr - &str[i];
5168 /* A color tag is found */
5169 if (bracketcol < endcol) endcol = bracketcol;
5171 /* The shower string is found before the color tag */
5172 if (showercol < endcol) endcol = showercol;
5174 /* Print a segment of the line */
5175 Term_addstr(endcol, color, &str[i]);
5179 /* Shower string? */
5180 if (endcol == showercol)
5182 int showerlen = strlen(shower);
5184 /* Print the shower string in yellow */
5185 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
5190 /* Colored segment? */
5191 else if (endcol == bracketcol)
5195 /* Found the end of colored segment */
5198 /* Now looking for an another tag_str */
5201 /* Set back to the default color */
5206 /* Found a tag_str, and get a tag color */
5207 i += sizeof(tag_str)-1;
5210 color = color_char_to_attr(str[i]);
5212 /* Illegal color tag */
5213 if (color == 255 || str[i+1] == '\0')
5215 /* Illegal color tag */
5218 /* Print the broken tag as a string */
5219 Term_addstr(-1, TERM_WHITE, tag_str);
5220 cx += sizeof(tag_str)-1;
5224 /* Skip the color tag */
5227 /* Now looking for a close tag */
5230 /* Skip the close-tag-indicator */
5236 } /* for (i = 0; str[i];) */
5238 /* Clear rest of line */
5239 Term_erase(cx, cy, 255);
5244 * Recursive file perusal.
5246 * Process various special text in the input file, including
5247 * the "menu" structures used by the "help file" system.
5249 * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
5251 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
5255 /* Number of "real" lines passed by */
5258 /* Number of "real" lines in the file */
5261 /* Backup value for "line" */
5264 /* This screen has sub-screens */
5267 /* Current help file */
5270 /* Find this string (if any) */
5273 /* Jump to this tag */
5276 /* Hold strings to find/show */
5277 char finder_str[81];
5278 char shower_str[81];
5280 /* String to show */
5284 char filename[1024];
5286 /* Describe this thing */
5292 /* General buffer */
5295 /* Sub-menu information */
5298 bool reverse = (line < 0);
5302 Term_get_size(&wid, &hgt);
5306 strcpy(finder_str, "");
5309 strcpy(shower_str, "");
5312 strcpy(caption, "");
5314 /* Wipe the hooks */
5315 for (i = 0; i < 68; i++)
5320 /* Copy the filename */
5321 strcpy(filename, name);
5323 n = strlen(filename);
5325 /* Extract the tag from the filename */
5326 for (i = 0; i < n; i++)
5328 if (filename[i] == '#')
5331 tag = filename + i + 1;
5336 /* Redirect the name */
5339 /* Hack XXX XXX XXX */
5343 strcpy(caption, what);
5345 /* Access the "file" */
5349 fff = my_fopen(path, "r");
5352 /* Look in "help" */
5357 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5359 sprintf(caption, "Help file '%s'", name);
5363 /* Build the filename */
5364 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5367 fff = my_fopen(path, "r");
5370 /* Look in "info" */
5375 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5377 sprintf(caption, "Info file '%s'", name);
5381 /* Build the filename */
5382 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5385 fff = my_fopen(path, "r");
5388 /* Look in "info" */
5391 /* Build the filename */
5392 path_build(path, sizeof(path), ANGBAND_DIR, name);
5394 for (i = 0; path[i]; i++)
5395 if ('\\' == path[i])
5396 path[i] = PATH_SEP[0];
5400 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5402 sprintf(caption, "Info file '%s'", name);
5406 fff = my_fopen(path, "r");
5414 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5416 msg_format("Cannot open '%s'.", name);
5426 /* Pre-Parse the file */
5431 /* Read a line or stop */
5432 if (my_fgets(fff, buf, sizeof(buf))) break;
5434 /* XXX Parse "menu" items */
5435 if (prefix(str, "***** "))
5437 /* Notice "menu" requests */
5438 if ((str[6] == '[') && isalpha(str[7]))
5440 /* Extract the menu item */
5441 int k = str[7] - 'A';
5443 /* This is a menu file */
5446 if ((str[8] == ']') && (str[9] == ' '))
5448 /* Extract the menu item */
5449 strncpy(hook[k], str + 10, 31);
5451 /* Make sure it's null-terminated */
5455 /* Notice "tag" requests */
5456 else if (str[6] == '<')
5458 size_t len = strlen(str);
5460 if (str[len - 1] == '>')
5462 str[len - 1] = '\0';
5463 if (tag && streq(str + 7, tag)) line = next;
5471 /* Count the "real" lines */
5475 /* Save the number of "real" lines */
5478 /* start from bottom when reverse mode */
5479 if (line == -1) line = ((size-1)/rows)*rows;
5484 /* Display the file */
5487 /* Restart when necessary */
5488 if (line >= size - rows) line = size - rows;
5489 if (line < 0) line = 0;
5491 /* Re-open the file if needed */
5497 /* Hack -- Re-Open the file */
5498 fff = my_fopen(path, "r");
5501 if (!fff) return (FALSE);
5503 /* File has been restarted */
5507 /* Goto the selected line */
5511 if (my_fgets(fff, buf, sizeof(buf))) break;
5513 /* Skip tags/links */
5514 if (prefix(buf, "***** ")) continue;
5516 /* Count the lines */
5520 /* Dump the next 20, or rows, lines of the file */
5521 for (i = 0; i < rows; )
5525 /* Hack -- track the "first" line */
5526 if (!i) line = next;
5528 /* Get a line of the file or stop */
5529 if (my_fgets(fff, buf, sizeof(buf))) break;
5531 /* Hack -- skip "special" lines */
5532 if (prefix(buf, "***** ")) continue;
5534 /* Count the "real" lines */
5537 /* Hack -- keep searching */
5542 /* Make a lower case version of str for searching */
5543 strcpy(lc_buf, str);
5544 str_tolower(lc_buf);
5546 if (!my_strstr(lc_buf, find)) continue;
5549 /* Hack -- stop searching */
5553 show_file_aux_line(str, i + 2, shower);
5555 /* Count the printed lines */
5561 /* Clear rest of line */
5562 Term_erase(0, i + 2, 255);
5567 /* Hack -- failed search */
5577 /* Show a general "title" */
5582 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5584 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5587 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5588 caption, line, size), 0, 0);
5598 caption, line, size), 0, 0);
5601 /* Prompt -- small files */
5606 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5608 prt("[Press ESC to exit.]", hgt - 1, 0);
5613 /* Prompt -- large files */
5618 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5620 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5622 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5626 /* Get a special key code */
5627 skey = inkey_special(TRUE);
5629 /* Show the help for the help */
5632 /* Hack - prevent silly recursion */
5634 if (strcmp(name, "jhelpinfo.txt") != 0)
5635 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5637 if (strcmp(name, "helpinfo.txt") != 0)
5638 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5642 /* Hack -- try showing */
5647 prt("¶¯Ä´: ", hgt - 1, 0);
5649 prt("Show: ", hgt - 1, 0);
5652 (void)askfor(shower_str, 80);
5654 /* Make it lowercase */
5655 str_tolower(shower_str);
5658 shower = shower_str;
5661 /* Hack -- try finding */
5662 if (skey == '/' || skey == KTRL('s'))
5666 prt("¸¡º÷: ", hgt - 1, 0);
5668 prt("Find: ", hgt - 1, 0);
5672 if (askfor(finder_str, 80))
5679 /* Make finder lowercase */
5680 str_tolower(finder_str);
5683 shower = finder_str;
5687 /* Hack -- go to a specific line */
5692 prt("¹Ô: ", hgt - 1, 0);
5694 prt("Goto Line: ", hgt - 1, 0);
5699 if (askfor(tmp, 80))
5705 /* Hack -- go to the top line */
5706 if (skey == SKEY_TOP)
5711 /* Hack -- go to the bottom line */
5712 if (skey == SKEY_BOTTOM)
5714 line = ((size-1)/rows)*rows;
5717 /* Hack -- go to a specific file */
5722 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5723 strcpy(tmp, "jhelp.hlp");
5725 prt("Goto File: ", hgt - 1, 0);
5726 strcpy(tmp, "help.hlp");
5730 if (askfor(tmp, 80))
5732 if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
5736 /* Allow backing up */
5739 line = line + (reverse ? rows : -rows);
5740 if (line < 0) line = 0;
5744 if (skey == SKEY_PGUP)
5747 if (line < 0) line = 0;
5750 /* Advance a single line */
5751 if ((skey == '\n') || (skey == '\r'))
5753 line = line + (reverse ? -1 : 1);
5754 if (line < 0) line = 0;
5758 /* Move up / down */
5759 if (skey == '8' || skey == SKEY_UP)
5762 if (line < 0) line = 0;
5765 if (skey == '2' || skey == SKEY_DOWN) line++;
5767 /* Advance one page */
5770 line = line + (reverse ? -rows : rows);
5771 if (line < 0) line = 0;
5775 if (skey == SKEY_PGDOWN)
5780 /* Recurse on numbers */
5785 if (!(skey & SKEY_MASK) && isalpha(skey))
5788 if ((key > -1) && hook[key][0])
5790 /* Recurse on that file */
5791 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5796 /* Hack, dump to file */
5806 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5808 if (!get_string("File name: ", xtmp, 80))
5817 /* Build the filename */
5818 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5820 /* Hack -- Re-Open the file */
5821 fff = my_fopen(path, "r");
5823 ffp = my_fopen(buff, "w");
5829 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5831 msg_print("Failed to open file.");
5838 sprintf(xtmp, "%s: %s", player_name, what ? what : caption);
5839 my_fputs(ffp, xtmp, 80);
5840 my_fputs(ffp, "\n", 80);
5842 while (!my_fgets(fff, buff, sizeof(buff)))
5843 my_fputs(ffp, buff, 80);
5849 /* Hack -- Re-Open the file */
5850 fff = my_fopen(path, "r");
5853 /* Return to last screen */
5854 if (skey == ESCAPE) break;
5855 if (skey == '<') break;
5857 /* Exit on the ^q */
5858 if (skey == KTRL('q')) skey = 'q';
5860 /* Exit on the q key */
5861 if (skey == 'q') break;
5864 /* Close the file */
5868 if (skey == 'q') return (FALSE);
5876 * Peruse the On-Line-Help
5878 void do_cmd_help(void)
5883 /* Peruse the main help file */
5885 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5887 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5897 * Process the player name.
5898 * Extract a clean "base name".
5899 * Build the savefile name if needed.
5901 void process_player_name(bool sf)
5904 char old_player_base[32] = "";
5906 if (character_generated) strcpy(old_player_base, player_base);
5908 /* Cannot be too long */
5909 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5911 if (strlen(player_name) > 8)
5913 if (strlen(player_name) > 15)
5918 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5920 quit_fmt("The name '%s' is too long!", player_name);
5926 /* Cannot contain "icky" characters */
5927 for (i = 0; player_name[i]; i++)
5929 /* No control characters */
5931 if (iskanji(player_name[i])){i++;continue;}
5932 if (iscntrl( (unsigned char)player_name[i]))
5934 if (iscntrl(player_name[i]))
5938 /* Illegal characters */
5940 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5942 quit_fmt("The name '%s' contains control chars!", player_name);
5951 /* Extract "useful" letters */
5952 for (i = 0; player_name[i]; i++)
5955 unsigned char c = player_name[i];
5957 char c = player_name[i];
5961 /* Convert "dot" to "underscore" */
5962 if (c == '.') c = '_';
5964 /* Accept all the letters */
5965 player_base[k++] = c;
5970 /* Extract "useful" letters */
5971 for (i = 0; player_name[i]; i++)
5974 unsigned char c = player_name[i];
5976 char c = player_name[i];
5979 /* Accept some letters */
5982 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5983 player_base[k++] = c;
5985 player_base[k++] = player_name[i];
5988 else if (iskana(c)) player_base[k++] = c;
5992 /* Convert path separator to underscore */
5993 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5994 player_base[k++] = '_';
5995 i += strlen(PATH_SEP);
5997 /* Convert some characters to underscore */
5999 else if (my_strchr(" \"*+,./:;<=>?[\\]|", c)) player_base[k++] = '_';
6000 #elif defined(WINDOWS)
6001 else if (my_strchr("\"*,/:;<>?\\|", c)) player_base[k++] = '_';
6003 else if (isprint(c)) player_base[k++] = c;
6011 /* Hack -- max length */
6017 player_base[k] = '\0';
6019 /* Require a "base" name */
6020 if (!player_base[0]) strcpy(player_base, "PLAYER");
6023 #ifdef SAVEFILE_MUTABLE
6029 if (!savefile_base[0] && savefile[0])
6036 t = my_strstr(s, PATH_SEP);
6041 strcpy(savefile_base, s);
6044 if (!savefile_base[0] || !savefile[0])
6047 /* Change the savefile name */
6052 strcpy(savefile_base, player_base);
6054 #ifdef SAVEFILE_USE_UID
6055 /* Rename the savefile, using the player_uid and player_base */
6056 (void)sprintf(temp, "%d.%s", player_uid, player_base);
6058 /* Rename the savefile, using the player_base */
6059 (void)sprintf(temp, "%s", player_base);
6063 /* Hack -- support "flat directory" usage on VM/ESA */
6064 (void)sprintf(temp, "%s.sv", player_base);
6067 /* Build the filename */
6068 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
6071 /* Load an autopick preference file */
6072 if (character_generated)
6074 if (!streq(old_player_base, player_base)) autopick_load_pref(FALSE);
6080 * Gets a name for the character, reacting to name changes.
6082 * Assumes that "display_player(0)" has just been called
6084 * Perhaps we should NOT ask for a name (at "birth()") on
6085 * Unix machines? XXX XXX
6087 * What a horrible name for a global function. XXX XXX XXX
6093 /* Save the player name */
6094 strcpy(tmp, player_name);
6096 /* Prompt for a new name */
6098 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
6100 if (get_string("Enter a name for your character: ", tmp, 15))
6104 strcpy(player_name, tmp);
6107 if (0 == strlen(player_name))
6109 /* Use default name */
6110 strcpy(player_name, "PLAYER");
6113 strcpy(tmp,ap_ptr->title);
6120 strcat(tmp,player_name);
6122 /* Re-Draw the name (in light blue) */
6123 Term_erase(34, 1, 255);
6124 c_put_str(TERM_L_BLUE, tmp, 1, 34);
6126 /* Erase the prompt, etc */
6133 * Hack -- commit suicide
6135 void do_cmd_suicide(void)
6142 /* Verify Retirement */
6143 if (p_ptr->total_winner)
6147 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
6149 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
6154 /* Verify Suicide */
6159 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
6161 if (!get_check("Do you really want to commit suicide? ")) return;
6166 if (!p_ptr->noscore)
6168 /* Special Verification for suicide */
6170 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
6172 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
6178 if (i != '@') return;
6181 /* Initialize "last message" buffer */
6182 if (p_ptr->last_message) string_free(p_ptr->last_message);
6183 p_ptr->last_message = NULL;
6185 /* Hack -- Note *winning* message */
6186 if (p_ptr->total_winner && last_words)
6188 char buf[1024] = "";
6193 while (!get_string("*¾¡Íø*¥á¥Ã¥»¡¼¥¸: ", buf, sizeof buf)) ;
6195 while (!get_string("*Winning* message: ", buf, sizeof buf)) ;
6199 while (!get_check_strict("¤è¤í¤·¤¤¤Ç¤¹¤«¡©", CHECK_NO_HISTORY));
6201 while (!get_check_strict("Are you sure? ", CHECK_NO_HISTORY));
6206 p_ptr->last_message = string_make(buf);
6207 msg_print(p_ptr->last_message);
6212 p_ptr->playing = FALSE;
6214 /* Kill the player */
6215 p_ptr->is_dead = TRUE;
6218 p_ptr->leaving = TRUE;
6220 if (!p_ptr->total_winner)
6223 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
6224 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
6226 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
6227 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
6229 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
6232 /* Cause of death */
6234 (void)strcpy(p_ptr->died_from, "ÅÓÃ潪λ");
6236 (void)strcpy(p_ptr->died_from, "Quitting");
6246 void do_cmd_save_game(int is_autosave)
6248 /* Autosaves do not disturb */
6252 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
6254 msg_print("Autosaving the game...");
6260 /* Disturb the player */
6264 /* Clear messages */
6272 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6274 prt("Saving game...", 0, 0);
6281 /* The player is not dead */
6283 (void)strcpy(p_ptr->died_from, "(¥»¡¼¥Ö)");
6285 (void)strcpy(p_ptr->died_from, "(saved)");
6289 /* Forbid suspend */
6290 signals_ignore_tstp();
6292 /* Save the player */
6296 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6298 prt("Saving game... done.", 0, 0);
6303 /* Save failed (oops) */
6307 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6309 prt("Saving game... failed!", 0, 0);
6314 /* Allow suspend again */
6315 signals_handle_tstp();
6320 /* Note that the player is not dead */
6322 (void)strcpy(p_ptr->died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6324 (void)strcpy(p_ptr->died_from, "(alive and well)");
6327 /* HACK -- don't get sanity blast on updating view */
6333 /* Initialize monster process */
6336 /* HACK -- reset the hackish flag */
6342 * Save the game and exit
6344 void do_cmd_save_and_exit(void)
6346 p_ptr->playing = FALSE;
6349 p_ptr->leaving = TRUE;
6351 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6353 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6359 * Hack -- Calculates the total number of points earned -JWT-
6361 long total_points(void)
6365 u32b point, point_h, point_l;
6366 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6368 if (!preserve_mode) mult += 10;
6369 if (!autoroller) mult += 10;
6370 if (!smart_learn) mult -= 20;
6371 if (smart_cheat) mult += 30;
6372 if (ironman_shops) mult += 50;
6373 if (ironman_small_levels) mult += 10;
6374 if (ironman_empty_levels) mult += 20;
6375 if (!powerup_home) mult += 50;
6376 if (ironman_rooms) mult += 100;
6377 if (ironman_nightmare) mult += 100;
6379 if (mult < 5) mult = 5;
6381 for (i = 0; i < max_d_idx; i++)
6382 if(max_dlv[i] > max_dl)
6383 max_dl = max_dlv[i];
6385 point_l = (p_ptr->max_max_exp + (100 * max_dl));
6386 point_h = point_l / 0x10000L;
6387 point_l = point_l % 0x10000L;
6390 point_h += point_l / 0x10000L;
6391 point_l %= 0x10000L;
6393 point_l += ((point_h % 100) << 16);
6397 point = (point_h << 16) + (point_l);
6398 if (p_ptr->arena_number >= 0)
6399 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6401 if (ironman_downward) point *= 2;
6402 if (p_ptr->pclass == CLASS_BERSERKER)
6404 if ( p_ptr->prace == RACE_SPECTRE )
6408 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6411 if (p_ptr->total_winner) point = 2;
6413 if (easy_band) point = (0 - point);
6419 #define GRAVE_LINE_WIDTH 31
6422 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
6424 static void center_string(char *buf, cptr str)
6431 /* Necessary border */
6432 j = GRAVE_LINE_WIDTH / 2 - i / 2;
6435 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
6441 * Save a "bones" file for a dead character
6443 * Note that we will not use these files until Angband 2.8.0, and
6444 * then we will only use the name and level on which death occured.
6446 * Should probably attempt some form of locking...
6448 static void make_bones(void)
6455 /* Ignore wizards and borgs */
6456 if (!(p_ptr->noscore & 0x00FF))
6458 /* Ignore people who die in town */
6463 /* XXX XXX XXX "Bones" name */
6464 sprintf(tmp, "bone.%03d", dun_level);
6466 /* Build the filename */
6467 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6469 /* Attempt to open the bones file */
6470 fp = my_fopen(str, "r");
6472 /* Close it right away */
6473 if (fp) my_fclose(fp);
6475 /* Do not over-write a previous ghost */
6478 /* File type is "TEXT" */
6479 FILE_TYPE(FILE_TYPE_TEXT);
6481 /* Grab permissions */
6484 /* Try to write a new "Bones File" */
6485 fp = my_fopen(str, "w");
6487 /* Drop permissions */
6490 /* Not allowed to write it? Weird. */
6494 fprintf(fp, "%s\n", player_name);
6495 fprintf(fp, "%d\n", p_ptr->mhp);
6496 fprintf(fp, "%d\n", p_ptr->prace);
6497 fprintf(fp, "%d\n", p_ptr->pclass);
6499 /* Close and save the Bones file */
6508 * Redefinable "print_tombstone" action
6510 bool (*tombstone_aux)(void) = NULL;
6514 * Display a "tomb-stone"
6516 static void print_tomb(void)
6520 /* Do we use a special tombstone ? */
6523 /* Use tombstone hook */
6524 done = (*tombstone_aux)();
6527 /* Print the text-tombstone */
6536 time_t ct = time((time_t)0);
6544 /* Build the filename */
6546 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead_j.txt");
6548 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead.txt");
6551 /* Open the News file */
6552 fp = my_fopen(buf, "r");
6559 /* Dump the file to the screen */
6560 while (0 == my_fgets(fp, buf, sizeof(buf)))
6562 /* Display and advance */
6563 put_str(buf, i++, 0);
6571 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6584 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6587 center_string(buf, player_name);
6588 put_str(buf, 6, 11);
6591 center_string(buf, "the");
6592 put_str(buf, 7, 11);
6595 center_string(buf, p);
6596 put_str(buf, 8, 11);
6598 center_string(buf, cp_ptr->title);
6599 put_str(buf, 10, 11);
6602 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6604 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6606 center_string(buf, tmp);
6607 put_str(buf, 11, 11);
6610 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6612 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6614 center_string(buf, tmp);
6615 put_str(buf, 12, 11);
6618 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6620 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6622 center_string(buf, tmp);
6623 put_str(buf, 13, 11);
6626 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6627 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6629 strcpy(tmp, "<¼«»¦>");
6631 else if (streq(p_ptr->died_from, "ripe"))
6633 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6635 else if (streq(p_ptr->died_from, "Seppuku"))
6637 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6641 roff_to_buf(p_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6642 t = tmp + strlen(tmp) + 1;
6645 strcpy(dummy, t); /* 2nd line */
6646 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6648 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
6651 else if (my_strstr(tmp, "¡Ø") && suffix(dummy, "¡Ù"))
6654 char *name_head = my_strstr(tmp, "¡Ø");
6655 sprintf(dummy2, "%s%s", name_head, dummy);
6656 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6658 strcpy(dummy, dummy2);
6662 else if (my_strstr(tmp, "¡Ö") && suffix(dummy, "¡×"))
6665 char *name_head = my_strstr(tmp, "¡Ö");
6666 sprintf(dummy2, "%s%s", name_head, dummy);
6667 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6669 strcpy(dummy, dummy2);
6673 center_string(buf, dummy);
6674 put_str(buf, 15, 11);
6678 center_string(buf, tmp);
6679 put_str(buf, 14, 11);
6681 if (!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6685 cptr town = p_ptr->town_num ? "³¹" : "¹ÓÌî";
6686 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6688 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6692 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6697 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6699 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6703 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6706 center_string(buf, tmp);
6707 put_str(buf, 15 + extra_line, 11);
6710 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6711 center_string(buf, tmp);
6712 put_str(buf, 14, 11);
6714 roff_to_buf(format("by %s.", p_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6715 center_string(buf, tmp);
6716 put_str(buf, 15, 11);
6717 t = tmp + strlen(tmp) + 1;
6720 strcpy(dummy, t); /* 2nd line */
6721 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6723 int dummy_len = strlen(dummy);
6724 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
6726 center_string(buf, dummy);
6727 put_str(buf, 16, 11);
6731 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6732 center_string(buf, tmp);
6733 put_str(buf, 17, 11);
6736 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6738 msg_format("Goodbye, %s!", player_name);
6745 * Display some character info
6747 static void show_info(void)
6753 /* Hack -- Know everything in the inven/equip */
6754 for (i = 0; i < INVEN_TOTAL; i++)
6756 o_ptr = &inventory[i];
6758 /* Skip non-objects */
6759 if (!o_ptr->k_idx) continue;
6761 /* Aware and Known */
6762 object_aware(o_ptr);
6763 object_known(o_ptr);
6766 for (i = 1; i < max_towns; i++)
6768 st_ptr = &town[i].store[STORE_HOME];
6770 /* Hack -- Know everything in the home */
6771 for (j = 0; j < st_ptr->stock_num; j++)
6773 o_ptr = &st_ptr->stock[j];
6775 /* Skip non-objects */
6776 if (!o_ptr->k_idx) continue;
6778 /* Aware and Known */
6779 object_aware(o_ptr);
6780 object_known(o_ptr);
6784 /* Hack -- Recalculate bonuses */
6785 p_ptr->update |= (PU_BONUS);
6790 /* Flush all input keys */
6793 /* Flush messages */
6797 /* Describe options */
6799 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6800 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6802 prt("You may now dump a character record to one or more files.", 21, 0);
6803 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6807 /* Dump character records as requested */
6814 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6816 put_str("Filename: ", 23, 0);
6821 strcpy(out_val, "");
6823 /* Ask for filename (or abort) */
6824 if (!askfor(out_val, 60)) return;
6826 /* Return means "show on screen" */
6827 if (!out_val[0]) break;
6832 /* Dump a character file */
6833 (void)file_character(out_val);
6841 /* Display player */
6844 /* Prompt for inventory */
6846 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6848 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6852 /* Allow abort at this point */
6853 if (inkey() == ESCAPE) return;
6856 /* Show equipment and inventory */
6858 /* Equipment -- if any */
6862 item_tester_full = TRUE;
6863 (void)show_equip(0);
6865 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6867 prt("You are using: -more-", 0, 0);
6870 if (inkey() == ESCAPE) return;
6873 /* Inventory -- if any */
6877 item_tester_full = TRUE;
6878 (void)show_inven(0);
6880 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6882 prt("You are carrying: -more-", 0, 0);
6885 if (inkey() == ESCAPE) return;
6888 /* Homes in the different towns */
6889 for (l = 1; l < max_towns; l++)
6891 st_ptr = &town[l].store[STORE_HOME];
6893 /* Home -- if anything there */
6894 if (st_ptr->stock_num)
6896 /* Display contents of the home */
6897 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6903 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6905 char o_name[MAX_NLEN];
6909 o_ptr = &st_ptr->stock[i];
6911 /* Print header, clear line */
6912 sprintf(tmp_val, "%c) ", I2A(j));
6913 prt(tmp_val, j+2, 4);
6915 /* Display object description */
6916 object_desc(o_name, o_ptr, 0);
6917 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6922 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6924 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6929 if (inkey() == ESCAPE) return;
6936 static bool check_score(void)
6942 if (highscore_fd < 0)
6945 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6947 msg_print("Score file unavailable.");
6954 #ifndef SCORE_WIZARDS
6955 /* Wizard-mode pre-empts scoring */
6956 if (p_ptr->noscore & 0x000F)
6959 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6961 msg_print("Score not registered for wizards.");
6970 /* Borg-mode pre-empts scoring */
6971 if (p_ptr->noscore & 0x00F0)
6974 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6976 msg_print("Score not registered for borgs.");
6984 #ifndef SCORE_CHEATERS
6985 /* Cheaters are not scored */
6986 if (p_ptr->noscore & 0xFF00)
6989 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6991 msg_print("Score not registered for cheaters.");
7001 if (!p_ptr->total_winner && streq(p_ptr->died_from, "¶¯À©½ªÎ»"))
7003 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Interrupting"))
7008 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
7010 msg_print("Score not registered due to interruption.");
7019 if (!p_ptr->total_winner && streq(p_ptr->died_from, "ÅÓÃ潪λ"))
7021 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Quitting"))
7026 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
7028 msg_print("Score not registered due to quitting.");
7038 * Close up the current game (player may or may not be dead)
7040 * This function is called only from "main.c" and "signals.c".
7042 void close_game(void)
7045 bool do_send = TRUE;
7047 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
7052 /* Flush the messages */
7055 /* Flush the input */
7059 /* No suspending now */
7060 signals_ignore_tstp();
7063 /* Hack -- Character is now "icky" */
7064 character_icky = TRUE;
7067 /* Build the filename */
7068 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
7070 /* Grab permissions */
7073 /* Open the high score file, for reading/writing */
7074 highscore_fd = fd_open(buf, O_RDWR);
7076 /* Drop permissions */
7082 /* Handle retirement */
7083 if (p_ptr->total_winner) kingly();
7087 if (!cheat_save || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
7089 if (!cheat_save || get_check("Save death? "))
7094 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7096 if (!save_player()) msg_print("death save failed!");
7099 else do_send = FALSE;
7106 /* Show more info */
7114 if ((!send_world_score(do_send)))
7117 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7119 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
7122 p_ptr->wait_report_score = TRUE;
7123 p_ptr->is_dead = FALSE;
7125 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
7127 if (!save_player()) msg_print("death save failed!");
7131 if (!p_ptr->wait_report_score)
7134 else if (highscore_fd >= 0)
7136 display_scores_aux(0, 10, -1, NULL);
7139 /* Dump bones file */
7148 do_cmd_save_game(FALSE);
7150 /* Prompt for scores XXX XXX XXX */
7152 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
7154 prt("Press Return (or Escape).", 0, 40);
7158 /* Predict score (or ESCAPE) */
7159 if (inkey() != ESCAPE) predict_score();
7163 /* Shut the high score file */
7164 (void)fd_close(highscore_fd);
7166 /* Forget the high score fd */
7169 /* Kill all temporal files */
7170 clear_saved_floor_files();
7172 /* Allow suspending now */
7173 signals_handle_tstp();
7178 * Handle abrupt death of the visual system
7180 * This routine is called only in very rare situations, and only
7181 * by certain visual systems, when they experience fatal errors.
7183 * XXX XXX Hack -- clear the death flag when creating a HANGUP
7184 * save file so that player can see tombstone when restart.
7186 void exit_game_panic(void)
7188 /* If nothing important has happened, just quit */
7190 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
7192 if (!character_generated || character_saved) quit("panic");
7195 /* Mega-Hack -- see "msg_print()" */
7198 /* Clear the top line */
7201 /* Hack -- turn off some things */
7204 /* Mega-Hack -- Delay death */
7205 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
7207 /* Hardcode panic save */
7208 p_ptr->panic_save = 1;
7210 /* Forbid suspend */
7211 signals_ignore_tstp();
7213 /* Indicate panic save */
7215 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7217 (void)strcpy(p_ptr->died_from, "(panic save)");
7221 /* Panic save, or get worried */
7223 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7225 if (!save_player()) quit("panic save failed!");
7229 /* Successful panic save */
7231 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7233 quit("panic save succeeded!");
7239 * Get a random line from a file
7240 * Based on the monster speech patch by Matt Graham,
7242 errr get_rnd_line(cptr file_name, int entry, char *output)
7250 /* Build the filename */
7251 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
7254 fp = my_fopen(buf, "r");
7259 /* Find the entry of the monster */
7262 /* Get a line from the file */
7263 if (my_fgets(fp, buf, sizeof(buf)) == 0)
7265 /* Count the lines */
7268 /* Look for lines starting with 'N:' */
7269 if ((buf[0] == 'N') && (buf[1] == ':'))
7271 /* Allow default lines */
7277 else if (buf[2] == 'M')
7279 if (r_info[entry].flags1 & RF1_MALE) break;
7281 else if (buf[2] == 'F')
7283 if (r_info[entry].flags1 & RF1_FEMALE) break;
7285 /* Get the monster number */
7286 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7288 /* Is it the right number? */
7289 if (test == entry) break;
7293 /* Error while converting the number */
7294 msg_format("Error in line %d of %s!", line_num, file_name);
7302 /* Reached end of file */
7308 /* Get the random line */
7309 for (counter = 0; ; counter++)
7313 test = my_fgets(fp, buf, sizeof(buf));
7315 /* Count the lines */
7316 /* line_num++; No more needed */
7320 /* Ignore lines starting with 'N:' */
7321 if ((buf[0] == 'N') && (buf[1] == ':')) continue;
7323 if (buf[0] != '#') break;
7332 if (one_in_(counter + 1)) strcpy(output, buf);
7335 /* Close the file */
7339 return counter ? 0 : -1;
7344 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7349 for (i = 0; i < count; i++)
7351 result = get_rnd_line(file_name, entry, output);
7354 for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
7362 * Process file for auto picker/destroyer.
7364 errr process_autopick_file(cptr name)
7370 /* Build the filename */
7371 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7373 err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
7381 * Process file for player's history editor.
7383 errr process_histpref_file(cptr name)
7387 bool old_character_xtra = character_xtra;
7389 /* Build the filename */
7390 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7392 /* Hack -- prevent modification birth options in this file */
7393 character_xtra = TRUE;
7395 err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
7397 character_xtra = old_character_xtra;
7404 static errr counts_seek(int fd, u32b where, bool flag)
7407 char temp1[128], temp2[128];
7408 u32b zero_header[3] = {0L, 0L, 0L};
7411 #ifdef SAVEFILE_USE_UID
7412 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7414 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7416 for (i = 0; temp1[i]; i++)
7417 temp1[i] ^= (i+1) * 63;
7422 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7424 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7429 fd_seek(fd, seekpoint);
7430 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7431 fd_write(fd, (char*)(temp1), sizeof(temp1));
7435 if (strcmp(temp1, temp2) == 0)
7438 seekpoint += 128 + 3 * sizeof(u32b);
7441 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7444 u32b counts_read(int where)
7451 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7453 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7455 fd = fd_open(buf, O_RDONLY);
7457 if (counts_seek(fd, where, FALSE) ||
7458 fd_read(fd, (char*)(&count), sizeof(u32b)))
7466 errr counts_write(int where, u32b count)
7473 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7475 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7478 /* Grab permissions */
7481 fd = fd_open(buf, O_RDWR);
7483 /* Drop permissions */
7488 /* File type is "DATA" */
7489 FILE_TYPE(FILE_TYPE_DATA);
7491 /* Grab permissions */
7494 /* Create a new high score file */
7495 fd = fd_make(buf, 0644);
7497 /* Drop permissions */
7501 /* Grab permissions */
7504 err = fd_lock(fd, F_WRLCK);
7506 /* Drop permissions */
7511 counts_seek(fd, where, TRUE);
7512 fd_write(fd, (char*)(&count), sizeof(u32b));
7514 /* Grab permissions */
7517 err = fd_lock(fd, F_UNLCK);
7519 /* Drop permissions */
7530 #ifdef HANDLE_SIGNALS
7537 * Handle signals -- suspend
7539 * Actually suspend the game, and then resume cleanly
7541 static void handle_signal_suspend(int sig)
7543 /* Disable handler */
7544 (void)signal(sig, SIG_IGN);
7551 /* Suspend the "Term" */
7552 Term_xtra(TERM_XTRA_ALIVE, 0);
7554 /* Suspend ourself */
7555 (void)kill(0, SIGSTOP);
7557 /* Resume the "Term" */
7558 Term_xtra(TERM_XTRA_ALIVE, 1);
7560 /* Redraw the term */
7563 /* Flush the term */
7568 /* Restore handler */
7569 (void)signal(sig, handle_signal_suspend);
7574 * Handle signals -- simple (interrupt and quit)
7576 * This function was causing a *huge* number of problems, so it has
7577 * been simplified greatly. We keep a global variable which counts
7578 * the number of times the user attempts to kill the process, and
7579 * we commit suicide if the user does this a certain number of times.
7581 * We attempt to give "feedback" to the user as he approaches the
7582 * suicide thresh-hold, but without penalizing accidental keypresses.
7584 * To prevent messy accidents, we should reset this global variable
7585 * whenever the user enters a keypress, or something like that.
7587 static void handle_signal_simple(int sig)
7589 /* Disable handler */
7590 (void)signal(sig, SIG_IGN);
7593 /* Nothing to save, just quit */
7594 if (!character_generated || character_saved) quit(NULL);
7597 /* Count the signals */
7601 /* Terminate dead characters */
7604 /* Mark the savefile */
7606 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»");
7608 (void)strcpy(p_ptr->died_from, "Abortion");
7627 /* Allow suicide (after 5) */
7628 else if (signal_count >= 5)
7630 /* Cause of "death" */
7632 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»Ãæ");
7634 (void)strcpy(p_ptr->died_from, "Interrupting");
7643 p_ptr->playing = FALSE;
7646 p_ptr->is_dead = TRUE;
7649 p_ptr->leaving = TRUE;
7663 /* Give warning (after 4) */
7664 else if (signal_count >= 4)
7667 Term_xtra(TERM_XTRA_NOISE, 0);
7669 /* Clear the top line */
7670 Term_erase(0, 0, 255);
7672 /* Display the cause */
7674 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7676 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7684 /* Give warning (after 2) */
7685 else if (signal_count >= 2)
7688 Term_xtra(TERM_XTRA_NOISE, 0);
7691 /* Restore handler */
7692 (void)signal(sig, handle_signal_simple);
7697 * Handle signal -- abort, kill, etc
7699 static void handle_signal_abort(int sig)
7703 Term_get_size(&wid, &hgt);
7705 /* Disable handler */
7706 (void)signal(sig, SIG_IGN);
7709 /* Nothing to save, just quit */
7710 if (!character_generated || character_saved) quit(NULL);
7717 /* Clear the bottom line */
7718 Term_erase(0, hgt - 1, 255);
7720 /* Give a warning */
7721 Term_putstr(0, hgt - 1, -1, TERM_RED,
7723 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7725 "A gruesome software bug LEAPS out at you!");
7731 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7733 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7738 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥à°Û¾ï½ªÎ»----");
7740 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Panic Save and Abort Game ----");
7747 p_ptr->panic_save = 1;
7751 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7753 (void)strcpy(p_ptr->died_from, "(panic save)");
7757 /* Forbid suspend */
7758 signals_ignore_tstp();
7760 /* Attempt to save */
7764 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7766 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7775 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7777 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7787 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7789 quit("software bug");
7798 * Ignore SIGTSTP signals (keyboard suspend)
7800 void signals_ignore_tstp(void)
7804 (void)signal(SIGTSTP, SIG_IGN);
7810 * Handle SIGTSTP signals (keyboard suspend)
7812 void signals_handle_tstp(void)
7816 (void)signal(SIGTSTP, handle_signal_suspend);
7823 * Prepare to handle the relevant signals
7825 void signals_init(void)
7829 (void)signal(SIGHUP, SIG_IGN);
7834 (void)signal(SIGTSTP, handle_signal_suspend);
7839 (void)signal(SIGINT, handle_signal_simple);
7843 (void)signal(SIGQUIT, handle_signal_simple);
7848 (void)signal(SIGFPE, handle_signal_abort);
7852 (void)signal(SIGILL, handle_signal_abort);
7856 (void)signal(SIGTRAP, handle_signal_abort);
7860 (void)signal(SIGIOT, handle_signal_abort);
7864 (void)signal(SIGKILL, handle_signal_abort);
7868 (void)signal(SIGBUS, handle_signal_abort);
7872 (void)signal(SIGSEGV, handle_signal_abort);
7876 (void)signal(SIGTERM, handle_signal_abort);
7880 (void)signal(SIGPIPE, handle_signal_abort);
7884 (void)signal(SIGEMT, handle_signal_abort);
7888 (void)signal(SIGDANGER, handle_signal_abort);
7892 (void)signal(SIGSYS, handle_signal_abort);
7896 (void)signal(SIGXCPU, handle_signal_abort);
7900 (void)signal(SIGPWR, handle_signal_abort);
7906 #else /* HANDLE_SIGNALS */
7912 void signals_ignore_tstp(void)
7919 void signals_handle_tstp(void)
7926 void signals_init(void)
7929 #endif /* HANDLE_SIGNALS */