3 * @brief ファイル入出力管理 / Purpose: code dealing with files (and death)
7 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
8 * This software may be copied and distributed for educational, research,
9 * and not for profit purposes provided that this copyright and statement
10 * are included in all such copies. Other copyrights may also apply.
11 * 2014 Deskull rearranged comment for Doxygen.\n
20 * You may or may not want to use the following "#undef".
22 /* #undef _POSIX_SAVED_IDS */
26 * @brief ファイルのドロップパーミッションチェック / Hack -- drop permissions
28 void safe_setuid_drop(void)
35 # ifdef SAFE_SETUID_POSIX
37 if (setuid(getuid()) != 0)
39 quit(_("setuid(): 正しく許可が取れません!", "setuid(): cannot set permissions correctly!"));
41 if (setgid(getgid()) != 0)
43 quit(_("setgid(): 正しく許可が取れません!", "setgid(): cannot set permissions correctly!"));
48 if (setreuid(geteuid(), getuid()) != 0)
50 quit(_("setreuid(): 正しく許可が取れません!", "setreuid(): cannot set permissions correctly!"));
52 if (setregid(getegid(), getgid()) != 0)
54 quit(_("setregid(): 正しく許可が取れません!", "setregid(): cannot set permissions correctly!"));
67 * @brief ファイルのグラブパーミッションチェック / Hack -- grab permissions
69 void safe_setuid_grab(void)
76 # ifdef SAFE_SETUID_POSIX
78 if (setuid(player_euid) != 0)
80 quit(_("setuid(): 正しく許可が取れません!", "setuid(): cannot set permissions correctly!"));
82 if (setgid(player_egid) != 0)
84 quit(_("setgid(): 正しく許可が取れません!", "setgid(): cannot set permissions correctly!"));
89 if (setreuid(geteuid(), getuid()) != 0)
91 quit(_("setreuid(): 正しく許可が取れません!", "setreuid(): cannot set permissions correctly!"));
93 if (setregid(getegid(), getgid()) != 0)
95 quit(_("setregid(): 正しく許可が取れません!", "setregid(): cannot set permissions correctly!"));
98 # endif /* SAFE_SETUID_POSIX */
100 # endif /* SAFE_SETUID */
108 * @brief 各種データテキストをトークン単位に分解する / Extract the first few "tokens" from a buffer
109 * @param buf データテキストの参照ポインタ
111 * @param tokens トークンを保管する文字列参照ポインタ配列
116 * This function uses "colon" and "slash" as the delimeter characters.
117 * We never extract more than "num" tokens. The "last" token may include
118 * "delimeter" characters, allowing the buffer to include a "string" token.
119 * We save pointers to the tokens in "tokens", and return the number found.
120 * Hack -- Attempt to handle the 'c' character formalism
121 * Hack -- An empty buffer, or a final delimeter, yields an "empty" token.
122 * Hack -- We will always extract at least one token
125 s16b tokenize(char *buf, s16b num, char **tokens, BIT_FLAGS mode)
137 /* Scan the string */
140 /* Found a delimiter */
141 if ((*t == ':') || (*t == '/')) break;
143 /* Handle single quotes */
144 if ((mode & TOKENIZE_CHECKQUOTE) && (*t == '\''))
149 /* Handle backslash */
152 /* Require a character */
158 /* Hack -- Require a close quote */
159 if (*t != '\'') *t = '\'';
162 /* Handle back-slash */
169 /* Nuke and advance */
187 /* A number with a name */
188 typedef struct named_num named_num;
192 cptr name; /* The name of this thing */
193 int num; /* A number associated with it */
197 /* Index of spell type names */
198 static named_num gf_desc[] =
200 {"GF_ELEC", GF_ELEC },
201 {"GF_POIS", GF_POIS },
202 {"GF_ACID", GF_ACID },
203 {"GF_COLD", GF_COLD },
204 {"GF_FIRE", GF_FIRE },
205 {"GF_PSY_SPEAR", GF_PSY_SPEAR },
206 {"GF_MISSILE", GF_MISSILE },
207 {"GF_ARROW", GF_ARROW },
208 {"GF_PLASMA", GF_PLASMA },
209 {"GF_WATER", GF_WATER },
210 {"GF_LITE", GF_LITE },
211 {"GF_DARK", GF_DARK },
212 {"GF_LITE_WEAK", GF_LITE_WEAK },
213 {"GF_DARK_WEAK", GF_DARK_WEAK },
214 {"GF_SHARDS", GF_SHARDS },
215 {"GF_SOUND", GF_SOUND },
216 {"GF_CONFUSION", GF_CONFUSION },
217 {"GF_FORCE", GF_FORCE },
218 {"GF_INERTIA", GF_INERTIAL },
219 {"GF_MANA", GF_MANA },
220 {"GF_METEOR", GF_METEOR },
222 {"GF_CHAOS", GF_CHAOS },
223 {"GF_NETHER", GF_NETHER },
224 {"GF_DISENCHANT", GF_DISENCHANT },
225 {"GF_NEXUS", GF_NEXUS },
226 {"GF_TIME", GF_TIME },
227 {"GF_GRAVITY", GF_GRAVITY },
228 {"GF_KILL_WALL", GF_KILL_WALL },
229 {"GF_KILL_DOOR", GF_KILL_DOOR },
230 {"GF_KILL_TRAP", GF_KILL_TRAP },
231 {"GF_MAKE_WALL", GF_MAKE_WALL },
232 {"GF_MAKE_DOOR", GF_MAKE_DOOR },
233 {"GF_MAKE_TRAP", GF_MAKE_TRAP },
234 {"GF_MAKE_TREE", GF_MAKE_TREE },
235 {"GF_OLD_CLONE", GF_OLD_CLONE },
236 {"GF_OLD_POLY", GF_OLD_POLY },
237 {"GF_OLD_HEAL", GF_OLD_HEAL },
238 {"GF_OLD_SPEED", GF_OLD_SPEED },
239 {"GF_OLD_SLOW", GF_OLD_SLOW },
240 {"GF_OLD_CONF", GF_OLD_CONF },
241 {"GF_OLD_SLEEP", GF_OLD_SLEEP },
242 {"GF_HYPODYNAMIA", GF_HYPODYNAMIA },
243 {"GF_AWAY_UNDEAD", GF_AWAY_UNDEAD },
244 {"GF_AWAY_EVIL", GF_AWAY_EVIL },
245 {"GF_AWAY_ALL", GF_AWAY_ALL },
246 {"GF_TURN_UNDEAD", GF_TURN_UNDEAD },
247 {"GF_TURN_EVIL", GF_TURN_EVIL },
248 {"GF_TURN_ALL", GF_TURN_ALL },
249 {"GF_DISP_UNDEAD", GF_DISP_UNDEAD },
250 {"GF_DISP_EVIL", GF_DISP_EVIL },
251 {"GF_DISP_ALL", GF_DISP_ALL },
252 {"GF_DISP_DEMON", GF_DISP_DEMON },
253 {"GF_DISP_LIVING", GF_DISP_LIVING },
254 {"GF_ROCKET", GF_ROCKET },
255 {"GF_NUKE", GF_NUKE },
256 {"GF_MAKE_GLYPH", GF_MAKE_GLYPH },
257 {"GF_STASIS", GF_STASIS },
258 {"GF_STONE_WALL", GF_STONE_WALL },
259 {"GF_DEATH_RAY", GF_DEATH_RAY },
260 {"GF_STUN", GF_STUN },
261 {"GF_HOLY_FIRE", GF_HOLY_FIRE },
262 {"GF_HELL_FIRE", GF_HELL_FIRE },
263 {"GF_DISINTEGRATE", GF_DISINTEGRATE },
264 {"GF_CHARM", GF_CHARM },
265 {"GF_CONTROL_UNDEAD", GF_CONTROL_UNDEAD },
266 {"GF_CONTROL_ANIMAL", GF_CONTROL_ANIMAL },
268 {"GF_PSI_DRAIN", GF_PSI_DRAIN },
269 {"GF_TELEKINESIS", GF_TELEKINESIS },
270 {"GF_JAM_DOOR", GF_JAM_DOOR },
271 {"GF_DOMINATION", GF_DOMINATION },
272 {"GF_DISP_GOOD", GF_DISP_GOOD },
273 {"GF_DRAIN_MANA", GF_DRAIN_MANA },
274 {"GF_MIND_BLAST", GF_MIND_BLAST },
275 {"GF_BRAIN_SMASH", GF_BRAIN_SMASH },
276 {"GF_CAUSE_1", GF_CAUSE_1 },
277 {"GF_CAUSE_2", GF_CAUSE_2 },
278 {"GF_CAUSE_3", GF_CAUSE_3 },
279 {"GF_CAUSE_4", GF_CAUSE_4 },
280 {"GF_HAND_DOOM", GF_HAND_DOOM },
281 {"GF_CAPTURE", GF_CAPTURE },
282 {"GF_ANIM_DEAD", GF_ANIM_DEAD },
283 {"GF_CHARM_LIVING", GF_CHARM_LIVING },
284 {"GF_IDENTIFY", GF_IDENTIFY },
285 {"GF_ATTACK", GF_ATTACK },
286 {"GF_ENGETSU", GF_ENGETSU },
287 {"GF_GENOCIDE", GF_GENOCIDE },
288 {"GF_PHOTO", GF_PHOTO },
289 {"GF_CONTROL_DEMON", GF_CONTROL_DEMON },
290 {"GF_LAVA_FLOW", GF_LAVA_FLOW },
291 {"GF_BLOOD_CURSE", GF_BLOOD_CURSE },
292 {"GF_SEEKER", GF_SEEKER },
293 {"GF_SUPER_RAY", GF_SUPER_RAY },
294 {"GF_STAR_HEAL", GF_STAR_HEAL },
295 {"GF_WATER_FLOW", GF_WATER_FLOW },
296 {"GF_CRUSADE", GF_CRUSADE },
297 {"GF_STASIS_EVIL", GF_STASIS_EVIL },
298 {"GF_WOUNDS", GF_WOUNDS },
304 * @brief 設定ファイルの各行から各種テキスト情報を取得する /
305 * Parse a sub-file of the "extra info" (format shown below)
306 * @param buf データテキストの参照ポインタ
310 * Each "action" line has an "action symbol" in the first column,
311 * followed by a colon, followed by some command specific info,
312 * usually in the form of "tokens" separated by colons or slashes.
313 * Blank lines, lines starting with white space, and lines starting
314 * with pound signs ("#") are ignored (as comments).
315 * Note the use of "tokenize()" to allow the use of both colons and
316 * slashes as delimeters, while still allowing final tokens which
317 * may contain any characters including "delimiters".
318 * Note the use of "strtol()" to allow all "integers" to be encoded
319 * in decimal, hexidecimal, or octal form.
320 * Note that "monster zero" is used for the "player" attr/char, "object
321 * zero" will be used for the "stack" attr/char, and "feature zero" is
322 * used for the "nothing" attr/char.
323 * Parse another file recursively, see below for details
325 * Specify the attr/char values for "monsters" by race index
326 * R:\<num\>:\<a\>:\<c\>
327 * Specify the attr/char values for "objects" by kind index
328 * K:\<num\>:\<a\>:\<c\>
329 * Specify the attr/char values for "features" by feature index
330 * F:\<num\>:\<a\>:\<c\>
331 * Specify the attr/char values for unaware "objects" by kind tval
332 * U:\<tv\>:\<a\>:\<c\>
333 * Specify the attr/char values for inventory "objects" by kind tval
334 * E:\<tv\>:\<a\>:\<c\>
335 * Define a macro action, given an encoded macro action
337 * Create a normal macro, given an encoded macro trigger
339 * Create a command macro, given an encoded macro trigger
341 * Create a keyset mapping
342 * S:\<key\>:\<key\>:\<dir\>
343 * Turn an option off, given its name
345 * Turn an option on, given its name
347 * Specify visual information, given an index, and some data
348 * V:\<num\>:\<kv\>:\<rv\>:\<gv\>:\<bv\>
349 * Specify the set of colors to use when drawing a zapped spell
351 * Specify a macro trigger template and macro trigger names.
352 * T:\<template\>:\<modifier chr\>:\<modifier name1\>:\<modifier name2\>:...
353 * T:\<trigger\>:\<keycode\>:\<shift-keycode\>
356 errr process_pref_file_command(char *buf)
366 /* Require "?:*" format */
367 if (buf[1] != ':') return 1;
372 /* Mega-Hack -- read external player's history file */
373 /* Process "H:<history>" */
375 add_history_from_pref_line(buf + 2);
378 /* Process "R:<num>:<a>/<c>" -- attr/char for monster races */
380 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
383 i = (huge)strtol(zz[0], NULL, 0);
384 n1 = (TERM_COLOR)strtol(zz[1], NULL, 0);
385 n2 = (SYMBOL_CODE)strtol(zz[2], NULL, 0);
386 if (i >= max_r_idx) return 1;
388 if (n1 || (!(n2 & 0x80) && n2)) r_ptr->x_attr = n1; /* Allow TERM_DARK text */
389 if (n2) r_ptr->x_char = n2;
394 /* Process "K:<num>:<a>/<c>" -- attr/char for object kinds */
396 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
399 i = (huge)strtol(zz[0], NULL, 0);
400 n1 = (TERM_COLOR)strtol(zz[1], NULL, 0);
401 n2 = (SYMBOL_CODE)strtol(zz[2], NULL, 0);
402 if (i >= max_k_idx) return 1;
404 if (n1 || (!(n2 & 0x80) && n2)) k_ptr->x_attr = n1; /* Allow TERM_DARK text */
405 if (n2) k_ptr->x_char = n2;
410 /* Process "F:<num>:<a>/<c>" -- attr/char for terrain features */
411 /* "F:<num>:<a>/<c>" */
412 /* "F:<num>:<a>/<c>:LIT" */
413 /* "F:<num>:<a>/<c>:<la>/<lc>:<da>/<dc>" */
417 int num = tokenize(buf + 2, F_LIT_MAX * 2 + 1, zz, TOKENIZE_CHECKQUOTE);
419 if ((num != 3) && (num != 4) && (num != F_LIT_MAX * 2 + 1)) return 1;
420 else if ((num == 4) && !streq(zz[3], "LIT")) return 1;
422 i = (huge)strtol(zz[0], NULL, 0);
423 if (i >= max_f_idx) return 1;
426 n1 = (TERM_COLOR)strtol(zz[1], NULL, 0);
427 n2 = (SYMBOL_CODE)strtol(zz[2], NULL, 0);
428 if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[F_LIT_STANDARD] = n1; /* Allow TERM_DARK text */
429 if (n2) f_ptr->x_char[F_LIT_STANDARD] = n2;
431 /* Mega-hack -- feat supports lighting */
434 /* No lighting support */
436 n1 = f_ptr->x_attr[F_LIT_STANDARD];
437 n2 = f_ptr->x_char[F_LIT_STANDARD];
438 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
440 f_ptr->x_attr[j] = n1;
441 f_ptr->x_char[j] = n2;
445 /* Use default lighting */
447 apply_default_feat_lighting(f_ptr->x_attr, f_ptr->x_char);
450 /* Use desired lighting */
451 case F_LIT_MAX * 2 + 1:
452 for (j = F_LIT_NS_BEGIN; j < F_LIT_MAX; j++)
454 n1 = (TERM_COLOR)strtol(zz[j * 2 + 1], NULL, 0);
455 n2 = (SYMBOL_CODE)strtol(zz[j * 2 + 2], NULL, 0);
456 if (n1 || (!(n2 & 0x80) && n2)) f_ptr->x_attr[j] = n1; /* Allow TERM_DARK text */
457 if (n2) f_ptr->x_char[j] = n2;
464 /* Process "S:<num>:<a>/<c>" -- attr/char for special things */
466 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
468 j = (byte)strtol(zz[0], NULL, 0);
469 n1 = (TERM_COLOR)strtol(zz[1], NULL, 0);
470 n2 = (SYMBOL_CODE)strtol(zz[2], NULL, 0);
471 misc_to_attr[j] = n1;
472 misc_to_char[j] = n2;
477 /* Process "U:<tv>:<a>/<c>" -- attr/char for unaware items */
479 if (tokenize(buf+2, 3, zz, TOKENIZE_CHECKQUOTE) == 3)
481 j = (huge)strtol(zz[0], NULL, 0);
482 n1 = (TERM_COLOR)strtol(zz[1], NULL, 0);
483 n2 = (SYMBOL_CODE)strtol(zz[2], NULL, 0);
484 for (i = 1; i < max_k_idx; i++)
486 object_kind *k_ptr = &k_info[i];
487 if (k_ptr->tval == j)
489 if (n1) k_ptr->d_attr = n1;
490 if (n2) k_ptr->d_char = n2;
497 /* Process "E:<tv>:<a>" -- attribute for inventory objects */
499 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) == 2)
501 j = (byte)strtol(zz[0], NULL, 0) % 128;
502 n1 = (TERM_COLOR)strtol(zz[1], NULL, 0);
503 if (n1) tval_to_attr[j] = n1;
508 /* Process "A:<str>" -- save an "action" for later */
510 text_to_ascii(macro__buf, buf+2);
513 /* Process "P:<str>" -- normal macro */
518 text_to_ascii(tmp, buf+2);
519 macro_add(tmp, macro__buf);
523 /* Process "C:<str>" -- create keymap */
529 if (tokenize(buf+2, 2, zz, TOKENIZE_CHECKQUOTE) != 2) return 1;
531 mode = strtol(zz[0], NULL, 0);
532 if ((mode < 0) || (mode >= KEYMAP_MODES)) return 1;
534 text_to_ascii(tmp, zz[1]);
535 if (!tmp[0] || tmp[1]) return 1;
538 string_free(keymap_act[mode][i]);
540 keymap_act[mode][i] = string_make(macro__buf);
545 /* Process "V:<num>:<kv>:<rv>:<gv>:<bv>" -- visual info */
547 if (tokenize(buf+2, 5, zz, TOKENIZE_CHECKQUOTE) == 5)
549 i = (byte)strtol(zz[0], NULL, 0);
550 angband_color_table[i][0] = (byte)strtol(zz[1], NULL, 0);
551 angband_color_table[i][1] = (byte)strtol(zz[2], NULL, 0);
552 angband_color_table[i][2] = (byte)strtol(zz[3], NULL, 0);
553 angband_color_table[i][3] = (byte)strtol(zz[4], NULL, 0);
558 /* Process "X:<str>" -- turn option off */
559 /* Process "Y:<str>" -- turn option on */
562 for (i = 0; option_info[i].o_desc; i++)
564 if (option_info[i].o_var &&
565 option_info[i].o_text &&
566 streq(option_info[i].o_text, buf + 2))
568 int os = option_info[i].o_set;
569 int ob = option_info[i].o_bit;
571 if ((p_ptr->playing || character_xtra) &&
572 (OPT_PAGE_BIRTH == option_info[i].o_page) && !p_ptr->wizard)
574 msg_format(_("初期オプションは変更できません! '%s'", "Birth options can not changed! '%s'"), buf);
582 option_flag[os] &= ~(1L << ob);
583 (*option_info[i].o_var) = FALSE;
588 option_flag[os] |= (1L << ob);
589 (*option_info[i].o_var) = TRUE;
595 /* don't know that option. ignore it.*/
596 msg_format(_("オプションの名前が正しくありません: %s", "Ignored invalid option: %s"), buf);
600 /* Process "Z:<type>:<str>" -- set spell color */
604 char *t = my_strchr(buf + 2, ':');
612 for (i = 0; gf_desc[i].name; i++)
614 /* Match this type */
615 if (streq(gf_desc[i].name, buf + 2))
617 /* Remember this color set */
618 gf_color[gf_desc[i].num] = quark_add(t);
628 /* Initialize macro trigger names and a template */
629 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
630 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
633 int tok = tokenize(buf+2, 2+MAX_MACRO_MOD, zz, 0);
635 /* Process "T:<template>:<modifier chr>:<modifier name>:..." */
640 if (macro_template != NULL)
642 num = strlen(macro_modifier_chr);
644 /* Kill the template string */
645 string_free(macro_template);
646 macro_template = NULL;
648 /* Kill flag characters of modifier keys */
649 string_free(macro_modifier_chr);
651 /* Kill corresponding modifier names */
652 for (i = 0; i < num; i++)
654 string_free(macro_modifier_name[i]);
657 /* Kill trigger name strings */
658 for (i = 0; i < max_macrotrigger; i++)
660 string_free(macro_trigger_name[i]);
661 string_free(macro_trigger_keycode[0][i]);
662 string_free(macro_trigger_keycode[1][i]);
665 max_macrotrigger = 0;
668 if (*zz[0] == '\0') return 0; /* clear template */
670 /* Number of modifier flags */
673 /* Limit the number */
674 num = MIN(MAX_MACRO_MOD, num);
676 /* Stop if number of modifier is not correct */
677 if (2 + num != tok) return 1;
679 /* Get a template string */
680 macro_template = string_make(zz[0]);
682 /* Get flag characters of modifier keys */
683 macro_modifier_chr = string_make(zz[1]);
685 /* Get corresponding modifier names */
686 for (i = 0; i < num; i++)
688 macro_modifier_name[i] = string_make(zz[2+i]);
692 /* Process "T:<trigger>:<keycode>:<shift-keycode>" */
698 if (max_macrotrigger >= MAX_MACRO_TRIG)
700 msg_print(_("マクロトリガーの設定が多すぎます!", "Too many macro triggers!"));
703 m = max_macrotrigger;
706 /* Take into account the escape character */
716 /* Get a trigger name */
717 macro_trigger_name[m] = string_make(buf_aux);
719 /* Get the corresponding key code */
720 macro_trigger_keycode[0][m] = string_make(zz[1]);
724 /* Key code of a combination of it with the shift key */
725 macro_trigger_keycode[1][m] = string_make(zz[2]);
729 macro_trigger_keycode[1][m] = string_make(zz[1]);
744 * @brief process_pref_fileのサブルーチンとして条件分岐処理の解釈と結果を返す /
745 * Helper function for "process_pref_file()"
746 * @param sp テキスト文字列の参照ポインタ
747 * @param fp 再帰中のポインタ参照
752 * v: output buffer array
758 cptr process_pref_file_expr(char **sp, char *fp)
775 while (iswspace(*s)) s++;
793 t = process_pref_file_expr(&s, &f);
802 else if (streq(t, "IOR"))
805 while (*s && (f != b2))
807 t = process_pref_file_expr(&s, &f);
808 if (*t && !streq(t, "0")) v = "1";
813 else if (streq(t, "AND"))
816 while (*s && (f != b2))
818 t = process_pref_file_expr(&s, &f);
819 if (*t && streq(t, "0")) v = "0";
824 else if (streq(t, "NOT"))
827 while (*s && (f != b2))
829 t = process_pref_file_expr(&s, &f);
830 if (*t && streq(t, "1")) v = "0";
835 else if (streq(t, "EQU"))
840 t = process_pref_file_expr(&s, &f);
842 while (*s && (f != b2))
844 p = process_pref_file_expr(&s, &f);
845 if (streq(t, p)) v = "1";
850 else if (streq(t, "LEQ"))
855 t = process_pref_file_expr(&s, &f);
857 while (*s && (f != b2))
860 t = process_pref_file_expr(&s, &f);
861 if (*t && atoi(p) > atoi(t)) v = "0";
866 else if (streq(t, "GEQ"))
871 t = process_pref_file_expr(&s, &f);
873 while (*s && (f != b2))
876 t = process_pref_file_expr(&s, &f);
878 /* Compare two numbers instead of string */
879 if (*t && atoi(p) < atoi(t)) 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 */
904 while (iskanji(*s) || (isprint(*s) && !my_strchr(" []", *s)))
906 if (iskanji(*s)) s++;
910 while (isprint(*s) && !my_strchr(" []", *s)) ++s;
913 /* Extract final and Terminate */
914 if ((f = *s) != '\0') *s++ = '\0';
920 if (streq(b+1, "SYS"))
925 else if (streq(b+1, "KEYBOARD"))
927 v = ANGBAND_KEYBOARD;
931 else if (streq(b+1, "GRAF"))
936 /* Monochrome mode */
937 else if (streq(b+1, "MONOCHROME"))
946 else if (streq(b+1, "RACE"))
956 else if (streq(b+1, "CLASS"))
966 else if (streq(b+1, "PLAYER"))
968 static char tmp_player_name[32];
970 for (pn = p_ptr->name, tpn = tmp_player_name; *pn; pn++, tpn++)
980 *tpn = my_strchr(" []", *pn) ? '_' : *pn;
987 else if (streq(b+1, "REALM1"))
990 v = E_realm_names[p_ptr->realm1];
992 v = realm_names[p_ptr->realm1];
997 else if (streq(b+1, "REALM2"))
1000 v = E_realm_names[p_ptr->realm2];
1002 v = realm_names[p_ptr->realm2];
1007 else if (streq(b+1, "LEVEL"))
1009 sprintf(tmp, "%02d", p_ptr->lev);
1013 /* Autopick auto-register is in-use or not? */
1014 else if (streq(b+1, "AUTOREGISTER"))
1016 if (p_ptr->autopick_autoregister)
1023 else if (streq(b+1, "MONEY"))
1025 sprintf(tmp, "%09ld", (long int)p_ptr->au);
1048 #define PREF_TYPE_NORMAL 0
1049 #define PREF_TYPE_AUTOPICK 1
1050 #define PREF_TYPE_HISTPREF 2
1053 * @brief process_pref_fileのサブルーチン /
1054 * Open the "user pref file" and parse it.
1055 * @param name 読み込むファイル名
1056 * @param preftype prefファイルのタイプ
1061 * v: output buffer array
1062 * f: final character
1067 static errr process_pref_file_aux(cptr name, int preftype)
1079 bool bypass = FALSE;
1083 fp = my_fopen(name, "r");
1086 if (!fp) return (-1);
1088 /* Process the file */
1089 while (0 == my_fgets(fp, buf, sizeof(buf)))
1094 /* Skip "empty" lines */
1095 if (!buf[0]) continue;
1097 /* Skip "blank" lines */
1099 if (!iskanji(buf[0]))
1101 if (iswspace(buf[0])) continue;
1104 if (buf[0] == '#') continue;
1111 /* Process "?:<expr>" */
1112 if ((buf[0] == '?') && (buf[1] == ':'))
1121 /* Parse the expr */
1122 v = process_pref_file_expr(&s, &f);
1125 bypass = (streq(v, "0") ? TRUE : FALSE);
1131 /* Apply conditionals */
1132 if (bypass) continue;
1135 /* Process "%:<file>" */
1138 static int depth_count = 0;
1140 /* Ignore if deeper than 20 level */
1141 if (depth_count > 20) continue;
1143 /* Count depth level */
1146 /* Process that file if allowed */
1149 case PREF_TYPE_AUTOPICK:
1150 (void)process_autopick_file(buf + 2);
1152 case PREF_TYPE_HISTPREF:
1153 (void)process_histpref_file(buf + 2);
1156 (void)process_pref_file(buf + 2);
1160 /* Set back depth level */
1168 /* Process the line */
1169 err = process_pref_file_command(buf);
1171 /* This is not original pref line... */
1174 if (preftype != PREF_TYPE_AUTOPICK)
1176 err = process_autopick_file_command(buf);
1184 /* Print error message */
1185 /* ToDo: Add better error messages */
1186 msg_format(_("ファイル'%s'の%d行でエラー番号%dのエラー。", "Error %d in line %d of file '%s'."),
1187 _(name, err), line, _(err, name));
1188 msg_format(_("('%s'を解析中)", "Parsing '%s'"), old);
1192 /* Close the file */
1201 * @brief pref設定ファイルを読み込み設定を反映させる /
1202 * Process the "user pref file" with the given name
1203 * @param name 読み込むファイル名
1207 * See the functions above for a list of legal "commands".
1208 * We also accept the special "?" and "%" directives, which
1209 * allow conditional evaluation and filename inclusion.
1212 errr process_pref_file(cptr name)
1218 /* Build the filename */
1219 path_build(buf, sizeof(buf), ANGBAND_DIR_PREF, name);
1221 /* Process the system pref file */
1222 err1 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1224 /* Stop at parser errors, but not at non-existing file */
1225 if (err1 > 0) return err1;
1228 /* Build the filename */
1229 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
1231 /* Process the user pref file */
1232 err2 = process_pref_file_aux(buf, PREF_TYPE_NORMAL);
1235 /* User file does not exist, but read system pref file */
1236 if (err2 < 0 && !err1)
1239 /* Result of user file processing */
1248 * Operating hours for ANGBAND (defaults to non-work hours)
1250 static char days[7][29] =
1252 "SUN:XXXXXXXXXXXXXXXXXXXXXXXX",
1253 "MON:XXXXXXXX.........XXXXXXX",
1254 "TUE:XXXXXXXX.........XXXXXXX",
1255 "WED:XXXXXXXX.........XXXXXXX",
1256 "THU:XXXXXXXX.........XXXXXXX",
1257 "FRI:XXXXXXXX.........XXXXXXX",
1258 "SAT:XXXXXXXXXXXXXXXXXXXXXXXX"
1262 * Restict usage (defaults to no restrictions)
1264 static bool check_time_flag = FALSE;
1270 * @brief Angbandプレイ禁止時刻をチェック /
1274 errr check_time(void)
1282 /* No restrictions */
1283 if (!check_time_flag) return (0);
1285 /* Check for time violation */
1286 c = time((time_t *)0);
1290 if (days[tp->tm_wday][tp->tm_hour + 4] != 'X') return (1);
1300 * @brief Angbandプレイ禁止時刻の初期化 /
1301 * Initialize CHECK_TIME
1304 errr check_time_init(void)
1314 /* Build the filename */
1315 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "time.txt");
1318 fp = my_fopen(buf, "r");
1320 /* No file, no restrictions */
1321 if (!fp) return (0);
1323 /* Assume restrictions */
1324 check_time_flag = TRUE;
1326 /* Parse the file */
1327 while (0 == my_fgets(fp, buf, sizeof(buf)))
1329 /* Skip comments and blank lines */
1330 if (!buf[0] || (buf[0] == '#')) continue;
1332 /* Chop the buffer */
1335 /* Extract the info */
1336 if (prefix(buf, "SUN:")) strcpy(days[0], buf);
1337 if (prefix(buf, "MON:")) strcpy(days[1], buf);
1338 if (prefix(buf, "TUE:")) strcpy(days[2], buf);
1339 if (prefix(buf, "WED:")) strcpy(days[3], buf);
1340 if (prefix(buf, "THU:")) strcpy(days[4], buf);
1341 if (prefix(buf, "FRI:")) strcpy(days[5], buf);
1342 if (prefix(buf, "SAT:")) strcpy(days[6], buf);
1358 #ifndef MAXHOSTNAMELEN
1359 # define MAXHOSTNAMELEN 64
1362 typedef struct statstime statstime;
1368 unsigned int v_pgpgin;
1369 unsigned int v_pgpgout;
1370 unsigned int v_pswpin;
1371 unsigned int v_pswpout;
1372 unsigned int v_intr;
1378 unsigned int v_swtch;
1380 struct timeval boottime;
1381 struct timeval curtime;
1385 * Maximal load (if any).
1387 static int check_load_value = 0;
1393 * @brief Angbandプレイ禁止ホストのチェック /
1397 errr check_load(void)
1402 struct statstime st;
1404 /* Success if not checking */
1405 if (!check_load_value) return (0);
1407 /* Check the load */
1408 if (0 == rstat("localhost", &st))
1410 long val1 = (long)(st.avenrun[2]);
1411 long val2 = (long)(check_load_value) * FSCALE;
1413 /* Check for violation */
1414 if (val1 >= val2) return (1);
1425 * @brief Angbandプレイ禁止ホストの設定初期化 /
1426 * Initialize CHECK_LOAD
1429 errr check_load_init(void)
1438 char temphost[MAXHOSTNAMELEN+1];
1439 char thishost[MAXHOSTNAMELEN+1];
1442 /* Build the filename */
1443 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "load.txt");
1445 /* Open the "load" file */
1446 fp = my_fopen(buf, "r");
1448 /* No file, no restrictions */
1449 if (!fp) return (0);
1452 check_load_value = 100;
1454 /* Get the host name */
1455 (void)gethostname(thishost, (sizeof thishost) - 1);
1458 while (0 == my_fgets(fp, buf, sizeof(buf)))
1462 /* Skip comments and blank lines */
1463 if (!buf[0] || (buf[0] == '#')) continue;
1465 /* Parse, or ignore */
1466 if (sscanf(buf, "%s%d", temphost, &value) != 2) continue;
1468 /* Skip other hosts */
1469 if (!streq(temphost, thishost) &&
1470 !streq(temphost, "localhost")) continue;
1472 /* Use that value */
1473 check_load_value = value;
1479 /* Close the file */
1489 #define ENTRY_BARE_HAND 0
1490 #define ENTRY_TWO_HANDS 1
1491 #define ENTRY_RIGHT_HAND1 2
1492 #define ENTRY_LEFT_HAND1 3
1493 #define ENTRY_LEFT_HAND2 4
1494 #define ENTRY_RIGHT_HAND2 5
1495 #define ENTRY_POSTURE 6
1496 #define ENTRY_SHOOT_HIT_DAM 7
1497 #define ENTRY_SHOOT_POWER 8
1498 #define ENTRY_SPEED 9
1499 #define ENTRY_BASE_AC 10
1500 #define ENTRY_LEVEL 11
1501 #define ENTRY_CUR_EXP 12
1502 #define ENTRY_MAX_EXP 13
1503 #define ENTRY_EXP_TO_ADV 14
1504 #define ENTRY_GOLD 15
1505 #define ENTRY_DAY 16
1508 #define ENTRY_PLAY_TIME 19
1509 #define ENTRY_SKILL_FIGHT 20
1510 #define ENTRY_SKILL_SHOOT 21
1511 #define ENTRY_SKILL_SAVING 22
1512 #define ENTRY_SKILL_STEALTH 23
1513 #define ENTRY_SKILL_PERCEP 24
1514 #define ENTRY_SKILL_SEARCH 25
1515 #define ENTRY_SKILL_DISARM 26
1516 #define ENTRY_SKILL_DEVICE 27
1517 #define ENTRY_SKILL_DIG 45
1520 #define ENTRY_BLOWS 28
1521 #define ENTRY_SHOTS 29
1522 #define ENTRY_AVG_DMG 30
1523 #define ENTRY_INFRA 31
1525 #define ENTRY_NAME 32
1526 #define ENTRY_SEX 33
1527 #define ENTRY_RACE 34
1528 #define ENTRY_CLASS 35
1529 #define ENTRY_REALM 36
1530 #define ENTRY_PATRON 37
1531 #define ENTRY_AGE 38
1532 #define ENTRY_HEIGHT 39
1533 #define ENTRY_WEIGHT 40
1534 #define ENTRY_SOCIAL 41
1535 #define ENTRY_ALIGN 42
1537 #define ENTRY_EXP_ANDR 43
1538 #define ENTRY_EXP_TO_ADV_ANDR 44
1547 } disp_player_line[]
1550 { 1, 10, 25, "打撃修正(格闘)"},
1551 { 1, 10, 25, "打撃修正(両手)"},
1552 { 1, 10, 25, "打撃修正(右手)"},
1553 { 1, 10, 25, "打撃修正(左手)"},
1554 { 1, 11, 25, "打撃修正(左手)"},
1555 { 1, 11, 25, "打撃修正(右手)"},
1557 { 1, 15, 25, "射撃攻撃修正"},
1558 { 1, 16, 25, "射撃武器倍率"},
1561 {29, 13, 21, "レベル"},
1562 {29, 14, 21, "経験値"},
1563 {29, 15, 21, "最大経験"},
1564 {29, 16, 21, "次レベル"},
1565 {29, 17, 21, "所持金"},
1569 {29, 20, 21, "プレイ時間"},
1570 {53, 10, -1, "打撃命中 :"},
1571 {53, 11, -1, "射撃命中 :"},
1572 {53, 12, -1, "魔法防御 :"},
1573 {53, 13, -1, "隠密行動 :"},
1574 {53, 15, -1, "知覚 :"},
1575 {53, 16, -1, "探索 :"},
1576 {53, 17, -1, "解除 :"},
1577 {53, 18, -1, "魔法道具 :"},
1578 { 1, 12, 25, "打撃回数"},
1579 { 1, 17, 25, "射撃回数"},
1580 { 1, 13, 25, "平均ダメージ"},
1581 {53, 20, -1, "赤外線視力:"},
1582 {26, 1, -1, "名前 : "},
1583 { 1, 3, -1, "性別 : "},
1584 { 1, 4, -1, "種族 : "},
1585 { 1, 5, -1, "職業 : "},
1586 { 1, 6, -1, "魔法 : "},
1587 { 1, 7, -1, "守護魔神 : "},
1591 {29, 6, 21, "社会的地位"},
1593 {29, 14, 21, "強化度"},
1594 {29, 16, 21, "次レベル"},
1595 {53, 19, -1, "掘削 :" },
1599 { 1, 10, 25, "Bare hand"},
1600 { 1, 10, 25, "Two hands"},
1601 { 1, 10, 25, "Right hand"},
1602 { 1, 10, 25, "Left hand"},
1603 { 1, 11, 25, "Left hand"},
1604 { 1, 11, 25, "Right hand"},
1605 { 1, 11, 25, "Posture"},
1606 { 1, 15, 25, "Shooting"},
1607 { 1, 16, 25, "Multiplier"},
1608 { 1, 20, 25, "Speed"},
1610 {29, 13, 21, "Level"},
1611 {29, 14, 21, "Experience"},
1612 {29, 15, 21, "Max Exp"},
1613 {29, 16, 21, "Exp to Adv"},
1614 {29, 17, 21, "Gold"},
1615 {29, 19, 21, "Time"},
1616 {29, 10, 21, "Hit point"},
1617 {29, 11, 21, "SP (Mana)"},
1618 {29, 20, 21, "Play time"},
1619 {53, 10, -1, "Fighting : "},
1620 {53, 11, -1, "Bows/Throw : "},
1621 {53, 12, -1, "SavingThrow: "},
1622 {53, 13, -1, "Stealth : "},
1623 {53, 15, -1, "Perception : "},
1624 {53, 16, -1, "Searching : "},
1625 {53, 17, -1, "Disarming : "},
1626 {53, 18, -1, "MagicDevice: "},
1627 { 1, 12, 25, "Blows/Round"},
1628 { 1, 17, 25, "Shots/Round"},
1629 { 1, 13, 25, "AverageDmg/Rnd"},
1630 {53, 20, -1, "Infra-Vision: "},
1631 {26, 1, -1, "Name : "},
1632 { 1, 3, -1, "Sex : "},
1633 { 1, 4, -1, "Race : "},
1634 { 1, 5, -1, "Class : "},
1635 { 1, 6, -1, "Magic : "},
1636 { 1, 7, -1, "Patron : "},
1638 {29, 4, 21, "Height"},
1639 {29, 5, 21, "Weight"},
1640 {29, 6, 21, "Social Class"},
1641 {29, 7, 21, "Align"},
1642 {29, 14, 21, "Construction"},
1643 {29, 16, 21, "Const to Adv"},
1644 {53, 19, -1, "Digging :" },
1649 * @brief プレイヤーのステータス1種を出力する
1651 * @param val 値を保管した文字列ポインタ
1652 * @param attr 項目表示の色
1655 static void display_player_one_line(int entry, cptr val, byte attr)
1659 int row = disp_player_line[entry].row;
1660 int col = disp_player_line[entry].col;
1661 int len = disp_player_line[entry].len;
1662 cptr head = disp_player_line[entry].header;
1664 int head_len = strlen(head);
1666 Term_putstr(col, row, -1, TERM_WHITE, head);
1673 int val_len = len - head_len;
1674 sprintf(buf, "%*.*s", val_len, val_len, val);
1675 Term_putstr(col + head_len, row, -1, attr, buf);
1679 Term_putstr(col + head_len, row, -1, attr, val);
1686 * @brief プレイヤーの打撃能力修正を表示する
1687 * @param hand 武器の装備部位ID
1688 * @param hand_entry 項目ID
1691 static void display_player_melee_bonus(int hand, int hand_entry)
1694 int show_tohit = p_ptr->dis_to_h[hand];
1695 int show_todam = p_ptr->dis_to_d[hand];
1696 object_type *o_ptr = &inventory[INVEN_RARM + hand];
1698 /* Hack -- add in weapon info if known */
1699 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1700 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1702 show_tohit += p_ptr->skill_thn / BTH_PLUS_ADJ;
1705 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1707 /* Dump the bonuses to hit/dam */
1708 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1709 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1710 else if (p_ptr->ryoute)
1711 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1713 display_player_one_line(hand_entry, buf, TERM_L_BLUE);
1718 * @brief プレイヤーステータス表示の中央部分を表示するサブルーチン
1719 * Prints the following information on the screen.
1722 static void display_player_middle(void)
1727 int show_tohit = p_ptr->dis_to_h_b;
1731 object_type *o_ptr = &inventory[INVEN_BOW];
1738 display_player_melee_bonus(0, left_hander ? ENTRY_LEFT_HAND1 : ENTRY_RIGHT_HAND1);
1741 if (p_ptr->hidarite)
1743 display_player_melee_bonus(1, left_hander ? ENTRY_RIGHT_HAND2: ENTRY_LEFT_HAND2);
1745 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
1748 if (p_ptr->special_defense & KAMAE_MASK)
1750 for (i = 0; i < MAX_KAMAE; i++)
1752 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1755 display_player_one_line(ENTRY_POSTURE, format(_("%sの構え", "%s form"), kamae_shurui[i].desc), TERM_YELLOW);
1758 display_player_one_line(ENTRY_POSTURE, _("構えなし", "none"), TERM_YELLOW);
1761 /* Apply weapon bonuses */
1762 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1763 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1765 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1766 show_tohit += p_ptr->weapon_exp[0][o_ptr->sval] / 400;
1768 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
1770 show_tohit += p_ptr->skill_thb / BTH_PLUS_ADJ;
1773 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1775 if (inventory[INVEN_BOW].k_idx)
1777 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1779 /* Get extra "power" from "extra might" */
1780 if (p_ptr->xtra_might) tmul++;
1782 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1786 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1788 /* Dump the armor class */
1789 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1797 i = p_ptr->pspeed-110;
1799 /* Hack -- Visually "undo" the Search Mode Slowdown */
1800 if (p_ptr->action == ACTION_SEARCH) i += 10;
1805 attr = TERM_L_GREEN;
1819 attr = TERM_L_UMBER;
1826 if (IS_FAST()) tmp_speed += 10;
1827 if (p_ptr->slow) tmp_speed -= 10;
1828 if (p_ptr->lightspeed) tmp_speed = 99;
1832 if (MON_FAST(&m_list[p_ptr->riding])) tmp_speed += 10;
1833 if (MON_SLOW(&m_list[p_ptr->riding])) tmp_speed -= 10;
1839 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1841 sprintf(buf, _("乗馬中 (%+d%+d)", "Riding (%+d%+d)"), i-tmp_speed, tmp_speed);
1851 sprintf(buf, "(%+d)", i);
1853 sprintf(buf, _("乗馬中 (%+d)", "Riding (%+d)"), i);
1856 display_player_one_line(ENTRY_SPEED, buf, attr);
1859 /* Dump character level */
1860 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1862 /* Dump experience */
1863 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1864 else e = ENTRY_CUR_EXP;
1866 if (p_ptr->exp >= p_ptr->max_exp)
1867 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1869 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1871 /* Dump max experience */
1872 if (p_ptr->prace == RACE_ANDROID)
1875 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1877 /* Dump exp to advance */
1878 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
1879 else e = ENTRY_EXP_TO_ADV;
1881 if (p_ptr->lev >= PY_MAX_LEVEL)
1882 display_player_one_line(e, "*****", TERM_L_GREEN);
1883 else if (p_ptr->prace == RACE_ANDROID)
1884 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1886 display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1889 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1894 extract_day_hour_min(&day, &hour, &min);
1896 if (day < MAX_DAYS) sprintf(buf, _("%d日目 %2d:%02d", "Day %d %2d:%02d"), day, hour, min);
1897 else sprintf(buf, _("*****日目 %2d:%02d", "Day ***** %2d:%02d"), hour, min);
1899 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1901 /* Dump hit point */
1902 if (p_ptr->chp >= p_ptr->mhp)
1903 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1904 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1905 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1907 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1909 /* Dump mana power */
1910 if (p_ptr->csp >= p_ptr->msp)
1911 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1912 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
1913 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1915 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1917 /* Dump play time */
1918 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1923 * Hack -- pass color info around this file
1925 static byte likert_color = TERM_WHITE;
1929 * @brief 技能ランクの表示基準を定める
1930 * Returns a "rating" of x depending on y
1932 * @param y 技能値に対するランク基準比
1935 static cptr likert(int x, int y)
1937 static char dummy[20] = "", dummy2[20] = "";
1938 memset(dummy, 0, strlen(dummy));
1939 memset(dummy2, 0, strlen(dummy2));
1944 if(show_actual_value)
1946 sprintf(dummy, "%3d-", x);
1949 /* Negative value */
1952 likert_color = TERM_L_DARK;
1953 strcat(dummy, _("最低", "Very Bad"));
1958 /* Analyze the value */
1963 likert_color = TERM_RED;
1964 strcat(dummy, _("悪い", "Bad"));
1967 likert_color = TERM_L_RED;
1968 strcat(dummy, _("劣る", "Poor"));
1973 likert_color = TERM_ORANGE;
1974 strcat(dummy, _("普通", "Fair"));
1978 likert_color = TERM_YELLOW;
1979 strcat(dummy, _("良い", "Good"));
1983 likert_color = TERM_YELLOW;
1984 strcat(dummy, _("大変良い", "Very Good"));
1989 likert_color = TERM_L_GREEN;
1990 strcat(dummy, _("卓越", "Excellent"));
1998 likert_color = TERM_GREEN;
1999 strcat(dummy, _("超越", "Superb"));
2006 likert_color = TERM_BLUE;
2007 strcat(dummy, _("英雄的", "Heroic"));
2011 likert_color = TERM_VIOLET;
2012 sprintf(dummy2, _("伝説的[%d]", "Legendary[%d]"),
2013 (int)((((x / y) - 17) * 5) / 2));
2014 strcat(dummy, dummy2);
2025 * @brief プレイヤーステータスの1ページ目各種詳細をまとめて表示するサブルーチン
2026 * Prints ratings on certain abilities
2029 * This code is "imitated" elsewhere to "dump" a character sheet.
2031 static void display_player_various(void)
2033 int tmp, damage[2], to_h[2], blows1, blows2, i, basedam;
2034 int xthn, xthb, xfos, xsrh;
2035 int xdis, xdev, xsav, xstl;
2039 u32b flgs[TR_FLAG_SIZE];
2040 int shots, shot_frac;
2045 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2046 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2047 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2048 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2049 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2051 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2053 /* Shooting Skill (with current bow and normal missile) */
2054 o_ptr = &inventory[INVEN_BOW];
2055 tmp = p_ptr->to_h_b + o_ptr->to_h;
2056 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2058 /* If the player is wielding one? */
2061 ENERGY energy_fire = bow_energy(o_ptr->sval);
2063 /* Calculate shots per round */
2064 shots = p_ptr->num_fire * 100;
2065 shot_frac = (shots * 100 / energy_fire) % 100;
2066 shots = shots / energy_fire;
2067 if (o_ptr->name1 == ART_CRIMSON)
2071 if (p_ptr->pclass == CLASS_ARCHER)
2073 /* Extra shot at level 10 */
2074 if (p_ptr->lev >= 10) shots++;
2076 /* Extra shot at level 30 */
2077 if (p_ptr->lev >= 30) shots++;
2079 /* Extra shot at level 45 */
2080 if (p_ptr->lev >= 45) shots++;
2090 for(i = 0; i < 2; i++)
2092 damage[i] = p_ptr->dis_to_d[i] * 100;
2093 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
2095 PLAYER_LEVEL level = p_ptr->lev;
2101 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2102 if (p_ptr->special_defense & KAMAE_BYAKKO)
2103 basedam = monk_ave_damage[level][1];
2104 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2105 basedam = monk_ave_damage[level][2];
2107 basedam = monk_ave_damage[level][0];
2111 o_ptr = &inventory[INVEN_RARM + i];
2113 /* Average damage per round */
2119 if((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) dokubari = TRUE;
2120 if (object_is_known(o_ptr))
2122 damage[i] += o_ptr->to_d * 100;
2123 to_h[i] += o_ptr->to_h;
2125 basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
2126 object_flags_known(o_ptr, flgs);
2128 basedam = calc_expect_crit(o_ptr->weight, to_h[i], basedam, p_ptr->dis_to_h[i], dokubari);
2129 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2135 else if (have_flag(flgs, TR_VORPAL))
2137 /* vorpal flag only */
2141 if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2142 basedam = basedam * 7 / 2;
2146 damage[i] += basedam;
2147 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2148 if (damage[i] < 0) damage[i] = 0;
2150 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2151 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2153 /* Basic abilities */
2155 xdis = p_ptr->skill_dis;
2156 xdev = p_ptr->skill_dev;
2157 xsav = p_ptr->skill_sav;
2158 xstl = p_ptr->skill_stl;
2159 xsrh = p_ptr->skill_srh;
2160 xfos = p_ptr->skill_fos;
2161 xdig = p_ptr->skill_dig;
2164 desc = likert(xthn, 12);
2165 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2167 desc = likert(xthb, 12);
2168 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2170 desc = likert(xsav, 7);
2171 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2173 /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
2174 desc = likert((xstl > 0) ? xstl : -1, 1);
2175 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2177 desc = likert(xfos, 6);
2178 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2180 desc = likert(xsrh, 6);
2181 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2183 desc = likert(xdis, 8);
2184 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2186 desc = likert(xdev, 6);
2187 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2189 desc = likert(xdev, 6);
2190 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2192 desc = likert(xdig, 4);
2193 display_player_one_line(ENTRY_SKILL_DIG, desc, likert_color);
2196 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2198 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2200 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2203 if ((damage[0]+damage[1]) == 0)
2206 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2208 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2210 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2216 * @brief プレイヤーの職業、種族に応じた耐性フラグを返す
2217 * Prints ratings on certain abilities
2218 * @param flgs フラグを保管する配列
2221 * Obtain the "flags" for the player as if he was an item
2223 * xtra1.c周りと多重実装になっているのを何とかする
2225 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2230 for (i = 0; i < TR_FLAG_SIZE; i++)
2234 switch (p_ptr->pclass)
2237 if (p_ptr->lev > 44)
2238 add_flag(flgs, TR_REGEN);
2240 if (p_ptr->lev > 29)
2241 add_flag(flgs, TR_RES_FEAR);
2244 if (p_ptr->lev > 39)
2245 add_flag(flgs, TR_RES_FEAR);
2247 case CLASS_CHAOS_WARRIOR:
2248 if (p_ptr->lev > 29)
2249 add_flag(flgs, TR_RES_CHAOS);
2250 if (p_ptr->lev > 39)
2251 add_flag(flgs, TR_RES_FEAR);
2254 case CLASS_FORCETRAINER:
2255 if ((p_ptr->lev > 9) && !heavy_armor())
2256 add_flag(flgs, TR_SPEED);
2257 if ((p_ptr->lev>24) && !heavy_armor())
2258 add_flag(flgs, TR_FREE_ACT);
2262 add_flag(flgs, TR_SPEED);
2265 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
2266 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
2267 add_flag(flgs, TR_SPEED);
2269 add_flag(flgs, TR_FREE_ACT);
2271 add_flag(flgs, TR_SLOW_DIGEST);
2272 add_flag(flgs, TR_RES_FEAR);
2273 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2274 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2275 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2277 case CLASS_MINDCRAFTER:
2279 add_flag(flgs, TR_RES_FEAR);
2280 if (p_ptr->lev > 19)
2281 add_flag(flgs, TR_SUST_WIS);
2282 if (p_ptr->lev > 29)
2283 add_flag(flgs, TR_RES_CONF);
2284 if (p_ptr->lev > 39)
2285 add_flag(flgs, TR_TELEPATHY);
2288 add_flag(flgs, TR_RES_SOUND);
2290 case CLASS_BERSERKER:
2291 add_flag(flgs, TR_SUST_STR);
2292 add_flag(flgs, TR_SUST_DEX);
2293 add_flag(flgs, TR_SUST_CON);
2294 add_flag(flgs, TR_REGEN);
2295 add_flag(flgs, TR_FREE_ACT);
2296 add_flag(flgs, TR_SPEED);
2297 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2299 case CLASS_MIRROR_MASTER:
2300 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2303 break; /* Do nothing */
2307 if (p_ptr->mimic_form)
2309 switch(p_ptr->mimic_form)
2312 add_flag(flgs, TR_HOLD_EXP);
2313 add_flag(flgs, TR_RES_CHAOS);
2314 add_flag(flgs, TR_RES_NETHER);
2315 add_flag(flgs, TR_RES_FIRE);
2316 add_flag(flgs, TR_SEE_INVIS);
2317 add_flag(flgs, TR_SPEED);
2319 case MIMIC_DEMON_LORD:
2320 add_flag(flgs, TR_HOLD_EXP);
2321 add_flag(flgs, TR_RES_CHAOS);
2322 add_flag(flgs, TR_RES_NETHER);
2323 add_flag(flgs, TR_RES_FIRE);
2324 add_flag(flgs, TR_RES_COLD);
2325 add_flag(flgs, TR_RES_ELEC);
2326 add_flag(flgs, TR_RES_ACID);
2327 add_flag(flgs, TR_RES_POIS);
2328 add_flag(flgs, TR_RES_CONF);
2329 add_flag(flgs, TR_RES_DISEN);
2330 add_flag(flgs, TR_RES_NEXUS);
2331 add_flag(flgs, TR_RES_FEAR);
2332 add_flag(flgs, TR_IM_FIRE);
2333 add_flag(flgs, TR_SH_FIRE);
2334 add_flag(flgs, TR_SEE_INVIS);
2335 add_flag(flgs, TR_TELEPATHY);
2336 add_flag(flgs, TR_LEVITATION);
2337 add_flag(flgs, TR_SPEED);
2340 add_flag(flgs, TR_HOLD_EXP);
2341 add_flag(flgs, TR_RES_DARK);
2342 add_flag(flgs, TR_RES_NETHER);
2343 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE_1);
2344 add_flag(flgs, TR_RES_POIS);
2345 add_flag(flgs, TR_RES_COLD);
2346 add_flag(flgs, TR_SEE_INVIS);
2347 add_flag(flgs, TR_SPEED);
2353 switch (p_ptr->prace)
2356 add_flag(flgs, TR_RES_LITE);
2359 add_flag(flgs, TR_HOLD_EXP);
2362 add_flag(flgs, TR_FREE_ACT);
2365 add_flag(flgs, TR_RES_BLIND);
2368 add_flag(flgs, TR_RES_DARK);
2370 case RACE_HALF_TROLL:
2371 add_flag(flgs, TR_SUST_STR);
2372 if (p_ptr->lev > 14)
2374 add_flag(flgs, TR_REGEN);
2375 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
2377 add_flag(flgs, TR_SLOW_DIGEST);
2379 * Let's not make Regeneration a disadvantage
2380 * for the poor warriors who can never learn
2381 * a spell that satisfies hunger (actually
2382 * neither can rogues, but half-trolls are not
2383 * supposed to play rogues)
2389 add_flag(flgs, TR_SUST_CON);
2390 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2393 add_flag(flgs, TR_RES_LITE);
2394 add_flag(flgs, TR_SEE_INVIS);
2396 case RACE_BARBARIAN:
2397 add_flag(flgs, TR_RES_FEAR);
2399 case RACE_HALF_OGRE:
2400 add_flag(flgs, TR_SUST_STR);
2401 add_flag(flgs, TR_RES_DARK);
2403 case RACE_HALF_GIANT:
2404 add_flag(flgs, TR_RES_SHARDS);
2405 add_flag(flgs, TR_SUST_STR);
2407 case RACE_HALF_TITAN:
2408 add_flag(flgs, TR_RES_CHAOS);
2411 add_flag(flgs, TR_RES_SOUND);
2414 add_flag(flgs, TR_RES_ACID);
2415 if (p_ptr->lev > 19)
2416 add_flag(flgs, TR_IM_ACID);
2419 add_flag(flgs, TR_RES_CONF);
2420 add_flag(flgs, TR_RES_ACID);
2422 add_flag(flgs, TR_SPEED);
2425 add_flag(flgs, TR_RES_POIS);
2428 add_flag(flgs, TR_RES_DISEN);
2429 add_flag(flgs, TR_RES_DARK);
2432 add_flag(flgs, TR_RES_DARK);
2433 if (p_ptr->lev > 19)
2434 add_flag(flgs, TR_SEE_INVIS);
2436 case RACE_DRACONIAN:
2437 add_flag(flgs, TR_LEVITATION);
2439 add_flag(flgs, TR_RES_FIRE);
2441 add_flag(flgs, TR_RES_COLD);
2442 if (p_ptr->lev > 14)
2443 add_flag(flgs, TR_RES_ACID);
2444 if (p_ptr->lev > 19)
2445 add_flag(flgs, TR_RES_ELEC);
2446 if (p_ptr->lev > 34)
2447 add_flag(flgs, TR_RES_POIS);
2449 case RACE_MIND_FLAYER:
2450 add_flag(flgs, TR_SUST_INT);
2451 add_flag(flgs, TR_SUST_WIS);
2452 if (p_ptr->lev > 14)
2453 add_flag(flgs, TR_SEE_INVIS);
2454 if (p_ptr->lev > 29)
2455 add_flag(flgs, TR_TELEPATHY);
2458 add_flag(flgs, TR_RES_FIRE);
2460 add_flag(flgs, TR_SEE_INVIS);
2463 add_flag(flgs, TR_SEE_INVIS);
2464 add_flag(flgs, TR_FREE_ACT);
2465 add_flag(flgs, TR_RES_POIS);
2466 add_flag(flgs, TR_SLOW_DIGEST);
2467 if (p_ptr->lev > 34)
2468 add_flag(flgs, TR_HOLD_EXP);
2471 add_flag(flgs, TR_SEE_INVIS);
2472 add_flag(flgs, TR_RES_SHARDS);
2473 add_flag(flgs, TR_HOLD_EXP);
2474 add_flag(flgs, TR_RES_POIS);
2476 add_flag(flgs, TR_RES_COLD);
2479 add_flag(flgs, TR_SEE_INVIS);
2480 add_flag(flgs, TR_HOLD_EXP);
2481 add_flag(flgs, TR_RES_NETHER);
2482 add_flag(flgs, TR_RES_POIS);
2483 add_flag(flgs, TR_SLOW_DIGEST);
2485 add_flag(flgs, TR_RES_COLD);
2488 add_flag(flgs, TR_HOLD_EXP);
2489 add_flag(flgs, TR_RES_DARK);
2490 add_flag(flgs, TR_RES_NETHER);
2491 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE_1);
2492 add_flag(flgs, TR_RES_POIS);
2493 add_flag(flgs, TR_RES_COLD);
2496 add_flag(flgs, TR_LEVITATION);
2497 add_flag(flgs, TR_FREE_ACT);
2498 add_flag(flgs, TR_RES_COLD);
2499 add_flag(flgs, TR_SEE_INVIS);
2500 add_flag(flgs, TR_HOLD_EXP);
2501 add_flag(flgs, TR_RES_NETHER);
2502 add_flag(flgs, TR_RES_POIS);
2503 add_flag(flgs, TR_SLOW_DIGEST);
2505 if (p_ptr->lev > 34)
2506 add_flag(flgs, TR_TELEPATHY);
2509 add_flag(flgs, TR_RES_LITE);
2510 add_flag(flgs, TR_LEVITATION);
2512 add_flag(flgs, TR_SPEED);
2515 add_flag(flgs, TR_RES_SOUND);
2516 add_flag(flgs, TR_RES_CONF);
2519 add_flag(flgs, TR_LEVITATION);
2520 add_flag(flgs, TR_SEE_INVIS);
2523 add_flag(flgs, TR_RES_FIRE);
2524 add_flag(flgs, TR_RES_NETHER);
2525 add_flag(flgs, TR_HOLD_EXP);
2527 add_flag(flgs, TR_SEE_INVIS);
2530 add_flag(flgs, TR_SUST_CON);
2533 add_flag(flgs, TR_LEVITATION);
2536 add_flag(flgs, TR_RES_CONF);
2539 add_flag(flgs, TR_FREE_ACT);
2540 add_flag(flgs, TR_RES_POIS);
2541 add_flag(flgs, TR_SLOW_DIGEST);
2542 add_flag(flgs, TR_HOLD_EXP);
2552 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2554 remove_flag(flgs, TR_REGEN);
2557 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2558 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2559 (p_ptr->muta3 & MUT3_SHORT_LEG))
2561 add_flag(flgs, TR_SPEED);
2564 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2566 add_flag(flgs, TR_SH_ELEC);
2569 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2571 add_flag(flgs, TR_SH_FIRE);
2572 add_flag(flgs, TR_LITE_1);
2575 if (p_ptr->muta3 & MUT3_WINGS)
2577 add_flag(flgs, TR_LEVITATION);
2580 if (p_ptr->muta3 & MUT3_FEARLESS)
2582 add_flag(flgs, TR_RES_FEAR);
2585 if (p_ptr->muta3 & MUT3_REGEN)
2587 add_flag(flgs, TR_REGEN);
2590 if (p_ptr->muta3 & MUT3_ESP)
2592 add_flag(flgs, TR_TELEPATHY);
2595 if (p_ptr->muta3 & MUT3_MOTION)
2597 add_flag(flgs, TR_FREE_ACT);
2601 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2602 add_flag(flgs, TR_AGGRAVATE);
2603 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2605 add_flag(flgs, TR_RES_BLIND);
2606 add_flag(flgs, TR_RES_CONF);
2607 add_flag(flgs, TR_HOLD_EXP);
2608 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE_1);
2610 add_flag(flgs, TR_SPEED);
2612 if (p_ptr->special_defense & KATA_FUUJIN)
2613 add_flag(flgs, TR_REFLECT);
2614 if (p_ptr->special_defense & KAMAE_GENBU)
2615 add_flag(flgs, TR_REFLECT);
2616 if (p_ptr->special_defense & KAMAE_SUZAKU)
2617 add_flag(flgs, TR_LEVITATION);
2618 if (p_ptr->special_defense & KAMAE_SEIRYU)
2620 add_flag(flgs, TR_RES_FIRE);
2621 add_flag(flgs, TR_RES_COLD);
2622 add_flag(flgs, TR_RES_ACID);
2623 add_flag(flgs, TR_RES_ELEC);
2624 add_flag(flgs, TR_RES_POIS);
2625 add_flag(flgs, TR_LEVITATION);
2626 add_flag(flgs, TR_SH_FIRE);
2627 add_flag(flgs, TR_SH_ELEC);
2628 add_flag(flgs, TR_SH_COLD);
2630 if (p_ptr->special_defense & KATA_MUSOU)
2632 add_flag(flgs, TR_RES_FEAR);
2633 add_flag(flgs, TR_RES_LITE);
2634 add_flag(flgs, TR_RES_DARK);
2635 add_flag(flgs, TR_RES_BLIND);
2636 add_flag(flgs, TR_RES_CONF);
2637 add_flag(flgs, TR_RES_SOUND);
2638 add_flag(flgs, TR_RES_SHARDS);
2639 add_flag(flgs, TR_RES_NETHER);
2640 add_flag(flgs, TR_RES_NEXUS);
2641 add_flag(flgs, TR_RES_CHAOS);
2642 add_flag(flgs, TR_RES_DISEN);
2643 add_flag(flgs, TR_REFLECT);
2644 add_flag(flgs, TR_HOLD_EXP);
2645 add_flag(flgs, TR_FREE_ACT);
2646 add_flag(flgs, TR_SH_FIRE);
2647 add_flag(flgs, TR_SH_ELEC);
2648 add_flag(flgs, TR_SH_COLD);
2649 add_flag(flgs, TR_LEVITATION);
2650 add_flag(flgs, TR_LITE_1);
2651 add_flag(flgs, TR_SEE_INVIS);
2652 add_flag(flgs, TR_TELEPATHY);
2653 add_flag(flgs, TR_SLOW_DIGEST);
2654 add_flag(flgs, TR_REGEN);
2655 add_flag(flgs, TR_SUST_STR);
2656 add_flag(flgs, TR_SUST_INT);
2657 add_flag(flgs, TR_SUST_WIS);
2658 add_flag(flgs, TR_SUST_DEX);
2659 add_flag(flgs, TR_SUST_CON);
2660 add_flag(flgs, TR_SUST_CHR);
2665 * @brief プレイヤーの一時的魔法効果による耐性を返す
2666 * Prints ratings on certain abilities
2667 * @param flgs フラグを保管する配列
2670 * xtra1.c周りと多重実装になっているのを何とかする
2672 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
2677 for (i = 0; i < TR_FLAG_SIZE; i++)
2680 if (IS_HERO() || p_ptr->shero)
2681 add_flag(flgs, TR_RES_FEAR);
2682 if (p_ptr->tim_invis)
2683 add_flag(flgs, TR_SEE_INVIS);
2684 if (p_ptr->tim_regen)
2685 add_flag(flgs, TR_REGEN);
2687 add_flag(flgs, TR_TELEPATHY);
2688 if (IS_FAST() || p_ptr->slow)
2689 add_flag(flgs, TR_SPEED);
2691 if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
2692 add_flag(flgs, TR_RES_ACID);
2693 if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
2694 add_flag(flgs, TR_RES_ELEC);
2695 if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
2696 add_flag(flgs, TR_RES_FIRE);
2697 if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
2698 add_flag(flgs, TR_RES_COLD);
2699 if (IS_OPPOSE_POIS())
2700 add_flag(flgs, TR_RES_POIS);
2702 if (p_ptr->special_attack & ATTACK_ACID)
2703 add_flag(flgs, TR_BRAND_ACID);
2704 if (p_ptr->special_attack & ATTACK_ELEC)
2705 add_flag(flgs, TR_BRAND_ELEC);
2706 if (p_ptr->special_attack & ATTACK_FIRE)
2707 add_flag(flgs, TR_BRAND_FIRE);
2708 if (p_ptr->special_attack & ATTACK_COLD)
2709 add_flag(flgs, TR_BRAND_COLD);
2710 if (p_ptr->special_attack & ATTACK_POIS)
2711 add_flag(flgs, TR_BRAND_POIS);
2712 if (p_ptr->special_defense & DEFENSE_ACID)
2713 add_flag(flgs, TR_IM_ACID);
2714 if (p_ptr->special_defense & DEFENSE_ELEC)
2715 add_flag(flgs, TR_IM_ELEC);
2716 if (p_ptr->special_defense & DEFENSE_FIRE)
2717 add_flag(flgs, TR_IM_FIRE);
2718 if (p_ptr->special_defense & DEFENSE_COLD)
2719 add_flag(flgs, TR_IM_COLD);
2720 if (p_ptr->wraith_form)
2721 add_flag(flgs, TR_REFLECT);
2723 if (p_ptr->tim_reflect)
2724 add_flag(flgs, TR_REFLECT);
2726 if (p_ptr->magicdef)
2728 add_flag(flgs, TR_RES_BLIND);
2729 add_flag(flgs, TR_RES_CONF);
2730 add_flag(flgs, TR_REFLECT);
2731 add_flag(flgs, TR_FREE_ACT);
2732 add_flag(flgs, TR_LEVITATION);
2734 if (p_ptr->tim_res_nether)
2736 add_flag(flgs, TR_RES_NETHER);
2738 if (p_ptr->tim_sh_fire)
2740 add_flag(flgs, TR_SH_FIRE);
2744 add_flag(flgs, TR_RES_FEAR);
2745 add_flag(flgs, TR_RES_LITE);
2746 add_flag(flgs, TR_RES_DARK);
2747 add_flag(flgs, TR_RES_BLIND);
2748 add_flag(flgs, TR_RES_CONF);
2749 add_flag(flgs, TR_RES_SOUND);
2750 add_flag(flgs, TR_RES_SHARDS);
2751 add_flag(flgs, TR_RES_NETHER);
2752 add_flag(flgs, TR_RES_NEXUS);
2753 add_flag(flgs, TR_RES_CHAOS);
2754 add_flag(flgs, TR_RES_DISEN);
2755 add_flag(flgs, TR_REFLECT);
2756 add_flag(flgs, TR_HOLD_EXP);
2757 add_flag(flgs, TR_FREE_ACT);
2758 add_flag(flgs, TR_SH_FIRE);
2759 add_flag(flgs, TR_SH_ELEC);
2760 add_flag(flgs, TR_SH_COLD);
2761 add_flag(flgs, TR_LEVITATION);
2762 add_flag(flgs, TR_LITE_1);
2763 add_flag(flgs, TR_SEE_INVIS);
2764 add_flag(flgs, TR_TELEPATHY);
2765 add_flag(flgs, TR_SLOW_DIGEST);
2766 add_flag(flgs, TR_REGEN);
2767 add_flag(flgs, TR_SUST_STR);
2768 add_flag(flgs, TR_SUST_INT);
2769 add_flag(flgs, TR_SUST_WIS);
2770 add_flag(flgs, TR_SUST_DEX);
2771 add_flag(flgs, TR_SUST_CON);
2772 add_flag(flgs, TR_SUST_CHR);
2776 if (p_ptr->realm1 == REALM_HEX)
2778 if (hex_spelling(HEX_DEMON_AURA))
2780 add_flag(flgs, TR_SH_FIRE);
2781 add_flag(flgs, TR_REGEN);
2783 if (hex_spelling(HEX_ICE_ARMOR)) add_flag(flgs, TR_SH_COLD);
2784 if (hex_spelling(HEX_SHOCK_CLOAK)) add_flag(flgs, TR_SH_ELEC);
2789 /* Mode flags for displaying player flags */
2790 #define DP_CURSE 0x01
2796 * @brief プレイヤーの装備一覧をシンボルで並べる
2798 * @param y 表示するコンソールの行
2799 * @param x 表示するコンソールの列
2803 static void display_player_equippy(TERM_LEN y, TERM_LEN x, u16b mode)
2812 /* Weapon flags need only two column */
2813 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2814 else max_i = INVEN_TOTAL;
2816 /* Dump equippy chars */
2817 for (i = INVEN_RARM; i < max_i; i++)
2820 o_ptr = &inventory[i];
2822 a = object_attr(o_ptr);
2823 c = object_char(o_ptr);
2825 /* Clear the part of the screen */
2826 if (!equippy_chars || !o_ptr->k_idx)
2833 Term_putch(x + i - INVEN_RARM, y, a, c);
2839 * @brief プレイヤーの装備一覧シンボルを固定位置に表示する
2842 void print_equippy(void)
2844 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2848 * @brief プレイヤーの装備による免疫フラグを返す
2849 * @param flgs フラグを保管する配列
2852 * xtra1.c周りと多重実装になっているのを何とかする
2854 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2859 for (i = 0; i < TR_FLAG_SIZE; i++)
2862 /* Check equipment */
2863 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2865 u32b o_flgs[TR_FLAG_SIZE];
2870 o_ptr = &inventory[i];
2872 if (!o_ptr->k_idx) continue;
2875 object_flags_known(o_ptr, o_flgs);
2877 if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2878 if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2879 if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2880 if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2885 * @brief プレイヤーの種族による免疫フラグを返す
2886 * @param flgs フラグを保管する配列
2889 * xtra1.c周りと多重実装になっているのを何とかする
2891 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2896 for (i = 0; i < TR_FLAG_SIZE; i++)
2899 if (prace_is_(RACE_SPECTRE))
2900 add_flag(flgs, TR_RES_NETHER);
2901 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2902 add_flag(flgs, TR_RES_DARK);
2903 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2904 add_flag(flgs, TR_RES_FIRE);
2905 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2906 add_flag(flgs, TR_RES_ACID);
2910 * @brief プレイヤーの一時的魔法効果による免疫フラグを返す
2911 * @param flgs フラグを保管する配列
2914 * xtra1.c周りと多重実装になっているのを何とかする
2916 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2921 for (i = 0; i < TR_FLAG_SIZE; i++)
2924 if (p_ptr->special_defense & DEFENSE_ACID)
2925 add_flag(flgs, TR_RES_ACID);
2926 if (p_ptr->special_defense & DEFENSE_ELEC)
2927 add_flag(flgs, TR_RES_ELEC);
2928 if (p_ptr->special_defense & DEFENSE_FIRE)
2929 add_flag(flgs, TR_RES_FIRE);
2930 if (p_ptr->special_defense & DEFENSE_COLD)
2931 add_flag(flgs, TR_RES_COLD);
2932 if (p_ptr->wraith_form)
2933 add_flag(flgs, TR_RES_DARK);
2937 * @brief プレイヤーの種族による弱点フラグを返す
2938 * @param flgs フラグを保管する配列
2941 * xtra1.c周りと多重実装になっているのを何とかする
2943 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2948 for (i = 0; i < TR_FLAG_SIZE; i++)
2951 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2953 add_flag(flgs, TR_RES_ACID);
2954 add_flag(flgs, TR_RES_ELEC);
2955 add_flag(flgs, TR_RES_FIRE);
2956 add_flag(flgs, TR_RES_COLD);
2958 if (prace_is_(RACE_ANDROID))
2959 add_flag(flgs, TR_RES_ELEC);
2960 if (prace_is_(RACE_ENT))
2961 add_flag(flgs, TR_RES_FIRE);
2962 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2963 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2964 add_flag(flgs, TR_RES_LITE);
2969 * A struct for storing misc. flags
2972 u32b player_flags[TR_FLAG_SIZE];
2973 u32b tim_player_flags[TR_FLAG_SIZE];
2974 u32b player_imm[TR_FLAG_SIZE];
2975 u32b tim_player_imm[TR_FLAG_SIZE];
2976 u32b player_vuln[TR_FLAG_SIZE];
2977 u32b known_obj_imm[TR_FLAG_SIZE];
2982 * @brief プレイヤーの特性フラグ一種を表示するサブルーチン /
2983 * Helper function, see below
2984 * @param row コンソール表示位置の左上行
2985 * @param col コンソール表示位置の左上列
2986 * @param header コンソール上で表示する特性名
2987 * @param flag1 参照する特性ID
2988 * @param f プレイヤーの特性情報構造体
2989 * @param mode 表示オプション
2992 static void display_flag_aux(int row, int col, cptr header,
2993 int flag1, all_player_flags *f, u16b mode)
2998 byte header_color = TERM_L_DARK;
2999 int header_col = col;
3001 if (have_flag(f->player_vuln, flag1) &&
3002 !(have_flag(f->known_obj_imm, flag1) ||
3003 have_flag(f->player_imm, flag1) ||
3004 have_flag(f->tim_player_imm, flag1)))
3008 col += strlen(header) + 1;
3010 /* Weapon flags need only two column */
3011 if (mode & DP_WP) max_i = INVEN_LARM + 1;
3012 else max_i = INVEN_TOTAL;
3014 /* Check equipment */
3015 for (i = INVEN_RARM; i < max_i; i++)
3017 u32b flgs[TR_FLAG_SIZE];
3021 o_ptr = &inventory[i];
3024 object_flags_known(o_ptr, flgs);
3027 if (!(mode & DP_IMM))
3028 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3031 if (mode & DP_CURSE)
3033 if (have_flag(flgs, TR_ADD_L_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
3035 c_put_str(TERM_L_DARK, "+", row, col);
3036 header_color = TERM_WHITE;
3038 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE))
3040 c_put_str(TERM_WHITE, "+", row, col);
3041 header_color = TERM_WHITE;
3043 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
3045 c_put_str(TERM_WHITE, "*", row, col);
3046 header_color = TERM_WHITE;
3049 else if (flag1 == TR_LITE_1)
3051 if (have_dark_flag(flgs))
3053 c_put_str(TERM_L_DARK, "+", row, col);
3054 header_color = TERM_WHITE;
3056 else if (have_lite_flag(flgs))
3058 c_put_str(TERM_WHITE, "+", row, col);
3059 header_color = TERM_WHITE;
3064 if (have_flag(flgs, flag1))
3066 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
3067 (mode & DP_IMM) ? "*" : "+", row, col);
3068 header_color = TERM_WHITE;
3076 /* Assume that player flag is already written */
3079 if (header_color != TERM_L_DARK)
3081 /* Overwrite Header Color */
3082 c_put_str(header_color, header, row, header_col);
3088 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3091 if (have_flag(f->player_flags, flag1))
3093 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3094 header_color = TERM_WHITE;
3097 /* Timed player flags */
3098 if (have_flag(f->tim_player_flags, flag1))
3100 c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3101 header_color = TERM_WHITE;
3105 if (have_flag(f->tim_player_imm, flag1))
3107 c_put_str(TERM_YELLOW, "*", row, col);
3108 header_color = TERM_WHITE;
3110 if (have_flag(f->player_imm, flag1))
3112 c_put_str(TERM_WHITE, "*", row, col);
3113 header_color = TERM_WHITE;
3117 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3120 c_put_str(header_color, header, row, header_col);
3125 * @brief プレイヤーの特性フラグ一覧表示1 /
3126 * Special display, part 1
3129 static void display_player_flag_info(void)
3136 /* Extract flags and store */
3137 player_flags(f.player_flags);
3138 tim_player_flags(f.tim_player_flags);
3139 player_immunity(f.player_imm);
3140 tim_player_immunity(f.tim_player_imm);
3141 known_obj_immunity(f.known_obj_imm);
3142 player_vuln_flags(f.player_vuln);
3149 display_player_equippy(row-2, col+8, 0);
3150 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3153 display_flag_aux(row+0, col, "耐酸 :", TR_RES_ACID, &f, 0);
3154 display_flag_aux(row+0, col, "耐酸 :", TR_IM_ACID, &f, DP_IMM);
3155 display_flag_aux(row+1, col, "耐電撃:", TR_RES_ELEC, &f, 0);
3156 display_flag_aux(row+1, col, "耐電撃:", TR_IM_ELEC, &f, DP_IMM);
3157 display_flag_aux(row+2, col, "耐火炎:", TR_RES_FIRE, &f, 0);
3158 display_flag_aux(row+2, col, "耐火炎:", TR_IM_FIRE, &f, DP_IMM);
3159 display_flag_aux(row+3, col, "耐冷気:", TR_RES_COLD, &f, 0);
3160 display_flag_aux(row+3, col, "耐冷気:", TR_IM_COLD, &f, DP_IMM);
3161 display_flag_aux(row+4, col, "耐毒 :", TR_RES_POIS, &f, 0);
3162 display_flag_aux(row+5, col, "耐閃光:", TR_RES_LITE, &f, 0);
3163 display_flag_aux(row+6, col, "耐暗黒:", TR_RES_DARK, &f, 0);
3164 display_flag_aux(row+7, col, "耐破片:", TR_RES_SHARDS, &f, 0);
3165 display_flag_aux(row+8, col, "耐盲目:", TR_RES_BLIND, &f, 0);
3166 display_flag_aux(row+9, col, "耐混乱:", TR_RES_CONF, &f, 0);
3168 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3169 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3170 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3171 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3172 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3173 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3174 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3175 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3176 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3177 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3178 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3179 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3180 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3181 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3190 display_player_equippy(row-2, col+8, 0);
3192 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3195 display_flag_aux(row+0, col, "耐轟音:", TR_RES_SOUND, &f, 0);
3196 display_flag_aux(row+1, col, "耐地獄:", TR_RES_NETHER, &f, 0);
3197 display_flag_aux(row+2, col, "耐因混:", TR_RES_NEXUS, &f, 0);
3198 display_flag_aux(row+3, col, "耐カオ:", TR_RES_CHAOS, &f, 0);
3199 display_flag_aux(row+4, col, "耐劣化:", TR_RES_DISEN, &f, 0);
3200 display_flag_aux(row+5, col, "耐恐怖:", TR_RES_FEAR, &f, 0);
3201 display_flag_aux(row+6, col, "反射 :", TR_REFLECT, &f, 0);
3202 display_flag_aux(row+7, col, "火炎オ:", TR_SH_FIRE, &f, 0);
3203 display_flag_aux(row+8, col, "電気オ:", TR_SH_ELEC, &f, 0);
3204 display_flag_aux(row+9, col, "冷気オ:", TR_SH_COLD, &f, 0);
3206 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3207 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3208 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3209 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3210 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3211 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3212 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3213 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3214 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3215 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3224 display_player_equippy(row-2, col+12, 0);
3226 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3229 display_flag_aux(row+0, col, "加速 :", TR_SPEED, &f, 0);
3230 display_flag_aux(row+1, col, "耐麻痺 :", TR_FREE_ACT, &f, 0);
3231 display_flag_aux(row+2, col, "透明体視認:", TR_SEE_INVIS, &f, 0);
3232 display_flag_aux(row+3, col, "経験値保持:", TR_HOLD_EXP, &f, 0);
3233 display_flag_aux(row+4, col, "警告 :", TR_WARNING, &f, 0);
3234 display_flag_aux(row+5, col, "遅消化 :", TR_SLOW_DIGEST, &f, 0);
3235 display_flag_aux(row+6, col, "急回復 :", TR_REGEN, &f, 0);
3236 display_flag_aux(row+7, col, "浮遊 :", TR_LEVITATION, &f, 0);
3237 display_flag_aux(row+8, col, "永遠光源 :", TR_LITE_1, &f, 0);
3238 display_flag_aux(row+9, col, "呪い :", 0, &f, DP_CURSE);
3240 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3241 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3242 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3243 display_flag_aux(row+3, col, "Hold Exp :", TR_HOLD_EXP, &f, 0);
3244 display_flag_aux(row+4, col, "Warning :", TR_WARNING, &f, 0);
3245 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3246 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3247 display_flag_aux(row+7, col, "Levitation:", TR_LEVITATION, &f, 0);
3248 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE_1, &f, 0);
3249 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3256 * @brief プレイヤーの特性フラグ一覧表示2 /
3257 * Special display, part 2
3260 static void display_player_other_flag_info(void)
3267 /* Extract flags and store */
3268 player_flags(f.player_flags);
3269 tim_player_flags(f.tim_player_flags);
3270 player_immunity(f.player_imm);
3271 tim_player_immunity(f.tim_player_imm);
3272 known_obj_immunity(f.known_obj_imm);
3273 player_vuln_flags(f.player_vuln);
3280 display_player_equippy(row-2, col+12, DP_WP);
3282 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3285 display_flag_aux(row+ 0, col, "邪悪 倍打 :", TR_SLAY_EVIL, &f, DP_WP);
3286 display_flag_aux(row+ 0, col, "邪悪 倍打 :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3287 display_flag_aux(row+ 1, col, "不死 倍打 :", TR_SLAY_UNDEAD, &f, DP_WP);
3288 display_flag_aux(row+ 1, col, "不死 倍打 :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3289 display_flag_aux(row+ 2, col, "悪魔 倍打 :", TR_SLAY_DEMON, &f, DP_WP);
3290 display_flag_aux(row+ 2, col, "悪魔 倍打 :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3291 display_flag_aux(row+ 3, col, "龍 倍打 :", TR_SLAY_DRAGON, &f, DP_WP);
3292 display_flag_aux(row+ 3, col, "龍 倍打 :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3293 display_flag_aux(row+ 4, col, "人間 倍打 :", TR_SLAY_HUMAN, &f, DP_WP);
3294 display_flag_aux(row+ 4, col, "人間 倍打 :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3295 display_flag_aux(row+ 5, col, "動物 倍打 :", TR_SLAY_ANIMAL, &f, DP_WP);
3296 display_flag_aux(row+ 5, col, "動物 倍打 :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3297 display_flag_aux(row+ 6, col, "オーク倍打:", TR_SLAY_ORC, &f, DP_WP);
3298 display_flag_aux(row+ 6, col, "オーク倍打:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3299 display_flag_aux(row+ 7, col, "トロル倍打:", TR_SLAY_TROLL, &f, DP_WP);
3300 display_flag_aux(row+ 7, col, "トロル倍打:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3301 display_flag_aux(row+ 8, col, "巨人 倍打 :", TR_SLAY_GIANT, &f, DP_WP);
3302 display_flag_aux(row+ 8, col, "巨人 倍打 :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3303 display_flag_aux(row+ 9, col, "溶解 :", TR_BRAND_ACID, &f, DP_WP);
3304 display_flag_aux(row+10, col, "電撃 :", TR_BRAND_ELEC, &f, DP_WP);
3305 display_flag_aux(row+11, col, "焼棄 :", TR_BRAND_FIRE, &f, DP_WP);
3306 display_flag_aux(row+12, col, "凍結 :", TR_BRAND_COLD, &f, DP_WP);
3307 display_flag_aux(row+13, col, "毒殺 :", TR_BRAND_POIS, &f, DP_WP);
3308 display_flag_aux(row+14, col, "切れ味 :", TR_VORPAL, &f, DP_WP);
3309 display_flag_aux(row+15, col, "地震 :", TR_IMPACT, &f, DP_WP);
3310 display_flag_aux(row+16, col, "吸血 :", TR_VAMPIRIC, &f, DP_WP);
3311 display_flag_aux(row+17, col, "カオス効果:", TR_CHAOTIC, &f, DP_WP);
3312 display_flag_aux(row+18, col, "理力 :", TR_FORCE_WEAPON, &f, DP_WP);
3314 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3315 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3316 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3317 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3318 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3319 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3320 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3321 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3322 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3323 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3324 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3325 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3326 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3327 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3328 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3329 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3330 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3331 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3332 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3333 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3334 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3335 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3336 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3337 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3338 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3339 display_flag_aux(row+16, col, "Vampiric :", TR_VAMPIRIC, &f, DP_WP);
3340 display_flag_aux(row+17, col, "Chaotic :", TR_CHAOTIC, &f, DP_WP);
3341 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3350 display_player_equippy(row-2, col+13, 0);
3351 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+13);
3354 display_flag_aux(row+ 0, col, "テレパシー :", TR_TELEPATHY, &f, 0);
3355 display_flag_aux(row+ 1, col, "邪悪ESP :", TR_ESP_EVIL, &f, 0);
3356 display_flag_aux(row+ 2, col, "無生物ESP :", TR_ESP_NONLIVING, &f, 0);
3357 display_flag_aux(row+ 3, col, "善良ESP :", TR_ESP_GOOD, &f, 0);
3358 display_flag_aux(row+ 4, col, "不死ESP :", TR_ESP_UNDEAD, &f, 0);
3359 display_flag_aux(row+ 5, col, "悪魔ESP :", TR_ESP_DEMON, &f, 0);
3360 display_flag_aux(row+ 6, col, "龍ESP :", TR_ESP_DRAGON, &f, 0);
3361 display_flag_aux(row+ 7, col, "人間ESP :", TR_ESP_HUMAN, &f, 0);
3362 display_flag_aux(row+ 8, col, "動物ESP :", TR_ESP_ANIMAL, &f, 0);
3363 display_flag_aux(row+ 9, col, "オークESP :", TR_ESP_ORC, &f, 0);
3364 display_flag_aux(row+10, col, "トロルESP :", TR_ESP_TROLL, &f, 0);
3365 display_flag_aux(row+11, col, "巨人ESP :", TR_ESP_GIANT, &f, 0);
3366 display_flag_aux(row+12, col, "ユニークESP:", TR_ESP_UNIQUE, &f, 0);
3367 display_flag_aux(row+13, col, "腕力維持 :", TR_SUST_STR, &f, 0);
3368 display_flag_aux(row+14, col, "知力維持 :", TR_SUST_INT, &f, 0);
3369 display_flag_aux(row+15, col, "賢さ維持 :", TR_SUST_WIS, &f, 0);
3370 display_flag_aux(row+16, col, "器用維持 :", TR_SUST_DEX, &f, 0);
3371 display_flag_aux(row+17, col, "耐久維持 :", TR_SUST_CON, &f, 0);
3372 display_flag_aux(row+18, col, "魅力維持 :", TR_SUST_CHR, &f, 0);
3374 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3375 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3376 display_flag_aux(row+ 2, col, "ESP Noliv. :", TR_ESP_NONLIVING, &f, 0);
3377 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3378 display_flag_aux(row+ 4, col, "ESP Undead :", TR_ESP_UNDEAD, &f, 0);
3379 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3380 display_flag_aux(row+ 6, col, "ESP Dragon :", TR_ESP_DRAGON, &f, 0);
3381 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3382 display_flag_aux(row+ 8, col, "ESP Animal :", TR_ESP_ANIMAL, &f, 0);
3383 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3384 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3385 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3386 display_flag_aux(row+12, col, "ESP Unique :", TR_ESP_UNIQUE, &f, 0);
3387 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3388 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3389 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3390 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3391 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3392 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3399 col = col + 12 + 17;
3401 display_player_equippy(row-2, col+14, 0);
3403 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3406 display_flag_aux(row+ 0, col, "追加攻撃 :", TR_BLOWS, &f, 0);
3407 display_flag_aux(row+ 1, col, "採掘 :", TR_TUNNEL, &f, 0);
3408 display_flag_aux(row+ 2, col, "赤外線視力 :", TR_INFRA, &f, 0);
3409 display_flag_aux(row+ 3, col, "魔法道具支配:", TR_MAGIC_MASTERY, &f, 0);
3410 display_flag_aux(row+ 4, col, "隠密 :", TR_STEALTH, &f, 0);
3411 display_flag_aux(row+ 5, col, "探索 :", TR_SEARCH, &f, 0);
3413 display_flag_aux(row+ 7, col, "乗馬 :", TR_RIDING, &f, 0);
3414 display_flag_aux(row+ 8, col, "投擲 :", TR_THROW, &f, 0);
3415 display_flag_aux(row+ 9, col, "祝福 :", TR_BLESSED, &f, 0);
3416 display_flag_aux(row+10, col, "反テレポート:", TR_NO_TELE, &f, 0);
3417 display_flag_aux(row+11, col, "反魔法 :", TR_NO_MAGIC, &f, 0);
3418 display_flag_aux(row+12, col, "消費魔力減少:", TR_DEC_MANA, &f, 0);
3420 display_flag_aux(row+14, col, "経験値減少 :", TR_DRAIN_EXP, &f, 0);
3421 display_flag_aux(row+15, col, "乱テレポート:", TR_TELEPORT, &f, 0);
3422 display_flag_aux(row+16, col, "反感 :", TR_AGGRAVATE, &f, 0);
3423 display_flag_aux(row+17, col, "太古の怨念 :", TR_TY_CURSE, &f, 0);
3425 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3426 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3427 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3428 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3429 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3430 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3432 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3433 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3434 display_flag_aux(row+ 9, col, "Blessed :", TR_BLESSED, &f, 0);
3435 display_flag_aux(row+10, col, "No Teleport :", TR_NO_TELE, &f, 0);
3436 display_flag_aux(row+11, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3437 display_flag_aux(row+12, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3439 display_flag_aux(row+14, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3440 display_flag_aux(row+15, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3441 display_flag_aux(row+16, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3442 display_flag_aux(row+17, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3449 * @brief プレイヤーの特性フラグ一覧表示2a /
3450 * Special display, part 2a
3453 static void display_player_misc_info(void)
3458 /* Display basics */
3460 put_str("名前 :", 1, 26);
3461 put_str("性別 :", 3, 1);
3462 put_str("種族 :", 4, 1);
3463 put_str("職業 :", 5, 1);
3465 put_str("Name :", 1, 26);
3466 put_str("Sex :", 3, 1);
3467 put_str("Race :", 4, 1);
3468 put_str("Class :", 5, 1);
3471 strcpy(tmp,ap_ptr->title);
3478 strcat(tmp,p_ptr->name);
3480 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3481 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3482 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3483 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3485 /* Display extras */
3487 put_str("レベル:", 6, 1);
3488 put_str("HP :", 7, 1);
3489 put_str("MP :", 8, 1);
3491 put_str("Level :", 6, 1);
3492 put_str("Hits :", 7, 1);
3493 put_str("Mana :", 8, 1);
3497 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3498 c_put_str(TERM_L_BLUE, buf, 6, 9);
3499 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3500 c_put_str(TERM_L_BLUE, buf, 7, 9);
3501 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3502 c_put_str(TERM_L_BLUE, buf, 8, 9);
3507 * @brief プレイヤーの特性フラグ一覧表示2b /
3508 * Special display, part 2b
3512 * How to print out the modifications and sustains.
3513 * Positive mods with no sustain will be light green.
3514 * Positive mods with a sustain will be dark green.
3515 * Sustains (with no modification) will be a dark green 's'.
3516 * Negative mods (from a curse) will be red.
3517 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3518 * No mod, no sustain, will be a slate '.'
3521 static void display_player_stat_info(void)
3528 u32b flgs[TR_FLAG_SIZE];
3542 /* Print out the labels for the columns */
3544 c_put_str(TERM_WHITE, "能力", row, stat_col+1);
3545 c_put_str(TERM_BLUE, " 基本", row, stat_col+7);
3546 c_put_str(TERM_L_BLUE, " 種 職 性 装 ", row, stat_col+13);
3547 c_put_str(TERM_L_GREEN, "合計", row, stat_col+28);
3548 c_put_str(TERM_YELLOW, "現在", row, stat_col+35);
3550 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3551 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3552 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3553 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3554 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3558 /* Display the stats */
3559 for (i = 0; i < 6; i++)
3563 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3564 else r_adj = rp_ptr->r_adj[i];
3566 /* Calculate equipment adjustment */
3569 /* Icky formula to deal with the 18 barrier */
3570 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3571 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3572 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3573 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3574 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3575 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3577 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3578 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3580 if (prace_is_(RACE_ENT))
3586 if (p_ptr->lev > 25) r_adj++;
3587 if (p_ptr->lev > 40) r_adj++;
3588 if (p_ptr->lev > 45) r_adj++;
3591 if (p_ptr->lev > 25) r_adj--;
3592 if (p_ptr->lev > 40) r_adj--;
3593 if (p_ptr->lev > 45) r_adj--;
3599 e_adj -= cp_ptr->c_adj[i];
3600 e_adj -= ap_ptr->a_adj[i];
3602 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3603 /* Reduced name of stat */
3604 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3606 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3609 /* Internal "natural" max value. Maxes at 18/100 */
3610 /* This is useful to see if you are maxed out */
3611 cnv_stat(p_ptr->stat_max[i], buf);
3612 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3614 c_put_str(TERM_WHITE, "!", row + i+1, _(stat_col + 6, stat_col + 4));
3616 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3618 /* Race, class, and equipment modifiers */
3619 (void)sprintf(buf, "%3d", r_adj);
3620 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3621 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3622 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3623 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3624 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3625 (void)sprintf(buf, "%3d", (int)e_adj);
3626 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3628 /* Actual maximal modified value */
3629 cnv_stat(p_ptr->stat_top[i], buf);
3630 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3632 /* Only display stat_use if not maximal */
3633 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3635 cnv_stat(p_ptr->stat_use[i], buf);
3636 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3641 col = stat_col + 41;
3643 /* Header and Footer */
3644 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3645 c_put_str(TERM_L_GREEN, _("能力修正", "Modification"), row - 1, col);
3647 /* Process equipment */
3648 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3651 o_ptr = &inventory[i];
3653 /* Acquire "known" flags */
3654 object_flags_known(o_ptr, flgs);
3656 /* Initialize color based of sign of pval. */
3657 for (stat = 0; stat < 6; stat++)
3664 if (have_flag(flgs, stat))
3670 if (o_ptr->pval > 0)
3676 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3679 if (have_flag(flgs, stat + TR_SUST_STR))
3681 /* Dark green for sustained stats */
3686 if (o_ptr->pval < 0)
3692 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3697 else if (have_flag(flgs, stat + TR_SUST_STR))
3699 /* Dark green "s" */
3704 /* Dump proper character */
3705 Term_putch(col, row + stat+1, a, c);
3716 for (stat = 0; stat < 6; stat++)
3723 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3729 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3730 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3731 if (p_ptr->tsuyoshi) dummy += 4;
3733 else if (stat == A_WIS || stat == A_INT)
3735 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3736 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3738 else if (stat == A_DEX)
3740 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3741 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3742 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3744 else if (stat == A_CON)
3746 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3747 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3748 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3749 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3750 if (p_ptr->tsuyoshi) dummy += 4;
3752 else if (stat == A_CHR)
3754 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3755 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3756 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3757 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3758 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3759 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3775 if (dummy < 10) c = '0' + dummy;
3785 if (dummy > -10) c = '0' - dummy;
3792 if (have_flag(flgs, stat + TR_SUST_STR))
3794 /* Dark green "s" */
3801 Term_putch(col, row + stat+1, a, c);
3807 * @brief プレイヤーのステータス表示メイン処理
3808 * Display the character on the screen (various modes)
3809 * @param mode 表示モードID
3813 * The top one and bottom two lines are left blank.
3814 * Mode 0 = standard display with skills
3815 * Mode 1 = standard display with history
3816 * Mode 2 = summary of various things
3817 * Mode 3 = summary of various things (part 2)
3818 * Mode 4 = mutations
3821 void display_player(BIT_FLAGS mode)
3830 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3839 if ((mode == 0) || (mode == 1))
3841 /* Name, Sex, Race, Class */
3843 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "の":"", p_ptr->name);
3845 sprintf(tmp, "%s %s", ap_ptr->title, p_ptr->name);
3848 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3849 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3850 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3851 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3856 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3858 strcpy(tmp, realm_names[p_ptr->realm1]);
3859 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3862 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3863 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3865 /* Age, Height, Weight, Social */
3866 /* 身長はセンチメートルに、体重はキログラムに変更してあります */
3868 display_player_one_line(ENTRY_AGE, format("%d才" ,(int)p_ptr->age), TERM_L_BLUE);
3869 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3870 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3871 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3873 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3874 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3875 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3876 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3878 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3881 /* Display the stats */
3882 for (i = 0; i < 6; i++)
3884 /* Special treatment of "injured" stats */
3885 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3889 /* Use lowercase stat name */
3890 put_str(stat_names_reduced[i], 3 + i, 53);
3892 /* Get the current stat */
3893 value = p_ptr->stat_use[i];
3895 /* Obtain the current stat (modified) */
3896 cnv_stat(value, buf);
3898 /* Display the current stat (modified) */
3899 c_put_str(TERM_YELLOW, buf, 3 + i, 60);
3901 /* Acquire the max stat */
3902 value = p_ptr->stat_top[i];
3904 /* Obtain the maximum stat (modified) */
3905 cnv_stat(value, buf);
3907 /* Display the maximum stat (modified) */
3908 c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
3911 /* Normal treatment of "normal" stats */
3914 /* Assume uppercase stat name */
3915 put_str(stat_names[i], 3 + i, 53);
3917 /* Obtain the current stat (modified) */
3918 cnv_stat(p_ptr->stat_use[i], buf);
3920 /* Display the current stat (modified) */
3921 c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
3924 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3926 c_put_str(TERM_WHITE, "!", 3 + i, _(58, 58-2));
3930 /* Display "history" info */
3934 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
3936 for (i = 0; i < 4; i++)
3938 put_str(p_ptr->history[i], i + 12, 10);
3945 if (p_ptr->total_winner)
3948 sprintf(statmsg, "…あなたは勝利の後%sした。", streq(p_ptr->died_from, "Seppuku") ? "切腹" : "引退");
3950 sprintf(statmsg, "...You %s after the winning.", streq(p_ptr->died_from, "Seppuku") ? "did Seppuku" : "retired from the adventure");
3953 else if (!dun_level)
3956 sprintf(statmsg, "…あなたは%sで%sに殺された。", map_name(), p_ptr->died_from);
3958 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3961 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3963 /* Get the quest text */
3964 /* Bewere that INIT_ASSIGN resets the cur_num. */
3965 init_flags = INIT_NAME_ONLY;
3967 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3970 sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3972 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3978 sprintf(statmsg, "…あなたは、%sの%d階で%sに殺された。", map_name(), (int)dun_level, p_ptr->died_from);
3980 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3984 else if (character_dungeon)
3988 sprintf(statmsg, _("…あなたは現在、 %s にいる。", "...Now, you are in %s."), map_name());
3990 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3992 /* Clear the text */
3993 /* Must be done before doing INIT_SHOW_TEXT */
3994 for (i = 0; i < 10; i++)
3996 quest_text[i][0] = '\0';
3998 quest_text_line = 0;
4000 /* Get the quest text */
4001 init_flags = INIT_NAME_ONLY;
4003 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
4005 sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[p_ptr->inside_quest].name);
4010 sprintf(statmsg, "…あなたは現在、 %s の %d 階で探索している。", map_name(), (int)dun_level);
4012 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
4019 char temp[64*2], *t;
4020 roff_to_buf(statmsg, 60, temp, sizeof(temp));
4022 for(i=0 ; i<2 ; i++)
4028 put_str(t, i + 5 + 12, 10);
4036 /* Display "various" info */
4039 display_player_middle();
4040 display_player_various();
4047 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4050 display_player_misc_info();
4051 display_player_stat_info();
4052 display_player_flag_info();
4058 display_player_other_flag_info();
4063 do_cmd_knowledge_mutations();
4068 * @brief プレイヤーのステータス表示をファイルにダンプする
4069 * @param fff ファイルポインタ
4072 static void dump_aux_display_player(FILE *fff)
4079 /* Display player */
4082 /* Dump part of the screen */
4083 for (y = 1; y < 22; y++)
4086 for (x = 0; x < 79; x++)
4088 /* Get the attr/char */
4089 (void)(Term_what(x, y, &a, &c));
4095 /* End the string */
4098 /* Kill trailing spaces */
4099 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4102 fprintf(fff, _("%s\n", "%s\n"), buf);
4105 /* Display history */
4108 /* Dump part of the screen */
4109 for (y = 10; y < 19; y++)
4112 for (x = 0; x < 79; x++)
4114 /* Get the attr/char */
4115 (void)(Term_what(x, y, &a, &c));
4121 /* End the string */
4124 /* Kill trailing spaces */
4125 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4128 fprintf(fff, "%s\n", buf);
4133 /* Display flags (part 1) */
4136 /* Dump part of the screen */
4137 for (y = 2; y < 22; y++)
4140 for (x = 0; x < 79; x++)
4142 /* Get the attr/char */
4143 (void)(Term_what(x, y, &a, &c));
4145 /* Dump it (Ignore equippy tile graphic) */
4152 /* End the string */
4155 /* Kill trailing spaces */
4156 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4159 fprintf(fff, "%s\n", buf);
4164 /* Display flags (part 2) */
4167 /* Dump part of the screen */
4168 for (y = 1; y < 22; y++)
4171 for (x = 0; x < 79; x++)
4173 /* Get the attr/char */
4174 (void)(Term_what(x, y, &a, &c));
4176 /* Dump it (Ignore equippy tile graphic) */
4183 /* End the string */
4186 /* Kill trailing spaces */
4187 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4190 fprintf(fff, "%s\n", buf);
4198 * @brief プレイヤーのペット情報をファイルにダンプする
4199 * @param fff ファイルポインタ
4202 static void dump_aux_pet(FILE *fff)
4206 bool pet_settings = FALSE;
4209 for (i = m_max - 1; i >= 1; i--)
4211 monster_type *m_ptr = &m_list[i];
4213 if (!m_ptr->r_idx) continue;
4214 if (!is_pet(m_ptr)) continue;
4215 pet_settings = TRUE;
4216 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4219 fprintf(fff, _("\n\n [主なペット]\n\n", "\n\n [Leading Pets]\n\n"));
4222 monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
4223 fprintf(fff, "%s\n", pet_name);
4228 fprintf(fff, _("\n\n [ペットへの命令]\n", "\n\n [Command for Pets]\n"));
4230 fprintf(fff, _("\n ドアを開ける: %s", "\n Pets open doors: %s"),
4231 (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4233 fprintf(fff, _("\n アイテムを拾う: %s", "\n Pets pick up items: %s"),
4234 (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4236 fprintf(fff, _("\n テレポート系魔法を使う: %s", "\n Allow teleport: %s"),
4237 (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4239 fprintf(fff, _("\n 攻撃魔法を使う: %s", "\n Allow cast attack spell: %s"),
4240 (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4242 fprintf(fff, _("\n 召喚魔法を使う: %s", "\n Allow cast summon spell: %s"),
4243 (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4245 fprintf(fff, _("\n プレイヤーを巻き込む範囲魔法を使う: %s", "\n Allow involve player in area spell: %s"),
4246 (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4254 * @brief プレイヤーの職業能力情報をファイルにダンプする
4255 * @param fff ファイルポインタ
4258 static void dump_aux_class_special(FILE *fff)
4260 if (p_ptr->pclass == CLASS_BLUE_MAGE)
4267 int spellnum[MAX_MONSPELLS];
4268 s32b f4 = 0, f5 = 0, f6 = 0;
4273 for (i=0;i<60;i++) { p[i][0] = '\0'; }
4275 strcat(p[col], _("\n\n [学習済みの青魔法]\n", "\n\n [Learned Blue Magic]\n"));
4280 set_rf_masks(&f4, &f5, &f6, j);
4283 case MONSPELL_TYPE_BOLT:
4284 strcat(p[col], _("\n [ボルト型]\n", "\n [Bolt Type]\n"));
4287 case MONSPELL_TYPE_BALL:
4288 strcat(p[col], _("\n [ボール型]\n", "\n [Ball Type]\n"));
4291 case MONSPELL_TYPE_BREATH:
4292 strcat(p[col], _("\n [ブレス型]\n", "\n [ Breath ]\n"));
4295 case MONSPELL_TYPE_SUMMON:
4296 strcat(p[col], _("\n [召喚魔法]\n", "\n [Summonning]\n"));
4299 case MONSPELL_TYPE_OTHER:
4300 strcat(p[col], _("\n [ その他 ]\n", "\n [Other Type]\n"));
4304 for (i = 0, num = 0; i < 32; i++)
4306 if ((0x00000001 << i) & f4) spellnum[num++] = i;
4310 if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
4314 if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
4319 strcat(p[col], " ");
4321 for (i = 0; i < num; i++)
4323 if (p_ptr->magic_num2[spellnum[i]])
4326 /* Dump blue magic */
4327 l1 = strlen(p[col]);
4328 l2 = strlen(monster_powers_short[spellnum[i]]);
4329 if ((l1 + l2) >= 75)
4331 strcat(p[col], "\n");
4333 strcat(p[col], " ");
4335 strcat(p[col], monster_powers_short[spellnum[i]]);
4336 strcat(p[col], ", ");
4342 strcat(p[col], _("なし", "None"));
4346 if (p[col][strlen(p[col])-2] == ',')
4348 p[col][strlen(p[col])-2] = '\0';
4352 p[col][strlen(p[col])-10] = '\0';
4356 strcat(p[col], "\n");
4359 for (i=0;i<=col;i++)
4364 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4366 char s[EATER_EXT][MAX_NLEN];
4367 OBJECT_TYPE_VALUE tval;
4370 OBJECT_SUBTYPE_VALUE i;
4373 fprintf(fff, _("\n\n [取り込んだ魔法道具]\n", "\n\n [Magic devices eaten]\n"));
4375 for (ext = 0; ext < 3; ext++)
4379 /* Dump an extent name */
4384 fprintf(fff, _("\n[杖]\n", "\n[Staffs]\n"));
4388 fprintf(fff, _("\n[魔法棒]\n", "\n[Wands]\n"));
4392 fprintf(fff, _("\n[ロッド]\n", "\n[Rods]\n"));
4396 /* Get magic device names that were eaten */
4397 for (i = 0; i < EATER_EXT; i++)
4399 int idx = EATER_EXT * ext + i;
4401 magic_num = p_ptr->magic_num2[idx];
4402 if (!magic_num) continue;
4404 k_idx = lookup_kind(tval, i);
4405 if (!k_idx) continue;
4406 sprintf(s[eat_num], "%23s (%2d)", (k_name + k_info[k_idx].name), magic_num);
4410 /* Dump magic devices in this extent */
4413 for (i = 0; i < eat_num; i++)
4416 if (i % 3 < 2) fputs(" ", fff);
4417 else fputs("\n", fff);
4420 if (i % 3 > 0) fputs("\n", fff);
4422 else /* Not found */
4424 fputs(_(" (なし)\n", " (none)\n"), fff);
4428 else if (p_ptr->pclass == CLASS_SMITH)
4430 int i, id[250], n = 0, row;
4432 fprintf(fff, _("\n\n [手に入れたエッセンス]\n\n", "\n\n [Get Essence]\n\n"));
4433 fprintf(fff, _("エッセンス 個数 エッセンス 個数 エッセンス 個数",
4434 "Essence Num Essence Num Essence Num "));
4435 for (i = 0; essence_name[i]; i++)
4437 if (!essence_name[i][0]) continue;
4444 for (i = 0; i < row; i++)
4447 fprintf(fff, "%-11s %5d ", essence_name[id[i]], (int)p_ptr->magic_num1[id[i]]);
4448 if(i + row < n) fprintf(fff, "%-11s %5d ", essence_name[id[i + row]], (int)p_ptr->magic_num1[id[i + row]]);
4449 if(i + row * 2 < n) fprintf(fff, "%-11s %5d", essence_name[id[i + row * 2]], (int)p_ptr->magic_num1[id[i + row * 2]]);
4459 * @brief クエスト情報をファイルにダンプする
4460 * @param fff ファイルポインタ
4463 static void dump_aux_quest(FILE *fff)
4469 fprintf(fff, _("\n\n [クエスト情報]\n", "\n\n [Quest Information]\n"));
4471 /* Allocate Memory */
4472 C_MAKE(quest_num, max_q_idx, IDX);
4474 /* Sort by compete level */
4475 for (i = 1; i < max_q_idx; i++) quest_num[i] = i;
4476 ang_sort_comp = ang_sort_comp_quest_num;
4477 ang_sort_swap = ang_sort_swap_quest_num;
4478 ang_sort(quest_num, &dummy, max_q_idx);
4480 /* Dump Quest Information */
4482 do_cmd_knowledge_quests_completed(fff, quest_num);
4484 do_cmd_knowledge_quests_failed(fff, quest_num);
4488 C_KILL(quest_num, max_q_idx, IDX);
4493 * @brief 死の直前メッセージ並びに遺言をファイルにダンプする
4494 * @param fff ファイルポインタ
4497 static void dump_aux_last_message(FILE *fff)
4501 if (!p_ptr->total_winner)
4505 fprintf(fff, _("\n [死ぬ直前のメッセージ]\n\n", "\n [Last Messages]\n\n"));
4506 for (i = MIN(message_num(), 30); i >= 0; i--)
4508 fprintf(fff,"> %s\n",message_str((s16b)i));
4513 /* Hack -- *Winning* message */
4514 else if (p_ptr->last_message)
4516 fprintf(fff, _("\n [*勝利*メッセージ]\n\n", "\n [*Winning* Message]\n\n"));
4517 fprintf(fff," %s\n", p_ptr->last_message);
4524 * @brief 帰還場所情報をファイルにダンプする
4525 * @param fff ファイルポインタ
4528 static void dump_aux_recall(FILE *fff)
4531 fprintf(fff, _("\n [帰還場所]\n\n", "\n [Recall Depth]\n\n"));
4533 for (y = 1; y < max_d_idx; y++)
4537 if (!d_info[y].maxdepth) continue;
4538 if (!max_dlv[y]) continue;
4539 if (d_info[y].final_guardian)
4541 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4543 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4545 fprintf(fff, _(" %c%-12s: %3d 階\n", " %c%-16s: level %3d\n"),
4546 seiha ? '!' : ' ', d_name+d_info[y].name, (int)max_dlv[y]);
4552 * @brief オプション情報をファイルにダンプする
4553 * @param fff ファイルポインタ
4556 static void dump_aux_options(FILE *fff)
4558 fprintf(fff, _("\n [オプション設定]\n", "\n [Option Settings]\n"));
4561 fprintf(fff, _("\n 保存モード: ON", "\n Preserve Mode: ON"));
4564 fprintf(fff, _("\n 保存モード: OFF", "\n Preserve Mode: OFF"));
4566 if (ironman_small_levels)
4567 fprintf(fff, _("\n 小さいダンジョン: ALWAYS", "\n Small Levels: ALWAYS"));
4568 else if (always_small_levels)
4569 fprintf(fff, _("\n 小さいダンジョン: ON", "\n Small Levels: ON"));
4570 else if (small_levels)
4571 fprintf(fff, _("\n 小さいダンジョン: ENABLED", "\n Small Levels: ENABLED"));
4573 fprintf(fff, _("\n 小さいダンジョン: OFF", "\n Small Levels: OFF"));
4577 fprintf(fff, _("\n 元祖の町のみ: ON", "\n Vanilla Town: ON"));
4579 fprintf(fff, _("\n 小規模な町: ON", "\n Lite Town: ON"));
4583 fprintf(fff, _("\n 店なし: ON", "\n No Shops: ON"));
4585 if (ironman_downward)
4586 fprintf(fff, _("\n 階段を上がれない: ON", "\n Diving Only: ON"));
4589 fprintf(fff, _("\n 普通でない部屋: ON", "\n Unusual Rooms: ON"));
4591 if (ironman_nightmare)
4592 fprintf(fff, _("\n 悪夢モード: ON", "\n Nightmare Mode: ON"));
4595 if (ironman_empty_levels)
4596 fprintf(fff, _("\n アリーナ: ALWAYS", "\n Arena Levels: ALWAYS"));
4597 else if (empty_levels)
4598 fprintf(fff, _("\n アリーナ: ENABLED", "\n Arena Levels: ENABLED"));
4600 fprintf(fff, _("\n アリーナ: OFF", "\n Arena Levels: OFF"));
4605 fprintf(fff, _("\n 何か不正なことをしてしまっています。\n", "\n You have done something illegal.\n"));
4612 * @brief 闘技場の情報をファイルにダンプする
4613 * @param fff ファイルポインタ
4616 static void dump_aux_arena(FILE *fff)
4618 if (lite_town || vanilla_town) return;
4620 if (p_ptr->arena_number < 0)
4622 if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
4624 fprintf(fff, _("\n 闘技場: 敗北\n", "\n Arena: Defeated\n"));
4629 fprintf(fff, "\n 闘技場: %d回戦で%sの前に敗北\n", -p_ptr->arena_number,
4630 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
4632 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
4633 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
4634 -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
4638 else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
4640 fprintf(fff, _("\n 闘技場: 真のチャンピオン\n", "\n Arena: True Champion\n"));
4642 else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
4644 fprintf(fff, _("\n 闘技場: チャンピオン\n", "\n Arena: Champion\n"));
4649 fprintf(fff, "\n 闘技場: %2d勝\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4651 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");
4660 * @brief 撃破モンスターの情報をファイルにダンプする
4661 * @param fff ファイルポインタ
4664 static void dump_aux_monsters(FILE *fff)
4666 /* Monsters slain */
4669 long uniq_total = 0;
4670 long norm_total = 0;
4673 /* Sort by monster level */
4676 fprintf(fff, _("\n [倒したモンスター]\n\n", "\n [Defeated Monsters]\n\n"));
4678 /* Allocate the "who" array */
4679 C_MAKE(who, max_r_idx, s16b);
4681 /* Count monster kills */
4682 for (k = 1; k < max_r_idx; k++)
4684 monster_race *r_ptr = &r_info[k];
4686 /* Ignore unused index */
4687 if (!r_ptr->name) continue;
4689 /* Unique monsters */
4690 if (r_ptr->flags1 & RF1_UNIQUE)
4692 bool dead = (r_ptr->max_num == 0);
4697 /* Add a unique monster to the list */
4698 who[uniq_total++] = k;
4702 /* Normal monsters */
4705 if (r_ptr->r_pkills > 0)
4707 norm_total += r_ptr->r_pkills;
4713 /* No monsters is defeated */
4716 fprintf(fff,_("まだ敵を倒していません。\n", "You have defeated no enemies yet.\n"));
4719 /* Defeated more than one normal monsters */
4720 else if (uniq_total == 0)
4723 fprintf(fff,"%ld体の敵を倒しています。\n", norm_total);
4725 fprintf(fff,"You have defeated %ld %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
4729 /* Defeated more than one unique monsters */
4730 else /* if (uniq_total > 0) */
4733 fprintf(fff, "%ld体のユニーク・モンスターを含む、合計%ld体の敵を倒しています。\n", uniq_total, norm_total);
4735 fprintf(fff, "You have defeated %ld %s including %ld unique monster%s in total.\n", norm_total, norm_total == 1 ? "enemy" : "enemies", uniq_total, (uniq_total == 1 ? "" : "s"));
4739 /* Select the sort method */
4740 ang_sort_comp = ang_sort_comp_hook;
4741 ang_sort_swap = ang_sort_swap_hook;
4743 /* Sort the array by dungeon depth of monsters */
4744 ang_sort(who, &why, uniq_total);
4745 fprintf(fff, _("\n《上位%ld体のユニーク・モンスター》\n", "\n< Unique monsters top %ld >\n"), MIN(uniq_total, 10));
4748 for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
4750 monster_race *r_ptr = &r_info[who[k]];
4751 fprintf(fff, _(" %-40s (レベル%3d)\n", " %-40s (level %3d)\n"), (r_name + r_ptr->name), (int)r_ptr->level);
4756 /* Free the "who" array */
4757 C_KILL(who, max_r_idx, s16b);
4762 * @brief 元種族情報をファイルにダンプする
4763 * @param fff ファイルポインタ
4766 static void dump_aux_race_history(FILE *fff)
4768 if (p_ptr->old_race1 || p_ptr->old_race2)
4772 fprintf(fff, _("\n\n あなたは%sとして生まれた。", "\n\n You were born as %s."), race_info[p_ptr->start_race].title);
4773 for (i = 0; i < MAX_RACES; i++)
4775 if (p_ptr->start_race == i) continue;
4778 if (!(p_ptr->old_race1 & 1L << i)) continue;
4782 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4784 fprintf(fff, _("\n あなたはかつて%sだった。", "\n You were a %s before."), race_info[i].title);
4793 * @brief 元魔法領域情報をファイルにダンプする
4794 * @param fff ファイルポインタ
4797 static void dump_aux_realm_history(FILE *fff)
4799 if (p_ptr->old_realm)
4804 for (i = 0; i < MAX_MAGIC; i++)
4806 if (!(p_ptr->old_realm & 1L << i)) continue;
4807 fprintf(fff, _("\n あなたはかつて%s魔法を使えた。", "\n You were able to use %s magic before."), realm_names[i+1]);
4815 * @brief 徳の情報をファイルにダンプする
4816 * @param fff ファイルポインタ
4819 static void dump_aux_virtues(FILE *fff)
4823 fprintf(fff, _("\n\n [自分に関する情報]\n\n", "\n\n [HP-rate & Max stat & Virtues]\n\n"));
4825 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
4826 (2 * p_ptr->hitdie +
4827 ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
4830 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "現在の体力ランク : %d/100\n\n", percent);
4831 else fprintf(fff, "現在の体力ランク : ???\n\n");
4832 fprintf(fff, "能力の最大値\n");
4834 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
4835 else fprintf(fff, "Your current Life Rating is ???.\n\n");
4836 fprintf(fff, "Limits of maximum stats\n");
4838 for (v_nr = 0; v_nr < 6; v_nr++)
4840 if ((p_ptr->knowledge & KNOW_STAT) || p_ptr->stat_max[v_nr] == p_ptr->stat_max_max[v_nr]) fprintf(fff, "%s 18/%d\n", stat_names[v_nr], p_ptr->stat_max_max[v_nr]-18);
4841 else fprintf(fff, "%s ???\n", stat_names[v_nr]);
4844 fprintf(fff, _("\n属性 : %s\n", "\nYour alighnment : %s\n"), your_alignment());
4851 * @brief 突然変異の情報をファイルにダンプする
4852 * @param fff ファイルポインタ
4855 static void dump_aux_mutations(FILE *fff)
4857 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4859 fprintf(fff, _("\n\n [突然変異]\n\n", "\n\n [Mutations]\n\n"));
4860 dump_mutations(fff);
4866 * @brief 所持品の情報をファイルにダンプする
4867 * @param fff ファイルポインタ
4870 static void dump_aux_equipment_inventory(FILE *fff)
4873 char o_name[MAX_NLEN];
4875 /* Dump the equipment */
4878 fprintf(fff, _(" [キャラクタの装備]\n\n", " [Character Equipment]\n\n"));
4879 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4881 object_desc(o_name, &inventory[i], 0);
4882 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
4883 strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
4885 fprintf(fff, "%c) %s\n",
4886 index_to_label(i), o_name);
4888 fprintf(fff, "\n\n");
4891 /* Dump the inventory */
4892 fprintf(fff, _(" [キャラクタの持ち物]\n\n", " [Character Inventory]\n\n"));
4894 for (i = 0; i < INVEN_PACK; i++)
4896 /* Don't dump the empty slots */
4897 if (!inventory[i].k_idx) break;
4899 /* Dump the inventory slots */
4900 object_desc(o_name, &inventory[i], 0);
4901 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
4904 /* Add an empty line */
4905 fprintf(fff, "\n\n");
4910 * @brief 我が家と博物館のオブジェクト情報をファイルにダンプする
4911 * @param fff ファイルポインタ
4914 static void dump_aux_home_museum(FILE *fff)
4916 char o_name[MAX_NLEN];
4919 /* Do we need it?? */
4920 /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
4922 /* Print the home */
4923 st_ptr = &town[1].store[STORE_HOME];
4925 /* Home -- if anything there */
4926 if (st_ptr->stock_num)
4931 fprintf(fff, _(" [我が家のアイテム]\n", " [Home Inventory]\n"));
4933 /* Dump all available items */
4934 for (i = 0; i < st_ptr->stock_num; i++)
4937 fprintf(fff, _("\n ( %d ページ )\n", "\n ( page %d )\n"), x++);
4938 object_desc(o_name, &st_ptr->stock[i], 0);
4939 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4942 /* Add an empty line */
4943 fprintf(fff, "\n\n");
4947 /* Print the home */
4948 st_ptr = &town[1].store[STORE_MUSEUM];
4950 /* Home -- if anything there */
4951 if (st_ptr->stock_num)
4956 fprintf(fff, _(" [博物館のアイテム]\n", " [Museum]\n"));
4958 /* Dump all available items */
4959 for (i = 0; i < st_ptr->stock_num; i++)
4962 if ((i % 12) == 0) fprintf(fff, "\n ( %d ページ )\n", x++);
4963 object_desc(o_name, &st_ptr->stock[i], 0);
4964 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4966 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4967 object_desc(o_name, &st_ptr->stock[i], 0);
4968 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4973 /* Add an empty line */
4974 fprintf(fff, "\n\n");
4980 * @brief ダンプ出力のメインルーチン
4981 * Output the character dump to a file
4982 * @param fff ファイルポインタ
4985 errr make_character_dump(FILE *fff)
4988 fprintf(fff, " [変愚蛮怒 %d.%d.%d キャラクタ情報]\n\n",
4989 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4991 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4992 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4997 dump_aux_display_player(fff);
4998 dump_aux_last_message(fff);
4999 dump_aux_options(fff);
5000 dump_aux_recall(fff);
5001 dump_aux_quest(fff);
5002 dump_aux_arena(fff);
5003 dump_aux_monsters(fff);
5004 dump_aux_virtues(fff);
5005 dump_aux_race_history(fff);
5006 dump_aux_realm_history(fff);
5007 dump_aux_class_special(fff);
5008 dump_aux_mutations(fff);
5011 dump_aux_equipment_inventory(fff);
5012 dump_aux_home_museum(fff);
5014 fprintf(fff, _(" [チェックサム: \"%s\"]\n\n", " [Check Sum: \"%s\"]\n\n"), get_check_sum());
5019 * @brief プレイヤーステータスをファイルダンプ出力する
5020 * Hack -- Dump a character description file
5021 * @param name 出力ファイル名
5024 * XXX XXX XXX Allow the "full" flag to dump additional info,
5025 * and trigger its usage from various places in the code.
5027 errr file_character(cptr name)
5033 /* Build the filename */
5034 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
5036 /* File type is "TEXT" */
5037 FILE_TYPE(FILE_TYPE_TEXT);
5039 /* Check for existing file */
5040 fd = fd_open(buf, O_RDONLY);
5047 /* Close the file */
5051 (void)sprintf(out_val, _("現存するファイル %s に上書きしますか? ", "Replace existing file %s? "), buf);
5054 if (get_check_strict(out_val, CHECK_NO_HISTORY)) fd = -1;
5057 /* Open the non-existing file */
5058 if (fd < 0) fff = my_fopen(buf, "w");
5064 prt(_("キャラクタ情報のファイルへの書き出しに失敗しました!", "Character dump failed!"), 0, 0);
5072 (void)make_character_dump(fff);
5079 msg_print(_("キャラクタ情報のファイルへの書き出しに成功しました。", "Character dump successful."));
5088 * @brief ファイル内容の一行をコンソールに出力する
5089 * Display single line of on-line help file
5090 * @param str 出力する文字列
5096 * You can insert some special color tag to change text color.
5098 * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
5099 * A colored segment is between "[[[[y|" and the last "|".
5100 * You can use any single character in place of the "|".
5103 static void show_file_aux_line(cptr str, int cy, cptr shower)
5105 static const char tag_str[] = "[[[[";
5106 byte color = TERM_WHITE;
5114 /* Make a lower case version of str for searching */
5119 /* Initial cursor position */
5120 Term_gotoxy(cx, cy);
5122 for (i = 0; str[i];)
5124 int len = strlen(&str[i]);
5125 int showercol = len + 1;
5126 int bracketcol = len + 1;
5130 /* Search for a shower string in the line */
5133 ptr = my_strstr(&lcstr[i], shower);
5134 if (ptr) showercol = ptr - &lcstr[i];
5137 /* Search for a color segment tag */
5138 ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
5139 if (ptr) bracketcol = ptr - &str[i];
5141 /* A color tag is found */
5142 if (bracketcol < endcol) endcol = bracketcol;
5144 /* The shower string is found before the color tag */
5145 if (showercol < endcol) endcol = showercol;
5147 /* Print a segment of the line */
5148 Term_addstr(endcol, color, &str[i]);
5152 /* Shower string? */
5153 if (endcol == showercol)
5155 int showerlen = strlen(shower);
5157 /* Print the shower string in yellow */
5158 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
5163 /* Colored segment? */
5164 else if (endcol == bracketcol)
5168 /* Found the end of colored segment */
5171 /* Now looking for an another tag_str */
5174 /* Set back to the default color */
5179 /* Found a tag_str, and get a tag color */
5180 i += sizeof(tag_str)-1;
5183 color = color_char_to_attr(str[i]);
5185 /* Illegal color tag */
5186 if (color == 255 || str[i+1] == '\0')
5188 /* Illegal color tag */
5191 /* Print the broken tag as a string */
5192 Term_addstr(-1, TERM_WHITE, tag_str);
5193 cx += sizeof(tag_str)-1;
5197 /* Skip the color tag */
5200 /* Now looking for a close tag */
5203 /* Skip the close-tag-indicator */
5209 } /* for (i = 0; str[i];) */
5211 /* Clear rest of line */
5212 Term_erase(cx, cy, 255);
5217 * @brief ファイル内容をコンソールに出力する
5218 * Recursive file perusal.
5219 * @param show_version TRUEならばコンソール上にゲームのバージョンを表示する
5220 * @param name ファイル名の文字列
5221 * @param what 内容キャプションの文字列
5222 * @param line 表示の現在行
5227 * Process various special text in the input file, including
5228 * the "menu" structures used by the "help file" system.
5229 * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
5232 bool show_file(bool show_version, cptr name, cptr what, int line, BIT_FLAGS mode)
5236 /* Number of "real" lines passed by */
5239 /* Number of "real" lines in the file */
5242 /* Backup value for "line" */
5245 /* This screen has sub-screens */
5248 /* Current help file */
5251 /* Find this string (if any) */
5254 /* Jump to this tag */
5257 /* Hold strings to find/show */
5258 char finder_str[81];
5259 char shower_str[81];
5262 /* String to show */
5266 char filename[1024];
5268 /* Describe this thing */
5274 /* General buffer */
5277 /* Sub-menu information */
5280 bool reverse = (line < 0);
5284 Term_get_size(&wid, &hgt);
5288 strcpy(finder_str, "");
5291 strcpy(shower_str, "");
5294 strcpy(caption, "");
5296 /* Wipe the hooks */
5297 for (i = 0; i < 68; i++)
5302 /* Copy the filename */
5303 strcpy(filename, name);
5305 n = strlen(filename);
5307 /* Extract the tag from the filename */
5308 for (i = 0; i < n; i++)
5310 if (filename[i] == '#')
5313 tag = filename + i + 1;
5318 /* Redirect the name */
5321 /* Hack XXX XXX XXX */
5325 strcpy(caption, what);
5327 /* Access the "file" */
5331 fff = my_fopen(path, "r");
5334 /* Look in "help" */
5338 sprintf(caption, _("ヘルプ・ファイル'%s'", "Help file '%s'"), name);
5340 /* Build the filename */
5341 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5344 fff = my_fopen(path, "r");
5347 /* Look in "info" */
5351 sprintf(caption, _("スポイラー・ファイル'%s'", "Info file '%s'"), name);
5353 /* Build the filename */
5354 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5357 fff = my_fopen(path, "r");
5360 /* Look in "info" */
5363 /* Build the filename */
5364 path_build(path, sizeof(path), ANGBAND_DIR, name);
5366 for (i = 0; path[i]; i++)
5367 if ('\\' == path[i])
5368 path[i] = PATH_SEP[0];
5371 sprintf(caption, _("スポイラー・ファイル'%s'", "Info file '%s'"), name);
5374 fff = my_fopen(path, "r");
5381 msg_format(_("'%s'をオープンできません。", "Cannot open '%s'."), name);
5389 /* Pre-Parse the file */
5394 /* Read a line or stop */
5395 if (my_fgets(fff, buf, sizeof(buf))) break;
5397 /* XXX Parse "menu" items */
5398 if (prefix(str, "***** "))
5400 /* Notice "menu" requests */
5401 if ((str[6] == '[') && isalpha(str[7]))
5403 /* Extract the menu item */
5404 int k = str[7] - 'A';
5406 /* This is a menu file */
5409 if ((str[8] == ']') && (str[9] == ' '))
5411 /* Extract the menu item */
5412 strncpy(hook[k], str + 10, 31);
5414 /* Make sure it's null-terminated */
5418 /* Notice "tag" requests */
5419 else if (str[6] == '<')
5421 size_t len = strlen(str);
5423 if (str[len - 1] == '>')
5425 str[len - 1] = '\0';
5426 if (tag && streq(str + 7, tag)) line = next;
5434 /* Count the "real" lines */
5438 /* Save the number of "real" lines */
5441 /* start from bottom when reverse mode */
5442 if (line == -1) line = ((size-1)/rows)*rows;
5447 /* Display the file */
5450 /* Restart when necessary */
5451 if (line >= size - rows) line = size - rows;
5452 if (line < 0) line = 0;
5454 /* Re-open the file if needed */
5460 /* Hack -- Re-Open the file */
5461 fff = my_fopen(path, "r");
5464 if (!fff) return (FALSE);
5466 /* File has been restarted */
5470 /* Goto the selected line */
5474 if (my_fgets(fff, buf, sizeof(buf))) break;
5476 /* Skip tags/links */
5477 if (prefix(buf, "***** ")) continue;
5479 /* Count the lines */
5483 /* Dump the next 20, or rows, lines of the file */
5484 for (i = 0; i < rows; )
5488 /* Hack -- track the "first" line */
5489 if (!i) line = next;
5491 /* Get a line of the file or stop */
5492 if (my_fgets(fff, buf, sizeof(buf))) break;
5494 /* Hack -- skip "special" lines */
5495 if (prefix(buf, "***** ")) continue;
5497 /* Count the "real" lines */
5500 /* Hack -- keep searching */
5505 /* Make a lower case version of str for searching */
5506 strcpy(lc_buf, str);
5507 str_tolower(lc_buf);
5509 if (!my_strstr(lc_buf, find)) continue;
5512 /* Hack -- stop searching */
5516 show_file_aux_line(str, i + 2, shower);
5518 /* Count the printed lines */
5524 /* Clear rest of line */
5525 Term_erase(0, i + 2, 255);
5530 /* Hack -- failed search */
5540 /* Show a general "title" */
5543 prt(format(_("[変愚蛮怒 %d.%d.%d, %s, %d/%d]", "[Hengband %d.%d.%d, %s, Line %d/%d]"),
5544 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5545 caption, line, size), 0, 0);
5549 prt(format(_("[%s, %d/%d]", "[%s, Line %d/%d]"),
5550 caption, line, size), 0, 0);
5553 /* Prompt -- small files */
5557 prt(_("[キー:(?)ヘルプ (ESC)終了]", "[Press ESC to exit.]"), hgt - 1, 0);
5560 /* Prompt -- large files */
5565 prt("[キー:(RET/スペース)↑ (-)↓ (?)ヘルプ (ESC)終了]", hgt - 1, 0);
5567 prt("[キー:(RET/スペース)↓ (-)↑ (?)ヘルプ (ESC)終了]", hgt - 1, 0);
5569 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5573 /* Get a special key code */
5574 skey = inkey_special(TRUE);
5578 /* Show the help for the help */
5580 /* Hack - prevent silly recursion */
5581 if (strcmp(name, _("jhelpinfo.txt", "helpinfo.txt")) != 0)
5582 show_file(TRUE, _("jhelpinfo.txt", "helpinfo.txt"), NULL, 0, mode);
5585 /* Hack -- try showing */
5588 prt(_("強調: ", "Show: "), hgt - 1, 0);
5590 strcpy(back_str, shower_str);
5591 if (askfor(shower_str, 80))
5595 /* Make it lowercase */
5596 str_tolower(shower_str);
5599 shower = shower_str;
5601 else shower = NULL; /* Stop showing */
5603 else strcpy(shower_str, back_str);
5606 /* Hack -- try finding */
5610 prt(_("検索: ", "Find: "), hgt - 1, 0);
5612 strcpy(back_str, finder_str);
5613 if (askfor(finder_str, 80))
5622 /* Make finder lowercase */
5623 str_tolower(finder_str);
5626 shower = finder_str;
5628 else shower = NULL; /* Stop showing */
5630 else strcpy(finder_str, back_str);
5633 /* Hack -- go to a specific line */
5637 prt(_("行: ", "Goto Line: "), hgt - 1, 0);
5640 if (askfor(tmp, 80)) line = atoi(tmp);
5644 /* Hack -- go to the top line */
5649 /* Hack -- go to the bottom line */
5651 line = ((size - 1) / rows) * rows;
5654 /* Hack -- go to a specific file */
5658 prt(_("ファイル・ネーム: ", "Goto File: "), hgt - 1, 0);
5659 strcpy(tmp, _("jhelp.hlp", "help.hlp"));
5661 if (askfor(tmp, 80))
5663 if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
5668 /* Allow backing up */
5670 line = line + (reverse ? rows : -rows);
5671 if (line < 0) line = 0;
5677 if (line < 0) line = 0;
5680 /* Advance a single line */
5683 line = line + (reverse ? -1 : 1);
5684 if (line < 0) line = 0;
5687 /* Move up / down */
5691 if (line < 0) line = 0;
5699 /* Advance one page */
5701 line = line + (reverse ? -rows : rows);
5702 if (line < 0) line = 0;
5711 /* Recurse on numbers */
5716 if (!(skey & SKEY_MASK) && isalpha(skey))
5719 if ((key > -1) && hook[key][0])
5721 /* Recurse on that file */
5722 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5727 /* Hack, dump to file */
5736 if (!get_string(_("ファイル名: ", "File name: "), xtmp, 80)) continue;
5741 /* Build the filename */
5742 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5744 /* Hack -- Re-Open the file */
5745 fff = my_fopen(path, "r");
5747 ffp = my_fopen(buff, "w");
5752 msg_print(_("ファイルを開けません。", "Failed to open file."));
5757 sprintf(xtmp, "%s: %s", p_ptr->name, what ? what : caption);
5758 my_fputs(ffp, xtmp, 80);
5759 my_fputs(ffp, "\n", 80);
5761 while (!my_fgets(fff, buff, sizeof(buff)))
5762 my_fputs(ffp, buff, 80);
5768 /* Hack -- Re-Open the file */
5769 fff = my_fopen(path, "r");
5772 /* Return to last screen */
5773 if ((skey == ESCAPE) || (skey == '<')) break;
5775 /* Exit on the ^q */
5776 if (skey == KTRL('q')) skey = 'q';
5778 /* Exit on the q key */
5779 if (skey == 'q') break;
5782 /* Close the file */
5786 if (skey == 'q') return (FALSE);
5794 * @brief ヘルプを表示するコマンドのメインルーチン
5795 * Peruse the On-Line-Help
5799 void do_cmd_help(void)
5804 /* Peruse the main help file */
5805 (void)show_file(TRUE, _("jhelp.hlp", "help.hlp"), NULL, 0, 0);
5813 * @brief プレイヤーの名前をチェックして修正する
5814 * Process the player name.
5815 * @param sf セーブファイル名に合わせた修正を行うならばTRUE
5818 * Extract a clean "base name".
5819 * Build the savefile name if needed.
5821 void process_player_name(bool sf)
5824 char old_player_base[32] = "";
5826 if (character_generated) strcpy(old_player_base, player_base);
5828 /* Cannot be too long */
5829 #if defined(MACINTOSH) || defined(ACORN)
5830 if (strlen(p_ptr->name) > 15)
5833 quit_fmt(_("'%s'という名前は長すぎます!", "The name '%s' is too long!"), p_ptr->name);
5837 /* Cannot contain "icky" characters */
5838 for (i = 0; p_ptr->name[i]; i++)
5840 /* No control characters */
5842 if (iskanji(p_ptr->name[i])){i++;continue;}
5843 if (iscntrl( (unsigned char)p_ptr->name[i]))
5845 if (iscntrl(p_ptr->name[i]))
5849 /* Illegal characters */
5850 quit_fmt(_("'%s' という名前は不正なコントロールコードを含んでいます。", "The name '%s' contains control chars!"), p_ptr->name);
5857 /* Extract "useful" letters */
5858 for (i = 0; p_ptr->name[i]; i++)
5861 unsigned char c = p_ptr->name[i];
5863 char c = p_ptr->name[i];
5867 /* Convert "dot" to "underscore" */
5868 if (c == '.') c = '_';
5870 /* Accept all the letters */
5871 player_base[k++] = c;
5876 /* Extract "useful" letters */
5877 for (i = 0; p_ptr->name[i]; i++)
5880 unsigned char c = p_ptr->name[i];
5882 char c = p_ptr->name[i];
5885 /* Accept some letters */
5888 if(k + 2 >= sizeof(player_base) || !p_ptr->name[i+1]) break;
5889 player_base[k++] = c;
5891 player_base[k++] = p_ptr->name[i];
5894 else if (iskana(c)) player_base[k++] = c;
5898 /* Convert path separator to underscore */
5899 if (!strncmp(PATH_SEP, p_ptr->name+i, strlen(PATH_SEP))){
5900 player_base[k++] = '_';
5901 i += strlen(PATH_SEP);
5903 /* Convert some characters to underscore */
5904 #if defined(WINDOWS)
5905 else if (my_strchr("\"*,/:;<>?\\|", c)) player_base[k++] = '_';
5907 else if (isprint(c)) player_base[k++] = c;
5913 player_base[k] = '\0';
5915 /* Require a "base" name */
5916 if (!player_base[0]) strcpy(player_base, "PLAYER");
5919 #ifdef SAVEFILE_MUTABLE
5925 if (!savefile_base[0] && savefile[0])
5932 t = my_strstr(s, PATH_SEP);
5937 strcpy(savefile_base, s);
5940 if (!savefile_base[0] || !savefile[0])
5943 /* Change the savefile name */
5948 strcpy(savefile_base, player_base);
5950 #ifdef SAVEFILE_USE_UID
5951 /* Rename the savefile, using the player_uid and player_base */
5952 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5954 /* Rename the savefile, using the player_base */
5955 (void)sprintf(temp, "%s", player_base);
5958 /* Build the filename */
5959 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
5962 /* Load an autopick preference file */
5963 if (character_generated)
5965 if (!streq(old_player_base, player_base)) autopick_load_pref(FALSE);
5971 * @brief プレイヤーの名前を変更するコマンドのメインルーチン
5972 * Gets a name for the character, reacting to name changes.
5976 * Assumes that "display_player(0)" has just been called
5977 * Perhaps we should NOT ask for a name (at "birth()") on
5978 * Unix machines? XXX XXX
5979 * What a horrible name for a global function. XXX XXX XXX
5986 /* Save the player name */
5987 strcpy(tmp, p_ptr->name);
5989 /* Prompt for a new name */
5990 if (get_string(_("キャラクターの名前を入力して下さい: ", "Enter a name for your character: "), tmp, 15))
5993 strcpy(p_ptr->name, tmp);
5996 if (0 == strlen(p_ptr->name))
5998 /* Use default name */
5999 strcpy(p_ptr->name, "PLAYER");
6002 strcpy(tmp,ap_ptr->title);
6009 strcat(tmp,p_ptr->name);
6011 /* Re-Draw the name (in light blue) */
6012 Term_erase(34, 1, 255);
6013 c_put_str(TERM_L_BLUE, tmp, 1, 34);
6015 /* Erase the prompt, etc */
6022 * @brief 自殺するコマンドのメインルーチン
6023 * Hack -- commit suicide
6027 void do_cmd_suicide(void)
6034 /* Verify Retirement */
6035 if (p_ptr->total_winner)
6038 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
6041 /* Verify Suicide */
6045 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
6049 if (!p_ptr->noscore)
6051 /* Special Verification for suicide */
6052 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
6057 if (i != '@') return;
6059 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
6062 /* Initialize "last message" buffer */
6063 if (p_ptr->last_message) string_free(p_ptr->last_message);
6064 p_ptr->last_message = NULL;
6066 /* Hack -- Note *winning* message */
6067 if (p_ptr->total_winner && last_words)
6069 char buf[1024] = "";
6070 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
6073 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf)) ;
6075 while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
6079 p_ptr->last_message = string_make(buf);
6080 msg_print(p_ptr->last_message);
6085 p_ptr->playing = FALSE;
6087 /* Kill the player */
6088 p_ptr->is_dead = TRUE;
6091 p_ptr->leaving = TRUE;
6093 if (!p_ptr->total_winner)
6095 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
6096 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
6097 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
6100 /* Cause of death */
6101 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));
6106 * @brief セーブするコマンドのメインルーチン
6108 * @param is_autosave オートセーブ中の処理ならばTRUE
6112 void do_cmd_save_game(int is_autosave)
6114 /* Autosaves do not disturb */
6117 msg_print(_("自動セーブ中", "Autosaving the game..."));
6121 /* Disturb the player */
6125 /* Clear messages */
6132 prt(_("ゲームをセーブしています...", "Saving game..."), 0, 0);
6137 /* The player is not dead */
6138 (void)strcpy(p_ptr->died_from, _("(セーブ)", "(saved)"));
6140 /* Forbid suspend */
6141 signals_ignore_tstp();
6143 /* Save the player */
6146 prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0);
6149 /* Save failed (oops) */
6152 prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0);
6155 /* Allow suspend again */
6156 signals_handle_tstp();
6161 /* Note that the player is not dead */
6162 (void)strcpy(p_ptr->died_from, _("(元気に生きている)", "(alive and well)"));
6164 /* HACK -- don't get sanity blast on updating view */
6165 is_loading_now = FALSE;
6170 /* Initialize monster process */
6173 /* HACK -- reset the hackish flag */
6174 is_loading_now = TRUE;
6179 * @brief セーブ後にゲーム中断フラグを立てる/
6180 * Save the game and exit
6184 void do_cmd_save_and_exit(void)
6186 p_ptr->playing = FALSE;
6189 p_ptr->leaving = TRUE;
6190 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
6196 * Hack -- Calculates the total number of points earned -JWT-
6200 long total_points(void)
6204 u32b point, point_h, point_l;
6205 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6207 if (!preserve_mode) mult += 10;
6208 if (!autoroller) mult += 10;
6209 if (!smart_learn) mult -= 20;
6210 if (smart_cheat) mult += 30;
6211 if (ironman_shops) mult += 50;
6212 if (ironman_small_levels) mult += 10;
6213 if (ironman_empty_levels) mult += 20;
6214 if (!powerup_home) mult += 50;
6215 if (ironman_rooms) mult += 100;
6216 if (ironman_nightmare) mult += 100;
6218 if (mult < 5) mult = 5;
6220 for (i = 0; i < max_d_idx; i++)
6221 if(max_dlv[i] > max_dl)
6222 max_dl = max_dlv[i];
6224 point_l = (p_ptr->max_max_exp + (100 * max_dl));
6225 point_h = point_l / 0x10000L;
6226 point_l = point_l % 0x10000L;
6229 point_h += point_l / 0x10000L;
6230 point_l %= 0x10000L;
6232 point_l += ((point_h % 100) << 16);
6236 point = (point_h << 16) + (point_l);
6237 if (p_ptr->arena_number >= 0)
6238 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6240 if (ironman_downward) point *= 2;
6241 if (p_ptr->pclass == CLASS_BERSERKER)
6243 if ( p_ptr->prace == RACE_SPECTRE )
6247 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6250 if (p_ptr->total_winner) point = 2;
6252 if (easy_band) point = (0 - point);
6258 #define GRAVE_LINE_WIDTH 31
6261 * @brief 墓石の真ん中に文字列を書き込む /
6262 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
6266 static void center_string(char *buf, cptr str)
6273 /* Necessary border */
6274 j = GRAVE_LINE_WIDTH / 2 - i / 2;
6277 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
6284 * Save a "bones" file for a dead character
6287 * Note that we will not use these files until Angband 2.8.0, and
6288 * then we will only use the name and level on which death occured.
6289 * Should probably attempt some form of locking...
6292 static void make_bones(void)
6299 /* Ignore wizards and borgs */
6300 if (!(p_ptr->noscore & 0x00FF))
6302 /* Ignore people who die in town */
6307 /* XXX XXX XXX "Bones" name */
6308 sprintf(tmp, "bone.%03d", dun_level);
6310 /* Build the filename */
6311 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6313 /* Attempt to open the bones file */
6314 fp = my_fopen(str, "r");
6316 /* Close it right away */
6317 if (fp) my_fclose(fp);
6319 /* Do not over-write a previous ghost */
6322 /* File type is "TEXT" */
6323 FILE_TYPE(FILE_TYPE_TEXT);
6325 /* Grab permissions */
6328 /* Try to write a new "Bones File" */
6329 fp = my_fopen(str, "w");
6331 /* Drop permissions */
6334 /* Not allowed to write it? Weird. */
6338 fprintf(fp, "%s\n", p_ptr->name);
6339 fprintf(fp, "%d\n", p_ptr->mhp);
6340 fprintf(fp, "%d\n", p_ptr->prace);
6341 fprintf(fp, "%d\n", p_ptr->pclass);
6343 /* Close and save the Bones file */
6352 * Redefinable "print_tombstone" action
6354 bool (*tombstone_aux)(void) = NULL;
6358 * @brief 墓石のアスキーアート表示 /
6359 * Display a "tomb-stone"
6362 static void print_tomb(void)
6366 /* Do we use a special tombstone ? */
6369 /* Use tombstone hook */
6370 done = (*tombstone_aux)();
6373 /* Print the text-tombstone */
6382 time_t ct = time((time_t)0);
6390 /* Build the filename */
6391 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("dead_j.txt", "dead.txt"));
6393 /* Open the News file */
6394 fp = my_fopen(buf, "r");
6401 /* Dump the file to the screen */
6402 while (0 == my_fgets(fp, buf, sizeof(buf)))
6404 /* Display and advance */
6405 put_str(buf, i++, 0);
6413 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6426 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6429 center_string(buf, p_ptr->name);
6430 put_str(buf, 6, 11);
6433 center_string(buf, "the");
6434 put_str(buf, 7, 11);
6437 center_string(buf, p);
6438 put_str(buf, 8, 11);
6440 center_string(buf, cp_ptr->title);
6441 put_str(buf, 10, 11);
6443 (void)sprintf(tmp, _("レベル: %d", "Level: %d"), (int)p_ptr->lev);
6444 center_string(buf, tmp);
6445 put_str(buf, 11, 11);
6447 (void)sprintf(tmp, _("経験値: %ld", "Exp: %ld"), (long)p_ptr->exp);
6448 center_string(buf, tmp);
6449 put_str(buf, 12, 11);
6451 (void)sprintf(tmp, _("所持金: %ld", "AU: %ld"), (long)p_ptr->au);
6452 center_string(buf, tmp);
6453 put_str(buf, 13, 11);
6456 /* 墓に刻む言葉をオリジナルより細かく表示 */
6457 if (streq(p_ptr->died_from, "途中終了"))
6459 strcpy(tmp, "<自殺>");
6461 else if (streq(p_ptr->died_from, "ripe"))
6463 strcpy(tmp, "引退後に天寿を全う");
6465 else if (streq(p_ptr->died_from, "Seppuku"))
6467 strcpy(tmp, "勝利の後、切腹");
6471 roff_to_buf(p_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6472 t = tmp + strlen(tmp) + 1;
6475 strcpy(dummy, t); /* 2nd line */
6476 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6478 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
6481 else if (my_strstr(tmp, "『") && suffix(dummy, "』"))
6484 char *name_head = my_strstr(tmp, "『");
6485 sprintf(dummy2, "%s%s", name_head, dummy);
6486 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6488 strcpy(dummy, dummy2);
6492 else if (my_strstr(tmp, "「") && suffix(dummy, "」"))
6495 char *name_head = my_strstr(tmp, "「");
6496 sprintf(dummy2, "%s%s", name_head, dummy);
6497 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6499 strcpy(dummy, dummy2);
6503 center_string(buf, dummy);
6504 put_str(buf, 15, 11);
6508 center_string(buf, tmp);
6509 put_str(buf, 14, 11);
6511 if (!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6515 cptr field_name = p_ptr->town_num ? "街" : "荒野";
6516 if (streq(p_ptr->died_from, "途中終了"))
6518 sprintf(tmp, "%sで死んだ", field_name);
6522 sprintf(tmp, "に%sで殺された", field_name);
6527 if (streq(p_ptr->died_from, "途中終了"))
6529 sprintf(tmp, "地下 %d 階で死んだ", (int)dun_level);
6533 sprintf(tmp, "に地下 %d 階で殺された", (int)dun_level);
6536 center_string(buf, tmp);
6537 put_str(buf, 15 + extra_line, 11);
6540 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6541 center_string(buf, tmp);
6542 put_str(buf, 14, 11);
6544 roff_to_buf(format("by %s.", p_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6545 center_string(buf, tmp);
6546 put_str(buf, 15, 11);
6547 t = tmp + strlen(tmp) + 1;
6550 strcpy(dummy, t); /* 2nd line */
6551 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6553 int dummy_len = strlen(dummy);
6554 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
6556 center_string(buf, dummy);
6557 put_str(buf, 16, 11);
6561 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6562 center_string(buf, tmp);
6563 put_str(buf, 17, 11);
6564 msg_format(_("さようなら、%s!", "Goodbye, %s!"), p_ptr->name);
6570 * @brief 死亡、引退時の簡易ステータス表示 /
6571 * Display some character info
6574 static void show_info(void)
6580 /* Hack -- Know everything in the inven/equip */
6581 for (i = 0; i < INVEN_TOTAL; i++)
6583 o_ptr = &inventory[i];
6585 /* Skip non-objects */
6586 if (!o_ptr->k_idx) continue;
6588 /* Aware and Known */
6589 object_aware(o_ptr);
6590 object_known(o_ptr);
6593 for (i = 1; i < max_towns; i++)
6595 st_ptr = &town[i].store[STORE_HOME];
6597 /* Hack -- Know everything in the home */
6598 for (j = 0; j < st_ptr->stock_num; j++)
6600 o_ptr = &st_ptr->stock[j];
6602 /* Skip non-objects */
6603 if (!o_ptr->k_idx) continue;
6605 /* Aware and Known */
6606 object_aware(o_ptr);
6607 object_known(o_ptr);
6611 /* Hack -- Recalculate bonuses */
6612 p_ptr->update |= (PU_BONUS);
6617 /* Flush all input keys */
6620 /* Flush messages */
6624 /* Describe options */
6625 prt(_("キャラクターの記録をファイルに書き出すことができます。", "You may now dump a character record to one or more files."), 21, 0);
6626 prt(_("リターンキーでキャラクターを見ます。ESCで中断します。", "Then, hit RETURN to see the character, or ESC to abort."), 22, 0);
6628 /* Dump character records as requested */
6634 put_str(_("ファイルネーム: ", "Filename: "), 23, 0);
6637 strcpy(out_val, "");
6639 /* Ask for filename (or abort) */
6640 if (!askfor(out_val, 60)) return;
6642 /* Return means "show on screen" */
6643 if (!out_val[0]) break;
6648 /* Dump a character file */
6649 (void)file_character(out_val);
6657 /* Display player */
6660 /* Prompt for inventory */
6661 prt(_("何かキーを押すとさらに情報が続きます (ESCで中断): ", "Hit any key to see more information (ESC to abort): "), 23, 0);
6663 /* Allow abort at this point */
6664 if (inkey() == ESCAPE) return;
6667 /* Show equipment and inventory */
6669 /* Equipment -- if any */
6673 item_tester_full = TRUE;
6674 (void)show_equip(0);
6675 prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
6677 if (inkey() == ESCAPE) return;
6680 /* Inventory -- if any */
6684 item_tester_full = TRUE;
6685 (void)show_inven(0);
6686 prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
6688 if (inkey() == ESCAPE) return;
6691 /* Homes in the different towns */
6692 for (l = 1; l < max_towns; l++)
6694 st_ptr = &town[l].store[STORE_HOME];
6696 /* Home -- if anything there */
6697 if (st_ptr->stock_num)
6699 /* Display contents of the home */
6700 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6706 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6708 char o_name[MAX_NLEN];
6712 o_ptr = &st_ptr->stock[i];
6714 /* Print header, clear line */
6715 sprintf(tmp_val, "%c) ", I2A(j));
6716 prt(tmp_val, j+2, 4);
6718 /* Display object description */
6719 object_desc(o_name, o_ptr, 0);
6720 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6724 prt(format(_("我が家に置いてあったアイテム ( %d ページ): -続く-", "Your home contains (page %d): -more-"), k+1), 0, 0);
6727 if (inkey() == ESCAPE) return;
6735 * Display some character info
6738 static bool check_score(void)
6744 if (highscore_fd < 0)
6746 msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
6751 #ifndef SCORE_WIZARDS
6752 /* Wizard-mode pre-empts scoring */
6753 if (p_ptr->noscore & 0x000F)
6755 msg_print(_("ウィザード・モードではスコアが記録されません。", "Score not registered for wizards."));
6762 /* Borg-mode pre-empts scoring */
6763 if (p_ptr->noscore & 0x00F0)
6765 msg_print(_("ボーグ・モードではスコアが記録されません。", "Score not registered for borgs."));
6771 #ifndef SCORE_CHEATERS
6772 /* Cheaters are not scored */
6773 if (p_ptr->noscore & 0xFF00)
6775 msg_print(_("詐欺をやった人はスコアが記録されません。", "Score not registered for cheaters."));
6782 if (!p_ptr->total_winner && streq(p_ptr->died_from, _("強制終了", "Interrupting")))
6784 msg_print(_("強制終了のためスコアが記録されません。", "Score not registered due to interruption."));
6790 if (!p_ptr->total_winner && streq(p_ptr->died_from, _("途中終了", "Quitting")))
6792 msg_print(_("途中終了のためスコアが記録されません。", "Score not registered due to quitting."));
6801 * Close up the current game (player may or may not be dead)
6805 * This function is called only from "main.c" and "signals.c".
6808 void close_game(void)
6811 bool do_send = TRUE;
6813 /* cptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
6818 /* Flush the messages */
6821 /* Flush the input */
6825 /* No suspending now */
6826 signals_ignore_tstp();
6829 /* Hack -- Character is now "icky" */
6830 character_icky = TRUE;
6833 /* Build the filename */
6834 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6836 /* Grab permissions */
6839 /* Open the high score file, for reading/writing */
6840 highscore_fd = fd_open(buf, O_RDWR);
6842 /* Drop permissions */
6848 /* Handle retirement */
6849 if (p_ptr->total_winner) kingly();
6852 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
6854 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6856 else do_send = FALSE;
6863 /* Show more info */
6871 if ((!send_world_score(do_send)))
6873 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
6874 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6876 p_ptr->wait_report_score = TRUE;
6877 p_ptr->is_dead = FALSE;
6878 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6881 if (!p_ptr->wait_report_score)
6884 else if (highscore_fd >= 0)
6886 display_scores_aux(0, 10, -1, NULL);
6889 /* Dump bones file */
6898 do_cmd_save_game(FALSE);
6900 /* Prompt for scores XXX XXX XXX */
6901 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
6902 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
6904 /* Predict score (or ESCAPE) */
6905 if (inkey() != ESCAPE) predict_score();
6909 /* Shut the high score file */
6910 (void)fd_close(highscore_fd);
6912 /* Forget the high score fd */
6915 /* Kill all temporal files */
6916 clear_saved_floor_files();
6918 /* Allow suspending now */
6919 signals_handle_tstp();
6924 * @brief 異常発生時のゲーム緊急終了処理 /
6925 * Handle abrupt death of the visual system
6929 * This routine is called only in very rare situations, and only
6930 * by certain visual systems, when they experience fatal errors.
6931 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6932 * save file so that player can see tombstone when restart.
6935 void exit_game_panic(void)
6937 /* If nothing important has happened, just quit */
6938 if (!character_generated || character_saved) quit(_("緊急事態", "panic"));
6940 /* Mega-Hack -- see "msg_print()" */
6943 /* Clear the top line */
6946 /* Hack -- turn off some things */
6949 /* Mega-Hack -- Delay death */
6950 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
6952 /* Hardcode panic save */
6953 p_ptr->panic_save = 1;
6955 /* Forbid suspend */
6956 signals_ignore_tstp();
6958 /* Indicate panic save */
6959 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
6961 /* Panic save, or get worried */
6962 if (!save_player()) quit(_("緊急セーブ失敗!", "panic save failed!"));
6964 /* Successful panic save */
6965 quit(_("緊急セーブ成功!", "panic save succeeded!"));
6970 * @brief ファイルからランダムに行を一つ取得する /
6971 * Get a random line from a file
6972 * @param file_name ファイル名
6973 * @param entry 特定条件時のN:タグヘッダID
6974 * @param output 出力先の文字列参照ポインタ
6978 * Based on the monster speech patch by Matt Graham,
6981 errr get_rnd_line(cptr file_name, int entry, char *output)
6989 /* Build the filename */
6990 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
6993 fp = my_fopen(buf, "r");
6998 /* Find the entry of the monster */
7001 /* Get a line from the file */
7002 if (my_fgets(fp, buf, sizeof(buf)) == 0)
7004 /* Count the lines */
7007 /* Look for lines starting with 'N:' */
7008 if ((buf[0] == 'N') && (buf[1] == ':'))
7010 /* Allow default lines */
7016 else if (buf[2] == 'M')
7018 if (r_info[entry].flags1 & RF1_MALE) break;
7020 else if (buf[2] == 'F')
7022 if (r_info[entry].flags1 & RF1_FEMALE) break;
7024 /* Get the monster number */
7025 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
7027 /* Is it the right number? */
7028 if (test == entry) break;
7032 /* Error while converting the number */
7033 msg_format("Error in line %d of %s!", line_num, file_name);
7041 /* Reached end of file */
7047 /* Get the random line */
7048 for (counter = 0; ; counter++)
7052 test = my_fgets(fp, buf, sizeof(buf));
7054 /* Count the lines */
7055 /* line_num++; No more needed */
7059 /* Ignore lines starting with 'N:' */
7060 if ((buf[0] == 'N') && (buf[1] == ':')) continue;
7062 if (buf[0] != '#') break;
7071 if (one_in_(counter + 1)) strcpy(output, buf);
7074 /* Close the file */
7078 return counter ? 0 : -1;
7084 * @brief ファイルからランダムに行を一つ取得する(日本語文字列のみ) /
7085 * @param file_name ファイル名
7086 * @param entry 特定条件時のN:タグヘッダID
7087 * @param output 出力先の文字列参照ポインタ
7092 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7097 for (i = 0; i < count; i++)
7099 result = get_rnd_line(file_name, entry, output);
7102 for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
7110 * @brief 自動拾いファイルを読み込む /
7114 errr process_autopick_file(cptr name)
7120 /* Build the filename */
7121 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7123 err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
7131 * @brief プレイヤーの生い立ちファイルを読み込む /
7132 * Process file for player's history editor.
7137 errr process_histpref_file(cptr name)
7141 bool old_character_xtra = character_xtra;
7143 /* Build the filename */
7144 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7146 /* Hack -- prevent modification birth options in this file */
7147 character_xtra = TRUE;
7149 err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
7151 character_xtra = old_character_xtra;
7158 * @brief ファイル位置をシーク /
7159 * @param fd ファイルディスクリプタ
7160 * @param where ファイルバイト位置
7161 * @param flag FALSEならば現ファイルを超えた位置へシーク時エラー、TRUEなら足りない間を0で埋め尽くす
7165 static errr counts_seek(int fd, u32b where, bool flag)
7168 char temp1[128], temp2[128];
7169 u32b zero_header[3] = {0L, 0L, 0L};
7172 #ifdef SAVEFILE_USE_UID
7173 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7175 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7177 for (i = 0; temp1[i]; i++)
7178 temp1[i] ^= (i+1) * 63;
7183 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7185 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7190 fd_seek(fd, seekpoint);
7191 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7192 fd_write(fd, (char*)(temp1), sizeof(temp1));
7196 if (strcmp(temp1, temp2) == 0)
7199 seekpoint += 128 + 3 * sizeof(u32b);
7202 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7206 * @brief ファイル位置を読み込む
7207 * @param where ファイルバイト位置
7211 u32b counts_read(int where)
7217 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
7218 fd = fd_open(buf, O_RDONLY);
7220 if (counts_seek(fd, where, FALSE) ||
7221 fd_read(fd, (char*)(&count), sizeof(u32b)))
7230 * @brief ファイル位置に書き込む /
7231 * @param where ファイルバイト位置
7232 * @param count 書き込む値
7236 errr counts_write(int where, u32b count)
7242 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
7244 /* Grab permissions */
7247 fd = fd_open(buf, O_RDWR);
7249 /* Drop permissions */
7254 /* File type is "DATA" */
7255 FILE_TYPE(FILE_TYPE_DATA);
7257 /* Grab permissions */
7260 /* Create a new high score file */
7261 fd = fd_make(buf, 0644);
7263 /* Drop permissions */
7267 /* Grab permissions */
7270 err = fd_lock(fd, F_WRLCK);
7272 /* Drop permissions */
7277 counts_seek(fd, where, TRUE);
7278 fd_write(fd, (char*)(&count), sizeof(u32b));
7280 /* Grab permissions */
7283 err = fd_lock(fd, F_UNLCK);
7285 /* Drop permissions */
7296 #ifdef HANDLE_SIGNALS
7303 * @brief OSからのシグナルを受けてサスペンド状態に入る /
7304 * Handle signals -- suspend
7305 * @param sig 受け取ったシグナル
7307 * Actually suspend the game, and then resume cleanly
7309 static void handle_signal_suspend(int sig)
7311 /* Disable handler */
7312 (void)signal(sig, SIG_IGN);
7319 /* Suspend the "Term" */
7320 Term_xtra(TERM_XTRA_ALIVE, 0);
7322 /* Suspend ourself */
7323 (void)kill(0, SIGSTOP);
7325 /* Resume the "Term" */
7326 Term_xtra(TERM_XTRA_ALIVE, 1);
7328 /* Redraw the term */
7331 /* Flush the term */
7336 /* Restore handler */
7337 (void)signal(sig, handle_signal_suspend);
7342 * @brief OSからのシグナルを受けて中断、終了する /
7343 * Handle signals -- simple (interrupt and quit)
7344 * @param sig 受け取ったシグナル
7347 * This function was causing a *huge* number of problems, so it has
7348 * been simplified greatly. We keep a global variable which counts
7349 * the number of times the user attempts to kill the process, and
7350 * we commit suicide if the user does this a certain number of times.
7351 * We attempt to give "feedback" to the user as he approaches the
7352 * suicide thresh-hold, but without penalizing accidental keypresses.
7353 * To prevent messy accidents, we should reset this global variable
7354 * whenever the user enters a keypress, or something like that.
7357 static void handle_signal_simple(int sig)
7359 /* Disable handler */
7360 (void)signal(sig, SIG_IGN);
7363 /* Nothing to save, just quit */
7364 if (!character_generated || character_saved) quit(NULL);
7367 /* Count the signals */
7371 /* Terminate dead characters */
7374 /* Mark the savefile */
7375 (void)strcpy(p_ptr->died_from, _("強制終了", "Abortion"));
7385 quit(_("強制終了", "interrupt"));
7388 /* Allow suicide (after 5) */
7389 else if (signal_count >= 5)
7391 /* Cause of "death" */
7392 (void)strcpy(p_ptr->died_from, _("強制終了中", "Interrupting"));
7399 p_ptr->playing = FALSE;
7402 p_ptr->is_dead = TRUE;
7405 p_ptr->leaving = TRUE;
7411 quit(_("強制終了", "interrupt"));
7414 /* Give warning (after 4) */
7415 else if (signal_count >= 4)
7418 Term_xtra(TERM_XTRA_NOISE, 0);
7420 /* Clear the top line */
7421 Term_erase(0, 0, 255);
7423 /* Display the cause */
7424 Term_putstr(0, 0, -1, TERM_WHITE, _("熟慮の上の自殺!", "Contemplating suicide!"));
7430 /* Give warning (after 2) */
7431 else if (signal_count >= 2)
7434 Term_xtra(TERM_XTRA_NOISE, 0);
7437 /* Restore handler */
7438 (void)signal(sig, handle_signal_simple);
7443 * @brief OSからのシグナルを受けて強制終了する /
7444 * Handle signal -- abort, kill, etc
7445 * @param sig 受け取ったシグナル
7449 * This function was causing a *huge* number of problems, so it has
7450 * been simplified greatly. We keep a global variable which counts
7451 * the number of times the user attempts to kill the process, and
7452 * we commit suicide if the user does this a certain number of times.
7453 * We attempt to give "feedback" to the user as he approaches the
7454 * suicide thresh-hold, but without penalizing accidental keypresses.
7455 * To prevent messy accidents, we should reset this global variable
7456 * whenever the user enters a keypress, or something like that.
7459 static void handle_signal_abort(int sig)
7463 Term_get_size(&wid, &hgt);
7465 /* Disable handler */
7466 (void)signal(sig, SIG_IGN);
7469 /* Nothing to save, just quit */
7470 if (!character_generated || character_saved) quit(NULL);
7477 /* Clear the bottom line */
7478 Term_erase(0, hgt - 1, 255);
7480 /* Give a warning */
7481 Term_putstr(0, hgt - 1, -1, TERM_RED,
7482 _("恐ろしいソフトのバグが飛びかかってきた!", "A gruesome software bug LEAPS out at you!"));
7486 Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ...", "Panic save..."));
7488 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム異常終了----", "---- Panic Save and Abort Game ----"));
7494 p_ptr->panic_save = 1;
7497 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
7499 /* Forbid suspend */
7500 signals_ignore_tstp();
7502 /* Attempt to save */
7505 Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
7511 Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ失敗!", "Panic save failed!"));
7518 quit(_("ソフトのバグ", "software bug"));
7522 * @brief OSからのSIGTSTPシグナルを無視する関数 /
7523 * Ignore SIGTSTP signals (keyboard suspend)
7527 void signals_ignore_tstp(void)
7531 (void)signal(SIGTSTP, SIG_IGN);
7537 * @brief OSからのSIGTSTPシグナルハンドラ /
7538 * Handle SIGTSTP signals (keyboard suspend)
7542 void signals_handle_tstp(void)
7546 (void)signal(SIGTSTP, handle_signal_suspend);
7553 * @brief OSからのシグナルハンドルを初期化する /
7554 * Prepare to handle the relevant signals
7558 void signals_init(void)
7562 (void)signal(SIGHUP, SIG_IGN);
7567 (void)signal(SIGTSTP, handle_signal_suspend);
7572 (void)signal(SIGINT, handle_signal_simple);
7576 (void)signal(SIGQUIT, handle_signal_simple);
7581 (void)signal(SIGFPE, handle_signal_abort);
7585 (void)signal(SIGILL, handle_signal_abort);
7589 (void)signal(SIGTRAP, handle_signal_abort);
7593 (void)signal(SIGIOT, handle_signal_abort);
7597 (void)signal(SIGKILL, handle_signal_abort);
7601 (void)signal(SIGBUS, handle_signal_abort);
7605 (void)signal(SIGSEGV, handle_signal_abort);
7609 (void)signal(SIGTERM, handle_signal_abort);
7613 (void)signal(SIGPIPE, handle_signal_abort);
7617 (void)signal(SIGEMT, handle_signal_abort);
7621 (void)signal(SIGDANGER, handle_signal_abort);
7625 (void)signal(SIGSYS, handle_signal_abort);
7629 (void)signal(SIGXCPU, handle_signal_abort);
7633 (void)signal(SIGPWR, handle_signal_abort);
7639 #else /* HANDLE_SIGNALS */
7646 void signals_ignore_tstp(void)
7654 void signals_handle_tstp(void)
7662 void signals_init(void)
7665 #endif /* HANDLE_SIGNALS */