1 #include "view/display-map.h"
2 #include "autopick/autopick-finder.h"
3 #include "autopick/autopick-methods-table.h"
4 #include "floor/cave.h"
5 #include "game-option/map-screen-options.h"
6 #include "game-option/special-options.h"
7 #include "grid/feature.h"
9 #include "monster-race/monster-race.h"
10 #include "monster-race/race-flags1.h"
11 #include "monster-race/race-flags2.h"
12 #include "object/object-info.h"
13 #include "object/object-kind.h"
14 #include "object/object-mark-types.h"
15 #include "system/floor-type-definition.h"
16 #include "term/term-color-types.h"
17 #include "util/bit-flags-calculator.h"
18 #include "window/main-window-util.h"
19 #include "world/world.h"
21 byte display_autopick; /*!< 自動拾い状態の設定フラグ */
23 /* 一般的にオブジェクトシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal object codes */
24 char image_object_hack[MAX_IMAGE_OBJECT_HACK] = "?/|\\\"!$()_-=[]{},~";
26 /* 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes */
27 char image_monster_hack[MAX_IMAGE_MONSTER_HACK] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
30 * @brief オブジェクトの表示を幻覚状態に差し替える / Hallucinatory object
35 static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
38 object_kind *k_ptr = &k_info[randint1(max_k_idx - 1)];
44 size_t n = sizeof(image_object_hack) - 1;
45 *cp = image_object_hack[randint0(n)];
50 * @brief モンスターの表示を幻覚状態に差し替える / Mega-Hack -- Hallucinatory monster
55 static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
58 monster_race *r_ptr = &r_info[randint1(max_r_idx - 1)];
64 *cp = (one_in_(25) ? image_object_hack[randint0(sizeof(image_object_hack) - 1)] : image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
69 * @brief オブジェクト&モンスターの表示を幻覚状態に差し替える / Hack -- Random hallucination
74 static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
76 if (randint0(100) < 75) {
77 image_monster(ap, cp);
83 static bool is_revealed_wall(floor_type *floor_ptr, feature_type *f_ptr, POSITION y, POSITION x)
85 if (view_hidden_walls)
88 if (!has_flag(f_ptr->flags, FF_WALL) || has_flag(f_ptr->flags, FF_HAS_GOLD))
91 if (in_bounds(floor_ptr, y, x) && has_flag(f_ptr->flags, FF_PERMANENT))
95 for (int i = 0; i < 8; i++) {
96 int dy = y + ddy_cdd[i];
97 int dx = x + ddx_cdd[i];
98 if (!in_bounds(floor_ptr, dy, dx)) {
103 FEAT_IDX f_idx = floor_ptr->grid_array[dy][dx].feat;
104 feature_type *n_ptr = &f_info[f_idx];
105 if (has_flag(n_ptr->flags, FF_WALL))
113 * @brief 指定した座標の地形の表示属性を取得する / Extract the attr/char to display at the given (legal) map location
114 * @param player_ptr プレイヤー情報への参照ポインタ
119 * @param tap 文字色属性(タイル)
120 * @param tcp 文字種属性(タイル)
123 void map_info(player_type *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
125 floor_type *floor_ptr = player_ptr->current_floor_ptr;
126 grid_type *g_ptr = &floor_ptr->grid_array[y][x];
127 OBJECT_IDX this_o_idx, next_o_idx = 0;
128 FEAT_IDX feat = get_feat_mimic(g_ptr);
129 feature_type *f_ptr = &f_info[feat];
132 if (!has_flag(f_ptr->flags, FF_REMEMBER)) {
133 if (!player_ptr->blind
134 && ((g_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT))
135 || ((g_ptr->info & CAVE_VIEW) && (((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || player_ptr->see_nocto)))) {
136 a = f_ptr->x_attr[F_LIT_STANDARD];
137 c = f_ptr->x_char[F_LIT_STANDARD];
138 if (player_ptr->wild_mode) {
139 if (view_special_lite && !is_daytime()) {
140 a = f_ptr->x_attr[F_LIT_DARK];
141 c = f_ptr->x_char[F_LIT_DARK];
143 } else if (darkened_grid(player_ptr, g_ptr)) {
144 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
145 f_ptr = &f_info[feat];
146 a = f_ptr->x_attr[F_LIT_STANDARD];
147 c = f_ptr->x_char[F_LIT_STANDARD];
148 } else if (view_special_lite) {
149 if (g_ptr->info & (CAVE_LITE | CAVE_MNLT)) {
150 if (view_yellow_lite) {
151 a = f_ptr->x_attr[F_LIT_LITE];
152 c = f_ptr->x_char[F_LIT_LITE];
154 } else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) {
155 a = f_ptr->x_attr[F_LIT_DARK];
156 c = f_ptr->x_char[F_LIT_DARK];
157 } else if (!(g_ptr->info & CAVE_VIEW)) {
158 if (view_bright_lite) {
159 a = f_ptr->x_attr[F_LIT_DARK];
160 c = f_ptr->x_char[F_LIT_DARK];
165 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
166 f_ptr = &f_info[feat];
167 a = f_ptr->x_attr[F_LIT_STANDARD];
168 c = f_ptr->x_char[F_LIT_STANDARD];
171 if (g_ptr->info & CAVE_MARK && is_revealed_wall(floor_ptr, f_ptr, y, x)) {
172 a = f_ptr->x_attr[F_LIT_STANDARD];
173 c = f_ptr->x_char[F_LIT_STANDARD];
174 if (player_ptr->wild_mode) {
175 if (view_granite_lite && (player_ptr->blind || !is_daytime())) {
176 a = f_ptr->x_attr[F_LIT_DARK];
177 c = f_ptr->x_char[F_LIT_DARK];
179 } else if (darkened_grid(player_ptr, g_ptr) && !player_ptr->blind) {
180 if (has_flag(f_ptr->flags, FF_LOS) && has_flag(f_ptr->flags, FF_PROJECT)) {
181 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
182 f_ptr = &f_info[feat];
183 a = f_ptr->x_attr[F_LIT_STANDARD];
184 c = f_ptr->x_char[F_LIT_STANDARD];
185 } else if (view_granite_lite && view_bright_lite) {
186 a = f_ptr->x_attr[F_LIT_DARK];
187 c = f_ptr->x_char[F_LIT_DARK];
189 } else if (view_granite_lite) {
190 if (player_ptr->blind) {
191 a = f_ptr->x_attr[F_LIT_DARK];
192 c = f_ptr->x_char[F_LIT_DARK];
193 } else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT)) {
194 if (view_yellow_lite) {
195 a = f_ptr->x_attr[F_LIT_LITE];
196 c = f_ptr->x_char[F_LIT_LITE];
198 } else if (view_bright_lite) {
199 if (!(g_ptr->info & CAVE_VIEW)) {
200 a = f_ptr->x_attr[F_LIT_DARK];
201 c = f_ptr->x_char[F_LIT_DARK];
202 } else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) {
203 a = f_ptr->x_attr[F_LIT_DARK];
204 c = f_ptr->x_char[F_LIT_DARK];
205 } else if (!has_flag(f_ptr->flags, FF_LOS) && !check_local_illumination(player_ptr, y, x)) {
206 a = f_ptr->x_attr[F_LIT_DARK];
207 c = f_ptr->x_char[F_LIT_DARK];
212 feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
213 f_ptr = &f_info[feat];
214 a = f_ptr->x_attr[F_LIT_STANDARD];
215 c = f_ptr->x_char[F_LIT_STANDARD];
219 if (feat_priority == -1)
220 feat_priority = f_ptr->priority;
227 if (player_ptr->image && one_in_(256))
228 image_random(ap, cp);
230 for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) {
232 o_ptr = &floor_ptr->o_list[this_o_idx];
233 next_o_idx = o_ptr->next_o_idx;
234 if (!(o_ptr->marked & OM_FOUND))
237 if (display_autopick) {
240 match_autopick = find_autopick_list(player_ptr, o_ptr);
241 if (match_autopick == -1)
244 act = autopick_list[match_autopick].action;
246 if ((act & DO_DISPLAY) && (act & display_autopick)) {
247 autopick_obj = o_ptr;
254 (*cp) = object_char(o_ptr);
255 (*ap) = object_attr(o_ptr);
257 if (player_ptr->image)
258 image_object(ap, cp);
263 if (g_ptr->m_idx && display_autopick != 0) {
264 set_term_color(player_ptr, y, x, ap, cp);
268 monster_type *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
270 set_term_color(player_ptr, y, x, ap, cp);
274 monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
276 if (player_ptr->image) {
277 if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) {
280 image_monster(ap, cp);
283 set_term_color(player_ptr, y, x, ap, cp);
289 if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_SHAPECHANGER | RF1_ATTR_CLEAR | RF1_ATTR_MULTI | RF1_ATTR_SEMIRAND))) {
292 set_term_color(player_ptr, y, x, ap, cp);
296 if ((r_ptr->flags1 & (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) == (RF1_CHAR_CLEAR | RF1_ATTR_CLEAR)) {
297 set_term_color(player_ptr, y, x, ap, cp);
301 if ((r_ptr->flags1 & RF1_ATTR_CLEAR) && (*ap != TERM_DARK) && !use_graphics) {
303 } else if ((r_ptr->flags1 & RF1_ATTR_MULTI) && !use_graphics) {
304 if (r_ptr->flags2 & RF2_ATTR_ANY)
307 switch (randint1(7)) {
330 } else if ((r_ptr->flags1 & RF1_ATTR_SEMIRAND) && !use_graphics) {
331 *ap = g_ptr->m_idx % 15 + 1;
336 if ((r_ptr->flags1 & RF1_CHAR_CLEAR) && (*cp != ' ') && !use_graphics) {
337 set_term_color(player_ptr, y, x, ap, cp);
341 if (r_ptr->flags1 & RF1_SHAPECHANGER) {
343 monster_race *tmp_r_ptr = &r_info[randint1(max_r_idx - 1)];
344 *cp = tmp_r_ptr->x_char;
345 *ap = tmp_r_ptr->x_attr;
347 *cp = (one_in_(25) ? image_object_hack[randint0(sizeof(image_object_hack) - 1)] : image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
350 set_term_color(player_ptr, y, x, ap, cp);
355 set_term_color(player_ptr, y, x, ap, cp);