3 /* Purpose: code dealing with files (and death) */
6 * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research, and
9 * not for profit purposes provided that this copyright and statement are
10 * included in all such copies.
17 * You may or may not want to use the following "#undef".
19 /* #undef _POSIX_SAVED_IDS */
23 * Hack -- drop permissions
25 void safe_setuid_drop(void)
32 # ifdef SAFE_SETUID_POSIX
34 if (setuid(getuid()) != 0)
37 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
39 quit("setuid(): cannot set permissions correctly!");
43 if (setgid(getgid()) != 0)
46 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
48 quit("setgid(): cannot set permissions correctly!");
55 if (setreuid(geteuid(), getuid()) != 0)
58 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
60 quit("setreuid(): cannot set permissions correctly!");
64 if (setregid(getegid(), getgid()) != 0)
67 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
69 quit("setregid(): cannot set permissions correctly!");
84 * Hack -- grab permissions
86 void safe_setuid_grab(void)
93 # ifdef SAFE_SETUID_POSIX
95 if (setuid(player_euid) != 0)
98 quit("setuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
100 quit("setuid(): cannot set permissions correctly!");
104 if (setgid(player_egid) != 0)
107 quit("setgid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
109 quit("setgid(): cannot set permissions correctly!");
116 if (setreuid(geteuid(), getuid()) != 0)
119 quit("setreuid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
121 quit("setreuid(): cannot set permissions correctly!");
125 if (setregid(getegid(), getgid()) != 0)
128 quit("setregid(): Àµ¤·¤¯µö²Ä¤¬¼è¤ì¤Þ¤»¤ó¡ª");
130 quit("setregid(): cannot set permissions correctly!");
135 # endif /* SAFE_SETUID_POSIX */
137 # endif /* SAFE_SETUID */
145 * Extract the first few "tokens" from a buffer
147 * This function uses "colon" and "slash" as the delimeter characters.
149 * We never extract more than "num" tokens. The "last" token may include
150 * "delimeter" characters, allowing the buffer to include a "string" token.
152 * We save pointers to the tokens in "tokens", and return the number found.
154 * Hack -- Attempt to handle the 'c' character formalism
156 * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
158 * Hack -- We will always extract at least one token
160 s16b tokenize(char *buf, s16b num, char **tokens, int mode)
172 /* Scan the string */
175 /* Found a delimiter */
176 if ((*t == ':') || (*t == '/')) break;
178 /* Handle single quotes */
179 if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
184 /* Handle backslash */
187 /* Require a character */
193 /* Hack -- Require a close quote */
194 if (*t != '\'') *t = '\'';
197 /* Handle back-slash */
204 /* Nuke and advance */
222 /* A number with a name */
223 typedef struct named_num named_num;
227 cptr name; /* The name of this thing */
228 int num; /* A number associated with it */
232 /* Index of spell type names */
233 static named_num gf_desc[] =
235 {"GF_ELEC", GF_ELEC },
236 {"GF_POIS", GF_POIS },
237 {"GF_ACID", GF_ACID },
238 {"GF_COLD", GF_COLD },
239 {"GF_FIRE", GF_FIRE },
240 {"GF_PSY_SPEAR", GF_PSY_SPEAR },
241 {"GF_MISSILE", GF_MISSILE },
242 {"GF_ARROW", GF_ARROW },
243 {"GF_PLASMA", GF_PLASMA },
244 {"GF_WATER", GF_WATER },
245 {"GF_LITE", GF_LITE },
246 {"GF_DARK", GF_DARK },
247 {"GF_LITE_WEAK", GF_LITE_WEAK },
248 {"GF_DARK_WEAK", GF_DARK_WEAK },
249 {"GF_SHARDS", GF_SHARDS },
250 {"GF_SOUND", GF_SOUND },
251 {"GF_CONFUSION", GF_CONFUSION },
252 {"GF_FORCE", GF_FORCE },
253 {"GF_INERTIA", GF_INERTIA },
254 {"GF_MANA", GF_MANA },
255 {"GF_METEOR", GF_METEOR },
257 {"GF_CHAOS", GF_CHAOS },
258 {"GF_NETHER", GF_NETHER },
259 {"GF_DISENCHANT", GF_DISENCHANT },
260 {"GF_NEXUS", GF_NEXUS },
261 {"GF_TIME", GF_TIME },
262 {"GF_GRAVITY", GF_GRAVITY },
263 {"GF_KILL_WALL", GF_KILL_WALL },
264 {"GF_KILL_DOOR", GF_KILL_DOOR },
265 {"GF_KILL_TRAP", GF_KILL_TRAP },
266 {"GF_MAKE_WALL", GF_MAKE_WALL },
267 {"GF_MAKE_DOOR", GF_MAKE_DOOR },
268 {"GF_MAKE_TRAP", GF_MAKE_TRAP },
269 {"GF_MAKE_TREE", GF_MAKE_TREE },
270 {"GF_OLD_CLONE", GF_OLD_CLONE },
271 {"GF_OLD_POLY", GF_OLD_POLY },
272 {"GF_OLD_HEAL", GF_OLD_HEAL },
273 {"GF_OLD_SPEED", GF_OLD_SPEED },
274 {"GF_OLD_SLOW", GF_OLD_SLOW },
275 {"GF_OLD_CONF", GF_OLD_CONF },
276 {"GF_OLD_SLEEP", GF_OLD_SLEEP },
277 {"GF_OLD_DRAIN", GF_OLD_DRAIN },
278 {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD },
279 {"GF_AWAY_EVIL", GF_AWAY_EVIL },
280 {"GF_AWAY_ALL", GF_AWAY_ALL },
281 {"GF_TURN_UNDEAD", GF_TURN_UNDEAD },
282 {"GF_TURN_EVIL", GF_TURN_EVIL },
283 {"GF_TURN_ALL", GF_TURN_ALL },
284 {"GF_DISP_UNDEAD", GF_DISP_UNDEAD },
285 {"GF_DISP_EVIL", GF_DISP_EVIL },
286 {"GF_DISP_ALL", GF_DISP_ALL },
287 {"GF_DISP_DEMON", GF_DISP_DEMON },
288 {"GF_DISP_LIVING", GF_DISP_LIVING },
289 {"GF_ROCKET", GF_ROCKET },
290 {"GF_NUKE", GF_NUKE },
291 {"GF_MAKE_GLYPH", GF_MAKE_GLYPH },
292 {"GF_STASIS", GF_STASIS },
293 {"GF_STONE_WALL", GF_STONE_WALL },
294 {"GF_DEATH_RAY", GF_DEATH_RAY },
295 {"GF_STUN", GF_STUN },
296 {"GF_HOLY_FIRE", GF_HOLY_FIRE },
297 {"GF_HELL_FIRE", GF_HELL_FIRE },
298 {"GF_DISINTEGRATE", GF_DISINTEGRATE },
299 {"GF_CHARM", GF_CHARM },
300 {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD },
301 {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL },
303 {"GF_PSI_DRAIN", GF_PSI_DRAIN },
304 {"GF_TELEKINESIS", GF_TELEKINESIS },
305 {"GF_JAM_DOOR", GF_JAM_DOOR },
306 {"GF_DOMINATION", GF_DOMINATION },
307 {"GF_DISP_GOOD", GF_DISP_GOOD },
308 {"GF_DRAIN_MANA", GF_DRAIN_MANA },
309 {"GF_MIND_BLAST", GF_MIND_BLAST },
310 {"GF_BRAIN_SMASH", GF_BRAIN_SMASH },
311 {"GF_CAUSE_1", GF_CAUSE_1 },
312 {"GF_CAUSE_2", GF_CAUSE_2 },
313 {"GF_CAUSE_3", GF_CAUSE_3 },
314 {"GF_CAUSE_4", GF_CAUSE_4 },
315 {"GF_HAND_DOOM", GF_HAND_DOOM },
316 {"GF_CAPTURE", GF_CAPTURE },
317 {"GF_ANIM_DEAD", GF_ANIM_DEAD },
318 {"GF_CONTROL_LIVING", GF_CONTROL_LIVING },
319 {"GF_IDENTIFY", GF_IDENTIFY },
320 {"GF_ATTACK", GF_ATTACK },
321 {"GF_ENGETSU", GF_ENGETSU },
322 {"GF_GENOCIDE", GF_GENOCIDE },
323 {"GF_PHOTO", GF_PHOTO },
324 {"GF_CONTROL_DEMON", GF_CONTROL_DEMON },
325 {"GF_LAVA_FLOW", GF_LAVA_FLOW },
326 {"GF_BLOOD_CURSE", GF_BLOOD_CURSE },
327 {"GF_SEEKER", GF_SEEKER },
328 {"GF_SUPER_RAY", GF_SUPER_RAY },
329 {"GF_STAR_HEAL", GF_STAR_HEAL },
335 * Parse a sub-file of the "extra info" (format shown below)
337 * Each "action" line has an "action symbol" in the first column,
338 * followed by a colon, followed by some command specific info,
339 * usually in the form of "tokens" separated by colons or slashes.
341 * Blank lines, lines starting with white space, and lines starting
342 * with pound signs ("#") are ignored (as comments).
344 * Note the use of "tokenize()" to allow the use of both colons and
345 * slashes as delimeters, while still allowing final tokens which
346 * may contain any characters including "delimiters".
348 * Note the use of "strtol()" to allow all "integers" to be encoded
349 * in decimal, hexidecimal, or octal form.
351 * Note that "monster zero" is used for the "player" attr/char, "object
352 * zero" will be used for the "stack" attr/char, and "feature zero" is
353 * used for the "nothing" attr/char.
355 * Parse another file recursively, see below for details
358 * Specify the attr/char values for "monsters" by race index
361 * Specify the attr/char values for "objects" by kind index
364 * Specify the attr/char values for "features" by feature index
367 * Specify the attr/char values for unaware "objects" by kind tval
370 * Specify the attr/char values for inventory "objects" by kind tval
373 * Define a macro action, given an encoded macro action
376 * Create a normal macro, given an encoded macro trigger
379 * Create a command macro, given an encoded macro trigger
382 * Create a keyset mapping
383 * S:<key>:<key>:<dir>
385 * Turn an option off, given its name
388 * Turn an option on, given its name
391 * Specify visual information, given an index, and some data
392 * V:<num>:<kv>:<rv>:<gv>:<bv>
394 * Specify the set of colors to use when drawing a zapped spell
397 * Specify a macro trigger template and macro trigger names.
398 * T:<template>:<modifier chr>:<modifier name1>:<modifier name2>:...
399 * T:<trigger>:<keycode>:<shift-keycode>
403 errr process_pref_file_command(char *buf)
410 /* Require "?:*" format */
411 if (buf[1] != ':') return (1);
414 /* Process "%:<fname>" */
417 /* Attempt to Process the given file */
418 return (process_pref_file(buf + 2));
422 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
425 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
428 i = (huge)strtol(zz[0], NULL, 0);
429 n1 = strtol(zz[1], NULL, 0);
430 n2 = strtol(zz[2], NULL, 0);
431 if (i >= max_r_idx) return (1);
433 if (n1) r_ptr->x_attr = n1;
434 if (n2) r_ptr->x_char = n2;
439 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
440 else if (buf[0] == 'K')
442 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
445 i = (huge)strtol(zz[0], NULL, 0);
446 n1 = strtol(zz[1], NULL, 0);
447 n2 = strtol(zz[2], NULL, 0);
448 if (i >= max_k_idx) return (1);
450 if (n1) k_ptr->x_attr = n1;
451 if (n2) k_ptr->x_char = n2;
456 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
457 else if (buf[0] == 'F')
459 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
462 i = (huge)strtol(zz[0], NULL, 0);
463 n1 = strtol(zz[1], NULL, 0);
464 n2 = strtol(zz[2], NULL, 0);
465 if (i >= max_f_idx) return (1);
467 if (n1) f_ptr->x_attr = n1;
468 if (n2) f_ptr->x_char = n2;
473 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
474 else if (buf[0] == 'S')
476 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
478 j = (byte)strtol(zz[0], NULL, 0);
479 n1 = strtol(zz[1], NULL, 0);
480 n2 = strtol(zz[2], NULL, 0);
481 misc_to_attr[j] = n1;
482 misc_to_char[j] = n2;
487 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
488 else if (buf[0] == 'U')
490 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
492 j = (huge)strtol(zz[0], NULL, 0);
493 n1 = strtol(zz[1], NULL, 0);
494 n2 = strtol(zz[2], NULL, 0);
495 for (i = 1; i < max_k_idx; i++)
497 object_kind *k_ptr = &k_info[i];
498 if (k_ptr->tval == j)
500 if (n1) k_ptr->d_attr = n1;
501 if (n2) k_ptr->d_char = n2;
508 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
509 else if (buf[0] == 'E')
511 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
513 j = (byte)strtol(zz[0], NULL, 0) % 128;
514 n1 = strtol(zz[1], NULL, 0);
515 if (n1) tval_to_attr[j] = n1;
521 /* Process "A:<str>" -- save an "action" for later */
522 else if (buf[0] == 'A')
524 text_to_ascii(macro__buf, buf+2);
528 /* Process "P:<str>" -- normal macro */
529 else if (buf[0] == 'P')
532 text_to_ascii(tmp, buf+2);
533 macro_add(tmp, macro__buf);
538 /* Process "C:<str>" -- create keymap */
539 else if (buf[0] == 'C')
545 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return (1);
547 mode = strtol(zz[0], NULL, 0);
548 if ((mode < 0) || (mode >= KEYMAP_MODES)) return (1);
550 text_to_ascii(tmp, zz[1]);
551 if (!tmp[0] || tmp[1]) return (1);
554 string_free(keymap_act[mode][i]);
556 keymap_act[mode][i] = string_make(macro__buf);
562 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
563 else if (buf[0] == 'V')
565 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
567 i = (byte)strtol(zz[0], NULL, 0);
568 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
569 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
570 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
571 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
577 /* Process "X:<str>" -- turn option off */
578 else if (buf[0] == 'X')
580 for (i = 0; option_info[i].o_desc; i++)
582 int os = option_info[i].o_set;
583 int ob = option_info[i].o_bit;
585 if (option_info[i].o_var &&
586 option_info[i].o_text &&
587 streq(option_info[i].o_text, buf + 2) &&
588 (!alive || option_info[i].o_page !=6))
591 option_flag[os] &= ~(1L << ob);
592 (*option_info[i].o_var) = FALSE;
597 /* don't know that option. ignore it.*/
598 msg_format("Ignored wrong option %s.", buf+2);
603 /* Process "Y:<str>" -- turn option on */
604 else if (buf[0] == 'Y')
606 for (i = 0; option_info[i].o_desc; i++)
608 int os = option_info[i].o_set;
609 int ob = option_info[i].o_bit;
611 if (option_info[i].o_var &&
612 option_info[i].o_text &&
613 streq(option_info[i].o_text, buf + 2) &&
614 (!alive || option_info[i].o_page !=6))
617 option_flag[os] |= (1L << ob);
618 (*option_info[i].o_var) = TRUE;
623 /* don't know that option. ignore it.*/
624 msg_format("Ignored wrong option %s.", buf+2);
629 /* Process "Z:<type>:<str>" -- set spell color */
630 else if (buf[0] == 'Z')
633 char *t = strchr(buf + 2, ':');
641 for (i = 0; gf_desc[i].name; i++)
643 /* Match this type */
644 if (streq(gf_desc[i].name, buf + 2))
646 /* Remember this color set */
647 gf_color[gf_desc[i].num] = quark_add(t);
654 /* set macro trigger names and a template */
655 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
656 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
657 else if (buf[0] == 'T')
660 tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
666 if (macro_template != NULL)
668 free(macro_template);
669 macro_template = NULL;
670 for (i = 0; i < max_macrotrigger; i++)
671 free(macro_trigger_name[i]);
672 max_macrotrigger = 0;
675 if (*zz[0] == '\0') return 0; /* clear template */
677 if (2 + num != tok) return 1; /* error */
679 len = strlen(zz[0])+1+num+1;
680 for (i = 0; i < num; i++)
681 len += strlen(zz[2+i])+1;
682 macro_template = malloc(len);
684 strcpy(macro_template, zz[0]);
686 macro_template + strlen(macro_template) + 1;
687 strcpy(macro_modifier_chr, zz[1]);
688 macro_modifier_name[0] =
689 macro_modifier_chr + strlen(macro_modifier_chr) + 1;
690 for (i = 0; i < num; i++)
692 strcpy(macro_modifier_name[i], zz[2+i]);
693 macro_modifier_name[i+1] = macro_modifier_name[i] +
694 strlen(macro_modifier_name[i]) + 1;
701 if (max_macrotrigger >= MAX_MACRO_TRIG)
704 msg_print("¥Þ¥¯¥í¥È¥ê¥¬¡¼¤ÎÀßÄ꤬¿¤¹¤®¤Þ¤¹!");
706 msg_print("Too many macro triggers!");
710 m = max_macrotrigger;
713 len = strlen(zz[0]) + 1 + strlen(zz[1]) + 1;
715 len += strlen(zz[2]) + 1;
716 macro_trigger_name[m] = malloc(len);
718 t = macro_trigger_name[m];
727 macro_trigger_keycode[0][m] = macro_trigger_name[m] +
728 strlen(macro_trigger_name[m]) + 1;
729 strcpy(macro_trigger_keycode[0][m], zz[1]);
732 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m] +
733 strlen(macro_trigger_keycode[0][m]) + 1;
734 strcpy(macro_trigger_keycode[1][m], zz[2]);
738 macro_trigger_keycode[1][m] = macro_trigger_keycode[0][m];
750 * Helper function for "process_pref_file()"
753 * v: output buffer array
759 static cptr process_pref_file_expr(char **sp, char *fp)
776 while (isspace(*s)) s++;
794 t = process_pref_file_expr(&s, &f);
803 else if (streq(t, "IOR"))
806 while (*s && (f != b2))
808 t = process_pref_file_expr(&s, &f);
809 if (*t && !streq(t, "0")) v = "1";
814 else if (streq(t, "AND"))
817 while (*s && (f != b2))
819 t = process_pref_file_expr(&s, &f);
820 if (*t && streq(t, "0")) v = "0";
825 else if (streq(t, "NOT"))
828 while (*s && (f != b2))
830 t = process_pref_file_expr(&s, &f);
831 if (*t && streq(t, "1")) v = "0";
836 else if (streq(t, "EQU"))
841 t = process_pref_file_expr(&s, &f);
843 while (*s && (f != b2))
846 t = process_pref_file_expr(&s, &f);
847 if (*t && !streq(p, t)) v = "0";
852 else if (streq(t, "LEQ"))
857 t = process_pref_file_expr(&s, &f);
859 while (*s && (f != b2))
862 t = process_pref_file_expr(&s, &f);
863 if (*t && (strcmp(p, t) > 0)) v = "0";
868 else if (streq(t, "GEQ"))
873 t = process_pref_file_expr(&s, &f);
875 while (*s && (f != b2))
878 t = process_pref_file_expr(&s, &f);
879 if (*t && (strcmp(p, t) < 0)) v = "0";
886 while (*s && (f != b2))
888 t = process_pref_file_expr(&s, &f);
893 if (f != b2) v = "?x?x?";
895 /* Extract final and Terminate */
896 if ((f = *s) != '\0') *s++ = '\0';
902 /* Accept all printables except spaces and brackets */
903 while (isprint(*s) && !strchr(" []", *s)) ++s;
905 /* Extract final and Terminate */
906 if ((f = *s) != '\0') *s++ = '\0';
912 if (streq(b+1, "SYS"))
917 else if (streq(b+1, "KEYBOARD"))
919 v = ANGBAND_KEYBOARD;
923 else if (streq(b+1, "GRAF"))
928 /* Monochrome mode */
929 else if (streq(b+1, "MONOCHROME"))
938 else if (streq(b+1, "RACE"))
948 else if (streq(b+1, "CLASS"))
958 else if (streq(b+1, "PLAYER"))
964 else if (streq(b+1, "REALM1"))
967 v = E_realm_names[p_ptr->realm1];
969 v = realm_names[p_ptr->realm1];
974 else if (streq(b+1, "REALM2"))
977 v = E_realm_names[p_ptr->realm2];
979 v = realm_names[p_ptr->realm2];
984 else if (streq(b+1, "LEVEL"))
986 sprintf(tmp, "%02d", p_ptr->lev);
1011 * Process line for auto picker/destroyer.
1013 static errr process_pickpref_file_line(char *buf)
1019 /* Nuke illegal char */
1020 for(i = 0; buf[i]; i++)
1023 if (iskanji(buf[i]))
1029 if (isspace(buf[i]) && buf[i] != ' ')
1036 act = DO_AUTOPICK | DO_DISPLAY;
1041 act &= ~DO_AUTOPICK;
1042 act |= DO_AUTODESTROY;
1047 act &= ~DO_AUTOPICK;
1048 act |= DONT_AUTOPICK;
1060 /* don't mind upper or lower case */
1062 for (i = 0; s[i]; i++)
1072 s[i] = tolower(s[i]);
1074 /* Auto-inscription? */
1083 /* Skip empty line */
1086 if (max_autopick == MAX_AUTOPICK)
1089 /* Already has the same entry? */
1090 for(i = 0; i < max_autopick; i++)
1091 if(!strcmp(s, autopick_name[i]))
1094 autopick_name[max_autopick] = string_make(s);
1095 autopick_action[max_autopick] = act;
1097 autopick_insc[max_autopick] = string_make(s2);
1105 * Open the "user pref file" and parse it.
1107 static errr process_pref_file_aux(cptr name, bool read_pickpref)
1119 bool bypass = FALSE;
1123 fp = my_fopen(name, "r");
1126 if (!fp) return (-1);
1128 /* Process the file */
1129 while (0 == my_fgets(fp, buf, 1024))
1134 /* Skip "empty" lines */
1135 if (!buf[0]) continue;
1137 /* Skip "blank" lines */
1139 if (!iskanji(buf[0]))
1141 if (isspace(buf[0])) continue;
1144 if (buf[0] == '#') continue;
1151 /* Process "?:<expr>" */
1152 if ((buf[0] == '?') && (buf[1] == ':'))
1161 /* Parse the expr */
1162 v = process_pref_file_expr(&s, &f);
1165 bypass = (streq(v, "0") ? TRUE : FALSE);
1171 /* Apply conditionals */
1172 if (bypass) continue;
1175 /* Process "%:<file>" */
1178 /* Process that file if allowed */
1180 (void)process_pickpref_file(buf + 2);
1182 (void)process_pref_file(buf + 2);
1189 /* Process the line */
1190 err = process_pref_file_command(buf);
1192 /* This is not original pref line... */
1197 err = process_pickpref_file_line(buf);
1205 /* Print error message */
1206 /* ToDo: Add better error messages */
1208 msg_format("¥Õ¥¡¥¤¥ë'%s'¤Î%d¹Ô¤Ç¥¨¥é¡¼ÈÖ¹æ%d¤Î¥¨¥é¡¼¡£", name, line, err);
1209 msg_format("('%s'¤ò²òÀÏÃæ)", old);
1211 msg_format("Error %d in line %d of file '%s'.", err, line, name);
1212 msg_format("Parsing '%s'", old);
1217 /* Close the file */
1227 * Process the "user pref file" with the given name
1229 * See the functions above for a list of legal "commands".
1231 * We also accept the special "?" and "%" directives, which
1232 * allow conditional evaluation and filename inclusion.
1234 errr process_pref_file(cptr name)
1240 /* Build the filename */
1241 path_build(buf, 1024, ANGBAND_DIR_PREF, name);
1243 /* Process the pref file */
1244 err = process_pref_file_aux(buf, FALSE);
1246 /* Stop at parser errors, but not at non-existing file */
1252 /* Build the filename */
1253 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1255 /* Process the pref file */
1256 err = process_pref_file_aux(buf, FALSE);
1271 * Operating hours for ANGBAND (defaults to non-work hours)
1273 static char days[7][29] =
1275 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1276 "MON:XXXXXXXX.........XXXXXXX",
1277 "TUE:XXXXXXXX.........XXXXXXX",
1278 "WED:XXXXXXXX.........XXXXXXX",
1279 "THU:XXXXXXXX.........XXXXXXX",
1280 "FRI:XXXXXXXX.........XXXXXXX",
1281 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1285 * Restict usage (defaults to no restrictions)
1287 static bool check_time_flag = FALSE;
1295 errr check_time(void)
1303 /* No restrictions */
1304 if (!check_time_flag) return (0);
1306 /* Check for time violation */
1307 c = time((time_t *)0);
1311 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1322 * Initialize CHECK_TIME
1324 errr check_time_init(void)
1334 /* Build the filename */
1335 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1338 fp = my_fopen(buf, "r");
1340 /* No file, no restrictions */
1341 if (!fp) return (0);
1343 /* Assume restrictions */
1344 check_time_flag = TRUE;
1346 /* Parse the file */
1347 while (0 == my_fgets(fp, buf, 80))
1349 /* Skip comments and blank lines */
1350 if (!buf[0] || (buf[0] == '#')) continue;
1352 /* Chop the buffer */
1355 /* Extract the info */
1356 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1357 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1358 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1359 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1360 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1361 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1362 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1378 #ifndef MAXHOSTNAMELEN
1379 # define MAXHOSTNAMELEN 64
1382 typedef struct statstime statstime;
1388 unsigned int v_pgpgin;
1389 unsigned int v_pgpgout;
1390 unsigned int v_pswpin;
1391 unsigned int v_pswpout;
1392 unsigned int v_intr;
1398 unsigned int v_swtch;
1400 struct timeval boottime;
1401 struct timeval curtime;
1405 * Maximal load (if any).
1407 static int check_load_value = 0;
1415 errr check_load(void)
1420 struct statstime st;
1422 /* Success if not checking */
1423 if (!check_load_value) return (0);
1425 /* Check the load */
1426 if (0 == rstat("localhost", &st))
1428 long val1 = (long)(st.avenrun[2]);
1429 long val2 = (long)(check_load_value) * FSCALE;
1431 /* Check for violation */
1432 if (val1 >= val2) return (1);
1443 * Initialize CHECK_LOAD
1445 errr check_load_init(void)
1454 char temphost[MAXHOSTNAMELEN+1];
1455 char thishost[MAXHOSTNAMELEN+1];
1458 /* Build the filename */
1459 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1461 /* Open the "load" file */
1462 fp = my_fopen(buf, "r");
1464 /* No file, no restrictions */
1465 if (!fp) return (0);
1468 check_load_value = 100;
1470 /* Get the host name */
1471 (void)gethostname(thishost, (sizeof thishost) - 1);
1474 while (0 == my_fgets(fp, buf, 1024))
1478 /* Skip comments and blank lines */
1479 if (!buf[0] || (buf[0] == '#')) continue;
1481 /* Parse, or ignore */
1482 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1484 /* Skip other hosts */
1485 if (!streq(temphost, thishost) &&
1486 !streq(temphost, "localhost")) continue;
1488 /* Use that value */
1489 check_load_value = value;
1495 /* Close the file */
1505 #define ENTRY_BARE_HAND 0
1506 #define ENTRY_TWO_HANDS 1
1507 #define ENTRY_RIGHT_HAND1 2
1508 #define ENTRY_LEFT_HAND1 3
1509 #define ENTRY_LEFT_HAND2 4
1510 #define ENTRY_RIGHT_HAND2 5
1511 #define ENTRY_POSTURE 6
1512 #define ENTRY_SHOOT_HIT_DAM 7
1513 #define ENTRY_SHOOT_POWER 8
1514 #define ENTRY_SPEED 9
1515 #define ENTRY_BASE_AC 10
1516 #define ENTRY_LEVEL 11
1517 #define ENTRY_CUR_EXP 12
1518 #define ENTRY_MAX_EXP 13
1519 #define ENTRY_EXP_TO_ADV 14
1520 #define ENTRY_GOLD 15
1521 #define ENTRY_DAY 16
1524 #define ENTRY_PLAY_TIME 19
1525 #define ENTRY_SKILL_FIGHT 20
1526 #define ENTRY_SKILL_SHOOT 21
1527 #define ENTRY_SKILL_SAVING 22
1528 #define ENTRY_SKILL_STEALTH 23
1529 #define ENTRY_SKILL_PERCEP 24
1530 #define ENTRY_SKILL_SEARCH 25
1531 #define ENTRY_SKILL_DISARM 26
1532 #define ENTRY_SKILL_DEVICE 27
1533 #define ENTRY_BLOWS 28
1534 #define ENTRY_SHOTS 29
1535 #define ENTRY_AVG_DMG 30
1536 #define ENTRY_INFRA 31
1538 #define ENTRY_NAME 32
1539 #define ENTRY_SEX 33
1540 #define ENTRY_RACE 34
1541 #define ENTRY_CLASS 35
1542 #define ENTRY_REALM 36
1543 #define ENTRY_PATRON 37
1544 #define ENTRY_AGE 38
1545 #define ENTRY_HEIGHT 39
1546 #define ENTRY_WEIGHT 40
1547 #define ENTRY_SOCIAL 41
1548 #define ENTRY_ALIGN 42
1557 } disp_player_line[]
1560 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1561 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1562 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1563 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1564 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1565 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1567 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1568 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1569 {01, 20, 25, "²Ã®"},
1570 { 1, 19, 25, "£Á£Ã"},
1571 {29, 13, 21, "¥ì¥Ù¥ë"},
1572 {29, 14, 21, "·Ð¸³ÃÍ"},
1573 {29, 15, 21, "ºÇÂç·Ð¸³"},
1574 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1575 {29, 17, 21, "½ê»ý¶â"},
1576 {29, 19, 21, "ÆüÉÕ"},
1577 {29, 10, 21, "£È£Ð"},
1578 {29, 11, 21, "£Í£Ð"},
1579 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1580 {54, 10, -1, "ÂǷ⹶·â :"},
1581 {54, 11, -1, "¼Í·â¹¶·â :"},
1582 {54, 12, -1, "ËâË¡Ëɸæ :"},
1583 {54, 13, -1, "±£Ì©¹ÔÆ° :"},
1584 {54, 15, -1, "ÃγР:"},
1585 {54, 16, -1, "õº÷ :"},
1586 {54, 17, -1, "²ò½ü :"},
1587 {54, 18, -1, "ËâË¡Æ»¶ñ :"},
1588 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1589 {01, 17, 25, "¼Í·â²ó¿ô"},
1590 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1591 {54, 20, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1592 {26, 1, -1, "̾Á° : "},
1593 { 1, 3, -1, "ÀÊÌ : "},
1594 { 1, 4, -1, "¼ï² : "},
1595 { 1, 5, -1, "¿¦¶È : "},
1596 { 1, 6, -1, "ËâË¡ : "},
1597 { 1, 7, -1, "¼é¸îËâ¿À : "},
1598 {29, 3, 21, "ǯÎð"},
1599 {29, 4, 21, "¿ÈĹ"},
1600 {29, 5, 21, "ÂνÅ"},
1601 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1602 {29, 7, 21, "°À"},
1606 { 1, 10, 25, "Bare hand"},
1607 { 1, 10, 25, "Two hands"},
1608 { 1, 10, 25, "Right hand"},
1609 { 1, 10, 25, "Left hand"},
1610 { 1, 11, 25, "Left hand"},
1611 { 1, 11, 25, "Right hand"},
1612 { 1, 11, 25, "Posture"},
1613 { 1, 15, 25, "Shooting"},
1614 { 1, 16, 25, "Multiplier"},
1615 {01, 20, 25, "Speed"},
1617 {29, 13, 21, "Level"},
1618 {29, 14, 21, "Experience"},
1619 {29, 15, 21, "Max Exp"},
1620 {29, 16, 21, "Exp to Adv"},
1621 {29, 17, 21, "Gold"},
1622 {29, 19, 21, "Time"},
1623 {29, 10, 21, "Hit point"},
1624 {29, 11, 21, "SP (Mana)"},
1625 {29, 20, 21, "Play time"},
1626 {54, 10, -1, "Fighting : "},
1627 {54, 11, -1, "Bows/Throw : "},
1628 {54, 12, -1, "Saving Throw: "},
1629 {54, 13, -1, "Stealth : "},
1630 {54, 15, -1, "Perception : "},
1631 {54, 16, -1, "Searching : "},
1632 {54, 17, -1, "Disarming : "},
1633 {54, 18, -1, "Magic Device: "},
1634 {01, 12, 25, "Blows/Round"},
1635 {01, 17, 25, "Shots/Round"},
1636 {01, 13, 25, "AverageDmg/Rnd"},
1637 {54, 20, -1, "Infra-Vision: "},
1638 {26, 1, -1, "Name : "},
1639 { 1, 3, -1, "Sex : "},
1640 { 1, 4, -1, "Race : "},
1641 { 1, 5, -1, "Class : "},
1642 { 1, 6, -1, "Magic : "},
1643 { 1, 7, -1, "Patron : "},
1645 {29, 4, 21, "Height"},
1646 {29, 5, 21, "Weight"},
1647 {29, 6, 21, "Social Class"},
1648 {29, 7, 21, "Align"},
1652 static void display_player_one_line(int entry, cptr val, byte attr)
1656 int row = disp_player_line[entry].row;
1657 int col = disp_player_line[entry].col;
1658 int len = disp_player_line[entry].len;
1659 cptr head = disp_player_line[entry].header;
1661 int head_len = strlen(head);
1663 Term_putstr(col, row, -1, TERM_WHITE, head);
1670 int val_len = len - head_len;
1671 sprintf(buf, "%*.*s", val_len, val_len, val);
1672 Term_putstr(col + head_len, row, -1, attr, buf);
1676 Term_putstr(col + head_len, row, -1, attr, val);
1684 * Prints the following information on the screen.
1686 static void display_player_middle(void)
1689 int show_tohit, show_todam;
1695 show_tohit = p_ptr->dis_to_h[0];
1696 show_todam = p_ptr->dis_to_d[0];
1698 o_ptr = &inventory[INVEN_RARM];
1700 /* Hack -- add in weapon info if known */
1701 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1702 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1705 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1707 /* Dump the bonuses to hit/dam */
1708 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1709 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1710 else if(p_ptr->ryoute)
1711 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1712 else if (left_hander)
1713 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1715 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1720 show_tohit = p_ptr->dis_to_h[1];
1721 show_todam = p_ptr->dis_to_d[1];
1723 o_ptr = &inventory[INVEN_LARM];
1725 /* Hack -- add in weapon info if known */
1726 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1727 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1730 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1732 /* Dump the bonuses to hit/dam */
1734 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1736 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1738 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1741 if (p_ptr->special_defense & KAMAE_MASK)
1743 for (i = 0; i < MAX_KAMAE; i++)
1745 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1749 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1751 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1756 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1758 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1763 o_ptr = &inventory[INVEN_BOW];
1766 show_tohit = p_ptr->dis_to_h_b;
1769 /* Apply weapon bonuses */
1770 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1771 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1773 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1776 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1778 if (inventory[INVEN_BOW].k_idx)
1780 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1782 /* Get extra "power" from "extra might" */
1783 if (p_ptr->xtra_might) tmul++;
1785 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1789 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1791 /* Dump the armor class */
1792 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1796 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1801 i = p_ptr->pspeed-110;
1803 /* Hack -- Visually "undo" the Search Mode Slowdown */
1804 if (p_ptr->action == ACTION_SEARCH) i += 10;
1807 attr = TERM_L_GREEN;
1811 attr = TERM_L_UMBER;
1813 if (is_fast) tmp_speed += 10;
1814 if (p_ptr->slow) tmp_speed -= 10;
1815 if (p_ptr->lightspeed) tmp_speed = 99;
1819 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1827 sprintf(buf, "(%+d)", i);
1830 display_player_one_line(ENTRY_SPEED, buf, attr);
1833 /* Dump character level */
1834 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1836 /* Dump experience */
1837 if (p_ptr->prace == RACE_ANDROID)
1838 display_player_one_line(ENTRY_CUR_EXP, "*****", TERM_L_GREEN);
1839 else if (p_ptr->exp >= p_ptr->max_exp)
1840 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_L_GREEN);
1842 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_YELLOW);
1844 /* Dump max experience */
1845 if (p_ptr->prace == RACE_ANDROID)
1846 display_player_one_line(ENTRY_MAX_EXP, "*****", TERM_L_GREEN);
1848 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1850 /* Dump exp to advance */
1851 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1852 display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
1854 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1857 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1861 s32b len = 20L * TOWN_DAWN;
1862 s32b tick = turn % len + len / 4;
1866 "%2ldÆüÌÜ %ld:%02ld",
1868 "Day %ld %ld:%02ld",
1870 ((p_ptr->prace == RACE_VAMPIRE) ||
1871 (p_ptr->prace == RACE_SKELETON) ||
1872 (p_ptr->prace == RACE_ZOMBIE) ||
1873 (p_ptr->prace == RACE_SPECTRE))
1874 ? (turn - (15L * TOWN_DAWN)) / len + 1
1875 : (turn + (5L * TOWN_DAWN))/ len + 1,
1876 (24 * tick / len) % 24,
1877 (1440 * tick / len) % 60);
1879 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1881 /* Dump hit point */
1882 if (p_ptr->chp >= p_ptr->mhp)
1883 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1884 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1885 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1887 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1889 /* Dump mana power */
1890 if (p_ptr->csp >= p_ptr->msp)
1891 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1892 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1893 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1895 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1897 /* Dump play time */
1898 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1903 * Hack -- pass color info around this file
1905 static byte likert_color = TERM_WHITE;
1909 * Returns a "rating" of x depending on y
1911 static cptr likert(int x, int y)
1913 static char dummy[20] = "";
1918 /* Negative value */
1921 likert_color = TERM_L_DARK;
1925 return ("Very Bad");
1930 /* Analyze the value */
1936 likert_color = TERM_RED;
1946 likert_color = TERM_L_RED;
1957 likert_color = TERM_ORANGE;
1967 likert_color = TERM_YELLOW;
1977 likert_color = TERM_YELLOW;
1979 return ("ÂçÊÑÎɤ¤");
1981 return ("Very Good");
1988 likert_color = TERM_L_GREEN;
1992 return ("Excellent");
2002 likert_color = TERM_GREEN;
2015 likert_color = TERM_BLUE;
2017 return ("¥«¥ª¥¹¥é¥ó¥¯");
2019 return ("Chaos Rank");
2025 likert_color = TERM_VIOLET;
2027 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2029 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2039 * Prints ratings on certain abilities
2041 * This code is "imitated" elsewhere to "dump" a character sheet.
2043 static void display_player_various(void)
2045 int tmp, damage[2], blows1, blows2, i, basedam;
2046 int xthn, xthb, xfos, xsrh;
2047 int xdis, xdev, xsav, xstl;
2051 int shots, shot_frac;
2055 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2056 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2057 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2058 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2059 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2061 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2063 /* Shooting Skill (with current bow and normal missile) */
2064 o_ptr = &inventory[INVEN_BOW];
2065 tmp = p_ptr->to_h_b + o_ptr->to_h;
2066 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2068 /* If the player is wielding one? */
2071 s16b energy_fire = bow_energy(o_ptr->sval);
2073 /* Calculate shots per round */
2074 shots = p_ptr->num_fire * 100;
2075 shot_frac = (shots * 100 / energy_fire) % 100;
2076 shots = shots / energy_fire;
2077 if (o_ptr->name1 == ART_CRIMSON)
2081 if (p_ptr->pclass == CLASS_ARCHER)
2083 /* Extra shot at level 10 */
2084 if (p_ptr->lev >= 10) shots++;
2086 /* Extra shot at level 30 */
2087 if (p_ptr->lev >= 30) shots++;
2089 /* Extra shot at level 45 */
2090 if (p_ptr->lev >= 45) shots++;
2100 for(i = 0; i< 2; i++)
2102 damage[i] = p_ptr->dis_to_d[i]*100;
2103 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2105 int level = p_ptr->lev;
2111 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2112 if (p_ptr->special_defense & KAMAE_BYAKKO)
2113 basedam = monk_ave_damage[level][1];
2114 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2115 basedam = monk_ave_damage[level][2];
2117 basedam = monk_ave_damage[level][0];
2121 /* Average damage per round */
2122 o_ptr = &inventory[INVEN_RARM+i];
2123 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2124 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2125 object_flags(o_ptr, &f1, &f2, &f3);
2126 if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
2132 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2134 /* vorpal flag only */
2138 if (object_known_p(o_ptr) && (p_ptr->pclass != CLASS_SAMURAI) && (f1 & TR1_FORCE_WEPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2139 basedam = basedam * 7 / 2;
2140 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2141 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2143 damage[i] += basedam;
2144 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2145 if (damage[i] < 0) damage[i] = 0;
2147 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2148 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2150 /* Basic abilities */
2152 xdis = p_ptr->skill_dis;
2153 xdev = p_ptr->skill_dev;
2154 xsav = p_ptr->skill_sav;
2155 xstl = p_ptr->skill_stl;
2156 xsrh = p_ptr->skill_srh;
2157 xfos = p_ptr->skill_fos;
2160 desc = likert(xthn, 12);
2161 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2163 desc = likert(xthb, 12);
2164 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2166 desc = likert(xsav, 7);
2167 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2169 desc = likert(xstl, 1);
2170 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2172 desc = likert(xfos, 6);
2173 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2175 desc = likert(xsrh, 6);
2176 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2178 desc = likert(xdis, 8);
2179 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2181 desc = likert(xdev, 6);
2182 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2185 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2187 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2189 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2192 if ((damage[0]+damage[1]) == 0)
2195 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2197 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2199 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2205 * Obtain the "flags" for the player as if he was an item
2207 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2210 (*f1) = (*f2) = (*f3) = 0L;
2213 switch (p_ptr->pclass)
2216 if (p_ptr->lev > 44)
2217 (*f3) |= (TR3_REGEN);
2219 if (p_ptr->lev > 29)
2220 (*f2) |= (TR2_RES_FEAR);
2223 if (p_ptr->lev > 39)
2224 (*f2) |= (TR2_RES_FEAR);
2226 case CLASS_CHAOS_WARRIOR:
2227 if (p_ptr->lev > 29)
2228 (*f2) |= (TR2_RES_CHAOS);
2229 if (p_ptr->lev > 39)
2230 (*f2) |= (TR2_RES_FEAR);
2233 case CLASS_FORCETRAINER:
2234 if ((p_ptr->lev > 9) && !heavy_armor())
2236 if ((p_ptr->lev>24) && !heavy_armor())
2237 (*f2) |= (TR2_FREE_ACT);
2244 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2247 (*f2) |= (TR2_FREE_ACT);
2249 (*f3) |= TR3_SLOW_DIGEST;
2250 (*f2) |= TR2_RES_FEAR;
2251 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2252 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2253 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2255 case CLASS_MINDCRAFTER:
2257 (*f2) |= (TR2_RES_FEAR);
2258 if (p_ptr->lev > 19)
2259 (*f2) |= (TR2_SUST_WIS);
2260 if (p_ptr->lev > 29)
2261 (*f2) |= (TR2_RES_CONF);
2262 if (p_ptr->lev > 39)
2263 (*f3) |= (TR3_TELEPATHY);
2266 (*f2) |= (TR2_RES_SOUND);
2268 case CLASS_BERSERKER:
2269 (*f2) |= (TR2_SUST_STR);
2270 (*f2) |= (TR2_SUST_DEX);
2271 (*f2) |= (TR2_SUST_CON);
2272 (*f3) |= (TR3_REGEN);
2273 (*f2) |= (TR2_FREE_ACT);
2274 (*f1) |= (TR1_SPEED);
2275 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2277 case CLASS_MIRROR_MASTER:
2278 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2281 break; /* Do nothing */
2285 if (p_ptr->mimic_form)
2287 switch(p_ptr->mimic_form)
2290 (*f2) |= (TR2_HOLD_LIFE);
2291 (*f2) |= (TR2_RES_CHAOS);
2292 (*f2) |= (TR2_RES_NETHER);
2293 (*f2) |= (TR2_RES_FIRE);
2294 (*f3) |= (TR3_SEE_INVIS);
2295 (*f1) |= (TR1_SPEED);
2297 case MIMIC_DEMON_LORD:
2298 (*f2) |= (TR2_HOLD_LIFE);
2299 (*f2) |= (TR2_RES_CHAOS);
2300 (*f2) |= (TR2_RES_NETHER);
2301 (*f2) |= (TR2_RES_FIRE);
2302 (*f2) |= (TR2_RES_COLD);
2303 (*f2) |= (TR2_RES_ELEC);
2304 (*f2) |= (TR2_RES_ACID);
2305 (*f2) |= (TR2_RES_POIS);
2306 (*f2) |= (TR2_RES_CONF);
2307 (*f2) |= (TR2_RES_DISEN);
2308 (*f2) |= (TR2_RES_NEXUS);
2309 (*f2) |= (TR2_RES_FEAR);
2310 (*f2) |= (TR2_IM_FIRE);
2311 (*f3) |= (TR3_SH_FIRE);
2312 (*f3) |= (TR3_SEE_INVIS);
2313 (*f3) |= (TR3_TELEPATHY);
2314 (*f3) |= (TR3_FEATHER);
2315 (*f1) |= (TR1_SPEED);
2318 (*f2) |= (TR2_HOLD_LIFE);
2319 (*f2) |= (TR2_RES_DARK);
2320 (*f2) |= (TR2_RES_NETHER);
2321 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2322 (*f2) |= (TR2_RES_POIS);
2323 (*f2) |= (TR2_RES_COLD);
2324 (*f3) |= (TR3_SEE_INVIS);
2325 (*f1) |= (TR1_SPEED);
2331 switch (p_ptr->prace)
2334 (*f2) |= (TR2_RES_LITE);
2337 (*f2) |= (TR2_SUST_DEX);
2340 (*f2) |= (TR2_FREE_ACT);
2343 (*f2) |= (TR2_RES_BLIND);
2346 (*f2) |= (TR2_RES_DARK);
2348 case RACE_HALF_TROLL:
2349 (*f2) |= (TR2_SUST_STR);
2350 if (p_ptr->lev > 14)
2352 (*f3) |= (TR3_REGEN);
2353 if (p_ptr->pclass == CLASS_WARRIOR)
2355 (*f3) |= (TR3_SLOW_DIGEST);
2357 * Let's not make Regeneration a disadvantage
2358 * for the poor warriors who can never learn
2359 * a spell that satisfies hunger (actually
2360 * neither can rogues, but half-trolls are not
2361 * supposed to play rogues)
2367 (*f2) |= (TR2_SUST_CON);
2368 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2371 (*f2) |= (TR2_RES_LITE);
2372 (*f3) |= (TR3_SEE_INVIS);
2374 case RACE_BARBARIAN:
2375 (*f2) |= (TR2_RES_FEAR);
2377 case RACE_HALF_OGRE:
2378 (*f2) |= (TR2_SUST_STR);
2379 (*f2) |= (TR2_RES_DARK);
2381 case RACE_HALF_GIANT:
2382 (*f2) |= (TR2_RES_SHARDS);
2383 (*f2) |= (TR2_SUST_STR);
2385 case RACE_HALF_TITAN:
2386 (*f2) |= (TR2_RES_CHAOS);
2389 (*f2) |= (TR2_RES_SOUND);
2392 (*f2) |= (TR2_RES_ACID);
2393 if (p_ptr->lev > 19)
2394 (*f2) |= (TR2_IM_ACID);
2397 (*f2) |= (TR2_RES_CONF);
2398 (*f2) |= (TR2_RES_ACID);
2403 (*f2) |= (TR2_RES_POIS);
2406 (*f2) |= (TR2_RES_DISEN);
2407 (*f2) |= (TR2_RES_DARK);
2410 (*f2) |= (TR2_RES_DARK);
2411 if (p_ptr->lev > 19)
2412 (*f3) |= (TR3_SEE_INVIS);
2414 case RACE_DRACONIAN:
2415 (*f3) |= TR3_FEATHER;
2417 (*f2) |= (TR2_RES_FIRE);
2419 (*f2) |= (TR2_RES_COLD);
2420 if (p_ptr->lev > 14)
2421 (*f2) |= (TR2_RES_ACID);
2422 if (p_ptr->lev > 19)
2423 (*f2) |= (TR2_RES_ELEC);
2424 if (p_ptr->lev > 34)
2425 (*f2) |= (TR2_RES_POIS);
2427 case RACE_MIND_FLAYER:
2428 (*f2) |= (TR2_SUST_INT);
2429 (*f2) |= (TR2_SUST_WIS);
2430 if (p_ptr->lev > 14)
2431 (*f3) |= (TR3_SEE_INVIS);
2432 if (p_ptr->lev > 29)
2433 (*f3) |= (TR3_TELEPATHY);
2436 (*f2) |= (TR2_RES_FIRE);
2438 (*f3) |= (TR3_SEE_INVIS);
2441 (*f3) |= (TR3_SEE_INVIS);
2442 (*f2) |= (TR2_FREE_ACT);
2443 (*f2) |= (TR2_RES_POIS);
2444 (*f3) |= (TR3_SLOW_DIGEST);
2445 if (p_ptr->lev > 34)
2446 (*f2) |= (TR2_HOLD_LIFE);
2449 (*f3) |= (TR3_SEE_INVIS);
2450 (*f2) |= (TR2_RES_SHARDS);
2451 (*f2) |= (TR2_HOLD_LIFE);
2452 (*f2) |= (TR2_RES_POIS);
2454 (*f2) |= (TR2_RES_COLD);
2457 (*f3) |= (TR3_SEE_INVIS);
2458 (*f2) |= (TR2_HOLD_LIFE);
2459 (*f2) |= (TR2_RES_NETHER);
2460 (*f2) |= (TR2_RES_POIS);
2461 (*f3) |= (TR3_SLOW_DIGEST);
2463 (*f2) |= (TR2_RES_COLD);
2466 (*f2) |= (TR2_HOLD_LIFE);
2467 (*f2) |= (TR2_RES_DARK);
2468 (*f2) |= (TR2_RES_NETHER);
2469 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2470 (*f2) |= (TR2_RES_POIS);
2471 (*f2) |= (TR2_RES_COLD);
2474 (*f3) |= (TR3_FEATHER);
2475 (*f2) |= (TR2_FREE_ACT);
2476 (*f2) |= (TR2_RES_COLD);
2477 (*f3) |= (TR3_SEE_INVIS);
2478 (*f2) |= (TR2_HOLD_LIFE);
2479 (*f2) |= (TR2_RES_NETHER);
2480 (*f2) |= (TR2_RES_POIS);
2481 (*f3) |= (TR3_SLOW_DIGEST);
2483 if (p_ptr->lev > 34)
2484 (*f3) |= TR3_TELEPATHY;
2487 (*f2) |= (TR2_RES_LITE);
2488 (*f3) |= (TR3_FEATHER);
2490 (*f1) |= (TR1_SPEED);
2493 (*f2) |= (TR2_RES_SOUND);
2494 (*f2) |= (TR2_RES_CONF);
2497 (*f3) |= (TR3_FEATHER);
2498 (*f3) |= (TR3_SEE_INVIS);
2501 (*f2) |= (TR2_RES_FIRE);
2502 (*f2) |= (TR2_RES_NETHER);
2503 (*f2) |= (TR2_HOLD_LIFE);
2505 (*f3) |= (TR3_SEE_INVIS);
2508 (*f2) |= (TR2_SUST_CON);
2511 (*f3) |= (TR3_FEATHER);
2514 (*f2) |= (TR2_RES_CONF);
2517 (*f2) |= (TR2_FREE_ACT);
2518 (*f2) |= (TR2_RES_POIS);
2519 (*f3) |= (TR3_SLOW_DIGEST);
2520 (*f2) |= (TR2_HOLD_LIFE);
2530 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2532 (*f3) &= ~(TR3_REGEN);
2535 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2536 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2537 (p_ptr->muta3 & MUT3_SHORT_LEG))
2542 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2544 (*f3) |= TR3_SH_ELEC;
2547 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2549 (*f3) |= TR3_SH_FIRE;
2553 if (p_ptr->muta3 & MUT3_WINGS)
2555 (*f3) |= TR3_FEATHER;
2558 if (p_ptr->muta3 & MUT3_FEARLESS)
2560 (*f2) |= (TR2_RES_FEAR);
2563 if (p_ptr->muta3 & MUT3_REGEN)
2568 if (p_ptr->muta3 & MUT3_ESP)
2570 (*f3) |= TR3_TELEPATHY;
2573 if (p_ptr->muta3 & MUT3_MOTION)
2575 (*f2) |= TR2_FREE_ACT;
2579 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2580 (*f3) |= TR3_AGGRAVATE;
2581 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2583 (*f2) |= (TR2_RES_BLIND);
2584 (*f2) |= (TR2_RES_CONF);
2585 (*f2) |= (TR2_HOLD_LIFE);
2586 (*f3) |= (TR3_LITE);
2588 (*f1) |= (TR1_SPEED);
2590 if (p_ptr->special_defense & KATA_FUUJIN)
2591 (*f2) |= TR2_REFLECT;
2592 if (p_ptr->special_defense & KAMAE_GENBU)
2593 (*f2) |= TR2_REFLECT;
2594 if (p_ptr->special_defense & KAMAE_SUZAKU)
2595 (*f3) |= TR3_FEATHER;
2596 if (p_ptr->special_defense & KAMAE_SEIRYU)
2598 (*f2) |= (TR2_RES_FIRE);
2599 (*f2) |= (TR2_RES_COLD);
2600 (*f2) |= (TR2_RES_ACID);
2601 (*f2) |= (TR2_RES_ELEC);
2602 (*f2) |= (TR2_RES_POIS);
2603 (*f3) |= (TR3_FEATHER);
2604 (*f3) |= (TR3_SH_FIRE);
2605 (*f3) |= (TR3_SH_ELEC);
2606 (*f3) |= (TR3_SH_COLD);
2608 if (p_ptr->special_defense & KATA_MUSOU)
2610 (*f2) |= TR2_RES_FEAR;
2611 (*f2) |= TR2_RES_LITE;
2612 (*f2) |= TR2_RES_DARK;
2613 (*f2) |= TR2_RES_BLIND;
2614 (*f2) |= TR2_RES_CONF;
2615 (*f2) |= TR2_RES_SOUND;
2616 (*f2) |= TR2_RES_SHARDS;
2617 (*f2) |= TR2_RES_NETHER;
2618 (*f2) |= TR2_RES_NEXUS;
2619 (*f2) |= TR2_RES_CHAOS;
2620 (*f2) |= TR2_RES_DISEN;
2621 (*f2) |= TR2_REFLECT;
2622 (*f2) |= TR2_HOLD_LIFE;
2623 (*f2) |= TR2_FREE_ACT;
2624 (*f3) |= TR3_SH_FIRE;
2625 (*f3) |= TR3_SH_ELEC;
2626 (*f3) |= TR3_SH_COLD;
2627 (*f3) |= TR3_FEATHER;
2629 (*f3) |= TR3_SEE_INVIS;
2630 (*f3) |= TR3_TELEPATHY;
2631 (*f3) |= TR3_SLOW_DIGEST;
2633 (*f2) |= (TR2_SUST_STR);
2634 (*f2) |= (TR2_SUST_INT);
2635 (*f2) |= (TR2_SUST_WIS);
2636 (*f2) |= (TR2_SUST_DEX);
2637 (*f2) |= (TR2_SUST_CON);
2638 (*f2) |= (TR2_SUST_CHR);
2643 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2646 (*f1) = (*f2) = (*f3) = 0L;
2648 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2649 (*f2) |= TR2_RES_FEAR;
2650 if (p_ptr->tim_invis)
2651 (*f3) |= TR3_SEE_INVIS;
2652 if (p_ptr->tim_regen)
2654 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2655 (*f3) |= TR3_TELEPATHY;
2656 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2658 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2660 (*f2) |= (TR2_RES_FIRE);
2661 (*f2) |= (TR2_RES_COLD);
2662 (*f2) |= (TR2_RES_ACID);
2663 (*f2) |= (TR2_RES_ELEC);
2664 (*f2) |= (TR2_RES_POIS);
2668 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2669 (*f2) |= TR2_RES_ACID;
2670 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2671 (*f2) |= TR2_RES_ELEC;
2672 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2673 (*f2) |= TR2_RES_FIRE;
2674 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2675 (*f2) |= TR2_RES_COLD;
2679 if (p_ptr->oppose_acid)
2680 (*f2) |= TR2_RES_ACID;
2681 if (p_ptr->oppose_elec)
2682 (*f2) |= TR2_RES_ELEC;
2683 if (p_ptr->oppose_fire)
2684 (*f2) |= TR2_RES_FIRE;
2685 if (p_ptr->oppose_cold)
2686 (*f2) |= TR2_RES_COLD;
2688 if (p_ptr->oppose_pois)
2689 (*f2) |= TR2_RES_POIS;
2690 if (p_ptr->special_attack & ATTACK_ACID)
2691 (*f1) |= TR1_BRAND_ACID;
2692 if (p_ptr->special_attack & ATTACK_ELEC)
2693 (*f1) |= TR1_BRAND_ELEC;
2694 if (p_ptr->special_attack & ATTACK_FIRE)
2695 (*f1) |= TR1_BRAND_FIRE;
2696 if (p_ptr->special_attack & ATTACK_COLD)
2697 (*f1) |= TR1_BRAND_COLD;
2698 if (p_ptr->special_attack & ATTACK_POIS)
2699 (*f1) |= TR1_BRAND_POIS;
2700 if (p_ptr->special_defense & DEFENSE_ACID)
2701 (*f2) |= TR2_IM_ACID;
2702 if (p_ptr->special_defense & DEFENSE_ELEC)
2703 (*f2) |= TR2_IM_ELEC;
2704 if (p_ptr->special_defense & DEFENSE_FIRE)
2705 (*f2) |= TR2_IM_FIRE;
2706 if (p_ptr->special_defense & DEFENSE_COLD)
2707 (*f2) |= TR2_IM_COLD;
2708 if (p_ptr->wraith_form)
2709 (*f2) |= TR2_REFLECT;
2711 if (p_ptr->tim_reflect){
2712 (*f2) |= TR2_REFLECT;
2715 if (p_ptr->magicdef)
2717 (*f2) |= TR2_RES_BLIND;
2718 (*f2) |= TR2_RES_CONF;
2719 (*f2) |= TR2_REFLECT;
2720 (*f2) |= TR2_FREE_ACT;
2721 (*f3) |= TR3_FEATHER;
2723 if (p_ptr->tim_res_nether)
2725 (*f2) |= TR2_RES_NETHER;
2727 if (p_ptr->tim_sh_fire)
2729 (*f3) |= TR3_SH_FIRE;
2733 (*f2) |= TR2_RES_FEAR;
2734 (*f2) |= TR2_RES_LITE;
2735 (*f2) |= TR2_RES_DARK;
2736 (*f2) |= TR2_RES_BLIND;
2737 (*f2) |= TR2_RES_CONF;
2738 (*f2) |= TR2_RES_SOUND;
2739 (*f2) |= TR2_RES_SHARDS;
2740 (*f2) |= TR2_RES_NETHER;
2741 (*f2) |= TR2_RES_NEXUS;
2742 (*f2) |= TR2_RES_CHAOS;
2743 (*f2) |= TR2_RES_DISEN;
2744 (*f2) |= TR2_REFLECT;
2745 (*f2) |= TR2_HOLD_LIFE;
2746 (*f2) |= TR2_FREE_ACT;
2747 (*f3) |= TR3_SH_FIRE;
2748 (*f3) |= TR3_SH_ELEC;
2749 (*f3) |= TR3_SH_COLD;
2750 (*f3) |= TR3_FEATHER;
2752 (*f3) |= TR3_SEE_INVIS;
2753 (*f3) |= TR3_TELEPATHY;
2754 (*f3) |= TR3_SLOW_DIGEST;
2756 (*f2) |= (TR2_SUST_STR);
2757 (*f2) |= (TR2_SUST_INT);
2758 (*f2) |= (TR2_SUST_WIS);
2759 (*f2) |= (TR2_SUST_DEX);
2760 (*f2) |= (TR2_SUST_CON);
2761 (*f2) |= (TR2_SUST_CHR);
2769 static void display_player_equippy(int y, int x)
2779 /* Dump equippy chars */
2780 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2783 o_ptr = &inventory[i];
2785 a = object_attr(o_ptr);
2786 c = object_char(o_ptr);
2788 /* Clear the part of the screen */
2789 if (!equippy_chars || !o_ptr->k_idx)
2796 Term_putch(x + i - INVEN_RARM, y, a, c);
2801 void print_equippy(void)
2803 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2810 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2815 (*f1) = (*f2) = (*f3) = 0L;
2817 /* Check equipment */
2818 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2820 u32b o_f1, o_f2, o_f3;
2825 o_ptr = &inventory[i];
2827 if (!o_ptr->k_idx) continue;
2830 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2832 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2833 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2834 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2835 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2839 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2842 (*f1) = (*f2) = (*f3) = 0L;
2844 if (prace_is_(RACE_SPECTRE))
2845 (*f2) |= TR2_RES_NETHER;
2846 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2847 (*f2) |= TR2_RES_DARK;
2848 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2849 (*f2) |= TR2_RES_FIRE;
2850 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2851 (*f2) |= TR2_RES_ACID;
2854 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2857 (*f1) = (*f2) = (*f3) = 0L;
2859 if (p_ptr->special_defense & DEFENSE_ACID)
2860 (*f2) |= TR2_RES_ACID;
2861 if (p_ptr->special_defense & DEFENSE_ELEC)
2862 (*f2) |= TR2_RES_ELEC;
2863 if (p_ptr->special_defense & DEFENSE_FIRE)
2864 (*f2) |= TR2_RES_FIRE;
2865 if (p_ptr->special_defense & DEFENSE_COLD)
2866 (*f2) |= TR2_RES_COLD;
2867 if (p_ptr->wraith_form)
2868 (*f2) |= TR2_RES_DARK;
2871 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2874 (*f1) = (*f2) = (*f3) = 0L;
2876 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2878 (*f2) |= TR2_RES_ACID;
2879 (*f2) |= TR2_RES_ELEC;
2880 (*f2) |= TR2_RES_FIRE;
2881 (*f2) |= TR2_RES_COLD;
2883 if (prace_is_(RACE_ANDROID))
2884 (*f2) |= TR2_RES_ELEC;
2885 if (prace_is_(RACE_ENT))
2886 (*f2) |= TR2_RES_FIRE;
2887 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2888 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2889 (*f2) |= TR2_RES_LITE;
2893 * Helper function, see below
2895 static void display_player_flag_aux(int row, int col, char *header,
2896 int n, u32b flag1, u32b flag2,
2897 u32b im_f[], u32b vul_f)
2903 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2907 c_put_str(TERM_WHITE, header, row, col);
2910 col += strlen(header) + 1;
2912 /* Check equipment */
2913 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2916 f[0] = f[1] = f[2] = 0L;
2919 o_ptr = &inventory[i];
2922 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2925 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2928 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2929 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
2936 player_flags(&f[0], &f[1], &f[2]);
2939 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2942 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2944 /* Timed player flags */
2945 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
2948 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
2951 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
2952 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
2955 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
2960 * Special display, part 1
2962 static void display_player_flag_info(void)
2967 u32b im_f[3][3], vul_f[3];
2969 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
2970 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
2971 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
2973 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
2980 display_player_equippy(row-2, col+8);
2981 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
2984 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
2985 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
2986 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
2987 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
2988 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
2989 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
2990 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
2991 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
2992 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
2993 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
2995 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
2996 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
2997 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
2998 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
2999 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3000 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3001 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3002 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3003 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3004 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3013 display_player_equippy(row-2, col+8);
3015 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3018 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3019 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3020 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3021 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3022 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3023 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3024 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3025 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3026 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3027 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3029 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3030 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3031 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3032 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3033 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3034 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3035 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3036 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3037 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3038 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3047 display_player_equippy(row-2, col+12);
3049 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3052 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3053 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3054 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3055 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3056 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3057 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3058 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3059 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3060 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3061 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3063 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3064 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3065 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3066 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3067 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3068 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3069 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3070 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3071 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3072 display_player_flag_aux(row+9, col, "Cursed :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3079 * Special display, part 2a
3081 static void display_player_misc_info(void)
3086 /* Display basics */
3088 put_str("̾Á° :", 1, 26);
3089 put_str("ÀÊÌ :", 3, 1);
3090 put_str("¼ï² :", 4, 1);
3091 put_str("¿¦¶È :", 5, 1);
3093 put_str("Name :", 1, 26);
3094 put_str("Sex :", 3, 1);
3095 put_str("Race :", 4, 1);
3096 put_str("Class :", 5, 1);
3099 strcpy(tmp,ap_ptr->title);
3106 strcat(tmp,player_name);
3108 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3109 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3110 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3111 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3113 /* Display extras */
3115 put_str("¥ì¥Ù¥ë:", 6, 1);
3116 put_str("£È£Ð :", 7, 1);
3117 put_str("£Í£Ð :", 8, 1);
3119 put_str("Level :", 6, 1);
3120 put_str("Hits :", 7, 1);
3121 put_str("Mana :", 8, 1);
3125 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3126 c_put_str(TERM_L_BLUE, buf, 6, 9);
3127 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3128 c_put_str(TERM_L_BLUE, buf, 7, 9);
3129 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3130 c_put_str(TERM_L_BLUE, buf, 8, 9);
3135 * Special display, part 2b
3137 * How to print out the modifications and sustains.
3138 * Positive mods with no sustain will be light green.
3139 * Positive mods with a sustain will be dark green.
3140 * Sustains (with no modification) will be a dark green 's'.
3141 * Negative mods (from a curse) will be red.
3142 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3143 * No mod, no sustain, will be a slate '.'
3145 static void display_player_stat_info(void)
3167 /* Print out the labels for the columns */
3169 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3170 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3171 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3172 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3173 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+33);
3175 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3176 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3177 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3178 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3179 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3183 /* Display the stats */
3184 for (i = 0; i < 6; i++)
3188 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3189 else r_adj = rp_ptr->r_adj[i];
3191 /* Calculate equipment adjustment */
3194 /* Icky formula to deal with the 18 barrier */
3195 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3196 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3197 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3198 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3199 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3200 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3202 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3203 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3205 if (prace_is_(RACE_ENT))
3211 if (p_ptr->lev > 25) r_adj++;
3212 if (p_ptr->lev > 40) r_adj++;
3213 if (p_ptr->lev > 45) r_adj++;
3216 if (p_ptr->lev > 25) r_adj--;
3217 if (p_ptr->lev > 40) r_adj--;
3218 if (p_ptr->lev > 45) r_adj--;
3224 e_adj -= cp_ptr->c_adj[i];
3225 e_adj -= ap_ptr->a_adj[i];
3227 /* Reduced name of stat */
3229 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3231 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3235 /* Internal "natural" max value. Maxes at 18/100 */
3236 /* This is useful to see if you are maxed out */
3237 cnv_stat(p_ptr->stat_max[i], buf);
3238 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3240 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3242 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3244 /* Race, class, and equipment modifiers */
3245 (void)sprintf(buf, "%3d", r_adj);
3246 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3247 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3248 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3249 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3250 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3251 (void)sprintf(buf, "%3d", (int)e_adj);
3252 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3254 /* Actual maximal modified value */
3255 cnv_stat(p_ptr->stat_top[i], buf);
3256 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3258 /* Only display stat_use if not maximal */
3259 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3261 cnv_stat(p_ptr->stat_use[i], buf);
3262 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3267 col = stat_col + 41;
3269 /* Header and Footer */
3270 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3272 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3274 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3278 /* Process equipment */
3279 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3282 o_ptr = &inventory[i];
3285 k_idx = o_ptr->k_idx;
3287 /* Acquire "known" flags */
3288 object_flags_known(o_ptr, &f1, &f2, &f3);
3290 /* Initialize color based of sign of pval. */
3291 for (stat = 0; stat < 6; stat++)
3304 if (o_ptr->pval > 0)
3310 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3315 /* Dark green for sustained stats */
3320 if (o_ptr->pval < 0)
3326 if (o_ptr->pval < 10) c = '0' - o_ptr->pval;
3331 else if (f2 & 1 << stat)
3333 /* Dark green "s" */
3338 /* Dump proper character */
3339 Term_putch(col, row + stat+1, a, c);
3347 player_flags(&f1, &f2, &f3);
3350 for (stat = 0; stat < 6; stat++)
3357 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3363 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3364 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3365 if (p_ptr->tsuyoshi) dummy += 4;
3367 else if (stat == A_WIS || stat == A_INT)
3369 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3370 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3372 else if (stat == A_DEX)
3374 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3375 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3376 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3378 else if (stat == A_CON)
3380 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3381 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3382 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3383 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3384 if (p_ptr->tsuyoshi) dummy += 4;
3386 else if (stat == A_CHR)
3388 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3389 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3390 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3391 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3392 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3393 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3409 if (dummy < 10) c = '0' + dummy;
3419 if (dummy < 10) c = '0' - dummy;
3428 /* Dark green "s" */
3435 Term_putch(col, row + stat+1, a, c);
3443 static cptr object_flag_names[96] =
3684 * Summarize resistances
3686 static void display_player_ben(void)
3699 for (i = 0; i < 6; i++) b[i] = 0;
3702 /* Scan equipment */
3703 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3706 o_ptr = &inventory[i];
3708 /* Known object flags */
3709 object_flags_known(o_ptr, &f1, &f2, &f3);
3712 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3714 f3 &= ~(TR3_AGGRAVATE);
3719 b[0] |= (f1 & 0xFFFF);
3721 b[2] |= (f2 & 0xFFFF);
3723 b[4] |= (f3 & 0xFFFF);
3729 player_flags(&f1, &f2, &f3);
3732 b[0] |= (f1 & 0xFFFF);
3734 b[2] |= (f2 & 0xFFFF);
3736 b[4] |= (f3 & 0xFFFF);
3740 tim_player_flags(&f1, &f2, &f3, FALSE);
3743 b[0] |= (f1 & 0xFFFF);
3745 b[2] |= (f2 & 0xFFFF);
3747 b[4] |= (f3 & 0xFFFF);
3749 color[0] = (u16b)(f1 & 0xFFFF);
3750 color[1] = (u16b)(f1 >> 16);
3751 color[2] = (u16b)(f2 & 0xFFFF);
3752 color[3] = (u16b)(f2 >> 16);
3753 color[4] = (u16b)(f3 & 0xFFFF);
3754 color[5] = (u16b)(f3 >> 16);
3757 for (x = 0; x < 6; x++)
3760 for (y = 0; y < 16; y++)
3762 byte a = TERM_SLATE;
3765 cptr name = object_flag_names[16*x+y];
3768 if (!name) continue;
3771 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3774 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3779 if (color[x] & (1<<y))
3792 Term_putch(x * 13 + 11, y + 4, a, c);
3799 * Summarize resistances
3801 static void display_player_ben_one(int mode)
3813 /* Scan equipment */
3814 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3817 n = (i - INVEN_RARM);
3820 o_ptr = &inventory[i];
3822 object_flags_known(o_ptr, &f1, &f2, &f3);
3824 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3826 f3 &= ~(TR3_AGGRAVATE);
3831 b[n][0] = (u16b)(f1 & 0xFFFF);
3832 b[n][1] = (u16b)(f1 >> 16);
3833 b[n][2] = (u16b)(f2 & 0xFFFF);
3834 b[n][3] = (u16b)(f2 >> 16);
3835 b[n][4] = (u16b)(f3 & 0xFFFF);
3836 b[n][5] = (u16b)(f3 >> 16);
3844 player_flags(&f1, &f2, &f3);
3847 b[n][0] = (u16b)(f1 & 0xFFFF);
3848 b[n][1] = (u16b)(f1 >> 16);
3849 b[n][2] = (u16b)(f2 & 0xFFFF);
3850 b[n][3] = (u16b)(f2 >> 16);
3851 b[n][4] = (u16b)(f3 & 0xFFFF);
3852 b[n][5] = (u16b)(f3 >> 16);
3855 tim_player_flags(&f1, &f2, &f3, FALSE);
3858 b[n][0] |= (f1 & 0xFFFF);
3859 b[n][1] |= (f1 >> 16);
3860 b[n][2] |= (f2 & 0xFFFF);
3861 b[n][3] |= (f2 >> 16);
3862 b[n][4] |= (f3 & 0xFFFF);
3863 b[n][5] |= (f3 >> 16);
3864 color[0] = (u16b)(f1 & 0xFFFF);
3865 color[1] = (u16b)(f1 >> 16);
3866 color[2] = (u16b)(f2 & 0xFFFF);
3867 color[3] = (u16b)(f2 >> 16);
3868 color[4] = (u16b)(f3 & 0xFFFF);
3869 color[5] = (u16b)(f3 >> 16);
3873 for (x = 0; x < 3; x++)
3876 display_player_equippy(2, x * 26 + 11);
3879 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3882 for (y = 0; y < 16; y++)
3884 cptr name = object_flag_names[48*mode+16*x+y];
3887 if (!name) continue;
3890 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3893 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3896 for (n = 0; n < 13; n++)
3898 byte a = TERM_SLATE;
3902 if (b[n][3*mode+x] & (1<<y))
3904 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3917 Term_putch(x * 26 + 11 + n, y + 4, a, c);
3925 * Display the character on the screen (various modes)
3927 * The top two and bottom two lines are left blank.
3929 * Mode 0 = standard display with skills
3930 * Mode 1 = standard display with history
3931 * Mode 2 = summary of various things
3932 * Mode 3 = current flags (combined)
3933 * Mode 4 = current flags (part 1)
3934 * Mode 5 = current flags (part 2)
3935 * Mode 6 = mutations
3937 void display_player(int mode)
3946 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
3955 if ((mode == 0) || (mode == 1))
3957 /* Name, Sex, Race, Class */
3959 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3961 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
3964 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3965 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3966 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3967 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3972 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3974 strcpy(tmp, realm_names[p_ptr->realm1]);
3975 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3978 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
3979 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3981 /* Age, Height, Weight, Social */
3982 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
3984 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
3985 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3986 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3987 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3989 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3990 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3991 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3992 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3994 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3997 /* Display the stats */
3998 for (i = 0; i < 6; i++)
4000 /* Special treatment of "injured" stats */
4001 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4005 /* Use lowercase stat name */
4006 put_str(stat_names_reduced[i], 3 + i, 54);
4008 /* Get the current stat */
4009 value = p_ptr->stat_use[i];
4011 /* Obtain the current stat (modified) */
4012 cnv_stat(value, buf);
4014 /* Display the current stat (modified) */
4015 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
4017 /* Acquire the max stat */
4018 value = p_ptr->stat_top[i];
4020 /* Obtain the maximum stat (modified) */
4021 cnv_stat(value, buf);
4023 /* Display the maximum stat (modified) */
4024 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
4027 /* Normal treatment of "normal" stats */
4030 /* Assume uppercase stat name */
4031 put_str(stat_names[i], 3 + i, 54);
4033 /* Obtain the current stat (modified) */
4034 cnv_stat(p_ptr->stat_use[i], buf);
4036 /* Display the current stat (modified) */
4037 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
4040 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4042 c_put_str(TERM_WHITE, "!", 3+i, 59);
4046 /* Display "history" info */
4050 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
4052 put_str("(Character Background)", 11, 25);
4055 for (i = 0; i < 4; i++)
4057 put_str(history[i], i + 12, 10);
4065 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Î %d ³¬¤Ç»à¤ó¤À¡£", map_name(), dun_level), 5 + 12, 10);
4067 put_str(format("...You were dead at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4071 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Ç»à¤ó¤À¡£", map_name()), 5 + 12, 10);
4073 put_str(format("...You were dead at %s.", map_name()), 5 + 12, 10);
4080 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level), 5 + 12, 10);
4082 put_str(format("...Now, you are exploring at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4086 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name()), 5 + 12, 10);
4088 put_str(format("...Now, you are in %s.", map_name()), 5 + 12, 10);
4093 /* Display "various" info */
4096 display_player_middle();
4097 display_player_various();
4104 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4107 display_player_misc_info();
4108 display_player_stat_info();
4109 display_player_flag_info();
4115 display_player_ben();
4120 do_cmd_knowledge_mutations();
4126 display_player_ben_one(mode % 2);
4130 errr make_character_dump(FILE *fff)
4137 char o_name[MAX_NLEN];
4141 #ifndef FAKE_VERSION
4143 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4144 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4147 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4148 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4150 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4151 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4158 /* Display player */
4161 /* Dump part of the screen */
4162 for (y = 1; y < 22; y++)
4165 for (x = 0; x < 79; x++)
4167 /* Get the attr/char */
4168 (void)(Term_what(x, y, &a, &c));
4174 /* End the string */
4177 /* Kill trailing spaces */
4178 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4182 fprintf(fff, "%s\n", buf);
4184 fprintf(fff, "%s\n", buf);
4189 /* Display history */
4192 /* Dump part of the screen */
4193 for (y = 11; y < 18; y++)
4196 for (x = 0; x < 79; x++)
4198 /* Get the attr/char */
4199 (void)(Term_what(x, y, &a, &c));
4205 /* End the string */
4208 /* Kill trailing spaces */
4209 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4212 fprintf(fff, "%s\n", buf);
4216 /* Display history */
4219 /* Dump part of the screen */
4220 for (y = 2; y < 22; y++)
4223 for (x = 0; x < 79; x++)
4225 /* Get the attr/char */
4226 (void)(Term_what(x, y, &a, &c));
4228 /* Dump it (Ignore equippy tile graphic) */
4235 /* End the string */
4238 /* Kill trailing spaces */
4239 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4242 fprintf(fff, "%s\n", buf);
4245 for (i = 0; i < p_ptr->count / 80; i++)
4248 for (i = 0; i < p_ptr->count % 80; i++)
4253 for (i = m_max - 1; i >= 1; i--)
4255 monster_type *m_ptr = &m_list[i];
4258 if (!m_ptr->r_idx) continue;
4259 if (!is_pet(m_ptr)) continue;
4260 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4264 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4266 fprintf(fff, "\n [leading pets]\n\n");
4270 monster_desc(pet_name, m_ptr, 0x88);
4271 fprintf(fff, "%s", pet_name);
4272 if (p_ptr->riding == i)
4274 fprintf(fff, " ¾èÇÏÃæ");
4276 fprintf(fff, " riding");
4280 if (pet) fprintf(fff, "\n");
4283 if (death && !total_winner)
4286 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4288 fprintf(fff, "\n [Last messages]\n\n");
4290 for (i = MIN(message_num(), 15); i >= 0; i--)
4292 fprintf(fff,"> %s\n",message_str((s16b)i));
4298 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4300 fprintf(fff, "\n [Miscellaneous information]\n");
4304 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4306 fprintf(fff, "\n Recall Depth:\n");
4308 for (y = 1; y < max_d_idx; y++)
4312 if (!d_info[y].maxdepth) continue;
4313 if (!max_dlv[y]) continue;
4314 if (d_info[y].final_guardian)
4316 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4318 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4321 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4323 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4329 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4331 fprintf(fff, "\n Preserve Mode: ON");
4336 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4338 fprintf(fff, "\n Preserve Mode: OFF");
4342 if (ironman_autoscum)
4344 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4346 fprintf(fff, "\n Autoscum: ALWAYS");
4351 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4353 fprintf(fff, "\n Autoscum: ON");
4358 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4360 fprintf(fff, "\n Autoscum: OFF");
4364 if (ironman_small_levels)
4366 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4368 fprintf(fff, "\n Small Levels: ALWAYS");
4371 else if (always_small_levels)
4373 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4375 fprintf(fff, "\n Small Levels: ON");
4378 else if (small_levels)
4380 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4382 fprintf(fff, "\n Small Levels: ENABLED");
4387 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4389 fprintf(fff, "\n Small Levels: OFF");
4395 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4397 fprintf(fff, "\n Vanilla Town: ON");
4402 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4404 fprintf(fff, "\n Lite Town: ON");
4410 fprintf(fff, "\n Ź¤Ê¤·: ON");
4412 fprintf(fff, "\n No Shops: ON");
4416 if (ironman_downward)
4418 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4420 fprintf(fff, "\n Diving only: ON");
4426 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4428 fprintf(fff, "\n Unusual rooms: ON");
4432 if (ironman_nightmare)
4434 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4436 fprintf(fff, "\n Nightmare Mode: ON");
4440 if (ironman_empty_levels)
4442 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4444 fprintf(fff, "\n Arena Levels: ALWAYS");
4447 else if (empty_levels)
4449 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4451 fprintf(fff, "\n Arena Levels: ENABLED");
4456 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4458 fprintf(fff, "\n Arena Levels: OFF");
4463 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4465 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4468 if (p_ptr->arena_number == 99)
4471 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4473 fprintf(fff, "\n Arena: defeated\n");
4476 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4479 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4481 fprintf(fff, "\n Arena: True Champion\n");
4484 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4487 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4489 fprintf(fff, "\n Arena: Champion\n");
4495 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4497 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");
4503 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4505 fprintf(fff, "\n You have done something illegal.");
4509 if (stupid_monsters)
4511 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4513 fprintf(fff, "\n Your opponents are behaving stupidly.");
4519 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4521 fprintf(fff, "\n You possess munchkinish power over death.");
4526 /* Monsters slain */
4531 for (k = 1; k < max_r_idx; k++)
4533 monster_race *r_ptr = &r_info[k];
4535 if (r_ptr->flags1 & RF1_UNIQUE)
4537 bool dead = (r_ptr->max_num == 0);
4545 s16b This = r_ptr->r_pkills;
4555 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4557 fprintf(fff,"\n You have defeated no enemies yet.\n");
4560 else if (Total == 1)
4562 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4564 fprintf(fff,"\n You have defeated one enemy.\n");
4569 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4571 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4577 if (p_ptr->old_race1 || p_ptr->old_race2)
4580 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4582 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4584 for (i = 0; i < MAX_RACES; i++)
4586 if (p_ptr->start_race == i) continue;
4589 if (!(p_ptr->old_race1 & 1L << i)) continue;
4593 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4596 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4598 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4603 if (p_ptr->old_realm)
4605 for (i = 0; i < MAX_MAGIC; i++)
4607 if (!(p_ptr->old_realm & 1L << i)) continue;
4609 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4611 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4617 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4619 fprintf(fff, "\n\n [Virtues]\n\n");
4623 fprintf(fff, "°À : %s\n", your_alignment());
4625 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4630 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4633 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4635 fprintf(fff, "\n\n [Mutations]\n\n");
4638 dump_mutations(fff);
4642 /* Skip some lines */
4643 fprintf(fff, "\n\n");
4646 /* Dump the equipment */
4650 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4652 fprintf(fff, " [Character Equipment]\n\n");
4655 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4657 object_desc(o_name, &inventory[i], TRUE, 3);
4658 if ((i == INVEN_LARM) && p_ptr->ryoute)
4660 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4662 strcpy(o_name, "(wielding with two-hands)");
4664 fprintf(fff, "%c%s %s\n",
4665 index_to_label(i), paren, o_name);
4667 fprintf(fff, "\n\n");
4670 /* Dump the inventory */
4672 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4674 fprintf(fff, " [Character Inventory]\n\n");
4677 for (i = 0; i < INVEN_PACK; i++)
4679 /* Don't dump the empty slots */
4680 if (!inventory[i].k_idx) break;
4682 /* Dump the inventory slots */
4683 object_desc(o_name, &inventory[i], TRUE, 3);
4684 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4687 /* Add an empty line */
4688 fprintf(fff, "\n\n");
4690 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4692 /* Print all homes in the different towns */
4693 st_ptr = &town[1].store[STORE_HOME];
4695 /* Home -- if anything there */
4696 if (st_ptr->stock_num)
4698 /* Header with name of the town */
4700 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4702 fprintf(fff, " [Home Inventory]\n");
4706 /* Dump all available items */
4707 for (i = 0; i < st_ptr->stock_num; i++)
4711 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4713 fprintf(fff, "\n ( page %d )\n", x++);
4715 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4716 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4719 /* Add an empty line */
4720 fprintf(fff, "\n\n");
4724 /* Print all homes in the different towns */
4725 st_ptr = &town[1].store[STORE_MUSEUM];
4727 /* Home -- if anything there */
4728 if (st_ptr->stock_num)
4730 /* Header with name of the town */
4732 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4734 fprintf(fff, " [Museum]\n");
4738 /* Dump all available items */
4739 for (i = 0; i < st_ptr->stock_num; i++)
4742 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4743 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4744 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4746 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4747 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4748 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4753 /* Add an empty line */
4754 fprintf(fff, "\n\n");
4761 * Hack -- Dump a character description file
4763 * XXX XXX XXX Allow the "full" flag to dump additional info,
4764 * and trigger its usage from various places in the code.
4766 errr file_character(cptr name, bool full)
4775 /* Build the filename */
4776 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4778 /* File type is "TEXT" */
4779 FILE_TYPE(FILE_TYPE_TEXT);
4781 /* Check for existing file */
4782 fd = fd_open(buf, O_RDONLY);
4789 /* Close the file */
4794 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4796 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4801 if (get_check(out_val)) fd = -1;
4804 /* Open the non-existing file */
4805 if (fd < 0) fff = my_fopen(buf, "w");
4812 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4814 msg_format("Character dump failed!");
4823 (void)make_character_dump(fff);
4833 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4835 msg_print("Character dump successful.");
4845 typedef struct file_tag
4852 typedef struct file_tags
4859 static void add_tag(file_tags *the_tags, cptr name, int line)
4861 if (the_tags->index < 64)
4863 file_tag *tag = &(the_tags->tags[the_tags->index]);
4865 /* Set the name and end it with '\0' */
4866 strncpy(tag->name, name, 31);
4867 tag->name[31] = '\0';
4869 /* Set the line-number */
4870 tag->line_number = line;
4872 /* Increase the number of tags */
4878 static int get_line(file_tags *the_tags, cptr name)
4882 /* Search for the tag */
4883 for (i = 0; i < the_tags->index; i++)
4885 if (streq(the_tags->tags[i].name, name))
4887 return the_tags->tags[i].line_number;
4897 * Recursive file perusal.
4899 * Return FALSE on 'Q', otherwise TRUE.
4901 * Process various special text in the input file, including
4902 * the "menu" structures used by the "help file" system.
4904 * XXX XXX XXX Consider using a temporary file.
4906 * XXX XXX XXX Allow the user to "save" the current file.
4908 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4912 /* Number of "real" lines passed by */
4915 /* Number of "real" lines in the file */
4918 /* Backup value for "line" */
4924 /* This screen has sub-screens */
4927 /* Current help file */
4930 /* Find this string (if any) */
4933 /* Jump to this tag */
4936 /* Hold a string to find */
4939 /* Hold a string to show */
4943 char filename[1024];
4945 /* Describe this thing */
4951 /* General buffer */
4954 /* Lower case version of the buffer, for searching */
4957 /* Aux pointer for making lc_buf (and find!) lowercase */
4960 /* Sub-menu information */
4963 /* Tags for in-file references */
4966 bool reverse = (line < 0);
4975 strcpy(caption, "");
4977 /* Wipe the hooks */
4978 for (i = 0; i < 68; i++)
4986 /* Copy the filename */
4987 strcpy(filename, name);
4989 n = strlen(filename);
4991 /* Extract the tag from the filename */
4992 for (i = 0; i < n; i++)
4994 if (filename[i] == '#')
4997 tag = filename + i + 1;
5002 /* Redirect the name */
5005 /* Hack XXX XXX XXX */
5009 strcpy(caption, what);
5011 /* Access the "file" */
5015 fff = my_fopen(path, "r");
5018 /* Look in "help" */
5023 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5025 sprintf(caption, "Help file '%s'", name);
5029 /* Build the filename */
5030 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5033 fff = my_fopen(path, "r");
5036 /* Look in "info" */
5041 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5043 sprintf(caption, "Info file '%s'", name);
5047 /* Build the filename */
5048 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5051 fff = my_fopen(path, "r");
5054 /* Look in "info" */
5057 /* Build the filename */
5058 path_build(path, 1024, ANGBAND_DIR, name);
5060 for (i = 0; path[i]; i++)
5061 if ('\\' == path[i])
5062 path[i] = PATH_SEP[0];
5066 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5068 sprintf(caption, "Info file '%s'", name);
5072 fff = my_fopen(path, "r");
5080 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5082 msg_format("Cannot open '%s'.", name);
5092 /* Pre-Parse the file */
5095 /* Read a line or stop */
5096 if (my_fgets(fff, buf, 1024)) break;
5098 /* XXX Parse "menu" items */
5099 if (prefix(buf, "***** "))
5101 /* Notice "menu" requests */
5102 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5104 /* This is a menu file */
5107 /* Extract the menu item */
5108 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5110 if ((buf[8] == ']') && (buf[9] == ' '))
5112 /* Extract the menu item */
5113 strncpy(hook[k], buf + 10, 31);
5115 /* Make sure it's null-terminated */
5119 /* Notice "tag" requests */
5120 else if (buf[6] == '<')
5122 buf[strlen(buf) - 1] = '\0';
5123 add_tag(&tags, buf + 7, next);
5130 /* Count the "real" lines */
5134 /* Save the number of "real" lines */
5137 /* Go to the tagged line */
5138 if (tag) line = get_line(&tags, tag);
5140 /* Display the file */
5146 /* Restart when necessary */
5147 if (line >= size) line = 0;
5150 /* Re-open the file if needed */
5156 /* Hack -- Re-Open the file */
5157 fff = my_fopen(path, "r");
5160 if (!fff) return (FALSE);
5162 /* File has been restarted */
5166 /* Goto the selected line */
5170 if (my_fgets(fff, buf, 1024)) break;
5172 /* Skip tags/links */
5173 if (prefix(buf, "***** ")) continue;
5175 /* Count the lines */
5179 /* Dump the next 20 lines of the file */
5180 for (i = 0; i < 20; )
5182 /* Hack -- track the "first" line */
5183 if (!i) line = next;
5185 /* Get a line of the file or stop */
5186 if (my_fgets(fff, buf, 1024)) break;
5188 /* Hack -- skip "special" lines */
5189 if (prefix(buf, "***** ")) continue;
5191 /* Count the "real" lines */
5194 /* Make a lower case version of buf for searching */
5195 strcpy(lc_buf, buf);
5197 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5200 if (iskanji(*lc_buf_ptr))
5204 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5207 /* Hack -- keep searching */
5208 if (find && !i && !strstr(lc_buf, find)) continue;
5210 /* Hack -- stop searching */
5214 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5216 /* Hilite "shower" */
5221 /* Display matches */
5222 while ((str = strstr(str, shower)) != NULL)
5224 int len = strlen(shower);
5226 /* Display the match */
5227 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5234 /* Count the printed lines */
5238 /* Hack -- failed search */
5248 /* Show a general "title" */
5253 "[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5255 "[Hengband %d.%d.%d, %s, Line %d/%d]",
5258 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5259 caption, line, size), 0, 0);
5269 caption, line, size), 0, 0);
5272 /* Prompt -- menu screen */
5277 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", 23, 0);
5279 prt("[Press a Number, or ESC to exit.]", 23, 0);
5284 /* Prompt -- small files */
5285 else if (size <= 20)
5289 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5291 prt("[Press ESC to exit.]", 23, 0);
5296 /* Prompt -- large files */
5301 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5303 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5305 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", 23, 0);
5309 /* Get a keypress */
5312 /* Hack -- return to last screen */
5313 if (k == '<') break;
5315 /* Show the help for the help */
5318 /* Hack - prevent silly recursion */
5320 if (strcmp(name, "jhelpinfo.txt") != 0)
5321 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5323 if (strcmp(name, "helpinfo.txt") != 0)
5324 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5328 /* Hack -- try showing */
5333 prt("¶¯Ä´: ", 23, 0);
5335 prt("Show: ", 23, 0);
5338 (void)askfor_aux(shower, 80);
5341 /* Hack -- try finding */
5346 prt("¸¡º÷: ", 23, 0);
5348 prt("Find: ", 23, 0);
5352 if (askfor_aux(finder, 80))
5359 /* Make finder lowercase */
5360 for (cnt = 0; finder[cnt] != 0; cnt++)
5363 if (iskanji(finder[cnt]))
5367 finder[cnt] = tolower(finder[cnt]);
5371 strcpy(shower, finder);
5375 /* Hack -- go to a specific line */
5382 prt("Goto Line: ", 23, 0);
5387 if (askfor_aux(tmp, 80))
5393 /* Hack -- go to a specific file */
5398 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", 23, 0);
5399 strcpy(tmp, "jhelp.hlp");
5401 prt("Goto File: ", 23, 0);
5402 strcpy(tmp, "help.hlp");
5406 if (askfor_aux(tmp, 80))
5408 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5412 /* Hack -- Allow backing up */
5415 line = line + (reverse ? 20 : -20);
5416 if (line < 0) line = ((size-1)/20)*20;
5419 /* Hack -- Advance a single line */
5420 if ((k == '\n') || (k == '\r'))
5422 line = line + (reverse ? -1 : 1);
5423 if (line < 0) line = ((size-1)/20)*20;
5426 /* Advance one page */
5429 line = line + (reverse ? -20 : 20);
5430 if (line < 0) line = ((size-1)/20)*20;
5433 /* Recurse on numbers */
5438 if (isdigit(k)) key = D2I(k);
5439 else if (isalpha(k)) key = k - 'A' + 10;
5441 if ((key > -1) && hook[key][0])
5443 /* Recurse on that file */
5444 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5449 /* Hack, dump to file */
5459 if (!get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5461 if (!get_string("File name: ", xtmp, 80))
5473 /* Build the filename */
5474 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5476 /* Hack -- Re-Open the file */
5477 fff = my_fopen(path, "r");
5479 ffp = my_fopen(buff, "w");
5485 msg_print("¥Õ¥¡¥¤¥ë¤¬³«¤±¤Þ¤»¤ó¡£");
5487 msg_print("Failed to open file.");
5494 sprintf(xtmp, "%s: %s", player_name, what);
5495 my_fputs(ffp, xtmp, 80);
5496 my_fputs(ffp, "\n", 80);
5498 while (!my_fgets(fff, buff, 80))
5499 my_fputs(ffp, buff, 80);
5508 /* Hack -- Re-Open the file */
5509 fff = my_fopen(path, "r");
5512 /* Exit on escape */
5513 if (k == ESCAPE) break;
5514 if (k == 'q') break;
5517 /* Close the file */
5521 if (k == 'q') return (FALSE);
5529 * Peruse the On-Line-Help
5531 void do_cmd_help(void)
5536 /* Peruse the main help file */
5538 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5540 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5550 * Process the player name.
5551 * Extract a clean "base name".
5552 * Build the savefile name if needed.
5554 void process_player_name(bool sf)
5559 /* Cannot be too long */
5560 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5562 if (strlen(player_name) > 8)
5564 if (strlen(player_name) > 15)
5569 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5571 quit_fmt("The name '%s' is too long!", player_name);
5577 /* Cannot contain "icky" characters */
5578 for (i = 0; player_name[i]; i++)
5580 /* No control characters */
5582 if (iskanji(player_name[i])){i++;continue;}
5583 if (iscntrl( (unsigned char)player_name[i]))
5585 if (iscntrl(player_name[i]))
5589 /* Illegal characters */
5591 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5593 quit_fmt("The name '%s' contains control chars!", player_name);
5602 /* Extract "useful" letters */
5603 for (i = 0; player_name[i]; i++)
5606 unsigned char c = player_name[i];
5608 char c = player_name[i];
5612 /* Convert "dot" to "underscore" */
5613 if (c == '.') c = '_';
5615 /* Accept all the letters */
5616 player_base[k++] = c;
5621 /* Extract "useful" letters */
5622 for (i = 0; player_name[i]; i++)
5625 unsigned char c = player_name[i];
5627 char c = player_name[i];
5630 /* Accept some letters */
5633 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5634 player_base[k++] = c;
5636 player_base[k++] = player_name[i];
5639 else if (iskana(c)) player_base[k++] = c;
5643 /* Convert path separator to underscore */
5644 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5645 player_base[k++] = '_';
5646 i += strlen(PATH_SEP);
5649 /* Convert space, dot, and underscore to underscore */
5650 else if (strchr(". _", c)) player_base[k++] = '_';
5652 else if (isprint(c)) player_base[k++] = c;
5658 #if defined(WINDOWS) || defined(MSDOS)
5660 /* Hack -- max length */
5666 player_base[k] = '\0';
5668 /* Require a "base" name */
5669 if (!player_base[0]) strcpy(player_base, "PLAYER");
5672 #ifdef SAVEFILE_MUTABLE
5678 if (!savefile_base[0] && savefile[0])
5685 t = strstr(s, PATH_SEP);
5690 strcpy(savefile_base, s);
5693 if (!savefile_base[0] || !savefile[0])
5696 /* Change the savefile name */
5701 strcpy(savefile_base, player_base);
5703 #ifdef SAVEFILE_USE_UID
5704 /* Rename the savefile, using the player_uid and player_base */
5705 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5707 /* Rename the savefile, using the player_base */
5708 (void)sprintf(temp, "%s", player_base);
5712 /* Hack -- support "flat directory" usage on VM/ESA */
5713 (void)sprintf(temp, "%s.sv", player_base);
5716 /* Build the filename */
5717 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5723 * Gets a name for the character, reacting to name changes.
5725 * Assumes that "display_player(0)" has just been called
5727 * Perhaps we should NOT ask for a name (at "birth()") on
5728 * Unix machines? XXX XXX
5730 * What a horrible name for a global function. XXX XXX XXX
5736 /* Save the player name */
5737 strcpy(tmp, player_name);
5739 /* Prompt for a new name */
5741 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5743 if (get_string("Enter a name for your character: ", tmp, 15))
5747 strcpy(player_name, tmp);
5749 else if (0 == strlen(player_name))
5751 /* Use default name */
5752 strcpy(player_name, "PLAYER");
5755 /* Process the player name */
5756 process_player_name(FALSE);
5758 strcpy(tmp,ap_ptr->title);
5765 strcat(tmp,player_name);
5767 /* Re-Draw the name (in light blue) */
5768 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5770 /* Erase the prompt, etc */
5777 * Hack -- commit suicide
5779 void do_cmd_suicide(void)
5786 /* Verify Retirement */
5791 if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
5793 if (!get_check("Do you want to retire? ")) return;
5798 /* Verify Suicide */
5803 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5805 if (!get_check("Do you really want to commit suicide? ")) return;
5812 /* Special Verification for suicide */
5814 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5816 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5822 if (i != '@') return;
5828 /* Kill the player */
5832 p_ptr->leaving = TRUE;
5837 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5838 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5840 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5841 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5843 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5846 /* Cause of death */
5848 (void)strcpy(died_from, "ÅÓÃ潪λ");
5850 (void)strcpy(died_from, "Quitting");
5860 void do_cmd_save_game(int is_autosave)
5862 /* Autosaves do not disturb */
5866 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5868 msg_print("Autosaving the game...");
5874 /* Disturb the player */
5878 /* Clear messages */
5886 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
5888 prt("Saving game...", 0, 0);
5895 /* The player is not dead */
5897 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
5899 (void)strcpy(died_from, "(saved)");
5903 /* Forbid suspend */
5904 signals_ignore_tstp();
5906 /* Save the player */
5910 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
5912 prt("Saving game... done.", 0, 0);
5917 /* Save failed (oops) */
5921 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
5923 prt("Saving game... failed!", 0, 0);
5928 /* Allow suspend again */
5929 signals_handle_tstp();
5934 /* Note that the player is not dead */
5936 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
5938 (void)strcpy(died_from, "(alive and well)");
5945 * Save the game and exit
5947 void do_cmd_save_and_exit(void)
5952 p_ptr->leaving = TRUE;
5954 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
5956 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
5962 * Hack -- Calculates the total number of points earned -JWT-
5964 long total_points(void)
5968 u32b point, point_h, point_l;
5969 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
5971 if (stupid_monsters) mult -= 70;
5972 if (!preserve_mode) mult += 10;
5973 if (!autoroller) mult += 10;
5974 if (!smart_learn) mult -= 20;
5975 if (!terrain_streams) mult -= 20;
5976 if (smart_cheat) mult += 30;
5977 if (ironman_shops) mult += 50;
5978 if (ironman_small_levels) mult += 10;
5979 if (ironman_empty_levels) mult += 20;
5980 if (!powerup_home) mult += 50;
5981 if (ironman_rooms) mult += 100;
5982 if (ironman_nightmare) mult += 100;
5984 if (mult < 5) mult = 5;
5986 for (i = 0; i < max_d_idx; i++)
5987 if(max_dlv[i] > max_dl)
5988 max_dl = max_dlv[i];
5990 point_l = (p_ptr->max_exp + (100 * max_dl));
5991 point_h = point_l / 0x10000L;
5992 point_l = point_l % 0x10000L;
5995 point_h += point_l / 0x10000L;
5996 point_l %= 0x10000L;
5998 point_l += ((point_h % 100) << 16);
6002 point = (point_h << 16) + (point_l);
6003 if (p_ptr->arena_number < 99)
6004 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6006 if (ironman_downward) point *= 2;
6007 if (p_ptr->pclass == CLASS_BERSERKER)
6009 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6013 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6016 if (total_winner) point = 2;
6018 if (easy_band) point = (0 - point);
6026 * Centers a string within a 31 character string -JWT-
6028 static void center_string(char *buf, cptr str)
6035 /* Necessary border */
6039 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6045 * Save a "bones" file for a dead character
6047 * Note that we will not use these files until Angband 2.8.0, and
6048 * then we will only use the name and level on which death occured.
6050 * Should probably attempt some form of locking...
6052 static void make_bones(void)
6059 /* Ignore wizards and borgs */
6060 if (!(noscore & 0x00FF))
6062 /* Ignore people who die in town */
6067 /* XXX XXX XXX "Bones" name */
6068 sprintf(tmp, "bone.%03d", dun_level);
6070 /* Build the filename */
6071 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6073 /* Attempt to open the bones file */
6074 fp = my_fopen(str, "r");
6076 /* Close it right away */
6077 if (fp) my_fclose(fp);
6079 /* Do not over-write a previous ghost */
6082 /* File type is "TEXT" */
6083 FILE_TYPE(FILE_TYPE_TEXT);
6085 /* Try to write a new "Bones File" */
6086 fp = my_fopen(str, "w");
6088 /* Not allowed to write it? Weird. */
6092 fprintf(fp, "%s\n", player_name);
6093 fprintf(fp, "%d\n", p_ptr->mhp);
6094 fprintf(fp, "%d\n", p_ptr->prace);
6095 fprintf(fp, "%d\n", p_ptr->pclass);
6097 /* Close and save the Bones file */
6106 * Redefinable "print_tombstone" action
6108 bool (*tombstone_aux)(void) = NULL;
6112 * Display a "tomb-stone"
6114 static void print_tomb(void)
6118 /* Do we use a special tombstone ? */
6121 /* Use tombstone hook */
6122 done = (*tombstone_aux)();
6125 /* Print the text-tombstone */
6139 time_t ct = time((time_t)0);
6145 /* Build the filename */
6147 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6149 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6153 /* Open the News file */
6154 fp = my_fopen(buf, "r");
6161 /* Dump the file to the screen */
6162 while (0 == my_fgets(fp, buf, 1024))
6164 /* Display and advance */
6165 put_str(buf, i++, 0);
6174 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6188 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6191 center_string(buf, player_name);
6192 put_str(buf, 6, 11);
6195 center_string(buf, "the");
6196 put_str(buf, 7, 11);
6199 center_string(buf, p);
6200 put_str(buf, 8, 11);
6203 center_string(buf, cp_ptr->title);
6205 put_str(buf, 10, 11);
6208 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6210 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6213 center_string(buf, tmp);
6214 put_str(buf, 11, 11);
6217 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6219 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6222 center_string(buf, tmp);
6223 put_str(buf, 12, 11);
6226 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6228 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6231 center_string(buf, tmp);
6232 put_str(buf, 13, 11);
6235 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6236 if (streq(died_from, "ÅÓÃ潪λ"))
6238 strcpy(tmp, "<¼«»¦>");
6242 if (streq(died_from, "ripe"))
6244 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6246 else if (streq(died_from, "Seppuku"))
6248 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6252 strcpy(tmp, died_from);
6255 center_string(buf, tmp);
6256 put_str(buf, 14, 11);
6258 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6260 if( dun_level == 0 )
6262 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6263 if(streq(died_from, "ÅÓÃ潪λ"))
6265 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6269 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6274 if(streq(died_from, "ÅÓÃ潪λ"))
6276 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6280 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6283 center_string(buf, tmp);
6284 put_str(buf, 15, 11);
6287 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6288 center_string(buf, tmp);
6289 put_str(buf, 14, 11);
6292 if (strlen(died_from) > 24)
6294 strncpy(dummy, died_from, 24);
6296 (void)sprintf(tmp, "by %s.", dummy);
6299 (void)sprintf(tmp, "by %s.", died_from);
6301 center_string(buf, tmp);
6302 put_str(buf, 15, 11);
6307 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6308 center_string(buf, tmp);
6309 put_str(buf, 17, 11);
6312 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6314 msg_format("Goodbye, %s!", player_name);
6322 * Display some character info
6324 static void show_info(void)
6330 /* Hack -- Know everything in the inven/equip */
6331 for (i = 0; i < INVEN_TOTAL; i++)
6333 o_ptr = &inventory[i];
6335 /* Skip non-objects */
6336 if (!o_ptr->k_idx) continue;
6338 /* Aware and Known */
6339 object_aware(o_ptr);
6340 object_known(o_ptr);
6343 for (i = 1; i < max_towns; i++)
6345 st_ptr = &town[i].store[STORE_HOME];
6347 /* Hack -- Know everything in the home */
6348 for (j = 0; j < st_ptr->stock_num; j++)
6350 o_ptr = &st_ptr->stock[j];
6352 /* Skip non-objects */
6353 if (!o_ptr->k_idx) continue;
6355 /* Aware and Known */
6356 object_aware(o_ptr);
6357 object_known(o_ptr);
6361 /* Hack -- Recalculate bonuses */
6362 p_ptr->update |= (PU_BONUS);
6367 /* Flush all input keys */
6370 /* Flush messages */
6374 /* Describe options */
6376 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6377 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6379 prt("You may now dump a character record to one or more files.", 21, 0);
6380 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6384 /* Dump character records as requested */
6391 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6393 put_str("Filename: ", 23, 0);
6398 strcpy(out_val, "");
6400 /* Ask for filename (or abort) */
6401 if (!askfor_aux(out_val, 60)) return;
6403 /* Return means "show on screen" */
6404 if (!out_val[0]) break;
6409 /* Dump a character file */
6410 (void)file_character(out_val, TRUE);
6418 /* Display player */
6421 /* Prompt for inventory */
6423 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6425 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6429 /* Allow abort at this point */
6430 if (inkey() == ESCAPE) return;
6433 /* Show equipment and inventory */
6435 /* Equipment -- if any */
6439 item_tester_full = TRUE;
6440 (void)show_equip(0);
6442 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6444 prt("You are using: -more-", 0, 0);
6447 if (inkey() == ESCAPE) return;
6450 /* Inventory -- if any */
6454 item_tester_full = TRUE;
6455 (void)show_inven(0);
6457 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6459 prt("You are carrying: -more-", 0, 0);
6462 if (inkey() == ESCAPE) return;
6465 /* Homes in the different towns */
6466 for (l = 1; l < max_towns; l++)
6468 st_ptr = &town[l].store[STORE_HOME];
6470 /* Home -- if anything there */
6471 if (st_ptr->stock_num)
6473 /* Display contents of the home */
6474 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6480 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6482 char o_name[MAX_NLEN];
6486 o_ptr = &st_ptr->stock[i];
6488 /* Print header, clear line */
6489 sprintf(tmp_val, "%c) ", I2A(j));
6490 prt(tmp_val, j+2, 4);
6492 /* Display object description */
6493 object_desc(o_name, o_ptr, TRUE, 3);
6494 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6499 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6501 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6506 if (inkey() == ESCAPE) return;
6513 static bool check_score(void)
6519 if (highscore_fd < 0)
6522 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6524 msg_print("Score file unavailable.");
6531 #ifndef SCORE_WIZARDS
6532 /* Wizard-mode pre-empts scoring */
6533 if (noscore & 0x000F)
6536 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6538 msg_print("Score not registered for wizards.");
6547 /* Borg-mode pre-empts scoring */
6548 if (noscore & 0x00F0)
6551 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6553 msg_print("Score not registered for borgs.");
6561 #ifndef SCORE_CHEATERS
6562 /* Cheaters are not scored */
6563 if (noscore & 0xFF00)
6566 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6568 msg_print("Score not registered for cheaters.");
6578 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6580 if (!total_winner && streq(died_from, "Interrupting"))
6585 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6587 msg_print("Score not registered due to interruption.");
6596 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6598 if (!total_winner && streq(died_from, "Quitting"))
6603 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6605 msg_print("Score not registered due to quitting.");
6615 * Close up the current game (player may or may not be dead)
6617 * This function is called only from "main.c" and "signals.c".
6619 void close_game(void)
6622 bool do_send = TRUE;
6624 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6629 /* Flush the messages */
6632 /* Flush the input */
6636 /* No suspending now */
6637 signals_ignore_tstp();
6640 /* Hack -- Character is now "icky" */
6641 character_icky = TRUE;
6644 /* Build the filename */
6645 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6647 /* Open the high score file, for reading/writing */
6648 highscore_fd = fd_open(buf, O_RDWR);
6654 /* Handle retirement */
6655 if (total_winner) kingly();
6659 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6661 if (!munchkin_death || get_check("Save death? "))
6666 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6668 if (!save_player()) msg_print("death save failed!");
6671 else do_send = FALSE;
6678 /* Show more info */
6686 if ((!send_world_score(do_send)))
6689 if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
6691 if (get_check("Stand by for later score registration? "))
6694 wait_report_score = TRUE;
6697 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6699 if (!save_player()) msg_print("death save failed!");
6703 if (!wait_report_score)
6706 else if (highscore_fd >= 0)
6708 display_scores_aux(0, 10, -1, NULL);
6711 /* Dump bones file */
6720 do_cmd_save_game(FALSE);
6722 /* Prompt for scores XXX XXX XXX */
6724 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6726 prt("Press Return (or Escape).", 0, 40);
6730 /* Predict score (or ESCAPE) */
6731 if (inkey() != ESCAPE) predict_score();
6735 /* Shut the high score file */
6736 (void)fd_close(highscore_fd);
6738 /* Forget the high score fd */
6742 /* Allow suspending now */
6743 signals_handle_tstp();
6748 * Handle abrupt death of the visual system
6750 * This routine is called only in very rare situations, and only
6751 * by certain visual systems, when they experience fatal errors.
6753 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6754 * save file so that player can see tombstone when restart.
6756 void exit_game_panic(void)
6758 /* If nothing important has happened, just quit */
6760 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6762 if (!character_generated || character_saved) quit("panic");
6766 /* Mega-Hack -- see "msg_print()" */
6769 /* Clear the top line */
6772 /* Hack -- turn off some things */
6775 /* Mega-Hack -- Delay death */
6776 if (p_ptr->chp < 0) death = FALSE;
6778 /* Hardcode panic save */
6781 /* Forbid suspend */
6782 signals_ignore_tstp();
6784 /* Indicate panic save */
6786 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6788 (void)strcpy(died_from, "(panic save)");
6792 /* Panic save, or get worried */
6794 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6796 if (!save_player()) quit("panic save failed!");
6800 /* Successful panic save */
6802 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6804 quit("panic save succeeded!");
6811 * Get a random line from a file
6812 * Based on the monster speech patch by Matt Graham,
6814 errr get_rnd_line(cptr file_name, int entry, char *output)
6818 int line, counter, test, numentries;
6823 /* Build the filename */
6824 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6827 fp = my_fopen(buf, "r");
6830 if (!fp) return (-1);
6832 /* Find the entry of the monster */
6835 /* Get a line from the file */
6836 if (my_fgets(fp, buf, 1024) == 0)
6838 /* Count the lines */
6841 /* Look for lines starting with 'N:' */
6842 if ((buf[0] == 'N') && (buf[1] == ':'))
6844 /* Allow default lines */
6851 else if (buf[2] == 'M')
6853 if (r_info[entry].flags1 & RF1_MALE)
6859 else if (buf[2] == 'F')
6861 if (r_info[entry].flags1 & RF1_FEMALE)
6867 /* Get the monster number */
6868 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6870 /* Is it the right monster? */
6879 /* Error while converting the monster number */
6880 msg_format("Error in line %d of %s!",
6881 line_num, file_name);
6889 /* Reached end of file */
6896 /* Get the number of entries */
6900 if (my_fgets(fp, buf, 1024) == 0)
6902 /* Count the lines */
6905 /* Look for the number of entries */
6906 if (isdigit(buf[0]))
6908 /* Get the number of entries */
6909 numentries = atoi(buf);
6915 /* Count the lines */
6918 /* Reached end of file without finding the number */
6919 msg_format("Error in line %d of %s!",
6920 line_num, file_name);
6929 /* Grab an appropriate line number */
6930 line = rand_int(numentries);
6932 /* Get the random line */
6933 for (counter = 0; counter <= line; counter++)
6935 /* Count the lines */
6940 test = my_fgets(fp, buf, 1024);
6941 if(test || buf[0] != '#')
6947 /* Found the line */
6948 if (counter == line) break;
6952 /* Error - End of file */
6953 msg_format("Error in line %d of %s!",
6954 line_num, file_name);
6962 strcpy(output, buf);
6969 /* Close the file */
6978 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
6982 for (i=0;i<count;i++){
6983 result=get_rnd_line(file_name, entry, output);
6986 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
6994 * Process file for auto picker/destroyer.
6996 errr process_pickpref_file(cptr name)
7005 /* Build the filename */
7006 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7008 err = process_pref_file_aux(buf, TRUE);
7017 static errr counts_seek(int fd, u32b where, bool flag)
7020 char temp1[128], temp2[128];
7021 u32b zero_header[3] = {0L, 0L, 0L};
7024 #ifdef SAVEFILE_USE_UID
7025 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7027 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7029 for (i = 0; temp1[i]; i++)
7030 temp1[i] ^= (i+1) * 63;
7035 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7037 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7042 fd_seek(fd, seekpoint);
7043 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7044 fd_write(fd, (char*)(temp1), sizeof(temp1));
7048 if (strcmp(temp1, temp2) == 0)
7051 seekpoint += 128 + 3 * sizeof(u32b);
7054 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7057 u32b counts_read(int where)
7064 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7066 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7068 fd = fd_open(buf, O_RDONLY);
7070 if (counts_seek(fd, where, FALSE) ||
7071 fd_read(fd, (char*)(&count), sizeof(u32b)))
7079 errr counts_write(int where, u32b count)
7085 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7087 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7089 fd = fd_open(buf, O_RDWR);
7092 /* File type is "DATA" */
7093 FILE_TYPE(FILE_TYPE_DATA);
7095 /* Create a new high score file */
7096 fd = fd_make(buf, 0644);
7099 if (fd_lock(fd, F_WRLCK)) return 1;
7101 counts_seek(fd, where, TRUE);
7102 fd_write(fd, (char*)(&count), sizeof(u32b));
7104 if (fd_lock(fd, F_UNLCK)) return 1;
7112 #ifdef HANDLE_SIGNALS
7119 * Handle signals -- suspend
7121 * Actually suspend the game, and then resume cleanly
7123 static void handle_signal_suspend(int sig)
7125 /* Disable handler */
7126 (void)signal(sig, SIG_IGN);
7133 /* Suspend the "Term" */
7134 Term_xtra(TERM_XTRA_ALIVE, 0);
7136 /* Suspend ourself */
7137 (void)kill(0, SIGSTOP);
7139 /* Resume the "Term" */
7140 Term_xtra(TERM_XTRA_ALIVE, 1);
7142 /* Redraw the term */
7145 /* Flush the term */
7150 /* Restore handler */
7151 (void)signal(sig, handle_signal_suspend);
7156 * Handle signals -- simple (interrupt and quit)
7158 * This function was causing a *huge* number of problems, so it has
7159 * been simplified greatly. We keep a global variable which counts
7160 * the number of times the user attempts to kill the process, and
7161 * we commit suicide if the user does this a certain number of times.
7163 * We attempt to give "feedback" to the user as he approaches the
7164 * suicide thresh-hold, but without penalizing accidental keypresses.
7166 * To prevent messy accidents, we should reset this global variable
7167 * whenever the user enters a keypress, or something like that.
7169 static void handle_signal_simple(int sig)
7171 /* Disable handler */
7172 (void)signal(sig, SIG_IGN);
7175 /* Nothing to save, just quit */
7176 if (!character_generated || character_saved) quit(NULL);
7179 /* Count the signals */
7183 /* Terminate dead characters */
7186 /* Mark the savefile */
7188 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7190 (void)strcpy(died_from, "Abortion");
7209 /* Allow suicide (after 5) */
7210 else if (signal_count >= 5)
7212 /* Cause of "death" */
7214 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7216 (void)strcpy(died_from, "Interrupting");
7231 p_ptr->leaving = TRUE;
7245 /* Give warning (after 4) */
7246 else if (signal_count >= 4)
7249 Term_xtra(TERM_XTRA_NOISE, 0);
7251 /* Clear the top line */
7252 Term_erase(0, 0, 255);
7254 /* Display the cause */
7256 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7258 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7266 /* Give warning (after 2) */
7267 else if (signal_count >= 2)
7270 Term_xtra(TERM_XTRA_NOISE, 0);
7273 /* Restore handler */
7274 (void)signal(sig, handle_signal_simple);
7279 * Handle signal -- abort, kill, etc
7281 static void handle_signal_abort(int sig)
7283 /* Disable handler */
7284 (void)signal(sig, SIG_IGN);
7287 /* Nothing to save, just quit */
7288 if (!character_generated || character_saved) quit(NULL);
7295 /* Clear the bottom line */
7296 Term_erase(0, 23, 255);
7298 /* Give a warning */
7299 Term_putstr(0, 23, -1, TERM_RED,
7301 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7303 "A gruesome software bug LEAPS out at you!");
7309 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7311 Term_putstr(45, 23, -1, TERM_RED, "Panic save...");
7323 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7325 (void)strcpy(died_from, "(panic save)");
7329 /* Forbid suspend */
7330 signals_ignore_tstp();
7332 /* Attempt to save */
7336 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7338 Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
7347 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7349 Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
7359 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7361 quit("software bug");
7370 * Ignore SIGTSTP signals (keyboard suspend)
7372 void signals_ignore_tstp(void)
7376 (void)signal(SIGTSTP, SIG_IGN);
7382 * Handle SIGTSTP signals (keyboard suspend)
7384 void signals_handle_tstp(void)
7388 (void)signal(SIGTSTP, handle_signal_suspend);
7395 * Prepare to handle the relevant signals
7397 void signals_init(void)
7401 (void)signal(SIGHUP, SIG_IGN);
7406 (void)signal(SIGTSTP, handle_signal_suspend);
7411 (void)signal(SIGINT, handle_signal_simple);
7415 (void)signal(SIGQUIT, handle_signal_simple);
7420 (void)signal(SIGFPE, handle_signal_abort);
7424 (void)signal(SIGILL, handle_signal_abort);
7428 (void)signal(SIGTRAP, handle_signal_abort);
7432 (void)signal(SIGIOT, handle_signal_abort);
7436 (void)signal(SIGKILL, handle_signal_abort);
7440 (void)signal(SIGBUS, handle_signal_abort);
7444 (void)signal(SIGSEGV, handle_signal_abort);
7448 (void)signal(SIGTERM, handle_signal_abort);
7452 (void)signal(SIGPIPE, handle_signal_abort);
7456 (void)signal(SIGEMT, handle_signal_abort);
7460 (void)signal(SIGDANGER, handle_signal_abort);
7464 (void)signal(SIGSYS, handle_signal_abort);
7468 (void)signal(SIGXCPU, handle_signal_abort);
7472 (void)signal(SIGPWR, handle_signal_abort);
7478 #else /* HANDLE_SIGNALS */
7484 void signals_ignore_tstp(void)
7491 void signals_handle_tstp(void)
7498 void signals_init(void)
7501 #endif /* HANDLE_SIGNALS */