OSDN Git Service

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