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_DAY 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, 15, -1, "ÃγР:"},
1637 {54, 16, -1, "õº÷ :"},
1638 {54, 17, -1, "²ò½ü :"},
1639 {54, 18, -1, "ËâË¡Æ»¶ñ :"},
1640 {01, 12, 25, "ÂÇ·â²ó¿ô"},
1641 {01, 17, 25, "¼Í·â²ó¿ô"},
1642 {01, 13, 25, "Ê¿¶Ñ¥À¥á¡¼¥¸"},
1643 {54, 20, -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, 7, 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, "Shooting"},
1666 { 1, 16, 25, "Multiplier"},
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, "Time"},
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, 15, -1, "Perception : "},
1683 {54, 16, -1, "Searching : "},
1684 {54, 17, -1, "Disarming : "},
1685 {54, 18, -1, "Magic Device: "},
1686 {01, 12, 25, "Blows/Round"},
1687 {01, 17, 25, "Shots/Round"},
1688 {01, 13, 25, "AverageDmg/Rnd"},
1689 {54, 20, -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, 7, 21, "Align"},
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);
1916 s32b len = 20L * TOWN_DAWN;
1917 s32b tick = turn % len + len / 4;
1921 "%2ldÆüÌÜ %ld:%02ld",
1923 "Day %ld %ld:%02ld",
1925 ((p_ptr->prace == RACE_VAMPIRE) ||
1926 (p_ptr->prace == RACE_SKELETON) ||
1927 (p_ptr->prace == RACE_ZOMBIE) ||
1928 (p_ptr->prace == RACE_SPECTRE))
1929 ? (turn - (15L * TOWN_DAWN)) / len + 1
1930 : (turn + (5L * TOWN_DAWN))/ len + 1,
1931 (24 * tick / len) % 24,
1932 (1440 * tick / len) % 60);
1934 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1936 /* Dump hit point */
1937 if (p_ptr->chp >= p_ptr->mhp)
1938 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1939 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1940 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1942 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1944 /* Dump mana power */
1945 if (p_ptr->csp >= p_ptr->msp)
1946 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1947 else if (p_ptr->csp > (p_ptr->msp * hitpoint_warn) / 10)
1948 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1950 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1952 /* Dump play time */
1953 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1958 * Hack -- pass color info around this file
1960 static byte likert_color = TERM_WHITE;
1964 * Returns a "rating" of x depending on y
1966 static cptr likert(int x, int y)
1968 static char dummy[20] = "";
1973 /* Negative value */
1976 likert_color = TERM_L_DARK;
1980 return ("Very Bad");
1985 /* Analyze the value */
1991 likert_color = TERM_RED;
2001 likert_color = TERM_L_RED;
2012 likert_color = TERM_ORANGE;
2022 likert_color = TERM_YELLOW;
2032 likert_color = TERM_YELLOW;
2034 return ("ÂçÊÑÎɤ¤");
2036 return ("Very Good");
2043 likert_color = TERM_L_GREEN;
2047 return ("Excellent");
2057 likert_color = TERM_GREEN;
2070 likert_color = TERM_BLUE;
2072 return ("¥«¥ª¥¹¥é¥ó¥¯");
2074 return ("Chaos Rank");
2080 likert_color = TERM_VIOLET;
2082 sprintf(dummy,"¥¢¥ó¥Ð¡¼ [%d]", (int) ((((x/y)-17)*5)/2));
2084 sprintf(dummy,"Amber [%d]", (int) ((((x/y)-17)*5)/2));
2094 * Prints ratings on certain abilities
2096 * This code is "imitated" elsewhere to "dump" a character sheet.
2098 static void display_player_various(void)
2100 int tmp, damage[2], blows1, blows2, i, basedam;
2101 int xthn, xthb, xfos, xsrh;
2102 int xdis, xdev, xsav, xstl;
2106 int shots, shot_frac;
2110 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2111 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2112 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2113 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2114 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2116 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2118 /* Shooting Skill (with current bow and normal missile) */
2119 o_ptr = &inventory[INVEN_BOW];
2120 tmp = p_ptr->to_h_b + o_ptr->to_h;
2121 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2123 /* If the player is wielding one? */
2126 s16b energy_fire = bow_energy(o_ptr->sval);
2128 /* Calculate shots per round */
2129 shots = p_ptr->num_fire * 100;
2130 shot_frac = (shots * 100 / energy_fire) % 100;
2131 shots = shots / energy_fire;
2132 if (o_ptr->name1 == ART_CRIMSON)
2136 if (p_ptr->pclass == CLASS_ARCHER)
2138 /* Extra shot at level 10 */
2139 if (p_ptr->lev >= 10) shots++;
2141 /* Extra shot at level 30 */
2142 if (p_ptr->lev >= 30) shots++;
2144 /* Extra shot at level 45 */
2145 if (p_ptr->lev >= 45) shots++;
2155 for(i = 0; i< 2; i++)
2157 damage[i] = p_ptr->dis_to_d[i]*100;
2158 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) > 1))
2160 int level = p_ptr->lev;
2166 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2167 if (p_ptr->special_defense & KAMAE_BYAKKO)
2168 basedam = monk_ave_damage[level][1];
2169 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2170 basedam = monk_ave_damage[level][2];
2172 basedam = monk_ave_damage[level][0];
2176 /* Average damage per round */
2177 o_ptr = &inventory[INVEN_RARM+i];
2178 if (object_known_p(o_ptr)) damage[i] += o_ptr->to_d*100;
2179 basedam = (o_ptr->dd * (o_ptr->ds + 1))*50;
2180 object_flags(o_ptr, &f1, &f2, &f3);
2181 if ((o_ptr->ident & IDENT_MENTAL) && (o_ptr->name1 == ART_VORPAL_BLADE))
2187 else if (object_known_p(o_ptr) && (f1 & TR1_VORPAL))
2189 /* vorpal flag only */
2193 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)))
2194 basedam = basedam * 7 / 2;
2195 if (p_ptr->riding && (o_ptr->tval == TV_POLEARM) && ((o_ptr->sval == SV_LANCE) || (o_ptr->sval == SV_HEAVY_LANCE)))
2196 basedam = basedam*(o_ptr->dd+2)/o_ptr->dd;
2198 damage[i] += basedam;
2199 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2200 if (damage[i] < 0) damage[i] = 0;
2202 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2203 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2205 /* Basic abilities */
2207 xdis = p_ptr->skill_dis;
2208 xdev = p_ptr->skill_dev;
2209 xsav = p_ptr->skill_sav;
2210 xstl = p_ptr->skill_stl;
2211 xsrh = p_ptr->skill_srh;
2212 xfos = p_ptr->skill_fos;
2215 desc = likert(xthn, 12);
2216 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2218 desc = likert(xthb, 12);
2219 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2221 desc = likert(xsav, 7);
2222 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2224 desc = likert(xstl, 1);
2225 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2227 desc = likert(xfos, 6);
2228 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2230 desc = likert(xsrh, 6);
2231 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2233 desc = likert(xdis, 8);
2234 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2236 desc = likert(xdev, 6);
2237 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2240 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2242 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2244 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2247 if ((damage[0]+damage[1]) == 0)
2250 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2252 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2254 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2260 * Obtain the "flags" for the player as if he was an item
2262 static void player_flags(u32b *f1, u32b *f2, u32b *f3)
2265 (*f1) = (*f2) = (*f3) = 0L;
2268 switch (p_ptr->pclass)
2271 if (p_ptr->lev > 44)
2272 (*f3) |= (TR3_REGEN);
2274 if (p_ptr->lev > 29)
2275 (*f2) |= (TR2_RES_FEAR);
2278 if (p_ptr->lev > 39)
2279 (*f2) |= (TR2_RES_FEAR);
2281 case CLASS_CHAOS_WARRIOR:
2282 if (p_ptr->lev > 29)
2283 (*f2) |= (TR2_RES_CHAOS);
2284 if (p_ptr->lev > 39)
2285 (*f2) |= (TR2_RES_FEAR);
2288 case CLASS_FORCETRAINER:
2289 if ((p_ptr->lev > 9) && !heavy_armor())
2291 if ((p_ptr->lev>24) && !heavy_armor())
2292 (*f2) |= (TR2_FREE_ACT);
2299 if (!inventory[INVEN_LARM].tval || p_ptr->hidarite)
2302 (*f2) |= (TR2_FREE_ACT);
2304 (*f3) |= TR3_SLOW_DIGEST;
2305 (*f2) |= TR2_RES_FEAR;
2306 if (p_ptr->lev > 19) (*f2) |= TR2_RES_POIS;
2307 if (p_ptr->lev > 24) (*f2) |= TR2_SUST_DEX;
2308 if (p_ptr->lev > 29) (*f3) |= TR3_SEE_INVIS;
2310 case CLASS_MINDCRAFTER:
2312 (*f2) |= (TR2_RES_FEAR);
2313 if (p_ptr->lev > 19)
2314 (*f2) |= (TR2_SUST_WIS);
2315 if (p_ptr->lev > 29)
2316 (*f2) |= (TR2_RES_CONF);
2317 if (p_ptr->lev > 39)
2318 (*f3) |= (TR3_TELEPATHY);
2321 (*f2) |= (TR2_RES_SOUND);
2323 case CLASS_BERSERKER:
2324 (*f2) |= (TR2_SUST_STR);
2325 (*f2) |= (TR2_SUST_DEX);
2326 (*f2) |= (TR2_SUST_CON);
2327 (*f3) |= (TR3_REGEN);
2328 (*f2) |= (TR2_FREE_ACT);
2329 (*f1) |= (TR1_SPEED);
2330 if (p_ptr->lev > 39) (*f2) |= (TR2_REFLECT);
2332 case CLASS_MIRROR_MASTER:
2333 if(p_ptr->lev > 39)(*f2) |= (TR2_REFLECT);
2336 break; /* Do nothing */
2340 if (p_ptr->mimic_form)
2342 switch(p_ptr->mimic_form)
2345 (*f2) |= (TR2_HOLD_LIFE);
2346 (*f2) |= (TR2_RES_CHAOS);
2347 (*f2) |= (TR2_RES_NETHER);
2348 (*f2) |= (TR2_RES_FIRE);
2349 (*f3) |= (TR3_SEE_INVIS);
2350 (*f1) |= (TR1_SPEED);
2352 case MIMIC_DEMON_LORD:
2353 (*f2) |= (TR2_HOLD_LIFE);
2354 (*f2) |= (TR2_RES_CHAOS);
2355 (*f2) |= (TR2_RES_NETHER);
2356 (*f2) |= (TR2_RES_FIRE);
2357 (*f2) |= (TR2_RES_COLD);
2358 (*f2) |= (TR2_RES_ELEC);
2359 (*f2) |= (TR2_RES_ACID);
2360 (*f2) |= (TR2_RES_POIS);
2361 (*f2) |= (TR2_RES_CONF);
2362 (*f2) |= (TR2_RES_DISEN);
2363 (*f2) |= (TR2_RES_NEXUS);
2364 (*f2) |= (TR2_RES_FEAR);
2365 (*f2) |= (TR2_IM_FIRE);
2366 (*f3) |= (TR3_SH_FIRE);
2367 (*f3) |= (TR3_SEE_INVIS);
2368 (*f3) |= (TR3_TELEPATHY);
2369 (*f3) |= (TR3_FEATHER);
2370 (*f1) |= (TR1_SPEED);
2373 (*f2) |= (TR2_HOLD_LIFE);
2374 (*f2) |= (TR2_RES_DARK);
2375 (*f2) |= (TR2_RES_NETHER);
2376 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2377 (*f2) |= (TR2_RES_POIS);
2378 (*f2) |= (TR2_RES_COLD);
2379 (*f3) |= (TR3_SEE_INVIS);
2380 (*f1) |= (TR1_SPEED);
2386 switch (p_ptr->prace)
2389 (*f2) |= (TR2_RES_LITE);
2392 (*f2) |= (TR2_SUST_DEX);
2395 (*f2) |= (TR2_FREE_ACT);
2398 (*f2) |= (TR2_RES_BLIND);
2401 (*f2) |= (TR2_RES_DARK);
2403 case RACE_HALF_TROLL:
2404 (*f2) |= (TR2_SUST_STR);
2405 if (p_ptr->lev > 14)
2407 (*f3) |= (TR3_REGEN);
2408 if (p_ptr->pclass == CLASS_WARRIOR)
2410 (*f3) |= (TR3_SLOW_DIGEST);
2412 * Let's not make Regeneration a disadvantage
2413 * for the poor warriors who can never learn
2414 * a spell that satisfies hunger (actually
2415 * neither can rogues, but half-trolls are not
2416 * supposed to play rogues)
2422 (*f2) |= (TR2_SUST_CON);
2423 (*f3) |= (TR3_REGEN); /* Amberites heal fast */
2426 (*f2) |= (TR2_RES_LITE);
2427 (*f3) |= (TR3_SEE_INVIS);
2429 case RACE_BARBARIAN:
2430 (*f2) |= (TR2_RES_FEAR);
2432 case RACE_HALF_OGRE:
2433 (*f2) |= (TR2_SUST_STR);
2434 (*f2) |= (TR2_RES_DARK);
2436 case RACE_HALF_GIANT:
2437 (*f2) |= (TR2_RES_SHARDS);
2438 (*f2) |= (TR2_SUST_STR);
2440 case RACE_HALF_TITAN:
2441 (*f2) |= (TR2_RES_CHAOS);
2444 (*f2) |= (TR2_RES_SOUND);
2447 (*f2) |= (TR2_RES_ACID);
2448 if (p_ptr->lev > 19)
2449 (*f2) |= (TR2_IM_ACID);
2452 (*f2) |= (TR2_RES_CONF);
2453 (*f2) |= (TR2_RES_ACID);
2458 (*f2) |= (TR2_RES_POIS);
2461 (*f2) |= (TR2_RES_DISEN);
2462 (*f2) |= (TR2_RES_DARK);
2465 (*f2) |= (TR2_RES_DARK);
2466 if (p_ptr->lev > 19)
2467 (*f3) |= (TR3_SEE_INVIS);
2469 case RACE_DRACONIAN:
2470 (*f3) |= TR3_FEATHER;
2472 (*f2) |= (TR2_RES_FIRE);
2474 (*f2) |= (TR2_RES_COLD);
2475 if (p_ptr->lev > 14)
2476 (*f2) |= (TR2_RES_ACID);
2477 if (p_ptr->lev > 19)
2478 (*f2) |= (TR2_RES_ELEC);
2479 if (p_ptr->lev > 34)
2480 (*f2) |= (TR2_RES_POIS);
2482 case RACE_MIND_FLAYER:
2483 (*f2) |= (TR2_SUST_INT);
2484 (*f2) |= (TR2_SUST_WIS);
2485 if (p_ptr->lev > 14)
2486 (*f3) |= (TR3_SEE_INVIS);
2487 if (p_ptr->lev > 29)
2488 (*f3) |= (TR3_TELEPATHY);
2491 (*f2) |= (TR2_RES_FIRE);
2493 (*f3) |= (TR3_SEE_INVIS);
2496 (*f3) |= (TR3_SEE_INVIS);
2497 (*f2) |= (TR2_FREE_ACT);
2498 (*f2) |= (TR2_RES_POIS);
2499 (*f3) |= (TR3_SLOW_DIGEST);
2500 if (p_ptr->lev > 34)
2501 (*f2) |= (TR2_HOLD_LIFE);
2504 (*f3) |= (TR3_SEE_INVIS);
2505 (*f2) |= (TR2_RES_SHARDS);
2506 (*f2) |= (TR2_HOLD_LIFE);
2507 (*f2) |= (TR2_RES_POIS);
2509 (*f2) |= (TR2_RES_COLD);
2512 (*f3) |= (TR3_SEE_INVIS);
2513 (*f2) |= (TR2_HOLD_LIFE);
2514 (*f2) |= (TR2_RES_NETHER);
2515 (*f2) |= (TR2_RES_POIS);
2516 (*f3) |= (TR3_SLOW_DIGEST);
2518 (*f2) |= (TR2_RES_COLD);
2521 (*f2) |= (TR2_HOLD_LIFE);
2522 (*f2) |= (TR2_RES_DARK);
2523 (*f2) |= (TR2_RES_NETHER);
2524 if (p_ptr->pclass != CLASS_NINJA) (*f3) |= (TR3_LITE);
2525 (*f2) |= (TR2_RES_POIS);
2526 (*f2) |= (TR2_RES_COLD);
2529 (*f3) |= (TR3_FEATHER);
2530 (*f2) |= (TR2_FREE_ACT);
2531 (*f2) |= (TR2_RES_COLD);
2532 (*f3) |= (TR3_SEE_INVIS);
2533 (*f2) |= (TR2_HOLD_LIFE);
2534 (*f2) |= (TR2_RES_NETHER);
2535 (*f2) |= (TR2_RES_POIS);
2536 (*f3) |= (TR3_SLOW_DIGEST);
2538 if (p_ptr->lev > 34)
2539 (*f3) |= TR3_TELEPATHY;
2542 (*f2) |= (TR2_RES_LITE);
2543 (*f3) |= (TR3_FEATHER);
2545 (*f1) |= (TR1_SPEED);
2548 (*f2) |= (TR2_RES_SOUND);
2549 (*f2) |= (TR2_RES_CONF);
2552 (*f3) |= (TR3_FEATHER);
2553 (*f3) |= (TR3_SEE_INVIS);
2556 (*f2) |= (TR2_RES_FIRE);
2557 (*f2) |= (TR2_RES_NETHER);
2558 (*f2) |= (TR2_HOLD_LIFE);
2560 (*f3) |= (TR3_SEE_INVIS);
2563 (*f2) |= (TR2_SUST_CON);
2566 (*f3) |= (TR3_FEATHER);
2569 (*f2) |= (TR2_RES_CONF);
2572 (*f2) |= (TR2_FREE_ACT);
2573 (*f2) |= (TR2_RES_POIS);
2574 (*f3) |= (TR3_SLOW_DIGEST);
2575 (*f2) |= (TR2_HOLD_LIFE);
2585 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2587 (*f3) &= ~(TR3_REGEN);
2590 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2591 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2592 (p_ptr->muta3 & MUT3_SHORT_LEG))
2597 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2599 (*f3) |= TR3_SH_ELEC;
2602 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2604 (*f3) |= TR3_SH_FIRE;
2608 if (p_ptr->muta3 & MUT3_WINGS)
2610 (*f3) |= TR3_FEATHER;
2613 if (p_ptr->muta3 & MUT3_FEARLESS)
2615 (*f2) |= (TR2_RES_FEAR);
2618 if (p_ptr->muta3 & MUT3_REGEN)
2623 if (p_ptr->muta3 & MUT3_ESP)
2625 (*f3) |= TR3_TELEPATHY;
2628 if (p_ptr->muta3 & MUT3_MOTION)
2630 (*f2) |= TR2_FREE_ACT;
2634 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2635 (*f3) |= TR3_AGGRAVATE;
2636 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2638 (*f2) |= (TR2_RES_BLIND);
2639 (*f2) |= (TR2_RES_CONF);
2640 (*f2) |= (TR2_HOLD_LIFE);
2641 (*f3) |= (TR3_LITE);
2643 (*f1) |= (TR1_SPEED);
2645 if (p_ptr->special_defense & KATA_FUUJIN)
2646 (*f2) |= TR2_REFLECT;
2647 if (p_ptr->special_defense & KAMAE_GENBU)
2648 (*f2) |= TR2_REFLECT;
2649 if (p_ptr->special_defense & KAMAE_SUZAKU)
2650 (*f3) |= TR3_FEATHER;
2651 if (p_ptr->special_defense & KAMAE_SEIRYU)
2653 (*f2) |= (TR2_RES_FIRE);
2654 (*f2) |= (TR2_RES_COLD);
2655 (*f2) |= (TR2_RES_ACID);
2656 (*f2) |= (TR2_RES_ELEC);
2657 (*f2) |= (TR2_RES_POIS);
2658 (*f3) |= (TR3_FEATHER);
2659 (*f3) |= (TR3_SH_FIRE);
2660 (*f3) |= (TR3_SH_ELEC);
2661 (*f3) |= (TR3_SH_COLD);
2663 if (p_ptr->special_defense & KATA_MUSOU)
2665 (*f2) |= TR2_RES_FEAR;
2666 (*f2) |= TR2_RES_LITE;
2667 (*f2) |= TR2_RES_DARK;
2668 (*f2) |= TR2_RES_BLIND;
2669 (*f2) |= TR2_RES_CONF;
2670 (*f2) |= TR2_RES_SOUND;
2671 (*f2) |= TR2_RES_SHARDS;
2672 (*f2) |= TR2_RES_NETHER;
2673 (*f2) |= TR2_RES_NEXUS;
2674 (*f2) |= TR2_RES_CHAOS;
2675 (*f2) |= TR2_RES_DISEN;
2676 (*f2) |= TR2_REFLECT;
2677 (*f2) |= TR2_HOLD_LIFE;
2678 (*f2) |= TR2_FREE_ACT;
2679 (*f3) |= TR3_SH_FIRE;
2680 (*f3) |= TR3_SH_ELEC;
2681 (*f3) |= TR3_SH_COLD;
2682 (*f3) |= TR3_FEATHER;
2684 (*f3) |= TR3_SEE_INVIS;
2685 (*f3) |= TR3_TELEPATHY;
2686 (*f3) |= TR3_SLOW_DIGEST;
2688 (*f2) |= (TR2_SUST_STR);
2689 (*f2) |= (TR2_SUST_INT);
2690 (*f2) |= (TR2_SUST_WIS);
2691 (*f2) |= (TR2_SUST_DEX);
2692 (*f2) |= (TR2_SUST_CON);
2693 (*f2) |= (TR2_SUST_CHR);
2698 static void tim_player_flags(u32b *f1, u32b *f2, u32b *f3, bool im_and_res)
2701 (*f1) = (*f2) = (*f3) = 0L;
2703 if (p_ptr->hero || p_ptr->shero || music_singing(MUSIC_HERO) || music_singing(MUSIC_SHERO))
2704 (*f2) |= TR2_RES_FEAR;
2705 if (p_ptr->tim_invis)
2706 (*f3) |= TR3_SEE_INVIS;
2707 if (p_ptr->tim_regen)
2709 if (p_ptr->tim_esp || music_singing(MUSIC_MIND))
2710 (*f3) |= TR3_TELEPATHY;
2711 if (p_ptr->fast || p_ptr->slow || music_singing(MUSIC_SPEED) || music_singing(MUSIC_SHERO))
2713 if ((p_ptr->special_defense & KATA_MUSOU) || music_singing(MUSIC_RESIST))
2715 (*f2) |= (TR2_RES_FIRE);
2716 (*f2) |= (TR2_RES_COLD);
2717 (*f2) |= (TR2_RES_ACID);
2718 (*f2) |= (TR2_RES_ELEC);
2719 (*f2) |= (TR2_RES_POIS);
2723 if (p_ptr->oppose_acid && !(p_ptr->special_defense & DEFENSE_ACID) && !((prace_is_(RACE_YEEK)) && (p_ptr->lev > 19)))
2724 (*f2) |= TR2_RES_ACID;
2725 if (p_ptr->oppose_elec && !(p_ptr->special_defense & DEFENSE_ELEC))
2726 (*f2) |= TR2_RES_ELEC;
2727 if (p_ptr->oppose_fire && !(p_ptr->special_defense & DEFENSE_FIRE))
2728 (*f2) |= TR2_RES_FIRE;
2729 if (p_ptr->oppose_cold && !(p_ptr->special_defense & DEFENSE_COLD))
2730 (*f2) |= TR2_RES_COLD;
2734 if (p_ptr->oppose_acid)
2735 (*f2) |= TR2_RES_ACID;
2736 if (p_ptr->oppose_elec)
2737 (*f2) |= TR2_RES_ELEC;
2738 if (p_ptr->oppose_fire)
2739 (*f2) |= TR2_RES_FIRE;
2740 if (p_ptr->oppose_cold)
2741 (*f2) |= TR2_RES_COLD;
2743 if (p_ptr->oppose_pois)
2744 (*f2) |= TR2_RES_POIS;
2745 if (p_ptr->special_attack & ATTACK_ACID)
2746 (*f1) |= TR1_BRAND_ACID;
2747 if (p_ptr->special_attack & ATTACK_ELEC)
2748 (*f1) |= TR1_BRAND_ELEC;
2749 if (p_ptr->special_attack & ATTACK_FIRE)
2750 (*f1) |= TR1_BRAND_FIRE;
2751 if (p_ptr->special_attack & ATTACK_COLD)
2752 (*f1) |= TR1_BRAND_COLD;
2753 if (p_ptr->special_attack & ATTACK_POIS)
2754 (*f1) |= TR1_BRAND_POIS;
2755 if (p_ptr->special_defense & DEFENSE_ACID)
2756 (*f2) |= TR2_IM_ACID;
2757 if (p_ptr->special_defense & DEFENSE_ELEC)
2758 (*f2) |= TR2_IM_ELEC;
2759 if (p_ptr->special_defense & DEFENSE_FIRE)
2760 (*f2) |= TR2_IM_FIRE;
2761 if (p_ptr->special_defense & DEFENSE_COLD)
2762 (*f2) |= TR2_IM_COLD;
2763 if (p_ptr->wraith_form)
2764 (*f2) |= TR2_REFLECT;
2766 if (p_ptr->tim_reflect){
2767 (*f2) |= TR2_REFLECT;
2770 if (p_ptr->magicdef)
2772 (*f2) |= TR2_RES_BLIND;
2773 (*f2) |= TR2_RES_CONF;
2774 (*f2) |= TR2_REFLECT;
2775 (*f2) |= TR2_FREE_ACT;
2776 (*f3) |= TR3_FEATHER;
2778 if (p_ptr->tim_res_nether)
2780 (*f2) |= TR2_RES_NETHER;
2782 if (p_ptr->tim_sh_fire)
2784 (*f3) |= TR3_SH_FIRE;
2788 (*f2) |= TR2_RES_FEAR;
2789 (*f2) |= TR2_RES_LITE;
2790 (*f2) |= TR2_RES_DARK;
2791 (*f2) |= TR2_RES_BLIND;
2792 (*f2) |= TR2_RES_CONF;
2793 (*f2) |= TR2_RES_SOUND;
2794 (*f2) |= TR2_RES_SHARDS;
2795 (*f2) |= TR2_RES_NETHER;
2796 (*f2) |= TR2_RES_NEXUS;
2797 (*f2) |= TR2_RES_CHAOS;
2798 (*f2) |= TR2_RES_DISEN;
2799 (*f2) |= TR2_REFLECT;
2800 (*f2) |= TR2_HOLD_LIFE;
2801 (*f2) |= TR2_FREE_ACT;
2802 (*f3) |= TR3_SH_FIRE;
2803 (*f3) |= TR3_SH_ELEC;
2804 (*f3) |= TR3_SH_COLD;
2805 (*f3) |= TR3_FEATHER;
2807 (*f3) |= TR3_SEE_INVIS;
2808 (*f3) |= TR3_TELEPATHY;
2809 (*f3) |= TR3_SLOW_DIGEST;
2811 (*f2) |= (TR2_SUST_STR);
2812 (*f2) |= (TR2_SUST_INT);
2813 (*f2) |= (TR2_SUST_WIS);
2814 (*f2) |= (TR2_SUST_DEX);
2815 (*f2) |= (TR2_SUST_CON);
2816 (*f2) |= (TR2_SUST_CHR);
2824 static void display_player_equippy(int y, int x)
2834 /* Dump equippy chars */
2835 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2838 o_ptr = &inventory[i];
2840 a = object_attr(o_ptr);
2841 c = object_char(o_ptr);
2843 /* Clear the part of the screen */
2844 if (!equippy_chars || !o_ptr->k_idx)
2851 Term_putch(x + i - INVEN_RARM, y, a, c);
2856 void print_equippy(void)
2858 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY);
2865 static void known_obj_immunity(u32b *f1, u32b *f2, u32b *f3)
2870 (*f1) = (*f2) = (*f3) = 0L;
2872 /* Check equipment */
2873 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2875 u32b o_f1, o_f2, o_f3;
2880 o_ptr = &inventory[i];
2882 if (!o_ptr->k_idx) continue;
2885 object_flags_known(o_ptr, &o_f1, &o_f2, &o_f3);
2887 if (o_f2 & TR2_IM_ACID) (*f2) |= TR2_RES_ACID;
2888 if (o_f2 & TR2_IM_ELEC) (*f2) |= TR2_RES_ELEC;
2889 if (o_f2 & TR2_IM_FIRE) (*f2) |= TR2_RES_FIRE;
2890 if (o_f2 & TR2_IM_COLD) (*f2) |= TR2_RES_COLD;
2894 static void player_immunity(u32b *f1, u32b *f2, u32b *f3)
2897 (*f1) = (*f2) = (*f3) = 0L;
2899 if (prace_is_(RACE_SPECTRE))
2900 (*f2) |= TR2_RES_NETHER;
2901 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2902 (*f2) |= TR2_RES_DARK;
2903 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2904 (*f2) |= TR2_RES_FIRE;
2905 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2906 (*f2) |= TR2_RES_ACID;
2909 static void tim_player_immunity(u32b *f1, u32b *f2, u32b *f3)
2912 (*f1) = (*f2) = (*f3) = 0L;
2914 if (p_ptr->special_defense & DEFENSE_ACID)
2915 (*f2) |= TR2_RES_ACID;
2916 if (p_ptr->special_defense & DEFENSE_ELEC)
2917 (*f2) |= TR2_RES_ELEC;
2918 if (p_ptr->special_defense & DEFENSE_FIRE)
2919 (*f2) |= TR2_RES_FIRE;
2920 if (p_ptr->special_defense & DEFENSE_COLD)
2921 (*f2) |= TR2_RES_COLD;
2922 if (p_ptr->wraith_form)
2923 (*f2) |= TR2_RES_DARK;
2926 static void player_vuln_flags(u32b *f1, u32b *f2, u32b *f3)
2929 (*f1) = (*f2) = (*f3) = 0L;
2931 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2933 (*f2) |= TR2_RES_ACID;
2934 (*f2) |= TR2_RES_ELEC;
2935 (*f2) |= TR2_RES_FIRE;
2936 (*f2) |= TR2_RES_COLD;
2938 if (prace_is_(RACE_ANDROID))
2939 (*f2) |= TR2_RES_ELEC;
2940 if (prace_is_(RACE_ENT))
2941 (*f2) |= TR2_RES_FIRE;
2942 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2943 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2944 (*f2) |= TR2_RES_LITE;
2948 * Helper function, see below
2950 static void display_player_flag_aux(int row, int col, char *header,
2951 int n, u32b flag1, u32b flag2,
2952 u32b im_f[], u32b vul_f)
2958 if ((vul_f & flag1) && !((im_f[0] | im_f[1] | im_f[2]) & flag1))
2962 c_put_str(TERM_WHITE, header, row, col);
2965 col += strlen(header) + 1;
2967 /* Check equipment */
2968 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2971 f[0] = f[1] = f[2] = 0L;
2974 o_ptr = &inventory[i];
2977 object_flags_known(o_ptr, &f[0], &f[1], &f[2]);
2980 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2983 if (f[n - 1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2984 if (f[n - 1] & flag2) c_put_str(TERM_WHITE, "*", row, col);
2991 player_flags(&f[0], &f[1], &f[2]);
2994 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2997 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
2999 /* Timed player flags */
3000 tim_player_flags(&f[0], &f[1], &f[2], TRUE);
3003 if (f[n-1] & flag1) c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3006 if (im_f[2] & flag1) c_put_str(TERM_YELLOW, "*", row, col);
3007 if (im_f[1] & flag1) c_put_str(TERM_WHITE, "*", row, col);
3010 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3015 * Special display, part 1
3017 static void display_player_flag_info(void)
3022 u32b im_f[3][3], vul_f[3];
3024 known_obj_immunity(&im_f[0][0], &im_f[1][0], &im_f[2][0]);
3025 player_immunity(&im_f[0][1], &im_f[1][1], &im_f[2][1]);
3026 tim_player_immunity(&im_f[0][2], &im_f[1][2], &im_f[2][2]);
3028 player_vuln_flags(&vul_f[0], &vul_f[1], &vul_f[2]);
3035 display_player_equippy(row-2, col+8);
3036 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3039 display_player_flag_aux(row+0, col, "ÂÑ»À :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3040 display_player_flag_aux(row+1, col, "ÂÑÅÅ·â:", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3041 display_player_flag_aux(row+2, col, "ÂѲбê:", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3042 display_player_flag_aux(row+3, col, "ÂÑÎ䵤:", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3043 display_player_flag_aux(row+4, col, "ÂÑÆÇ :", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3044 display_player_flag_aux(row+5, col, "ÂÑÁ®¸÷:", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3045 display_player_flag_aux(row+6, col, "ÂѰŹõ:", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3046 display_player_flag_aux(row+7, col, "ÂÑÇËÊÒ:", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3047 display_player_flag_aux(row+8, col, "ÂÑÌÕÌÜ:", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3048 display_player_flag_aux(row+9, col, "ÂѺ®Íð:", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3050 display_player_flag_aux(row+0, col, "Acid :", 2, TR2_RES_ACID, TR2_IM_ACID, im_f[1], vul_f[1]);
3051 display_player_flag_aux(row+1, col, "Elec :", 2, TR2_RES_ELEC, TR2_IM_ELEC, im_f[1], vul_f[1]);
3052 display_player_flag_aux(row+2, col, "Fire :", 2, TR2_RES_FIRE, TR2_IM_FIRE, im_f[1], vul_f[1]);
3053 display_player_flag_aux(row+3, col, "Cold :", 2, TR2_RES_COLD, TR2_IM_COLD, im_f[1], vul_f[1]);
3054 display_player_flag_aux(row+4, col, "Poison:", 2, TR2_RES_POIS, 0, im_f[1], vul_f[1]);
3055 display_player_flag_aux(row+5, col, "Light :", 2, TR2_RES_LITE, 0, im_f[1], vul_f[1]);
3056 display_player_flag_aux(row+6, col, "Dark :", 2, TR2_RES_DARK, 0, im_f[1], vul_f[1]);
3057 display_player_flag_aux(row+7, col, "Shard :", 2, TR2_RES_SHARDS, 0, im_f[1], vul_f[1]);
3058 display_player_flag_aux(row+8, col, "Blind :", 2, TR2_RES_BLIND, 0, im_f[1], vul_f[1]);
3059 display_player_flag_aux(row+9, col, "Conf :", 2, TR2_RES_CONF, 0, im_f[1], vul_f[1]);
3068 display_player_equippy(row-2, col+8);
3070 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3073 display_player_flag_aux(row+0, col, "Âѹ첻:", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3074 display_player_flag_aux(row+1, col, "ÂÑÃϹö:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3075 display_player_flag_aux(row+2, col, "ÂÑ°øº®:", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3076 display_player_flag_aux(row+3, col, "ÂÑ¥«¥ª:", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3077 display_player_flag_aux(row+4, col, "ÂÑÎô²½:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3078 display_player_flag_aux(row+5, col, "ÂѶ²ÉÝ:", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3079 display_player_flag_aux(row+6, col, "È¿¼Í :", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3080 display_player_flag_aux(row+7, col, "²Ð±ê¥ª:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3081 display_player_flag_aux(row+8, col, "Åŵ¤¥ª:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3082 display_player_flag_aux(row+9, col, "Î䵤¥ª:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3084 display_player_flag_aux(row+0, col, "Sound :", 2, TR2_RES_SOUND, 0, im_f[1], vul_f[1]);
3085 display_player_flag_aux(row+1, col, "Nether:", 2, TR2_RES_NETHER, 0, im_f[1], vul_f[1]);
3086 display_player_flag_aux(row+2, col, "Nexus :", 2, TR2_RES_NEXUS, 0, im_f[1], vul_f[1]);
3087 display_player_flag_aux(row+3, col, "Chaos :", 2, TR2_RES_CHAOS, 0, im_f[1], vul_f[1]);
3088 display_player_flag_aux(row+4, col, "Disnch:", 2, TR2_RES_DISEN, 0, im_f[1], vul_f[1]);
3089 display_player_flag_aux(row+5, col, "Fear :", 2, TR2_RES_FEAR, 0, im_f[1], vul_f[1]);
3090 display_player_flag_aux(row+6, col, "Reflct:", 2, TR2_REFLECT, 0, im_f[1], vul_f[1]);
3091 display_player_flag_aux(row+7, col, "AuFire:", 3, TR3_SH_FIRE, 0, im_f[2], vul_f[2]);
3092 display_player_flag_aux(row+8, col, "AuElec:", 3, TR3_SH_ELEC, 0, im_f[2], vul_f[2]);
3093 display_player_flag_aux(row+9, col, "AuCold:", 3, TR3_SH_COLD, 0, im_f[2], vul_f[2]);
3102 display_player_equippy(row-2, col+12);
3104 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3107 display_player_flag_aux(row+0, col, "²Ã® :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3108 display_player_flag_aux(row+1, col, "ÂÑËãáã :", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3109 display_player_flag_aux(row+2, col, "Æ©ÌÀÂλëǧ:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3110 display_player_flag_aux(row+3, col, "·Ð¸³ÃÍÊÝ»ý:", 2, TR2_HOLD_LIFE, 0, im_f[2], vul_f[1]);
3111 display_player_flag_aux(row+4, col, "¥Æ¥ì¥Ñ¥·¡¼:", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3112 display_player_flag_aux(row+5, col, "Ãپò½ :", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3113 display_player_flag_aux(row+6, col, "µÞ²óÉü :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3114 display_player_flag_aux(row+7, col, "ÉâÍ· :", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3115 display_player_flag_aux(row+8, col, "±Ê±ó¸÷¸» :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3116 display_player_flag_aux(row+9, col, "¼ö¤¤ :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3118 display_player_flag_aux(row+0, col, "Speed :", 1, TR1_SPEED, 0, im_f[0], vul_f[0]);
3119 display_player_flag_aux(row+1, col, "FreeAction:", 2, TR2_FREE_ACT, 0, im_f[1], vul_f[1]);
3120 display_player_flag_aux(row+2, col, "SeeInvisi.:", 3, TR3_SEE_INVIS, 0, im_f[2], vul_f[2]);
3121 display_player_flag_aux(row+3, col, "Hold Life :", 2, TR2_HOLD_LIFE, 0, im_f[1], vul_f[1]);
3122 display_player_flag_aux(row+4, col, "Telepathy :", 3, TR3_TELEPATHY, 0, im_f[2], vul_f[2]);
3123 display_player_flag_aux(row+5, col, "SlowDigest:", 3, TR3_SLOW_DIGEST, 0, im_f[2], vul_f[2]);
3124 display_player_flag_aux(row+6, col, "Regene. :", 3, TR3_REGEN, 0, im_f[2], vul_f[2]);
3125 display_player_flag_aux(row+7, col, "Levitation:", 3, TR3_FEATHER, 0, im_f[2], vul_f[2]);
3126 display_player_flag_aux(row+8, col, "Perm Lite :", 3, TR3_LITE, 0, im_f[2], vul_f[2]);
3127 display_player_flag_aux(row+9, col, "Cursed :", 3, (TR3_CURSED | TR3_HEAVY_CURSE), TR3_PERMA_CURSE, im_f[2], vul_f[2]);
3134 * Special display, part 2a
3136 static void display_player_misc_info(void)
3141 /* Display basics */
3143 put_str("̾Á° :", 1, 26);
3144 put_str("ÀÊÌ :", 3, 1);
3145 put_str("¼ï² :", 4, 1);
3146 put_str("¿¦¶È :", 5, 1);
3148 put_str("Name :", 1, 26);
3149 put_str("Sex :", 3, 1);
3150 put_str("Race :", 4, 1);
3151 put_str("Class :", 5, 1);
3154 strcpy(tmp,ap_ptr->title);
3161 strcat(tmp,player_name);
3163 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3164 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3165 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3166 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3168 /* Display extras */
3170 put_str("¥ì¥Ù¥ë:", 6, 1);
3171 put_str("£È£Ð :", 7, 1);
3172 put_str("£Í£Ð :", 8, 1);
3174 put_str("Level :", 6, 1);
3175 put_str("Hits :", 7, 1);
3176 put_str("Mana :", 8, 1);
3180 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3181 c_put_str(TERM_L_BLUE, buf, 6, 9);
3182 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3183 c_put_str(TERM_L_BLUE, buf, 7, 9);
3184 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3185 c_put_str(TERM_L_BLUE, buf, 8, 9);
3190 * Special display, part 2b
3192 * How to print out the modifications and sustains.
3193 * Positive mods with no sustain will be light green.
3194 * Positive mods with a sustain will be dark green.
3195 * Sustains (with no modification) will be a dark green 's'.
3196 * Negative mods (from a curse) will be red.
3197 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3198 * No mod, no sustain, will be a slate '.'
3200 static void display_player_stat_info(void)
3222 /* Print out the labels for the columns */
3224 c_put_str(TERM_WHITE, "ǽÎÏ", row, stat_col+1);
3225 c_put_str(TERM_BLUE, " ´ðËÜ", row, stat_col+7);
3226 c_put_str(TERM_L_BLUE, " ¼ï ¿¦ À Áõ ", row, stat_col+13);
3227 c_put_str(TERM_L_GREEN, "¹ç·×", row, stat_col+28);
3228 c_put_str(TERM_YELLOW, "¸½ºß", row, stat_col+33);
3230 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3231 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3232 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3233 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3234 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3238 /* Display the stats */
3239 for (i = 0; i < 6; i++)
3243 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3244 else r_adj = rp_ptr->r_adj[i];
3246 /* Calculate equipment adjustment */
3249 /* Icky formula to deal with the 18 barrier */
3250 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3251 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3252 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3253 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3254 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3255 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3257 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3258 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3260 if (prace_is_(RACE_ENT))
3266 if (p_ptr->lev > 25) r_adj++;
3267 if (p_ptr->lev > 40) r_adj++;
3268 if (p_ptr->lev > 45) r_adj++;
3271 if (p_ptr->lev > 25) r_adj--;
3272 if (p_ptr->lev > 40) r_adj--;
3273 if (p_ptr->lev > 45) r_adj--;
3279 e_adj -= cp_ptr->c_adj[i];
3280 e_adj -= ap_ptr->a_adj[i];
3282 /* Reduced name of stat */
3284 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3286 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3290 /* Internal "natural" max value. Maxes at 18/100 */
3291 /* This is useful to see if you are maxed out */
3292 cnv_stat(p_ptr->stat_max[i], buf);
3293 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3295 c_put_str(TERM_WHITE, "!", row + i+1, stat_col + 6);
3297 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3299 /* Race, class, and equipment modifiers */
3300 (void)sprintf(buf, "%3d", r_adj);
3301 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3302 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3303 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3304 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3305 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3306 (void)sprintf(buf, "%3d", (int)e_adj);
3307 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3309 /* Actual maximal modified value */
3310 cnv_stat(p_ptr->stat_top[i], buf);
3311 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3313 /* Only display stat_use if not maximal */
3314 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3316 cnv_stat(p_ptr->stat_use[i], buf);
3317 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3322 col = stat_col + 41;
3324 /* Header and Footer */
3325 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3327 c_put_str(TERM_L_GREEN, "ǽÎϽ¤Àµ", row - 1, col);
3329 c_put_str(TERM_L_GREEN, "Modification", row - 1, col);
3333 /* Process equipment */
3334 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3337 o_ptr = &inventory[i];
3340 k_idx = o_ptr->k_idx;
3342 /* Acquire "known" flags */
3343 object_flags_known(o_ptr, &f1, &f2, &f3);
3345 /* Initialize color based of sign of pval. */
3346 for (stat = 0; stat < 6; stat++)
3359 if (o_ptr->pval > 0)
3365 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3370 /* Dark green for sustained stats */
3375 if (o_ptr->pval < 0)
3381 if (o_ptr->pval < 10) c = '0' - o_ptr->pval;
3386 else if (f2 & 1 << stat)
3388 /* Dark green "s" */
3393 /* Dump proper character */
3394 Term_putch(col, row + stat+1, a, c);
3402 player_flags(&f1, &f2, &f3);
3405 for (stat = 0; stat < 6; stat++)
3412 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3418 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3419 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3420 if (p_ptr->tsuyoshi) dummy += 4;
3422 else if (stat == A_WIS || stat == A_INT)
3424 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3425 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3427 else if (stat == A_DEX)
3429 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3430 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3431 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3433 else if (stat == A_CON)
3435 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3436 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3437 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3438 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3439 if (p_ptr->tsuyoshi) dummy += 4;
3441 else if (stat == A_CHR)
3443 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3444 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3445 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3446 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3447 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3448 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3464 if (dummy < 10) c = '0' + dummy;
3474 if (dummy < 10) c = '0' - dummy;
3483 /* Dark green "s" */
3490 Term_putch(col, row + stat+1, a, c);
3498 static cptr object_flag_names[96] =
3739 * Summarize resistances
3741 static void display_player_ben(void)
3754 for (i = 0; i < 6; i++) b[i] = 0;
3757 /* Scan equipment */
3758 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3761 o_ptr = &inventory[i];
3763 /* Known object flags */
3764 object_flags_known(o_ptr, &f1, &f2, &f3);
3767 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3769 f3 &= ~(TR3_AGGRAVATE);
3774 b[0] |= (f1 & 0xFFFF);
3776 b[2] |= (f2 & 0xFFFF);
3778 b[4] |= (f3 & 0xFFFF);
3784 player_flags(&f1, &f2, &f3);
3787 b[0] |= (f1 & 0xFFFF);
3789 b[2] |= (f2 & 0xFFFF);
3791 b[4] |= (f3 & 0xFFFF);
3795 tim_player_flags(&f1, &f2, &f3, FALSE);
3798 b[0] |= (f1 & 0xFFFF);
3800 b[2] |= (f2 & 0xFFFF);
3802 b[4] |= (f3 & 0xFFFF);
3804 color[0] = (u16b)(f1 & 0xFFFF);
3805 color[1] = (u16b)(f1 >> 16);
3806 color[2] = (u16b)(f2 & 0xFFFF);
3807 color[3] = (u16b)(f2 >> 16);
3808 color[4] = (u16b)(f3 & 0xFFFF);
3809 color[5] = (u16b)(f3 >> 16);
3812 for (x = 0; x < 6; x++)
3815 for (y = 0; y < 16; y++)
3817 byte a = TERM_SLATE;
3820 cptr name = object_flag_names[16*x+y];
3823 if (!name) continue;
3826 Term_putstr(x * 13, y + 4, -1, TERM_WHITE, name);
3829 Term_putch(x * 13 + 10, y + 4, TERM_WHITE, ':');
3834 if (color[x] & (1<<y))
3847 Term_putch(x * 13 + 11, y + 4, a, c);
3854 * Summarize resistances
3856 static void display_player_ben_one(int mode)
3868 /* Scan equipment */
3869 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3872 n = (i - INVEN_RARM);
3875 o_ptr = &inventory[i];
3877 object_flags_known(o_ptr, &f1, &f2, &f3);
3879 if ((prace_is_(RACE_S_FAIRY)) && (f3 & TR3_AGGRAVATE))
3881 f3 &= ~(TR3_AGGRAVATE);
3886 b[n][0] = (u16b)(f1 & 0xFFFF);
3887 b[n][1] = (u16b)(f1 >> 16);
3888 b[n][2] = (u16b)(f2 & 0xFFFF);
3889 b[n][3] = (u16b)(f2 >> 16);
3890 b[n][4] = (u16b)(f3 & 0xFFFF);
3891 b[n][5] = (u16b)(f3 >> 16);
3899 player_flags(&f1, &f2, &f3);
3902 b[n][0] = (u16b)(f1 & 0xFFFF);
3903 b[n][1] = (u16b)(f1 >> 16);
3904 b[n][2] = (u16b)(f2 & 0xFFFF);
3905 b[n][3] = (u16b)(f2 >> 16);
3906 b[n][4] = (u16b)(f3 & 0xFFFF);
3907 b[n][5] = (u16b)(f3 >> 16);
3910 tim_player_flags(&f1, &f2, &f3, FALSE);
3913 b[n][0] |= (f1 & 0xFFFF);
3914 b[n][1] |= (f1 >> 16);
3915 b[n][2] |= (f2 & 0xFFFF);
3916 b[n][3] |= (f2 >> 16);
3917 b[n][4] |= (f3 & 0xFFFF);
3918 b[n][5] |= (f3 >> 16);
3919 color[0] = (u16b)(f1 & 0xFFFF);
3920 color[1] = (u16b)(f1 >> 16);
3921 color[2] = (u16b)(f2 & 0xFFFF);
3922 color[3] = (u16b)(f2 >> 16);
3923 color[4] = (u16b)(f3 & 0xFFFF);
3924 color[5] = (u16b)(f3 >> 16);
3928 for (x = 0; x < 3; x++)
3931 display_player_equippy(2, x * 26 + 11);
3934 Term_putstr(x * 26 + 11, 3, -1, TERM_WHITE, "abcdefghijkl@");
3937 for (y = 0; y < 16; y++)
3939 cptr name = object_flag_names[48*mode+16*x+y];
3942 if (!name) continue;
3945 Term_putstr(x * 26, y + 4, -1, TERM_WHITE, name);
3948 Term_putch(x * 26 + 10, y + 4, TERM_WHITE, ':');
3951 for (n = 0; n < 13; n++)
3953 byte a = TERM_SLATE;
3957 if (b[n][3*mode+x] & (1<<y))
3959 if ((n == 12) && (color[3*mode+x] & (1<<y)))
3972 Term_putch(x * 26 + 11 + n, y + 4, a, c);
3980 * Display the character on the screen (various modes)
3982 * The top two and bottom two lines are left blank.
3984 * Mode 0 = standard display with skills
3985 * Mode 1 = standard display with history
3986 * Mode 2 = summary of various things
3987 * Mode 3 = current flags (combined)
3988 * Mode 4 = current flags (part 1)
3989 * Mode 5 = current flags (part 2)
3990 * Mode 6 = mutations
3992 void display_player(int mode)
4001 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && skip_mutations)
4010 if ((mode == 0) || (mode == 1))
4012 /* Name, Sex, Race, Class */
4014 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "¤Î":"", player_name);
4016 sprintf(tmp, "%s %s", ap_ptr->title, player_name);
4019 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
4020 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
4021 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
4022 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
4027 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
4029 strcpy(tmp, realm_names[p_ptr->realm1]);
4030 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
4033 if (p_ptr->pclass == CLASS_CHAOS_WARRIOR)
4034 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
4036 /* Age, Height, Weight, Social */
4037 /* ¿ÈĹ¤Ï¥»¥ó¥Á¥á¡¼¥È¥ë¤Ë¡¢ÂνŤϥ¥í¥°¥é¥à¤ËÊѹ¹¤·¤Æ¤¢¤ê¤Þ¤¹ */
4039 display_player_one_line(ENTRY_AGE, format("%dºÍ" ,(int)p_ptr->age), TERM_L_BLUE);
4040 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
4041 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
4042 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
4044 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
4045 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
4046 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
4047 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
4049 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
4052 /* Display the stats */
4053 for (i = 0; i < 6; i++)
4055 /* Special treatment of "injured" stats */
4056 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
4060 /* Use lowercase stat name */
4061 put_str(stat_names_reduced[i], 3 + i, 54);
4063 /* Get the current stat */
4064 value = p_ptr->stat_use[i];
4066 /* Obtain the current stat (modified) */
4067 cnv_stat(value, buf);
4069 /* Display the current stat (modified) */
4070 c_put_str(TERM_YELLOW, buf, 3 + i, 61);
4072 /* Acquire the max stat */
4073 value = p_ptr->stat_top[i];
4075 /* Obtain the maximum stat (modified) */
4076 cnv_stat(value, buf);
4078 /* Display the maximum stat (modified) */
4079 c_put_str(TERM_L_GREEN, buf, 3 + i, 68);
4082 /* Normal treatment of "normal" stats */
4085 /* Assume uppercase stat name */
4086 put_str(stat_names[i], 3 + i, 54);
4088 /* Obtain the current stat (modified) */
4089 cnv_stat(p_ptr->stat_use[i], buf);
4091 /* Display the current stat (modified) */
4092 c_put_str(TERM_L_GREEN, buf, 3 + i, 61);
4095 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
4097 c_put_str(TERM_WHITE, "!", 2+i, 64);
4101 /* Display "history" info */
4105 put_str("(¥¥ã¥é¥¯¥¿¡¼¤ÎÀ¸¤¤Î©¤Á)", 11, 25);
4107 put_str("(Character Background)", 11, 25);
4110 for (i = 0; i < 4; i++)
4112 put_str(history[i], i + 12, 10);
4120 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Î %d ³¬¤Ç»à¤ó¤À¡£", map_name(), dun_level), 5 + 12, 10);
4122 put_str(format("...You were dead at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4126 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï %s ¤Ç»à¤ó¤À¡£", map_name()), 5 + 12, 10);
4128 put_str(format("...You were dead at %s.", map_name()), 5 + 12, 10);
4135 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Î %d ³¬¤Çõº÷¤·¤Æ¤¤¤ë¡£", map_name(), dun_level), 5 + 12, 10);
4137 put_str(format("...Now, you are exploring at level %d of %s.", dun_level, map_name()), 5 + 12, 10);
4141 put_str(format("¡Ä¤¢¤Ê¤¿¤Ï¸½ºß¡¢ %s ¤Ë¤¤¤ë¡£", map_name()), 5 + 12, 10);
4143 put_str(format("...Now, you are in %s.", map_name()), 5 + 12, 10);
4148 /* Display "various" info */
4151 display_player_middle();
4152 display_player_various();
4159 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4162 display_player_misc_info();
4163 display_player_stat_info();
4164 display_player_flag_info();
4170 display_player_ben();
4175 do_cmd_knowledge_mutations();
4181 display_player_ben_one(mode % 2);
4185 errr make_character_dump(FILE *fff)
4192 char o_name[MAX_NLEN];
4196 #ifndef FAKE_VERSION
4198 fprintf(fff, " [Angband %d.%d.%d Character Dump]\n\n",
4199 VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
4202 fprintf(fff, " [ÊѶòÈÚÅÜ %d.%d.%d ¥¥ã¥é¥¯¥¿¾ðÊó]\n\n",
4203 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4205 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4206 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4213 /* Display player */
4216 /* Dump part of the screen */
4217 for (y = 1; y < 22; y++)
4220 for (x = 0; x < 79; x++)
4222 /* Get the attr/char */
4223 (void)(Term_what(x, y, &a, &c));
4229 /* End the string */
4232 /* Kill trailing spaces */
4233 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4237 fprintf(fff, "%s\n", buf);
4239 fprintf(fff, "%s\n", buf);
4244 /* Display history */
4247 /* Dump part of the screen */
4248 for (y = 11; y < 18; y++)
4251 for (x = 0; x < 79; x++)
4253 /* Get the attr/char */
4254 (void)(Term_what(x, y, &a, &c));
4260 /* End the string */
4263 /* Kill trailing spaces */
4264 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4267 fprintf(fff, "%s\n", buf);
4271 /* Display history */
4274 /* Dump part of the screen */
4275 for (y = 2; y < 22; y++)
4278 for (x = 0; x < 79; x++)
4280 /* Get the attr/char */
4281 (void)(Term_what(x, y, &a, &c));
4283 /* Dump it (Ignore equippy tile graphic) */
4290 /* End the string */
4293 /* Kill trailing spaces */
4294 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4297 fprintf(fff, "%s\n", buf);
4300 for (i = 0; i < p_ptr->count / 80; i++)
4303 for (i = 0; i < p_ptr->count % 80; i++)
4308 for (i = m_max - 1; i >= 1; i--)
4310 monster_type *m_ptr = &m_list[i];
4313 if (!m_ptr->r_idx) continue;
4314 if (!is_pet(m_ptr)) continue;
4315 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4319 fprintf(fff, "\n [¼ç¤Ê¥Ú¥Ã¥È]\n\n");
4321 fprintf(fff, "\n [leading pets]\n\n");
4325 monster_desc(pet_name, m_ptr, 0x88);
4326 fprintf(fff, "%s", pet_name);
4327 if (p_ptr->riding == i)
4329 fprintf(fff, " ¾èÇÏÃæ");
4331 fprintf(fff, " riding");
4335 if (pet) fprintf(fff, "\n");
4338 if (death && !total_winner)
4341 fprintf(fff, "\n [»à¤ÌľÁ°¤Î¥á¥Ã¥»¡¼¥¸]\n\n");
4343 fprintf(fff, "\n [Last messages]\n\n");
4345 for (i = MIN(message_num(), 15); i >= 0; i--)
4347 fprintf(fff,"> %s\n",message_str((s16b)i));
4353 fprintf(fff, "\n [¤½¤Î¾¤Î¾ðÊó] \n");
4355 fprintf(fff, "\n [Miscellaneous information]\n");
4359 fprintf(fff, "\n µ¢´Ô¾ì½ê:\n");
4361 fprintf(fff, "\n Recall Depth:\n");
4363 for (y = 1; y < max_d_idx; y++)
4367 if (!d_info[y].maxdepth) continue;
4368 if (!max_dlv[y]) continue;
4369 if (d_info[y].final_guardian)
4371 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4373 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4376 fprintf(fff, " %c%-12s: %3d ³¬\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4378 fprintf(fff, " %c%-16s: level %3d\n", seiha ? '!' : ' ', d_name+d_info[y].name, max_dlv[y]);
4384 fprintf(fff, "\n Êݸ¥â¡¼¥É: ON");
4386 fprintf(fff, "\n Preserve Mode: ON");
4391 fprintf(fff, "\n Êݸ¥â¡¼¥É: OFF");
4393 fprintf(fff, "\n Preserve Mode: OFF");
4397 if (ironman_autoscum)
4399 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ALWAYS");
4401 fprintf(fff, "\n Autoscum: ALWAYS");
4406 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : ON");
4408 fprintf(fff, "\n Autoscum: ON");
4413 fprintf(fff, "\n ¼«Æ°Áª¤ê¹¥¤ß : OFF");
4415 fprintf(fff, "\n Autoscum: OFF");
4419 if (ironman_small_levels)
4421 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ALWAYS");
4423 fprintf(fff, "\n Small Levels: ALWAYS");
4426 else if (always_small_levels)
4428 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ON");
4430 fprintf(fff, "\n Small Levels: ON");
4433 else if (small_levels)
4435 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: ENABLED");
4437 fprintf(fff, "\n Small Levels: ENABLED");
4442 fprintf(fff, "\n ¾®¤µ¤¤¥À¥ó¥¸¥ç¥ó: OFF");
4444 fprintf(fff, "\n Small Levels: OFF");
4450 fprintf(fff, "\n ¸µÁĤÎÄ®¤Î¤ß: ON");
4452 fprintf(fff, "\n Vanilla Town: ON");
4457 fprintf(fff, "\n ¾®µ¬ÌϤÊÄ®: ON");
4459 fprintf(fff, "\n Lite Town: ON");
4465 fprintf(fff, "\n Ź¤Ê¤·: ON");
4467 fprintf(fff, "\n No Shops: ON");
4471 if (ironman_downward)
4473 fprintf(fff, "\n ³¬Ãʤò¾å¤¬¤ì¤Ê¤¤: ON");
4475 fprintf(fff, "\n Diving only: ON");
4481 fprintf(fff, "\n ÉáÄ̤Ǥʤ¤Éô²°¤òÀ¸À®: ON");
4483 fprintf(fff, "\n Unusual rooms: ON");
4487 if (ironman_nightmare)
4489 fprintf(fff, "\n °Ì´¥â¡¼¥É: ON");
4491 fprintf(fff, "\n Nightmare Mode: ON");
4495 if (ironman_empty_levels)
4497 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ALWAYS");
4499 fprintf(fff, "\n Arena Levels: ALWAYS");
4502 else if (empty_levels)
4504 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: ON");
4506 fprintf(fff, "\n Arena Levels: ENABLED");
4511 fprintf(fff, "\n ¥¢¥ê¡¼¥Ê: OFF");
4513 fprintf(fff, "\n Arena Levels: OFF");
4518 fprintf(fff, "\n ¥é¥ó¥À¥à¥¯¥¨¥¹¥È¿ô: %d", number_of_quests());
4520 fprintf(fff, "\n Num. Random Quests: %d", number_of_quests());
4523 if (p_ptr->arena_number == 99)
4526 fprintf(fff, "\n Æ®µ»¾ì: ÇÔËÌ\n");
4528 fprintf(fff, "\n Arena: defeated\n");
4531 else if (p_ptr->arena_number > MAX_ARENA_MONS+2)
4534 fprintf(fff, "\n Æ®µ»¾ì: ¿¿¤Î¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4536 fprintf(fff, "\n Arena: True Champion\n");
4539 else if (p_ptr->arena_number > MAX_ARENA_MONS-1)
4542 fprintf(fff, "\n Æ®µ»¾ì: ¥Á¥ã¥ó¥Ô¥ª¥ó\n");
4544 fprintf(fff, "\n Arena: Champion\n");
4550 fprintf(fff, "\n Æ®µ»¾ì: %2d¾¡\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4552 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");
4558 fprintf(fff, "\n ²¿¤«ÉÔÀµ¤Ê¤³¤È¤ò¤·¤Æ¤·¤Þ¤Ã¤Æ¤Þ¤¹¡£");
4560 fprintf(fff, "\n You have done something illegal.");
4564 if (stupid_monsters)
4566 fprintf(fff, "\n Ũ¤Ï¶ò¤«¤Ê¹ÔÆ°¤ò¼è¤ê¤Þ¤¹¡£");
4568 fprintf(fff, "\n Your opponents are behaving stupidly.");
4574 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï»à¤ò²óÈò¤¹¤ë¥¤¥ó¥Á¥¤ÊÎϤò»ý¤Ã¤Æ¤¤¤Þ¤¹¡£");
4576 fprintf(fff, "\n You possess munchkinish power over death.");
4581 /* Monsters slain */
4586 for (k = 1; k < max_r_idx; k++)
4588 monster_race *r_ptr = &r_info[k];
4590 if (r_ptr->flags1 & RF1_UNIQUE)
4592 bool dead = (r_ptr->max_num == 0);
4600 s16b This = r_ptr->r_pkills;
4610 fprintf(fff,"\n ¤Þ¤ÀŨ¤òÅݤ·¤Æ¤¤¤Þ¤»¤ó¡£\n");
4612 fprintf(fff,"\n You have defeated no enemies yet.\n");
4615 else if (Total == 1)
4617 fprintf(fff,"\n °ìÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n");
4619 fprintf(fff,"\n You have defeated one enemy.\n");
4624 fprintf(fff,"\n %lu ÂΤÎŨ¤òÅݤ·¤Æ¤¤¤Þ¤¹¡£\n", Total);
4626 fprintf(fff,"\n You have defeated %lu enemies.\n", Total);
4632 if (p_ptr->old_race1 || p_ptr->old_race2)
4635 fprintf(fff, "\n\n ¤¢¤Ê¤¿¤Ï%s¤È¤·¤ÆÀ¸¤Þ¤ì¤¿¡£", race_info[p_ptr->start_race].title);
4637 fprintf(fff, "\n\n You were born as %s.", race_info[p_ptr->start_race].title);
4639 for (i = 0; i < MAX_RACES; i++)
4641 if (p_ptr->start_race == i) continue;
4644 if (!(p_ptr->old_race1 & 1L << i)) continue;
4648 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4651 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%s¤À¤Ã¤¿¡£", race_info[i].title);
4653 fprintf(fff, "\n You were a %s before.", race_info[i].title);
4658 if (p_ptr->old_realm)
4660 for (i = 0; i < MAX_MAGIC; i++)
4662 if (!(p_ptr->old_realm & 1L << i)) continue;
4664 fprintf(fff, "\n ¤¢¤Ê¤¿¤Ï¤«¤Ä¤Æ%sËâË¡¤ò»È¤¨¤¿¡£", realm_names[i+1]);
4666 fprintf(fff, "\n You were able to use %s magic before.", realm_names[i+1]);
4672 fprintf(fff, "\n\n [¥×¥ì¥¤¥ä¡¼¤ÎÆÁ]\n\n");
4674 fprintf(fff, "\n\n [Virtues]\n\n");
4678 fprintf(fff, "°À : %s\n", your_alignment());
4680 fprintf(fff, "Your alighnment : %s\n", your_alignment());
4685 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4688 fprintf(fff, "\n\n [ÆÍÁ³ÊÑ°Û]\n\n");
4690 fprintf(fff, "\n\n [Mutations]\n\n");
4693 dump_mutations(fff);
4697 /* Skip some lines */
4698 fprintf(fff, "\n\n");
4701 /* Dump the equipment */
4705 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤ÎÁõÈ÷ ]\n\n");
4707 fprintf(fff, " [Character Equipment]\n\n");
4710 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4712 object_desc(o_name, &inventory[i], TRUE, 3);
4713 if ((i == INVEN_LARM) && p_ptr->ryoute)
4715 strcpy(o_name, "(Éð´ï¤òξ¼ê»ý¤Á)");
4717 strcpy(o_name, "(wielding with two-hands)");
4719 fprintf(fff, "%c%s %s\n",
4720 index_to_label(i), paren, o_name);
4722 fprintf(fff, "\n\n");
4725 /* Dump the inventory */
4727 fprintf(fff, " [ ¥¥ã¥é¥¯¥¿¤Î»ý¤Áʪ ]\n\n");
4729 fprintf(fff, " [Character Inventory]\n\n");
4732 for (i = 0; i < INVEN_PACK; i++)
4734 /* Don't dump the empty slots */
4735 if (!inventory[i].k_idx) break;
4737 /* Dump the inventory slots */
4738 object_desc(o_name, &inventory[i], TRUE, 3);
4739 fprintf(fff, "%c%s %s\n", index_to_label(i), paren, o_name);
4742 /* Add an empty line */
4743 fprintf(fff, "\n\n");
4745 process_dungeon_file("w_info_j.txt", 0, 0, max_wild_y, max_wild_x);
4747 /* Print all homes in the different towns */
4748 st_ptr = &town[1].store[STORE_HOME];
4750 /* Home -- if anything there */
4751 if (st_ptr->stock_num)
4753 /* Header with name of the town */
4755 fprintf(fff, " [ ²æ¤¬²È¤Î¥¢¥¤¥Æ¥à ]\n");
4757 fprintf(fff, " [Home Inventory]\n");
4761 /* Dump all available items */
4762 for (i = 0; i < st_ptr->stock_num; i++)
4766 fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4768 fprintf(fff, "\n ( page %d )\n", x++);
4770 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4771 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4774 /* Add an empty line */
4775 fprintf(fff, "\n\n");
4779 /* Print all homes in the different towns */
4780 st_ptr = &town[1].store[STORE_MUSEUM];
4782 /* Home -- if anything there */
4783 if (st_ptr->stock_num)
4785 /* Header with name of the town */
4787 fprintf(fff, " [ Çîʪ´Û¤Î¥¢¥¤¥Æ¥à ]\n");
4789 fprintf(fff, " [Museum]\n");
4793 /* Dump all available items */
4794 for (i = 0; i < st_ptr->stock_num; i++)
4797 if ((i % 12) == 0) fprintf(fff, "\n ( %d ¥Ú¡¼¥¸ )\n", x++);
4798 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4799 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4801 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4802 object_desc(o_name, &st_ptr->stock[i], TRUE, 3);
4803 fprintf(fff, "%c%s %s\n", I2A(i%12), paren, o_name);
4808 /* Add an empty line */
4809 fprintf(fff, "\n\n");
4816 * Hack -- Dump a character description file
4818 * XXX XXX XXX Allow the "full" flag to dump additional info,
4819 * and trigger its usage from various places in the code.
4821 errr file_character(cptr name, bool full)
4830 /* Build the filename */
4831 path_build(buf, 1024, ANGBAND_DIR_USER, name);
4833 /* File type is "TEXT" */
4834 FILE_TYPE(FILE_TYPE_TEXT);
4836 /* Check for existing file */
4837 fd = fd_open(buf, O_RDONLY);
4844 /* Close the file */
4849 (void)sprintf(out_val, "¸½Â¸¤¹¤ë¥Õ¥¡¥¤¥ë %s ¤Ë¾å½ñ¤¤·¤Þ¤¹¤«? ", buf);
4851 (void)sprintf(out_val, "Replace existing file %s? ", buf);
4856 if (get_check(out_val)) fd = -1;
4859 /* Open the non-existing file */
4860 if (fd < 0) fff = my_fopen(buf, "w");
4871 msg_format("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤Ë¼ºÇÔ¤·¤Þ¤·¤¿¡ª");
4873 msg_format("Character dump failed!");
4882 (void)make_character_dump(fff);
4890 msg_print("¥¥ã¥é¥¯¥¿¾ðÊó¤Î¥Õ¥¡¥¤¥ë¤Ø¤Î½ñ¤½Ð¤·¤ËÀ®¸ù¤·¤Þ¤·¤¿¡£");
4892 msg_print("Character dump successful.");
4903 * Recursive file perusal.
4905 * Return FALSE on 'Q', otherwise TRUE.
4907 * Process various special text in the input file, including
4908 * the "menu" structures used by the "help file" system.
4910 * XXX XXX XXX Consider using a temporary file.
4912 * XXX XXX XXX Allow the user to "save" the current file.
4914 bool show_file(bool show_version, cptr name, cptr what, int line, int mode)
4918 /* Number of "real" lines passed by */
4921 /* Number of "real" lines in the file */
4924 /* Backup value for "line" */
4930 /* This screen has sub-screens */
4933 /* Current help file */
4936 /* Find this string (if any) */
4939 /* Jump to this tag */
4942 /* Hold a string to find */
4945 /* Hold a string to show */
4949 char filename[1024];
4951 /* Describe this thing */
4957 /* General buffer */
4960 /* Lower case version of the buffer, for searching */
4963 /* Aux pointer for making lc_buf (and find!) lowercase */
4966 /* Sub-menu information */
4969 /* Tags for in-file references */
4972 bool reverse = (line < 0);
4981 strcpy(caption, "");
4983 /* Wipe the hooks */
4984 for (i = 0; i < 68; i++)
4989 /* Copy the filename */
4990 strcpy(filename, name);
4992 n = strlen(filename);
4994 /* Extract the tag from the filename */
4995 for (i = 0; i < n; i++)
4997 if (filename[i] == '#')
5000 tag = filename + i + 1;
5005 /* Redirect the name */
5008 /* Hack XXX XXX XXX */
5012 strcpy(caption, what);
5014 /* Access the "file" */
5018 fff = my_fopen(path, "r");
5021 /* Look in "help" */
5026 sprintf(caption, "¥Ø¥ë¥×¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5028 sprintf(caption, "Help file '%s'", name);
5032 /* Build the filename */
5033 path_build(path, 1024, ANGBAND_DIR_HELP, name);
5036 fff = my_fopen(path, "r");
5039 /* Look in "info" */
5044 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5046 sprintf(caption, "Info file '%s'", name);
5050 /* Build the filename */
5051 path_build(path, 1024, ANGBAND_DIR_INFO, name);
5054 fff = my_fopen(path, "r");
5057 /* Look in "info" */
5060 /* Build the filename */
5061 path_build(path, 1024, ANGBAND_DIR, name);
5063 for (i = 0; path[i]; i++)
5064 if ('\\' == path[i])
5065 path[i] = PATH_SEP[0];
5069 sprintf(caption, "¥¹¥Ý¥¤¥é¡¼¡¦¥Õ¥¡¥¤¥ë'%s'", name);
5071 sprintf(caption, "Info file '%s'", name);
5075 fff = my_fopen(path, "r");
5083 msg_format("'%s'¤ò¥ª¡¼¥×¥ó¤Ç¤¤Þ¤»¤ó¡£", name);
5085 msg_format("Cannot open '%s'.", name);
5095 /* Pre-Parse the file */
5098 /* Read a line or stop */
5099 if (my_fgets(fff, buf, 1024)) break;
5101 /* XXX Parse "menu" items */
5102 if (prefix(buf, "***** "))
5104 /* Notice "menu" requests */
5105 if ((buf[6] == '[') && (isdigit(buf[7]) || isalpha(buf[7])))
5107 /* This is a menu file */
5110 /* Extract the menu item */
5111 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5113 if ((buf[8] == ']') && (buf[9] == ' '))
5115 /* Extract the menu item */
5116 strcpy(hook[k], buf + 10);
5119 /* Notice "tag" requests */
5120 else if ((buf[6] == '<') && (isdigit(buf[7]) || isalpha(buf[7])) &&
5123 /* Extract the menu item */
5124 k = isdigit(buf[7]) ? D2I(buf[7]) : buf[7] - 'A' + 10;
5126 /* Extract the menu item */
5134 /* Count the "real" lines */
5138 /* Save the number of "real" lines */
5141 if (line == -1) line = ((size-1)/20)*20;
5143 /* Go to the tagged line */
5145 line = tags[isdigit(tag[0]) ? D2I(tag[0]) : tag[0] - 'A' + 10];
5147 /* Display the file */
5153 /* Restart when necessary */
5154 if (line >= size) line = 0;
5157 /* Re-open the file if needed */
5163 /* Hack -- Re-Open the file */
5164 fff = my_fopen(path, "r");
5167 if (!fff) return (FALSE);
5169 /* File has been restarted */
5173 /* Goto the selected line */
5177 if (my_fgets(fff, buf, 1024)) break;
5179 /* Skip tags/links */
5180 if (prefix(buf, "***** ")) continue;
5182 /* Count the lines */
5186 /* Dump the next 20 lines of the file */
5187 for (i = 0; i < 20; )
5189 /* Hack -- track the "first" line */
5190 if (!i) line = next;
5192 /* Get a line of the file or stop */
5193 if (my_fgets(fff, buf, 1024)) break;
5195 /* Hack -- skip "special" lines */
5196 if (prefix(buf, "***** ")) continue;
5198 /* Count the "real" lines */
5201 /* Make a lower case version of buf for searching */
5202 strcpy(lc_buf, buf);
5204 for (lc_buf_ptr = lc_buf; *lc_buf_ptr != 0; lc_buf_ptr++)
5207 if (iskanji(*lc_buf_ptr))
5211 lc_buf[lc_buf_ptr-lc_buf] = tolower(*lc_buf_ptr);
5214 /* Hack -- keep searching */
5215 if (find && !i && !strstr(lc_buf, find)) continue;
5217 /* Hack -- stop searching */
5221 Term_putstr(0, i+2, -1, TERM_WHITE, buf);
5223 /* Hilite "shower" */
5228 /* Display matches */
5229 while ((str = strstr(str, shower)) != NULL)
5231 int len = strlen(shower);
5233 /* Display the match */
5234 Term_putstr(str-lc_buf, i+2, len, TERM_YELLOW, &buf[str-lc_buf]);
5241 /* Count the printed lines */
5245 /* Hack -- failed search */
5255 /* Show a general "title" */
5259 prt(format("[ÊѶòÈÚÅÜ %d.%d.%d, %s, %d/%d]",
5261 prt(format("[Hengband %d.%d.%d, %s, Line %d/%d]",
5264 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5265 caption, line, size), 0, 0);
5270 prt(format("[%s, %d/%d]",
5272 prt(format("[%s, Line %d/%d]",
5274 caption, line, size), 0, 0);
5277 /* Prompt -- menu screen */
5282 prt("[ ÈÖ¹æ¤òÆþÎϤ·¤Æ²¼¤µ¤¤( ESC¤Ç½ªÎ» ) ]", 23, 0);
5284 prt("[Press a Number, or ESC to exit.]", 23, 0);
5289 /* Prompt -- small files */
5290 else if (size <= 20)
5294 prt("[¥¡¼:(?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5296 prt("[Press ESC to exit.]", 23, 0);
5301 /* Prompt -- large files */
5306 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢¬ (-)¢ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5308 prt("[¥¡¼:(RET/¥¹¥Ú¡¼¥¹)¢ (-)¢¬ (?)¥Ø¥ë¥× (ESC)½ªÎ»]", 23, 0);
5310 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", 23, 0);
5314 /* Get a keypress */
5317 /* Hack -- return to last screen */
5318 if (k == '<') break;
5320 /* Show the help for the help */
5323 /* Hack - prevent silly recursion */
5325 if (strcmp(name, "jhelpinfo.txt") != 0)
5326 show_file(TRUE, "jhelpinfo.txt", NULL, 0, mode);
5328 if (strcmp(name, "helpinfo.txt") != 0)
5329 show_file(TRUE, "helpinfo.txt", NULL, 0, mode);
5333 /* Hack -- try showing */
5338 prt("¶¯Ä´: ", 23, 0);
5340 prt("Show: ", 23, 0);
5343 (void)askfor_aux(shower, 80);
5346 /* Hack -- try finding */
5351 prt("¸¡º÷: ", 23, 0);
5353 prt("Find: ", 23, 0);
5357 if (askfor_aux(finder, 80))
5364 /* Make finder lowercase */
5365 for (cnt = 0; finder[cnt] != 0; cnt++)
5368 if (iskanji(finder[cnt]))
5372 finder[cnt] = tolower(finder[cnt]);
5376 strcpy(shower, finder);
5380 /* Hack -- go to a specific line */
5387 prt("Goto Line: ", 23, 0);
5392 if (askfor_aux(tmp, 80))
5398 /* Hack -- go to a specific file */
5403 prt("¥Õ¥¡¥¤¥ë¡¦¥Í¡¼¥à: ", 23, 0);
5404 strcpy(tmp, "jhelp.hlp");
5406 prt("Goto File: ", 23, 0);
5407 strcpy(tmp, "help.hlp");
5411 if (askfor_aux(tmp, 80))
5413 if (!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5417 /* Hack -- Allow backing up */
5420 line = line + (reverse ? 20 : -20);
5421 if (line < 0) line = ((size-1)/20)*20;
5424 /* Hack -- Advance a single line */
5425 if ((k == '\n') || (k == '\r'))
5427 line = line + (reverse ? -1 : 1);
5428 if (line < 0) line = ((size-1)/20)*20;
5431 /* Advance one page */
5434 line = line + (reverse ? -20 : 20);
5435 if (line < 0) line = ((size-1)/20)*20;
5439 /* ÆüËܸìÈǤÇÄɲ䵤줿¥Ø¥ë¥×¤Îɽ¼¨ */
5440 /* ¤¢¤Þ¤ê¤è¤¤½èÍý¤Î»ÅÊý¤È¤Ï»×¤¨¤Ê¤¤¡¦¡¦¡¦¤¹¤Þ¤ó */
5442 /* ´Ê°×¥³¥Þ¥ó¥É°ìÍ÷ */
5443 if (menu && (k == 'c' || k == 'C'))
5446 switch (rogue_like_commands)
5450 strcpy(tmp, "j_com_r.txt");
5451 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5456 strcpy(tmp, "j_com_o.txt");
5457 if(!show_file(TRUE, tmp, NULL, 0, mode)) k = 'q';
5464 /* Recurse on numbers */
5469 if (isdigit(k)) key = D2I(k);
5470 else if (isalpha(k)) key = k - 'A' + 10;
5472 if ((key > -1) && hook[key][0])
5474 /* Recurse on that file */
5475 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5480 /* Hack, dump to file */
5490 if (get_string("¥Õ¥¡¥¤¥ë̾: ", xtmp, 80))
5492 if (get_string("File name: ", xtmp, 80))
5496 if (xtmp[0] && (xtmp[0] != ' '))
5505 /* Build the filename */
5506 path_build(buff, 1024, ANGBAND_DIR_USER, xtmp);
5511 /* Hack -- Re-Open the file */
5512 fff = my_fopen(path, "r");
5514 ffp = my_fopen(buff, "w");
5520 msg_print("¥Õ¥¡¥¤¥ë¤¬¸«¤Ä¤«¤ê¤Þ¤»¤ó¡£");
5522 msg_print("Failed to open file.");
5529 sprintf(xtmp, "%s: %s", player_name, what);
5530 my_fputs(ffp, xtmp, 80);
5531 my_fputs(ffp, "\n", 80);
5533 while (!my_fgets(fff, buff, 80))
5534 my_fputs(ffp, buff, 80);
5540 /* Hack -- Re-Open the file */
5541 fff = my_fopen(path, "r");
5544 /* Exit on escape */
5545 if (k == ESCAPE) break;
5546 if (k == 'q') break;
5549 /* Close the file */
5553 if (k == 'q') return (FALSE);
5561 * Peruse the On-Line-Help
5563 void do_cmd_help(void)
5568 /* Peruse the main help file */
5570 (void)show_file(TRUE, "jhelp.hlp", NULL, 0, 0);
5572 (void)show_file(TRUE, "help.hlp", NULL, 0, 0);
5582 * Process the player name.
5583 * Extract a clean "base name".
5584 * Build the savefile name if needed.
5586 void process_player_name(bool sf)
5591 /* Cannot be too long */
5592 #if defined(MACINTOSH) || defined(MSDOS) || defined(USE_EMX) || defined(AMIGA) || defined(ACORN) || defined(VM)
5594 if (strlen(player_name) > 8)
5596 if (strlen(player_name) > 15)
5601 quit_fmt("'%s'¤È¤¤¤¦Ì¾Á°¤ÏŤ¹¤®¤Þ¤¹¡ª", player_name);
5603 quit_fmt("The name '%s' is too long!", player_name);
5609 /* Cannot contain "icky" characters */
5610 for (i = 0; player_name[i]; i++)
5612 /* No control characters */
5614 if (iskanji(player_name[i])){i++;continue;}
5615 if (iscntrl( (unsigned char)player_name[i]))
5617 if (iscntrl(player_name[i]))
5621 /* Illegal characters */
5623 quit_fmt("'%s' ¤È¤¤¤¦Ì¾Á°¤ÏÉÔÀµ¤Ê¥³¥ó¥È¥í¡¼¥ë¥³¡¼¥É¤ò´Þ¤ó¤Ç¤¤¤Þ¤¹¡£", player_name);
5625 quit_fmt("The name '%s' contains control chars!", player_name);
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];
5644 /* Convert "dot" to "underscore" */
5645 if (c == '.') c = '_';
5647 /* Accept all the letters */
5648 player_base[k++] = c;
5653 /* Extract "useful" letters */
5654 for (i = 0; player_name[i]; i++)
5657 unsigned char c = player_name[i];
5659 char c = player_name[i];
5662 /* Accept some letters */
5665 if(k + 2 >= sizeof(player_base) || !player_name[i+1]) break;
5666 player_base[k++] = c;
5668 player_base[k++] = player_name[i];
5671 else if (iskana(c)) player_base[k++] = c;
5675 /* Convert path separator to underscore */
5676 if (!strncmp(PATH_SEP, player_name+i, strlen(PATH_SEP))){
5677 player_base[k++] = '_';
5678 i += strlen(PATH_SEP);
5681 /* Convert space, dot, and underscore to underscore */
5682 else if (strchr(". _", c)) player_base[k++] = '_';
5684 else if (isprint(c)) player_base[k++] = c;
5690 #if defined(WINDOWS) || defined(MSDOS)
5692 /* Hack -- max length */
5698 player_base[k] = '\0';
5700 /* Require a "base" name */
5701 if (!player_base[0]) strcpy(player_base, "PLAYER");
5704 #ifdef SAVEFILE_MUTABLE
5710 if (!savefile_base[0] && savefile[0])
5717 t = strstr(s, PATH_SEP);
5722 strcpy(savefile_base, s);
5725 if (!savefile_base[0] || !savefile[0])
5728 /* Change the savefile name */
5733 strcpy(savefile_base, player_base);
5735 #ifdef SAVEFILE_USE_UID
5736 /* Rename the savefile, using the player_uid and player_base */
5737 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5739 /* Rename the savefile, using the player_base */
5740 (void)sprintf(temp, "%s", player_base);
5744 /* Hack -- support "flat directory" usage on VM/ESA */
5745 (void)sprintf(temp, "%s.sv", player_base);
5748 /* Build the filename */
5749 path_build(savefile, 1024, ANGBAND_DIR_SAVE, temp);
5755 * Gets a name for the character, reacting to name changes.
5757 * Assumes that "display_player(0)" has just been called
5759 * Perhaps we should NOT ask for a name (at "birth()") on
5760 * Unix machines? XXX XXX
5762 * What a horrible name for a global function. XXX XXX XXX
5768 /* Save the player name */
5769 strcpy(tmp, player_name);
5771 /* Prompt for a new name */
5773 if (get_string("¥¥ã¥é¥¯¥¿¡¼¤Î̾Á°¤òÆþÎϤ·¤Æ²¼¤µ¤¤: ", tmp, 15))
5775 if (get_string("Enter a name for your character: ", tmp, 15))
5779 strcpy(player_name, tmp);
5781 else if (0 == strlen(player_name))
5783 /* Use default name */
5784 strcpy(player_name, "PLAYER");
5787 /* Process the player name */
5788 process_player_name(FALSE);
5790 strcpy(tmp,ap_ptr->title);
5797 strcat(tmp,player_name);
5799 /* Re-Draw the name (in light blue) */
5800 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5802 /* Erase the prompt, etc */
5809 * Hack -- commit suicide
5811 void do_cmd_suicide(void)
5818 /* Verify Retirement */
5823 if (!get_check("°úÂष¤Þ¤¹¤«? ")) return;
5825 if (!get_check("Do you want to retire? ")) return;
5830 /* Verify Suicide */
5835 if (!get_check("ËÜÅö¤Ë¼«»¦¤·¤Þ¤¹¤«¡©")) return;
5837 if (!get_check("Do you really want to commit suicide? ")) return;
5844 /* Special Verification for suicide */
5846 prt("³Îǧ¤Î¤¿¤á '@' ¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 0);
5848 prt("Please verify SUICIDE by typing the '@' sign: ", 0, 0);
5854 if (i != '@') return;
5860 /* Kill the player */
5864 p_ptr->leaving = TRUE;
5869 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "¥À¥ó¥¸¥ç¥ó¤Îõº÷¤ËÀä˾¤·¤Æ¼«»¦¤·¤¿¡£");
5870 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- ¥²¡¼¥à¥ª¡¼¥Ð¡¼ --------");
5872 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, "give up all hope to commit suicide.");
5873 do_cmd_write_nikki(NIKKI_GAMESTART, 1, "-------- Game Over --------");
5875 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
5878 /* Cause of death */
5880 (void)strcpy(died_from, "ÅÓÃ潪λ");
5882 (void)strcpy(died_from, "Quitting");
5892 void do_cmd_save_game(int is_autosave)
5894 /* Autosaves do not disturb */
5898 msg_print("¼«Æ°¥»¡¼¥ÖÃæ");
5900 msg_print("Autosaving the game...");
5906 /* Disturb the player */
5910 /* Clear messages */
5918 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹...", 0, 0);
5920 prt("Saving game...", 0, 0);
5927 /* The player is not dead */
5929 (void)strcpy(died_from, "(¥»¡¼¥Ö)");
5931 (void)strcpy(died_from, "(saved)");
5935 /* Forbid suspend */
5936 signals_ignore_tstp();
5938 /* Save the player */
5942 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ½ªÎ»", 0, 0);
5944 prt("Saving game... done.", 0, 0);
5949 /* Save failed (oops) */
5953 prt("¥²¡¼¥à¤ò¥»¡¼¥Ö¤·¤Æ¤¤¤Þ¤¹... ¼ºÇÔ¡ª", 0, 0);
5955 prt("Saving game... failed!", 0, 0);
5960 /* Allow suspend again */
5961 signals_handle_tstp();
5966 /* Note that the player is not dead */
5968 (void)strcpy(died_from, "(¸µµ¤¤ËÀ¸¤¤Æ¤¤¤ë)");
5970 (void)strcpy(died_from, "(alive and well)");
5977 * Save the game and exit
5979 void do_cmd_save_and_exit(void)
5984 p_ptr->leaving = TRUE;
5986 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "----¥²¡¼¥àÃæÃÇ----");
5988 do_cmd_write_nikki(NIKKI_GAMESTART, 0, "---- Save and Exit Game ----");
5994 * Hack -- Calculates the total number of points earned -JWT-
5996 long total_points(void)
6000 u32b point, point_h, point_l;
6001 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6003 if (stupid_monsters) mult -= 70;
6004 if (!preserve_mode) mult += 10;
6005 if (!autoroller) mult += 10;
6006 if (!smart_learn) mult -= 20;
6007 if (!terrain_streams) mult -= 20;
6008 if (smart_cheat) mult += 30;
6009 if (ironman_shops) mult += 50;
6010 if (ironman_small_levels) mult += 10;
6011 if (ironman_empty_levels) mult += 20;
6012 if (!powerup_home) mult += 50;
6013 if (ironman_rooms) mult += 100;
6014 if (ironman_nightmare) mult += 100;
6016 if (mult < 5) mult = 5;
6018 for (i = 0; i < max_d_idx; i++)
6019 if(max_dlv[i] > max_dl)
6020 max_dl = max_dlv[i];
6022 point_l = (p_ptr->max_exp + (100 * max_dl));
6023 point_h = point_l / 0x10000L;
6024 point_l = point_l % 0x10000L;
6027 point_h += point_l / 0x10000L;
6028 point_l %= 0x10000L;
6030 point_l += ((point_h % 100) << 16);
6034 point = (point_h << 16) + (point_l);
6035 if (p_ptr->arena_number < 99)
6036 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6038 if (ironman_downward) point *= 2;
6039 if (p_ptr->pclass == CLASS_BERSERKER)
6041 if ((p_ptr->prace == RACE_SPECTRE) || (p_ptr->prace == RACE_AMBERITE))
6045 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6048 if (total_winner) point = 2;
6050 if (easy_band) point = (0 - point);
6058 * Centers a string within a 31 character string -JWT-
6060 static void center_string(char *buf, cptr str)
6067 /* Necessary border */
6071 (void)sprintf(buf, "%*s%s%*s", j, "", str, 31 - i - j, "");
6077 * Save a "bones" file for a dead character
6079 * Note that we will not use these files until Angband 2.8.0, and
6080 * then we will only use the name and level on which death occured.
6082 * Should probably attempt some form of locking...
6084 static void make_bones(void)
6091 /* Ignore wizards and borgs */
6092 if (!(noscore & 0x00FF))
6094 /* Ignore people who die in town */
6099 /* XXX XXX XXX "Bones" name */
6100 sprintf(tmp, "bone.%03d", dun_level);
6102 /* Build the filename */
6103 path_build(str, 1024, ANGBAND_DIR_BONE, tmp);
6105 /* Attempt to open the bones file */
6106 fp = my_fopen(str, "r");
6108 /* Close it right away */
6109 if (fp) my_fclose(fp);
6111 /* Do not over-write a previous ghost */
6114 /* File type is "TEXT" */
6115 FILE_TYPE(FILE_TYPE_TEXT);
6117 /* Try to write a new "Bones File" */
6118 fp = my_fopen(str, "w");
6120 /* Not allowed to write it? Weird. */
6124 fprintf(fp, "%s\n", player_name);
6125 fprintf(fp, "%d\n", p_ptr->mhp);
6126 fprintf(fp, "%d\n", p_ptr->prace);
6127 fprintf(fp, "%d\n", p_ptr->pclass);
6129 /* Close and save the Bones file */
6138 * Redefinable "print_tombstone" action
6140 bool (*tombstone_aux)(void) = NULL;
6144 * Display a "tomb-stone"
6146 static void print_tomb(void)
6150 /* Do we use a special tombstone ? */
6153 /* Use tombstone hook */
6154 done = (*tombstone_aux)();
6157 /* Print the text-tombstone */
6171 time_t ct = time((time_t)0);
6177 /* Build the filename */
6179 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead_j.txt");
6181 path_build(buf, 1024, ANGBAND_DIR_FILE, "dead.txt");
6185 /* Open the News file */
6186 fp = my_fopen(buf, "r");
6193 /* Dump the file to the screen */
6194 while (0 == my_fgets(fp, buf, 1024))
6196 /* Display and advance */
6197 put_str(buf, i++, 0);
6206 if (total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6220 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6223 center_string(buf, player_name);
6224 put_str(buf, 6, 11);
6227 center_string(buf, "the");
6228 put_str(buf, 7, 11);
6231 center_string(buf, p);
6232 put_str(buf, 8, 11);
6235 center_string(buf, cp_ptr->title);
6237 put_str(buf, 10, 11);
6240 (void)sprintf(tmp, "¥ì¥Ù¥ë: %d", (int)p_ptr->lev);
6242 (void)sprintf(tmp, "Level: %d", (int)p_ptr->lev);
6245 center_string(buf, tmp);
6246 put_str(buf, 11, 11);
6249 (void)sprintf(tmp, "·Ð¸³ÃÍ: %ld", (long)p_ptr->exp);
6251 (void)sprintf(tmp, "Exp: %ld", (long)p_ptr->exp);
6254 center_string(buf, tmp);
6255 put_str(buf, 12, 11);
6258 (void)sprintf(tmp, "½ê»ý¶â: %ld", (long)p_ptr->au);
6260 (void)sprintf(tmp, "AU: %ld", (long)p_ptr->au);
6263 center_string(buf, tmp);
6264 put_str(buf, 13, 11);
6267 /* Êè¤Ë¹ï¤à¸ÀÍÕ¤ò¥ª¥ê¥¸¥Ê¥ë¤è¤êºÙ¤«¤¯É½¼¨ */
6268 if (streq(died_from, "ÅÓÃ潪λ"))
6270 strcpy(tmp, "<¼«»¦>");
6274 if (streq(died_from, "ripe"))
6276 strcpy(tmp, "°úÂà¸å¤ËÅ·¼÷¤òÁ´¤¦");
6278 else if (streq(died_from, "Seppuku"))
6280 strcpy(tmp, "¾¡Íø¤Î¸å¡¢ÀÚÊ¢");
6284 strcpy(tmp, died_from);
6287 center_string(buf, tmp);
6288 put_str(buf, 14, 11);
6290 if(!streq(died_from, "ripe") && !streq(died_from, "Seppuku"))
6292 if( dun_level == 0 )
6294 cptr town = (p_ptr->town_num ? "³¹" : "¹ÓÌî");
6295 if(streq(died_from, "ÅÓÃ潪λ"))
6297 sprintf(tmp, "%s¤Ç»à¤ó¤À", town);
6301 sprintf(tmp, "¤Ë%s¤Ç»¦¤µ¤ì¤¿", town);
6306 if(streq(died_from, "ÅÓÃ潪λ"))
6308 sprintf(tmp, "Ãϲ¼ %d ³¬¤Ç»à¤ó¤À", dun_level);
6312 sprintf(tmp, "¤ËÃϲ¼ %d ³¬¤Ç»¦¤µ¤ì¤¿", dun_level);
6315 center_string(buf, tmp);
6316 put_str(buf, 15, 11);
6319 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6320 center_string(buf, tmp);
6321 put_str(buf, 14, 11);
6324 if (strlen(died_from) > 24)
6326 strncpy(dummy, died_from, 24);
6328 (void)sprintf(tmp, "by %s.", dummy);
6331 (void)sprintf(tmp, "by %s.", died_from);
6333 center_string(buf, tmp);
6334 put_str(buf, 15, 11);
6339 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6340 center_string(buf, tmp);
6341 put_str(buf, 17, 11);
6344 msg_format("¤µ¤è¤¦¤Ê¤é¡¢%s!", player_name);
6346 msg_format("Goodbye, %s!", player_name);
6354 * Display some character info
6356 static void show_info(void)
6362 /* Hack -- Know everything in the inven/equip */
6363 for (i = 0; i < INVEN_TOTAL; i++)
6365 o_ptr = &inventory[i];
6367 /* Skip non-objects */
6368 if (!o_ptr->k_idx) continue;
6370 /* Aware and Known */
6371 object_aware(o_ptr);
6372 object_known(o_ptr);
6375 for (i = 1; i < max_towns; i++)
6377 st_ptr = &town[i].store[STORE_HOME];
6379 /* Hack -- Know everything in the home */
6380 for (j = 0; j < st_ptr->stock_num; j++)
6382 o_ptr = &st_ptr->stock[j];
6384 /* Skip non-objects */
6385 if (!o_ptr->k_idx) continue;
6387 /* Aware and Known */
6388 object_aware(o_ptr);
6389 object_known(o_ptr);
6393 /* Hack -- Recalculate bonuses */
6394 p_ptr->update |= (PU_BONUS);
6399 /* Flush all input keys */
6402 /* Flush messages */
6406 /* Describe options */
6408 prt("¥¥ã¥é¥¯¥¿¡¼¤ÎµÏ¿¤ò¥Õ¥¡¥¤¥ë¤Ë½ñ¤½Ð¤¹¤³¤È¤¬¤Ç¤¤Þ¤¹¡£", 21, 0);
6409 prt("¥ê¥¿¡¼¥ó¥¡¼¤Ç¥¥ã¥é¥¯¥¿¡¼¤ò¸«¤Þ¤¹¡£ESC¤ÇÃæÃǤ·¤Þ¤¹¡£", 22, 0);
6411 prt("You may now dump a character record to one or more files.", 21, 0);
6412 prt("Then, hit RETURN to see the character, or ESC to abort.", 22, 0);
6416 /* Dump character records as requested */
6423 put_str("¥Õ¥¡¥¤¥ë¥Í¡¼¥à: ", 23, 0);
6425 put_str("Filename: ", 23, 0);
6430 strcpy(out_val, "");
6432 /* Ask for filename (or abort) */
6433 if (!askfor_aux(out_val, 60)) return;
6435 /* Return means "show on screen" */
6436 if (!out_val[0]) break;
6441 /* Dump a character file */
6442 (void)file_character(out_val, TRUE);
6450 /* Display player */
6453 /* Prompt for inventory */
6455 prt("²¿¤«¥¡¼¤ò²¡¤¹¤È¤µ¤é¤Ë¾ðÊó¤¬Â³¤¤Þ¤¹ (ESC¤ÇÃæÃÇ): ", 23, 0);
6457 prt("Hit any key to see more information (ESC to abort): ", 23, 0);
6461 /* Allow abort at this point */
6462 if (inkey() == ESCAPE) return;
6465 /* Show equipment and inventory */
6467 /* Equipment -- if any */
6471 item_tester_full = TRUE;
6472 (void)show_equip(0);
6474 prt("ÁõÈ÷¤·¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6476 prt("You are using: -more-", 0, 0);
6479 if (inkey() == ESCAPE) return;
6482 /* Inventory -- if any */
6486 item_tester_full = TRUE;
6487 (void)show_inven(0);
6489 prt("»ý¤Ã¤Æ¤¤¤¿¥¢¥¤¥Æ¥à: -³¤¯-", 0, 0);
6491 prt("You are carrying: -more-", 0, 0);
6494 if (inkey() == ESCAPE) return;
6497 /* Homes in the different towns */
6498 for (l = 1; l < max_towns; l++)
6500 st_ptr = &town[l].store[STORE_HOME];
6502 /* Home -- if anything there */
6503 if (st_ptr->stock_num)
6505 /* Display contents of the home */
6506 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6512 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6514 char o_name[MAX_NLEN];
6518 o_ptr = &st_ptr->stock[i];
6520 /* Print header, clear line */
6521 sprintf(tmp_val, "%c) ", I2A(j));
6522 prt(tmp_val, j+2, 4);
6524 /* Display object description */
6525 object_desc(o_name, o_ptr, TRUE, 3);
6526 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6531 prt(format("²æ¤¬²È¤ËÃÖ¤¤¤Æ¤¢¤Ã¤¿¥¢¥¤¥Æ¥à ( %d ¥Ú¡¼¥¸): -³¤¯-", k+1), 0, 0);
6533 prt(format("Your home contains (page %d): -more-", k+1), 0, 0);
6538 if (inkey() == ESCAPE) return;
6545 static bool check_score(void)
6551 if (highscore_fd < 0)
6554 msg_print("¥¹¥³¥¢¡¦¥Õ¥¡¥¤¥ë¤¬»ÈÍѤǤ¤Þ¤»¤ó¡£");
6556 msg_print("Score file unavailable.");
6563 #ifndef SCORE_WIZARDS
6564 /* Wizard-mode pre-empts scoring */
6565 if (noscore & 0x000F)
6568 msg_print("¥¦¥£¥¶¡¼¥É¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6570 msg_print("Score not registered for wizards.");
6579 /* Borg-mode pre-empts scoring */
6580 if (noscore & 0x00F0)
6583 msg_print("¥Ü¡¼¥°¡¦¥â¡¼¥É¤Ç¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6585 msg_print("Score not registered for borgs.");
6593 #ifndef SCORE_CHEATERS
6594 /* Cheaters are not scored */
6595 if (noscore & 0xFF00)
6598 msg_print("º¾µ½¤ò¤ä¤Ã¤¿¿Í¤Ï¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6600 msg_print("Score not registered for cheaters.");
6610 if (!total_winner && streq(died_from, "¶¯À©½ªÎ»"))
6612 if (!total_winner && streq(died_from, "Interrupting"))
6617 msg_print("¶¯À©½ªÎ»¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6619 msg_print("Score not registered due to interruption.");
6628 if (!total_winner && streq(died_from, "ÅÓÃ潪λ"))
6630 if (!total_winner && streq(died_from, "Quitting"))
6635 msg_print("ÅÓÃ潪λ¤Î¤¿¤á¥¹¥³¥¢¤¬µÏ¿¤µ¤ì¤Þ¤»¤ó¡£");
6637 msg_print("Score not registered due to quitting.");
6647 * Close up the current game (player may or may not be dead)
6649 * This function is called only from "main.c" and "signals.c".
6651 void close_game(void)
6654 bool do_send = TRUE;
6656 /* cptr p = "[i:¥¥ã¥é¥¯¥¿¤Î¾ðÊó, f:¥Õ¥¡¥¤¥ë½ñ¤½Ð¤·, t:¥¹¥³¥¢, x:*´ÕÄê*, ESC:¥²¡¼¥à½ªÎ»]"; */
6661 /* Flush the messages */
6664 /* Flush the input */
6668 /* No suspending now */
6669 signals_ignore_tstp();
6672 /* Hack -- Character is now "icky" */
6673 character_icky = TRUE;
6676 /* Build the filename */
6677 path_build(buf, 1024, ANGBAND_DIR_APEX, "scores.raw");
6679 /* Open the high score file, for reading/writing */
6680 highscore_fd = fd_open(buf, O_RDWR);
6686 /* Handle retirement */
6687 if (total_winner) kingly();
6691 if (!munchkin_death || get_check("»à¤ó¤À¥Ç¡¼¥¿¤ò¥»¡¼¥Ö¤·¤Þ¤¹¤«¡© "))
6693 if (!munchkin_death || get_check("Save death? "))
6698 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6700 if (!save_player()) msg_print("death save failed!");
6703 else do_send = FALSE;
6710 /* Show more info */
6718 if ((!send_world_score(do_send)))
6721 if (get_check("¸å¤Ç¥¹¥³¥¢¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ËÂÔµ¡¤·¤Þ¤¹¤«¡©"))
6723 if (get_check("Stand by for later score registration? "))
6726 wait_report_score = TRUE;
6729 if (!save_player()) msg_print("¥»¡¼¥Ö¼ºÇÔ¡ª");
6731 if (!save_player()) msg_print("death save failed!");
6735 if (!wait_report_score)
6738 else if (highscore_fd >= 0)
6740 display_scores_aux(0, 10, -1, NULL);
6743 /* Dump bones file */
6752 do_cmd_save_game(FALSE);
6754 /* Prompt for scores XXX XXX XXX */
6756 prt("¥ê¥¿¡¼¥ó¥¡¼¤« ESC ¥¡¼¤ò²¡¤·¤Æ²¼¤µ¤¤¡£", 0, 40);
6758 prt("Press Return (or Escape).", 0, 40);
6762 /* Predict score (or ESCAPE) */
6763 if (inkey() != ESCAPE) predict_score();
6767 /* Shut the high score file */
6768 (void)fd_close(highscore_fd);
6770 /* Forget the high score fd */
6774 /* Allow suspending now */
6775 signals_handle_tstp();
6780 * Handle abrupt death of the visual system
6782 * This routine is called only in very rare situations, and only
6783 * by certain visual systems, when they experience fatal errors.
6785 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6786 * save file so that player can see tombstone when restart.
6788 void exit_game_panic(void)
6790 /* If nothing important has happened, just quit */
6792 if (!character_generated || character_saved) quit("¶ÛµÞ»öÂÖ");
6794 if (!character_generated || character_saved) quit("panic");
6798 /* Mega-Hack -- see "msg_print()" */
6801 /* Clear the top line */
6804 /* Hack -- turn off some things */
6807 /* Mega-Hack -- Delay death */
6808 if (p_ptr->chp < 0) death = FALSE;
6810 /* Hardcode panic save */
6813 /* Forbid suspend */
6814 signals_ignore_tstp();
6816 /* Indicate panic save */
6818 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
6820 (void)strcpy(died_from, "(panic save)");
6824 /* Panic save, or get worried */
6826 if (!save_player()) quit("¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
6828 if (!save_player()) quit("panic save failed!");
6832 /* Successful panic save */
6834 quit("¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
6836 quit("panic save succeeded!");
6843 * Get a random line from a file
6844 * Based on the monster speech patch by Matt Graham,
6846 errr get_rnd_line(cptr file_name, int entry, char *output)
6850 int line, counter, test, numentries;
6855 /* Build the filename */
6856 path_build(buf, 1024, ANGBAND_DIR_FILE, file_name);
6859 fp = my_fopen(buf, "r");
6862 if (!fp) return (-1);
6864 /* Find the entry of the monster */
6867 /* Get a line from the file */
6868 if (my_fgets(fp, buf, 1024) == 0)
6870 /* Count the lines */
6873 /* Look for lines starting with 'N:' */
6874 if ((buf[0] == 'N') && (buf[1] == ':'))
6876 /* Allow default lines */
6883 else if (buf[2] == 'M')
6885 if (r_info[entry].flags1 & RF1_MALE)
6891 else if (buf[2] == 'F')
6893 if (r_info[entry].flags1 & RF1_FEMALE)
6899 /* Get the monster number */
6900 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6902 /* Is it the right monster? */
6911 /* Error while converting the monster number */
6912 msg_format("Error in line %d of %s!",
6913 line_num, file_name);
6921 /* Reached end of file */
6928 /* Get the number of entries */
6932 if (my_fgets(fp, buf, 1024) == 0)
6934 /* Count the lines */
6937 /* Look for the number of entries */
6938 if (isdigit(buf[0]))
6940 /* Get the number of entries */
6941 numentries = atoi(buf);
6947 /* Count the lines */
6950 /* Reached end of file without finding the number */
6951 msg_format("Error in line %d of %s!",
6952 line_num, file_name);
6961 /* Grab an appropriate line number */
6962 line = rand_int(numentries);
6964 /* Get the random line */
6965 for (counter = 0; counter <= line; counter++)
6967 /* Count the lines */
6972 test = my_fgets(fp, buf, 1024);
6973 if(test || buf[0] != '#')
6979 /* Found the line */
6980 if (counter == line) break;
6984 /* Error - End of file */
6985 msg_format("Error in line %d of %s!",
6986 line_num, file_name);
6994 strcpy(output, buf);
7001 /* Close the file */
7010 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7014 for (i=0;i<count;i++){
7015 result=get_rnd_line(file_name, entry, output);
7018 for(j=0; output[j]; j++) kanji |= iskanji(output[j]);
7026 * Process file for auto picker/destroyer.
7028 errr process_pickpref_file(cptr name)
7034 /* Build the filename */
7035 path_build(buf, 1024, ANGBAND_DIR_USER, name);
7037 err = process_pref_file_aux(buf, TRUE);
7043 static errr counts_seek(int fd, u32b where, bool flag)
7046 char temp1[128], temp2[128];
7047 u32b zero_header[3] = {0L, 0L, 0L};
7050 #ifdef SAVEFILE_USE_UID
7051 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7053 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7055 for (i = 0; temp1[i]; i++)
7056 temp1[i] ^= (i+1) * 63;
7061 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7063 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7068 fd_seek(fd, seekpoint);
7069 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7070 fd_write(fd, (char*)(temp1), sizeof(temp1));
7074 if (strcmp(temp1, temp2) == 0)
7077 seekpoint += 128 + 3 * sizeof(u32b);
7080 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7083 u32b counts_read(int where)
7090 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7092 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7094 fd = fd_open(buf, O_RDONLY);
7096 if (counts_seek(fd, where, FALSE) ||
7097 fd_read(fd, (char*)(&count), sizeof(u32b)))
7105 errr counts_write(int where, u32b count)
7111 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info_j.raw");
7113 path_build(buf, 1024, ANGBAND_DIR_DATA, "z_info.raw");
7115 fd = fd_open(buf, O_RDWR);
7118 /* File type is "DATA" */
7119 FILE_TYPE(FILE_TYPE_DATA);
7121 /* Create a new high score file */
7122 fd = fd_make(buf, 0644);
7125 if (fd_lock(fd, F_WRLCK)) return 1;
7127 counts_seek(fd, where, TRUE);
7128 fd_write(fd, (char*)(&count), sizeof(u32b));
7130 if (fd_lock(fd, F_UNLCK)) return 1;
7138 #ifdef HANDLE_SIGNALS
7145 * Handle signals -- suspend
7147 * Actually suspend the game, and then resume cleanly
7149 static void handle_signal_suspend(int sig)
7151 /* Disable handler */
7152 (void)signal(sig, SIG_IGN);
7159 /* Suspend the "Term" */
7160 Term_xtra(TERM_XTRA_ALIVE, 0);
7162 /* Suspend ourself */
7163 (void)kill(0, SIGSTOP);
7165 /* Resume the "Term" */
7166 Term_xtra(TERM_XTRA_ALIVE, 1);
7168 /* Redraw the term */
7171 /* Flush the term */
7176 /* Restore handler */
7177 (void)signal(sig, handle_signal_suspend);
7182 * Handle signals -- simple (interrupt and quit)
7184 * This function was causing a *huge* number of problems, so it has
7185 * been simplified greatly. We keep a global variable which counts
7186 * the number of times the user attempts to kill the process, and
7187 * we commit suicide if the user does this a certain number of times.
7189 * We attempt to give "feedback" to the user as he approaches the
7190 * suicide thresh-hold, but without penalizing accidental keypresses.
7192 * To prevent messy accidents, we should reset this global variable
7193 * whenever the user enters a keypress, or something like that.
7195 static void handle_signal_simple(int sig)
7197 /* Disable handler */
7198 (void)signal(sig, SIG_IGN);
7201 /* Nothing to save, just quit */
7202 if (!character_generated || character_saved) quit(NULL);
7205 /* Count the signals */
7209 /* Terminate dead characters */
7212 /* Mark the savefile */
7214 (void)strcpy(died_from, "¶¯À©½ªÎ»");
7216 (void)strcpy(died_from, "Abortion");
7235 /* Allow suicide (after 5) */
7236 else if (signal_count >= 5)
7238 /* Cause of "death" */
7240 (void)strcpy(died_from, "¶¯À©½ªÎ»Ãæ");
7242 (void)strcpy(died_from, "Interrupting");
7257 p_ptr->leaving = TRUE;
7271 /* Give warning (after 4) */
7272 else if (signal_count >= 4)
7275 Term_xtra(TERM_XTRA_NOISE, 0);
7277 /* Clear the top line */
7278 Term_erase(0, 0, 255);
7280 /* Display the cause */
7282 Term_putstr(0, 0, -1, TERM_WHITE, "½Ïθ¤Î¾å¤Î¼«»¦¡ª");
7284 Term_putstr(0, 0, -1, TERM_WHITE, "Contemplating suicide!");
7292 /* Give warning (after 2) */
7293 else if (signal_count >= 2)
7296 Term_xtra(TERM_XTRA_NOISE, 0);
7299 /* Restore handler */
7300 (void)signal(sig, handle_signal_simple);
7305 * Handle signal -- abort, kill, etc
7307 static void handle_signal_abort(int sig)
7309 /* Disable handler */
7310 (void)signal(sig, SIG_IGN);
7313 /* Nothing to save, just quit */
7314 if (!character_generated || character_saved) quit(NULL);
7321 /* Clear the bottom line */
7322 Term_erase(0, 23, 255);
7324 /* Give a warning */
7325 Term_putstr(0, 23, -1, TERM_RED,
7327 "¶²¤í¤·¤¤¥½¥Õ¥È¤Î¥Ð¥°¤¬Èô¤Ó¤«¤«¤Ã¤Æ¤¤¿¡ª");
7329 "A gruesome software bug LEAPS out at you!");
7335 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö...");
7337 Term_putstr(45, 23, -1, TERM_RED, "Panic save...");
7349 (void)strcpy(died_from, "(¶ÛµÞ¥»¡¼¥Ö)");
7351 (void)strcpy(died_from, "(panic save)");
7355 /* Forbid suspend */
7356 signals_ignore_tstp();
7358 /* Attempt to save */
7362 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥ÖÀ®¸ù¡ª");
7364 Term_putstr(45, 23, -1, TERM_RED, "Panic save succeeded!");
7373 Term_putstr(45, 23, -1, TERM_RED, "¶ÛµÞ¥»¡¼¥Ö¼ºÇÔ¡ª");
7375 Term_putstr(45, 23, -1, TERM_RED, "Panic save failed!");
7385 quit("¥½¥Õ¥È¤Î¥Ð¥°");
7387 quit("software bug");
7396 * Ignore SIGTSTP signals (keyboard suspend)
7398 void signals_ignore_tstp(void)
7402 (void)signal(SIGTSTP, SIG_IGN);
7408 * Handle SIGTSTP signals (keyboard suspend)
7410 void signals_handle_tstp(void)
7414 (void)signal(SIGTSTP, handle_signal_suspend);
7421 * Prepare to handle the relevant signals
7423 void signals_init(void)
7427 (void)signal(SIGHUP, SIG_IGN);
7432 (void)signal(SIGTSTP, handle_signal_suspend);
7437 (void)signal(SIGINT, handle_signal_simple);
7441 (void)signal(SIGQUIT, handle_signal_simple);
7446 (void)signal(SIGFPE, handle_signal_abort);
7450 (void)signal(SIGILL, handle_signal_abort);
7454 (void)signal(SIGTRAP, handle_signal_abort);
7458 (void)signal(SIGIOT, handle_signal_abort);
7462 (void)signal(SIGKILL, handle_signal_abort);
7466 (void)signal(SIGBUS, handle_signal_abort);
7470 (void)signal(SIGSEGV, handle_signal_abort);
7474 (void)signal(SIGTERM, handle_signal_abort);
7478 (void)signal(SIGPIPE, handle_signal_abort);
7482 (void)signal(SIGEMT, handle_signal_abort);
7486 (void)signal(SIGDANGER, handle_signal_abort);
7490 (void)signal(SIGSYS, handle_signal_abort);
7494 (void)signal(SIGXCPU, handle_signal_abort);
7498 (void)signal(SIGPWR, handle_signal_abort);
7504 #else /* HANDLE_SIGNALS */
7510 void signals_ignore_tstp(void)
7517 void signals_handle_tstp(void)
7524 void signals_init(void)
7527 #endif /* HANDLE_SIGNALS */