OSDN Git Service

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