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 */
1249 /* Build the filename */
1250 path_build(buf, 1024, ANGBAND_DIR_USER, name);
1252 /* Process the pref file */
1253 err = process_pref_file_aux(buf, FALSE);
1265 * Operating hours for ANGBAND (defaults to non-work hours)
1267 static char days[7][29] =
1269 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1270 "MON:XXXXXXXX.........XXXXXXX",
1271 "TUE:XXXXXXXX.........XXXXXXX",
1272 "WED:XXXXXXXX.........XXXXXXX",
1273 "THU:XXXXXXXX.........XXXXXXX",
1274 "FRI:XXXXXXXX.........XXXXXXX",
1275 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1279 * Restict usage (defaults to no restrictions)
1281 static bool check_time_flag = FALSE;
1289 errr check_time(void)
1297 /* No restrictions */
1298 if (!check_time_flag) return (0);
1300 /* Check for time violation */
1301 c = time((time_t *)0);
1305 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1316 * Initialize CHECK_TIME
1318 errr check_time_init(void)
1328 /* Build the filename */
1329 path_build(buf, 1024, ANGBAND_DIR_FILE, "time.txt");
1332 fp = my_fopen(buf, "r");
1334 /* No file, no restrictions */
1335 if (!fp) return (0);
1337 /* Assume restrictions */
1338 check_time_flag = TRUE;
1340 /* Parse the file */
1341 while (0 == my_fgets(fp, buf, 80))
1343 /* Skip comments and blank lines */
1344 if (!buf[0] || (buf[0] == '#')) continue;
1346 /* Chop the buffer */
1349 /* Extract the info */
1350 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1351 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1352 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1353 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1354 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1355 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1356 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1372 #ifndef MAXHOSTNAMELEN
1373 # define MAXHOSTNAMELEN 64
1376 typedef struct statstime statstime;
1382 unsigned int v_pgpgin;
1383 unsigned int v_pgpgout;
1384 unsigned int v_pswpin;
1385 unsigned int v_pswpout;
1386 unsigned int v_intr;
1392 unsigned int v_swtch;
1394 struct timeval boottime;
1395 struct timeval curtime;
1399 * Maximal load (if any).
1401 static int check_load_value = 0;
1409 errr check_load(void)
1414 struct statstime st;
1416 /* Success if not checking */
1417 if (!check_load_value) return (0);
1419 /* Check the load */
1420 if (0 == rstat("localhost", &st))
1422 long val1 = (long)(st.avenrun[2]);
1423 long val2 = (long)(check_load_value) * FSCALE;
1425 /* Check for violation */
1426 if (val1 >= val2) return (1);
1437 * Initialize CHECK_LOAD
1439 errr check_load_init(void)
1448 char temphost[MAXHOSTNAMELEN+1];
1449 char thishost[MAXHOSTNAMELEN+1];
1452 /* Build the filename */
1453 path_build(buf, 1024, ANGBAND_DIR_FILE, "load.txt");
1455 /* Open the "load" file */
1456 fp = my_fopen(buf, "r");
1458 /* No file, no restrictions */
1459 if (!fp) return (0);
1462 check_load_value = 100;
1464 /* Get the host name */
1465 (void)gethostname(thishost, (sizeof thishost) - 1);
1468 while (0 == my_fgets(fp, buf, 1024))
1472 /* Skip comments and blank lines */
1473 if (!buf[0] || (buf[0] == '#')) continue;
1475 /* Parse, or ignore */
1476 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1478 /* Skip other hosts */
1479 if (!streq(temphost, thishost) &&
1480 !streq(temphost, "localhost")) continue;
1482 /* Use that value */
1483 check_load_value = value;
1489 /* Close the file */
1500 * Print long number with header at given row, column
1501 * Use the color for the number, not the header
1503 static void prt_lnum(cptr header, s32b num, int row, int col, byte color)
1505 int len = strlen(header);
1507 put_str(header, row, col);
1508 (void)sprintf(out_val, "%9ld", (long)num);
1509 c_put_str(color, out_val, row, col + len);
1514 * Print number with header at given row, column
1516 static void prt_num(cptr header, int num, int row, int col, byte color)
1518 int len = strlen(header);
1520 put_str(header, row, col);
1521 put_str(" ", row, col + len);
1522 (void)sprintf(out_val, "%6ld", (long)num);
1523 c_put_str(color, out_val, row, col + len + 3);
1529 * £È£Ð / ºÇÂç ¤Î¤è¤¦¤Êɽ¼¨
1532 static void prt_num_max( int num, int max , int row, int col, byte color1, byte color2 )
1535 (void)sprintf(out_val, "%5ld", (long)num);
1536 c_put_str(color1, out_val, row, col );
1537 put_str("/",row, col+6);
1538 (void)sprintf(out_val, "%5ld", (long)max);
1539 c_put_str(color2, out_val, row, col+8 );
1543 * xx ºÐ ¤È¤« xx kg ¤Ê¤É¤Îɽ¼¨ÍÑ cptr tailer ¤Ëñ°Ì¤¬Æþ¤ë¡£
1545 static void prt_num2(cptr header, cptr tailer, int num, int row, int col, byte color)
1547 int len = strlen(header);
1549 put_str(header, row, col);
1550 put_str(" ", row, col + len);
1551 (void)sprintf(out_val, "%6ld", (long)num);
1552 c_put_str(color, out_val, row, col + len + 3);
1553 put_str(tailer, row, col + len + 3+6);
1557 #define ENTRY_BARE_HAND 0
1558 #define ENTRY_TWO_HANDS 1
1559 #define ENTRY_RIGHT_HAND1 2
1560 #define ENTRY_LEFT_HAND1 3
1561 #define ENTRY_LEFT_HAND2 4
1562 #define ENTRY_RIGHT_HAND2 5
1563 #define ENTRY_POSTURE 6
1564 #define ENTRY_SHOOT_HIT_DAM 7
1565 #define ENTRY_SHOOT_POWER 8
1566 #define ENTRY_SPEED 9
1567 #define ENTRY_BASE_AC 10
1568 #define ENTRY_LEVEL 11
1569 #define ENTRY_CUR_EXP 12
1570 #define ENTRY_MAX_EXP 13
1571 #define ENTRY_EXP_TO_ADV 14
1572 #define ENTRY_GOLD 15
1573 #define ENTRY_TURN 16
1576 #define ENTRY_PLAY_TIME 19
1577 #define ENTRY_SKILL_FIGHT 20
1578 #define ENTRY_SKILL_SHOOT 21
1579 #define ENTRY_SKILL_SAVING 22
1580 #define ENTRY_SKILL_STEALTH 23
1581 #define ENTRY_SKILL_PERCEP 24
1582 #define ENTRY_SKILL_SEARCH 25
1583 #define ENTRY_SKILL_DISARM 26
1584 #define ENTRY_SKILL_DEVICE 27
1585 #define ENTRY_BLOWS 28
1586 #define ENTRY_SHOTS 29
1587 #define ENTRY_AVG_DMG 30
1588 #define ENTRY_INFRA 31
1590 #define ENTRY_NAME 32
1591 #define ENTRY_SEX 33
1592 #define ENTRY_RACE 34
1593 #define ENTRY_CLASS 35
1594 #define ENTRY_REALM 36
1595 #define ENTRY_PATRON 37
1596 #define ENTRY_AGE 38
1597 #define ENTRY_HEIGHT 39
1598 #define ENTRY_WEIGHT 40
1599 #define ENTRY_SOCIAL 41
1600 #define ENTRY_ALIGN 42
1609 } disp_player_line[]
1612 { 1, 10, 25, "ÂǷ⽤Àµ(³ÊÆ®)"},
1613 { 1, 10, 25, "ÂǷ⽤Àµ(ξ¼ê)"},
1614 { 1, 10, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1615 { 1, 10, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1616 { 1, 11, 25, "ÂǷ⽤Àµ(º¸¼ê)"},
1617 { 1, 11, 25, "ÂǷ⽤Àµ(±¦¼ê)"},
1619 { 1, 15, 25, "¼Í·â¹¶·â½¤Àµ"},
1620 { 1, 16, 25, "¼Í·âÉð´ïÇÜΨ"},
1621 {01, 20, 25, "²Ã®"},
1622 { 1, 19, 25, "£Á£Ã"},
1623 {29, 13, 21, "¥ì¥Ù¥ë"},
1624 {29, 14, 21, "·Ð¸³ÃÍ"},
1625 {29, 15, 21, "ºÇÂç·Ð¸³"},
1626 {29, 16, 21, "¼¡¥ì¥Ù¥ë"},
1627 {29, 17, 21, "½ê»ý¶â"},
1628 {29, 19, 21, "¥¿¡¼¥ó¿ô"},
1629 {29, 10, 21, "£È£Ð"},
1630 {29, 11, 21, "£Í£Ð"},
1631 {29, 20, 21, "¥×¥ì¥¤»þ´Ö"},
1632 {54, 10, -1, "ÂǷ⹶·â :"},
1633 {54, 11, -1, "¼Í·â¹¶·â :"},
1634 {54, 12, -1, "ËâË¡Ëɸæ :"},
1635 {54, 13, -1, "±£Ì©¹ÔÆ° :"},
1636 {54, 14, -1, "ÃγР:"},
1637 {54, 15, -1, "õº÷ :"},
1638 {54, 16, -1, "²ò½ü :"},
1639 {54, 17, -1, "ËâË¡Æ»¶ñ :"},
1640 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1641 {01, 17, 25, "¼Í·â²ó¿ô"},
1642 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1643 {54, 19, -1, "ÀÖ³°Àþ»ëÎÏ:"},
1644 {26, 1, -1, "̾Á° : "},
1645 { 1, 3, -1, "ÀÊÌ : "},
1646 { 1, 4, -1, "¼ï² : "},
1647 { 1, 5, -1, "¿¦¶È : "},
1648 { 1, 6, -1, "ËâË¡ : "},
1649 { 1, 7, -1, "¼é¸îËâ¿À : "},
1650 {29, 3, 21, "ǯÎð"},
1651 {29, 4, 21, "¿ÈĹ"},
1652 {29, 5, 21, "ÂνÅ"},
1653 {29, 6, 21, "¼Ò²ñŪÃÏ°Ì"},
1654 {29, 8, 21, "°À"},
1658 { 1, 10, 25, "Bare hand"},
1659 { 1, 10, 25, "Two hands"},
1660 { 1, 10, 25, "Right hand"},
1661 { 1, 10, 25, "Left hand"},
1662 { 1, 11, 25, "Left hand"},
1663 { 1, 11, 25, "Right hand"},
1664 { 1, 11, 25, "Posture"},
1665 { 1, 15, 25, "Shoot"},
1666 { 1, 16, 25, "Shoot Power"},
1667 {01, 20, 25, "Speed"},
1669 {29, 13, 21, "Level"},
1670 {29, 14, 21, "Experience"},
1671 {29, 15, 21, "Max Exp"},
1672 {29, 16, 21, "Exp to Adv"},
1673 {29, 17, 21, "Gold"},
1674 {29, 19, 21, "Total turn"},
1675 {29, 10, 21, "Hit point"},
1676 {29, 11, 21, "SP (Mana)"},
1677 {29, 20, 21, "Play time"},
1678 {54, 10, -1, "Fighting : "},
1679 {54, 11, -1, "Bows/Throw : "},
1680 {54, 12, -1, "Saving Throw: "},
1681 {54, 13, -1, "Stealth : "},
1682 {54, 14, -1, "Perception : "},
1683 {54, 15, -1, "Searching : "},
1684 {54, 16, -1, "Disarming : "},
1685 {54, 17, -1, "Magic Device: "},
1686 {01, 12, 25, "Blows/Round"},
1687 {01, 17, 25, "Shots/Round"},
1688 {01, 13, 25, "Wpn.dmg/Rnd"},
1689 {54, 19, -1, "Infra-Vision: "},
1690 {26, 1, -1, "Name : "},
1691 { 1, 3, -1, "Sex : "},
1692 { 1, 4, -1, "Race : "},
1693 { 1, 5, -1, "Class : "},
1694 { 1, 6, -1, "Magic : "},
1695 { 1, 7, -1, "Patron : "},
1697 {29, 4, 21, "Height"},
1698 {29, 5, 21, "Weight"},
1699 {29, 6, 21, "Social Class"},
1700 {29, 8, 21, "Alignment"},
1704 static void display_player_one_line(int entry, cptr val, byte attr)
1708 int row = disp_player_line[entry].row;
1709 int col = disp_player_line[entry].col;
1710 int len = disp_player_line[entry].len;
1711 cptr head = disp_player_line[entry].header;
1713 int head_len = strlen(head);
1715 Term_putstr(col, row, -1, TERM_WHITE, head);
1722 int val_len = len - head_len;
1723 sprintf(buf, "%*.*s", val_len, val_len, val);
1724 Term_putstr(col + head_len, row, -1, attr, buf);
1728 Term_putstr(col + head_len, row, -1, attr, val);
1736 * Prints the following information on the screen.
1738 * For this to look right, the following should be spaced the
1739 * same as in the prt_lnum code... -CFT
1741 static void display_player_middle(void)
1744 int show_tohit, show_todam;
1750 show_tohit = p_ptr->dis_to_h[0];
1751 show_todam = p_ptr->dis_to_d[0];
1753 o_ptr = &inventory[INVEN_RARM];
1755 /* Hack -- add in weapon info if known */
1756 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1757 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1760 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1762 /* Dump the bonuses to hit/dam */
1763 if(!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1764 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1765 else if(p_ptr->ryoute)
1766 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1767 else if (left_hander)
1768 display_player_one_line(ENTRY_LEFT_HAND1, buf, TERM_L_BLUE);
1770 display_player_one_line(ENTRY_RIGHT_HAND1, buf, TERM_L_BLUE);
1775 show_tohit = p_ptr->dis_to_h[1];
1776 show_todam = p_ptr->dis_to_d[1];
1778 o_ptr = &inventory[INVEN_LARM];
1780 /* Hack -- add in weapon info if known */
1781 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1782 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1785 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1787 /* Dump the bonuses to hit/dam */
1789 display_player_one_line(ENTRY_RIGHT_HAND2, buf, TERM_L_BLUE);
1791 display_player_one_line(ENTRY_LEFT_HAND2, buf, TERM_L_BLUE);
1793 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) > 1))
1796 if (p_ptr->special_defense & KAMAE_MASK)
1798 for (i = 0; i < MAX_KAMAE; i++)
1800 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1804 display_player_one_line(ENTRY_POSTURE, format("%s¤Î¹½¤¨", kamae_shurui[i].desc), TERM_YELLOW);
1806 display_player_one_line(ENTRY_POSTURE, format("%s form", kamae_shurui[i].desc), TERM_YELLOW);
1811 display_player_one_line(ENTRY_POSTURE, "¹½¤¨¤Ê¤·", TERM_YELLOW);
1813 display_player_one_line(ENTRY_POSTURE, "none", TERM_YELLOW);
1818 o_ptr = &inventory[INVEN_BOW];
1821 show_tohit = p_ptr->dis_to_h_b;
1824 /* Apply weapon bonuses */
1825 if (object_known_p(o_ptr)) show_tohit += o_ptr->to_h;
1826 if (object_known_p(o_ptr)) show_todam += o_ptr->to_d;
1828 show_tohit += (weapon_exp[0][o_ptr->sval]-4000)/200;
1831 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1833 if (inventory[INVEN_BOW].k_idx)
1835 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1837 /* Get extra "power" from "extra might" */
1838 if (p_ptr->xtra_might) tmul++;
1840 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1844 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1846 /* Dump the armor class */
1847 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1851 bool is_fast = (p_ptr->fast || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO));
1856 i = p_ptr->pspeed-110;
1858 /* Hack -- Visually "undo" the Search Mode Slowdown */
1859 if (p_ptr->action == ACTION_SEARCH) i += 10;
1862 attr = TERM_L_GREEN;
1866 attr = TERM_L_UMBER;
1868 if (is_fast) tmp_speed += 10;
1869 if (p_ptr->slow) tmp_speed -= 10;
1870 if (p_ptr->lightspeed) tmp_speed = 99;
1874 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1882 sprintf(buf, "(%+d)", i);
1885 display_player_one_line(ENTRY_SPEED, buf, attr);
1888 /* Dump character level */
1889 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1891 /* Dump experience */
1892 if (p_ptr->prace == RACE_ANDROID)
1893 display_player_one_line(ENTRY_CUR_EXP, "*****", TERM_L_GREEN);
1894 else if (p_ptr->exp >= p_ptr->max_exp)
1895 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_L_GREEN);
1897 display_player_one_line(ENTRY_CUR_EXP, format("%ld", p_ptr->exp), TERM_YELLOW);
1899 /* Dump max experience */
1900 if (p_ptr->prace == RACE_ANDROID)
1901 display_player_one_line(ENTRY_MAX_EXP, "*****", TERM_L_GREEN);
1903 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1905 /* Dump exp to advance */
1906 if ((p_ptr->lev >= PY_MAX_LEVEL) || (p_ptr->prace == RACE_ANDROID))
1907 display_player_one_line(ENTRY_EXP_TO_ADV, "*****", TERM_L_GREEN);
1909 display_player_one_line(ENTRY_EXP_TO_ADV, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1912 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1915 display_player_one_line(ENTRY_TURN, format("%ld", MAX(turn_real(turn),0)), TERM_L_GREEN);
1917 /* Dump hit point */
1918 if (p_ptr->chp >= p_ptr->mhp)
1919 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1920 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1921 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1923 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1925 /* Dump mana power */
1926 if (p_ptr->csp >= p_ptr->msp)
1927 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1928 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1929 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1931 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1933 /* Dump play time */
1934 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1939 * Hack -- pass color info around this file
1941 static byte likert_color = TERM_WHITE;
1945 * Returns a "rating" of x depending on y
1947 static cptr likert(int x, int y)
1949 static char dummy[20] = "";
1954 /* Negative value */
1957 likert_color = TERM_L_DARK;
1961 return ("Very Bad");
1966 /* Analyze the value */
1972 likert_color = TERM_RED;
1982 likert_color = TERM_L_RED;
1993 likert_color = TERM_ORANGE;
2003 likert_color = TERM_YELLOW;
2013 likert_color = TERM_YELLOW;
2015 return ("ÂçÊÑÎɤ¤");
2017 return ("Very Good");
2024 likert_color = TERM_L_GREEN;
2028 return ("Excellent");
2038 likert_color = TERM_GREEN;
2051 likert_color = TERM_BLUE;
2053 return ("¥«¥ª¥¹¥é¥ó¥¯");
2055 return ("Chaos Rank");
2061 likert_color = TERM_VIOLET;
2063 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2065 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2075 * Prints ratings on certain abilities
2077 * This code is "imitated" elsewhere to "dump" a character sheet.
2079 static void display_player_various(void)
2081 int tmp, damage[2], blows1, blows2, i, basedam;
2082 int xthn, xthb, xfos, xsrh;
2083 int xdis, xdev, xsav, xstl;
2087 int shots, shot_frac;
2091 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2092 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2093 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2094 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2095 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2097 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2099 /* Shooting Skill (with current bow and normal missile) */
2100 o_ptr = &inventory[INVEN_BOW];
2101 tmp = p_ptr->to_h_b + o_ptr->to_h;
2102 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2104 /* If the player is wielding one? */
2107 s16b energy_fire = bow_energy(o_ptr->sval);
2109 /* Calculate shots per round */
2110 shots = p_ptr->num_fire * 100;
2111 shot_frac = (shots * 100 / energy_fire) % 100;
2112 shots = shots / energy_fire;
2113 if (o_ptr->name1 == ART_CRIMSON)
2117 if (p_ptr->pclass == CLASS_ARCHER)
2119 /* Extra shot at level 10 */
2120 if (p_ptr->lev >= 10) shots++;
2122 /* Extra shot at level 30 */
2123 if (p_ptr->lev >= 30) shots++;
2125 /* Extra shot at level 45 */
2126 if (p_ptr->lev >= 45) shots++;
2136 for(i = 0; i< 2; i++)
2138 damage[i] = p_ptr->dis_to_d[i]*100;
2139 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2141 int level = p_ptr->lev;
2147 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2148 if (p_ptr->special_defense & KAMAE_BYAKKO)
2149 basedam = monk_ave_damage[level][1];
2150 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2151 basedam = monk_ave_damage[level][2];
2153 basedam = monk_ave_damage[level][0];
2157 /* Average damage per round */
2158 o_ptr = &inventory[INVEN_RARM+i];
2159 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2160 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2161 object_flags(o_ptr, &f1, &f2, &f3);
2162 if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
2168 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2170 /* vorpal flag only */
2174 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)))
2175 basedam = basedam * 7 / 2;
2176 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2177 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2179 damage[i] += basedam;
2180 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2181 if (damage[i] < 0) damage[i] = 0;
2183 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2184 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2186 /* Basic abilities */
2188 xdis = p_ptr->skill_dis;
2189 xdev = p_ptr->skill_dev;
2190 xsav = p_ptr->skill_sav;
2191 xstl = p_ptr->skill_stl;
2192 xsrh = p_ptr->skill_srh;
2193 xfos = p_ptr->skill_fos;
2196 desc = likert(xthn, 12);
2197 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2199 desc = likert(xthb, 12);
2200 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2202 desc = likert(xsav, 7);
2203 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2205 desc = likert(xstl, 1);
2206 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2208 desc = likert(xfos, 6);
2209 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2211 desc = likert(xsrh, 6);
2212 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2214 desc = likert(xdis, 8);
2215 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2217 desc = likert(xdev, 6);
2218 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2221 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2223 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2225 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2228 if ((damage[0]+damage[1]) == 0)
2231 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2233 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2235 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2241 * Obtain the "flags" for the player as if he was an item
2243 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2246 (*f1) = (*f2) = (*f3) = 0L;
2249 switch (p_ptr->pclass)
2252 if (p_ptr->lev > 44)
2253 (*f3) |= (TR3_REGEN);
2255 if (p_ptr->lev > 29)
2256 (*f2) |= (TR2_RES_FEAR);
2259 if (p_ptr->lev > 39)
2260 (*f2) |= (TR2_RES_FEAR);
2262 case CLASS_CHAOS_WARRIOR:
2263 if (p_ptr->lev > 29)
2264 (*f2) |= (TR2_RES_CHAOS);
2265 if (p_ptr->lev > 39)
2266 (*f2) |= (TR2_RES_FEAR);
2269 case CLASS_FORCETRAINER:
2270 if ((p_ptr->lev > 9) && !heavy_armor())
2272 if ((p_ptr->lev>24) && !heavy_armor())
2273 (*f2) |= (TR2_FREE_ACT);
2280 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2283 (*f2) |= (TR2_FREE_ACT);
2285 (*f3) |= TR3_SLOW_DIGEST;
2286 (*f2) |= TR2_RES_FEAR;
2287 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2288 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2289 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2291 case CLASS_MINDCRAFTER:
2293 (*f2) |= (TR2_RES_FEAR);
2294 if (p_ptr->lev > 19)
2295 (*f2) |= (TR2_SUST_WIS);
2296 if (p_ptr->lev > 29)
2297 (*f2) |= (TR2_RES_CONF);
2298 if (p_ptr->lev > 39)
2299 (*f3) |= (TR3_TELEPATHY);
2302 (*f2) |= (TR2_RES_SOUND);
2304 case CLASS_BERSERKER:
2305 (*f2) |= (TR2_SUST_STR);
2306 (*f2) |= (TR2_SUST_DEX);
2307 (*f2) |= (TR2_SUST_CON);
2308 (*f3) |= (TR3_REGEN);
2309 (*f2) |= (TR2_FREE_ACT);
2310 (*f1) |= (TR1_SPEED);
2311 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2313 case CLASS_MIRROR_MASTER:
2314 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2317 break; /* Do nothing */
2321 if (p_ptr->mimic_form)
2323 switch(p_ptr->mimic_form)
2326 (*f2) |= (TR2_HOLD_LIFE);
2327 (*f2) |= (TR2_RES_CHAOS);
2328 (*f2) |= (TR2_RES_NETHER);
2329 (*f2) |= (TR2_RES_FIRE);
2330 (*f3) |= (TR3_SEE_INVIS);
2331 (*f1) |= (TR1_SPEED);
2333 case MIMIC_DEMON_LORD:
2334 (*f2) |= (TR2_HOLD_LIFE);
2335 (*f2) |= (TR2_RES_CHAOS);
2336 (*f2) |= (TR2_RES_NETHER);
2337 (*f2) |= (TR2_RES_FIRE);
2338 (*f2) |= (TR2_RES_COLD);
2339 (*f2) |= (TR2_RES_ELEC);
2340 (*f2) |= (TR2_RES_ACID);
2341 (*f2) |= (TR2_RES_POIS);
2342 (*f2) |= (TR2_RES_CONF);
2343 (*f2) |= (TR2_RES_DISEN);
2344 (*f2) |= (TR2_RES_NEXUS);
2345 (*f2) |= (TR2_RES_FEAR);
2346 (*f2) |= (TR2_IM_FIRE);
2347 (*f3) |= (TR3_SH_FIRE);
2348 (*f3) |= (TR3_SEE_INVIS);
2349 (*f3) |= (TR3_TELEPATHY);
2350 (*f3) |= (TR3_FEATHER);
2351 (*f1) |= (TR1_SPEED);
2354 (*f2) |= (TR2_HOLD_LIFE);
2355 (*f2) |= (TR2_RES_DARK);
2356 (*f2) |= (TR2_RES_NETHER);
2357 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2358 (*f2) |= (TR2_RES_POIS);
2359 (*f2) |= (TR2_RES_COLD);
2360 (*f3) |= (TR3_SEE_INVIS);
2361 (*f1) |= (TR1_SPEED);
2367 switch (p_ptr->prace)
2370 (*f2) |= (TR2_RES_LITE);
2373 (*f2) |= (TR2_SUST_DEX);
2376 (*f2) |= (TR2_FREE_ACT);
2379 (*f2) |= (TR2_RES_BLIND);
2382 (*f2) |= (TR2_RES_DARK);
2384 case RACE_HALF_TROLL:
2385 (*f2) |= (TR2_SUST_STR);
2386 if (p_ptr->lev > 14)
2388 (*f3) |= (TR3_REGEN);
2389 if (p_ptr->pclass == CLASS_WARRIOR)
2391 (*f3) |= (TR3_SLOW_DIGEST);
2393 * Let's not make Regeneration a disadvantage
2394 * for the poor warriors who can never learn
2395 * a spell that satisfies hunger (actually
2396 * neither can rogues, but half-trolls are not
2397 * supposed to play rogues)
2403 (*f2) |= (TR2_SUST_CON);
2404 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2407 (*f2) |= (TR2_RES_LITE);
2408 (*f3) |= (TR3_SEE_INVIS);
2410 case RACE_BARBARIAN:
2411 (*f2) |= (TR2_RES_FEAR);
2413 case RACE_HALF_OGRE:
2414 (*f2) |= (TR2_SUST_STR);
2415 (*f2) |= (TR2_RES_DARK);
2417 case RACE_HALF_GIANT:
2418 (*f2) |= (TR2_RES_SHARDS);
2419 (*f2) |= (TR2_SUST_STR);
2421 case RACE_HALF_TITAN:
2422 (*f2) |= (TR2_RES_CHAOS);
2425 (*f2) |= (TR2_RES_SOUND);
2428 (*f2) |= (TR2_RES_ACID);
2429 if (p_ptr->lev > 19)
2430 (*f2) |= (TR2_IM_ACID);
2433 (*f2) |= (TR2_RES_CONF);
2434 (*f2) |= (TR2_RES_ACID);
2439 (*f2) |= (TR2_RES_POIS);
2442 (*f2) |= (TR2_RES_DISEN);
2443 (*f2) |= (TR2_RES_DARK);
2446 (*f2) |= (TR2_RES_DARK);
2447 if (p_ptr->lev > 19)
2448 (*f3) |= (TR3_SEE_INVIS);
2450 case RACE_DRACONIAN:
2451 (*f3) |= TR3_FEATHER;
2453 (*f2) |= (TR2_RES_FIRE);
2455 (*f2) |= (TR2_RES_COLD);
2456 if (p_ptr->lev > 14)
2457 (*f2) |= (TR2_RES_ACID);
2458 if (p_ptr->lev > 19)
2459 (*f2) |= (TR2_RES_ELEC);
2460 if (p_ptr->lev > 34)
2461 (*f2) |= (TR2_RES_POIS);
2463 case RACE_MIND_FLAYER:
2464 (*f2) |= (TR2_SUST_INT);
2465 (*f2) |= (TR2_SUST_WIS);
2466 if (p_ptr->lev > 14)
2467 (*f3) |= (TR3_SEE_INVIS);
2468 if (p_ptr->lev > 29)
2469 (*f3) |= (TR3_TELEPATHY);
2472 (*f2) |= (TR2_RES_FIRE);
2474 (*f3) |= (TR3_SEE_INVIS);
2477 (*f3) |= (TR3_SEE_INVIS);
2478 (*f2) |= (TR2_FREE_ACT);
2479 (*f2) |= (TR2_RES_POIS);
2480 (*f3) |= (TR3_SLOW_DIGEST);
2481 if (p_ptr->lev > 34)
2482 (*f2) |= (TR2_HOLD_LIFE);
2485 (*f3) |= (TR3_SEE_INVIS);
2486 (*f2) |= (TR2_RES_SHARDS);
2487 (*f2) |= (TR2_HOLD_LIFE);
2488 (*f2) |= (TR2_RES_POIS);
2490 (*f2) |= (TR2_RES_COLD);
2493 (*f3) |= (TR3_SEE_INVIS);
2494 (*f2) |= (TR2_HOLD_LIFE);
2495 (*f2) |= (TR2_RES_NETHER);
2496 (*f2) |= (TR2_RES_POIS);
2497 (*f3) |= (TR3_SLOW_DIGEST);
2499 (*f2) |= (TR2_RES_COLD);
2502 (*f2) |= (TR2_HOLD_LIFE);
2503 (*f2) |= (TR2_RES_DARK);
2504 (*f2) |= (TR2_RES_NETHER);
2505 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2506 (*f2) |= (TR2_RES_POIS);
2507 (*f2) |= (TR2_RES_COLD);
2510 (*f3) |= (TR3_FEATHER);
2511 (*f2) |= (TR2_FREE_ACT);
2512 (*f2) |= (TR2_RES_COLD);
2513 (*f3) |= (TR3_SEE_INVIS);
2514 (*f2) |= (TR2_HOLD_LIFE);
2515 (*f2) |= (TR2_RES_NETHER);
2516 (*f2) |= (TR2_RES_POIS);
2517 (*f3) |= (TR3_SLOW_DIGEST);
2519 if (p_ptr->lev > 34)
2520 (*f3) |= TR3_TELEPATHY;
2523 (*f2) |= (TR2_RES_LITE);
2524 (*f3) |= (TR3_FEATHER);
2526 (*f1) |= (TR1_SPEED);
2529 (*f2) |= (TR2_RES_SOUND);
2530 (*f2) |= (TR2_RES_CONF);
2533 (*f3) |= (TR3_FEATHER);
2534 (*f3) |= (TR3_SEE_INVIS);
2537 (*f2) |= (TR2_RES_FIRE);
2538 (*f2) |= (TR2_RES_NETHER);
2539 (*f2) |= (TR2_HOLD_LIFE);
2541 (*f3) |= (TR3_SEE_INVIS);
2544 (*f2) |= (TR2_SUST_CON);
2547 (*f3) |= (TR3_FEATHER);
2550 (*f2) |= (TR2_RES_CONF);
2553 (*f2) |= (TR2_FREE_ACT);
2554 (*f2) |= (TR2_RES_POIS);
2555 (*f3) |= (TR3_SLOW_DIGEST);
2556 (*f2) |= (TR2_HOLD_LIFE);
2566 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2568 (*f3) &= ~(TR3_REGEN);
2571 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2572 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2573 (p_ptr->muta3 & MUT3_SHORT_LEG))
2578 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2580 (*f3) |= TR3_SH_ELEC;
2583 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2585 (*f3) |= TR3_SH_FIRE;
2589 if (p_ptr->muta3 & MUT3_WINGS)
2591 (*f3) |= TR3_FEATHER;
2594 if (p_ptr->muta3 & MUT3_FEARLESS)
2596 (*f2) |= (TR2_RES_FEAR);
2599 if (p_ptr->muta3 & MUT3_REGEN)
2604 if (p_ptr->muta3 & MUT3_ESP)
2606 (*f3) |= TR3_TELEPATHY;
2609 if (p_ptr->muta3 & MUT3_MOTION)
2611 (*f2) |= TR2_FREE_ACT;
2615 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2616 (*f3) |= TR3_AGGRAVATE;
2617 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2619 (*f2) |= (TR2_RES_BLIND);
2620 (*f2) |= (TR2_RES_CONF);
2621 (*f2) |= (TR2_HOLD_LIFE);
2622 (*f3) |= (TR3_LITE);
2624 (*f1) |= (TR1_SPEED);
2626 if (p_ptr->special_defense & KATA_FUUJIN)
2627 (*f2) |= TR2_REFLECT;
2628 if (p_ptr->special_defense & KAMAE_GENBU)
2629 (*f2) |= TR2_REFLECT;
2630 if (p_ptr->special_defense & KAMAE_SUZAKU)
2631 (*f3) |= TR3_FEATHER;
2632 if (p_ptr->special_defense & KAMAE_SEIRYU)
2634 (*f2) |= (TR2_RES_FIRE);
2635 (*f2) |= (TR2_RES_COLD);
2636 (*f2) |= (TR2_RES_ACID);
2637 (*f2) |= (TR2_RES_ELEC);
2638 (*f2) |= (TR2_RES_POIS);
2639 (*f3) |= (TR3_FEATHER);
2640 (*f3) |= (TR3_SH_FIRE);
2641 (*f3) |= (TR3_SH_ELEC);
2642 (*f3) |= (TR3_SH_COLD);
2644 if (p_ptr->special_defense & KATA_MUSOU)
2646 (*f2) |= TR2_RES_FEAR;
2647 (*f2) |= TR2_RES_LITE;
2648 (*f2) |= TR2_RES_DARK;
2649 (*f2) |= TR2_RES_BLIND;
2650 (*f2) |= TR2_RES_CONF;
2651 (*f2) |= TR2_RES_SOUND;
2652 (*f2) |= TR2_RES_SHARDS;
2653 (*f2) |= TR2_RES_NETHER;
2654 (*f2) |= TR2_RES_NEXUS;
2655 (*f2) |= TR2_RES_CHAOS;
2656 (*f2) |= TR2_RES_DISEN;
2657 (*f2) |= TR2_REFLECT;
2658 (*f2) |= TR2_HOLD_LIFE;
2659 (*f2) |= TR2_FREE_ACT;
2660 (*f3) |= TR3_SH_FIRE;
2661 (*f3) |= TR3_SH_ELEC;
2662 (*f3) |= TR3_SH_COLD;
2663 (*f3) |= TR3_FEATHER;
2665 (*f3) |= TR3_SEE_INVIS;
2666 (*f3) |= TR3_TELEPATHY;
2667 (*f3) |= TR3_SLOW_DIGEST;
2669 (*f2) |= (TR2_SUST_STR);
2670 (*f2) |= (TR2_SUST_INT);
2671 (*f2) |= (TR2_SUST_WIS);
2672 (*f2) |= (TR2_SUST_DEX);
2673 (*f2) |= (TR2_SUST_CON);
2674 (*f2) |= (TR2_SUST_CHR);
2679 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2682 (*f1) = (*f2) = (*f3) = 0L;
2684 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2685 (*f2) |= TR2_RES_FEAR;
2686 if (p_ptr->tim_invis)
2687 (*f3) |= TR3_SEE_INVIS;
2688 if (p_ptr->tim_regen)
2690 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2691 (*f3) |= TR3_TELEPATHY;
2692 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2694 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2696 (*f2) |= (TR2_RES_FIRE);
2697 (*f2) |= (TR2_RES_COLD);
2698 (*f2) |= (TR2_RES_ACID);
2699 (*f2) |= (TR2_RES_ELEC);
2700 (*f2) |= (TR2_RES_POIS);
2704 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2705 (*f2) |= TR2_RES_ACID;
2706 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2707 (*f2) |= TR2_RES_ELEC;
2708 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2709 (*f2) |= TR2_RES_FIRE;
2710 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2711 (*f2) |= TR2_RES_COLD;
2715 if (p_ptr->oppose_acid)
2716 (*f2) |= TR2_RES_ACID;
2717 if (p_ptr->oppose_elec)
2718 (*f2) |= TR2_RES_ELEC;
2719 if (p_ptr->oppose_fire)
2720 (*f2) |= TR2_RES_FIRE;
2721 if (p_ptr->oppose_cold)
2722 (*f2) |= TR2_RES_COLD;
2724 if (p_ptr->oppose_pois)
2725 (*f2) |= TR2_RES_POIS;
2726 if (p_ptr->special_attack & ATTACK_ACID)
2727 (*f1) |= TR1_BRAND_ACID;
2728 if (p_ptr->special_attack & ATTACK_ELEC)
2729 (*f1) |= TR1_BRAND_ELEC;
2730 if (p_ptr->special_attack & ATTACK_FIRE)
2731 (*f1) |= TR1_BRAND_FIRE;
2732 if (p_ptr->special_attack & ATTACK_COLD)
2733 (*f1) |= TR1_BRAND_COLD;
2734 if (p_ptr->special_attack & ATTACK_POIS)
2735 (*f1) |= TR1_BRAND_POIS;
2736 if (p_ptr->special_defense & DEFENSE_ACID)
2737 (*f2) |= TR2_IM_ACID;
2738 if (p_ptr->special_defense & DEFENSE_ELEC)
2739 (*f2) |= TR2_IM_ELEC;
2740 if (p_ptr->special_defense & DEFENSE_FIRE)
2741 (*f2) |= TR2_IM_FIRE;
2742 if (p_ptr->special_defense & DEFENSE_COLD)
2743 (*f2) |= TR2_IM_COLD;
2744 if (p_ptr->wraith_form)
2745 (*f2) |= TR2_REFLECT;
2747 if (p_ptr->tim_reflect){
2748 (*f2) |= TR2_REFLECT;
2751 if (p_ptr->magicdef)
2753 (*f2) |= TR2_RES_BLIND;
2754 (*f2) |= TR2_RES_CONF;
2755 (*f2) |= TR2_REFLECT;
2756 (*f2) |= TR2_FREE_ACT;
2757 (*f3) |= TR3_FEATHER;
2759 if (p_ptr->tim_res_nether)
2761 (*f2) |= TR2_RES_NETHER;
2763 if (p_ptr->tim_sh_fire)
2765 (*f3) |= TR3_SH_FIRE;
2769 (*f2) |= TR2_RES_FEAR;
2770 (*f2) |= TR2_RES_LITE;
2771 (*f2) |= TR2_RES_DARK;
2772 (*f2) |= TR2_RES_BLIND;
2773 (*f2) |= TR2_RES_CONF;
2774 (*f2) |= TR2_RES_SOUND;
2775 (*f2) |= TR2_RES_SHARDS;
2776 (*f2) |= TR2_RES_NETHER;
2777 (*f2) |= TR2_RES_NEXUS;
2778 (*f2) |= TR2_RES_CHAOS;
2779 (*f2) |= TR2_RES_DISEN;
2780 (*f2) |= TR2_REFLECT;
2781 (*f2) |= TR2_HOLD_LIFE;
2782 (*f2) |= TR2_FREE_ACT;
2783 (*f3) |= TR3_SH_FIRE;
2784 (*f3) |= TR3_SH_ELEC;
2785 (*f3) |= TR3_SH_COLD;
2786 (*f3) |= TR3_FEATHER;
2788 (*f3) |= TR3_SEE_INVIS;
2789 (*f3) |= TR3_TELEPATHY;
2790 (*f3) |= TR3_SLOW_DIGEST;
2792 (*f2) |= (TR2_SUST_STR);
2793 (*f2) |= (TR2_SUST_INT);
2794 (*f2) |= (TR2_SUST_WIS);
2795 (*f2) |= (TR2_SUST_DEX);
2796 (*f2) |= (TR2_SUST_CON);
2797 (*f2) |= (TR2_SUST_CHR);
2805 static void display_player_equippy(int y, int x)
2815 /* Dump equippy chars */
2816 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2819 o_ptr = &inventory[i];
2821 a = object_attr(o_ptr);
2822 c = object_char(o_ptr);
2824 /* Clear the part of the screen */
2825 if (!equippy_chars || !o_ptr->k_idx)
2832 Term_putch(x + i - INVEN_RARM, y, a, c);
2837 void print_equippy(void)
2839 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2846 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2851 (*f1) = (*f2) = (*f3) = 0L;
2853 /* Check equipment */
2854 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2856 u32b o_f1, o_f2, o_f3;
2861 o_ptr = &inventory[i];
2863 if (!o_ptr->k_idx) continue;
2866 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2868 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2869 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2870 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2871 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2875 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2878 (*f1) = (*f2) = (*f3) = 0L;
2880 if (prace_is_(RACE_SPECTRE))
2881 (*f2) |= TR2_RES_NETHER;
2882 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2883 (*f2) |= TR2_RES_DARK;
2884 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2885 (*f2) |= TR2_RES_FIRE;
2886 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2887 (*f2) |= TR2_RES_ACID;
2890 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2893 (*f1) = (*f2) = (*f3) = 0L;
2895 if (p_ptr->special_defense & DEFENSE_ACID)
2896 (*f2) |= TR2_RES_ACID;
2897 if (p_ptr->special_defense & DEFENSE_ELEC)
2898 (*f2) |= TR2_RES_ELEC;
2899 if (p_ptr->special_defense & DEFENSE_FIRE)
2900 (*f2) |= TR2_RES_FIRE;
2901 if (p_ptr->special_defense & DEFENSE_COLD)
2902 (*f2) |= TR2_RES_COLD;
2903 if (p_ptr->wraith_form)
2904 (*f2) |= TR2_RES_DARK;
2907 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2910 (*f1) = (*f2) = (*f3) = 0L;
2912 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2914 (*f2) |= TR2_RES_ACID;
2915 (*f2) |= TR2_RES_ELEC;
2916 (*f2) |= TR2_RES_FIRE;
2917 (*f2) |= TR2_RES_COLD;
2919 if (prace_is_(RACE_ANDROID))
2920 (*f2) |= TR2_RES_ELEC;
2921 if (prace_is_(RACE_ENT))
2922 (*f2) |= TR2_RES_FIRE;
2923 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2924 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2925 (*f2) |= TR2_RES_LITE;
2929 * Helper function, see below
2931 static void display_player_flag_aux(int row, int col, char *header,
2932 int n, u32b flag1, u32b flag2,
2933 u32b im_f[], u32b vul_f)
2939 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2943 c_put_str(TERM_WHITE, header, row, col);
2946 col += strlen(header) + 1;
2948 /* Check equipment */
2949 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2952 f[0] = f[1] = f[2] = 0L;
2955 o_ptr = &inventory[i];
2958 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2961 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2964 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2965 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
2972 player_flags(&f[0], &f[1], &f[2]);
2975 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2978 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2980 /* Timed player flags */
2981 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
2984 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
2987 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
2988 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
2991 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
2996 * Special display, part 1
2998 static void display_player_flag_info(void)
3003 u32b im_f[3][3], vul_f[3];
3005 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
3006 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
3007 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
3009 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3016 display_player_equippy(row-2, col+8);
3017 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3020 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3021 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3022 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3023 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3024 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3025 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3026 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3027 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3028 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3029 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3031 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3032 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3033 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3034 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3035 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3036 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3037 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3038 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3039 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3040 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3049 display_player_equippy(row-2, col+8);
3051 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3054 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3055 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3056 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3057 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3058 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3059 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3060 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3061 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3062 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3063 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3065 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3066 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3067 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3068 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3069 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3070 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3071 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3072 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3073 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3074 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3083 display_player_equippy(row-2, col+12);
3085 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3088 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3089 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3090 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3091 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3092 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3093 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3094 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3095 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3096 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3097 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3099 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3100 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3101 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3102 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3103 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3104 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3105 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3106 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3107 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3108 display_player_flag_aux(row+9, col, "Cursed :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3115 * Special display, part 2a
3117 static void display_player_misc_info(void)
3122 /* Display basics */
3124 put_str("̾Á° :", 1, 26);
3125 put_str("ÀÊÌ :", 3, 1);
3126 put_str("¼ï² :", 4, 1);
3127 put_str("¿¦¶È :", 5, 1);
3129 put_str("Name :", 1, 26);
3130 put_str("Sex :", 3, 1);
3131 put_str("Race :", 4, 1);
3132 put_str("Class :", 5, 1);
3135 strcpy(tmp,ap_ptr->title);
3142 strcat(tmp,player_name);
3144 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3145 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3146 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3147 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3149 /* Display extras */
3151 put_str("¥ì¥Ù¥ë:", 6, 1);
3152 put_str("£È£Ð :", 7, 1);
3153 put_str("£Í£Ð :", 8, 1);
3155 put_str("Level :", 6, 1);
3156 put_str("Hits :", 7, 1);
3157 put_str("Mana :", 8, 1);
3161 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3162 c_put_str(TERM_L_BLUE, buf, 6, 9);
3163 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3164 c_put_str(TERM_L_BLUE, buf, 7, 9);
3165 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3166 c_put_str(TERM_L_BLUE, buf, 8, 9);
3171 * Special display, part 2b
3173 * How to print out the modifications and sustains.
3174 * Positive mods with no sustain will be light green.
3175 * Positive mods with a sustain will be dark green.
3176 * Sustains (with no modification) will be a dark green 's'.
3177 * Negative mods (from a curse) will be red.
3178 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3179 * No mod, no sustain, will be a slate '.'
3181 static void display_player_stat_info(void)
3203 /* Print out the labels for the columns */
3205 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3206 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3207 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3208 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3209 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+33);
3211 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3212 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3213 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3214 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3215 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3219 /* Display the stats */
3220 for (i = 0; i < 6; i++)
3224 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3225 else r_adj = rp_ptr->r_adj[i];
3227 /* Calculate equipment adjustment */
3230 /* Icky formula to deal with the 18 barrier */
3231 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3232 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3233 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3234 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3235 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3236 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3238 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3239 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3241 if (prace_is_(RACE_ENT))
3247 if (p_ptr->lev > 25) r_adj++;
3248 if (p_ptr->lev > 40) r_adj++;
3249 if (p_ptr->lev > 45) r_adj++;
3252 if (p_ptr->lev > 25) r_adj--;
3253 if (p_ptr->lev > 40) r_adj--;
3254 if (p_ptr->lev > 45) r_adj--;
3260 e_adj -= cp_ptr->c_adj[i];
3261 e_adj -= ap_ptr->a_adj[i];
3263 /* Reduced name of stat */
3265 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3267 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3271 /* Internal "natural" max value. Maxes at 18/100 */
3272 /* This is useful to see if you are maxed out */
3273 cnv_stat(p_ptr->stat_max[i], buf);
3274 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3276 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3278 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3280 /* Race, class, and equipment modifiers */
3281 (void)sprintf(buf, "%3d", r_adj);
3282 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3283 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3284 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3285 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3286 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3287 (void)sprintf(buf, "%3d", (int)e_adj);
3288 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3290 /* Actual maximal modified value */
3291 cnv_stat(p_ptr->stat_top[i], buf);
3292 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3294 /* Only display stat_use if not maximal */
3295 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3297 cnv_stat(p_ptr->stat_use[i], buf);
3298 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3303 col = stat_col + 41;
3305 /* Header and Footer */
3306 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3308 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3310 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3314 /* Process equipment */
3315 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3318 o_ptr = &inventory[i];
3321 k_idx = o_ptr->k_idx;
3323 /* Acquire "known" flags */
3324 object_flags_known(o_ptr, &f1, &f2, &f3);
3326 /* Initialize color based of sign of pval. */
3327 for (stat = 0; stat < 6; stat++)
3340 if (o_ptr->pval > 0)
3346 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3351 /* Dark green for sustained stats */
3356 if (o_ptr->pval < 0)
3362 if (o_ptr->pval < 10) c = '0' - o_ptr->pval;
3367 else if (f2 & 1 << stat)
3369 /* Dark green "s" */
3374 /* Dump proper character */
3375 Term_putch(col, row + stat+1, a, c);
3383 player_flags(&f1, &f2, &f3);
3386 for (stat = 0; stat < 6; stat++)
3393 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3399 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3400 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3401 if (p_ptr->tsuyoshi) dummy += 4;
3403 else if (stat == A_WIS || stat == A_INT)
3405 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3406 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3408 else if (stat == A_DEX)
3410 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3411 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3412 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3414 else if (stat == A_CON)
3416 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3417 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3418 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3419 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3420 if (p_ptr->tsuyoshi) dummy += 4;
3422 else if (stat == A_CHR)
3424 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3425 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3426 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3427 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3428 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3429 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3445 if (dummy < 10) c = '0' + dummy;
3455 if (dummy < 10) c = '0' - dummy;
3464 /* Dark green "s" */
3471 Term_putch(col, row + stat+1, a, c);
3479 static cptr object_flag_names[96] =
3720 * Summarize resistances
3722 static void display_player_ben(void)
3735 for (i = 0; i < 6; i++) b[i] = 0;
3738 /* Scan equipment */
3739 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3742 o_ptr = &inventory[i];
3744 /* Known object flags */
3745 object_flags_known(o_ptr, &f1, &f2, &f3);
3748 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3750 f3 &= ~(TR3_AGGRAVATE);
3755 b[0] |= (f1 & 0xFFFF);
3757 b[2] |= (f2 & 0xFFFF);
3759 b[4] |= (f3 & 0xFFFF);
3765 player_flags(&f1, &f2, &f3);
3768 b[0] |= (f1 & 0xFFFF);
3770 b[2] |= (f2 & 0xFFFF);
3772 b[4] |= (f3 & 0xFFFF);
3776 tim_player_flags(&f1, &f2, &f3, FALSE);
3779 b[0] |= (f1 & 0xFFFF);
3781 b[2] |= (f2 & 0xFFFF);
3783 b[4] |= (f3 & 0xFFFF);
3785 color[0] = (u16b)(f1 & 0xFFFF);
3786 color[1] = (u16b)(f1 >> 16);
3787 color[2] = (u16b)(f2 & 0xFFFF);
3788 color[3] = (u16b)(f2 >> 16);
3789 color[4] = (u16b)(f3 & 0xFFFF);
3790 color[5] = (u16b)(f3 >> 16);
3793 for (x = 0; x < 6; x++)
3796 for (y = 0; y < 16; y++)
3798 byte a = TERM_SLATE;
3801 cptr name = object_flag_names[16*x+y];
3804 if (!name) continue;
3807 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3810 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3815 if (color[x] & (1<<y))
3828 Term_putch(x * 13 + 11, y + 4, a, c);
3835 * Summarize resistances
3837 static void display_player_ben_one(int mode)
3849 /* Scan equipment */
3850 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3853 n = (i - INVEN_RARM);
3856 o_ptr = &inventory[i];
3858 object_flags_known(o_ptr, &f1, &f2, &f3);
3860 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3862 f3 &= ~(TR3_AGGRAVATE);
3867 b[n][0] = (u16b)(f1 & 0xFFFF);
3868 b[n][1] = (u16b)(f1 >> 16);
3869 b[n][2] = (u16b)(f2 & 0xFFFF);
3870 b[n][3] = (u16b)(f2 >> 16);
3871 b[n][4] = (u16b)(f3 & 0xFFFF);
3872 b[n][5] = (u16b)(f3 >> 16);
3880 player_flags(&f1, &f2, &f3);
3883 b[n][0] = (u16b)(f1 & 0xFFFF);
3884 b[n][1] = (u16b)(f1 >> 16);
3885 b[n][2] = (u16b)(f2 & 0xFFFF);
3886 b[n][3] = (u16b)(f2 >> 16);
3887 b[n][4] = (u16b)(f3 & 0xFFFF);
3888 b[n][5] = (u16b)(f3 >> 16);
3891 tim_player_flags(&f1, &f2, &f3, FALSE);
3894 b[n][0] |= (f1 & 0xFFFF);
3895 b[n][1] |= (f1 >> 16);
3896 b[n][2] |= (f2 & 0xFFFF);
3897 b[n][3] |= (f2 >> 16);
3898 b[n][4] |= (f3 & 0xFFFF);
3899 b[n][5] |= (f3 >> 16);
3900 color[0] = (u16b)(f1 & 0xFFFF);
3901 color[1] = (u16b)(f1 >> 16);
3902 color[2] = (u16b)(f2 & 0xFFFF);
3903 color[3] = (u16b)(f2 >> 16);
3904 color[4] = (u16b)(f3 & 0xFFFF);
3905 color[5] = (u16b)(f3 >> 16);
3909 for (x = 0; x < 3; x++)
3912 display_player_equippy(2, x * 26 + 11);
3915 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3918 for (y = 0; y < 16; y++)
3920 cptr name = object_flag_names[48*mode+16*x+y];
3923 if (!name) continue;
3926 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3929 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3932 for (n = 0; n < 13; n++)
3934 byte a = TERM_SLATE;
3938 if (b[n][3*mode+x] & (1<<y))
3940 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3953 Term_putch(x * 26 + 11 + n, y + 4, a, c);
3961 * Display the character on the screen (various modes)
3963 * The top two and bottom two lines are left blank.
3965 * Mode 0 = standard display with skills
3966 * Mode 1 = standard display with history
3967 * Mode 2 = summary of various things
3968 * Mode 3 = current flags (combined)
3969 * Mode 4 = current flags (part 1)
3970 * Mode 5 = current flags (part 2)
3971 * Mode 6 = mutations
3973 void display_player(int mode)
3982 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
3991 if ((mode == 0) || (mode == 1))
3993 /* Name, Sex, Race, Class */
3995 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
3997 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
4000 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
4001 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
4002 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
4003 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
4008 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
4010 strcpy(tmp, realm_names[p_ptr->realm1]);
4011 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
4014 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4015 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
4017 /* Age, Height, Weight, Social */
4018 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4020 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
4021 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
4022 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
4023 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
4025 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
4026 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
4027 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
4028 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
4030 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
4033 /* Display the stats */
4034 for (i = 0; i < 6; i++)
4036 /* Special treatment of "injured" stats */
4037 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4041 /* Use lowercase stat name */
4042 put_str(stat_names_reduced[i], 3 + i, 54);
4044 /* Get the current stat */
4045 value = p_ptr->stat_use[i];
4047 /* Obtain the current stat (modified) */
4048 cnv_stat(value, buf);
4050 /* Display the current stat (modified) */
4051 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
4053 /* Acquire the max stat */
4054 value = p_ptr->stat_top[i];
4056 /* Obtain the maximum stat (modified) */
4057 cnv_stat(value, buf);
4059 /* Display the maximum stat (modified) */
4060 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
4063 /* Normal treatment of "normal" stats */
4066 /* Assume uppercase stat name */
4067 put_str(stat_names[i], 3 + i, 54);
4069 /* Obtain the current stat (modified) */
4070 cnv_stat(p_ptr->stat_use[i], buf);
4072 /* Display the current stat (modified) */
4073 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
4076 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4078 c_put_str(TERM_WHITE, "!", 2+i, 64);
4082 /* Display "history" info */
4086 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
4088 put_str("(Character Background)", 11, 25);
4091 for (i = 0; i < 4; i++)
4093 put_str(history[i], i + 12, 10);
4101 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Î %d ³¬¤Ç»à¤ó¤À¡£", map_name(), dun_level), 5 + 12, 10);
4103 put_str(format("...You were dead at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4107 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Ç»à¤ó¤À¡£", map_name()), 5 + 12, 10);
4109 put_str(format("...You were dead at %s.", map_name()), 5 + 12, 10);
4116 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level), 5 + 12, 10);
4118 put_str(format("...Now, you are exploring at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4122 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name()), 5 + 12, 10);
4124 put_str(format("...Now, you are in %s.", map_name()), 5 + 12, 10);
4129 /* Display "various" info */
4132 display_player_middle();
4133 display_player_various();
4140 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4143 display_player_misc_info();
4144 display_player_stat_info();
4145 display_player_flag_info();
4151 display_player_ben();
4156 do_cmd_knowledge_mutations();
4162 display_player_ben_one(mode % 2);
4166 errr make_character_dump(FILE *fff)
4173 char o_name[MAX_NLEN];
4177 #ifndef FAKE_VERSION
4179 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4180 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4183 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4184 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4186 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4187 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4194 /* Display player */
4197 /* Dump part of the screen */
4198 for (y = 1; y < 22; y++)
4201 for (x = 0; x < 79; x++)
4203 /* Get the attr/char */
4204 (void)(Term_what(x, y, &a, &c));
4210 /* End the string */
4213 /* Kill trailing spaces */
4214 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4218 fprintf(fff, "%s\n", buf);
4220 fprintf(fff, "%s\n", buf);
4225 /* Display history */
4228 /* Dump part of the screen */
4229 for (y = 11; y < 18; y++)
4232 for (x = 0; x < 79; x++)
4234 /* Get the attr/char */
4235 (void)(Term_what(x, y, &a, &c));
4241 /* End the string */
4244 /* Kill trailing spaces */
4245 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4248 fprintf(fff, "%s\n", buf);
4252 /* Display history */
4255 /* Dump part of the screen */
4256 for (y = 2; y < 22; y++)
4259 for (x = 0; x < 79; x++)
4261 /* Get the attr/char */
4262 (void)(Term_what(x, y, &a, &c));
4264 /* Dump it (Ignore equippy tile graphic) */
4271 /* End the string */
4274 /* Kill trailing spaces */
4275 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4278 fprintf(fff, "%s\n", buf);
4281 for (i = 0; i < p_ptr->count / 80; i++)
4284 for (i = 0; i < p_ptr->count % 80; i++)
4289 for (i = m_max - 1; i >= 1; i--)
4291 monster_type *m_ptr = &m_list[i];
4294 if (!m_ptr->r_idx) continue;
4295 if (!is_pet(m_ptr)) continue;
4296 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4300 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4302 fprintf(fff, "\n [leading pets]\n\n");
4306 monster_desc(pet_name, m_ptr, 0x88);
4307 fprintf(fff, "%s", pet_name);
4308 if (p_ptr->riding == i)
4310 fprintf(fff, " ¾èÇÏÃæ");
4312 fprintf(fff, " riding");
4316 if (pet) fprintf(fff, "\n");
4319 if (death && !total_winner)
4322 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4324 fprintf(fff, "\n [Last messages]\n\n");
4326 for (i = MIN(message_num(), 15); i >= 0; i--)
4328 fprintf(fff,"> %s\n",message_str((s16b)i));
4334 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4336 fprintf(fff, "\n [Miscellaneous information]\n");
4340 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4342 fprintf(fff, "\n Recall Depth:\n");
4344 for (y = 1; y < max_d_idx; y++)
4348 if (!d_info[y].maxdepth) continue;
4349 if (!max_dlv[y]) continue;
4350 if (d_info[y].final_guardian)
4352 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4354 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4357 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4359 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4365 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4367 fprintf(fff, "\n Preserve Mode: ON");
4372 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4374 fprintf(fff, "\n Preserve Mode: OFF");
4378 if (ironman_autoscum)
4380 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4382 fprintf(fff, "\n Autoscum: ALWAYS");
4387 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4389 fprintf(fff, "\n Autoscum: ON");
4394 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4396 fprintf(fff, "\n Autoscum: OFF");
4400 if (ironman_small_levels)
4402 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4404 fprintf(fff, "\n Small Levels: ALWAYS");
4407 else if (always_small_levels)
4409 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4411 fprintf(fff, "\n Small Levels: ON");
4414 else if (small_levels)
4416 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4418 fprintf(fff, "\n Small Levels: ENABLED");
4423 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4425 fprintf(fff, "\n Small Levels: OFF");
4431 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4433 fprintf(fff, "\n Vanilla Town: ON");
4438 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4440 fprintf(fff, "\n Lite Town: ON");
4446 fprintf(fff, "\n Ź¤Ê¤·: ON");
4448 fprintf(fff, "\n No Shops: ON");
4452 if (ironman_downward)
4454 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4456 fprintf(fff, "\n Diving only: ON");
4462 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4464 fprintf(fff, "\n Unusual rooms: ON");
4468 if (ironman_nightmare)
4470 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4472 fprintf(fff, "\n Nightmare Mode: ON");
4476 if (ironman_empty_levels)
4478 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4480 fprintf(fff, "\n Arena Levels: ALWAYS");
4483 else if (empty_levels)
4485 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4487 fprintf(fff, "\n Arena Levels: ENABLED");
4492 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4494 fprintf(fff, "\n Arena Levels: OFF");
4499 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4501 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4504 if (p_ptr->arena_number == 99)
4507 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4509 fprintf(fff, "\n Arena: defeated\n");
4512 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4515 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4517 fprintf(fff, "\n Arena: True Champion\n");
4520 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4523 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4525 fprintf(fff, "\n Arena: Champion\n");
4531 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4533 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");
4539 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4541 fprintf(fff, "\n You have done something illegal.");
4545 if (stupid_monsters)
4547 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4549 fprintf(fff, "\n Your opponents are behaving stupidly.");
4555 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4557 fprintf(fff, "\n You possess munchkinish power over death.");
4562 /* Monsters slain */
4567 for (k = 1; k < max_r_idx; k++)
4569 monster_race *r_ptr = &r_info[k];
4571 if (r_ptr->flags1 & RF1_UNIQUE)
4573 bool dead = (r_ptr->max_num == 0);
4581 s16b This = r_ptr->r_pkills;
4591 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4593 fprintf(fff,"\n You have defeated no enemies yet.\n");
4596 else if (Total == 1)
4598 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4600 fprintf(fff,"\n You have defeated one enemy.\n");
4605 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4607 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4613 if (p_ptr->old_race1 || p_ptr->old_race2)
4616 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4618 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4620 for (i = 0; i < MAX_RACES; i++)
4622 if (p_ptr->start_race == i) continue;
4625 if (!(p_ptr->old_race1 & 1L << i)) continue;
4629 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4632 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4634 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4639 if (p_ptr->old_realm)
4641 for (i = 0; i < MAX_MAGIC; i++)
4643 if (!(p_ptr->old_realm & 1L << i)) continue;
4645 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4647 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4653 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4655 fprintf(fff, "\n\n [Virtues]\n\n");
4659 fprintf(fff, "°À : %s\n", your_alignment());
4661 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4666 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4669 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4671 fprintf(fff, "\n\n [Mutations]\n\n");
4674 dump_mutations(fff);
4678 /* Skip some lines */
4679 fprintf(fff, "\n\n");
4682 /* Dump the equipment */
4686 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4688 fprintf(fff, " [Character Equipment]\n\n");
4691 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4693 object_desc(o_name, &inventory[i], TRUE, 3);
4694 if ((i == INVEN_LARM) && p_ptr->ryoute)
4696 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4698 strcpy(o_name, "(wielding with two-hands)");
4700 fprintf(fff, "%c%s %s\n",
4701 index_to_label(i), paren, o_name);
4703 fprintf(fff, "\n\n");
4706 /* Dump the inventory */
4708 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4710 fprintf(fff, " [Character Inventory]\n\n");
4713 for (i = 0; i < INVEN_PACK; i++)
4715 /* Don't dump the empty slots */
4716 if (!inventory[i].k_idx) break;
4718 /* Dump the inventory slots */
4719 object_desc(o_name, &inventory[i], TRUE, 3);
4720 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4723 /* Add an empty line */
4724 fprintf(fff, "\n\n");
4726 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4728 /* Print all homes in the different towns */
4729 st_ptr = &town[1].store[STORE_HOME];
4731 /* Home -- if anything there */
4732 if (st_ptr->stock_num)
4734 /* Header with name of the town */
4736 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4738 fprintf(fff, " [Home Inventory]\n");
4742 /* Dump all available items */
4743 for (i = 0; i < st_ptr->stock_num; i++)
4747 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4749 fprintf(fff, "\n ( page %d )\n", x++);
4751 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4752 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4755 /* Add an empty line */
4756 fprintf(fff, "\n\n");
4760 /* Print all homes in the different towns */
4761 st_ptr = &town[1].store[STORE_MUSEUM];
4763 /* Home -- if anything there */
4764 if (st_ptr->stock_num)
4766 /* Header with name of the town */
4768 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4770 fprintf(fff, " [Museum]\n");
4774 /* Dump all available items */
4775 for (i = 0; i < st_ptr->stock_num; i++)
4778 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4779 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4780 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4782 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4783 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4784 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4789 /* Add an empty line */
4790 fprintf(fff, "\n\n");
4797 * Hack -- Dump a character description file
4799 * XXX XXX XXX Allow the "full" flag to dump additional info,
4800 * and trigger its usage from various places in the code.
4802 errr file_character(cptr name, bool full)
4811 /* Build the filename */
4812 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4814 /* File type is "TEXT" */
4815 FILE_TYPE(FILE_TYPE_TEXT);
4817 /* Check for existing file */
4818 fd = fd_open(buf, O_RDONLY);
4825 /* Close the file */
4830 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4832 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4837 if (get_check(out_val)) fd = -1;
4840 /* Open the non-existing file */
4841 if (fd < 0) fff = my_fopen(buf, "w");
4852 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4854 msg_format("Character dump failed!");
4863 (void)make_character_dump(fff);
4871 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4873 msg_print("Character dump successful.");
4884 * Recursive file perusal.
4886 * Return FALSE on 'Q', otherwise TRUE.
4888 * Process various special text in the input file, including
4889 * the "menu" structures used by the "help file" system.
4891 * XXX XXX XXX Consider using a temporary file.
4893 * XXX XXX XXX Allow the user to "save" the current file.
4895 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4899 /* Number of "real" lines passed by */
4902 /* Number of "real" lines in the file */
4905 /* Backup value for "line" */
4911 /* This screen has sub-screens */
4914 /* Current help file */
4917 /* Find this string (if any) */
4920 /* Jump to this tag */
4923 /* Hold a string to find */
4926 /* Hold a string to show */
4930 char filename[1024];
4932 /* Describe this thing */
4938 /* General buffer */
4941 /* Lower case version of the buffer, for searching */
4944 /* Aux pointer for making lc_buf (and find!) lowercase */
4947 /* Sub-menu information */
4950 /* Tags for in-file references */
4953 bool reverse = (line < 0);
4962 strcpy(caption, "");
4964 /* Wipe the hooks */
4965 for (i = 0; i < 68; i++)
4970 /* Copy the filename */
4971 strcpy(filename, name);
4973 n = strlen(filename);
4975 /* Extract the tag from the filename */
4976 for (i = 0; i < n; i++)
4978 if (filename[i] == '#')
4981 tag = filename + i + 1;
4986 /* Redirect the name */
4989 /* Hack XXX XXX XXX */
4993 strcpy(caption, what);
4995 /* Access the "file" */
4999 fff = my_fopen(path, "r");
5002 /* Look in "help" */
5007 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5009 sprintf(caption, "Help file '%s'", name);
5013 /* Build the filename */
5014 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5017 fff = my_fopen(path, "r");
5020 /* Look in "info" */
5025 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5027 sprintf(caption, "Info file '%s'", name);
5031 /* Build the filename */
5032 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5035 fff = my_fopen(path, "r");
5038 /* Look in "info" */
5041 /* Build the filename */
5042 path_build(path, 1024, ANGBAND_DIR, name);
5044 for (i = 0; path[i]; i++)
5045 if ('\\' == path[i])
5046 path[i] = PATH_SEP[0];
5050 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5052 sprintf(caption, "Info file '%s'", name);
5056 fff = my_fopen(path, "r");
5064 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5066 msg_format("Cannot open '%s'.", name);
5076 /* Pre-Parse the file */
5079 /* Read a line or stop */
5080 if (my_fgets(fff, buf, 1024)) break;
5082 /* XXX Parse "menu" items */
5083 if (prefix(buf, "***** "))
5085 /* Notice "menu" requests */
5086 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5088 /* This is a menu file */
5091 /* Extract the menu item */
5092 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5094 if ((buf[8] == ']') && (buf[9] == ' '))
5096 /* Extract the menu item */
5097 strcpy(hook[k], buf + 10);
5100 /* Notice "tag" requests */
5101 else if ((buf[6] == '<') && (isdigit(buf[7]) || isalpha(buf[7])) &&
5104 /* Extract the menu item */
5105 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5107 /* Extract the menu item */
5115 /* Count the "real" lines */
5119 /* Save the number of "real" lines */
5122 if (line == -1) line = ((size-1)/20)*20;
5124 /* Go to the tagged line */
5126 line = tags[isdigit(tag[0]) ? D2I(tag[0]) : tag[0] - 'A' + 10];
5128 /* Display the file */
5134 /* Restart when necessary */
5135 if (line >= size) line = 0;
5138 /* Re-open the file if needed */
5144 /* Hack -- Re-Open the file */
5145 fff = my_fopen(path, "r");
5148 if (!fff) return (FALSE);
5150 /* File has been restarted */
5154 /* Goto the selected line */
5158 if (my_fgets(fff, buf, 1024)) break;
5160 /* Skip tags/links */
5161 if (prefix(buf, "***** ")) continue;
5163 /* Count the lines */
5167 /* Dump the next 20 lines of the file */
5168 for (i = 0; i < 20; )
5170 /* Hack -- track the "first" line */
5171 if (!i) line = next;
5173 /* Get a line of the file or stop */
5174 if (my_fgets(fff, buf, 1024)) break;
5176 /* Hack -- skip "special" lines */
5177 if (prefix(buf, "***** ")) continue;
5179 /* Count the "real" lines */
5182 /* Make a lower case version of buf for searching */
5183 strcpy(lc_buf, buf);
5185 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5188 if (iskanji(*lc_buf_ptr))
5192 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5195 /* Hack -- keep searching */
5196 if (find && !i && !strstr(lc_buf, find)) continue;
5198 /* Hack -- stop searching */
5202 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5204 /* Hilite "shower" */
5209 /* Display matches */
5210 while ((str = strstr(str, shower)) != NULL)
5212 int len = strlen(shower);
5214 /* Display the match */
5215 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5222 /* Count the printed lines */
5226 /* Hack -- failed search */
5236 /* Show a general "title" */
5240 prt(format("[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5242 prt(format("[Hengband %d.%d.%d, %s, Line %d/%d]",
5245 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5246 caption, line, size), 0, 0);
5251 prt(format("[%s, %d/%d]",
5253 prt(format("[%s, Line %d/%d]",
5255 caption, line, size), 0, 0);
5258 /* Prompt -- menu screen */
5263 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", 23, 0);
5265 prt("[Press a Number, or ESC to exit.]", 23, 0);
5270 /* Prompt -- small files */
5271 else if (size <= 20)
5275 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5277 prt("[Press ESC to exit.]", 23, 0);
5282 /* Prompt -- large files */
5287 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5289 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5291 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", 23, 0);
5295 /* Get a keypress */
5298 /* Hack -- return to last screen */
5299 if (k == '<') break;
5301 /* Show the help for the help */
5304 /* Hack - prevent silly recursion */
5306 if (strcmp(name, "jhelpinfo.txt") != 0)
5307 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5309 if (strcmp(name, "helpinfo.txt") != 0)
5310 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5314 /* Hack -- try showing */
5319 prt("¶¯Ä´: ", 23, 0);
5321 prt("Show: ", 23, 0);
5324 (void)askfor_aux(shower, 80);
5327 /* Hack -- try finding */
5332 prt("¸¡º÷: ", 23, 0);
5334 prt("Find: ", 23, 0);
5338 if (askfor_aux(finder, 80))
5345 /* Make finder lowercase */
5346 for (cnt = 0; finder[cnt] != 0; cnt++)
5349 if (iskanji(finder[cnt]))
5353 finder[cnt] = tolower(finder[cnt]);
5357 strcpy(shower, finder);
5361 /* Hack -- go to a specific line */
5368 prt("Goto Line: ", 23, 0);
5373 if (askfor_aux(tmp, 80))
5379 /* Hack -- go to a specific file */
5384 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", 23, 0);
5385 strcpy(tmp, "jhelp.hlp");
5387 prt("Goto File: ", 23, 0);
5388 strcpy(tmp, "help.hlp");
5392 if (askfor_aux(tmp, 80))
5394 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5398 /* Hack -- Allow backing up */
5401 line = line + (reverse ? 20 : -20);
5402 if (line < 0) line = ((size-1)/20)*20;
5405 /* Hack -- Advance a single line */
5406 if ((k == '\n') || (k == '\r'))
5408 line = line + (reverse ? -1 : 1);
5409 if (line < 0) line = ((size-1)/20)*20;
5412 /* Advance one page */
5415 line = line + (reverse ? -20 : 20);
5416 if (line < 0) line = ((size-1)/20)*20;
5420 /* ÆüËܸìÈǤÇÄɲ䵤줿¥Ø¥ë¥×¤Îɽ¼¨ */
5421 /* ¤¢¤Þ¤ê¤è¤¤½èÍý¤Î»ÅÊý¤È¤Ï»×¤¨¤Ê¤¤¡¦¡¦¡¦¤¹¤Þ¤ó */
5423 /* ´Ê°×¥³¥Þ¥ó¥É°ìÍ÷ */
5424 if (menu && (k == 'c' || k == 'C'))
5427 switch (rogue_like_commands)
5431 strcpy(tmp, "j_com_r.txt");
5432 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5437 strcpy(tmp, "j_com_o.txt");
5438 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5445 /* Recurse on numbers */
5450 if (isdigit(k)) key = D2I(k);
5451 else if (isalpha(k)) key = k - 'A' + 10;
5453 if ((key > -1) && hook[key][0])
5455 /* Recurse on that file */
5456 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5461 /* Hack, dump to file */
5471 if (get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5473 if (get_string("File name: ", xtmp, 80))
5477 if (xtmp[0] && (xtmp[0] != ' '))
5486 /* Build the filename */
5487 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5492 /* Hack -- Re-Open the file */
5493 fff = my_fopen(path, "r");
5495 ffp = my_fopen(buff, "w");
5501 msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
5503 msg_print("Failed to open file.");
5510 sprintf(xtmp, "%s: %s", player_name, what);
5511 my_fputs(ffp, xtmp, 80);
5512 my_fputs(ffp, "\n", 80);
5514 while (!my_fgets(fff, buff, 80))
5515 my_fputs(ffp, buff, 80);
5521 /* Hack -- Re-Open the file */
5522 fff = my_fopen(path, "r");
5525 /* Exit on escape */
5526 if (k == ESCAPE) break;
5527 if (k == 'q') break;
5530 /* Close the file */
5534 if (k == 'q') return (FALSE);
5542 * Peruse the On-Line-Help
5544 void do_cmd_help(void)
5549 /* Peruse the main help file */
5551 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5553 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5563 * Process the player name.
5564 * Extract a clean "base name".
5565 * Build the savefile name if needed.
5567 void process_player_name(bool sf)
5572 /* Cannot be too long */
5573 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5575 if (strlen(player_name) > 8)
5577 if (strlen(player_name) > 15)
5582 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5584 quit_fmt("The name '%s' is too long!", player_name);
5590 /* Cannot contain "icky" characters */
5591 for (i = 0; player_name[i]; i++)
5593 /* No control characters */
5595 if (iskanji(player_name[i])){i++;continue;}
5596 if (iscntrl( (unsigned char)player_name[i]))
5598 if (iscntrl(player_name[i]))
5602 /* Illegal characters */
5604 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5606 quit_fmt("The name '%s' contains control chars!", player_name);
5615 /* Extract "useful" letters */
5616 for (i = 0; player_name[i]; i++)
5619 unsigned char c = player_name[i];
5621 char c = player_name[i];
5625 /* Convert "dot" to "underscore" */
5626 if (c == '.') c = '_';
5628 /* Accept all the letters */
5629 player_base[k++] = c;
5634 /* Extract "useful" letters */
5635 for (i = 0; player_name[i]; i++)
5638 unsigned char c = player_name[i];
5640 char c = player_name[i];
5643 /* Accept some letters */
5646 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5647 player_base[k++] = c;
5649 player_base[k++] = player_name[i];
5652 else if (iskana(c)) player_base[k++] = c;
5656 /* Convert path separator to underscore */
5657 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5658 player_base[k++] = '_';
5659 i += strlen(PATH_SEP);
5662 /* Convert space, dot, and underscore to underscore */
5663 else if (strchr(". _", c)) player_base[k++] = '_';
5665 else if (isprint(c)) player_base[k++] = c;
5671 #if defined(WINDOWS) || defined(MSDOS)
5673 /* Hack -- max length */
5679 player_base[k] = '\0';
5681 /* Require a "base" name */
5682 if (!player_base[0]) strcpy(player_base, "PLAYER");
5685 #ifdef SAVEFILE_MUTABLE
5691 if (!savefile_base[0] && savefile[0])
5698 t = strstr(s, PATH_SEP);
5703 strcpy(savefile_base, s);
5706 if (!savefile_base[0] || !savefile[0])
5709 /* Change the savefile name */
5714 strcpy(savefile_base, player_base);
5716 #ifdef SAVEFILE_USE_UID
5717 /* Rename the savefile, using the player_uid and player_base */
5718 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5720 /* Rename the savefile, using the player_base */
5721 (void)sprintf(temp, "%s", player_base);
5725 /* Hack -- support "flat directory" usage on VM/ESA */
5726 (void)sprintf(temp, "%s.sv", player_base);
5729 /* Build the filename */
5730 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5736 * Gets a name for the character, reacting to name changes.
5738 * Assumes that "display_player(0)" has just been called
5740 * Perhaps we should NOT ask for a name (at "birth()") on
5741 * Unix machines? XXX XXX
5743 * What a horrible name for a global function. XXX XXX XXX
5749 /* Save the player name */
5750 strcpy(tmp, player_name);
5752 /* Prompt for a new name */
5754 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5756 if (get_string("Enter a name for your character: ", tmp, 15))
5760 strcpy(player_name, tmp);
5762 else if (0 == strlen(player_name))
5764 /* Use default name */
5765 strcpy(player_name, "PLAYER");
5768 /* Process the player name */
5769 process_player_name(FALSE);
5771 strcpy(tmp,ap_ptr->title);
5778 strcat(tmp,player_name);
5780 /* Re-Draw the name (in light blue) */
5781 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5783 /* Erase the prompt, etc */
5790 * Hack -- commit suicide
5792 void do_cmd_suicide(void)
5799 /* Verify Retirement */
5804 if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
5806 if (!get_check("Do you want to retire? ")) return;
5811 /* Verify Suicide */
5816 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5818 if (!get_check("Do you really want to commit suicide? ")) return;
5825 /* Special Verification for suicide */
5827 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5829 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5835 if (i != '@') return;
5841 /* Kill the player */
5845 p_ptr->leaving = TRUE;
5850 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5851 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5853 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5854 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5856 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5859 /* Cause of death */
5861 (void)strcpy(died_from, "ÅÓÃ潪λ");
5863 (void)strcpy(died_from, "Quitting");
5873 void do_cmd_save_game(int is_autosave)
5875 /* Autosaves do not disturb */
5879 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5881 msg_print("Autosaving the game...");
5887 /* Disturb the player */
5891 /* Clear messages */
5899 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
5901 prt("Saving game...", 0, 0);
5908 /* The player is not dead */
5910 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
5912 (void)strcpy(died_from, "(saved)");
5916 /* Forbid suspend */
5917 signals_ignore_tstp();
5919 /* Save the player */
5923 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
5925 prt("Saving game... done.", 0, 0);
5930 /* Save failed (oops) */
5934 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
5936 prt("Saving game... failed!", 0, 0);
5941 /* Allow suspend again */
5942 signals_handle_tstp();
5947 /* Note that the player is not dead */
5949 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
5951 (void)strcpy(died_from, "(alive and well)");
5958 * Save the game and exit
5960 void do_cmd_save_and_exit(void)
5965 p_ptr->leaving = TRUE;
5967 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
5969 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
5975 * Hack -- Calculates the total number of points earned -JWT-
5977 long total_points(void)
5981 u32b point, point_h, point_l;
5982 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
5984 if (stupid_monsters) mult -= 70;
5985 if (!preserve_mode) mult += 10;
5986 if (!autoroller) mult += 10;
5987 if (!smart_learn) mult -= 20;
5988 if (!terrain_streams) mult -= 20;
5989 if (smart_cheat) mult += 30;
5990 if (ironman_shops) mult += 50;
5991 if (ironman_small_levels) mult += 10;
5992 if (ironman_empty_levels) mult += 20;
5993 if (!powerup_home) mult += 50;
5994 if (ironman_rooms) mult += 100;
5995 if (ironman_nightmare) mult += 100;
5997 if (mult < 5) mult = 5;
5999 for (i = 0; i < max_d_idx; i++)
6000 if(max_dlv[i] > max_dl)
6001 max_dl = max_dlv[i];
6003 point_l = (p_ptr->max_exp + (100 * max_dl));
6004 point_h = point_l / 0x10000L;
6005 point_l = point_l % 0x10000L;
6008 point_h += point_l / 0x10000L;
6009 point_l %= 0x10000L;
6011 point_l += ((point_h % 100) << 16);
6015 point = (point_h << 16) + (point_l);
6016 if (p_ptr->arena_number < 99)
6017 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6019 if (ironman_downward) point *= 2;
6020 if (p_ptr->pclass == CLASS_BERSERKER)
6022 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6026 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6029 if (total_winner) point = 2;
6031 if (easy_band) point = (0 - point);
6039 * Centers a string within a 31 character string -JWT-
6041 static void center_string(char *buf, cptr str)
6048 /* Necessary border */
6052 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6058 * Save a "bones" file for a dead character
6060 * Note that we will not use these files until Angband 2.8.0, and
6061 * then we will only use the name and level on which death occured.
6063 * Should probably attempt some form of locking...
6065 static void make_bones(void)
6072 /* Ignore wizards and borgs */
6073 if (!(noscore & 0x00FF))
6075 /* Ignore people who die in town */
6080 /* XXX XXX XXX "Bones" name */
6081 sprintf(tmp, "bone.%03d", dun_level);
6083 /* Build the filename */
6084 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6086 /* Attempt to open the bones file */
6087 fp = my_fopen(str, "r");
6089 /* Close it right away */
6090 if (fp) my_fclose(fp);
6092 /* Do not over-write a previous ghost */
6095 /* File type is "TEXT" */
6096 FILE_TYPE(FILE_TYPE_TEXT);
6098 /* Try to write a new "Bones File" */
6099 fp = my_fopen(str, "w");
6101 /* Not allowed to write it? Weird. */
6105 fprintf(fp, "%s\n", player_name);
6106 fprintf(fp, "%d\n", p_ptr->mhp);
6107 fprintf(fp, "%d\n", p_ptr->prace);
6108 fprintf(fp, "%d\n", p_ptr->pclass);
6110 /* Close and save the Bones file */
6119 * Redefinable "print_tombstone" action
6121 bool (*tombstone_aux)(void) = NULL;
6125 * Display a "tomb-stone"
6127 static void print_tomb(void)
6131 /* Do we use a special tombstone ? */
6134 /* Use tombstone hook */
6135 done = (*tombstone_aux)();
6138 /* Print the text-tombstone */
6152 time_t ct = time((time_t)0);
6158 /* Build the filename */
6160 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6162 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6166 /* Open the News file */
6167 fp = my_fopen(buf, "r");
6174 /* Dump the file to the screen */
6175 while (0 == my_fgets(fp, buf, 1024))
6177 /* Display and advance */
6178 put_str(buf, i++, 0);
6187 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6201 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6204 center_string(buf, player_name);
6205 put_str(buf, 6, 11);
6208 center_string(buf, "the");
6209 put_str(buf, 7, 11);
6212 center_string(buf, p);
6213 put_str(buf, 8, 11);
6216 center_string(buf, cp_ptr->title);
6218 put_str(buf, 10, 11);
6221 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6223 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6226 center_string(buf, tmp);
6227 put_str(buf, 11, 11);
6230 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6232 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6235 center_string(buf, tmp);
6236 put_str(buf, 12, 11);
6239 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6241 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6244 center_string(buf, tmp);
6245 put_str(buf, 13, 11);
6248 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6249 if (streq(died_from, "ÅÓÃ潪λ"))
6251 strcpy(tmp, "<¼«»¦>");
6255 if (streq(died_from, "ripe"))
6257 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6259 else if (streq(died_from, "Seppuku"))
6261 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6265 strcpy(tmp, died_from);
6268 center_string(buf, tmp);
6269 put_str(buf, 14, 11);
6271 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6273 if( dun_level == 0 )
6275 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6276 if(streq(died_from, "ÅÓÃ潪λ"))
6278 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6282 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6287 if(streq(died_from, "ÅÓÃ潪λ"))
6289 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6293 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6296 center_string(buf, tmp);
6297 put_str(buf, 15, 11);
6300 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6301 center_string(buf, tmp);
6302 put_str(buf, 14, 11);
6305 if (strlen(died_from) > 24)
6307 strncpy(dummy, died_from, 24);
6309 (void)sprintf(tmp, "by %s.", dummy);
6312 (void)sprintf(tmp, "by %s.", died_from);
6314 center_string(buf, tmp);
6315 put_str(buf, 15, 11);
6320 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6321 center_string(buf, tmp);
6322 put_str(buf, 17, 11);
6325 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6327 msg_format("Goodbye, %s!", player_name);
6335 * Display some character info
6337 static void show_info(void)
6343 /* Hack -- Know everything in the inven/equip */
6344 for (i = 0; i < INVEN_TOTAL; i++)
6346 o_ptr = &inventory[i];
6348 /* Skip non-objects */
6349 if (!o_ptr->k_idx) continue;
6351 /* Aware and Known */
6352 object_aware(o_ptr);
6353 object_known(o_ptr);
6356 for (i = 1; i < max_towns; i++)
6358 st_ptr = &town[i].store[STORE_HOME];
6360 /* Hack -- Know everything in the home */
6361 for (j = 0; j < st_ptr->stock_num; j++)
6363 o_ptr = &st_ptr->stock[j];
6365 /* Skip non-objects */
6366 if (!o_ptr->k_idx) continue;
6368 /* Aware and Known */
6369 object_aware(o_ptr);
6370 object_known(o_ptr);
6374 /* Hack -- Recalculate bonuses */
6375 p_ptr->update |= (PU_BONUS);
6380 /* Flush all input keys */
6383 /* Flush messages */
6387 /* Describe options */
6389 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6390 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6392 prt("You may now dump a character record to one or more files.", 21, 0);
6393 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6397 /* Dump character records as requested */
6404 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6406 put_str("Filename: ", 23, 0);
6411 strcpy(out_val, "");
6413 /* Ask for filename (or abort) */
6414 if (!askfor_aux(out_val, 60)) return;
6416 /* Return means "show on screen" */
6417 if (!out_val[0]) break;
6422 /* Dump a character file */
6423 (void)file_character(out_val, TRUE);
6431 /* Display player */
6434 /* Prompt for inventory */
6436 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6438 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6442 /* Allow abort at this point */
6443 if (inkey() == ESCAPE) return;
6446 /* Show equipment and inventory */
6448 /* Equipment -- if any */
6452 item_tester_full = TRUE;
6453 (void)show_equip(0);
6455 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6457 prt("You are using: -more-", 0, 0);
6460 if (inkey() == ESCAPE) return;
6463 /* Inventory -- if any */
6467 item_tester_full = TRUE;
6468 (void)show_inven(0);
6470 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6472 prt("You are carrying: -more-", 0, 0);
6475 if (inkey() == ESCAPE) return;
6478 /* Homes in the different towns */
6479 for (l = 1; l < max_towns; l++)
6481 st_ptr = &town[l].store[STORE_HOME];
6483 /* Home -- if anything there */
6484 if (st_ptr->stock_num)
6486 /* Display contents of the home */
6487 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6493 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6495 char o_name[MAX_NLEN];
6499 o_ptr = &st_ptr->stock[i];
6501 /* Print header, clear line */
6502 sprintf(tmp_val, "%c) ", I2A(j));
6503 prt(tmp_val, j+2, 4);
6505 /* Display object description */
6506 object_desc(o_name, o_ptr, TRUE, 3);
6507 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6512 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6514 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6519 if (inkey() == ESCAPE) return;
6526 static bool check_score(void)
6532 if (highscore_fd < 0)
6535 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6537 msg_print("Score file unavailable.");
6544 #ifndef SCORE_WIZARDS
6545 /* Wizard-mode pre-empts scoring */
6546 if (noscore & 0x000F)
6549 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6551 msg_print("Score not registered for wizards.");
6560 /* Borg-mode pre-empts scoring */
6561 if (noscore & 0x00F0)
6564 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6566 msg_print("Score not registered for borgs.");
6574 #ifndef SCORE_CHEATERS
6575 /* Cheaters are not scored */
6576 if (noscore & 0xFF00)
6579 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6581 msg_print("Score not registered for cheaters.");
6591 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6593 if (!total_winner && streq(died_from, "Interrupting"))
6598 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6600 msg_print("Score not registered due to interruption.");
6609 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6611 if (!total_winner && streq(died_from, "Quitting"))
6616 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6618 msg_print("Score not registered due to quitting.");
6628 * Close up the current game (player may or may not be dead)
6630 * This function is called only from "main.c" and "signals.c".
6632 void close_game(void)
6635 bool do_send = TRUE;
6637 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6642 /* Flush the messages */
6645 /* Flush the input */
6649 /* No suspending now */
6650 signals_ignore_tstp();
6653 /* Hack -- Character is now "icky" */
6654 character_icky = TRUE;
6657 /* Build the filename */
6658 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6660 /* Open the high score file, for reading/writing */
6661 highscore_fd = fd_open(buf, O_RDWR);
6667 /* Handle retirement */
6668 if (total_winner) kingly();
6672 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6674 if (!munchkin_death || get_check("Save death? "))
6679 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6681 if (!save_player()) msg_print("death save failed!");
6684 else do_send = FALSE;
6691 /* Show more info */
6699 if ((!send_world_score(do_send)))
6702 if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
6704 if (get_check("Stand by for later score registration? "))
6707 wait_report_score = TRUE;
6710 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6712 if (!save_player()) msg_print("death save failed!");
6716 if (!wait_report_score)
6719 else if (highscore_fd >= 0)
6721 display_scores_aux(0, 10, -1, NULL);
6724 /* Dump bones file */
6733 do_cmd_save_game(FALSE);
6735 /* Prompt for scores XXX XXX XXX */
6737 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6739 prt("Press Return (or Escape).", 0, 40);
6743 /* Predict score (or ESCAPE) */
6744 if (inkey() != ESCAPE) predict_score();
6748 /* Shut the high score file */
6749 (void)fd_close(highscore_fd);
6751 /* Forget the high score fd */
6755 /* Allow suspending now */
6756 signals_handle_tstp();
6761 * Handle abrupt death of the visual system
6763 * This routine is called only in very rare situations, and only
6764 * by certain visual systems, when they experience fatal errors.
6766 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6767 * save file so that player can see tombstone when restart.
6769 void exit_game_panic(void)
6771 /* If nothing important has happened, just quit */
6773 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6775 if (!character_generated || character_saved) quit("panic");
6779 /* Mega-Hack -- see "msg_print()" */
6782 /* Clear the top line */
6785 /* Hack -- turn off some things */
6788 /* Mega-Hack -- Delay death */
6789 if (p_ptr->chp < 0) death = FALSE;
6791 /* Hardcode panic save */
6794 /* Forbid suspend */
6795 signals_ignore_tstp();
6797 /* Indicate panic save */
6799 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6801 (void)strcpy(died_from, "(panic save)");
6805 /* Panic save, or get worried */
6807 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6809 if (!save_player()) quit("panic save failed!");
6813 /* Successful panic save */
6815 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6817 quit("panic save succeeded!");
6824 * Get a random line from a file
6825 * Based on the monster speech patch by Matt Graham,
6827 errr get_rnd_line(cptr file_name, int entry, char *output)
6831 int line, counter, test, numentries;
6836 /* Build the filename */
6837 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6840 fp = my_fopen(buf, "r");
6843 if (!fp) return (-1);
6845 /* Find the entry of the monster */
6848 /* Get a line from the file */
6849 if (my_fgets(fp, buf, 1024) == 0)
6851 /* Count the lines */
6854 /* Look for lines starting with 'N:' */
6855 if ((buf[0] == 'N') && (buf[1] == ':'))
6857 /* Allow default lines */
6864 else if (buf[2] == 'M')
6866 if (r_info[entry].flags1 & RF1_MALE)
6872 else if (buf[2] == 'F')
6874 if (r_info[entry].flags1 & RF1_FEMALE)
6880 /* Get the monster number */
6881 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6883 /* Is it the right monster? */
6892 /* Error while converting the monster number */
6893 msg_format("Error in line %d of %s!",
6894 line_num, file_name);
6902 /* Reached end of file */
6909 /* Get the number of entries */
6913 if (my_fgets(fp, buf, 1024) == 0)
6915 /* Count the lines */
6918 /* Look for the number of entries */
6919 if (isdigit(buf[0]))
6921 /* Get the number of entries */
6922 numentries = atoi(buf);
6928 /* Count the lines */
6931 /* Reached end of file without finding the number */
6932 msg_format("Error in line %d of %s!",
6933 line_num, file_name);
6942 /* Grab an appropriate line number */
6943 line = rand_int(numentries);
6945 /* Get the random line */
6946 for (counter = 0; counter <= line; counter++)
6948 /* Count the lines */
6953 test = my_fgets(fp, buf, 1024);
6954 if(test || buf[0] != '#')
6960 /* Found the line */
6961 if (counter == line) break;
6965 /* Error - End of file */
6966 msg_format("Error in line %d of %s!",
6967 line_num, file_name);
6975 strcpy(output, buf);
6982 /* Close the file */
6991 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
6995 for (i=0;i<count;i++){
6996 result=get_rnd_line(file_name, entry, output);
6999 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7007 * Process file for auto picker/destroyer.
7009 errr process_pickpref_file(cptr name)
7015 /* Build the filename */
7016 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7018 err = process_pref_file_aux(buf, TRUE);
7024 static errr counts_seek(int fd, u32b where, bool flag)
7027 char temp1[128], temp2[128];
7028 u32b zero_header[3] = {0L, 0L, 0L};
7031 #ifdef SAVEFILE_USE_UID
7032 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7034 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7036 for (i = 0; temp1[i]; i++)
7037 temp1[i] ^= (i+1) * 63;
7042 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7044 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7049 fd_seek(fd, seekpoint);
7050 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7051 fd_write(fd, (char*)(temp1), sizeof(temp1));
7055 if (strcmp(temp1, temp2) == 0)
7058 seekpoint += 128 + 3 * sizeof(u32b);
7061 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7064 u32b counts_read(int where)
7071 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7073 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7075 fd = fd_open(buf, O_RDONLY);
7077 if (counts_seek(fd, where, FALSE) ||
7078 fd_read(fd, (char*)(&count), sizeof(u32b)))
7086 errr counts_write(int where, u32b count)
7092 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7094 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7096 fd = fd_open(buf, O_RDWR);
7099 /* File type is "DATA" */
7100 FILE_TYPE(FILE_TYPE_DATA);
7102 /* Create a new high score file */
7103 fd = fd_make(buf, 0644);
7106 if (fd_lock(fd, F_WRLCK)) return 1;
7108 counts_seek(fd, where, TRUE);
7109 fd_write(fd, (char*)(&count), sizeof(u32b));
7111 if (fd_lock(fd, F_UNLCK)) return 1;
7119 #ifdef HANDLE_SIGNALS
7126 * Handle signals -- suspend
7128 * Actually suspend the game, and then resume cleanly
7130 static void handle_signal_suspend(int sig)
7132 /* Disable handler */
7133 (void)signal(sig, SIG_IGN);
7140 /* Suspend the "Term" */
7141 Term_xtra(TERM_XTRA_ALIVE, 0);
7143 /* Suspend ourself */
7144 (void)kill(0, SIGSTOP);
7146 /* Resume the "Term" */
7147 Term_xtra(TERM_XTRA_ALIVE, 1);
7149 /* Redraw the term */
7152 /* Flush the term */
7157 /* Restore handler */
7158 (void)signal(sig, handle_signal_suspend);
7163 * Handle signals -- simple (interrupt and quit)
7165 * This function was causing a *huge* number of problems, so it has
7166 * been simplified greatly. We keep a global variable which counts
7167 * the number of times the user attempts to kill the process, and
7168 * we commit suicide if the user does this a certain number of times.
7170 * We attempt to give "feedback" to the user as he approaches the
7171 * suicide thresh-hold, but without penalizing accidental keypresses.
7173 * To prevent messy accidents, we should reset this global variable
7174 * whenever the user enters a keypress, or something like that.
7176 static void handle_signal_simple(int sig)
7178 /* Disable handler */
7179 (void)signal(sig, SIG_IGN);
7182 /* Nothing to save, just quit */
7183 if (!character_generated || character_saved) quit(NULL);
7186 /* Count the signals */
7190 /* Terminate dead characters */
7193 /* Mark the savefile */
7195 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7197 (void)strcpy(died_from, "Abortion");
7216 /* Allow suicide (after 5) */
7217 else if (signal_count >= 5)
7219 /* Cause of "death" */
7221 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7223 (void)strcpy(died_from, "Interrupting");
7238 p_ptr->leaving = TRUE;
7252 /* Give warning (after 4) */
7253 else if (signal_count >= 4)
7256 Term_xtra(TERM_XTRA_NOISE, 0);
7258 /* Clear the top line */
7259 Term_erase(0, 0, 255);
7261 /* Display the cause */
7263 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7265 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7273 /* Give warning (after 2) */
7274 else if (signal_count >= 2)
7277 Term_xtra(TERM_XTRA_NOISE, 0);
7280 /* Restore handler */
7281 (void)signal(sig, handle_signal_simple);
7286 * Handle signal -- abort, kill, etc
7288 static void handle_signal_abort(int sig)
7290 /* Disable handler */
7291 (void)signal(sig, SIG_IGN);
7294 /* Nothing to save, just quit */
7295 if (!character_generated || character_saved) quit(NULL);
7302 /* Clear the bottom line */
7303 Term_erase(0, 23, 255);
7305 /* Give a warning */
7306 Term_putstr(0, 23, -1, TERM_RED,
7308 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7310 "A gruesome software bug LEAPS out at you!");
7316 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7318 Term_putstr(45, 23, -1, TERM_RED, "Panic save...");
7330 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7332 (void)strcpy(died_from, "(panic save)");
7336 /* Forbid suspend */
7337 signals_ignore_tstp();
7339 /* Attempt to save */
7343 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7345 Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
7354 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7356 Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
7366 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7368 quit("software bug");
7377 * Ignore SIGTSTP signals (keyboard suspend)
7379 void signals_ignore_tstp(void)
7383 (void)signal(SIGTSTP, SIG_IGN);
7389 * Handle SIGTSTP signals (keyboard suspend)
7391 void signals_handle_tstp(void)
7395 (void)signal(SIGTSTP, handle_signal_suspend);
7402 * Prepare to handle the relevant signals
7404 void signals_init(void)
7408 (void)signal(SIGHUP, SIG_IGN);
7413 (void)signal(SIGTSTP, handle_signal_suspend);
7418 (void)signal(SIGINT, handle_signal_simple);
7422 (void)signal(SIGQUIT, handle_signal_simple);
7427 (void)signal(SIGFPE, handle_signal_abort);
7431 (void)signal(SIGILL, handle_signal_abort);
7435 (void)signal(SIGTRAP, handle_signal_abort);
7439 (void)signal(SIGIOT, handle_signal_abort);
7443 (void)signal(SIGKILL, handle_signal_abort);
7447 (void)signal(SIGBUS, handle_signal_abort);
7451 (void)signal(SIGSEGV, handle_signal_abort);
7455 (void)signal(SIGTERM, handle_signal_abort);
7459 (void)signal(SIGPIPE, handle_signal_abort);
7463 (void)signal(SIGEMT, handle_signal_abort);
7467 (void)signal(SIGDANGER, handle_signal_abort);
7471 (void)signal(SIGSYS, handle_signal_abort);
7475 (void)signal(SIGXCPU, handle_signal_abort);
7479 (void)signal(SIGPWR, handle_signal_abort);
7485 #else /* HANDLE_SIGNALS */
7491 void signals_ignore_tstp(void)
7498 void signals_handle_tstp(void)
7505 void signals_init(void)
7508 #endif /* HANDLE_SIGNALS */