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_OLD_DRAIN", GF_OLD_DRAIN },
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_CONTROL_LIVING", GF_CONTROL_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 = (SYMBOL_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 = (SYMBOL_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 = (SYMBOL_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 = (SYMBOL_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 = (SYMBOL_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 = (SYMBOL_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 = (SYMBOL_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_BLOWS 28
1518 #define ENTRY_SHOTS 29
1519 #define ENTRY_AVG_DMG 30
1520 #define ENTRY_INFRA 31
1522 #define ENTRY_NAME 32
1523 #define ENTRY_SEX 33
1524 #define ENTRY_RACE 34
1525 #define ENTRY_CLASS 35
1526 #define ENTRY_REALM 36
1527 #define ENTRY_PATRON 37
1528 #define ENTRY_AGE 38
1529 #define ENTRY_HEIGHT 39
1530 #define ENTRY_WEIGHT 40
1531 #define ENTRY_SOCIAL 41
1532 #define ENTRY_ALIGN 42
1534 #define ENTRY_EXP_ANDR 43
1535 #define ENTRY_EXP_TO_ADV_ANDR 44
1544 } disp_player_line[]
1547 { 1, 10, 25, "打撃修正(格闘)"},
1548 { 1, 10, 25, "打撃修正(両手)"},
1549 { 1, 10, 25, "打撃修正(右手)"},
1550 { 1, 10, 25, "打撃修正(左手)"},
1551 { 1, 11, 25, "打撃修正(左手)"},
1552 { 1, 11, 25, "打撃修正(右手)"},
1554 { 1, 15, 25, "射撃攻撃修正"},
1555 { 1, 16, 25, "射撃武器倍率"},
1558 {29, 13, 21, "レベル"},
1559 {29, 14, 21, "経験値"},
1560 {29, 15, 21, "最大経験"},
1561 {29, 16, 21, "次レベル"},
1562 {29, 17, 21, "所持金"},
1566 {29, 20, 21, "プレイ時間"},
1567 {53, 10, -1, "打撃命中 :"},
1568 {53, 11, -1, "射撃命中 :"},
1569 {53, 12, -1, "魔法防御 :"},
1570 {53, 13, -1, "隠密行動 :"},
1571 {53, 15, -1, "知覚 :"},
1572 {53, 16, -1, "探索 :"},
1573 {53, 17, -1, "解除 :"},
1574 {53, 18, -1, "魔法道具 :"},
1575 { 1, 12, 25, "打撃回数"},
1576 { 1, 17, 25, "射撃回数"},
1577 { 1, 13, 25, "平均ダメージ"},
1578 {53, 20, -1, "赤外線視力:"},
1579 {26, 1, -1, "名前 : "},
1580 { 1, 3, -1, "性別 : "},
1581 { 1, 4, -1, "種族 : "},
1582 { 1, 5, -1, "職業 : "},
1583 { 1, 6, -1, "魔法 : "},
1584 { 1, 7, -1, "守護魔神 : "},
1588 {29, 6, 21, "社会的地位"},
1590 {29, 14, 21, "強化度"},
1591 {29, 16, 21, "次レベル"},
1595 { 1, 10, 25, "Bare hand"},
1596 { 1, 10, 25, "Two hands"},
1597 { 1, 10, 25, "Right hand"},
1598 { 1, 10, 25, "Left hand"},
1599 { 1, 11, 25, "Left hand"},
1600 { 1, 11, 25, "Right hand"},
1601 { 1, 11, 25, "Posture"},
1602 { 1, 15, 25, "Shooting"},
1603 { 1, 16, 25, "Multiplier"},
1604 { 1, 20, 25, "Speed"},
1606 {29, 13, 21, "Level"},
1607 {29, 14, 21, "Experience"},
1608 {29, 15, 21, "Max Exp"},
1609 {29, 16, 21, "Exp to Adv"},
1610 {29, 17, 21, "Gold"},
1611 {29, 19, 21, "Time"},
1612 {29, 10, 21, "Hit point"},
1613 {29, 11, 21, "SP (Mana)"},
1614 {29, 20, 21, "Play time"},
1615 {53, 10, -1, "Fighting : "},
1616 {53, 11, -1, "Bows/Throw : "},
1617 {53, 12, -1, "SavingThrow: "},
1618 {53, 13, -1, "Stealth : "},
1619 {53, 15, -1, "Perception : "},
1620 {53, 16, -1, "Searching : "},
1621 {53, 17, -1, "Disarming : "},
1622 {53, 18, -1, "MagicDevice: "},
1623 { 1, 12, 25, "Blows/Round"},
1624 { 1, 17, 25, "Shots/Round"},
1625 { 1, 13, 25, "AverageDmg/Rnd"},
1626 {53, 20, -1, "Infra-Vision: "},
1627 {26, 1, -1, "Name : "},
1628 { 1, 3, -1, "Sex : "},
1629 { 1, 4, -1, "Race : "},
1630 { 1, 5, -1, "Class : "},
1631 { 1, 6, -1, "Magic : "},
1632 { 1, 7, -1, "Patron : "},
1634 {29, 4, 21, "Height"},
1635 {29, 5, 21, "Weight"},
1636 {29, 6, 21, "Social Class"},
1637 {29, 7, 21, "Align"},
1638 {29, 14, 21, "Construction"},
1639 {29, 16, 21, "Const to Adv"},
1644 * @brief プレイヤーのステータス1種を出力する
1646 * @param val 値を保管した文字列ポインタ
1647 * @param attr 項目表示の色
1650 static void display_player_one_line(int entry, cptr val, byte attr)
1654 int row = disp_player_line[entry].row;
1655 int col = disp_player_line[entry].col;
1656 int len = disp_player_line[entry].len;
1657 cptr head = disp_player_line[entry].header;
1659 int head_len = strlen(head);
1661 Term_putstr(col, row, -1, TERM_WHITE, head);
1668 int val_len = len - head_len;
1669 sprintf(buf, "%*.*s", val_len, val_len, val);
1670 Term_putstr(col + head_len, row, -1, attr, buf);
1674 Term_putstr(col + head_len, row, -1, attr, val);
1681 * @brief プレイヤーの打撃能力修正を表示する
1682 * @param hand 武器の装備部位ID
1683 * @param hand_entry 項目ID
1686 static void display_player_melee_bonus(int hand, int hand_entry)
1689 int show_tohit = p_ptr->dis_to_h[hand];
1690 int show_todam = p_ptr->dis_to_d[hand];
1691 object_type *o_ptr = &inventory[INVEN_RARM + hand];
1693 /* Hack -- add in weapon info if known */
1694 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1695 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1697 show_tohit += p_ptr->skill_thn / BTH_PLUS_ADJ;
1700 sprintf(buf, "(%+d,%+d)", show_tohit, show_todam);
1702 /* Dump the bonuses to hit/dam */
1703 if (!buki_motteruka(INVEN_RARM) && !buki_motteruka(INVEN_LARM))
1704 display_player_one_line(ENTRY_BARE_HAND, buf, TERM_L_BLUE);
1705 else if (p_ptr->ryoute)
1706 display_player_one_line(ENTRY_TWO_HANDS, buf, TERM_L_BLUE);
1708 display_player_one_line(hand_entry, buf, TERM_L_BLUE);
1713 * @brief プレイヤーステータス表示の中央部分を表示するサブルーチン
1714 * Prints the following information on the screen.
1717 static void display_player_middle(void)
1722 int show_tohit = p_ptr->dis_to_h_b;
1726 object_type *o_ptr = &inventory[INVEN_BOW];
1733 display_player_melee_bonus(0, left_hander ? ENTRY_LEFT_HAND1 : ENTRY_RIGHT_HAND1);
1736 if (p_ptr->hidarite)
1738 display_player_melee_bonus(1, left_hander ? ENTRY_RIGHT_HAND2: ENTRY_LEFT_HAND2);
1740 else if ((p_ptr->pclass == CLASS_MONK) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
1743 if (p_ptr->special_defense & KAMAE_MASK)
1745 for (i = 0; i < MAX_KAMAE; i++)
1747 if ((p_ptr->special_defense >> i) & KAMAE_GENBU) break;
1750 display_player_one_line(ENTRY_POSTURE, format(_("%sの構え", "%s form"), kamae_shurui[i].desc), TERM_YELLOW);
1753 display_player_one_line(ENTRY_POSTURE, _("構えなし", "none"), TERM_YELLOW);
1756 /* Apply weapon bonuses */
1757 if (object_is_known(o_ptr)) show_tohit += o_ptr->to_h;
1758 if (object_is_known(o_ptr)) show_todam += o_ptr->to_d;
1760 if ((o_ptr->sval == SV_LIGHT_XBOW) || (o_ptr->sval == SV_HEAVY_XBOW))
1761 show_tohit += p_ptr->weapon_exp[0][o_ptr->sval] / 400;
1763 show_tohit += (p_ptr->weapon_exp[0][o_ptr->sval] - (WEAPON_EXP_MASTER / 2)) / 200;
1765 show_tohit += p_ptr->skill_thb / BTH_PLUS_ADJ;
1768 display_player_one_line(ENTRY_SHOOT_HIT_DAM, format("(%+d,%+d)", show_tohit, show_todam), TERM_L_BLUE);
1770 if (inventory[INVEN_BOW].k_idx)
1772 tmul = bow_tmul(inventory[INVEN_BOW].sval);
1774 /* Get extra "power" from "extra might" */
1775 if (p_ptr->xtra_might) tmul++;
1777 tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128);
1781 display_player_one_line(ENTRY_SHOOT_POWER, format("x%d.%02d", tmul/100, tmul%100), TERM_L_BLUE);
1783 /* Dump the armor class */
1784 display_player_one_line(ENTRY_BASE_AC, format("[%d,%+d]", p_ptr->dis_ac, p_ptr->dis_to_a), TERM_L_BLUE);
1792 i = p_ptr->pspeed-110;
1794 /* Hack -- Visually "undo" the Search Mode Slowdown */
1795 if (p_ptr->action == ACTION_SEARCH) i += 10;
1800 attr = TERM_L_GREEN;
1814 attr = TERM_L_UMBER;
1821 if (IS_FAST()) tmp_speed += 10;
1822 if (p_ptr->slow) tmp_speed -= 10;
1823 if (p_ptr->lightspeed) tmp_speed = 99;
1827 if (MON_FAST(&m_list[p_ptr->riding])) tmp_speed += 10;
1828 if (MON_SLOW(&m_list[p_ptr->riding])) tmp_speed -= 10;
1834 sprintf(buf, "(%+d%+d)", i-tmp_speed, tmp_speed);
1836 sprintf(buf, _("乗馬中 (%+d%+d)", "Riding (%+d%+d)"), i-tmp_speed, tmp_speed);
1846 sprintf(buf, "(%+d)", i);
1848 sprintf(buf, _("乗馬中 (%+d)", "Riding (%+d)"), i);
1851 display_player_one_line(ENTRY_SPEED, buf, attr);
1854 /* Dump character level */
1855 display_player_one_line(ENTRY_LEVEL, format("%d", p_ptr->lev), TERM_L_GREEN);
1857 /* Dump experience */
1858 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_ANDR;
1859 else e = ENTRY_CUR_EXP;
1861 if (p_ptr->exp >= p_ptr->max_exp)
1862 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_L_GREEN);
1864 display_player_one_line(e, format("%ld", p_ptr->exp), TERM_YELLOW);
1866 /* Dump max experience */
1867 if (p_ptr->prace == RACE_ANDROID)
1870 display_player_one_line(ENTRY_MAX_EXP, format("%ld", p_ptr->max_exp), TERM_L_GREEN);
1872 /* Dump exp to advance */
1873 if (p_ptr->prace == RACE_ANDROID) e = ENTRY_EXP_TO_ADV_ANDR;
1874 else e = ENTRY_EXP_TO_ADV;
1876 if (p_ptr->lev >= PY_MAX_LEVEL)
1877 display_player_one_line(e, "*****", TERM_L_GREEN);
1878 else if (p_ptr->prace == RACE_ANDROID)
1879 display_player_one_line(e, format("%ld", (s32b)(player_exp_a[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1881 display_player_one_line(e, format("%ld", (s32b)(player_exp[p_ptr->lev - 1] * p_ptr->expfact / 100L)), TERM_L_GREEN);
1884 display_player_one_line(ENTRY_GOLD, format("%ld", p_ptr->au), TERM_L_GREEN);
1889 extract_day_hour_min(&day, &hour, &min);
1891 if (day < MAX_DAYS) sprintf(buf, _("%d日目 %2d:%02d", "Day %d %2d:%02d"), day, hour, min);
1892 else sprintf(buf, _("*****日目 %2d:%02d", "Day ***** %2d:%02d"), hour, min);
1894 display_player_one_line(ENTRY_DAY, buf, TERM_L_GREEN);
1896 /* Dump hit point */
1897 if (p_ptr->chp >= p_ptr->mhp)
1898 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_L_GREEN);
1899 else if (p_ptr->chp > (p_ptr->mhp * hitpoint_warn) / 10)
1900 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_YELLOW);
1902 display_player_one_line(ENTRY_HP, format("%4d/%4d", p_ptr->chp , p_ptr->mhp), TERM_RED);
1904 /* Dump mana power */
1905 if (p_ptr->csp >= p_ptr->msp)
1906 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_L_GREEN);
1907 else if (p_ptr->csp > (p_ptr->msp * mana_warn) / 10)
1908 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_YELLOW);
1910 display_player_one_line(ENTRY_SP, format("%4d/%4d", p_ptr->csp , p_ptr->msp), TERM_RED);
1912 /* Dump play time */
1913 display_player_one_line(ENTRY_PLAY_TIME, format("%.2lu:%.2lu:%.2lu", playtime/(60*60), (playtime/60)%60, playtime%60), TERM_L_GREEN);
1918 * Hack -- pass color info around this file
1920 static byte likert_color = TERM_WHITE;
1924 * @brief 技能ランクの表示基準を定める
1925 * Returns a "rating" of x depending on y
1927 * @param y 技能値に対するランク基準比
1930 static cptr likert(int x, int y)
1932 static char dummy[20] = "";
1937 /* Negative value */
1940 likert_color = TERM_L_DARK;
1941 return _("最低", "Very Bad");
1944 /* Analyze the value */
1949 likert_color = TERM_RED;
1950 return _("悪い", "Bad");
1953 likert_color = TERM_L_RED;
1954 return _("劣る", "Poor");
1958 likert_color = TERM_ORANGE;
1959 return _("普通", "Fair");
1962 likert_color = TERM_YELLOW;
1963 return _("良い", "Good");
1966 likert_color = TERM_YELLOW;
1967 return _("大変良い", "Very Good");
1971 likert_color = TERM_L_GREEN;
1972 return _("卓越", "Excellent");
1979 likert_color = TERM_GREEN;
1980 return _("超越", "Superb");
1986 likert_color = TERM_BLUE;
1987 return _("英雄的", "Heroic");
1990 likert_color = TERM_VIOLET;
1991 sprintf(dummy, _("伝説的[%d]", "Legendary[%d]"), (int)((((x / y) - 17) * 5) / 2));
1998 * @brief プレイヤーステータスの1ページ目各種詳細をまとめて表示するサブルーチン
1999 * Prints ratings on certain abilities
2002 * This code is "imitated" elsewhere to "dump" a character sheet.
2004 static void display_player_various(void)
2006 int tmp, damage[2], to_h[2], blows1, blows2, i, basedam;
2007 int xthn, xthb, xfos, xsrh;
2008 int xdis, xdev, xsav, xstl;
2011 u32b flgs[TR_FLAG_SIZE];
2012 int shots, shot_frac;
2017 if (p_ptr->muta2 & MUT2_HORNS) muta_att++;
2018 if (p_ptr->muta2 & MUT2_SCOR_TAIL) muta_att++;
2019 if (p_ptr->muta2 & MUT2_BEAK) muta_att++;
2020 if (p_ptr->muta2 & MUT2_TRUNK) muta_att++;
2021 if (p_ptr->muta2 & MUT2_TENTACLES) muta_att++;
2023 xthn = p_ptr->skill_thn + (p_ptr->to_h_m * BTH_PLUS_ADJ);
2025 /* Shooting Skill (with current bow and normal missile) */
2026 o_ptr = &inventory[INVEN_BOW];
2027 tmp = p_ptr->to_h_b + o_ptr->to_h;
2028 xthb = p_ptr->skill_thb + (tmp * BTH_PLUS_ADJ);
2030 /* If the player is wielding one? */
2033 ENERGY energy_fire = bow_energy(o_ptr->sval);
2035 /* Calculate shots per round */
2036 shots = p_ptr->num_fire * 100;
2037 shot_frac = (shots * 100 / energy_fire) % 100;
2038 shots = shots / energy_fire;
2039 if (o_ptr->name1 == ART_CRIMSON)
2043 if (p_ptr->pclass == CLASS_ARCHER)
2045 /* Extra shot at level 10 */
2046 if (p_ptr->lev >= 10) shots++;
2048 /* Extra shot at level 30 */
2049 if (p_ptr->lev >= 30) shots++;
2051 /* Extra shot at level 45 */
2052 if (p_ptr->lev >= 45) shots++;
2062 for(i = 0; i < 2; i++)
2064 damage[i] = p_ptr->dis_to_d[i] * 100;
2065 if (((p_ptr->pclass == CLASS_MONK) || (p_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(TRUE) & EMPTY_HAND_RARM))
2067 int level = p_ptr->lev;
2073 if (p_ptr->pclass == CLASS_FORCETRAINER) level = MAX(1, level - 3);
2074 if (p_ptr->special_defense & KAMAE_BYAKKO)
2075 basedam = monk_ave_damage[level][1];
2076 else if (p_ptr->special_defense & (KAMAE_GENBU | KAMAE_SUZAKU))
2077 basedam = monk_ave_damage[level][2];
2079 basedam = monk_ave_damage[level][0];
2083 o_ptr = &inventory[INVEN_RARM + i];
2085 /* Average damage per round */
2091 if((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) dokubari = TRUE;
2092 if (object_is_known(o_ptr))
2094 damage[i] += o_ptr->to_d * 100;
2095 to_h[i] += o_ptr->to_h;
2097 basedam = ((o_ptr->dd + p_ptr->to_dd[i]) * (o_ptr->ds + p_ptr->to_ds[i] + 1)) * 50;
2098 object_flags_known(o_ptr, flgs);
2100 basedam = calc_expect_crit(o_ptr->weight, to_h[i], basedam, p_ptr->dis_to_h[i], dokubari);
2101 if ((o_ptr->ident & IDENT_MENTAL) && ((o_ptr->name1 == ART_VORPAL_BLADE) || (o_ptr->name1 == ART_CHAINSWORD)))
2107 else if (have_flag(flgs, TR_VORPAL))
2109 /* vorpal flag only */
2113 if ((p_ptr->pclass != CLASS_SAMURAI) && have_flag(flgs, TR_FORCE_WEAPON) && (p_ptr->csp > (o_ptr->dd * o_ptr->ds / 5)))
2114 basedam = basedam * 7 / 2;
2118 damage[i] += basedam;
2119 if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_DOKUBARI)) damage[i] = 1;
2120 if (damage[i] < 0) damage[i] = 0;
2122 blows1 = p_ptr->migite ? p_ptr->num_blow[0]: 0;
2123 blows2 = p_ptr->hidarite ? p_ptr->num_blow[1] : 0;
2125 /* Basic abilities */
2127 xdis = p_ptr->skill_dis;
2128 xdev = p_ptr->skill_dev;
2129 xsav = p_ptr->skill_sav;
2130 xstl = p_ptr->skill_stl;
2131 xsrh = p_ptr->skill_srh;
2132 xfos = p_ptr->skill_fos;
2135 desc = likert(xthn, 12);
2136 display_player_one_line(ENTRY_SKILL_FIGHT, desc, likert_color);
2138 desc = likert(xthb, 12);
2139 display_player_one_line(ENTRY_SKILL_SHOOT, desc, likert_color);
2141 desc = likert(xsav, 7);
2142 display_player_one_line(ENTRY_SKILL_SAVING, desc, likert_color);
2144 /* Hack -- 0 is "minimum stealth value", so print "Very Bad" */
2145 desc = likert((xstl > 0) ? xstl : -1, 1);
2146 display_player_one_line(ENTRY_SKILL_STEALTH, desc, likert_color);
2148 desc = likert(xfos, 6);
2149 display_player_one_line(ENTRY_SKILL_PERCEP, desc, likert_color);
2151 desc = likert(xsrh, 6);
2152 display_player_one_line(ENTRY_SKILL_SEARCH, desc, likert_color);
2154 desc = likert(xdis, 8);
2155 display_player_one_line(ENTRY_SKILL_DISARM, desc, likert_color);
2157 desc = likert(xdev, 6);
2158 display_player_one_line(ENTRY_SKILL_DEVICE, desc, likert_color);
2161 display_player_one_line(ENTRY_BLOWS, format("%d+%d", blows1, blows2), TERM_L_BLUE);
2163 display_player_one_line(ENTRY_BLOWS, format("%d+%d+%d", blows1, blows2, muta_att), TERM_L_BLUE);
2165 display_player_one_line(ENTRY_SHOTS, format("%d.%02d", shots, shot_frac), TERM_L_BLUE);
2168 if ((damage[0]+damage[1]) == 0)
2171 desc = format("%d+%d", blows1 * damage[0] / 100, blows2 * damage[1] / 100);
2173 display_player_one_line(ENTRY_AVG_DMG, desc, TERM_L_BLUE);
2175 display_player_one_line(ENTRY_INFRA, format("%d feet", p_ptr->see_infra * 10), TERM_WHITE);
2181 * @brief プレイヤーの職業、種族に応じた耐性フラグを返す
2182 * Prints ratings on certain abilities
2183 * @param flgs フラグを保管する配列
2186 * Obtain the "flags" for the player as if he was an item
2188 * xtra1.c周りと多重実装になっているのを何とかする
2190 static void player_flags(u32b flgs[TR_FLAG_SIZE])
2195 for (i = 0; i < TR_FLAG_SIZE; i++)
2199 switch (p_ptr->pclass)
2202 if (p_ptr->lev > 44)
2203 add_flag(flgs, TR_REGEN);
2205 if (p_ptr->lev > 29)
2206 add_flag(flgs, TR_RES_FEAR);
2209 if (p_ptr->lev > 39)
2210 add_flag(flgs, TR_RES_FEAR);
2212 case CLASS_CHAOS_WARRIOR:
2213 if (p_ptr->lev > 29)
2214 add_flag(flgs, TR_RES_CHAOS);
2215 if (p_ptr->lev > 39)
2216 add_flag(flgs, TR_RES_FEAR);
2219 case CLASS_FORCETRAINER:
2220 if ((p_ptr->lev > 9) && !heavy_armor())
2221 add_flag(flgs, TR_SPEED);
2222 if ((p_ptr->lev>24) && !heavy_armor())
2223 add_flag(flgs, TR_FREE_ACT);
2227 add_flag(flgs, TR_SPEED);
2230 if ((!inventory[INVEN_RARM].k_idx || p_ptr->migite) &&
2231 (!inventory[INVEN_LARM].k_idx || p_ptr->hidarite))
2232 add_flag(flgs, TR_SPEED);
2234 add_flag(flgs, TR_FREE_ACT);
2236 add_flag(flgs, TR_SLOW_DIGEST);
2237 add_flag(flgs, TR_RES_FEAR);
2238 if (p_ptr->lev > 19) add_flag(flgs, TR_RES_POIS);
2239 if (p_ptr->lev > 24) add_flag(flgs, TR_SUST_DEX);
2240 if (p_ptr->lev > 29) add_flag(flgs, TR_SEE_INVIS);
2242 case CLASS_MINDCRAFTER:
2244 add_flag(flgs, TR_RES_FEAR);
2245 if (p_ptr->lev > 19)
2246 add_flag(flgs, TR_SUST_WIS);
2247 if (p_ptr->lev > 29)
2248 add_flag(flgs, TR_RES_CONF);
2249 if (p_ptr->lev > 39)
2250 add_flag(flgs, TR_TELEPATHY);
2253 add_flag(flgs, TR_RES_SOUND);
2255 case CLASS_BERSERKER:
2256 add_flag(flgs, TR_SUST_STR);
2257 add_flag(flgs, TR_SUST_DEX);
2258 add_flag(flgs, TR_SUST_CON);
2259 add_flag(flgs, TR_REGEN);
2260 add_flag(flgs, TR_FREE_ACT);
2261 add_flag(flgs, TR_SPEED);
2262 if (p_ptr->lev > 39) add_flag(flgs, TR_REFLECT);
2264 case CLASS_MIRROR_MASTER:
2265 if(p_ptr->lev > 39)add_flag(flgs, TR_REFLECT);
2268 break; /* Do nothing */
2272 if (p_ptr->mimic_form)
2274 switch(p_ptr->mimic_form)
2277 add_flag(flgs, TR_HOLD_EXP);
2278 add_flag(flgs, TR_RES_CHAOS);
2279 add_flag(flgs, TR_RES_NETHER);
2280 add_flag(flgs, TR_RES_FIRE);
2281 add_flag(flgs, TR_SEE_INVIS);
2282 add_flag(flgs, TR_SPEED);
2284 case MIMIC_DEMON_LORD:
2285 add_flag(flgs, TR_HOLD_EXP);
2286 add_flag(flgs, TR_RES_CHAOS);
2287 add_flag(flgs, TR_RES_NETHER);
2288 add_flag(flgs, TR_RES_FIRE);
2289 add_flag(flgs, TR_RES_COLD);
2290 add_flag(flgs, TR_RES_ELEC);
2291 add_flag(flgs, TR_RES_ACID);
2292 add_flag(flgs, TR_RES_POIS);
2293 add_flag(flgs, TR_RES_CONF);
2294 add_flag(flgs, TR_RES_DISEN);
2295 add_flag(flgs, TR_RES_NEXUS);
2296 add_flag(flgs, TR_RES_FEAR);
2297 add_flag(flgs, TR_IM_FIRE);
2298 add_flag(flgs, TR_SH_FIRE);
2299 add_flag(flgs, TR_SEE_INVIS);
2300 add_flag(flgs, TR_TELEPATHY);
2301 add_flag(flgs, TR_LEVITATION);
2302 add_flag(flgs, TR_SPEED);
2305 add_flag(flgs, TR_HOLD_EXP);
2306 add_flag(flgs, TR_RES_DARK);
2307 add_flag(flgs, TR_RES_NETHER);
2308 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE_1);
2309 add_flag(flgs, TR_RES_POIS);
2310 add_flag(flgs, TR_RES_COLD);
2311 add_flag(flgs, TR_SEE_INVIS);
2312 add_flag(flgs, TR_SPEED);
2318 switch (p_ptr->prace)
2321 add_flag(flgs, TR_RES_LITE);
2324 add_flag(flgs, TR_HOLD_EXP);
2327 add_flag(flgs, TR_FREE_ACT);
2330 add_flag(flgs, TR_RES_BLIND);
2333 add_flag(flgs, TR_RES_DARK);
2335 case RACE_HALF_TROLL:
2336 add_flag(flgs, TR_SUST_STR);
2337 if (p_ptr->lev > 14)
2339 add_flag(flgs, TR_REGEN);
2340 if ((p_ptr->pclass == CLASS_WARRIOR) || (p_ptr->pclass == CLASS_BERSERKER))
2342 add_flag(flgs, TR_SLOW_DIGEST);
2344 * Let's not make Regeneration a disadvantage
2345 * for the poor warriors who can never learn
2346 * a spell that satisfies hunger (actually
2347 * neither can rogues, but half-trolls are not
2348 * supposed to play rogues)
2354 add_flag(flgs, TR_SUST_CON);
2355 add_flag(flgs, TR_REGEN); /* Amberites heal fast */
2358 add_flag(flgs, TR_RES_LITE);
2359 add_flag(flgs, TR_SEE_INVIS);
2361 case RACE_BARBARIAN:
2362 add_flag(flgs, TR_RES_FEAR);
2364 case RACE_HALF_OGRE:
2365 add_flag(flgs, TR_SUST_STR);
2366 add_flag(flgs, TR_RES_DARK);
2368 case RACE_HALF_GIANT:
2369 add_flag(flgs, TR_RES_SHARDS);
2370 add_flag(flgs, TR_SUST_STR);
2372 case RACE_HALF_TITAN:
2373 add_flag(flgs, TR_RES_CHAOS);
2376 add_flag(flgs, TR_RES_SOUND);
2379 add_flag(flgs, TR_RES_ACID);
2380 if (p_ptr->lev > 19)
2381 add_flag(flgs, TR_IM_ACID);
2384 add_flag(flgs, TR_RES_CONF);
2385 add_flag(flgs, TR_RES_ACID);
2387 add_flag(flgs, TR_SPEED);
2390 add_flag(flgs, TR_RES_POIS);
2393 add_flag(flgs, TR_RES_DISEN);
2394 add_flag(flgs, TR_RES_DARK);
2397 add_flag(flgs, TR_RES_DARK);
2398 if (p_ptr->lev > 19)
2399 add_flag(flgs, TR_SEE_INVIS);
2401 case RACE_DRACONIAN:
2402 add_flag(flgs, TR_LEVITATION);
2404 add_flag(flgs, TR_RES_FIRE);
2406 add_flag(flgs, TR_RES_COLD);
2407 if (p_ptr->lev > 14)
2408 add_flag(flgs, TR_RES_ACID);
2409 if (p_ptr->lev > 19)
2410 add_flag(flgs, TR_RES_ELEC);
2411 if (p_ptr->lev > 34)
2412 add_flag(flgs, TR_RES_POIS);
2414 case RACE_MIND_FLAYER:
2415 add_flag(flgs, TR_SUST_INT);
2416 add_flag(flgs, TR_SUST_WIS);
2417 if (p_ptr->lev > 14)
2418 add_flag(flgs, TR_SEE_INVIS);
2419 if (p_ptr->lev > 29)
2420 add_flag(flgs, TR_TELEPATHY);
2423 add_flag(flgs, TR_RES_FIRE);
2425 add_flag(flgs, TR_SEE_INVIS);
2428 add_flag(flgs, TR_SEE_INVIS);
2429 add_flag(flgs, TR_FREE_ACT);
2430 add_flag(flgs, TR_RES_POIS);
2431 add_flag(flgs, TR_SLOW_DIGEST);
2432 if (p_ptr->lev > 34)
2433 add_flag(flgs, TR_HOLD_EXP);
2436 add_flag(flgs, TR_SEE_INVIS);
2437 add_flag(flgs, TR_RES_SHARDS);
2438 add_flag(flgs, TR_HOLD_EXP);
2439 add_flag(flgs, TR_RES_POIS);
2441 add_flag(flgs, TR_RES_COLD);
2444 add_flag(flgs, TR_SEE_INVIS);
2445 add_flag(flgs, TR_HOLD_EXP);
2446 add_flag(flgs, TR_RES_NETHER);
2447 add_flag(flgs, TR_RES_POIS);
2448 add_flag(flgs, TR_SLOW_DIGEST);
2450 add_flag(flgs, TR_RES_COLD);
2453 add_flag(flgs, TR_HOLD_EXP);
2454 add_flag(flgs, TR_RES_DARK);
2455 add_flag(flgs, TR_RES_NETHER);
2456 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE_1);
2457 add_flag(flgs, TR_RES_POIS);
2458 add_flag(flgs, TR_RES_COLD);
2461 add_flag(flgs, TR_LEVITATION);
2462 add_flag(flgs, TR_FREE_ACT);
2463 add_flag(flgs, TR_RES_COLD);
2464 add_flag(flgs, TR_SEE_INVIS);
2465 add_flag(flgs, TR_HOLD_EXP);
2466 add_flag(flgs, TR_RES_NETHER);
2467 add_flag(flgs, TR_RES_POIS);
2468 add_flag(flgs, TR_SLOW_DIGEST);
2470 if (p_ptr->lev > 34)
2471 add_flag(flgs, TR_TELEPATHY);
2474 add_flag(flgs, TR_RES_LITE);
2475 add_flag(flgs, TR_LEVITATION);
2477 add_flag(flgs, TR_SPEED);
2480 add_flag(flgs, TR_RES_SOUND);
2481 add_flag(flgs, TR_RES_CONF);
2484 add_flag(flgs, TR_LEVITATION);
2485 add_flag(flgs, TR_SEE_INVIS);
2488 add_flag(flgs, TR_RES_FIRE);
2489 add_flag(flgs, TR_RES_NETHER);
2490 add_flag(flgs, TR_HOLD_EXP);
2492 add_flag(flgs, TR_SEE_INVIS);
2495 add_flag(flgs, TR_SUST_CON);
2498 add_flag(flgs, TR_LEVITATION);
2501 add_flag(flgs, TR_RES_CONF);
2504 add_flag(flgs, TR_FREE_ACT);
2505 add_flag(flgs, TR_RES_POIS);
2506 add_flag(flgs, TR_SLOW_DIGEST);
2507 add_flag(flgs, TR_HOLD_EXP);
2517 if (p_ptr->muta3 & MUT3_FLESH_ROT)
2519 remove_flag(flgs, TR_REGEN);
2522 if ((p_ptr->muta3 & MUT3_XTRA_FAT) ||
2523 (p_ptr->muta3 & MUT3_XTRA_LEGS) ||
2524 (p_ptr->muta3 & MUT3_SHORT_LEG))
2526 add_flag(flgs, TR_SPEED);
2529 if (p_ptr->muta3 & MUT3_ELEC_TOUC)
2531 add_flag(flgs, TR_SH_ELEC);
2534 if (p_ptr->muta3 & MUT3_FIRE_BODY)
2536 add_flag(flgs, TR_SH_FIRE);
2537 add_flag(flgs, TR_LITE_1);
2540 if (p_ptr->muta3 & MUT3_WINGS)
2542 add_flag(flgs, TR_LEVITATION);
2545 if (p_ptr->muta3 & MUT3_FEARLESS)
2547 add_flag(flgs, TR_RES_FEAR);
2550 if (p_ptr->muta3 & MUT3_REGEN)
2552 add_flag(flgs, TR_REGEN);
2555 if (p_ptr->muta3 & MUT3_ESP)
2557 add_flag(flgs, TR_TELEPATHY);
2560 if (p_ptr->muta3 & MUT3_MOTION)
2562 add_flag(flgs, TR_FREE_ACT);
2566 if (p_ptr->pseikaku == SEIKAKU_SEXY)
2567 add_flag(flgs, TR_AGGRAVATE);
2568 if (p_ptr->pseikaku == SEIKAKU_MUNCHKIN)
2570 add_flag(flgs, TR_RES_BLIND);
2571 add_flag(flgs, TR_RES_CONF);
2572 add_flag(flgs, TR_HOLD_EXP);
2573 if (p_ptr->pclass != CLASS_NINJA) add_flag(flgs, TR_LITE_1);
2575 add_flag(flgs, TR_SPEED);
2577 if (p_ptr->special_defense & KATA_FUUJIN)
2578 add_flag(flgs, TR_REFLECT);
2579 if (p_ptr->special_defense & KAMAE_GENBU)
2580 add_flag(flgs, TR_REFLECT);
2581 if (p_ptr->special_defense & KAMAE_SUZAKU)
2582 add_flag(flgs, TR_LEVITATION);
2583 if (p_ptr->special_defense & KAMAE_SEIRYU)
2585 add_flag(flgs, TR_RES_FIRE);
2586 add_flag(flgs, TR_RES_COLD);
2587 add_flag(flgs, TR_RES_ACID);
2588 add_flag(flgs, TR_RES_ELEC);
2589 add_flag(flgs, TR_RES_POIS);
2590 add_flag(flgs, TR_LEVITATION);
2591 add_flag(flgs, TR_SH_FIRE);
2592 add_flag(flgs, TR_SH_ELEC);
2593 add_flag(flgs, TR_SH_COLD);
2595 if (p_ptr->special_defense & KATA_MUSOU)
2597 add_flag(flgs, TR_RES_FEAR);
2598 add_flag(flgs, TR_RES_LITE);
2599 add_flag(flgs, TR_RES_DARK);
2600 add_flag(flgs, TR_RES_BLIND);
2601 add_flag(flgs, TR_RES_CONF);
2602 add_flag(flgs, TR_RES_SOUND);
2603 add_flag(flgs, TR_RES_SHARDS);
2604 add_flag(flgs, TR_RES_NETHER);
2605 add_flag(flgs, TR_RES_NEXUS);
2606 add_flag(flgs, TR_RES_CHAOS);
2607 add_flag(flgs, TR_RES_DISEN);
2608 add_flag(flgs, TR_REFLECT);
2609 add_flag(flgs, TR_HOLD_EXP);
2610 add_flag(flgs, TR_FREE_ACT);
2611 add_flag(flgs, TR_SH_FIRE);
2612 add_flag(flgs, TR_SH_ELEC);
2613 add_flag(flgs, TR_SH_COLD);
2614 add_flag(flgs, TR_LEVITATION);
2615 add_flag(flgs, TR_LITE_1);
2616 add_flag(flgs, TR_SEE_INVIS);
2617 add_flag(flgs, TR_TELEPATHY);
2618 add_flag(flgs, TR_SLOW_DIGEST);
2619 add_flag(flgs, TR_REGEN);
2620 add_flag(flgs, TR_SUST_STR);
2621 add_flag(flgs, TR_SUST_INT);
2622 add_flag(flgs, TR_SUST_WIS);
2623 add_flag(flgs, TR_SUST_DEX);
2624 add_flag(flgs, TR_SUST_CON);
2625 add_flag(flgs, TR_SUST_CHR);
2630 * @brief プレイヤーの一時的魔法効果による耐性を返す
2631 * Prints ratings on certain abilities
2632 * @param flgs フラグを保管する配列
2635 * xtra1.c周りと多重実装になっているのを何とかする
2637 static void tim_player_flags(u32b flgs[TR_FLAG_SIZE])
2642 for (i = 0; i < TR_FLAG_SIZE; i++)
2645 if (IS_HERO() || p_ptr->shero)
2646 add_flag(flgs, TR_RES_FEAR);
2647 if (p_ptr->tim_invis)
2648 add_flag(flgs, TR_SEE_INVIS);
2649 if (p_ptr->tim_regen)
2650 add_flag(flgs, TR_REGEN);
2652 add_flag(flgs, TR_TELEPATHY);
2653 if (IS_FAST() || p_ptr->slow)
2654 add_flag(flgs, TR_SPEED);
2656 if (IS_OPPOSE_ACID() && !(p_ptr->special_defense & DEFENSE_ACID) && !(prace_is_(RACE_YEEK) && (p_ptr->lev > 19)))
2657 add_flag(flgs, TR_RES_ACID);
2658 if (IS_OPPOSE_ELEC() && !(p_ptr->special_defense & DEFENSE_ELEC))
2659 add_flag(flgs, TR_RES_ELEC);
2660 if (IS_OPPOSE_FIRE() && !(p_ptr->special_defense & DEFENSE_FIRE))
2661 add_flag(flgs, TR_RES_FIRE);
2662 if (IS_OPPOSE_COLD() && !(p_ptr->special_defense & DEFENSE_COLD))
2663 add_flag(flgs, TR_RES_COLD);
2664 if (IS_OPPOSE_POIS())
2665 add_flag(flgs, TR_RES_POIS);
2667 if (p_ptr->special_attack & ATTACK_ACID)
2668 add_flag(flgs, TR_BRAND_ACID);
2669 if (p_ptr->special_attack & ATTACK_ELEC)
2670 add_flag(flgs, TR_BRAND_ELEC);
2671 if (p_ptr->special_attack & ATTACK_FIRE)
2672 add_flag(flgs, TR_BRAND_FIRE);
2673 if (p_ptr->special_attack & ATTACK_COLD)
2674 add_flag(flgs, TR_BRAND_COLD);
2675 if (p_ptr->special_attack & ATTACK_POIS)
2676 add_flag(flgs, TR_BRAND_POIS);
2677 if (p_ptr->special_defense & DEFENSE_ACID)
2678 add_flag(flgs, TR_IM_ACID);
2679 if (p_ptr->special_defense & DEFENSE_ELEC)
2680 add_flag(flgs, TR_IM_ELEC);
2681 if (p_ptr->special_defense & DEFENSE_FIRE)
2682 add_flag(flgs, TR_IM_FIRE);
2683 if (p_ptr->special_defense & DEFENSE_COLD)
2684 add_flag(flgs, TR_IM_COLD);
2685 if (p_ptr->wraith_form)
2686 add_flag(flgs, TR_REFLECT);
2688 if (p_ptr->tim_reflect)
2689 add_flag(flgs, TR_REFLECT);
2691 if (p_ptr->magicdef)
2693 add_flag(flgs, TR_RES_BLIND);
2694 add_flag(flgs, TR_RES_CONF);
2695 add_flag(flgs, TR_REFLECT);
2696 add_flag(flgs, TR_FREE_ACT);
2697 add_flag(flgs, TR_LEVITATION);
2699 if (p_ptr->tim_res_nether)
2701 add_flag(flgs, TR_RES_NETHER);
2703 if (p_ptr->tim_sh_fire)
2705 add_flag(flgs, TR_SH_FIRE);
2709 add_flag(flgs, TR_RES_FEAR);
2710 add_flag(flgs, TR_RES_LITE);
2711 add_flag(flgs, TR_RES_DARK);
2712 add_flag(flgs, TR_RES_BLIND);
2713 add_flag(flgs, TR_RES_CONF);
2714 add_flag(flgs, TR_RES_SOUND);
2715 add_flag(flgs, TR_RES_SHARDS);
2716 add_flag(flgs, TR_RES_NETHER);
2717 add_flag(flgs, TR_RES_NEXUS);
2718 add_flag(flgs, TR_RES_CHAOS);
2719 add_flag(flgs, TR_RES_DISEN);
2720 add_flag(flgs, TR_REFLECT);
2721 add_flag(flgs, TR_HOLD_EXP);
2722 add_flag(flgs, TR_FREE_ACT);
2723 add_flag(flgs, TR_SH_FIRE);
2724 add_flag(flgs, TR_SH_ELEC);
2725 add_flag(flgs, TR_SH_COLD);
2726 add_flag(flgs, TR_LEVITATION);
2727 add_flag(flgs, TR_LITE_1);
2728 add_flag(flgs, TR_SEE_INVIS);
2729 add_flag(flgs, TR_TELEPATHY);
2730 add_flag(flgs, TR_SLOW_DIGEST);
2731 add_flag(flgs, TR_REGEN);
2732 add_flag(flgs, TR_SUST_STR);
2733 add_flag(flgs, TR_SUST_INT);
2734 add_flag(flgs, TR_SUST_WIS);
2735 add_flag(flgs, TR_SUST_DEX);
2736 add_flag(flgs, TR_SUST_CON);
2737 add_flag(flgs, TR_SUST_CHR);
2741 if (p_ptr->realm1 == REALM_HEX)
2743 if (hex_spelling(HEX_DEMON_AURA))
2745 add_flag(flgs, TR_SH_FIRE);
2746 add_flag(flgs, TR_REGEN);
2748 if (hex_spelling(HEX_ICE_ARMOR)) add_flag(flgs, TR_SH_COLD);
2749 if (hex_spelling(HEX_SHOCK_CLOAK)) add_flag(flgs, TR_SH_ELEC);
2754 /* Mode flags for displaying player flags */
2755 #define DP_CURSE 0x01
2761 * @brief プレイヤーの装備一覧をシンボルで並べる
2763 * @param y 表示するコンソールの行
2764 * @param x 表示するコンソールの列
2768 static void display_player_equippy(int y, int x, u16b mode)
2777 /* Weapon flags need only two column */
2778 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2779 else max_i = INVEN_TOTAL;
2781 /* Dump equippy chars */
2782 for (i = INVEN_RARM; i < max_i; i++)
2785 o_ptr = &inventory[i];
2787 a = object_attr(o_ptr);
2788 c = object_char(o_ptr);
2790 /* Clear the part of the screen */
2791 if (!equippy_chars || !o_ptr->k_idx)
2798 Term_putch(x + i - INVEN_RARM, y, a, c);
2804 * @brief プレイヤーの装備一覧シンボルを固定位置に表示する
2807 void print_equippy(void)
2809 display_player_equippy(ROW_EQUIPPY, COL_EQUIPPY, 0);
2813 * @brief プレイヤーの装備による免疫フラグを返す
2814 * @param flgs フラグを保管する配列
2817 * xtra1.c周りと多重実装になっているのを何とかする
2819 static void known_obj_immunity(u32b flgs[TR_FLAG_SIZE])
2824 for (i = 0; i < TR_FLAG_SIZE; i++)
2827 /* Check equipment */
2828 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
2830 u32b o_flgs[TR_FLAG_SIZE];
2835 o_ptr = &inventory[i];
2837 if (!o_ptr->k_idx) continue;
2840 object_flags_known(o_ptr, o_flgs);
2842 if (have_flag(o_flgs, TR_IM_ACID)) add_flag(flgs, TR_RES_ACID);
2843 if (have_flag(o_flgs, TR_IM_ELEC)) add_flag(flgs, TR_RES_ELEC);
2844 if (have_flag(o_flgs, TR_IM_FIRE)) add_flag(flgs, TR_RES_FIRE);
2845 if (have_flag(o_flgs, TR_IM_COLD)) add_flag(flgs, TR_RES_COLD);
2850 * @brief プレイヤーの種族による免疫フラグを返す
2851 * @param flgs フラグを保管する配列
2854 * xtra1.c周りと多重実装になっているのを何とかする
2856 static void player_immunity(u32b flgs[TR_FLAG_SIZE])
2861 for (i = 0; i < TR_FLAG_SIZE; i++)
2864 if (prace_is_(RACE_SPECTRE))
2865 add_flag(flgs, TR_RES_NETHER);
2866 if (p_ptr->mimic_form == MIMIC_VAMPIRE || prace_is_(RACE_VAMPIRE))
2867 add_flag(flgs, TR_RES_DARK);
2868 if (p_ptr->mimic_form == MIMIC_DEMON_LORD)
2869 add_flag(flgs, TR_RES_FIRE);
2870 else if (prace_is_(RACE_YEEK) && p_ptr->lev > 19)
2871 add_flag(flgs, TR_RES_ACID);
2875 * @brief プレイヤーの一時的魔法効果による免疫フラグを返す
2876 * @param flgs フラグを保管する配列
2879 * xtra1.c周りと多重実装になっているのを何とかする
2881 static void tim_player_immunity(u32b flgs[TR_FLAG_SIZE])
2886 for (i = 0; i < TR_FLAG_SIZE; i++)
2889 if (p_ptr->special_defense & DEFENSE_ACID)
2890 add_flag(flgs, TR_RES_ACID);
2891 if (p_ptr->special_defense & DEFENSE_ELEC)
2892 add_flag(flgs, TR_RES_ELEC);
2893 if (p_ptr->special_defense & DEFENSE_FIRE)
2894 add_flag(flgs, TR_RES_FIRE);
2895 if (p_ptr->special_defense & DEFENSE_COLD)
2896 add_flag(flgs, TR_RES_COLD);
2897 if (p_ptr->wraith_form)
2898 add_flag(flgs, TR_RES_DARK);
2902 * @brief プレイヤーの種族による弱点フラグを返す
2903 * @param flgs フラグを保管する配列
2906 * xtra1.c周りと多重実装になっているのを何とかする
2908 static void player_vuln_flags(u32b flgs[TR_FLAG_SIZE])
2913 for (i = 0; i < TR_FLAG_SIZE; i++)
2916 if ((p_ptr->muta3 & MUT3_VULN_ELEM) || (p_ptr->special_defense & KATA_KOUKIJIN))
2918 add_flag(flgs, TR_RES_ACID);
2919 add_flag(flgs, TR_RES_ELEC);
2920 add_flag(flgs, TR_RES_FIRE);
2921 add_flag(flgs, TR_RES_COLD);
2923 if (prace_is_(RACE_ANDROID))
2924 add_flag(flgs, TR_RES_ELEC);
2925 if (prace_is_(RACE_ENT))
2926 add_flag(flgs, TR_RES_FIRE);
2927 if (prace_is_(RACE_VAMPIRE) || prace_is_(RACE_S_FAIRY) ||
2928 (p_ptr->mimic_form == MIMIC_VAMPIRE))
2929 add_flag(flgs, TR_RES_LITE);
2934 * A struct for storing misc. flags
2937 u32b player_flags[TR_FLAG_SIZE];
2938 u32b tim_player_flags[TR_FLAG_SIZE];
2939 u32b player_imm[TR_FLAG_SIZE];
2940 u32b tim_player_imm[TR_FLAG_SIZE];
2941 u32b player_vuln[TR_FLAG_SIZE];
2942 u32b known_obj_imm[TR_FLAG_SIZE];
2947 * @brief プレイヤーの特性フラグ一種を表示するサブルーチン /
2948 * Helper function, see below
2949 * @param row コンソール表示位置の左上行
2950 * @param col コンソール表示位置の左上列
2951 * @param header コンソール上で表示する特性名
2952 * @param flag1 参照する特性ID
2953 * @param f プレイヤーの特性情報構造体
2954 * @param mode 表示オプション
2957 static void display_flag_aux(int row, int col, cptr header,
2958 int flag1, all_player_flags *f, u16b mode)
2963 byte header_color = TERM_L_DARK;
2964 int header_col = col;
2966 if (have_flag(f->player_vuln, flag1) &&
2967 !(have_flag(f->known_obj_imm, flag1) ||
2968 have_flag(f->player_imm, flag1) ||
2969 have_flag(f->tim_player_imm, flag1)))
2973 col += strlen(header) + 1;
2975 /* Weapon flags need only two column */
2976 if (mode & DP_WP) max_i = INVEN_LARM + 1;
2977 else max_i = INVEN_TOTAL;
2979 /* Check equipment */
2980 for (i = INVEN_RARM; i < max_i; i++)
2982 u32b flgs[TR_FLAG_SIZE];
2986 o_ptr = &inventory[i];
2989 object_flags_known(o_ptr, flgs);
2992 if (!(mode & DP_IMM))
2993 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
2996 if (mode & DP_CURSE)
2998 if (have_flag(flgs, TR_ADD_L_CURSE) || have_flag(flgs, TR_ADD_H_CURSE))
3000 c_put_str(TERM_L_DARK, "+", row, col);
3001 header_color = TERM_WHITE;
3003 if (o_ptr->curse_flags & (TRC_CURSED | TRC_HEAVY_CURSE))
3005 c_put_str(TERM_WHITE, "+", row, col);
3006 header_color = TERM_WHITE;
3008 if (o_ptr->curse_flags & TRC_PERMA_CURSE)
3010 c_put_str(TERM_WHITE, "*", row, col);
3011 header_color = TERM_WHITE;
3014 else if (flag1 == TR_LITE_1)
3016 if (have_dark_flag(flgs))
3018 c_put_str(TERM_L_DARK, "+", row, col);
3019 header_color = TERM_WHITE;
3021 else if (have_lite_flag(flgs))
3023 c_put_str(TERM_WHITE, "+", row, col);
3024 header_color = TERM_WHITE;
3029 if (have_flag(flgs, flag1))
3031 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE),
3032 (mode & DP_IMM) ? "*" : "+", row, col);
3033 header_color = TERM_WHITE;
3041 /* Assume that player flag is already written */
3044 if (header_color != TERM_L_DARK)
3046 /* Overwrite Header Color */
3047 c_put_str(header_color, header, row, header_col);
3053 c_put_str((byte)(vuln ? TERM_RED : TERM_SLATE), ".", row, col);
3056 if (have_flag(f->player_flags, flag1))
3058 c_put_str((byte)(vuln ? TERM_L_RED : TERM_WHITE), "+", row, col);
3059 header_color = TERM_WHITE;
3062 /* Timed player flags */
3063 if (have_flag(f->tim_player_flags, flag1))
3065 c_put_str((byte)(vuln ? TERM_ORANGE : TERM_YELLOW), "#", row, col);
3066 header_color = TERM_WHITE;
3070 if (have_flag(f->tim_player_imm, flag1))
3072 c_put_str(TERM_YELLOW, "*", row, col);
3073 header_color = TERM_WHITE;
3075 if (have_flag(f->player_imm, flag1))
3077 c_put_str(TERM_WHITE, "*", row, col);
3078 header_color = TERM_WHITE;
3082 if (vuln) c_put_str(TERM_RED, "v", row, col + 1);
3085 c_put_str(header_color, header, row, header_col);
3090 * @brief プレイヤーの特性フラグ一覧表示1 /
3091 * Special display, part 1
3094 static void display_player_flag_info(void)
3101 /* Extract flags and store */
3102 player_flags(f.player_flags);
3103 tim_player_flags(f.tim_player_flags);
3104 player_immunity(f.player_imm);
3105 tim_player_immunity(f.tim_player_imm);
3106 known_obj_immunity(f.known_obj_imm);
3107 player_vuln_flags(f.player_vuln);
3114 display_player_equippy(row-2, col+8, 0);
3115 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3118 display_flag_aux(row+0, col, "耐酸 :", TR_RES_ACID, &f, 0);
3119 display_flag_aux(row+0, col, "耐酸 :", TR_IM_ACID, &f, DP_IMM);
3120 display_flag_aux(row+1, col, "耐電撃:", TR_RES_ELEC, &f, 0);
3121 display_flag_aux(row+1, col, "耐電撃:", TR_IM_ELEC, &f, DP_IMM);
3122 display_flag_aux(row+2, col, "耐火炎:", TR_RES_FIRE, &f, 0);
3123 display_flag_aux(row+2, col, "耐火炎:", TR_IM_FIRE, &f, DP_IMM);
3124 display_flag_aux(row+3, col, "耐冷気:", TR_RES_COLD, &f, 0);
3125 display_flag_aux(row+3, col, "耐冷気:", TR_IM_COLD, &f, DP_IMM);
3126 display_flag_aux(row+4, col, "耐毒 :", TR_RES_POIS, &f, 0);
3127 display_flag_aux(row+5, col, "耐閃光:", TR_RES_LITE, &f, 0);
3128 display_flag_aux(row+6, col, "耐暗黒:", TR_RES_DARK, &f, 0);
3129 display_flag_aux(row+7, col, "耐破片:", TR_RES_SHARDS, &f, 0);
3130 display_flag_aux(row+8, col, "耐盲目:", TR_RES_BLIND, &f, 0);
3131 display_flag_aux(row+9, col, "耐混乱:", TR_RES_CONF, &f, 0);
3133 display_flag_aux(row+0, col, "Acid :", TR_RES_ACID, &f, 0);
3134 display_flag_aux(row+0, col, "Acid :", TR_IM_ACID, &f, DP_IMM);
3135 display_flag_aux(row+1, col, "Elec :", TR_RES_ELEC, &f, 0);
3136 display_flag_aux(row+1, col, "Elec :", TR_IM_ELEC, &f, DP_IMM);
3137 display_flag_aux(row+2, col, "Fire :", TR_RES_FIRE, &f, 0);
3138 display_flag_aux(row+2, col, "Fire :", TR_IM_FIRE, &f, DP_IMM);
3139 display_flag_aux(row+3, col, "Cold :", TR_RES_COLD, &f, 0);
3140 display_flag_aux(row+3, col, "Cold :", TR_IM_COLD, &f, DP_IMM);
3141 display_flag_aux(row+4, col, "Poison:", TR_RES_POIS, &f, 0);
3142 display_flag_aux(row+5, col, "Light :", TR_RES_LITE, &f, 0);
3143 display_flag_aux(row+6, col, "Dark :", TR_RES_DARK, &f, 0);
3144 display_flag_aux(row+7, col, "Shard :", TR_RES_SHARDS, &f, 0);
3145 display_flag_aux(row+8, col, "Blind :", TR_RES_BLIND, &f, 0);
3146 display_flag_aux(row+9, col, "Conf :", TR_RES_CONF, &f, 0);
3155 display_player_equippy(row-2, col+8, 0);
3157 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+8);
3160 display_flag_aux(row+0, col, "耐轟音:", TR_RES_SOUND, &f, 0);
3161 display_flag_aux(row+1, col, "耐地獄:", TR_RES_NETHER, &f, 0);
3162 display_flag_aux(row+2, col, "耐因混:", TR_RES_NEXUS, &f, 0);
3163 display_flag_aux(row+3, col, "耐カオ:", TR_RES_CHAOS, &f, 0);
3164 display_flag_aux(row+4, col, "耐劣化:", TR_RES_DISEN, &f, 0);
3165 display_flag_aux(row+5, col, "耐恐怖:", TR_RES_FEAR, &f, 0);
3166 display_flag_aux(row+6, col, "反射 :", TR_REFLECT, &f, 0);
3167 display_flag_aux(row+7, col, "火炎オ:", TR_SH_FIRE, &f, 0);
3168 display_flag_aux(row+8, col, "電気オ:", TR_SH_ELEC, &f, 0);
3169 display_flag_aux(row+9, col, "冷気オ:", TR_SH_COLD, &f, 0);
3171 display_flag_aux(row+0, col, "Sound :", TR_RES_SOUND, &f, 0);
3172 display_flag_aux(row+1, col, "Nether:", TR_RES_NETHER, &f, 0);
3173 display_flag_aux(row+2, col, "Nexus :", TR_RES_NEXUS, &f, 0);
3174 display_flag_aux(row+3, col, "Chaos :", TR_RES_CHAOS, &f, 0);
3175 display_flag_aux(row+4, col, "Disnch:", TR_RES_DISEN, &f, 0);
3176 display_flag_aux(row+5, col, "Fear :", TR_RES_FEAR, &f, 0);
3177 display_flag_aux(row+6, col, "Reflct:", TR_REFLECT, &f, 0);
3178 display_flag_aux(row+7, col, "AuFire:", TR_SH_FIRE, &f, 0);
3179 display_flag_aux(row+8, col, "AuElec:", TR_SH_ELEC, &f, 0);
3180 display_flag_aux(row+9, col, "AuCold:", TR_SH_COLD, &f, 0);
3189 display_player_equippy(row-2, col+12, 0);
3191 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+12);
3194 display_flag_aux(row+0, col, "加速 :", TR_SPEED, &f, 0);
3195 display_flag_aux(row+1, col, "耐麻痺 :", TR_FREE_ACT, &f, 0);
3196 display_flag_aux(row+2, col, "透明体視認:", TR_SEE_INVIS, &f, 0);
3197 display_flag_aux(row+3, col, "経験値保持:", TR_HOLD_EXP, &f, 0);
3198 display_flag_aux(row+4, col, "警告 :", TR_WARNING, &f, 0);
3199 display_flag_aux(row+5, col, "遅消化 :", TR_SLOW_DIGEST, &f, 0);
3200 display_flag_aux(row+6, col, "急回復 :", TR_REGEN, &f, 0);
3201 display_flag_aux(row+7, col, "浮遊 :", TR_LEVITATION, &f, 0);
3202 display_flag_aux(row+8, col, "永遠光源 :", TR_LITE_1, &f, 0);
3203 display_flag_aux(row+9, col, "呪い :", 0, &f, DP_CURSE);
3205 display_flag_aux(row+0, col, "Speed :", TR_SPEED, &f, 0);
3206 display_flag_aux(row+1, col, "FreeAction:", TR_FREE_ACT, &f, 0);
3207 display_flag_aux(row+2, col, "SeeInvisi.:", TR_SEE_INVIS, &f, 0);
3208 display_flag_aux(row+3, col, "Hold Exp :", TR_HOLD_EXP, &f, 0);
3209 display_flag_aux(row+4, col, "Warning :", TR_WARNING, &f, 0);
3210 display_flag_aux(row+5, col, "SlowDigest:", TR_SLOW_DIGEST, &f, 0);
3211 display_flag_aux(row+6, col, "Regene. :", TR_REGEN, &f, 0);
3212 display_flag_aux(row+7, col, "Levitation:", TR_LEVITATION, &f, 0);
3213 display_flag_aux(row+8, col, "Perm Lite :", TR_LITE_1, &f, 0);
3214 display_flag_aux(row+9, col, "Cursed :", 0, &f, DP_CURSE);
3221 * @brief プレイヤーの特性フラグ一覧表示2 /
3222 * Special display, part 2
3225 static void display_player_other_flag_info(void)
3232 /* Extract flags and store */
3233 player_flags(f.player_flags);
3234 tim_player_flags(f.tim_player_flags);
3235 player_immunity(f.player_imm);
3236 tim_player_immunity(f.tim_player_imm);
3237 known_obj_immunity(f.known_obj_imm);
3238 player_vuln_flags(f.player_vuln);
3245 display_player_equippy(row-2, col+12, DP_WP);
3247 c_put_str(TERM_WHITE, "ab@", row-1, col+12);
3250 display_flag_aux(row+ 0, col, "邪悪 倍打 :", TR_SLAY_EVIL, &f, DP_WP);
3251 display_flag_aux(row+ 0, col, "邪悪 倍打 :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3252 display_flag_aux(row+ 1, col, "不死 倍打 :", TR_SLAY_UNDEAD, &f, DP_WP);
3253 display_flag_aux(row+ 1, col, "不死 倍打 :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3254 display_flag_aux(row+ 2, col, "悪魔 倍打 :", TR_SLAY_DEMON, &f, DP_WP);
3255 display_flag_aux(row+ 2, col, "悪魔 倍打 :", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3256 display_flag_aux(row+ 3, col, "龍 倍打 :", TR_SLAY_DRAGON, &f, DP_WP);
3257 display_flag_aux(row+ 3, col, "龍 倍打 :", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3258 display_flag_aux(row+ 4, col, "人間 倍打 :", TR_SLAY_HUMAN, &f, DP_WP);
3259 display_flag_aux(row+ 4, col, "人間 倍打 :", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3260 display_flag_aux(row+ 5, col, "動物 倍打 :", TR_SLAY_ANIMAL, &f, DP_WP);
3261 display_flag_aux(row+ 5, col, "動物 倍打 :", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3262 display_flag_aux(row+ 6, col, "オーク倍打:", TR_SLAY_ORC, &f, DP_WP);
3263 display_flag_aux(row+ 6, col, "オーク倍打:", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3264 display_flag_aux(row+ 7, col, "トロル倍打:", TR_SLAY_TROLL, &f, DP_WP);
3265 display_flag_aux(row+ 7, col, "トロル倍打:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3266 display_flag_aux(row+ 8, col, "巨人 倍打 :", TR_SLAY_GIANT, &f, DP_WP);
3267 display_flag_aux(row+ 8, col, "巨人 倍打 :", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3268 display_flag_aux(row+ 9, col, "溶解 :", TR_BRAND_ACID, &f, DP_WP);
3269 display_flag_aux(row+10, col, "電撃 :", TR_BRAND_ELEC, &f, DP_WP);
3270 display_flag_aux(row+11, col, "焼棄 :", TR_BRAND_FIRE, &f, DP_WP);
3271 display_flag_aux(row+12, col, "凍結 :", TR_BRAND_COLD, &f, DP_WP);
3272 display_flag_aux(row+13, col, "毒殺 :", TR_BRAND_POIS, &f, DP_WP);
3273 display_flag_aux(row+14, col, "切れ味 :", TR_VORPAL, &f, DP_WP);
3274 display_flag_aux(row+15, col, "地震 :", TR_IMPACT, &f, DP_WP);
3275 display_flag_aux(row+16, col, "吸血 :", TR_VAMPIRIC, &f, DP_WP);
3276 display_flag_aux(row+17, col, "カオス効果:", TR_CHAOTIC, &f, DP_WP);
3277 display_flag_aux(row+18, col, "理力 :", TR_FORCE_WEAPON, &f, DP_WP);
3279 display_flag_aux(row+ 0, col, "Slay Evil :", TR_SLAY_EVIL, &f, DP_WP);
3280 display_flag_aux(row+ 0, col, "Slay Evil :", TR_KILL_EVIL, &f, (DP_WP|DP_IMM));
3281 display_flag_aux(row+ 1, col, "Slay Und. :", TR_SLAY_UNDEAD, &f, DP_WP);
3282 display_flag_aux(row+ 1, col, "Slay Und. :", TR_KILL_UNDEAD, &f, (DP_WP|DP_IMM));
3283 display_flag_aux(row+ 2, col, "Slay Demon:", TR_SLAY_DEMON, &f, DP_WP);
3284 display_flag_aux(row+ 2, col, "Slay Demon:", TR_KILL_DEMON, &f, (DP_WP|DP_IMM));
3285 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_SLAY_DRAGON, &f, DP_WP);
3286 display_flag_aux(row+ 3, col, "Slay Drag.:", TR_KILL_DRAGON, &f, (DP_WP|DP_IMM));
3287 display_flag_aux(row+ 4, col, "Slay Human:", TR_SLAY_HUMAN, &f, DP_WP);
3288 display_flag_aux(row+ 4, col, "Slay Human:", TR_KILL_HUMAN, &f, (DP_WP|DP_IMM));
3289 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_SLAY_ANIMAL, &f, DP_WP);
3290 display_flag_aux(row+ 5, col, "Slay Anim.:", TR_KILL_ANIMAL, &f, (DP_WP|DP_IMM));
3291 display_flag_aux(row+ 6, col, "Slay Orc :", TR_SLAY_ORC, &f, DP_WP);
3292 display_flag_aux(row+ 6, col, "Slay Orc :", TR_KILL_ORC, &f, (DP_WP|DP_IMM));
3293 display_flag_aux(row+ 7, col, "Slay Troll:", TR_SLAY_TROLL, &f, DP_WP);
3294 display_flag_aux(row+ 7, col, "Slay Troll:", TR_KILL_TROLL, &f, (DP_WP|DP_IMM));
3295 display_flag_aux(row+ 8, col, "Slay Giant:", TR_SLAY_GIANT, &f, DP_WP);
3296 display_flag_aux(row+ 8, col, "Slay Giant:", TR_KILL_GIANT, &f, (DP_WP|DP_IMM));
3297 display_flag_aux(row+ 9, col, "Acid Brand:", TR_BRAND_ACID, &f, DP_WP);
3298 display_flag_aux(row+10, col, "Elec Brand:", TR_BRAND_ELEC, &f, DP_WP);
3299 display_flag_aux(row+11, col, "Fire Brand:", TR_BRAND_FIRE, &f, DP_WP);
3300 display_flag_aux(row+12, col, "Cold Brand:", TR_BRAND_COLD, &f, DP_WP);
3301 display_flag_aux(row+13, col, "Poison Brd:", TR_BRAND_POIS, &f, DP_WP);
3302 display_flag_aux(row+14, col, "Sharpness :", TR_VORPAL, &f, DP_WP);
3303 display_flag_aux(row+15, col, "Quake :", TR_IMPACT, &f, DP_WP);
3304 display_flag_aux(row+16, col, "Vampiric :", TR_VAMPIRIC, &f, DP_WP);
3305 display_flag_aux(row+17, col, "Chaotic :", TR_CHAOTIC, &f, DP_WP);
3306 display_flag_aux(row+18, col, "Force Wep.:", TR_FORCE_WEAPON, &f, DP_WP);
3315 display_player_equippy(row-2, col+13, 0);
3316 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+13);
3319 display_flag_aux(row+ 0, col, "テレパシー :", TR_TELEPATHY, &f, 0);
3320 display_flag_aux(row+ 1, col, "邪悪ESP :", TR_ESP_EVIL, &f, 0);
3321 display_flag_aux(row+ 2, col, "無生物ESP :", TR_ESP_NONLIVING, &f, 0);
3322 display_flag_aux(row+ 3, col, "善良ESP :", TR_ESP_GOOD, &f, 0);
3323 display_flag_aux(row+ 4, col, "不死ESP :", TR_ESP_UNDEAD, &f, 0);
3324 display_flag_aux(row+ 5, col, "悪魔ESP :", TR_ESP_DEMON, &f, 0);
3325 display_flag_aux(row+ 6, col, "龍ESP :", TR_ESP_DRAGON, &f, 0);
3326 display_flag_aux(row+ 7, col, "人間ESP :", TR_ESP_HUMAN, &f, 0);
3327 display_flag_aux(row+ 8, col, "動物ESP :", TR_ESP_ANIMAL, &f, 0);
3328 display_flag_aux(row+ 9, col, "オークESP :", TR_ESP_ORC, &f, 0);
3329 display_flag_aux(row+10, col, "トロルESP :", TR_ESP_TROLL, &f, 0);
3330 display_flag_aux(row+11, col, "巨人ESP :", TR_ESP_GIANT, &f, 0);
3331 display_flag_aux(row+12, col, "ユニークESP:", TR_ESP_UNIQUE, &f, 0);
3332 display_flag_aux(row+13, col, "腕力維持 :", TR_SUST_STR, &f, 0);
3333 display_flag_aux(row+14, col, "知力維持 :", TR_SUST_INT, &f, 0);
3334 display_flag_aux(row+15, col, "賢さ維持 :", TR_SUST_WIS, &f, 0);
3335 display_flag_aux(row+16, col, "器用維持 :", TR_SUST_DEX, &f, 0);
3336 display_flag_aux(row+17, col, "耐久維持 :", TR_SUST_CON, &f, 0);
3337 display_flag_aux(row+18, col, "魅力維持 :", TR_SUST_CHR, &f, 0);
3339 display_flag_aux(row+ 0, col, "Telepathy :", TR_TELEPATHY, &f, 0);
3340 display_flag_aux(row+ 1, col, "ESP Evil :", TR_ESP_EVIL, &f, 0);
3341 display_flag_aux(row+ 2, col, "ESP Noliv. :", TR_ESP_NONLIVING, &f, 0);
3342 display_flag_aux(row+ 3, col, "ESP Good :", TR_ESP_GOOD, &f, 0);
3343 display_flag_aux(row+ 4, col, "ESP Undead :", TR_ESP_UNDEAD, &f, 0);
3344 display_flag_aux(row+ 5, col, "ESP Demon :", TR_ESP_DEMON, &f, 0);
3345 display_flag_aux(row+ 6, col, "ESP Dragon :", TR_ESP_DRAGON, &f, 0);
3346 display_flag_aux(row+ 7, col, "ESP Human :", TR_ESP_HUMAN, &f, 0);
3347 display_flag_aux(row+ 8, col, "ESP Animal :", TR_ESP_ANIMAL, &f, 0);
3348 display_flag_aux(row+ 9, col, "ESP Orc :", TR_ESP_ORC, &f, 0);
3349 display_flag_aux(row+10, col, "ESP Troll :", TR_ESP_TROLL, &f, 0);
3350 display_flag_aux(row+11, col, "ESP Giant :", TR_ESP_GIANT, &f, 0);
3351 display_flag_aux(row+12, col, "ESP Unique :", TR_ESP_UNIQUE, &f, 0);
3352 display_flag_aux(row+13, col, "Sust Str :", TR_SUST_STR, &f, 0);
3353 display_flag_aux(row+14, col, "Sust Int :", TR_SUST_INT, &f, 0);
3354 display_flag_aux(row+15, col, "Sust Wis :", TR_SUST_WIS, &f, 0);
3355 display_flag_aux(row+16, col, "Sust Dex :", TR_SUST_DEX, &f, 0);
3356 display_flag_aux(row+17, col, "Sust Con :", TR_SUST_CON, &f, 0);
3357 display_flag_aux(row+18, col, "Sust Chr :", TR_SUST_CHR, &f, 0);
3364 col = col + 12 + 17;
3366 display_player_equippy(row-2, col+14, 0);
3368 c_put_str(TERM_WHITE, "abcdefghijkl@", row-1, col+14);
3371 display_flag_aux(row+ 0, col, "追加攻撃 :", TR_BLOWS, &f, 0);
3372 display_flag_aux(row+ 1, col, "採掘 :", TR_TUNNEL, &f, 0);
3373 display_flag_aux(row+ 2, col, "赤外線視力 :", TR_INFRA, &f, 0);
3374 display_flag_aux(row+ 3, col, "魔法道具支配:", TR_MAGIC_MASTERY, &f, 0);
3375 display_flag_aux(row+ 4, col, "隠密 :", TR_STEALTH, &f, 0);
3376 display_flag_aux(row+ 5, col, "探索 :", TR_SEARCH, &f, 0);
3378 display_flag_aux(row+ 7, col, "乗馬 :", TR_RIDING, &f, 0);
3379 display_flag_aux(row+ 8, col, "投擲 :", TR_THROW, &f, 0);
3380 display_flag_aux(row+ 9, col, "祝福 :", TR_BLESSED, &f, 0);
3381 display_flag_aux(row+10, col, "反テレポート:", TR_NO_TELE, &f, 0);
3382 display_flag_aux(row+11, col, "反魔法 :", TR_NO_MAGIC, &f, 0);
3383 display_flag_aux(row+12, col, "消費魔力減少:", TR_DEC_MANA, &f, 0);
3385 display_flag_aux(row+14, col, "経験値減少 :", TR_DRAIN_EXP, &f, 0);
3386 display_flag_aux(row+15, col, "乱テレポート:", TR_TELEPORT, &f, 0);
3387 display_flag_aux(row+16, col, "反感 :", TR_AGGRAVATE, &f, 0);
3388 display_flag_aux(row+17, col, "太古の怨念 :", TR_TY_CURSE, &f, 0);
3390 display_flag_aux(row+ 0, col, "Add Blows :", TR_BLOWS, &f, 0);
3391 display_flag_aux(row+ 1, col, "Add Tunnel :", TR_TUNNEL, &f, 0);
3392 display_flag_aux(row+ 2, col, "Add Infra :", TR_INFRA, &f, 0);
3393 display_flag_aux(row+ 3, col, "Add Device :", TR_MAGIC_MASTERY, &f, 0);
3394 display_flag_aux(row+ 4, col, "Add Stealth :", TR_STEALTH, &f, 0);
3395 display_flag_aux(row+ 5, col, "Add Search :", TR_SEARCH, &f, 0);
3397 display_flag_aux(row+ 7, col, "Riding :", TR_RIDING, &f, 0);
3398 display_flag_aux(row+ 8, col, "Throw :", TR_THROW, &f, 0);
3399 display_flag_aux(row+ 9, col, "Blessed :", TR_BLESSED, &f, 0);
3400 display_flag_aux(row+10, col, "No Teleport :", TR_NO_TELE, &f, 0);
3401 display_flag_aux(row+11, col, "Anti Magic :", TR_NO_MAGIC, &f, 0);
3402 display_flag_aux(row+12, col, "Econom. Mana:", TR_DEC_MANA, &f, 0);
3404 display_flag_aux(row+14, col, "Drain Exp :", TR_DRAIN_EXP, &f, 0);
3405 display_flag_aux(row+15, col, "Rnd.Teleport:", TR_TELEPORT, &f, 0);
3406 display_flag_aux(row+16, col, "Aggravate :", TR_AGGRAVATE, &f, 0);
3407 display_flag_aux(row+17, col, "TY Curse :", TR_TY_CURSE, &f, 0);
3414 * @brief プレイヤーの特性フラグ一覧表示2a /
3415 * Special display, part 2a
3418 static void display_player_misc_info(void)
3423 /* Display basics */
3425 put_str("名前 :", 1, 26);
3426 put_str("性別 :", 3, 1);
3427 put_str("種族 :", 4, 1);
3428 put_str("職業 :", 5, 1);
3430 put_str("Name :", 1, 26);
3431 put_str("Sex :", 3, 1);
3432 put_str("Race :", 4, 1);
3433 put_str("Class :", 5, 1);
3436 strcpy(tmp,ap_ptr->title);
3443 strcat(tmp,p_ptr->name);
3445 c_put_str(TERM_L_BLUE, tmp, 1, 34);
3446 c_put_str(TERM_L_BLUE, sp_ptr->title, 3, 9);
3447 c_put_str(TERM_L_BLUE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), 4, 9);
3448 c_put_str(TERM_L_BLUE, cp_ptr->title, 5, 9);
3450 /* Display extras */
3452 put_str("レベル:", 6, 1);
3453 put_str("HP :", 7, 1);
3454 put_str("MP :", 8, 1);
3456 put_str("Level :", 6, 1);
3457 put_str("Hits :", 7, 1);
3458 put_str("Mana :", 8, 1);
3462 (void)sprintf(buf, "%d", (int)p_ptr->lev);
3463 c_put_str(TERM_L_BLUE, buf, 6, 9);
3464 (void)sprintf(buf, "%d/%d", (int)p_ptr->chp, (int)p_ptr->mhp);
3465 c_put_str(TERM_L_BLUE, buf, 7, 9);
3466 (void)sprintf(buf, "%d/%d", (int)p_ptr->csp, (int)p_ptr->msp);
3467 c_put_str(TERM_L_BLUE, buf, 8, 9);
3472 * @brief プレイヤーの特性フラグ一覧表示2b /
3473 * Special display, part 2b
3477 * How to print out the modifications and sustains.
3478 * Positive mods with no sustain will be light green.
3479 * Positive mods with a sustain will be dark green.
3480 * Sustains (with no modification) will be a dark green 's'.
3481 * Negative mods (from a curse) will be red.
3482 * Huge mods (>9), like from MICoMorgoth, will be a '*'
3483 * No mod, no sustain, will be a slate '.'
3486 static void display_player_stat_info(void)
3493 u32b flgs[TR_FLAG_SIZE];
3507 /* Print out the labels for the columns */
3509 c_put_str(TERM_WHITE, "能力", row, stat_col+1);
3510 c_put_str(TERM_BLUE, " 基本", row, stat_col+7);
3511 c_put_str(TERM_L_BLUE, " 種 職 性 装 ", row, stat_col+13);
3512 c_put_str(TERM_L_GREEN, "合計", row, stat_col+28);
3513 c_put_str(TERM_YELLOW, "現在", row, stat_col+35);
3515 c_put_str(TERM_WHITE, "Stat", row, stat_col+1);
3516 c_put_str(TERM_BLUE, " Base", row, stat_col+7);
3517 c_put_str(TERM_L_BLUE, "RacClaPerMod", row, stat_col+13);
3518 c_put_str(TERM_L_GREEN, "Actual", row, stat_col+26);
3519 c_put_str(TERM_YELLOW, "Current", row, stat_col+32);
3523 /* Display the stats */
3524 for (i = 0; i < 6; i++)
3528 if (p_ptr->mimic_form) r_adj = mimic_info[p_ptr->mimic_form].r_adj[i];
3529 else r_adj = rp_ptr->r_adj[i];
3531 /* Calculate equipment adjustment */
3534 /* Icky formula to deal with the 18 barrier */
3535 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] > 18))
3536 e_adj = (p_ptr->stat_top[i] - p_ptr->stat_max[i]) / 10;
3537 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] <= 18))
3538 e_adj = p_ptr->stat_top[i] - p_ptr->stat_max[i];
3539 if ((p_ptr->stat_max[i] <= 18) && (p_ptr->stat_top[i] > 18))
3540 e_adj = (p_ptr->stat_top[i] - 18) / 10 - p_ptr->stat_max[i] + 18;
3542 if ((p_ptr->stat_max[i] > 18) && (p_ptr->stat_top[i] <= 18))
3543 e_adj = p_ptr->stat_top[i] - (p_ptr->stat_max[i] - 19) / 10 - 19;
3545 if (prace_is_(RACE_ENT))
3551 if (p_ptr->lev > 25) r_adj++;
3552 if (p_ptr->lev > 40) r_adj++;
3553 if (p_ptr->lev > 45) r_adj++;
3556 if (p_ptr->lev > 25) r_adj--;
3557 if (p_ptr->lev > 40) r_adj--;
3558 if (p_ptr->lev > 45) r_adj--;
3564 e_adj -= cp_ptr->c_adj[i];
3565 e_adj -= ap_ptr->a_adj[i];
3567 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3568 /* Reduced name of stat */
3569 c_put_str(TERM_WHITE, stat_names_reduced[i], row + i+1, stat_col+1);
3571 c_put_str(TERM_WHITE, stat_names[i], row + i+1, stat_col+1);
3574 /* Internal "natural" max value. Maxes at 18/100 */
3575 /* This is useful to see if you are maxed out */
3576 cnv_stat(p_ptr->stat_max[i], buf);
3577 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3579 c_put_str(TERM_WHITE, "!", row + i+1, _(stat_col + 6, stat_col + 4));
3581 c_put_str(TERM_BLUE, buf, row + i+1, stat_col + 13 - strlen(buf));
3583 /* Race, class, and equipment modifiers */
3584 (void)sprintf(buf, "%3d", r_adj);
3585 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 13);
3586 (void)sprintf(buf, "%3d", (int)cp_ptr->c_adj[i]);
3587 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 16);
3588 (void)sprintf(buf, "%3d", (int)ap_ptr->a_adj[i]);
3589 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 19);
3590 (void)sprintf(buf, "%3d", (int)e_adj);
3591 c_put_str(TERM_L_BLUE, buf, row + i+1, stat_col + 22);
3593 /* Actual maximal modified value */
3594 cnv_stat(p_ptr->stat_top[i], buf);
3595 c_put_str(TERM_L_GREEN, buf, row + i+1, stat_col + 26);
3597 /* Only display stat_use if not maximal */
3598 if (p_ptr->stat_use[i] < p_ptr->stat_top[i])
3600 cnv_stat(p_ptr->stat_use[i], buf);
3601 c_put_str(TERM_YELLOW, buf, row + i+1, stat_col + 33);
3606 col = stat_col + 41;
3608 /* Header and Footer */
3609 c_put_str(TERM_WHITE, "abcdefghijkl@", row, col);
3610 c_put_str(TERM_L_GREEN, _("能力修正", "Modification"), row - 1, col);
3612 /* Process equipment */
3613 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
3616 o_ptr = &inventory[i];
3618 /* Acquire "known" flags */
3619 object_flags_known(o_ptr, flgs);
3621 /* Initialize color based of sign of pval. */
3622 for (stat = 0; stat < 6; stat++)
3629 if (have_flag(flgs, stat))
3635 if (o_ptr->pval > 0)
3641 if (o_ptr->pval < 10) c = '0' + o_ptr->pval;
3644 if (have_flag(flgs, stat + TR_SUST_STR))
3646 /* Dark green for sustained stats */
3651 if (o_ptr->pval < 0)
3657 if (o_ptr->pval > -10) c = '0' - o_ptr->pval;
3662 else if (have_flag(flgs, stat + TR_SUST_STR))
3664 /* Dark green "s" */
3669 /* Dump proper character */
3670 Term_putch(col, row + stat+1, a, c);
3681 for (stat = 0; stat < 6; stat++)
3688 if (p_ptr->muta3 || p_ptr->tsuyoshi)
3694 if (p_ptr->muta3 & MUT3_HYPER_STR) dummy += 4;
3695 if (p_ptr->muta3 & MUT3_PUNY) dummy -= 4;
3696 if (p_ptr->tsuyoshi) dummy += 4;
3698 else if (stat == A_WIS || stat == A_INT)
3700 if (p_ptr->muta3 & MUT3_HYPER_INT) dummy += 4;
3701 if (p_ptr->muta3 & MUT3_MORONIC) dummy -= 4;
3703 else if (stat == A_DEX)
3705 if (p_ptr->muta3 & MUT3_IRON_SKIN) dummy -= 1;
3706 if (p_ptr->muta3 & MUT3_LIMBER) dummy += 3;
3707 if (p_ptr->muta3 & MUT3_ARTHRITIS) dummy -= 3;
3709 else if (stat == A_CON)
3711 if (p_ptr->muta3 & MUT3_RESILIENT) dummy += 4;
3712 if (p_ptr->muta3 & MUT3_XTRA_FAT) dummy += 2;
3713 if (p_ptr->muta3 & MUT3_ALBINO) dummy -= 4;
3714 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 2;
3715 if (p_ptr->tsuyoshi) dummy += 4;
3717 else if (stat == A_CHR)
3719 if (p_ptr->muta3 & MUT3_SILLY_VOI) dummy -= 4;
3720 if (p_ptr->muta3 & MUT3_BLANK_FAC) dummy -= 1;
3721 if (p_ptr->muta3 & MUT3_FLESH_ROT) dummy -= 1;
3722 if (p_ptr->muta3 & MUT3_SCALES) dummy -= 1;
3723 if (p_ptr->muta3 & MUT3_WART_SKIN) dummy -= 2;
3724 if (p_ptr->muta3 & MUT3_ILL_NORM) dummy = 0;
3740 if (dummy < 10) c = '0' + dummy;
3750 if (dummy > -10) c = '0' - dummy;
3757 if (have_flag(flgs, stat + TR_SUST_STR))
3759 /* Dark green "s" */
3766 Term_putch(col, row + stat+1, a, c);
3772 * @brief プレイヤーのステータス表示メイン処理
3773 * Display the character on the screen (various modes)
3774 * @param mode 表示モードID
3778 * The top one and bottom two lines are left blank.
3779 * Mode 0 = standard display with skills
3780 * Mode 1 = standard display with history
3781 * Mode 2 = summary of various things
3782 * Mode 3 = summary of various things (part 2)
3783 * Mode 4 = mutations
3786 void display_player(BIT_FLAGS mode)
3795 if ((p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3) && display_mutations)
3804 if ((mode == 0) || (mode == 1))
3806 /* Name, Sex, Race, Class */
3808 sprintf(tmp, "%s%s%s", ap_ptr->title, ap_ptr->no == 1 ? "の":"", p_ptr->name);
3810 sprintf(tmp, "%s %s", ap_ptr->title, p_ptr->name);
3813 display_player_one_line(ENTRY_NAME, tmp, TERM_L_BLUE);
3814 display_player_one_line(ENTRY_SEX, sp_ptr->title, TERM_L_BLUE);
3815 display_player_one_line(ENTRY_RACE, (p_ptr->mimic_form ? mimic_info[p_ptr->mimic_form].title : rp_ptr->title), TERM_L_BLUE);
3816 display_player_one_line(ENTRY_CLASS, cp_ptr->title, TERM_L_BLUE);
3821 sprintf(tmp, "%s, %s", realm_names[p_ptr->realm1], realm_names[p_ptr->realm2]);
3823 strcpy(tmp, realm_names[p_ptr->realm1]);
3824 display_player_one_line(ENTRY_REALM, tmp, TERM_L_BLUE);
3827 if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || (p_ptr->muta2 & MUT2_CHAOS_GIFT))
3828 display_player_one_line(ENTRY_PATRON, chaos_patrons[p_ptr->chaos_patron], TERM_L_BLUE);
3830 /* Age, Height, Weight, Social */
3831 /* 身長はセンチメートルに、体重はキログラムに変更してあります */
3833 display_player_one_line(ENTRY_AGE, format("%d才" ,(int)p_ptr->age), TERM_L_BLUE);
3834 display_player_one_line(ENTRY_HEIGHT, format("%dcm" ,(int)((p_ptr->ht*254)/100)), TERM_L_BLUE);
3835 display_player_one_line(ENTRY_WEIGHT, format("%dkg" ,(int)((p_ptr->wt*4536)/10000)), TERM_L_BLUE);
3836 display_player_one_line(ENTRY_SOCIAL, format("%d " ,(int)p_ptr->sc), TERM_L_BLUE);
3838 display_player_one_line(ENTRY_AGE, format("%d" ,(int)p_ptr->age), TERM_L_BLUE);
3839 display_player_one_line(ENTRY_HEIGHT, format("%d" ,(int)p_ptr->ht), TERM_L_BLUE);
3840 display_player_one_line(ENTRY_WEIGHT, format("%d" ,(int)p_ptr->wt), TERM_L_BLUE);
3841 display_player_one_line(ENTRY_SOCIAL, format("%d" ,(int)p_ptr->sc), TERM_L_BLUE);
3843 display_player_one_line(ENTRY_ALIGN, format("%s" ,your_alignment()), TERM_L_BLUE);
3846 /* Display the stats */
3847 for (i = 0; i < 6; i++)
3849 /* Special treatment of "injured" stats */
3850 if (p_ptr->stat_cur[i] < p_ptr->stat_max[i])
3854 /* Use lowercase stat name */
3855 put_str(stat_names_reduced[i], 3 + i, 53);
3857 /* Get the current stat */
3858 value = p_ptr->stat_use[i];
3860 /* Obtain the current stat (modified) */
3861 cnv_stat(value, buf);
3863 /* Display the current stat (modified) */
3864 c_put_str(TERM_YELLOW, buf, 3 + i, 60);
3866 /* Acquire the max stat */
3867 value = p_ptr->stat_top[i];
3869 /* Obtain the maximum stat (modified) */
3870 cnv_stat(value, buf);
3872 /* Display the maximum stat (modified) */
3873 c_put_str(TERM_L_GREEN, buf, 3 + i, 67);
3876 /* Normal treatment of "normal" stats */
3879 /* Assume uppercase stat name */
3880 put_str(stat_names[i], 3 + i, 53);
3882 /* Obtain the current stat (modified) */
3883 cnv_stat(p_ptr->stat_use[i], buf);
3885 /* Display the current stat (modified) */
3886 c_put_str(TERM_L_GREEN, buf, 3 + i, 60);
3889 if (p_ptr->stat_max[i] == p_ptr->stat_max_max[i])
3891 c_put_str(TERM_WHITE, "!", 3 + i, _(58, 58-2));
3895 /* Display "history" info */
3899 put_str(_("(キャラクターの生い立ち)", "(Character Background)"), 11, 25);
3901 for (i = 0; i < 4; i++)
3903 put_str(p_ptr->history[i], i + 12, 10);
3910 if (p_ptr->total_winner)
3913 sprintf(statmsg, "…あなたは勝利の後%sした。", streq(p_ptr->died_from, "Seppuku") ? "切腹" : "引退");
3915 sprintf(statmsg, "...You %s after the winning.", streq(p_ptr->died_from, "Seppuku") ? "did Seppuku" : "retired from the adventure");
3918 else if (!dun_level)
3921 sprintf(statmsg, "…あなたは%sで%sに殺された。", map_name(), p_ptr->died_from);
3923 sprintf(statmsg, "...You were killed by %s in %s.", p_ptr->died_from, map_name());
3926 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3928 /* Get the quest text */
3929 /* Bewere that INIT_ASSIGN resets the cur_num. */
3930 init_flags = INIT_NAME_ONLY;
3932 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3935 sprintf(statmsg, "…あなたは、クエスト「%s」で%sに殺された。", quest[p_ptr->inside_quest].name, p_ptr->died_from);
3937 sprintf(statmsg, "...You were killed by %s in the quest '%s'.", p_ptr->died_from, quest[p_ptr->inside_quest].name);
3943 sprintf(statmsg, "…あなたは、%sの%d階で%sに殺された。", map_name(), (int)dun_level, p_ptr->died_from);
3945 sprintf(statmsg, "...You were killed by %s on level %d of %s.", p_ptr->died_from, dun_level, map_name());
3949 else if (character_dungeon)
3953 sprintf(statmsg, _("…あなたは現在、 %s にいる。", "...Now, you are in %s."), map_name());
3955 else if (p_ptr->inside_quest && is_fixed_quest_idx(p_ptr->inside_quest))
3957 /* Clear the text */
3958 /* Must be done before doing INIT_SHOW_TEXT */
3959 for (i = 0; i < 10; i++)
3961 quest_text[i][0] = '\0';
3963 quest_text_line = 0;
3965 /* Get the quest text */
3966 init_flags = INIT_NAME_ONLY;
3968 process_dungeon_file("q_info.txt", 0, 0, 0, 0);
3970 sprintf(statmsg, _("…あなたは現在、 クエスト「%s」を遂行中だ。", "...Now, you are in the quest '%s'."), quest[p_ptr->inside_quest].name);
3975 sprintf(statmsg, "…あなたは現在、 %s の %d 階で探索している。", map_name(), (int)dun_level);
3977 sprintf(statmsg, "...Now, you are exploring level %d of %s.", dun_level, map_name());
3984 char temp[64*2], *t;
3985 roff_to_buf(statmsg, 60, temp, sizeof(temp));
3987 for(i=0 ; i<2 ; i++)
3993 put_str(t, i + 5 + 12, 10);
4001 /* Display "various" info */
4004 display_player_middle();
4005 display_player_various();
4012 /* See "http://www.cs.berkeley.edu/~davidb/angband.html" */
4015 display_player_misc_info();
4016 display_player_stat_info();
4017 display_player_flag_info();
4023 display_player_other_flag_info();
4028 do_cmd_knowledge_mutations();
4033 * @brief プレイヤーのステータス表示をファイルにダンプする
4034 * @param fff ファイルポインタ
4037 static void dump_aux_display_player(FILE *fff)
4044 /* Display player */
4047 /* Dump part of the screen */
4048 for (y = 1; y < 22; y++)
4051 for (x = 0; x < 79; x++)
4053 /* Get the attr/char */
4054 (void)(Term_what(x, y, &a, &c));
4060 /* End the string */
4063 /* Kill trailing spaces */
4064 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4067 fprintf(fff, _("%s\n", "%s\n"), buf);
4070 /* Display history */
4073 /* Dump part of the screen */
4074 for (y = 10; y < 19; y++)
4077 for (x = 0; x < 79; x++)
4079 /* Get the attr/char */
4080 (void)(Term_what(x, y, &a, &c));
4086 /* End the string */
4089 /* Kill trailing spaces */
4090 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4093 fprintf(fff, "%s\n", buf);
4098 /* Display flags (part 1) */
4101 /* Dump part of the screen */
4102 for (y = 2; y < 22; y++)
4105 for (x = 0; x < 79; x++)
4107 /* Get the attr/char */
4108 (void)(Term_what(x, y, &a, &c));
4110 /* Dump it (Ignore equippy tile graphic) */
4117 /* End the string */
4120 /* Kill trailing spaces */
4121 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4124 fprintf(fff, "%s\n", buf);
4129 /* Display flags (part 2) */
4132 /* Dump part of the screen */
4133 for (y = 1; y < 22; y++)
4136 for (x = 0; x < 79; x++)
4138 /* Get the attr/char */
4139 (void)(Term_what(x, y, &a, &c));
4141 /* Dump it (Ignore equippy tile graphic) */
4148 /* End the string */
4151 /* Kill trailing spaces */
4152 while ((x > 0) && (buf[x-1] == ' ')) buf[--x] = '\0';
4155 fprintf(fff, "%s\n", buf);
4163 * @brief プレイヤーのペット情報をファイルにダンプする
4164 * @param fff ファイルポインタ
4167 static void dump_aux_pet(FILE *fff)
4171 bool pet_settings = FALSE;
4174 for (i = m_max - 1; i >= 1; i--)
4176 monster_type *m_ptr = &m_list[i];
4178 if (!m_ptr->r_idx) continue;
4179 if (!is_pet(m_ptr)) continue;
4180 pet_settings = TRUE;
4181 if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
4184 fprintf(fff, _("\n\n [主なペット]\n\n", "\n\n [Leading Pets]\n\n"));
4187 monster_desc(pet_name, m_ptr, MD_ASSUME_VISIBLE | MD_INDEF_VISIBLE);
4188 fprintf(fff, "%s\n", pet_name);
4193 fprintf(fff, _("\n\n [ペットへの命令]\n", "\n\n [Command for Pets]\n"));
4195 fprintf(fff, _("\n ドアを開ける: %s", "\n Pets open doors: %s"),
4196 (p_ptr->pet_extra_flags & PF_OPEN_DOORS) ? "ON" : "OFF");
4198 fprintf(fff, _("\n アイテムを拾う: %s", "\n Pets pick up items: %s"),
4199 (p_ptr->pet_extra_flags & PF_PICKUP_ITEMS) ? "ON" : "OFF");
4201 fprintf(fff, _("\n テレポート系魔法を使う: %s", "\n Allow teleport: %s"),
4202 (p_ptr->pet_extra_flags & PF_TELEPORT) ? "ON" : "OFF");
4204 fprintf(fff, _("\n 攻撃魔法を使う: %s", "\n Allow cast attack spell: %s"),
4205 (p_ptr->pet_extra_flags & PF_ATTACK_SPELL) ? "ON" : "OFF");
4207 fprintf(fff, _("\n 召喚魔法を使う: %s", "\n Allow cast summon spell: %s"),
4208 (p_ptr->pet_extra_flags & PF_SUMMON_SPELL) ? "ON" : "OFF");
4210 fprintf(fff, _("\n プレイヤーを巻き込む範囲魔法を使う: %s", "\n Allow involve player in area spell: %s"),
4211 (p_ptr->pet_extra_flags & PF_BALL_SPELL) ? "ON" : "OFF");
4219 * @brief プレイヤーの職業能力情報をファイルにダンプする
4220 * @param fff ファイルポインタ
4223 static void dump_aux_class_special(FILE *fff)
4225 if (p_ptr->pclass == CLASS_BLUE_MAGE)
4232 int spellnum[MAX_MONSPELLS];
4233 s32b f4 = 0, f5 = 0, f6 = 0;
4238 for (i=0;i<60;i++) { p[i][0] = '\0'; }
4240 strcat(p[col], _("\n\n [学習済みの青魔法]\n", "\n\n [Learned Blue Magic]\n"));
4245 set_rf_masks(&f4, &f5, &f6, j);
4248 case MONSPELL_TYPE_BOLT:
4249 strcat(p[col], _("\n [ボルト型]\n", "\n [Bolt Type]\n"));
4252 case MONSPELL_TYPE_BALL:
4253 strcat(p[col], _("\n [ボール型]\n", "\n [Ball Type]\n"));
4256 case MONSPELL_TYPE_BREATH:
4257 strcat(p[col], _("\n [ブレス型]\n", "\n [ Breath ]\n"));
4260 case MONSPELL_TYPE_SUMMON:
4261 strcat(p[col], _("\n [召喚魔法]\n", "\n [Summonning]\n"));
4264 case MONSPELL_TYPE_OTHER:
4265 strcat(p[col], _("\n [ その他 ]\n", "\n [Other Type]\n"));
4269 for (i = 0, num = 0; i < 32; i++)
4271 if ((0x00000001 << i) & f4) spellnum[num++] = i;
4275 if ((0x00000001 << (i - 32)) & f5) spellnum[num++] = i;
4279 if ((0x00000001 << (i - 64)) & f6) spellnum[num++] = i;
4284 strcat(p[col], " ");
4286 for (i = 0; i < num; i++)
4288 if (p_ptr->magic_num2[spellnum[i]])
4291 /* Dump blue magic */
4292 l1 = strlen(p[col]);
4293 l2 = strlen(monster_powers_short[spellnum[i]]);
4294 if ((l1 + l2) >= 75)
4296 strcat(p[col], "\n");
4298 strcat(p[col], " ");
4300 strcat(p[col], monster_powers_short[spellnum[i]]);
4301 strcat(p[col], ", ");
4307 strcat(p[col], _("なし", "None"));
4311 if (p[col][strlen(p[col])-2] == ',')
4313 p[col][strlen(p[col])-2] = '\0';
4317 p[col][strlen(p[col])-10] = '\0';
4321 strcat(p[col], "\n");
4324 for (i=0;i<=col;i++)
4329 else if (p_ptr->pclass == CLASS_MAGIC_EATER)
4331 char s[EATER_EXT][MAX_NLEN];
4332 OBJECT_TYPE_VALUE tval;
4335 OBJECT_SUBTYPE_VALUE i;
4338 fprintf(fff, _("\n\n [取り込んだ魔法道具]\n", "\n\n [Magic devices eaten]\n"));
4340 for (ext = 0; ext < 3; ext++)
4344 /* Dump an extent name */
4349 fprintf(fff, _("\n[杖]\n", "\n[Staffs]\n"));
4353 fprintf(fff, _("\n[魔法棒]\n", "\n[Wands]\n"));
4357 fprintf(fff, _("\n[ロッド]\n", "\n[Rods]\n"));
4361 /* Get magic device names that were eaten */
4362 for (i = 0; i < EATER_EXT; i++)
4364 int idx = EATER_EXT * ext + i;
4366 magic_num = p_ptr->magic_num2[idx];
4367 if (!magic_num) continue;
4369 k_idx = lookup_kind(tval, i);
4370 if (!k_idx) continue;
4371 sprintf(s[eat_num], "%23s (%2d)", (k_name + k_info[k_idx].name), magic_num);
4375 /* Dump magic devices in this extent */
4378 for (i = 0; i < eat_num; i++)
4381 if (i % 3 < 2) fputs(" ", fff);
4382 else fputs("\n", fff);
4385 if (i % 3 > 0) fputs("\n", fff);
4387 else /* Not found */
4389 fputs(_(" (なし)\n", " (none)\n"), fff);
4393 else if (p_ptr->pclass == CLASS_SMITH)
4395 int i, id[250], n = 0, row;
4397 fprintf(fff, _("\n\n [手に入れたエッセンス]\n\n", "\n\n [Get Essence]\n\n"));
4398 fprintf(fff, _("エッセンス 個数 エッセンス 個数 エッセンス 個数",
4399 "Essence Num Essence Num Essence Num "));
4400 for (i = 0; essence_name[i]; i++)
4402 if (!essence_name[i][0]) continue;
4409 for (i = 0; i < row; i++)
4412 fprintf(fff, "%-11s %5d ", essence_name[id[i]], (int)p_ptr->magic_num1[id[i]]);
4413 if(i + row < n) fprintf(fff, "%-11s %5d ", essence_name[id[i + row]], (int)p_ptr->magic_num1[id[i + row]]);
4414 if(i + row * 2 < n) fprintf(fff, "%-11s %5d", essence_name[id[i + row * 2]], (int)p_ptr->magic_num1[id[i + row * 2]]);
4424 * @brief クエスト情報をファイルにダンプする
4425 * @param fff ファイルポインタ
4428 static void dump_aux_quest(FILE *fff)
4434 fprintf(fff, _("\n\n [クエスト情報]\n", "\n\n [Quest Information]\n"));
4436 /* Allocate Memory */
4437 C_MAKE(quest_num, max_quests, IDX);
4439 /* Sort by compete level */
4440 for (i = 1; i < max_quests; i++) quest_num[i] = i;
4441 ang_sort_comp = ang_sort_comp_quest_num;
4442 ang_sort_swap = ang_sort_swap_quest_num;
4443 ang_sort(quest_num, &dummy, max_quests);
4445 /* Dump Quest Information */
4447 do_cmd_knowledge_quests_completed(fff, quest_num);
4449 do_cmd_knowledge_quests_failed(fff, quest_num);
4453 C_KILL(quest_num, max_quests, IDX);
4458 * @brief 死の直前メッセージ並びに遺言をファイルにダンプする
4459 * @param fff ファイルポインタ
4462 static void dump_aux_last_message(FILE *fff)
4466 if (!p_ptr->total_winner)
4470 fprintf(fff, _("\n [死ぬ直前のメッセージ]\n\n", "\n [Last Messages]\n\n"));
4471 for (i = MIN(message_num(), 30); i >= 0; i--)
4473 fprintf(fff,"> %s\n",message_str((s16b)i));
4478 /* Hack -- *Winning* message */
4479 else if (p_ptr->last_message)
4481 fprintf(fff, _("\n [*勝利*メッセージ]\n\n", "\n [*Winning* Message]\n\n"));
4482 fprintf(fff," %s\n", p_ptr->last_message);
4489 * @brief 帰還場所情報をファイルにダンプする
4490 * @param fff ファイルポインタ
4493 static void dump_aux_recall(FILE *fff)
4496 fprintf(fff, _("\n [帰還場所]\n\n", "\n [Recall Depth]\n\n"));
4498 for (y = 1; y < max_d_idx; y++)
4502 if (!d_info[y].maxdepth) continue;
4503 if (!max_dlv[y]) continue;
4504 if (d_info[y].final_guardian)
4506 if (!r_info[d_info[y].final_guardian].max_num) seiha = TRUE;
4508 else if (max_dlv[y] == d_info[y].maxdepth) seiha = TRUE;
4510 fprintf(fff, _(" %c%-12s: %3d 階\n", " %c%-16s: level %3d\n"),
4511 seiha ? '!' : ' ', d_name+d_info[y].name, (int)max_dlv[y]);
4517 * @brief オプション情報をファイルにダンプする
4518 * @param fff ファイルポインタ
4521 static void dump_aux_options(FILE *fff)
4523 fprintf(fff, _("\n [オプション設定]\n", "\n [Option Settings]\n"));
4526 fprintf(fff, _("\n 保存モード: ON", "\n Preserve Mode: ON"));
4529 fprintf(fff, _("\n 保存モード: OFF", "\n Preserve Mode: OFF"));
4531 if (ironman_small_levels)
4532 fprintf(fff, _("\n 小さいダンジョン: ALWAYS", "\n Small Levels: ALWAYS"));
4533 else if (always_small_levels)
4534 fprintf(fff, _("\n 小さいダンジョン: ON", "\n Small Levels: ON"));
4535 else if (small_levels)
4536 fprintf(fff, _("\n 小さいダンジョン: ENABLED", "\n Small Levels: ENABLED"));
4538 fprintf(fff, _("\n 小さいダンジョン: OFF", "\n Small Levels: OFF"));
4542 fprintf(fff, _("\n 元祖の町のみ: ON", "\n Vanilla Town: ON"));
4544 fprintf(fff, _("\n 小規模な町: ON", "\n Lite Town: ON"));
4548 fprintf(fff, _("\n 店なし: ON", "\n No Shops: ON"));
4550 if (ironman_downward)
4551 fprintf(fff, _("\n 階段を上がれない: ON", "\n Diving Only: ON"));
4554 fprintf(fff, _("\n 普通でない部屋: ON", "\n Unusual Rooms: ON"));
4556 if (ironman_nightmare)
4557 fprintf(fff, _("\n 悪夢モード: ON", "\n Nightmare Mode: ON"));
4560 if (ironman_empty_levels)
4561 fprintf(fff, _("\n アリーナ: ALWAYS", "\n Arena Levels: ALWAYS"));
4562 else if (empty_levels)
4563 fprintf(fff, _("\n アリーナ: ENABLED", "\n Arena Levels: ENABLED"));
4565 fprintf(fff, _("\n アリーナ: OFF", "\n Arena Levels: OFF"));
4570 fprintf(fff, _("\n 何か不正なことをしてしまっています。\n", "\n You have done something illegal.\n"));
4577 * @brief 闘技場の情報をファイルにダンプする
4578 * @param fff ファイルポインタ
4581 static void dump_aux_arena(FILE *fff)
4583 if (lite_town || vanilla_town) return;
4585 if (p_ptr->arena_number < 0)
4587 if (p_ptr->arena_number <= ARENA_DEFEATED_OLD_VER)
4589 fprintf(fff, _("\n 闘技場: 敗北\n", "\n Arena: Defeated\n"));
4594 fprintf(fff, "\n 闘技場: %d回戦で%sの前に敗北\n", -p_ptr->arena_number,
4595 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name);
4597 fprintf(fff, "\n Arena: Defeated by %s in the %d%s fight\n",
4598 r_name + r_info[arena_info[-1 - p_ptr->arena_number].r_idx].name,
4599 -p_ptr->arena_number, get_ordinal_number_suffix(-p_ptr->arena_number));
4603 else if (p_ptr->arena_number > MAX_ARENA_MONS + 2)
4605 fprintf(fff, _("\n 闘技場: 真のチャンピオン\n", "\n Arena: True Champion\n"));
4607 else if (p_ptr->arena_number > MAX_ARENA_MONS - 1)
4609 fprintf(fff, _("\n 闘技場: チャンピオン\n", "\n Arena: Champion\n"));
4614 fprintf(fff, "\n 闘技場: %2d勝\n", (p_ptr->arena_number > MAX_ARENA_MONS ? MAX_ARENA_MONS : p_ptr->arena_number));
4616 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");
4625 * @brief 撃破モンスターの情報をファイルにダンプする
4626 * @param fff ファイルポインタ
4629 static void dump_aux_monsters(FILE *fff)
4631 /* Monsters slain */
4634 long uniq_total = 0;
4635 long norm_total = 0;
4638 /* Sort by monster level */
4641 fprintf(fff, _("\n [倒したモンスター]\n\n", "\n [Defeated Monsters]\n\n"));
4643 /* Allocate the "who" array */
4644 C_MAKE(who, max_r_idx, s16b);
4646 /* Count monster kills */
4647 for (k = 1; k < max_r_idx; k++)
4649 monster_race *r_ptr = &r_info[k];
4651 /* Ignore unused index */
4652 if (!r_ptr->name) continue;
4654 /* Unique monsters */
4655 if (r_ptr->flags1 & RF1_UNIQUE)
4657 bool dead = (r_ptr->max_num == 0);
4662 /* Add a unique monster to the list */
4663 who[uniq_total++] = k;
4667 /* Normal monsters */
4670 if (r_ptr->r_pkills > 0)
4672 norm_total += r_ptr->r_pkills;
4678 /* No monsters is defeated */
4681 fprintf(fff,_("まだ敵を倒していません。\n", "You have defeated no enemies yet.\n"));
4684 /* Defeated more than one normal monsters */
4685 else if (uniq_total == 0)
4688 fprintf(fff,"%ld体の敵を倒しています。\n", norm_total);
4690 fprintf(fff,"You have defeated %ld %s.\n", norm_total, norm_total == 1 ? "enemy" : "enemies");
4694 /* Defeated more than one unique monsters */
4695 else /* if (uniq_total > 0) */
4698 fprintf(fff, "%ld体のユニーク・モンスターを含む、合計%ld体の敵を倒しています。\n", uniq_total, norm_total);
4700 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"));
4704 /* Select the sort method */
4705 ang_sort_comp = ang_sort_comp_hook;
4706 ang_sort_swap = ang_sort_swap_hook;
4708 /* Sort the array by dungeon depth of monsters */
4709 ang_sort(who, &why, uniq_total);
4710 fprintf(fff, _("\n《上位%ld体のユニーク・モンスター》\n", "\n< Unique monsters top %ld >\n"), MIN(uniq_total, 10));
4713 for (k = uniq_total - 1; k >= 0 && k >= uniq_total - 10; k--)
4715 monster_race *r_ptr = &r_info[who[k]];
4716 fprintf(fff, _(" %-40s (レベル%3d)\n", " %-40s (level %3d)\n"), (r_name + r_ptr->name), (int)r_ptr->level);
4721 /* Free the "who" array */
4722 C_KILL(who, max_r_idx, s16b);
4727 * @brief 元種族情報をファイルにダンプする
4728 * @param fff ファイルポインタ
4731 static void dump_aux_race_history(FILE *fff)
4733 if (p_ptr->old_race1 || p_ptr->old_race2)
4737 fprintf(fff, _("\n\n あなたは%sとして生まれた。", "\n\n You were born as %s."), race_info[p_ptr->start_race].title);
4738 for (i = 0; i < MAX_RACES; i++)
4740 if (p_ptr->start_race == i) continue;
4743 if (!(p_ptr->old_race1 & 1L << i)) continue;
4747 if (!(p_ptr->old_race2 & 1L << (i-32))) continue;
4749 fprintf(fff, _("\n あなたはかつて%sだった。", "\n You were a %s before."), race_info[i].title);
4758 * @brief 元魔法領域情報をファイルにダンプする
4759 * @param fff ファイルポインタ
4762 static void dump_aux_realm_history(FILE *fff)
4764 if (p_ptr->old_realm)
4769 for (i = 0; i < MAX_MAGIC; i++)
4771 if (!(p_ptr->old_realm & 1L << i)) continue;
4772 fprintf(fff, _("\n あなたはかつて%s魔法を使えた。", "\n You were able to use %s magic before."), realm_names[i+1]);
4780 * @brief 徳の情報をファイルにダンプする
4781 * @param fff ファイルポインタ
4784 static void dump_aux_virtues(FILE *fff)
4788 fprintf(fff, _("\n\n [自分に関する情報]\n\n", "\n\n [HP-rate & Max stat & Virtues]\n\n"));
4790 percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
4791 (2 * p_ptr->hitdie +
4792 ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
4795 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "現在の体力ランク : %d/100\n\n", percent);
4796 else fprintf(fff, "現在の体力ランク : ???\n\n");
4797 fprintf(fff, "能力の最大値\n");
4799 if (p_ptr->knowledge & KNOW_HPRATE) fprintf(fff, "Your current Life Rating is %d/100.\n\n", percent);
4800 else fprintf(fff, "Your current Life Rating is ???.\n\n");
4801 fprintf(fff, "Limits of maximum stats\n");
4803 for (v_nr = 0; v_nr < 6; v_nr++)
4805 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);
4806 else fprintf(fff, "%s ???\n", stat_names[v_nr]);
4809 fprintf(fff, _("\n属性 : %s\n", "\nYour alighnment : %s\n"), your_alignment());
4816 * @brief 突然変異の情報をファイルにダンプする
4817 * @param fff ファイルポインタ
4820 static void dump_aux_mutations(FILE *fff)
4822 if (p_ptr->muta1 || p_ptr->muta2 || p_ptr->muta3)
4824 fprintf(fff, _("\n\n [突然変異]\n\n", "\n\n [Mutations]\n\n"));
4825 dump_mutations(fff);
4831 * @brief 所持品の情報をファイルにダンプする
4832 * @param fff ファイルポインタ
4835 static void dump_aux_equipment_inventory(FILE *fff)
4838 char o_name[MAX_NLEN];
4840 /* Dump the equipment */
4843 fprintf(fff, _(" [キャラクタの装備]\n\n", " [Character Equipment]\n\n"));
4844 for (i = INVEN_RARM; i < INVEN_TOTAL; i++)
4846 object_desc(o_name, &inventory[i], 0);
4847 if ((((i == INVEN_RARM) && p_ptr->hidarite) || ((i == INVEN_LARM) && p_ptr->migite)) && p_ptr->ryoute)
4848 strcpy(o_name, _("(武器を両手持ち)", "(wielding with two-hands)"));
4850 fprintf(fff, "%c) %s\n",
4851 index_to_label(i), o_name);
4853 fprintf(fff, "\n\n");
4856 /* Dump the inventory */
4857 fprintf(fff, _(" [キャラクタの持ち物]\n\n", " [Character Inventory]\n\n"));
4859 for (i = 0; i < INVEN_PACK; i++)
4861 /* Don't dump the empty slots */
4862 if (!inventory[i].k_idx) break;
4864 /* Dump the inventory slots */
4865 object_desc(o_name, &inventory[i], 0);
4866 fprintf(fff, "%c) %s\n", index_to_label(i), o_name);
4869 /* Add an empty line */
4870 fprintf(fff, "\n\n");
4875 * @brief 我が家と博物館のオブジェクト情報をファイルにダンプする
4876 * @param fff ファイルポインタ
4879 static void dump_aux_home_museum(FILE *fff)
4881 char o_name[MAX_NLEN];
4884 /* Do we need it?? */
4885 /* process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x); */
4887 /* Print the home */
4888 st_ptr = &town[1].store[STORE_HOME];
4890 /* Home -- if anything there */
4891 if (st_ptr->stock_num)
4896 fprintf(fff, _(" [我が家のアイテム]\n", " [Home Inventory]\n"));
4898 /* Dump all available items */
4899 for (i = 0; i < st_ptr->stock_num; i++)
4902 fprintf(fff, _("\n ( %d ページ )\n", "\n ( page %d )\n"), x++);
4903 object_desc(o_name, &st_ptr->stock[i], 0);
4904 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4907 /* Add an empty line */
4908 fprintf(fff, "\n\n");
4912 /* Print the home */
4913 st_ptr = &town[1].store[STORE_MUSEUM];
4915 /* Home -- if anything there */
4916 if (st_ptr->stock_num)
4921 fprintf(fff, _(" [博物館のアイテム]\n", " [Museum]\n"));
4923 /* Dump all available items */
4924 for (i = 0; i < st_ptr->stock_num; i++)
4927 if ((i % 12) == 0) fprintf(fff, "\n ( %d ページ )\n", x++);
4928 object_desc(o_name, &st_ptr->stock[i], 0);
4929 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4931 if ((i % 12) == 0) fprintf(fff, "\n ( page %d )\n", x++);
4932 object_desc(o_name, &st_ptr->stock[i], 0);
4933 fprintf(fff, "%c) %s\n", I2A(i%12), o_name);
4938 /* Add an empty line */
4939 fprintf(fff, "\n\n");
4945 * @brief ダンプ出力のメインルーチン
4946 * Output the character dump to a file
4947 * @param fff ファイルポインタ
4950 errr make_character_dump(FILE *fff)
4953 fprintf(fff, " [変愚蛮怒 %d.%d.%d キャラクタ情報]\n\n",
4954 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4956 fprintf(fff, " [Hengband %d.%d.%d Character Dump]\n\n",
4957 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH);
4962 dump_aux_display_player(fff);
4963 dump_aux_last_message(fff);
4964 dump_aux_options(fff);
4965 dump_aux_recall(fff);
4966 dump_aux_quest(fff);
4967 dump_aux_arena(fff);
4968 dump_aux_monsters(fff);
4969 dump_aux_virtues(fff);
4970 dump_aux_race_history(fff);
4971 dump_aux_realm_history(fff);
4972 dump_aux_class_special(fff);
4973 dump_aux_mutations(fff);
4976 dump_aux_equipment_inventory(fff);
4977 dump_aux_home_museum(fff);
4979 fprintf(fff, _(" [チェックサム: \"%s\"]\n\n", " [Check Sum: \"%s\"]\n\n"), get_check_sum());
4984 * @brief プレイヤーステータスをファイルダンプ出力する
4985 * Hack -- Dump a character description file
4986 * @param name 出力ファイル名
4989 * XXX XXX XXX Allow the "full" flag to dump additional info,
4990 * and trigger its usage from various places in the code.
4992 errr file_character(cptr name)
4998 /* Build the filename */
4999 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
5001 /* File type is "TEXT" */
5002 FILE_TYPE(FILE_TYPE_TEXT);
5004 /* Check for existing file */
5005 fd = fd_open(buf, O_RDONLY);
5012 /* Close the file */
5016 (void)sprintf(out_val, _("現存するファイル %s に上書きしますか? ", "Replace existing file %s? "), buf);
5019 if (get_check_strict(out_val, CHECK_NO_HISTORY)) fd = -1;
5022 /* Open the non-existing file */
5023 if (fd < 0) fff = my_fopen(buf, "w");
5029 prt(_("キャラクタ情報のファイルへの書き出しに失敗しました!", "Character dump failed!"), 0, 0);
5037 (void)make_character_dump(fff);
5044 msg_print(_("キャラクタ情報のファイルへの書き出しに成功しました。", "Character dump successful."));
5053 * @brief ファイル内容の一行をコンソールに出力する
5054 * Display single line of on-line help file
5055 * @param str 出力する文字列
5061 * You can insert some special color tag to change text color.
5063 * WHITETEXT [[[[y|SOME TEXT WHICH IS DISPLAYED IN YELLOW| WHITETEXT
5064 * A colored segment is between "[[[[y|" and the last "|".
5065 * You can use any single character in place of the "|".
5068 static void show_file_aux_line(cptr str, int cy, cptr shower)
5070 static const char tag_str[] = "[[[[";
5071 byte color = TERM_WHITE;
5079 /* Make a lower case version of str for searching */
5084 /* Initial cursor position */
5085 Term_gotoxy(cx, cy);
5087 for (i = 0; str[i];)
5089 int len = strlen(&str[i]);
5090 int showercol = len + 1;
5091 int bracketcol = len + 1;
5095 /* Search for a shower string in the line */
5098 ptr = my_strstr(&lcstr[i], shower);
5099 if (ptr) showercol = ptr - &lcstr[i];
5102 /* Search for a color segment tag */
5103 ptr = in_tag ? my_strchr(&str[i], in_tag) : my_strstr(&str[i], tag_str);
5104 if (ptr) bracketcol = ptr - &str[i];
5106 /* A color tag is found */
5107 if (bracketcol < endcol) endcol = bracketcol;
5109 /* The shower string is found before the color tag */
5110 if (showercol < endcol) endcol = showercol;
5112 /* Print a segment of the line */
5113 Term_addstr(endcol, color, &str[i]);
5117 /* Shower string? */
5118 if (endcol == showercol)
5120 int showerlen = strlen(shower);
5122 /* Print the shower string in yellow */
5123 Term_addstr(showerlen, TERM_YELLOW, &str[i]);
5128 /* Colored segment? */
5129 else if (endcol == bracketcol)
5133 /* Found the end of colored segment */
5136 /* Now looking for an another tag_str */
5139 /* Set back to the default color */
5144 /* Found a tag_str, and get a tag color */
5145 i += sizeof(tag_str)-1;
5148 color = color_char_to_attr(str[i]);
5150 /* Illegal color tag */
5151 if (color == 255 || str[i+1] == '\0')
5153 /* Illegal color tag */
5156 /* Print the broken tag as a string */
5157 Term_addstr(-1, TERM_WHITE, tag_str);
5158 cx += sizeof(tag_str)-1;
5162 /* Skip the color tag */
5165 /* Now looking for a close tag */
5168 /* Skip the close-tag-indicator */
5174 } /* for (i = 0; str[i];) */
5176 /* Clear rest of line */
5177 Term_erase(cx, cy, 255);
5182 * @brief ファイル内容をコンソールに出力する
5183 * Recursive file perusal.
5184 * @param show_version TRUEならばコンソール上にゲームのバージョンを表示する
5185 * @param name ファイル名の文字列
5186 * @param what 内容キャプションの文字列
5187 * @param line 表示の現在行
5192 * Process various special text in the input file, including
5193 * the "menu" structures used by the "help file" system.
5194 * Return FALSE on 'q' to exit from a deep, otherwise TRUE.
5197 bool show_file(bool show_version, cptr name, cptr what, int line, BIT_FLAGS mode)
5201 /* Number of "real" lines passed by */
5204 /* Number of "real" lines in the file */
5207 /* Backup value for "line" */
5210 /* This screen has sub-screens */
5213 /* Current help file */
5216 /* Find this string (if any) */
5219 /* Jump to this tag */
5222 /* Hold strings to find/show */
5223 char finder_str[81];
5224 char shower_str[81];
5227 /* String to show */
5231 char filename[1024];
5233 /* Describe this thing */
5239 /* General buffer */
5242 /* Sub-menu information */
5245 bool reverse = (line < 0);
5249 Term_get_size(&wid, &hgt);
5253 strcpy(finder_str, "");
5256 strcpy(shower_str, "");
5259 strcpy(caption, "");
5261 /* Wipe the hooks */
5262 for (i = 0; i < 68; i++)
5267 /* Copy the filename */
5268 strcpy(filename, name);
5270 n = strlen(filename);
5272 /* Extract the tag from the filename */
5273 for (i = 0; i < n; i++)
5275 if (filename[i] == '#')
5278 tag = filename + i + 1;
5283 /* Redirect the name */
5286 /* Hack XXX XXX XXX */
5290 strcpy(caption, what);
5292 /* Access the "file" */
5296 fff = my_fopen(path, "r");
5299 /* Look in "help" */
5303 sprintf(caption, _("ヘルプ・ファイル'%s'", "Help file '%s'"), name);
5305 /* Build the filename */
5306 path_build(path, sizeof(path), ANGBAND_DIR_HELP, name);
5309 fff = my_fopen(path, "r");
5312 /* Look in "info" */
5316 sprintf(caption, _("スポイラー・ファイル'%s'", "Info file '%s'"), name);
5318 /* Build the filename */
5319 path_build(path, sizeof(path), ANGBAND_DIR_INFO, name);
5322 fff = my_fopen(path, "r");
5325 /* Look in "info" */
5328 /* Build the filename */
5329 path_build(path, sizeof(path), ANGBAND_DIR, name);
5331 for (i = 0; path[i]; i++)
5332 if ('\\' == path[i])
5333 path[i] = PATH_SEP[0];
5336 sprintf(caption, _("スポイラー・ファイル'%s'", "Info file '%s'"), name);
5339 fff = my_fopen(path, "r");
5346 msg_format(_("'%s'をオープンできません。", "Cannot open '%s'."), name);
5354 /* Pre-Parse the file */
5359 /* Read a line or stop */
5360 if (my_fgets(fff, buf, sizeof(buf))) break;
5362 /* XXX Parse "menu" items */
5363 if (prefix(str, "***** "))
5365 /* Notice "menu" requests */
5366 if ((str[6] == '[') && isalpha(str[7]))
5368 /* Extract the menu item */
5369 int k = str[7] - 'A';
5371 /* This is a menu file */
5374 if ((str[8] == ']') && (str[9] == ' '))
5376 /* Extract the menu item */
5377 strncpy(hook[k], str + 10, 31);
5379 /* Make sure it's null-terminated */
5383 /* Notice "tag" requests */
5384 else if (str[6] == '<')
5386 size_t len = strlen(str);
5388 if (str[len - 1] == '>')
5390 str[len - 1] = '\0';
5391 if (tag && streq(str + 7, tag)) line = next;
5399 /* Count the "real" lines */
5403 /* Save the number of "real" lines */
5406 /* start from bottom when reverse mode */
5407 if (line == -1) line = ((size-1)/rows)*rows;
5412 /* Display the file */
5415 /* Restart when necessary */
5416 if (line >= size - rows) line = size - rows;
5417 if (line < 0) line = 0;
5419 /* Re-open the file if needed */
5425 /* Hack -- Re-Open the file */
5426 fff = my_fopen(path, "r");
5429 if (!fff) return (FALSE);
5431 /* File has been restarted */
5435 /* Goto the selected line */
5439 if (my_fgets(fff, buf, sizeof(buf))) break;
5441 /* Skip tags/links */
5442 if (prefix(buf, "***** ")) continue;
5444 /* Count the lines */
5448 /* Dump the next 20, or rows, lines of the file */
5449 for (i = 0; i < rows; )
5453 /* Hack -- track the "first" line */
5454 if (!i) line = next;
5456 /* Get a line of the file or stop */
5457 if (my_fgets(fff, buf, sizeof(buf))) break;
5459 /* Hack -- skip "special" lines */
5460 if (prefix(buf, "***** ")) continue;
5462 /* Count the "real" lines */
5465 /* Hack -- keep searching */
5470 /* Make a lower case version of str for searching */
5471 strcpy(lc_buf, str);
5472 str_tolower(lc_buf);
5474 if (!my_strstr(lc_buf, find)) continue;
5477 /* Hack -- stop searching */
5481 show_file_aux_line(str, i + 2, shower);
5483 /* Count the printed lines */
5489 /* Clear rest of line */
5490 Term_erase(0, i + 2, 255);
5495 /* Hack -- failed search */
5505 /* Show a general "title" */
5508 prt(format(_("[変愚蛮怒 %d.%d.%d, %s, %d/%d]", "[Hengband %d.%d.%d, %s, Line %d/%d]"),
5509 FAKE_VER_MAJOR-10, FAKE_VER_MINOR, FAKE_VER_PATCH,
5510 caption, line, size), 0, 0);
5514 prt(format(_("[%s, %d/%d]", "[%s, Line %d/%d]"),
5515 caption, line, size), 0, 0);
5518 /* Prompt -- small files */
5522 prt(_("[キー:(?)ヘルプ (ESC)終了]", "[Press ESC to exit.]"), hgt - 1, 0);
5525 /* Prompt -- large files */
5530 prt("[キー:(RET/スペース)↑ (-)↓ (?)ヘルプ (ESC)終了]", hgt - 1, 0);
5532 prt("[キー:(RET/スペース)↓ (-)↑ (?)ヘルプ (ESC)終了]", hgt - 1, 0);
5534 prt("[Press Return, Space, -, =, /, |, or ESC to exit.]", hgt - 1, 0);
5538 /* Get a special key code */
5539 skey = inkey_special(TRUE);
5543 /* Show the help for the help */
5545 /* Hack - prevent silly recursion */
5546 if (strcmp(name, _("jhelpinfo.txt", "helpinfo.txt")) != 0)
5547 show_file(TRUE, _("jhelpinfo.txt", "helpinfo.txt"), NULL, 0, mode);
5550 /* Hack -- try showing */
5553 prt(_("強調: ", "Show: "), hgt - 1, 0);
5555 strcpy(back_str, shower_str);
5556 if (askfor(shower_str, 80))
5560 /* Make it lowercase */
5561 str_tolower(shower_str);
5564 shower = shower_str;
5566 else shower = NULL; /* Stop showing */
5568 else strcpy(shower_str, back_str);
5571 /* Hack -- try finding */
5575 prt(_("検索: ", "Find: "), hgt - 1, 0);
5577 strcpy(back_str, finder_str);
5578 if (askfor(finder_str, 80))
5587 /* Make finder lowercase */
5588 str_tolower(finder_str);
5591 shower = finder_str;
5593 else shower = NULL; /* Stop showing */
5595 else strcpy(finder_str, back_str);
5598 /* Hack -- go to a specific line */
5602 prt(_("行: ", "Goto Line: "), hgt - 1, 0);
5605 if (askfor(tmp, 80)) line = atoi(tmp);
5609 /* Hack -- go to the top line */
5614 /* Hack -- go to the bottom line */
5616 line = ((size - 1) / rows) * rows;
5619 /* Hack -- go to a specific file */
5623 prt(_("ファイル・ネーム: ", "Goto File: "), hgt - 1, 0);
5624 strcpy(tmp, _("jhelp.hlp", "help.hlp"));
5626 if (askfor(tmp, 80))
5628 if (!show_file(TRUE, tmp, NULL, 0, mode)) skey = 'q';
5633 /* Allow backing up */
5635 line = line + (reverse ? rows : -rows);
5636 if (line < 0) line = 0;
5642 if (line < 0) line = 0;
5645 /* Advance a single line */
5648 line = line + (reverse ? -1 : 1);
5649 if (line < 0) line = 0;
5652 /* Move up / down */
5656 if (line < 0) line = 0;
5664 /* Advance one page */
5666 line = line + (reverse ? -rows : rows);
5667 if (line < 0) line = 0;
5676 /* Recurse on numbers */
5681 if (!(skey & SKEY_MASK) && isalpha(skey))
5684 if ((key > -1) && hook[key][0])
5686 /* Recurse on that file */
5687 if (!show_file(TRUE, hook[key], NULL, 0, mode))
5692 /* Hack, dump to file */
5701 if (!get_string(_("ファイル名: ", "File name: "), xtmp, 80)) continue;
5706 /* Build the filename */
5707 path_build(buff, sizeof(buff), ANGBAND_DIR_USER, xtmp);
5709 /* Hack -- Re-Open the file */
5710 fff = my_fopen(path, "r");
5712 ffp = my_fopen(buff, "w");
5717 msg_print(_("ファイルを開けません。", "Failed to open file."));
5722 sprintf(xtmp, "%s: %s", p_ptr->name, what ? what : caption);
5723 my_fputs(ffp, xtmp, 80);
5724 my_fputs(ffp, "\n", 80);
5726 while (!my_fgets(fff, buff, sizeof(buff)))
5727 my_fputs(ffp, buff, 80);
5733 /* Hack -- Re-Open the file */
5734 fff = my_fopen(path, "r");
5737 /* Return to last screen */
5738 if ((skey == ESCAPE) || (skey == '<')) break;
5740 /* Exit on the ^q */
5741 if (skey == KTRL('q')) skey = 'q';
5743 /* Exit on the q key */
5744 if (skey == 'q') break;
5747 /* Close the file */
5751 if (skey == 'q') return (FALSE);
5759 * @brief ヘルプを表示するコマンドのメインルーチン
5760 * Peruse the On-Line-Help
5764 void do_cmd_help(void)
5769 /* Peruse the main help file */
5770 (void)show_file(TRUE, _("jhelp.hlp", "help.hlp"), NULL, 0, 0);
5778 * @brief プレイヤーの名前をチェックして修正する
5779 * Process the player name.
5780 * @param sf セーブファイル名に合わせた修正を行うならばTRUE
5783 * Extract a clean "base name".
5784 * Build the savefile name if needed.
5786 void process_player_name(bool sf)
5789 char old_player_base[32] = "";
5791 if (character_generated) strcpy(old_player_base, player_base);
5793 /* Cannot be too long */
5794 #if defined(MACINTOSH) || defined(ACORN)
5795 if (strlen(p_ptr->name) > 15)
5798 quit_fmt(_("'%s'という名前は長すぎます!", "The name '%s' is too long!"), p_ptr->name);
5802 /* Cannot contain "icky" characters */
5803 for (i = 0; p_ptr->name[i]; i++)
5805 /* No control characters */
5807 if (iskanji(p_ptr->name[i])){i++;continue;}
5808 if (iscntrl( (unsigned char)p_ptr->name[i]))
5810 if (iscntrl(p_ptr->name[i]))
5814 /* Illegal characters */
5815 quit_fmt(_("'%s' という名前は不正なコントロールコードを含んでいます。", "The name '%s' contains control chars!"), p_ptr->name);
5822 /* Extract "useful" letters */
5823 for (i = 0; p_ptr->name[i]; i++)
5826 unsigned char c = p_ptr->name[i];
5828 char c = p_ptr->name[i];
5832 /* Convert "dot" to "underscore" */
5833 if (c == '.') c = '_';
5835 /* Accept all the letters */
5836 player_base[k++] = c;
5841 /* Extract "useful" letters */
5842 for (i = 0; p_ptr->name[i]; i++)
5845 unsigned char c = p_ptr->name[i];
5847 char c = p_ptr->name[i];
5850 /* Accept some letters */
5853 if(k + 2 >= sizeof(player_base) || !p_ptr->name[i+1]) break;
5854 player_base[k++] = c;
5856 player_base[k++] = p_ptr->name[i];
5859 else if (iskana(c)) player_base[k++] = c;
5863 /* Convert path separator to underscore */
5864 if (!strncmp(PATH_SEP, p_ptr->name+i, strlen(PATH_SEP))){
5865 player_base[k++] = '_';
5866 i += strlen(PATH_SEP);
5868 /* Convert some characters to underscore */
5869 #if defined(WINDOWS)
5870 else if (my_strchr("\"*,/:;<>?\\|", c)) player_base[k++] = '_';
5872 else if (isprint(c)) player_base[k++] = c;
5878 player_base[k] = '\0';
5880 /* Require a "base" name */
5881 if (!player_base[0]) strcpy(player_base, "PLAYER");
5884 #ifdef SAVEFILE_MUTABLE
5890 if (!savefile_base[0] && savefile[0])
5897 t = my_strstr(s, PATH_SEP);
5902 strcpy(savefile_base, s);
5905 if (!savefile_base[0] || !savefile[0])
5908 /* Change the savefile name */
5913 strcpy(savefile_base, player_base);
5915 #ifdef SAVEFILE_USE_UID
5916 /* Rename the savefile, using the player_uid and player_base */
5917 (void)sprintf(temp, "%d.%s", player_uid, player_base);
5919 /* Rename the savefile, using the player_base */
5920 (void)sprintf(temp, "%s", player_base);
5923 /* Build the filename */
5924 path_build(savefile, sizeof(savefile), ANGBAND_DIR_SAVE, temp);
5927 /* Load an autopick preference file */
5928 if (character_generated)
5930 if (!streq(old_player_base, player_base)) autopick_load_pref(FALSE);
5936 * @brief プレイヤーの名前を変更するコマンドのメインルーチン
5937 * Gets a name for the character, reacting to name changes.
5941 * Assumes that "display_player(0)" has just been called
5942 * Perhaps we should NOT ask for a name (at "birth()") on
5943 * Unix machines? XXX XXX
5944 * What a horrible name for a global function. XXX XXX XXX
5951 /* Save the player name */
5952 strcpy(tmp, p_ptr->name);
5954 /* Prompt for a new name */
5955 if (get_string(_("キャラクターの名前を入力して下さい: ", "Enter a name for your character: "), tmp, 15))
5958 strcpy(p_ptr->name, tmp);
5961 if (0 == strlen(p_ptr->name))
5963 /* Use default name */
5964 strcpy(p_ptr->name, "PLAYER");
5967 strcpy(tmp,ap_ptr->title);
5974 strcat(tmp,p_ptr->name);
5976 /* Re-Draw the name (in light blue) */
5977 Term_erase(34, 1, 255);
5978 c_put_str(TERM_L_BLUE, tmp, 1, 34);
5980 /* Erase the prompt, etc */
5987 * @brief 自殺するコマンドのメインルーチン
5988 * Hack -- commit suicide
5992 void do_cmd_suicide(void)
5999 /* Verify Retirement */
6000 if (p_ptr->total_winner)
6003 if (!get_check_strict(_("引退しますか? ", "Do you want to retire? "), CHECK_NO_HISTORY)) return;
6006 /* Verify Suicide */
6010 if (!get_check(_("本当に自殺しますか?", "Do you really want to commit suicide? "))) return;
6014 if (!p_ptr->noscore)
6016 /* Special Verification for suicide */
6017 prt(_("確認のため '@' を押して下さい。", "Please verify SUICIDE by typing the '@' sign: "), 0, 0);
6022 if (i != '@') return;
6024 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_GAMEOVER);
6027 /* Initialize "last message" buffer */
6028 if (p_ptr->last_message) string_free(p_ptr->last_message);
6029 p_ptr->last_message = NULL;
6031 /* Hack -- Note *winning* message */
6032 if (p_ptr->total_winner && last_words)
6034 char buf[1024] = "";
6035 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_WINNER);
6038 while (!get_string(_("*勝利*メッセージ: ", "*Winning* message: "), buf, sizeof buf)) ;
6040 while (!get_check_strict(_("よろしいですか?", "Are you sure? "), CHECK_NO_HISTORY));
6044 p_ptr->last_message = string_make(buf);
6045 msg_print(p_ptr->last_message);
6050 p_ptr->playing = FALSE;
6052 /* Kill the player */
6053 p_ptr->is_dead = TRUE;
6056 p_ptr->leaving = TRUE;
6058 if (!p_ptr->total_winner)
6060 do_cmd_write_nikki(NIKKI_BUNSHOU, 0, _("ダンジョンの探索に絶望して自殺した。", "give up all hope to commit suicide."));
6061 do_cmd_write_nikki(NIKKI_GAMESTART, 1, _("-------- ゲームオーバー --------", "-------- Game Over --------"));
6062 do_cmd_write_nikki(NIKKI_BUNSHOU, 1, "\n\n\n\n");
6065 /* Cause of death */
6066 (void)strcpy(p_ptr->died_from, _("途中終了", "Quitting"));
6071 * @brief セーブするコマンドのメインルーチン
6073 * @param is_autosave オートセーブ中の処理ならばTRUE
6077 void do_cmd_save_game(int is_autosave)
6079 /* Autosaves do not disturb */
6082 msg_print(_("自動セーブ中", "Autosaving the game..."));
6086 /* Disturb the player */
6090 /* Clear messages */
6097 prt(_("ゲームをセーブしています...", "Saving game..."), 0, 0);
6102 /* The player is not dead */
6103 (void)strcpy(p_ptr->died_from, _("(セーブ)", "(saved)"));
6105 /* Forbid suspend */
6106 signals_ignore_tstp();
6108 /* Save the player */
6111 prt(_("ゲームをセーブしています... 終了", "Saving game... done."), 0, 0);
6114 /* Save failed (oops) */
6117 prt(_("ゲームをセーブしています... 失敗!", "Saving game... failed!"), 0, 0);
6120 /* Allow suspend again */
6121 signals_handle_tstp();
6126 /* Note that the player is not dead */
6127 (void)strcpy(p_ptr->died_from, _("(元気に生きている)", "(alive and well)"));
6129 /* HACK -- don't get sanity blast on updating view */
6135 /* Initialize monster process */
6138 /* HACK -- reset the hackish flag */
6144 * @brief セーブ後にゲーム中断フラグを立てる/
6145 * Save the game and exit
6149 void do_cmd_save_and_exit(void)
6151 p_ptr->playing = FALSE;
6154 p_ptr->leaving = TRUE;
6155 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム中断----", "---- Save and Exit Game ----"));
6161 * Hack -- Calculates the total number of points earned -JWT-
6165 long total_points(void)
6169 u32b point, point_h, point_l;
6170 int arena_win = MIN(p_ptr->arena_number, MAX_ARENA_MONS);
6172 if (!preserve_mode) mult += 10;
6173 if (!autoroller) mult += 10;
6174 if (!smart_learn) mult -= 20;
6175 if (smart_cheat) mult += 30;
6176 if (ironman_shops) mult += 50;
6177 if (ironman_small_levels) mult += 10;
6178 if (ironman_empty_levels) mult += 20;
6179 if (!powerup_home) mult += 50;
6180 if (ironman_rooms) mult += 100;
6181 if (ironman_nightmare) mult += 100;
6183 if (mult < 5) mult = 5;
6185 for (i = 0; i < max_d_idx; i++)
6186 if(max_dlv[i] > max_dl)
6187 max_dl = max_dlv[i];
6189 point_l = (p_ptr->max_max_exp + (100 * max_dl));
6190 point_h = point_l / 0x10000L;
6191 point_l = point_l % 0x10000L;
6194 point_h += point_l / 0x10000L;
6195 point_l %= 0x10000L;
6197 point_l += ((point_h % 100) << 16);
6201 point = (point_h << 16) + (point_l);
6202 if (p_ptr->arena_number >= 0)
6203 point += (arena_win * arena_win * (arena_win > 29 ? 1000 : 100));
6205 if (ironman_downward) point *= 2;
6206 if (p_ptr->pclass == CLASS_BERSERKER)
6208 if ( p_ptr->prace == RACE_SPECTRE )
6212 if ((p_ptr->pseikaku == SEIKAKU_MUNCHKIN) && point)
6215 if (p_ptr->total_winner) point = 2;
6217 if (easy_band) point = (0 - point);
6223 #define GRAVE_LINE_WIDTH 31
6226 * @brief 墓石の真ん中に文字列を書き込む /
6227 * Centers a string within a GRAVE_LINE_WIDTH character string -JWT-
6231 static void center_string(char *buf, cptr str)
6238 /* Necessary border */
6239 j = GRAVE_LINE_WIDTH / 2 - i / 2;
6242 (void)sprintf(buf, "%*s%s%*s", j, "", str, GRAVE_LINE_WIDTH - i - j, "");
6249 * Save a "bones" file for a dead character
6252 * Note that we will not use these files until Angband 2.8.0, and
6253 * then we will only use the name and level on which death occured.
6254 * Should probably attempt some form of locking...
6257 static void make_bones(void)
6264 /* Ignore wizards and borgs */
6265 if (!(p_ptr->noscore & 0x00FF))
6267 /* Ignore people who die in town */
6272 /* XXX XXX XXX "Bones" name */
6273 sprintf(tmp, "bone.%03d", dun_level);
6275 /* Build the filename */
6276 path_build(str, sizeof(str), ANGBAND_DIR_BONE, tmp);
6278 /* Attempt to open the bones file */
6279 fp = my_fopen(str, "r");
6281 /* Close it right away */
6282 if (fp) my_fclose(fp);
6284 /* Do not over-write a previous ghost */
6287 /* File type is "TEXT" */
6288 FILE_TYPE(FILE_TYPE_TEXT);
6290 /* Grab permissions */
6293 /* Try to write a new "Bones File" */
6294 fp = my_fopen(str, "w");
6296 /* Drop permissions */
6299 /* Not allowed to write it? Weird. */
6303 fprintf(fp, "%s\n", p_ptr->name);
6304 fprintf(fp, "%d\n", p_ptr->mhp);
6305 fprintf(fp, "%d\n", p_ptr->prace);
6306 fprintf(fp, "%d\n", p_ptr->pclass);
6308 /* Close and save the Bones file */
6317 * Redefinable "print_tombstone" action
6319 bool (*tombstone_aux)(void) = NULL;
6323 * @brief 墓石のアスキーアート表示 /
6324 * Display a "tomb-stone"
6327 static void print_tomb(void)
6331 /* Do we use a special tombstone ? */
6334 /* Use tombstone hook */
6335 done = (*tombstone_aux)();
6338 /* Print the text-tombstone */
6347 time_t ct = time((time_t)0);
6355 /* Build the filename */
6356 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, _("dead_j.txt", "dead.txt"));
6358 /* Open the News file */
6359 fp = my_fopen(buf, "r");
6366 /* Dump the file to the screen */
6367 while (0 == my_fgets(fp, buf, sizeof(buf)))
6369 /* Display and advance */
6370 put_str(buf, i++, 0);
6378 if (p_ptr->total_winner || (p_ptr->lev > PY_MAX_LEVEL))
6391 p = player_title[p_ptr->pclass][(p_ptr->lev - 1) / 5];
6394 center_string(buf, p_ptr->name);
6395 put_str(buf, 6, 11);
6398 center_string(buf, "the");
6399 put_str(buf, 7, 11);
6402 center_string(buf, p);
6403 put_str(buf, 8, 11);
6405 center_string(buf, cp_ptr->title);
6406 put_str(buf, 10, 11);
6408 (void)sprintf(tmp, _("レベル: %d", "Level: %d"), (int)p_ptr->lev);
6409 center_string(buf, tmp);
6410 put_str(buf, 11, 11);
6412 (void)sprintf(tmp, _("経験値: %ld", "Exp: %ld"), (long)p_ptr->exp);
6413 center_string(buf, tmp);
6414 put_str(buf, 12, 11);
6416 (void)sprintf(tmp, _("所持金: %ld", "AU: %ld"), (long)p_ptr->au);
6417 center_string(buf, tmp);
6418 put_str(buf, 13, 11);
6421 /* 墓に刻む言葉をオリジナルより細かく表示 */
6422 if (streq(p_ptr->died_from, "途中終了"))
6424 strcpy(tmp, "<自殺>");
6426 else if (streq(p_ptr->died_from, "ripe"))
6428 strcpy(tmp, "引退後に天寿を全う");
6430 else if (streq(p_ptr->died_from, "Seppuku"))
6432 strcpy(tmp, "勝利の後、切腹");
6436 roff_to_buf(p_ptr->died_from, GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6437 t = tmp + strlen(tmp) + 1;
6440 strcpy(dummy, t); /* 2nd line */
6441 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6443 for (t = dummy + strlen(dummy) - 2; iskanji(*(t - 1)); t--) /* Loop */;
6446 else if (my_strstr(tmp, "『") && suffix(dummy, "』"))
6449 char *name_head = my_strstr(tmp, "『");
6450 sprintf(dummy2, "%s%s", name_head, dummy);
6451 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6453 strcpy(dummy, dummy2);
6457 else if (my_strstr(tmp, "「") && suffix(dummy, "」"))
6460 char *name_head = my_strstr(tmp, "「");
6461 sprintf(dummy2, "%s%s", name_head, dummy);
6462 if (strlen(dummy2) <= GRAVE_LINE_WIDTH)
6464 strcpy(dummy, dummy2);
6468 center_string(buf, dummy);
6469 put_str(buf, 15, 11);
6473 center_string(buf, tmp);
6474 put_str(buf, 14, 11);
6476 if (!streq(p_ptr->died_from, "ripe") && !streq(p_ptr->died_from, "Seppuku"))
6480 cptr field_name = p_ptr->town_num ? "街" : "荒野";
6481 if (streq(p_ptr->died_from, "途中終了"))
6483 sprintf(tmp, "%sで死んだ", field_name);
6487 sprintf(tmp, "に%sで殺された", field_name);
6492 if (streq(p_ptr->died_from, "途中終了"))
6494 sprintf(tmp, "地下 %d 階で死んだ", (int)dun_level);
6498 sprintf(tmp, "に地下 %d 階で殺された", (int)dun_level);
6501 center_string(buf, tmp);
6502 put_str(buf, 15 + extra_line, 11);
6505 (void)sprintf(tmp, "Killed on Level %d", dun_level);
6506 center_string(buf, tmp);
6507 put_str(buf, 14, 11);
6509 roff_to_buf(format("by %s.", p_ptr->died_from), GRAVE_LINE_WIDTH + 1, tmp, sizeof tmp);
6510 center_string(buf, tmp);
6511 put_str(buf, 15, 11);
6512 t = tmp + strlen(tmp) + 1;
6515 strcpy(dummy, t); /* 2nd line */
6516 if (*(t + strlen(t) + 1)) /* Does 3rd line exist? */
6518 int dummy_len = strlen(dummy);
6519 strcpy(dummy + MIN(dummy_len, GRAVE_LINE_WIDTH - 3), "...");
6521 center_string(buf, dummy);
6522 put_str(buf, 16, 11);
6526 (void)sprintf(tmp, "%-.24s", ctime(&ct));
6527 center_string(buf, tmp);
6528 put_str(buf, 17, 11);
6529 msg_format(_("さようなら、%s!", "Goodbye, %s!"), p_ptr->name);
6535 * @brief 死亡、引退時の簡易ステータス表示 /
6536 * Display some character info
6539 static void show_info(void)
6545 /* Hack -- Know everything in the inven/equip */
6546 for (i = 0; i < INVEN_TOTAL; i++)
6548 o_ptr = &inventory[i];
6550 /* Skip non-objects */
6551 if (!o_ptr->k_idx) continue;
6553 /* Aware and Known */
6554 object_aware(o_ptr);
6555 object_known(o_ptr);
6558 for (i = 1; i < max_towns; i++)
6560 st_ptr = &town[i].store[STORE_HOME];
6562 /* Hack -- Know everything in the home */
6563 for (j = 0; j < st_ptr->stock_num; j++)
6565 o_ptr = &st_ptr->stock[j];
6567 /* Skip non-objects */
6568 if (!o_ptr->k_idx) continue;
6570 /* Aware and Known */
6571 object_aware(o_ptr);
6572 object_known(o_ptr);
6576 /* Hack -- Recalculate bonuses */
6577 p_ptr->update |= (PU_BONUS);
6582 /* Flush all input keys */
6585 /* Flush messages */
6589 /* Describe options */
6590 prt(_("キャラクターの記録をファイルに書き出すことができます。", "You may now dump a character record to one or more files."), 21, 0);
6591 prt(_("リターンキーでキャラクターを見ます。ESCで中断します。", "Then, hit RETURN to see the character, or ESC to abort."), 22, 0);
6593 /* Dump character records as requested */
6599 put_str(_("ファイルネーム: ", "Filename: "), 23, 0);
6602 strcpy(out_val, "");
6604 /* Ask for filename (or abort) */
6605 if (!askfor(out_val, 60)) return;
6607 /* Return means "show on screen" */
6608 if (!out_val[0]) break;
6613 /* Dump a character file */
6614 (void)file_character(out_val);
6622 /* Display player */
6625 /* Prompt for inventory */
6626 prt(_("何かキーを押すとさらに情報が続きます (ESCで中断): ", "Hit any key to see more information (ESC to abort): "), 23, 0);
6628 /* Allow abort at this point */
6629 if (inkey() == ESCAPE) return;
6632 /* Show equipment and inventory */
6634 /* Equipment -- if any */
6638 item_tester_full = TRUE;
6639 (void)show_equip(0);
6640 prt(_("装備していたアイテム: -続く-", "You are using: -more-"), 0, 0);
6642 if (inkey() == ESCAPE) return;
6645 /* Inventory -- if any */
6649 item_tester_full = TRUE;
6650 (void)show_inven(0);
6651 prt(_("持っていたアイテム: -続く-", "You are carrying: -more-"), 0, 0);
6653 if (inkey() == ESCAPE) return;
6656 /* Homes in the different towns */
6657 for (l = 1; l < max_towns; l++)
6659 st_ptr = &town[l].store[STORE_HOME];
6661 /* Home -- if anything there */
6662 if (st_ptr->stock_num)
6664 /* Display contents of the home */
6665 for (k = 0, i = 0; i < st_ptr->stock_num; k++)
6671 for (j = 0; (j < 12) && (i < st_ptr->stock_num); j++, i++)
6673 char o_name[MAX_NLEN];
6677 o_ptr = &st_ptr->stock[i];
6679 /* Print header, clear line */
6680 sprintf(tmp_val, "%c) ", I2A(j));
6681 prt(tmp_val, j+2, 4);
6683 /* Display object description */
6684 object_desc(o_name, o_ptr, 0);
6685 c_put_str(tval_to_attr[o_ptr->tval], o_name, j+2, 7);
6689 prt(format(_("我が家に置いてあったアイテム ( %d ページ): -続く-", "Your home contains (page %d): -more-"), k+1), 0, 0);
6692 if (inkey() == ESCAPE) return;
6700 * Display some character info
6703 static bool check_score(void)
6709 if (highscore_fd < 0)
6711 msg_print(_("スコア・ファイルが使用できません。", "Score file unavailable."));
6716 #ifndef SCORE_WIZARDS
6717 /* Wizard-mode pre-empts scoring */
6718 if (p_ptr->noscore & 0x000F)
6720 msg_print(_("ウィザード・モードではスコアが記録されません。", "Score not registered for wizards."));
6727 /* Borg-mode pre-empts scoring */
6728 if (p_ptr->noscore & 0x00F0)
6730 msg_print(_("ボーグ・モードではスコアが記録されません。", "Score not registered for borgs."));
6736 #ifndef SCORE_CHEATERS
6737 /* Cheaters are not scored */
6738 if (p_ptr->noscore & 0xFF00)
6740 msg_print(_("詐欺をやった人はスコアが記録されません。", "Score not registered for cheaters."));
6747 if (!p_ptr->total_winner && streq(p_ptr->died_from, _("強制終了", "Interrupting")))
6749 msg_print(_("強制終了のためスコアが記録されません。", "Score not registered due to interruption."));
6755 if (!p_ptr->total_winner && streq(p_ptr->died_from, _("途中終了", "Quitting")))
6757 msg_print(_("途中終了のためスコアが記録されません。", "Score not registered due to quitting."));
6766 * Close up the current game (player may or may not be dead)
6770 * This function is called only from "main.c" and "signals.c".
6773 void close_game(void)
6776 bool do_send = TRUE;
6778 /* cptr p = "[i:キャラクタの情報, f:ファイル書き出し, t:スコア, x:*鑑定*, ESC:ゲーム終了]"; */
6783 /* Flush the messages */
6786 /* Flush the input */
6790 /* No suspending now */
6791 signals_ignore_tstp();
6794 /* Hack -- Character is now "icky" */
6795 character_icky = TRUE;
6798 /* Build the filename */
6799 path_build(buf, sizeof(buf), ANGBAND_DIR_APEX, "scores.raw");
6801 /* Grab permissions */
6804 /* Open the high score file, for reading/writing */
6805 highscore_fd = fd_open(buf, O_RDWR);
6807 /* Drop permissions */
6813 /* Handle retirement */
6814 if (p_ptr->total_winner) kingly();
6817 if (!cheat_save || get_check(_("死んだデータをセーブしますか? ", "Save death? ")))
6819 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6821 else do_send = FALSE;
6828 /* Show more info */
6836 if ((!send_world_score(do_send)))
6838 if (get_check_strict(_("後でスコアを登録するために待機しますか?", "Stand by for later score registration? "),
6839 (CHECK_NO_ESCAPE | CHECK_NO_HISTORY)))
6841 p_ptr->wait_report_score = TRUE;
6842 p_ptr->is_dead = FALSE;
6843 if (!save_player()) msg_print(_("セーブ失敗!", "death save failed!"));
6846 if (!p_ptr->wait_report_score)
6849 else if (highscore_fd >= 0)
6851 display_scores_aux(0, 10, -1, NULL);
6854 /* Dump bones file */
6863 do_cmd_save_game(FALSE);
6865 /* Prompt for scores XXX XXX XXX */
6866 prt(_("リターンキーか ESC キーを押して下さい。", "Press Return (or Escape)."), 0, 40);
6867 play_music(TERM_XTRA_MUSIC_BASIC, MUSIC_BASIC_EXIT);
6869 /* Predict score (or ESCAPE) */
6870 if (inkey() != ESCAPE) predict_score();
6874 /* Shut the high score file */
6875 (void)fd_close(highscore_fd);
6877 /* Forget the high score fd */
6880 /* Kill all temporal files */
6881 clear_saved_floor_files();
6883 /* Allow suspending now */
6884 signals_handle_tstp();
6889 * @brief 異常発生時のゲーム緊急終了処理 /
6890 * Handle abrupt death of the visual system
6894 * This routine is called only in very rare situations, and only
6895 * by certain visual systems, when they experience fatal errors.
6896 * XXX XXX Hack -- clear the death flag when creating a HANGUP
6897 * save file so that player can see tombstone when restart.
6900 void exit_game_panic(void)
6902 /* If nothing important has happened, just quit */
6903 if (!character_generated || character_saved) quit(_("緊急事態", "panic"));
6905 /* Mega-Hack -- see "msg_print()" */
6908 /* Clear the top line */
6911 /* Hack -- turn off some things */
6914 /* Mega-Hack -- Delay death */
6915 if (p_ptr->chp < 0) p_ptr->is_dead = FALSE;
6917 /* Hardcode panic save */
6918 p_ptr->panic_save = 1;
6920 /* Forbid suspend */
6921 signals_ignore_tstp();
6923 /* Indicate panic save */
6924 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
6926 /* Panic save, or get worried */
6927 if (!save_player()) quit(_("緊急セーブ失敗!", "panic save failed!"));
6929 /* Successful panic save */
6930 quit(_("緊急セーブ成功!", "panic save succeeded!"));
6935 * @brief ファイルからランダムに行を一つ取得する /
6936 * Get a random line from a file
6937 * @param file_name ファイル名
6938 * @param entry 特定条件時のN:タグヘッダID
6939 * @param output 出力先の文字列参照ポインタ
6943 * Based on the monster speech patch by Matt Graham,
6946 errr get_rnd_line(cptr file_name, int entry, char *output)
6954 /* Build the filename */
6955 path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, file_name);
6958 fp = my_fopen(buf, "r");
6963 /* Find the entry of the monster */
6966 /* Get a line from the file */
6967 if (my_fgets(fp, buf, sizeof(buf)) == 0)
6969 /* Count the lines */
6972 /* Look for lines starting with 'N:' */
6973 if ((buf[0] == 'N') && (buf[1] == ':'))
6975 /* Allow default lines */
6981 else if (buf[2] == 'M')
6983 if (r_info[entry].flags1 & RF1_MALE) break;
6985 else if (buf[2] == 'F')
6987 if (r_info[entry].flags1 & RF1_FEMALE) break;
6989 /* Get the monster number */
6990 else if (sscanf(&(buf[2]), "%d", &test) != EOF)
6992 /* Is it the right number? */
6993 if (test == entry) break;
6997 /* Error while converting the number */
6998 msg_format("Error in line %d of %s!", line_num, file_name);
7006 /* Reached end of file */
7012 /* Get the random line */
7013 for (counter = 0; ; counter++)
7017 test = my_fgets(fp, buf, sizeof(buf));
7019 /* Count the lines */
7020 /* line_num++; No more needed */
7024 /* Ignore lines starting with 'N:' */
7025 if ((buf[0] == 'N') && (buf[1] == ':')) continue;
7027 if (buf[0] != '#') break;
7036 if (one_in_(counter + 1)) strcpy(output, buf);
7039 /* Close the file */
7043 return counter ? 0 : -1;
7049 * @brief ファイルからランダムに行を一つ取得する(日本語文字列のみ) /
7050 * @param file_name ファイル名
7051 * @param entry 特定条件時のN:タグヘッダID
7052 * @param output 出力先の文字列参照ポインタ
7057 errr get_rnd_line_jonly(cptr file_name, int entry, char *output, int count)
7062 for (i = 0; i < count; i++)
7064 result = get_rnd_line(file_name, entry, output);
7067 for (j = 0; output[j]; j++) kanji |= iskanji(output[j]);
7075 * @brief 自動拾いファイルを読み込む /
7079 errr process_autopick_file(cptr name)
7085 /* Build the filename */
7086 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7088 err = process_pref_file_aux(buf, PREF_TYPE_AUTOPICK);
7096 * @brief プレイヤーの生い立ちファイルを読み込む /
7097 * Process file for player's history editor.
7102 errr process_histpref_file(cptr name)
7106 bool old_character_xtra = character_xtra;
7108 /* Build the filename */
7109 path_build(buf, sizeof(buf), ANGBAND_DIR_USER, name);
7111 /* Hack -- prevent modification birth options in this file */
7112 character_xtra = TRUE;
7114 err = process_pref_file_aux(buf, PREF_TYPE_HISTPREF);
7116 character_xtra = old_character_xtra;
7123 * @brief ファイル位置をシーク /
7124 * @param fd ファイルディスクリプタ
7125 * @param where ファイルバイト位置
7126 * @param flag FALSEならば現ファイルを超えた位置へシーク時エラー、TRUEなら足りない間を0で埋め尽くす
7130 static errr counts_seek(int fd, u32b where, bool flag)
7133 char temp1[128], temp2[128];
7134 u32b zero_header[3] = {0L, 0L, 0L};
7137 #ifdef SAVEFILE_USE_UID
7138 (void)sprintf(temp1, "%d.%s.%d%d%d", player_uid, savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7140 (void)sprintf(temp1, "%s.%d%d%d", savefile_base, p_ptr->pclass, p_ptr->pseikaku, p_ptr->age);
7142 for (i = 0; temp1[i]; i++)
7143 temp1[i] ^= (i+1) * 63;
7148 if (fd_seek(fd, seekpoint + 3 * sizeof(u32b)))
7150 if (fd_read(fd, (char*)(temp2), sizeof(temp2)))
7155 fd_seek(fd, seekpoint);
7156 fd_write(fd, (char*)zero_header, 3*sizeof(u32b));
7157 fd_write(fd, (char*)(temp1), sizeof(temp1));
7161 if (strcmp(temp1, temp2) == 0)
7164 seekpoint += 128 + 3 * sizeof(u32b);
7167 return fd_seek(fd, seekpoint + where * sizeof(u32b));
7171 * @brief ファイル位置を読み込む
7172 * @param where ファイルバイト位置
7176 u32b counts_read(int where)
7182 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
7183 fd = fd_open(buf, O_RDONLY);
7185 if (counts_seek(fd, where, FALSE) ||
7186 fd_read(fd, (char*)(&count), sizeof(u32b)))
7195 * @brief ファイル位置に書き込む /
7196 * @param where ファイルバイト位置
7197 * @param count 書き込む値
7201 errr counts_write(int where, u32b count)
7207 path_build(buf, sizeof(buf), ANGBAND_DIR_DATA, _("z_info_j.raw", "z_info.raw"));
7209 /* Grab permissions */
7212 fd = fd_open(buf, O_RDWR);
7214 /* Drop permissions */
7219 /* File type is "DATA" */
7220 FILE_TYPE(FILE_TYPE_DATA);
7222 /* Grab permissions */
7225 /* Create a new high score file */
7226 fd = fd_make(buf, 0644);
7228 /* Drop permissions */
7232 /* Grab permissions */
7235 err = fd_lock(fd, F_WRLCK);
7237 /* Drop permissions */
7242 counts_seek(fd, where, TRUE);
7243 fd_write(fd, (char*)(&count), sizeof(u32b));
7245 /* Grab permissions */
7248 err = fd_lock(fd, F_UNLCK);
7250 /* Drop permissions */
7261 #ifdef HANDLE_SIGNALS
7268 * @brief OSからのシグナルを受けてサスペンド状態に入る /
7269 * Handle signals -- suspend
7270 * @param sig 受け取ったシグナル
7272 * Actually suspend the game, and then resume cleanly
7274 static void handle_signal_suspend(int sig)
7276 /* Disable handler */
7277 (void)signal(sig, SIG_IGN);
7284 /* Suspend the "Term" */
7285 Term_xtra(TERM_XTRA_ALIVE, 0);
7287 /* Suspend ourself */
7288 (void)kill(0, SIGSTOP);
7290 /* Resume the "Term" */
7291 Term_xtra(TERM_XTRA_ALIVE, 1);
7293 /* Redraw the term */
7296 /* Flush the term */
7301 /* Restore handler */
7302 (void)signal(sig, handle_signal_suspend);
7307 * @brief OSからのシグナルを受けて中断、終了する /
7308 * Handle signals -- simple (interrupt and quit)
7309 * @param sig 受け取ったシグナル
7312 * This function was causing a *huge* number of problems, so it has
7313 * been simplified greatly. We keep a global variable which counts
7314 * the number of times the user attempts to kill the process, and
7315 * we commit suicide if the user does this a certain number of times.
7316 * We attempt to give "feedback" to the user as he approaches the
7317 * suicide thresh-hold, but without penalizing accidental keypresses.
7318 * To prevent messy accidents, we should reset this global variable
7319 * whenever the user enters a keypress, or something like that.
7322 static void handle_signal_simple(int sig)
7324 /* Disable handler */
7325 (void)signal(sig, SIG_IGN);
7328 /* Nothing to save, just quit */
7329 if (!character_generated || character_saved) quit(NULL);
7332 /* Count the signals */
7336 /* Terminate dead characters */
7339 /* Mark the savefile */
7340 (void)strcpy(p_ptr->died_from, _("強制終了", "Abortion"));
7350 quit(_("強制終了", "interrupt"));
7353 /* Allow suicide (after 5) */
7354 else if (signal_count >= 5)
7356 /* Cause of "death" */
7357 (void)strcpy(p_ptr->died_from, _("強制終了中", "Interrupting"));
7364 p_ptr->playing = FALSE;
7367 p_ptr->is_dead = TRUE;
7370 p_ptr->leaving = TRUE;
7376 quit(_("強制終了", "interrupt"));
7379 /* Give warning (after 4) */
7380 else if (signal_count >= 4)
7383 Term_xtra(TERM_XTRA_NOISE, 0);
7385 /* Clear the top line */
7386 Term_erase(0, 0, 255);
7388 /* Display the cause */
7389 Term_putstr(0, 0, -1, TERM_WHITE, _("熟慮の上の自殺!", "Contemplating suicide!"));
7395 /* Give warning (after 2) */
7396 else if (signal_count >= 2)
7399 Term_xtra(TERM_XTRA_NOISE, 0);
7402 /* Restore handler */
7403 (void)signal(sig, handle_signal_simple);
7408 * @brief OSからのシグナルを受けて強制終了する /
7409 * Handle signal -- abort, kill, etc
7410 * @param sig 受け取ったシグナル
7414 * This function was causing a *huge* number of problems, so it has
7415 * been simplified greatly. We keep a global variable which counts
7416 * the number of times the user attempts to kill the process, and
7417 * we commit suicide if the user does this a certain number of times.
7418 * We attempt to give "feedback" to the user as he approaches the
7419 * suicide thresh-hold, but without penalizing accidental keypresses.
7420 * To prevent messy accidents, we should reset this global variable
7421 * whenever the user enters a keypress, or something like that.
7424 static void handle_signal_abort(int sig)
7428 Term_get_size(&wid, &hgt);
7430 /* Disable handler */
7431 (void)signal(sig, SIG_IGN);
7434 /* Nothing to save, just quit */
7435 if (!character_generated || character_saved) quit(NULL);
7442 /* Clear the bottom line */
7443 Term_erase(0, hgt - 1, 255);
7445 /* Give a warning */
7446 Term_putstr(0, hgt - 1, -1, TERM_RED,
7447 _("恐ろしいソフトのバグが飛びかかってきた!", "A gruesome software bug LEAPS out at you!"));
7451 Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ...", "Panic save..."));
7453 do_cmd_write_nikki(NIKKI_GAMESTART, 0, _("----ゲーム異常終了----", "---- Panic Save and Abort Game ----"));
7459 p_ptr->panic_save = 1;
7462 (void)strcpy(p_ptr->died_from, _("(緊急セーブ)", "(panic save)"));
7464 /* Forbid suspend */
7465 signals_ignore_tstp();
7467 /* Attempt to save */
7470 Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ成功!", "Panic save succeeded!"));
7476 Term_putstr(45, hgt - 1, -1, TERM_RED, _("緊急セーブ失敗!", "Panic save failed!"));
7483 quit(_("ソフトのバグ", "software bug"));
7487 * @brief OSからのSIGTSTPシグナルを無視する関数 /
7488 * Ignore SIGTSTP signals (keyboard suspend)
7492 void signals_ignore_tstp(void)
7496 (void)signal(SIGTSTP, SIG_IGN);
7502 * @brief OSからのSIGTSTPシグナルハンドラ /
7503 * Handle SIGTSTP signals (keyboard suspend)
7507 void signals_handle_tstp(void)
7511 (void)signal(SIGTSTP, handle_signal_suspend);
7518 * @brief OSからのシグナルハンドルを初期化する /
7519 * Prepare to handle the relevant signals
7523 void signals_init(void)
7527 (void)signal(SIGHUP, SIG_IGN);
7532 (void)signal(SIGTSTP, handle_signal_suspend);
7537 (void)signal(SIGINT, handle_signal_simple);
7541 (void)signal(SIGQUIT, handle_signal_simple);
7546 (void)signal(SIGFPE, handle_signal_abort);
7550 (void)signal(SIGILL, handle_signal_abort);
7554 (void)signal(SIGTRAP, handle_signal_abort);
7558 (void)signal(SIGIOT, handle_signal_abort);
7562 (void)signal(SIGKILL, handle_signal_abort);
7566 (void)signal(SIGBUS, handle_signal_abort);
7570 (void)signal(SIGSEGV, handle_signal_abort);
7574 (void)signal(SIGTERM, handle_signal_abort);
7578 (void)signal(SIGPIPE, handle_signal_abort);
7582 (void)signal(SIGEMT, handle_signal_abort);
7586 (void)signal(SIGDANGER, handle_signal_abort);
7590 (void)signal(SIGSYS, handle_signal_abort);
7594 (void)signal(SIGXCPU, handle_signal_abort);
7598 (void)signal(SIGPWR, handle_signal_abort);
7604 #else /* HANDLE_SIGNALS */
7611 void signals_ignore_tstp(void)
7619 void signals_handle_tstp(void)
7627 void signals_init(void)
7630 #endif /* HANDLE_SIGNALS */