OSDN Git Service

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