4 * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
6 * This software may be copied and distributed for educational, research,
7 * and not for profit purposes provided that this copyright and statement
8 * are included in all such copies. Other copyrights may also apply.
11 /* Purpose: low level dungeon routines -BEN- */
18 * Support for Adam Bolt's tileset, lighting and transparency effects
19 * by Robert Ruehlmann (rr9@angband.org)
22 static byte display_autopick;
23 static int match_autopick;
24 static object_type *autopick_obj;
25 static int feat_priority;
28 * Distance between two points via Newton-Raphson technique
30 int distance (int y1, int x1, int y2, int x2)
32 int dy = (y1 > y2) ? (y1 - y2) : (y2 - y1);
33 int dx = (x1 > x2) ? (x1 - x2) : (x2 - x1);
35 /* Squared distance */
36 int target = (dy * dy) + (dx * dx);
38 /* Approximate distance: hypot(dy,dx) = max(dy,dx) + min(dy,dx) / 2 */
39 int d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
44 if (!dy || !dx) return d;
48 /* Approximate error */
49 err = (target - d * d) / (2 * d);
51 /* No error - we are done */
63 * Return TRUE if the given feature is a trap
65 bool is_trap(int feat)
69 case FEAT_TRAP_TRAPDOOR:
71 case FEAT_TRAP_SPIKED_PIT:
72 case FEAT_TRAP_POISON_PIT:
73 case FEAT_TRAP_TY_CURSE:
74 case FEAT_TRAP_TELEPORT:
78 case FEAT_TRAP_LOSE_STR:
79 case FEAT_TRAP_LOSE_DEX:
80 case FEAT_TRAP_LOSE_CON:
82 case FEAT_TRAP_CONFUSE:
83 case FEAT_TRAP_POISON:
88 case FEAT_TRAP_ARMAGEDDON:
89 case FEAT_TRAP_PIRANHA:
104 * Return TRUE if the given grid is a known trap
106 bool is_known_trap(cave_type *c_ptr)
108 if (!c_ptr->mimic && is_trap(c_ptr->feat)) return TRUE;
114 * Return TRUE if the given grid is a closed door
116 bool is_closed_door(int feat)
118 return (feat >= FEAT_DOOR_HEAD && feat <= FEAT_DOOR_TAIL);
123 * Return TRUE if the given grid is a hidden closed door
125 bool is_hidden_door(cave_type *c_ptr)
128 is_closed_door(c_ptr->feat))
136 * A simple, fast, integer-based line-of-sight algorithm. By Joseph Hall,
137 * 4116 Brewster Drive, Raleigh NC 27606. Email to jnh@ecemwl.ncsu.edu.
139 * Returns TRUE if a line of sight can be traced from (x1,y1) to (x2,y2).
141 * The LOS begins at the center of the tile (x1,y1) and ends at the center of
142 * the tile (x2,y2). If los() is to return TRUE, all of the tiles this line
143 * passes through must be floor tiles, except for (x1,y1) and (x2,y2).
145 * We assume that the "mathematical corner" of a non-floor tile does not
146 * block line of sight.
148 * Because this function uses (short) ints for all calculations, overflow may
149 * occur if dx and dy exceed 90.
151 * Once all the degenerate cases are eliminated, the values "qx", "qy", and
152 * "m" are multiplied by a scale factor "f1 = abs(dx * dy * 2)", so that
153 * we can use integer arithmetic.
155 * We travel from start to finish along the longer axis, starting at the border
156 * between the first and second tiles, where the y offset = .5 * slope, taking
157 * into account the scale factor. See below.
159 * Also note that this function and the "move towards target" code do NOT
160 * share the same properties. Thus, you can see someone, target them, and
161 * then fire a bolt at them, but the bolt may hit a wall, not them. However,
162 * by clever choice of target locations, you can sometimes throw a "curve".
164 * Note that "line of sight" is not "reflexive" in all cases.
166 * Use the "projectable()" routine to test "spell/missile line of sight".
168 * Use the "update_view()" function to determine player line-of-sight.
170 bool los(int y1, int x1, int y2, int x2)
190 /* Slope, or 1/Slope, of LOS */
194 /* Extract the offset */
198 /* Extract the absolute offset */
203 /* Handle adjacent (or identical) grids */
204 if ((ax < 2) && (ay < 2)) return (TRUE);
207 /* Paranoia -- require "safe" origin */
208 /* if (!in_bounds(y1, x1)) return (FALSE); */
209 /* if (!in_bounds(y2, x2)) return (FALSE); */
212 /* Directly South/North */
215 /* South -- check for walls */
218 for (ty = y1 + 1; ty < y2; ty++)
220 if (!cave_floor_bold(ty, x1)) return (FALSE);
224 /* North -- check for walls */
227 for (ty = y1 - 1; ty > y2; ty--)
229 if (!cave_floor_bold(ty, x1)) return (FALSE);
237 /* Directly East/West */
240 /* East -- check for walls */
243 for (tx = x1 + 1; tx < x2; tx++)
245 if (!cave_floor_bold(y1, tx)) return (FALSE);
249 /* West -- check for walls */
252 for (tx = x1 - 1; tx > x2; tx--)
254 if (!cave_floor_bold(y1, tx)) return (FALSE);
263 /* Extract some signs */
264 sx = (dx < 0) ? -1 : 1;
265 sy = (dy < 0) ? -1 : 1;
268 /* Vertical "knights" */
273 if (cave_floor_bold(y1 + sy, x1)) return (TRUE);
277 /* Horizontal "knights" */
282 if (cave_floor_bold(y1, x1 + sx)) return (TRUE);
287 /* Calculate scale factor div 2 */
290 /* Calculate scale factor */
294 /* Travel horizontally */
297 /* Let m = dy / dx * 2 * (dy * dx) = 2 * dy * dy */
303 /* Consider the special case where slope == 1. */
314 /* Note (below) the case (qy == f2), where */
315 /* the LOS exactly meets the corner of a tile. */
318 if (!cave_floor_bold(ty, tx)) return (FALSE);
329 if (!cave_floor_bold(ty, tx)) return (FALSE);
342 /* Travel vertically */
345 /* Let m = dx / dy * 2 * (dx * dy) = 2 * dx * dx */
361 /* Note (below) the case (qx == f2), where */
362 /* the LOS exactly meets the corner of a tile. */
365 if (!cave_floor_bold(ty, tx)) return (FALSE);
376 if (!cave_floor_bold(ty, tx)) return (FALSE);
399 * Can the player "see" the given grid in detail?
401 * He must have vision, illumination, and line of sight.
403 * Note -- "CAVE_LITE" is only set if the "torch" has "los()".
404 * So, given "CAVE_LITE", we know that the grid is "fully visible".
406 * Note that "CAVE_GLOW" makes little sense for a wall, since it would mean
407 * that a wall is visible from any direction. That would be odd. Except
408 * under wizard light, which might make sense. Thus, for walls, we require
409 * not only that they be "CAVE_GLOW", but also, that they be adjacent to a
410 * grid which is not only "CAVE_GLOW", but which is a non-wall, and which is
411 * in line of sight of the player.
413 * This extra check is expensive, but it provides a more "correct" semantics.
415 * Note that we should not run this check on walls which are "outer walls" of
416 * the dungeon, or we will induce a memory fault, but actually verifying all
417 * of the locations would be extremely expensive.
419 * Thus, to speed up the function, we assume that all "perma-walls" which are
420 * "CAVE_GLOW" are "illuminated" from all sides. This is correct for all cases
421 * except "vaults" and the "buildings" in town. But the town is a hack anyway,
422 * and the player has more important things on his mind when he is attacking a
423 * monster vault. It is annoying, but an extremely important optimization.
425 * Note that "glowing walls" are only considered to be "illuminated" if the
426 * grid which is next to the wall in the direction of the player is also a
427 * "glowing" grid. This prevents the player from being able to "see" the
428 * walls of illuminated rooms from a corridor outside the room.
430 bool player_can_see_bold(int y, int x)
436 /* Blind players see nothing */
437 if (p_ptr->blind) return (FALSE);
439 /* Access the cave grid */
442 /* Note that "torch-lite" yields "illumination" */
443 if (c_ptr->info & (CAVE_LITE)) return (TRUE);
445 /* Require line of sight to the grid */
446 if (!player_has_los_bold(y, x)) return (FALSE);
448 if (p_ptr->pclass == CLASS_NINJA) return TRUE;
450 /* Require "perma-lite" of the grid */
451 if (!(c_ptr->info & (CAVE_GLOW | CAVE_MNLT))) return (FALSE);
453 /* Floors are simple */
454 if (cave_floor_bold(y, x)) return (TRUE);
456 /* Hack -- move towards player */
457 yy = (y < py) ? (y + 1) : (y > py) ? (y - 1) : y;
458 xx = (x < px) ? (x + 1) : (x > px) ? (x - 1) : x;
460 /* Check for "local" illumination */
461 if (cave[yy][xx].info & (CAVE_GLOW | CAVE_MNLT))
463 /* Assume the wall is really illuminated */
467 /* Assume not visible */
474 * Returns true if the player's grid is dark
478 return (!player_can_see_bold(py, px));
485 * Determine if a given location may be "destroyed"
487 * Used by destruction spells, and for placing stairs, etc.
489 bool cave_valid_bold(int y, int x)
491 cave_type *c_ptr = &cave[y][x];
493 s16b this_o_idx, next_o_idx = 0;
496 /* Forbid perma-grids */
497 if (cave_perma_grid(c_ptr)) return (FALSE);
500 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
505 o_ptr = &o_list[this_o_idx];
507 /* Acquire next object */
508 next_o_idx = o_ptr->next_o_idx;
510 /* Forbid artifact grids */
511 if ((o_ptr->art_name) || artifact_p(o_ptr)) return (FALSE);
522 * Determine if a given location may be "destroyed"
524 * Used by destruction spells, and for placing stairs, etc.
526 bool cave_valid_grid(cave_type *c_ptr)
528 s16b this_o_idx, next_o_idx = 0;
531 /* Forbid perma-grids */
532 if (cave_perma_grid(c_ptr)) return (FALSE);
535 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
540 o_ptr = &o_list[this_o_idx];
542 /* Acquire next object */
543 next_o_idx = o_ptr->next_o_idx;
545 /* Forbid artifact grids */
546 if ((o_ptr->art_name) || artifact_p(o_ptr)) return (FALSE);
557 * Hack -- Legal monster codes
559 static cptr image_monster_hack = \
560 "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
563 * Hack -- Legal monster codes for IBM pseudo-graphics
565 static cptr image_monster_hack_ibm = \
569 * Mega-Hack -- Hallucinatory monster
571 static void image_monster(byte *ap, char *cp)
573 int n = strlen(image_monster_hack);
575 /* Random symbol from set above */
578 /* Normal graphics */
579 if (!(streq(ANGBAND_SYS, "ibm")))
581 (*cp) = r_info[randint1(max_r_idx-1)].x_char;
582 (*ap) = r_info[randint1(max_r_idx-1)].x_attr;
585 /* IBM-pseudo graphics */
587 n = strlen(image_monster_hack_ibm);
588 (*cp) = (image_monster_hack_ibm[randint0(n)]);
591 (*ap) = randint1(15);
597 (*cp) = (image_monster_hack[randint0(n)]);
600 (*ap) = randint1(15);
607 * Hack -- Legal object codes
609 static cptr image_object_hack = \
610 "?/|\\\"!$()_-=[]{},~";
612 static cptr image_object_hack_ibm = \
616 * Mega-Hack -- Hallucinatory object
618 static void image_object(byte *ap, char *cp)
620 int n = strlen(image_object_hack);
624 if (!(streq(ANGBAND_SYS, "ibm")))
626 (*cp) = k_info[randint1(max_k_idx-1)].x_char;
627 (*ap) = k_info[randint1(max_k_idx-1)].x_attr;
631 n = strlen(image_object_hack_ibm);
632 (*cp) = (image_object_hack_ibm[randint0(n)]);
635 (*ap) = randint1(15);
640 (*cp) = (image_object_hack[randint0(n)]);
643 (*ap) = randint1(15);
650 * Hack -- Random hallucination
652 static void image_random(byte *ap, char *cp)
654 /* Normally, assume monsters */
655 if (randint0(100) < 75)
657 image_monster(ap, cp);
660 /* Otherwise, assume objects */
663 image_object(ap, cp);
668 * Not using graphical tiles for this feature?
670 #define is_ascii_graphics(C , A) \
671 (!(((C) & 0x80) && ((A) & 0x80)))
674 * The 16x16 tile of the terrain supports lighting
676 static bool feat_supports_lighting(byte feat)
678 if (is_trap(feat)) return streq(ANGBAND_GRAF, "new");
696 case FEAT_WALL_EXTRA:
697 case FEAT_WALL_INNER:
698 case FEAT_WALL_OUTER:
699 case FEAT_WALL_SOLID:
700 case FEAT_PERM_EXTRA:
701 case FEAT_PERM_INNER:
702 case FEAT_PERM_OUTER:
703 case FEAT_PERM_SOLID:
704 case FEAT_MINOR_GLYPH:
705 case FEAT_DEEP_WATER:
706 case FEAT_SHAL_WATER:
713 case FEAT_DEEP_GRASS:
724 * This array lists the effects of "brightness" on various "base" colours.
726 * This is used to do dynamic lighting effects in ascii :-)
727 * At the moment, only the various "floor" tiles are affected.
729 * The layout of the array is [x][0] = light and [x][1] = dark.
732 static byte lighting_colours[16][2] =
735 {TERM_L_DARK, TERM_DARK},
738 {TERM_YELLOW, TERM_SLATE},
741 {TERM_WHITE, TERM_L_DARK},
744 {TERM_L_UMBER, TERM_UMBER},
747 {TERM_RED, TERM_RED},
750 {TERM_L_GREEN, TERM_GREEN},
753 {TERM_BLUE, TERM_BLUE},
756 {TERM_L_UMBER, TERM_RED},
759 {TERM_SLATE, TERM_L_DARK},
762 {TERM_WHITE, TERM_SLATE},
765 {TERM_L_RED, TERM_BLUE},
768 {TERM_YELLOW, TERM_ORANGE},
771 {TERM_L_RED, TERM_L_RED},
774 {TERM_L_GREEN, TERM_GREEN},
777 {TERM_L_BLUE, TERM_L_BLUE},
780 {TERM_L_UMBER, TERM_UMBER}
784 * Extract the attr/char to display at the given (legal) map location
786 * Basically, we "paint" the chosen attr/char in several passes, starting
787 * with any known "terrain features" (defaulting to darkness), then adding
788 * any known "objects", and finally, adding any known "monsters". This
789 * is not the fastest method but since most of the calls to this function
790 * are made for grids with no monsters or objects, it is fast enough.
792 * Note that this function, if used on the grid containing the "player",
793 * will return the attr/char of the grid underneath the player, and not
794 * the actual player attr/char itself, allowing a lot of optimization
795 * in various "display" functions.
797 * Note that the "zero" entry in the feature/object/monster arrays are
798 * used to provide "special" attr/char codes, with "monster zero" being
799 * used for the player attr/char, "object zero" being used for the "stack"
800 * attr/char, and "feature zero" being used for the "nothing" attr/char,
801 * though this function makes use of only "feature zero".
803 * Note that monsters can have some "special" flags, including "ATTR_MULTI",
804 * which means their color changes, and "ATTR_CLEAR", which means they take
805 * the color of whatever is under them, and "CHAR_CLEAR", which means that
806 * they take the symbol of whatever is under them. Technically, the flag
807 * "CHAR_MULTI" is supposed to indicate that a monster looks strange when
808 * examined, but this flag is currently ignored.
810 * Currently, we do nothing with multi-hued objects, because there are
811 * not any. If there were, they would have to set "shimmer_objects"
812 * when they were created, and then new "shimmer" code in "dungeon.c"
813 * would have to be created handle the "shimmer" effect, and the code
814 * in "cave.c" would have to be updated to create the shimmer effect.
816 * Note the effects of hallucination. Objects always appear as random
817 * "objects", monsters as random "monsters", and normal grids occasionally
818 * appear as random "monsters" or "objects", but note that these random
819 * "monsters" and "objects" are really just "colored ascii symbols".
821 * Note that "floors" and "invisible traps" (and "zero" features) are
822 * drawn as "floors" using a special check for optimization purposes,
823 * and these are the only features which get drawn using the special
824 * lighting effects activated by "view_special_lite".
826 * Note the use of the "mimic" field in the "terrain feature" processing,
827 * which allows any feature to "pretend" to be another feature. This is
828 * used to "hide" secret doors, and to make all "doors" appear the same,
829 * and all "walls" appear the same, and "hidden" treasure stay hidden.
830 * It is possible to use this field to make a feature "look" like a floor,
831 * but the "special lighting effects" for floors will not be used.
833 * Note the use of the new "terrain feature" information. Note that the
834 * assumption that all interesting "objects" and "terrain features" are
835 * memorized allows extremely optimized processing below. Note the use
836 * of separate flags on objects to mark them as memorized allows a grid
837 * to have memorized "terrain" without granting knowledge of any object
838 * which may appear in that grid.
840 * Note the efficient code used to determine if a "floor" grid is
841 * "memorized" or "viewable" by the player, where the test for the
842 * grid being "viewable" is based on the facts that (1) the grid
843 * must be "lit" (torch-lit or perma-lit), (2) the grid must be in
844 * line of sight, and (3) the player must not be blind, and uses the
845 * assumption that all torch-lit grids are in line of sight.
847 * Note that floors (and invisible traps) are the only grids which are
848 * not memorized when seen, so only these grids need to check to see if
849 * the grid is "viewable" to the player (if it is not memorized). Since
850 * most non-memorized grids are in fact walls, this induces *massive*
851 * efficiency, at the cost of *forcing* the memorization of non-floor
852 * grids when they are first seen. Note that "invisible traps" are
853 * always treated exactly like "floors", which prevents "cheating".
855 * Note the "special lighting effects" which can be activated for floor
856 * grids using the "view_special_lite" option (for "white" floor grids),
857 * causing certain grids to be displayed using special colors. If the
858 * player is "blind", we will use "dark gray", else if the grid is lit
859 * by the torch, and the "view_yellow_lite" option is set, we will use
860 * "yellow", else if the grid is "dark", we will use "dark gray", else
861 * if the grid is not "viewable", and the "view_bright_lite" option is
862 * set, and the we will use "slate" (gray). We will use "white" for all
863 * other cases, in particular, for illuminated viewable floor grids.
865 * Note the "special lighting effects" which can be activated for wall
866 * grids using the "view_granite_lite" option (for "white" wall grids),
867 * causing certain grids to be displayed using special colors. If the
868 * player is "blind", we will use "dark gray", else if the grid is lit
869 * by the torch, and the "view_yellow_lite" option is set, we will use
870 * "yellow", else if the "view_bright_lite" option is set, and the grid
871 * is not "viewable", or is "dark", or is glowing, but not when viewed
872 * from the player's current location, we will use "slate" (gray). We
873 * will use "white" for all other cases, in particular, for correctly
874 * illuminated viewable wall grids.
876 * Note that, when "view_granite_lite" is set, we use an inline version
877 * of the "player_can_see_bold()" function to check the "viewability" of
878 * grids when the "view_bright_lite" option is set, and we do NOT use
879 * any special colors for "dark" wall grids, since this would allow the
880 * player to notice the walls of illuminated rooms from a hallway that
881 * happened to run beside the room. The alternative, by the way, would
882 * be to prevent the generation of hallways next to rooms, but this
883 * would still allow problems when digging towards a room.
885 * Note that bizarre things must be done when the "attr" and/or "char"
886 * codes have the "high-bit" set, since these values are used to encode
887 * various "special" pictures in some versions, and certain situations,
888 * such as "multi-hued" or "clear" monsters, cause the attr/char codes
889 * to be "scrambled" in various ways.
891 * Note that eventually we may use the "&" symbol for embedded treasure,
892 * and use the "*" symbol to indicate multiple objects, though this will
893 * have to wait for Angband 2.8.0 or later. Note that currently, this
894 * is not important, since only one object or terrain feature is allowed
895 * in each grid. If needed, "k_info[0]" will hold the "stack" attr/char.
897 * Note the assumption that doing "x_ptr = &x_info[x]" plus a few of
898 * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect
899 * then a whole lot of code should be changed... XXX XXX
901 #ifdef USE_TRANSPARENCY
902 void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
903 #else /* USE_TRANSPARENCY */
904 void map_info(int y, int x, byte *ap, char *cp)
905 #endif /* USE_TRANSPARENCY */
911 s16b this_o_idx, next_o_idx = 0;
921 /* Feature code (applying "mimic" field) */
922 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
925 if ((feat <= FEAT_INVIS) || (feat == FEAT_DIRT) || (feat == FEAT_GRASS))
927 /* Memorized (or visible) floor */
928 if ((c_ptr->info & CAVE_MARK) ||
929 (((c_ptr->info & CAVE_LITE) || (c_ptr->info & CAVE_MNLT) ||
930 ((c_ptr->info & CAVE_GLOW) &&
931 (c_ptr->info & CAVE_VIEW))) &&
935 f_ptr = &f_info[feat];
943 /* Special lighting effects */
944 if (view_special_lite && (!p_ptr->wild_mode) && ((a == TERM_WHITE) || use_graphics))
952 * feat_supports_lighting(feat)
953 * is always TRUE here
956 /* Use a dark tile */
961 /* Use "dark gray" */
966 /* Handle "torch-lit" grids */
967 else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
970 if (view_yellow_lite && !p_ptr->wild_mode)
975 * feat_supports_lighting(feat)
976 * is always TRUE here
979 /* Use a brightly lit tile */
990 /* Handle "dark" grids */
991 else if (!(c_ptr->info & CAVE_GLOW))
996 * feat_supports_lighting(feat)
997 * is always TRUE here
1000 /* Use a dark tile */
1005 /* Use "dark gray" */
1010 /* Handle "out-of-sight" grids */
1011 else if (!(c_ptr->info & CAVE_VIEW))
1014 if (view_bright_lite && !p_ptr->wild_mode)
1019 * feat_supports_lighting(feat)
1020 * is always TRUE here
1023 /* Use a dark tile */
1039 /* Unsafe cave grid -- idea borrowed from Unangband */
1040 if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
1041 feat = FEAT_UNDETECTD;
1045 /* Access darkness */
1046 f_ptr = &f_info[feat];
1059 /* Memorized grids */
1060 if ((c_ptr->info & CAVE_MARK) && (view_granite_lite || new_ascii_graphics))
1062 /* Access feature */
1063 f_ptr = &f_info[feat];
1071 if (new_ascii_graphics)
1073 /* Handle "blind" */
1076 if (is_ascii_graphics(c,a))
1078 /* Use darkened colour */
1079 a = lighting_colours[a][1];
1081 else if (use_graphics && feat_supports_lighting(feat))
1083 /* Use a dark tile */
1088 /* Handle "torch-lit" grids */
1089 else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
1092 if (view_yellow_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
1094 if (is_ascii_graphics(c,a))
1096 /* Use lightened colour */
1097 a = lighting_colours[a][0];
1099 else if (use_graphics &&
1100 feat_supports_lighting(feat))
1102 /* Use a brightly lit tile */
1108 /* Handle "view_bright_lite" */
1109 else if (view_bright_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(c,a)))
1112 if (!(c_ptr->info & CAVE_VIEW))
1114 if (is_ascii_graphics(c,a))
1116 /* Use darkened colour */
1117 a = lighting_colours[a][1];
1119 else if (use_graphics && feat_supports_lighting(feat))
1121 /* Use a dark tile */
1127 else if (!(c_ptr->info & CAVE_GLOW))
1129 if (is_ascii_graphics(c,a))
1131 /* Use darkened colour */
1132 a = lighting_colours[a][1];
1137 /* Special lighting effects */
1138 else if (view_granite_lite && !p_ptr->wild_mode &&
1139 (((a == TERM_WHITE) && !use_graphics) ||
1140 (use_graphics && feat_supports_lighting(feat))))
1142 /* Handle "blind" */
1147 /* Use a dark tile */
1152 /* Use "dark gray" */
1157 /* Handle "torch-lit" grids */
1158 else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
1161 if (view_yellow_lite && !p_ptr->wild_mode)
1165 /* Use a brightly lit tile */
1176 /* Handle "view_bright_lite" */
1177 else if (view_bright_lite && !p_ptr->wild_mode)
1180 if (!(c_ptr->info & CAVE_VIEW))
1184 /* Use a dark tile */
1195 else if (!(c_ptr->info & CAVE_GLOW))
1199 /* Use a lit tile */
1208 /* Not glowing correctly */
1213 /* Hack -- move towards player */
1214 yy = (y < py) ? (y + 1) : (y > py) ? (y - 1) : y;
1215 xx = (x < px) ? (x + 1) : (x > px) ? (x - 1) : x;
1217 /* Check for "local" illumination */
1218 if (!(cave[yy][xx].info & CAVE_GLOW))
1222 /* Use a lit tile */
1235 /* "Simple Lighting" */
1238 /* Handle "blind" */
1239 if (!(c_ptr->info & CAVE_MARK))
1241 /* Unsafe cave grid -- idea borrowed from Unangband */
1242 if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
1243 feat = FEAT_UNDETECTD;
1248 /* Access feature */
1249 f_ptr = &f_info[feat];
1259 if (feat_priority == -1)
1264 case FEAT_UNDETECTD:
1271 case FEAT_TRAP_TRAPDOOR:
1273 case FEAT_TRAP_SPIKED_PIT:
1274 case FEAT_TRAP_POISON_PIT:
1275 case FEAT_TRAP_TY_CURSE:
1276 case FEAT_TRAP_TELEPORT:
1277 case FEAT_TRAP_FIRE:
1278 case FEAT_TRAP_ACID:
1279 case FEAT_TRAP_SLOW:
1280 case FEAT_TRAP_LOSE_STR:
1281 case FEAT_TRAP_LOSE_DEX:
1282 case FEAT_TRAP_LOSE_CON:
1283 case FEAT_TRAP_BLIND:
1284 case FEAT_TRAP_CONFUSE:
1285 case FEAT_TRAP_POISON:
1286 case FEAT_TRAP_SLEEP:
1287 case FEAT_TRAP_TRAPS:
1288 case FEAT_TRAP_ALARM:
1292 case FEAT_DEEP_GRASS:
1300 case FEAT_WALL_EXTRA:
1301 case FEAT_WALL_INNER:
1302 case FEAT_WALL_OUTER:
1303 case FEAT_WALL_SOLID:
1304 case FEAT_DEEP_WATER:
1305 case FEAT_SHAL_WATER:
1306 case FEAT_DEEP_LAVA:
1307 case FEAT_SHAL_LAVA:
1313 /* Now a days treasere grid is too many */
1318 case FEAT_PERM_EXTRA:
1319 case FEAT_PERM_INNER:
1320 case FEAT_PERM_OUTER:
1321 case FEAT_PERM_SOLID:
1325 /* default is feat_priority = 20; (doors and stores) */
1328 case FEAT_MINOR_GLYPH:
1330 case FEAT_PATTERN_START:
1331 case FEAT_PATTERN_1:
1332 case FEAT_PATTERN_2:
1333 case FEAT_PATTERN_3:
1334 case FEAT_PATTERN_4:
1335 case FEAT_PATTERN_END:
1336 case FEAT_PATTERN_OLD:
1337 case FEAT_PATTERN_XTRA1:
1338 case FEAT_PATTERN_XTRA2:
1342 /* objects have feat_priority = 20 */
1343 /* monsters have feat_priority = 30 */
1347 case FEAT_QUEST_ENTER:
1348 case FEAT_QUEST_EXIT:
1349 case FEAT_QUEST_DOWN:
1351 case FEAT_LESS_LESS:
1352 case FEAT_MORE_MORE:
1364 #ifdef USE_TRANSPARENCY
1365 /* Save the terrain info for the transparency effects */
1368 #endif /* USE_TRANSPARENCY */
1374 /* Hack -- rare random hallucination, except on outer dungeon walls */
1375 if (p_ptr->image && (feat < FEAT_PERM_SOLID) && !randint0(256))
1378 image_random(ap, cp);
1382 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1386 /* Acquire object */
1387 o_ptr = &o_list[this_o_idx];
1389 /* Acquire next object */
1390 next_o_idx = o_ptr->next_o_idx;
1392 /* Memorized objects */
1395 if (display_autopick)
1399 match_autopick = is_autopick(o_ptr);
1400 if(match_autopick == -1)
1403 act = autopick_list[match_autopick].action;
1405 if ((act & DO_DISPLAY) && (act & display_autopick))
1407 autopick_obj = o_ptr;
1411 match_autopick = -1;
1416 (*cp) = object_char(o_ptr);
1419 (*ap) = object_attr(o_ptr);
1423 /* Hack -- hallucination */
1424 if (p_ptr->image) image_object(ap, cp);
1432 /* Handle monsters */
1433 if (c_ptr->m_idx && display_autopick == 0 )
1435 monster_type *m_ptr = &m_list[c_ptr->m_idx];
1437 /* Visible monster */
1440 monster_race *r_ptr;
1441 r_ptr = &r_info[m_ptr->ap_r_idx];
1451 /* Mimics' colors vary */
1452 if (strchr("\"!=", c) && !(r_ptr->flags1 & RF1_UNIQUE))
1457 /* Use semi-random attr */
1458 (*ap) = c_ptr->m_idx % 15 + 1;
1461 /* Special attr/char codes */
1462 else if ((a & 0x80) && (c & 0x80))
1471 /* Multi-hued monster */
1472 else if (r_ptr->flags1 & (RF1_ATTR_MULTI))
1474 /* Is it a shapechanger? */
1475 if (r_ptr->flags2 & (RF2_SHAPECHANGER))
1479 if (!(streq(ANGBAND_SYS, "ibm")))
1481 (*cp) = r_info[randint1(max_r_idx-1)].x_char;
1482 (*ap) = r_info[randint1(max_r_idx-1)].x_attr;
1486 int n = strlen(image_monster_hack_ibm);
1487 (*cp) = (image_monster_hack_ibm[randint0(n)]);
1490 (*ap) = randint1(15);
1495 (*cp) = (one_in_(25) ?
1496 image_object_hack[randint0(strlen(image_object_hack))] :
1497 image_monster_hack[randint0(strlen(image_monster_hack))]);
1503 /* Multi-hued attr */
1504 if (r_ptr->flags2 & RF2_ATTR_ANY)
1505 (*ap) = randint1(15);
1506 else switch (randint1(7))
1518 (*ap) = TERM_L_GREEN;
1524 (*ap) = TERM_L_DARK;
1532 /* Normal monster (not "clear" in any way) */
1533 else if (!(r_ptr->flags1 & (RF1_ATTR_CLEAR | RF1_CHAR_CLEAR)))
1542 /* Hack -- Bizarre grid under monster */
1543 else if ((*ap & 0x80) || (*cp & 0x80))
1555 /* Normal (non-clear char) monster */
1556 if (!(r_ptr->flags1 & (RF1_CHAR_CLEAR)))
1562 /* Normal (non-clear attr) monster */
1563 else if (!(r_ptr->flags1 & (RF1_ATTR_CLEAR)))
1570 /* Hack -- hallucination */
1573 /* Hallucinatory monster */
1574 image_monster(ap, cp);
1579 /* Handle "player" */
1580 if ((y == py) && (x == px))
1582 monster_race *r_ptr = &r_info[0];
1586 /* Get the "player" attr */
1589 /* Get the "player" char */
1592 #ifdef VARIABLE_PLAYER_GRAPH
1594 if (!streq(ANGBAND_GRAF, "new"))
1596 if (streq(ANGBAND_SYS,"ibm"))
1598 if (use_graphics && player_symbols)
1600 if (p_ptr->psex == SEX_FEMALE) c = (char)242;
1601 switch (p_ptr->pclass)
1604 if (p_ptr->lev < 20)
1610 case CLASS_WARRIOR_MAGE:
1611 case CLASS_RED_MAGE:
1612 if (p_ptr->lev < 20)
1617 case CLASS_CHAOS_WARRIOR:
1622 while (a == TERM_DARK);
1625 case CLASS_HIGH_MAGE:
1626 case CLASS_SORCERER:
1627 case CLASS_MAGIC_EATER:
1628 case CLASS_BLUE_MAGE:
1629 if (p_ptr->lev < 20)
1637 if (p_ptr->lev < 20)
1645 if (p_ptr->lev < 20)
1652 if (p_ptr->lev < 20)
1659 case CLASS_BERSERKER:
1661 if (p_ptr->lev < 20)
1667 case CLASS_MINDCRAFTER:
1668 case CLASS_FORCETRAINER:
1669 case CLASS_MIRROR_MASTER:
1670 if (p_ptr->lev < 20)
1676 default: /* Unknown */
1680 switch (p_ptr->prace)
1692 case RACE_HALF_TROLL:
1702 case RACE_HALF_OGRE:
1705 case RACE_HALF_GIANT:
1706 case RACE_HALF_TITAN:
1725 case RACE_DRACONIAN:
1726 if (p_ptr->lev < 20)
1728 else if (p_ptr->lev < 40)
1733 case RACE_MIND_FLAYER:
1744 if (p_ptr->pclass == CLASS_MAGE ||
1745 p_ptr->pclass == CLASS_PRIEST ||
1746 p_ptr->pclass == CLASS_HIGH_MAGE ||
1747 p_ptr->pclass == CLASS_SORCERER ||
1748 p_ptr->pclass == CLASS_MONK ||
1749 p_ptr->pclass == CLASS_FORCETRAINER ||
1750 p_ptr->pclass == CLASS_BLUE_MAGE ||
1751 p_ptr->pclass == CLASS_MIRROR_MASTER ||
1752 p_ptr->pclass == CLASS_MINDCRAFTER)
1786 #endif /* VARIABLE_PLAYER_GRAPH */
1794 * Table of Ascii-to-Zenkaku
1795 * ¡Ö¢£¡×¤ÏÆóÇÜÉýƦÉå¤ÎÆâÉô¥³¡¼¥É¤Ë»ÈÍÑ¡£
1797 static char ascii_to_zenkaku[2*128+1] = "\
1798 ¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿\
1799 £°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©\
1800 ¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï\
1801 £Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡À¡Ï¡°¡²\
1802 ¡Æ£á£â£ã£ä£å£æ£ç£è£é£ê£ë£ì£í£î£ï\
1803 £ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡Á¢£";
1807 * Prepare Bigtile or 2-bytes character attr/char pairs
1809 void bigtile_attr(char *cp, byte *ap, char *cp2, byte *ap2)
1811 if ((*ap & 0x80) && (*cp & 0x80))
1819 if (isprint(*cp) || *cp == 127)
1821 *ap2 = (*ap) | 0xf0;
1822 *cp2 = ascii_to_zenkaku[2*(*cp-' ') + 1];
1823 *cp = ascii_to_zenkaku[2*(*cp-' ')];
1834 * Calculate panel colum of a location in the map
1836 static int panel_col_of(int col)
1838 col -= panel_col_min;
1839 if (use_bigtile) col *= 2;
1845 * Moves the cursor to a given MAP (y,x) location
1847 void move_cursor_relative(int row, int col)
1849 /* Real co-ords convert to screen positions */
1850 row -= panel_row_prt;
1853 Term_gotoxy(panel_col_of(col), row);
1859 * Place an attr/char pair at the given map coordinate, if legal.
1861 void print_rel(char c, byte a, int y, int x)
1866 /* Only do "legal" locations */
1867 if (panel_contains(y, x))
1869 /* Hack -- fake monochrome */
1870 if (!use_graphics || streq(ANGBAND_SYS, "ibm"))
1872 if (world_monster) a = TERM_DARK;
1873 else if (p_ptr->invuln || world_player) a = TERM_WHITE;
1874 else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
1875 else if (p_ptr->wraith_form) a = TERM_L_DARK;
1878 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
1880 /* Draw the char using the attr */
1881 Term_draw(panel_col_of(x), y-panel_row_prt, a, c);
1883 Term_draw(panel_col_of(x)+1, y-panel_row_prt, a2, c2);
1892 * Memorize interesting viewable object/features in the given grid
1894 * This function should only be called on "legal" grids.
1896 * This function will memorize the object and/or feature in the given
1897 * grid, if they are (1) viewable and (2) interesting. Note that all
1898 * objects are interesting, all terrain features except floors (and
1899 * invisible traps) are interesting, and floors (and invisible traps)
1900 * are interesting sometimes (depending on various options involving
1901 * the illumination of floor grids).
1903 * The automatic memorization of all objects and non-floor terrain
1904 * features as soon as they are displayed allows incredible amounts
1905 * of optimization in various places, especially "map_info()".
1907 * Note that the memorization of objects is completely separate from
1908 * the memorization of terrain features, preventing annoying floor
1909 * memorization when a detected object is picked up from a dark floor,
1910 * and object memorization when an object is dropped into a floor grid
1911 * which is memorized but out-of-sight.
1913 * This function should be called every time the "memorization" of
1914 * a grid (or the object in a grid) is called into question, such
1915 * as when an object is created in a grid, when a terrain feature
1916 * "changes" from "floor" to "non-floor", when any grid becomes
1917 * "illuminated" or "viewable", and when a "floor" grid becomes
1920 * Note the relatively efficient use of this function by the various
1921 * "update_view()" and "update_lite()" calls, to allow objects and
1922 * terrain features to be memorized (and drawn) whenever they become
1923 * viewable or illuminated in any way, but not when they "maintain"
1924 * or "lose" their previous viewability or illumination.
1926 * Note the butchered "internal" version of "player_can_see_bold()",
1927 * optimized primarily for the most common cases, that is, for the
1928 * non-marked floor grids.
1930 void note_spot(int y, int x)
1932 cave_type *c_ptr = &cave[y][x];
1934 s16b this_o_idx, next_o_idx = 0;
1938 /* Feature code (applying "mimic" field) */
1939 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
1942 /* Blind players see nothing */
1943 if (p_ptr->blind) return;
1945 /* Analyze non-torch-lit grids */
1946 if (!(c_ptr->info & (CAVE_LITE)))
1948 /* Require line of sight to the grid */
1949 if (!(c_ptr->info & (CAVE_VIEW))) return;
1951 if (p_ptr->pclass != CLASS_NINJA)
1953 /* Require "perma-lite" of the grid */
1954 if (!(c_ptr->info & (CAVE_GLOW | CAVE_MNLT))) return;
1959 /* Hack -- memorize objects */
1960 for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
1962 object_type *o_ptr = &o_list[this_o_idx];
1964 /* Acquire next object */
1965 next_o_idx = o_ptr->next_o_idx;
1967 /* Memorize objects */
1968 o_ptr->marked |= OM_FOUND;
1972 /* Hack -- memorize grids */
1973 if (!(c_ptr->info & (CAVE_MARK)))
1975 if (p_ptr->pclass == CLASS_NINJA)
1977 c_ptr->info |= (CAVE_MARK);
1979 /* Handle floor grids first */
1980 if ((feat <= FEAT_INVIS) || (feat == FEAT_DIRT) || (feat == FEAT_GRASS))
1982 /* Option -- memorize all torch-lit floors */
1983 if (view_torch_grids && (c_ptr->info & (CAVE_LITE | CAVE_MNLT)))
1986 c_ptr->info |= (CAVE_MARK);
1989 /* Option -- memorize all perma-lit floors */
1990 else if (view_perma_grids && (c_ptr->info & (CAVE_GLOW)))
1993 c_ptr->info |= (CAVE_MARK);
1997 /* Memorize normal grids */
1998 else if (cave_floor_grid(c_ptr))
2001 c_ptr->info |= (CAVE_MARK);
2004 /* Memorize torch-lit walls */
2005 else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
2008 c_ptr->info |= (CAVE_MARK);
2011 /* Memorize certain non-torch-lit wall grids */
2016 /* Hack -- move one grid towards player */
2017 yy = (y < py) ? (y + 1) : (y > py) ? (y - 1) : y;
2018 xx = (x < px) ? (x + 1) : (x > px) ? (x - 1) : x;
2020 /* Check for "local" illumination */
2021 if (cave[yy][xx].info & (CAVE_GLOW))
2024 c_ptr->info |= (CAVE_MARK);
2031 void display_dungeon(void)
2037 #ifdef USE_TRANSPARENCY
2040 #endif /* USE_TRANSPARENCY */
2042 for (x = px - Term->wid / 2 + 1; x <= px + Term->wid / 2; x++)
2044 for (y = py - Term->hgt / 2 + 1; y <= py + Term->hgt / 2; y++)
2046 if (in_bounds2(y, x))
2049 #ifdef USE_TRANSPARENCY
2050 /* Examine the grid */
2051 map_info(y, x, &a, &c, &ta, &tc);
2052 #else /* USE_TRANSPARENCY */
2053 /* Examine the grid */
2054 map_info(y, x, &a, &c);
2055 #endif /* USE_TRANSPARENCY */
2057 /* Hack -- fake monochrome */
2058 if (!use_graphics || streq(ANGBAND_SYS, "ibm"))
2060 if (world_monster) a = TERM_DARK;
2061 else if (p_ptr->invuln || world_player) a = TERM_WHITE;
2062 else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
2063 else if (p_ptr->wraith_form) a = TERM_L_DARK;
2066 #ifdef USE_TRANSPARENCY
2067 /* Hack -- Queue it */
2068 Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c, ta, tc);
2069 #else /* USE_TRANSPARENCY */
2070 /* Hack -- Queue it */
2071 Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c);
2072 #endif /* USE_TRANSPARENCY */
2077 /* Clear out-of-bound tiles */
2079 /* Access darkness */
2080 feature_type *f_ptr = &f_info[FEAT_NONE];
2088 #ifdef USE_TRANSPARENCY
2089 /* Hack -- Queue it */
2090 Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c, ta, tc);
2091 #else /* USE_TRANSPARENCY */
2092 /* Hack -- Queue it */
2093 Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c);
2094 #endif /* USE_TRANSPARENCY */
2102 * Redraw (on the screen) a given MAP location
2104 * This function should only be called on "legal" grids
2106 void lite_spot(int y, int x)
2108 /* Redraw if on screen */
2109 if (panel_contains(y, x) && in_bounds2(y, x))
2114 #ifdef USE_TRANSPARENCY
2118 /* Examine the grid */
2119 map_info(y, x, &a, &c, &ta, &tc);
2120 #else /* USE_TRANSPARENCY */
2121 /* Examine the grid */
2122 map_info(y, x, &a, &c);
2123 #endif /* USE_TRANSPARENCY */
2125 /* Hack -- fake monochrome */
2126 if (!use_graphics || streq(ANGBAND_SYS, "ibm"))
2128 if (world_monster) a = TERM_DARK;
2129 else if (p_ptr->invuln || world_player) a = TERM_WHITE;
2130 else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
2131 else if (p_ptr->wraith_form) a = TERM_L_DARK;
2135 if (use_bigtile && !(a & 0x80) && (isprint(c) || c == 127))
2137 /* Term_queue_chars ¤ÏÁ´³ÑASCIIÃÏ·Á¤òÀµ¤·¤¯update¤¹¤ë¡£ */
2138 Term_queue_chars(panel_col_of(x), y-panel_row_prt, 2, a, &ascii_to_zenkaku[2*(c-' ')]);
2143 #ifdef USE_TRANSPARENCY
2144 /* Hack -- Queue it */
2145 Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
2147 Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, 255, -1, 0, 0);
2148 #else /* USE_TRANSPARENCY */
2149 /* Hack -- Queue it */
2150 Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c);
2152 Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, 255, -1);
2153 #endif /* USE_TRANSPARENCY */
2155 /* Update sub-windows */
2156 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
2162 * Prints the map of the dungeon
2164 * Note that, for efficiency, we contain an "optimized" version
2165 * of both "lite_spot()" and "print_rel()", and that we use the
2166 * "lite_spot()" function to display the player grid, if needed.
2174 s16b xmin, xmax, ymin, ymax;
2178 bool fake_monochrome = (!use_graphics || streq(ANGBAND_SYS, "ibm"));
2181 Term_get_size(&wid, &hgt);
2183 /* Remove map offset */
2187 /* Access the cursor state */
2188 (void)Term_get_cursor(&v);
2190 /* Hide the cursor */
2191 (void)Term_set_cursor(0);
2194 xmin = (0 < panel_col_min) ? panel_col_min : 0;
2195 xmax = (cur_wid - 1 > panel_col_max) ? panel_col_max : cur_wid - 1;
2196 ymin = (0 < panel_row_min) ? panel_row_min : 0;
2197 ymax = (cur_hgt - 1 > panel_row_max) ? panel_row_max : cur_hgt - 1;
2199 /* Bottom section of screen */
2200 for (y = 1; y <= ymin - panel_row_prt; y++)
2202 /* Erase the section */
2203 Term_erase(COL_MAP, y, wid);
2206 /* Top section of screen */
2207 for (y = ymax - panel_row_prt; y <= hgt; y++)
2209 /* Erase the section */
2210 Term_erase(COL_MAP, y, wid);
2214 for (y = ymin; y <= ymax; y++)
2216 /* Scan the columns of row "y" */
2217 for (x = xmin; x <= xmax; x++)
2222 #ifdef USE_TRANSPARENCY
2226 /* Determine what is there */
2227 map_info(y, x, &a, &c, &ta, &tc);
2229 /* Determine what is there */
2230 map_info(y, x, &a, &c);
2233 /* Hack -- fake monochrome */
2234 if (fake_monochrome)
2236 if (world_monster) a = TERM_DARK;
2237 else if (p_ptr->invuln || world_player) a = TERM_WHITE;
2238 else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
2239 else if (p_ptr->wraith_form) a = TERM_L_DARK;
2242 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
2244 /* Efficiency -- Redraw that grid of the map */
2245 #ifdef USE_TRANSPARENCY
2246 Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
2247 if (use_bigtile) Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, a2, c2, 0, 0);
2249 Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c);
2250 if (use_bigtile) Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, a2, c2);
2255 /* Display player */
2258 /* Restore the cursor */
2259 (void)Term_set_cursor(v);
2265 * print project path
2267 void prt_path(int y, int x)
2272 int default_color = TERM_SLATE;
2273 bool fake_monochrome = (!use_graphics || streq(ANGBAND_SYS, "ibm"));
2275 if (!display_path) return;
2276 if (-1 == project_length)
2279 /* Get projection path */
2280 path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), py, px, y, x, PROJECT_PATH|PROJECT_THRU);
2283 p_ptr->redraw |= (PR_MAP);
2289 for (i = 0; i < path_n; i++)
2291 int ny = GRID_Y(path_g[i]);
2292 int nx = GRID_X(path_g[i]);
2294 if (panel_contains(ny, nx))
2296 byte a2, a = default_color;
2299 #ifdef USE_TRANSPARENCY
2304 if (cave[ny][nx].m_idx && m_list[cave[ny][nx].m_idx].ml)
2306 /* Determine what is there */
2307 #ifdef USE_TRANSPARENCY
2308 map_info(ny, nx, &a, &c, &ta, &tc);
2310 map_info(ny, nx, &a, &c);
2314 else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
2316 else if (a == default_color)
2320 if (fake_monochrome)
2322 if (world_monster) a = TERM_DARK;
2323 else if (p_ptr->invuln || world_player) a = TERM_WHITE;
2324 else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) a = TERM_WHITE;
2325 else if (p_ptr->wraith_form) a = TERM_L_DARK;
2329 if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
2331 /* Hack -- Queue it */
2332 #ifdef USE_TRANSPARENCY
2333 Term_queue_char(panel_col_of(nx), ny-panel_row_prt, a, c, ta, tc);
2334 if (use_bigtile) Term_queue_char(panel_col_of(nx)+1, ny-panel_row_prt, a, c2, 0, 0);
2336 Term_queue_char(panel_col_of(nx), ny-panel_row_prt, a, c);
2337 if (use_bigtile) Term_queue_char(panel_col_of(nx)+1, ny-panel_row_prt, a, c2);
2342 if ((cave[ny][nx].info & CAVE_MARK) && !cave_floor_bold(ny, nx)) break;
2345 if (nx == x && ny == y) default_color = TERM_L_DARK;
2350 static cptr simplify_list[][2] =
2357 {"^Amulet of ", "\""},
2358 {"^Scroll of ", "?"},
2359 {"^Scroll titled ", "?"},
2360 {"^Wand of " , "-"},
2362 {"^Staff of " , "_"},
2363 {"^Potion of ", "!"},
2375 static void display_shortened_item_name(object_type *o_ptr, int y)
2382 object_desc(buf, o_ptr, FALSE, 0);
2383 attr = tval_to_attr[o_ptr->tval % 128];
2389 strcpy(buf, "²¿¤«´ñ̯¤Êʪ");
2391 strcpy(buf, "something strange");
2395 for (c = buf; *c; c++)
2398 for (i = 0; simplify_list[i][1]; i++)
2400 cptr org_w = simplify_list[i][0];
2410 if (!strncmp(c, org_w, strlen(org_w)))
2413 cptr tmp = simplify_list[i][1];
2416 tmp = c + strlen(org_w);
2426 /* Ⱦ³Ñ 12 ʸ»úʬ¤ÇÀÚ¤ë */
2432 if(len + 2 > 12) break;
2439 if(len + 1 > 12) break;
2445 Term_putstr(0, y, 12, attr, buf);
2449 * Display a "small-scale" map of the dungeon in the active Term
2451 void display_map(int *cy, int *cx)
2468 /* Save lighting effects */
2469 bool old_view_special_lite = view_special_lite;
2470 bool old_view_granite_lite = view_granite_lite;
2472 bool fake_monochrome = (!use_graphics || streq(ANGBAND_SYS, "ibm"));
2474 int hgt, wid, yrat, xrat;
2476 int **match_autopick_yx;
2477 object_type ***object_autopick_yx;
2480 Term_get_size(&wid, &hgt);
2483 if (use_bigtile) wid /= 2;
2485 yrat = (cur_hgt + hgt - 1) / hgt;
2486 xrat = (cur_wid + wid - 1) / wid;
2488 /* Disable lighting effects */
2489 view_special_lite = FALSE;
2490 view_granite_lite = FALSE;
2492 /* Allocate the maps */
2493 C_MAKE(ma, (hgt + 2), byte_ptr);
2494 C_MAKE(mc, (hgt + 2), char_ptr);
2495 C_MAKE(mp, (hgt + 2), byte_ptr);
2496 C_MAKE(match_autopick_yx, (hgt + 2), sint_ptr);
2497 C_MAKE(object_autopick_yx, (hgt + 2), object_type **);
2499 /* Allocate and wipe each line map */
2500 for (y = 0; y < (hgt + 2); y++)
2502 /* Allocate one row each array */
2503 C_MAKE(ma[y], (wid + 2), byte);
2504 C_MAKE(mc[y], (wid + 2), char);
2505 C_MAKE(mp[y], (wid + 2), byte);
2506 C_MAKE(match_autopick_yx[y], (wid + 2), int);
2507 C_MAKE(object_autopick_yx[y], (wid + 2), object_type *);
2509 for (x = 0; x < wid + 2; ++x)
2511 match_autopick_yx[y][x] = -1;
2512 object_autopick_yx[y][x] = NULL;
2515 ma[y][x] = TERM_WHITE;
2523 /* Allocate the maps */
2524 C_MAKE(bigma, (cur_hgt + 2), byte_ptr);
2525 C_MAKE(bigmc, (cur_hgt + 2), char_ptr);
2526 C_MAKE(bigmp, (cur_hgt + 2), byte_ptr);
2528 /* Allocate and wipe each line map */
2529 for (y = 0; y < (cur_hgt + 2); y++)
2531 /* Allocate one row each array */
2532 C_MAKE(bigma[y], (cur_wid + 2), byte);
2533 C_MAKE(bigmc[y], (cur_wid + 2), char);
2534 C_MAKE(bigmp[y], (cur_wid + 2), byte);
2536 for (x = 0; x < cur_wid + 2; ++x)
2539 bigma[y][x] = TERM_WHITE;
2547 /* Fill in the map */
2548 for (i = 0; i < cur_wid; ++i)
2550 for (j = 0; j < cur_hgt; ++j)
2560 /* Extract the current attr/char at that map location */
2561 #ifdef USE_TRANSPARENCY
2562 map_info(j, i, &ta, &tc, &ta, &tc);
2563 #else /* USE_TRANSPARENCY */
2564 map_info(j, i, &ta, &tc);
2565 #endif /* USE_TRANSPARENCY */
2567 /* Extract the priority */
2570 if(match_autopick!=-1
2571 && (match_autopick_yx[y][x] == -1
2572 || match_autopick_yx[y][x] > match_autopick))
2574 match_autopick_yx[y][x] = match_autopick;
2575 object_autopick_yx[y][x] = autopick_obj;
2579 /* Save the char, attr and priority */
2580 bigmc[j+1][i+1] = tc;
2581 bigma[j+1][i+1] = ta;
2582 bigmp[j+1][i+1] = tp;
2586 for (j = 0; j < cur_hgt; ++j)
2588 for (i = 0; i < cur_wid; ++i)
2594 tc = bigmc[j+1][i+1];
2595 ta = bigma[j+1][i+1];
2596 tp = bigmp[j+1][i+1];
2598 /* rare feature has more priority */
2604 for (t = 0; t < 8; t++)
2606 if (tc == bigmc[j+1+ddy_cdd[t]][i+1+ddx_cdd[t]] &&
2607 ta == bigma[j+1+ddy_cdd[t]][i+1+ddx_cdd[t]])
2617 /* Save the char, attr and priority */
2630 /* Draw the corners */
2631 mc[0][0] = mc[0][x] = mc[y][0] = mc[y][x] = '+';
2633 /* Draw the horizontal edges */
2634 for (x = 1; x <= wid; x++) mc[0][x] = mc[y][x] = '-';
2636 /* Draw the vertical edges */
2637 for (y = 1; y <= hgt; y++) mc[y][0] = mc[y][x] = '|';
2640 /* Display each map line in order */
2641 for (y = 0; y < hgt + 2; ++y)
2643 /* Start a new line */
2644 Term_gotoxy(COL_MAP, y);
2646 /* Display the line */
2647 for (x = 0; x < wid + 2; ++x)
2652 /* Hack -- fake monochrome */
2653 if (fake_monochrome)
2655 if (world_monster) ta = TERM_DARK;
2656 else if (p_ptr->invuln || world_player) ta = TERM_WHITE;
2657 else if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] == MUSIC_INVULN)) ta = TERM_WHITE;
2658 else if (p_ptr->wraith_form) ta = TERM_L_DARK;
2661 if (use_bigtile) bigtile_attr(&tc, &ta, &c2, &a2);
2663 /* Add the character */
2665 if (use_bigtile) Term_addch(a2, c2);
2670 for (y = 1; y < hgt + 1; ++y)
2672 match_autopick = -1;
2673 for (x = 1; x <= wid; x++){
2674 if (match_autopick_yx[y][x] != -1 &&
2675 (match_autopick > match_autopick_yx[y][x] ||
2676 match_autopick == -1)){
2677 match_autopick = match_autopick_yx[y][x];
2678 autopick_obj = object_autopick_yx[y][x];
2682 /* Clear old display */
2683 Term_putstr(0, y, 12, 0, " ");
2685 if (match_autopick != -1)
2687 display_shortened_item_name(autopick_obj, y);
2690 char buf[13] = "\0";
2691 strncpy(buf,autopick_list[match_autopick].name,12);
2699 /* Player location */
2700 (*cy) = py / yrat + 1 + ROW_MAP;
2702 (*cx) = px / xrat + 1 + COL_MAP;
2704 (*cx) = (px / xrat + 1) * 2 + COL_MAP;
2706 /* Restore lighting effects */
2707 view_special_lite = old_view_special_lite;
2708 view_granite_lite = old_view_granite_lite;
2710 /* Free each line map */
2711 for (y = 0; y < (hgt + 2); y++)
2713 /* Free one row each array */
2714 C_FREE(ma[y], (wid + 2), byte);
2715 C_FREE(mc[y], (wid + 2), char);
2716 C_FREE(mp[y], (wid + 2), byte);
2717 C_FREE(match_autopick_yx[y], (wid + 2), int);
2718 C_FREE(object_autopick_yx[y], (wid + 2), object_type **);
2721 /* Free each line map */
2722 C_FREE(ma, (hgt + 2), byte_ptr);
2723 C_FREE(mc, (hgt + 2), char_ptr);
2724 C_FREE(mp, (hgt + 2), byte_ptr);
2725 C_FREE(match_autopick_yx, (hgt + 2), sint_ptr);
2726 C_FREE(object_autopick_yx, (hgt + 2), object_type **);
2728 /* Free each line map */
2729 for (y = 0; y < (cur_hgt + 2); y++)
2731 /* Free one row each array */
2732 C_FREE(bigma[y], (cur_wid + 2), byte);
2733 C_FREE(bigmc[y], (cur_wid + 2), char);
2734 C_FREE(bigmp[y], (cur_wid + 2), byte);
2737 /* Free each line map */
2738 C_FREE(bigma, (cur_hgt + 2), byte_ptr);
2739 C_FREE(bigmc, (cur_hgt + 2), char_ptr);
2740 C_FREE(bigmp, (cur_hgt + 2), byte_ptr);
2745 * Display a "small-scale" map of the dungeon for the player
2747 * Currently, the "player" is displayed on the map. XXX XXX XXX
2749 void do_cmd_view_map(void)
2754 /* Save the screen */
2759 prt("¤ªÂÔ¤Á²¼¤µ¤¤...", 0, 0);
2761 prt("Please wait...", 0, 0);
2767 /* Clear the screen */
2770 display_autopick = 0;
2772 /* Display the map */
2773 display_map(&cy, &cx);
2776 if(max_autopick && !p_ptr->wild_mode)
2778 display_autopick = ITEM_DISPLAY;
2785 int wid, hgt, row_message;
2787 Term_get_size(&wid, &hgt);
2788 row_message = hgt - 1;
2791 put_str("²¿¤«¥¡¼¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤('M':½¦¤¦ 'N':ÊüÃÖ 'D':M+N 'K':²õ¤¹¥¢¥¤¥Æ¥à¤òɽ¼¨)", row_message, 1);
2793 put_str(" Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items.", row_message, 1);
2796 /* Hilite the player */
2797 move_cursor(cy, cx);
2802 flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK);
2804 flag = DONT_AUTOPICK;
2806 flag = DO_AUTODESTROY;
2808 flag = (DO_AUTOPICK | DO_QUERY_AUTOPICK | DONT_AUTOPICK);
2814 if (~display_autopick & flag)
2815 display_autopick |= flag;
2817 display_autopick &= ~flag;
2818 /* Display the map */
2819 display_map(&cy, &cx);
2822 display_autopick = 0;
2828 put_str("²¿¤«¥¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 23, 30);
2830 put_str("Hit any key to continue", 23, 30);
2831 #endif /* Hilite the player */
2832 move_cursor(cy, cx);
2837 /* Restore the screen */
2846 * Some comments on the cave grid flags. -BEN-
2849 * One of the major bottlenecks in previous versions of Angband was in
2850 * the calculation of "line of sight" from the player to various grids,
2851 * such as monsters. This was such a nasty bottleneck that a lot of
2852 * silly things were done to reduce the dependancy on "line of sight",
2853 * for example, you could not "see" any grids in a lit room until you
2854 * actually entered the room, and there were all kinds of bizarre grid
2855 * flags to enable this behavior. This is also why the "call light"
2856 * spells always lit an entire room.
2858 * The code below provides functions to calculate the "field of view"
2859 * for the player, which, once calculated, provides extremely fast
2860 * calculation of "line of sight from the player", and to calculate
2861 * the "field of torch lite", which, again, once calculated, provides
2862 * extremely fast calculation of "which grids are lit by the player's
2863 * lite source". In addition to marking grids as "GRID_VIEW" and/or
2864 * "GRID_LITE", as appropriate, these functions maintain an array for
2865 * each of these two flags, each array containing the locations of all
2866 * of the grids marked with the appropriate flag, which can be used to
2867 * very quickly scan through all of the grids in a given set.
2869 * To allow more "semantically valid" field of view semantics, whenever
2870 * the field of view (or the set of torch lit grids) changes, all of the
2871 * grids in the field of view (or the set of torch lit grids) are "drawn"
2872 * so that changes in the world will become apparent as soon as possible.
2873 * This has been optimized so that only grids which actually "change" are
2874 * redrawn, using the "temp" array and the "GRID_TEMP" flag to keep track
2875 * of the grids which are entering or leaving the relevent set of grids.
2877 * These new methods are so efficient that the old nasty code was removed.
2879 * Note that there is no reason to "update" the "viewable space" unless
2880 * the player "moves", or walls/doors are created/destroyed, and there
2881 * is no reason to "update" the "torch lit grids" unless the field of
2882 * view changes, or the "light radius" changes. This means that when
2883 * the player is resting, or digging, or doing anything that does not
2884 * involve movement or changing the state of the dungeon, there is no
2885 * need to update the "view" or the "lite" regions, which is nice.
2887 * Note that the calls to the nasty "los()" function have been reduced
2888 * to a bare minimum by the use of the new "field of view" calculations.
2890 * I wouldn't be surprised if slight modifications to the "update_view()"
2891 * function would allow us to determine "reverse line-of-sight" as well
2892 * as "normal line-of-sight", which would allow monsters to use a more
2893 * "correct" calculation to determine if they can "see" the player. For
2894 * now, monsters simply "cheat" somewhat and assume that if the player
2895 * has "line of sight" to the monster, then the monster can "pretend"
2896 * that it has "line of sight" to the player.
2899 * The "update_lite()" function maintains the "CAVE_LITE" flag for each
2900 * grid and maintains an array of all "CAVE_LITE" grids.
2902 * This set of grids is the complete set of all grids which are lit by
2903 * the players light source, which allows the "player_can_see_bold()"
2904 * function to work very quickly.
2906 * Note that every "CAVE_LITE" grid is also a "CAVE_VIEW" grid, and in
2907 * fact, the player (unless blind) can always "see" all grids which are
2908 * marked as "CAVE_LITE", unless they are "off screen".
2911 * The "update_view()" function maintains the "CAVE_VIEW" flag for each
2912 * grid and maintains an array of all "CAVE_VIEW" grids.
2914 * This set of grids is the complete set of all grids within line of sight
2915 * of the player, allowing the "player_has_los_bold()" macro to work very
2919 * The current "update_view()" algorithm uses the "CAVE_XTRA" flag as a
2920 * temporary internal flag to mark those grids which are not only in view,
2921 * but which are also "easily" in line of sight of the player. This flag
2922 * is always cleared when we are done.
2925 * The current "update_lite()" and "update_view()" algorithms use the
2926 * "CAVE_TEMP" flag, and the array of grids which are marked as "CAVE_TEMP",
2927 * to keep track of which grids were previously marked as "CAVE_LITE" or
2928 * "CAVE_VIEW", which allows us to optimize the "screen updates".
2930 * The "CAVE_TEMP" flag, and the array of "CAVE_TEMP" grids, is also used
2931 * for various other purposes, such as spreading lite or darkness during
2932 * "lite_room()" / "unlite_room()", and for calculating monster flow.
2935 * Any grid can be marked as "CAVE_GLOW" which means that the grid itself is
2936 * in some way permanently lit. However, for the player to "see" anything
2937 * in the grid, as determined by "player_can_see()", the player must not be
2938 * blind, the grid must be marked as "CAVE_VIEW", and, in addition, "wall"
2939 * grids, even if marked as "perma lit", are only illuminated if they touch
2940 * a grid which is not a wall and is marked both "CAVE_GLOW" and "CAVE_VIEW".
2943 * To simplify various things, a grid may be marked as "CAVE_MARK", meaning
2944 * that even if the player cannot "see" the grid, he "knows" the terrain in
2945 * that grid. This is used to "remember" walls/doors/stairs/floors when they
2946 * are "seen" or "detected", and also to "memorize" floors, after "wiz_lite()",
2947 * or when one of the "memorize floor grids" options induces memorization.
2949 * Objects are "memorized" in a different way, using a special "marked" flag
2950 * on the object itself, which is set when an object is observed or detected.
2953 * A grid may be marked as "CAVE_ROOM" which means that it is part of a "room",
2954 * and should be illuminated by "lite room" and "darkness" spells.
2957 * A grid may be marked as "CAVE_ICKY" which means it is part of a "vault",
2958 * and should be unavailable for "teleportation" destinations.
2961 * The "view_perma_grids" allows the player to "memorize" every perma-lit grid
2962 * which is observed, and the "view_torch_grids" allows the player to memorize
2963 * every torch-lit grid. The player will always memorize important walls,
2964 * doors, stairs, and other terrain features, as well as any "detected" grids.
2966 * Note that the new "update_view()" method allows, among other things, a room
2967 * to be "partially" seen as the player approaches it, with a growing cone of
2968 * floor appearing as the player gets closer to the door. Also, by not turning
2969 * on the "memorize perma-lit grids" option, the player will only "see" those
2970 * floor grids which are actually in line of sight.
2972 * And my favorite "plus" is that you can now use a special option to draw the
2973 * "floors" in the "viewable region" brightly (actually, to draw the *other*
2974 * grids dimly), providing a "pretty" effect as the player runs around, and
2975 * to efficiently display the "torch lite" in a special color.
2978 * Some comments on the "update_view()" algorithm...
2980 * The algorithm is very fast, since it spreads "obvious" grids very quickly,
2981 * and only has to call "los()" on the borderline cases. The major axes/diags
2982 * even terminate early when they hit walls. I need to find a quick way
2983 * to "terminate" the other scans.
2985 * Note that in the worst case (a big empty area with say 5% scattered walls),
2986 * each of the 1500 or so nearby grids is checked once, most of them getting
2987 * an "instant" rating, and only a small portion requiring a call to "los()".
2989 * The only time that the algorithm appears to be "noticeably" too slow is
2990 * when running, and this is usually only important in town, since the town
2991 * provides about the worst scenario possible, with large open regions and
2992 * a few scattered obstructions. There is a special "efficiency" option to
2993 * allow the player to reduce his field of view in town, if needed.
2995 * In the "best" case (say, a normal stretch of corridor), the algorithm
2996 * makes one check for each viewable grid, and makes no calls to "los()".
2997 * So running in corridors is very fast, and if a lot of monsters are
2998 * nearby, it is much faster than the old methods.
3000 * Note that resting, most normal commands, and several forms of running,
3001 * plus all commands executed near large groups of monsters, are strictly
3002 * more efficient with "update_view()" that with the old "compute los() on
3003 * demand" method, primarily because once the "field of view" has been
3004 * calculated, it does not have to be recalculated until the player moves
3005 * (or a wall or door is created or destroyed).
3007 * Note that we no longer have to do as many "los()" checks, since once the
3008 * "view" region has been built, very few things cause it to be "changed"
3009 * (player movement, and the opening/closing of doors, changes in wall status).
3010 * Note that door/wall changes are only relevant when the door/wall itself is
3011 * in the "view" region.
3013 * The algorithm seems to only call "los()" from zero to ten times, usually
3014 * only when coming down a corridor into a room, or standing in a room, just
3015 * misaligned with a corridor. So if, say, there are five "nearby" monsters,
3016 * we will be reducing the calls to "los()".
3018 * I am thinking in terms of an algorithm that "walks" from the central point
3019 * out to the maximal "distance", at each point, determining the "view" code
3020 * (above). For each grid not on a major axis or diagonal, the "view" code
3021 * depends on the "cave_floor_bold()" and "view" of exactly two other grids
3022 * (the one along the nearest diagonal, and the one next to that one, see
3023 * "update_view_aux()"...).
3025 * We "memorize" the viewable space array, so that at the cost of under 3000
3026 * bytes, we reduce the time taken by "forget_view()" to one assignment for
3027 * each grid actually in the "viewable space". And for another 3000 bytes,
3028 * we prevent "erase + redraw" ineffiencies via the "seen" set. These bytes
3029 * are also used by other routines, thus reducing the cost to almost nothing.
3031 * A similar thing is done for "forget_lite()" in which case the savings are
3032 * much less, but save us from doing bizarre maintenance checking.
3034 * In the worst "normal" case (in the middle of the town), the reachable space
3035 * actually reaches to more than half of the largest possible "circle" of view,
3036 * or about 800 grids, and in the worse case (in the middle of a dungeon level
3037 * where all the walls have been removed), the reachable space actually reaches
3038 * the theoretical maximum size of just under 1500 grids.
3040 * Each grid G examines the "state" of two (?) other (adjacent) grids, G1 & G2.
3041 * If G1 is lite, G is lite. Else if G2 is lite, G is half. Else if G1 and G2
3042 * are both half, G is half. Else G is dark. It only takes 2 (or 4) bits to
3043 * "name" a grid, so (for MAX_RAD of 20) we could use 1600 bytes, and scan the
3044 * entire possible space (including initialization) in one step per grid. If
3045 * we do the "clearing" as a separate step (and use an array of "view" grids),
3046 * then the clearing will take as many steps as grids that were viewed, and the
3047 * algorithm will be able to "stop" scanning at various points.
3048 * Oh, and outside of the "torch radius", only "lite" grids need to be scanned.
3059 * Actually erase the entire "lite" array, redrawing every grid
3061 void forget_lite(void)
3065 /* None to forget */
3066 if (!lite_n) return;
3068 /* Clear them all */
3069 for (i = 0; i < lite_n; i++)
3074 /* Forget "LITE" flag */
3075 cave[y][x].info &= ~(CAVE_LITE);
3089 * This macro allows us to efficiently add a grid to the "lite" array,
3090 * note that we are never called for illegal grids, or for grids which
3091 * have already been placed into the "lite" array, and we are never
3092 * called when the "lite" array is full.
3094 #define cave_lite_hack(Y,X) \
3096 if (!(cave[Y][X].info & (CAVE_LITE))) { \
3097 cave[Y][X].info |= (CAVE_LITE); \
3098 lite_y[lite_n] = (Y); \
3099 lite_x[lite_n] = (X); \
3105 * Update the set of grids "illuminated" by the player's lite.
3107 * This routine needs to use the results of "update_view()"
3109 * Note that "blindness" does NOT affect "torch lite". Be careful!
3111 * We optimize most lites (all non-artifact lites) by using "obvious"
3112 * facts about the results of "small" lite radius, and we attempt to
3113 * list the "nearby" grids before the more "distant" ones in the
3114 * array of torch-lit grids.
3116 * We assume that "radius zero" lite is in fact no lite at all.
3118 * Torch Lantern Artifacts
3128 void update_lite(void)
3130 int i, x, y, min_x, max_x, min_y, max_y;
3131 int p = p_ptr->cur_lite;
3133 /*** Special case ***/
3135 /* Hack -- Player has no lite */
3138 /* Forget the old lite */
3141 /* Draw the player */
3146 /*** Save the old "lite" grids for later ***/
3148 /* Clear them all */
3149 for (i = 0; i < lite_n; i++)
3154 /* Mark the grid as not "lite" */
3155 cave[y][x].info &= ~(CAVE_LITE);
3157 /* Mark the grid as "seen" */
3158 cave[y][x].info |= (CAVE_TEMP);
3160 /* Add it to the "seen" set */
3170 /*** Collect the new "lite" grids ***/
3172 /* Radius 1 -- torch radius */
3176 cave_lite_hack(py, px);
3179 cave_lite_hack(py+1, px);
3180 cave_lite_hack(py-1, px);
3181 cave_lite_hack(py, px+1);
3182 cave_lite_hack(py, px-1);
3184 /* Diagonal grids */
3185 cave_lite_hack(py+1, px+1);
3186 cave_lite_hack(py+1, px-1);
3187 cave_lite_hack(py-1, px+1);
3188 cave_lite_hack(py-1, px-1);
3191 /* Radius 2 -- lantern radius */
3194 /* South of the player */
3195 if (cave_floor_bold(py+1, px))
3197 cave_lite_hack(py+2, px);
3198 cave_lite_hack(py+2, px+1);
3199 cave_lite_hack(py+2, px-1);
3202 /* North of the player */
3203 if (cave_floor_bold(py-1, px))
3205 cave_lite_hack(py-2, px);
3206 cave_lite_hack(py-2, px+1);
3207 cave_lite_hack(py-2, px-1);
3210 /* East of the player */
3211 if (cave_floor_bold(py, px+1))
3213 cave_lite_hack(py, px+2);
3214 cave_lite_hack(py+1, px+2);
3215 cave_lite_hack(py-1, px+2);
3218 /* West of the player */
3219 if (cave_floor_bold(py, px-1))
3221 cave_lite_hack(py, px-2);
3222 cave_lite_hack(py+1, px-2);
3223 cave_lite_hack(py-1, px-2);
3227 /* Radius 3+ -- artifact radius */
3232 /* Paranoia -- see "LITE_MAX" */
3235 /* South-East of the player */
3236 if (cave_floor_bold(py+1, px+1))
3238 cave_lite_hack(py+2, px+2);
3241 /* South-West of the player */
3242 if (cave_floor_bold(py+1, px-1))
3244 cave_lite_hack(py+2, px-2);
3247 /* North-East of the player */
3248 if (cave_floor_bold(py-1, px+1))
3250 cave_lite_hack(py-2, px+2);
3253 /* North-West of the player */
3254 if (cave_floor_bold(py-1, px-1))
3256 cave_lite_hack(py-2, px-2);
3261 if (min_y < 0) min_y = 0;
3265 if (max_y > cur_hgt-1) max_y = cur_hgt-1;
3269 if (min_x < 0) min_x = 0;
3273 if (max_x > cur_wid-1) max_x = cur_wid-1;
3275 /* Scan the maximal box */
3276 for (y = min_y; y <= max_y; y++)
3278 for (x = min_x; x <= max_x; x++)
3280 int dy = (py > y) ? (py - y) : (y - py);
3281 int dx = (px > x) ? (px - x) : (x - px);
3283 /* Skip the "central" grids (above) */
3284 if ((dy <= 2) && (dx <= 2)) continue;
3286 /* Hack -- approximate the distance */
3287 d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
3289 /* Skip distant grids */
3290 if (d > p) continue;
3292 /* Viewable, nearby, grids get "torch lit" */
3293 if (player_has_los_bold(y, x))
3295 /* This grid is "torch lit" */
3296 cave_lite_hack(y, x);
3303 /*** Complete the algorithm ***/
3305 /* Draw the new grids */
3306 for (i = 0; i < lite_n; i++)
3311 /* Update fresh grids */
3312 if (cave[y][x].info & (CAVE_TEMP)) continue;
3321 /* Clear them all */
3322 for (i = 0; i < temp_n; i++)
3327 /* No longer in the array */
3328 cave[y][x].info &= ~(CAVE_TEMP);
3330 /* Update stale grids */
3331 if (cave[y][x].info & (CAVE_LITE)) continue;
3342 static bool mon_invis;
3345 * Add a square to the changes array
3347 static void mon_lite_hack(int y, int x)
3352 if (!in_bounds2(y, x)) return;
3354 c_ptr = &cave[y][x];
3356 /* Want a unlit square in view of the player */
3357 if ((c_ptr->info & (CAVE_MNLT | CAVE_VIEW)) != CAVE_VIEW) return;
3359 /* Hack XXX XXX - Is it a wall and monster not in LOS? */
3360 if (!cave_floor_grid(c_ptr) && mon_invis) return;
3362 /* Save this square */
3363 if (temp_n < TEMP_MAX)
3371 c_ptr->info |= CAVE_MNLT;
3378 * Update squares illuminated by monsters.
3380 * Hack - use the CAVE_ROOM flag (renamed to be CAVE_MNLT) to
3381 * denote squares illuminated by monsters.
3383 * The CAVE_TEMP flag is used to store the state during the
3384 * updating. Only squares in view of the player, whos state
3385 * changes are drawn via lite_spot().
3387 void update_mon_lite(void)
3396 /* Clear all monster lit squares */
3397 for (i = 0; i < mon_lite_n; i++)
3400 c_ptr = &cave[mon_lite_y[i]][mon_lite_x[i]];
3403 c_ptr->info |= (CAVE_TEMP);
3405 /* Clear monster illumination flag */
3406 c_ptr->info &= ~(CAVE_MNLT);
3409 /* Empty temp list of new squares to lite up */
3412 /* Loop through monsters, adding newly lit squares to changes list */
3413 for (i = 1; i < m_max; i++)
3415 monster_type *m_ptr = &m_list[i];
3416 monster_race *r_ptr = &r_info[m_ptr->r_idx];
3418 /* Skip dead monsters */
3419 if (!m_ptr->r_idx) continue;
3421 /* Is it too far away? */
3422 if (m_ptr->cdis > ((d_info[dungeon_type].flags1 & DF1_DARKNESS) ? MAX_SIGHT / 2 + 1 : MAX_SIGHT + 3)) continue;
3424 /* Get lite radius */
3427 /* Note the radii are cumulative */
3428 if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_SELF_LITE_1)) rad++;
3429 if (r_ptr->flags7 & (RF7_HAS_LITE_2 | RF7_SELF_LITE_2)) rad += 2;
3431 /* Exit if has no light */
3433 if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (m_ptr->csleep || (!dun_level && is_daytime()) || p_ptr->inside_battle)) continue;
3435 if (world_monster) continue;
3437 if (d_info[dungeon_type].flags1 & DF1_DARKNESS) rad = 1;
3439 /* Access the location */
3443 /* Is the monster visible? */
3444 mon_invis = !(cave[fy][fx].info & CAVE_VIEW);
3446 /* The square it is on */
3447 mon_lite_hack(fy, fx);
3449 /* Adjacent squares */
3450 mon_lite_hack(fy + 1, fx);
3451 mon_lite_hack(fy - 1, fx);
3452 mon_lite_hack(fy, fx + 1);
3453 mon_lite_hack(fy, fx - 1);
3454 mon_lite_hack(fy + 1, fx + 1);
3455 mon_lite_hack(fy + 1, fx - 1);
3456 mon_lite_hack(fy - 1, fx + 1);
3457 mon_lite_hack(fy - 1, fx - 1);
3462 /* South of the monster */
3463 if (cave_floor_bold(fy + 1, fx))
3465 mon_lite_hack(fy + 2, fx + 1);
3466 mon_lite_hack(fy + 2, fx);
3467 mon_lite_hack(fy + 2, fx - 1);
3469 c_ptr = &cave[fy + 2][fx];
3472 if ((rad == 3) && cave_floor_grid(c_ptr))
3474 mon_lite_hack(fy + 3, fx + 1);
3475 mon_lite_hack(fy + 3, fx);
3476 mon_lite_hack(fy + 3, fx - 1);
3480 /* North of the monster */
3481 if (cave_floor_bold(fy - 1, fx))
3483 mon_lite_hack(fy - 2, fx + 1);
3484 mon_lite_hack(fy - 2, fx);
3485 mon_lite_hack(fy - 2, fx - 1);
3487 c_ptr = &cave[fy - 2][fx];
3490 if ((rad == 3) && cave_floor_grid(c_ptr))
3492 mon_lite_hack(fy - 3, fx + 1);
3493 mon_lite_hack(fy - 3, fx);
3494 mon_lite_hack(fy - 3, fx - 1);
3498 /* East of the monster */
3499 if (cave_floor_bold(fy, fx + 1))
3501 mon_lite_hack(fy + 1, fx + 2);
3502 mon_lite_hack(fy, fx + 2);
3503 mon_lite_hack(fy - 1, fx + 2);
3505 c_ptr = &cave[fy][fx + 2];
3508 if ((rad == 3) && cave_floor_grid(c_ptr))
3510 mon_lite_hack(fy + 1, fx + 3);
3511 mon_lite_hack(fy, fx + 3);
3512 mon_lite_hack(fy - 1, fx + 3);
3516 /* West of the monster */
3517 if (cave_floor_bold(fy, fx - 1))
3519 mon_lite_hack(fy + 1, fx - 2);
3520 mon_lite_hack(fy, fx - 2);
3521 mon_lite_hack(fy - 1, fx - 2);
3523 c_ptr = &cave[fy][fx - 2];
3526 if ((rad == 3) && cave_floor_grid(c_ptr))
3528 mon_lite_hack(fy + 1, fx - 3);
3529 mon_lite_hack(fy, fx - 3);
3530 mon_lite_hack(fy - 1, fx - 3);
3538 /* South-East of the monster */
3539 if (cave_floor_bold(fy + 1, fx + 1))
3541 mon_lite_hack(fy + 2, fx + 2);
3544 /* South-West of the monster */
3545 if (cave_floor_bold(fy + 1, fx - 1))
3547 mon_lite_hack(fy + 2, fx - 2);
3550 /* North-East of the monster */
3551 if (cave_floor_bold(fy - 1, fx + 1))
3553 mon_lite_hack(fy - 2, fx + 2);
3556 /* North-West of the monster */
3557 if (cave_floor_bold(fy - 1, fx - 1))
3559 mon_lite_hack(fy - 2, fx - 2);
3564 /* Save end of list of new squares */
3568 * Look at old set flags to see if there are any changes.
3570 for (i = 0; i < mon_lite_n; i++)
3575 if (!in_bounds2(fy, fx)) continue;
3578 c_ptr = &cave[fy][fx];
3580 /* It it no longer lit? */
3581 if (!(c_ptr->info & CAVE_MNLT) && player_has_los_grid(c_ptr))
3583 /* It is now unlit */
3588 /* Add to end of temp array */
3589 temp_x[temp_n] = (byte)fx;
3590 temp_y[temp_n] = (byte)fy;
3594 /* Clear the lite array */
3597 /* Copy the temp array into the lit array lighting the new squares. */
3598 for (i = 0; i < temp_n; i++)
3603 if (!in_bounds2(fy, fx)) continue;
3606 c_ptr = &cave[fy][fx];
3610 /* Clear the temp flag for the old lit grids */
3611 c_ptr->info &= ~(CAVE_TEMP);
3615 /* The is the square newly lit and visible? */
3616 if ((c_ptr->info & (CAVE_VIEW | CAVE_TEMP)) == CAVE_VIEW)
3623 /* Save in the monster lit array */
3624 mon_lite_x[mon_lite_n] = fx;
3625 mon_lite_y[mon_lite_n] = fy;
3630 /* Finished with temp_n */
3633 p_ptr->monlite = (cave[py][px].info & CAVE_MNLT) ? TRUE : FALSE;
3635 if (p_ptr->special_defense & NINJA_S_STEALTH)
3637 if (p_ptr->old_monlite != p_ptr->monlite)
3642 msg_print("±Æ¤Îʤ¤¤¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
3644 msg_print("Your mantle of shadow become thin.");
3650 msg_print("±Æ¤Îʤ¤¤¤¬Ç»¤¯¤Ê¤Ã¤¿¡ª");
3652 msg_print("Your mantle of shadow restored its original darkness.");
3657 p_ptr->old_monlite = p_ptr->monlite;
3660 void clear_mon_lite(void)
3665 /* Clear all monster lit squares */
3666 for (i = 0; i < mon_lite_n; i++)
3669 c_ptr = &cave[mon_lite_y[i]][mon_lite_x[i]];
3671 /* Clear monster illumination flag */
3672 c_ptr->info &= ~(CAVE_MNLT);
3675 /* Empty the array */
3682 * Clear the viewable space
3684 void forget_view(void)
3690 /* None to forget */
3691 if (!view_n) return;
3693 /* Clear them all */
3694 for (i = 0; i < view_n; i++)
3699 /* Access the grid */
3700 c_ptr = &cave[y][x];
3702 /* Forget that the grid is viewable */
3703 c_ptr->info &= ~(CAVE_VIEW);
3705 if (!panel_contains(y, x)) continue;
3707 /* Update the screen */
3718 * This macro allows us to efficiently add a grid to the "view" array,
3719 * note that we are never called for illegal grids, or for grids which
3720 * have already been placed into the "view" array, and we are never
3721 * called when the "view" array is full.
3723 #define cave_view_hack(C,Y,X) \
3725 if (!((C)->info & (CAVE_VIEW))){\
3726 (C)->info |= (CAVE_VIEW); \
3727 view_y[view_n] = (Y); \
3728 view_x[view_n] = (X); \
3735 * Helper function for "update_view()" below
3737 * We are checking the "viewability" of grid (y,x) by the player.
3739 * This function assumes that (y,x) is legal (i.e. on the map).
3741 * Grid (y1,x1) is on the "diagonal" between (py,px) and (y,x)
3742 * Grid (y2,x2) is "adjacent", also between (py,px) and (y,x).
3744 * Note that we are using the "CAVE_XTRA" field for marking grids as
3745 * "easily viewable". This bit is cleared at the end of "update_view()".
3747 * This function adds (y,x) to the "viewable set" if necessary.
3749 * This function now returns "TRUE" if vision is "blocked" by grid (y,x).
3751 static bool update_view_aux(int y, int x, int y1, int x1, int y2, int x2)
3753 bool f1, f2, v1, v2, z1, z2, wall;
3757 cave_type *g1_c_ptr;
3758 cave_type *g2_c_ptr;
3760 /* Access the grids */
3761 g1_c_ptr = &cave[y1][x1];
3762 g2_c_ptr = &cave[y2][x2];
3765 /* Check for walls */
3766 f1 = (cave_floor_grid(g1_c_ptr));
3767 f2 = (cave_floor_grid(g2_c_ptr));
3769 /* Totally blocked by physical walls */
3770 if (!f1 && !f2) return (TRUE);
3773 /* Check for visibility */
3774 v1 = (f1 && (g1_c_ptr->info & (CAVE_VIEW)));
3775 v2 = (f2 && (g2_c_ptr->info & (CAVE_VIEW)));
3777 /* Totally blocked by "unviewable neighbors" */
3778 if (!v1 && !v2) return (TRUE);
3781 /* Access the grid */
3782 c_ptr = &cave[y][x];
3785 /* Check for walls */
3786 wall = (!cave_floor_grid(c_ptr));
3789 /* Check the "ease" of visibility */
3790 z1 = (v1 && (g1_c_ptr->info & (CAVE_XTRA)));
3791 z2 = (v2 && (g2_c_ptr->info & (CAVE_XTRA)));
3793 /* Hack -- "easy" plus "easy" yields "easy" */
3796 c_ptr->info |= (CAVE_XTRA);
3798 cave_view_hack(c_ptr, y, x);
3803 /* Hack -- primary "easy" yields "viewed" */
3806 cave_view_hack(c_ptr, y, x);
3811 /* Hack -- "view" plus "view" yields "view" */
3814 /* c_ptr->info |= (CAVE_XTRA); */
3816 cave_view_hack(c_ptr, y, x);
3822 /* Mega-Hack -- the "los()" function works poorly on walls */
3825 cave_view_hack(c_ptr, y, x);
3831 /* Hack -- check line of sight */
3832 if (los(py, px, y, x))
3834 cave_view_hack(c_ptr, y, x);
3840 /* Assume no line of sight. */
3847 * Calculate the viewable space
3849 * 1: Process the player
3850 * 1a: The player is always (easily) viewable
3851 * 2: Process the diagonals
3852 * 2a: The diagonals are (easily) viewable up to the first wall
3853 * 2b: But never go more than 2/3 of the "full" distance
3854 * 3: Process the main axes
3855 * 3a: The main axes are (easily) viewable up to the first wall
3856 * 3b: But never go more than the "full" distance
3857 * 4: Process sequential "strips" in each of the eight octants
3858 * 4a: Each strip runs along the previous strip
3859 * 4b: The main axes are "previous" to the first strip
3860 * 4c: Process both "sides" of each "direction" of each strip
3861 * 4c1: Each side aborts as soon as possible
3862 * 4c2: Each side tells the next strip how far it has to check
3864 * Note that the octant processing involves some pretty interesting
3865 * observations involving when a grid might possibly be viewable from
3866 * a given grid, and on the order in which the strips are processed.
3868 * Note the use of the mathematical facts shown below, which derive
3869 * from the fact that (1 < sqrt(2) < 1.5), and that the length of the
3870 * hypotenuse of a right triangle is primarily determined by the length
3871 * of the longest side, when one side is small, and is strictly less
3872 * than one-and-a-half times as long as the longest side when both of
3873 * the sides are large.
3875 * if (manhatten(dy,dx) < R) then (hypot(dy,dx) < R)
3876 * if (manhatten(dy,dx) > R*3/2) then (hypot(dy,dx) > R)
3878 * hypot(dy,dx) is approximated by (dx+dy+MAX(dx,dy)) / 2
3880 * These observations are important because the calculation of the actual
3881 * value of "hypot(dx,dy)" is extremely expensive, involving square roots,
3882 * while for small values (up to about 20 or so), the approximations above
3883 * are correct to within an error of at most one grid or so.
3885 * Observe the use of "full" and "over" in the code below, and the use of
3886 * the specialized calculation involving "limit", all of which derive from
3887 * the observations given above. Basically, we note that the "circle" of
3888 * view is completely contained in an "octagon" whose bounds are easy to
3889 * determine, and that only a few steps are needed to derive the actual
3890 * bounds of the circle given the bounds of the octagon.
3892 * Note that by skipping all the grids in the corners of the octagon, we
3893 * place an upper limit on the number of grids in the field of view, given
3894 * that "full" is never more than 20. Of the 1681 grids in the "square" of
3895 * view, only about 1475 of these are in the "octagon" of view, and even
3896 * fewer are in the "circle" of view, so 1500 or 1536 is more than enough
3897 * entries to completely contain the actual field of view.
3899 * Note also the care taken to prevent "running off the map". The use of
3900 * explicit checks on the "validity" of the "diagonal", and the fact that
3901 * the loops are never allowed to "leave" the map, lets "update_view_aux()"
3902 * use the optimized "cave_floor_bold()" macro, and to avoid the overhead
3903 * of multiple checks on the validity of grids.
3905 * Note the "optimizations" involving the "se","sw","ne","nw","es","en",
3906 * "ws","wn" variables. They work like this: While travelling down the
3907 * south-bound strip just to the east of the main south axis, as soon as
3908 * we get to a grid which does not "transmit" viewing, if all of the strips
3909 * preceding us (in this case, just the main axis) had terminated at or before
3910 * the same point, then we can stop, and reset the "max distance" to ourself.
3911 * So, each strip (named by major axis plus offset, thus "se" in this case)
3912 * maintains a "blockage" variable, initialized during the main axis step,
3913 * and checks it whenever a blockage is observed. After processing each
3914 * strip as far as the previous strip told us to process, the next strip is
3915 * told not to go farther than the current strip's farthest viewable grid,
3916 * unless open space is still available. This uses the "k" variable.
3918 * Note the use of "inline" macros for efficiency. The "cave_floor_grid()"
3919 * macro is a replacement for "cave_floor_bold()" which takes a pointer to
3920 * a cave grid instead of its location. The "cave_view_hack()" macro is a
3921 * chunk of code which adds the given location to the "view" array if it
3922 * is not already there, using both the actual location and a pointer to
3923 * the cave grid. See above.
3925 * By the way, the purpose of this code is to reduce the dependancy on the
3926 * "los()" function which is slow, and, in some cases, not very accurate.
3928 * It is very possible that I am the only person who fully understands this
3929 * function, and for that I am truly sorry, but efficiency was very important
3930 * and the "simple" version of this function was just not fast enough. I am
3931 * more than willing to replace this function with a simpler one, if it is
3932 * equally efficient, and especially willing if the new function happens to
3933 * derive "reverse-line-of-sight" at the same time, since currently monsters
3934 * just use an optimized hack of "you see me, so I see you", and then use the
3935 * actual "projectable()" function to check spell attacks.
3937 void update_view(void)
3939 int n, m, d, k, y, x, z;
3941 int se, sw, ne, nw, es, en, ws, wn;
3945 int y_max = cur_hgt - 1;
3946 int x_max = cur_wid - 1;
3950 /*** Initialize ***/
3953 if (view_reduce_view && !dun_level)
3955 /* Full radius (10) */
3956 full = MAX_SIGHT / 2;
3958 /* Octagon factor (15) */
3959 over = MAX_SIGHT * 3 / 4;
3965 /* Full radius (20) */
3968 /* Octagon factor (30) */
3969 over = MAX_SIGHT * 3 / 2;
3973 /*** Step 0 -- Begin ***/
3975 /* Save the old "view" grids for later */
3976 for (n = 0; n < view_n; n++)
3981 /* Access the grid */
3982 c_ptr = &cave[y][x];
3984 /* Mark the grid as not in "view" */
3985 c_ptr->info &= ~(CAVE_VIEW);
3987 /* Mark the grid as "seen" */
3988 c_ptr->info |= (CAVE_TEMP);
3990 /* Add it to the "seen" set */
3996 /* Start over with the "view" array */
3999 /*** Step 1 -- adjacent grids ***/
4001 /* Now start on the player */
4005 /* Access the grid */
4006 c_ptr = &cave[y][x];
4008 /* Assume the player grid is easily viewable */
4009 c_ptr->info |= (CAVE_XTRA);
4011 /* Assume the player grid is viewable */
4012 cave_view_hack(c_ptr, y, x);
4015 /*** Step 2 -- Major Diagonals ***/
4020 /* Scan south-east */
4021 for (d = 1; d <= z; d++)
4023 c_ptr = &cave[y+d][x+d];
4024 c_ptr->info |= (CAVE_XTRA);
4025 cave_view_hack(c_ptr, y+d, x+d);
4026 if (!cave_floor_grid(c_ptr)) break;
4029 /* Scan south-west */
4030 for (d = 1; d <= z; d++)
4032 c_ptr = &cave[y+d][x-d];
4033 c_ptr->info |= (CAVE_XTRA);
4034 cave_view_hack(c_ptr, y+d, x-d);
4035 if (!cave_floor_grid(c_ptr)) break;
4038 /* Scan north-east */
4039 for (d = 1; d <= z; d++)
4041 c_ptr = &cave[y-d][x+d];
4042 c_ptr->info |= (CAVE_XTRA);
4043 cave_view_hack(c_ptr, y-d, x+d);
4044 if (!cave_floor_grid(c_ptr)) break;
4047 /* Scan north-west */
4048 for (d = 1; d <= z; d++)
4050 c_ptr = &cave[y-d][x-d];
4051 c_ptr->info |= (CAVE_XTRA);
4052 cave_view_hack(c_ptr, y-d, x-d);
4053 if (!cave_floor_grid(c_ptr)) break;
4057 /*** Step 3 -- major axes ***/
4060 for (d = 1; d <= full; d++)
4062 c_ptr = &cave[y+d][x];
4063 c_ptr->info |= (CAVE_XTRA);
4064 cave_view_hack(c_ptr, y+d, x);
4065 if (!cave_floor_grid(c_ptr)) break;
4068 /* Initialize the "south strips" */
4072 for (d = 1; d <= full; d++)
4074 c_ptr = &cave[y-d][x];
4075 c_ptr->info |= (CAVE_XTRA);
4076 cave_view_hack(c_ptr, y-d, x);
4077 if (!cave_floor_grid(c_ptr)) break;
4080 /* Initialize the "north strips" */
4084 for (d = 1; d <= full; d++)
4086 c_ptr = &cave[y][x+d];
4087 c_ptr->info |= (CAVE_XTRA);
4088 cave_view_hack(c_ptr, y, x+d);
4089 if (!cave_floor_grid(c_ptr)) break;
4092 /* Initialize the "east strips" */
4096 for (d = 1; d <= full; d++)
4098 c_ptr = &cave[y][x-d];
4099 c_ptr->info |= (CAVE_XTRA);
4100 cave_view_hack(c_ptr, y, x-d);
4101 if (!cave_floor_grid(c_ptr)) break;
4104 /* Initialize the "west strips" */
4108 /*** Step 4 -- Divide each "octant" into "strips" ***/
4110 /* Now check each "diagonal" (in parallel) */
4111 for (n = 1; n <= over / 2; n++)
4113 int ypn, ymn, xpn, xmn;
4116 /* Acquire the "bounds" of the maximal circle */
4118 if (z > full - n) z = full - n;
4119 while ((z + n + (n>>1)) > full) z--;
4122 /* Access the four diagonal grids */
4132 /* Maximum distance */
4133 m = MIN(z, y_max - ypn);
4136 if ((xpn <= x_max) && (n < se))
4139 for (k = n, d = 1; d <= m; d++)
4141 /* Check grid "d" in strip "n", notice "blockage" */
4142 if (update_view_aux(ypn+d, xpn, ypn+d-1, xpn-1, ypn+d-1, xpn))
4144 if (n + d >= se) break;
4147 /* Track most distant "non-blockage" */
4154 /* Limit the next strip */
4159 if ((xmn >= 0) && (n < sw))
4162 for (k = n, d = 1; d <= m; d++)
4164 /* Check grid "d" in strip "n", notice "blockage" */
4165 if (update_view_aux(ypn+d, xmn, ypn+d-1, xmn+1, ypn+d-1, xmn))
4167 if (n + d >= sw) break;
4170 /* Track most distant "non-blockage" */
4177 /* Limit the next strip */
4186 /* Maximum distance */
4190 if ((xpn <= x_max) && (n < ne))
4193 for (k = n, d = 1; d <= m; d++)
4195 /* Check grid "d" in strip "n", notice "blockage" */
4196 if (update_view_aux(ymn-d, xpn, ymn-d+1, xpn-1, ymn-d+1, xpn))
4198 if (n + d >= ne) break;
4201 /* Track most distant "non-blockage" */
4208 /* Limit the next strip */
4213 if ((xmn >= 0) && (n < nw))
4216 for (k = n, d = 1; d <= m; d++)
4218 /* Check grid "d" in strip "n", notice "blockage" */
4219 if (update_view_aux(ymn-d, xmn, ymn-d+1, xmn+1, ymn-d+1, xmn))
4221 if (n + d >= nw) break;
4224 /* Track most distant "non-blockage" */
4231 /* Limit the next strip */
4240 /* Maximum distance */
4241 m = MIN(z, x_max - xpn);
4244 if ((ypn <= x_max) && (n < es))
4247 for (k = n, d = 1; d <= m; d++)
4249 /* Check grid "d" in strip "n", notice "blockage" */
4250 if (update_view_aux(ypn, xpn+d, ypn-1, xpn+d-1, ypn, xpn+d-1))
4252 if (n + d >= es) break;
4255 /* Track most distant "non-blockage" */
4262 /* Limit the next strip */
4267 if ((ymn >= 0) && (n < en))
4270 for (k = n, d = 1; d <= m; d++)
4272 /* Check grid "d" in strip "n", notice "blockage" */
4273 if (update_view_aux(ymn, xpn+d, ymn+1, xpn+d-1, ymn, xpn+d-1))
4275 if (n + d >= en) break;
4278 /* Track most distant "non-blockage" */
4285 /* Limit the next strip */
4294 /* Maximum distance */
4298 if ((ypn <= y_max) && (n < ws))
4301 for (k = n, d = 1; d <= m; d++)
4303 /* Check grid "d" in strip "n", notice "blockage" */
4304 if (update_view_aux(ypn, xmn-d, ypn-1, xmn-d+1, ypn, xmn-d+1))
4306 if (n + d >= ws) break;
4309 /* Track most distant "non-blockage" */
4316 /* Limit the next strip */
4321 if ((ymn >= 0) && (n < wn))
4324 for (k = n, d = 1; d <= m; d++)
4326 /* Check grid "d" in strip "n", notice "blockage" */
4327 if (update_view_aux(ymn, xmn-d, ymn+1, xmn-d+1, ymn, xmn-d+1))
4329 if (n + d >= wn) break;
4332 /* Track most distant "non-blockage" */
4339 /* Limit the next strip */
4346 /*** Step 5 -- Complete the algorithm ***/
4348 /* Update all the new grids */
4349 for (n = 0; n < view_n; n++)
4354 /* Access the grid */
4355 c_ptr = &cave[y][x];
4357 /* Clear the "CAVE_XTRA" flag */
4358 c_ptr->info &= ~(CAVE_XTRA);
4360 /* Update only newly viewed grids */
4361 if (c_ptr->info & (CAVE_TEMP)) continue;
4370 /* Wipe the old grids, update as needed */
4371 for (n = 0; n < temp_n; n++)
4376 /* Access the grid */
4377 c_ptr = &cave[y][x];
4379 /* No longer in the array */
4380 c_ptr->info &= ~(CAVE_TEMP);
4382 /* Update only non-viewable grids */
4383 if (c_ptr->info & (CAVE_VIEW)) continue;
4396 * Hack -- forget the "flow" information
4398 void forget_flow(void)
4402 /* Check the entire dungeon */
4403 for (y = 0; y < cur_hgt; y++)
4405 for (x = 0; x < cur_wid; x++)
4407 /* Forget the old data */
4408 cave[y][x].dist = 0;
4409 cave[y][x].cost = 0;
4410 cave[y][x].when = 0;
4417 * Hack - speed up the update_flow algorithm by only doing
4418 * it everytime the player moves out of LOS of the last
4421 static u16b flow_x = 0;
4422 static u16b flow_y = 0;
4427 * Hack -- fill in the "cost" field of every grid that the player
4428 * can "reach" with the number of steps needed to reach that grid.
4429 * This also yields the "distance" of the player from every grid.
4431 * In addition, mark the "when" of the grids that can reach
4432 * the player with the incremented value of "flow_n".
4434 * Hack -- use the "seen" array as a "circular queue".
4436 * We do not need a priority queue because the cost from grid
4437 * to grid is always "one" and we process them in order.
4439 void update_flow(void)
4445 /* Paranoia -- make sure the array is empty */
4448 /* The last way-point is on the map */
4449 if (running && in_bounds(flow_y, flow_x))
4451 /* The way point is in sight - do not update. (Speedup) */
4452 if (cave[flow_y][flow_x].info & CAVE_VIEW) return;
4455 /* Erase all of the current flow information */
4456 for (y = 0; y < cur_hgt; y++)
4458 for (x = 0; x < cur_wid; x++)
4460 cave[y][x].cost = 0;
4461 cave[y][x].dist = 0;
4465 /* Save player position */
4469 /* Add the player's grid to the queue */
4473 /* Now process the queue */
4474 while (flow_head != flow_tail)
4478 /* Extract the next entry */
4479 ty = temp_y[flow_tail];
4480 tx = temp_x[flow_tail];
4482 /* Forget that entry */
4483 if (++flow_tail == TEMP_MAX) flow_tail = 0;
4485 /* Add the "children" */
4486 for (d = 0; d < 8; d++)
4488 int old_head = flow_head;
4489 int m = cave[ty][tx].cost + 1;
4490 int n = cave[ty][tx].dist + 1;
4493 /* Child location */
4494 y = ty + ddy_ddd[d];
4495 x = tx + ddx_ddd[d];
4497 /* Ignore player's grid */
4498 if (x == px && y == py) continue;
4500 c_ptr = &cave[y][x];
4502 if (is_closed_door(c_ptr->feat)) m += 3;
4504 /* Ignore "pre-stamped" entries */
4505 if (c_ptr->dist != 0 && c_ptr->dist <= n && c_ptr->cost <= m) continue;
4507 /* Ignore "walls" and "rubble" */
4508 if ((c_ptr->feat >= FEAT_RUBBLE) && (c_ptr->feat != FEAT_TREES) && !cave_floor_grid(c_ptr)) continue;
4510 /* Save the flow cost */
4511 if (c_ptr->cost == 0 || c_ptr->cost > m) c_ptr->cost = m;
4512 if (c_ptr->dist == 0 || c_ptr->dist > n) c_ptr->dist = n;
4514 /* Hack -- limit flow depth */
4515 if (n == MONSTER_FLOW_DEPTH) continue;
4517 /* Enqueue that entry */
4518 temp_y[flow_head] = y;
4519 temp_x[flow_head] = x;
4521 /* Advance the queue */
4522 if (++flow_head == TEMP_MAX) flow_head = 0;
4524 /* Hack -- notice overflow by forgetting new entry */
4525 if (flow_head == flow_tail) flow_head = old_head;
4531 static int scent_when = 0;
4534 * Characters leave scent trails for perceptive monsters to track.
4536 * Smell is rather more limited than sound. Many creatures cannot use
4537 * it at all, it doesn't extend very far outwards from the character's
4538 * current position, and monsters can use it to home in the character,
4539 * but not to run away from him.
4541 * Smell is valued according to age. When a character takes his turn,
4542 * scent is aged by one, and new scent of the current age is laid down.
4543 * Speedy characters leave more scent, true, but it also ages faster,
4544 * which makes it harder to hunt them down.
4546 * Whenever the age count loops, most of the scent trail is erased and
4547 * the age of the remainder is recalculated.
4549 void update_smell(void)
4554 /* Create a table that controls the spread of scent */
4555 const int scent_adjust[5][5] =
4564 /* Loop the age and adjust scent values when necessary */
4565 if (++scent_when == 254)
4567 /* Scan the entire dungeon */
4568 for (y = 0; y < cur_hgt; y++)
4570 for (x = 0; x < cur_wid; x++)
4572 int w = cave[y][x].when;
4573 cave[y][x].when = (w > 128) ? (w - 128) : 0;
4582 /* Lay down new scent */
4583 for (i = 0; i < 5; i++)
4585 for (j = 0; j < 5; j++)
4589 /* Translate table to map grids */
4594 if (!in_bounds(y, x)) continue;
4596 c_ptr = &cave[y][x];
4598 /* Walls, water, and lava cannot hold scent. */
4599 if ((c_ptr->feat >= FEAT_RUBBLE) && (c_ptr->feat != FEAT_TREES) && !cave_floor_grid(c_ptr)) continue;
4601 /* Grid must not be blocked by walls from the character */
4602 if (!player_has_los_bold(y, x)) continue;
4604 /* Note grids that are too far away */
4605 if (scent_adjust[i][j] == -1) continue;
4607 /* Mark the grid with new scent */
4608 c_ptr->when = scent_when + scent_adjust[i][j];
4615 * Hack -- map the current panel (plus some) ala "magic mapping"
4617 void map_area(int range)
4625 if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
4627 /* Scan that area */
4628 for (y = 1; y < cur_hgt - 1; y++)
4630 for (x = 1; x < cur_wid - 1; x++)
4632 if (distance(py, px, y, x) > range) continue;
4634 c_ptr = &cave[y][x];
4636 /* Feature code (applying "mimic" field) */
4637 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
4639 /* All non-walls are "checked" */
4640 if ((feat <= FEAT_DOOR_TAIL) ||
4641 (feat == FEAT_RUBBLE) ||
4642 ((feat >= FEAT_MINOR_GLYPH) &&
4643 (feat <= FEAT_TREES)) ||
4644 (feat >= FEAT_TOWN))
4646 /* Memorize normal features */
4647 if ((feat > FEAT_INVIS) && (feat != FEAT_DIRT) && (feat != FEAT_GRASS))
4649 /* Memorize the object */
4650 c_ptr->info |= (CAVE_MARK);
4653 /* Memorize known walls */
4654 for (i = 0; i < 8; i++)
4656 c_ptr = &cave[y + ddy_ddd[i]][x + ddx_ddd[i]];
4658 /* Feature code (applying "mimic" field) */
4659 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
4661 /* Memorize walls (etc) */
4662 if ((feat >= FEAT_RUBBLE) && (feat != FEAT_DIRT) && (feat != FEAT_GRASS))
4664 /* Memorize the walls */
4665 c_ptr->info |= (CAVE_MARK);
4673 p_ptr->redraw |= (PR_MAP);
4676 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4682 * Light up the dungeon using "clairvoyance"
4684 * This function "illuminates" every grid in the dungeon, memorizes all
4685 * "objects", memorizes all grids as with magic mapping, and, under the
4686 * standard option settings (view_perma_grids but not view_torch_grids)
4687 * memorizes all floor grids too.
4689 * Note that if "view_perma_grids" is not set, we do not memorize floor
4690 * grids, since this would defeat the purpose of "view_perma_grids", not
4691 * that anyone seems to play without this option.
4693 * Note that if "view_torch_grids" is set, we do not memorize floor grids,
4694 * since this would prevent the use of "view_torch_grids" as a method to
4695 * keep track of what grids have been observed directly.
4697 void wiz_lite(bool ninja)
4702 /* Memorize objects */
4703 for (i = 1; i < o_max; i++)
4705 object_type *o_ptr = &o_list[i];
4707 /* Skip dead objects */
4708 if (!o_ptr->k_idx) continue;
4710 /* Skip held objects */
4711 if (o_ptr->held_m_idx) continue;
4714 o_ptr->marked |= OM_FOUND;
4717 /* Scan all normal grids */
4718 for (y = 1; y < cur_hgt - 1; y++)
4720 /* Scan all normal grids */
4721 for (x = 1; x < cur_wid - 1; x++)
4723 cave_type *c_ptr = &cave[y][x];
4725 /* Feature code (applying "mimic" field) */
4726 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
4728 /* Process all non-walls */
4729 if (cave_floor_bold(y, x) || (feat == FEAT_RUBBLE) || (feat == FEAT_TREES) || (feat == FEAT_MOUNTAIN))
4731 /* Scan all neighbors */
4732 for (i = 0; i < 9; i++)
4734 int yy = y + ddy_ddd[i];
4735 int xx = x + ddx_ddd[i];
4738 c_ptr = &cave[yy][xx];
4740 /* Feature code (applying "mimic" field) */
4741 feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
4743 /* Memorize normal features */
4746 /* Memorize the grid */
4747 c_ptr->info |= (CAVE_MARK);
4751 if ((feat > FEAT_INVIS))
4753 /* Memorize the grid */
4754 c_ptr->info |= (CAVE_MARK);
4757 /* Perma-lite the grid */
4758 if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
4760 c_ptr->info |= (CAVE_GLOW);
4762 /* Normally, memorize floors (see above) */
4763 if (view_perma_grids && !view_torch_grids)
4765 /* Memorize the grid */
4766 c_ptr->info |= (CAVE_MARK);
4775 /* Update the monsters */
4776 p_ptr->update |= (PU_MONSTERS);
4779 p_ptr->redraw |= (PR_MAP);
4782 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4787 * Forget the dungeon map (ala "Thinking of Maud...").
4794 /* Forget every grid */
4795 for (y = 0; y < cur_hgt; y++)
4797 for (x = 0; x < cur_wid; x++)
4799 cave_type *c_ptr = &cave[y][x];
4801 /* Process the grid */
4802 c_ptr->info &= ~(CAVE_MARK);
4806 /* Forget all objects */
4807 for (i = 1; i < o_max; i++)
4809 object_type *o_ptr = &o_list[i];
4811 /* Skip dead objects */
4812 if (!o_ptr->k_idx) continue;
4814 /* Skip held objects */
4815 if (o_ptr->held_m_idx) continue;
4817 /* Forget the object */
4821 /* Mega-Hack -- Forget the view and lite */
4822 p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
4824 /* Update the view and lite */
4825 p_ptr->update |= (PU_VIEW | PU_LITE);
4827 /* Update the monsters */
4828 p_ptr->update |= (PU_MONSTERS);
4831 p_ptr->redraw |= (PR_MAP);
4834 p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
4842 * Change the "feat" flag for a grid, and notice/redraw the grid
4844 void cave_set_feat(int y, int x, int feat)
4846 cave_type *c_ptr = &cave[y][x];
4848 /* Clear mimic type */
4851 /* Remove flag for mirror/glyph */
4852 c_ptr->info &= ~(CAVE_OBJECT);
4854 /* Change the feature */
4864 /* Remove a mirror */
4865 void remove_mirror(int y, int x)
4867 /* Remove the mirror */
4868 cave[y][x].info &= ~(CAVE_OBJECT);
4869 cave[y][x].mimic = 0;
4871 if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
4873 cave[y][x].info &= ~(CAVE_GLOW);
4874 if( !view_torch_grids )cave[y][x].info &= ~(CAVE_MARK);
4885 * Return TRUE if there is a mirror on the grid.
4887 bool is_mirror_grid(cave_type *c_ptr)
4889 if ((c_ptr->info & CAVE_OBJECT) && c_ptr->mimic == FEAT_MIRROR)
4897 * Return TRUE if there is a mirror on the grid.
4899 bool is_glyph_grid(cave_type *c_ptr)
4901 if ((c_ptr->info & CAVE_OBJECT) && c_ptr->mimic == FEAT_GLYPH)
4909 * Return TRUE if there is a mirror on the grid.
4911 bool is_explosive_rune_grid(cave_type *c_ptr)
4913 if ((c_ptr->info & CAVE_OBJECT) && c_ptr->mimic == FEAT_MINOR_GLYPH)
4921 * Calculate "incremental motion". Used by project() and shoot().
4922 * Assumes that (*y,*x) lies on the path from (y1,x1) to (y2,x2).
4924 void mmove2(int *y, int *x, int y1, int x1, int y2, int x2)
4926 int dy, dx, dist, shift;
4928 /* Extract the distance travelled */
4929 dy = (*y < y1) ? y1 - *y : *y - y1;
4930 dx = (*x < x1) ? x1 - *x : *x - x1;
4932 /* Number of steps */
4933 dist = (dy > dx) ? dy : dx;
4935 /* We are calculating the next location */
4939 /* Calculate the total distance along each axis */
4940 dy = (y2 < y1) ? (y1 - y2) : (y2 - y1);
4941 dx = (x2 < x1) ? (x1 - x2) : (x2 - x1);
4943 /* Paranoia -- Hack -- no motion */
4944 if (!dy && !dx) return;
4947 /* Move mostly vertically */
4950 /* Extract a shift factor */
4951 shift = (dist * dx + (dy - 1) / 2) / dy;
4953 /* Sometimes move along the minor axis */
4954 (*x) = (x2 < x1) ? (x1 - shift) : (x1 + shift);
4956 /* Always move along major axis */
4957 (*y) = (y2 < y1) ? (y1 - dist) : (y1 + dist);
4960 /* Move mostly horizontally */
4963 /* Extract a shift factor */
4964 shift = (dist * dy + (dx - 1) / 2) / dx;
4966 /* Sometimes move along the minor axis */
4967 (*y) = (y2 < y1) ? (y1 - shift) : (y1 + shift);
4969 /* Always move along major axis */
4970 (*x) = (x2 < x1) ? (x1 - dist) : (x1 + dist);
4977 * Determine if a bolt spell cast from (y1,x1) to (y2,x2) will arrive
4978 * at the final destination, assuming no monster gets in the way.
4980 * This is slightly (but significantly) different from "los(y1,x1,y2,x2)".
4982 bool projectable(int y1, int x1, int y2, int x2)
4989 /* Check the projection path */
4990 grid_n = project_path(grid_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, 0);
4992 /* No grid is ever projectable from itself */
4993 if (!grid_n) return (FALSE);
4996 y = GRID_Y(grid_g[grid_n - 1]);
4997 x = GRID_X(grid_g[grid_n - 1]);
4999 /* May not end in an unrequested grid */
5000 if ((y != y2) || (x != x2)) return (FALSE);
5008 * Standard "find me a location" function
5010 * Obtains a legal location within the given distance of the initial
5011 * location, and with "los()" from the source to destination location.
5013 * This function is often called from inside a loop which searches for
5014 * locations while increasing the "d" distance.
5016 * Currently the "m" parameter is unused.
5018 void scatter(int *yp, int *xp, int y, int x, int d, int m)
5025 /* Pick a location */
5028 /* Pick a new location */
5029 ny = rand_spread(y, d);
5030 nx = rand_spread(x, d);
5032 /* Ignore annoying locations */
5033 if (!in_bounds(ny, nx)) continue;
5035 /* Ignore "excessively distant" locations */
5036 if ((d > 1) && (distance(y, x, ny, nx) > d)) continue;
5038 /* Require "line of sight" */
5039 if (los(y, x, ny, nx)) break;
5042 /* Save the location */
5051 * Track a new monster
5053 void health_track(int m_idx)
5055 /* Mount monster is already tracked */
5056 if (m_idx && m_idx == p_ptr->riding) return;
5058 /* Track a new guy */
5059 p_ptr->health_who = m_idx;
5061 /* Redraw (later) */
5062 p_ptr->redraw |= (PR_HEALTH);
5068 * Hack -- track the given monster race
5070 void monster_race_track(int r_idx)
5072 /* Save this monster ID */
5073 p_ptr->monster_race_idx = r_idx;
5076 p_ptr->window |= (PW_MONSTER);
5082 * Hack -- track the given object kind
5084 void object_kind_track(int k_idx)
5086 /* Save this monster ID */
5087 p_ptr->object_kind_idx = k_idx;
5090 p_ptr->window |= (PW_OBJECT);
5096 * Something has happened to disturb the player.
5098 * The first arg indicates a major disturbance, which affects search.
5100 * The second arg is currently unused, but could induce output flush.
5102 * All disturbance cancels repeated commands, resting, and running.
5104 void disturb(int stop_search, int unused_flag)
5107 unused_flag = unused_flag;
5109 /* Cancel auto-commands */
5110 /* command_new = 0; */
5112 /* Cancel repeated commands */
5118 /* Redraw the state (later) */
5119 p_ptr->redraw |= (PR_STATE);
5122 /* Cancel Resting */
5123 if ((p_ptr->action == ACTION_REST) || (p_ptr->action == ACTION_FISH) || (stop_search && (p_ptr->action == ACTION_SEARCH)))
5126 set_action(ACTION_NONE);
5129 /* Cancel running */
5135 /* Check for new panel if appropriate */
5136 if (center_player && !center_running) verify_panel();
5138 /* Calculate torch radius */
5139 p_ptr->update |= (PU_TORCH);
5141 /* Update monster flow */
5142 p_ptr->update |= (PU_FLOW);
5145 /* Flush the input if requested */
5146 if (flush_disturb) flush();
5151 * Glow deep lava in the floor
5153 void glow_deep_lava(void)
5155 int y, x, i, yy, xx;
5158 for (y = 1; y < cur_hgt - 1; y++)
5160 for (x = 1; x < cur_wid - 1; x++)
5162 c_ptr = &cave[y][x];
5164 if (c_ptr->feat == FEAT_DEEP_LAVA)
5166 for (i = 0; i < 9; i++)
5168 yy = y + ddy_ddd[i];
5169 xx = x + ddx_ddd[i];
5170 cave[yy][xx].info |= CAVE_GLOW;
5171 if (player_has_los_bold(yy, xx)) note_spot(yy, xx);