3 /* Purpose: code dealing with files (and death) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
17 * You may or may not want to use the following "#undef".
19 /* #undef _POSIX_SAVED_IDS */
23 * Hack -- drop permissions
25 void safe_setuid_drop(void)
32 # ifdef SAFE_SETUID_POSIX
34 if (setuid(getuid()) != 0)
37 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
39 quit("setuid(): cannot set permissions correctly!");
43 if (setgid(getgid()) != 0)
46 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
48 quit("setgid(): cannot set permissions correctly!");
55 if (setreuid(geteuid(), getuid()) != 0)
58 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
60 quit("setreuid(): cannot set permissions correctly!");
64 if (setregid(getegid(), getgid()) != 0)
67 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
69 quit("setregid(): cannot set permissions correctly!");
84 * Hack -- grab permissions
86 void safe_setuid_grab(void)
93 # ifdef SAFE_SETUID_POSIX
95 if (setuid(player_euid) != 0)
98 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
100 quit("setuid(): cannot set permissions correctly!");
104 if (setgid(player_egid) != 0)
107 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
109 quit("setgid(): cannot set permissions correctly!");
116 if (setreuid(geteuid(), getuid()) != 0)
119 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
121 quit("setreuid(): cannot set permissions correctly!");
125 if (setregid(getegid(), getgid()) != 0)
128 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
130 quit("setregid(): cannot set permissions correctly!");
135 # endif /* SAFE_SETUID_POSIX */
137 # endif /* SAFE_SETUID */
145 * Extract the first few "tokens" from a buffer
147 * This function uses "colon" and "slash" as the delimeter characters.
149 * We never extract more than "num" tokens. The "last" token may include
150 * "delimeter" characters, allowing the buffer to include a "string" token.
152 * We save pointers to the tokens in "tokens", and return the number found.
154 * Hack -- Attempt to handle the 'c' character formalism
156 * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
158 * Hack -- We will always extract at least one token
160 s16b tokenize(char *buf, s16b num, char **tokens, int mode)
172 /* Scan the string */
175 /* Found a delimiter */
176 if ((*t == ':') || (*t == '/')) break;
178 /* Handle single quotes */
179 if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
184 /* Handle backslash */
187 /* Require a character */
193 /* Hack -- Require a close quote */
194 if (*t != '\'') *t = '\'';
197 /* Handle back-slash */
204 /* Nuke and advance */
222 /* A number with a name */
223 typedef struct named_num named_num;
227 cptr name; /* The name of this thing */
228 int num; /* A number associated with it */
232 /* Index of spell type names */
233 static named_num gf_desc[] =
235 {"GF_ELEC", GF_ELEC },
236 {"GF_POIS", GF_POIS },
237 {"GF_ACID", GF_ACID },
238 {"GF_COLD", GF_COLD },
239 {"GF_FIRE", GF_FIRE },
240 {"GF_PSY_SPEAR", GF_PSY_SPEAR },
241 {"GF_MISSILE", GF_MISSILE },
242 {"GF_ARROW", GF_ARROW },
243 {"GF_PLASMA", GF_PLASMA },
244 {"GF_WATER", GF_WATER },
245 {"GF_LITE", GF_LITE },
246 {"GF_DARK", GF_DARK },
247 {"GF_LITE_WEAK", GF_LITE_WEAK },
248 {"GF_DARK_WEAK", GF_DARK_WEAK },
249 {"GF_SHARDS", GF_SHARDS },
250 {"GF_SOUND", GF_SOUND },
251 {"GF_CONFUSION", GF_CONFUSION },
252 {"GF_FORCE", GF_FORCE },
253 {"GF_INERTIA", GF_INERTIA },
254 {"GF_MANA", GF_MANA },
255 {"GF_METEOR", GF_METEOR },
257 {"GF_CHAOS", GF_CHAOS },
258 {"GF_NETHER", GF_NETHER },
259 {"GF_DISENCHANT", GF_DISENCHANT },
260 {"GF_NEXUS", GF_NEXUS },
261 {"GF_TIME", GF_TIME },
262 {"GF_GRAVITY", GF_GRAVITY },
263 {"GF_KILL_WALL", GF_KILL_WALL },
264 {"GF_KILL_DOOR", GF_KILL_DOOR },
265 {"GF_KILL_TRAP", GF_KILL_TRAP },
266 {"GF_MAKE_WALL", GF_MAKE_WALL },
267 {"GF_MAKE_DOOR", GF_MAKE_DOOR },
268 {"GF_MAKE_TRAP", GF_MAKE_TRAP },
269 {"GF_MAKE_TREE", GF_MAKE_TREE },
270 {"GF_OLD_CLONE", GF_OLD_CLONE },
271 {"GF_OLD_POLY", GF_OLD_POLY },
272 {"GF_OLD_HEAL", GF_OLD_HEAL },
273 {"GF_OLD_SPEED", GF_OLD_SPEED },
274 {"GF_OLD_SLOW", GF_OLD_SLOW },
275 {"GF_OLD_CONF", GF_OLD_CONF },
276 {"GF_OLD_SLEEP", GF_OLD_SLEEP },
277 {"GF_OLD_DRAIN", GF_OLD_DRAIN },
278 {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD },
279 {"GF_AWAY_EVIL", GF_AWAY_EVIL },
280 {"GF_AWAY_ALL", GF_AWAY_ALL },
281 {"GF_TURN_UNDEAD", GF_TURN_UNDEAD },
282 {"GF_TURN_EVIL", GF_TURN_EVIL },
283 {"GF_TURN_ALL", GF_TURN_ALL },
284 {"GF_DISP_UNDEAD", GF_DISP_UNDEAD },
285 {"GF_DISP_EVIL", GF_DISP_EVIL },
286 {"GF_DISP_ALL", GF_DISP_ALL },
287 {"GF_DISP_DEMON", GF_DISP_DEMON },
288 {"GF_DISP_LIVING", GF_DISP_LIVING },
289 {"GF_ROCKET", GF_ROCKET },
290 {"GF_NUKE", GF_NUKE },
291 {"GF_MAKE_GLYPH", GF_MAKE_GLYPH },
292 {"GF_STASIS", GF_STASIS },
293 {"GF_STONE_WALL", GF_STONE_WALL },
294 {"GF_DEATH_RAY", GF_DEATH_RAY },
295 {"GF_STUN", GF_STUN },
296 {"GF_HOLY_FIRE", GF_HOLY_FIRE },
297 {"GF_HELL_FIRE", GF_HELL_FIRE },
298 {"GF_DISINTEGRATE", GF_DISINTEGRATE },
299 {"GF_CHARM", GF_CHARM },
300 {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD },
301 {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL },
303 {"GF_PSI_DRAIN", GF_PSI_DRAIN },
304 {"GF_TELEKINESIS", GF_TELEKINESIS },
305 {"GF_JAM_DOOR", GF_JAM_DOOR },
306 {"GF_DOMINATION", GF_DOMINATION },
307 {"GF_DISP_GOOD", GF_DISP_GOOD },
308 {"GF_DRAIN_MANA", GF_DRAIN_MANA },
309 {"GF_MIND_BLAST", GF_MIND_BLAST },
310 {"GF_BRAIN_SMASH", GF_BRAIN_SMASH },
311 {"GF_CAUSE_1", GF_CAUSE_1 },
312 {"GF_CAUSE_2", GF_CAUSE_2 },
313 {"GF_CAUSE_3", GF_CAUSE_3 },
314 {"GF_CAUSE_4", GF_CAUSE_4 },
315 {"GF_HAND_DOOM", GF_HAND_DOOM },
316 {"GF_CAPTURE", GF_CAPTURE },
317 {"GF_ANIM_DEAD", GF_ANIM_DEAD },
318 {"GF_CONTROL_LIVING", GF_CONTROL_LIVING },
319 {"GF_IDENTIFY", GF_IDENTIFY },
320 {"GF_ATTACK", GF_ATTACK },
321 {"GF_ENGETSU", GF_ENGETSU },
322 {"GF_GENOCIDE", GF_GENOCIDE },
323 {"GF_PHOTO", GF_PHOTO },
324 {"GF_CONTROL_DEMON", GF_CONTROL_DEMON },
325 {"GF_LAVA_FLOW", GF_LAVA_FLOW },
326 {"GF_BLOOD_CURSE", GF_BLOOD_CURSE },
327 {"GF_SEEKER", GF_SEEKER },
328 {"GF_SUPER_RAY", GF_SUPER_RAY },
329 {"GF_STAR_HEAL", GF_STAR_HEAL },
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);
418 /* Process "%:<fname>" */
421 /* Attempt to Process the given file */
422 return (process_pref_file(buf + 2));
426 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
429 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
432 i = (huge)strtol(zz[0], NULL, 0);
433 n1 = strtol(zz[1], NULL, 0);
434 n2 = strtol(zz[2], NULL, 0);
435 if (i >= max_r_idx) return (1);
437 if (n1) r_ptr->x_attr = n1;
438 if (n2) r_ptr->x_char = n2;
443 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
444 else if (buf[0] == 'K')
446 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
449 i = (huge)strtol(zz[0], NULL, 0);
450 n1 = strtol(zz[1], NULL, 0);
451 n2 = strtol(zz[2], NULL, 0);
452 if (i >= max_k_idx) return (1);
454 if (n1) k_ptr->x_attr = n1;
455 if (n2) k_ptr->x_char = n2;
460 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
461 else if (buf[0] == 'F')
463 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
466 i = (huge)strtol(zz[0], NULL, 0);
467 n1 = strtol(zz[1], NULL, 0);
468 n2 = strtol(zz[2], NULL, 0);
469 if (i >= max_f_idx) return (1);
471 if (n1) f_ptr->x_attr = n1;
472 if (n2) f_ptr->x_char = n2;
477 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
478 else if (buf[0] == 'S')
480 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
482 j = (byte)strtol(zz[0], NULL, 0);
483 n1 = strtol(zz[1], NULL, 0);
484 n2 = strtol(zz[2], NULL, 0);
485 misc_to_attr[j] = n1;
486 misc_to_char[j] = n2;
491 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
492 else if (buf[0] == 'U')
494 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
496 j = (huge)strtol(zz[0], NULL, 0);
497 n1 = strtol(zz[1], NULL, 0);
498 n2 = strtol(zz[2], NULL, 0);
499 for (i = 1; i < max_k_idx; i++)
501 object_kind *k_ptr = &k_info[i];
502 if (k_ptr->tval == j)
504 if (n1) k_ptr->d_attr = n1;
505 if (n2) k_ptr->d_char = n2;
512 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
513 else if (buf[0] == 'E')
515 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
517 j = (byte)strtol(zz[0], NULL, 0) % 128;
518 n1 = strtol(zz[1], NULL, 0);
519 if (n1) tval_to_attr[j] = n1;
525 /* Process "A:<str>" -- save an "action" for later */
526 else if (buf[0] == 'A')
528 text_to_ascii(macro__buf, buf+2);
532 /* Process "P:<str>" -- normal macro */
533 else if (buf[0] == 'P')
536 text_to_ascii(tmp, buf+2);
537 macro_add(tmp, macro__buf);
542 /* Process "C:<str>" -- create keymap */
543 else if (buf[0] == 'C')
549 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return (1);
551 mode = strtol(zz[0], NULL, 0);
552 if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1);
554 text_to_ascii(tmp, zz[1]);
555 if (!tmp[0] || tmp[1]) return (1);
558 string_free(keymap_act[mode][i]);
560 keymap_act[mode][i] = string_make(macro__buf);
566 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
567 else if (buf[0] == 'V')
569 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
571 i = (byte)strtol(zz[0], NULL, 0);
572 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
573 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
574 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
575 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
581 /* Process "X:<str>" -- turn option off */
582 else if (buf[0] == 'X')
584 for (i = 0; option_info[i].o_desc; i++)
586 int os = option_info[i].o_set;
587 int ob = option_info[i].o_bit;
589 if (option_info[i].o_var &&
590 option_info[i].o_text &&
591 streq(option_info[i].o_text, buf + 2))
593 if (p_ptr->playing && 6 == option_info[i].o_page && !p_ptr->wizard)
596 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
598 msg_format("Startup options can not changed! '%s'", buf);
605 option_flag[os] &= ~(1L << ob);
606 (*option_info[i].o_var) = FALSE;
611 /* don't know that option. ignore it.*/
613 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
615 msg_format("Ignored invalid option: %s", buf);
621 /* Process "Y:<str>" -- turn option on */
622 else if (buf[0] == 'Y')
624 for (i = 0; option_info[i].o_desc; i++)
626 int os = option_info[i].o_set;
627 int ob = option_info[i].o_bit;
629 if (option_info[i].o_var &&
630 option_info[i].o_text &&
631 streq(option_info[i].o_text, buf + 2))
633 if (p_ptr->playing && 6 == option_info[i].o_page && !p_ptr->wizard)
636 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
638 msg_format("Startup options can not changed! '%s'", buf);
645 option_flag[os] |= (1L << ob);
646 (*option_info[i].o_var) = TRUE;
651 /* don't know that option. ignore it.*/
653 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
655 msg_format("Ignored invalid option: %s", buf);
661 /* Process "Z:<type>:<str>" -- set spell color */
662 else if (buf[0] == 'Z')
665 char *t = strchr(buf + 2, ':');
673 for (i = 0; gf_desc[i].name; i++)
675 /* Match this type */
676 if (streq(gf_desc[i].name, buf + 2))
678 /* Remember this color set */
679 gf_color[gf_desc[i].num] = quark_add(t);
686 /* set macro trigger names and a template */
687 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
688 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
689 else if (buf[0] == 'T')
692 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
698 if (macro_template != NULL)
700 free(macro_template);
701 macro_template = NULL;
702 for (i = 0; i < max_macrotrigger; i++)
703 free(macro_trigger_name[i]);
704 max_macrotrigger = 0;
707 if (*zz[0] == '\0') return 0; /* clear template */
709 if (2 + num != tok) return 1; /* error */
711 len = strlen(zz[0])+1+num+1;
712 for (i = 0; i < num; i++)
713 len += strlen(zz[2+i])+1;
714 macro_template = malloc(len);
716 strcpy(macro_template, zz[0]);
718 macro_template + strlen(macro_template) + 1;
719 strcpy(macro_modifier_chr, zz[1]);
720 macro_modifier_name[0] =
721 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
722 for (i = 0; i < num; i++)
724 strcpy(macro_modifier_name[i], zz[2+i]);
725 macro_modifier_name[i+1] = macro_modifier_name[i] +
726 strlen(macro_modifier_name[i]) + 1;
733 if (max_macrotrigger >= MAX_MACRO_TRIG)
736 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
738 msg_print("Too many macro triggers!");
742 m = max_macrotrigger;
745 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
747 len += strlen(zz[2]) + 1;
748 macro_trigger_name[m] = malloc(len);
750 t = macro_trigger_name[m];
759 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
760 strlen(macro_trigger_name[m]) + 1;
761 strcpy(macro_trigger_keycode[0][m], zz[1]);
764 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
765 strlen(macro_trigger_keycode[0][m]) + 1;
766 strcpy(macro_trigger_keycode[1][m], zz[2]);
770 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
782 * Helper function for "process_pref_file()"
785 * v: output buffer array
791 static cptr process_pref_file_expr(char **sp, char *fp)
808 while (isspace(*s)) s++;
826 t = process_pref_file_expr(&s, &f);
835 else if (streq(t, "IOR"))
838 while (*s && (f != b2))
840 t = process_pref_file_expr(&s, &f);
841 if (*t && !streq(t, "0")) v = "1";
846 else if (streq(t, "AND"))
849 while (*s && (f != b2))
851 t = process_pref_file_expr(&s, &f);
852 if (*t && streq(t, "0")) v = "0";
857 else if (streq(t, "NOT"))
860 while (*s && (f != b2))
862 t = process_pref_file_expr(&s, &f);
863 if (*t && streq(t, "1")) v = "0";
868 else if (streq(t, "EQU"))
873 t = process_pref_file_expr(&s, &f);
875 while (*s && (f != b2))
878 t = process_pref_file_expr(&s, &f);
879 if (*t && !streq(p, t)) v = "0";
884 else if (streq(t, "LEQ"))
889 t = process_pref_file_expr(&s, &f);
891 while (*s && (f != b2))
894 t = process_pref_file_expr(&s, &f);
895 if (*t && (strcmp(p, t) > 0)) v = "0";
900 else if (streq(t, "GEQ"))
905 t = process_pref_file_expr(&s, &f);
907 while (*s && (f != b2))
910 t = process_pref_file_expr(&s, &f);
911 if (*t && (strcmp(p, t) < 0)) v = "0";
918 while (*s && (f != b2))
920 t = process_pref_file_expr(&s, &f);
925 if (f != b2) v = "?x?x?";
927 /* Extract final and Terminate */
928 if ((f = *s) != '\0') *s++ = '\0';
934 /* Accept all printables except spaces and brackets */
935 while (isprint(*s) && !strchr(" []", *s)) ++s;
937 /* Extract final and Terminate */
938 if ((f = *s) != '\0') *s++ = '\0';
944 if (streq(b+1, "SYS"))
949 else if (streq(b+1, "KEYBOARD"))
951 v = ANGBAND_KEYBOARD;
955 else if (streq(b+1, "GRAF"))
960 /* Monochrome mode */
961 else if (streq(b+1, "MONOCHROME"))
970 else if (streq(b+1, "RACE"))
980 else if (streq(b+1, "CLASS"))
990 else if (streq(b+1, "PLAYER"))
996 else if (streq(b+1, "REALM1"))
999 v = E_realm_names[p_ptr->realm1];
1001 v = realm_names[p_ptr->realm1];
1006 else if (streq(b+1, "REALM2"))
1009 v = E_realm_names[p_ptr->realm2];
1011 v = realm_names[p_ptr->realm2];
1016 else if (streq(b+1, "LEVEL"))
1018 sprintf(tmp, "%02d", p_ptr->lev);
1043 * Process line for auto picker/destroyer.
1045 static errr process_pickpref_file_line(char *buf)
1047 autopick_type entry;
1050 if (max_autopick == MAX_AUTOPICK)
1053 /* Nuke illegal char */
1054 for(i = 0; buf[i]; i++)
1057 if (iskanji(buf[i]))
1063 if (isspace(buf[i]) && buf[i] != ' ')
1068 if (!autopick_new_entry(&entry, buf)) return 0;
1070 /* Already has the same entry? */
1071 for(i = 0; i < max_autopick; i++)
1072 if(!strcmp(entry.name, autopick_list[i].name)
1073 && entry.flag[0] == autopick_list[i].flag[0]
1074 && entry.flag[1] == autopick_list[i].flag[1]) return 0;
1076 autopick_list[max_autopick++] = entry;
1083 * Open the "user pref file" and parse it.
1085 static errr process_pref_file_aux(cptr name, bool read_pickpref)
1097 bool bypass = FALSE;
1101 fp = my_fopen(name, "r");
1104 if (!fp) return (-1);
1106 /* Process the file */
1107 while (0 == my_fgets(fp, buf, sizeof(buf)))
1112 /* Skip "empty" lines */
1113 if (!buf[0]) continue;
1115 /* Skip "blank" lines */
1117 if (!iskanji(buf[0]))
1119 if (isspace(buf[0])) continue;
1122 if (buf[0] == '#') continue;
1129 /* Process "?:<expr>" */
1130 if ((buf[0] == '?') && (buf[1] == ':'))
1139 /* Parse the expr */
1140 v = process_pref_file_expr(&s, &f);
1143 bypass = (streq(v, "0") ? TRUE : FALSE);
1149 /* Apply conditionals */
1150 if (bypass) continue;
1153 /* Process "%:<file>" */
1156 /* Process that file if allowed */
1158 (void)process_pickpref_file(buf + 2);
1160 (void)process_pref_file(buf + 2);
1167 /* Process the line */
1168 err = process_pref_file_command(buf);
1170 /* This is not original pref line... */
1175 err = process_pickpref_file_line(buf);
1183 /* Print error message */
1184 /* ToDo: Add better error messages */
1186 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1187 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1189 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1190 msg_format("Parsing '%s'", old);
1195 /* Close the file */
1205 * Process the "user pref file" with the given name
1207 * See the functions above for a list of legal "commands".
1209 * We also accept the special "?" and "%" directives, which
1210 * allow conditional evaluation and filename inclusion.
1212 errr process_pref_file(cptr name)
1218 /* Build the filename */
1219 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
1221 /* Process the system pref file */
1222 err1 = process_pref_file_aux(buf, FALSE);
1224 /* Stop at parser errors, but not at non-existing file */
1225 if (err1 > 0) return err1;
1231 /* Build the filename */
1232 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
1234 /* Process the user pref file */
1235 err2 = process_pref_file_aux(buf, FALSE);
1241 /* User file does not exist, but read system pref file */
1242 if (err2 < 0 && !err1)
1245 /* Result of user file processing */
1254 * Operating hours for ANGBAND (defaults to non-work hours)
1256 static char days[7][29] =
1258 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1259 "MON:XXXXXXXX.........XXXXXXX",
1260 "TUE:XXXXXXXX.........XXXXXXX",
1261 "WED:XXXXXXXX.........XXXXXXX",
1262 "THU:XXXXXXXX.........XXXXXXX",
1263 "FRI:XXXXXXXX.........XXXXXXX",
1264 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1268 * Restict usage (defaults to no restrictions)
1270 static bool check_time_flag = FALSE;
1278 errr check_time(void)
1286 /* No restrictions */
1287 if (!check_time_flag) return (0);
1289 /* Check for time violation */
1290 c = time((time_t *)0);
1294 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1305 * Initialize CHECK_TIME
1307 errr check_time_init(void)
1317 /* Build the filename */
1318 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
1321 fp = my_fopen(buf, "r");
1323 /* No file, no restrictions */
1324 if (!fp) return (0);
1326 /* Assume restrictions */
1327 check_time_flag = TRUE;
1329 /* Parse the file */
1330 while (0 == my_fgets(fp, buf, sizeof(buf)))
1332 /* Skip comments and blank lines */
1333 if (!buf[0] || (buf[0] == '#')) continue;
1335 /* Chop the buffer */
1338 /* Extract the info */
1339 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1340 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1341 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1342 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1343 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1344 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1345 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1361 #ifndef MAXHOSTNAMELEN
1362 # define MAXHOSTNAMELEN 64
1365 typedef struct statstime statstime;
1371 unsigned int v_pgpgin;
1372 unsigned int v_pgpgout;
1373 unsigned int v_pswpin;
1374 unsigned int v_pswpout;
1375 unsigned int v_intr;
1381 unsigned int v_swtch;
1383 struct timeval boottime;
1384 struct timeval curtime;
1388 * Maximal load (if any).
1390 static int check_load_value = 0;
1398 errr check_load(void)
1403 struct statstime st;
1405 /* Success if not checking */
1406 if (!check_load_value) return (0);
1408 /* Check the load */
1409 if (0 == rstat("localhost", &st))
1411 long val1 = (long)(st.avenrun[2]);
1412 long val2 = (long)(check_load_value) * FSCALE;
1414 /* Check for violation */
1415 if (val1 >= val2) return (1);
1426 * Initialize CHECK_LOAD
1428 errr check_load_init(void)
1437 char temphost[MAXHOSTNAMELEN+1];
1438 char thishost[MAXHOSTNAMELEN+1];
1441 /* Build the filename */
1442 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
1444 /* Open the "load" file */
1445 fp = my_fopen(buf, "r");
1447 /* No file, no restrictions */
1448 if (!fp) return (0);
1451 check_load_value = 100;
1453 /* Get the host name */
1454 (void)gethostname(thishost, (sizeof thishost) - 1);
1457 while (0 == my_fgets(fp, buf, sizeof(buf)))
1461 /* Skip comments and blank lines */
1462 if (!buf[0] || (buf[0] == '#')) continue;
1464 /* Parse, or ignore */
1465 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1467 /* Skip other hosts */
1468 if (!streq(temphost, thishost) &&
1469 !streq(temphost, "localhost")) continue;
1471 /* Use that value */
1472 check_load_value = value;
1478 /* Close the file */
1488 #define ENTRY_BARE_HAND 0
1489 #define ENTRY_TWO_HANDS 1
1490 #define ENTRY_RIGHT_HAND1 2
1491 #define ENTRY_LEFT_HAND1 3
1492 #define ENTRY_LEFT_HAND2 4
1493 #define ENTRY_RIGHT_HAND2 5
1494 #define ENTRY_POSTURE 6
1495 #define ENTRY_SHOOT_HIT_DAM 7
1496 #define ENTRY_SHOOT_POWER 8
1497 #define ENTRY_SPEED 9
1498 #define ENTRY_BASE_AC 10
1499 #define ENTRY_LEVEL 11
1500 #define ENTRY_CUR_EXP 12
1501 #define ENTRY_MAX_EXP 13
1502 #define ENTRY_EXP_TO_ADV 14
1503 #define ENTRY_GOLD 15
1504 #define ENTRY_DAY 16
1507 #define ENTRY_PLAY_TIME 19
1508 #define ENTRY_SKILL_FIGHT 20
1509 #define ENTRY_SKILL_SHOOT 21
1510 #define ENTRY_SKILL_SAVING 22
1511 #define ENTRY_SKILL_STEALTH 23
1512 #define ENTRY_SKILL_PERCEP 24
1513 #define ENTRY_SKILL_SEARCH 25
1514 #define ENTRY_SKILL_DISARM 26
1515 #define ENTRY_SKILL_DEVICE 27
1516 #define ENTRY_BLOWS 28
1517 #define ENTRY_SHOTS 29
1518 #define ENTRY_AVG_DMG 30
1519 #define ENTRY_INFRA 31
1521 #define ENTRY_NAME 32
1522 #define ENTRY_SEX 33
1523 #define ENTRY_RACE 34
1524 #define ENTRY_CLASS 35
1525 #define ENTRY_REALM 36
1526 #define ENTRY_PATRON 37
1527 #define ENTRY_AGE 38
1528 #define ENTRY_HEIGHT 39
1529 #define ENTRY_WEIGHT 40
1530 #define ENTRY_SOCIAL 41
1531 #define ENTRY_ALIGN 42
1533 #define ENTRY_EXP_ANDR 43
1542 } disp_player_line[]
1545 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1546 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1547 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1548 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1549 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1550 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1552 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1553 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1554 {01, 20, 25, "²Ã®"},
1555 { 1, 19, 25, "£Á£Ã"},
1556 {29, 13, 21, "¥ì¥Ù¥ë"},
1557 {29, 14, 21, "·Ð¸³ÃÍ"},
1558 {29, 15, 21, "ºÇÂç·Ð¸³"},
1559 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1560 {29, 17, 21, "½ê»ý¶â"},
1561 {29, 19, 21, "ÆüÉÕ"},
1562 {29, 10, 21, "£È£Ð"},
1563 {29, 11, 21, "£Í£Ð"},
1564 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1565 {54, 10, -1, "ÂǷ⹶·â :"},
1566 {54, 11, -1, "¼Í·â¹¶·â :"},
1567 {54, 12, -1, "ËâË¡Ëɸæ :"},
1568 {54, 13, -1, "±£Ì©¹ÔÆ° :"},
1569 {54, 15, -1, "ÃγР:"},
1570 {54, 16, -1, "õº÷ :"},
1571 {54, 17, -1, "²ò½ü :"},
1572 {54, 18, -1, "ËâË¡Æ»¶ñ :"},
1573 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1574 {01, 17, 25, "¼Í·â²ó¿ô"},
1575 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1576 {54, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1577 {26, 1, -1, "̾Á° : "},
1578 { 1, 3, -1, "ÀÊÌ : "},
1579 { 1, 4, -1, "¼ï² : "},
1580 { 1, 5, -1, "¿¦¶È : "},
1581 { 1, 6, -1, "ËâË¡ : "},
1582 { 1, 7, -1, "¼é¸îËâ¿À : "},
1583 {29, 3, 21, "ǯÎð"},
1584 {29, 4, 21, "¿ÈĹ"},
1585 {29, 5, 21, "ÂνÅ"},
1586 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1587 {29, 7, 21, "°À"},
1588 {29, 14, 21, "¶¯²½ÅÙ"},
1592 { 1, 10, 25, "Bare hand"},
1593 { 1, 10, 25, "Two hands"},
1594 { 1, 10, 25, "Right hand"},
1595 { 1, 10, 25, "Left hand"},
1596 { 1, 11, 25, "Left hand"},
1597 { 1, 11, 25, "Right hand"},
1598 { 1, 11, 25, "Posture"},
1599 { 1, 15, 25, "Shooting"},
1600 { 1, 16, 25, "Multiplier"},
1601 {01, 20, 25, "Speed"},
1603 {29, 13, 21, "Level"},
1604 {29, 14, 21, "Experience"},
1605 {29, 15, 21, "Max Exp"},
1606 {29, 16, 21, "Exp to Adv"},
1607 {29, 17, 21, "Gold"},
1608 {29, 19, 21, "Time"},
1609 {29, 10, 21, "Hit point"},
1610 {29, 11, 21, "SP (Mana)"},
1611 {29, 20, 21, "Play time"},
1612 {54, 10, -1, "Fighting : "},
1613 {54, 11, -1, "Bows/Throw : "},
1614 {54, 12, -1, "Saving Throw: "},
1615 {54, 13, -1, "Stealth : "},
1616 {54, 15, -1, "Perception : "},
1617 {54, 16, -1, "Searching : "},
1618 {54, 17, -1, "Disarming : "},
1619 {54, 18, -1, "Magic Device: "},
1620 {01, 12, 25, "Blows/Round"},
1621 {01, 17, 25, "Shots/Round"},
1622 {01, 13, 25, "AverageDmg/Rnd"},
1623 {54, 20, -1, "Infra-Vision: "},
1624 {26, 1, -1, "Name : "},
1625 { 1, 3, -1, "Sex : "},
1626 { 1, 4, -1, "Race : "},
1627 { 1, 5, -1, "Class : "},
1628 { 1, 6, -1, "Magic : "},
1629 { 1, 7, -1, "Patron : "},
1631 {29, 4, 21, "Height"},
1632 {29, 5, 21, "Weight"},
1633 {29, 6, 21, "Social Class"},
1634 {29, 7, 21, "Align"},
1635 {29, 14, 21, "Constraction"},
1639 static void display_player_one_line(int entry, cptr val, byte attr)
1643 int row = disp_player_line[entry].row;
1644 int col = disp_player_line[entry].col;
1645 int len = disp_player_line[entry].len;
1646 cptr head = disp_player_line[entry].header;
1648 int head_len = strlen(head);
1650 Term_putstr(col, row, -1, TERM_WHITE, head);
1657 int val_len = len - head_len;
1658 sprintf(buf, "%*.*s", val_len, val_len, val);
1659 Term_putstr(col + head_len, row, -1, attr, buf);
1663 Term_putstr(col + head_len, row, -1, attr, val);
1671 * Prints the following information on the screen.
1673 static void display_player_middle(void)
1676 int show_tohit, show_todam;
1683 show_tohit = p_ptr->dis_to_h[0];
1684 show_todam = p_ptr->dis_to_d[0];
1686 o_ptr = &inventory[INVEN_RARM];
1688 /* Hack -- add in weapon info if known */
1689 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1690 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1693 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1695 /* Dump the bonuses to hit/dam */
1696 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1697 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1698 else if(p_ptr->ryoute)
1699 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1700 else if (left_hander)
1701 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1703 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1708 show_tohit = p_ptr->dis_to_h[1];
1709 show_todam = p_ptr->dis_to_d[1];
1711 o_ptr = &inventory[INVEN_LARM];
1713 /* Hack -- add in weapon info if known */
1714 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1715 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1718 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1720 /* Dump the bonuses to hit/dam */
1722 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1724 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1726 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1729 if (p_ptr->special_defense & KAMAE_MASK)
1731 for (i = 0; i < MAX_KAMAE; i++)
1733 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1737 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1739 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1744 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1746 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1751 o_ptr = &inventory[INVEN_BOW];
1754 show_tohit = p_ptr->dis_to_h_b;
1757 /* Apply weapon bonuses */
1758 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1759 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1761 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1762 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval])/400;
1764 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval]-4000)/200;
1767 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1769 if (inventory[INVEN_BOW].k_idx)
1771 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1773 /* Get extra "power" from "extra might" */
1774 if (p_ptr->xtra_might) tmul++;
1776 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1780 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1782 /* Dump the armor class */
1783 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1787 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1792 i = p_ptr->pspeed-110;
1794 /* Hack -- Visually "undo" the Search Mode Slowdown */
1795 if (p_ptr->action == ACTION_SEARCH) i += 10;
1800 attr = TERM_L_GREEN;
1814 attr = TERM_L_UMBER;
1821 if (is_fast) tmp_speed += 10;
1822 if (p_ptr->slow) tmp_speed -= 10;
1823 if (p_ptr->lightspeed) tmp_speed = 99;
1827 if (m_list[p_ptr->riding].fast) tmp_speed += 10;
1828 if (m_list[p_ptr->riding].slow) tmp_speed -= 10;
1834 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1837 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1839 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1850 sprintf(buf, "(%+d)", i);
1853 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1855 sprintf(buf, "Riding (%+d)", i);
1859 display_player_one_line(ENTRY_SPEED, buf, attr);
1862 /* Dump character level */
1863 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1865 /* Dump experience */
1866 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1867 else e = ENTRY_CUR_EXP;
1869 if (p_ptr->exp >= p_ptr->max_exp)
1870 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1872 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1874 /* Dump max experience */
1875 if (p_ptr->prace == RACE_ANDROID)
1878 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1880 /* Dump exp to advance */
1881 if (p_ptr->lev >= PY_MAX_LEVEL)
1882 display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
1883 else if (p_ptr->prace == RACE_ANDROID)
1884 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1886 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1889 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1894 extract_day_hour_min(&day, &hour, &min);
1904 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1906 /* Dump hit point */
1907 if (p_ptr->chp >= p_ptr->mhp)
1908 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1909 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1910 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1912 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1914 /* Dump mana power */
1915 if (p_ptr->csp >= p_ptr->msp)
1916 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1917 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1918 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1920 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1922 /* Dump play time */
1923 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1928 * Hack -- pass color info around this file
1930 static byte likert_color = TERM_WHITE;
1934 * Returns a "rating" of x depending on y
1936 static cptr likert(int x, int y)
1938 static char dummy[20] = "";
1943 /* Negative value */
1946 likert_color = TERM_L_DARK;
1950 return ("Very Bad");
1955 /* Analyze the value */
1961 likert_color = TERM_RED;
1971 likert_color = TERM_L_RED;
1982 likert_color = TERM_ORANGE;
1992 likert_color = TERM_YELLOW;
2002 likert_color = TERM_YELLOW;
2004 return ("ÂçÊÑÎɤ¤");
2006 return ("Very Good");
2013 likert_color = TERM_L_GREEN;
2017 return ("Excellent");
2027 likert_color = TERM_GREEN;
2040 likert_color = TERM_BLUE;
2042 return ("¥«¥ª¥¹¥é¥ó¥¯");
2044 return ("Chaos Rank");
2050 likert_color = TERM_VIOLET;
2052 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2054 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2064 * Prints ratings on certain abilities
2066 * This code is "imitated" elsewhere to "dump" a character sheet.
2068 static void display_player_various(void)
2070 int tmp, damage[2], blows1, blows2, i, basedam;
2071 int xthn, xthb, xfos, xsrh;
2072 int xdis, xdev, xsav, xstl;
2075 u32b flgs[TR_FLAG_SIZE];
2076 int shots, shot_frac;
2080 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2081 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2082 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2083 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2084 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2086 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2088 /* Shooting Skill (with current bow and normal missile) */
2089 o_ptr = &inventory[INVEN_BOW];
2090 tmp = p_ptr->to_h_b + o_ptr->to_h;
2091 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2093 /* If the player is wielding one? */
2096 s16b energy_fire = bow_energy(o_ptr->sval);
2098 /* Calculate shots per round */
2099 shots = p_ptr->num_fire * 100;
2100 shot_frac = (shots * 100 / energy_fire) % 100;
2101 shots = shots / energy_fire;
2102 if (o_ptr->name1 == ART_CRIMSON)
2106 if (p_ptr->pclass == CLASS_ARCHER)
2108 /* Extra shot at level 10 */
2109 if (p_ptr->lev >= 10) shots++;
2111 /* Extra shot at level 30 */
2112 if (p_ptr->lev >= 30) shots++;
2114 /* Extra shot at level 45 */
2115 if (p_ptr->lev >= 45) shots++;
2125 for(i = 0; i< 2; i++)
2127 damage[i] = p_ptr->dis_to_d[i]*100;
2128 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2130 int level = p_ptr->lev;
2136 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2137 if (p_ptr->special_defense & KAMAE_BYAKKO)
2138 basedam = monk_ave_damage[level][1];
2139 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2140 basedam = monk_ave_damage[level][2];
2142 basedam = monk_ave_damage[level][0];
2146 /* Average damage per round */
2147 o_ptr = &inventory[INVEN_RARM+i];
2148 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2149 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2150 object_flags(o_ptr, flgs);
2151 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2157 else if (object_known_p(o_ptr) && (have_flag(flgs, TR_VORPAL)))
2159 /* vorpal flag only */
2163 if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (have_flag(flgs, TR_FORCE_WEAPON)) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2164 basedam = basedam * 7 / 2;
2165 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2166 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2168 damage[i] += basedam;
2169 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2170 if (damage[i] < 0) damage[i] = 0;
2172 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2173 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2175 /* Basic abilities */
2177 xdis = p_ptr->skill_dis;
2178 xdev = p_ptr->skill_dev;
2179 xsav = p_ptr->skill_sav;
2180 xstl = p_ptr->skill_stl;
2181 xsrh = p_ptr->skill_srh;
2182 xfos = p_ptr->skill_fos;
2185 desc = likert(xthn, 12);
2186 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2188 desc = likert(xthb, 12);
2189 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2191 desc = likert(xsav, 7);
2192 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2194 desc = likert(xstl, 1);
2195 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2197 desc = likert(xfos, 6);
2198 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2200 desc = likert(xsrh, 6);
2201 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2203 desc = likert(xdis, 8);
2204 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2206 desc = likert(xdev, 6);
2207 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2210 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2212 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2214 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2217 if ((damage[0]+damage[1]) == 0)
2220 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2222 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2224 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2230 * Obtain the "flags" for the player as if he was an item
2232 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2237 for (i = 0; i < TR_FLAG_SIZE; i++)
2241 switch (p_ptr->pclass)
2244 if (p_ptr->lev > 44)
2245 add_flag(flgs, TR_REGEN);
2247 if (p_ptr->lev > 29)
2248 add_flag(flgs, TR_RES_FEAR);
2251 if (p_ptr->lev > 39)
2252 add_flag(flgs, TR_RES_FEAR);
2254 case CLASS_CHAOS_WARRIOR:
2255 if (p_ptr->lev > 29)
2256 add_flag(flgs, TR_RES_CHAOS);
2257 if (p_ptr->lev > 39)
2258 add_flag(flgs, TR_RES_FEAR);
2261 case CLASS_FORCETRAINER:
2262 if ((p_ptr->lev > 9) && !heavy_armor())
2263 add_flag(flgs, TR_SPEED);
2264 if ((p_ptr->lev>24) && !heavy_armor())
2265 add_flag(flgs, TR_FREE_ACT);
2269 add_flag(flgs, TR_SPEED);
2272 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2273 add_flag(flgs, TR_SPEED);
2275 add_flag(flgs, TR_FREE_ACT);
2277 add_flag(flgs, TR_SLOW_DIGEST);
2278 add_flag(flgs, TR_RES_FEAR);
2279 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2280 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2281 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2283 case CLASS_MINDCRAFTER:
2285 add_flag(flgs, TR_RES_FEAR);
2286 if (p_ptr->lev > 19)
2287 add_flag(flgs, TR_SUST_WIS);
2288 if (p_ptr->lev > 29)
2289 add_flag(flgs, TR_RES_CONF);
2290 if (p_ptr->lev > 39)
2291 add_flag(flgs, TR_TELEPATHY);
2294 add_flag(flgs, TR_RES_SOUND);
2296 case CLASS_BERSERKER:
2297 add_flag(flgs, TR_SUST_STR);
2298 add_flag(flgs, TR_SUST_DEX);
2299 add_flag(flgs, TR_SUST_CON);
2300 add_flag(flgs, TR_REGEN);
2301 add_flag(flgs, TR_FREE_ACT);
2302 add_flag(flgs, TR_SPEED);
2303 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2305 case CLASS_MIRROR_MASTER:
2306 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2309 break; /* Do nothing */
2313 if (p_ptr->mimic_form)
2315 switch(p_ptr->mimic_form)
2318 add_flag(flgs, TR_HOLD_LIFE);
2319 add_flag(flgs, TR_RES_CHAOS);
2320 add_flag(flgs, TR_RES_NETHER);
2321 add_flag(flgs, TR_RES_FIRE);
2322 add_flag(flgs, TR_SEE_INVIS);
2323 add_flag(flgs, TR_SPEED);
2325 case MIMIC_DEMON_LORD:
2326 add_flag(flgs, TR_HOLD_LIFE);
2327 add_flag(flgs, TR_RES_CHAOS);
2328 add_flag(flgs, TR_RES_NETHER);
2329 add_flag(flgs, TR_RES_FIRE);
2330 add_flag(flgs, TR_RES_COLD);
2331 add_flag(flgs, TR_RES_ELEC);
2332 add_flag(flgs, TR_RES_ACID);
2333 add_flag(flgs, TR_RES_POIS);
2334 add_flag(flgs, TR_RES_CONF);
2335 add_flag(flgs, TR_RES_DISEN);
2336 add_flag(flgs, TR_RES_NEXUS);
2337 add_flag(flgs, TR_RES_FEAR);
2338 add_flag(flgs, TR_IM_FIRE);
2339 add_flag(flgs, TR_SH_FIRE);
2340 add_flag(flgs, TR_SEE_INVIS);
2341 add_flag(flgs, TR_TELEPATHY);
2342 add_flag(flgs, TR_FEATHER);
2343 add_flag(flgs, TR_SPEED);
2346 add_flag(flgs, TR_HOLD_LIFE);
2347 add_flag(flgs, TR_RES_DARK);
2348 add_flag(flgs, TR_RES_NETHER);
2349 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2350 add_flag(flgs, TR_RES_POIS);
2351 add_flag(flgs, TR_RES_COLD);
2352 add_flag(flgs, TR_SEE_INVIS);
2353 add_flag(flgs, TR_SPEED);
2359 switch (p_ptr->prace)
2362 add_flag(flgs, TR_RES_LITE);
2365 add_flag(flgs, TR_SUST_DEX);
2368 add_flag(flgs, TR_FREE_ACT);
2371 add_flag(flgs, TR_RES_BLIND);
2374 add_flag(flgs, TR_RES_DARK);
2376 case RACE_HALF_TROLL:
2377 add_flag(flgs, TR_SUST_STR);
2378 if (p_ptr->lev > 14)
2380 add_flag(flgs, TR_REGEN);
2381 if (p_ptr->pclass == CLASS_WARRIOR)
2383 add_flag(flgs, TR_SLOW_DIGEST);
2385 * Let's not make Regeneration a disadvantage
2386 * for the poor warriors who can never learn
2387 * a spell that satisfies hunger (actually
2388 * neither can rogues, but half-trolls are not
2389 * supposed to play rogues)
2395 add_flag(flgs, TR_SUST_CON);
2396 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2399 add_flag(flgs, TR_RES_LITE);
2400 add_flag(flgs, TR_SEE_INVIS);
2402 case RACE_BARBARIAN:
2403 add_flag(flgs, TR_RES_FEAR);
2405 case RACE_HALF_OGRE:
2406 add_flag(flgs, TR_SUST_STR);
2407 add_flag(flgs, TR_RES_DARK);
2409 case RACE_HALF_GIANT:
2410 add_flag(flgs, TR_RES_SHARDS);
2411 add_flag(flgs, TR_SUST_STR);
2413 case RACE_HALF_TITAN:
2414 add_flag(flgs, TR_RES_CHAOS);
2417 add_flag(flgs, TR_RES_SOUND);
2420 add_flag(flgs, TR_RES_ACID);
2421 if (p_ptr->lev > 19)
2422 add_flag(flgs, TR_IM_ACID);
2425 add_flag(flgs, TR_RES_CONF);
2426 add_flag(flgs, TR_RES_ACID);
2428 add_flag(flgs, TR_SPEED);
2431 add_flag(flgs, TR_RES_POIS);
2434 add_flag(flgs, TR_RES_DISEN);
2435 add_flag(flgs, TR_RES_DARK);
2438 add_flag(flgs, TR_RES_DARK);
2439 if (p_ptr->lev > 19)
2440 add_flag(flgs, TR_SEE_INVIS);
2442 case RACE_DRACONIAN:
2443 add_flag(flgs, TR_FEATHER);
2445 add_flag(flgs, TR_RES_FIRE);
2447 add_flag(flgs, TR_RES_COLD);
2448 if (p_ptr->lev > 14)
2449 add_flag(flgs, TR_RES_ACID);
2450 if (p_ptr->lev > 19)
2451 add_flag(flgs, TR_RES_ELEC);
2452 if (p_ptr->lev > 34)
2453 add_flag(flgs, TR_RES_POIS);
2455 case RACE_MIND_FLAYER:
2456 add_flag(flgs, TR_SUST_INT);
2457 add_flag(flgs, TR_SUST_WIS);
2458 if (p_ptr->lev > 14)
2459 add_flag(flgs, TR_SEE_INVIS);
2460 if (p_ptr->lev > 29)
2461 add_flag(flgs, TR_TELEPATHY);
2464 add_flag(flgs, TR_RES_FIRE);
2466 add_flag(flgs, TR_SEE_INVIS);
2469 add_flag(flgs, TR_SEE_INVIS);
2470 add_flag(flgs, TR_FREE_ACT);
2471 add_flag(flgs, TR_RES_POIS);
2472 add_flag(flgs, TR_SLOW_DIGEST);
2473 if (p_ptr->lev > 34)
2474 add_flag(flgs, TR_HOLD_LIFE);
2477 add_flag(flgs, TR_SEE_INVIS);
2478 add_flag(flgs, TR_RES_SHARDS);
2479 add_flag(flgs, TR_HOLD_LIFE);
2480 add_flag(flgs, TR_RES_POIS);
2482 add_flag(flgs, TR_RES_COLD);
2485 add_flag(flgs, TR_SEE_INVIS);
2486 add_flag(flgs, TR_HOLD_LIFE);
2487 add_flag(flgs, TR_RES_NETHER);
2488 add_flag(flgs, TR_RES_POIS);
2489 add_flag(flgs, TR_SLOW_DIGEST);
2491 add_flag(flgs, TR_RES_COLD);
2494 add_flag(flgs, TR_HOLD_LIFE);
2495 add_flag(flgs, TR_RES_DARK);
2496 add_flag(flgs, TR_RES_NETHER);
2497 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE);
2498 add_flag(flgs, TR_RES_POIS);
2499 add_flag(flgs, TR_RES_COLD);
2502 add_flag(flgs, TR_FEATHER);
2503 add_flag(flgs, TR_FREE_ACT);
2504 add_flag(flgs, TR_RES_COLD);
2505 add_flag(flgs, TR_SEE_INVIS);
2506 add_flag(flgs, TR_HOLD_LIFE);
2507 add_flag(flgs, TR_RES_NETHER);
2508 add_flag(flgs, TR_RES_POIS);
2509 add_flag(flgs, TR_SLOW_DIGEST);
2511 if (p_ptr->lev > 34)
2512 add_flag(flgs, TR_TELEPATHY);
2515 add_flag(flgs, TR_RES_LITE);
2516 add_flag(flgs, TR_FEATHER);
2518 add_flag(flgs, TR_SPEED);
2521 add_flag(flgs, TR_RES_SOUND);
2522 add_flag(flgs, TR_RES_CONF);
2525 add_flag(flgs, TR_FEATHER);
2526 add_flag(flgs, TR_SEE_INVIS);
2529 add_flag(flgs, TR_RES_FIRE);
2530 add_flag(flgs, TR_RES_NETHER);
2531 add_flag(flgs, TR_HOLD_LIFE);
2533 add_flag(flgs, TR_SEE_INVIS);
2536 add_flag(flgs, TR_SUST_CON);
2539 add_flag(flgs, TR_FEATHER);
2542 add_flag(flgs, TR_RES_CONF);
2545 add_flag(flgs, TR_FREE_ACT);
2546 add_flag(flgs, TR_RES_POIS);
2547 add_flag(flgs, TR_SLOW_DIGEST);
2548 add_flag(flgs, TR_HOLD_LIFE);
2558 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2560 remove_flag(flgs, TR_REGEN);
2563 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2564 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2565 (p_ptr->muta3 & MUT3_SHORT_LEG))
2567 add_flag(flgs, TR_SPEED);
2570 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2572 add_flag(flgs, TR_SH_ELEC);
2575 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2577 add_flag(flgs, TR_SH_FIRE);
2578 add_flag(flgs, TR_LITE);
2581 if (p_ptr->muta3 & MUT3_WINGS)
2583 add_flag(flgs, TR_FEATHER);
2586 if (p_ptr->muta3 & MUT3_FEARLESS)
2588 add_flag(flgs, TR_RES_FEAR);
2591 if (p_ptr->muta3 & MUT3_REGEN)
2593 add_flag(flgs, TR_REGEN);
2596 if (p_ptr->muta3 & MUT3_ESP)
2598 add_flag(flgs, TR_TELEPATHY);
2601 if (p_ptr->muta3 & MUT3_MOTION)
2603 add_flag(flgs, TR_FREE_ACT);
2607 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2608 add_flag(flgs, TR_AGGRAVATE);
2609 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2611 add_flag(flgs, TR_RES_BLIND);
2612 add_flag(flgs, TR_RES_CONF);
2613 add_flag(flgs, TR_HOLD_LIFE);
2614 add_flag(flgs, TR_LITE);
2616 add_flag(flgs, TR_SPEED);
2618 if (p_ptr->special_defense & KATA_FUUJIN)
2619 add_flag(flgs, TR_REFLECT);
2620 if (p_ptr->special_defense & KAMAE_GENBU)
2621 add_flag(flgs, TR_REFLECT);
2622 if (p_ptr->special_defense & KAMAE_SUZAKU)
2623 add_flag(flgs, TR_FEATHER);
2624 if (p_ptr->special_defense & KAMAE_SEIRYU)
2626 add_flag(flgs, TR_RES_FIRE);
2627 add_flag(flgs, TR_RES_COLD);
2628 add_flag(flgs, TR_RES_ACID);
2629 add_flag(flgs, TR_RES_ELEC);
2630 add_flag(flgs, TR_RES_POIS);
2631 add_flag(flgs, TR_FEATHER);
2632 add_flag(flgs, TR_SH_FIRE);
2633 add_flag(flgs, TR_SH_ELEC);
2634 add_flag(flgs, TR_SH_COLD);
2636 if (p_ptr->special_defense & KATA_MUSOU)
2638 add_flag(flgs, TR_RES_FEAR);
2639 add_flag(flgs, TR_RES_LITE);
2640 add_flag(flgs, TR_RES_DARK);
2641 add_flag(flgs, TR_RES_BLIND);
2642 add_flag(flgs, TR_RES_CONF);
2643 add_flag(flgs, TR_RES_SOUND);
2644 add_flag(flgs, TR_RES_SHARDS);
2645 add_flag(flgs, TR_RES_NETHER);
2646 add_flag(flgs, TR_RES_NEXUS);
2647 add_flag(flgs, TR_RES_CHAOS);
2648 add_flag(flgs, TR_RES_DISEN);
2649 add_flag(flgs, TR_REFLECT);
2650 add_flag(flgs, TR_HOLD_LIFE);
2651 add_flag(flgs, TR_FREE_ACT);
2652 add_flag(flgs, TR_SH_FIRE);
2653 add_flag(flgs, TR_SH_ELEC);
2654 add_flag(flgs, TR_SH_COLD);
2655 add_flag(flgs, TR_FEATHER);
2656 add_flag(flgs, TR_LITE);
2657 add_flag(flgs, TR_SEE_INVIS);
2658 add_flag(flgs, TR_TELEPATHY);
2659 add_flag(flgs, TR_SLOW_DIGEST);
2660 add_flag(flgs, TR_REGEN);
2661 add_flag(flgs, TR_SUST_STR);
2662 add_flag(flgs, TR_SUST_INT);
2663 add_flag(flgs, TR_SUST_WIS);
2664 add_flag(flgs, TR_SUST_DEX);
2665 add_flag(flgs, TR_SUST_CON);
2666 add_flag(flgs, TR_SUST_CHR);
2671 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE], bool im_and_res)
2676 for (i = 0; i < TR_FLAG_SIZE; i++)
2679 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2680 add_flag(flgs, TR_RES_FEAR);
2681 if (p_ptr->tim_invis)
2682 add_flag(flgs, TR_SEE_INVIS);
2683 if (p_ptr->tim_regen)
2684 add_flag(flgs, TR_REGEN);
2685 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2686 add_flag(flgs, TR_TELEPATHY);
2687 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2688 add_flag(flgs, TR_SPEED);
2689 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2691 add_flag(flgs, TR_RES_FIRE);
2692 add_flag(flgs, TR_RES_COLD);
2693 add_flag(flgs, TR_RES_ACID);
2694 add_flag(flgs, TR_RES_ELEC);
2695 add_flag(flgs, TR_RES_POIS);
2699 if (p_ptr->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 (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2702 add_flag(flgs, TR_RES_ELEC);
2703 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2704 add_flag(flgs, TR_RES_FIRE);
2705 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2706 add_flag(flgs, TR_RES_COLD);
2710 if (p_ptr->oppose_acid)
2711 add_flag(flgs, TR_RES_ACID);
2712 if (p_ptr->oppose_elec)
2713 add_flag(flgs, TR_RES_ELEC);
2714 if (p_ptr->oppose_fire)
2715 add_flag(flgs, TR_RES_FIRE);
2716 if (p_ptr->oppose_cold)
2717 add_flag(flgs, TR_RES_COLD);
2719 if (p_ptr->oppose_pois)
2720 add_flag(flgs, TR_RES_POIS);
2721 if (p_ptr->special_attack & ATTACK_ACID)
2722 add_flag(flgs, TR_BRAND_ACID);
2723 if (p_ptr->special_attack & ATTACK_ELEC)
2724 add_flag(flgs, TR_BRAND_ELEC);
2725 if (p_ptr->special_attack & ATTACK_FIRE)
2726 add_flag(flgs, TR_BRAND_FIRE);
2727 if (p_ptr->special_attack & ATTACK_COLD)
2728 add_flag(flgs, TR_BRAND_COLD);
2729 if (p_ptr->special_attack & ATTACK_POIS)
2730 add_flag(flgs, TR_BRAND_POIS);
2731 if (p_ptr->special_defense & DEFENSE_ACID)
2732 add_flag(flgs, TR_IM_ACID);
2733 if (p_ptr->special_defense & DEFENSE_ELEC)
2734 add_flag(flgs, TR_IM_ELEC);
2735 if (p_ptr->special_defense & DEFENSE_FIRE)
2736 add_flag(flgs, TR_IM_FIRE);
2737 if (p_ptr->special_defense & DEFENSE_COLD)
2738 add_flag(flgs, TR_IM_COLD);
2739 if (p_ptr->wraith_form)
2740 add_flag(flgs, TR_REFLECT);
2742 if (p_ptr->tim_reflect){
2743 add_flag(flgs, TR_REFLECT);
2746 if (p_ptr->magicdef)
2748 add_flag(flgs, TR_RES_BLIND);
2749 add_flag(flgs, TR_RES_CONF);
2750 add_flag(flgs, TR_REFLECT);
2751 add_flag(flgs, TR_FREE_ACT);
2752 add_flag(flgs, TR_FEATHER);
2754 if (p_ptr->tim_res_nether)
2756 add_flag(flgs, TR_RES_NETHER);
2758 if (p_ptr->tim_sh_fire)
2760 add_flag(flgs, TR_SH_FIRE);
2764 add_flag(flgs, TR_RES_FEAR);
2765 add_flag(flgs, TR_RES_LITE);
2766 add_flag(flgs, TR_RES_DARK);
2767 add_flag(flgs, TR_RES_BLIND);
2768 add_flag(flgs, TR_RES_CONF);
2769 add_flag(flgs, TR_RES_SOUND);
2770 add_flag(flgs, TR_RES_SHARDS);
2771 add_flag(flgs, TR_RES_NETHER);
2772 add_flag(flgs, TR_RES_NEXUS);
2773 add_flag(flgs, TR_RES_CHAOS);
2774 add_flag(flgs, TR_RES_DISEN);
2775 add_flag(flgs, TR_REFLECT);
2776 add_flag(flgs, TR_HOLD_LIFE);
2777 add_flag(flgs, TR_FREE_ACT);
2778 add_flag(flgs, TR_SH_FIRE);
2779 add_flag(flgs, TR_SH_ELEC);
2780 add_flag(flgs, TR_SH_COLD);
2781 add_flag(flgs, TR_FEATHER);
2782 add_flag(flgs, TR_LITE);
2783 add_flag(flgs, TR_SEE_INVIS);
2784 add_flag(flgs, TR_TELEPATHY);
2785 add_flag(flgs, TR_SLOW_DIGEST);
2786 add_flag(flgs, TR_REGEN);
2787 add_flag(flgs, TR_SUST_STR);
2788 add_flag(flgs, TR_SUST_INT);
2789 add_flag(flgs, TR_SUST_WIS);
2790 add_flag(flgs, TR_SUST_DEX);
2791 add_flag(flgs, TR_SUST_CON);
2792 add_flag(flgs, TR_SUST_CHR);
2797 /* Mode flags for displaying player flags */
2798 #define DP_CURSE 0x01
2807 static void display_player_equippy(int y, int x, u16b mode)
2816 /* Weapon flags need only two column */
2817 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2818 else max_i = INVEN_TOTAL;
2820 /* Dump equippy chars */
2821 for (i = INVEN_RARM; i < max_i; i++)
2824 o_ptr = &inventory[i];
2826 a = object_attr(o_ptr);
2827 c = object_char(o_ptr);
2829 /* Clear the part of the screen */
2830 if (!equippy_chars || !o_ptr->k_idx)
2837 Term_putch(x + i - INVEN_RARM, y, a, c);
2842 void print_equippy(void)
2844 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2851 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2856 for (i = 0; i < TR_FLAG_SIZE; i++)
2859 /* Check equipment */
2860 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2862 u32b o_flgs[TR_FLAG_SIZE];
2867 o_ptr = &inventory[i];
2869 if (!o_ptr->k_idx) continue;
2872 object_flags_known(o_ptr, o_flgs);
2874 if (have_flag(flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2875 if (have_flag(flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2876 if (have_flag(flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2877 if (have_flag(flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2881 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2886 for (i = 0; i < TR_FLAG_SIZE; i++)
2889 if (prace_is_(RACE_SPECTRE))
2890 add_flag(flgs, TR_RES_NETHER);
2891 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2892 add_flag(flgs, TR_RES_DARK);
2893 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2894 add_flag(flgs, TR_RES_FIRE);
2895 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2896 add_flag(flgs, TR_RES_ACID);
2899 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2904 for (i = 0; i < TR_FLAG_SIZE; i++)
2907 if (p_ptr->special_defense & DEFENSE_ACID)
2908 add_flag(flgs, TR_RES_ACID);
2909 if (p_ptr->special_defense & DEFENSE_ELEC)
2910 add_flag(flgs, TR_RES_ELEC);
2911 if (p_ptr->special_defense & DEFENSE_FIRE)
2912 add_flag(flgs, TR_RES_FIRE);
2913 if (p_ptr->special_defense & DEFENSE_COLD)
2914 add_flag(flgs, TR_RES_COLD);
2915 if (p_ptr->wraith_form)
2916 add_flag(flgs, TR_RES_DARK);
2919 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2924 for (i = 0; i < TR_FLAG_SIZE; i++)
2927 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2929 add_flag(flgs, TR_RES_ACID);
2930 add_flag(flgs, TR_RES_ELEC);
2931 add_flag(flgs, TR_RES_FIRE);
2932 add_flag(flgs, TR_RES_COLD);
2934 if (prace_is_(RACE_ANDROID))
2935 add_flag(flgs, TR_RES_ELEC);
2936 if (prace_is_(RACE_ENT))
2937 add_flag(flgs, TR_RES_FIRE);
2938 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2939 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2940 add_flag(flgs, TR_RES_LITE);
2945 * A struct for storing misc. flags
2948 u32b player_flags[TR_FLAG_SIZE];
2949 u32b tim_player_flags[TR_FLAG_SIZE];
2950 u32b player_imm[TR_FLAG_SIZE];
2951 u32b tim_player_imm[TR_FLAG_SIZE];
2952 u32b player_vuln[TR_FLAG_SIZE];
2953 u32b known_obj_imm[TR_FLAG_SIZE];
2958 * Helper function, see below
2960 static void display_flag_aux(int row, int col, cptr header,
2961 int flag1, all_player_flags *f, u16b mode)
2967 if (have_flag(f->player_vuln, flag1) &&
2968 !(have_flag(f->known_obj_imm, flag1) ||
2969 have_flag(f->player_imm, flag1) ||
2970 have_flag(f->tim_player_imm, flag1)))
2974 if (!(mode & DP_IMM)) c_put_str(TERM_WHITE, header, row, col);
2977 col += strlen(header) + 1;
2979 /* Weapon flags need only two column */
2980 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2981 else max_i = INVEN_TOTAL;
2983 /* Check equipment */
2984 for (i = INVEN_RARM; i < max_i; i++)
2986 u32b flgs[TR_FLAG_SIZE];
2990 o_ptr = &inventory[i];
2993 object_flags_known(o_ptr, flgs);
2996 if (!(mode & DP_IMM))
2997 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3000 if (mode & DP_CURSE)
3002 if ((mode & DP_CURSE) && (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE)))
3003 c_put_str(TERM_WHITE, "+", row, col);
3004 if ((mode & DP_CURSE) && (o_ptr->curse_flags & TRC_PERMA_CURSE))
3005 c_put_str(TERM_WHITE, "*", row, col);
3007 else if (mode & DP_ESP)
3009 if (have_flag(flgs, TR_TELEPATHY))
3010 c_put_str(TERM_WHITE, "*", row, col);
3011 else if (have_flag(flgs, TR_ESP_EVIL))
3012 c_put_str(TERM_L_DARK, "*", row, col);
3013 else if (have_flag(flgs, TR_ESP_NONLIVING))
3014 c_put_str(TERM_BLUE, "+", row, col);
3015 else if (have_flag(flgs, TR_ESP_GOOD))
3016 c_put_str(TERM_WHITE, "+", row, col);
3017 else if (have_flag(flgs, TR_ESP_UNDEAD))
3018 c_put_str(TERM_L_DARK, "+", row, col);
3019 else if (have_flag(flgs, TR_ESP_DEMON))
3020 c_put_str(TERM_RED, "+", row, col);
3021 else if (have_flag(flgs, TR_ESP_DRAGON))
3022 c_put_str(TERM_GREEN, "+", row, col);
3023 else if (have_flag(flgs, TR_ESP_HUMAN))
3024 c_put_str(TERM_YELLOW, "+", row, col);
3025 else if (have_flag(flgs, TR_ESP_UNIQUE))
3026 c_put_str(TERM_VIOLET, "+", row, col);
3027 else if (have_flag(flgs, TR_ESP_ANIMAL))
3028 c_put_str(TERM_L_GREEN, "+", row, col);
3029 else if (have_flag(flgs, TR_ESP_ORC))
3030 c_put_str(TERM_L_UMBER, "+", row, col);
3031 else if (have_flag(flgs, TR_ESP_TROLL))
3032 c_put_str(TERM_SLATE, "+", row, col);
3033 else if (have_flag(flgs, TR_ESP_GIANT))
3034 c_put_str(TERM_ORANGE, "+", row, col);
3038 if (have_flag(flgs, flag1))
3039 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
3040 (mode & DP_IMM) ? "*" : "+", row, col);
3047 /* Assume that player flag is already written */
3048 if (mode & DP_IMM) return;
3051 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3054 if (have_flag(f->player_flags, flag1)) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3056 /* Timed player flags */
3057 if (have_flag(f->tim_player_flags, flag1)) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3060 if (have_flag(f->tim_player_imm, flag1)) c_put_str(TERM_YELLOW, "*", row, col);
3061 if (have_flag(f->player_imm, flag1)) c_put_str(TERM_WHITE, "*", row, col);
3064 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3069 * Special display, part 1
3071 static void display_player_flag_info(void)
3078 /* Extract flags and store */
3079 player_flags(f.player_flags);
3080 tim_player_flags(f.tim_player_flags, TRUE);
3081 player_immunity(f.player_imm);
3082 tim_player_immunity(f.tim_player_imm);
3083 known_obj_immunity(f.known_obj_imm);
3084 player_vuln_flags(f.player_vuln);
3091 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_ACID, &f, 0);
3096 display_flag_aux(row+0, col, "ÂÑ»À :", TR_IM_ACID, &f, DP_IMM);
3097 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_RES_ELEC, &f, 0);
3098 display_flag_aux(row+1, col, "ÂÑÅÅ·â:", TR_IM_ELEC, &f, DP_IMM);
3099 display_flag_aux(row+2, col, "ÂѲбê:", TR_RES_FIRE, &f, 0);
3100 display_flag_aux(row+2, col, "ÂѲбê:", TR_IM_FIRE, &f, DP_IMM);
3101 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_RES_COLD, &f, 0);
3102 display_flag_aux(row+3, col, "ÂÑÎ䵤:", TR_IM_COLD, &f, DP_IMM);
3103 display_flag_aux(row+4, col, "ÂÑÆÇ :", TR_RES_POIS, &f, 0);
3104 display_flag_aux(row+5, col, "ÂÑÁ®¸÷:", TR_RES_LITE, &f, 0);
3105 display_flag_aux(row+6, col, "ÂѰŹõ:", TR_RES_DARK, &f, 0);
3106 display_flag_aux(row+7, col, "ÂÑÇËÊÒ:", TR_RES_SHARDS, &f, 0);
3107 display_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", TR_RES_BLIND, &f, 0);
3108 display_flag_aux(row+9, col, "ÂѺ®Íð:", TR_RES_CONF, &f, 0);
3110 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3111 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3112 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3113 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3114 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3115 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3116 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3117 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3118 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3119 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3120 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3121 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3122 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3123 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3132 display_player_equippy(row-2, col+8, 0);
3134 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3137 display_flag_aux(row+0, col, "Âѹ첻:", TR_RES_SOUND, &f, 0);
3138 display_flag_aux(row+1, col, "ÂÑÃϹö:", TR_RES_NETHER, &f, 0);
3139 display_flag_aux(row+2, col, "ÂÑ°øº®:", TR_RES_NEXUS, &f, 0);
3140 display_flag_aux(row+3, col, "ÂÑ¥«¥ª:", TR_RES_CHAOS, &f, 0);
3141 display_flag_aux(row+4, col, "ÂÑÎô²½:", TR_RES_DISEN, &f, 0);
3142 display_flag_aux(row+5, col, "ÂѶ²ÉÝ:", TR_RES_FEAR, &f, 0);
3143 display_flag_aux(row+6, col, "È¿¼Í :", TR_REFLECT, &f, 0);
3144 display_flag_aux(row+7, col, "²Ð±ê¥ª:", TR_SH_FIRE, &f, 0);
3145 display_flag_aux(row+8, col, "Åŵ¤¥ª:", TR_SH_ELEC, &f, 0);
3146 display_flag_aux(row+9, col, "Î䵤¥ª:", TR_SH_COLD, &f, 0);
3148 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3149 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3150 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3151 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3152 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3153 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3154 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3155 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3156 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3157 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3166 display_player_equippy(row-2, col+12, 0);
3168 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3171 display_flag_aux(row+0, col, "²Ã® :", TR_SPEED, &f, 0);
3172 display_flag_aux(row+1, col, "ÂÑËãáã :", TR_FREE_ACT, &f, 0);
3173 display_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", TR_SEE_INVIS, &f, 0);
3174 display_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", TR_HOLD_LIFE, &f, 0);
3175 display_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", TR_TELEPATHY, &f, DP_ESP);
3176 display_flag_aux(row+5, col, "Ãپò½ :", TR_SLOW_DIGEST, &f, 0);
3177 display_flag_aux(row+6, col, "µÞ²óÉü :", TR_REGEN, &f, 0);
3178 display_flag_aux(row+7, col, "ÉâÍ· :", TR_FEATHER, &f, 0);
3179 display_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", TR_LITE, &f, 0);
3180 display_flag_aux(row+9, col, "¼ö¤¤ :", 0, &f, DP_CURSE);
3182 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3183 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3184 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3185 display_flag_aux(row+3, col, "Hold Life :", TR_HOLD_LIFE, &f, 0);
3186 display_flag_aux(row+4, col, "Telepathy :", TR_TELEPATHY, &f, DP_ESP);
3187 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3188 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3189 display_flag_aux(row+7, col, "Levitation:", TR_FEATHER, &f, 0);
3190 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE, &f, 0);
3191 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3198 * Special display, part 2
3200 static void display_player_other_flag_info(void)
3207 /* Extract flags and store */
3208 player_flags(f.player_flags);
3209 tim_player_flags(f.tim_player_flags, TRUE);
3210 player_immunity(f.player_imm);
3211 tim_player_immunity(f.tim_player_imm);
3212 known_obj_immunity(f.known_obj_imm);
3213 player_vuln_flags(f.player_vuln);
3220 display_player_equippy(row-2, col+12, DP_WP);
3222 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3225 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_SLAY_EVIL, &f, DP_WP);
3226 display_flag_aux(row+ 0, col, "¼Ù° ÇÜÂÇ :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3227 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_SLAY_UNDEAD, &f, DP_WP);
3228 display_flag_aux(row+ 1, col, "ÉÔ»à ÇÜÂÇ :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3229 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_SLAY_DEMON, &f, DP_WP);
3230 display_flag_aux(row+ 2, col, "°Ëâ ÇÜÂÇ :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3231 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_SLAY_DRAGON, &f, DP_WP);
3232 display_flag_aux(row+ 3, col, "ζ ÇÜÂÇ :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3233 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_SLAY_HUMAN, &f, DP_WP);
3234 display_flag_aux(row+ 4, col, "¿Í´Ö ÇÜÂÇ :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3235 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_SLAY_ANIMAL, &f, DP_WP);
3236 display_flag_aux(row+ 5, col, "ưʪ ÇÜÂÇ :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3237 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_SLAY_ORC, &f, DP_WP);
3238 display_flag_aux(row+ 6, col, "¥ª¡¼¥¯ÇÜÂÇ:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3239 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_SLAY_TROLL, &f, DP_WP);
3240 display_flag_aux(row+ 7, col, "¥È¥í¥ëÇÜÂÇ:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3241 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_SLAY_GIANT, &f, DP_WP);
3242 display_flag_aux(row+ 8, col, "µð¿Í ÇÜÂÇ :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3243 display_flag_aux(row+ 9, col, "Íϲò :", TR_BRAND_ACID, &f, DP_WP);
3244 display_flag_aux(row+10, col, "ÅÅ·â :", TR_BRAND_ELEC, &f, DP_WP);
3245 display_flag_aux(row+11, col, "¾Æ´þ :", TR_BRAND_FIRE, &f, DP_WP);
3246 display_flag_aux(row+12, col, "Åà·ë :", TR_BRAND_COLD, &f, DP_WP);
3247 display_flag_aux(row+13, col, "ÆÇ»¦ :", TR_BRAND_POIS, &f, DP_WP);
3248 display_flag_aux(row+14, col, "ÀÚ¤ìÌ£ :", TR_VORPAL, &f, DP_WP);
3249 display_flag_aux(row+15, col, "ÃÏ¿Ì :", TR_IMPACT, &f, DP_WP);
3250 display_flag_aux(row+16, col, "µÛ·ì :", TR_VAMPIRIC, &f, DP_WP);
3251 display_flag_aux(row+17, col, "¥«¥ª¥¹¸ú²Ì:", TR_CHAOTIC, &f, DP_WP);
3252 display_flag_aux(row+18, col, "ÍýÎÏ :", TR_FORCE_WEAPON, &f, DP_WP);
3254 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3255 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3256 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3257 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3258 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3259 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3260 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3261 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3262 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3263 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3264 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3265 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3266 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3267 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3268 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3269 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3270 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3271 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3272 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3273 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3274 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3275 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3276 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3277 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3278 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3279 display_flag_aux(row+16, col, "Vampicic :", TR_VAMPIRIC, &f, DP_WP);
3280 display_flag_aux(row+17, col, "Chatic :", TR_CHAOTIC, &f, DP_WP);
3281 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3290 display_player_equippy(row-2, col+12, 0);
3291 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3294 display_flag_aux(row+ 0, col, "¥Æ¥ì¥Ñ¥·¡¼:", TR_TELEPATHY, &f, 0);
3295 display_flag_aux(row+ 1, col, "¼Ù°ESP :", TR_ESP_EVIL, &f, 0);
3296 display_flag_aux(row+ 2, col, "̵À¸ÊªESP :", TR_ESP_NONLIVING, &f, 0);
3297 display_flag_aux(row+ 3, col, "Á±ÎÉESP :", TR_ESP_GOOD, &f, 0);
3298 display_flag_aux(row+ 4, col, "ÉÔ»àESP :", TR_ESP_UNDEAD, &f, 0);
3299 display_flag_aux(row+ 5, col, "°ËâESP :", TR_ESP_DEMON, &f, 0);
3300 display_flag_aux(row+ 6, col, "ζESP :", TR_ESP_DRAGON, &f, 0);
3301 display_flag_aux(row+ 7, col, "¿Í´ÖESP :", TR_ESP_HUMAN, &f, 0);
3302 display_flag_aux(row+ 8, col, "ưʪESP :", TR_ESP_ANIMAL, &f, 0);
3303 display_flag_aux(row+ 9, col, "¥ª¡¼¥¯ESP :", TR_ESP_ORC, &f, 0);
3304 display_flag_aux(row+10, col, "¥È¥í¥ëESP :", TR_ESP_TROLL, &f, 0);
3305 display_flag_aux(row+11, col, "µð¿ÍESP :", TR_ESP_GIANT, &f, 0);
3307 display_flag_aux(row+13, col, "ÏÓÎÏ°Ý»ý :", TR_SUST_STR, &f, 0);
3308 display_flag_aux(row+14, col, "ÃÎÎÏ°Ý»ý :", TR_SUST_INT, &f, 0);
3309 display_flag_aux(row+15, col, "¸¤µ°Ý»ý :", TR_SUST_WIS, &f, 0);
3310 display_flag_aux(row+16, col, "´ïÍÑ°Ý»ý :", TR_SUST_DEX, &f, 0);
3311 display_flag_aux(row+17, col, "Âѵװݻý :", TR_SUST_CON, &f, 0);
3312 display_flag_aux(row+18, col, "Ì¥ÎÏ°Ý»ý :", TR_SUST_CHR, &f, 0);
3314 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3315 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3316 display_flag_aux(row+ 2, col, "ESP Noliv.:", TR_ESP_NONLIVING, &f, 0);
3317 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3318 display_flag_aux(row+ 4, col, "ESP Undead:", TR_ESP_UNDEAD, &f, 0);
3319 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3320 display_flag_aux(row+ 6, col, "ESP Dragon:", TR_ESP_DRAGON, &f, 0);
3321 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3322 display_flag_aux(row+ 8, col, "ESP Animal:", TR_ESP_ANIMAL, &f, 0);
3323 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3324 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3325 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3327 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3328 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3329 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3330 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3331 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3332 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3339 col = col + 12 + 18;
3341 display_player_equippy(row-2, col+14, 0);
3343 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3346 display_flag_aux(row+ 0, col, "Äɲù¶·â :", TR_BLOWS, &f, 0);
3347 display_flag_aux(row+ 1, col, "ºÎ·¡ :", TR_TUNNEL, &f, 0);
3348 display_flag_aux(row+ 2, col, "ÀÖ³°Àþ»ëÎÏ :", TR_INFRA, &f, 0);
3349 display_flag_aux(row+ 3, col, "ËâË¡Æ»¶ñ»ÙÇÛ:", TR_MAGIC_MASTERY, &f, 0);
3350 display_flag_aux(row+ 4, col, "±£Ì© :", TR_STEALTH, &f, 0);
3351 display_flag_aux(row+ 5, col, "õº÷ :", TR_SEARCH, &f, 0);
3353 display_flag_aux(row+ 7, col, "¾èÇÏ :", TR_RIDING, &f, 0);
3354 display_flag_aux(row+ 8, col, "ÅêÚ³ :", TR_THROW, &f, 0);
3355 display_flag_aux(row+ 9, col, "È¿¥Æ¥ì¥Ý¡¼¥È:", TR_NO_TELE, &f, 0);
3356 display_flag_aux(row+10, col, "È¿ËâË¡ :", TR_NO_MAGIC, &f, 0);
3357 display_flag_aux(row+11, col, "¾ÃÈñËâÎϸº¾¯:", TR_DEC_MANA, &f, 0);
3358 display_flag_aux(row+12, col, "·Ù¹ð :", TR_WARNING, &f, 0);
3359 display_flag_aux(row+13, col, "½ËÊ¡ :", TR_BLESSED, &f, 0);
3360 display_flag_aux(row+15, col, "·Ð¸³Ã͸º¾¯ :", TR_DRAIN_EXP, &f, 0);
3361 display_flag_aux(row+16, col, "Íð¥Æ¥ì¥Ý¡¼¥È:", TR_TELEPORT, &f, 0);
3362 display_flag_aux(row+17, col, "È¿´¶ :", TR_AGGRAVATE, &f, 0);
3363 display_flag_aux(row+18, col, "ÂÀ¸Å¤Î±åÇ° :", TR_TY_CURSE, &f, 0);
3365 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3366 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3367 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3368 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3369 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3370 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3372 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3373 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3374 display_flag_aux(row+ 9, col, "No Teleport :", TR_NO_TELE, &f, 0);
3375 display_flag_aux(row+10, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3376 display_flag_aux(row+11, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3377 display_flag_aux(row+12, col, "Warning :", TR_WARNING, &f, 0);
3378 display_flag_aux(row+13, col, "Blessed :", TR_BLESSED, &f, 0);
3379 display_flag_aux(row+15, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3380 display_flag_aux(row+16, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3381 display_flag_aux(row+17, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3382 display_flag_aux(row+18, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3389 * Special display, part 2a
3391 static void display_player_misc_info(void)
3396 /* Display basics */
3398 put_str("̾Á° :", 1, 26);
3399 put_str("ÀÊÌ :", 3, 1);
3400 put_str("¼ï² :", 4, 1);
3401 put_str("¿¦¶È :", 5, 1);
3403 put_str("Name :", 1, 26);
3404 put_str("Sex :", 3, 1);
3405 put_str("Race :", 4, 1);
3406 put_str("Class :", 5, 1);
3409 strcpy(tmp,ap_ptr->title);
3416 strcat(tmp,player_name);
3418 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3419 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3420 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3421 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3423 /* Display extras */
3425 put_str("¥ì¥Ù¥ë:", 6, 1);
3426 put_str("£È£Ð :", 7, 1);
3427 put_str("£Í£Ð :", 8, 1);
3429 put_str("Level :", 6, 1);
3430 put_str("Hits :", 7, 1);
3431 put_str("Mana :", 8, 1);
3435 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3436 c_put_str(TERM_L_BLUE, buf, 6, 9);
3437 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3438 c_put_str(TERM_L_BLUE, buf, 7, 9);
3439 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3440 c_put_str(TERM_L_BLUE, buf, 8, 9);
3445 * Special display, part 2b
3447 * How to print out the modifications and sustains.
3448 * Positive mods with no sustain will be light green.
3449 * Positive mods with a sustain will be dark green.
3450 * Sustains (with no modification) will be a dark green 's'.
3451 * Negative mods (from a curse) will be red.
3452 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3453 * No mod, no sustain, will be a slate '.'
3455 static void display_player_stat_info(void)
3462 u32b flgs[TR_FLAG_SIZE];
3477 /* Print out the labels for the columns */
3479 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3480 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3481 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3482 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3483 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3485 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3486 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3487 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3488 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3489 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3493 /* Display the stats */
3494 for (i = 0; i < 6; i++)
3498 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3499 else r_adj = rp_ptr->r_adj[i];
3501 /* Calculate equipment adjustment */
3504 /* Icky formula to deal with the 18 barrier */
3505 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3506 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3507 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3508 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3509 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3510 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3512 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3513 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3515 if (prace_is_(RACE_ENT))
3521 if (p_ptr->lev > 25) r_adj++;
3522 if (p_ptr->lev > 40) r_adj++;
3523 if (p_ptr->lev > 45) r_adj++;
3526 if (p_ptr->lev > 25) r_adj--;
3527 if (p_ptr->lev > 40) r_adj--;
3528 if (p_ptr->lev > 45) r_adj--;
3534 e_adj -= cp_ptr->c_adj[i];
3535 e_adj -= ap_ptr->a_adj[i];
3537 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3538 /* Reduced name of stat */
3539 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3541 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3544 /* Internal "natural" max value. Maxes at 18/100 */
3545 /* This is useful to see if you are maxed out */
3546 cnv_stat(p_ptr->stat_max[i], buf);
3547 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3550 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3552 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3555 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3557 /* Race, class, and equipment modifiers */
3558 (void)sprintf(buf, "%3d", r_adj);
3559 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3560 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3561 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3562 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3563 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3564 (void)sprintf(buf, "%3d", (int)e_adj);
3565 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3567 /* Actual maximal modified value */
3568 cnv_stat(p_ptr->stat_top[i], buf);
3569 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3571 /* Only display stat_use if not maximal */
3572 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3574 cnv_stat(p_ptr->stat_use[i], buf);
3575 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3580 col = stat_col + 41;
3582 /* Header and Footer */
3583 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3585 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3587 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3591 /* Process equipment */
3592 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3595 o_ptr = &inventory[i];
3598 k_idx = o_ptr->k_idx;
3600 /* Acquire "known" flags */
3601 object_flags_known(o_ptr, flgs);
3603 /* Initialize color based of sign of pval. */
3604 for (stat = 0; stat < 6; stat++)
3611 if (have_flag(flgs, stat))
3617 if (o_ptr->pval > 0)
3623 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3626 if (have_flag(flgs, stat + TR_SUST_STR))
3628 /* Dark green for sustained stats */
3633 if (o_ptr->pval < 0)
3639 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3644 else if (have_flag(flgs, stat + TR_SUST_STR))
3646 /* Dark green "s" */
3651 /* Dump proper character */
3652 Term_putch(col, row + stat+1, a, c);
3663 for (stat = 0; stat < 6; stat++)
3670 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3676 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3677 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3678 if (p_ptr->tsuyoshi) dummy += 4;
3680 else if (stat == A_WIS || stat == A_INT)
3682 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3683 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3685 else if (stat == A_DEX)
3687 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3688 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3689 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3691 else if (stat == A_CON)
3693 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3694 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3695 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3696 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3697 if (p_ptr->tsuyoshi) dummy += 4;
3699 else if (stat == A_CHR)
3701 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3702 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3703 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3704 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3705 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3706 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3722 if (dummy < 10) c = '0' + dummy;
3732 if (dummy > -10) c = '0' - dummy;
3739 if (have_flag(flgs, stat + TR_SUST_STR))
3741 /* Dark green "s" */
3748 Term_putch(col, row + stat+1, a, c);
3754 * Display the character on the screen (various modes)
3756 * The top one and bottom two lines are left blank.
3758 * Mode 0 = standard display with skills
3759 * Mode 1 = standard display with history
3760 * Mode 2 = summary of various things
3761 * Mode 3 = summary of various things (part 2)
3762 * Mode 4 = mutations
3764 void display_player(int mode)
3773 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3782 if ((mode == 0) || (mode == 1))
3784 /* Name, Sex, Race, Class */
3786 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3788 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3791 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3792 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3793 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3794 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3799 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3801 strcpy(tmp, realm_names[p_ptr->realm1]);
3802 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3805 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3806 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3808 /* Age, Height, Weight, Social */
3809 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
3811 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
3812 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3813 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3814 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3816 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3817 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3818 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3819 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3821 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3824 /* Display the stats */
3825 for (i = 0; i < 6; i++)
3827 /* Special treatment of "injured" stats */
3828 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3832 /* Use lowercase stat name */
3833 put_str(stat_names_reduced[i], 3 + i, 54);
3835 /* Get the current stat */
3836 value = p_ptr->stat_use[i];
3838 /* Obtain the current stat (modified) */
3839 cnv_stat(value, buf);
3841 /* Display the current stat (modified) */
3842 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
3844 /* Acquire the max stat */
3845 value = p_ptr->stat_top[i];
3847 /* Obtain the maximum stat (modified) */
3848 cnv_stat(value, buf);
3850 /* Display the maximum stat (modified) */
3851 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
3854 /* Normal treatment of "normal" stats */
3857 /* Assume uppercase stat name */
3858 put_str(stat_names[i], 3 + i, 54);
3860 /* Obtain the current stat (modified) */
3861 cnv_stat(p_ptr->stat_use[i], buf);
3863 /* Display the current stat (modified) */
3864 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
3867 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3870 c_put_str(TERM_WHITE, "!", 3+i, 59);
3872 c_put_str(TERM_WHITE, "!", 3+i, 59-2);
3877 /* Display "history" info */
3883 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
3885 put_str("(Character Background)", 11, 25);
3888 for (i = 0; i < 4; i++)
3890 put_str(p_ptr->history[i], i + 12, 10);
3895 if (p_ptr->is_dead && p_ptr->total_winner)
3898 strcpy(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£");
3900 strcpy(statmsg, "...You retired from the adventure after the winning.");
3903 else if (p_ptr->is_dead)
3907 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
3909 /* Get the quest text */
3910 init_flags = INIT_ASSIGN;
3912 process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
3915 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3917 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3923 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, p_ptr->died_from);
3925 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3931 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), p_ptr->died_from);
3933 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3936 else if (character_dungeon)
3940 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
3942 /* Get the quest text */
3943 init_flags = INIT_ASSIGN;
3945 process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
3948 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
3950 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
3956 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
3958 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
3964 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
3966 sprintf(statmsg, "...Now, you are in %s.", map_name());
3972 char temp[64*2], *t;
3973 roff_to_buf(statmsg, 60, temp);
3975 for(i=0 ; i<2 ; i++)
3981 put_str(t, i + 5 + 12, 10);
3989 /* Display "various" info */
3992 display_player_middle();
3993 display_player_various();
4000 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4003 display_player_misc_info();
4004 display_player_stat_info();
4005 display_player_flag_info();
4011 display_player_other_flag_info();
4016 do_cmd_knowledge_mutations();
4020 errr make_character_dump(FILE *fff)
4027 char o_name[MAX_NLEN];
4032 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4033 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4035 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4036 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4041 /* Display player */
4044 /* Dump part of the screen */
4045 for (y = 1; y < 22; y++)
4048 for (x = 0; x < 79; x++)
4050 /* Get the attr/char */
4051 (void)(Term_what(x, y, &a, &c));
4057 /* End the string */
4060 /* Kill trailing spaces */
4061 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4065 fprintf(fff, "%s\n", buf);
4067 fprintf(fff, "%s\n", buf);
4072 /* Display history */
4075 /* Dump part of the screen */
4076 for (y = 10; y < 19; y++)
4079 for (x = 0; x < 79; x++)
4081 /* Get the attr/char */
4082 (void)(Term_what(x, y, &a, &c));
4088 /* End the string */
4091 /* Kill trailing spaces */
4092 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4095 fprintf(fff, "%s\n", buf);
4099 /* Display history */
4102 /* Dump part of the screen */
4103 for (y = 2; y < 22; y++)
4106 for (x = 0; x < 79; x++)
4108 /* Get the attr/char */
4109 (void)(Term_what(x, y, &a, &c));
4111 /* Dump it (Ignore equippy tile graphic) */
4118 /* End the string */
4121 /* Kill trailing spaces */
4122 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4125 fprintf(fff, "%s\n", buf);
4128 for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
4131 for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
4137 for (i = m_max - 1; i >= 1; i--)
4139 monster_type *m_ptr = &m_list[i];
4142 if (!m_ptr->r_idx) continue;
4143 if (!is_pet(m_ptr)) continue;
4144 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4148 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4150 fprintf(fff, "\n [leading pets]\n\n");
4154 monster_desc(pet_name, m_ptr, 0x88);
4155 fprintf(fff, "%s", pet_name);
4156 if (p_ptr->riding == i)
4158 fprintf(fff, " ¾èÇÏÃæ");
4160 fprintf(fff, " (riding)");
4164 if (pet) fprintf(fff, "\n");
4168 fprintf(fff, "\n [¥¯¥¨¥¹¥È¾ðÊó] \n");
4170 fprintf(fff, "\n [Quest information] \n");
4174 fprintf(fff, "\n¡ÔãÀ®¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
4176 fprintf(fff, "\n< Completed Quest >\n");
4179 for (i = 1; i < max_quests; i++)
4181 /* No info from "silent" quests */
4182 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
4184 if (quest[i].status == QUEST_STATUS_FINISHED)
4190 if (i < MIN_RANDOM_QUEST)
4192 /* Set the quest number temporary */
4193 old_quest = p_ptr->inside_quest;
4194 p_ptr->inside_quest = i;
4197 init_flags = INIT_ASSIGN;
4199 process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
4201 /* Reset the old quest number */
4202 p_ptr->inside_quest = old_quest;
4205 if ((i >= MIN_RANDOM_QUEST) && quest[i].r_idx)
4207 /* Print the quest info */
4209 if (quest[i].complev == 0)
4213 " %s (%d³¬) - ÉÔÀᄀ\n",
4215 " %s (Dungeon level: %d) - (Cancelled)\n",
4217 r_name+r_info[quest[i].r_idx].name,
4224 " %s (%d³¬) - ¥ì¥Ù¥ë%d\n",
4226 " %s (Dungeon level: %d) - level %d\n",
4228 r_name+r_info[quest[i].r_idx].name,
4235 /* Print the quest info */
4237 fprintf(fff, " %s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
4239 fprintf(fff, " %s (Danger level: %d) - level %d\n",
4242 quest[i].name, quest[i].level, quest[i].complev);
4247 if (!total) fprintf(fff, " ¤Ê¤·\n");
4249 if (!total) fprintf(fff, " Nothing.\n");
4253 fprintf(fff, "\n¡Ô¼ºÇÔ¤·¤¿¥¯¥¨¥¹¥È¡Õ\n");
4255 fprintf(fff, "\n< Failed Quest >\n");
4258 for (i = 1; i < max_quests; i++)
4260 /* No info from "silent" quests */
4261 if (quest[i].flags & QUEST_FLAG_SILENT) continue;
4263 if ((quest[i].status == QUEST_STATUS_FAILED_DONE) || (quest[i].status == QUEST_STATUS_FAILED))
4269 if (i < MIN_RANDOM_QUEST)
4271 /* Set the quest number temporary */
4272 old_quest = p_ptr->inside_quest;
4273 p_ptr->inside_quest = i;
4275 /* Get the quest text */
4276 init_flags = INIT_ASSIGN;
4278 process_dungeon_file("q_info_j.txt", 0, 0, 0, 0);
4280 /* Reset the old quest number */
4281 p_ptr->inside_quest = old_quest;
4284 if ((i >= MIN_RANDOM_QUEST) && quest[i].r_idx)
4286 /* Print the quest info */
4288 fprintf(fff, " %s (%d³¬) - ¥ì¥Ù¥ë%d\n",
4290 fprintf(fff, " %s (Dungeon level: %d) - level %d\n",
4293 r_name+r_info[quest[i].r_idx].name, quest[i].level, quest[i].complev);
4297 /* Print the quest info */
4299 fprintf(fff, " %s (´í¸±ÅÙ:%d³¬ÁêÅö) - ¥ì¥Ù¥ë%d\n",
4301 fprintf(fff, " %s (Danger level: %d) - level %d\n",
4304 quest[i].name, quest[i].level, quest[i].complev);
4309 if (!total) fprintf(fff, " ¤Ê¤·\n");
4311 if (!total) fprintf(fff, " Nothing.\n");
4315 if (p_ptr->is_dead && !p_ptr->total_winner)
4318 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4320 fprintf(fff, "\n [Last messages]\n\n");
4322 for (i = MIN(message_num(), 30); i >= 0; i--)
4324 fprintf(fff,"> %s\n",message_str((s16b)i));
4330 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4332 fprintf(fff, "\n [Miscellaneous information]\n");
4336 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4338 fprintf(fff, "\n Recall Depth:\n");
4340 for (y = 1; y < max_d_idx; y++)
4344 if (!d_info[y].maxdepth) continue;
4345 if (!max_dlv[y]) continue;
4346 if (d_info[y].final_guardian)
4348 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4350 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4353 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4355 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4361 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4363 fprintf(fff, "\n Preserve Mode: ON");
4368 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4370 fprintf(fff, "\n Preserve Mode: OFF");
4374 if (ironman_autoscum)
4376 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4378 fprintf(fff, "\n Autoscum: ALWAYS");
4383 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4385 fprintf(fff, "\n Autoscum: ON");
4390 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4392 fprintf(fff, "\n Autoscum: OFF");
4396 if (ironman_small_levels)
4398 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4400 fprintf(fff, "\n Small Levels: ALWAYS");
4403 else if (always_small_levels)
4405 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4407 fprintf(fff, "\n Small Levels: ON");
4410 else if (small_levels)
4412 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4414 fprintf(fff, "\n Small Levels: ENABLED");
4419 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4421 fprintf(fff, "\n Small Levels: OFF");
4427 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4429 fprintf(fff, "\n Vanilla Town: ON");
4434 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4436 fprintf(fff, "\n Lite Town: ON");
4442 fprintf(fff, "\n Ź¤Ê¤·: ON");
4444 fprintf(fff, "\n No Shops: ON");
4448 if (ironman_downward)
4450 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4452 fprintf(fff, "\n Diving only: ON");
4458 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4460 fprintf(fff, "\n Unusual rooms: ON");
4464 if (ironman_nightmare)
4466 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4468 fprintf(fff, "\n Nightmare Mode: ON");
4472 if (ironman_empty_levels)
4474 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4476 fprintf(fff, "\n Arena Levels: ALWAYS");
4479 else if (empty_levels)
4481 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4483 fprintf(fff, "\n Arena Levels: ENABLED");
4488 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4490 fprintf(fff, "\n Arena Levels: OFF");
4495 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4497 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4500 if (p_ptr->arena_number == 99)
4503 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4505 fprintf(fff, "\n Arena: defeated\n");
4508 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4511 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4513 fprintf(fff, "\n Arena: True Champion\n");
4516 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4519 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4521 fprintf(fff, "\n Arena: Champion\n");
4527 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4529 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");
4535 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4537 fprintf(fff, "\n You have done something illegal.");
4541 if (stupid_monsters)
4543 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4545 fprintf(fff, "\n Your opponents are behaving stupidly.");
4551 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4553 fprintf(fff, "\n You possess munchkinish power over death.");
4558 /* Monsters slain */
4563 for (k = 1; k < max_r_idx; k++)
4565 monster_race *r_ptr = &r_info[k];
4567 if (r_ptr->flags1 & RF1_UNIQUE)
4569 bool dead = (r_ptr->max_num == 0);
4577 s16b This = r_ptr->r_pkills;
4587 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4589 fprintf(fff,"\n You have defeated no enemies yet.\n");
4592 else if (Total == 1)
4594 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4596 fprintf(fff,"\n You have defeated one enemy.\n");
4601 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4603 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4609 if (p_ptr->old_race1 || p_ptr->old_race2)
4612 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4614 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4616 for (i = 0; i < MAX_RACES; i++)
4618 if (p_ptr->start_race == i) continue;
4621 if (!(p_ptr->old_race1 & 1L << i)) continue;
4625 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4628 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4630 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4635 if (p_ptr->old_realm)
4637 for (i = 0; i < MAX_MAGIC; i++)
4639 if (!(p_ptr->old_realm & 1L << i)) continue;
4641 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4643 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4649 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4651 fprintf(fff, "\n\n [Virtues]\n\n");
4655 fprintf(fff, "°À : %s\n", your_alignment());
4657 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4662 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4665 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4667 fprintf(fff, "\n\n [Mutations]\n\n");
4670 dump_mutations(fff);
4674 /* Skip some lines */
4675 fprintf(fff, "\n\n");
4678 /* Dump the equipment */
4682 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4684 fprintf(fff, " [Character Equipment]\n\n");
4687 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4689 object_desc(o_name, &inventory[i], TRUE, 3);
4690 if ((i == INVEN_LARM) && p_ptr->ryoute)
4692 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4694 strcpy(o_name, "(wielding with two-hands)");
4696 fprintf(fff, "%c%s %s\n",
4697 index_to_label(i), paren, o_name);
4699 fprintf(fff, "\n\n");
4702 /* Dump the inventory */
4704 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4706 fprintf(fff, " [Character Inventory]\n\n");
4709 for (i = 0; i < INVEN_PACK; i++)
4711 /* Don't dump the empty slots */
4712 if (!inventory[i].k_idx) break;
4714 /* Dump the inventory slots */
4715 object_desc(o_name, &inventory[i], TRUE, 3);
4716 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4719 /* Add an empty line */
4720 fprintf(fff, "\n\n");
4722 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4724 /* Print all homes in the different towns */
4725 st_ptr = &town[1].store[STORE_HOME];
4727 /* Home -- if anything there */
4728 if (st_ptr->stock_num)
4730 /* Header with name of the town */
4732 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4734 fprintf(fff, " [Home Inventory]\n");
4738 /* Dump all available items */
4739 for (i = 0; i < st_ptr->stock_num; i++)
4743 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4745 fprintf(fff, "\n ( page %d )\n", x++);
4747 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4748 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4751 /* Add an empty line */
4752 fprintf(fff, "\n\n");
4756 /* Print all homes in the different towns */
4757 st_ptr = &town[1].store[STORE_MUSEUM];
4759 /* Home -- if anything there */
4760 if (st_ptr->stock_num)
4762 /* Header with name of the town */
4764 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4766 fprintf(fff, " [Museum]\n");
4770 /* Dump all available items */
4771 for (i = 0; i < st_ptr->stock_num; i++)
4774 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4775 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4776 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4778 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4779 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4780 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4785 /* Add an empty line */
4786 fprintf(fff, "\n\n");
4790 fprintf(fff, " [¥Á¥§¥Ã¥¯¥µ¥à: \"%s\"]\n\n", get_check_sum());
4792 fprintf(fff, " [Check Sum: \"%s\"]\n\n", get_check_sum());
4799 * Hack -- Dump a character description file
4801 * XXX XXX XXX Allow the "full" flag to dump additional info,
4802 * and trigger its usage from various places in the code.
4804 errr file_character(cptr name, bool full)
4813 /* Build the filename */
4814 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
4816 /* File type is "TEXT" */
4817 FILE_TYPE(FILE_TYPE_TEXT);
4819 /* Check for existing file */
4820 fd = fd_open(buf, O_RDONLY);
4827 /* Close the file */
4832 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4834 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4839 if (get_check(out_val)) fd = -1;
4842 /* Open the non-existing file */
4843 if (fd < 0) fff = my_fopen(buf, "w");
4850 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4852 msg_format("Character dump failed!");
4861 (void)make_character_dump(fff);
4871 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4873 msg_print("Character dump successful.");
4883 typedef struct file_tag
4890 typedef struct file_tags
4897 static void add_tag(file_tags *the_tags, cptr name, int line)
4899 if (the_tags->index < 64)
4901 file_tag *tag = &(the_tags->tags[the_tags->index]);
4903 /* Set the name and end it with '\0' */
4904 strncpy(tag->name, name, 31);
4905 tag->name[31] = '\0';
4907 /* Set the line-number */
4908 tag->line_number = line;
4910 /* Increase the number of tags */
4916 static int get_line(file_tags *the_tags, cptr name)
4920 /* Search for the tag */
4921 for (i = 0; i < the_tags->index; i++)
4923 if (streq(the_tags->tags[i].name, name))
4925 return the_tags->tags[i].line_number;
4935 * Recursive file perusal.
4937 * Return FALSE on 'Q', otherwise TRUE.
4939 * Process various special text in the input file, including
4940 * the "menu" structures used by the "help file" system.
4942 * XXX XXX XXX Consider using a temporary file.
4944 * XXX XXX XXX Allow the user to "save" the current file.
4946 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4950 /* Number of "real" lines passed by */
4953 /* Number of "real" lines in the file */
4956 /* Backup value for "line" */
4959 /* Color of the next line */
4960 byte color = TERM_WHITE;
4965 /* This screen has sub-screens */
4968 /* Current help file */
4971 /* Find this string (if any) */
4974 /* Jump to this tag */
4977 /* Hold a string to find */
4980 /* Hold a string to show */
4984 char filename[1024];
4986 /* Describe this thing */
4992 /* General buffer */
4995 /* Lower case version of the buffer, for searching */
4998 /* Aux pointer for making lc_buf (and find!) lowercase */
5001 /* Sub-menu information */
5004 /* Tags for in-file references */
5007 bool reverse = (line < 0);
5011 Term_get_size(&wid, &hgt);
5021 strcpy(caption, "");
5023 /* Wipe the hooks */
5024 for (i = 0; i < 68; i++)
5032 /* Copy the filename */
5033 strcpy(filename, name);
5035 n = strlen(filename);
5037 /* Extract the tag from the filename */
5038 for (i = 0; i < n; i++)
5040 if (filename[i] == '#')
5043 tag = filename + i + 1;
5048 /* Redirect the name */
5051 /* Hack XXX XXX XXX */
5055 strcpy(caption, what);
5057 /* Access the "file" */
5061 fff = my_fopen(path, "r");
5064 /* Look in "help" */
5069 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5071 sprintf(caption, "Help file '%s'", name);
5075 /* Build the filename */
5076 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5079 fff = my_fopen(path, "r");
5082 /* Look in "info" */
5087 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5089 sprintf(caption, "Info file '%s'", name);
5093 /* Build the filename */
5094 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5097 fff = my_fopen(path, "r");
5100 /* Look in "info" */
5103 /* Build the filename */
5104 path_build(path, sizeof(path), ANGBAND_DIR, name);
5106 for (i = 0; path[i]; i++)
5107 if ('\\' == path[i])
5108 path[i] = PATH_SEP[0];
5112 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5114 sprintf(caption, "Info file '%s'", name);
5118 fff = my_fopen(path, "r");
5126 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5128 msg_format("Cannot open '%s'.", name);
5138 /* Pre-Parse the file */
5143 /* Read a line or stop */
5144 if (my_fgets(fff, buf, sizeof(buf))) break;
5147 if (prefix(buf, "#####")) str = &buf[6];
5150 /* XXX Parse "menu" items */
5151 if (prefix(str, "***** "))
5153 /* Notice "menu" requests */
5154 if ((str[6] == '[') && isalpha(str[7]))
5156 /* This is a menu file */
5159 /* Extract the menu item */
5162 if ((str[8] == ']') && (str[9] == ' '))
5164 /* Extract the menu item */
5165 strncpy(hook[k], str + 10, 31);
5167 /* Make sure it's null-terminated */
5171 /* Notice "tag" requests */
5172 else if (str[6] == '<')
5174 str[strlen(str) - 1] = '\0';
5175 add_tag(&tags, str + 7, next);
5182 /* Count the "real" lines */
5186 /* Save the number of "real" lines */
5189 /* start from bottom when reverse mode */
5190 if (line == -1) line = ((size-1)/rows)*rows;
5192 /* Go to the tagged line */
5193 if (tag) line = get_line(&tags, tag);
5195 /* Display the file */
5201 /* Restart when necessary */
5202 if (line >= size - rows) line = size - rows;
5203 if (line < 0) line = 0;
5205 /* Re-open the file if needed */
5211 /* Hack -- Re-Open the file */
5212 fff = my_fopen(path, "r");
5215 if (!fff) return (FALSE);
5217 /* File has been restarted */
5221 /* Goto the selected line */
5225 if (my_fgets(fff, buf, sizeof(buf))) break;
5227 /* Skip tags/links */
5228 if (prefix(buf, "***** ")) continue;
5230 /* Count the lines */
5234 /* Dump the next 20, or rows, lines of the file */
5235 for (i = 0; i < rows; )
5240 /* Hack -- track the "first" line */
5241 if (!i) line = next;
5243 /* Get a line of the file or stop */
5244 if (my_fgets(fff, buf, sizeof(buf))) break;
5246 /* Hack -- skip "special" lines */
5247 if (prefix(buf, "***** ")) continue;
5250 if (prefix(buf, "#####"))
5252 color = color_char_to_attr(buf[5]);
5261 /* Count the "real" lines */
5264 /* Make a lower case version of str for searching */
5265 strcpy(lc_buf, str);
5267 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5270 if (iskanji(*lc_buf_ptr))
5274 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5277 /* Hack -- keep searching */
5278 if (find && !i && !strstr(lc_buf, find)) continue;
5280 /* Hack -- stop searching */
5289 if (prefix(str + x, "[[[[["))
5291 byte c = color_char_to_attr(str[x + 5]);
5294 /* Ok print the link name */
5295 while (str[x] != ']')
5297 Term_putch(print_x, i + 2, c, str[x]);
5304 Term_putch(print_x, i + 2, color, str[x]);
5311 /* Hilite "shower" */
5316 /* Display matches */
5317 while ((s2 = strstr(s2, shower)) != NULL)
5319 int len = strlen(shower);
5321 /* Display the match */
5322 Term_putstr(s2-lc_buf, i+2, len, TERM_YELLOW, &str[s2-lc_buf]);
5329 /* Count the printed lines */
5333 /* Hack -- failed search */
5343 /* Show a general "title" */
5348 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5350 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5353 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5354 caption, line, size), 0, 0);
5364 caption, line, size), 0, 0);
5367 /* Prompt -- small files */
5372 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5374 prt("[Press ESC to exit.]", hgt - 1, 0);
5379 /* Prompt -- large files */
5384 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5386 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5388 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5392 /* Get a keypress */
5395 /* Hack -- return to last screen */
5396 if (k == '<') break;
5398 /* Show the help for the help */
5401 /* Hack - prevent silly recursion */
5403 if (strcmp(name, "jhelpinfo.txt") != 0)
5404 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5406 if (strcmp(name, "helpinfo.txt") != 0)
5407 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5411 /* Hack -- try showing */
5416 prt("¶¯Ä´: ", hgt - 1, 0);
5418 prt("Show: ", hgt - 1, 0);
5421 (void)askfor_aux(shower, 80);
5424 /* Hack -- try finding */
5429 prt("¸¡º÷: ", hgt - 1, 0);
5431 prt("Find: ", hgt - 1, 0);
5435 if (askfor_aux(finder, 80))
5442 /* Make finder lowercase */
5443 for (cnt = 0; finder[cnt] != 0; cnt++)
5446 if (iskanji(finder[cnt]))
5450 finder[cnt] = tolower(finder[cnt]);
5454 strcpy(shower, finder);
5458 /* Hack -- go to a specific line */
5463 prt("¹Ô: ", hgt - 1, 0);
5465 prt("Goto Line: ", hgt - 1, 0);
5470 if (askfor_aux(tmp, 80))
5476 /* Hack -- go to a specific file */
5481 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5482 strcpy(tmp, "jhelp.hlp");
5484 prt("Goto File: ", hgt - 1, 0);
5485 strcpy(tmp, "help.hlp");
5489 if (askfor_aux(tmp, 80))
5491 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5495 /* Allow backing up */
5498 line = line + (reverse ? rows : -rows);
5499 if (line < 0) line = 0;
5502 /* Advance a single line */
5503 if ((k == '\n') || (k == '\r'))
5505 line = line + (reverse ? -1 : 1);
5506 if (line < 0) line = 0;
5510 /* Move up / down */
5514 if (line < 0) line = 0;
5517 if (k == '2') line++;
5519 /* Advance one page */
5522 line = line + (reverse ? -rows : rows);
5523 if (line < 0) line = ((size-1)/rows)*rows;
5526 /* Recurse on numbers */
5534 if ((key > -1) && hook[key][0])
5536 /* Recurse on that file */
5537 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5542 /* Hack, dump to file */
5552 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5554 if (!get_string("File name: ", xtmp, 80))
5566 /* Build the filename */
5567 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5569 /* Hack -- Re-Open the file */
5570 fff = my_fopen(path, "r");
5572 ffp = my_fopen(buff, "w");
5578 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5580 msg_print("Failed to open file.");
5587 sprintf(xtmp, "%s: %s", player_name, what);
5588 my_fputs(ffp, xtmp, 80);
5589 my_fputs(ffp, "\n", 80);
5591 while (!my_fgets(fff, buff, sizeof(buff)))
5592 my_fputs(ffp, buff, 80);
5601 /* Hack -- Re-Open the file */
5602 fff = my_fopen(path, "r");
5605 /* Exit on escape */
5606 if (k == ESCAPE) break;
5607 if (k == 'q') break;
5610 /* Close the file */
5614 if (k == 'q') return (FALSE);
5622 * Peruse the On-Line-Help
5624 void do_cmd_help(void)
5629 /* Peruse the main help file */
5631 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5633 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5643 * Process the player name.
5644 * Extract a clean "base name".
5645 * Build the savefile name if needed.
5647 void process_player_name(bool sf)
5652 /* Cannot be too long */
5653 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5655 if (strlen(player_name) > 8)
5657 if (strlen(player_name) > 15)
5662 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5664 quit_fmt("The name '%s' is too long!", player_name);
5670 /* Cannot contain "icky" characters */
5671 for (i = 0; player_name[i]; i++)
5673 /* No control characters */
5675 if (iskanji(player_name[i])){i++;continue;}
5676 if (iscntrl( (unsigned char)player_name[i]))
5678 if (iscntrl(player_name[i]))
5682 /* Illegal characters */
5684 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5686 quit_fmt("The name '%s' contains control chars!", player_name);
5695 /* Extract "useful" letters */
5696 for (i = 0; player_name[i]; i++)
5699 unsigned char c = player_name[i];
5701 char c = player_name[i];
5705 /* Convert "dot" to "underscore" */
5706 if (c == '.') c = '_';
5708 /* Accept all the letters */
5709 player_base[k++] = c;
5714 /* Extract "useful" letters */
5715 for (i = 0; player_name[i]; i++)
5718 unsigned char c = player_name[i];
5720 char c = player_name[i];
5723 /* Accept some letters */
5726 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5727 player_base[k++] = c;
5729 player_base[k++] = player_name[i];
5732 else if (iskana(c)) player_base[k++] = c;
5736 /* Convert path separator to underscore */
5737 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5738 player_base[k++] = '_';
5739 i += strlen(PATH_SEP);
5742 /* Convert space, dot, and underscore to underscore */
5743 else if (strchr(". _", c)) player_base[k++] = '_';
5745 else if (isprint(c)) player_base[k++] = c;
5753 /* Hack -- max length */
5759 player_base[k] = '\0';
5761 /* Require a "base" name */
5762 if (!player_base[0]) strcpy(player_base, "PLAYER");
5765 #ifdef SAVEFILE_MUTABLE
5771 if (!savefile_base[0] && savefile[0])
5778 t = strstr(s, PATH_SEP);
5783 strcpy(savefile_base, s);
5786 if (!savefile_base[0] || !savefile[0])
5789 /* Change the savefile name */
5794 strcpy(savefile_base, player_base);
5796 #ifdef SAVEFILE_USE_UID
5797 /* Rename the savefile, using the player_uid and player_base */
5798 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5800 /* Rename the savefile, using the player_base */
5801 (void)sprintf(temp, "%s", player_base);
5805 /* Hack -- support "flat directory" usage on VM/ESA */
5806 (void)sprintf(temp, "%s.sv", player_base);
5809 /* Build the filename */
5810 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
5816 * Gets a name for the character, reacting to name changes.
5818 * Assumes that "display_player(0)" has just been called
5820 * Perhaps we should NOT ask for a name (at "birth()") on
5821 * Unix machines? XXX XXX
5823 * What a horrible name for a global function. XXX XXX XXX
5829 /* Save the player name */
5830 strcpy(tmp, player_name);
5832 /* Prompt for a new name */
5834 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5836 if (get_string("Enter a name for your character: ", tmp, 15))
5840 strcpy(player_name, tmp);
5842 else if (0 == strlen(player_name))
5844 /* Use default name */
5845 strcpy(player_name, "PLAYER");
5848 /* Process the player name */
5849 process_player_name(FALSE);
5851 strcpy(tmp,ap_ptr->title);
5858 strcat(tmp,player_name);
5860 /* Re-Draw the name (in light blue) */
5861 Term_erase(34, 1, 255);
5862 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5864 /* Erase the prompt, etc */
5871 * Hack -- commit suicide
5873 void do_cmd_suicide(void)
5880 /* Verify Retirement */
5881 if (p_ptr->total_winner)
5885 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
5887 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
5892 /* Verify Suicide */
5897 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5899 if (!get_check("Do you really want to commit suicide? ")) return;
5904 if (!p_ptr->noscore)
5906 /* Special Verification for suicide */
5908 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5910 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5916 if (i != '@') return;
5920 p_ptr->playing = FALSE;
5922 /* Kill the player */
5923 p_ptr->is_dead = TRUE;
5926 p_ptr->leaving = TRUE;
5928 if (!p_ptr->total_winner)
5931 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5932 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5934 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5935 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5937 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5940 /* Cause of death */
5942 (void)strcpy(p_ptr->died_from, "ÅÓÃ潪λ");
5944 (void)strcpy(p_ptr->died_from, "Quitting");
5954 void do_cmd_save_game(int is_autosave)
5956 /* Autosaves do not disturb */
5960 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5962 msg_print("Autosaving the game...");
5968 /* Disturb the player */
5972 /* Clear messages */
5980 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
5982 prt("Saving game...", 0, 0);
5989 /* The player is not dead */
5991 (void)strcpy(p_ptr->died_from, "(¥»¡¼¥Ö)");
5993 (void)strcpy(p_ptr->died_from, "(saved)");
5997 /* Forbid suspend */
5998 signals_ignore_tstp();
6000 /* Save the player */
6004 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6006 prt("Saving game... done.", 0, 0);
6011 /* Save failed (oops) */
6015 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6017 prt("Saving game... failed!", 0, 0);
6022 /* Allow suspend again */
6023 signals_handle_tstp();
6028 /* Note that the player is not dead */
6030 (void)strcpy(p_ptr->died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6032 (void)strcpy(p_ptr->died_from, "(alive and well)");
6039 * Save the game and exit
6041 void do_cmd_save_and_exit(void)
6043 p_ptr->playing = FALSE;
6046 p_ptr->leaving = TRUE;
6048 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6050 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6056 * Hack -- Calculates the total number of points earned -JWT-
6058 long total_points(void)
6062 u32b point, point_h, point_l;
6063 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6065 if (stupid_monsters) mult -= 70;
6066 if (!preserve_mode) mult += 10;
6067 if (!autoroller) mult += 10;
6068 if (!smart_learn) mult -= 20;
6069 if (!terrain_streams) mult -= 20;
6070 if (smart_cheat) mult += 30;
6071 if (ironman_shops) mult += 50;
6072 if (ironman_small_levels) mult += 10;
6073 if (ironman_empty_levels) mult += 20;
6074 if (!powerup_home) mult += 50;
6075 if (ironman_rooms) mult += 100;
6076 if (ironman_nightmare) mult += 100;
6078 if (mult < 5) mult = 5;
6080 for (i = 0; i < max_d_idx; i++)
6081 if(max_dlv[i] > max_dl)
6082 max_dl = max_dlv[i];
6084 point_l = (p_ptr->max_exp + (100 * max_dl));
6085 point_h = point_l / 0x10000L;
6086 point_l = point_l % 0x10000L;
6089 point_h += point_l / 0x10000L;
6090 point_l %= 0x10000L;
6092 point_l += ((point_h % 100) << 16);
6096 point = (point_h << 16) + (point_l);
6097 if (p_ptr->arena_number < 99)
6098 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6100 if (ironman_downward) point *= 2;
6101 if (p_ptr->pclass == CLASS_BERSERKER)
6103 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6107 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6110 if (p_ptr->total_winner) point = 2;
6112 if (easy_band) point = (0 - point);
6120 * Centers a string within a 31 character string -JWT-
6122 static void center_string(char *buf, cptr str)
6129 /* Necessary border */
6133 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6139 * Save a "bones" file for a dead character
6141 * Note that we will not use these files until Angband 2.8.0, and
6142 * then we will only use the name and level on which death occured.
6144 * Should probably attempt some form of locking...
6146 static void make_bones(void)
6153 /* Ignore wizards and borgs */
6154 if (!(p_ptr->noscore & 0x00FF))
6156 /* Ignore people who die in town */
6161 /* XXX XXX XXX "Bones" name */
6162 sprintf(tmp, "bone.%03d", dun_level);
6164 /* Build the filename */
6165 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6167 /* Attempt to open the bones file */
6168 fp = my_fopen(str, "r");
6170 /* Close it right away */
6171 if (fp) my_fclose(fp);
6173 /* Do not over-write a previous ghost */
6176 /* File type is "TEXT" */
6177 FILE_TYPE(FILE_TYPE_TEXT);
6179 /* Try to write a new "Bones File" */
6180 fp = my_fopen(str, "w");
6182 /* Not allowed to write it? Weird. */
6186 fprintf(fp, "%s\n", player_name);
6187 fprintf(fp, "%d\n", p_ptr->mhp);
6188 fprintf(fp, "%d\n", p_ptr->prace);
6189 fprintf(fp, "%d\n", p_ptr->pclass);
6191 /* Close and save the Bones file */
6200 * Redefinable "print_tombstone" action
6202 bool (*tombstone_aux)(void) = NULL;
6206 * Display a "tomb-stone"
6208 static void print_tomb(void)
6212 /* Do we use a special tombstone ? */
6215 /* Use tombstone hook */
6216 done = (*tombstone_aux)();
6219 /* Print the text-tombstone */
6233 time_t ct = time((time_t)0);
6239 /* Build the filename */
6241 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead_j.txt");
6243 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "dead.txt");
6247 /* Open the News file */
6248 fp = my_fopen(buf, "r");
6255 /* Dump the file to the screen */
6256 while (0 == my_fgets(fp, buf, sizeof(buf)))
6258 /* Display and advance */
6259 put_str(buf, i++, 0);
6268 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6282 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6285 center_string(buf, player_name);
6286 put_str(buf, 6, 11);
6289 center_string(buf, "the");
6290 put_str(buf, 7, 11);
6293 center_string(buf, p);
6294 put_str(buf, 8, 11);
6297 center_string(buf, cp_ptr->title);
6299 put_str(buf, 10, 11);
6302 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6304 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6307 center_string(buf, tmp);
6308 put_str(buf, 11, 11);
6311 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6313 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6316 center_string(buf, tmp);
6317 put_str(buf, 12, 11);
6320 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6322 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6325 center_string(buf, tmp);
6326 put_str(buf, 13, 11);
6329 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6330 if (streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6332 strcpy(tmp, "<¼«»¦>");
6336 if (streq(p_ptr->died_from, "ripe"))
6338 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6340 else if (streq(p_ptr->died_from, "Seppuku"))
6342 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6346 strcpy(tmp, p_ptr->died_from);
6349 center_string(buf, tmp);
6350 put_str(buf, 14, 11);
6352 if(!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6354 if( dun_level == 0 )
6356 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6357 if(streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6359 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6363 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6368 if(streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6370 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6374 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6377 center_string(buf, tmp);
6378 put_str(buf, 15, 11);
6381 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6382 center_string(buf, tmp);
6383 put_str(buf, 14, 11);
6386 if (strlen(p_ptr->died_from) > 24)
6388 strncpy(dummy, p_ptr->died_from, 24);
6390 (void)sprintf(tmp, "by %s.", dummy);
6393 (void)sprintf(tmp, "by %s.", p_ptr->died_from);
6395 center_string(buf, tmp);
6396 put_str(buf, 15, 11);
6401 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6402 center_string(buf, tmp);
6403 put_str(buf, 17, 11);
6406 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6408 msg_format("Goodbye, %s!", player_name);
6416 * Display some character info
6418 static void show_info(void)
6424 /* Hack -- Know everything in the inven/equip */
6425 for (i = 0; i < INVEN_TOTAL; i++)
6427 o_ptr = &inventory[i];
6429 /* Skip non-objects */
6430 if (!o_ptr->k_idx) continue;
6432 /* Aware and Known */
6433 object_aware(o_ptr);
6434 object_known(o_ptr);
6437 for (i = 1; i < max_towns; i++)
6439 st_ptr = &town[i].store[STORE_HOME];
6441 /* Hack -- Know everything in the home */
6442 for (j = 0; j < st_ptr->stock_num; j++)
6444 o_ptr = &st_ptr->stock[j];
6446 /* Skip non-objects */
6447 if (!o_ptr->k_idx) continue;
6449 /* Aware and Known */
6450 object_aware(o_ptr);
6451 object_known(o_ptr);
6455 /* Hack -- Recalculate bonuses */
6456 p_ptr->update |= (PU_BONUS);
6461 /* Flush all input keys */
6464 /* Flush messages */
6468 /* Describe options */
6470 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6471 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6473 prt("You may now dump a character record to one or more files.", 21, 0);
6474 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6478 /* Dump character records as requested */
6485 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6487 put_str("Filename: ", 23, 0);
6492 strcpy(out_val, "");
6494 /* Ask for filename (or abort) */
6495 if (!askfor_aux(out_val, 60)) return;
6497 /* Return means "show on screen" */
6498 if (!out_val[0]) break;
6503 /* Dump a character file */
6504 (void)file_character(out_val, TRUE);
6512 /* Display player */
6515 /* Prompt for inventory */
6517 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6519 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6523 /* Allow abort at this point */
6524 if (inkey() == ESCAPE) return;
6527 /* Show equipment and inventory */
6529 /* Equipment -- if any */
6533 item_tester_full = TRUE;
6534 (void)show_equip(0);
6536 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6538 prt("You are using: -more-", 0, 0);
6541 if (inkey() == ESCAPE) return;
6544 /* Inventory -- if any */
6548 item_tester_full = TRUE;
6549 (void)show_inven(0);
6551 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6553 prt("You are carrying: -more-", 0, 0);
6556 if (inkey() == ESCAPE) return;
6559 /* Homes in the different towns */
6560 for (l = 1; l < max_towns; l++)
6562 st_ptr = &town[l].store[STORE_HOME];
6564 /* Home -- if anything there */
6565 if (st_ptr->stock_num)
6567 /* Display contents of the home */
6568 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6574 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6576 char o_name[MAX_NLEN];
6580 o_ptr = &st_ptr->stock[i];
6582 /* Print header, clear line */
6583 sprintf(tmp_val, "%c) ", I2A(j));
6584 prt(tmp_val, j+2, 4);
6586 /* Display object description */
6587 object_desc(o_name, o_ptr, TRUE, 3);
6588 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6593 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6595 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6600 if (inkey() == ESCAPE) return;
6607 static bool check_score(void)
6613 if (highscore_fd < 0)
6616 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6618 msg_print("Score file unavailable.");
6625 #ifndef SCORE_WIZARDS
6626 /* Wizard-mode pre-empts scoring */
6627 if (p_ptr->noscore & 0x000F)
6630 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6632 msg_print("Score not registered for wizards.");
6641 /* Borg-mode pre-empts scoring */
6642 if (p_ptr->noscore & 0x00F0)
6645 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6647 msg_print("Score not registered for borgs.");
6655 #ifndef SCORE_CHEATERS
6656 /* Cheaters are not scored */
6657 if (p_ptr->noscore & 0xFF00)
6660 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6662 msg_print("Score not registered for cheaters.");
6672 if (!p_ptr->total_winner && streq(p_ptr->died_from, "¶¯À©½ªÎ»"))
6674 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Interrupting"))
6679 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6681 msg_print("Score not registered due to interruption.");
6690 if (!p_ptr->total_winner && streq(p_ptr->died_from, "ÅÓÃ潪λ"))
6692 if (!p_ptr->total_winner && streq(p_ptr->died_from, "Quitting"))
6697 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6699 msg_print("Score not registered due to quitting.");
6709 * Close up the current game (player may or may not be dead)
6711 * This function is called only from "main.c" and "signals.c".
6713 void close_game(void)
6716 bool do_send = TRUE;
6718 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6723 /* Flush the messages */
6726 /* Flush the input */
6730 /* No suspending now */
6731 signals_ignore_tstp();
6734 /* Hack -- Character is now "icky" */
6735 character_icky = TRUE;
6738 /* Build the filename */
6739 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6741 /* Open the high score file, for reading/writing */
6742 highscore_fd = fd_open(buf, O_RDWR);
6748 /* Handle retirement */
6749 if (p_ptr->total_winner) kingly();
6753 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6755 if (!munchkin_death || get_check("Save death? "))
6760 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6762 if (!save_player()) msg_print("death save failed!");
6765 else do_send = FALSE;
6772 /* Show more info */
6780 if ((!send_world_score(do_send)))
6783 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6785 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6788 p_ptr->wait_report_score = TRUE;
6789 p_ptr->is_dead = FALSE;
6791 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6793 if (!save_player()) msg_print("death save failed!");
6797 if (!p_ptr->wait_report_score)
6800 else if (highscore_fd >= 0)
6802 display_scores_aux(0, 10, -1, NULL);
6805 /* Dump bones file */
6814 do_cmd_save_game(FALSE);
6816 /* Prompt for scores XXX XXX XXX */
6818 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6820 prt("Press Return (or Escape).", 0, 40);
6824 /* Predict score (or ESCAPE) */
6825 if (inkey() != ESCAPE) predict_score();
6829 /* Shut the high score file */
6830 (void)fd_close(highscore_fd);
6832 /* Forget the high score fd */
6836 /* Allow suspending now */
6837 signals_handle_tstp();
6842 * Handle abrupt death of the visual system
6844 * This routine is called only in very rare situations, and only
6845 * by certain visual systems, when they experience fatal errors.
6847 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6848 * save file so that player can see tombstone when restart.
6850 void exit_game_panic(void)
6852 /* If nothing important has happened, just quit */
6854 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6856 if (!character_generated || character_saved) quit("panic");
6860 /* Mega-Hack -- see "msg_print()" */
6863 /* Clear the top line */
6866 /* Hack -- turn off some things */
6869 /* Mega-Hack -- Delay death */
6870 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
6872 /* Hardcode panic save */
6873 p_ptr->panic_save = 1;
6875 /* Forbid suspend */
6876 signals_ignore_tstp();
6878 /* Indicate panic save */
6880 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6882 (void)strcpy(p_ptr->died_from, "(panic save)");
6886 /* Panic save, or get worried */
6888 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6890 if (!save_player()) quit("panic save failed!");
6894 /* Successful panic save */
6896 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6898 quit("panic save succeeded!");
6905 * Get a random line from a file
6906 * Based on the monster speech patch by Matt Graham,
6908 errr get_rnd_line(cptr file_name, int entry, char *output)
6912 int line, counter, test, numentries;
6917 /* Build the filename */
6918 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
6921 fp = my_fopen(buf, "r");
6924 if (!fp) return (-1);
6926 /* Find the entry of the monster */
6929 /* Get a line from the file */
6930 if (my_fgets(fp, buf, sizeof(buf)) == 0)
6932 /* Count the lines */
6935 /* Look for lines starting with 'N:' */
6936 if ((buf[0] == 'N') && (buf[1] == ':'))
6938 /* Allow default lines */
6945 else if (buf[2] == 'M')
6947 if (r_info[entry].flags1 & RF1_MALE)
6953 else if (buf[2] == 'F')
6955 if (r_info[entry].flags1 & RF1_FEMALE)
6961 /* Get the monster number */
6962 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6964 /* Is it the right monster? */
6973 /* Error while converting the monster number */
6974 msg_format("Error in line %d of %s!",
6975 line_num, file_name);
6983 /* Reached end of file */
6990 /* Get the number of entries */
6994 if (my_fgets(fp, buf, sizeof(buf)) == 0)
6996 /* Count the lines */
6999 /* Look for the number of entries */
7000 if (isdigit(buf[0]))
7002 /* Get the number of entries */
7003 numentries = atoi(buf);
7009 /* Count the lines */
7012 /* Reached end of file without finding the number */
7013 msg_format("Error in line %d of %s!",
7014 line_num, file_name);
7023 /* Grab an appropriate line number */
7024 line = randint0(numentries);
7026 /* Get the random line */
7027 for (counter = 0; counter <= line; counter++)
7029 /* Count the lines */
7034 test = my_fgets(fp, buf, sizeof(buf));
7035 if(test || buf[0] != '#')
7041 /* Found the line */
7042 if (counter == line) break;
7046 /* Error - End of file */
7047 msg_format("Error in line %d of %s!",
7048 line_num, file_name);
7056 strcpy(output, buf);
7063 /* Close the file */
7072 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7076 for (i=0;i<count;i++){
7077 result=get_rnd_line(file_name, entry, output);
7080 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7088 * Process file for auto picker/destroyer.
7090 errr process_pickpref_file(cptr name)
7099 /* Build the filename */
7100 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7102 err = process_pref_file_aux(buf, TRUE);
7111 static errr counts_seek(int fd, u32b where, bool flag)
7114 char temp1[128], temp2[128];
7115 u32b zero_header[3] = {0L, 0L, 0L};
7118 #ifdef SAVEFILE_USE_UID
7119 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7121 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7123 for (i = 0; temp1[i]; i++)
7124 temp1[i] ^= (i+1) * 63;
7129 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7131 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7136 fd_seek(fd, seekpoint);
7137 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7138 fd_write(fd, (char*)(temp1), sizeof(temp1));
7142 if (strcmp(temp1, temp2) == 0)
7145 seekpoint += 128 + 3 * sizeof(u32b);
7148 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7151 u32b counts_read(int where)
7158 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7160 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7162 fd = fd_open(buf, O_RDONLY);
7164 if (counts_seek(fd, where, FALSE) ||
7165 fd_read(fd, (char*)(&count), sizeof(u32b)))
7173 errr counts_write(int where, u32b count)
7179 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info_j.raw");
7181 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, "z_info.raw");
7183 fd = fd_open(buf, O_RDWR);
7186 /* File type is "DATA" */
7187 FILE_TYPE(FILE_TYPE_DATA);
7189 /* Create a new high score file */
7190 fd = fd_make(buf, 0644);
7193 if (fd_lock(fd, F_WRLCK)) return 1;
7195 counts_seek(fd, where, TRUE);
7196 fd_write(fd, (char*)(&count), sizeof(u32b));
7198 if (fd_lock(fd, F_UNLCK)) return 1;
7206 #ifdef HANDLE_SIGNALS
7213 * Handle signals -- suspend
7215 * Actually suspend the game, and then resume cleanly
7217 static void handle_signal_suspend(int sig)
7219 /* Disable handler */
7220 (void)signal(sig, SIG_IGN);
7227 /* Suspend the "Term" */
7228 Term_xtra(TERM_XTRA_ALIVE, 0);
7230 /* Suspend ourself */
7231 (void)kill(0, SIGSTOP);
7233 /* Resume the "Term" */
7234 Term_xtra(TERM_XTRA_ALIVE, 1);
7236 /* Redraw the term */
7239 /* Flush the term */
7244 /* Restore handler */
7245 (void)signal(sig, handle_signal_suspend);
7250 * Handle signals -- simple (interrupt and quit)
7252 * This function was causing a *huge* number of problems, so it has
7253 * been simplified greatly. We keep a global variable which counts
7254 * the number of times the user attempts to kill the process, and
7255 * we commit suicide if the user does this a certain number of times.
7257 * We attempt to give "feedback" to the user as he approaches the
7258 * suicide thresh-hold, but without penalizing accidental keypresses.
7260 * To prevent messy accidents, we should reset this global variable
7261 * whenever the user enters a keypress, or something like that.
7263 static void handle_signal_simple(int sig)
7265 /* Disable handler */
7266 (void)signal(sig, SIG_IGN);
7269 /* Nothing to save, just quit */
7270 if (!character_generated || character_saved) quit(NULL);
7273 /* Count the signals */
7277 /* Terminate dead characters */
7280 /* Mark the savefile */
7282 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»");
7284 (void)strcpy(p_ptr->died_from, "Abortion");
7303 /* Allow suicide (after 5) */
7304 else if (signal_count >= 5)
7306 /* Cause of "death" */
7308 (void)strcpy(p_ptr->died_from, "¶¯À©½ªÎ»Ãæ");
7310 (void)strcpy(p_ptr->died_from, "Interrupting");
7319 p_ptr->playing = FALSE;
7322 p_ptr->is_dead = TRUE;
7325 p_ptr->leaving = TRUE;
7339 /* Give warning (after 4) */
7340 else if (signal_count >= 4)
7343 Term_xtra(TERM_XTRA_NOISE, 0);
7345 /* Clear the top line */
7346 Term_erase(0, 0, 255);
7348 /* Display the cause */
7350 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7352 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7360 /* Give warning (after 2) */
7361 else if (signal_count >= 2)
7364 Term_xtra(TERM_XTRA_NOISE, 0);
7367 /* Restore handler */
7368 (void)signal(sig, handle_signal_simple);
7373 * Handle signal -- abort, kill, etc
7375 static void handle_signal_abort(int sig)
7379 Term_get_size(&wid, &hgt);
7382 /* Disable handler */
7383 (void)signal(sig, SIG_IGN);
7386 /* Nothing to save, just quit */
7387 if (!character_generated || character_saved) quit(NULL);
7394 /* Clear the bottom line */
7395 Term_erase(0, hgt - 1, 255);
7397 /* Give a warning */
7398 Term_putstr(0, hgt - 1, -1, TERM_RED,
7400 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7402 "A gruesome software bug LEAPS out at you!");
7408 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7410 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7418 p_ptr->panic_save = 1;
7422 (void)strcpy(p_ptr->died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7424 (void)strcpy(p_ptr->died_from, "(panic save)");
7428 /* Forbid suspend */
7429 signals_ignore_tstp();
7431 /* Attempt to save */
7435 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7437 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7446 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7448 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7458 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7460 quit("software bug");
7469 * Ignore SIGTSTP signals (keyboard suspend)
7471 void signals_ignore_tstp(void)
7475 (void)signal(SIGTSTP, SIG_IGN);
7481 * Handle SIGTSTP signals (keyboard suspend)
7483 void signals_handle_tstp(void)
7487 (void)signal(SIGTSTP, handle_signal_suspend);
7494 * Prepare to handle the relevant signals
7496 void signals_init(void)
7500 (void)signal(SIGHUP, SIG_IGN);
7505 (void)signal(SIGTSTP, handle_signal_suspend);
7510 (void)signal(SIGINT, handle_signal_simple);
7514 (void)signal(SIGQUIT, handle_signal_simple);
7519 (void)signal(SIGFPE, handle_signal_abort);
7523 (void)signal(SIGILL, handle_signal_abort);
7527 (void)signal(SIGTRAP, handle_signal_abort);
7531 (void)signal(SIGIOT, handle_signal_abort);
7535 (void)signal(SIGKILL, handle_signal_abort);
7539 (void)signal(SIGBUS, handle_signal_abort);
7543 (void)signal(SIGSEGV, handle_signal_abort);
7547 (void)signal(SIGTERM, handle_signal_abort);
7551 (void)signal(SIGPIPE, handle_signal_abort);
7555 (void)signal(SIGEMT, handle_signal_abort);
7559 (void)signal(SIGDANGER, handle_signal_abort);
7563 (void)signal(SIGSYS, handle_signal_abort);
7567 (void)signal(SIGXCPU, handle_signal_abort);
7571 (void)signal(SIGPWR, handle_signal_abort);
7577 #else /* HANDLE_SIGNALS */
7583 void signals_ignore_tstp(void)
7590 void signals_handle_tstp(void)
7597 void signals_init(void)
7600 #endif /* HANDLE_SIGNALS */