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 },
335 * Parse a sub-file of the "extra info" (format shown below)
337 * Each "action" line has an "action symbol" in the first column,
338 * followed by a colon, followed by some command specific info,
339 * usually in the form of "tokens" separated by colons or slashes.
341 * Blank lines, lines starting with white space, and lines starting
342 * with pound signs ("#") are ignored (as comments).
344 * Note the use of "tokenize()" to allow the use of both colons and
345 * slashes as delimeters, while still allowing final tokens which
346 * may contain any characters including "delimiters".
348 * Note the use of "strtol()" to allow all "integers" to be encoded
349 * in decimal, hexidecimal, or octal form.
351 * Note that "monster zero" is used for the "player" attr/char, "object
352 * zero" will be used for the "stack" attr/char, and "feature zero" is
353 * used for the "nothing" attr/char.
355 * Parse another file recursively, see below for details
358 * Specify the attr/char values for "monsters" by race index
361 * Specify the attr/char values for "objects" by kind index
364 * Specify the attr/char values for "features" by feature index
367 * Specify the attr/char values for unaware "objects" by kind tval
370 * Specify the attr/char values for inventory "objects" by kind tval
373 * Define a macro action, given an encoded macro action
376 * Create a normal macro, given an encoded macro trigger
379 * Create a command macro, given an encoded macro trigger
382 * Create a keyset mapping
383 * S:<key>:<key>:<dir>
385 * Turn an option off, given its name
388 * Turn an option on, given its name
391 * Specify visual information, given an index, and some data
392 * V:<num>:<kv>:<rv>:<gv>:<bv>
394 * Specify the set of colors to use when drawing a zapped spell
397 * Specify a macro trigger template and macro trigger names.
398 * T:<template>:<modifier chr>:<modifier name1>:<modifier name2>:...
399 * T:<trigger>:<keycode>:<shift-keycode>
403 errr process_pref_file_command(char *buf)
410 /* Require "?:*" format */
411 if (buf[1] != ':') return (1);
414 /* Process "%:<fname>" */
417 /* Attempt to Process the given file */
418 return (process_pref_file(buf + 2));
422 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
425 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
428 i = (huge)strtol(zz[0], NULL, 0);
429 n1 = strtol(zz[1], NULL, 0);
430 n2 = strtol(zz[2], NULL, 0);
431 if (i >= max_r_idx) return (1);
433 if (n1) r_ptr->x_attr = n1;
434 if (n2) r_ptr->x_char = n2;
439 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
440 else if (buf[0] == 'K')
442 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
445 i = (huge)strtol(zz[0], NULL, 0);
446 n1 = strtol(zz[1], NULL, 0);
447 n2 = strtol(zz[2], NULL, 0);
448 if (i >= max_k_idx) return (1);
450 if (n1) k_ptr->x_attr = n1;
451 if (n2) k_ptr->x_char = n2;
456 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
457 else if (buf[0] == 'F')
459 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
462 i = (huge)strtol(zz[0], NULL, 0);
463 n1 = strtol(zz[1], NULL, 0);
464 n2 = strtol(zz[2], NULL, 0);
465 if (i >= max_f_idx) return (1);
467 if (n1) f_ptr->x_attr = n1;
468 if (n2) f_ptr->x_char = n2;
473 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
474 else if (buf[0] == 'S')
476 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
478 j = (byte)strtol(zz[0], NULL, 0);
479 n1 = strtol(zz[1], NULL, 0);
480 n2 = strtol(zz[2], NULL, 0);
481 misc_to_attr[j] = n1;
482 misc_to_char[j] = n2;
487 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
488 else if (buf[0] == 'U')
490 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
492 j = (huge)strtol(zz[0], NULL, 0);
493 n1 = strtol(zz[1], NULL, 0);
494 n2 = strtol(zz[2], NULL, 0);
495 for (i = 1; i < max_k_idx; i++)
497 object_kind *k_ptr = &k_info[i];
498 if (k_ptr->tval == j)
500 if (n1) k_ptr->d_attr = n1;
501 if (n2) k_ptr->d_char = n2;
508 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
509 else if (buf[0] == 'E')
511 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
513 j = (byte)strtol(zz[0], NULL, 0) % 128;
514 n1 = strtol(zz[1], NULL, 0);
515 if (n1) tval_to_attr[j] = n1;
521 /* Process "A:<str>" -- save an "action" for later */
522 else if (buf[0] == 'A')
524 text_to_ascii(macro__buf, buf+2);
528 /* Process "P:<str>" -- normal macro */
529 else if (buf[0] == 'P')
532 text_to_ascii(tmp, buf+2);
533 macro_add(tmp, macro__buf);
538 /* Process "C:<str>" -- create keymap */
539 else if (buf[0] == 'C')
545 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return (1);
547 mode = strtol(zz[0], NULL, 0);
548 if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1);
550 text_to_ascii(tmp, zz[1]);
551 if (!tmp[0] || tmp[1]) return (1);
554 string_free(keymap_act[mode][i]);
556 keymap_act[mode][i] = string_make(macro__buf);
562 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
563 else if (buf[0] == 'V')
565 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
567 i = (byte)strtol(zz[0], NULL, 0);
568 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
569 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
570 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
571 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
577 /* Process "X:<str>" -- turn option off */
578 else if (buf[0] == 'X')
580 for (i = 0; option_info[i].o_desc; i++)
582 int os = option_info[i].o_set;
583 int ob = option_info[i].o_bit;
585 if (option_info[i].o_var &&
586 option_info[i].o_text &&
587 streq(option_info[i].o_text, buf + 2))
589 if (alive && 6 == option_info[i].o_page && !wizard)
592 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
594 msg_format("Startup options can not changed! '%s'", buf);
601 option_flag[os] &= ~(1L << ob);
602 (*option_info[i].o_var) = FALSE;
607 /* don't know that option. ignore it.*/
609 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
611 msg_format("Ignored invalid option: %s", buf);
617 /* Process "Y:<str>" -- turn option on */
618 else if (buf[0] == 'Y')
620 for (i = 0; option_info[i].o_desc; i++)
622 int os = option_info[i].o_set;
623 int ob = option_info[i].o_bit;
625 if (option_info[i].o_var &&
626 option_info[i].o_text &&
627 streq(option_info[i].o_text, buf + 2))
629 if (alive && 6 == option_info[i].o_page && !wizard)
632 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
634 msg_format("Startup options can not changed! '%s'", buf);
641 option_flag[os] |= (1L << ob);
642 (*option_info[i].o_var) = TRUE;
647 /* don't know that option. ignore it.*/
649 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
651 msg_format("Ignored invalid option: %s", buf);
657 /* Process "Z:<type>:<str>" -- set spell color */
658 else if (buf[0] == 'Z')
661 char *t = strchr(buf + 2, ':');
669 for (i = 0; gf_desc[i].name; i++)
671 /* Match this type */
672 if (streq(gf_desc[i].name, buf + 2))
674 /* Remember this color set */
675 gf_color[gf_desc[i].num] = quark_add(t);
682 /* set macro trigger names and a template */
683 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
684 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
685 else if (buf[0] == 'T')
688 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
694 if (macro_template != NULL)
696 free(macro_template);
697 macro_template = NULL;
698 for (i = 0; i < max_macrotrigger; i++)
699 free(macro_trigger_name[i]);
700 max_macrotrigger = 0;
703 if (*zz[0] == '\0') return 0; /* clear template */
705 if (2 + num != tok) return 1; /* error */
707 len = strlen(zz[0])+1+num+1;
708 for (i = 0; i < num; i++)
709 len += strlen(zz[2+i])+1;
710 macro_template = malloc(len);
712 strcpy(macro_template, zz[0]);
714 macro_template + strlen(macro_template) + 1;
715 strcpy(macro_modifier_chr, zz[1]);
716 macro_modifier_name[0] =
717 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
718 for (i = 0; i < num; i++)
720 strcpy(macro_modifier_name[i], zz[2+i]);
721 macro_modifier_name[i+1] = macro_modifier_name[i] +
722 strlen(macro_modifier_name[i]) + 1;
729 if (max_macrotrigger >= MAX_MACRO_TRIG)
732 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
734 msg_print("Too many macro triggers!");
738 m = max_macrotrigger;
741 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
743 len += strlen(zz[2]) + 1;
744 macro_trigger_name[m] = malloc(len);
746 t = macro_trigger_name[m];
755 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
756 strlen(macro_trigger_name[m]) + 1;
757 strcpy(macro_trigger_keycode[0][m], zz[1]);
760 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
761 strlen(macro_trigger_keycode[0][m]) + 1;
762 strcpy(macro_trigger_keycode[1][m], zz[2]);
766 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
778 * Helper function for "process_pref_file()"
781 * v: output buffer array
787 static cptr process_pref_file_expr(char **sp, char *fp)
804 while (isspace(*s)) s++;
822 t = process_pref_file_expr(&s, &f);
831 else if (streq(t, "IOR"))
834 while (*s && (f != b2))
836 t = process_pref_file_expr(&s, &f);
837 if (*t && !streq(t, "0")) v = "1";
842 else if (streq(t, "AND"))
845 while (*s && (f != b2))
847 t = process_pref_file_expr(&s, &f);
848 if (*t && streq(t, "0")) v = "0";
853 else if (streq(t, "NOT"))
856 while (*s && (f != b2))
858 t = process_pref_file_expr(&s, &f);
859 if (*t && streq(t, "1")) v = "0";
864 else if (streq(t, "EQU"))
869 t = process_pref_file_expr(&s, &f);
871 while (*s && (f != b2))
874 t = process_pref_file_expr(&s, &f);
875 if (*t && !streq(p, t)) v = "0";
880 else if (streq(t, "LEQ"))
885 t = process_pref_file_expr(&s, &f);
887 while (*s && (f != b2))
890 t = process_pref_file_expr(&s, &f);
891 if (*t && (strcmp(p, t) > 0)) v = "0";
896 else if (streq(t, "GEQ"))
901 t = process_pref_file_expr(&s, &f);
903 while (*s && (f != b2))
906 t = process_pref_file_expr(&s, &f);
907 if (*t && (strcmp(p, t) < 0)) v = "0";
914 while (*s && (f != b2))
916 t = process_pref_file_expr(&s, &f);
921 if (f != b2) v = "?x?x?";
923 /* Extract final and Terminate */
924 if ((f = *s) != '\0') *s++ = '\0';
930 /* Accept all printables except spaces and brackets */
931 while (isprint(*s) && !strchr(" []", *s)) ++s;
933 /* Extract final and Terminate */
934 if ((f = *s) != '\0') *s++ = '\0';
940 if (streq(b+1, "SYS"))
945 else if (streq(b+1, "KEYBOARD"))
947 v = ANGBAND_KEYBOARD;
951 else if (streq(b+1, "GRAF"))
956 /* Monochrome mode */
957 else if (streq(b+1, "MONOCHROME"))
966 else if (streq(b+1, "RACE"))
976 else if (streq(b+1, "CLASS"))
986 else if (streq(b+1, "PLAYER"))
992 else if (streq(b+1, "REALM1"))
995 v = E_realm_names[p_ptr->realm1];
997 v = realm_names[p_ptr->realm1];
1002 else if (streq(b+1, "REALM2"))
1005 v = E_realm_names[p_ptr->realm2];
1007 v = realm_names[p_ptr->realm2];
1012 else if (streq(b+1, "LEVEL"))
1014 sprintf(tmp, "%02d", p_ptr->lev);
1039 * Process line for auto picker/destroyer.
1041 static errr process_pickpref_file_line(char *buf)
1047 /* Nuke illegal char */
1048 for(i = 0; buf[i]; i++)
1051 if (iskanji(buf[i]))
1057 if (isspace(buf[i]) && buf[i] != ' ')
1064 act = DO_AUTOPICK | DO_DISPLAY;
1069 act &= ~DO_AUTOPICK;
1070 act |= DO_AUTODESTROY;
1075 act &= ~DO_AUTOPICK;
1076 act |= DONT_AUTOPICK;
1088 /* don't mind upper or lower case */
1090 for (i = 0; s[i]; i++)
1100 s[i] = tolower(s[i]);
1102 /* Auto-inscription? */
1111 /* Skip empty line */
1114 if (max_autopick == MAX_AUTOPICK)
1117 /* Already has the same entry? */
1118 for(i = 0; i < max_autopick; i++)
1119 if(!strcmp(s, autopick_name[i]))
1122 autopick_name[max_autopick] = string_make(s);
1123 autopick_action[max_autopick] = act;
1125 autopick_insc[max_autopick] = string_make(s2);
1133 * Open the "user pref file" and parse it.
1135 static errr process_pref_file_aux(cptr name, bool read_pickpref)
1147 bool bypass = FALSE;
1151 fp = my_fopen(name, "r");
1154 if (!fp) return (-1);
1156 /* Process the file */
1157 while (0 == my_fgets(fp, buf, 1024))
1162 /* Skip "empty" lines */
1163 if (!buf[0]) continue;
1165 /* Skip "blank" lines */
1167 if (!iskanji(buf[0]))
1169 if (isspace(buf[0])) continue;
1172 if (buf[0] == '#') continue;
1179 /* Process "?:<expr>" */
1180 if ((buf[0] == '?') && (buf[1] == ':'))
1189 /* Parse the expr */
1190 v = process_pref_file_expr(&s, &f);
1193 bypass = (streq(v, "0") ? TRUE : FALSE);
1199 /* Apply conditionals */
1200 if (bypass) continue;
1203 /* Process "%:<file>" */
1206 /* Process that file if allowed */
1208 (void)process_pickpref_file(buf + 2);
1210 (void)process_pref_file(buf + 2);
1217 /* Process the line */
1218 err = process_pref_file_command(buf);
1220 /* This is not original pref line... */
1225 err = process_pickpref_file_line(buf);
1233 /* Print error message */
1234 /* ToDo: Add better error messages */
1236 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1237 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1239 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1240 msg_format("Parsing '%s'", old);
1245 /* Close the file */
1255 * Process the "user pref file" with the given name
1257 * See the functions above for a list of legal "commands".
1259 * We also accept the special "?" and "%" directives, which
1260 * allow conditional evaluation and filename inclusion.
1262 errr process_pref_file(cptr name)
1268 /* Build the filename */
1269 path_build(buf, 1024, ANGBAND_DIR_PREF, name);
1271 /* Process the system pref file */
1272 err1 = process_pref_file_aux(buf, FALSE);
1274 /* Stop at parser errors, but not at non-existing file */
1275 if (err1 > 0) return err1;
1281 /* Build the filename */
1282 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1284 /* Process the user pref file */
1285 err2 = process_pref_file_aux(buf, FALSE);
1291 /* User file does not exist, but read system pref file */
1292 if (err2 < 0 && !err1)
1295 /* Result of user file processing */
1304 * Operating hours for ANGBAND (defaults to non-work hours)
1306 static char days[7][29] =
1308 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1309 "MON:XXXXXXXX.........XXXXXXX",
1310 "TUE:XXXXXXXX.........XXXXXXX",
1311 "WED:XXXXXXXX.........XXXXXXX",
1312 "THU:XXXXXXXX.........XXXXXXX",
1313 "FRI:XXXXXXXX.........XXXXXXX",
1314 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1318 * Restict usage (defaults to no restrictions)
1320 static bool check_time_flag = FALSE;
1328 errr check_time(void)
1336 /* No restrictions */
1337 if (!check_time_flag) return (0);
1339 /* Check for time violation */
1340 c = time((time_t *)0);
1344 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1355 * Initialize CHECK_TIME
1357 errr check_time_init(void)
1367 /* Build the filename */
1368 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1371 fp = my_fopen(buf, "r");
1373 /* No file, no restrictions */
1374 if (!fp) return (0);
1376 /* Assume restrictions */
1377 check_time_flag = TRUE;
1379 /* Parse the file */
1380 while (0 == my_fgets(fp, buf, 80))
1382 /* Skip comments and blank lines */
1383 if (!buf[0] || (buf[0] == '#')) continue;
1385 /* Chop the buffer */
1388 /* Extract the info */
1389 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1390 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1391 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1392 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1393 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1394 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1395 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1411 #ifndef MAXHOSTNAMELEN
1412 # define MAXHOSTNAMELEN 64
1415 typedef struct statstime statstime;
1421 unsigned int v_pgpgin;
1422 unsigned int v_pgpgout;
1423 unsigned int v_pswpin;
1424 unsigned int v_pswpout;
1425 unsigned int v_intr;
1431 unsigned int v_swtch;
1433 struct timeval boottime;
1434 struct timeval curtime;
1438 * Maximal load (if any).
1440 static int check_load_value = 0;
1448 errr check_load(void)
1453 struct statstime st;
1455 /* Success if not checking */
1456 if (!check_load_value) return (0);
1458 /* Check the load */
1459 if (0 == rstat("localhost", &st))
1461 long val1 = (long)(st.avenrun[2]);
1462 long val2 = (long)(check_load_value) * FSCALE;
1464 /* Check for violation */
1465 if (val1 >= val2) return (1);
1476 * Initialize CHECK_LOAD
1478 errr check_load_init(void)
1487 char temphost[MAXHOSTNAMELEN+1];
1488 char thishost[MAXHOSTNAMELEN+1];
1491 /* Build the filename */
1492 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1494 /* Open the "load" file */
1495 fp = my_fopen(buf, "r");
1497 /* No file, no restrictions */
1498 if (!fp) return (0);
1501 check_load_value = 100;
1503 /* Get the host name */
1504 (void)gethostname(thishost, (sizeof thishost) - 1);
1507 while (0 == my_fgets(fp, buf, 1024))
1511 /* Skip comments and blank lines */
1512 if (!buf[0] || (buf[0] == '#')) continue;
1514 /* Parse, or ignore */
1515 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1517 /* Skip other hosts */
1518 if (!streq(temphost, thishost) &&
1519 !streq(temphost, "localhost")) continue;
1521 /* Use that value */
1522 check_load_value = value;
1528 /* Close the file */
1538 #define ENTRY_BARE_HAND 0
1539 #define ENTRY_TWO_HANDS 1
1540 #define ENTRY_RIGHT_HAND1 2
1541 #define ENTRY_LEFT_HAND1 3
1542 #define ENTRY_LEFT_HAND2 4
1543 #define ENTRY_RIGHT_HAND2 5
1544 #define ENTRY_POSTURE 6
1545 #define ENTRY_SHOOT_HIT_DAM 7
1546 #define ENTRY_SHOOT_POWER 8
1547 #define ENTRY_SPEED 9
1548 #define ENTRY_BASE_AC 10
1549 #define ENTRY_LEVEL 11
1550 #define ENTRY_CUR_EXP 12
1551 #define ENTRY_MAX_EXP 13
1552 #define ENTRY_EXP_TO_ADV 14
1553 #define ENTRY_GOLD 15
1554 #define ENTRY_DAY 16
1557 #define ENTRY_PLAY_TIME 19
1558 #define ENTRY_SKILL_FIGHT 20
1559 #define ENTRY_SKILL_SHOOT 21
1560 #define ENTRY_SKILL_SAVING 22
1561 #define ENTRY_SKILL_STEALTH 23
1562 #define ENTRY_SKILL_PERCEP 24
1563 #define ENTRY_SKILL_SEARCH 25
1564 #define ENTRY_SKILL_DISARM 26
1565 #define ENTRY_SKILL_DEVICE 27
1566 #define ENTRY_BLOWS 28
1567 #define ENTRY_SHOTS 29
1568 #define ENTRY_AVG_DMG 30
1569 #define ENTRY_INFRA 31
1571 #define ENTRY_NAME 32
1572 #define ENTRY_SEX 33
1573 #define ENTRY_RACE 34
1574 #define ENTRY_CLASS 35
1575 #define ENTRY_REALM 36
1576 #define ENTRY_PATRON 37
1577 #define ENTRY_AGE 38
1578 #define ENTRY_HEIGHT 39
1579 #define ENTRY_WEIGHT 40
1580 #define ENTRY_SOCIAL 41
1581 #define ENTRY_ALIGN 42
1590 } disp_player_line[]
1593 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1594 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1595 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1596 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1597 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1598 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1600 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1601 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1602 {01, 20, 25, "²Ã®"},
1603 { 1, 19, 25, "£Á£Ã"},
1604 {29, 13, 21, "¥ì¥Ù¥ë"},
1605 {29, 14, 21, "·Ð¸³ÃÍ"},
1606 {29, 15, 21, "ºÇÂç·Ð¸³"},
1607 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1608 {29, 17, 21, "½ê»ý¶â"},
1609 {29, 19, 21, "ÆüÉÕ"},
1610 {29, 10, 21, "£È£Ð"},
1611 {29, 11, 21, "£Í£Ð"},
1612 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1613 {54, 10, -1, "ÂǷ⹶·â :"},
1614 {54, 11, -1, "¼Í·â¹¶·â :"},
1615 {54, 12, -1, "ËâË¡Ëɸæ :"},
1616 {54, 13, -1, "±£Ì©¹ÔÆ° :"},
1617 {54, 15, -1, "ÃγР:"},
1618 {54, 16, -1, "õº÷ :"},
1619 {54, 17, -1, "²ò½ü :"},
1620 {54, 18, -1, "ËâË¡Æ»¶ñ :"},
1621 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1622 {01, 17, 25, "¼Í·â²ó¿ô"},
1623 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1624 {54, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1625 {26, 1, -1, "̾Á° : "},
1626 { 1, 3, -1, "ÀÊÌ : "},
1627 { 1, 4, -1, "¼ï² : "},
1628 { 1, 5, -1, "¿¦¶È : "},
1629 { 1, 6, -1, "ËâË¡ : "},
1630 { 1, 7, -1, "¼é¸îËâ¿À : "},
1631 {29, 3, 21, "ǯÎð"},
1632 {29, 4, 21, "¿ÈĹ"},
1633 {29, 5, 21, "ÂνÅ"},
1634 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1635 {29, 7, 21, "°À"},
1639 { 1, 10, 25, "Bare hand"},
1640 { 1, 10, 25, "Two hands"},
1641 { 1, 10, 25, "Right hand"},
1642 { 1, 10, 25, "Left hand"},
1643 { 1, 11, 25, "Left hand"},
1644 { 1, 11, 25, "Right hand"},
1645 { 1, 11, 25, "Posture"},
1646 { 1, 15, 25, "Shooting"},
1647 { 1, 16, 25, "Multiplier"},
1648 {01, 20, 25, "Speed"},
1650 {29, 13, 21, "Level"},
1651 {29, 14, 21, "Experience"},
1652 {29, 15, 21, "Max Exp"},
1653 {29, 16, 21, "Exp to Adv"},
1654 {29, 17, 21, "Gold"},
1655 {29, 19, 21, "Time"},
1656 {29, 10, 21, "Hit point"},
1657 {29, 11, 21, "SP (Mana)"},
1658 {29, 20, 21, "Play time"},
1659 {54, 10, -1, "Fighting : "},
1660 {54, 11, -1, "Bows/Throw : "},
1661 {54, 12, -1, "Saving Throw: "},
1662 {54, 13, -1, "Stealth : "},
1663 {54, 15, -1, "Perception : "},
1664 {54, 16, -1, "Searching : "},
1665 {54, 17, -1, "Disarming : "},
1666 {54, 18, -1, "Magic Device: "},
1667 {01, 12, 25, "Blows/Round"},
1668 {01, 17, 25, "Shots/Round"},
1669 {01, 13, 25, "AverageDmg/Rnd"},
1670 {54, 20, -1, "Infra-Vision: "},
1671 {26, 1, -1, "Name : "},
1672 { 1, 3, -1, "Sex : "},
1673 { 1, 4, -1, "Race : "},
1674 { 1, 5, -1, "Class : "},
1675 { 1, 6, -1, "Magic : "},
1676 { 1, 7, -1, "Patron : "},
1678 {29, 4, 21, "Height"},
1679 {29, 5, 21, "Weight"},
1680 {29, 6, 21, "Social Class"},
1681 {29, 7, 21, "Align"},
1685 static void display_player_one_line(int entry, cptr val, byte attr)
1689 int row = disp_player_line[entry].row;
1690 int col = disp_player_line[entry].col;
1691 int len = disp_player_line[entry].len;
1692 cptr head = disp_player_line[entry].header;
1694 int head_len = strlen(head);
1696 Term_putstr(col, row, -1, TERM_WHITE, head);
1703 int val_len = len - head_len;
1704 sprintf(buf, "%*.*s", val_len, val_len, val);
1705 Term_putstr(col + head_len, row, -1, attr, buf);
1709 Term_putstr(col + head_len, row, -1, attr, val);
1717 * Prints the following information on the screen.
1719 static void display_player_middle(void)
1722 int show_tohit, show_todam;
1728 show_tohit = p_ptr->dis_to_h[0];
1729 show_todam = p_ptr->dis_to_d[0];
1731 o_ptr = &inventory[INVEN_RARM];
1733 /* Hack -- add in weapon info if known */
1734 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1735 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1738 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1740 /* Dump the bonuses to hit/dam */
1741 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1742 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1743 else if(p_ptr->ryoute)
1744 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1745 else if (left_hander)
1746 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1748 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1753 show_tohit = p_ptr->dis_to_h[1];
1754 show_todam = p_ptr->dis_to_d[1];
1756 o_ptr = &inventory[INVEN_LARM];
1758 /* Hack -- add in weapon info if known */
1759 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1760 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1763 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1765 /* Dump the bonuses to hit/dam */
1767 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1769 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1771 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1774 if (p_ptr->special_defense & KAMAE_MASK)
1776 for (i = 0; i < MAX_KAMAE; i++)
1778 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1782 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1784 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1789 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1791 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1796 o_ptr = &inventory[INVEN_BOW];
1799 show_tohit = p_ptr->dis_to_h_b;
1802 /* Apply weapon bonuses */
1803 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1804 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1806 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1807 show_tohit += (weapon_exp[0][o_ptr->sval])/400;
1809 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1812 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1814 if (inventory[INVEN_BOW].k_idx)
1816 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1818 /* Get extra "power" from "extra might" */
1819 if (p_ptr->xtra_might) tmul++;
1821 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1825 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1827 /* Dump the armor class */
1828 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1832 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1837 i = p_ptr->pspeed-110;
1839 /* Hack -- Visually "undo" the Search Mode Slowdown */
1840 if (p_ptr->action == ACTION_SEARCH) i += 10;
1845 attr = TERM_L_GREEN;
1859 attr = TERM_L_UMBER;
1866 if (is_fast) tmp_speed += 10;
1867 if (p_ptr->slow) tmp_speed -= 10;
1868 if (p_ptr->lightspeed) tmp_speed = 99;
1872 if (m_list[p_ptr->riding].fast) tmp_speed += 10;
1873 if (m_list[p_ptr->riding].slow) tmp_speed -= 10;
1879 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1882 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1884 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1895 sprintf(buf, "(%+d)", i);
1898 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1900 sprintf(buf, "Riding (%+d)", i);
1904 display_player_one_line(ENTRY_SPEED, buf, attr);
1907 /* Dump character level */
1908 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1910 /* Dump experience */
1911 if (p_ptr->prace == RACE_ANDROID)
1912 display_player_one_line(ENTRY_CUR_EXP, "*****", TERM_L_GREEN);
1913 else if (p_ptr->exp >= p_ptr->max_exp)
1914 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_L_GREEN);
1916 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_YELLOW);
1918 /* Dump max experience */
1919 if (p_ptr->prace == RACE_ANDROID)
1920 display_player_one_line(ENTRY_MAX_EXP, "*****", TERM_L_GREEN);
1922 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1924 /* Dump exp to advance */
1925 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1926 display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
1928 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1931 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1935 s32b len = 20L * TOWN_DAWN;
1936 s32b tick = turn % len + len / 4;
1940 "%ldÆüÌÜ %2ld:%02ld",
1942 "Day %ld %2ld:%02ld",
1944 ((p_ptr->prace == RACE_VAMPIRE) ||
1945 (p_ptr->prace == RACE_SKELETON) ||
1946 (p_ptr->prace == RACE_ZOMBIE) ||
1947 (p_ptr->prace == RACE_SPECTRE))
1948 ? (turn - (15L * TOWN_DAWN)) / len + 1
1949 : (turn + (5L * TOWN_DAWN))/ len + 1,
1950 (24 * tick / len) % 24,
1951 (1440 * tick / len) % 60);
1953 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1955 /* Dump hit point */
1956 if (p_ptr->chp >= p_ptr->mhp)
1957 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1958 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1959 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1961 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1963 /* Dump mana power */
1964 if (p_ptr->csp >= p_ptr->msp)
1965 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1966 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1967 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1969 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1971 /* Dump play time */
1972 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1977 * Hack -- pass color info around this file
1979 static byte likert_color = TERM_WHITE;
1983 * Returns a "rating" of x depending on y
1985 static cptr likert(int x, int y)
1987 static char dummy[20] = "";
1992 /* Negative value */
1995 likert_color = TERM_L_DARK;
1999 return ("Very Bad");
2004 /* Analyze the value */
2010 likert_color = TERM_RED;
2020 likert_color = TERM_L_RED;
2031 likert_color = TERM_ORANGE;
2041 likert_color = TERM_YELLOW;
2051 likert_color = TERM_YELLOW;
2053 return ("ÂçÊÑÎɤ¤");
2055 return ("Very Good");
2062 likert_color = TERM_L_GREEN;
2066 return ("Excellent");
2076 likert_color = TERM_GREEN;
2089 likert_color = TERM_BLUE;
2091 return ("¥«¥ª¥¹¥é¥ó¥¯");
2093 return ("Chaos Rank");
2099 likert_color = TERM_VIOLET;
2101 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2103 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2113 * Prints ratings on certain abilities
2115 * This code is "imitated" elsewhere to "dump" a character sheet.
2117 static void display_player_various(void)
2119 int tmp, damage[2], blows1, blows2, i, basedam;
2120 int xthn, xthb, xfos, xsrh;
2121 int xdis, xdev, xsav, xstl;
2125 int shots, shot_frac;
2129 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2130 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2131 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2132 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2133 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2135 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2137 /* Shooting Skill (with current bow and normal missile) */
2138 o_ptr = &inventory[INVEN_BOW];
2139 tmp = p_ptr->to_h_b + o_ptr->to_h;
2140 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2142 /* If the player is wielding one? */
2145 s16b energy_fire = bow_energy(o_ptr->sval);
2147 /* Calculate shots per round */
2148 shots = p_ptr->num_fire * 100;
2149 shot_frac = (shots * 100 / energy_fire) % 100;
2150 shots = shots / energy_fire;
2151 if (o_ptr->name1 == ART_CRIMSON)
2155 if (p_ptr->pclass == CLASS_ARCHER)
2157 /* Extra shot at level 10 */
2158 if (p_ptr->lev >= 10) shots++;
2160 /* Extra shot at level 30 */
2161 if (p_ptr->lev >= 30) shots++;
2163 /* Extra shot at level 45 */
2164 if (p_ptr->lev >= 45) shots++;
2174 for(i = 0; i< 2; i++)
2176 damage[i] = p_ptr->dis_to_d[i]*100;
2177 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2179 int level = p_ptr->lev;
2185 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2186 if (p_ptr->special_defense & KAMAE_BYAKKO)
2187 basedam = monk_ave_damage[level][1];
2188 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2189 basedam = monk_ave_damage[level][2];
2191 basedam = monk_ave_damage[level][0];
2195 /* Average damage per round */
2196 o_ptr = &inventory[INVEN_RARM+i];
2197 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2198 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2199 object_flags(o_ptr, &f1, &f2, &f3);
2200 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2206 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2208 /* vorpal flag only */
2212 if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2213 basedam = basedam * 7 / 2;
2214 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2215 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2217 damage[i] += basedam;
2218 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2219 if (damage[i] < 0) damage[i] = 0;
2221 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2222 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2224 /* Basic abilities */
2226 xdis = p_ptr->skill_dis;
2227 xdev = p_ptr->skill_dev;
2228 xsav = p_ptr->skill_sav;
2229 xstl = p_ptr->skill_stl;
2230 xsrh = p_ptr->skill_srh;
2231 xfos = p_ptr->skill_fos;
2234 desc = likert(xthn, 12);
2235 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2237 desc = likert(xthb, 12);
2238 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2240 desc = likert(xsav, 7);
2241 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2243 desc = likert(xstl, 1);
2244 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2246 desc = likert(xfos, 6);
2247 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2249 desc = likert(xsrh, 6);
2250 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2252 desc = likert(xdis, 8);
2253 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2255 desc = likert(xdev, 6);
2256 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2259 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2261 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2263 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2266 if ((damage[0]+damage[1]) == 0)
2269 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2271 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2273 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2279 * Obtain the "flags" for the player as if he was an item
2281 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2284 (*f1) = (*f2) = (*f3) = 0L;
2287 switch (p_ptr->pclass)
2290 if (p_ptr->lev > 44)
2291 (*f3) |= (TR3_REGEN);
2293 if (p_ptr->lev > 29)
2294 (*f2) |= (TR2_RES_FEAR);
2297 if (p_ptr->lev > 39)
2298 (*f2) |= (TR2_RES_FEAR);
2300 case CLASS_CHAOS_WARRIOR:
2301 if (p_ptr->lev > 29)
2302 (*f2) |= (TR2_RES_CHAOS);
2303 if (p_ptr->lev > 39)
2304 (*f2) |= (TR2_RES_FEAR);
2307 case CLASS_FORCETRAINER:
2308 if ((p_ptr->lev > 9) && !heavy_armor())
2310 if ((p_ptr->lev>24) && !heavy_armor())
2311 (*f2) |= (TR2_FREE_ACT);
2318 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2321 (*f2) |= (TR2_FREE_ACT);
2323 (*f3) |= TR3_SLOW_DIGEST;
2324 (*f2) |= TR2_RES_FEAR;
2325 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2326 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2327 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2329 case CLASS_MINDCRAFTER:
2331 (*f2) |= (TR2_RES_FEAR);
2332 if (p_ptr->lev > 19)
2333 (*f2) |= (TR2_SUST_WIS);
2334 if (p_ptr->lev > 29)
2335 (*f2) |= (TR2_RES_CONF);
2336 if (p_ptr->lev > 39)
2337 (*f3) |= (TR3_TELEPATHY);
2340 (*f2) |= (TR2_RES_SOUND);
2342 case CLASS_BERSERKER:
2343 (*f2) |= (TR2_SUST_STR);
2344 (*f2) |= (TR2_SUST_DEX);
2345 (*f2) |= (TR2_SUST_CON);
2346 (*f3) |= (TR3_REGEN);
2347 (*f2) |= (TR2_FREE_ACT);
2348 (*f1) |= (TR1_SPEED);
2349 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2351 case CLASS_MIRROR_MASTER:
2352 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2355 break; /* Do nothing */
2359 if (p_ptr->mimic_form)
2361 switch(p_ptr->mimic_form)
2364 (*f2) |= (TR2_HOLD_LIFE);
2365 (*f2) |= (TR2_RES_CHAOS);
2366 (*f2) |= (TR2_RES_NETHER);
2367 (*f2) |= (TR2_RES_FIRE);
2368 (*f3) |= (TR3_SEE_INVIS);
2369 (*f1) |= (TR1_SPEED);
2371 case MIMIC_DEMON_LORD:
2372 (*f2) |= (TR2_HOLD_LIFE);
2373 (*f2) |= (TR2_RES_CHAOS);
2374 (*f2) |= (TR2_RES_NETHER);
2375 (*f2) |= (TR2_RES_FIRE);
2376 (*f2) |= (TR2_RES_COLD);
2377 (*f2) |= (TR2_RES_ELEC);
2378 (*f2) |= (TR2_RES_ACID);
2379 (*f2) |= (TR2_RES_POIS);
2380 (*f2) |= (TR2_RES_CONF);
2381 (*f2) |= (TR2_RES_DISEN);
2382 (*f2) |= (TR2_RES_NEXUS);
2383 (*f2) |= (TR2_RES_FEAR);
2384 (*f2) |= (TR2_IM_FIRE);
2385 (*f3) |= (TR3_SH_FIRE);
2386 (*f3) |= (TR3_SEE_INVIS);
2387 (*f3) |= (TR3_TELEPATHY);
2388 (*f3) |= (TR3_FEATHER);
2389 (*f1) |= (TR1_SPEED);
2392 (*f2) |= (TR2_HOLD_LIFE);
2393 (*f2) |= (TR2_RES_DARK);
2394 (*f2) |= (TR2_RES_NETHER);
2395 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2396 (*f2) |= (TR2_RES_POIS);
2397 (*f2) |= (TR2_RES_COLD);
2398 (*f3) |= (TR3_SEE_INVIS);
2399 (*f1) |= (TR1_SPEED);
2405 switch (p_ptr->prace)
2408 (*f2) |= (TR2_RES_LITE);
2411 (*f2) |= (TR2_SUST_DEX);
2414 (*f2) |= (TR2_FREE_ACT);
2417 (*f2) |= (TR2_RES_BLIND);
2420 (*f2) |= (TR2_RES_DARK);
2422 case RACE_HALF_TROLL:
2423 (*f2) |= (TR2_SUST_STR);
2424 if (p_ptr->lev > 14)
2426 (*f3) |= (TR3_REGEN);
2427 if (p_ptr->pclass == CLASS_WARRIOR)
2429 (*f3) |= (TR3_SLOW_DIGEST);
2431 * Let's not make Regeneration a disadvantage
2432 * for the poor warriors who can never learn
2433 * a spell that satisfies hunger (actually
2434 * neither can rogues, but half-trolls are not
2435 * supposed to play rogues)
2441 (*f2) |= (TR2_SUST_CON);
2442 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2445 (*f2) |= (TR2_RES_LITE);
2446 (*f3) |= (TR3_SEE_INVIS);
2448 case RACE_BARBARIAN:
2449 (*f2) |= (TR2_RES_FEAR);
2451 case RACE_HALF_OGRE:
2452 (*f2) |= (TR2_SUST_STR);
2453 (*f2) |= (TR2_RES_DARK);
2455 case RACE_HALF_GIANT:
2456 (*f2) |= (TR2_RES_SHARDS);
2457 (*f2) |= (TR2_SUST_STR);
2459 case RACE_HALF_TITAN:
2460 (*f2) |= (TR2_RES_CHAOS);
2463 (*f2) |= (TR2_RES_SOUND);
2466 (*f2) |= (TR2_RES_ACID);
2467 if (p_ptr->lev > 19)
2468 (*f2) |= (TR2_IM_ACID);
2471 (*f2) |= (TR2_RES_CONF);
2472 (*f2) |= (TR2_RES_ACID);
2477 (*f2) |= (TR2_RES_POIS);
2480 (*f2) |= (TR2_RES_DISEN);
2481 (*f2) |= (TR2_RES_DARK);
2484 (*f2) |= (TR2_RES_DARK);
2485 if (p_ptr->lev > 19)
2486 (*f3) |= (TR3_SEE_INVIS);
2488 case RACE_DRACONIAN:
2489 (*f3) |= TR3_FEATHER;
2491 (*f2) |= (TR2_RES_FIRE);
2493 (*f2) |= (TR2_RES_COLD);
2494 if (p_ptr->lev > 14)
2495 (*f2) |= (TR2_RES_ACID);
2496 if (p_ptr->lev > 19)
2497 (*f2) |= (TR2_RES_ELEC);
2498 if (p_ptr->lev > 34)
2499 (*f2) |= (TR2_RES_POIS);
2501 case RACE_MIND_FLAYER:
2502 (*f2) |= (TR2_SUST_INT);
2503 (*f2) |= (TR2_SUST_WIS);
2504 if (p_ptr->lev > 14)
2505 (*f3) |= (TR3_SEE_INVIS);
2506 if (p_ptr->lev > 29)
2507 (*f3) |= (TR3_TELEPATHY);
2510 (*f2) |= (TR2_RES_FIRE);
2512 (*f3) |= (TR3_SEE_INVIS);
2515 (*f3) |= (TR3_SEE_INVIS);
2516 (*f2) |= (TR2_FREE_ACT);
2517 (*f2) |= (TR2_RES_POIS);
2518 (*f3) |= (TR3_SLOW_DIGEST);
2519 if (p_ptr->lev > 34)
2520 (*f2) |= (TR2_HOLD_LIFE);
2523 (*f3) |= (TR3_SEE_INVIS);
2524 (*f2) |= (TR2_RES_SHARDS);
2525 (*f2) |= (TR2_HOLD_LIFE);
2526 (*f2) |= (TR2_RES_POIS);
2528 (*f2) |= (TR2_RES_COLD);
2531 (*f3) |= (TR3_SEE_INVIS);
2532 (*f2) |= (TR2_HOLD_LIFE);
2533 (*f2) |= (TR2_RES_NETHER);
2534 (*f2) |= (TR2_RES_POIS);
2535 (*f3) |= (TR3_SLOW_DIGEST);
2537 (*f2) |= (TR2_RES_COLD);
2540 (*f2) |= (TR2_HOLD_LIFE);
2541 (*f2) |= (TR2_RES_DARK);
2542 (*f2) |= (TR2_RES_NETHER);
2543 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2544 (*f2) |= (TR2_RES_POIS);
2545 (*f2) |= (TR2_RES_COLD);
2548 (*f3) |= (TR3_FEATHER);
2549 (*f2) |= (TR2_FREE_ACT);
2550 (*f2) |= (TR2_RES_COLD);
2551 (*f3) |= (TR3_SEE_INVIS);
2552 (*f2) |= (TR2_HOLD_LIFE);
2553 (*f2) |= (TR2_RES_NETHER);
2554 (*f2) |= (TR2_RES_POIS);
2555 (*f3) |= (TR3_SLOW_DIGEST);
2557 if (p_ptr->lev > 34)
2558 (*f3) |= TR3_TELEPATHY;
2561 (*f2) |= (TR2_RES_LITE);
2562 (*f3) |= (TR3_FEATHER);
2564 (*f1) |= (TR1_SPEED);
2567 (*f2) |= (TR2_RES_SOUND);
2568 (*f2) |= (TR2_RES_CONF);
2571 (*f3) |= (TR3_FEATHER);
2572 (*f3) |= (TR3_SEE_INVIS);
2575 (*f2) |= (TR2_RES_FIRE);
2576 (*f2) |= (TR2_RES_NETHER);
2577 (*f2) |= (TR2_HOLD_LIFE);
2579 (*f3) |= (TR3_SEE_INVIS);
2582 (*f2) |= (TR2_SUST_CON);
2585 (*f3) |= (TR3_FEATHER);
2588 (*f2) |= (TR2_RES_CONF);
2591 (*f2) |= (TR2_FREE_ACT);
2592 (*f2) |= (TR2_RES_POIS);
2593 (*f3) |= (TR3_SLOW_DIGEST);
2594 (*f2) |= (TR2_HOLD_LIFE);
2604 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2606 (*f3) &= ~(TR3_REGEN);
2609 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2610 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2611 (p_ptr->muta3 & MUT3_SHORT_LEG))
2616 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2618 (*f3) |= TR3_SH_ELEC;
2621 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2623 (*f3) |= TR3_SH_FIRE;
2627 if (p_ptr->muta3 & MUT3_WINGS)
2629 (*f3) |= TR3_FEATHER;
2632 if (p_ptr->muta3 & MUT3_FEARLESS)
2634 (*f2) |= (TR2_RES_FEAR);
2637 if (p_ptr->muta3 & MUT3_REGEN)
2642 if (p_ptr->muta3 & MUT3_ESP)
2644 (*f3) |= TR3_TELEPATHY;
2647 if (p_ptr->muta3 & MUT3_MOTION)
2649 (*f2) |= TR2_FREE_ACT;
2653 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2654 (*f3) |= TR3_AGGRAVATE;
2655 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2657 (*f2) |= (TR2_RES_BLIND);
2658 (*f2) |= (TR2_RES_CONF);
2659 (*f2) |= (TR2_HOLD_LIFE);
2660 (*f3) |= (TR3_LITE);
2662 (*f1) |= (TR1_SPEED);
2664 if (p_ptr->special_defense & KATA_FUUJIN)
2665 (*f2) |= TR2_REFLECT;
2666 if (p_ptr->special_defense & KAMAE_GENBU)
2667 (*f2) |= TR2_REFLECT;
2668 if (p_ptr->special_defense & KAMAE_SUZAKU)
2669 (*f3) |= TR3_FEATHER;
2670 if (p_ptr->special_defense & KAMAE_SEIRYU)
2672 (*f2) |= (TR2_RES_FIRE);
2673 (*f2) |= (TR2_RES_COLD);
2674 (*f2) |= (TR2_RES_ACID);
2675 (*f2) |= (TR2_RES_ELEC);
2676 (*f2) |= (TR2_RES_POIS);
2677 (*f3) |= (TR3_FEATHER);
2678 (*f3) |= (TR3_SH_FIRE);
2679 (*f3) |= (TR3_SH_ELEC);
2680 (*f3) |= (TR3_SH_COLD);
2682 if (p_ptr->special_defense & KATA_MUSOU)
2684 (*f2) |= TR2_RES_FEAR;
2685 (*f2) |= TR2_RES_LITE;
2686 (*f2) |= TR2_RES_DARK;
2687 (*f2) |= TR2_RES_BLIND;
2688 (*f2) |= TR2_RES_CONF;
2689 (*f2) |= TR2_RES_SOUND;
2690 (*f2) |= TR2_RES_SHARDS;
2691 (*f2) |= TR2_RES_NETHER;
2692 (*f2) |= TR2_RES_NEXUS;
2693 (*f2) |= TR2_RES_CHAOS;
2694 (*f2) |= TR2_RES_DISEN;
2695 (*f2) |= TR2_REFLECT;
2696 (*f2) |= TR2_HOLD_LIFE;
2697 (*f2) |= TR2_FREE_ACT;
2698 (*f3) |= TR3_SH_FIRE;
2699 (*f3) |= TR3_SH_ELEC;
2700 (*f3) |= TR3_SH_COLD;
2701 (*f3) |= TR3_FEATHER;
2703 (*f3) |= TR3_SEE_INVIS;
2704 (*f3) |= TR3_TELEPATHY;
2705 (*f3) |= TR3_SLOW_DIGEST;
2707 (*f2) |= (TR2_SUST_STR);
2708 (*f2) |= (TR2_SUST_INT);
2709 (*f2) |= (TR2_SUST_WIS);
2710 (*f2) |= (TR2_SUST_DEX);
2711 (*f2) |= (TR2_SUST_CON);
2712 (*f2) |= (TR2_SUST_CHR);
2717 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2720 (*f1) = (*f2) = (*f3) = 0L;
2722 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2723 (*f2) |= TR2_RES_FEAR;
2724 if (p_ptr->tim_invis)
2725 (*f3) |= TR3_SEE_INVIS;
2726 if (p_ptr->tim_regen)
2728 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2729 (*f3) |= TR3_TELEPATHY;
2730 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2732 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2734 (*f2) |= (TR2_RES_FIRE);
2735 (*f2) |= (TR2_RES_COLD);
2736 (*f2) |= (TR2_RES_ACID);
2737 (*f2) |= (TR2_RES_ELEC);
2738 (*f2) |= (TR2_RES_POIS);
2742 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2743 (*f2) |= TR2_RES_ACID;
2744 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2745 (*f2) |= TR2_RES_ELEC;
2746 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2747 (*f2) |= TR2_RES_FIRE;
2748 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2749 (*f2) |= TR2_RES_COLD;
2753 if (p_ptr->oppose_acid)
2754 (*f2) |= TR2_RES_ACID;
2755 if (p_ptr->oppose_elec)
2756 (*f2) |= TR2_RES_ELEC;
2757 if (p_ptr->oppose_fire)
2758 (*f2) |= TR2_RES_FIRE;
2759 if (p_ptr->oppose_cold)
2760 (*f2) |= TR2_RES_COLD;
2762 if (p_ptr->oppose_pois)
2763 (*f2) |= TR2_RES_POIS;
2764 if (p_ptr->special_attack & ATTACK_ACID)
2765 (*f1) |= TR1_BRAND_ACID;
2766 if (p_ptr->special_attack & ATTACK_ELEC)
2767 (*f1) |= TR1_BRAND_ELEC;
2768 if (p_ptr->special_attack & ATTACK_FIRE)
2769 (*f1) |= TR1_BRAND_FIRE;
2770 if (p_ptr->special_attack & ATTACK_COLD)
2771 (*f1) |= TR1_BRAND_COLD;
2772 if (p_ptr->special_attack & ATTACK_POIS)
2773 (*f1) |= TR1_BRAND_POIS;
2774 if (p_ptr->special_defense & DEFENSE_ACID)
2775 (*f2) |= TR2_IM_ACID;
2776 if (p_ptr->special_defense & DEFENSE_ELEC)
2777 (*f2) |= TR2_IM_ELEC;
2778 if (p_ptr->special_defense & DEFENSE_FIRE)
2779 (*f2) |= TR2_IM_FIRE;
2780 if (p_ptr->special_defense & DEFENSE_COLD)
2781 (*f2) |= TR2_IM_COLD;
2782 if (p_ptr->wraith_form)
2783 (*f2) |= TR2_REFLECT;
2785 if (p_ptr->tim_reflect){
2786 (*f2) |= TR2_REFLECT;
2789 if (p_ptr->magicdef)
2791 (*f2) |= TR2_RES_BLIND;
2792 (*f2) |= TR2_RES_CONF;
2793 (*f2) |= TR2_REFLECT;
2794 (*f2) |= TR2_FREE_ACT;
2795 (*f3) |= TR3_FEATHER;
2797 if (p_ptr->tim_res_nether)
2799 (*f2) |= TR2_RES_NETHER;
2801 if (p_ptr->tim_sh_fire)
2803 (*f3) |= TR3_SH_FIRE;
2807 (*f2) |= TR2_RES_FEAR;
2808 (*f2) |= TR2_RES_LITE;
2809 (*f2) |= TR2_RES_DARK;
2810 (*f2) |= TR2_RES_BLIND;
2811 (*f2) |= TR2_RES_CONF;
2812 (*f2) |= TR2_RES_SOUND;
2813 (*f2) |= TR2_RES_SHARDS;
2814 (*f2) |= TR2_RES_NETHER;
2815 (*f2) |= TR2_RES_NEXUS;
2816 (*f2) |= TR2_RES_CHAOS;
2817 (*f2) |= TR2_RES_DISEN;
2818 (*f2) |= TR2_REFLECT;
2819 (*f2) |= TR2_HOLD_LIFE;
2820 (*f2) |= TR2_FREE_ACT;
2821 (*f3) |= TR3_SH_FIRE;
2822 (*f3) |= TR3_SH_ELEC;
2823 (*f3) |= TR3_SH_COLD;
2824 (*f3) |= TR3_FEATHER;
2826 (*f3) |= TR3_SEE_INVIS;
2827 (*f3) |= TR3_TELEPATHY;
2828 (*f3) |= TR3_SLOW_DIGEST;
2830 (*f2) |= (TR2_SUST_STR);
2831 (*f2) |= (TR2_SUST_INT);
2832 (*f2) |= (TR2_SUST_WIS);
2833 (*f2) |= (TR2_SUST_DEX);
2834 (*f2) |= (TR2_SUST_CON);
2835 (*f2) |= (TR2_SUST_CHR);
2843 static void display_player_equippy(int y, int x)
2853 /* Dump equippy chars */
2854 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2857 o_ptr = &inventory[i];
2859 a = object_attr(o_ptr);
2860 c = object_char(o_ptr);
2862 /* Clear the part of the screen */
2863 if (!equippy_chars || !o_ptr->k_idx)
2870 Term_putch(x + i - INVEN_RARM, y, a, c);
2875 void print_equippy(void)
2877 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2884 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2889 (*f1) = (*f2) = (*f3) = 0L;
2891 /* Check equipment */
2892 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2894 u32b o_f1, o_f2, o_f3;
2899 o_ptr = &inventory[i];
2901 if (!o_ptr->k_idx) continue;
2904 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2906 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2907 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2908 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2909 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2913 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2916 (*f1) = (*f2) = (*f3) = 0L;
2918 if (prace_is_(RACE_SPECTRE))
2919 (*f2) |= TR2_RES_NETHER;
2920 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2921 (*f2) |= TR2_RES_DARK;
2922 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2923 (*f2) |= TR2_RES_FIRE;
2924 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2925 (*f2) |= TR2_RES_ACID;
2928 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2931 (*f1) = (*f2) = (*f3) = 0L;
2933 if (p_ptr->special_defense & DEFENSE_ACID)
2934 (*f2) |= TR2_RES_ACID;
2935 if (p_ptr->special_defense & DEFENSE_ELEC)
2936 (*f2) |= TR2_RES_ELEC;
2937 if (p_ptr->special_defense & DEFENSE_FIRE)
2938 (*f2) |= TR2_RES_FIRE;
2939 if (p_ptr->special_defense & DEFENSE_COLD)
2940 (*f2) |= TR2_RES_COLD;
2941 if (p_ptr->wraith_form)
2942 (*f2) |= TR2_RES_DARK;
2945 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2948 (*f1) = (*f2) = (*f3) = 0L;
2950 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2952 (*f2) |= TR2_RES_ACID;
2953 (*f2) |= TR2_RES_ELEC;
2954 (*f2) |= TR2_RES_FIRE;
2955 (*f2) |= TR2_RES_COLD;
2957 if (prace_is_(RACE_ANDROID))
2958 (*f2) |= TR2_RES_ELEC;
2959 if (prace_is_(RACE_ENT))
2960 (*f2) |= TR2_RES_FIRE;
2961 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2962 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2963 (*f2) |= TR2_RES_LITE;
2967 * Helper function, see below
2969 static void display_player_flag_aux(int row, int col, char *header,
2970 int n, u32b flag1, u32b flag2,
2971 u32b im_f[], u32b vul_f)
2977 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2981 c_put_str(TERM_WHITE, header, row, col);
2984 col += strlen(header) + 1;
2986 /* Check equipment */
2987 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2990 f[0] = f[1] = f[2] = f[3] = 0L;
2993 o_ptr = &inventory[i];
2996 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2997 f[3] = o_ptr->curse_flags;
3000 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3003 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3004 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
3011 player_flags(&f[0], &f[1], &f[2]);
3015 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3018 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3020 /* Timed player flags */
3021 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
3025 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3028 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
3029 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
3032 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3037 * Special display, part 1
3039 static void display_player_flag_info(void)
3044 u32b im_f[3][3], vul_f[3];
3046 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
3047 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
3048 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
3050 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3057 display_player_equippy(row-2, col+8);
3058 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3061 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3062 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3063 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3064 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3065 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3066 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3067 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3068 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3069 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3070 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3072 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3073 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3074 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3075 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3076 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3077 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3078 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3079 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3080 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3081 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3090 display_player_equippy(row-2, col+8);
3092 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3095 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3096 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3097 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3098 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3099 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3100 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3101 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3102 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3103 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3104 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3106 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3107 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3108 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3109 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3110 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3111 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3112 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3113 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3114 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3115 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3124 display_player_equippy(row-2, col+12);
3126 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3129 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3130 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3131 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3132 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3133 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3134 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3135 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3136 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3137 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3138 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 4, (TRC_CURSED | TRC_HEAVY_CURSE), TRC_PERMA_CURSE, im_f[2], vul_f[2]);
3140 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3141 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3142 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3143 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3144 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3145 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3146 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3147 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3148 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3149 display_player_flag_aux(row+9, col, "Cursed :", 4, (TRC_CURSED | TRC_HEAVY_CURSE), TRC_PERMA_CURSE, im_f[2], vul_f[2]);
3156 * Special display, part 2a
3158 static void display_player_misc_info(void)
3163 /* Display basics */
3165 put_str("̾Á° :", 1, 26);
3166 put_str("ÀÊÌ :", 3, 1);
3167 put_str("¼ï² :", 4, 1);
3168 put_str("¿¦¶È :", 5, 1);
3170 put_str("Name :", 1, 26);
3171 put_str("Sex :", 3, 1);
3172 put_str("Race :", 4, 1);
3173 put_str("Class :", 5, 1);
3176 strcpy(tmp,ap_ptr->title);
3183 strcat(tmp,player_name);
3185 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3186 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3187 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3188 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3190 /* Display extras */
3192 put_str("¥ì¥Ù¥ë:", 6, 1);
3193 put_str("£È£Ð :", 7, 1);
3194 put_str("£Í£Ð :", 8, 1);
3196 put_str("Level :", 6, 1);
3197 put_str("Hits :", 7, 1);
3198 put_str("Mana :", 8, 1);
3202 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3203 c_put_str(TERM_L_BLUE, buf, 6, 9);
3204 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3205 c_put_str(TERM_L_BLUE, buf, 7, 9);
3206 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3207 c_put_str(TERM_L_BLUE, buf, 8, 9);
3212 * Special display, part 2b
3214 * How to print out the modifications and sustains.
3215 * Positive mods with no sustain will be light green.
3216 * Positive mods with a sustain will be dark green.
3217 * Sustains (with no modification) will be a dark green 's'.
3218 * Negative mods (from a curse) will be red.
3219 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3220 * No mod, no sustain, will be a slate '.'
3222 static void display_player_stat_info(void)
3244 /* Print out the labels for the columns */
3246 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3247 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3248 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3249 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3250 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3252 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3253 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3254 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3255 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3256 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3260 /* Display the stats */
3261 for (i = 0; i < 6; i++)
3265 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3266 else r_adj = rp_ptr->r_adj[i];
3268 /* Calculate equipment adjustment */
3271 /* Icky formula to deal with the 18 barrier */
3272 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3273 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3274 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3275 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3276 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3277 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3279 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3280 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3282 if (prace_is_(RACE_ENT))
3288 if (p_ptr->lev > 25) r_adj++;
3289 if (p_ptr->lev > 40) r_adj++;
3290 if (p_ptr->lev > 45) r_adj++;
3293 if (p_ptr->lev > 25) r_adj--;
3294 if (p_ptr->lev > 40) r_adj--;
3295 if (p_ptr->lev > 45) r_adj--;
3301 e_adj -= cp_ptr->c_adj[i];
3302 e_adj -= ap_ptr->a_adj[i];
3304 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3305 /* Reduced name of stat */
3306 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3308 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3311 /* Internal "natural" max value. Maxes at 18/100 */
3312 /* This is useful to see if you are maxed out */
3313 cnv_stat(p_ptr->stat_max[i], buf);
3314 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3317 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3319 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3322 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3324 /* Race, class, and equipment modifiers */
3325 (void)sprintf(buf, "%3d", r_adj);
3326 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3327 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3328 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3329 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3330 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3331 (void)sprintf(buf, "%3d", (int)e_adj);
3332 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3334 /* Actual maximal modified value */
3335 cnv_stat(p_ptr->stat_top[i], buf);
3336 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3338 /* Only display stat_use if not maximal */
3339 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3341 cnv_stat(p_ptr->stat_use[i], buf);
3342 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3347 col = stat_col + 41;
3349 /* Header and Footer */
3350 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3352 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3354 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3358 /* Process equipment */
3359 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3362 o_ptr = &inventory[i];
3365 k_idx = o_ptr->k_idx;
3367 /* Acquire "known" flags */
3368 object_flags_known(o_ptr, &f1, &f2, &f3);
3370 /* Initialize color based of sign of pval. */
3371 for (stat = 0; stat < 6; stat++)
3384 if (o_ptr->pval > 0)
3390 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3395 /* Dark green for sustained stats */
3400 if (o_ptr->pval < 0)
3406 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3411 else if (f2 & 1 << stat)
3413 /* Dark green "s" */
3418 /* Dump proper character */
3419 Term_putch(col, row + stat+1, a, c);
3427 player_flags(&f1, &f2, &f3);
3430 for (stat = 0; stat < 6; stat++)
3437 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3443 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3444 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3445 if (p_ptr->tsuyoshi) dummy += 4;
3447 else if (stat == A_WIS || stat == A_INT)
3449 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3450 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3452 else if (stat == A_DEX)
3454 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3455 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3456 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3458 else if (stat == A_CON)
3460 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3461 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3462 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3463 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3464 if (p_ptr->tsuyoshi) dummy += 4;
3466 else if (stat == A_CHR)
3468 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3469 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3470 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3471 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3472 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3473 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3489 if (dummy < 10) c = '0' + dummy;
3499 if (dummy > -10) c = '0' - dummy;
3508 /* Dark green "s" */
3515 Term_putch(col, row + stat+1, a, c);
3523 static cptr object_flag_names[96] =
3764 * Summarize resistances
3766 static void display_player_ben(void)
3779 for (i = 0; i < 6; i++) b[i] = 0;
3782 /* Scan equipment */
3783 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3786 o_ptr = &inventory[i];
3788 /* Known object flags */
3789 object_flags_known(o_ptr, &f1, &f2, &f3);
3792 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3794 f3 &= ~(TR3_AGGRAVATE);
3799 b[0] |= (f1 & 0xFFFF);
3801 b[2] |= (f2 & 0xFFFF);
3803 b[4] |= (f3 & 0xFFFF);
3809 player_flags(&f1, &f2, &f3);
3812 b[0] |= (f1 & 0xFFFF);
3814 b[2] |= (f2 & 0xFFFF);
3816 b[4] |= (f3 & 0xFFFF);
3820 tim_player_flags(&f1, &f2, &f3, FALSE);
3823 b[0] |= (f1 & 0xFFFF);
3825 b[2] |= (f2 & 0xFFFF);
3827 b[4] |= (f3 & 0xFFFF);
3829 color[0] = (u16b)(f1 & 0xFFFF);
3830 color[1] = (u16b)(f1 >> 16);
3831 color[2] = (u16b)(f2 & 0xFFFF);
3832 color[3] = (u16b)(f2 >> 16);
3833 color[4] = (u16b)(f3 & 0xFFFF);
3834 color[5] = (u16b)(f3 >> 16);
3837 for (x = 0; x < 6; x++)
3840 for (y = 0; y < 16; y++)
3842 byte a = TERM_SLATE;
3845 cptr name = object_flag_names[16*x+y];
3848 if (!name) continue;
3851 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3854 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3859 if (color[x] & (1<<y))
3872 Term_putch(x * 13 + 11, y + 4, a, c);
3879 * Summarize resistances
3881 static void display_player_ben_one(int mode)
3893 /* Scan equipment */
3894 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3897 n = (i - INVEN_RARM);
3900 o_ptr = &inventory[i];
3902 object_flags_known(o_ptr, &f1, &f2, &f3);
3904 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3906 f3 &= ~(TR3_AGGRAVATE);
3911 b[n][0] = (u16b)(f1 & 0xFFFF);
3912 b[n][1] = (u16b)(f1 >> 16);
3913 b[n][2] = (u16b)(f2 & 0xFFFF);
3914 b[n][3] = (u16b)(f2 >> 16);
3915 b[n][4] = (u16b)(f3 & 0xFFFF);
3916 b[n][5] = (u16b)(f3 >> 16);
3924 player_flags(&f1, &f2, &f3);
3927 b[n][0] = (u16b)(f1 & 0xFFFF);
3928 b[n][1] = (u16b)(f1 >> 16);
3929 b[n][2] = (u16b)(f2 & 0xFFFF);
3930 b[n][3] = (u16b)(f2 >> 16);
3931 b[n][4] = (u16b)(f3 & 0xFFFF);
3932 b[n][5] = (u16b)(f3 >> 16);
3935 tim_player_flags(&f1, &f2, &f3, FALSE);
3938 b[n][0] |= (f1 & 0xFFFF);
3939 b[n][1] |= (f1 >> 16);
3940 b[n][2] |= (f2 & 0xFFFF);
3941 b[n][3] |= (f2 >> 16);
3942 b[n][4] |= (f3 & 0xFFFF);
3943 b[n][5] |= (f3 >> 16);
3944 color[0] = (u16b)(f1 & 0xFFFF);
3945 color[1] = (u16b)(f1 >> 16);
3946 color[2] = (u16b)(f2 & 0xFFFF);
3947 color[3] = (u16b)(f2 >> 16);
3948 color[4] = (u16b)(f3 & 0xFFFF);
3949 color[5] = (u16b)(f3 >> 16);
3953 for (x = 0; x < 3; x++)
3956 display_player_equippy(2, x * 26 + 11);
3959 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3962 for (y = 0; y < 16; y++)
3964 cptr name = object_flag_names[48*mode+16*x+y];
3967 if (!name) continue;
3970 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3973 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3976 for (n = 0; n < 13; n++)
3978 byte a = TERM_SLATE;
3982 if (b[n][3*mode+x] & (1<<y))
3984 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3997 Term_putch(x * 26 + 11 + n, y + 4, a, c);
4005 * Display the character on the screen (various modes)
4007 * The top two and bottom two lines are left blank.
4009 * Mode 0 = standard display with skills
4010 * Mode 1 = standard display with history
4011 * Mode 2 = summary of various things
4012 * Mode 3 = current flags (combined)
4013 * Mode 4 = current flags (part 1)
4014 * Mode 5 = current flags (part 2)
4015 * Mode 6 = mutations
4017 void display_player(int mode)
4026 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
4035 if ((mode == 0) || (mode == 1))
4037 /* Name, Sex, Race, Class */
4039 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
4041 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
4044 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
4045 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
4046 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
4047 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
4052 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
4054 strcpy(tmp, realm_names[p_ptr->realm1]);
4055 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
4058 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4059 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
4061 /* Age, Height, Weight, Social */
4062 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4064 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
4065 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
4066 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
4067 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
4069 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
4070 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
4071 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
4072 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
4074 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
4077 /* Display the stats */
4078 for (i = 0; i < 6; i++)
4080 /* Special treatment of "injured" stats */
4081 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4085 /* Use lowercase stat name */
4086 put_str(stat_names_reduced[i], 3 + i, 54);
4088 /* Get the current stat */
4089 value = p_ptr->stat_use[i];
4091 /* Obtain the current stat (modified) */
4092 cnv_stat(value, buf);
4094 /* Display the current stat (modified) */
4095 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
4097 /* Acquire the max stat */
4098 value = p_ptr->stat_top[i];
4100 /* Obtain the maximum stat (modified) */
4101 cnv_stat(value, buf);
4103 /* Display the maximum stat (modified) */
4104 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
4107 /* Normal treatment of "normal" stats */
4110 /* Assume uppercase stat name */
4111 put_str(stat_names[i], 3 + i, 54);
4113 /* Obtain the current stat (modified) */
4114 cnv_stat(p_ptr->stat_use[i], buf);
4116 /* Display the current stat (modified) */
4117 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
4120 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4123 c_put_str(TERM_WHITE, "!", 3+i, 59);
4125 c_put_str(TERM_WHITE, "!", 3+i, 59-2);
4130 /* Display "history" info */
4136 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
4138 put_str("(Character Background)", 11, 25);
4141 for (i = 0; i < 4; i++)
4143 put_str(history[i], i + 12, 10);
4148 if (death && total_winner)
4151 strcpy(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£");
4153 strcpy(statmsg, "...You retired from the adventure after the winning.");
4160 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
4163 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, died_from);
4165 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", died_from, quest[p_ptr->inside_quest].name);
4171 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, died_from);
4173 sprintf(statmsg, "...You were killed by %s on level %d of %s.", died_from, dun_level, map_name());
4179 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), died_from);
4181 sprintf(statmsg, "...You were killed by %s in %s.", died_from, map_name());
4184 else if (character_dungeon)
4188 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
4191 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
4193 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
4199 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
4201 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
4207 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
4209 sprintf(statmsg, "...Now, you are in %s.", map_name());
4215 char temp[64*2], *t;
4216 roff_to_buf(statmsg, 60, temp);
4218 for(i=0 ; i<2 ; i++)
4224 put_str(t, i + 5 + 12, 10);
4232 /* Display "various" info */
4235 display_player_middle();
4236 display_player_various();
4243 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4246 display_player_misc_info();
4247 display_player_stat_info();
4248 display_player_flag_info();
4254 display_player_ben();
4259 do_cmd_knowledge_mutations();
4265 display_player_ben_one(mode % 2);
4269 errr make_character_dump(FILE *fff)
4276 char o_name[MAX_NLEN];
4280 #ifndef FAKE_VERSION
4282 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4283 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4286 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4287 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4289 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4290 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4297 /* Display player */
4300 /* Dump part of the screen */
4301 for (y = 1; y < 22; y++)
4304 for (x = 0; x < 79; x++)
4306 /* Get the attr/char */
4307 (void)(Term_what(x, y, &a, &c));
4313 /* End the string */
4316 /* Kill trailing spaces */
4317 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4321 fprintf(fff, "%s\n", buf);
4323 fprintf(fff, "%s\n", buf);
4328 /* Display history */
4331 /* Dump part of the screen */
4332 for (y = 10; y < 19; y++)
4335 for (x = 0; x < 79; x++)
4337 /* Get the attr/char */
4338 (void)(Term_what(x, y, &a, &c));
4344 /* End the string */
4347 /* Kill trailing spaces */
4348 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4351 fprintf(fff, "%s\n", buf);
4355 /* Display history */
4358 /* Dump part of the screen */
4359 for (y = 2; y < 22; y++)
4362 for (x = 0; x < 79; x++)
4364 /* Get the attr/char */
4365 (void)(Term_what(x, y, &a, &c));
4367 /* Dump it (Ignore equippy tile graphic) */
4374 /* End the string */
4377 /* Kill trailing spaces */
4378 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4381 fprintf(fff, "%s\n", buf);
4384 for (i = 0; i < p_ptr->count / 80; i++)
4387 for (i = 0; i < p_ptr->count % 80; i++)
4393 for (i = m_max - 1; i >= 1; i--)
4395 monster_type *m_ptr = &m_list[i];
4398 if (!m_ptr->r_idx) continue;
4399 if (!is_pet(m_ptr)) continue;
4400 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4404 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4406 fprintf(fff, "\n [leading pets]\n\n");
4410 monster_desc(pet_name, m_ptr, 0x88);
4411 fprintf(fff, "%s", pet_name);
4412 if (p_ptr->riding == i)
4414 fprintf(fff, " ¾èÇÏÃæ");
4416 fprintf(fff, " (riding)");
4420 if (pet) fprintf(fff, "\n");
4423 if (death && !total_winner)
4426 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4428 fprintf(fff, "\n [Last messages]\n\n");
4430 for (i = MIN(message_num(), 30); i >= 0; i--)
4432 fprintf(fff,"> %s\n",message_str((s16b)i));
4438 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4440 fprintf(fff, "\n [Miscellaneous information]\n");
4444 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4446 fprintf(fff, "\n Recall Depth:\n");
4448 for (y = 1; y < max_d_idx; y++)
4452 if (!d_info[y].maxdepth) continue;
4453 if (!max_dlv[y]) continue;
4454 if (d_info[y].final_guardian)
4456 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4458 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4461 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4463 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4469 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4471 fprintf(fff, "\n Preserve Mode: ON");
4476 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4478 fprintf(fff, "\n Preserve Mode: OFF");
4482 if (ironman_autoscum)
4484 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4486 fprintf(fff, "\n Autoscum: ALWAYS");
4491 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4493 fprintf(fff, "\n Autoscum: ON");
4498 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4500 fprintf(fff, "\n Autoscum: OFF");
4504 if (ironman_small_levels)
4506 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4508 fprintf(fff, "\n Small Levels: ALWAYS");
4511 else if (always_small_levels)
4513 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4515 fprintf(fff, "\n Small Levels: ON");
4518 else if (small_levels)
4520 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4522 fprintf(fff, "\n Small Levels: ENABLED");
4527 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4529 fprintf(fff, "\n Small Levels: OFF");
4535 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4537 fprintf(fff, "\n Vanilla Town: ON");
4542 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4544 fprintf(fff, "\n Lite Town: ON");
4550 fprintf(fff, "\n Ź¤Ê¤·: ON");
4552 fprintf(fff, "\n No Shops: ON");
4556 if (ironman_downward)
4558 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4560 fprintf(fff, "\n Diving only: ON");
4566 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4568 fprintf(fff, "\n Unusual rooms: ON");
4572 if (ironman_nightmare)
4574 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4576 fprintf(fff, "\n Nightmare Mode: ON");
4580 if (ironman_empty_levels)
4582 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4584 fprintf(fff, "\n Arena Levels: ALWAYS");
4587 else if (empty_levels)
4589 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4591 fprintf(fff, "\n Arena Levels: ENABLED");
4596 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4598 fprintf(fff, "\n Arena Levels: OFF");
4603 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4605 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4608 if (p_ptr->arena_number == 99)
4611 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4613 fprintf(fff, "\n Arena: defeated\n");
4616 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4619 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4621 fprintf(fff, "\n Arena: True Champion\n");
4624 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4627 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4629 fprintf(fff, "\n Arena: Champion\n");
4635 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4637 fprintf(fff, "\n Arena: %2d victor%s\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number), (p_ptr->arena_number>1) ? "ies" : "y");
4643 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4645 fprintf(fff, "\n You have done something illegal.");
4649 if (stupid_monsters)
4651 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4653 fprintf(fff, "\n Your opponents are behaving stupidly.");
4659 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4661 fprintf(fff, "\n You possess munchkinish power over death.");
4666 /* Monsters slain */
4671 for (k = 1; k < max_r_idx; k++)
4673 monster_race *r_ptr = &r_info[k];
4675 if (r_ptr->flags1 & RF1_UNIQUE)
4677 bool dead = (r_ptr->max_num == 0);
4685 s16b This = r_ptr->r_pkills;
4695 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4697 fprintf(fff,"\n You have defeated no enemies yet.\n");
4700 else if (Total == 1)
4702 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4704 fprintf(fff,"\n You have defeated one enemy.\n");
4709 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4711 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4717 if (p_ptr->old_race1 || p_ptr->old_race2)
4720 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4722 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4724 for (i = 0; i < MAX_RACES; i++)
4726 if (p_ptr->start_race == i) continue;
4729 if (!(p_ptr->old_race1 & 1L << i)) continue;
4733 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4736 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4738 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4743 if (p_ptr->old_realm)
4745 for (i = 0; i < MAX_MAGIC; i++)
4747 if (!(p_ptr->old_realm & 1L << i)) continue;
4749 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4751 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4757 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4759 fprintf(fff, "\n\n [Virtues]\n\n");
4763 fprintf(fff, "°À : %s\n", your_alignment());
4765 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4770 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4773 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4775 fprintf(fff, "\n\n [Mutations]\n\n");
4778 dump_mutations(fff);
4782 /* Skip some lines */
4783 fprintf(fff, "\n\n");
4786 /* Dump the equipment */
4790 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4792 fprintf(fff, " [Character Equipment]\n\n");
4795 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4797 object_desc(o_name, &inventory[i], TRUE, 3);
4798 if ((i == INVEN_LARM) && p_ptr->ryoute)
4800 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4802 strcpy(o_name, "(wielding with two-hands)");
4804 fprintf(fff, "%c%s %s\n",
4805 index_to_label(i), paren, o_name);
4807 fprintf(fff, "\n\n");
4810 /* Dump the inventory */
4812 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4814 fprintf(fff, " [Character Inventory]\n\n");
4817 for (i = 0; i < INVEN_PACK; i++)
4819 /* Don't dump the empty slots */
4820 if (!inventory[i].k_idx) break;
4822 /* Dump the inventory slots */
4823 object_desc(o_name, &inventory[i], TRUE, 3);
4824 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4827 /* Add an empty line */
4828 fprintf(fff, "\n\n");
4830 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4832 /* Print all homes in the different towns */
4833 st_ptr = &town[1].store[STORE_HOME];
4835 /* Home -- if anything there */
4836 if (st_ptr->stock_num)
4838 /* Header with name of the town */
4840 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4842 fprintf(fff, " [Home Inventory]\n");
4846 /* Dump all available items */
4847 for (i = 0; i < st_ptr->stock_num; i++)
4851 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4853 fprintf(fff, "\n ( page %d )\n", x++);
4855 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4856 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4859 /* Add an empty line */
4860 fprintf(fff, "\n\n");
4864 /* Print all homes in the different towns */
4865 st_ptr = &town[1].store[STORE_MUSEUM];
4867 /* Home -- if anything there */
4868 if (st_ptr->stock_num)
4870 /* Header with name of the town */
4872 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4874 fprintf(fff, " [Museum]\n");
4878 /* Dump all available items */
4879 for (i = 0; i < st_ptr->stock_num; i++)
4882 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4883 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4884 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4886 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4887 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4888 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4893 /* Add an empty line */
4894 fprintf(fff, "\n\n");
4901 * Hack -- Dump a character description file
4903 * XXX XXX XXX Allow the "full" flag to dump additional info,
4904 * and trigger its usage from various places in the code.
4906 errr file_character(cptr name, bool full)
4915 /* Build the filename */
4916 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4918 /* File type is "TEXT" */
4919 FILE_TYPE(FILE_TYPE_TEXT);
4921 /* Check for existing file */
4922 fd = fd_open(buf, O_RDONLY);
4929 /* Close the file */
4934 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4936 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4941 if (get_check(out_val)) fd = -1;
4944 /* Open the non-existing file */
4945 if (fd < 0) fff = my_fopen(buf, "w");
4952 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4954 msg_format("Character dump failed!");
4963 (void)make_character_dump(fff);
4973 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4975 msg_print("Character dump successful.");
4985 typedef struct file_tag
4992 typedef struct file_tags
4999 static void add_tag(file_tags *the_tags, cptr name, int line)
5001 if (the_tags->index < 64)
5003 file_tag *tag = &(the_tags->tags[the_tags->index]);
5005 /* Set the name and end it with '\0' */
5006 strncpy(tag->name, name, 31);
5007 tag->name[31] = '\0';
5009 /* Set the line-number */
5010 tag->line_number = line;
5012 /* Increase the number of tags */
5018 static int get_line(file_tags *the_tags, cptr name)
5022 /* Search for the tag */
5023 for (i = 0; i < the_tags->index; i++)
5025 if (streq(the_tags->tags[i].name, name))
5027 return the_tags->tags[i].line_number;
5037 * Recursive file perusal.
5039 * Return FALSE on 'Q', otherwise TRUE.
5041 * Process various special text in the input file, including
5042 * the "menu" structures used by the "help file" system.
5044 * XXX XXX XXX Consider using a temporary file.
5046 * XXX XXX XXX Allow the user to "save" the current file.
5048 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
5052 /* Number of "real" lines passed by */
5055 /* Number of "real" lines in the file */
5058 /* Backup value for "line" */
5064 /* This screen has sub-screens */
5067 /* Current help file */
5070 /* Find this string (if any) */
5073 /* Jump to this tag */
5076 /* Hold a string to find */
5079 /* Hold a string to show */
5083 char filename[1024];
5085 /* Describe this thing */
5091 /* General buffer */
5094 /* Lower case version of the buffer, for searching */
5097 /* Aux pointer for making lc_buf (and find!) lowercase */
5100 /* Sub-menu information */
5103 /* Tags for in-file references */
5106 bool reverse = (line < 0);
5110 Term_get_size(&wid, &hgt);
5120 strcpy(caption, "");
5122 /* Wipe the hooks */
5123 for (i = 0; i < 68; i++)
5131 /* Copy the filename */
5132 strcpy(filename, name);
5134 n = strlen(filename);
5136 /* Extract the tag from the filename */
5137 for (i = 0; i < n; i++)
5139 if (filename[i] == '#')
5142 tag = filename + i + 1;
5147 /* Redirect the name */
5150 /* Hack XXX XXX XXX */
5154 strcpy(caption, what);
5156 /* Access the "file" */
5160 fff = my_fopen(path, "r");
5163 /* Look in "help" */
5168 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5170 sprintf(caption, "Help file '%s'", name);
5174 /* Build the filename */
5175 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5178 fff = my_fopen(path, "r");
5181 /* Look in "info" */
5186 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5188 sprintf(caption, "Info file '%s'", name);
5192 /* Build the filename */
5193 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5196 fff = my_fopen(path, "r");
5199 /* Look in "info" */
5202 /* Build the filename */
5203 path_build(path, 1024, ANGBAND_DIR, name);
5205 for (i = 0; path[i]; i++)
5206 if ('\\' == path[i])
5207 path[i] = PATH_SEP[0];
5211 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5213 sprintf(caption, "Info file '%s'", name);
5217 fff = my_fopen(path, "r");
5225 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5227 msg_format("Cannot open '%s'.", name);
5237 /* Pre-Parse the file */
5240 /* Read a line or stop */
5241 if (my_fgets(fff, buf, 1024)) break;
5243 /* XXX Parse "menu" items */
5244 if (prefix(buf, "***** "))
5246 /* Notice "menu" requests */
5247 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5249 /* This is a menu file */
5252 /* Extract the menu item */
5253 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5255 if ((buf[8] == ']') && (buf[9] == ' '))
5257 /* Extract the menu item */
5258 strncpy(hook[k], buf + 10, 31);
5260 /* Make sure it's null-terminated */
5264 /* Notice "tag" requests */
5265 else if (buf[6] == '<')
5267 buf[strlen(buf) - 1] = '\0';
5268 add_tag(&tags, buf + 7, next);
5275 /* Count the "real" lines */
5279 /* Save the number of "real" lines */
5282 /* start from bottom when reverse mode */
5283 if (line == -1) line = ((size-1)/rows)*rows;
5285 /* Go to the tagged line */
5286 if (tag) line = get_line(&tags, tag);
5288 /* Display the file */
5294 /* Restart when necessary */
5295 if (line >= size) line = 0;
5298 /* Re-open the file if needed */
5304 /* Hack -- Re-Open the file */
5305 fff = my_fopen(path, "r");
5308 if (!fff) return (FALSE);
5310 /* File has been restarted */
5314 /* Goto the selected line */
5318 if (my_fgets(fff, buf, 1024)) break;
5320 /* Skip tags/links */
5321 if (prefix(buf, "***** ")) continue;
5323 /* Count the lines */
5327 /* Dump the next rows lines of the file */
5328 for (i = 0; i < rows; )
5330 /* Hack -- track the "first" line */
5331 if (!i) line = next;
5333 /* Get a line of the file or stop */
5334 if (my_fgets(fff, buf, 1024)) break;
5336 /* Hack -- skip "special" lines */
5337 if (prefix(buf, "***** ")) continue;
5339 /* Count the "real" lines */
5342 /* Make a lower case version of buf for searching */
5343 strcpy(lc_buf, buf);
5345 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5348 if (iskanji(*lc_buf_ptr))
5352 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5355 /* Hack -- keep searching */
5356 if (find && !i && !strstr(lc_buf, find)) continue;
5358 /* Hack -- stop searching */
5362 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5364 /* Hilite "shower" */
5369 /* Display matches */
5370 while ((str = strstr(str, shower)) != NULL)
5372 int len = strlen(shower);
5374 /* Display the match */
5375 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5382 /* Count the printed lines */
5386 /* Hack -- failed search */
5396 /* Show a general "title" */
5401 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5403 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5406 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5407 caption, line, size), 0, 0);
5417 caption, line, size), 0, 0);
5420 /* Prompt -- menu screen */
5425 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", hgt - 1, 0);
5427 prt("[Press a Number, or ESC to exit.]", hgt - 1, 0);
5432 /* Prompt -- small files */
5433 else if (size <= rows)
5437 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5439 prt("[Press ESC to exit.]", hgt - 1, 0);
5444 /* Prompt -- large files */
5449 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5451 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5453 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5457 /* Get a keypress */
5460 /* Hack -- return to last screen */
5461 if (k == '<') break;
5463 /* Show the help for the help */
5466 /* Hack - prevent silly recursion */
5468 if (strcmp(name, "jhelpinfo.txt") != 0)
5469 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5471 if (strcmp(name, "helpinfo.txt") != 0)
5472 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5476 /* Hack -- try showing */
5481 prt("¶¯Ä´: ", hgt - 1, 0);
5483 prt("Show: ", hgt - 1, 0);
5486 (void)askfor_aux(shower, 80);
5489 /* Hack -- try finding */
5494 prt("¸¡º÷: ", hgt - 1, 0);
5496 prt("Find: ", hgt - 1, 0);
5500 if (askfor_aux(finder, 80))
5507 /* Make finder lowercase */
5508 for (cnt = 0; finder[cnt] != 0; cnt++)
5511 if (iskanji(finder[cnt]))
5515 finder[cnt] = tolower(finder[cnt]);
5519 strcpy(shower, finder);
5523 /* Hack -- go to a specific line */
5528 prt("¹Ô: ", hgt - 1, 0);
5530 prt("Goto Line: ", hgt - 1, 0);
5535 if (askfor_aux(tmp, 80))
5541 /* Hack -- go to a specific file */
5546 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5547 strcpy(tmp, "jhelp.hlp");
5549 prt("Goto File: ", hgt - 1, 0);
5550 strcpy(tmp, "help.hlp");
5554 if (askfor_aux(tmp, 80))
5556 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5560 /* Hack -- Allow backing up */
5563 line = line + (reverse ? rows : -rows);
5564 if (line < 0) line = ((size-1)/rows)*rows;
5567 /* Hack -- Advance a single line */
5568 if ((k == '\n') || (k == '\r'))
5570 line = line + (reverse ? -1 : 1);
5571 if (line < 0) line = ((size-1)/rows)*rows;
5574 /* Advance one page */
5577 line = line + (reverse ? -rows : rows);
5578 if (line < 0) line = ((size-1)/rows)*rows;
5581 /* Recurse on numbers */
5586 if (isdigit(k)) key = D2I(k);
5587 else if (isalpha(k)) key = k - 'A' + 10;
5589 if ((key > -1) && hook[key][0])
5591 /* Recurse on that file */
5592 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5597 /* Hack, dump to file */
5607 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5609 if (!get_string("File name: ", xtmp, 80))
5621 /* Build the filename */
5622 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5624 /* Hack -- Re-Open the file */
5625 fff = my_fopen(path, "r");
5627 ffp = my_fopen(buff, "w");
5633 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5635 msg_print("Failed to open file.");
5642 sprintf(xtmp, "%s: %s", player_name, what);
5643 my_fputs(ffp, xtmp, 80);
5644 my_fputs(ffp, "\n", 80);
5646 while (!my_fgets(fff, buff, 80))
5647 my_fputs(ffp, buff, 80);
5656 /* Hack -- Re-Open the file */
5657 fff = my_fopen(path, "r");
5660 /* Exit on escape */
5661 if (k == ESCAPE) break;
5662 if (k == 'q') break;
5665 /* Close the file */
5669 if (k == 'q') return (FALSE);
5677 * Peruse the On-Line-Help
5679 void do_cmd_help(void)
5684 /* Peruse the main help file */
5686 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5688 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5698 * Process the player name.
5699 * Extract a clean "base name".
5700 * Build the savefile name if needed.
5702 void process_player_name(bool sf)
5707 /* Cannot be too long */
5708 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5710 if (strlen(player_name) > 8)
5712 if (strlen(player_name) > 15)
5717 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5719 quit_fmt("The name '%s' is too long!", player_name);
5725 /* Cannot contain "icky" characters */
5726 for (i = 0; player_name[i]; i++)
5728 /* No control characters */
5730 if (iskanji(player_name[i])){i++;continue;}
5731 if (iscntrl( (unsigned char)player_name[i]))
5733 if (iscntrl(player_name[i]))
5737 /* Illegal characters */
5739 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5741 quit_fmt("The name '%s' contains control chars!", player_name);
5750 /* Extract "useful" letters */
5751 for (i = 0; player_name[i]; i++)
5754 unsigned char c = player_name[i];
5756 char c = player_name[i];
5760 /* Convert "dot" to "underscore" */
5761 if (c == '.') c = '_';
5763 /* Accept all the letters */
5764 player_base[k++] = c;
5769 /* Extract "useful" letters */
5770 for (i = 0; player_name[i]; i++)
5773 unsigned char c = player_name[i];
5775 char c = player_name[i];
5778 /* Accept some letters */
5781 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5782 player_base[k++] = c;
5784 player_base[k++] = player_name[i];
5787 else if (iskana(c)) player_base[k++] = c;
5791 /* Convert path separator to underscore */
5792 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5793 player_base[k++] = '_';
5794 i += strlen(PATH_SEP);
5797 /* Convert space, dot, and underscore to underscore */
5798 else if (strchr(". _", c)) player_base[k++] = '_';
5800 else if (isprint(c)) player_base[k++] = c;
5808 /* Hack -- max length */
5814 player_base[k] = '\0';
5816 /* Require a "base" name */
5817 if (!player_base[0]) strcpy(player_base, "PLAYER");
5820 #ifdef SAVEFILE_MUTABLE
5826 if (!savefile_base[0] && savefile[0])
5833 t = strstr(s, PATH_SEP);
5838 strcpy(savefile_base, s);
5841 if (!savefile_base[0] || !savefile[0])
5844 /* Change the savefile name */
5849 strcpy(savefile_base, player_base);
5851 #ifdef SAVEFILE_USE_UID
5852 /* Rename the savefile, using the player_uid and player_base */
5853 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5855 /* Rename the savefile, using the player_base */
5856 (void)sprintf(temp, "%s", player_base);
5860 /* Hack -- support "flat directory" usage on VM/ESA */
5861 (void)sprintf(temp, "%s.sv", player_base);
5864 /* Build the filename */
5865 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5871 * Gets a name for the character, reacting to name changes.
5873 * Assumes that "display_player(0)" has just been called
5875 * Perhaps we should NOT ask for a name (at "birth()") on
5876 * Unix machines? XXX XXX
5878 * What a horrible name for a global function. XXX XXX XXX
5884 /* Save the player name */
5885 strcpy(tmp, player_name);
5887 /* Prompt for a new name */
5889 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5891 if (get_string("Enter a name for your character: ", tmp, 15))
5895 strcpy(player_name, tmp);
5897 else if (0 == strlen(player_name))
5899 /* Use default name */
5900 strcpy(player_name, "PLAYER");
5903 /* Process the player name */
5904 process_player_name(FALSE);
5906 strcpy(tmp,ap_ptr->title);
5913 strcat(tmp,player_name);
5915 /* Re-Draw the name (in light blue) */
5916 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5918 /* Erase the prompt, etc */
5925 * Hack -- commit suicide
5927 void do_cmd_suicide(void)
5934 /* Verify Retirement */
5939 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
5941 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
5946 /* Verify Suicide */
5951 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5953 if (!get_check("Do you really want to commit suicide? ")) return;
5960 /* Special Verification for suicide */
5962 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5964 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5970 if (i != '@') return;
5976 /* Kill the player */
5980 p_ptr->leaving = TRUE;
5985 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5986 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5988 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5989 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5991 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5994 /* Cause of death */
5996 (void)strcpy(died_from, "ÅÓÃ潪λ");
5998 (void)strcpy(died_from, "Quitting");
6008 void do_cmd_save_game(int is_autosave)
6010 /* Autosaves do not disturb */
6014 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
6016 msg_print("Autosaving the game...");
6022 /* Disturb the player */
6026 /* Clear messages */
6034 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6036 prt("Saving game...", 0, 0);
6043 /* The player is not dead */
6045 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
6047 (void)strcpy(died_from, "(saved)");
6051 /* Forbid suspend */
6052 signals_ignore_tstp();
6054 /* Save the player */
6058 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6060 prt("Saving game... done.", 0, 0);
6065 /* Save failed (oops) */
6069 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6071 prt("Saving game... failed!", 0, 0);
6076 /* Allow suspend again */
6077 signals_handle_tstp();
6082 /* Note that the player is not dead */
6084 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6086 (void)strcpy(died_from, "(alive and well)");
6093 * Save the game and exit
6095 void do_cmd_save_and_exit(void)
6100 p_ptr->leaving = TRUE;
6102 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6104 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6110 * Hack -- Calculates the total number of points earned -JWT-
6112 long total_points(void)
6116 u32b point, point_h, point_l;
6117 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6119 if (stupid_monsters) mult -= 70;
6120 if (!preserve_mode) mult += 10;
6121 if (!autoroller) mult += 10;
6122 if (!smart_learn) mult -= 20;
6123 if (!terrain_streams) mult -= 20;
6124 if (smart_cheat) mult += 30;
6125 if (ironman_shops) mult += 50;
6126 if (ironman_small_levels) mult += 10;
6127 if (ironman_empty_levels) mult += 20;
6128 if (!powerup_home) mult += 50;
6129 if (ironman_rooms) mult += 100;
6130 if (ironman_nightmare) mult += 100;
6132 if (mult < 5) mult = 5;
6134 for (i = 0; i < max_d_idx; i++)
6135 if(max_dlv[i] > max_dl)
6136 max_dl = max_dlv[i];
6138 point_l = (p_ptr->max_exp + (100 * max_dl));
6139 point_h = point_l / 0x10000L;
6140 point_l = point_l % 0x10000L;
6143 point_h += point_l / 0x10000L;
6144 point_l %= 0x10000L;
6146 point_l += ((point_h % 100) << 16);
6150 point = (point_h << 16) + (point_l);
6151 if (p_ptr->arena_number < 99)
6152 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6154 if (ironman_downward) point *= 2;
6155 if (p_ptr->pclass == CLASS_BERSERKER)
6157 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6161 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6164 if (total_winner) point = 2;
6166 if (easy_band) point = (0 - point);
6174 * Centers a string within a 31 character string -JWT-
6176 static void center_string(char *buf, cptr str)
6183 /* Necessary border */
6187 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6193 * Save a "bones" file for a dead character
6195 * Note that we will not use these files until Angband 2.8.0, and
6196 * then we will only use the name and level on which death occured.
6198 * Should probably attempt some form of locking...
6200 static void make_bones(void)
6207 /* Ignore wizards and borgs */
6208 if (!(noscore & 0x00FF))
6210 /* Ignore people who die in town */
6215 /* XXX XXX XXX "Bones" name */
6216 sprintf(tmp, "bone.%03d", dun_level);
6218 /* Build the filename */
6219 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6221 /* Attempt to open the bones file */
6222 fp = my_fopen(str, "r");
6224 /* Close it right away */
6225 if (fp) my_fclose(fp);
6227 /* Do not over-write a previous ghost */
6230 /* File type is "TEXT" */
6231 FILE_TYPE(FILE_TYPE_TEXT);
6233 /* Try to write a new "Bones File" */
6234 fp = my_fopen(str, "w");
6236 /* Not allowed to write it? Weird. */
6240 fprintf(fp, "%s\n", player_name);
6241 fprintf(fp, "%d\n", p_ptr->mhp);
6242 fprintf(fp, "%d\n", p_ptr->prace);
6243 fprintf(fp, "%d\n", p_ptr->pclass);
6245 /* Close and save the Bones file */
6254 * Redefinable "print_tombstone" action
6256 bool (*tombstone_aux)(void) = NULL;
6260 * Display a "tomb-stone"
6262 static void print_tomb(void)
6266 /* Do we use a special tombstone ? */
6269 /* Use tombstone hook */
6270 done = (*tombstone_aux)();
6273 /* Print the text-tombstone */
6287 time_t ct = time((time_t)0);
6293 /* Build the filename */
6295 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6297 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6301 /* Open the News file */
6302 fp = my_fopen(buf, "r");
6309 /* Dump the file to the screen */
6310 while (0 == my_fgets(fp, buf, 1024))
6312 /* Display and advance */
6313 put_str(buf, i++, 0);
6322 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6336 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6339 center_string(buf, player_name);
6340 put_str(buf, 6, 11);
6343 center_string(buf, "the");
6344 put_str(buf, 7, 11);
6347 center_string(buf, p);
6348 put_str(buf, 8, 11);
6351 center_string(buf, cp_ptr->title);
6353 put_str(buf, 10, 11);
6356 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6358 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6361 center_string(buf, tmp);
6362 put_str(buf, 11, 11);
6365 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6367 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6370 center_string(buf, tmp);
6371 put_str(buf, 12, 11);
6374 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6376 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6379 center_string(buf, tmp);
6380 put_str(buf, 13, 11);
6383 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6384 if (streq(died_from, "ÅÓÃ潪λ"))
6386 strcpy(tmp, "<¼«»¦>");
6390 if (streq(died_from, "ripe"))
6392 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6394 else if (streq(died_from, "Seppuku"))
6396 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6400 strcpy(tmp, died_from);
6403 center_string(buf, tmp);
6404 put_str(buf, 14, 11);
6406 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6408 if( dun_level == 0 )
6410 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6411 if(streq(died_from, "ÅÓÃ潪λ"))
6413 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6417 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6422 if(streq(died_from, "ÅÓÃ潪λ"))
6424 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6428 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6431 center_string(buf, tmp);
6432 put_str(buf, 15, 11);
6435 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6436 center_string(buf, tmp);
6437 put_str(buf, 14, 11);
6440 if (strlen(died_from) > 24)
6442 strncpy(dummy, died_from, 24);
6444 (void)sprintf(tmp, "by %s.", dummy);
6447 (void)sprintf(tmp, "by %s.", died_from);
6449 center_string(buf, tmp);
6450 put_str(buf, 15, 11);
6455 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6456 center_string(buf, tmp);
6457 put_str(buf, 17, 11);
6460 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6462 msg_format("Goodbye, %s!", player_name);
6470 * Display some character info
6472 static void show_info(void)
6478 /* Hack -- Know everything in the inven/equip */
6479 for (i = 0; i < INVEN_TOTAL; i++)
6481 o_ptr = &inventory[i];
6483 /* Skip non-objects */
6484 if (!o_ptr->k_idx) continue;
6486 /* Aware and Known */
6487 object_aware(o_ptr);
6488 object_known(o_ptr);
6491 for (i = 1; i < max_towns; i++)
6493 st_ptr = &town[i].store[STORE_HOME];
6495 /* Hack -- Know everything in the home */
6496 for (j = 0; j < st_ptr->stock_num; j++)
6498 o_ptr = &st_ptr->stock[j];
6500 /* Skip non-objects */
6501 if (!o_ptr->k_idx) continue;
6503 /* Aware and Known */
6504 object_aware(o_ptr);
6505 object_known(o_ptr);
6509 /* Hack -- Recalculate bonuses */
6510 p_ptr->update |= (PU_BONUS);
6515 /* Flush all input keys */
6518 /* Flush messages */
6522 /* Describe options */
6524 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6525 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6527 prt("You may now dump a character record to one or more files.", 21, 0);
6528 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6532 /* Dump character records as requested */
6539 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6541 put_str("Filename: ", 23, 0);
6546 strcpy(out_val, "");
6548 /* Ask for filename (or abort) */
6549 if (!askfor_aux(out_val, 60)) return;
6551 /* Return means "show on screen" */
6552 if (!out_val[0]) break;
6557 /* Dump a character file */
6558 (void)file_character(out_val, TRUE);
6566 /* Display player */
6569 /* Prompt for inventory */
6571 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6573 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6577 /* Allow abort at this point */
6578 if (inkey() == ESCAPE) return;
6581 /* Show equipment and inventory */
6583 /* Equipment -- if any */
6587 item_tester_full = TRUE;
6588 (void)show_equip(0);
6590 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6592 prt("You are using: -more-", 0, 0);
6595 if (inkey() == ESCAPE) return;
6598 /* Inventory -- if any */
6602 item_tester_full = TRUE;
6603 (void)show_inven(0);
6605 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6607 prt("You are carrying: -more-", 0, 0);
6610 if (inkey() == ESCAPE) return;
6613 /* Homes in the different towns */
6614 for (l = 1; l < max_towns; l++)
6616 st_ptr = &town[l].store[STORE_HOME];
6618 /* Home -- if anything there */
6619 if (st_ptr->stock_num)
6621 /* Display contents of the home */
6622 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6628 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6630 char o_name[MAX_NLEN];
6634 o_ptr = &st_ptr->stock[i];
6636 /* Print header, clear line */
6637 sprintf(tmp_val, "%c) ", I2A(j));
6638 prt(tmp_val, j+2, 4);
6640 /* Display object description */
6641 object_desc(o_name, o_ptr, TRUE, 3);
6642 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6647 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6649 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6654 if (inkey() == ESCAPE) return;
6661 static bool check_score(void)
6667 if (highscore_fd < 0)
6670 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6672 msg_print("Score file unavailable.");
6679 #ifndef SCORE_WIZARDS
6680 /* Wizard-mode pre-empts scoring */
6681 if (noscore & 0x000F)
6684 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6686 msg_print("Score not registered for wizards.");
6695 /* Borg-mode pre-empts scoring */
6696 if (noscore & 0x00F0)
6699 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6701 msg_print("Score not registered for borgs.");
6709 #ifndef SCORE_CHEATERS
6710 /* Cheaters are not scored */
6711 if (noscore & 0xFF00)
6714 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6716 msg_print("Score not registered for cheaters.");
6726 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6728 if (!total_winner && streq(died_from, "Interrupting"))
6733 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6735 msg_print("Score not registered due to interruption.");
6744 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6746 if (!total_winner && streq(died_from, "Quitting"))
6751 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6753 msg_print("Score not registered due to quitting.");
6763 * Close up the current game (player may or may not be dead)
6765 * This function is called only from "main.c" and "signals.c".
6767 void close_game(void)
6770 bool do_send = TRUE;
6772 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6777 /* Flush the messages */
6780 /* Flush the input */
6784 /* No suspending now */
6785 signals_ignore_tstp();
6788 /* Hack -- Character is now "icky" */
6789 character_icky = TRUE;
6792 /* Build the filename */
6793 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6795 /* Open the high score file, for reading/writing */
6796 highscore_fd = fd_open(buf, O_RDWR);
6802 /* Handle retirement */
6803 if (total_winner) kingly();
6807 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6809 if (!munchkin_death || get_check("Save death? "))
6814 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6816 if (!save_player()) msg_print("death save failed!");
6819 else do_send = FALSE;
6826 /* Show more info */
6834 if ((!send_world_score(do_send)))
6837 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6839 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6842 wait_report_score = TRUE;
6845 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6847 if (!save_player()) msg_print("death save failed!");
6851 if (!wait_report_score)
6854 else if (highscore_fd >= 0)
6856 display_scores_aux(0, 10, -1, NULL);
6859 /* Dump bones file */
6868 do_cmd_save_game(FALSE);
6870 /* Prompt for scores XXX XXX XXX */
6872 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6874 prt("Press Return (or Escape).", 0, 40);
6878 /* Predict score (or ESCAPE) */
6879 if (inkey() != ESCAPE) predict_score();
6883 /* Shut the high score file */
6884 (void)fd_close(highscore_fd);
6886 /* Forget the high score fd */
6890 /* Allow suspending now */
6891 signals_handle_tstp();
6896 * Handle abrupt death of the visual system
6898 * This routine is called only in very rare situations, and only
6899 * by certain visual systems, when they experience fatal errors.
6901 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6902 * save file so that player can see tombstone when restart.
6904 void exit_game_panic(void)
6906 /* If nothing important has happened, just quit */
6908 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6910 if (!character_generated || character_saved) quit("panic");
6914 /* Mega-Hack -- see "msg_print()" */
6917 /* Clear the top line */
6920 /* Hack -- turn off some things */
6923 /* Mega-Hack -- Delay death */
6924 if (p_ptr->chp < 0) death = FALSE;
6926 /* Hardcode panic save */
6929 /* Forbid suspend */
6930 signals_ignore_tstp();
6932 /* Indicate panic save */
6934 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6936 (void)strcpy(died_from, "(panic save)");
6940 /* Panic save, or get worried */
6942 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6944 if (!save_player()) quit("panic save failed!");
6948 /* Successful panic save */
6950 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6952 quit("panic save succeeded!");
6959 * Get a random line from a file
6960 * Based on the monster speech patch by Matt Graham,
6962 errr get_rnd_line(cptr file_name, int entry, char *output)
6966 int line, counter, test, numentries;
6971 /* Build the filename */
6972 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6975 fp = my_fopen(buf, "r");
6978 if (!fp) return (-1);
6980 /* Find the entry of the monster */
6983 /* Get a line from the file */
6984 if (my_fgets(fp, buf, 1024) == 0)
6986 /* Count the lines */
6989 /* Look for lines starting with 'N:' */
6990 if ((buf[0] == 'N') && (buf[1] == ':'))
6992 /* Allow default lines */
6999 else if (buf[2] == 'M')
7001 if (r_info[entry].flags1 & RF1_MALE)
7007 else if (buf[2] == 'F')
7009 if (r_info[entry].flags1 & RF1_FEMALE)
7015 /* Get the monster number */
7016 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7018 /* Is it the right monster? */
7027 /* Error while converting the monster number */
7028 msg_format("Error in line %d of %s!",
7029 line_num, file_name);
7037 /* Reached end of file */
7044 /* Get the number of entries */
7048 if (my_fgets(fp, buf, 1024) == 0)
7050 /* Count the lines */
7053 /* Look for the number of entries */
7054 if (isdigit(buf[0]))
7056 /* Get the number of entries */
7057 numentries = atoi(buf);
7063 /* Count the lines */
7066 /* Reached end of file without finding the number */
7067 msg_format("Error in line %d of %s!",
7068 line_num, file_name);
7077 /* Grab an appropriate line number */
7078 line = randint0(numentries);
7080 /* Get the random line */
7081 for (counter = 0; counter <= line; counter++)
7083 /* Count the lines */
7088 test = my_fgets(fp, buf, 1024);
7089 if(test || buf[0] != '#')
7095 /* Found the line */
7096 if (counter == line) break;
7100 /* Error - End of file */
7101 msg_format("Error in line %d of %s!",
7102 line_num, file_name);
7110 strcpy(output, buf);
7117 /* Close the file */
7126 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7130 for (i=0;i<count;i++){
7131 result=get_rnd_line(file_name, entry, output);
7134 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7142 * Process file for auto picker/destroyer.
7144 errr process_pickpref_file(cptr name)
7153 /* Build the filename */
7154 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7156 err = process_pref_file_aux(buf, TRUE);
7165 static errr counts_seek(int fd, u32b where, bool flag)
7168 char temp1[128], temp2[128];
7169 u32b zero_header[3] = {0L, 0L, 0L};
7172 #ifdef SAVEFILE_USE_UID
7173 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7175 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7177 for (i = 0; temp1[i]; i++)
7178 temp1[i] ^= (i+1) * 63;
7183 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7185 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7190 fd_seek(fd, seekpoint);
7191 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7192 fd_write(fd, (char*)(temp1), sizeof(temp1));
7196 if (strcmp(temp1, temp2) == 0)
7199 seekpoint += 128 + 3 * sizeof(u32b);
7202 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7205 u32b counts_read(int where)
7212 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7214 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7216 fd = fd_open(buf, O_RDONLY);
7218 if (counts_seek(fd, where, FALSE) ||
7219 fd_read(fd, (char*)(&count), sizeof(u32b)))
7227 errr counts_write(int where, u32b count)
7233 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7235 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7237 fd = fd_open(buf, O_RDWR);
7240 /* File type is "DATA" */
7241 FILE_TYPE(FILE_TYPE_DATA);
7243 /* Create a new high score file */
7244 fd = fd_make(buf, 0644);
7247 if (fd_lock(fd, F_WRLCK)) return 1;
7249 counts_seek(fd, where, TRUE);
7250 fd_write(fd, (char*)(&count), sizeof(u32b));
7252 if (fd_lock(fd, F_UNLCK)) return 1;
7260 #ifdef HANDLE_SIGNALS
7267 * Handle signals -- suspend
7269 * Actually suspend the game, and then resume cleanly
7271 static void handle_signal_suspend(int sig)
7273 /* Disable handler */
7274 (void)signal(sig, SIG_IGN);
7281 /* Suspend the "Term" */
7282 Term_xtra(TERM_XTRA_ALIVE, 0);
7284 /* Suspend ourself */
7285 (void)kill(0, SIGSTOP);
7287 /* Resume the "Term" */
7288 Term_xtra(TERM_XTRA_ALIVE, 1);
7290 /* Redraw the term */
7293 /* Flush the term */
7298 /* Restore handler */
7299 (void)signal(sig, handle_signal_suspend);
7304 * Handle signals -- simple (interrupt and quit)
7306 * This function was causing a *huge* number of problems, so it has
7307 * been simplified greatly. We keep a global variable which counts
7308 * the number of times the user attempts to kill the process, and
7309 * we commit suicide if the user does this a certain number of times.
7311 * We attempt to give "feedback" to the user as he approaches the
7312 * suicide thresh-hold, but without penalizing accidental keypresses.
7314 * To prevent messy accidents, we should reset this global variable
7315 * whenever the user enters a keypress, or something like that.
7317 static void handle_signal_simple(int sig)
7319 /* Disable handler */
7320 (void)signal(sig, SIG_IGN);
7323 /* Nothing to save, just quit */
7324 if (!character_generated || character_saved) quit(NULL);
7327 /* Count the signals */
7331 /* Terminate dead characters */
7334 /* Mark the savefile */
7336 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7338 (void)strcpy(died_from, "Abortion");
7357 /* Allow suicide (after 5) */
7358 else if (signal_count >= 5)
7360 /* Cause of "death" */
7362 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7364 (void)strcpy(died_from, "Interrupting");
7379 p_ptr->leaving = TRUE;
7393 /* Give warning (after 4) */
7394 else if (signal_count >= 4)
7397 Term_xtra(TERM_XTRA_NOISE, 0);
7399 /* Clear the top line */
7400 Term_erase(0, 0, 255);
7402 /* Display the cause */
7404 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7406 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7414 /* Give warning (after 2) */
7415 else if (signal_count >= 2)
7418 Term_xtra(TERM_XTRA_NOISE, 0);
7421 /* Restore handler */
7422 (void)signal(sig, handle_signal_simple);
7427 * Handle signal -- abort, kill, etc
7429 static void handle_signal_abort(int sig)
7433 Term_get_size(&wid, &hgt);
7436 /* Disable handler */
7437 (void)signal(sig, SIG_IGN);
7440 /* Nothing to save, just quit */
7441 if (!character_generated || character_saved) quit(NULL);
7448 /* Clear the bottom line */
7449 Term_erase(0, hgt - 1, 255);
7451 /* Give a warning */
7452 Term_putstr(0, hgt - 1, -1, TERM_RED,
7454 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7456 "A gruesome software bug LEAPS out at you!");
7462 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7464 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7476 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7478 (void)strcpy(died_from, "(panic save)");
7482 /* Forbid suspend */
7483 signals_ignore_tstp();
7485 /* Attempt to save */
7489 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7491 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7500 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7502 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7512 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7514 quit("software bug");
7523 * Ignore SIGTSTP signals (keyboard suspend)
7525 void signals_ignore_tstp(void)
7529 (void)signal(SIGTSTP, SIG_IGN);
7535 * Handle SIGTSTP signals (keyboard suspend)
7537 void signals_handle_tstp(void)
7541 (void)signal(SIGTSTP, handle_signal_suspend);
7548 * Prepare to handle the relevant signals
7550 void signals_init(void)
7554 (void)signal(SIGHUP, SIG_IGN);
7559 (void)signal(SIGTSTP, handle_signal_suspend);
7564 (void)signal(SIGINT, handle_signal_simple);
7568 (void)signal(SIGQUIT, handle_signal_simple);
7573 (void)signal(SIGFPE, handle_signal_abort);
7577 (void)signal(SIGILL, handle_signal_abort);
7581 (void)signal(SIGTRAP, handle_signal_abort);
7585 (void)signal(SIGIOT, handle_signal_abort);
7589 (void)signal(SIGKILL, handle_signal_abort);
7593 (void)signal(SIGBUS, handle_signal_abort);
7597 (void)signal(SIGSEGV, handle_signal_abort);
7601 (void)signal(SIGTERM, handle_signal_abort);
7605 (void)signal(SIGPIPE, handle_signal_abort);
7609 (void)signal(SIGEMT, handle_signal_abort);
7613 (void)signal(SIGDANGER, handle_signal_abort);
7617 (void)signal(SIGSYS, handle_signal_abort);
7621 (void)signal(SIGXCPU, handle_signal_abort);
7625 (void)signal(SIGPWR, handle_signal_abort);
7631 #else /* HANDLE_SIGNALS */
7637 void signals_ignore_tstp(void)
7644 void signals_handle_tstp(void)
7651 void signals_init(void)
7654 #endif /* HANDLE_SIGNALS */