3 /* Purpose: code dealing with files (and death) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
17 * You may or may not want to use the following "#undef".
19 /* #undef _POSIX_SAVED_IDS */
23 * Hack -- drop permissions
25 void safe_setuid_drop(void)
32 # ifdef SAFE_SETUID_POSIX
34 if (setuid(getuid()) != 0)
37 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
39 quit("setuid(): cannot set permissions correctly!");
43 if (setgid(getgid()) != 0)
46 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
48 quit("setgid(): cannot set permissions correctly!");
55 if (setreuid(geteuid(), getuid()) != 0)
58 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
60 quit("setreuid(): cannot set permissions correctly!");
64 if (setregid(getegid(), getgid()) != 0)
67 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
69 quit("setregid(): cannot set permissions correctly!");
84 * Hack -- grab permissions
86 void safe_setuid_grab(void)
93 # ifdef SAFE_SETUID_POSIX
95 if (setuid(player_euid) != 0)
98 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
100 quit("setuid(): cannot set permissions correctly!");
104 if (setgid(player_egid) != 0)
107 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
109 quit("setgid(): cannot set permissions correctly!");
116 if (setreuid(geteuid(), getuid()) != 0)
119 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
121 quit("setreuid(): cannot set permissions correctly!");
125 if (setregid(getegid(), getgid()) != 0)
128 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
130 quit("setregid(): cannot set permissions correctly!");
135 # endif /* SAFE_SETUID_POSIX */
137 # endif /* SAFE_SETUID */
145 * Extract the first few "tokens" from a buffer
147 * This function uses "colon" and "slash" as the delimeter characters.
149 * We never extract more than "num" tokens. The "last" token may include
150 * "delimeter" characters, allowing the buffer to include a "string" token.
152 * We save pointers to the tokens in "tokens", and return the number found.
154 * Hack -- Attempt to handle the 'c' character formalism
156 * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
158 * Hack -- We will always extract at least one token
160 s16b tokenize(char *buf, s16b num, char **tokens, int mode)
172 /* Scan the string */
175 /* Found a delimiter */
176 if ((*t == ':') || (*t == '/')) break;
178 /* Handle single quotes */
179 if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
184 /* Handle backslash */
187 /* Require a character */
193 /* Hack -- Require a close quote */
194 if (*t != '\'') *t = '\'';
197 /* Handle back-slash */
204 /* Nuke and advance */
222 /* A number with a name */
223 typedef struct named_num named_num;
227 cptr name; /* The name of this thing */
228 int num; /* A number associated with it */
232 /* Index of spell type names */
233 static named_num gf_desc[] =
235 {"GF_ELEC", GF_ELEC },
236 {"GF_POIS", GF_POIS },
237 {"GF_ACID", GF_ACID },
238 {"GF_COLD", GF_COLD },
239 {"GF_FIRE", GF_FIRE },
240 {"GF_PSY_SPEAR", GF_PSY_SPEAR },
241 {"GF_MISSILE", GF_MISSILE },
242 {"GF_ARROW", GF_ARROW },
243 {"GF_PLASMA", GF_PLASMA },
244 {"GF_WATER", GF_WATER },
245 {"GF_LITE", GF_LITE },
246 {"GF_DARK", GF_DARK },
247 {"GF_LITE_WEAK", GF_LITE_WEAK },
248 {"GF_DARK_WEAK", GF_DARK_WEAK },
249 {"GF_SHARDS", GF_SHARDS },
250 {"GF_SOUND", GF_SOUND },
251 {"GF_CONFUSION", GF_CONFUSION },
252 {"GF_FORCE", GF_FORCE },
253 {"GF_INERTIA", GF_INERTIA },
254 {"GF_MANA", GF_MANA },
255 {"GF_METEOR", GF_METEOR },
257 {"GF_CHAOS", GF_CHAOS },
258 {"GF_NETHER", GF_NETHER },
259 {"GF_DISENCHANT", GF_DISENCHANT },
260 {"GF_NEXUS", GF_NEXUS },
261 {"GF_TIME", GF_TIME },
262 {"GF_GRAVITY", GF_GRAVITY },
263 {"GF_KILL_WALL", GF_KILL_WALL },
264 {"GF_KILL_DOOR", GF_KILL_DOOR },
265 {"GF_KILL_TRAP", GF_KILL_TRAP },
266 {"GF_MAKE_WALL", GF_MAKE_WALL },
267 {"GF_MAKE_DOOR", GF_MAKE_DOOR },
268 {"GF_MAKE_TRAP", GF_MAKE_TRAP },
269 {"GF_MAKE_TREE", GF_MAKE_TREE },
270 {"GF_OLD_CLONE", GF_OLD_CLONE },
271 {"GF_OLD_POLY", GF_OLD_POLY },
272 {"GF_OLD_HEAL", GF_OLD_HEAL },
273 {"GF_OLD_SPEED", GF_OLD_SPEED },
274 {"GF_OLD_SLOW", GF_OLD_SLOW },
275 {"GF_OLD_CONF", GF_OLD_CONF },
276 {"GF_OLD_SLEEP", GF_OLD_SLEEP },
277 {"GF_OLD_DRAIN", GF_OLD_DRAIN },
278 {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD },
279 {"GF_AWAY_EVIL", GF_AWAY_EVIL },
280 {"GF_AWAY_ALL", GF_AWAY_ALL },
281 {"GF_TURN_UNDEAD", GF_TURN_UNDEAD },
282 {"GF_TURN_EVIL", GF_TURN_EVIL },
283 {"GF_TURN_ALL", GF_TURN_ALL },
284 {"GF_DISP_UNDEAD", GF_DISP_UNDEAD },
285 {"GF_DISP_EVIL", GF_DISP_EVIL },
286 {"GF_DISP_ALL", GF_DISP_ALL },
287 {"GF_DISP_DEMON", GF_DISP_DEMON },
288 {"GF_DISP_LIVING", GF_DISP_LIVING },
289 {"GF_ROCKET", GF_ROCKET },
290 {"GF_NUKE", GF_NUKE },
291 {"GF_MAKE_GLYPH", GF_MAKE_GLYPH },
292 {"GF_STASIS", GF_STASIS },
293 {"GF_STONE_WALL", GF_STONE_WALL },
294 {"GF_DEATH_RAY", GF_DEATH_RAY },
295 {"GF_STUN", GF_STUN },
296 {"GF_HOLY_FIRE", GF_HOLY_FIRE },
297 {"GF_HELL_FIRE", GF_HELL_FIRE },
298 {"GF_DISINTEGRATE", GF_DISINTEGRATE },
299 {"GF_CHARM", GF_CHARM },
300 {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD },
301 {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL },
303 {"GF_PSI_DRAIN", GF_PSI_DRAIN },
304 {"GF_TELEKINESIS", GF_TELEKINESIS },
305 {"GF_JAM_DOOR", GF_JAM_DOOR },
306 {"GF_DOMINATION", GF_DOMINATION },
307 {"GF_DISP_GOOD", GF_DISP_GOOD },
308 {"GF_DRAIN_MANA", GF_DRAIN_MANA },
309 {"GF_MIND_BLAST", GF_MIND_BLAST },
310 {"GF_BRAIN_SMASH", GF_BRAIN_SMASH },
311 {"GF_CAUSE_1", GF_CAUSE_1 },
312 {"GF_CAUSE_2", GF_CAUSE_2 },
313 {"GF_CAUSE_3", GF_CAUSE_3 },
314 {"GF_CAUSE_4", GF_CAUSE_4 },
315 {"GF_HAND_DOOM", GF_HAND_DOOM },
316 {"GF_CAPTURE", GF_CAPTURE },
317 {"GF_ANIM_DEAD", GF_ANIM_DEAD },
318 {"GF_CONTROL_LIVING", GF_CONTROL_LIVING },
319 {"GF_IDENTIFY", GF_IDENTIFY },
320 {"GF_ATTACK", GF_ATTACK },
321 {"GF_ENGETSU", GF_ENGETSU },
322 {"GF_GENOCIDE", GF_GENOCIDE },
323 {"GF_PHOTO", GF_PHOTO },
324 {"GF_CONTROL_DEMON", GF_CONTROL_DEMON },
325 {"GF_LAVA_FLOW", GF_LAVA_FLOW },
326 {"GF_BLOOD_CURSE", GF_BLOOD_CURSE },
327 {"GF_SEEKER", GF_SEEKER },
328 {"GF_SUPER_RAY", GF_SUPER_RAY },
329 {"GF_STAR_HEAL", GF_STAR_HEAL },
330 {"GF_WATER_FLOW", GF_WATER_FLOW },
331 {"GF_CRUSADE", GF_CRUSADE },
332 {"GF_STASIS_EVIL", GF_STASIS_EVIL },
333 {"GF_WOUNDS", GF_WOUNDS },
339 * Parse a sub-file of the "extra info" (format shown below)
341 * Each "action" line has an "action symbol" in the first column,
342 * followed by a colon, followed by some command specific info,
343 * usually in the form of "tokens" separated by colons or slashes.
345 * Blank lines, lines starting with white space, and lines starting
346 * with pound signs ("#") are ignored (as comments).
348 * Note the use of "tokenize()" to allow the use of both colons and
349 * slashes as delimeters, while still allowing final tokens which
350 * may contain any characters including "delimiters".
352 * Note the use of "strtol()" to allow all "integers" to be encoded
353 * in decimal, hexidecimal, or octal form.
355 * Note that "monster zero" is used for the "player" attr/char, "object
356 * zero" will be used for the "stack" attr/char, and "feature zero" is
357 * used for the "nothing" attr/char.
359 * Parse another file recursively, see below for details
362 * Specify the attr/char values for "monsters" by race index
365 * Specify the attr/char values for "objects" by kind index
368 * Specify the attr/char values for "features" by feature index
371 * Specify the attr/char values for unaware "objects" by kind tval
374 * Specify the attr/char values for inventory "objects" by kind tval
377 * Define a macro action, given an encoded macro action
380 * Create a normal macro, given an encoded macro trigger
383 * Create a command macro, given an encoded macro trigger
386 * Create a keyset mapping
387 * S:<key>:<key>:<dir>
389 * Turn an option off, given its name
392 * Turn an option on, given its name
395 * Specify visual information, given an index, and some data
396 * V:<num>:<kv>:<rv>:<gv>:<bv>
398 * Specify the set of colors to use when drawing a zapped spell
401 * Specify a macro trigger template and macro trigger names.
402 * T:<template>:<modifier chr>:<modifier name1>:<modifier name2>:...
403 * T:<trigger>:<keycode>:<shift-keycode>
407 errr process_pref_file_command(char *buf)
414 /* Require "?:*" format */
415 if (buf[1] != ':') return (1);
418 /* Process "%:<fname>" */
421 /* Attempt to Process the given file */
422 return (process_pref_file(buf + 2));
426 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
429 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
432 i = (huge)strtol(zz[0], NULL, 0);
433 n1 = strtol(zz[1], NULL, 0);
434 n2 = strtol(zz[2], NULL, 0);
435 if (i >= max_r_idx) return (1);
437 if (n1) r_ptr->x_attr = n1;
438 if (n2) r_ptr->x_char = n2;
443 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
444 else if (buf[0] == 'K')
446 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
449 i = (huge)strtol(zz[0], NULL, 0);
450 n1 = strtol(zz[1], NULL, 0);
451 n2 = strtol(zz[2], NULL, 0);
452 if (i >= max_k_idx) return (1);
454 if (n1) k_ptr->x_attr = n1;
455 if (n2) k_ptr->x_char = n2;
460 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
461 else if (buf[0] == 'F')
463 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
466 i = (huge)strtol(zz[0], NULL, 0);
467 n1 = strtol(zz[1], NULL, 0);
468 n2 = strtol(zz[2], NULL, 0);
469 if (i >= max_f_idx) return (1);
471 if (n1) f_ptr->x_attr = n1;
472 if (n2) f_ptr->x_char = n2;
477 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
478 else if (buf[0] == 'S')
480 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
482 j = (byte)strtol(zz[0], NULL, 0);
483 n1 = strtol(zz[1], NULL, 0);
484 n2 = strtol(zz[2], NULL, 0);
485 misc_to_attr[j] = n1;
486 misc_to_char[j] = n2;
491 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
492 else if (buf[0] == 'U')
494 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
496 j = (huge)strtol(zz[0], NULL, 0);
497 n1 = strtol(zz[1], NULL, 0);
498 n2 = strtol(zz[2], NULL, 0);
499 for (i = 1; i < max_k_idx; i++)
501 object_kind *k_ptr = &k_info[i];
502 if (k_ptr->tval == j)
504 if (n1) k_ptr->d_attr = n1;
505 if (n2) k_ptr->d_char = n2;
512 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
513 else if (buf[0] == 'E')
515 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
517 j = (byte)strtol(zz[0], NULL, 0) % 128;
518 n1 = strtol(zz[1], NULL, 0);
519 if (n1) tval_to_attr[j] = n1;
525 /* Process "A:<str>" -- save an "action" for later */
526 else if (buf[0] == 'A')
528 text_to_ascii(macro__buf, buf+2);
532 /* Process "P:<str>" -- normal macro */
533 else if (buf[0] == 'P')
536 text_to_ascii(tmp, buf+2);
537 macro_add(tmp, macro__buf);
542 /* Process "C:<str>" -- create keymap */
543 else if (buf[0] == 'C')
549 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return (1);
551 mode = strtol(zz[0], NULL, 0);
552 if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1);
554 text_to_ascii(tmp, zz[1]);
555 if (!tmp[0] || tmp[1]) return (1);
558 string_free(keymap_act[mode][i]);
560 keymap_act[mode][i] = string_make(macro__buf);
566 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
567 else if (buf[0] == 'V')
569 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
571 i = (byte)strtol(zz[0], NULL, 0);
572 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
573 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
574 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
575 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
581 /* Process "X:<str>" -- turn option off */
582 else if (buf[0] == 'X')
584 for (i = 0; option_info[i].o_desc; i++)
586 int os = option_info[i].o_set;
587 int ob = option_info[i].o_bit;
589 if (option_info[i].o_var &&
590 option_info[i].o_text &&
591 streq(option_info[i].o_text, buf + 2))
593 if (alive && 6 == option_info[i].o_page && !wizard)
596 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
598 msg_format("Startup options can not changed! '%s'", buf);
605 option_flag[os] &= ~(1L << ob);
606 (*option_info[i].o_var) = FALSE;
611 /* don't know that option. ignore it.*/
613 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
615 msg_format("Ignored invalid option: %s", buf);
621 /* Process "Y:<str>" -- turn option on */
622 else if (buf[0] == 'Y')
624 for (i = 0; option_info[i].o_desc; i++)
626 int os = option_info[i].o_set;
627 int ob = option_info[i].o_bit;
629 if (option_info[i].o_var &&
630 option_info[i].o_text &&
631 streq(option_info[i].o_text, buf + 2))
633 if (alive && 6 == option_info[i].o_page && !wizard)
636 msg_format("½é´ü¥ª¥×¥·¥ç¥ó¤ÏÊѹ¹¤Ç¤¤Þ¤»¤ó! '%s'", buf);
638 msg_format("Startup options can not changed! '%s'", buf);
645 option_flag[os] |= (1L << ob);
646 (*option_info[i].o_var) = TRUE;
651 /* don't know that option. ignore it.*/
653 msg_format("¥ª¥×¥·¥ç¥ó¤Î̾Á°¤¬Àµ¤·¤¯¤¢¤ê¤Þ¤»¤ó¡§ %s", buf);
655 msg_format("Ignored invalid option: %s", buf);
661 /* Process "Z:<type>:<str>" -- set spell color */
662 else if (buf[0] == 'Z')
665 char *t = strchr(buf + 2, ':');
673 for (i = 0; gf_desc[i].name; i++)
675 /* Match this type */
676 if (streq(gf_desc[i].name, buf + 2))
678 /* Remember this color set */
679 gf_color[gf_desc[i].num] = quark_add(t);
686 /* set macro trigger names and a template */
687 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
688 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
689 else if (buf[0] == 'T')
692 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
698 if (macro_template != NULL)
700 free(macro_template);
701 macro_template = NULL;
702 for (i = 0; i < max_macrotrigger; i++)
703 free(macro_trigger_name[i]);
704 max_macrotrigger = 0;
707 if (*zz[0] == '\0') return 0; /* clear template */
709 if (2 + num != tok) return 1; /* error */
711 len = strlen(zz[0])+1+num+1;
712 for (i = 0; i < num; i++)
713 len += strlen(zz[2+i])+1;
714 macro_template = malloc(len);
716 strcpy(macro_template, zz[0]);
718 macro_template + strlen(macro_template) + 1;
719 strcpy(macro_modifier_chr, zz[1]);
720 macro_modifier_name[0] =
721 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
722 for (i = 0; i < num; i++)
724 strcpy(macro_modifier_name[i], zz[2+i]);
725 macro_modifier_name[i+1] = macro_modifier_name[i] +
726 strlen(macro_modifier_name[i]) + 1;
733 if (max_macrotrigger >= MAX_MACRO_TRIG)
736 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
738 msg_print("Too many macro triggers!");
742 m = max_macrotrigger;
745 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
747 len += strlen(zz[2]) + 1;
748 macro_trigger_name[m] = malloc(len);
750 t = macro_trigger_name[m];
759 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
760 strlen(macro_trigger_name[m]) + 1;
761 strcpy(macro_trigger_keycode[0][m], zz[1]);
764 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
765 strlen(macro_trigger_keycode[0][m]) + 1;
766 strcpy(macro_trigger_keycode[1][m], zz[2]);
770 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
782 * Helper function for "process_pref_file()"
785 * v: output buffer array
791 static cptr process_pref_file_expr(char **sp, char *fp)
808 while (isspace(*s)) s++;
826 t = process_pref_file_expr(&s, &f);
835 else if (streq(t, "IOR"))
838 while (*s && (f != b2))
840 t = process_pref_file_expr(&s, &f);
841 if (*t && !streq(t, "0")) v = "1";
846 else if (streq(t, "AND"))
849 while (*s && (f != b2))
851 t = process_pref_file_expr(&s, &f);
852 if (*t && streq(t, "0")) v = "0";
857 else if (streq(t, "NOT"))
860 while (*s && (f != b2))
862 t = process_pref_file_expr(&s, &f);
863 if (*t && streq(t, "1")) v = "0";
868 else if (streq(t, "EQU"))
873 t = process_pref_file_expr(&s, &f);
875 while (*s && (f != b2))
878 t = process_pref_file_expr(&s, &f);
879 if (*t && !streq(p, t)) v = "0";
884 else if (streq(t, "LEQ"))
889 t = process_pref_file_expr(&s, &f);
891 while (*s && (f != b2))
894 t = process_pref_file_expr(&s, &f);
895 if (*t && (strcmp(p, t) > 0)) v = "0";
900 else if (streq(t, "GEQ"))
905 t = process_pref_file_expr(&s, &f);
907 while (*s && (f != b2))
910 t = process_pref_file_expr(&s, &f);
911 if (*t && (strcmp(p, t) < 0)) v = "0";
918 while (*s && (f != b2))
920 t = process_pref_file_expr(&s, &f);
925 if (f != b2) v = "?x?x?";
927 /* Extract final and Terminate */
928 if ((f = *s) != '\0') *s++ = '\0';
934 /* Accept all printables except spaces and brackets */
935 while (isprint(*s) && !strchr(" []", *s)) ++s;
937 /* Extract final and Terminate */
938 if ((f = *s) != '\0') *s++ = '\0';
944 if (streq(b+1, "SYS"))
949 else if (streq(b+1, "KEYBOARD"))
951 v = ANGBAND_KEYBOARD;
955 else if (streq(b+1, "GRAF"))
960 /* Monochrome mode */
961 else if (streq(b+1, "MONOCHROME"))
970 else if (streq(b+1, "RACE"))
980 else if (streq(b+1, "CLASS"))
990 else if (streq(b+1, "PLAYER"))
996 else if (streq(b+1, "REALM1"))
999 v = E_realm_names[p_ptr->realm1];
1001 v = realm_names[p_ptr->realm1];
1006 else if (streq(b+1, "REALM2"))
1009 v = E_realm_names[p_ptr->realm2];
1011 v = realm_names[p_ptr->realm2];
1016 else if (streq(b+1, "LEVEL"))
1018 sprintf(tmp, "%02d", p_ptr->lev);
1043 * Process line for auto picker/destroyer.
1045 static errr process_pickpref_file_line(char *buf)
1047 autopick_type entry;
1050 if (max_autopick == MAX_AUTOPICK)
1053 /* Nuke illegal char */
1054 for(i = 0; buf[i]; i++)
1057 if (iskanji(buf[i]))
1063 if (isspace(buf[i]) && buf[i] != ' ')
1068 if (!autopick_new_entry(&entry, buf)) return 0;
1070 /* Already has the same entry? */
1071 for(i = 0; i < max_autopick; i++)
1072 if(!strcmp(entry.name, autopick_list[i].name)
1073 && entry.flag[0] == autopick_list[i].flag[0]
1074 && entry.flag[1] == autopick_list[i].flag[1]) return 0;
1076 autopick_list[max_autopick++] = entry;
1083 * Open the "user pref file" and parse it.
1085 static errr process_pref_file_aux(cptr name, bool read_pickpref)
1097 bool bypass = FALSE;
1101 fp = my_fopen(name, "r");
1104 if (!fp) return (-1);
1106 /* Process the file */
1107 while (0 == my_fgets(fp, buf, 1024))
1112 /* Skip "empty" lines */
1113 if (!buf[0]) continue;
1115 /* Skip "blank" lines */
1117 if (!iskanji(buf[0]))
1119 if (isspace(buf[0])) continue;
1122 if (buf[0] == '#') continue;
1129 /* Process "?:<expr>" */
1130 if ((buf[0] == '?') && (buf[1] == ':'))
1139 /* Parse the expr */
1140 v = process_pref_file_expr(&s, &f);
1143 bypass = (streq(v, "0") ? TRUE : FALSE);
1149 /* Apply conditionals */
1150 if (bypass) continue;
1153 /* Process "%:<file>" */
1156 /* Process that file if allowed */
1158 (void)process_pickpref_file(buf + 2);
1160 (void)process_pref_file(buf + 2);
1167 /* Process the line */
1168 err = process_pref_file_command(buf);
1170 /* This is not original pref line... */
1175 err = process_pickpref_file_line(buf);
1183 /* Print error message */
1184 /* ToDo: Add better error messages */
1186 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1187 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1189 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1190 msg_format("Parsing '%s'", old);
1195 /* Close the file */
1205 * Process the "user pref file" with the given name
1207 * See the functions above for a list of legal "commands".
1209 * We also accept the special "?" and "%" directives, which
1210 * allow conditional evaluation and filename inclusion.
1212 errr process_pref_file(cptr name)
1218 /* Build the filename */
1219 path_build(buf, 1024, ANGBAND_DIR_PREF, name);
1221 /* Process the system pref file */
1222 err1 = process_pref_file_aux(buf, FALSE);
1224 /* Stop at parser errors, but not at non-existing file */
1225 if (err1 > 0) return err1;
1231 /* Build the filename */
1232 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1234 /* Process the user pref file */
1235 err2 = process_pref_file_aux(buf, FALSE);
1241 /* User file does not exist, but read system pref file */
1242 if (err2 < 0 && !err1)
1245 /* Result of user file processing */
1254 * Operating hours for ANGBAND (defaults to non-work hours)
1256 static char days[7][29] =
1258 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1259 "MON:XXXXXXXX.........XXXXXXX",
1260 "TUE:XXXXXXXX.........XXXXXXX",
1261 "WED:XXXXXXXX.........XXXXXXX",
1262 "THU:XXXXXXXX.........XXXXXXX",
1263 "FRI:XXXXXXXX.........XXXXXXX",
1264 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1268 * Restict usage (defaults to no restrictions)
1270 static bool check_time_flag = FALSE;
1278 errr check_time(void)
1286 /* No restrictions */
1287 if (!check_time_flag) return (0);
1289 /* Check for time violation */
1290 c = time((time_t *)0);
1294 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1305 * Initialize CHECK_TIME
1307 errr check_time_init(void)
1317 /* Build the filename */
1318 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1321 fp = my_fopen(buf, "r");
1323 /* No file, no restrictions */
1324 if (!fp) return (0);
1326 /* Assume restrictions */
1327 check_time_flag = TRUE;
1329 /* Parse the file */
1330 while (0 == my_fgets(fp, buf, 80))
1332 /* Skip comments and blank lines */
1333 if (!buf[0] || (buf[0] == '#')) continue;
1335 /* Chop the buffer */
1338 /* Extract the info */
1339 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1340 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1341 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1342 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1343 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1344 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1345 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1361 #ifndef MAXHOSTNAMELEN
1362 # define MAXHOSTNAMELEN 64
1365 typedef struct statstime statstime;
1371 unsigned int v_pgpgin;
1372 unsigned int v_pgpgout;
1373 unsigned int v_pswpin;
1374 unsigned int v_pswpout;
1375 unsigned int v_intr;
1381 unsigned int v_swtch;
1383 struct timeval boottime;
1384 struct timeval curtime;
1388 * Maximal load (if any).
1390 static int check_load_value = 0;
1398 errr check_load(void)
1403 struct statstime st;
1405 /* Success if not checking */
1406 if (!check_load_value) return (0);
1408 /* Check the load */
1409 if (0 == rstat("localhost", &st))
1411 long val1 = (long)(st.avenrun[2]);
1412 long val2 = (long)(check_load_value) * FSCALE;
1414 /* Check for violation */
1415 if (val1 >= val2) return (1);
1426 * Initialize CHECK_LOAD
1428 errr check_load_init(void)
1437 char temphost[MAXHOSTNAMELEN+1];
1438 char thishost[MAXHOSTNAMELEN+1];
1441 /* Build the filename */
1442 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1444 /* Open the "load" file */
1445 fp = my_fopen(buf, "r");
1447 /* No file, no restrictions */
1448 if (!fp) return (0);
1451 check_load_value = 100;
1453 /* Get the host name */
1454 (void)gethostname(thishost, (sizeof thishost) - 1);
1457 while (0 == my_fgets(fp, buf, 1024))
1461 /* Skip comments and blank lines */
1462 if (!buf[0] || (buf[0] == '#')) continue;
1464 /* Parse, or ignore */
1465 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1467 /* Skip other hosts */
1468 if (!streq(temphost, thishost) &&
1469 !streq(temphost, "localhost")) continue;
1471 /* Use that value */
1472 check_load_value = value;
1478 /* Close the file */
1488 #define ENTRY_BARE_HAND 0
1489 #define ENTRY_TWO_HANDS 1
1490 #define ENTRY_RIGHT_HAND1 2
1491 #define ENTRY_LEFT_HAND1 3
1492 #define ENTRY_LEFT_HAND2 4
1493 #define ENTRY_RIGHT_HAND2 5
1494 #define ENTRY_POSTURE 6
1495 #define ENTRY_SHOOT_HIT_DAM 7
1496 #define ENTRY_SHOOT_POWER 8
1497 #define ENTRY_SPEED 9
1498 #define ENTRY_BASE_AC 10
1499 #define ENTRY_LEVEL 11
1500 #define ENTRY_CUR_EXP 12
1501 #define ENTRY_MAX_EXP 13
1502 #define ENTRY_EXP_TO_ADV 14
1503 #define ENTRY_GOLD 15
1504 #define ENTRY_DAY 16
1507 #define ENTRY_PLAY_TIME 19
1508 #define ENTRY_SKILL_FIGHT 20
1509 #define ENTRY_SKILL_SHOOT 21
1510 #define ENTRY_SKILL_SAVING 22
1511 #define ENTRY_SKILL_STEALTH 23
1512 #define ENTRY_SKILL_PERCEP 24
1513 #define ENTRY_SKILL_SEARCH 25
1514 #define ENTRY_SKILL_DISARM 26
1515 #define ENTRY_SKILL_DEVICE 27
1516 #define ENTRY_BLOWS 28
1517 #define ENTRY_SHOTS 29
1518 #define ENTRY_AVG_DMG 30
1519 #define ENTRY_INFRA 31
1521 #define ENTRY_NAME 32
1522 #define ENTRY_SEX 33
1523 #define ENTRY_RACE 34
1524 #define ENTRY_CLASS 35
1525 #define ENTRY_REALM 36
1526 #define ENTRY_PATRON 37
1527 #define ENTRY_AGE 38
1528 #define ENTRY_HEIGHT 39
1529 #define ENTRY_WEIGHT 40
1530 #define ENTRY_SOCIAL 41
1531 #define ENTRY_ALIGN 42
1540 } disp_player_line[]
1543 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1544 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1545 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1546 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1547 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1548 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1550 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1551 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1552 {01, 20, 25, "²Ã®"},
1553 { 1, 19, 25, "£Á£Ã"},
1554 {29, 13, 21, "¥ì¥Ù¥ë"},
1555 {29, 14, 21, "·Ð¸³ÃÍ"},
1556 {29, 15, 21, "ºÇÂç·Ð¸³"},
1557 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1558 {29, 17, 21, "½ê»ý¶â"},
1559 {29, 19, 21, "ÆüÉÕ"},
1560 {29, 10, 21, "£È£Ð"},
1561 {29, 11, 21, "£Í£Ð"},
1562 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1563 {54, 10, -1, "ÂǷ⹶·â :"},
1564 {54, 11, -1, "¼Í·â¹¶·â :"},
1565 {54, 12, -1, "ËâË¡Ëɸæ :"},
1566 {54, 13, -1, "±£Ì©¹ÔÆ° :"},
1567 {54, 15, -1, "ÃγР:"},
1568 {54, 16, -1, "õº÷ :"},
1569 {54, 17, -1, "²ò½ü :"},
1570 {54, 18, -1, "ËâË¡Æ»¶ñ :"},
1571 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1572 {01, 17, 25, "¼Í·â²ó¿ô"},
1573 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1574 {54, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1575 {26, 1, -1, "̾Á° : "},
1576 { 1, 3, -1, "ÀÊÌ : "},
1577 { 1, 4, -1, "¼ï² : "},
1578 { 1, 5, -1, "¿¦¶È : "},
1579 { 1, 6, -1, "ËâË¡ : "},
1580 { 1, 7, -1, "¼é¸îËâ¿À : "},
1581 {29, 3, 21, "ǯÎð"},
1582 {29, 4, 21, "¿ÈĹ"},
1583 {29, 5, 21, "ÂνÅ"},
1584 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1585 {29, 7, 21, "°À"},
1589 { 1, 10, 25, "Bare hand"},
1590 { 1, 10, 25, "Two hands"},
1591 { 1, 10, 25, "Right hand"},
1592 { 1, 10, 25, "Left hand"},
1593 { 1, 11, 25, "Left hand"},
1594 { 1, 11, 25, "Right hand"},
1595 { 1, 11, 25, "Posture"},
1596 { 1, 15, 25, "Shooting"},
1597 { 1, 16, 25, "Multiplier"},
1598 {01, 20, 25, "Speed"},
1600 {29, 13, 21, "Level"},
1601 {29, 14, 21, "Experience"},
1602 {29, 15, 21, "Max Exp"},
1603 {29, 16, 21, "Exp to Adv"},
1604 {29, 17, 21, "Gold"},
1605 {29, 19, 21, "Time"},
1606 {29, 10, 21, "Hit point"},
1607 {29, 11, 21, "SP (Mana)"},
1608 {29, 20, 21, "Play time"},
1609 {54, 10, -1, "Fighting : "},
1610 {54, 11, -1, "Bows/Throw : "},
1611 {54, 12, -1, "Saving Throw: "},
1612 {54, 13, -1, "Stealth : "},
1613 {54, 15, -1, "Perception : "},
1614 {54, 16, -1, "Searching : "},
1615 {54, 17, -1, "Disarming : "},
1616 {54, 18, -1, "Magic Device: "},
1617 {01, 12, 25, "Blows/Round"},
1618 {01, 17, 25, "Shots/Round"},
1619 {01, 13, 25, "AverageDmg/Rnd"},
1620 {54, 20, -1, "Infra-Vision: "},
1621 {26, 1, -1, "Name : "},
1622 { 1, 3, -1, "Sex : "},
1623 { 1, 4, -1, "Race : "},
1624 { 1, 5, -1, "Class : "},
1625 { 1, 6, -1, "Magic : "},
1626 { 1, 7, -1, "Patron : "},
1628 {29, 4, 21, "Height"},
1629 {29, 5, 21, "Weight"},
1630 {29, 6, 21, "Social Class"},
1631 {29, 7, 21, "Align"},
1635 static void display_player_one_line(int entry, cptr val, byte attr)
1639 int row = disp_player_line[entry].row;
1640 int col = disp_player_line[entry].col;
1641 int len = disp_player_line[entry].len;
1642 cptr head = disp_player_line[entry].header;
1644 int head_len = strlen(head);
1646 Term_putstr(col, row, -1, TERM_WHITE, head);
1653 int val_len = len - head_len;
1654 sprintf(buf, "%*.*s", val_len, val_len, val);
1655 Term_putstr(col + head_len, row, -1, attr, buf);
1659 Term_putstr(col + head_len, row, -1, attr, val);
1667 * Prints the following information on the screen.
1669 static void display_player_middle(void)
1672 int show_tohit, show_todam;
1678 show_tohit = p_ptr->dis_to_h[0];
1679 show_todam = p_ptr->dis_to_d[0];
1681 o_ptr = &inventory[INVEN_RARM];
1683 /* Hack -- add in weapon info if known */
1684 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1685 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1688 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1690 /* Dump the bonuses to hit/dam */
1691 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1692 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1693 else if(p_ptr->ryoute)
1694 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1695 else if (left_hander)
1696 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1698 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1703 show_tohit = p_ptr->dis_to_h[1];
1704 show_todam = p_ptr->dis_to_d[1];
1706 o_ptr = &inventory[INVEN_LARM];
1708 /* Hack -- add in weapon info if known */
1709 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1710 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1713 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1715 /* Dump the bonuses to hit/dam */
1717 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1719 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1721 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1724 if (p_ptr->special_defense & KAMAE_MASK)
1726 for (i = 0; i < MAX_KAMAE; i++)
1728 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1732 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1734 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1739 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1741 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1746 o_ptr = &inventory[INVEN_BOW];
1749 show_tohit = p_ptr->dis_to_h_b;
1752 /* Apply weapon bonuses */
1753 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1754 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1756 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1757 show_tohit += (weapon_exp[0][o_ptr->sval])/400;
1759 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1762 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1764 if (inventory[INVEN_BOW].k_idx)
1766 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1768 /* Get extra "power" from "extra might" */
1769 if (p_ptr->xtra_might) tmul++;
1771 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1775 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1777 /* Dump the armor class */
1778 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1782 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1787 i = p_ptr->pspeed-110;
1789 /* Hack -- Visually "undo" the Search Mode Slowdown */
1790 if (p_ptr->action == ACTION_SEARCH) i += 10;
1795 attr = TERM_L_GREEN;
1809 attr = TERM_L_UMBER;
1816 if (is_fast) tmp_speed += 10;
1817 if (p_ptr->slow) tmp_speed -= 10;
1818 if (p_ptr->lightspeed) tmp_speed = 99;
1822 if (m_list[p_ptr->riding].fast) tmp_speed += 10;
1823 if (m_list[p_ptr->riding].slow) tmp_speed -= 10;
1829 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1832 sprintf(buf, "¾èÇÏÃæ (%+d%+d)", i-tmp_speed, tmp_speed);
1834 sprintf(buf, "Riding (%+d%+d)", i-tmp_speed, tmp_speed);
1845 sprintf(buf, "(%+d)", i);
1848 sprintf(buf, "¾èÇÏÃæ (%+d)", i);
1850 sprintf(buf, "Riding (%+d)", i);
1854 display_player_one_line(ENTRY_SPEED, buf, attr);
1857 /* Dump character level */
1858 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1860 /* Dump experience */
1861 if (p_ptr->prace == RACE_ANDROID)
1862 display_player_one_line(ENTRY_CUR_EXP, "*****", TERM_L_GREEN);
1863 else if (p_ptr->exp >= p_ptr->max_exp)
1864 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_L_GREEN);
1866 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_YELLOW);
1868 /* Dump max experience */
1869 if (p_ptr->prace == RACE_ANDROID)
1870 display_player_one_line(ENTRY_MAX_EXP, "*****", TERM_L_GREEN);
1872 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1874 /* Dump exp to advance */
1875 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1876 display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
1878 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1881 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1886 extract_day_hour_min(&day, &hour, &min);
1896 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1898 /* Dump hit point */
1899 if (p_ptr->chp >= p_ptr->mhp)
1900 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1901 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1902 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1904 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1906 /* Dump mana power */
1907 if (p_ptr->csp >= p_ptr->msp)
1908 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1909 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1910 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1912 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1914 /* Dump play time */
1915 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1920 * Hack -- pass color info around this file
1922 static byte likert_color = TERM_WHITE;
1926 * Returns a "rating" of x depending on y
1928 static cptr likert(int x, int y)
1930 static char dummy[20] = "";
1935 /* Negative value */
1938 likert_color = TERM_L_DARK;
1942 return ("Very Bad");
1947 /* Analyze the value */
1953 likert_color = TERM_RED;
1963 likert_color = TERM_L_RED;
1974 likert_color = TERM_ORANGE;
1984 likert_color = TERM_YELLOW;
1994 likert_color = TERM_YELLOW;
1996 return ("ÂçÊÑÎɤ¤");
1998 return ("Very Good");
2005 likert_color = TERM_L_GREEN;
2009 return ("Excellent");
2019 likert_color = TERM_GREEN;
2032 likert_color = TERM_BLUE;
2034 return ("¥«¥ª¥¹¥é¥ó¥¯");
2036 return ("Chaos Rank");
2042 likert_color = TERM_VIOLET;
2044 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2046 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2056 * Prints ratings on certain abilities
2058 * This code is "imitated" elsewhere to "dump" a character sheet.
2060 static void display_player_various(void)
2062 int tmp, damage[2], blows1, blows2, i, basedam;
2063 int xthn, xthb, xfos, xsrh;
2064 int xdis, xdev, xsav, xstl;
2068 int shots, shot_frac;
2072 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2073 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2074 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2075 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2076 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2078 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2080 /* Shooting Skill (with current bow and normal missile) */
2081 o_ptr = &inventory[INVEN_BOW];
2082 tmp = p_ptr->to_h_b + o_ptr->to_h;
2083 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2085 /* If the player is wielding one? */
2088 s16b energy_fire = bow_energy(o_ptr->sval);
2090 /* Calculate shots per round */
2091 shots = p_ptr->num_fire * 100;
2092 shot_frac = (shots * 100 / energy_fire) % 100;
2093 shots = shots / energy_fire;
2094 if (o_ptr->name1 == ART_CRIMSON)
2098 if (p_ptr->pclass == CLASS_ARCHER)
2100 /* Extra shot at level 10 */
2101 if (p_ptr->lev >= 10) shots++;
2103 /* Extra shot at level 30 */
2104 if (p_ptr->lev >= 30) shots++;
2106 /* Extra shot at level 45 */
2107 if (p_ptr->lev >= 45) shots++;
2117 for(i = 0; i< 2; i++)
2119 damage[i] = p_ptr->dis_to_d[i]*100;
2120 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2122 int level = p_ptr->lev;
2128 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2129 if (p_ptr->special_defense & KAMAE_BYAKKO)
2130 basedam = monk_ave_damage[level][1];
2131 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2132 basedam = monk_ave_damage[level][2];
2134 basedam = monk_ave_damage[level][0];
2138 /* Average damage per round */
2139 o_ptr = &inventory[INVEN_RARM+i];
2140 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2141 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2142 object_flags(o_ptr, &f1, &f2, &f3);
2143 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2149 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2151 /* vorpal flag only */
2155 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)))
2156 basedam = basedam * 7 / 2;
2157 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2158 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2160 damage[i] += basedam;
2161 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2162 if (damage[i] < 0) damage[i] = 0;
2164 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2165 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2167 /* Basic abilities */
2169 xdis = p_ptr->skill_dis;
2170 xdev = p_ptr->skill_dev;
2171 xsav = p_ptr->skill_sav;
2172 xstl = p_ptr->skill_stl;
2173 xsrh = p_ptr->skill_srh;
2174 xfos = p_ptr->skill_fos;
2177 desc = likert(xthn, 12);
2178 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2180 desc = likert(xthb, 12);
2181 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2183 desc = likert(xsav, 7);
2184 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2186 desc = likert(xstl, 1);
2187 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2189 desc = likert(xfos, 6);
2190 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2192 desc = likert(xsrh, 6);
2193 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2195 desc = likert(xdis, 8);
2196 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2198 desc = likert(xdev, 6);
2199 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2202 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2204 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2206 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2209 if ((damage[0]+damage[1]) == 0)
2212 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2214 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2216 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2222 * Obtain the "flags" for the player as if he was an item
2224 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2227 (*f1) = (*f2) = (*f3) = 0L;
2230 switch (p_ptr->pclass)
2233 if (p_ptr->lev > 44)
2234 (*f3) |= (TR3_REGEN);
2236 if (p_ptr->lev > 29)
2237 (*f2) |= (TR2_RES_FEAR);
2240 if (p_ptr->lev > 39)
2241 (*f2) |= (TR2_RES_FEAR);
2243 case CLASS_CHAOS_WARRIOR:
2244 if (p_ptr->lev > 29)
2245 (*f2) |= (TR2_RES_CHAOS);
2246 if (p_ptr->lev > 39)
2247 (*f2) |= (TR2_RES_FEAR);
2250 case CLASS_FORCETRAINER:
2251 if ((p_ptr->lev > 9) && !heavy_armor())
2253 if ((p_ptr->lev>24) && !heavy_armor())
2254 (*f2) |= (TR2_FREE_ACT);
2261 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2264 (*f2) |= (TR2_FREE_ACT);
2266 (*f3) |= TR3_SLOW_DIGEST;
2267 (*f2) |= TR2_RES_FEAR;
2268 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2269 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2270 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2272 case CLASS_MINDCRAFTER:
2274 (*f2) |= (TR2_RES_FEAR);
2275 if (p_ptr->lev > 19)
2276 (*f2) |= (TR2_SUST_WIS);
2277 if (p_ptr->lev > 29)
2278 (*f2) |= (TR2_RES_CONF);
2279 if (p_ptr->lev > 39)
2280 (*f3) |= (TR3_TELEPATHY);
2283 (*f2) |= (TR2_RES_SOUND);
2285 case CLASS_BERSERKER:
2286 (*f2) |= (TR2_SUST_STR);
2287 (*f2) |= (TR2_SUST_DEX);
2288 (*f2) |= (TR2_SUST_CON);
2289 (*f3) |= (TR3_REGEN);
2290 (*f2) |= (TR2_FREE_ACT);
2291 (*f1) |= (TR1_SPEED);
2292 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2294 case CLASS_MIRROR_MASTER:
2295 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2298 break; /* Do nothing */
2302 if (p_ptr->mimic_form)
2304 switch(p_ptr->mimic_form)
2307 (*f2) |= (TR2_HOLD_LIFE);
2308 (*f2) |= (TR2_RES_CHAOS);
2309 (*f2) |= (TR2_RES_NETHER);
2310 (*f2) |= (TR2_RES_FIRE);
2311 (*f3) |= (TR3_SEE_INVIS);
2312 (*f1) |= (TR1_SPEED);
2314 case MIMIC_DEMON_LORD:
2315 (*f2) |= (TR2_HOLD_LIFE);
2316 (*f2) |= (TR2_RES_CHAOS);
2317 (*f2) |= (TR2_RES_NETHER);
2318 (*f2) |= (TR2_RES_FIRE);
2319 (*f2) |= (TR2_RES_COLD);
2320 (*f2) |= (TR2_RES_ELEC);
2321 (*f2) |= (TR2_RES_ACID);
2322 (*f2) |= (TR2_RES_POIS);
2323 (*f2) |= (TR2_RES_CONF);
2324 (*f2) |= (TR2_RES_DISEN);
2325 (*f2) |= (TR2_RES_NEXUS);
2326 (*f2) |= (TR2_RES_FEAR);
2327 (*f2) |= (TR2_IM_FIRE);
2328 (*f3) |= (TR3_SH_FIRE);
2329 (*f3) |= (TR3_SEE_INVIS);
2330 (*f3) |= (TR3_TELEPATHY);
2331 (*f3) |= (TR3_FEATHER);
2332 (*f1) |= (TR1_SPEED);
2335 (*f2) |= (TR2_HOLD_LIFE);
2336 (*f2) |= (TR2_RES_DARK);
2337 (*f2) |= (TR2_RES_NETHER);
2338 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2339 (*f2) |= (TR2_RES_POIS);
2340 (*f2) |= (TR2_RES_COLD);
2341 (*f3) |= (TR3_SEE_INVIS);
2342 (*f1) |= (TR1_SPEED);
2348 switch (p_ptr->prace)
2351 (*f2) |= (TR2_RES_LITE);
2354 (*f2) |= (TR2_SUST_DEX);
2357 (*f2) |= (TR2_FREE_ACT);
2360 (*f2) |= (TR2_RES_BLIND);
2363 (*f2) |= (TR2_RES_DARK);
2365 case RACE_HALF_TROLL:
2366 (*f2) |= (TR2_SUST_STR);
2367 if (p_ptr->lev > 14)
2369 (*f3) |= (TR3_REGEN);
2370 if (p_ptr->pclass == CLASS_WARRIOR)
2372 (*f3) |= (TR3_SLOW_DIGEST);
2374 * Let's not make Regeneration a disadvantage
2375 * for the poor warriors who can never learn
2376 * a spell that satisfies hunger (actually
2377 * neither can rogues, but half-trolls are not
2378 * supposed to play rogues)
2384 (*f2) |= (TR2_SUST_CON);
2385 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2388 (*f2) |= (TR2_RES_LITE);
2389 (*f3) |= (TR3_SEE_INVIS);
2391 case RACE_BARBARIAN:
2392 (*f2) |= (TR2_RES_FEAR);
2394 case RACE_HALF_OGRE:
2395 (*f2) |= (TR2_SUST_STR);
2396 (*f2) |= (TR2_RES_DARK);
2398 case RACE_HALF_GIANT:
2399 (*f2) |= (TR2_RES_SHARDS);
2400 (*f2) |= (TR2_SUST_STR);
2402 case RACE_HALF_TITAN:
2403 (*f2) |= (TR2_RES_CHAOS);
2406 (*f2) |= (TR2_RES_SOUND);
2409 (*f2) |= (TR2_RES_ACID);
2410 if (p_ptr->lev > 19)
2411 (*f2) |= (TR2_IM_ACID);
2414 (*f2) |= (TR2_RES_CONF);
2415 (*f2) |= (TR2_RES_ACID);
2420 (*f2) |= (TR2_RES_POIS);
2423 (*f2) |= (TR2_RES_DISEN);
2424 (*f2) |= (TR2_RES_DARK);
2427 (*f2) |= (TR2_RES_DARK);
2428 if (p_ptr->lev > 19)
2429 (*f3) |= (TR3_SEE_INVIS);
2431 case RACE_DRACONIAN:
2432 (*f3) |= TR3_FEATHER;
2434 (*f2) |= (TR2_RES_FIRE);
2436 (*f2) |= (TR2_RES_COLD);
2437 if (p_ptr->lev > 14)
2438 (*f2) |= (TR2_RES_ACID);
2439 if (p_ptr->lev > 19)
2440 (*f2) |= (TR2_RES_ELEC);
2441 if (p_ptr->lev > 34)
2442 (*f2) |= (TR2_RES_POIS);
2444 case RACE_MIND_FLAYER:
2445 (*f2) |= (TR2_SUST_INT);
2446 (*f2) |= (TR2_SUST_WIS);
2447 if (p_ptr->lev > 14)
2448 (*f3) |= (TR3_SEE_INVIS);
2449 if (p_ptr->lev > 29)
2450 (*f3) |= (TR3_TELEPATHY);
2453 (*f2) |= (TR2_RES_FIRE);
2455 (*f3) |= (TR3_SEE_INVIS);
2458 (*f3) |= (TR3_SEE_INVIS);
2459 (*f2) |= (TR2_FREE_ACT);
2460 (*f2) |= (TR2_RES_POIS);
2461 (*f3) |= (TR3_SLOW_DIGEST);
2462 if (p_ptr->lev > 34)
2463 (*f2) |= (TR2_HOLD_LIFE);
2466 (*f3) |= (TR3_SEE_INVIS);
2467 (*f2) |= (TR2_RES_SHARDS);
2468 (*f2) |= (TR2_HOLD_LIFE);
2469 (*f2) |= (TR2_RES_POIS);
2471 (*f2) |= (TR2_RES_COLD);
2474 (*f3) |= (TR3_SEE_INVIS);
2475 (*f2) |= (TR2_HOLD_LIFE);
2476 (*f2) |= (TR2_RES_NETHER);
2477 (*f2) |= (TR2_RES_POIS);
2478 (*f3) |= (TR3_SLOW_DIGEST);
2480 (*f2) |= (TR2_RES_COLD);
2483 (*f2) |= (TR2_HOLD_LIFE);
2484 (*f2) |= (TR2_RES_DARK);
2485 (*f2) |= (TR2_RES_NETHER);
2486 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2487 (*f2) |= (TR2_RES_POIS);
2488 (*f2) |= (TR2_RES_COLD);
2491 (*f3) |= (TR3_FEATHER);
2492 (*f2) |= (TR2_FREE_ACT);
2493 (*f2) |= (TR2_RES_COLD);
2494 (*f3) |= (TR3_SEE_INVIS);
2495 (*f2) |= (TR2_HOLD_LIFE);
2496 (*f2) |= (TR2_RES_NETHER);
2497 (*f2) |= (TR2_RES_POIS);
2498 (*f3) |= (TR3_SLOW_DIGEST);
2500 if (p_ptr->lev > 34)
2501 (*f3) |= TR3_TELEPATHY;
2504 (*f2) |= (TR2_RES_LITE);
2505 (*f3) |= (TR3_FEATHER);
2507 (*f1) |= (TR1_SPEED);
2510 (*f2) |= (TR2_RES_SOUND);
2511 (*f2) |= (TR2_RES_CONF);
2514 (*f3) |= (TR3_FEATHER);
2515 (*f3) |= (TR3_SEE_INVIS);
2518 (*f2) |= (TR2_RES_FIRE);
2519 (*f2) |= (TR2_RES_NETHER);
2520 (*f2) |= (TR2_HOLD_LIFE);
2522 (*f3) |= (TR3_SEE_INVIS);
2525 (*f2) |= (TR2_SUST_CON);
2528 (*f3) |= (TR3_FEATHER);
2531 (*f2) |= (TR2_RES_CONF);
2534 (*f2) |= (TR2_FREE_ACT);
2535 (*f2) |= (TR2_RES_POIS);
2536 (*f3) |= (TR3_SLOW_DIGEST);
2537 (*f2) |= (TR2_HOLD_LIFE);
2547 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2549 (*f3) &= ~(TR3_REGEN);
2552 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2553 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2554 (p_ptr->muta3 & MUT3_SHORT_LEG))
2559 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2561 (*f3) |= TR3_SH_ELEC;
2564 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2566 (*f3) |= TR3_SH_FIRE;
2570 if (p_ptr->muta3 & MUT3_WINGS)
2572 (*f3) |= TR3_FEATHER;
2575 if (p_ptr->muta3 & MUT3_FEARLESS)
2577 (*f2) |= (TR2_RES_FEAR);
2580 if (p_ptr->muta3 & MUT3_REGEN)
2585 if (p_ptr->muta3 & MUT3_ESP)
2587 (*f3) |= TR3_TELEPATHY;
2590 if (p_ptr->muta3 & MUT3_MOTION)
2592 (*f2) |= TR2_FREE_ACT;
2596 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2597 (*f3) |= TR3_AGGRAVATE;
2598 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2600 (*f2) |= (TR2_RES_BLIND);
2601 (*f2) |= (TR2_RES_CONF);
2602 (*f2) |= (TR2_HOLD_LIFE);
2603 (*f3) |= (TR3_LITE);
2605 (*f1) |= (TR1_SPEED);
2607 if (p_ptr->special_defense & KATA_FUUJIN)
2608 (*f2) |= TR2_REFLECT;
2609 if (p_ptr->special_defense & KAMAE_GENBU)
2610 (*f2) |= TR2_REFLECT;
2611 if (p_ptr->special_defense & KAMAE_SUZAKU)
2612 (*f3) |= TR3_FEATHER;
2613 if (p_ptr->special_defense & KAMAE_SEIRYU)
2615 (*f2) |= (TR2_RES_FIRE);
2616 (*f2) |= (TR2_RES_COLD);
2617 (*f2) |= (TR2_RES_ACID);
2618 (*f2) |= (TR2_RES_ELEC);
2619 (*f2) |= (TR2_RES_POIS);
2620 (*f3) |= (TR3_FEATHER);
2621 (*f3) |= (TR3_SH_FIRE);
2622 (*f3) |= (TR3_SH_ELEC);
2623 (*f3) |= (TR3_SH_COLD);
2625 if (p_ptr->special_defense & KATA_MUSOU)
2627 (*f2) |= TR2_RES_FEAR;
2628 (*f2) |= TR2_RES_LITE;
2629 (*f2) |= TR2_RES_DARK;
2630 (*f2) |= TR2_RES_BLIND;
2631 (*f2) |= TR2_RES_CONF;
2632 (*f2) |= TR2_RES_SOUND;
2633 (*f2) |= TR2_RES_SHARDS;
2634 (*f2) |= TR2_RES_NETHER;
2635 (*f2) |= TR2_RES_NEXUS;
2636 (*f2) |= TR2_RES_CHAOS;
2637 (*f2) |= TR2_RES_DISEN;
2638 (*f2) |= TR2_REFLECT;
2639 (*f2) |= TR2_HOLD_LIFE;
2640 (*f2) |= TR2_FREE_ACT;
2641 (*f3) |= TR3_SH_FIRE;
2642 (*f3) |= TR3_SH_ELEC;
2643 (*f3) |= TR3_SH_COLD;
2644 (*f3) |= TR3_FEATHER;
2646 (*f3) |= TR3_SEE_INVIS;
2647 (*f3) |= TR3_TELEPATHY;
2648 (*f3) |= TR3_SLOW_DIGEST;
2650 (*f2) |= (TR2_SUST_STR);
2651 (*f2) |= (TR2_SUST_INT);
2652 (*f2) |= (TR2_SUST_WIS);
2653 (*f2) |= (TR2_SUST_DEX);
2654 (*f2) |= (TR2_SUST_CON);
2655 (*f2) |= (TR2_SUST_CHR);
2660 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2663 (*f1) = (*f2) = (*f3) = 0L;
2665 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2666 (*f2) |= TR2_RES_FEAR;
2667 if (p_ptr->tim_invis)
2668 (*f3) |= TR3_SEE_INVIS;
2669 if (p_ptr->tim_regen)
2671 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2672 (*f3) |= TR3_TELEPATHY;
2673 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2675 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2677 (*f2) |= (TR2_RES_FIRE);
2678 (*f2) |= (TR2_RES_COLD);
2679 (*f2) |= (TR2_RES_ACID);
2680 (*f2) |= (TR2_RES_ELEC);
2681 (*f2) |= (TR2_RES_POIS);
2685 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2686 (*f2) |= TR2_RES_ACID;
2687 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2688 (*f2) |= TR2_RES_ELEC;
2689 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2690 (*f2) |= TR2_RES_FIRE;
2691 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2692 (*f2) |= TR2_RES_COLD;
2696 if (p_ptr->oppose_acid)
2697 (*f2) |= TR2_RES_ACID;
2698 if (p_ptr->oppose_elec)
2699 (*f2) |= TR2_RES_ELEC;
2700 if (p_ptr->oppose_fire)
2701 (*f2) |= TR2_RES_FIRE;
2702 if (p_ptr->oppose_cold)
2703 (*f2) |= TR2_RES_COLD;
2705 if (p_ptr->oppose_pois)
2706 (*f2) |= TR2_RES_POIS;
2707 if (p_ptr->special_attack & ATTACK_ACID)
2708 (*f1) |= TR1_BRAND_ACID;
2709 if (p_ptr->special_attack & ATTACK_ELEC)
2710 (*f1) |= TR1_BRAND_ELEC;
2711 if (p_ptr->special_attack & ATTACK_FIRE)
2712 (*f1) |= TR1_BRAND_FIRE;
2713 if (p_ptr->special_attack & ATTACK_COLD)
2714 (*f1) |= TR1_BRAND_COLD;
2715 if (p_ptr->special_attack & ATTACK_POIS)
2716 (*f1) |= TR1_BRAND_POIS;
2717 if (p_ptr->special_defense & DEFENSE_ACID)
2718 (*f2) |= TR2_IM_ACID;
2719 if (p_ptr->special_defense & DEFENSE_ELEC)
2720 (*f2) |= TR2_IM_ELEC;
2721 if (p_ptr->special_defense & DEFENSE_FIRE)
2722 (*f2) |= TR2_IM_FIRE;
2723 if (p_ptr->special_defense & DEFENSE_COLD)
2724 (*f2) |= TR2_IM_COLD;
2725 if (p_ptr->wraith_form)
2726 (*f2) |= TR2_REFLECT;
2728 if (p_ptr->tim_reflect){
2729 (*f2) |= TR2_REFLECT;
2732 if (p_ptr->magicdef)
2734 (*f2) |= TR2_RES_BLIND;
2735 (*f2) |= TR2_RES_CONF;
2736 (*f2) |= TR2_REFLECT;
2737 (*f2) |= TR2_FREE_ACT;
2738 (*f3) |= TR3_FEATHER;
2740 if (p_ptr->tim_res_nether)
2742 (*f2) |= TR2_RES_NETHER;
2744 if (p_ptr->tim_sh_fire)
2746 (*f3) |= TR3_SH_FIRE;
2750 (*f2) |= TR2_RES_FEAR;
2751 (*f2) |= TR2_RES_LITE;
2752 (*f2) |= TR2_RES_DARK;
2753 (*f2) |= TR2_RES_BLIND;
2754 (*f2) |= TR2_RES_CONF;
2755 (*f2) |= TR2_RES_SOUND;
2756 (*f2) |= TR2_RES_SHARDS;
2757 (*f2) |= TR2_RES_NETHER;
2758 (*f2) |= TR2_RES_NEXUS;
2759 (*f2) |= TR2_RES_CHAOS;
2760 (*f2) |= TR2_RES_DISEN;
2761 (*f2) |= TR2_REFLECT;
2762 (*f2) |= TR2_HOLD_LIFE;
2763 (*f2) |= TR2_FREE_ACT;
2764 (*f3) |= TR3_SH_FIRE;
2765 (*f3) |= TR3_SH_ELEC;
2766 (*f3) |= TR3_SH_COLD;
2767 (*f3) |= TR3_FEATHER;
2769 (*f3) |= TR3_SEE_INVIS;
2770 (*f3) |= TR3_TELEPATHY;
2771 (*f3) |= TR3_SLOW_DIGEST;
2773 (*f2) |= (TR2_SUST_STR);
2774 (*f2) |= (TR2_SUST_INT);
2775 (*f2) |= (TR2_SUST_WIS);
2776 (*f2) |= (TR2_SUST_DEX);
2777 (*f2) |= (TR2_SUST_CON);
2778 (*f2) |= (TR2_SUST_CHR);
2786 static void display_player_equippy(int y, int x)
2796 /* Dump equippy chars */
2797 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2800 o_ptr = &inventory[i];
2802 a = object_attr(o_ptr);
2803 c = object_char(o_ptr);
2805 /* Clear the part of the screen */
2806 if (!equippy_chars || !o_ptr->k_idx)
2813 Term_putch(x + i - INVEN_RARM, y, a, c);
2818 void print_equippy(void)
2820 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2827 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2832 (*f1) = (*f2) = (*f3) = 0L;
2834 /* Check equipment */
2835 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2837 u32b o_f1, o_f2, o_f3;
2842 o_ptr = &inventory[i];
2844 if (!o_ptr->k_idx) continue;
2847 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2849 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2850 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2851 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2852 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2856 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2859 (*f1) = (*f2) = (*f3) = 0L;
2861 if (prace_is_(RACE_SPECTRE))
2862 (*f2) |= TR2_RES_NETHER;
2863 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2864 (*f2) |= TR2_RES_DARK;
2865 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2866 (*f2) |= TR2_RES_FIRE;
2867 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2868 (*f2) |= TR2_RES_ACID;
2871 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2874 (*f1) = (*f2) = (*f3) = 0L;
2876 if (p_ptr->special_defense & DEFENSE_ACID)
2877 (*f2) |= TR2_RES_ACID;
2878 if (p_ptr->special_defense & DEFENSE_ELEC)
2879 (*f2) |= TR2_RES_ELEC;
2880 if (p_ptr->special_defense & DEFENSE_FIRE)
2881 (*f2) |= TR2_RES_FIRE;
2882 if (p_ptr->special_defense & DEFENSE_COLD)
2883 (*f2) |= TR2_RES_COLD;
2884 if (p_ptr->wraith_form)
2885 (*f2) |= TR2_RES_DARK;
2888 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2891 (*f1) = (*f2) = (*f3) = 0L;
2893 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2895 (*f2) |= TR2_RES_ACID;
2896 (*f2) |= TR2_RES_ELEC;
2897 (*f2) |= TR2_RES_FIRE;
2898 (*f2) |= TR2_RES_COLD;
2900 if (prace_is_(RACE_ANDROID))
2901 (*f2) |= TR2_RES_ELEC;
2902 if (prace_is_(RACE_ENT))
2903 (*f2) |= TR2_RES_FIRE;
2904 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2905 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2906 (*f2) |= TR2_RES_LITE;
2910 * Helper function, see below
2912 static void display_player_flag_aux(int row, int col, char *header,
2913 int n, u32b flag1, u32b flag2,
2914 u32b im_f[], u32b vul_f)
2920 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2924 c_put_str(TERM_WHITE, header, row, col);
2927 col += strlen(header) + 1;
2929 /* Check equipment */
2930 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2933 f[0] = f[1] = f[2] = f[3] = 0L;
2936 o_ptr = &inventory[i];
2939 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2940 f[3] = o_ptr->curse_flags;
2943 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2946 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2947 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
2954 player_flags(&f[0], &f[1], &f[2]);
2958 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2961 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2963 /* Timed player flags */
2964 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
2968 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
2971 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
2972 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
2975 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
2980 * Special display, part 1
2982 static void display_player_flag_info(void)
2987 u32b im_f[3][3], vul_f[3];
2989 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
2990 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
2991 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
2993 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3000 display_player_equippy(row-2, col+8);
3001 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3004 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3005 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3006 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3007 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3008 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3009 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3010 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3011 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3012 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3013 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3015 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3016 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3017 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3018 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3019 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3020 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3021 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3022 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3023 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3024 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3033 display_player_equippy(row-2, col+8);
3035 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3038 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3039 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3040 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3041 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3042 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3043 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3044 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3045 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3046 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3047 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3049 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3050 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3051 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3052 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3053 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3054 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3055 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3056 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3057 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3058 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3067 display_player_equippy(row-2, col+12);
3069 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3072 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3073 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3074 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3075 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3076 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3077 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3078 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3079 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3080 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3081 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 4, (TRC_CURSED | TRC_HEAVY_CURSE), TRC_PERMA_CURSE, im_f[2], vul_f[2]);
3083 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3084 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3085 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3086 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3087 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3088 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3089 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3090 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3091 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3092 display_player_flag_aux(row+9, col, "Cursed :", 4, (TRC_CURSED | TRC_HEAVY_CURSE), TRC_PERMA_CURSE, im_f[2], vul_f[2]);
3099 * Special display, part 2a
3101 static void display_player_misc_info(void)
3106 /* Display basics */
3108 put_str("̾Á° :", 1, 26);
3109 put_str("ÀÊÌ :", 3, 1);
3110 put_str("¼ï² :", 4, 1);
3111 put_str("¿¦¶È :", 5, 1);
3113 put_str("Name :", 1, 26);
3114 put_str("Sex :", 3, 1);
3115 put_str("Race :", 4, 1);
3116 put_str("Class :", 5, 1);
3119 strcpy(tmp,ap_ptr->title);
3126 strcat(tmp,player_name);
3128 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3129 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3130 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3131 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3133 /* Display extras */
3135 put_str("¥ì¥Ù¥ë:", 6, 1);
3136 put_str("£È£Ð :", 7, 1);
3137 put_str("£Í£Ð :", 8, 1);
3139 put_str("Level :", 6, 1);
3140 put_str("Hits :", 7, 1);
3141 put_str("Mana :", 8, 1);
3145 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3146 c_put_str(TERM_L_BLUE, buf, 6, 9);
3147 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3148 c_put_str(TERM_L_BLUE, buf, 7, 9);
3149 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3150 c_put_str(TERM_L_BLUE, buf, 8, 9);
3155 * Special display, part 2b
3157 * How to print out the modifications and sustains.
3158 * Positive mods with no sustain will be light green.
3159 * Positive mods with a sustain will be dark green.
3160 * Sustains (with no modification) will be a dark green 's'.
3161 * Negative mods (from a curse) will be red.
3162 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3163 * No mod, no sustain, will be a slate '.'
3165 static void display_player_stat_info(void)
3187 /* Print out the labels for the columns */
3189 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3190 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3191 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3192 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3193 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+35);
3195 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3196 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3197 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3198 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3199 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3203 /* Display the stats */
3204 for (i = 0; i < 6; i++)
3208 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3209 else r_adj = rp_ptr->r_adj[i];
3211 /* Calculate equipment adjustment */
3214 /* Icky formula to deal with the 18 barrier */
3215 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3216 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3217 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3218 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3219 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3220 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3222 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3223 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3225 if (prace_is_(RACE_ENT))
3231 if (p_ptr->lev > 25) r_adj++;
3232 if (p_ptr->lev > 40) r_adj++;
3233 if (p_ptr->lev > 45) r_adj++;
3236 if (p_ptr->lev > 25) r_adj--;
3237 if (p_ptr->lev > 40) r_adj--;
3238 if (p_ptr->lev > 45) r_adj--;
3244 e_adj -= cp_ptr->c_adj[i];
3245 e_adj -= ap_ptr->a_adj[i];
3247 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3248 /* Reduced name of stat */
3249 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3251 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3254 /* Internal "natural" max value. Maxes at 18/100 */
3255 /* This is useful to see if you are maxed out */
3256 cnv_stat(p_ptr->stat_max[i], buf);
3257 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3260 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3262 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 4);
3265 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3267 /* Race, class, and equipment modifiers */
3268 (void)sprintf(buf, "%3d", r_adj);
3269 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3270 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3271 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3272 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3273 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3274 (void)sprintf(buf, "%3d", (int)e_adj);
3275 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3277 /* Actual maximal modified value */
3278 cnv_stat(p_ptr->stat_top[i], buf);
3279 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3281 /* Only display stat_use if not maximal */
3282 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3284 cnv_stat(p_ptr->stat_use[i], buf);
3285 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3290 col = stat_col + 41;
3292 /* Header and Footer */
3293 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3295 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3297 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3301 /* Process equipment */
3302 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3305 o_ptr = &inventory[i];
3308 k_idx = o_ptr->k_idx;
3310 /* Acquire "known" flags */
3311 object_flags_known(o_ptr, &f1, &f2, &f3);
3313 /* Initialize color based of sign of pval. */
3314 for (stat = 0; stat < 6; stat++)
3327 if (o_ptr->pval > 0)
3333 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3338 /* Dark green for sustained stats */
3343 if (o_ptr->pval < 0)
3349 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3354 else if (f2 & 1 << stat)
3356 /* Dark green "s" */
3361 /* Dump proper character */
3362 Term_putch(col, row + stat+1, a, c);
3370 player_flags(&f1, &f2, &f3);
3373 for (stat = 0; stat < 6; stat++)
3380 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3386 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3387 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3388 if (p_ptr->tsuyoshi) dummy += 4;
3390 else if (stat == A_WIS || stat == A_INT)
3392 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3393 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3395 else if (stat == A_DEX)
3397 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3398 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3399 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3401 else if (stat == A_CON)
3403 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3404 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3405 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3406 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3407 if (p_ptr->tsuyoshi) dummy += 4;
3409 else if (stat == A_CHR)
3411 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3412 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3413 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3414 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3415 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3416 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3432 if (dummy < 10) c = '0' + dummy;
3442 if (dummy > -10) c = '0' - dummy;
3451 /* Dark green "s" */
3458 Term_putch(col, row + stat+1, a, c);
3466 static cptr object_flag_names[96] =
3707 * Summarize resistances
3709 static void display_player_ben(void)
3722 for (i = 0; i < 6; i++) b[i] = 0;
3725 /* Scan equipment */
3726 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3729 o_ptr = &inventory[i];
3731 /* Known object flags */
3732 object_flags_known(o_ptr, &f1, &f2, &f3);
3735 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3737 f3 &= ~(TR3_AGGRAVATE);
3742 b[0] |= (f1 & 0xFFFF);
3744 b[2] |= (f2 & 0xFFFF);
3746 b[4] |= (f3 & 0xFFFF);
3752 player_flags(&f1, &f2, &f3);
3755 b[0] |= (f1 & 0xFFFF);
3757 b[2] |= (f2 & 0xFFFF);
3759 b[4] |= (f3 & 0xFFFF);
3763 tim_player_flags(&f1, &f2, &f3, FALSE);
3766 b[0] |= (f1 & 0xFFFF);
3768 b[2] |= (f2 & 0xFFFF);
3770 b[4] |= (f3 & 0xFFFF);
3772 color[0] = (u16b)(f1 & 0xFFFF);
3773 color[1] = (u16b)(f1 >> 16);
3774 color[2] = (u16b)(f2 & 0xFFFF);
3775 color[3] = (u16b)(f2 >> 16);
3776 color[4] = (u16b)(f3 & 0xFFFF);
3777 color[5] = (u16b)(f3 >> 16);
3780 for (x = 0; x < 6; x++)
3783 for (y = 0; y < 16; y++)
3785 byte a = TERM_SLATE;
3788 cptr name = object_flag_names[16*x+y];
3791 if (!name) continue;
3794 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3797 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3802 if (color[x] & (1<<y))
3815 Term_putch(x * 13 + 11, y + 4, a, c);
3822 * Summarize resistances
3824 static void display_player_ben_one(int mode)
3836 /* Scan equipment */
3837 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3840 n = (i - INVEN_RARM);
3843 o_ptr = &inventory[i];
3845 object_flags_known(o_ptr, &f1, &f2, &f3);
3847 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3849 f3 &= ~(TR3_AGGRAVATE);
3854 b[n][0] = (u16b)(f1 & 0xFFFF);
3855 b[n][1] = (u16b)(f1 >> 16);
3856 b[n][2] = (u16b)(f2 & 0xFFFF);
3857 b[n][3] = (u16b)(f2 >> 16);
3858 b[n][4] = (u16b)(f3 & 0xFFFF);
3859 b[n][5] = (u16b)(f3 >> 16);
3867 player_flags(&f1, &f2, &f3);
3870 b[n][0] = (u16b)(f1 & 0xFFFF);
3871 b[n][1] = (u16b)(f1 >> 16);
3872 b[n][2] = (u16b)(f2 & 0xFFFF);
3873 b[n][3] = (u16b)(f2 >> 16);
3874 b[n][4] = (u16b)(f3 & 0xFFFF);
3875 b[n][5] = (u16b)(f3 >> 16);
3878 tim_player_flags(&f1, &f2, &f3, FALSE);
3881 b[n][0] |= (f1 & 0xFFFF);
3882 b[n][1] |= (f1 >> 16);
3883 b[n][2] |= (f2 & 0xFFFF);
3884 b[n][3] |= (f2 >> 16);
3885 b[n][4] |= (f3 & 0xFFFF);
3886 b[n][5] |= (f3 >> 16);
3887 color[0] = (u16b)(f1 & 0xFFFF);
3888 color[1] = (u16b)(f1 >> 16);
3889 color[2] = (u16b)(f2 & 0xFFFF);
3890 color[3] = (u16b)(f2 >> 16);
3891 color[4] = (u16b)(f3 & 0xFFFF);
3892 color[5] = (u16b)(f3 >> 16);
3896 for (x = 0; x < 3; x++)
3899 display_player_equippy(2, x * 26 + 11);
3902 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3905 for (y = 0; y < 16; y++)
3907 cptr name = object_flag_names[48*mode+16*x+y];
3910 if (!name) continue;
3913 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3916 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3919 for (n = 0; n < 13; n++)
3921 byte a = TERM_SLATE;
3925 if (b[n][3*mode+x] & (1<<y))
3927 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3940 Term_putch(x * 26 + 11 + n, y + 4, a, c);
3948 * Display the character on the screen (various modes)
3950 * The top two and bottom two lines are left blank.
3952 * Mode 0 = standard display with skills
3953 * Mode 1 = standard display with history
3954 * Mode 2 = summary of various things
3955 * Mode 3 = current flags (combined)
3956 * Mode 4 = current flags (part 1)
3957 * Mode 5 = current flags (part 2)
3958 * Mode 6 = mutations
3960 void display_player(int mode)
3969 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3978 if ((mode == 0) || (mode == 1))
3980 /* Name, Sex, Race, Class */
3982 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3984 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3987 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3988 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3989 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3990 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3995 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3997 strcpy(tmp, realm_names[p_ptr->realm1]);
3998 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
4001 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
4002 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
4004 /* Age, Height, Weight, Social */
4005 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4007 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
4008 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
4009 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
4010 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
4012 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
4013 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
4014 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
4015 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
4017 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
4020 /* Display the stats */
4021 for (i = 0; i < 6; i++)
4023 /* Special treatment of "injured" stats */
4024 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4028 /* Use lowercase stat name */
4029 put_str(stat_names_reduced[i], 3 + i, 54);
4031 /* Get the current stat */
4032 value = p_ptr->stat_use[i];
4034 /* Obtain the current stat (modified) */
4035 cnv_stat(value, buf);
4037 /* Display the current stat (modified) */
4038 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
4040 /* Acquire the max stat */
4041 value = p_ptr->stat_top[i];
4043 /* Obtain the maximum stat (modified) */
4044 cnv_stat(value, buf);
4046 /* Display the maximum stat (modified) */
4047 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
4050 /* Normal treatment of "normal" stats */
4053 /* Assume uppercase stat name */
4054 put_str(stat_names[i], 3 + i, 54);
4056 /* Obtain the current stat (modified) */
4057 cnv_stat(p_ptr->stat_use[i], buf);
4059 /* Display the current stat (modified) */
4060 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
4063 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4066 c_put_str(TERM_WHITE, "!", 3+i, 59);
4068 c_put_str(TERM_WHITE, "!", 3+i, 59-2);
4073 /* Display "history" info */
4079 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
4081 put_str("(Character Background)", 11, 25);
4084 for (i = 0; i < 4; i++)
4086 put_str(history[i], i + 12, 10);
4091 if (death && total_winner)
4094 strcpy(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¾¡Íø¤Î¸å°úÂष¤¿¡£");
4096 strcpy(statmsg, "...You retired from the adventure after the winning.");
4103 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
4106 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢¥¯¥¨¥¹¥È¡Ö%s¡×¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", quest[p_ptr->inside_quest].name, died_from);
4108 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", died_from, quest[p_ptr->inside_quest].name);
4114 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¡¢%s¤Î%d³¬¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), dun_level, died_from);
4116 sprintf(statmsg, "...You were killed by %s on level %d of %s.", died_from, dun_level, map_name());
4122 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï%s¤Ç%s¤Ë»¦¤µ¤ì¤¿¡£", map_name(), died_from);
4124 sprintf(statmsg, "...You were killed by %s in %s.", died_from, map_name());
4127 else if (character_dungeon)
4131 if (p_ptr->inside_quest && (p_ptr->inside_quest < MIN_RANDOM_QUEST))
4134 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ ¥¯¥¨¥¹¥È¡Ö%s¡×¤ò¿ë¹ÔÃæ¤À¡£", quest[p_ptr->inside_quest].name);
4136 sprintf(statmsg, "...Now, you are in the quest '%s'.", quest[p_ptr->inside_quest].name);
4142 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level);
4144 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
4150 sprintf(statmsg, "¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name());
4152 sprintf(statmsg, "...Now, you are in %s.", map_name());
4158 char temp[64*2], *t;
4159 roff_to_buf(statmsg, 60, temp);
4161 for(i=0 ; i<2 ; i++)
4167 put_str(t, i + 5 + 12, 10);
4175 /* Display "various" info */
4178 display_player_middle();
4179 display_player_various();
4186 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4189 display_player_misc_info();
4190 display_player_stat_info();
4191 display_player_flag_info();
4197 display_player_ben();
4202 do_cmd_knowledge_mutations();
4208 display_player_ben_one(mode % 2);
4212 errr make_character_dump(FILE *fff)
4219 char o_name[MAX_NLEN];
4223 #ifndef FAKE_VERSION
4225 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4226 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4229 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4230 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4232 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4233 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4240 /* Display player */
4243 /* Dump part of the screen */
4244 for (y = 1; y < 22; y++)
4247 for (x = 0; x < 79; x++)
4249 /* Get the attr/char */
4250 (void)(Term_what(x, y, &a, &c));
4256 /* End the string */
4259 /* Kill trailing spaces */
4260 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4264 fprintf(fff, "%s\n", buf);
4266 fprintf(fff, "%s\n", buf);
4271 /* Display history */
4274 /* Dump part of the screen */
4275 for (y = 10; y < 19; y++)
4278 for (x = 0; x < 79; x++)
4280 /* Get the attr/char */
4281 (void)(Term_what(x, y, &a, &c));
4287 /* End the string */
4290 /* Kill trailing spaces */
4291 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4294 fprintf(fff, "%s\n", buf);
4298 /* Display history */
4301 /* Dump part of the screen */
4302 for (y = 2; y < 22; y++)
4305 for (x = 0; x < 79; x++)
4307 /* Get the attr/char */
4308 (void)(Term_what(x, y, &a, &c));
4310 /* Dump it (Ignore equippy tile graphic) */
4317 /* End the string */
4320 /* Kill trailing spaces */
4321 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4324 fprintf(fff, "%s\n", buf);
4327 for (i = 0; (unsigned int) i < (p_ptr->count / 80); i++)
4330 for (i = 0; (unsigned int) i < (p_ptr->count % 80); i++)
4336 for (i = m_max - 1; i >= 1; i--)
4338 monster_type *m_ptr = &m_list[i];
4341 if (!m_ptr->r_idx) continue;
4342 if (!is_pet(m_ptr)) continue;
4343 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4347 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4349 fprintf(fff, "\n [leading pets]\n\n");
4353 monster_desc(pet_name, m_ptr, 0x88);
4354 fprintf(fff, "%s", pet_name);
4355 if (p_ptr->riding == i)
4357 fprintf(fff, " ¾èÇÏÃæ");
4359 fprintf(fff, " (riding)");
4363 if (pet) fprintf(fff, "\n");
4366 if (death && !total_winner)
4369 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4371 fprintf(fff, "\n [Last messages]\n\n");
4373 for (i = MIN(message_num(), 30); i >= 0; i--)
4375 fprintf(fff,"> %s\n",message_str((s16b)i));
4381 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4383 fprintf(fff, "\n [Miscellaneous information]\n");
4387 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4389 fprintf(fff, "\n Recall Depth:\n");
4391 for (y = 1; y < max_d_idx; y++)
4395 if (!d_info[y].maxdepth) continue;
4396 if (!max_dlv[y]) continue;
4397 if (d_info[y].final_guardian)
4399 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4401 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4404 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4406 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4412 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4414 fprintf(fff, "\n Preserve Mode: ON");
4419 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4421 fprintf(fff, "\n Preserve Mode: OFF");
4425 if (ironman_autoscum)
4427 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4429 fprintf(fff, "\n Autoscum: ALWAYS");
4434 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4436 fprintf(fff, "\n Autoscum: ON");
4441 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4443 fprintf(fff, "\n Autoscum: OFF");
4447 if (ironman_small_levels)
4449 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4451 fprintf(fff, "\n Small Levels: ALWAYS");
4454 else if (always_small_levels)
4456 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4458 fprintf(fff, "\n Small Levels: ON");
4461 else if (small_levels)
4463 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4465 fprintf(fff, "\n Small Levels: ENABLED");
4470 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4472 fprintf(fff, "\n Small Levels: OFF");
4478 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4480 fprintf(fff, "\n Vanilla Town: ON");
4485 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4487 fprintf(fff, "\n Lite Town: ON");
4493 fprintf(fff, "\n Ź¤Ê¤·: ON");
4495 fprintf(fff, "\n No Shops: ON");
4499 if (ironman_downward)
4501 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4503 fprintf(fff, "\n Diving only: ON");
4509 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4511 fprintf(fff, "\n Unusual rooms: ON");
4515 if (ironman_nightmare)
4517 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4519 fprintf(fff, "\n Nightmare Mode: ON");
4523 if (ironman_empty_levels)
4525 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4527 fprintf(fff, "\n Arena Levels: ALWAYS");
4530 else if (empty_levels)
4532 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4534 fprintf(fff, "\n Arena Levels: ENABLED");
4539 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4541 fprintf(fff, "\n Arena Levels: OFF");
4546 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4548 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4551 if (p_ptr->arena_number == 99)
4554 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4556 fprintf(fff, "\n Arena: defeated\n");
4559 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4562 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4564 fprintf(fff, "\n Arena: True Champion\n");
4567 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4570 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4572 fprintf(fff, "\n Arena: Champion\n");
4578 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4580 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");
4586 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4588 fprintf(fff, "\n You have done something illegal.");
4592 if (stupid_monsters)
4594 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4596 fprintf(fff, "\n Your opponents are behaving stupidly.");
4602 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4604 fprintf(fff, "\n You possess munchkinish power over death.");
4609 /* Monsters slain */
4614 for (k = 1; k < max_r_idx; k++)
4616 monster_race *r_ptr = &r_info[k];
4618 if (r_ptr->flags1 & RF1_UNIQUE)
4620 bool dead = (r_ptr->max_num == 0);
4628 s16b This = r_ptr->r_pkills;
4638 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4640 fprintf(fff,"\n You have defeated no enemies yet.\n");
4643 else if (Total == 1)
4645 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4647 fprintf(fff,"\n You have defeated one enemy.\n");
4652 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4654 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4660 if (p_ptr->old_race1 || p_ptr->old_race2)
4663 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4665 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4667 for (i = 0; i < MAX_RACES; i++)
4669 if (p_ptr->start_race == i) continue;
4672 if (!(p_ptr->old_race1 & 1L << i)) continue;
4676 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4679 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4681 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4686 if (p_ptr->old_realm)
4688 for (i = 0; i < MAX_MAGIC; i++)
4690 if (!(p_ptr->old_realm & 1L << i)) continue;
4692 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4694 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4700 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4702 fprintf(fff, "\n\n [Virtues]\n\n");
4706 fprintf(fff, "°À : %s\n", your_alignment());
4708 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4713 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4716 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4718 fprintf(fff, "\n\n [Mutations]\n\n");
4721 dump_mutations(fff);
4725 /* Skip some lines */
4726 fprintf(fff, "\n\n");
4729 /* Dump the equipment */
4733 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4735 fprintf(fff, " [Character Equipment]\n\n");
4738 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4740 object_desc(o_name, &inventory[i], TRUE, 3);
4741 if ((i == INVEN_LARM) && p_ptr->ryoute)
4743 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4745 strcpy(o_name, "(wielding with two-hands)");
4747 fprintf(fff, "%c%s %s\n",
4748 index_to_label(i), paren, o_name);
4750 fprintf(fff, "\n\n");
4753 /* Dump the inventory */
4755 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4757 fprintf(fff, " [Character Inventory]\n\n");
4760 for (i = 0; i < INVEN_PACK; i++)
4762 /* Don't dump the empty slots */
4763 if (!inventory[i].k_idx) break;
4765 /* Dump the inventory slots */
4766 object_desc(o_name, &inventory[i], TRUE, 3);
4767 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4770 /* Add an empty line */
4771 fprintf(fff, "\n\n");
4773 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4775 /* Print all homes in the different towns */
4776 st_ptr = &town[1].store[STORE_HOME];
4778 /* Home -- if anything there */
4779 if (st_ptr->stock_num)
4781 /* Header with name of the town */
4783 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4785 fprintf(fff, " [Home Inventory]\n");
4789 /* Dump all available items */
4790 for (i = 0; i < st_ptr->stock_num; i++)
4794 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4796 fprintf(fff, "\n ( page %d )\n", x++);
4798 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4799 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4802 /* Add an empty line */
4803 fprintf(fff, "\n\n");
4807 /* Print all homes in the different towns */
4808 st_ptr = &town[1].store[STORE_MUSEUM];
4810 /* Home -- if anything there */
4811 if (st_ptr->stock_num)
4813 /* Header with name of the town */
4815 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4817 fprintf(fff, " [Museum]\n");
4821 /* Dump all available items */
4822 for (i = 0; i < st_ptr->stock_num; i++)
4825 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4826 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4827 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4829 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4830 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4831 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4836 /* Add an empty line */
4837 fprintf(fff, "\n\n");
4844 * Hack -- Dump a character description file
4846 * XXX XXX XXX Allow the "full" flag to dump additional info,
4847 * and trigger its usage from various places in the code.
4849 errr file_character(cptr name, bool full)
4858 /* Build the filename */
4859 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4861 /* File type is "TEXT" */
4862 FILE_TYPE(FILE_TYPE_TEXT);
4864 /* Check for existing file */
4865 fd = fd_open(buf, O_RDONLY);
4872 /* Close the file */
4877 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4879 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4884 if (get_check(out_val)) fd = -1;
4887 /* Open the non-existing file */
4888 if (fd < 0) fff = my_fopen(buf, "w");
4895 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4897 msg_format("Character dump failed!");
4906 (void)make_character_dump(fff);
4916 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4918 msg_print("Character dump successful.");
4928 typedef struct file_tag
4935 typedef struct file_tags
4942 static void add_tag(file_tags *the_tags, cptr name, int line)
4944 if (the_tags->index < 64)
4946 file_tag *tag = &(the_tags->tags[the_tags->index]);
4948 /* Set the name and end it with '\0' */
4949 strncpy(tag->name, name, 31);
4950 tag->name[31] = '\0';
4952 /* Set the line-number */
4953 tag->line_number = line;
4955 /* Increase the number of tags */
4961 static int get_line(file_tags *the_tags, cptr name)
4965 /* Search for the tag */
4966 for (i = 0; i < the_tags->index; i++)
4968 if (streq(the_tags->tags[i].name, name))
4970 return the_tags->tags[i].line_number;
4980 * Recursive file perusal.
4982 * Return FALSE on 'Q', otherwise TRUE.
4984 * Process various special text in the input file, including
4985 * the "menu" structures used by the "help file" system.
4987 * XXX XXX XXX Consider using a temporary file.
4989 * XXX XXX XXX Allow the user to "save" the current file.
4991 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4995 /* Number of "real" lines passed by */
4998 /* Number of "real" lines in the file */
5001 /* Backup value for "line" */
5004 /* Color of the next line */
5005 byte color = TERM_WHITE;
5010 /* This screen has sub-screens */
5013 /* Current help file */
5016 /* Find this string (if any) */
5019 /* Jump to this tag */
5022 /* Hold a string to find */
5025 /* Hold a string to show */
5029 char filename[1024];
5031 /* Describe this thing */
5037 /* General buffer */
5040 /* Lower case version of the buffer, for searching */
5043 /* Aux pointer for making lc_buf (and find!) lowercase */
5046 /* Sub-menu information */
5049 /* Tags for in-file references */
5052 bool reverse = (line < 0);
5056 Term_get_size(&wid, &hgt);
5066 strcpy(caption, "");
5068 /* Wipe the hooks */
5069 for (i = 0; i < 68; i++)
5077 /* Copy the filename */
5078 strcpy(filename, name);
5080 n = strlen(filename);
5082 /* Extract the tag from the filename */
5083 for (i = 0; i < n; i++)
5085 if (filename[i] == '#')
5088 tag = filename + i + 1;
5093 /* Redirect the name */
5096 /* Hack XXX XXX XXX */
5100 strcpy(caption, what);
5102 /* Access the "file" */
5106 fff = my_fopen(path, "r");
5109 /* Look in "help" */
5114 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5116 sprintf(caption, "Help file '%s'", name);
5120 /* Build the filename */
5121 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5124 fff = my_fopen(path, "r");
5127 /* Look in "info" */
5132 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5134 sprintf(caption, "Info file '%s'", name);
5138 /* Build the filename */
5139 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5142 fff = my_fopen(path, "r");
5145 /* Look in "info" */
5148 /* Build the filename */
5149 path_build(path, 1024, ANGBAND_DIR, name);
5151 for (i = 0; path[i]; i++)
5152 if ('\\' == path[i])
5153 path[i] = PATH_SEP[0];
5157 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5159 sprintf(caption, "Info file '%s'", name);
5163 fff = my_fopen(path, "r");
5171 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5173 msg_format("Cannot open '%s'.", name);
5183 /* Pre-Parse the file */
5188 /* Read a line or stop */
5189 if (my_fgets(fff, buf, 1024)) break;
5192 if (prefix(buf, "#####")) str = &buf[6];
5195 /* XXX Parse "menu" items */
5196 if (prefix(str, "***** "))
5198 /* Notice "menu" requests */
5199 if ((str[6] == '[') && isalpha(str[7]))
5201 /* This is a menu file */
5204 /* Extract the menu item */
5207 if ((str[8] == ']') && (str[9] == ' '))
5209 /* Extract the menu item */
5210 strncpy(hook[k], str + 10, 31);
5212 /* Make sure it's null-terminated */
5216 /* Notice "tag" requests */
5217 else if (str[6] == '<')
5219 str[strlen(str) - 1] = '\0';
5220 add_tag(&tags, str + 7, next);
5227 /* Count the "real" lines */
5231 /* Save the number of "real" lines */
5234 /* start from bottom when reverse mode */
5235 if (line == -1) line = ((size-1)/rows)*rows;
5237 /* Go to the tagged line */
5238 if (tag) line = get_line(&tags, tag);
5240 /* Display the file */
5246 /* Restart when necessary */
5247 if (line >= size - rows) line = size - rows;
5248 if (line < 0) line = 0;
5250 /* Re-open the file if needed */
5256 /* Hack -- Re-Open the file */
5257 fff = my_fopen(path, "r");
5260 if (!fff) return (FALSE);
5262 /* File has been restarted */
5266 /* Goto the selected line */
5270 if (my_fgets(fff, buf, 1024)) break;
5272 /* Skip tags/links */
5273 if (prefix(buf, "***** ")) continue;
5275 /* Count the lines */
5279 /* Dump the next 20, or rows, lines of the file */
5280 for (i = 0; i < rows; )
5285 /* Hack -- track the "first" line */
5286 if (!i) line = next;
5288 /* Get a line of the file or stop */
5289 if (my_fgets(fff, buf, 1024)) break;
5291 /* Hack -- skip "special" lines */
5292 if (prefix(buf, "***** ")) continue;
5295 if (prefix(buf, "#####"))
5297 color = color_char_to_attr(buf[5]);
5306 /* Count the "real" lines */
5309 /* Make a lower case version of str for searching */
5310 strcpy(lc_buf, str);
5312 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5315 if (iskanji(*lc_buf_ptr))
5319 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5322 /* Hack -- keep searching */
5323 if (find && !i && !strstr(lc_buf, find)) continue;
5325 /* Hack -- stop searching */
5334 if (prefix(str + x, "[[[[["))
5336 byte c = color_char_to_attr(str[x + 5]);
5339 /* Ok print the link name */
5340 while (str[x] != ']')
5342 Term_putch(print_x, i + 2, c, str[x]);
5349 Term_putch(print_x, i + 2, color, str[x]);
5356 /* Hilite "shower" */
5361 /* Display matches */
5362 while ((s2 = strstr(s2, shower)) != NULL)
5364 int len = strlen(shower);
5366 /* Display the match */
5367 Term_putstr(s2-lc_buf, i+2, len, TERM_YELLOW, &str[s2-lc_buf]);
5374 /* Count the printed lines */
5378 /* Hack -- failed search */
5388 /* Show a general "title" */
5393 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5395 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5398 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5399 caption, line, size), 0, 0);
5409 caption, line, size), 0, 0);
5412 /* Prompt -- small files */
5417 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5419 prt("[Press ESC to exit.]", hgt - 1, 0);
5424 /* Prompt -- large files */
5429 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5431 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", hgt - 1, 0);
5433 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5437 /* Get a keypress */
5440 /* Hack -- return to last screen */
5441 if (k == '<') break;
5443 /* Show the help for the help */
5446 /* Hack - prevent silly recursion */
5448 if (strcmp(name, "jhelpinfo.txt") != 0)
5449 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5451 if (strcmp(name, "helpinfo.txt") != 0)
5452 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5456 /* Hack -- try showing */
5461 prt("¶¯Ä´: ", hgt - 1, 0);
5463 prt("Show: ", hgt - 1, 0);
5466 (void)askfor_aux(shower, 80);
5469 /* Hack -- try finding */
5474 prt("¸¡º÷: ", hgt - 1, 0);
5476 prt("Find: ", hgt - 1, 0);
5480 if (askfor_aux(finder, 80))
5487 /* Make finder lowercase */
5488 for (cnt = 0; finder[cnt] != 0; cnt++)
5491 if (iskanji(finder[cnt]))
5495 finder[cnt] = tolower(finder[cnt]);
5499 strcpy(shower, finder);
5503 /* Hack -- go to a specific line */
5508 prt("¹Ô: ", hgt - 1, 0);
5510 prt("Goto Line: ", hgt - 1, 0);
5515 if (askfor_aux(tmp, 80))
5521 /* Hack -- go to a specific file */
5526 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", hgt - 1, 0);
5527 strcpy(tmp, "jhelp.hlp");
5529 prt("Goto File: ", hgt - 1, 0);
5530 strcpy(tmp, "help.hlp");
5534 if (askfor_aux(tmp, 80))
5536 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5540 /* Allow backing up */
5543 line = line + (reverse ? rows : -rows);
5544 if (line < 0) line = 0;
5547 /* Advance a single line */
5548 if ((k == '\n') || (k == '\r'))
5550 line = line + (reverse ? -1 : 1);
5551 if (line < 0) line = 0;
5555 /* Move up / down */
5559 if (line < 0) line = 0;
5562 if (k == '2') line++;
5564 /* Advance one page */
5567 line = line + (reverse ? -rows : rows);
5568 if (line < 0) line = ((size-1)/rows)*rows;
5571 /* Recurse on numbers */
5579 if ((key > -1) && hook[key][0])
5581 /* Recurse on that file */
5582 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5587 /* Hack, dump to file */
5597 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5599 if (!get_string("File name: ", xtmp, 80))
5611 /* Build the filename */
5612 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5614 /* Hack -- Re-Open the file */
5615 fff = my_fopen(path, "r");
5617 ffp = my_fopen(buff, "w");
5623 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5625 msg_print("Failed to open file.");
5632 sprintf(xtmp, "%s: %s", player_name, what);
5633 my_fputs(ffp, xtmp, 80);
5634 my_fputs(ffp, "\n", 80);
5636 while (!my_fgets(fff, buff, 80))
5637 my_fputs(ffp, buff, 80);
5646 /* Hack -- Re-Open the file */
5647 fff = my_fopen(path, "r");
5650 /* Exit on escape */
5651 if (k == ESCAPE) break;
5652 if (k == 'q') break;
5655 /* Close the file */
5659 if (k == 'q') return (FALSE);
5667 * Peruse the On-Line-Help
5669 void do_cmd_help(void)
5674 /* Peruse the main help file */
5676 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5678 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5688 * Process the player name.
5689 * Extract a clean "base name".
5690 * Build the savefile name if needed.
5692 void process_player_name(bool sf)
5697 /* Cannot be too long */
5698 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5700 if (strlen(player_name) > 8)
5702 if (strlen(player_name) > 15)
5707 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5709 quit_fmt("The name '%s' is too long!", player_name);
5715 /* Cannot contain "icky" characters */
5716 for (i = 0; player_name[i]; i++)
5718 /* No control characters */
5720 if (iskanji(player_name[i])){i++;continue;}
5721 if (iscntrl( (unsigned char)player_name[i]))
5723 if (iscntrl(player_name[i]))
5727 /* Illegal characters */
5729 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5731 quit_fmt("The name '%s' contains control chars!", player_name);
5740 /* Extract "useful" letters */
5741 for (i = 0; player_name[i]; i++)
5744 unsigned char c = player_name[i];
5746 char c = player_name[i];
5750 /* Convert "dot" to "underscore" */
5751 if (c == '.') c = '_';
5753 /* Accept all the letters */
5754 player_base[k++] = c;
5759 /* Extract "useful" letters */
5760 for (i = 0; player_name[i]; i++)
5763 unsigned char c = player_name[i];
5765 char c = player_name[i];
5768 /* Accept some letters */
5771 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5772 player_base[k++] = c;
5774 player_base[k++] = player_name[i];
5777 else if (iskana(c)) player_base[k++] = c;
5781 /* Convert path separator to underscore */
5782 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5783 player_base[k++] = '_';
5784 i += strlen(PATH_SEP);
5787 /* Convert space, dot, and underscore to underscore */
5788 else if (strchr(". _", c)) player_base[k++] = '_';
5790 else if (isprint(c)) player_base[k++] = c;
5798 /* Hack -- max length */
5804 player_base[k] = '\0';
5806 /* Require a "base" name */
5807 if (!player_base[0]) strcpy(player_base, "PLAYER");
5810 #ifdef SAVEFILE_MUTABLE
5816 if (!savefile_base[0] && savefile[0])
5823 t = strstr(s, PATH_SEP);
5828 strcpy(savefile_base, s);
5831 if (!savefile_base[0] || !savefile[0])
5834 /* Change the savefile name */
5839 strcpy(savefile_base, player_base);
5841 #ifdef SAVEFILE_USE_UID
5842 /* Rename the savefile, using the player_uid and player_base */
5843 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5845 /* Rename the savefile, using the player_base */
5846 (void)sprintf(temp, "%s", player_base);
5850 /* Hack -- support "flat directory" usage on VM/ESA */
5851 (void)sprintf(temp, "%s.sv", player_base);
5854 /* Build the filename */
5855 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5861 * Gets a name for the character, reacting to name changes.
5863 * Assumes that "display_player(0)" has just been called
5865 * Perhaps we should NOT ask for a name (at "birth()") on
5866 * Unix machines? XXX XXX
5868 * What a horrible name for a global function. XXX XXX XXX
5874 /* Save the player name */
5875 strcpy(tmp, player_name);
5877 /* Prompt for a new name */
5879 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5881 if (get_string("Enter a name for your character: ", tmp, 15))
5885 strcpy(player_name, tmp);
5887 else if (0 == strlen(player_name))
5889 /* Use default name */
5890 strcpy(player_name, "PLAYER");
5893 /* Process the player name */
5894 process_player_name(FALSE);
5896 strcpy(tmp,ap_ptr->title);
5903 strcat(tmp,player_name);
5905 /* Re-Draw the name (in light blue) */
5906 Term_erase(34, 1, 255);
5907 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5909 /* Erase the prompt, etc */
5916 * Hack -- commit suicide
5918 void do_cmd_suicide(void)
5925 /* Verify Retirement */
5930 if (!get_check_strict("°úÂष¤Þ¤¹¤«? ", CHECK_NO_HISTORY)) return;
5932 if (!get_check_strict("Do you want to retire? ", CHECK_NO_HISTORY)) return;
5937 /* Verify Suicide */
5942 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5944 if (!get_check("Do you really want to commit suicide? ")) return;
5951 /* Special Verification for suicide */
5953 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5955 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5961 if (i != '@') return;
5967 /* Kill the player */
5971 p_ptr->leaving = TRUE;
5976 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5977 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5979 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5980 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5982 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5985 /* Cause of death */
5987 (void)strcpy(died_from, "ÅÓÃ潪λ");
5989 (void)strcpy(died_from, "Quitting");
5999 void do_cmd_save_game(int is_autosave)
6001 /* Autosaves do not disturb */
6005 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
6007 msg_print("Autosaving the game...");
6013 /* Disturb the player */
6017 /* Clear messages */
6025 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
6027 prt("Saving game...", 0, 0);
6034 /* The player is not dead */
6036 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
6038 (void)strcpy(died_from, "(saved)");
6042 /* Forbid suspend */
6043 signals_ignore_tstp();
6045 /* Save the player */
6049 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
6051 prt("Saving game... done.", 0, 0);
6056 /* Save failed (oops) */
6060 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
6062 prt("Saving game... failed!", 0, 0);
6067 /* Allow suspend again */
6068 signals_handle_tstp();
6073 /* Note that the player is not dead */
6075 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
6077 (void)strcpy(died_from, "(alive and well)");
6084 * Save the game and exit
6086 void do_cmd_save_and_exit(void)
6091 p_ptr->leaving = TRUE;
6093 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
6095 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
6101 * Hack -- Calculates the total number of points earned -JWT-
6103 long total_points(void)
6107 u32b point, point_h, point_l;
6108 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6110 if (stupid_monsters) mult -= 70;
6111 if (!preserve_mode) mult += 10;
6112 if (!autoroller) mult += 10;
6113 if (!smart_learn) mult -= 20;
6114 if (!terrain_streams) mult -= 20;
6115 if (smart_cheat) mult += 30;
6116 if (ironman_shops) mult += 50;
6117 if (ironman_small_levels) mult += 10;
6118 if (ironman_empty_levels) mult += 20;
6119 if (!powerup_home) mult += 50;
6120 if (ironman_rooms) mult += 100;
6121 if (ironman_nightmare) mult += 100;
6123 if (mult < 5) mult = 5;
6125 for (i = 0; i < max_d_idx; i++)
6126 if(max_dlv[i] > max_dl)
6127 max_dl = max_dlv[i];
6129 point_l = (p_ptr->max_exp + (100 * max_dl));
6130 point_h = point_l / 0x10000L;
6131 point_l = point_l % 0x10000L;
6134 point_h += point_l / 0x10000L;
6135 point_l %= 0x10000L;
6137 point_l += ((point_h % 100) << 16);
6141 point = (point_h << 16) + (point_l);
6142 if (p_ptr->arena_number < 99)
6143 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6145 if (ironman_downward) point *= 2;
6146 if (p_ptr->pclass == CLASS_BERSERKER)
6148 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6152 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6155 if (total_winner) point = 2;
6157 if (easy_band) point = (0 - point);
6165 * Centers a string within a 31 character string -JWT-
6167 static void center_string(char *buf, cptr str)
6174 /* Necessary border */
6178 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6184 * Save a "bones" file for a dead character
6186 * Note that we will not use these files until Angband 2.8.0, and
6187 * then we will only use the name and level on which death occured.
6189 * Should probably attempt some form of locking...
6191 static void make_bones(void)
6198 /* Ignore wizards and borgs */
6199 if (!(noscore & 0x00FF))
6201 /* Ignore people who die in town */
6206 /* XXX XXX XXX "Bones" name */
6207 sprintf(tmp, "bone.%03d", dun_level);
6209 /* Build the filename */
6210 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6212 /* Attempt to open the bones file */
6213 fp = my_fopen(str, "r");
6215 /* Close it right away */
6216 if (fp) my_fclose(fp);
6218 /* Do not over-write a previous ghost */
6221 /* File type is "TEXT" */
6222 FILE_TYPE(FILE_TYPE_TEXT);
6224 /* Try to write a new "Bones File" */
6225 fp = my_fopen(str, "w");
6227 /* Not allowed to write it? Weird. */
6231 fprintf(fp, "%s\n", player_name);
6232 fprintf(fp, "%d\n", p_ptr->mhp);
6233 fprintf(fp, "%d\n", p_ptr->prace);
6234 fprintf(fp, "%d\n", p_ptr->pclass);
6236 /* Close and save the Bones file */
6245 * Redefinable "print_tombstone" action
6247 bool (*tombstone_aux)(void) = NULL;
6251 * Display a "tomb-stone"
6253 static void print_tomb(void)
6257 /* Do we use a special tombstone ? */
6260 /* Use tombstone hook */
6261 done = (*tombstone_aux)();
6264 /* Print the text-tombstone */
6278 time_t ct = time((time_t)0);
6284 /* Build the filename */
6286 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6288 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6292 /* Open the News file */
6293 fp = my_fopen(buf, "r");
6300 /* Dump the file to the screen */
6301 while (0 == my_fgets(fp, buf, 1024))
6303 /* Display and advance */
6304 put_str(buf, i++, 0);
6313 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6327 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6330 center_string(buf, player_name);
6331 put_str(buf, 6, 11);
6334 center_string(buf, "the");
6335 put_str(buf, 7, 11);
6338 center_string(buf, p);
6339 put_str(buf, 8, 11);
6342 center_string(buf, cp_ptr->title);
6344 put_str(buf, 10, 11);
6347 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6349 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6352 center_string(buf, tmp);
6353 put_str(buf, 11, 11);
6356 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6358 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6361 center_string(buf, tmp);
6362 put_str(buf, 12, 11);
6365 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6367 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6370 center_string(buf, tmp);
6371 put_str(buf, 13, 11);
6374 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6375 if (streq(died_from, "ÅÓÃ潪λ"))
6377 strcpy(tmp, "<¼«»¦>");
6381 if (streq(died_from, "ripe"))
6383 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6385 else if (streq(died_from, "Seppuku"))
6387 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6391 strcpy(tmp, died_from);
6394 center_string(buf, tmp);
6395 put_str(buf, 14, 11);
6397 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6399 if( dun_level == 0 )
6401 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6402 if(streq(died_from, "ÅÓÃ潪λ"))
6404 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6408 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6413 if(streq(died_from, "ÅÓÃ潪λ"))
6415 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6419 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6422 center_string(buf, tmp);
6423 put_str(buf, 15, 11);
6426 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6427 center_string(buf, tmp);
6428 put_str(buf, 14, 11);
6431 if (strlen(died_from) > 24)
6433 strncpy(dummy, died_from, 24);
6435 (void)sprintf(tmp, "by %s.", dummy);
6438 (void)sprintf(tmp, "by %s.", died_from);
6440 center_string(buf, tmp);
6441 put_str(buf, 15, 11);
6446 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6447 center_string(buf, tmp);
6448 put_str(buf, 17, 11);
6451 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6453 msg_format("Goodbye, %s!", player_name);
6461 * Display some character info
6463 static void show_info(void)
6469 /* Hack -- Know everything in the inven/equip */
6470 for (i = 0; i < INVEN_TOTAL; i++)
6472 o_ptr = &inventory[i];
6474 /* Skip non-objects */
6475 if (!o_ptr->k_idx) continue;
6477 /* Aware and Known */
6478 object_aware(o_ptr);
6479 object_known(o_ptr);
6482 for (i = 1; i < max_towns; i++)
6484 st_ptr = &town[i].store[STORE_HOME];
6486 /* Hack -- Know everything in the home */
6487 for (j = 0; j < st_ptr->stock_num; j++)
6489 o_ptr = &st_ptr->stock[j];
6491 /* Skip non-objects */
6492 if (!o_ptr->k_idx) continue;
6494 /* Aware and Known */
6495 object_aware(o_ptr);
6496 object_known(o_ptr);
6500 /* Hack -- Recalculate bonuses */
6501 p_ptr->update |= (PU_BONUS);
6506 /* Flush all input keys */
6509 /* Flush messages */
6513 /* Describe options */
6515 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6516 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6518 prt("You may now dump a character record to one or more files.", 21, 0);
6519 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6523 /* Dump character records as requested */
6530 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6532 put_str("Filename: ", 23, 0);
6537 strcpy(out_val, "");
6539 /* Ask for filename (or abort) */
6540 if (!askfor_aux(out_val, 60)) return;
6542 /* Return means "show on screen" */
6543 if (!out_val[0]) break;
6548 /* Dump a character file */
6549 (void)file_character(out_val, TRUE);
6557 /* Display player */
6560 /* Prompt for inventory */
6562 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6564 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6568 /* Allow abort at this point */
6569 if (inkey() == ESCAPE) return;
6572 /* Show equipment and inventory */
6574 /* Equipment -- if any */
6578 item_tester_full = TRUE;
6579 (void)show_equip(0);
6581 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6583 prt("You are using: -more-", 0, 0);
6586 if (inkey() == ESCAPE) return;
6589 /* Inventory -- if any */
6593 item_tester_full = TRUE;
6594 (void)show_inven(0);
6596 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6598 prt("You are carrying: -more-", 0, 0);
6601 if (inkey() == ESCAPE) return;
6604 /* Homes in the different towns */
6605 for (l = 1; l < max_towns; l++)
6607 st_ptr = &town[l].store[STORE_HOME];
6609 /* Home -- if anything there */
6610 if (st_ptr->stock_num)
6612 /* Display contents of the home */
6613 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6619 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6621 char o_name[MAX_NLEN];
6625 o_ptr = &st_ptr->stock[i];
6627 /* Print header, clear line */
6628 sprintf(tmp_val, "%c) ", I2A(j));
6629 prt(tmp_val, j+2, 4);
6631 /* Display object description */
6632 object_desc(o_name, o_ptr, TRUE, 3);
6633 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6638 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6640 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6645 if (inkey() == ESCAPE) return;
6652 static bool check_score(void)
6658 if (highscore_fd < 0)
6661 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6663 msg_print("Score file unavailable.");
6670 #ifndef SCORE_WIZARDS
6671 /* Wizard-mode pre-empts scoring */
6672 if (noscore & 0x000F)
6675 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6677 msg_print("Score not registered for wizards.");
6686 /* Borg-mode pre-empts scoring */
6687 if (noscore & 0x00F0)
6690 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6692 msg_print("Score not registered for borgs.");
6700 #ifndef SCORE_CHEATERS
6701 /* Cheaters are not scored */
6702 if (noscore & 0xFF00)
6705 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6707 msg_print("Score not registered for cheaters.");
6717 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6719 if (!total_winner && streq(died_from, "Interrupting"))
6724 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6726 msg_print("Score not registered due to interruption.");
6735 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6737 if (!total_winner && streq(died_from, "Quitting"))
6742 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6744 msg_print("Score not registered due to quitting.");
6754 * Close up the current game (player may or may not be dead)
6756 * This function is called only from "main.c" and "signals.c".
6758 void close_game(void)
6761 bool do_send = TRUE;
6763 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6768 /* Flush the messages */
6771 /* Flush the input */
6775 /* No suspending now */
6776 signals_ignore_tstp();
6779 /* Hack -- Character is now "icky" */
6780 character_icky = TRUE;
6783 /* Build the filename */
6784 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6786 /* Open the high score file, for reading/writing */
6787 highscore_fd = fd_open(buf, O_RDWR);
6793 /* Handle retirement */
6794 if (total_winner) kingly();
6798 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6800 if (!munchkin_death || get_check("Save death? "))
6805 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6807 if (!save_player()) msg_print("death save failed!");
6810 else do_send = FALSE;
6817 /* Show more info */
6825 if ((!send_world_score(do_send)))
6828 if (get_check_strict("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6830 if (get_check_strict("Stand by for later score registration? ", (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6833 wait_report_score = TRUE;
6836 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6838 if (!save_player()) msg_print("death save failed!");
6842 if (!wait_report_score)
6845 else if (highscore_fd >= 0)
6847 display_scores_aux(0, 10, -1, NULL);
6850 /* Dump bones file */
6859 do_cmd_save_game(FALSE);
6861 /* Prompt for scores XXX XXX XXX */
6863 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6865 prt("Press Return (or Escape).", 0, 40);
6869 /* Predict score (or ESCAPE) */
6870 if (inkey() != ESCAPE) predict_score();
6874 /* Shut the high score file */
6875 (void)fd_close(highscore_fd);
6877 /* Forget the high score fd */
6881 /* Allow suspending now */
6882 signals_handle_tstp();
6887 * Handle abrupt death of the visual system
6889 * This routine is called only in very rare situations, and only
6890 * by certain visual systems, when they experience fatal errors.
6892 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6893 * save file so that player can see tombstone when restart.
6895 void exit_game_panic(void)
6897 /* If nothing important has happened, just quit */
6899 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6901 if (!character_generated || character_saved) quit("panic");
6905 /* Mega-Hack -- see "msg_print()" */
6908 /* Clear the top line */
6911 /* Hack -- turn off some things */
6914 /* Mega-Hack -- Delay death */
6915 if (p_ptr->chp < 0) death = FALSE;
6917 /* Hardcode panic save */
6920 /* Forbid suspend */
6921 signals_ignore_tstp();
6923 /* Indicate panic save */
6925 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6927 (void)strcpy(died_from, "(panic save)");
6931 /* Panic save, or get worried */
6933 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6935 if (!save_player()) quit("panic save failed!");
6939 /* Successful panic save */
6941 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6943 quit("panic save succeeded!");
6950 * Get a random line from a file
6951 * Based on the monster speech patch by Matt Graham,
6953 errr get_rnd_line(cptr file_name, int entry, char *output)
6957 int line, counter, test, numentries;
6962 /* Build the filename */
6963 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6966 fp = my_fopen(buf, "r");
6969 if (!fp) return (-1);
6971 /* Find the entry of the monster */
6974 /* Get a line from the file */
6975 if (my_fgets(fp, buf, 1024) == 0)
6977 /* Count the lines */
6980 /* Look for lines starting with 'N:' */
6981 if ((buf[0] == 'N') && (buf[1] == ':'))
6983 /* Allow default lines */
6990 else if (buf[2] == 'M')
6992 if (r_info[entry].flags1 & RF1_MALE)
6998 else if (buf[2] == 'F')
7000 if (r_info[entry].flags1 & RF1_FEMALE)
7006 /* Get the monster number */
7007 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7009 /* Is it the right monster? */
7018 /* Error while converting the monster number */
7019 msg_format("Error in line %d of %s!",
7020 line_num, file_name);
7028 /* Reached end of file */
7035 /* Get the number of entries */
7039 if (my_fgets(fp, buf, 1024) == 0)
7041 /* Count the lines */
7044 /* Look for the number of entries */
7045 if (isdigit(buf[0]))
7047 /* Get the number of entries */
7048 numentries = atoi(buf);
7054 /* Count the lines */
7057 /* Reached end of file without finding the number */
7058 msg_format("Error in line %d of %s!",
7059 line_num, file_name);
7068 /* Grab an appropriate line number */
7069 line = randint0(numentries);
7071 /* Get the random line */
7072 for (counter = 0; counter <= line; counter++)
7074 /* Count the lines */
7079 test = my_fgets(fp, buf, 1024);
7080 if(test || buf[0] != '#')
7086 /* Found the line */
7087 if (counter == line) break;
7091 /* Error - End of file */
7092 msg_format("Error in line %d of %s!",
7093 line_num, file_name);
7101 strcpy(output, buf);
7108 /* Close the file */
7117 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7121 for (i=0;i<count;i++){
7122 result=get_rnd_line(file_name, entry, output);
7125 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7133 * Process file for auto picker/destroyer.
7135 errr process_pickpref_file(cptr name)
7144 /* Build the filename */
7145 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7147 err = process_pref_file_aux(buf, TRUE);
7156 static errr counts_seek(int fd, u32b where, bool flag)
7159 char temp1[128], temp2[128];
7160 u32b zero_header[3] = {0L, 0L, 0L};
7163 #ifdef SAVEFILE_USE_UID
7164 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7166 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7168 for (i = 0; temp1[i]; i++)
7169 temp1[i] ^= (i+1) * 63;
7174 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7176 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7181 fd_seek(fd, seekpoint);
7182 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7183 fd_write(fd, (char*)(temp1), sizeof(temp1));
7187 if (strcmp(temp1, temp2) == 0)
7190 seekpoint += 128 + 3 * sizeof(u32b);
7193 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7196 u32b counts_read(int where)
7203 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7205 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7207 fd = fd_open(buf, O_RDONLY);
7209 if (counts_seek(fd, where, FALSE) ||
7210 fd_read(fd, (char*)(&count), sizeof(u32b)))
7218 errr counts_write(int where, u32b count)
7224 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7226 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7228 fd = fd_open(buf, O_RDWR);
7231 /* File type is "DATA" */
7232 FILE_TYPE(FILE_TYPE_DATA);
7234 /* Create a new high score file */
7235 fd = fd_make(buf, 0644);
7238 if (fd_lock(fd, F_WRLCK)) return 1;
7240 counts_seek(fd, where, TRUE);
7241 fd_write(fd, (char*)(&count), sizeof(u32b));
7243 if (fd_lock(fd, F_UNLCK)) return 1;
7251 #ifdef HANDLE_SIGNALS
7258 * Handle signals -- suspend
7260 * Actually suspend the game, and then resume cleanly
7262 static void handle_signal_suspend(int sig)
7264 /* Disable handler */
7265 (void)signal(sig, SIG_IGN);
7272 /* Suspend the "Term" */
7273 Term_xtra(TERM_XTRA_ALIVE, 0);
7275 /* Suspend ourself */
7276 (void)kill(0, SIGSTOP);
7278 /* Resume the "Term" */
7279 Term_xtra(TERM_XTRA_ALIVE, 1);
7281 /* Redraw the term */
7284 /* Flush the term */
7289 /* Restore handler */
7290 (void)signal(sig, handle_signal_suspend);
7295 * Handle signals -- simple (interrupt and quit)
7297 * This function was causing a *huge* number of problems, so it has
7298 * been simplified greatly. We keep a global variable which counts
7299 * the number of times the user attempts to kill the process, and
7300 * we commit suicide if the user does this a certain number of times.
7302 * We attempt to give "feedback" to the user as he approaches the
7303 * suicide thresh-hold, but without penalizing accidental keypresses.
7305 * To prevent messy accidents, we should reset this global variable
7306 * whenever the user enters a keypress, or something like that.
7308 static void handle_signal_simple(int sig)
7310 /* Disable handler */
7311 (void)signal(sig, SIG_IGN);
7314 /* Nothing to save, just quit */
7315 if (!character_generated || character_saved) quit(NULL);
7318 /* Count the signals */
7322 /* Terminate dead characters */
7325 /* Mark the savefile */
7327 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7329 (void)strcpy(died_from, "Abortion");
7348 /* Allow suicide (after 5) */
7349 else if (signal_count >= 5)
7351 /* Cause of "death" */
7353 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7355 (void)strcpy(died_from, "Interrupting");
7370 p_ptr->leaving = TRUE;
7384 /* Give warning (after 4) */
7385 else if (signal_count >= 4)
7388 Term_xtra(TERM_XTRA_NOISE, 0);
7390 /* Clear the top line */
7391 Term_erase(0, 0, 255);
7393 /* Display the cause */
7395 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7397 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7405 /* Give warning (after 2) */
7406 else if (signal_count >= 2)
7409 Term_xtra(TERM_XTRA_NOISE, 0);
7412 /* Restore handler */
7413 (void)signal(sig, handle_signal_simple);
7418 * Handle signal -- abort, kill, etc
7420 static void handle_signal_abort(int sig)
7424 Term_get_size(&wid, &hgt);
7427 /* Disable handler */
7428 (void)signal(sig, SIG_IGN);
7431 /* Nothing to save, just quit */
7432 if (!character_generated || character_saved) quit(NULL);
7439 /* Clear the bottom line */
7440 Term_erase(0, hgt - 1, 255);
7442 /* Give a warning */
7443 Term_putstr(0, hgt - 1, -1, TERM_RED,
7445 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7447 "A gruesome software bug LEAPS out at you!");
7453 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7455 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save...");
7467 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7469 (void)strcpy(died_from, "(panic save)");
7473 /* Forbid suspend */
7474 signals_ignore_tstp();
7476 /* Attempt to save */
7480 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7482 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save succeeded!");
7491 Term_putstr(45, hgt - 1, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7493 Term_putstr(45, hgt - 1, -1, TERM_RED, "Panic save failed!");
7503 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7505 quit("software bug");
7514 * Ignore SIGTSTP signals (keyboard suspend)
7516 void signals_ignore_tstp(void)
7520 (void)signal(SIGTSTP, SIG_IGN);
7526 * Handle SIGTSTP signals (keyboard suspend)
7528 void signals_handle_tstp(void)
7532 (void)signal(SIGTSTP, handle_signal_suspend);
7539 * Prepare to handle the relevant signals
7541 void signals_init(void)
7545 (void)signal(SIGHUP, SIG_IGN);
7550 (void)signal(SIGTSTP, handle_signal_suspend);
7555 (void)signal(SIGINT, handle_signal_simple);
7559 (void)signal(SIGQUIT, handle_signal_simple);
7564 (void)signal(SIGFPE, handle_signal_abort);
7568 (void)signal(SIGILL, handle_signal_abort);
7572 (void)signal(SIGTRAP, handle_signal_abort);
7576 (void)signal(SIGIOT, handle_signal_abort);
7580 (void)signal(SIGKILL, handle_signal_abort);
7584 (void)signal(SIGBUS, handle_signal_abort);
7588 (void)signal(SIGSEGV, handle_signal_abort);
7592 (void)signal(SIGTERM, handle_signal_abort);
7596 (void)signal(SIGPIPE, handle_signal_abort);
7600 (void)signal(SIGEMT, handle_signal_abort);
7604 (void)signal(SIGDANGER, handle_signal_abort);
7608 (void)signal(SIGSYS, handle_signal_abort);
7612 (void)signal(SIGXCPU, handle_signal_abort);
7616 (void)signal(SIGPWR, handle_signal_abort);
7622 #else /* HANDLE_SIGNALS */
7628 void signals_ignore_tstp(void)
7635 void signals_handle_tstp(void)
7642 void signals_init(void)
7645 #endif /* HANDLE_SIGNALS */