OSDN Git Service

6bf2248512db32a4bd4a1573920a11c85e793ca6
[hengband/hengband.git] / src / view / display-main-window.c
1 /*!
2  * @brief プレイヤーのステータス処理 / status
3  * @date 2018/09/25
4  * @author
5  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
6  * This software may be copied and distributed for educational, research, and\n
7  * not for profit purposes provided that this copyright and statement are\n
8  * included in all such copies.\n
9  * 2014 Deskull rearranged comment for Doxygen.
10  */
11
12 #include "view/display-main-window.h"
13 #include "autopick/autopick-finder.h"
14 #include "autopick/autopick-methods-table.h"
15 #include "autopick/autopick-util.h"
16 #include "cmd-building/cmd-building.h"
17 #include "core/player-processor.h"
18 #include "core/stuff-handler.h"
19 #include "dungeon/dungeon.h"
20 #include "dungeon/quest.h"
21 #include "effect/effect-characteristics.h"
22 #include "effect/spells-effect-util.h"
23 #include "floor/floor-town.h"
24 #include "floor/floor.h"
25 #include "game-option/map-screen-options.h"
26 #include "game-option/option-flags.h"
27 #include "game-option/special-options.h"
28 #include "game-option/text-display-options.h"
29 #include "grid/feature.h"
30 #include "grid/grid.h"
31 #include "inventory/player-inventory.h"
32 #include "io/files-util.h"
33 #include "io/input-key-acceptor.h"
34 #include "io/input-key-processor.h"
35 #include "io/input-key-requester.h"
36 #include "io/targeting.h"
37 #include "main/sound-of-music.h"
38 #include "market/arena-info-table.h"
39 #include "monster-race/race-flags1.h"
40 #include "monster-race/race-flags2.h"
41 #include "monster/monster-flag-types.h"
42 #include "monster/monster-info.h"
43 #include "monster/monster-status.h"
44 #include "monster/monster-update.h"
45 #include "monster/smart-learn-types.h"
46 #include "object/object-flavor.h"
47 #include "object/object-kind.h"
48 #include "object/object-mark-types.h"
49 #include "object/object-info.h"
50 #include "player/avatar.h"
51 #include "player/mimic-info-table.h"
52 #include "player/player-class.h"
53 #include "player/player-effects.h"
54 #include "player/player-race-types.h"
55 #include "player/player-status.h"
56 #include "realm/realm-hex-numbers.h"
57 #include "realm/realm-song-numbers.h"
58 #include "spell-realm/spells-hex.h"
59 #include "spell/spells3.h"
60 #include "system/system-variables.h"
61 #include "term/gameterm.h"
62 #include "term/screen-processor.h"
63 #include "term/term-color-types.h"
64 #include "util/bit-flags-calculator.h"
65 #include "view/display-lore.h"
66 #include "view/display-messages.h"
67 #include "view/display-player.h"
68 #include "view/object-describer.h"
69 #include "world/world.h"
70
71  /*
72   * Not using graphical tiles for this feature?
73   */
74 #define IS_ASCII_GRAPHICS(A) (!((A) & 0x80))
75
76 static int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
77 static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
78 static int match_autopick;
79 static object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
80
81 /*
82  * Dungeon size info
83  */
84 POSITION panel_row_min, panel_row_max;
85 POSITION panel_col_min, panel_col_max;
86 POSITION panel_col_prt, panel_row_prt;
87
88 /*
89  * Some screen locations for various display routines
90  * Currently, row 8 and 15 are the only "blank" rows.
91  * That leaves a "border" around the "stat" values.
92  */
93
94 #define ROW_RACE                1
95 #define COL_RACE                0       /* <race name> */
96
97  /*#define ROW_CLASS               2 */
98  /*#define COL_CLASS               0 */      /* <class name> */
99
100 #define ROW_TITLE               2
101 #define COL_TITLE               0       /* <title> or <mode> */
102
103 /*#define ROW_SEIKAKU           4 */
104 /*#define COL_SEIKAKU           0*/     /* <seikaku> */
105
106 #define ROW_DAY                 21
107 #define COL_DAY                 0       /* day */
108
109 #define ROW_DUNGEON             22
110 #define COL_DUNGEON             0       /* dungeon */
111
112 #define ROW_LEVEL               3
113 #define COL_LEVEL               0       /* "LEVEL xxxxxx" */
114
115 #define ROW_EXP                 4
116 #define COL_EXP                 0       /* "EXP xxxxxxxx" */
117
118 #define ROW_GOLD                5
119 #define COL_GOLD                0       /* "AU xxxxxxxxx" */
120
121 #define ROW_EQUIPPY             6
122 #define COL_EQUIPPY             0       /* equippy chars */
123
124 #define ROW_STAT                7
125 #define COL_STAT                0       /* "xxx   xxxxxx" */
126
127 #define ROW_AC                  13
128 #define COL_AC                  0       /* "Cur AC xxxxx" */
129
130 #define ROW_HPMP                14
131 #define COL_HPMP                0
132
133 #define ROW_CURHP               14
134 #define COL_CURHP               0       /* "Cur HP xxxxx" */
135
136 #define ROW_CURSP               15
137 #define COL_CURSP               0       /* "Cur SP xxxxx" */
138
139 #define ROW_RIDING_INFO         16
140 #define COL_RIDING_INFO         0       /* "xxxxxxxxxxxx" */
141
142 #define ROW_INFO                17
143 #define COL_INFO                0       /* "xxxxxxxxxxxx" */
144
145 #define ROW_CUT                 18
146 #define COL_CUT                 0       /* <cut> */
147
148 #define ROW_STUN                19
149 #define COL_STUN                0       /* <stun> */
150
151 #define ROW_HUNGRY              20
152 #define COL_HUNGRY              0       /* "Weak" / "Hungry" / "Full" / "Gorged" */
153
154 #define ROW_STATE               20
155 #define COL_STATE                7      /* <state> */
156
157 #define ROW_SPEED               (-1)
158 #define COL_SPEED               (-24)      /* "Slow (-NN)" or "Fast (+NN)" */
159
160 #define ROW_STUDY               (-1)
161 #define COL_STUDY               (-13)      /* "Study" */
162
163 #define ROW_DEPTH               (-1)
164 #define COL_DEPTH               (-8)      /* "Lev NNN" / "NNNN ft" */
165
166 #define ROW_STATBAR             (-1)
167 #define COL_STATBAR              0
168 #define MAX_COL_STATBAR         (-26)
169
170 void print_equippy(player_type *creature_ptr);
171 void print_map(player_type *player_ptr);
172 void display_map(player_type *player_ptr, int *cy, int *cx);
173 void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp);
174
175 /*!
176  * @brief 画面左の能力値表示を行うために指定位置から13キャラ分を空白消去後指定のメッセージを明るい青で描画する /
177  * Print character info at given row, column in a 13 char field
178  * @param info 表示文字列
179  * @param row 描画列
180  * @param col 描画行
181  * @return なし
182  */
183 static void print_field(concptr info, TERM_LEN row, TERM_LEN col)
184 {
185         /* Dump 13 spaces to clear */
186         c_put_str(TERM_WHITE, "             ", row, col);
187
188         /* Dump the info itself */
189         c_put_str(TERM_L_BLUE, info, row, col);
190 }
191
192
193 /*!
194  * @brief ゲーム時刻を表示する /
195  * Print time
196  * @return なし
197  */
198 void print_time(player_type *player_ptr)
199 {
200         int day, hour, min;
201
202         /* Dump 13 spaces to clear */
203         c_put_str(TERM_WHITE, "             ", ROW_DAY, COL_DAY);
204
205         extract_day_hour_min(player_ptr, &day, &hour, &min);
206
207         /* Dump the info itself */
208         if (day < 1000) c_put_str(TERM_WHITE, format(_("%2d日目", "Day%3d"), day), ROW_DAY, COL_DAY);
209         else c_put_str(TERM_WHITE, _("***日目", "Day***"), ROW_DAY, COL_DAY);
210
211         c_put_str(TERM_WHITE, format("%2d:%02d", hour, min), ROW_DAY, COL_DAY + 7);
212 }
213
214
215 /*!
216  * @brief 現在のマップ名を返す /
217  * @param creature_ptr プレーヤーへの参照ポインタ
218  * @return マップ名の文字列参照ポインタ
219  */
220 concptr map_name(player_type *creature_ptr)
221 {
222         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
223         if (floor_ptr->inside_quest && is_fixed_quest_idx(floor_ptr->inside_quest)
224                 && (quest[floor_ptr->inside_quest].flags & QUEST_FLAG_PRESET))
225                 return _("クエスト", "Quest");
226         else if (creature_ptr->wild_mode)
227                 return _("地上", "Surface");
228         else if (creature_ptr->current_floor_ptr->inside_arena)
229                 return _("アリーナ", "Arena");
230         else if (creature_ptr->phase_out)
231                 return _("闘技場", "Monster Arena");
232         else if (!floor_ptr->dun_level && creature_ptr->town_num)
233                 return town_info[creature_ptr->town_num].name;
234         else
235                 return d_name + d_info[creature_ptr->dungeon_idx].name;
236 }
237
238
239 /*!
240  * @brief 現在のマップ名を描画する / Print dungeon
241  * @param creature_ptr プレーヤーへの参照ポインタ
242  * @return なし
243  */
244 static void print_dungeon(player_type *creature_ptr)
245 {
246         /* Dump 13 spaces to clear */
247         c_put_str(TERM_WHITE, "             ", ROW_DUNGEON, COL_DUNGEON);
248
249         concptr dungeon_name = map_name(creature_ptr);
250
251         TERM_LEN col = COL_DUNGEON + 6 - strlen(dungeon_name) / 2;
252         if (col < 0) col = 0;
253
254         /* Dump the info itself */
255         c_put_str(TERM_L_UMBER, format("%s", dungeon_name),
256                 ROW_DUNGEON, col);
257 }
258
259
260 /*!
261  * @brief プレイヤー能力値を描画する / Print character stat in given row, column
262  * @param stat 描画するステータスのID
263  * @return なし
264  */
265 static void print_stat(player_type *creature_ptr, int stat)
266 {
267         GAME_TEXT tmp[32];
268
269         /* Display "injured" stat */
270         if (creature_ptr->stat_cur[stat] < creature_ptr->stat_max[stat])
271         {
272                 put_str(stat_names_reduced[stat], ROW_STAT + stat, 0);
273                 cnv_stat(creature_ptr->stat_use[stat], tmp);
274                 c_put_str(TERM_YELLOW, tmp, ROW_STAT + stat, COL_STAT + 6);
275         }
276
277         /* Display "healthy" stat */
278         else
279         {
280                 put_str(stat_names[stat], ROW_STAT + stat, 0);
281                 cnv_stat(creature_ptr->stat_use[stat], tmp);
282                 c_put_str(TERM_L_GREEN, tmp, ROW_STAT + stat, COL_STAT + 6);
283         }
284
285         /* Indicate natural maximum */
286         if (creature_ptr->stat_max[stat] != creature_ptr->stat_max_max[stat])
287                 return;
288
289 #ifdef JP
290         /* 日本語にかぶらないように表示位置を変更 */
291         put_str("!", ROW_STAT + stat, 5);
292 #else
293         put_str("!", ROW_STAT + stat, 3);
294 #endif
295 }
296
297
298 /*
299  * 画面下部に表示する状態表示定義ID / Data structure for status bar
300  */
301 #define BAR_TSUYOSHI 0      /*!< 下部ステータス表示: オクレ兄さん状態 */
302 #define BAR_HALLUCINATION 1 /*!< 下部ステータス表示: 幻覚 */
303 #define BAR_BLINDNESS 2     /*!< 下部ステータス表示: 盲目 */
304 #define BAR_PARALYZE 3      /*!< 下部ステータス表示: 麻痺 */
305 #define BAR_CONFUSE 4       /*!< 下部ステータス表示: 混乱 */
306 #define BAR_POISONED 5      /*!< 下部ステータス表示: 毒 */
307 #define BAR_AFRAID 6        /*!< 下部ステータス表示: 恐怖 */
308 #define BAR_LEVITATE 7      /*!< 下部ステータス表示: 浮遊 */
309 #define BAR_REFLECTION 8    /*!< 下部ステータス表示: 反射 */
310 #define BAR_PASSWALL 9      /*!< 下部ステータス表示: 壁抜け */
311 #define BAR_WRAITH 10       /*!< 下部ステータス表示: 幽体化 */
312 #define BAR_PROTEVIL 11     /*!< 下部ステータス表示: 対邪悪結界 */
313 #define BAR_KAWARIMI 12     /*!< 下部ステータス表示: 変わり身 */
314 #define BAR_MAGICDEFENSE 13 /*!< 下部ステータス表示: 魔法の鎧 */
315 #define BAR_EXPAND 14       /*!< 下部ステータス表示: 横伸び */
316 #define BAR_STONESKIN 15    /*!< 下部ステータス表示: 石肌化 */
317 #define BAR_MULTISHADOW 16  /*!< 下部ステータス表示: 影分身 */
318 #define BAR_REGMAGIC 17     /*!< 下部ステータス表示: 魔法防御 */
319 #define BAR_ULTIMATE 18     /*!< 下部ステータス表示: 究極の耐性 */
320 #define BAR_INVULN 19       /*!< 下部ステータス表示: 無敵化 */
321 #define BAR_IMMACID 20      /*!< 下部ステータス表示: 酸免疫 */
322 #define BAR_RESACID 21      /*!< 下部ステータス表示: 酸耐性 */
323 #define BAR_IMMELEC 22      /*!< 下部ステータス表示: 電撃免疫 */
324 #define BAR_RESELEC 23      /*!< 下部ステータス表示: 電撃耐性 */
325 #define BAR_IMMFIRE 24      /*!< 下部ステータス表示: 火炎免疫 */
326 #define BAR_RESFIRE 25      /*!< 下部ステータス表示: 火炎耐性 */
327 #define BAR_IMMCOLD 26      /*!< 下部ステータス表示: 冷気免疫 */
328 #define BAR_RESCOLD 27      /*!< 下部ステータス表示: 冷気耐性 */
329 #define BAR_RESPOIS 28      /*!< 下部ステータス表示: 毒耐性 */
330 #define BAR_RESNETH 29      /*!< 下部ステータス表示: 地獄耐性 */
331 #define BAR_RESTIME 30      /*!< 下部ステータス表示: 時間逆転耐性 */
332 #define BAR_DUSTROBE 31     /*!< 下部ステータス表示: 破片オーラ */
333 #define BAR_SHFIRE 32       /*!< 下部ステータス表示: 火炎オーラ */
334 #define BAR_TOUKI 33        /*!< 下部ステータス表示: 闘気 */
335 #define BAR_SHHOLY 34       /*!< 下部ステータス表示: 聖なるオーラ */
336 #define BAR_EYEEYE 35       /*!< 下部ステータス表示: 目には目を */
337 #define BAR_BLESSED 36      /*!< 下部ステータス表示: 祝福 */
338 #define BAR_HEROISM 37      /*!< 下部ステータス表示: 士気高揚 */
339 #define BAR_BERSERK 38      /*!< 下部ステータス表示: 狂戦士化 */
340 #define BAR_ATTKFIRE 39     /*!< 下部ステータス表示: 焼棄スレイ */
341 #define BAR_ATTKCOLD 40     /*!< 下部ステータス表示: 冷凍スレイ */
342 #define BAR_ATTKELEC 41     /*!< 下部ステータス表示: 電撃スレイ */
343 #define BAR_ATTKACID 42     /*!< 下部ステータス表示: 溶解スレイ */
344 #define BAR_ATTKPOIS 43     /*!< 下部ステータス表示: 毒殺スレイ */
345 #define BAR_ATTKCONF 44     /*!< 下部ステータス表示: 混乱打撃 */
346 #define BAR_SENSEUNSEEN 45  /*!< 下部ステータス表示: 透明視 */
347 #define BAR_TELEPATHY 46    /*!< 下部ステータス表示: テレパシー */
348 #define BAR_REGENERATION 47 /*!< 下部ステータス表示: 急回復 */
349 #define BAR_INFRAVISION 48  /*!< 下部ステータス表示: 赤外線視力 */
350 #define BAR_STEALTH 49      /*!< 下部ステータス表示: 隠密 */
351 #define BAR_SUPERSTEALTH 50 /*!< 下部ステータス表示: 超隠密 */
352 #define BAR_RECALL 51       /*!< 下部ステータス表示: 帰還待ち */
353 #define BAR_ALTER 52        /*!< 下部ステータス表示: 現実変容待ち */
354 #define BAR_SHCOLD 53       /*!< 下部ステータス表示: 冷気オーラ */
355 #define BAR_SHELEC 54       /*!< 下部ステータス表示: 電撃オーラ */
356 #define BAR_SHSHADOW 55     /*!< 下部ステータス表示: 影のオーラ */
357 #define BAR_MIGHT 56        /*!< 下部ステータス表示: 腕力強化 */
358 #define BAR_BUILD 57        /*!< 下部ステータス表示: 肉体強化 */
359 #define BAR_ANTIMULTI 58    /*!< 下部ステータス表示: 反増殖 */
360 #define BAR_ANTITELE 59     /*!< 下部ステータス表示: 反テレポート */
361 #define BAR_ANTIMAGIC 60    /*!< 下部ステータス表示: 反魔法 */
362 #define BAR_PATIENCE 61     /*!< 下部ステータス表示: 我慢 */
363 #define BAR_REVENGE 62      /*!< 下部ステータス表示: 宣告 */
364 #define BAR_RUNESWORD 63    /*!< 下部ステータス表示: 魔剣化 */
365 #define BAR_VAMPILIC 64     /*!< 下部ステータス表示: 吸血 */
366 #define BAR_CURE 65         /*!< 下部ステータス表示: 回復 */
367 #define BAR_ESP_EVIL 66     /*!< 下部ステータス表示: 邪悪感知 */
368
369 static struct {
370         TERM_COLOR attr;
371         concptr sstr;
372         concptr lstr;
373 } bar[]
374 #ifdef JP
375 = {
376         {TERM_YELLOW, "つ", "つよし"},
377         {TERM_VIOLET, "幻", "幻覚"},
378         {TERM_L_DARK, "盲", "盲目"},
379         {TERM_RED, "痺", "麻痺"},
380         {TERM_VIOLET, "乱", "混乱"},
381         {TERM_GREEN, "毒", "毒"},
382         {TERM_BLUE, "恐", "恐怖"},
383         {TERM_L_BLUE, "浮", "浮遊"},
384         {TERM_SLATE, "反", "反射"},
385         {TERM_SLATE, "壁", "壁抜け"},
386         {TERM_L_DARK, "幽", "幽体"},
387         {TERM_SLATE, "邪", "防邪"},
388         {TERM_VIOLET, "変", "変わり身"},
389         {TERM_YELLOW, "魔", "魔法鎧"},
390         {TERM_L_UMBER, "伸", "伸び"},
391         {TERM_WHITE, "石", "石肌"},
392         {TERM_L_BLUE, "分", "分身"},
393         {TERM_SLATE, "防", "魔法防御"},
394         {TERM_YELLOW, "究", "究極"},
395         {TERM_YELLOW, "無", "無敵"},
396         {TERM_L_GREEN, "酸", "酸免疫"},
397         {TERM_GREEN, "酸", "耐酸"},
398         {TERM_L_BLUE, "電", "電免疫"},
399         {TERM_BLUE, "電", "耐電"},
400         {TERM_L_RED, "火", "火免疫"},
401         {TERM_RED, "火", "耐火"},
402         {TERM_WHITE, "冷", "冷免疫"},
403         {TERM_SLATE, "冷", "耐冷"},
404         {TERM_GREEN, "毒", "耐毒"},
405         {TERM_L_DARK, "獄", "耐地獄"},
406         {TERM_L_BLUE, "時", "耐時間"},
407         {TERM_L_DARK, "鏡", "鏡オーラ"},
408         {TERM_L_RED, "オ", "火オーラ"},
409         {TERM_WHITE, "闘", "闘気"},
410         {TERM_WHITE, "聖", "聖オーラ"},
411         {TERM_VIOLET, "目", "目には目"},
412         {TERM_WHITE, "祝", "祝福"},
413         {TERM_WHITE, "勇", "勇"},
414         {TERM_RED, "狂", "狂乱"},
415         {TERM_L_RED, "火", "魔剣火"},
416         {TERM_WHITE, "冷", "魔剣冷"},
417         {TERM_L_BLUE, "電", "魔剣電"},
418         {TERM_SLATE, "酸", "魔剣酸"},
419         {TERM_L_GREEN, "毒", "魔剣毒"},
420         {TERM_RED, "乱", "混乱打撃"},
421         {TERM_L_BLUE, "視", "透明視"},
422         {TERM_ORANGE, "テ", "テレパシ"},
423         {TERM_L_BLUE, "回", "回復"},
424         {TERM_L_RED, "赤", "赤外"},
425         {TERM_UMBER, "隠", "隠密"},
426         {TERM_YELLOW, "隠", "超隠密"},
427         {TERM_WHITE, "帰", "帰還"},
428         {TERM_WHITE, "現", "現実変容"},
429         {TERM_WHITE, "オ", "氷オーラ"},
430         {TERM_BLUE, "オ", "電オーラ"},
431         {TERM_L_DARK, "オ", "影オーラ"},
432         {TERM_YELLOW, "腕", "腕力強化"},
433         {TERM_RED, "肉", "肉体強化"},
434         {TERM_L_DARK, "殖", "反増殖"},
435         {TERM_ORANGE, "テ", "反テレポ"},
436         {TERM_RED, "魔", "反魔法"},
437         {TERM_SLATE, "我", "我慢"},
438         {TERM_SLATE, "宣", "宣告"},
439         {TERM_L_DARK, "剣", "魔剣化"},
440         {TERM_RED, "吸", "吸血打撃"},
441         {TERM_WHITE, "回", "回復"},
442         {TERM_L_DARK, "感", "邪悪感知"},
443         {0, NULL, NULL}
444 };
445 #else
446 = {
447         {TERM_YELLOW, "Ts", "Tsuyoshi"},
448         {TERM_VIOLET, "Ha", "Halluc"},
449         {TERM_L_DARK, "Bl", "Blind"},
450         {TERM_RED, "Pa", "Paralyzed"},
451         {TERM_VIOLET, "Cf", "Confused"},
452         {TERM_GREEN, "Po", "Poisoned"},
453         {TERM_BLUE, "Af", "Afraid"},
454         {TERM_L_BLUE, "Lv", "Levit"},
455         {TERM_SLATE, "Rf", "Reflect"},
456         {TERM_SLATE, "Pw", "PassWall"},
457         {TERM_L_DARK, "Wr", "Wraith"},
458         {TERM_SLATE, "Ev", "PrtEvl"},
459         {TERM_VIOLET, "Kw", "Kawarimi"},
460         {TERM_YELLOW, "Md", "MgcArm"},
461         {TERM_L_UMBER, "Eh", "Expand"},
462         {TERM_WHITE, "Ss", "StnSkn"},
463         {TERM_L_BLUE, "Ms", "MltShdw"},
464         {TERM_SLATE, "Rm", "ResMag"},
465         {TERM_YELLOW, "Ul", "Ultima"},
466         {TERM_YELLOW, "Iv", "Invuln"},
467         {TERM_L_GREEN, "IAc", "ImmAcid"},
468         {TERM_GREEN, "Ac", "Acid"},
469         {TERM_L_BLUE, "IEl", "ImmElec"},
470         {TERM_BLUE, "El", "Elec"},
471         {TERM_L_RED, "IFi", "ImmFire"},
472         {TERM_RED, "Fi", "Fire"},
473         {TERM_WHITE, "ICo", "ImmCold"},
474         {TERM_SLATE, "Co", "Cold"},
475         {TERM_GREEN, "Po", "Pois"},
476         {TERM_L_DARK, "Nt", "Nthr"},
477         {TERM_L_BLUE, "Ti", "Time"},
478         {TERM_L_DARK, "Mr", "Mirr"},
479         {TERM_L_RED, "SFi", "SFire"},
480         {TERM_WHITE, "Fo", "Force"},
481         {TERM_WHITE, "Ho", "Holy"},
482         {TERM_VIOLET, "Ee", "EyeEye"},
483         {TERM_WHITE, "Bs", "Bless"},
484         {TERM_WHITE, "He", "Hero"},
485         {TERM_RED, "Br", "Berserk"},
486         {TERM_L_RED, "BFi", "BFire"},
487         {TERM_WHITE, "BCo", "BCold"},
488         {TERM_L_BLUE, "BEl", "BElec"},
489         {TERM_SLATE, "BAc", "BAcid"},
490         {TERM_L_GREEN, "BPo", "BPois"},
491         {TERM_RED, "TCf", "TchCnf"},
492         {TERM_L_BLUE, "Se", "SInv"},
493         {TERM_ORANGE, "Te", "Telepa"},
494         {TERM_L_BLUE, "Rg", "Regen"},
495         {TERM_L_RED, "If", "Infr"},
496         {TERM_UMBER, "Sl", "Stealth"},
497         {TERM_YELLOW, "Stlt", "Stealth"},
498         {TERM_WHITE, "Rc", "Recall"},
499         {TERM_WHITE, "Al", "Alter"},
500         {TERM_WHITE, "SCo", "SCold"},
501         {TERM_BLUE, "SEl", "SElec"},
502         {TERM_L_DARK, "SSh", "SShadow"},
503         {TERM_YELLOW, "EMi", "ExMight"},
504         {TERM_RED, "Bu", "BuildUp"},
505         {TERM_L_DARK, "AMl", "AntiMulti"},
506         {TERM_ORANGE, "AT", "AntiTele"},
507         {TERM_RED, "AM", "AntiMagic"},
508         {TERM_SLATE, "Pa", "Patience"},
509         {TERM_SLATE, "Rv", "Revenge"},
510         {TERM_L_DARK, "Rs", "RuneSword"},
511         {TERM_RED, "Vm", "Vampiric"},
512         {TERM_WHITE, "Cu", "Cure"},
513         {TERM_L_DARK, "ET", "EvilTele"},
514         {0, NULL, NULL}
515 };
516 #endif
517
518 /*!
519  * @brief 32ビット変数配列の指定位置のビットフラグを1にする。
520  * @param FLG フラグ位置(ビット)
521  * @return なし
522  */
523 #define ADD_FLG(FLG) (bar_flags[FLG / 32] |= (1L << (FLG % 32)))
524
525  /*!
526   * @brief 32ビット変数配列の指定位置のビットフラグが1かどうかを返す。
527   * @param FLG フラグ位置(ビット)
528   * @return 1ならば0以外を返す
529   */
530 #define IS_FLG(FLG) (bar_flags[FLG / 32] & (1L << (FLG % 32)))
531
532
533   /*!
534    * @brief 下部に状態表示を行う / Show status bar
535    * @return なし
536    */
537 static void print_status(player_type *creature_ptr)
538 {
539         TERM_LEN wid, hgt;
540         Term_get_size(&wid, &hgt);
541         TERM_LEN row_statbar = hgt + ROW_STATBAR;
542         TERM_LEN max_col_statbar = wid + MAX_COL_STATBAR;
543
544         Term_erase(0, row_statbar, max_col_statbar);
545
546         BIT_FLAGS bar_flags[3];
547         bar_flags[0] = bar_flags[1] = bar_flags[2] = 0L;
548
549         /* Tsuyoshi  */
550         if (creature_ptr->tsuyoshi) ADD_FLG(BAR_TSUYOSHI);
551
552         /* Hallucinating */
553         if (creature_ptr->image) ADD_FLG(BAR_HALLUCINATION);
554
555         /* Blindness */
556         if (creature_ptr->blind) ADD_FLG(BAR_BLINDNESS);
557
558         /* Paralysis */
559         if (creature_ptr->paralyzed) ADD_FLG(BAR_PARALYZE);
560
561         /* Confusion */
562         if (creature_ptr->confused) ADD_FLG(BAR_CONFUSE);
563
564         /* Posioned */
565         if (creature_ptr->poisoned) ADD_FLG(BAR_POISONED);
566
567         /* Times see-invisible */
568         if (creature_ptr->tim_invis) ADD_FLG(BAR_SENSEUNSEEN);
569
570         /* Timed esp */
571         if (is_time_limit_esp(creature_ptr)) ADD_FLG(BAR_TELEPATHY);
572
573         /* Timed regenerate */
574         if (creature_ptr->tim_regen) ADD_FLG(BAR_REGENERATION);
575
576         /* Timed infra-vision */
577         if (creature_ptr->tim_infra) ADD_FLG(BAR_INFRAVISION);
578
579         /* Protection from evil */
580         if (creature_ptr->protevil) ADD_FLG(BAR_PROTEVIL);
581
582         /* Invulnerability */
583         if (IS_INVULN(creature_ptr)) ADD_FLG(BAR_INVULN);
584
585         /* Wraith form */
586         if (creature_ptr->wraith_form) ADD_FLG(BAR_WRAITH);
587
588         /* Kabenuke */
589         if (creature_ptr->kabenuke) ADD_FLG(BAR_PASSWALL);
590
591         if (creature_ptr->tim_reflect) ADD_FLG(BAR_REFLECTION);
592
593         /* Heroism */
594         if (IS_HERO(creature_ptr)) ADD_FLG(BAR_HEROISM);
595
596         /* Super Heroism / berserk */
597         if (creature_ptr->shero) ADD_FLG(BAR_BERSERK);
598
599         /* Blessed */
600         if (is_blessed(creature_ptr)) ADD_FLG(BAR_BLESSED);
601
602         /* Shield */
603         if (creature_ptr->magicdef) ADD_FLG(BAR_MAGICDEFENSE);
604
605         if (creature_ptr->tsubureru) ADD_FLG(BAR_EXPAND);
606
607         if (creature_ptr->shield) ADD_FLG(BAR_STONESKIN);
608
609         if (creature_ptr->special_defense & NINJA_KAWARIMI) ADD_FLG(BAR_KAWARIMI);
610
611         /* Oppose Acid */
612         if (creature_ptr->special_defense & DEFENSE_ACID) ADD_FLG(BAR_IMMACID);
613         if (is_oppose_acid(creature_ptr)) ADD_FLG(BAR_RESACID);
614
615         /* Oppose Lightning */
616         if (creature_ptr->special_defense & DEFENSE_ELEC) ADD_FLG(BAR_IMMELEC);
617         if (is_oppose_elec(creature_ptr)) ADD_FLG(BAR_RESELEC);
618
619         /* Oppose Fire */
620         if (creature_ptr->special_defense & DEFENSE_FIRE) ADD_FLG(BAR_IMMFIRE);
621         if (is_oppose_fire(creature_ptr)) ADD_FLG(BAR_RESFIRE);
622
623         /* Oppose Cold */
624         if (creature_ptr->special_defense & DEFENSE_COLD) ADD_FLG(BAR_IMMCOLD);
625         if (is_oppose_cold(creature_ptr)) ADD_FLG(BAR_RESCOLD);
626
627         /* Oppose Poison */
628         if (is_oppose_pois(creature_ptr)) ADD_FLG(BAR_RESPOIS);
629
630         /* Word of Recall */
631         if (creature_ptr->word_recall) ADD_FLG(BAR_RECALL);
632
633         /* Alter realiry */
634         if (creature_ptr->alter_reality) ADD_FLG(BAR_ALTER);
635
636         /* Afraid */
637         if (creature_ptr->afraid) ADD_FLG(BAR_AFRAID);
638
639         /* Resist time */
640         if (creature_ptr->tim_res_time) ADD_FLG(BAR_RESTIME);
641
642         if (creature_ptr->multishadow) ADD_FLG(BAR_MULTISHADOW);
643
644         /* Confusing Hands */
645         if (creature_ptr->special_attack & ATTACK_CONFUSE) ADD_FLG(BAR_ATTKCONF);
646
647         if (creature_ptr->resist_magic) ADD_FLG(BAR_REGMAGIC);
648
649         /* Ultimate-resistance */
650         if (creature_ptr->ult_res) ADD_FLG(BAR_ULTIMATE);
651
652         /* tim levitation */
653         if (creature_ptr->tim_levitation) ADD_FLG(BAR_LEVITATE);
654
655         if (creature_ptr->tim_res_nether) ADD_FLG(BAR_RESNETH);
656
657         if (creature_ptr->dustrobe) ADD_FLG(BAR_DUSTROBE);
658
659         /* Mahouken */
660         if (creature_ptr->special_attack & ATTACK_FIRE) ADD_FLG(BAR_ATTKFIRE);
661         if (creature_ptr->special_attack & ATTACK_COLD) ADD_FLG(BAR_ATTKCOLD);
662         if (creature_ptr->special_attack & ATTACK_ELEC) ADD_FLG(BAR_ATTKELEC);
663         if (creature_ptr->special_attack & ATTACK_ACID) ADD_FLG(BAR_ATTKACID);
664         if (creature_ptr->special_attack & ATTACK_POIS) ADD_FLG(BAR_ATTKPOIS);
665         if (creature_ptr->special_defense & NINJA_S_STEALTH) ADD_FLG(BAR_SUPERSTEALTH);
666
667         if (creature_ptr->tim_sh_fire) ADD_FLG(BAR_SHFIRE);
668
669         /* tim stealth */
670         if (is_time_limit_stealth(creature_ptr)) ADD_FLG(BAR_STEALTH);
671
672         if (creature_ptr->tim_sh_touki) ADD_FLG(BAR_TOUKI);
673
674         /* Holy aura */
675         if (creature_ptr->tim_sh_holy) ADD_FLG(BAR_SHHOLY);
676
677         /* An Eye for an Eye */
678         if (creature_ptr->tim_eyeeye) ADD_FLG(BAR_EYEEYE);
679
680         /* Hex spells */
681         if (creature_ptr->realm1 == REALM_HEX)
682         {
683                 if (hex_spelling(creature_ptr, HEX_BLESS)) ADD_FLG(BAR_BLESSED);
684                 if (hex_spelling(creature_ptr, HEX_DEMON_AURA)) { ADD_FLG(BAR_SHFIRE); ADD_FLG(BAR_REGENERATION); }
685                 if (hex_spelling(creature_ptr, HEX_XTRA_MIGHT)) ADD_FLG(BAR_MIGHT);
686                 if (hex_spelling(creature_ptr, HEX_DETECT_EVIL)) ADD_FLG(BAR_ESP_EVIL);
687                 if (hex_spelling(creature_ptr, HEX_ICE_ARMOR)) ADD_FLG(BAR_SHCOLD);
688                 if (hex_spelling(creature_ptr, HEX_RUNESWORD)) ADD_FLG(BAR_RUNESWORD);
689                 if (hex_spelling(creature_ptr, HEX_BUILDING)) ADD_FLG(BAR_BUILD);
690                 if (hex_spelling(creature_ptr, HEX_ANTI_TELE)) ADD_FLG(BAR_ANTITELE);
691                 if (hex_spelling(creature_ptr, HEX_SHOCK_CLOAK)) ADD_FLG(BAR_SHELEC);
692                 if (hex_spelling(creature_ptr, HEX_SHADOW_CLOAK)) ADD_FLG(BAR_SHSHADOW);
693                 if (hex_spelling(creature_ptr, HEX_CONFUSION)) ADD_FLG(BAR_ATTKCONF);
694                 if (hex_spelling(creature_ptr, HEX_EYE_FOR_EYE)) ADD_FLG(BAR_EYEEYE);
695                 if (hex_spelling(creature_ptr, HEX_ANTI_MULTI)) ADD_FLG(BAR_ANTIMULTI);
696                 if (hex_spelling(creature_ptr, HEX_VAMP_BLADE)) ADD_FLG(BAR_VAMPILIC);
697                 if (hex_spelling(creature_ptr, HEX_ANTI_MAGIC)) ADD_FLG(BAR_ANTIMAGIC);
698                 if (hex_spelling(creature_ptr, HEX_CURE_LIGHT) ||
699                         hex_spelling(creature_ptr, HEX_CURE_SERIOUS) ||
700                         hex_spelling(creature_ptr, HEX_CURE_CRITICAL)) ADD_FLG(BAR_CURE);
701
702                 if (hex_revenge_turn(creature_ptr))
703                 {
704                         if (hex_revenge_type(creature_ptr) == 1) ADD_FLG(BAR_PATIENCE);
705                         if (hex_revenge_type(creature_ptr) == 2) ADD_FLG(BAR_REVENGE);
706                 }
707         }
708
709         /* Calcurate length */
710         TERM_LEN col = 0, num = 0;
711         for (int i = 0; bar[i].sstr; i++)
712         {
713                 if (IS_FLG(i))
714                 {
715                         col += strlen(bar[i].lstr) + 1;
716                         num++;
717                 }
718         }
719
720         /* If there are not excess spaces for long strings, use short one */
721         int space = 2;
722         if (col - 1 > max_col_statbar)
723         {
724                 space = 0;
725                 col = 0;
726
727                 for (int i = 0; bar[i].sstr; i++)
728                 {
729                         if (IS_FLG(i))
730                         {
731                                 col += strlen(bar[i].sstr);
732                         }
733                 }
734
735                 /* If there are excess spaces for short string, use more */
736                 if (col - 1 <= max_col_statbar - (num - 1))
737                 {
738                         space = 1;
739                         col += num - 1;
740                 }
741         }
742
743         /* Centering display column */
744         col = (max_col_statbar - col) / 2;
745
746         /* Display status bar */
747         for (int i = 0; bar[i].sstr; i++)
748         {
749                 if (!IS_FLG(i)) continue;
750
751                 concptr str;
752                 if (space == 2) str = bar[i].lstr;
753                 else str = bar[i].sstr;
754
755                 c_put_str(bar[i].attr, str, row_statbar, col);
756                 col += strlen(str);
757                 if (space > 0) col++;
758                 if (col > max_col_statbar) break;
759         }
760 }
761
762
763 /*!
764  * @brief プレイヤーの称号を表示する / Prints "title", including "wizard" or "winner" as needed.
765  * @return なし
766  */
767 static void print_title(player_type *creature_ptr)
768 {
769         GAME_TEXT str[14];
770
771         concptr p = "";
772         if (current_world_ptr->wizard)
773         {
774                 p = _("[ウィザード]", "[=-WIZARD-=]");
775         }
776         else if (current_world_ptr->total_winner || (creature_ptr->lev > PY_MAX_LEVEL))
777         {
778                 if (creature_ptr->arena_number > MAX_ARENA_MONS + 2)
779                 {
780                         p = _("*真・勝利者*", "*TRUEWINNER*");
781                 }
782                 else
783                 {
784                         p = _("***勝利者***", "***WINNER***");
785                 }
786         }
787         else
788         {
789                 angband_strcpy(str, player_title[creature_ptr->pclass][(creature_ptr->lev - 1) / 5], sizeof(str));
790                 p = str;
791         }
792
793         print_field(p, ROW_TITLE, COL_TITLE);
794 }
795
796
797 /*!
798  * @brief プレイヤーのレベルを表示する / Prints level
799  * @return なし
800  */
801 static void print_level(player_type *creature_ptr)
802 {
803         char tmp[32];
804         sprintf(tmp, "%5d", creature_ptr->lev);
805         if (creature_ptr->lev >= creature_ptr->max_plv)
806         {
807                 put_str(_("レベル ", "LEVEL "), ROW_LEVEL, 0);
808                 c_put_str(TERM_L_GREEN, tmp, ROW_LEVEL, COL_LEVEL + 7);
809         }
810         else
811         {
812                 put_str(_("xレベル", "Level "), ROW_LEVEL, 0);
813                 c_put_str(TERM_YELLOW, tmp, ROW_LEVEL, COL_LEVEL + 7);
814         }
815 }
816
817
818 /*!
819  * @brief プレイヤーの経験値を表示する / Display the experience
820  * @return なし
821  */
822 static void print_exp(player_type *creature_ptr)
823 {
824         char out_val[32];
825
826         if ((!exp_need) || (creature_ptr->prace == RACE_ANDROID))
827         {
828                 (void)sprintf(out_val, "%8ld", (long)creature_ptr->exp);
829         }
830         else
831         {
832                 if (creature_ptr->lev >= PY_MAX_LEVEL)
833                 {
834                         (void)sprintf(out_val, "********");
835                 }
836                 else
837                 {
838                         (void)sprintf(out_val, "%8ld", (long)(player_exp[creature_ptr->lev - 1] * creature_ptr->expfact / 100L) - creature_ptr->exp);
839                 }
840         }
841
842         if (creature_ptr->exp >= creature_ptr->max_exp)
843         {
844                 if (creature_ptr->prace == RACE_ANDROID) put_str(_("強化 ", "Cst "), ROW_EXP, 0);
845                 else put_str(_("経験 ", "EXP "), ROW_EXP, 0);
846                 c_put_str(TERM_L_GREEN, out_val, ROW_EXP, COL_EXP + 4);
847         }
848         else
849         {
850                 put_str(_("x経験", "Exp "), ROW_EXP, 0);
851                 c_put_str(TERM_YELLOW, out_val, ROW_EXP, COL_EXP + 4);
852         }
853 }
854
855
856 /*!
857  * @brief プレイヤーの所持金を表示する / Prints current gold
858  * @param creature_ptr プレーヤーへの参照ポインタ
859  * @return なし
860  */
861 static void print_gold(player_type *creature_ptr)
862 {
863         char tmp[32];
864         put_str(_("$ ", "AU "), ROW_GOLD, COL_GOLD);
865         sprintf(tmp, "%9ld", (long)creature_ptr->au);
866         c_put_str(TERM_L_GREEN, tmp, ROW_GOLD, COL_GOLD + 3);
867 }
868
869
870 /*!
871  * @brief プレイヤーのACを表示する / Prints current AC
872  * @return なし
873  */
874 static void print_ac(player_type *creature_ptr)
875 {
876         char tmp[32];
877
878 #ifdef JP
879         /* AC の表示方式を変更している */
880         put_str(" AC(     )", ROW_AC, COL_AC);
881         sprintf(tmp, "%5d", creature_ptr->dis_ac + creature_ptr->dis_to_a);
882         c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 6);
883 #else
884         put_str("Cur AC ", ROW_AC, COL_AC);
885         sprintf(tmp, "%5d", creature_ptr->dis_ac + creature_ptr->dis_to_a);
886         c_put_str(TERM_L_GREEN, tmp, ROW_AC, COL_AC + 7);
887 #endif
888
889 }
890
891
892 /*!
893  * @brief プレイヤーのHPを表示する / Prints Cur/Max hit points
894  * @return なし
895  */
896 static void print_hp(player_type *creature_ptr)
897 {
898         /* ヒットポイントの表示方法を変更 */
899         char tmp[32];
900
901         /* タイトル */
902         put_str("HP", ROW_CURHP, COL_CURHP);
903
904         /* 現在のヒットポイント */
905         sprintf(tmp, "%4ld", (long int)creature_ptr->chp);
906
907         TERM_COLOR color;
908         if (creature_ptr->chp >= creature_ptr->mhp)
909         {
910                 color = TERM_L_GREEN;
911         }
912         else if (creature_ptr->chp > (creature_ptr->mhp * hitpoint_warn) / 10)
913         {
914                 color = TERM_YELLOW;
915         }
916         else
917         {
918                 color = TERM_RED;
919         }
920
921         c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 3);
922
923         /* 区切り */
924         put_str("/", ROW_CURHP, COL_CURHP + 7);
925
926         /* 最大ヒットポイント */
927         sprintf(tmp, "%4ld", (long int)creature_ptr->mhp);
928         color = TERM_L_GREEN;
929
930         c_put_str(color, tmp, ROW_CURHP, COL_CURHP + 8);
931 }
932
933
934 /*!
935  * @brief プレイヤーのMPを表示する / Prints players max/cur spell points
936  * @return なし
937  */
938 static void print_sp(player_type *creature_ptr)
939 {
940         /* マジックポイントの表示方法を変更している */
941         char tmp[32];
942         byte color;
943
944         /* Do not show mana unless it matters */
945         if (!mp_ptr->spell_book) return;
946
947         /* タイトル */
948         put_str(_("MP", "SP"), ROW_CURSP, COL_CURSP);
949
950         /* 現在のマジックポイント */
951         sprintf(tmp, "%4ld", (long int)creature_ptr->csp);
952
953         if (creature_ptr->csp >= creature_ptr->msp)
954         {
955                 color = TERM_L_GREEN;
956         }
957         else if (creature_ptr->csp > (creature_ptr->msp * mana_warn) / 10)
958         {
959                 color = TERM_YELLOW;
960         }
961         else
962         {
963                 color = TERM_RED;
964         }
965
966         c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 3);
967
968         /* 区切り */
969         put_str("/", ROW_CURSP, COL_CURSP + 7);
970
971         /* 最大マジックポイント */
972         sprintf(tmp, "%4ld", (long int)creature_ptr->msp);
973         color = TERM_L_GREEN;
974
975         c_put_str(color, tmp, ROW_CURSP, COL_CURSP + 8);
976 }
977
978
979 /*!
980  * @brief 現在のフロアの深さを表示する / Prints depth in stat area
981  * @param creature_ptr プレーヤーへの参照ポインタ
982  * @return なし
983  */
984 static void print_depth(player_type *creature_ptr)
985 {
986         char depths[32];
987         TERM_COLOR attr = TERM_WHITE;
988
989         TERM_LEN wid, hgt;
990         Term_get_size(&wid, &hgt);
991         TERM_LEN col_depth = wid + COL_DEPTH;
992         TERM_LEN row_depth = hgt + ROW_DEPTH;
993
994         floor_type *floor_ptr = creature_ptr->current_floor_ptr;
995         if (!floor_ptr->dun_level)
996         {
997                 strcpy(depths, _("地上", "Surf."));
998                 c_prt(attr, format("%7s", depths), row_depth, col_depth);
999                 return;
1000         }
1001
1002         if (floor_ptr->inside_quest && !creature_ptr->dungeon_idx)
1003         {
1004                 strcpy(depths, _("地上", "Quest"));
1005                 c_prt(attr, format("%7s", depths), row_depth, col_depth);
1006                 return;
1007         }
1008
1009         if (depth_in_feet) (void)sprintf(depths, _("%d ft", "%d ft"), (int)floor_ptr->dun_level * 50);
1010         else (void)sprintf(depths, _("%d 階", "Lev %d"), (int)floor_ptr->dun_level);
1011
1012         /* Get color of level based on feeling  -JSV- */
1013         switch (creature_ptr->feeling)
1014         {
1015         case  0: attr = TERM_SLATE;   break; /* Unknown */
1016         case  1: attr = TERM_L_BLUE;  break; /* Special */
1017         case  2: attr = TERM_VIOLET;  break; /* Horrible visions */
1018         case  3: attr = TERM_RED;     break; /* Very dangerous */
1019         case  4: attr = TERM_L_RED;   break; /* Very bad feeling */
1020         case  5: attr = TERM_ORANGE;  break; /* Bad feeling */
1021         case  6: attr = TERM_YELLOW;  break; /* Nervous */
1022         case  7: attr = TERM_L_UMBER; break; /* Luck is turning */
1023         case  8: attr = TERM_L_WHITE; break; /* Don't like */
1024         case  9: attr = TERM_WHITE;   break; /* Reasonably safe */
1025         case 10: attr = TERM_WHITE;   break; /* Boring place */
1026         }
1027
1028         c_prt(attr, format("%7s", depths), row_depth, col_depth);
1029 }
1030
1031
1032 /*!
1033  * @brief プレイヤーの空腹状態を表示する / Prints status of hunger
1034  * @param player_ptr プレーヤーへの参照ポインタ
1035  * @return なし
1036  */
1037 static void print_hunger(player_type *player_ptr)
1038 {
1039         if (current_world_ptr->wizard && player_ptr->current_floor_ptr->inside_arena) return;
1040
1041         if (player_ptr->food < PY_FOOD_FAINT)
1042         {
1043                 c_put_str(TERM_RED, _("衰弱  ", "Weak  "), ROW_HUNGRY, COL_HUNGRY);
1044                 return;
1045         }
1046
1047         if (player_ptr->food < PY_FOOD_WEAK)
1048         {
1049                 c_put_str(TERM_ORANGE, _("衰弱  ", "Weak  "), ROW_HUNGRY, COL_HUNGRY);
1050                 return;
1051         }
1052
1053         if (player_ptr->food < PY_FOOD_ALERT)
1054         {
1055                 c_put_str(TERM_YELLOW, _("空腹  ", "Hungry"), ROW_HUNGRY, COL_HUNGRY);
1056                 return;
1057         }
1058
1059         if (player_ptr->food < PY_FOOD_FULL)
1060         {
1061                 c_put_str(TERM_L_GREEN, "      ", ROW_HUNGRY, COL_HUNGRY);
1062                 return;
1063         }
1064
1065         if (player_ptr->food < PY_FOOD_MAX)
1066         {
1067                 c_put_str(TERM_L_GREEN, _("満腹  ", "Full  "), ROW_HUNGRY, COL_HUNGRY);
1068                 return;
1069         }
1070
1071         c_put_str(TERM_GREEN, _("食過ぎ", "Gorged"), ROW_HUNGRY, COL_HUNGRY);
1072 }
1073
1074
1075 /*!
1076  * @brief プレイヤーの行動状態を表示する / Prints Searching, Resting, Paralysis, or 'count' status
1077  * @param player_ptr プレーヤーへの参照ポインタ
1078  * @return なし
1079  * @details
1080  * Display is always exactly 10 characters wide (see below)
1081  * This function was a major bottleneck when resting, so a lot of
1082  * the text formatting code was optimized in place below.
1083  */
1084 static void print_state(player_type *player_ptr)
1085 {
1086         TERM_COLOR attr = TERM_WHITE;
1087         GAME_TEXT text[16];
1088
1089         /* Repeating */
1090         if (command_rep)
1091         {
1092                 if (command_rep > 999)
1093                 {
1094                         (void)sprintf(text, "%2d00", command_rep / 100);
1095                 }
1096                 else
1097                 {
1098                         (void)sprintf(text, "  %2d", command_rep);
1099                 }
1100
1101                 c_put_str(attr, format("%5.5s", text), ROW_STATE, COL_STATE);
1102                 return;
1103         }
1104
1105         /* Action */
1106         switch (player_ptr->action)
1107         {
1108         case ACTION_SEARCH:
1109         {
1110                 strcpy(text, _("探索", "Sear"));
1111                 break;
1112         }
1113         case ACTION_REST:
1114                 /* Start with "Rest" */
1115                 strcpy(text, _("    ", "    "));
1116
1117                 if (player_ptr->resting > 0)
1118                 {
1119                         sprintf(text, "%4d", player_ptr->resting);
1120                 }
1121                 else if (player_ptr->resting == COMMAND_ARG_REST_FULL_HEALING)
1122                 {
1123                         text[0] = text[1] = text[2] = text[3] = '*';
1124                 }
1125                 else if (player_ptr->resting == COMMAND_ARG_REST_UNTIL_DONE)
1126                 {
1127                         text[0] = text[1] = text[2] = text[3] = '&';
1128                 }
1129                 break;
1130
1131         case ACTION_LEARN:
1132         {
1133                 strcpy(text, _("学習", "lear"));
1134                 if (player_ptr->new_mane) attr = TERM_L_RED;
1135                 break;
1136         }
1137         case ACTION_FISH:
1138         {
1139                 strcpy(text, _("釣り", "fish"));
1140                 break;
1141         }
1142         case ACTION_KAMAE:
1143         {
1144                 int i;
1145                 for (i = 0; i < MAX_KAMAE; i++)
1146                         if (player_ptr->special_defense & (KAMAE_GENBU << i)) break;
1147                 switch (i)
1148                 {
1149                 case 0: attr = TERM_GREEN; break;
1150                 case 1: attr = TERM_WHITE; break;
1151                 case 2: attr = TERM_L_BLUE; break;
1152                 case 3: attr = TERM_L_RED; break;
1153                 }
1154                 strcpy(text, kamae_shurui[i].desc);
1155                 break;
1156         }
1157         case ACTION_KATA:
1158         {
1159                 int i;
1160                 for (i = 0; i < MAX_KATA; i++)
1161                         if (player_ptr->special_defense & (KATA_IAI << i)) break;
1162                 strcpy(text, kata_shurui[i].desc);
1163                 break;
1164         }
1165         case ACTION_SING:
1166         {
1167                 strcpy(text, _("歌  ", "Sing"));
1168                 break;
1169         }
1170         case ACTION_HAYAGAKE:
1171         {
1172                 strcpy(text, _("速駆", "Fast"));
1173                 break;
1174         }
1175         case ACTION_SPELL:
1176         {
1177                 strcpy(text, _("詠唱", "Spel"));
1178                 break;
1179         }
1180         default:
1181         {
1182                 strcpy(text, "    ");
1183                 break;
1184         }
1185         }
1186
1187         c_put_str(attr, format("%5.5s", text), ROW_STATE, COL_STATE);
1188 }
1189
1190
1191 /*!
1192  * @brief プレイヤーの行動速度を表示する / Prints the speed of a character.                      -CJS-
1193  * @param player_ptr プレーヤーへの参照ポインタ
1194  * @return なし
1195  */
1196 static void print_speed(player_type *player_ptr)
1197 {
1198         TERM_LEN wid, hgt;
1199         Term_get_size(&wid, &hgt);
1200         TERM_LEN col_speed = wid + COL_SPEED;
1201         TERM_LEN row_speed = hgt + ROW_SPEED;
1202
1203         /* Hack -- Visually "undo" the Search Mode Slowdown */
1204         int i = player_ptr->pspeed;
1205         if (player_ptr->action == ACTION_SEARCH && !player_ptr->lightspeed) i += 10;
1206
1207         /* Fast */
1208         floor_type *floor_ptr = player_ptr->current_floor_ptr;
1209         bool is_fast = IS_FAST(player_ptr);
1210         char buf[32] = "";
1211         TERM_COLOR attr = TERM_WHITE;
1212         if (i > 110)
1213         {
1214                 if (player_ptr->riding)
1215                 {
1216                         monster_type *m_ptr = &floor_ptr->m_list[player_ptr->riding];
1217                         if (monster_fast_remaining(m_ptr) && !monster_slow_remaining(m_ptr)) attr = TERM_L_BLUE;
1218                         else if (monster_slow_remaining(m_ptr) && !monster_fast_remaining(m_ptr)) attr = TERM_VIOLET;
1219                         else attr = TERM_GREEN;
1220                 }
1221                 else if ((is_fast && !player_ptr->slow) || player_ptr->lightspeed) attr = TERM_YELLOW;
1222                 else if (player_ptr->slow && !is_fast) attr = TERM_VIOLET;
1223                 else attr = TERM_L_GREEN;
1224                 sprintf(buf, "%s(+%d)", (player_ptr->riding ? _("乗馬", "Ride") : _("加速", "Fast")), (i - 110));
1225         }
1226
1227         /* Slow */
1228         else if (i < 110)
1229         {
1230                 if (player_ptr->riding)
1231                 {
1232                         monster_type *m_ptr = &floor_ptr->m_list[player_ptr->riding];
1233                         if (monster_fast_remaining(m_ptr) && !monster_slow_remaining(m_ptr)) attr = TERM_L_BLUE;
1234                         else if (monster_slow_remaining(m_ptr) && !monster_fast_remaining(m_ptr)) attr = TERM_VIOLET;
1235                         else attr = TERM_RED;
1236                 }
1237                 else if (is_fast && !player_ptr->slow) attr = TERM_YELLOW;
1238                 else if (player_ptr->slow && !is_fast) attr = TERM_VIOLET;
1239                 else attr = TERM_L_UMBER;
1240                 sprintf(buf, "%s(-%d)", (player_ptr->riding ? _("乗馬", "Ride") : _("減速", "Slow")), (110 - i));
1241         }
1242         else if (player_ptr->riding)
1243         {
1244                 attr = TERM_GREEN;
1245                 strcpy(buf, _("乗馬中", "Riding"));
1246         }
1247
1248         c_put_str(attr, format("%-9s", buf), row_speed, col_speed);
1249 }
1250
1251
1252 /*!
1253  * @brief プレイヤーの呪文学習可能状態を表示する
1254  * @param player_ptr プレーヤーへの参照ポインタ
1255  * @return なし
1256  */
1257 static void print_study(player_type *player_ptr)
1258 {
1259         TERM_LEN wid, hgt;
1260         Term_get_size(&wid, &hgt);
1261         TERM_LEN col_study = wid + COL_STUDY;
1262         TERM_LEN row_study = hgt + ROW_STUDY;
1263
1264         if (player_ptr->new_spells)
1265         {
1266                 put_str(_("学習", "Stud"), row_study, col_study);
1267         }
1268         else
1269         {
1270                 put_str("    ", row_study, col_study);
1271         }
1272 }
1273
1274
1275 /*!
1276  * @brief プレイヤーのものまね可能状態を表示する
1277  * @param player_ptr プレーヤーへの参照ポインタ
1278  * @return なし
1279  */
1280 static void print_imitation(player_type *player_ptr)
1281 {
1282         TERM_LEN wid, hgt;
1283         Term_get_size(&wid, &hgt);
1284         TERM_LEN col_study = wid + COL_STUDY;
1285         TERM_LEN row_study = hgt + ROW_STUDY;
1286
1287         if (player_ptr->pclass != CLASS_IMITATOR) return;
1288
1289         if (player_ptr->mane_num != 0)
1290         {
1291                 put_str("    ", row_study, col_study);
1292                 return;
1293         }
1294
1295         TERM_COLOR attr;
1296         if (player_ptr->new_mane) attr = TERM_L_RED;
1297         else attr = TERM_WHITE;
1298         c_put_str(attr, _("まね", "Imit"), row_study, col_study);
1299 }
1300
1301 /*!
1302  * @brief プレイヤーの負傷状態を表示する
1303  * @return なし
1304  */
1305 static void print_cut(player_type *creature_ptr)
1306 {
1307         int c = creature_ptr->cut;
1308         if (c > 1000)
1309         {
1310                 c_put_str(TERM_L_RED, _("致命傷      ", "Mortal wound"), ROW_CUT, COL_CUT);
1311                 return;
1312         }
1313
1314         if (c > 200)
1315         {
1316                 c_put_str(TERM_RED, _("ひどい深手  ", "Deep gash   "), ROW_CUT, COL_CUT);
1317                 return;
1318         }
1319
1320         if (c > 100)
1321         {
1322                 c_put_str(TERM_RED, _("重傷        ", "Severe cut  "), ROW_CUT, COL_CUT);
1323                 return;
1324         }
1325
1326         if (c > 50)
1327         {
1328                 c_put_str(TERM_ORANGE, _("大変な傷    ", "Nasty cut   "), ROW_CUT, COL_CUT);
1329                 return;
1330         }
1331
1332         if (c > 25)
1333         {
1334                 c_put_str(TERM_ORANGE, _("ひどい傷    ", "Bad cut     "), ROW_CUT, COL_CUT);
1335                 return;
1336         }
1337
1338         if (c > 10)
1339         {
1340                 c_put_str(TERM_YELLOW, _("軽傷        ", "Light cut   "), ROW_CUT, COL_CUT);
1341                 return;
1342         }
1343
1344         if (c)
1345         {
1346                 c_put_str(TERM_YELLOW, _("かすり傷    ", "Graze       "), ROW_CUT, COL_CUT);
1347                 return;
1348         }
1349
1350         put_str("            ", ROW_CUT, COL_CUT);
1351 }
1352
1353
1354 /*!
1355  * @brief プレイヤーの朦朧状態を表示する
1356  * @return なし
1357  */
1358 static void print_stun(player_type *creature_ptr)
1359 {
1360         int s = creature_ptr->stun;
1361         if (s > 100)
1362         {
1363                 c_put_str(TERM_RED, _("意識不明瞭  ", "Knocked out "), ROW_STUN, COL_STUN);
1364                 return;
1365         }
1366
1367         if (s > 50)
1368         {
1369                 c_put_str(TERM_ORANGE, _("ひどく朦朧  ", "Heavy stun  "), ROW_STUN, COL_STUN);
1370                 return;
1371         }
1372
1373         if (s)
1374         {
1375                 c_put_str(TERM_ORANGE, _("朦朧        ", "Stun        "), ROW_STUN, COL_STUN);
1376                 return;
1377         }
1378
1379         put_str("            ", ROW_STUN, COL_STUN);
1380 }
1381
1382
1383 /*!
1384  * @brief モンスターの体力ゲージを表示する
1385  * @param riding TRUEならば騎乗中のモンスターの体力、FALSEならターゲットモンスターの体力を表示する。表示位置は固定。
1386  * @return なし
1387  * @details
1388  * <pre>
1389  * Redraw the "monster health bar"      -DRS-
1390  * Rather extensive modifications by    -BEN-
1391  *
1392  * The "monster health bar" provides visual feedback on the "health"
1393  * of the monster currently being "tracked".  There are several ways
1394  * to "track" a monster, including targetting it, attacking it, and
1395  * affecting it (and nobody else) with a ranged attack.
1396  *
1397  * Display the monster health bar (affectionately known as the
1398  * "health-o-meter").  Clear health bar if nothing is being tracked.
1399  * Auto-track current target monster when bored.  Note that the
1400  * health-bar stops tracking any monster that "disappears".
1401  * </pre>
1402  */
1403 static void health_redraw(player_type *creature_ptr, bool riding)
1404 {
1405         s16b health_who;
1406         int row, col;
1407
1408         if (riding)
1409         {
1410                 health_who = creature_ptr->riding;
1411                 row = ROW_RIDING_INFO;
1412                 col = COL_RIDING_INFO;
1413         }
1414         else
1415         {
1416                 health_who = creature_ptr->health_who;
1417                 row = ROW_INFO;
1418                 col = COL_INFO;
1419         }
1420
1421         monster_type *m_ptr;
1422         m_ptr = &creature_ptr->current_floor_ptr->m_list[health_who];
1423
1424         if (current_world_ptr->wizard && creature_ptr->phase_out)
1425         {
1426                 row = ROW_INFO - 2;
1427                 col = COL_INFO + 2;
1428
1429                 Term_putstr(col - 2, row, 12, TERM_WHITE, "      /     ");
1430                 Term_putstr(col - 2, row + 1, 12, TERM_WHITE, "      /     ");
1431                 Term_putstr(col - 2, row + 2, 12, TERM_WHITE, "      /     ");
1432                 Term_putstr(col - 2, row + 3, 12, TERM_WHITE, "      /     ");
1433
1434                 if (creature_ptr->current_floor_ptr->m_list[1].r_idx)
1435                 {
1436                         Term_putstr(col - 2, row, 2, r_info[creature_ptr->current_floor_ptr->m_list[1].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[1].r_idx].x_char));
1437                         Term_putstr(col - 1, row, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[1].hp));
1438                         Term_putstr(col + 5, row, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[1].max_maxhp));
1439                 }
1440
1441                 if (creature_ptr->current_floor_ptr->m_list[2].r_idx)
1442                 {
1443                         Term_putstr(col - 2, row + 1, 2, r_info[creature_ptr->current_floor_ptr->m_list[2].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[2].r_idx].x_char));
1444                         Term_putstr(col - 1, row + 1, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[2].hp));
1445                         Term_putstr(col + 5, row + 1, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[2].max_maxhp));
1446                 }
1447
1448                 if (creature_ptr->current_floor_ptr->m_list[3].r_idx)
1449                 {
1450                         Term_putstr(col - 2, row + 2, 2, r_info[creature_ptr->current_floor_ptr->m_list[3].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[3].r_idx].x_char));
1451                         Term_putstr(col - 1, row + 2, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[3].hp));
1452                         Term_putstr(col + 5, row + 2, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[3].max_maxhp));
1453                 }
1454
1455                 if (creature_ptr->current_floor_ptr->m_list[4].r_idx)
1456                 {
1457                         Term_putstr(col - 2, row + 3, 2, r_info[creature_ptr->current_floor_ptr->m_list[4].r_idx].x_attr, format("%c", r_info[creature_ptr->current_floor_ptr->m_list[4].r_idx].x_char));
1458                         Term_putstr(col - 1, row + 3, 5, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[4].hp));
1459                         Term_putstr(col + 5, row + 3, 6, TERM_WHITE, format("%5d", creature_ptr->current_floor_ptr->m_list[4].max_maxhp));
1460                 }
1461
1462                 return;
1463         }
1464
1465         /* Not tracking */
1466         if (!health_who)
1467         {
1468                 /* Erase the health bar */
1469                 Term_erase(col, row, 12);
1470                 return;
1471         }
1472
1473         /* Tracking an unseen monster */
1474         if (!m_ptr->ml)
1475         {
1476                 /* Indicate that the monster health is "unknown" */
1477                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1478                 return;
1479         }
1480
1481         /* Tracking a hallucinatory monster */
1482         if (creature_ptr->image)
1483         {
1484                 /* Indicate that the monster health is "unknown" */
1485                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1486                 return;
1487         }
1488
1489         /* Tracking a dead monster (???) */
1490         if (m_ptr->hp < 0)
1491         {
1492                 /* Indicate that the monster health is "unknown" */
1493                 Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1494                 return;
1495         }
1496
1497         /* Tracking a visible monster */
1498         /* Extract the "percent" of health */
1499         int pct = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->maxhp : 0;
1500         int pct2 = m_ptr->maxhp > 0 ? 100L * m_ptr->hp / m_ptr->max_maxhp : 0;
1501
1502         /* Convert percent into "health" */
1503         int len = (pct2 < 10) ? 1 : (pct2 < 90) ? (pct2 / 10 + 1) : 10;
1504
1505         /* Default to almost dead */
1506         TERM_COLOR attr = TERM_RED;
1507
1508         /* Invulnerable */
1509         if (monster_invulner_remaining(m_ptr)) attr = TERM_WHITE;
1510
1511         /* Asleep */
1512         else if (monster_csleep_remaining(m_ptr)) attr = TERM_BLUE;
1513
1514         /* Afraid */
1515         else if (monster_fear_remaining(m_ptr)) attr = TERM_VIOLET;
1516
1517         /* Healthy */
1518         else if (pct >= 100) attr = TERM_L_GREEN;
1519
1520         /* Somewhat Wounded */
1521         else if (pct >= 60) attr = TERM_YELLOW;
1522
1523         /* Wounded */
1524         else if (pct >= 25) attr = TERM_ORANGE;
1525
1526         /* Badly wounded */
1527         else if (pct >= 10) attr = TERM_L_RED;
1528
1529         /* Default to "unknown" */
1530         Term_putstr(col, row, 12, TERM_WHITE, "[----------]");
1531
1532         /* Dump the current "health" (use '*' symbols) */
1533         Term_putstr(col + 1, row, len, attr, "**********");
1534 }
1535
1536
1537
1538 /*!
1539  * @brief プレイヤーのステータスを一括表示する(左側部分) / Display basic info (mostly left of map)
1540  * @param creature_ptr プレーヤーへの参照ポインタ
1541  * @return なし
1542  */
1543 static void print_frame_basic(player_type *creature_ptr)
1544 {
1545         if (creature_ptr->mimic_form)
1546         {
1547                 print_field(mimic_info[creature_ptr->mimic_form].title, ROW_RACE, COL_RACE);
1548         }
1549         else
1550         {
1551                 char str[14];
1552                 angband_strcpy(str, rp_ptr->title, sizeof(str));
1553                 print_field(str, ROW_RACE, COL_RACE);
1554         }
1555
1556         print_title(creature_ptr);
1557         print_level(creature_ptr);
1558         print_exp(creature_ptr);
1559         for (int i = 0; i < A_MAX; i++)
1560                 print_stat(creature_ptr, i);
1561         print_ac(creature_ptr);
1562         print_hp(creature_ptr);
1563         print_sp(creature_ptr);
1564         print_gold(creature_ptr);
1565         print_depth(creature_ptr);
1566         health_redraw(creature_ptr, FALSE);
1567         health_redraw(creature_ptr, TRUE);
1568 }
1569
1570
1571 /*!
1572  * @brief プレイヤーのステータスを一括表示する(下部分) / Display extra info (mostly below map)
1573  * @param player_ptr プレーヤーへの参照ポインタ
1574  * @return なし
1575  */
1576 static void print_frame_extra(player_type *player_ptr)
1577 {
1578         print_cut(player_ptr);
1579         print_stun(player_ptr);
1580         print_hunger(player_ptr);
1581         print_state(player_ptr);
1582         print_speed(player_ptr);
1583         print_study(player_ptr);
1584         print_imitation(player_ptr);
1585         print_status(player_ptr);
1586 }
1587
1588
1589 /*!
1590  * @brief サブウィンドウに所持品一覧を表示する / Hack -- display inventory in sub-windows
1591  * @param player_ptr プレーヤーへの参照ポインタ
1592  * @return なし
1593  */
1594 static void fix_inventory(player_type *player_ptr, tval_type item_tester_tval)
1595 {
1596         /* Scan windows */
1597         for (int j = 0; j < 8; j++)
1598         {
1599                 term *old = Term;
1600
1601                 /* No window */
1602                 if (!angband_term[j]) continue;
1603
1604                 /* No relevant flags */
1605                 if (!(window_flag[j] & (PW_INVEN))) continue;
1606
1607                 /* Activate */
1608                 Term_activate(angband_term[j]);
1609
1610                 display_inventory(player_ptr, item_tester_tval);
1611                 Term_fresh();
1612                 Term_activate(old);
1613         }
1614 }
1615
1616
1617 /*!
1618  * @brief モンスターの現在数を一行で表現する / Print monster info in line
1619  * @param x 表示列
1620  * @param y 表示行
1621  * @param m_ptr 思い出を表示するモンスター情報の参照ポインタ
1622  * @param n_same モンスターの数の現在数
1623  * @details
1624  * <pre>
1625  * nnn X LV name
1626  *  nnn : number or unique(U) or wanted unique(W)
1627  *  X   : symbol of monster
1628  *  LV  : monster lv if known
1629  *  name: name of monster
1630  * @return なし
1631  * </pre>
1632  */
1633 static void print_monster_line(TERM_LEN x, TERM_LEN y, monster_type* m_ptr, int n_same) {
1634         char buf[256];
1635         MONRACE_IDX r_idx = m_ptr->ap_r_idx;
1636         monster_race* r_ptr = &r_info[r_idx];
1637
1638         Term_gotoxy(x, y);
1639         if (!r_ptr)return;
1640         //Number of 'U'nique
1641         //unique
1642         if (r_ptr->flags1 & RF1_UNIQUE)
1643         {
1644                 bool is_bounty = FALSE;
1645                 for (int i = 0; i < MAX_BOUNTY; i++)
1646                 {
1647                         if (current_world_ptr->bounty_r_idx[i] == r_idx)
1648                         {
1649                                 is_bounty = TRUE;
1650                                 break;
1651                         }
1652                 }
1653
1654                 Term_addstr(-1, TERM_WHITE, is_bounty ? "  W" : "  U");
1655         }
1656         else
1657         {
1658                 sprintf(buf, "%3d", n_same);
1659                 Term_addstr(-1, TERM_WHITE, buf);
1660         }
1661
1662         //symbol
1663         Term_addstr(-1, TERM_WHITE, " ");
1664         Term_add_bigch(r_ptr->x_attr, r_ptr->x_char);
1665
1666         //LV
1667         if (r_ptr->r_tkills && !(m_ptr->mflag2 & MFLAG2_KAGE))
1668         {
1669                 sprintf(buf, " %2d", (int)r_ptr->level);
1670         }
1671         else
1672         {
1673                 strcpy(buf, " ??");
1674         }
1675
1676         Term_addstr(-1, TERM_WHITE, buf);
1677
1678         //name
1679         sprintf(buf, " %s ", r_name + r_ptr->name);
1680         Term_addstr(-1, TERM_WHITE, buf);
1681 }
1682
1683
1684 /*!
1685  * @brief モンスターの出現リストを表示する / Print monster info in line
1686  * @param x 表示列
1687  * @param y 表示行
1688  * @param max_lines 最大何行描画するか
1689  */
1690 void print_monster_list(floor_type *floor_ptr, TERM_LEN x, TERM_LEN y, TERM_LEN max_lines) {
1691         TERM_LEN line = y;
1692         monster_type* last_mons = NULL;
1693         monster_type* m_ptr = NULL;
1694         int n_same = 0;
1695         int i;
1696         for (i = 0; i < tmp_pos.n; i++)
1697         {
1698                 grid_type* g_ptr = &floor_ptr->grid_array[tmp_pos.y[i]][tmp_pos.x[i]];
1699                 if (!g_ptr->m_idx || !floor_ptr->m_list[g_ptr->m_idx].ml)
1700                         continue;//no mons or cannot look
1701                 m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
1702                 if (is_pet(m_ptr)) continue;//pet
1703                 if (!m_ptr->r_idx) continue;//dead?
1704
1705                 //ソート済みなので同じモンスターは連続する.これを利用して同じモンスターをカウント,まとめて表示する.
1706
1707                 //先頭モンスター
1708                 if (!last_mons)
1709                 {
1710                         last_mons = m_ptr;
1711                         n_same = 1;
1712                         continue;
1713                 }
1714
1715                 //same race?
1716                 if (last_mons->ap_r_idx == m_ptr->ap_r_idx)
1717                 {
1718                         n_same++;
1719                         continue;//表示処理を次に回す
1720                 }
1721
1722                 //print last mons info
1723                 print_monster_line(x, line++, last_mons, n_same);
1724                 n_same = 1;
1725                 last_mons = m_ptr;
1726                 if (line - y - 1 == max_lines) break;
1727         }
1728
1729         if (line - y - 1 == max_lines && i != tmp_pos.n)
1730         {
1731                 Term_gotoxy(x, line);
1732                 Term_addstr(-1, TERM_WHITE, "-- and more --");
1733         }
1734         else
1735         {
1736                 if (last_mons)
1737                         print_monster_line(x, line++, last_mons, n_same);
1738         }
1739 }
1740
1741
1742 /*!
1743  * @brief 出現中モンスターのリストをサブウィンドウに表示する / Hack -- display monster list in sub-windows
1744  * @param player_ptr プレーヤーへの参照ポインタ
1745  * @return なし
1746  */
1747 static void fix_monster_list(player_type *player_ptr)
1748 {
1749         /* Scan windows */
1750         for (int j = 0; j < 8; j++)
1751         {
1752                 term *old = Term;
1753
1754                 /* No window */
1755                 if (!angband_term[j]) continue;
1756
1757                 /* No relevant flags */
1758                 if (!(window_flag[j] & (PW_MONSTER_LIST))) continue;
1759
1760                 /* Activate */
1761                 Term_activate(angband_term[j]);
1762                 int w, h;
1763                 Term_get_size(&w, &h);
1764
1765                 Term_clear();
1766
1767                 target_set_prepare_look(player_ptr);//モンスター一覧を生成,ソート
1768                 print_monster_list(player_ptr->current_floor_ptr, 0, 0, h);
1769                 Term_fresh();
1770                 Term_activate(old);
1771         }
1772 }
1773
1774
1775 /*!
1776  * @brief 現在の装備品をサブウィンドウに表示する /
1777  * Hack -- display equipment in sub-windows
1778  * @param player_ptr プレーヤーへの参照ポインタ
1779  * @return なし
1780  */
1781 static void fix_equip(player_type *player_ptr, tval_type item_tester_tval)
1782 {
1783         /* Scan windows */
1784         for (int j = 0; j < 8; j++)
1785         {
1786                 term *old = Term;
1787
1788                 /* No window */
1789                 if (!angband_term[j]) continue;
1790
1791                 /* No relevant flags */
1792                 if (!(window_flag[j] & (PW_EQUIP))) continue;
1793
1794                 /* Activate */
1795                 Term_activate(angband_term[j]);
1796
1797                 /* Display equipment */
1798                 display_equipment(player_ptr, item_tester_tval);
1799                 Term_fresh();
1800                 Term_activate(old);
1801         }
1802 }
1803
1804
1805 /*!
1806  * @brief 現在の習得済魔法をサブウィンドウに表示する /
1807  * @param player_ptr プレーヤーへの参照ポインタ
1808  * Hack -- display spells in sub-windows
1809  * @return なし
1810  */
1811 static void fix_spell(player_type *player_ptr)
1812 {
1813         /* Scan windows */
1814         for (int j = 0; j < 8; j++)
1815         {
1816                 term *old = Term;
1817
1818                 /* No window */
1819                 if (!angband_term[j]) continue;
1820
1821                 /* No relevant flags */
1822                 if (!(window_flag[j] & (PW_SPELL))) continue;
1823
1824                 /* Activate */
1825                 Term_activate(angband_term[j]);
1826
1827                 /* Display spell list */
1828                 display_spell_list(player_ptr);
1829                 Term_fresh();
1830                 Term_activate(old);
1831         }
1832 }
1833
1834
1835 /*!
1836  * @brief 現在のプレイヤーステータスをサブウィンドウに表示する /
1837  * @param player_ptr プレーヤーへの参照ポインタ
1838  * Hack -- display character in sub-windows
1839  * @return なし
1840  */
1841 static void fix_player(player_type *player_ptr)
1842 {
1843         /* Scan windows */
1844         for (int j = 0; j < 8; j++)
1845         {
1846                 term *old = Term;
1847
1848                 /* No window */
1849                 if (!angband_term[j]) continue;
1850
1851                 /* No relevant flags */
1852                 if (!(window_flag[j] & (PW_PLAYER))) continue;
1853
1854                 /* Activate */
1855                 Term_activate(angband_term[j]);
1856
1857                 update_playtime();
1858                 display_player(player_ptr, 0, map_name);
1859                 Term_fresh();
1860                 Term_activate(old);
1861         }
1862 }
1863
1864
1865 /*!
1866  * @brief ゲームメッセージ履歴をサブウィンドウに表示する /
1867  * Hack -- display recent messages in sub-windows
1868  * Adjust for width and split messages
1869  * @return なし
1870  */
1871 static void fix_message(void)
1872 {
1873         /* Scan windows */
1874         for (int j = 0; j < 8; j++)
1875         {
1876                 term *old = Term;
1877
1878                 /* No window */
1879                 if (!angband_term[j]) continue;
1880
1881                 /* No relevant flags */
1882                 if (!(window_flag[j] & (PW_MESSAGE))) continue;
1883
1884                 /* Activate */
1885                 Term_activate(angband_term[j]);
1886
1887                 TERM_LEN w, h;
1888                 Term_get_size(&w, &h);
1889
1890                 /* Dump messages */
1891                 for (int i = 0; i < h; i++)
1892                 {
1893                         /* Dump the message on the appropriate line */
1894                         Term_putstr(0, (h - 1) - i, -1, (byte)((i < now_message) ? TERM_WHITE : TERM_SLATE), message_str((s16b)i));
1895
1896                         /* Cursor */
1897                         TERM_LEN x, y;
1898                         Term_locate(&x, &y);
1899
1900                         /* Clear to end of line */
1901                         Term_erase(x, y, 255);
1902                 }
1903
1904                 Term_fresh();
1905                 Term_activate(old);
1906         }
1907 }
1908
1909
1910 /*!
1911  * @brief 簡易マップをサブウィンドウに表示する /
1912  * Hack -- display overhead view in sub-windows
1913  * Adjust for width and split messages
1914  * @param player_ptr プレーヤーへの参照ポインタ
1915  * @return なし
1916  * @details
1917  * Note that the "player" symbol does NOT appear on the map.
1918  */
1919 static void fix_overhead(player_type *player_ptr)
1920 {
1921         /* Scan windows */
1922         for (int j = 0; j < 8; j++)
1923         {
1924                 term *old = Term;
1925                 TERM_LEN wid, hgt;
1926
1927                 /* No window */
1928                 if (!angband_term[j]) continue;
1929
1930                 /* No relevant flags */
1931                 if (!(window_flag[j] & (PW_OVERHEAD))) continue;
1932
1933                 /* Activate */
1934                 Term_activate(angband_term[j]);
1935
1936                 /* Full map in too small window is useless  */
1937                 Term_get_size(&wid, &hgt);
1938                 if (wid > COL_MAP + 2 && hgt > ROW_MAP + 2)
1939                 {
1940                         int cy, cx;
1941                         display_map(player_ptr, &cy, &cx);
1942                         Term_fresh();
1943                 }
1944
1945                 Term_activate(old);
1946         }
1947 }
1948
1949 static void display_dungeon(player_type *player_ptr)
1950 {
1951         TERM_COLOR ta = 0;
1952         SYMBOL_CODE tc = '\0';
1953
1954         for (TERM_LEN x = player_ptr->x - Term->wid / 2 + 1; x <= player_ptr->x + Term->wid / 2; x++)
1955         {
1956                 for (TERM_LEN y = player_ptr->y - Term->hgt / 2 + 1; y <= player_ptr->y + Term->hgt / 2; y++)
1957                 {
1958                         TERM_COLOR a;
1959                         SYMBOL_CODE c;
1960                         if (!in_bounds2(player_ptr->current_floor_ptr, y, x))
1961                         {
1962                                 feature_type *f_ptr = &f_info[feat_none];
1963                                 a = f_ptr->x_attr[F_LIT_STANDARD];
1964                                 c = f_ptr->x_char[F_LIT_STANDARD];
1965                                 Term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
1966                                 continue;
1967                         }
1968
1969                         map_info(player_ptr, y, x, &a, &c, &ta, &tc);
1970
1971                         if (!use_graphics)
1972                         {
1973                                 if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
1974                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) a = TERM_WHITE;
1975                                 else if (player_ptr->wraith_form) a = TERM_L_DARK;
1976                         }
1977
1978                         Term_queue_char(x - player_ptr->x + Term->wid / 2 - 1, y - player_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
1979                 }
1980         }
1981 }
1982
1983 /*!
1984  * @brief ダンジョンの地形をサブウィンドウに表示する /
1985  * Hack -- display dungeon view in sub-windows
1986  * @param player_ptr プレーヤーへの参照ポインタ
1987  * @return なし
1988  */
1989 static void fix_dungeon(player_type *player_ptr)
1990 {
1991         /* Scan windows */
1992         for (int j = 0; j < 8; j++)
1993         {
1994                 term *old = Term;
1995
1996                 /* No window */
1997                 if (!angband_term[j]) continue;
1998
1999                 /* No relevant flags */
2000                 if (!(window_flag[j] & (PW_DUNGEON))) continue;
2001
2002                 /* Activate */
2003                 Term_activate(angband_term[j]);
2004
2005                 /* Redraw dungeon view */
2006                 display_dungeon(player_ptr);
2007                 Term_fresh();
2008                 Term_activate(old);
2009         }
2010 }
2011
2012
2013 /*!
2014  * @brief モンスターの思い出をサブウィンドウに表示する /
2015  * Hack -- display dungeon view in sub-windows
2016  * @param player_ptr プレーヤーへの参照ポインタ
2017  * @return なし
2018  */
2019 static void fix_monster(player_type *player_ptr)
2020 {
2021         /* Scan windows */
2022         for (int j = 0; j < 8; j++)
2023         {
2024                 term *old = Term;
2025
2026                 /* No window */
2027                 if (!angband_term[j]) continue;
2028
2029                 /* No relevant flags */
2030                 if (!(window_flag[j] & (PW_MONSTER))) continue;
2031
2032                 /* Activate */
2033                 Term_activate(angband_term[j]);
2034
2035                 /* Display monster race info */
2036                 if (player_ptr->monster_race_idx) display_roff(player_ptr);
2037                 Term_fresh();
2038                 Term_activate(old);
2039         }
2040 }
2041
2042
2043 /*!
2044  * @brief ベースアイテム情報をサブウィンドウに表示する /
2045  * Hack -- display object recall in sub-windows
2046  * @param player_ptr プレーヤーへの参照ポインタ
2047  * @return なし
2048  */
2049 static void fix_object(player_type *player_ptr)
2050 {
2051         /* Scan windows */
2052         for (int j = 0; j < 8; j++)
2053         {
2054                 term *old = Term;
2055
2056                 /* No window */
2057                 if (!angband_term[j]) continue;
2058
2059                 /* No relevant flags */
2060                 if (!(window_flag[j] & (PW_OBJECT))) continue;
2061
2062                 /* Activate */
2063                 Term_activate(angband_term[j]);
2064
2065                 /* Display monster race info */
2066                 if (player_ptr->object_kind_idx) display_koff(player_ptr, player_ptr->object_kind_idx);
2067                 Term_fresh();
2068                 Term_activate(old);
2069         }
2070 }
2071
2072
2073 /*!
2074  * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
2075  * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
2076  * @return 重すぎるならばTRUE
2077  */
2078 bool is_heavy_shoot(player_type *creature_ptr, object_type *o_ptr)
2079 {
2080         int hold = adj_str_hold[creature_ptr->stat_ind[A_STR]];
2081         /* It is hard to carholdry a heavy bow */
2082         return (hold < o_ptr->weight / 10);
2083 }
2084
2085
2086 /*!
2087  * @brief redraw のフラグに応じた更新をまとめて行う / Handle "redraw"
2088  * @return なし
2089  * @details 更新処理の対象はゲーム中の全描画処理
2090  */
2091 void redraw_stuff(player_type *creature_ptr)
2092 {
2093         if (!creature_ptr->redraw) return;
2094
2095         /* Character is not ready yet, no screen updates */
2096         if (!current_world_ptr->character_generated) return;
2097
2098         /* Character is in "icky" mode, no screen updates */
2099         if (current_world_ptr->character_icky) return;
2100
2101         /* Hack -- clear the screen */
2102         if (creature_ptr->redraw & (PR_WIPE))
2103         {
2104                 creature_ptr->redraw &= ~(PR_WIPE);
2105                 msg_print(NULL);
2106                 Term_clear();
2107         }
2108
2109         if (creature_ptr->redraw & (PR_MAP))
2110         {
2111                 creature_ptr->redraw &= ~(PR_MAP);
2112                 print_map(creature_ptr);
2113         }
2114
2115         if (creature_ptr->redraw & (PR_BASIC))
2116         {
2117                 creature_ptr->redraw &= ~(PR_BASIC);
2118                 creature_ptr->redraw &= ~(PR_MISC | PR_TITLE | PR_STATS);
2119                 creature_ptr->redraw &= ~(PR_LEV | PR_EXP | PR_GOLD);
2120                 creature_ptr->redraw &= ~(PR_ARMOR | PR_HP | PR_MANA);
2121                 creature_ptr->redraw &= ~(PR_DEPTH | PR_HEALTH | PR_UHEALTH);
2122                 print_frame_basic(creature_ptr);
2123                 print_time(creature_ptr);
2124                 print_dungeon(creature_ptr);
2125         }
2126
2127         if (creature_ptr->redraw & (PR_EQUIPPY))
2128         {
2129                 creature_ptr->redraw &= ~(PR_EQUIPPY);
2130                 print_equippy(creature_ptr); /* To draw / delete equippy chars */
2131         }
2132
2133         if (creature_ptr->redraw & (PR_MISC))
2134         {
2135                 creature_ptr->redraw &= ~(PR_MISC);
2136                 print_field(rp_ptr->title, ROW_RACE, COL_RACE);
2137         }
2138
2139         if (creature_ptr->redraw & (PR_TITLE))
2140         {
2141                 creature_ptr->redraw &= ~(PR_TITLE);
2142                 print_title(creature_ptr);
2143         }
2144
2145         if (creature_ptr->redraw & (PR_LEV))
2146         {
2147                 creature_ptr->redraw &= ~(PR_LEV);
2148                 print_level(creature_ptr);
2149         }
2150
2151         if (creature_ptr->redraw & (PR_EXP))
2152         {
2153                 creature_ptr->redraw &= ~(PR_EXP);
2154                 print_exp(creature_ptr);
2155         }
2156
2157         if (creature_ptr->redraw & (PR_STATS))
2158         {
2159                 creature_ptr->redraw &= ~(PR_STATS);
2160                 print_stat(creature_ptr, A_STR);
2161                 print_stat(creature_ptr, A_INT);
2162                 print_stat(creature_ptr, A_WIS);
2163                 print_stat(creature_ptr, A_DEX);
2164                 print_stat(creature_ptr, A_CON);
2165                 print_stat(creature_ptr, A_CHR);
2166         }
2167
2168         if (creature_ptr->redraw & (PR_STATUS))
2169         {
2170                 creature_ptr->redraw &= ~(PR_STATUS);
2171                 print_status(creature_ptr);
2172         }
2173
2174         if (creature_ptr->redraw & (PR_ARMOR))
2175         {
2176                 creature_ptr->redraw &= ~(PR_ARMOR);
2177                 print_ac(creature_ptr);
2178         }
2179
2180         if (creature_ptr->redraw & (PR_HP))
2181         {
2182                 creature_ptr->redraw &= ~(PR_HP);
2183                 print_hp(creature_ptr);
2184         }
2185
2186         if (creature_ptr->redraw & (PR_MANA))
2187         {
2188                 creature_ptr->redraw &= ~(PR_MANA);
2189                 print_sp(creature_ptr);
2190         }
2191
2192         if (creature_ptr->redraw & (PR_GOLD))
2193         {
2194                 creature_ptr->redraw &= ~(PR_GOLD);
2195                 print_gold(creature_ptr);
2196         }
2197
2198         if (creature_ptr->redraw & (PR_DEPTH))
2199         {
2200                 creature_ptr->redraw &= ~(PR_DEPTH);
2201                 print_depth(creature_ptr);
2202         }
2203
2204         if (creature_ptr->redraw & (PR_HEALTH))
2205         {
2206                 creature_ptr->redraw &= ~(PR_HEALTH);
2207                 health_redraw(creature_ptr, FALSE);
2208         }
2209
2210         if (creature_ptr->redraw & (PR_UHEALTH))
2211         {
2212                 creature_ptr->redraw &= ~(PR_UHEALTH);
2213                 health_redraw(creature_ptr, TRUE);
2214         }
2215
2216         if (creature_ptr->redraw & (PR_EXTRA))
2217         {
2218                 creature_ptr->redraw &= ~(PR_EXTRA);
2219                 creature_ptr->redraw &= ~(PR_CUT | PR_STUN);
2220                 creature_ptr->redraw &= ~(PR_HUNGER);
2221                 creature_ptr->redraw &= ~(PR_STATE | PR_SPEED | PR_STUDY | PR_IMITATION | PR_STATUS);
2222                 print_frame_extra(creature_ptr);
2223         }
2224
2225         if (creature_ptr->redraw & (PR_CUT))
2226         {
2227                 creature_ptr->redraw &= ~(PR_CUT);
2228                 print_cut(creature_ptr);
2229         }
2230
2231         if (creature_ptr->redraw & (PR_STUN))
2232         {
2233                 creature_ptr->redraw &= ~(PR_STUN);
2234                 print_stun(creature_ptr);
2235         }
2236
2237         if (creature_ptr->redraw & (PR_HUNGER))
2238         {
2239                 creature_ptr->redraw &= ~(PR_HUNGER);
2240                 print_hunger(creature_ptr);
2241         }
2242
2243         if (creature_ptr->redraw & (PR_STATE))
2244         {
2245                 creature_ptr->redraw &= ~(PR_STATE);
2246                 print_state(creature_ptr);
2247         }
2248
2249         if (creature_ptr->redraw & (PR_SPEED))
2250         {
2251                 creature_ptr->redraw &= ~(PR_SPEED);
2252                 print_speed(creature_ptr);
2253         }
2254
2255         if (creature_ptr->pclass == CLASS_IMITATOR)
2256         {
2257                 if (creature_ptr->redraw & (PR_IMITATION))
2258                 {
2259                         creature_ptr->redraw &= ~(PR_IMITATION);
2260                         print_imitation(creature_ptr);
2261                 }
2262
2263                 return;
2264         }
2265
2266         if (creature_ptr->redraw & (PR_STUDY))
2267         {
2268                 creature_ptr->redraw &= ~(PR_STUDY);
2269                 print_study(creature_ptr);
2270         }
2271 }
2272
2273
2274 /*!
2275  * @brief player_ptr->window のフラグに応じた更新をまとめて行う / Handle "player_ptr->window"
2276  * @param player_ptr プレーヤーへの参照ポインタ
2277  * @return なし
2278  * @details 更新処理の対象はサブウィンドウ全般
2279  */
2280 void window_stuff(player_type *player_ptr)
2281 {
2282         if (!player_ptr->window) return;
2283
2284         /* Scan windows */
2285         BIT_FLAGS mask = 0L;
2286         for (int j = 0; j < 8; j++)
2287         {
2288                 /* Save usable flags */
2289                 if (angband_term[j]) mask |= window_flag[j];
2290         }
2291
2292         /* Apply usable flags */
2293         player_ptr->window &= mask;
2294
2295         /* Nothing to do */
2296         if (!player_ptr->window) return;
2297
2298         if (player_ptr->window & (PW_INVEN))
2299         {
2300                 player_ptr->window &= ~(PW_INVEN);
2301                 fix_inventory(player_ptr, 0); // TODO:2.2.2 まともなtval参照手段を確保
2302         }
2303
2304         /* Display equipment */
2305         if (player_ptr->window & (PW_EQUIP))
2306         {
2307                 player_ptr->window &= ~(PW_EQUIP);
2308                 fix_equip(player_ptr, 0);  // TODO:2.2.2 まともなtval参照手段を確保
2309         }
2310
2311         /* Display spell list */
2312         if (player_ptr->window & (PW_SPELL))
2313         {
2314                 player_ptr->window &= ~(PW_SPELL);
2315                 fix_spell(player_ptr);
2316         }
2317
2318         /* Display player */
2319         if (player_ptr->window & (PW_PLAYER))
2320         {
2321                 player_ptr->window &= ~(PW_PLAYER);
2322                 fix_player(player_ptr);
2323         }
2324
2325         /* Display monster list */
2326         if (player_ptr->window & (PW_MONSTER_LIST))
2327         {
2328                 player_ptr->window &= ~(PW_MONSTER_LIST);
2329                 fix_monster_list(player_ptr);
2330         }
2331
2332         /* Display overhead view */
2333         if (player_ptr->window & (PW_MESSAGE))
2334         {
2335                 player_ptr->window &= ~(PW_MESSAGE);
2336                 fix_message();
2337         }
2338
2339         /* Display overhead view */
2340         if (player_ptr->window & (PW_OVERHEAD))
2341         {
2342                 player_ptr->window &= ~(PW_OVERHEAD);
2343                 fix_overhead(player_ptr);
2344         }
2345
2346         /* Display overhead view */
2347         if (player_ptr->window & (PW_DUNGEON))
2348         {
2349                 player_ptr->window &= ~(PW_DUNGEON);
2350                 fix_dungeon(player_ptr);
2351         }
2352
2353         /* Display monster recall */
2354         if (player_ptr->window & (PW_MONSTER))
2355         {
2356                 player_ptr->window &= ~(PW_MONSTER);
2357                 fix_monster(player_ptr);
2358         }
2359
2360         /* Display object recall */
2361         if (player_ptr->window & (PW_OBJECT))
2362         {
2363                 player_ptr->window &= ~(PW_OBJECT);
2364                 fix_object(player_ptr);
2365         }
2366 }
2367
2368
2369 /*!
2370  * todo ここにplayer_type を追加するとz-termに影響が行くので保留
2371  * @brief コンソールのリサイズに合わせてマップを再描画する /
2372  * Map resizing whenever the main term changes size
2373  * @return なし
2374  */
2375 void resize_map()
2376 {
2377         /* Only if the dungeon exists */
2378         if (!current_world_ptr->character_dungeon) return;
2379
2380         /* Mega-Hack -- no panel yet */
2381         panel_row_max = 0;
2382         panel_col_max = 0;
2383
2384         /* Reset the panels */
2385         panel_row_min = p_ptr->current_floor_ptr->height;
2386         panel_col_min = p_ptr->current_floor_ptr->width;
2387
2388         verify_panel(p_ptr);
2389
2390         p_ptr->update |= (PU_TORCH | PU_BONUS | PU_HP | PU_MANA | PU_SPELLS);
2391         p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
2392         p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
2393         p_ptr->update |= (PU_MONSTERS);
2394         p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP | PR_EQUIPPY);
2395
2396         handle_stuff(p_ptr);
2397         Term_redraw();
2398
2399         /*
2400          * Waiting command;
2401          * Place the cursor on the player
2402          */
2403         if (can_save) move_cursor_relative(p_ptr->y, p_ptr->x);
2404
2405         Term_fresh();
2406 }
2407
2408
2409 /*!
2410  * todo ここにplayer_type を追加するとz-termに影響が行くので保留
2411  * @brief コンソールを再描画する /
2412  * Redraw a term when it is resized
2413  * @return なし
2414  */
2415 void redraw_window(void)
2416 {
2417         /* Only if the dungeon exists */
2418         if (!current_world_ptr->character_dungeon) return;
2419
2420         p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_SPELL | PW_PLAYER);
2421         p_ptr->window |= (PW_MESSAGE | PW_OVERHEAD | PW_DUNGEON | PW_MONSTER | PW_OBJECT);
2422
2423         handle_stuff(p_ptr);
2424         Term_redraw();
2425 }
2426
2427
2428 /*!
2429  * @brief フォーカスを当てるべきマップ描画の基準座標を指定する(サブルーチン)
2430  * @param creature_ptr プレーヤーへの参照ポインタ
2431  * @param dy 変更先のフロアY座標
2432  * @param dx 変更先のフロアX座標
2433  * Handle a request to change the current panel
2434  * Return TRUE if the panel was changed.
2435  * Also used in do_cmd_locate
2436  * @return 実際に再描画が必要だった場合TRUEを返す
2437  */
2438 bool change_panel(player_type *player_ptr, POSITION dy, POSITION dx)
2439 {
2440         TERM_LEN wid, hgt;
2441         get_screen_size(&wid, &hgt);
2442
2443         /* Apply the motion */
2444         POSITION y = panel_row_min + dy * hgt / 2;
2445         POSITION x = panel_col_min + dx * wid / 2;
2446
2447         /* Verify the row */
2448         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2449         if (y > floor_ptr->height - hgt) y = floor_ptr->height - hgt;
2450         if (y < 0) y = 0;
2451
2452         /* Verify the col */
2453         if (x > floor_ptr->width - wid) x = floor_ptr->width - wid;
2454         if (x < 0) x = 0;
2455
2456         if ((y == panel_row_min) && (x == panel_col_min))
2457                 return FALSE;
2458
2459         panel_row_min = y;
2460         panel_col_min = x;
2461         panel_bounds_center();
2462
2463         player_ptr->update |= (PU_MONSTERS);
2464         player_ptr->redraw |= (PR_MAP);
2465         handle_stuff(player_ptr);
2466         return TRUE;
2467 }
2468
2469
2470 /*!
2471  * @brief プレイヤーの装備一覧シンボルを固定位置に表示する
2472  * @param creature_ptr プレーヤーへの参照ポインタ
2473  * @return なし
2474  */
2475 void print_equippy(player_type *creature_ptr)
2476 {
2477         display_player_equippy(creature_ptr, ROW_EQUIPPY, COL_EQUIPPY, 0);
2478 }
2479
2480
2481 /*!
2482  * @brief 現在のコンソール表示の縦横を返す。 /
2483  * Get term size and calculate screen size
2484  * @param wid_p コンソールの表示幅文字数を返す
2485  * @param hgt_p コンソールの表示行数を返す
2486  * @return なし
2487  */
2488 void get_screen_size(TERM_LEN *wid_p, TERM_LEN *hgt_p)
2489 {
2490         Term_get_size(wid_p, hgt_p);
2491         *hgt_p -= ROW_MAP + 2;
2492         *wid_p -= COL_MAP + 2;
2493         if (use_bigtile) *wid_p /= 2;
2494 }
2495
2496
2497 /*
2498  * Calculate panel colum of a location in the map
2499  */
2500 int panel_col_of(int col)
2501 {
2502         col -= panel_col_min;
2503         if (use_bigtile) col *= 2;
2504         return col + 13;
2505 }
2506
2507
2508 /*
2509  * Prints the map of the dungeon
2510  *
2511  * Note that, for efficiency, we contain an "optimized" version
2512  * of both "lite_spot()" and "print_rel()", and that we use the
2513  * "lite_spot()" function to display the player grid, if needed.
2514  */
2515 void print_map(player_type *player_ptr)
2516 {
2517         TERM_LEN wid, hgt;
2518         Term_get_size(&wid, &hgt);
2519
2520         /* Remove map offset */
2521         wid -= COL_MAP + 2;
2522         hgt -= ROW_MAP + 2;
2523
2524         /* Access the cursor state */
2525         int v;
2526         (void)Term_get_cursor(&v);
2527
2528         /* Hide the cursor */
2529         (void)Term_set_cursor(0);
2530
2531         /* Get bounds */
2532         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2533         POSITION xmin = (0 < panel_col_min) ? panel_col_min : 0;
2534         POSITION xmax = (floor_ptr->width - 1 > panel_col_max) ? panel_col_max : floor_ptr->width - 1;
2535         POSITION ymin = (0 < panel_row_min) ? panel_row_min : 0;
2536         POSITION ymax = (floor_ptr->height - 1 > panel_row_max) ? panel_row_max : floor_ptr->height - 1;
2537
2538         /* Bottom section of screen */
2539         for (POSITION y = 1; y <= ymin - panel_row_prt; y++)
2540         {
2541                 /* Erase the section */
2542                 Term_erase(COL_MAP, y, wid);
2543         }
2544
2545         /* Top section of screen */
2546         for (POSITION y = ymax - panel_row_prt; y <= hgt; y++)
2547         {
2548                 /* Erase the section */
2549                 Term_erase(COL_MAP, y, wid);
2550         }
2551
2552         /* Dump the map */
2553         for (POSITION y = ymin; y <= ymax; y++)
2554         {
2555                 /* Scan the columns of row "y" */
2556                 for (POSITION x = xmin; x <= xmax; x++)
2557                 {
2558                         TERM_COLOR a;
2559                         SYMBOL_CODE c;
2560
2561                         TERM_COLOR ta;
2562                         SYMBOL_CODE tc;
2563
2564                         /* Determine what is there */
2565                         map_info(player_ptr, y, x, &a, &c, &ta, &tc);
2566
2567                         /* Hack -- fake monochrome */
2568                         if (!use_graphics)
2569                         {
2570                                 if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
2571                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) a = TERM_WHITE;
2572                                 else if (player_ptr->wraith_form) a = TERM_L_DARK;
2573                         }
2574
2575                         /* Efficiency -- Redraw that grid of the map */
2576                         Term_queue_bigchar(panel_col_of(x), y - panel_row_prt, a, c, ta, tc);
2577                 }
2578         }
2579
2580         /* Display player */
2581         lite_spot(player_ptr, player_ptr->y, player_ptr->x);
2582
2583         /* Restore the cursor */
2584         (void)Term_set_cursor(v);
2585 }
2586
2587
2588 /*!
2589  * 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes
2590  */
2591 static char image_monster_hack[] = \
2592 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
2593
2594
2595 /*!
2596  * 一般的にオブジェクトシンボルとして扱われる記号を定義する(幻覚処理向け) /  Hack -- Legal object codes
2597  */
2598 static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
2599
2600
2601 /*!
2602  * @brief モンスターの表示を幻覚状態に差し替える / Mega-Hack -- Hallucinatory monster
2603  * @param ap 本来の色
2604  * @param cp 本来のシンボル
2605  * @return なし
2606  */
2607 static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
2608 {
2609         if (use_graphics)
2610         {
2611                 monster_race *r_ptr = &r_info[randint1(max_r_idx - 1)];
2612                 *cp = r_ptr->x_char;
2613                 *ap = r_ptr->x_attr;
2614                 return;
2615         }
2616
2617         *cp = (one_in_(25) ?
2618                 image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
2619                 image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
2620         *ap = randint1(15);
2621 }
2622
2623
2624 /*!
2625  * @brief オブジェクトの表示を幻覚状態に差し替える / Hallucinatory object
2626  * @param ap 本来の色
2627  * @param cp 本来のシンボル
2628  * @return なし
2629  */
2630 static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
2631 {
2632         if (use_graphics)
2633         {
2634                 object_kind *k_ptr = &k_info[randint1(max_k_idx - 1)];
2635                 *cp = k_ptr->x_char;
2636                 *ap = k_ptr->x_attr;
2637                 return;
2638         }
2639
2640         int n = sizeof(image_object_hack) - 1;
2641         *cp = image_object_hack[randint0(n)];
2642         *ap = randint1(15);
2643 }
2644
2645
2646 /*!
2647  * @brief オブジェクト&モンスターの表示を幻覚状態に差し替える / Hack -- Random hallucination
2648  * @param ap 本来の色
2649  * @param cp 本来のシンボル
2650  * @return なし
2651  */
2652 static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
2653 {
2654         /* Normally, assume monsters */
2655         if (randint0(100) < 75)
2656         {
2657                 image_monster(ap, cp);
2658         }
2659
2660         /* Otherwise, assume objects */
2661         else
2662         {
2663                 image_object(ap, cp);
2664         }
2665 }
2666
2667 /*!
2668  * 照明の表現を行うための色合いの関係を{暗闇時, 照明時} で定義する /
2669  * This array lists the effects of "brightness" on various "base" colours.\n
2670  *\n
2671  * This is used to do dynamic lighting effects in ascii :-)\n
2672  * At the moment, only the various "floor" tiles are affected.\n
2673  *\n
2674  * The layout of the array is [x][0] = light and [x][1] = dark.\n
2675  */
2676 static TERM_COLOR lighting_colours[16][2] =
2677 {
2678         /* TERM_DARK */
2679         {TERM_L_DARK, TERM_DARK},
2680
2681         /* TERM_WHITE */
2682         {TERM_YELLOW, TERM_SLATE},
2683
2684         /* TERM_SLATE */
2685         {TERM_WHITE, TERM_L_DARK},
2686
2687         /* TERM_ORANGE */
2688         {TERM_L_UMBER, TERM_UMBER},
2689
2690         /* TERM_RED */
2691         {TERM_RED, TERM_RED},
2692
2693         /* TERM_GREEN */
2694         {TERM_L_GREEN, TERM_GREEN},
2695
2696         /* TERM_BLUE */
2697         {TERM_BLUE, TERM_BLUE},
2698
2699         /* TERM_UMBER */
2700         {TERM_L_UMBER, TERM_RED},
2701
2702         /* TERM_L_DARK */
2703         {TERM_SLATE, TERM_L_DARK},
2704
2705         /* TERM_L_WHITE */
2706         {TERM_WHITE, TERM_SLATE},
2707
2708         /* TERM_VIOLET */
2709         {TERM_L_RED, TERM_BLUE},
2710
2711         /* TERM_YELLOW */
2712         {TERM_YELLOW, TERM_ORANGE},
2713
2714         /* TERM_L_RED */
2715         {TERM_L_RED, TERM_L_RED},
2716
2717         /* TERM_L_GREEN */
2718         {TERM_L_GREEN, TERM_GREEN},
2719
2720         /* TERM_L_BLUE */
2721         {TERM_L_BLUE, TERM_L_BLUE},
2722
2723         /* TERM_L_UMBER */
2724         {TERM_L_UMBER, TERM_UMBER}
2725 };
2726
2727
2728 /*!
2729  * @brief 調査中
2730  * @todo コメントを付加すること
2731  */
2732 void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_CODE f_char[F_LIT_MAX])
2733 {
2734         TERM_COLOR s_attr = f_attr[F_LIT_STANDARD];
2735         SYMBOL_CODE s_char = f_char[F_LIT_STANDARD];
2736
2737         if (IS_ASCII_GRAPHICS(s_attr)) /* For ASCII */
2738         {
2739                 f_attr[F_LIT_LITE] = lighting_colours[s_attr & 0x0f][0];
2740                 f_attr[F_LIT_DARK] = lighting_colours[s_attr & 0x0f][1];
2741                 for (int i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_char[i] = s_char;
2742         }
2743         else /* For tile graphics */
2744         {
2745                 for (int i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_attr[i] = s_attr;
2746                 f_char[F_LIT_LITE] = s_char + 2;
2747                 f_char[F_LIT_DARK] = s_char + 1;
2748         }
2749 }
2750
2751
2752 /*!
2753  * @brief Mコマンドによる縮小マップの表示を行う / Extract the attr/char to display at the given (legal) map location
2754  * @details
2755  * Basically, we "paint" the chosen attr/char in several passes, starting\n
2756  * with any known "terrain features" (defaulting to darkness), then adding\n
2757  * any known "objects", and finally, adding any known "monsters".  This\n
2758  * is not the fastest method but since most of the calls to this function\n
2759  * are made for grids with no monsters or objects, it is fast enough.\n
2760  *\n
2761  * Note that this function, if used on the grid containing the "player",\n
2762  * will return the attr/char of the grid underneath the player, and not\n
2763  * the actual player attr/char itself, allowing a lot of optimization\n
2764  * in various "display" functions.\n
2765  *\n
2766  * Note that the "zero" entry in the feature/object/monster arrays are\n
2767  * used to provide "special" attr/char codes, with "monster zero" being\n
2768  * used for the player attr/char, "object zero" being used for the "stack"\n
2769  * attr/char, and "feature zero" being used for the "nothing" attr/char,\n
2770  * though this function makes use of only "feature zero".\n
2771  *\n
2772  * Note that monsters can have some "special" flags, including "ATTR_MULTI",\n
2773  * which means their color changes, and "ATTR_CLEAR", which means they take\n
2774  * the color of whatever is under them, and "CHAR_CLEAR", which means that\n
2775  * they take the symbol of whatever is under them.  Technically, the flag\n
2776  * "CHAR_MULTI" is supposed to indicate that a monster looks strange when\n
2777  * examined, but this flag is currently ignored.\n
2778  *\n
2779  * Currently, we do nothing with multi-hued objects, because there are\n
2780  * not any.  If there were, they would have to set "shimmer_objects"\n
2781  * when they were created, and then new "shimmer" code in "dungeon.c"\n
2782  * would have to be created handle the "shimmer" effect, and the code\n
2783  * in floor would have to be updated to create the shimmer effect.\n
2784  *\n
2785  * Note the effects of hallucination.  Objects always appear as random\n
2786  * "objects", monsters as random "monsters", and normal grids occasionally\n
2787  * appear as random "monsters" or "objects", but note that these random\n
2788  * "monsters" and "objects" are really just "colored ascii symbols".\n
2789  *\n
2790  * Note that "floors" and "invisible traps" (and "zero" features) are\n
2791  * drawn as "floors" using a special check for optimization purposes,\n
2792  * and these are the only features which get drawn using the special\n
2793  * lighting effects activated by "view_special_lite".\n
2794  *\n
2795  * Note the use of the "mimic" field in the "terrain feature" processing,\n
2796  * which allows any feature to "pretend" to be another feature.  This is\n
2797  * used to "hide" secret doors, and to make all "doors" appear the same,\n
2798  * and all "walls" appear the same, and "hidden" treasure stay hidden.\n
2799  * It is possible to use this field to make a feature "look" like a floor,\n
2800  * but the "special lighting effects" for floors will not be used.\n
2801  *\n
2802  * Note the use of the new "terrain feature" information.  Note that the\n
2803  * assumption that all interesting "objects" and "terrain features" are\n
2804  * memorized allows extremely optimized processing below.  Note the use\n
2805  * of separate flags on objects to mark them as memorized allows a grid\n
2806  * to have memorized "terrain" without granting knowledge of any object\n
2807  * which may appear in that grid.\n
2808  *\n
2809  * Note the efficient code used to determine if a "floor" grid is\n
2810  * "memorized" or "viewable" by the player, where the test for the\n
2811  * grid being "viewable" is based on the facts that (1) the grid\n
2812  * must be "lit" (torch-lit or perma-lit), (2) the grid must be in\n
2813  * line of sight, and (3) the player must not be blind, and uses the\n
2814  * assumption that all torch-lit grids are in line of sight.\n
2815  *\n
2816  * Note that floors (and invisible traps) are the only grids which are\n
2817  * not memorized when seen, so only these grids need to check to see if\n
2818  * the grid is "viewable" to the player (if it is not memorized).  Since\n
2819  * most non-memorized grids are in fact walls, this induces *massive*\n
2820  * efficiency, at the cost of *forcing* the memorization of non-floor\n
2821  * grids when they are first seen.  Note that "invisible traps" are\n
2822  * always treated exactly like "floors", which prevents "cheating".\n
2823  *\n
2824  * Note the "special lighting effects" which can be activated for floor\n
2825  * grids using the "view_special_lite" option (for "white" floor grids),\n
2826  * causing certain grids to be displayed using special colors.  If the\n
2827  * player is "blind", we will use "dark gray", else if the grid is lit\n
2828  * by the torch, and the "view_yellow_lite" option is set, we will use\n
2829  * "yellow", else if the grid is "dark", we will use "dark gray", else\n
2830  * if the grid is not "viewable", and the "view_bright_lite" option is\n
2831  * set, and the we will use "slate" (gray).  We will use "white" for all\n
2832  * other cases, in particular, for illuminated viewable floor grids.\n
2833  *\n
2834  * Note the "special lighting effects" which can be activated for wall\n
2835  * grids using the "view_granite_lite" option (for "white" wall grids),\n
2836  * causing certain grids to be displayed using special colors.  If the\n
2837  * player is "blind", we will use "dark gray", else if the grid is lit\n
2838  * by the torch, and the "view_yellow_lite" option is set, we will use\n
2839  * "yellow", else if the "view_bright_lite" option is set, and the grid\n
2840  * is not "viewable", or is "dark", or is glowing, but not when viewed\n
2841  * from the player's current location, we will use "slate" (gray).  We\n
2842  * will use "white" for all other cases, in particular, for correctly\n
2843  * illuminated viewable wall grids.\n
2844  *\n
2845  * Note that, when "view_granite_lite" is set, we use an inline version\n
2846  * of the "player_can_see_bold()" function to check the "viewability" of\n
2847  * grids when the "view_bright_lite" option is set, and we do NOT use\n
2848  * any special colors for "dark" wall grids, since this would allow the\n
2849  * player to notice the walls of illuminated rooms from a hallway that\n
2850  * happened to run beside the room.  The alternative, by the way, would\n
2851  * be to prevent the generation of hallways next to rooms, but this\n
2852  * would still allow problems when digging towards a room.\n
2853  *\n
2854  * Note that bizarre things must be done when the "attr" and/or "char"\n
2855  * codes have the "high-bit" set, since these values are used to encode\n
2856  * various "special" pictures in some versions, and certain situations,\n
2857  * such as "multi-hued" or "clear" monsters, cause the attr/char codes\n
2858  * to be "scrambled" in various ways.\n
2859  *\n
2860  * Note that eventually we may use the "&" symbol for embedded treasure,\n
2861  * and use the "*" symbol to indicate multiple objects, though this will\n
2862  * have to wait for Angband 2.8.0 or later.  Note that currently, this\n
2863  * is not important, since only one object or terrain feature is allowed\n
2864  * in each grid.  If needed, "k_info[0]" will hold the "stack" attr/char.\n
2865  *\n
2866  * Note the assumption that doing "x_ptr = &x_info[x]" plus a few of\n
2867  * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect\n
2868  * then a whole lot of code should be changed...  XXX XXX\n
2869  */
2870 void map_info(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
2871 {
2872         floor_type *floor_ptr = player_ptr->current_floor_ptr;
2873         grid_type *g_ptr = &floor_ptr->grid_array[y][x];
2874
2875         OBJECT_IDX this_o_idx, next_o_idx = 0;
2876
2877         /* Feature code (applying "mimic" field) */
2878         FEAT_IDX feat = get_feat_mimic(g_ptr);
2879
2880         /* Access floor */
2881         feature_type *f_ptr = &f_info[feat];
2882
2883         TERM_COLOR a;
2884         SYMBOL_CODE c;
2885
2886         /* Boring grids (floors, etc) */
2887         if (!have_flag(f_ptr->flags, FF_REMEMBER))
2888         {
2889                 /*
2890                  * Handle Memorized or visible floor
2891                  *
2892                  * No visual when blinded.
2893                  *   (to prevent strange effects on darkness breath)
2894                  * otherwise,
2895                  * - Can see grids with CAVE_MARK.
2896                  * - Can see grids with CAVE_LITE or CAVE_MNLT.
2897                  *   (Such grids also have CAVE_VIEW)
2898                  * - Can see grids with CAVE_VIEW unless darkened by monsters.
2899                  */
2900                 if (!player_ptr->blind &&
2901                         ((g_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT)) ||
2902                         ((g_ptr->info & CAVE_VIEW) && (((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || player_ptr->see_nocto))))
2903                 {
2904                         /* Normal attr/char */
2905                         a = f_ptr->x_attr[F_LIT_STANDARD];
2906                         c = f_ptr->x_char[F_LIT_STANDARD];
2907
2908                         if (player_ptr->wild_mode)
2909                         {
2910                                 /* Special lighting effects */
2911                                 /* Handle "night" */
2912                                 if (view_special_lite && !is_daytime())
2913                                 {
2914                                         /* Use a darkened colour/tile */
2915                                         a = f_ptr->x_attr[F_LIT_DARK];
2916                                         c = f_ptr->x_char[F_LIT_DARK];
2917                                 }
2918                         }
2919
2920                         /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
2921                         else if (darkened_grid(player_ptr, g_ptr))
2922                         {
2923                                 /* Unsafe grid -- idea borrowed from Unangband */
2924                                 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
2925
2926                                 /* Access darkness */
2927                                 f_ptr = &f_info[feat];
2928
2929                                 /* Char and attr of darkness */
2930                                 a = f_ptr->x_attr[F_LIT_STANDARD];
2931                                 c = f_ptr->x_char[F_LIT_STANDARD];
2932                         }
2933
2934                         /* Special lighting effects */
2935                         else if (view_special_lite)
2936                         {
2937                                 /* Handle "torch-lit" grids */
2938                                 if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
2939                                 {
2940                                         /* Torch lite */
2941                                         if (view_yellow_lite)
2942                                         {
2943                                                 /* Use a brightly lit colour/tile */
2944                                                 a = f_ptr->x_attr[F_LIT_LITE];
2945                                                 c = f_ptr->x_char[F_LIT_LITE];
2946                                         }
2947                                 }
2948
2949                                 /* Handle "dark" grids */
2950                                 else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
2951                                 {
2952                                         /* Use a darkened colour/tile */
2953                                         a = f_ptr->x_attr[F_LIT_DARK];
2954                                         c = f_ptr->x_char[F_LIT_DARK];
2955                                 }
2956
2957                                 /* Handle "out-of-sight" grids */
2958                                 else if (!(g_ptr->info & CAVE_VIEW))
2959                                 {
2960                                         /* Special flag */
2961                                         if (view_bright_lite)
2962                                         {
2963                                                 /* Use a darkened colour/tile */
2964                                                 a = f_ptr->x_attr[F_LIT_DARK];
2965                                                 c = f_ptr->x_char[F_LIT_DARK];
2966                                         }
2967                                 }
2968                         }
2969                 }
2970
2971                 /* Unknown */
2972                 else
2973                 {
2974                         /* Unsafe grid -- idea borrowed from Unangband */
2975                         feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
2976
2977                         /* Access darkness */
2978                         f_ptr = &f_info[feat];
2979
2980                         /* Normal attr/char */
2981                         a = f_ptr->x_attr[F_LIT_STANDARD];
2982                         c = f_ptr->x_char[F_LIT_STANDARD];
2983                 }
2984         }
2985
2986         /* Interesting grids (non-floors) */
2987         else
2988         {
2989                 /* Memorized grids */
2990                 if (g_ptr->info & CAVE_MARK)
2991                 {
2992                         /* Normal attr/char */
2993                         a = f_ptr->x_attr[F_LIT_STANDARD];
2994                         c = f_ptr->x_char[F_LIT_STANDARD];
2995
2996                         if (player_ptr->wild_mode)
2997                         {
2998                                 /* Special lighting effects */
2999                                 /* Handle "blind" or "night" */
3000                                 if (view_granite_lite && (player_ptr->blind || !is_daytime()))
3001                                 {
3002                                         /* Use a darkened colour/tile */
3003                                         a = f_ptr->x_attr[F_LIT_DARK];
3004                                         c = f_ptr->x_char[F_LIT_DARK];
3005                                 }
3006                         }
3007
3008                         /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
3009                         else if (darkened_grid(player_ptr, g_ptr) && !player_ptr->blind)
3010                         {
3011                                 if (have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT))
3012                                 {
3013                                         /* Unsafe grid -- idea borrowed from Unangband */
3014                                         feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
3015
3016                                         /* Access darkness */
3017                                         f_ptr = &f_info[feat];
3018
3019                                         /* Char and attr of darkness */
3020                                         a = f_ptr->x_attr[F_LIT_STANDARD];
3021                                         c = f_ptr->x_char[F_LIT_STANDARD];
3022                                 }
3023                                 else if (view_granite_lite && view_bright_lite)
3024                                 {
3025                                         /* Use a darkened colour/tile */
3026                                         a = f_ptr->x_attr[F_LIT_DARK];
3027                                         c = f_ptr->x_char[F_LIT_DARK];
3028                                 }
3029                         }
3030
3031                         /* Special lighting effects */
3032                         else if (view_granite_lite)
3033                         {
3034                                 /* Handle "blind" */
3035                                 if (player_ptr->blind)
3036                                 {
3037                                         /* Use a darkened colour/tile */
3038                                         a = f_ptr->x_attr[F_LIT_DARK];
3039                                         c = f_ptr->x_char[F_LIT_DARK];
3040                                 }
3041
3042                                 /* Handle "torch-lit" grids */
3043                                 else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
3044                                 {
3045                                         /* Torch lite */
3046                                         if (view_yellow_lite)
3047                                         {
3048                                                 /* Use a brightly lit colour/tile */
3049                                                 a = f_ptr->x_attr[F_LIT_LITE];
3050                                                 c = f_ptr->x_char[F_LIT_LITE];
3051                                         }
3052                                 }
3053
3054                                 /* Handle "view_bright_lite" */
3055                                 else if (view_bright_lite)
3056                                 {
3057                                         /* Not viewable */
3058                                         if (!(g_ptr->info & CAVE_VIEW))
3059                                         {
3060                                                 /* Use a darkened colour/tile */
3061                                                 a = f_ptr->x_attr[F_LIT_DARK];
3062                                                 c = f_ptr->x_char[F_LIT_DARK];
3063                                         }
3064
3065                                         /* Not glowing */
3066                                         else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
3067                                         {
3068                                                 /* Use a darkened colour/tile */
3069                                                 a = f_ptr->x_attr[F_LIT_DARK];
3070                                                 c = f_ptr->x_char[F_LIT_DARK];
3071                                         }
3072
3073                                         /* Not glowing correctly */
3074                                         else if (!have_flag(f_ptr->flags, FF_LOS) && !check_local_illumination(player_ptr, y, x))
3075                                         {
3076                                                 /* Use a darkened colour/tile */
3077                                                 a = f_ptr->x_attr[F_LIT_DARK];
3078                                                 c = f_ptr->x_char[F_LIT_DARK];
3079                                         }
3080                                 }
3081                         }
3082                 }
3083
3084                 /* Unknown */
3085                 else
3086                 {
3087                         /* Unsafe grid -- idea borrowed from Unangband */
3088                         feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
3089
3090                         /* Access feature */
3091                         f_ptr = &f_info[feat];
3092
3093                         /* Normal attr/char */
3094                         a = f_ptr->x_attr[F_LIT_STANDARD];
3095                         c = f_ptr->x_char[F_LIT_STANDARD];
3096                 }
3097         }
3098
3099         if (feat_priority == -1) feat_priority = f_ptr->priority;
3100
3101         /* Save the terrain info for the transparency effects */
3102         (*tap) = a;
3103         (*tcp) = c;
3104
3105         /* Save the info */
3106         (*ap) = a;
3107         (*cp) = c;
3108
3109         /* Hack -- rare random hallucination, except on outer dungeon walls */
3110         if (player_ptr->image && one_in_(256))
3111                 image_random(ap, cp);
3112
3113         /* Objects */
3114         for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
3115         {
3116                 object_type *o_ptr;
3117                 o_ptr = &floor_ptr->o_list[this_o_idx];
3118                 next_o_idx = o_ptr->next_o_idx;
3119
3120                 /* Memorized objects */
3121                 if (!(o_ptr->marked & OM_FOUND)) continue;
3122
3123                 if (display_autopick)
3124                 {
3125                         byte act;
3126
3127                         match_autopick = find_autopick_list(player_ptr, o_ptr);
3128                         if (match_autopick == -1)
3129                                 continue;
3130
3131                         act = autopick_list[match_autopick].action;
3132
3133                         if ((act & DO_DISPLAY) && (act & display_autopick))
3134                         {
3135                                 autopick_obj = o_ptr;
3136                         }
3137                         else
3138                         {
3139                                 match_autopick = -1;
3140                                 continue;
3141                         }
3142                 }
3143
3144                 /* Normal char */
3145                 (*cp) = object_char(o_ptr);
3146
3147                 /* Normal attr */
3148                 (*ap) = object_attr(o_ptr);
3149
3150                 feat_priority = 20;
3151
3152                 /* Hack -- hallucination */
3153                 if (player_ptr->image) image_object(ap, cp);
3154
3155                 break;
3156         }
3157
3158         /* Handle monsters */
3159         if (g_ptr->m_idx && display_autopick != 0)
3160         {
3161                 set_term_color(player_ptr, y, x, ap, cp);
3162                 return;
3163         }
3164
3165         monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
3166
3167         /* Visible monster */
3168         if (!m_ptr->ml)
3169         {
3170                 set_term_color(player_ptr, y, x, ap, cp);
3171                 return;
3172         }
3173
3174
3175         monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
3176
3177         feat_priority = 30;
3178
3179         /* Hallucination */
3180         if (player_ptr->image)
3181         {
3182                 /*
3183                  * Monsters with both CHAR_CLEAR and ATTR_CLEAR
3184                  * flags are always unseen.
3185                  */
3186                 if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR))
3187                 {
3188                         /* Do nothing */
3189                 }
3190                 else
3191                 {
3192                         image_monster(ap, cp);
3193                 }
3194
3195                 set_term_color(player_ptr, y, x, ap, cp);
3196                 return;
3197         }
3198
3199         /* Monster attr/char */
3200         a = r_ptr->x_attr;
3201         c = r_ptr->x_char;
3202
3203         if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_SHAPECHANGER | RF1_ATTR_CLEAR
3204                 | RF1_ATTR_MULTI | RF1_ATTR_SEMIRAND)))
3205         {
3206                 /* Desired monster attr/char */
3207                 *ap = a;
3208                 *cp = c;
3209                 set_term_color(player_ptr, y, x, ap, cp);
3210                 return;
3211         }
3212
3213         /*
3214          * Monsters with both CHAR_CLEAR and ATTR_CLEAR
3215          * flags are always unseen.
3216          */
3217         if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR))
3218         {
3219                 set_term_color(player_ptr, y, x, ap, cp);
3220                 return;
3221         }
3222
3223         /***  Monster's attr  ***/
3224         if ((r_ptr->flags1 & RF1_ATTR_CLEAR) && (*ap != TERM_DARK) && !use_graphics)
3225         {
3226                 /* Clear-attr */
3227                 /* Do nothing */
3228         }
3229         else if ((r_ptr->flags1 & RF1_ATTR_MULTI) && !use_graphics)
3230         {
3231                 /* Multi-hued attr */
3232                 if (r_ptr->flags2 & RF2_ATTR_ANY) *ap = randint1(15);
3233                 else switch (randint1(7))
3234                 {
3235                 case 1: *ap = TERM_RED;     break;
3236                 case 2: *ap = TERM_L_RED;   break;
3237                 case 3: *ap = TERM_WHITE;   break;
3238                 case 4: *ap = TERM_L_GREEN; break;
3239                 case 5: *ap = TERM_BLUE;    break;
3240                 case 6: *ap = TERM_L_DARK;  break;
3241                 case 7: *ap = TERM_GREEN;   break;
3242                 }
3243         }
3244         else if ((r_ptr->flags1 & RF1_ATTR_SEMIRAND) && !use_graphics)
3245         {
3246                 /* Use semi-random attr (usually mimics' colors vary) */
3247                 *ap = g_ptr->m_idx % 15 + 1;
3248         }
3249         else
3250         {
3251                 /* Normal case */
3252                 *ap = a;
3253         }
3254
3255         /***  Monster's char  ***/
3256         if ((r_ptr->flags1 & RF1_CHAR_CLEAR) && (*cp != ' ') && !use_graphics)
3257         {
3258                 set_term_color(player_ptr, y, x, ap, cp);
3259                 return;
3260         }
3261
3262         if (r_ptr->flags1 & RF1_SHAPECHANGER)
3263         {
3264                 if (use_graphics)
3265                 {
3266                         monster_race *tmp_r_ptr = &r_info[randint1(max_r_idx - 1)];
3267                         *cp = tmp_r_ptr->x_char;
3268                         *ap = tmp_r_ptr->x_attr;
3269                 }
3270                 else
3271                 {
3272                         *cp = (one_in_(25) ?
3273                                 image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
3274                                 image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
3275                 }
3276
3277                 set_term_color(player_ptr, y, x, ap, cp);
3278                 return;
3279         }
3280
3281         *cp = c;
3282         set_term_color(player_ptr, y, x, ap, cp);
3283 }
3284
3285
3286 void set_term_color(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp)
3287 {
3288         if (!player_bold(player_ptr, y, x)) return;
3289
3290         monster_race *r_ptr = &r_info[0];
3291         *ap = r_ptr->x_attr;
3292         *cp = r_ptr->x_char;
3293         feat_priority = 31;
3294 }
3295
3296
3297 static concptr simplify_list[][2] =
3298 {
3299 #ifdef JP
3300         {"の魔法書", ""},
3301         {NULL, NULL}
3302 #else
3303         {"^Ring of ",   "="},
3304         {"^Amulet of ", "\""},
3305         {"^Scroll of ", "?"},
3306         {"^Scroll titled ", "?"},
3307         {"^Wand of "  , "-"},
3308         {"^Rod of "   , "-"},
3309         {"^Staff of " , "_"},
3310         {"^Potion of ", "!"},
3311         {" Spellbook ",""},
3312         {"^Book of ",   ""},
3313         {" Magic [",   "["},
3314         {" Book [",    "["},
3315         {" Arts [",    "["},
3316         {"^Set of ",    ""},
3317         {"^Pair of ",   ""},
3318         {NULL, NULL}
3319 #endif
3320 };
3321
3322
3323 static void display_shortened_item_name(player_type *player_ptr, object_type *o_ptr, int y)
3324 {
3325         char buf[MAX_NLEN];
3326         object_desc(player_ptr, buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
3327         TERM_COLOR attr = tval_to_attr[o_ptr->tval % 128];
3328
3329         if (player_ptr->image)
3330         {
3331                 attr = TERM_WHITE;
3332                 strcpy(buf, _("何か奇妙な物", "something strange"));
3333         }
3334
3335         char *c = buf;
3336         for (c = buf; *c; c++)
3337         {
3338                 for (int i = 0; simplify_list[i][1]; i++)
3339                 {
3340                         concptr org_w = simplify_list[i][0];
3341
3342                         if (*org_w == '^')
3343                         {
3344                                 if (c == buf)
3345                                         org_w++;
3346                                 else
3347                                         continue;
3348                         }
3349
3350                         if (strncmp(c, org_w, strlen(org_w))) continue;
3351
3352                         char *s = c;
3353                         concptr tmp = simplify_list[i][1];
3354                         while (*tmp)
3355                                 *s++ = *tmp++;
3356                         tmp = c + strlen(org_w);
3357                         while (*tmp)
3358                                 *s++ = *tmp++;
3359                         *s = '\0';
3360                 }
3361         }
3362
3363         c = buf;
3364         int len = 0;
3365         /* 半角 12 文字分で切る */
3366         while (*c)
3367         {
3368 #ifdef JP
3369                 if (iskanji(*c))
3370                 {
3371                         if (len + 2 > 12) break;
3372                         c += 2;
3373                         len += 2;
3374                 }
3375                 else
3376 #endif
3377                 {
3378                         if (len + 1 > 12) break;
3379                         c++;
3380                         len++;
3381                 }
3382         }
3383
3384         *c = '\0';
3385         Term_putstr(0, y, 12, attr, buf);
3386 }
3387
3388
3389 /*
3390  * Display a "small-scale" map of the dungeon in the active Term
3391  */
3392 void display_map(player_type *player_ptr, int *cy, int *cx)
3393 {
3394         int i, j, x, y;
3395
3396         TERM_COLOR ta;
3397         SYMBOL_CODE tc;
3398
3399         byte tp;
3400
3401         TERM_COLOR **bigma;
3402         SYMBOL_CODE **bigmc;
3403         byte **bigmp;
3404
3405         TERM_COLOR **ma;
3406         SYMBOL_CODE **mc;
3407         byte **mp;
3408
3409         /* Save lighting effects */
3410         bool old_view_special_lite = view_special_lite;
3411         bool old_view_granite_lite = view_granite_lite;
3412
3413         TERM_LEN hgt, wid, yrat, xrat;
3414
3415         int **match_autopick_yx;
3416         object_type ***object_autopick_yx;
3417
3418         Term_get_size(&wid, &hgt);
3419         hgt -= 2;
3420         wid -= 14;
3421         if (use_bigtile) wid /= 2;
3422
3423         floor_type *floor_ptr = player_ptr->current_floor_ptr;
3424         yrat = (floor_ptr->height + hgt - 1) / hgt;
3425         xrat = (floor_ptr->width + wid - 1) / wid;
3426
3427         /* Disable lighting effects */
3428         view_special_lite = FALSE;
3429         view_granite_lite = FALSE;
3430
3431         /* Allocate the maps */
3432         C_MAKE(ma, (hgt + 2), TERM_COLOR *);
3433         C_MAKE(mc, (hgt + 2), char_ptr);
3434         C_MAKE(mp, (hgt + 2), byte_ptr);
3435         C_MAKE(match_autopick_yx, (hgt + 2), int*);
3436         C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
3437
3438         /* Allocate and wipe each line map */
3439         for (y = 0; y < (hgt + 2); y++)
3440         {
3441                 /* Allocate one row each array */
3442                 C_MAKE(ma[y], (wid + 2), TERM_COLOR);
3443                 C_MAKE(mc[y], (wid + 2), char);
3444                 C_MAKE(mp[y], (wid + 2), byte);
3445                 C_MAKE(match_autopick_yx[y], (wid + 2), int);
3446                 C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
3447
3448                 for (x = 0; x < wid + 2; ++x)
3449                 {
3450                         match_autopick_yx[y][x] = -1;
3451                         object_autopick_yx[y][x] = NULL;
3452
3453                         /* Nothing here */
3454                         ma[y][x] = TERM_WHITE;
3455                         mc[y][x] = ' ';
3456
3457                         /* No priority */
3458                         mp[y][x] = 0;
3459                 }
3460         }
3461
3462         /* Allocate the maps */
3463         C_MAKE(bigma, (floor_ptr->height + 2), TERM_COLOR *);
3464         C_MAKE(bigmc, (floor_ptr->height + 2), char_ptr);
3465         C_MAKE(bigmp, (floor_ptr->height + 2), byte_ptr);
3466
3467         /* Allocate and wipe each line map */
3468         for (y = 0; y < (floor_ptr->height + 2); y++)
3469         {
3470                 /* Allocate one row each array */
3471                 C_MAKE(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
3472                 C_MAKE(bigmc[y], (floor_ptr->width + 2), char);
3473                 C_MAKE(bigmp[y], (floor_ptr->width + 2), byte);
3474
3475                 for (x = 0; x < floor_ptr->width + 2; ++x)
3476                 {
3477                         /* Nothing here */
3478                         bigma[y][x] = TERM_WHITE;
3479                         bigmc[y][x] = ' ';
3480
3481                         /* No priority */
3482                         bigmp[y][x] = 0;
3483                 }
3484         }
3485
3486         /* Fill in the map */
3487         for (i = 0; i < floor_ptr->width; ++i)
3488         {
3489                 for (j = 0; j < floor_ptr->height; ++j)
3490                 {
3491                         x = i / xrat + 1;
3492                         y = j / yrat + 1;
3493
3494                         match_autopick = -1;
3495                         autopick_obj = NULL;
3496                         feat_priority = -1;
3497
3498                         /* Extract the current attr/char at that map location */
3499                         map_info(player_ptr, j, i, &ta, &tc, &ta, &tc);
3500
3501                         /* Extract the priority */
3502                         tp = (byte)feat_priority;
3503
3504                         if (match_autopick != -1
3505                                 && (match_autopick_yx[y][x] == -1
3506                                         || match_autopick_yx[y][x] > match_autopick))
3507                         {
3508                                 match_autopick_yx[y][x] = match_autopick;
3509                                 object_autopick_yx[y][x] = autopick_obj;
3510                                 tp = 0x7f;
3511                         }
3512
3513                         /* Save the char, attr and priority */
3514                         bigmc[j + 1][i + 1] = tc;
3515                         bigma[j + 1][i + 1] = ta;
3516                         bigmp[j + 1][i + 1] = tp;
3517                 }
3518         }
3519
3520         for (j = 0; j < floor_ptr->height; ++j)
3521         {
3522                 for (i = 0; i < floor_ptr->width; ++i)
3523                 {
3524                         x = i / xrat + 1;
3525                         y = j / yrat + 1;
3526
3527                         tc = bigmc[j + 1][i + 1];
3528                         ta = bigma[j + 1][i + 1];
3529                         tp = bigmp[j + 1][i + 1];
3530
3531                         /* rare feature has more priority */
3532                         if (mp[y][x] == tp)
3533                         {
3534                                 int t;
3535                                 int cnt = 0;
3536
3537                                 for (t = 0; t < 8; t++)
3538                                 {
3539                                         if (tc == bigmc[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]] &&
3540                                                 ta == bigma[j + 1 + ddy_cdd[t]][i + 1 + ddx_cdd[t]])
3541                                                 cnt++;
3542                                 }
3543                                 if (cnt <= 4)
3544                                         tp++;
3545                         }
3546
3547                         /* Save "best" */
3548                         if (mp[y][x] < tp)
3549                         {
3550                                 /* Save the char, attr and priority */
3551                                 mc[y][x] = tc;
3552                                 ma[y][x] = ta;
3553                                 mp[y][x] = tp;
3554                         }
3555                 }
3556         }
3557
3558         /* Corners */
3559         x = wid + 1;
3560         y = hgt + 1;
3561
3562         /* Draw the corners */
3563         mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
3564
3565         /* Draw the horizontal edges */
3566         for (x = 1; x <= wid; x++) mc[0][x] = mc[y][x] = '-';
3567
3568         /* Draw the vertical edges */
3569         for (y = 1; y <= hgt; y++) mc[y][0] = mc[y][x] = '|';
3570
3571         /* Display each map line in order */
3572         for (y = 0; y < hgt + 2; ++y)
3573         {
3574                 /* Start a new line */
3575                 Term_gotoxy(COL_MAP, y);
3576
3577                 /* Display the line */
3578                 for (x = 0; x < wid + 2; ++x)
3579                 {
3580                         ta = ma[y][x];
3581                         tc = mc[y][x];
3582
3583                         /* Hack -- fake monochrome */
3584                         if (!use_graphics)
3585                         {
3586                                 if (current_world_ptr->timewalk_m_idx) ta = TERM_DARK;
3587                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) ta = TERM_WHITE;
3588                                 else if (player_ptr->wraith_form) ta = TERM_L_DARK;
3589                         }
3590
3591                         /* Add the character */
3592                         Term_add_bigch(ta, tc);
3593                 }
3594         }
3595
3596         for (y = 1; y < hgt + 1; ++y)
3597         {
3598                 match_autopick = -1;
3599                 for (x = 1; x <= wid; x++) {
3600                         if (match_autopick_yx[y][x] != -1 &&
3601                                 (match_autopick > match_autopick_yx[y][x] ||
3602                                         match_autopick == -1)) {
3603                                 match_autopick = match_autopick_yx[y][x];
3604                                 autopick_obj = object_autopick_yx[y][x];
3605                         }
3606                 }
3607
3608                 /* Clear old display */
3609                 Term_putstr(0, y, 12, 0, "            ");
3610
3611                 if (match_autopick != -1)
3612                         display_shortened_item_name(player_ptr, autopick_obj, y);
3613         }
3614
3615         /* Player location */
3616         (*cy) = player_ptr->y / yrat + 1 + ROW_MAP;
3617         if (!use_bigtile)
3618                 (*cx) = player_ptr->x / xrat + 1 + COL_MAP;
3619         else
3620                 (*cx) = (player_ptr->x / xrat + 1) * 2 + COL_MAP;
3621
3622         /* Restore lighting effects */
3623         view_special_lite = old_view_special_lite;
3624         view_granite_lite = old_view_granite_lite;
3625
3626         /* Free each line map */
3627         for (y = 0; y < (hgt + 2); y++)
3628         {
3629                 /* Free one row each array */
3630                 C_KILL(ma[y], (wid + 2), TERM_COLOR);
3631                 C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
3632                 C_KILL(mp[y], (wid + 2), byte);
3633                 C_KILL(match_autopick_yx[y], (wid + 2), int);
3634                 C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
3635         }
3636
3637         /* Free each line map */
3638         C_KILL(ma, (hgt + 2), TERM_COLOR *);
3639         C_KILL(mc, (hgt + 2), char_ptr);
3640         C_KILL(mp, (hgt + 2), byte_ptr);
3641         C_KILL(match_autopick_yx, (hgt + 2), int*);
3642         C_KILL(object_autopick_yx, (hgt + 2), object_type **);
3643
3644         /* Free each line map */
3645         for (y = 0; y < (floor_ptr->height + 2); y++)
3646         {
3647                 /* Free one row each array */
3648                 C_KILL(bigma[y], (floor_ptr->width + 2), TERM_COLOR);
3649                 C_KILL(bigmc[y], (floor_ptr->width + 2), SYMBOL_CODE);
3650                 C_KILL(bigmp[y], (floor_ptr->width + 2), byte);
3651         }
3652
3653         /* Free each line map */
3654         C_KILL(bigma, (floor_ptr->height + 2), TERM_COLOR *);
3655         C_KILL(bigmc, (floor_ptr->height + 2), char_ptr);
3656         C_KILL(bigmp, (floor_ptr->height + 2), byte_ptr);
3657 }
3658
3659
3660 /*
3661  * Display a "small-scale" map of the dungeon for the player
3662  *
3663  * Currently, the "player" is displayed on the map.
3664  */
3665 void do_cmd_view_map(player_type *player_ptr)
3666 {
3667         screen_save();
3668         prt(_("お待ち下さい...", "Please wait..."), 0, 0);
3669
3670         Term_fresh();
3671         Term_clear();
3672
3673         display_autopick = 0;
3674
3675         /* Display the map */
3676         int cy, cx;
3677         display_map(player_ptr, &cy, &cx);
3678
3679         if ((max_autopick == 0) || player_ptr->wild_mode)
3680         {
3681                 put_str(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"), 23, 30);
3682                 /* Hilite the player */
3683                 move_cursor(cy, cx);
3684                 /* Get any key */
3685                 inkey();
3686                 screen_load();
3687                 return;
3688         }
3689
3690         display_autopick = ITEM_DISPLAY;
3691
3692         while (TRUE)
3693         {
3694                 int wid, hgt;
3695                 Term_get_size(&wid, &hgt);
3696                 int row_message = hgt - 1;
3697
3698                 put_str(_("何かキーを押してください('M':拾う 'N':放置 'D':M+N 'K':壊すアイテムを表示)",
3699                         " Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items."), row_message, 1);
3700
3701                 move_cursor(cy, cx);
3702
3703                 int i = inkey();
3704
3705                 byte flag;
3706                 if ('M' == i)
3707                         flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK);
3708                 else if ('N' == i)
3709                         flag = DONT_AUTOPICK;
3710                 else if ('K' == i)
3711                         flag = DO_AUTODESTROY;
3712                 else if ('D' == i)
3713                         flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK | DONT_AUTOPICK);
3714                 else
3715                         break;
3716
3717                 Term_fresh();
3718
3719                 if (~display_autopick & flag)
3720                         display_autopick |= flag;
3721                 else
3722                         display_autopick &= ~flag;
3723                 display_map(player_ptr, &cy, &cx);
3724         }
3725
3726         display_autopick = 0;
3727         screen_load();
3728 }
3729
3730
3731 /*
3732  * Track a new monster
3733  * @param player_ptr プレーヤーへの参照ポインタ
3734  * @param m_idx トラッキング対象のモンスターID。0の時キャンセル
3735  * @param なし
3736  */
3737 void health_track(player_type *player_ptr, MONSTER_IDX m_idx)
3738 {
3739         /* Mount monster is already tracked */
3740         if (m_idx && m_idx == player_ptr->riding) return;
3741
3742         /* Track a new guy */
3743         player_ptr->health_who = m_idx;
3744
3745         /* Redraw (later) */
3746         player_ptr->redraw |= (PR_HEALTH);
3747 }
3748
3749
3750 /*
3751  * Moves the cursor to a given MAP (y,x) location
3752  */
3753 void move_cursor_relative(int row, int col)
3754 {
3755         /* Real co-ords convert to screen positions */
3756         row -= panel_row_prt;
3757
3758         /* Go there */
3759         Term_gotoxy(panel_col_of(col), row);
3760 }
3761
3762
3763 /*
3764  * print project path
3765  */
3766 void print_path(player_type *player_ptr, POSITION y, POSITION x)
3767 {
3768         int path_n;
3769         u16b path_g[512];
3770         byte default_color = TERM_SLATE;
3771
3772         if (!display_path) return;
3773         if (project_length == -1) return;
3774
3775         /* Get projection path */
3776         floor_type *floor_ptr = player_ptr->current_floor_ptr;
3777         path_n = project_path(player_ptr, path_g, (project_length ? project_length : MAX_RANGE), player_ptr->y, player_ptr->x, y, x, PROJECT_PATH | PROJECT_THRU);
3778
3779         player_ptr->redraw |= (PR_MAP);
3780         handle_stuff(player_ptr);
3781
3782         /* Draw path */
3783         for (int i = 0; i < path_n; i++)
3784         {
3785                 POSITION ny = GRID_Y(path_g[i]);
3786                 POSITION nx = GRID_X(path_g[i]);
3787                 grid_type *g_ptr = &floor_ptr->grid_array[ny][nx];
3788
3789                 if (panel_contains(ny, nx))
3790                 {
3791                         TERM_COLOR a = default_color;
3792                         SYMBOL_CODE c;
3793
3794                         TERM_COLOR ta = default_color;
3795                         SYMBOL_CODE tc = '*';
3796
3797                         if (g_ptr->m_idx && floor_ptr->m_list[g_ptr->m_idx].ml)
3798                         {
3799                                 /* Determine what is there */
3800                                 map_info(player_ptr, ny, nx, &a, &c, &ta, &tc);
3801
3802                                 if (!IS_ASCII_GRAPHICS(a))
3803                                         a = default_color;
3804                                 else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
3805                                         a = default_color;
3806                                 else if (a == default_color)
3807                                         a = TERM_WHITE;
3808                         }
3809
3810                         if (!use_graphics)
3811                         {
3812                                 if (current_world_ptr->timewalk_m_idx) a = TERM_DARK;
3813                                 else if (IS_INVULN(player_ptr) || player_ptr->timewalk) a = TERM_WHITE;
3814                                 else if (player_ptr->wraith_form) a = TERM_L_DARK;
3815                         }
3816
3817                         c = '*';
3818
3819                         /* Hack -- Queue it */
3820                         Term_queue_bigchar(panel_col_of(nx), ny - panel_row_prt, a, c, ta, tc);
3821                 }
3822
3823                 /* Known Wall */
3824                 if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT)) break;
3825
3826                 /* Change color */
3827                 if (nx == x && ny == y) default_color = TERM_L_DARK;
3828         }
3829 }
3830
3831
3832 /*
3833  * Hack -- track the given monster race
3834  */
3835 void monster_race_track(player_type *player_ptr, MONRACE_IDX r_idx)
3836 {
3837         player_ptr->monster_race_idx = r_idx;
3838         player_ptr->window |= (PW_MONSTER);
3839 }
3840
3841
3842 /*
3843  * Hack -- track the given object kind
3844  */
3845 void object_kind_track(player_type *player_ptr, KIND_OBJECT_IDX k_idx)
3846 {
3847         player_ptr->object_kind_idx = k_idx;
3848         player_ptr->window |= (PW_OBJECT);
3849 }
3850
3851
3852 /*!
3853  * @brief 実ゲームプレイ時間を更新する
3854  */
3855 void update_playtime(void)
3856 {
3857         /* Check if the game has started */
3858         if (current_world_ptr->start_time != 0)
3859         {
3860                 u32b tmp = (u32b)time(NULL);
3861                 current_world_ptr->play_time += (tmp - current_world_ptr->start_time);
3862                 current_world_ptr->start_time = tmp;
3863         }
3864 }
3865
3866
3867 /*
3868  * Mega-Hack -- Delayed visual update
3869  * Only used if update_view(), update_lite() or update_mon_lite() was called
3870  */
3871 void delayed_visual_update(player_type *player_ptr)
3872 {
3873         /* Update needed grids */
3874         floor_type *floor_ptr = player_ptr->current_floor_ptr;
3875         for (int i = 0; i < floor_ptr->redraw_n; i++)
3876         {
3877                 POSITION y = floor_ptr->redraw_y[i];
3878                 POSITION x = floor_ptr->redraw_x[i];
3879                 grid_type *g_ptr;
3880                 g_ptr = &floor_ptr->grid_array[y][x];
3881
3882                 /* Update only needed grids (prevent multiple updating) */
3883                 if (!(g_ptr->info & CAVE_REDRAW)) continue;
3884
3885                 /* If required, note */
3886                 if (g_ptr->info & CAVE_NOTE) note_spot(player_ptr, y, x);
3887
3888                 lite_spot(player_ptr, y, x);
3889
3890                 /* Hack -- Visual update of monster on this grid */
3891                 if (g_ptr->m_idx) update_monster(player_ptr, g_ptr->m_idx, FALSE);
3892
3893                 /* No longer in the array */
3894                 g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
3895         }
3896
3897         /* None left */
3898         floor_ptr->redraw_n = 0;
3899 }