-/* File: cave.c */
-
-/*
- * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
- * This software may be copied and distributed for educational, research,
- * and not for profit purposes provided that this copyright and statement
- * are included in all such copies. Other copyrights may also apply.
+/*!
+ * @file cave.c
+ * @brief ダンジョンの基礎部分実装(主にマスの実装) / low level dungeon routines -BEN-
+ * @date 2013/12/30
+ * @author
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
+ *\n
+ * This software may be copied and distributed for educational, research,\n
+ * and not for profit purposes provided that this copyright and statement\n
+ * are included in all such copies. Other copyrights may also apply.\n
+ * \n
+ * Support for Adam Bolt's tileset, lighting and transparency effects\n
+ * by Robert Ruehlmann (rr9@angband.org)\n
+ * \n
+ * 2013 Deskull Doxygen向けのコメント整理\n
*/
-/* Purpose: low level dungeon routines -BEN- */
-
#include "angband.h"
-
-/*
- * Support for Adam Bolt's tileset, lighting and transparency effects
- * by Robert Ruehlmann (rr9@angband.org)
- */
-
-static byte display_autopick;
+static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
static int match_autopick;
-static object_type *autopick_obj;
-static int feat_priority;
-
-/*
- * Distance between two points via Newton-Raphson technique
+static object_type *autopick_obj; /*!< 各種自動拾い処理時に使うオブジェクトポインタ */
+static int feat_priority; /*!< マップ縮小表示時に表示すべき地形の優先度を保管する */
+
+/*!
+ * @brief 2点間の距離をニュートン・ラプソン法で算出する / Distance between two points via Newton-Raphson technique
+ * @param y1 1点目のy座標
+ * @param x1 1点目のx座標
+ * @param y2 2点目のy座標
+ * @param x2 2点目のx座標
+ * @return 2点間の距離
*/
-int distance (int y1, int x1, int y2, int x2)
+POSITION distance (POSITION y1, POSITION x1, POSITION y2, POSITION x2)
{
- int dy = (y1 > y2) ? (y1 - y2) : (y2 - y1);
- int dx = (x1 > x2) ? (x1 - x2) : (x2 - x1);
+ POSITION dy = (y1 > y2) ? (y1 - y2) : (y2 - y1);
+ POSITION dx = (x1 > x2) ? (x1 - x2) : (x2 - x1);
/* Squared distance */
- int target = (dy * dy) + (dx * dx);
+ POSITION target = (dy * dy) + (dx * dx);
/* Approximate distance: hypot(dy,dx) = max(dy,dx) + min(dy,dx) / 2 */
- int d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
+ POSITION d = (dy > dx) ? (dy + (dx>>1)) : (dx + (dy>>1));
- int err;
+ POSITION err;
/* Simple case */
if (!dy || !dx) return d;
return d;
}
-
-/*
- * Return TRUE if the given feature is a trap
+/*!
+ * @brief 地形が罠持ちであるかの判定を行う。 / Return TRUE if the given feature is a trap
+ * @param feat 地形情報のID
+ * @return 罠持ちの地形ならばTRUEを返す。
*/
-bool is_trap(int feat)
+bool is_trap(IDX feat)
{
- switch (feat)
- {
- case FEAT_TRAP_TRAPDOOR:
- case FEAT_TRAP_PIT:
- case FEAT_TRAP_SPIKED_PIT:
- case FEAT_TRAP_POISON_PIT:
- case FEAT_TRAP_TY_CURSE:
- case FEAT_TRAP_TELEPORT:
- case FEAT_TRAP_FIRE:
- case FEAT_TRAP_ACID:
- case FEAT_TRAP_SLOW:
- case FEAT_TRAP_LOSE_STR:
- case FEAT_TRAP_LOSE_DEX:
- case FEAT_TRAP_LOSE_CON:
- case FEAT_TRAP_BLIND:
- case FEAT_TRAP_CONFUSE:
- case FEAT_TRAP_POISON:
- case FEAT_TRAP_SLEEP:
- case FEAT_TRAP_TRAPS:
- case FEAT_TRAP_ALARM:
- case FEAT_TRAP_OPEN:
- case FEAT_TRAP_ARMAGEDDON:
- case FEAT_TRAP_PIRANHA:
- {
- /* A trap */
- return (TRUE);
- }
- default:
- {
- /* Not a trap */
- return (FALSE);
- }
- }
+ return have_flag(f_info[feat].flags, FF_TRAP);
}
-
-/*
- * Return TRUE if the given grid is a known trap
+/*!
+ * @brief マスに看破済みの罠があるかの判定を行う。 / Return TRUE if the given grid is a known trap
+ * @param c_ptr マス構造体の参照ポインタ
+ * @return 看破済みの罠があるならTRUEを返す。
*/
bool is_known_trap(cave_type *c_ptr)
{
- if (!c_ptr->mimic && is_trap(c_ptr->feat)) return TRUE;
- else return FALSE;
+ if (!c_ptr->mimic && !cave_have_flag_grid(c_ptr, FF_SECRET) &&
+ is_trap(c_ptr->feat)) return TRUE;
+ else
+ return FALSE;
}
-
-/*
- * Return TRUE if the given grid is a closed door
+/*!
+ * @brief 地形が閉じたドアであるかの判定を行う。 / Return TRUE if the given grid is a closed door
+ * @param feat 地形情報のID
+ * @return 閉じたドアのある地形ならばTRUEを返す。
*/
-bool is_closed_door(int feat)
+bool is_closed_door(IDX feat)
{
- return (feat >= FEAT_DOOR_HEAD && feat <= FEAT_DOOR_TAIL);
-}
+ feature_type *f_ptr = &f_info[feat];
+ return (have_flag(f_ptr->flags, FF_OPEN) || have_flag(f_ptr->flags, FF_BASH)) &&
+ !have_flag(f_ptr->flags, FF_MOVE);
+}
-/*
- * Return TRUE if the given grid is a hidden closed door
+/*!
+ * @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door
+ * @param c_ptr マス構造体の参照ポインタ
+ * @return 隠されたドアがあるならTRUEを返す。
*/
bool is_hidden_door(cave_type *c_ptr)
{
- if (c_ptr->mimic &&
+ if ((c_ptr->mimic || cave_have_flag_grid(c_ptr, FF_SECRET)) &&
is_closed_door(c_ptr->feat))
return TRUE;
- else
+ else
return FALSE;
}
-
-/*
- * A simple, fast, integer-based line-of-sight algorithm. By Joseph Hall,
- * 4116 Brewster Drive, Raleigh NC 27606. Email to jnh@ecemwl.ncsu.edu.
- *
- * Returns TRUE if a line of sight can be traced from (x1,y1) to (x2,y2).
- *
- * The LOS begins at the center of the tile (x1,y1) and ends at the center of
- * the tile (x2,y2). If los() is to return TRUE, all of the tiles this line
- * passes through must be floor tiles, except for (x1,y1) and (x2,y2).
- *
- * We assume that the "mathematical corner" of a non-floor tile does not
- * block line of sight.
- *
- * Because this function uses (short) ints for all calculations, overflow may
- * occur if dx and dy exceed 90.
- *
- * Once all the degenerate cases are eliminated, the values "qx", "qy", and
- * "m" are multiplied by a scale factor "f1 = abs(dx * dy * 2)", so that
- * we can use integer arithmetic.
- *
- * We travel from start to finish along the longer axis, starting at the border
- * between the first and second tiles, where the y offset = .5 * slope, taking
- * into account the scale factor. See below.
- *
- * Also note that this function and the "move towards target" code do NOT
- * share the same properties. Thus, you can see someone, target them, and
- * then fire a bolt at them, but the bolt may hit a wall, not them. However,
- * by clever choice of target locations, you can sometimes throw a "curve".
- *
- * Note that "line of sight" is not "reflexive" in all cases.
- *
- * Use the "projectable()" routine to test "spell/missile line of sight".
- *
- * Use the "update_view()" function to determine player line-of-sight.
+/*!
+ * @brief LOS(Line Of Sight / 視線が通っているか)の判定を行う。
+ * @param y1 始点のy座標
+ * @param x1 始点のx座標
+ * @param y2 終点のy座標
+ * @param x2 終点のx座標
+ * @return LOSが通っているならTRUEを返す。
+ * @details
+ * A simple, fast, integer-based line-of-sight algorithm. By Joseph Hall,\n
+ * 4116 Brewster Drive, Raleigh NC 27606. Email to jnh@ecemwl.ncsu.edu.\n
+ *\n
+ * Returns TRUE if a line of sight can be traced from (x1,y1) to (x2,y2).\n
+ *\n
+ * The LOS begins at the center of the tile (x1,y1) and ends at the center of\n
+ * the tile (x2,y2). If los() is to return TRUE, all of the tiles this line\n
+ * passes through must be floor tiles, except for (x1,y1) and (x2,y2).\n
+ *\n
+ * We assume that the "mathematical corner" of a non-floor tile does not\n
+ * block line of sight.\n
+ *\n
+ * Because this function uses (short) ints for all calculations, overflow may\n
+ * occur if dx and dy exceed 90.\n
+ *\n
+ * Once all the degenerate cases are eliminated, the values "qx", "qy", and\n
+ * "m" are multiplied by a scale factor "f1 = abs(dx * dy * 2)", so that\n
+ * we can use integer arithmetic.\n
+ *\n
+ * We travel from start to finish along the longer axis, starting at the border\n
+ * between the first and second tiles, where the y offset = .5 * slope, taking\n
+ * into account the scale factor. See below.\n
+ *\n
+ * Also note that this function and the "move towards target" code do NOT\n
+ * share the same properties. Thus, you can see someone, target them, and\n
+ * then fire a bolt at them, but the bolt may hit a wall, not them. However\n,
+ * by clever choice of target locations, you can sometimes throw a "curve".\n
+ *\n
+ * Note that "line of sight" is not "reflexive" in all cases.\n
+ *\n
+ * Use the "projectable()" routine to test "spell/missile line of sight".\n
+ *\n
+ * Use the "update_view()" function to determine player line-of-sight.\n
*/
-bool los(int y1, int x1, int y2, int x2)
+bool los(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
{
/* Delta */
- int dx, dy;
+ POSITION dx, dy;
/* Absolute */
int ax, ay;
/* Handle adjacent (or identical) grids */
- if ((ax < 2) && (ay < 2)) return (TRUE);
+ if ((ax < 2) && (ay < 2)) return TRUE;
/* Paranoia -- require "safe" origin */
- /* if (!in_bounds(y1, x1)) return (FALSE); */
- /* if (!in_bounds(y2, x2)) return (FALSE); */
+ /* if (!in_bounds(y1, x1)) return FALSE; */
+ /* if (!in_bounds(y2, x2)) return FALSE; */
/* Directly South/North */
{
for (ty = y1 + 1; ty < y2; ty++)
{
- if (!cave_floor_bold(ty, x1)) return (FALSE);
+ if (!cave_los_bold(ty, x1)) return FALSE;
}
}
{
for (ty = y1 - 1; ty > y2; ty--)
{
- if (!cave_floor_bold(ty, x1)) return (FALSE);
+ if (!cave_los_bold(ty, x1)) return FALSE;
}
}
/* Assume los */
- return (TRUE);
+ return TRUE;
}
/* Directly East/West */
{
for (tx = x1 + 1; tx < x2; tx++)
{
- if (!cave_floor_bold(y1, tx)) return (FALSE);
+ if (!cave_los_bold(y1, tx)) return FALSE;
}
}
{
for (tx = x1 - 1; tx > x2; tx--)
{
- if (!cave_floor_bold(y1, tx)) return (FALSE);
+ if (!cave_los_bold(y1, tx)) return FALSE;
}
}
/* Assume los */
- return (TRUE);
+ return TRUE;
}
{
if (ay == 2)
{
- if (cave_floor_bold(y1 + sy, x1)) return (TRUE);
+ if (cave_los_bold(y1 + sy, x1)) return TRUE;
}
}
{
if (ax == 2)
{
- if (cave_floor_bold(y1, x1 + sx)) return (TRUE);
+ if (cave_los_bold(y1, x1 + sx)) return TRUE;
}
}
/* the LOS exactly meets the corner of a tile. */
while (x2 - tx)
{
- if (!cave_floor_bold(ty, tx)) return (FALSE);
+ if (!cave_los_bold(ty, tx)) return FALSE;
qy += m;
else if (qy > f2)
{
ty += sy;
- if (!cave_floor_bold(ty, tx)) return (FALSE);
+ if (!cave_los_bold(ty, tx)) return FALSE;
qy -= f1;
tx += sx;
}
/* the LOS exactly meets the corner of a tile. */
while (y2 - ty)
{
- if (!cave_floor_bold(ty, tx)) return (FALSE);
+ if (!cave_los_bold(ty, tx)) return FALSE;
qx += m;
else if (qx > f2)
{
tx += sx;
- if (!cave_floor_bold(ty, tx)) return (FALSE);
+ if (!cave_los_bold(ty, tx)) return FALSE;
qx -= f1;
ty += sy;
}
}
/* Assume los */
- return (TRUE);
+ return TRUE;
}
+#define COMPLEX_WALL_ILLUMINATION /*!< 照明状態を壁により影響を受ける、より複雑な判定に切り替えるマクロ */
+/*!
+ * @brief 指定された座標のマスが現在照らされているかを返す。 / Check for "local" illumination
+ * @param y y座標
+ * @param x x座標
+ * @return 指定された座標に照明がかかっているならTRUEを返す。。
+ */
+static bool check_local_illumination(int y, int x)
+{
+ /* Hack -- move towards player */
+ int yy = (y < p_ptr->y) ? (y + 1) : (y > p_ptr->y) ? (y - 1) : y;
+ int xx = (x < p_ptr->x) ? (x + 1) : (x > p_ptr->x) ? (x - 1) : x;
+ /* Check for "local" illumination */
+#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
-/*
- * Can the player "see" the given grid in detail?
- *
- * He must have vision, illumination, and line of sight.
- *
- * Note -- "CAVE_LITE" is only set if the "torch" has "los()".
- * So, given "CAVE_LITE", we know that the grid is "fully visible".
- *
- * Note that "CAVE_GLOW" makes little sense for a wall, since it would mean
- * that a wall is visible from any direction. That would be odd. Except
- * under wizard light, which might make sense. Thus, for walls, we require
- * not only that they be "CAVE_GLOW", but also, that they be adjacent to a
- * grid which is not only "CAVE_GLOW", but which is a non-wall, and which is
- * in line of sight of the player.
- *
- * This extra check is expensive, but it provides a more "correct" semantics.
- *
- * Note that we should not run this check on walls which are "outer walls" of
- * the dungeon, or we will induce a memory fault, but actually verifying all
- * of the locations would be extremely expensive.
- *
- * Thus, to speed up the function, we assume that all "perma-walls" which are
- * "CAVE_GLOW" are "illuminated" from all sides. This is correct for all cases
- * except "vaults" and the "buildings" in town. But the town is a hack anyway,
- * and the player has more important things on his mind when he is attacking a
- * monster vault. It is annoying, but an extremely important optimization.
- *
- * Note that "glowing walls" are only considered to be "illuminated" if the
- * grid which is next to the wall in the direction of the player is also a
- * "glowing" grid. This prevents the player from being able to "see" the
- * walls of illuminated rooms from a corridor outside the room.
+ /* Check for "complex" illumination */
+ if ((feat_supports_los(get_feat_mimic(&cave[yy][xx])) &&
+ (cave[yy][xx].info & CAVE_GLOW)) ||
+ (feat_supports_los(get_feat_mimic(&cave[y][xx])) &&
+ (cave[y][xx].info & CAVE_GLOW)) ||
+ (feat_supports_los(get_feat_mimic(&cave[yy][x])) &&
+ (cave[yy][x].info & CAVE_GLOW)))
+ {
+ return TRUE;
+ }
+ else return FALSE;
+
+#else /* COMPLEX_WALL_ILLUMINATION */
+
+ /* Check for "simple" illumination */
+ return (cave[yy][xx].info & CAVE_GLOW) ? TRUE : FALSE;
+
+#endif /* COMPLEX_WALL_ILLUMINATION */
+}
+
+
+/*! 対象座標のマスの照明状態を更新する際の補助処理マクロ */
+#define update_local_illumination_aux(Y, X) \
+{ \
+ if (player_has_los_bold((Y), (X))) \
+ { \
+ /* Update the monster */ \
+ if (cave[(Y)][(X)].m_idx) update_mon(cave[(Y)][(X)].m_idx, FALSE); \
+\
+ /* Notice and redraw */ \
+ note_spot((Y), (X)); \
+ lite_spot((Y), (X)); \
+ } \
+}
+
+/*!
+ * @brief 指定された座標の照明状態を更新する / Update "local" illumination
+ * @param y y座標
+ * @param x x座標
+ * @return なし
*/
-bool player_can_see_bold(int y, int x)
+void update_local_illumination(int y, int x)
{
- int xx, yy;
+ int i, yy, xx;
+
+ if (!in_bounds(y, x)) return;
+
+#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
+
+ if ((y != p_ptr->y) && (x != p_ptr->x))
+ {
+ yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
+ xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ update_local_illumination_aux(yy, xx);
+ update_local_illumination_aux(y, xx);
+ update_local_illumination_aux(yy, x);
+ }
+ else if (x != p_ptr->x) /* y == p_ptr->y */
+ {
+ xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ for (i = -1; i <= 1; i++)
+ {
+ yy = y + i;
+ update_local_illumination_aux(yy, xx);
+ }
+ yy = y - 1;
+ update_local_illumination_aux(yy, x);
+ yy = y + 1;
+ update_local_illumination_aux(yy, x);
+ }
+ else if (y != p_ptr->y) /* x == p_ptr->x */
+ {
+ yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
+ for (i = -1; i <= 1; i++)
+ {
+ xx = x + i;
+ update_local_illumination_aux(yy, xx);
+ }
+ xx = x - 1;
+ update_local_illumination_aux(y, xx);
+ xx = x + 1;
+ update_local_illumination_aux(y, xx);
+ }
+ else /* Player's grid */
+ {
+ for (i = 0; i < 8; i++)
+ {
+ yy = y + ddy_cdd[i];
+ xx = x + ddx_cdd[i];
+ update_local_illumination_aux(yy, xx);
+ }
+ }
+
+#else /* COMPLEX_WALL_ILLUMINATION */
+ if ((y != p_ptr->y) && (x != p_ptr->x))
+ {
+ yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
+ xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ update_local_illumination_aux(yy, xx);
+ }
+ else if (x != p_ptr->x) /* y == p_ptr->y */
+ {
+ xx = (x < p_ptr->x) ? (x - 1) : (x + 1);
+ for (i = -1; i <= 1; i++)
+ {
+ yy = y + i;
+ update_local_illumination_aux(yy, xx);
+ }
+ }
+ else if (y != p_ptr->y) /* x == p_ptr->x */
+ {
+ yy = (y < p_ptr->y) ? (y - 1) : (y + 1);
+ for (i = -1; i <= 1; i++)
+ {
+ xx = x + i;
+ update_local_illumination_aux(yy, xx);
+ }
+ }
+ else /* Player's grid */
+ {
+ for (i = 0; i < 8; i++)
+ {
+ yy = y + ddy_cdd[i];
+ xx = x + ddx_cdd[i];
+ update_local_illumination_aux(yy, xx);
+ }
+ }
+
+#endif /* COMPLEX_WALL_ILLUMINATION */
+}
+
+
+/*!
+ * @brief 指定された座標をプレイヤーが視覚に収められるかを返す。 / Can the player "see" the given grid in detail?
+ * @param y y座標
+ * @param x x座標
+ * @return 視覚に収められる状態ならTRUEを返す
+ * @details
+ * He must have vision, illumination, and line of sight.\n
+ * \n
+ * Note -- "CAVE_LITE" is only set if the "torch" has "los()".\n
+ * So, given "CAVE_LITE", we know that the grid is "fully visible".\n
+ *\n
+ * Note that "CAVE_GLOW" makes little sense for a wall, since it would mean\n
+ * that a wall is visible from any direction. That would be odd. Except\n
+ * under wizard light, which might make sense. Thus, for walls, we require\n
+ * not only that they be "CAVE_GLOW", but also, that they be adjacent to a\n
+ * grid which is not only "CAVE_GLOW", but which is a non-wall, and which is\n
+ * in line of sight of the player.\n
+ *\n
+ * This extra check is expensive, but it provides a more "correct" semantics.\n
+ *\n
+ * Note that we should not run this check on walls which are "outer walls" of\n
+ * the dungeon, or we will induce a memory fault, but actually verifying all\n
+ * of the locations would be extremely expensive.\n
+ *\n
+ * Thus, to speed up the function, we assume that all "perma-walls" which are\n
+ * "CAVE_GLOW" are "illuminated" from all sides. This is correct for all cases\n
+ * except "vaults" and the "buildings" in town. But the town is a hack anyway,\n
+ * and the player has more important things on his mind when he is attacking a\n
+ * monster vault. It is annoying, but an extremely important optimization.\n
+ *\n
+ * Note that "glowing walls" are only considered to be "illuminated" if the\n
+ * grid which is next to the wall in the direction of the player is also a\n
+ * "glowing" grid. This prevents the player from being able to "see" the\n
+ * walls of illuminated rooms from a corridor outside the room.\n
+ */
+bool player_can_see_bold(int y, int x)
+{
cave_type *c_ptr;
/* Blind players see nothing */
- if (p_ptr->blind) return (FALSE);
+ if (p_ptr->blind) return FALSE;
/* Access the cave grid */
c_ptr = &cave[y][x];
/* Note that "torch-lite" yields "illumination" */
- if (c_ptr->info & (CAVE_LITE)) return (TRUE);
+ if (c_ptr->info & (CAVE_LITE | CAVE_MNLT)) return TRUE;
/* Require line of sight to the grid */
- if (!player_has_los_bold(y, x)) return (FALSE);
+ if (!player_has_los_bold(y, x)) return FALSE;
/* Noctovision of Ninja */
if (p_ptr->see_nocto) return TRUE;
/* Require "perma-lite" of the grid */
- if (!(c_ptr->info & CAVE_MNLT) && ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)) return FALSE;
+ if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) return FALSE;
+ /* Feature code (applying "mimic" field) */
/* Floors are simple */
- if (cave_floor_bold(y, x)) return (TRUE);
-
- /* Hack -- move towards player */
- yy = (y < py) ? (y + 1) : (y > py) ? (y - 1) : y;
- xx = (x < px) ? (x + 1) : (x > px) ? (x - 1) : x;
+ if (feat_supports_los(get_feat_mimic(c_ptr))) return TRUE;
/* Check for "local" illumination */
- if ((cave[yy][xx].info & CAVE_MNLT) || ((cave[yy][xx].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW))
- {
- /* Assume the wall is really illuminated */
- return (TRUE);
- }
-
- /* Assume not visible */
- return (FALSE);
+ return check_local_illumination(y, x);
}
-
-
-/*
- * Returns true if the player's grid is dark
+/*!
+ * @brief 指定された座標をプレイヤー収められていない状態かどうか / Returns true if the player's grid is dark
+ * @return 視覚に収められていないならTRUEを返す
+ * @details player_can_see_bold()関数の返り値の否定を返している。
*/
bool no_lite(void)
{
- return (!player_can_see_bold(py, px));
+ return (!player_can_see_bold(p_ptr->y, p_ptr->x));
}
-
-
-/*
- * Determine if a given location may be "destroyed"
- *
- * Used by destruction spells, and for placing stairs, etc.
+/*!
+ * @brief 指定された座標が地震や階段生成の対象となるマスかを返す。 / Determine if a given location may be "destroyed"
+ * @param y y座標
+ * @param x x座標
+ * @return 各種の変更が可能ならTRUEを返す。
+ * @details
+ * 条件は永久地形でなく、なおかつ該当のマスにアーティファクトが存在しないか、である。英語の旧コメントに反して*破壊*の抑止判定には現在使われていない。
*/
bool cave_valid_bold(int y, int x)
{
next_o_idx = o_ptr->next_o_idx;
/* Forbid artifact grids */
- if ((o_ptr->art_name) || artifact_p(o_ptr)) return (FALSE);
+ if (object_is_artifact(o_ptr)) return (FALSE);
}
/* Accept */
-/*
- * Determine if a given location may be "destroyed"
- *
- * Used by destruction spells, and for placing stairs, etc.
- */
-bool cave_valid_grid(cave_type *c_ptr)
-{
- s16b this_o_idx, next_o_idx = 0;
-
-
- /* Forbid perma-grids */
- if (cave_perma_grid(c_ptr)) return (FALSE);
-
- /* Check objects */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
- {
- object_type *o_ptr;
-
- /* Acquire object */
- o_ptr = &o_list[this_o_idx];
-
- /* Acquire next object */
- next_o_idx = o_ptr->next_o_idx;
-
- /* Forbid artifact grids */
- if ((o_ptr->art_name) || artifact_p(o_ptr)) return (FALSE);
- }
-
- /* Accept */
- return (TRUE);
-}
-
-
-
-
-/*
- * Hack -- Legal monster codes
+/*!
+ * 一般的にモンスターシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal monster codes
*/
static char image_monster_hack[] = \
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
-/*
- * Mega-Hack -- Hallucinatory monster
+/*!
+ * 一般的にオブジェクトシンボルとして扱われる記号を定義する(幻覚処理向け) / Hack -- Legal object codes
+ */
+static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
+
+/*!
+ * @brief モンスターの表示を幻覚状態に差し替える / Mega-Hack -- Hallucinatory monster
+ * @param ap 本来の色
+ * @param cp 本来のシンボル
+ * @return なし
*/
static void image_monster(byte *ap, char *cp)
{
else
/* Text mode */
{
- int n = sizeof(image_monster_hack) - 1;
-
- *cp = image_monster_hack[randint0(n)];
+ *cp = (one_in_(25) ?
+ image_object_hack[randint0(sizeof(image_object_hack) - 1)] :
+ image_monster_hack[randint0(sizeof(image_monster_hack) - 1)]);
/* Random color */
*ap = randint1(15);
}
}
-
-
-/*
- * Hack -- Legal object codes
- */
-static char image_object_hack[] = "?/|\\\"!$()_-=[]{},~";
-
-/*
- * Mega-Hack -- Hallucinatory object
+/*!
+ * @brief オブジェクトの表示を幻覚状態に差し替える / Hallucinatory object
+ * @param ap 本来の色
+ * @param cp 本来のシンボル
+ * @return なし
*/
static void image_object(byte *ap, char *cp)
{
}
-
-/*
- * Hack -- Random hallucination
+/*!
+ * @brief オブジェクト&モンスターの表示を幻覚状態に差し替える / Hack -- Random hallucination
+ * @param ap 本来の色
+ * @param cp 本来のシンボル
+ * @return なし
*/
static void image_random(byte *ap, char *cp)
{
}
}
-/*
- * Not using graphical tiles for this feature?
- */
-#define is_ascii_graphics(A) (!((A) & 0x80))
-
-/*
- * The 16x16 tile of the terrain supports lighting
- */
-static bool feat_supports_lighting(byte feat)
-{
- if (is_trap(feat)) return streq(ANGBAND_GRAF, "new");
-
- switch (feat)
- {
- case FEAT_FLOOR:
- case FEAT_INVIS:
- case FEAT_GLYPH:
- case FEAT_LESS:
- case FEAT_MORE:
- case FEAT_LESS_LESS:
- case FEAT_MORE_MORE:
- case FEAT_RUBBLE:
- case FEAT_MAGMA:
- case FEAT_QUARTZ:
- case FEAT_MAGMA_H:
- case FEAT_QUARTZ_H:
- case FEAT_MAGMA_K:
- case FEAT_QUARTZ_K:
- case FEAT_WALL_EXTRA:
- case FEAT_WALL_INNER:
- case FEAT_WALL_OUTER:
- case FEAT_WALL_SOLID:
- case FEAT_PERM_EXTRA:
- case FEAT_PERM_INNER:
- case FEAT_PERM_OUTER:
- case FEAT_PERM_SOLID:
- case FEAT_MINOR_GLYPH:
- case FEAT_DEEP_WATER:
- case FEAT_SHAL_WATER:
- case FEAT_DEEP_LAVA:
- case FEAT_SHAL_LAVA:
- case FEAT_DARK_PIT:
- case FEAT_DIRT:
- case FEAT_GRASS:
- case FEAT_FLOWER:
- case FEAT_DEEP_GRASS:
- case FEAT_TREES:
- case FEAT_MOUNTAIN:
- case FEAT_MIRROR:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-/*
- * This array lists the effects of "brightness" on various "base" colours.
- *
- * This is used to do dynamic lighting effects in ascii :-)
- * At the moment, only the various "floor" tiles are affected.
- *
- * The layout of the array is [x][0] = light and [x][1] = dark.
+/*!
+ * 照明の表現を行うための色合いの関係を{暗闇時, 照明時} で定義する /
+ * This array lists the effects of "brightness" on various "base" colours.\n
+ *\n
+ * This is used to do dynamic lighting effects in ascii :-)\n
+ * At the moment, only the various "floor" tiles are affected.\n
+ *\n
+ * The layout of the array is [x][0] = light and [x][1] = dark.\n
*/
-
static byte lighting_colours[16][2] =
{
/* TERM_DARK */
{TERM_L_UMBER, TERM_UMBER}
};
-
-/*
- * Mega-Hack -- Partial code of map_info() for darkened grids
- * Note: Each variable is declared in map_info().
- * This macro modifies "feat", "f_ptr", "c" and "a".
+/*!
+ * @brief 調査中
+ * @todo コメントを付加すること
*/
-#define darkened_grid_hack() \
-{ \
- if (feat_floor(feat)) \
- { \
- /* Unsafe cave grid -- idea borrowed from Unangband */ \
- if (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) \
- { \
- feat = FEAT_UNDETECTD; \
-\
- /* Access unsafe darkness */ \
- f_ptr = &f_info[feat]; \
-\
- /* Char and attr of unsafe grid */ \
- c = f_ptr->x_char; \
- a = f_ptr->x_attr; \
- } \
- else \
- { \
- /* For feat_priority control */ \
- feat = FEAT_NONE; \
-\
- if (use_graphics) \
- { \
- /* Access darkness */ \
- f_ptr = &f_info[feat]; \
-\
- /* Char and attr of darkness */ \
- c = f_ptr->x_char; \
- a = f_ptr->x_attr; \
- } \
- else \
- { \
- /* Use "black" */ \
- a = TERM_DARK; \
- } \
- } \
- } \
- else \
- { \
- if (is_ascii_graphics(a)) \
- { \
- /* Use darkened colour */ \
- a = !new_ascii_graphics ? TERM_L_DARK : lighting_colours[a][1]; \
- } \
- else if (use_graphics && feat_supports_lighting(feat)) \
- { \
- /* Use a dark tile */ \
- c++; \
- } \
- } \
-} ;
+void apply_default_feat_lighting(byte f_attr[F_LIT_MAX], byte f_char[F_LIT_MAX])
+{
+ byte s_attr = f_attr[F_LIT_STANDARD];
+ byte s_char = f_char[F_LIT_STANDARD];
+ int i;
+ if (is_ascii_graphics(s_attr)) /* For ASCII */
+ {
+ f_attr[F_LIT_LITE] = lighting_colours[s_attr & 0x0f][0];
+ f_attr[F_LIT_DARK] = lighting_colours[s_attr & 0x0f][1];
+ for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_char[i] = s_char;
+ }
+ else /* For tile graphics */
+ {
+ for (i = F_LIT_NS_BEGIN; i < F_LIT_MAX; i++) f_attr[i] = s_attr;
+ f_char[F_LIT_LITE] = s_char + 2;
+ f_char[F_LIT_DARK] = s_char + 1;
+ }
+}
-/*
- * Extract the attr/char to display at the given (legal) map location
- *
- * Basically, we "paint" the chosen attr/char in several passes, starting
- * with any known "terrain features" (defaulting to darkness), then adding
- * any known "objects", and finally, adding any known "monsters". This
- * is not the fastest method but since most of the calls to this function
- * are made for grids with no monsters or objects, it is fast enough.
- *
- * Note that this function, if used on the grid containing the "player",
- * will return the attr/char of the grid underneath the player, and not
- * the actual player attr/char itself, allowing a lot of optimization
- * in various "display" functions.
- *
- * Note that the "zero" entry in the feature/object/monster arrays are
- * used to provide "special" attr/char codes, with "monster zero" being
- * used for the player attr/char, "object zero" being used for the "stack"
- * attr/char, and "feature zero" being used for the "nothing" attr/char,
- * though this function makes use of only "feature zero".
- *
- * Note that monsters can have some "special" flags, including "ATTR_MULTI",
- * which means their color changes, and "ATTR_CLEAR", which means they take
- * the color of whatever is under them, and "CHAR_CLEAR", which means that
- * they take the symbol of whatever is under them. Technically, the flag
- * "CHAR_MULTI" is supposed to indicate that a monster looks strange when
- * examined, but this flag is currently ignored.
- *
- * Currently, we do nothing with multi-hued objects, because there are
- * not any. If there were, they would have to set "shimmer_objects"
- * when they were created, and then new "shimmer" code in "dungeon.c"
- * would have to be created handle the "shimmer" effect, and the code
- * in "cave.c" would have to be updated to create the shimmer effect.
- *
- * Note the effects of hallucination. Objects always appear as random
- * "objects", monsters as random "monsters", and normal grids occasionally
- * appear as random "monsters" or "objects", but note that these random
- * "monsters" and "objects" are really just "colored ascii symbols".
- *
- * Note that "floors" and "invisible traps" (and "zero" features) are
- * drawn as "floors" using a special check for optimization purposes,
- * and these are the only features which get drawn using the special
- * lighting effects activated by "view_special_lite".
- *
- * Note the use of the "mimic" field in the "terrain feature" processing,
- * which allows any feature to "pretend" to be another feature. This is
- * used to "hide" secret doors, and to make all "doors" appear the same,
- * and all "walls" appear the same, and "hidden" treasure stay hidden.
- * It is possible to use this field to make a feature "look" like a floor,
- * but the "special lighting effects" for floors will not be used.
- *
- * Note the use of the new "terrain feature" information. Note that the
- * assumption that all interesting "objects" and "terrain features" are
- * memorized allows extremely optimized processing below. Note the use
- * of separate flags on objects to mark them as memorized allows a grid
- * to have memorized "terrain" without granting knowledge of any object
- * which may appear in that grid.
- *
- * Note the efficient code used to determine if a "floor" grid is
- * "memorized" or "viewable" by the player, where the test for the
- * grid being "viewable" is based on the facts that (1) the grid
- * must be "lit" (torch-lit or perma-lit), (2) the grid must be in
- * line of sight, and (3) the player must not be blind, and uses the
- * assumption that all torch-lit grids are in line of sight.
- *
- * Note that floors (and invisible traps) are the only grids which are
- * not memorized when seen, so only these grids need to check to see if
- * the grid is "viewable" to the player (if it is not memorized). Since
- * most non-memorized grids are in fact walls, this induces *massive*
- * efficiency, at the cost of *forcing* the memorization of non-floor
- * grids when they are first seen. Note that "invisible traps" are
- * always treated exactly like "floors", which prevents "cheating".
- *
- * Note the "special lighting effects" which can be activated for floor
- * grids using the "view_special_lite" option (for "white" floor grids),
- * causing certain grids to be displayed using special colors. If the
- * player is "blind", we will use "dark gray", else if the grid is lit
- * by the torch, and the "view_yellow_lite" option is set, we will use
- * "yellow", else if the grid is "dark", we will use "dark gray", else
- * if the grid is not "viewable", and the "view_bright_lite" option is
- * set, and the we will use "slate" (gray). We will use "white" for all
- * other cases, in particular, for illuminated viewable floor grids.
- *
- * Note the "special lighting effects" which can be activated for wall
- * grids using the "view_granite_lite" option (for "white" wall grids),
- * causing certain grids to be displayed using special colors. If the
- * player is "blind", we will use "dark gray", else if the grid is lit
- * by the torch, and the "view_yellow_lite" option is set, we will use
- * "yellow", else if the "view_bright_lite" option is set, and the grid
- * is not "viewable", or is "dark", or is glowing, but not when viewed
- * from the player's current location, we will use "slate" (gray). We
- * will use "white" for all other cases, in particular, for correctly
- * illuminated viewable wall grids.
- *
- * Note that, when "view_granite_lite" is set, we use an inline version
- * of the "player_can_see_bold()" function to check the "viewability" of
- * grids when the "view_bright_lite" option is set, and we do NOT use
- * any special colors for "dark" wall grids, since this would allow the
- * player to notice the walls of illuminated rooms from a hallway that
- * happened to run beside the room. The alternative, by the way, would
- * be to prevent the generation of hallways next to rooms, but this
- * would still allow problems when digging towards a room.
- *
- * Note that bizarre things must be done when the "attr" and/or "char"
- * codes have the "high-bit" set, since these values are used to encode
- * various "special" pictures in some versions, and certain situations,
- * such as "multi-hued" or "clear" monsters, cause the attr/char codes
- * to be "scrambled" in various ways.
- *
- * Note that eventually we may use the "&" symbol for embedded treasure,
- * and use the "*" symbol to indicate multiple objects, though this will
- * have to wait for Angband 2.8.0 or later. Note that currently, this
- * is not important, since only one object or terrain feature is allowed
- * in each grid. If needed, "k_info[0]" will hold the "stack" attr/char.
- *
- * Note the assumption that doing "x_ptr = &x_info[x]" plus a few of
- * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect
- * then a whole lot of code should be changed... XXX XXX
+
+/*!
+ * モンスターにより照明が消されている地形か否かを判定する。 / Is this grid "darkened" by monster?
+ */
+#define darkened_grid(C) \
+ ((((C)->info & (CAVE_VIEW | CAVE_LITE | CAVE_MNLT | CAVE_MNDK)) == (CAVE_VIEW | CAVE_MNDK)) && \
+ !p_ptr->see_nocto)
+
+
+/*!
+ * @brief Mコマンドによる縮小マップの表示を行う / Extract the attr/char to display at the given (legal) map location
+ * @details
+ * Basically, we "paint" the chosen attr/char in several passes, starting\n
+ * with any known "terrain features" (defaulting to darkness), then adding\n
+ * any known "objects", and finally, adding any known "monsters". This\n
+ * is not the fastest method but since most of the calls to this function\n
+ * are made for grids with no monsters or objects, it is fast enough.\n
+ *\n
+ * Note that this function, if used on the grid containing the "player",\n
+ * will return the attr/char of the grid underneath the player, and not\n
+ * the actual player attr/char itself, allowing a lot of optimization\n
+ * in various "display" functions.\n
+ *\n
+ * Note that the "zero" entry in the feature/object/monster arrays are\n
+ * used to provide "special" attr/char codes, with "monster zero" being\n
+ * used for the player attr/char, "object zero" being used for the "stack"\n
+ * attr/char, and "feature zero" being used for the "nothing" attr/char,\n
+ * though this function makes use of only "feature zero".\n
+ *\n
+ * Note that monsters can have some "special" flags, including "ATTR_MULTI",\n
+ * which means their color changes, and "ATTR_CLEAR", which means they take\n
+ * the color of whatever is under them, and "CHAR_CLEAR", which means that\n
+ * they take the symbol of whatever is under them. Technically, the flag\n
+ * "CHAR_MULTI" is supposed to indicate that a monster looks strange when\n
+ * examined, but this flag is currently ignored.\n
+ *\n
+ * Currently, we do nothing with multi-hued objects, because there are\n
+ * not any. If there were, they would have to set "shimmer_objects"\n
+ * when they were created, and then new "shimmer" code in "dungeon.c"\n
+ * would have to be created handle the "shimmer" effect, and the code\n
+ * in "cave.c" would have to be updated to create the shimmer effect.\n
+ *\n
+ * Note the effects of hallucination. Objects always appear as random\n
+ * "objects", monsters as random "monsters", and normal grids occasionally\n
+ * appear as random "monsters" or "objects", but note that these random\n
+ * "monsters" and "objects" are really just "colored ascii symbols".\n
+ *\n
+ * Note that "floors" and "invisible traps" (and "zero" features) are\n
+ * drawn as "floors" using a special check for optimization purposes,\n
+ * and these are the only features which get drawn using the special\n
+ * lighting effects activated by "view_special_lite".\n
+ *\n
+ * Note the use of the "mimic" field in the "terrain feature" processing,\n
+ * which allows any feature to "pretend" to be another feature. This is\n
+ * used to "hide" secret doors, and to make all "doors" appear the same,\n
+ * and all "walls" appear the same, and "hidden" treasure stay hidden.\n
+ * It is possible to use this field to make a feature "look" like a floor,\n
+ * but the "special lighting effects" for floors will not be used.\n
+ *\n
+ * Note the use of the new "terrain feature" information. Note that the\n
+ * assumption that all interesting "objects" and "terrain features" are\n
+ * memorized allows extremely optimized processing below. Note the use\n
+ * of separate flags on objects to mark them as memorized allows a grid\n
+ * to have memorized "terrain" without granting knowledge of any object\n
+ * which may appear in that grid.\n
+ *\n
+ * Note the efficient code used to determine if a "floor" grid is\n
+ * "memorized" or "viewable" by the player, where the test for the\n
+ * grid being "viewable" is based on the facts that (1) the grid\n
+ * must be "lit" (torch-lit or perma-lit), (2) the grid must be in\n
+ * line of sight, and (3) the player must not be blind, and uses the\n
+ * assumption that all torch-lit grids are in line of sight.\n
+ *\n
+ * Note that floors (and invisible traps) are the only grids which are\n
+ * not memorized when seen, so only these grids need to check to see if\n
+ * the grid is "viewable" to the player (if it is not memorized). Since\n
+ * most non-memorized grids are in fact walls, this induces *massive*\n
+ * efficiency, at the cost of *forcing* the memorization of non-floor\n
+ * grids when they are first seen. Note that "invisible traps" are\n
+ * always treated exactly like "floors", which prevents "cheating".\n
+ *\n
+ * Note the "special lighting effects" which can be activated for floor\n
+ * grids using the "view_special_lite" option (for "white" floor grids),\n
+ * causing certain grids to be displayed using special colors. If the\n
+ * player is "blind", we will use "dark gray", else if the grid is lit\n
+ * by the torch, and the "view_yellow_lite" option is set, we will use\n
+ * "yellow", else if the grid is "dark", we will use "dark gray", else\n
+ * if the grid is not "viewable", and the "view_bright_lite" option is\n
+ * set, and the we will use "slate" (gray). We will use "white" for all\n
+ * other cases, in particular, for illuminated viewable floor grids.\n
+ *\n
+ * Note the "special lighting effects" which can be activated for wall\n
+ * grids using the "view_granite_lite" option (for "white" wall grids),\n
+ * causing certain grids to be displayed using special colors. If the\n
+ * player is "blind", we will use "dark gray", else if the grid is lit\n
+ * by the torch, and the "view_yellow_lite" option is set, we will use\n
+ * "yellow", else if the "view_bright_lite" option is set, and the grid\n
+ * is not "viewable", or is "dark", or is glowing, but not when viewed\n
+ * from the player's current location, we will use "slate" (gray). We\n
+ * will use "white" for all other cases, in particular, for correctly\n
+ * illuminated viewable wall grids.\n
+ *\n
+ * Note that, when "view_granite_lite" is set, we use an inline version\n
+ * of the "player_can_see_bold()" function to check the "viewability" of\n
+ * grids when the "view_bright_lite" option is set, and we do NOT use\n
+ * any special colors for "dark" wall grids, since this would allow the\n
+ * player to notice the walls of illuminated rooms from a hallway that\n
+ * happened to run beside the room. The alternative, by the way, would\n
+ * be to prevent the generation of hallways next to rooms, but this\n
+ * would still allow problems when digging towards a room.\n
+ *\n
+ * Note that bizarre things must be done when the "attr" and/or "char"\n
+ * codes have the "high-bit" set, since these values are used to encode\n
+ * various "special" pictures in some versions, and certain situations,\n
+ * such as "multi-hued" or "clear" monsters, cause the attr/char codes\n
+ * to be "scrambled" in various ways.\n
+ *\n
+ * Note that eventually we may use the "&" symbol for embedded treasure,\n
+ * and use the "*" symbol to indicate multiple objects, though this will\n
+ * have to wait for Angband 2.8.0 or later. Note that currently, this\n
+ * is not important, since only one object or terrain feature is allowed\n
+ * in each grid. If needed, "k_info[0]" will hold the "stack" attr/char.\n
+ *\n
+ * Note the assumption that doing "x_ptr = &x_info[x]" plus a few of\n
+ * "x_ptr->xxx", is quicker than "x_info[x].xxx", if this is incorrect\n
+ * then a whole lot of code should be changed... XXX XXX\n
*/
-#ifdef USE_TRANSPARENCY
void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
-#else /* USE_TRANSPARENCY */
-void map_info(int y, int x, byte *ap, char *cp)
-#endif /* USE_TRANSPARENCY */
{
/* Get the cave */
cave_type *c_ptr = &cave[y][x];
- feature_type *f_ptr;
-
s16b this_o_idx, next_o_idx = 0;
/* Feature code (applying "mimic" field) */
- byte feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+ s16b feat = get_feat_mimic(c_ptr);
+
+ /* Access floor */
+ feature_type *f_ptr = &f_info[feat];
byte a;
byte c;
- /* Is this grid "darkened" by monster? */
- bool darkened_grid = ((c_ptr->info & (CAVE_VIEW | CAVE_LITE | CAVE_MNLT | CAVE_MNDK)) == (CAVE_VIEW | CAVE_MNDK)) &&
- !p_ptr->see_nocto && !p_ptr->blind;
-
- /* Floors (etc) */
- if ((feat <= FEAT_INVIS) || (feat == FEAT_DIRT) || (feat == FEAT_GRASS))
+ /* Boring grids (floors, etc) */
+ if (!have_flag(f_ptr->flags, FF_REMEMBER))
{
- /* Memorized (or visible) floor */
- if ((c_ptr->info & CAVE_MARK) ||
- (((c_ptr->info & (CAVE_LITE | CAVE_MNLT)) ||
- ((c_ptr->info & CAVE_VIEW) &&
- (((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || p_ptr->see_nocto))) &&
- !p_ptr->blind))
+ /*
+ * Handle Memorized or visible floor
+ *
+ * No visual when blinded.
+ * (to prevent strange effects on darkness breath)
+ * otherwise,
+ * - Can see grids with CAVE_MARK.
+ * - Can see grids with CAVE_LITE or CAVE_MNLT.
+ * (Such grids also have CAVE_VIEW)
+ * - Can see grids with CAVE_VIEW unless darkened by monsters.
+ */
+ if (!p_ptr->blind &&
+ ((c_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT)) ||
+ ((c_ptr->info & CAVE_VIEW) && (((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || p_ptr->see_nocto))))
{
- /* Access floor */
- f_ptr = &f_info[feat];
-
- /* Normal char */
- c = f_ptr->x_char;
-
- /* Normal attr */
- a = f_ptr->x_attr;
+ /* Normal attr/char */
+ a = f_ptr->x_attr[F_LIT_STANDARD];
+ c = f_ptr->x_char[F_LIT_STANDARD];
- /* Mega-Hack -- Handle "in-sight" and "darkened" grids first */
- if (darkened_grid)
+ if (p_ptr->wild_mode)
{
- darkened_grid_hack();
+ /* Special lighting effects */
+ /* Handle "night" */
+ if (view_special_lite && !is_daytime())
+ {
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
+ }
}
- /* Special lighting effects */
- else if (view_special_lite && (!p_ptr->wild_mode) && ((a == TERM_WHITE) || use_graphics))
+ /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
+ else if (darkened_grid(c_ptr))
{
- /* Handle "blind" */
- if (p_ptr->blind)
- {
- if (use_graphics)
- {
- /*
- * feat_supports_lighting(feat)
- * is always TRUE here
- */
+ /* Unsafe cave grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
- /* Use a dark tile */
- c++;
- }
- else
- {
- /* Use "dark gray" */
- a = TERM_L_DARK;
- }
- }
+ /* Access darkness */
+ f_ptr = &f_info[feat];
+
+ /* Char and attr of darkness */
+ a = f_ptr->x_attr[F_LIT_STANDARD];
+ c = f_ptr->x_char[F_LIT_STANDARD];
+ }
+ /* Special lighting effects */
+ else if (view_special_lite)
+ {
/* Handle "torch-lit" grids */
- else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
+ if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
{
/* Torch lite */
- if (view_yellow_lite && !p_ptr->wild_mode)
+ if (view_yellow_lite)
{
- if (use_graphics)
- {
- /*
- * feat_supports_lighting(feat)
- * is always TRUE here
- */
-
- /* Use a brightly lit tile */
- c += 2;
- }
- else
- {
- /* Use "yellow" */
- a = TERM_YELLOW;
- }
+ /* Use a brightly lit colour/tile */
+ a = f_ptr->x_attr[F_LIT_LITE];
+ c = f_ptr->x_char[F_LIT_LITE];
}
}
/* Handle "dark" grids */
else if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
{
- if (use_graphics)
- {
- /*
- * feat_supports_lighting(feat)
- * is always TRUE here
- */
-
- /* Use a dark tile */
- c++;
- }
- else
- {
- /* Use "dark gray" */
- a = TERM_L_DARK;
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
/* Handle "out-of-sight" grids */
else if (!(c_ptr->info & CAVE_VIEW))
{
/* Special flag */
- if (view_bright_lite && !p_ptr->wild_mode)
+ if (view_bright_lite)
{
- if (use_graphics)
- {
- /*
- * feat_supports_lighting(feat)
- * is always TRUE here
- */
-
- /* Use a dark tile */
- c++;
- }
- else
- {
- /* Use "gray" */
- a = TERM_SLATE;
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
}
}
else
{
/* Unsafe cave grid -- idea borrowed from Unangband */
- if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
- feat = FEAT_UNDETECTD;
- else
- feat = FEAT_NONE;
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
- /* Normal attr */
- a = f_ptr->x_attr;
-
- /* Normal char */
- c = f_ptr->x_char;
+ /* Normal attr/char */
+ a = f_ptr->x_attr[F_LIT_STANDARD];
+ c = f_ptr->x_char[F_LIT_STANDARD];
}
}
- /* Non floors */
+ /* Interesting grids (non-floors) */
else
{
/* Memorized grids */
- if ((c_ptr->info & CAVE_MARK) && (view_granite_lite || new_ascii_graphics))
+ if (c_ptr->info & CAVE_MARK)
{
- /* Access feature */
- f_ptr = &f_info[feat];
+ /* Normal attr/char */
+ a = f_ptr->x_attr[F_LIT_STANDARD];
+ c = f_ptr->x_char[F_LIT_STANDARD];
- /* Normal char */
- c = f_ptr->x_char;
-
- /* Normal attr */
- a = f_ptr->x_attr;
-
- /* Mega-Hack -- Handle "in-sight" and "darkened" grids first */
- if (darkened_grid)
+ if (p_ptr->wild_mode)
{
- darkened_grid_hack();
+ /* Special lighting effects */
+ /* Handle "blind" or "night" */
+ if (view_granite_lite && (p_ptr->blind || !is_daytime()))
+ {
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
+ }
}
- else if (new_ascii_graphics)
+ /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
+ else if (darkened_grid(c_ptr) && !p_ptr->blind)
{
- /* Handle "blind" */
- if (p_ptr->blind)
+ if (have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT))
{
- if (is_ascii_graphics(a))
- {
- /* Use darkened colour */
- a = lighting_colours[a][1];
- }
- else if (use_graphics && feat_supports_lighting(feat))
- {
- /* Use a dark tile */
- c++;
- }
- }
+ /* Unsafe cave grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
- /* Handle "torch-lit" grids */
- else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
- {
- /* Torch lite */
- if (view_yellow_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(a)))
- {
- if (is_ascii_graphics(a))
- {
- /* Use lightened colour */
- a = lighting_colours[a][0];
- }
- else if (use_graphics &&
- feat_supports_lighting(feat))
- {
- /* Use a brightly lit tile */
- c += 2;
- }
- }
- }
+ /* Access darkness */
+ f_ptr = &f_info[feat];
- /* Handle "view_bright_lite" */
- else if (view_bright_lite && !p_ptr->wild_mode && ((use_graphics && feat_supports_lighting(feat)) || is_ascii_graphics(a)))
+ /* Char and attr of darkness */
+ a = f_ptr->x_attr[F_LIT_STANDARD];
+ c = f_ptr->x_char[F_LIT_STANDARD];
+ }
+ else if (view_granite_lite && view_bright_lite)
{
- /* Not viewable */
- if (!(c_ptr->info & CAVE_VIEW))
- {
- if (is_ascii_graphics(a))
- {
- /* Use darkened colour */
- a = lighting_colours[a][1];
- }
- else if (use_graphics && feat_supports_lighting(feat))
- {
- /* Use a dark tile */
- c++;
- }
- }
-
- /* Not glowing */
- else if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
- {
- if (is_ascii_graphics(a))
- {
- /* Use darkened colour */
- a = lighting_colours[a][1];
- }
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
}
/* Special lighting effects */
- else if (view_granite_lite && !p_ptr->wild_mode &&
- (((a == TERM_WHITE) && !use_graphics) ||
- (use_graphics && feat_supports_lighting(feat))))
+ else if (view_granite_lite)
{
/* Handle "blind" */
if (p_ptr->blind)
{
- if (use_graphics)
- {
- /* Use a dark tile */
- c++;
- }
- else
- {
- /* Use "dark gray" */
- a = TERM_L_DARK;
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
/* Handle "torch-lit" grids */
else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
{
/* Torch lite */
- if (view_yellow_lite && !p_ptr->wild_mode)
+ if (view_yellow_lite)
{
- if (use_graphics)
- {
- /* Use a brightly lit tile */
- c += 2;
- }
- else
- {
- /* Use "yellow" */
- a = TERM_YELLOW;
- }
+ /* Use a brightly lit colour/tile */
+ a = f_ptr->x_attr[F_LIT_LITE];
+ c = f_ptr->x_char[F_LIT_LITE];
}
}
/* Handle "view_bright_lite" */
- else if (view_bright_lite && !p_ptr->wild_mode)
+ else if (view_bright_lite)
{
/* Not viewable */
if (!(c_ptr->info & CAVE_VIEW))
{
- if (use_graphics)
- {
- /* Use a dark tile */
- c++;
- }
- else
- {
- /* Use "gray" */
- a = TERM_SLATE;
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
/* Not glowing */
else if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
{
- if (use_graphics)
- {
- /* Use a lit tile */
- }
- else
- {
- /* Use "gray" */
- a = TERM_SLATE;
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
/* Not glowing correctly */
- else
+ else if (!have_flag(f_ptr->flags, FF_LOS) && !check_local_illumination(y, x))
{
- int xx, yy;
-
- /* Hack -- move towards player */
- yy = (y < py) ? (y + 1) : (y > py) ? (y - 1) : y;
- xx = (x < px) ? (x + 1) : (x > px) ? (x - 1) : x;
-
- /* Check for "local" illumination */
- if ((cave[yy][xx].info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
- {
- if (use_graphics)
- {
- /* Use a lit tile */
- }
- else
- {
- /* Use "gray" */
- a = TERM_SLATE;
- }
- }
+ /* Use a darkened colour/tile */
+ a = f_ptr->x_attr[F_LIT_DARK];
+ c = f_ptr->x_char[F_LIT_DARK];
}
}
}
}
- /* "Simple Lighting" */
+ /* Unknown */
else
{
- /* Handle "blind" */
- if (!(c_ptr->info & CAVE_MARK))
- {
- /* Unsafe cave grid -- idea borrowed from Unangband */
- if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
- feat = FEAT_UNDETECTD;
- else
- feat = FEAT_NONE;
- }
+ /* Unsafe cave grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access feature */
f_ptr = &f_info[feat];
- /* Normal attr */
- a = f_ptr->x_attr;
-
- /* Normal char */
- c = f_ptr->x_char;
-
- /* Mega-Hack -- Handle "in-sight" and "darkened" grids */
- if (darkened_grid)
- {
- darkened_grid_hack();
- }
+ /* Normal attr/char */
+ a = f_ptr->x_attr[F_LIT_STANDARD];
+ c = f_ptr->x_char[F_LIT_STANDARD];
}
}
- if (feat_priority == -1)
- {
- switch (feat)
- {
- case FEAT_NONE:
- case FEAT_UNDETECTD:
- case FEAT_DARK_PIT:
- feat_priority = 1;
- break;
+ if (feat_priority == -1) feat_priority = f_ptr->priority;
- case FEAT_FLOOR:
- case FEAT_INVIS:
- case FEAT_TRAP_TRAPDOOR:
- case FEAT_TRAP_PIT:
- case FEAT_TRAP_SPIKED_PIT:
- case FEAT_TRAP_POISON_PIT:
- case FEAT_TRAP_TY_CURSE:
- case FEAT_TRAP_TELEPORT:
- case FEAT_TRAP_FIRE:
- case FEAT_TRAP_ACID:
- case FEAT_TRAP_SLOW:
- case FEAT_TRAP_LOSE_STR:
- case FEAT_TRAP_LOSE_DEX:
- case FEAT_TRAP_LOSE_CON:
- case FEAT_TRAP_BLIND:
- case FEAT_TRAP_CONFUSE:
- case FEAT_TRAP_POISON:
- case FEAT_TRAP_SLEEP:
- case FEAT_TRAP_TRAPS:
- case FEAT_TRAP_ALARM:
- case FEAT_DIRT:
- case FEAT_GRASS:
- case FEAT_FLOWER:
- case FEAT_DEEP_GRASS:
- case FEAT_SWAMP:
- case FEAT_TREES:
- case FEAT_RUBBLE:
- case FEAT_MAGMA:
- case FEAT_QUARTZ:
- case FEAT_MAGMA_H:
- case FEAT_QUARTZ_H:
- case FEAT_WALL_EXTRA:
- case FEAT_WALL_INNER:
- case FEAT_WALL_OUTER:
- case FEAT_WALL_SOLID:
- case FEAT_DEEP_WATER:
- case FEAT_SHAL_WATER:
- case FEAT_DEEP_LAVA:
- case FEAT_SHAL_LAVA:
- feat_priority = 2;
- break;
-
- case FEAT_MAGMA_K:
- case FEAT_QUARTZ_K:
- /* Now a days treasere grid is too many */
- feat_priority = 2;
- break;
-
- case FEAT_MOUNTAIN:
- case FEAT_PERM_EXTRA:
- case FEAT_PERM_INNER:
- case FEAT_PERM_OUTER:
- case FEAT_PERM_SOLID:
- feat_priority = 5;
- break;
-
- /* default is feat_priority = 20; (doors and stores) */
-
- case FEAT_GLYPH:
- case FEAT_MINOR_GLYPH:
- case FEAT_MIRROR:
- case FEAT_PATTERN_START:
- case FEAT_PATTERN_1:
- case FEAT_PATTERN_2:
- case FEAT_PATTERN_3:
- case FEAT_PATTERN_4:
- case FEAT_PATTERN_END:
- case FEAT_PATTERN_OLD:
- case FEAT_PATTERN_XTRA1:
- case FEAT_PATTERN_XTRA2:
- feat_priority = 16;
- break;
-
- /* objects have feat_priority = 20 */
- /* monsters have feat_priority = 30 */
-
- case FEAT_LESS:
- case FEAT_MORE:
- case FEAT_QUEST_ENTER:
- case FEAT_QUEST_EXIT:
- case FEAT_QUEST_DOWN:
- case FEAT_QUEST_UP:
- case FEAT_LESS_LESS:
- case FEAT_MORE_MORE:
- case FEAT_TOWN:
- case FEAT_ENTRANCE:
- feat_priority = 35;
- break;
-
- default:
- feat_priority = 10;
- break;
- }
- }
-
-#ifdef USE_TRANSPARENCY
/* Save the terrain info for the transparency effects */
(*tap) = a;
(*tcp) = c;
-#endif /* USE_TRANSPARENCY */
/* Save the info */
(*ap) = a;
(*cp) = c;
/* Hack -- rare random hallucination, except on outer dungeon walls */
- if (p_ptr->image && (feat < FEAT_PERM_SOLID) && one_in_(256))
+ if (p_ptr->image)
{
- /* Hallucinate */
- image_random(ap, cp);
+ if (one_in_(256))
+ {
+ /* Hallucinate */
+ image_random(ap, cp);
+ }
}
/* Objects */
next_o_idx = o_ptr->next_o_idx;
/* Memorized objects */
- if (o_ptr->marked)
+ if (o_ptr->marked & OM_FOUND)
{
if (display_autopick)
{
}
-#ifdef JP
-/*
- * Table of Ascii-to-Zenkaku
- * ¡Ö¢£¡×¤ÏÆóÇÜÉýƦÉå¤ÎÆâÉô¥³¡¼¥É¤Ë»ÈÍÑ¡£
- */
-static char ascii_to_zenkaku[2*128+1] = "\
-¡¡¡ª¡É¡ô¡ð¡ó¡õ¡Ç¡Ê¡Ë¡ö¡Ü¡¤¡Ý¡¥¡¿\
-£°£±£²£³£´£µ£¶£·£¸£¹¡§¡¨¡ã¡á¡ä¡©\
-¡÷£Á£Â£Ã£Ä£Å£Æ£Ç£È£É£Ê£Ë£Ì£Í£Î£Ï\
-£Ð£Ñ£Ò£Ó£Ô£Õ£Ö£×£Ø£Ù£Ú¡Î¡À¡Ï¡°¡²\
-¡Æ£á£â£ã£ä£å£æ£ç£è£é£ê£ë£ì£í£î£ï\
-£ð£ñ£ò£ó£ô£õ£ö£÷£ø£ù£ú¡Ð¡Ã¡Ñ¡Á¢£";
-#endif
-
-/*
- * Prepare Bigtile or 2-bytes character attr/char pairs
- */
-void bigtile_attr(char *cp, byte *ap, char *cp2, byte *ap2)
-{
- if ((*ap & 0x80) && (*cp & 0x80))
- {
- *ap2 = 255;
- *cp2 = -1;
- return;
- }
-
-#ifdef JP
- if (isprint(*cp) || *cp == 127)
- {
- *ap2 = (*ap) | 0xf0;
- *cp2 = ascii_to_zenkaku[2*(*cp-' ') + 1];
- *cp = ascii_to_zenkaku[2*(*cp-' ')];
- return;
- }
-#endif
-
- *ap2 = TERM_WHITE;
- *cp2 = ' ';
-}
-
-
/*
* Calculate panel colum of a location in the map
*/
*/
void print_rel(char c, byte a, int y, int x)
{
- char c2;
- byte a2;
-
/* Only do "legal" locations */
if (panel_contains(y, x))
{
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
- if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
-
/* Draw the char using the attr */
- Term_draw(panel_col_of(x), y-panel_row_prt, a, c);
- if (use_bigtile)
- Term_draw(panel_col_of(x)+1, y-panel_row_prt, a2, c2);
+ Term_queue_bigchar(panel_col_of(x), y-panel_row_prt, a, c, 0, 0);
}
}
s16b this_o_idx, next_o_idx = 0;
- byte feat;
-
- /* Feature code (applying "mimic" field) */
- feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
-
/* Blind players see nothing */
if (p_ptr->blind) return;
/* Analyze non-torch-lit grids */
- if (!(c_ptr->info & (CAVE_LITE)))
+ if (!(c_ptr->info & (CAVE_LITE | CAVE_MNLT)))
{
/* Require line of sight to the grid */
if (!(c_ptr->info & (CAVE_VIEW))) return;
/* Require "perma-lite" of the grid */
- if (!(c_ptr->info & CAVE_MNLT) && ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW))
+ if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
{
/* Not Ninja */
if (!p_ptr->see_nocto) return;
/* Hack -- memorize grids */
if (!(c_ptr->info & (CAVE_MARK)))
{
- /* Handle floor grids first */
- if ((feat <= FEAT_INVIS) || (feat == FEAT_DIRT) || (feat == FEAT_GRASS))
+ /* Feature code (applying "mimic" field) */
+ feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
+
+ /* Memorize some "boring" grids */
+ if (!have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Option -- memorize all torch-lit floors */
if (view_torch_grids &&
}
/* Memorize normal grids */
- else if (cave_floor_grid(c_ptr))
+ else if (have_flag(f_ptr->flags, FF_LOS))
{
/* Memorize */
c_ptr->info |= (CAVE_MARK);
}
/* Memorize certain non-torch-lit wall grids */
- else
+ else if (check_local_illumination(y, x))
{
- int yy, xx;
-
- /* Hack -- move one grid towards player */
- yy = (y < py) ? (y + 1) : (y > py) ? (y - 1) : y;
- xx = (x < px) ? (x + 1) : (x > px) ? (x - 1) : x;
-
- /* Check for "local" illumination */
- if ((cave[yy][xx].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW)
- {
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
- }
+ /* Memorize */
+ c_ptr->info |= (CAVE_MARK);
}
}
+
+ /* Memorize terrain of the grid */
+ c_ptr->info |= (CAVE_KNOWN);
}
byte a;
char c;
-#ifdef USE_TRANSPARENCY
- byte ta;
- char tc;
-#endif /* USE_TRANSPARENCY */
+ byte ta = 0;
+ char tc = '\0';
- for (x = px - Term->wid / 2 + 1; x <= px + Term->wid / 2; x++)
+ for (x = p_ptr->x - Term->wid / 2 + 1; x <= p_ptr->x + Term->wid / 2; x++)
{
- for (y = py - Term->hgt / 2 + 1; y <= py + Term->hgt / 2; y++)
+ for (y = p_ptr->y - Term->hgt / 2 + 1; y <= p_ptr->y + Term->hgt / 2; y++)
{
if (in_bounds2(y, x))
{
-#ifdef USE_TRANSPARENCY
/* Examine the grid */
map_info(y, x, &a, &c, &ta, &tc);
-#else /* USE_TRANSPARENCY */
- /* Examine the grid */
- map_info(y, x, &a, &c);
-#endif /* USE_TRANSPARENCY */
/* Hack -- fake monochrome */
if (!use_graphics)
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
-#ifdef USE_TRANSPARENCY
- /* Hack -- Queue it */
- Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c, ta, tc);
-#else /* USE_TRANSPARENCY */
/* Hack -- Queue it */
- Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c);
-#endif /* USE_TRANSPARENCY */
-
+ Term_queue_char(x - p_ptr->x + Term->wid / 2 - 1, y - p_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
}
else
{
/* Clear out-of-bound tiles */
/* Access darkness */
- feature_type *f_ptr = &f_info[FEAT_NONE];
+ feature_type *f_ptr = &f_info[feat_none];
/* Normal attr */
- a = f_ptr->x_attr;
+ a = f_ptr->x_attr[F_LIT_STANDARD];
/* Normal char */
- c = f_ptr->x_char;
+ c = f_ptr->x_char[F_LIT_STANDARD];
-#ifdef USE_TRANSPARENCY
- /* Hack -- Queue it */
- Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c, ta, tc);
-#else /* USE_TRANSPARENCY */
/* Hack -- Queue it */
- Term_queue_char(x - px + Term->wid / 2 - 1, y - py + Term->hgt / 2 - 1, a, c);
-#endif /* USE_TRANSPARENCY */
+ Term_queue_char(x - p_ptr->x + Term->wid / 2 - 1, y - p_ptr->y + Term->hgt / 2 - 1, a, c, ta, tc);
}
}
}
byte a;
char c;
-#ifdef USE_TRANSPARENCY
byte ta;
char tc;
/* Examine the grid */
map_info(y, x, &a, &c, &ta, &tc);
-#else /* USE_TRANSPARENCY */
- /* Examine the grid */
- map_info(y, x, &a, &c);
-#endif /* USE_TRANSPARENCY */
/* Hack -- fake monochrome */
if (!use_graphics)
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
-#ifdef JP
- if (use_bigtile && is_ascii_graphics(a) && (isprint(c) || c == 127))
- {
- /* Term_queue_chars ¤ÏÁ´³ÑASCIIÃÏ·Á¤òÀµ¤·¤¯update¤¹¤ë¡£ */
- Term_queue_chars(panel_col_of(x), y-panel_row_prt, 2, a, &ascii_to_zenkaku[2*(c-' ')]);
- return;
- }
-#endif
-
-#ifdef USE_TRANSPARENCY
/* Hack -- Queue it */
- Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
- if (use_bigtile)
- Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, 255, -1, 0, 0);
-#else /* USE_TRANSPARENCY */
- /* Hack -- Queue it */
- Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c);
- if (use_bigtile)
- Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, 255, -1);
-#endif /* USE_TRANSPARENCY */
+ Term_queue_bigchar(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
/* Update sub-windows */
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
/* Scan the columns of row "y" */
for (x = xmin; x <= xmax; x++)
{
- byte a, a2;
- char c, c2;
+ byte a;
+ char c;
-#ifdef USE_TRANSPARENCY
byte ta;
char tc;
/* Determine what is there */
map_info(y, x, &a, &c, &ta, &tc);
-#else
- /* Determine what is there */
- map_info(y, x, &a, &c);
-#endif
/* Hack -- fake monochrome */
if (!use_graphics)
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
- if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
-
/* Efficiency -- Redraw that grid of the map */
-#ifdef USE_TRANSPARENCY
- Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
- if (use_bigtile) Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, a2, c2, 0, 0);
-#else
- Term_queue_char(panel_col_of(x), y-panel_row_prt, a, c);
- if (use_bigtile) Term_queue_char(panel_col_of(x)+1, y-panel_row_prt, a2, c2);
-#endif
+ Term_queue_bigchar(panel_col_of(x), y-panel_row_prt, a, c, ta, tc);
}
}
/* Display player */
- lite_spot(py, px);
+ lite_spot(p_ptr->y, p_ptr->x);
/* Restore the cursor */
(void)Term_set_cursor(v);
int i;
int path_n;
u16b path_g[512];
- int default_color = TERM_SLATE;
+ byte_hack default_color = TERM_SLATE;
if (!display_path) return;
if (-1 == project_length)
return;
/* Get projection path */
- path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), py, px, y, x, PROJECT_PATH|PROJECT_THRU);
+ path_n = project_path(path_g, (project_length ? project_length : MAX_RANGE), p_ptr->y, p_ptr->x, y, x, PROJECT_PATH|PROJECT_THRU);
/* Redraw map */
p_ptr->redraw |= (PR_MAP);
{
int ny = GRID_Y(path_g[i]);
int nx = GRID_X(path_g[i]);
+ cave_type *c_ptr = &cave[ny][nx];
if (panel_contains(ny, nx))
{
- byte a2, a = default_color;
- char c, c2;
+ byte a = default_color;
+ char c;
-#ifdef USE_TRANSPARENCY
byte ta;
char tc;
-#endif
- if (cave[ny][nx].m_idx && m_list[cave[ny][nx].m_idx].ml)
+ if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
{
/* Determine what is there */
-#ifdef USE_TRANSPARENCY
map_info(ny, nx, &a, &c, &ta, &tc);
-#else
- map_info(ny, nx, &a, &c);
-#endif
+
if (!is_ascii_graphics(a))
a = default_color;
else if (c == '.' && (a == TERM_WHITE || a == TERM_L_WHITE))
}
c = '*';
- if (use_bigtile) bigtile_attr(&c, &a, &c2, &a2);
/* Hack -- Queue it */
-#ifdef USE_TRANSPARENCY
- Term_queue_char(panel_col_of(nx), ny-panel_row_prt, a, c, ta, tc);
- if (use_bigtile) Term_queue_char(panel_col_of(nx)+1, ny-panel_row_prt, a, c2, 0, 0);
-#else
- Term_queue_char(panel_col_of(nx), ny-panel_row_prt, a, c);
- if (use_bigtile) Term_queue_char(panel_col_of(nx)+1, ny-panel_row_prt, a, c2);
-#endif
+ Term_queue_bigchar(panel_col_of(nx), ny-panel_row_prt, a, c, ta, tc);
}
/* Known Wall */
- if ((cave[ny][nx].info & CAVE_MARK) && !cave_floor_bold(ny, nx)) break;
+ if ((c_ptr->info & CAVE_MARK) && !cave_have_flag_grid(c_ptr, FF_PROJECT)) break;
/* Change color */
if (nx == x && ny == y) default_color = TERM_L_DARK;
static cptr simplify_list[][2] =
{
#ifdef JP
- {"¤ÎËâË¡½ñ", ""},
+ {"の魔法書", ""},
{NULL, NULL}
#else
{"^Ring of ", "="},
int len = 0;
byte attr;
- object_desc(buf, o_ptr, FALSE, 0);
+ object_desc(buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
attr = tval_to_attr[o_ptr->tval % 128];
if (p_ptr->image)
{
attr = TERM_WHITE;
-#ifdef JP
- strcpy(buf, "²¿¤«´ñ̯¤Êʪ");
-#else
- strcpy(buf, "something strange");
-#endif
+ strcpy(buf, _("何か奇妙な物", "something strange"));
}
for (c = buf; *c; c++)
c = buf;
len = 0;
- /* Ⱦ³Ñ 12 ʸ»úʬ¤ÇÀÚ¤ë */
+ /* 半角 12 文字分で切る */
while(*c)
{
#ifdef JP
{
int i, j, x, y;
- byte ta, a2;
- char tc, c2;
+ byte ta;
+ char tc;
byte tp;
feat_priority = -1;
/* Extract the current attr/char at that map location */
-#ifdef USE_TRANSPARENCY
map_info(j, i, &ta, &tc, &ta, &tc);
-#else /* USE_TRANSPARENCY */
- map_info(j, i, &ta, &tc);
-#endif /* USE_TRANSPARENCY */
/* Extract the priority */
- tp = feat_priority;
+ tp = (byte_hack)feat_priority;
if(match_autopick!=-1
&& (match_autopick_yx[y][x] == -1
else if (p_ptr->wraith_form) ta = TERM_L_DARK;
}
- if (use_bigtile) bigtile_attr(&tc, &ta, &c2, &a2);
-
/* Add the character */
- Term_addch(ta, tc);
- if (use_bigtile) Term_addch(a2, c2);
+ Term_add_bigch(ta, tc);
}
}
}
/* Player location */
- (*cy) = py / yrat + 1 + ROW_MAP;
+ (*cy) = p_ptr->y / yrat + 1 + ROW_MAP;
if (!use_bigtile)
- (*cx) = px / xrat + 1 + COL_MAP;
+ (*cx) = p_ptr->x / xrat + 1 + COL_MAP;
else
- (*cx) = (px / xrat + 1) * 2 + COL_MAP;
+ (*cx) = (p_ptr->x / xrat + 1) * 2 + COL_MAP;
/* Restore lighting effects */
view_special_lite = old_view_special_lite;
for (y = 0; y < (hgt + 2); y++)
{
/* Free one row each array */
- C_FREE(ma[y], (wid + 2), byte);
- C_FREE(mc[y], (wid + 2), char);
- C_FREE(mp[y], (wid + 2), byte);
- C_FREE(match_autopick_yx[y], (wid + 2), int);
- C_FREE(object_autopick_yx[y], (wid + 2), object_type **);
+ C_KILL(ma[y], (wid + 2), byte);
+ C_KILL(mc[y], (wid + 2), char);
+ C_KILL(mp[y], (wid + 2), byte);
+ C_KILL(match_autopick_yx[y], (wid + 2), int);
+ C_KILL(object_autopick_yx[y], (wid + 2), object_type *);
}
/* Free each line map */
- C_FREE(ma, (hgt + 2), byte_ptr);
- C_FREE(mc, (hgt + 2), char_ptr);
- C_FREE(mp, (hgt + 2), byte_ptr);
- C_FREE(match_autopick_yx, (hgt + 2), sint_ptr);
- C_FREE(object_autopick_yx, (hgt + 2), object_type **);
+ C_KILL(ma, (hgt + 2), byte_ptr);
+ C_KILL(mc, (hgt + 2), char_ptr);
+ C_KILL(mp, (hgt + 2), byte_ptr);
+ C_KILL(match_autopick_yx, (hgt + 2), sint_ptr);
+ C_KILL(object_autopick_yx, (hgt + 2), object_type **);
/* Free each line map */
for (y = 0; y < (cur_hgt + 2); y++)
{
/* Free one row each array */
- C_FREE(bigma[y], (cur_wid + 2), byte);
- C_FREE(bigmc[y], (cur_wid + 2), char);
- C_FREE(bigmp[y], (cur_wid + 2), byte);
+ C_KILL(bigma[y], (cur_wid + 2), byte);
+ C_KILL(bigmc[y], (cur_wid + 2), char);
+ C_KILL(bigmp[y], (cur_wid + 2), byte);
}
/* Free each line map */
- C_FREE(bigma, (cur_hgt + 2), byte_ptr);
- C_FREE(bigmc, (cur_hgt + 2), char_ptr);
- C_FREE(bigmp, (cur_hgt + 2), byte_ptr);
+ C_KILL(bigma, (cur_hgt + 2), byte_ptr);
+ C_KILL(bigmc, (cur_hgt + 2), char_ptr);
+ C_KILL(bigmp, (cur_hgt + 2), byte_ptr);
}
screen_save();
/* Note */
-#ifdef JP
-prt("¤ªÂÔ¤Á²¼¤µ¤¤...", 0, 0);
-#else
- prt("Please wait...", 0, 0);
-#endif
+ prt(_("お待ち下さい...", "Please wait..."), 0, 0);
/* Flush */
Term_fresh();
Term_get_size(&wid, &hgt);
row_message = hgt - 1;
-#ifdef JP
- put_str("²¿¤«¥¡¼¤ò²¡¤·¤Æ¤¯¤À¤µ¤¤('M':½¦¤¦ 'N':ÊüÃÖ 'D':M+N 'K':²õ¤¹¥¢¥¤¥Æ¥à¤òɽ¼¨)", row_message, 1);
-#else
- put_str(" Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items.", row_message, 1);
-#endif
+ put_str(_("何かキーを押してください('M':拾う 'N':放置 'D':M+N 'K':壊すアイテムを表示)",
+ " Hit M, N(for ~), K(for !), or D(same as M+N) to display auto-picker items."), row_message, 1);
/* Hilite the player */
move_cursor(cy, cx);
}
else
{
-#ifdef JP
- put_str("²¿¤«¥¡¼¤ò²¡¤¹¤È¥²¡¼¥à¤ËÌá¤ê¤Þ¤¹", 23, 30);
-#else
- put_str("Hit any key to continue", 23, 30);
-#endif /* Hilite the player */
+ put_str(_("何かキーを押すとゲームに戻ります", "Hit any key to continue"), 23, 30);
+ /* Hilite the player */
move_cursor(cy, cx);
/* Get any key */
inkey();
* I am thinking in terms of an algorithm that "walks" from the central point
* out to the maximal "distance", at each point, determining the "view" code
* (above). For each grid not on a major axis or diagonal, the "view" code
- * depends on the "cave_floor_bold()" and "view" of exactly two other grids
+ * depends on the "cave_los_bold()" and "view" of exactly two other grids
* (the one along the nearest diagonal, and the one next to that one, see
* "update_view_aux()"...).
*
*/
#define cave_lite_hack(Y,X) \
{\
- if (!(cave[Y][X].info & (CAVE_LITE))) { \
- cave[Y][X].info |= (CAVE_LITE); \
- lite_y[lite_n] = (Y); \
- lite_x[lite_n] = (X); \
- lite_n++;} \
+ if (!(cave[Y][X].info & (CAVE_LITE))) \
+ { \
+ cave[Y][X].info |= (CAVE_LITE); \
+ lite_y[lite_n] = (Y); \
+ lite_x[lite_n++] = (X); \
+ } \
}
/* forget_lite(); Perhaps don't need? */
/* Add it to later visual update */
- cave_redraw_later(&cave[py][px], py, px);
+ cave_redraw_later(&cave[p_ptr->y][p_ptr->x], p_ptr->y, p_ptr->x);
}
#endif
if (p >= 1)
{
/* Player grid */
- cave_lite_hack(py, px);
+ cave_lite_hack(p_ptr->y, p_ptr->x);
/* Adjacent grid */
- cave_lite_hack(py+1, px);
- cave_lite_hack(py-1, px);
- cave_lite_hack(py, px+1);
- cave_lite_hack(py, px-1);
+ cave_lite_hack(p_ptr->y+1, p_ptr->x);
+ cave_lite_hack(p_ptr->y-1, p_ptr->x);
+ cave_lite_hack(p_ptr->y, p_ptr->x+1);
+ cave_lite_hack(p_ptr->y, p_ptr->x-1);
/* Diagonal grids */
- cave_lite_hack(py+1, px+1);
- cave_lite_hack(py+1, px-1);
- cave_lite_hack(py-1, px+1);
- cave_lite_hack(py-1, px-1);
+ cave_lite_hack(p_ptr->y+1, p_ptr->x+1);
+ cave_lite_hack(p_ptr->y+1, p_ptr->x-1);
+ cave_lite_hack(p_ptr->y-1, p_ptr->x+1);
+ cave_lite_hack(p_ptr->y-1, p_ptr->x-1);
}
/* Radius 2 -- lantern radius */
if (p >= 2)
{
/* South of the player */
- if (cave_floor_bold(py+1, px))
+ if (cave_los_bold(p_ptr->y + 1, p_ptr->x))
{
- cave_lite_hack(py+2, px);
- cave_lite_hack(py+2, px+1);
- cave_lite_hack(py+2, px-1);
+ cave_lite_hack(p_ptr->y+2, p_ptr->x);
+ cave_lite_hack(p_ptr->y+2, p_ptr->x+1);
+ cave_lite_hack(p_ptr->y+2, p_ptr->x-1);
}
/* North of the player */
- if (cave_floor_bold(py-1, px))
+ if (cave_los_bold(p_ptr->y - 1, p_ptr->x))
{
- cave_lite_hack(py-2, px);
- cave_lite_hack(py-2, px+1);
- cave_lite_hack(py-2, px-1);
+ cave_lite_hack(p_ptr->y-2, p_ptr->x);
+ cave_lite_hack(p_ptr->y-2, p_ptr->x+1);
+ cave_lite_hack(p_ptr->y-2, p_ptr->x-1);
}
/* East of the player */
- if (cave_floor_bold(py, px+1))
+ if (cave_los_bold(p_ptr->y, p_ptr->x + 1))
{
- cave_lite_hack(py, px+2);
- cave_lite_hack(py+1, px+2);
- cave_lite_hack(py-1, px+2);
+ cave_lite_hack(p_ptr->y, p_ptr->x+2);
+ cave_lite_hack(p_ptr->y+1, p_ptr->x+2);
+ cave_lite_hack(p_ptr->y-1, p_ptr->x+2);
}
/* West of the player */
- if (cave_floor_bold(py, px-1))
+ if (cave_los_bold(p_ptr->y, p_ptr->x - 1))
{
- cave_lite_hack(py, px-2);
- cave_lite_hack(py+1, px-2);
- cave_lite_hack(py-1, px-2);
+ cave_lite_hack(p_ptr->y, p_ptr->x-2);
+ cave_lite_hack(p_ptr->y+1, p_ptr->x-2);
+ cave_lite_hack(p_ptr->y-1, p_ptr->x-2);
}
}
if (p > 14) p = 14;
/* South-East of the player */
- if (cave_floor_bold(py+1, px+1))
+ if (cave_los_bold(p_ptr->y + 1, p_ptr->x + 1))
{
- cave_lite_hack(py+2, px+2);
+ cave_lite_hack(p_ptr->y+2, p_ptr->x+2);
}
/* South-West of the player */
- if (cave_floor_bold(py+1, px-1))
+ if (cave_los_bold(p_ptr->y + 1, p_ptr->x - 1))
{
- cave_lite_hack(py+2, px-2);
+ cave_lite_hack(p_ptr->y+2, p_ptr->x-2);
}
/* North-East of the player */
- if (cave_floor_bold(py-1, px+1))
+ if (cave_los_bold(p_ptr->y - 1, p_ptr->x + 1))
{
- cave_lite_hack(py-2, px+2);
+ cave_lite_hack(p_ptr->y-2, p_ptr->x+2);
}
/* North-West of the player */
- if (cave_floor_bold(py-1, px-1))
+ if (cave_los_bold(p_ptr->y - 1, p_ptr->x - 1))
{
- cave_lite_hack(py-2, px-2);
+ cave_lite_hack(p_ptr->y-2, p_ptr->x-2);
}
/* Maximal north */
- min_y = py - p;
+ min_y = p_ptr->y - p;
if (min_y < 0) min_y = 0;
/* Maximal south */
- max_y = py + p;
+ max_y = p_ptr->y + p;
if (max_y > cur_hgt-1) max_y = cur_hgt-1;
/* Maximal west */
- min_x = px - p;
+ min_x = p_ptr->x - p;
if (min_x < 0) min_x = 0;
/* Maximal east */
- max_x = px + p;
+ max_x = p_ptr->x + p;
if (max_x > cur_wid-1) max_x = cur_wid-1;
/* Scan the maximal box */
{
for (x = min_x; x <= max_x; x++)
{
- int dy = (py > y) ? (py - y) : (y - py);
- int dx = (px > x) ? (px - x) : (x - px);
+ int dy = (p_ptr->y > y) ? (p_ptr->y - y) : (y - p_ptr->y);
+ int dx = (p_ptr->x > x) ? (p_ptr->x - x) : (x - p_ptr->x);
/* Skip the "central" grids (above) */
if ((dy <= 2) && (dx <= 2)) continue;
if (d > p) continue;
/* Viewable, nearby, grids get "torch lit" */
- if (player_has_los_bold(y, x))
+ if (cave[y][x].info & CAVE_VIEW)
{
/* This grid is "torch lit" */
cave_lite_hack(y, x);
static bool mon_invis;
+static POSITION mon_fy, mon_fx;
/*
* Add a square to the changes array
*/
-static void mon_lite_hack(int y, int x)
+static void mon_lite_hack(POSITION y, POSITION x)
{
cave_type *c_ptr;
+ int dpf, d;
+ POSITION midpoint;
- /* Out of bounds */
- if (!in_bounds2(y, x)) return;
+ /* We trust this grid is in bounds */
+ /* if (!in_bounds2(y, x)) return; */
c_ptr = &cave[y][x];
/* Want a unlit square in view of the player */
if ((c_ptr->info & (CAVE_MNLT | CAVE_VIEW)) != CAVE_VIEW) return;
- /* Hack XXX XXX - Is it a wall and monster not in LOS? */
- if (!cave_floor_grid(c_ptr) && mon_invis) return;
-
- if (temp_n < TEMP_MAX)
+ if (!cave_los_grid(c_ptr))
{
- /* New grid */
- if (!(c_ptr->info & CAVE_MNDK))
+ /* Hack -- Prevent monster lite leakage in walls */
+
+ /* Horizontal walls between player and a monster */
+ if (((y < p_ptr->y) && (y > mon_fy)) || ((y > p_ptr->y) && (y < mon_fy)))
{
- /* Save this square */
- temp_x[temp_n] = x;
- temp_y[temp_n] = y;
- temp_n++;
+ dpf = p_ptr->y - mon_fy;
+ d = y - mon_fy;
+ midpoint = mon_fx + ((p_ptr->x - mon_fx) * ABS(d)) / ABS(dpf);
+
+ /* Only first wall viewed from mid-x is lit */
+ if (x < midpoint)
+ {
+ if (!cave_los_bold(y, x + 1)) return;
+ }
+ else if (x > midpoint)
+ {
+ if (!cave_los_bold(y, x - 1)) return;
+ }
+
+ /* Hack XXX XXX - Is it a wall and monster not in LOS? */
+ else if (mon_invis) return;
}
- /* Darkened grid */
- else
+ /* Vertical walls between player and a monster */
+ if (((x < p_ptr->x) && (x > mon_fx)) || ((x > p_ptr->x) && (x < mon_fx)))
{
- /* No longer dark */
- c_ptr->info &= ~(CAVE_MNDK);
+ dpf = p_ptr->x - mon_fx;
+ d = x - mon_fx;
+ midpoint = mon_fy + ((p_ptr->y - mon_fy) * ABS(d)) / ABS(dpf);
+
+ /* Only first wall viewed from mid-y is lit */
+ if (y < midpoint)
+ {
+ if (!cave_los_bold(y + 1, x)) return;
+ }
+ else if (y > midpoint)
+ {
+ if (!cave_los_bold(y - 1, x)) return;
+ }
+
+ /* Hack XXX XXX - Is it a wall and monster not in LOS? */
+ else if (mon_invis) return;
}
+ }
+
+ /* We trust temp_n does not exceed TEMP_MAX */
+
+ /* New grid */
+ if (!(c_ptr->info & CAVE_MNDK))
+ {
+ /* Save this square */
+ temp_x[temp_n] = x;
+ temp_y[temp_n] = y;
+ temp_n++;
+ }
- /* Light it */
- c_ptr->info |= CAVE_MNLT;
+ /* Darkened grid */
+ else
+ {
+ /* No longer dark */
+ c_ptr->info &= ~(CAVE_MNDK);
}
+
+ /* Light it */
+ c_ptr->info |= CAVE_MNLT;
}
/*
* Add a square to the changes array
*/
-static void mon_dark_hack(int y, int x)
+static void mon_dark_hack(POSITION y, POSITION x)
{
cave_type *c_ptr;
+ int midpoint, dpf, d;
- /* Out of bounds */
- if (!in_bounds2(y, x)) return;
+ /* We trust this grid is in bounds */
+ /* if (!in_bounds2(y, x)) return; */
c_ptr = &cave[y][x];
/* Want a unlit and undarkened square in view of the player */
- if ((c_ptr->info & (CAVE_LITE | CAVE_MNLT)) || ((c_ptr->info & (CAVE_MNDK | CAVE_VIEW)) != CAVE_VIEW)) return;
+ if ((c_ptr->info & (CAVE_LITE | CAVE_MNLT | CAVE_MNDK | CAVE_VIEW)) != CAVE_VIEW) return;
- /* Hack XXX XXX - Is it a wall and monster not in LOS? */
- if (!cave_floor_grid(c_ptr) && mon_invis) return;
-
- if (temp_n < TEMP_MAX)
+ if (!cave_los_grid(c_ptr) && !cave_have_flag_grid(c_ptr, FF_PROJECT))
{
- /* Save this square */
- temp_x[temp_n] = x;
- temp_y[temp_n] = y;
- temp_n++;
+ /* Hack -- Prevent monster dark lite leakage in walls */
+
+ /* Horizontal walls between player and a monster */
+ if (((y < p_ptr->y) && (y > mon_fy)) || ((y > p_ptr->y) && (y < mon_fy)))
+ {
+ dpf = p_ptr->y - mon_fy;
+ d = y - mon_fy;
+ midpoint = mon_fx + ((p_ptr->x - mon_fx) * ABS(d)) / ABS(dpf);
+
+ /* Only first wall viewed from mid-x is lit */
+ if (x < midpoint)
+ {
+ if (!cave_los_bold(y, x + 1) && !cave_have_flag_bold(y, x + 1, FF_PROJECT)) return;
+ }
+ else if (x > midpoint)
+ {
+ if (!cave_los_bold(y, x - 1) && !cave_have_flag_bold(y, x - 1, FF_PROJECT)) return;
+ }
+
+ /* Hack XXX XXX - Is it a wall and monster not in LOS? */
+ else if (mon_invis) return;
+ }
+
+ /* Vertical walls between player and a monster */
+ if (((x < p_ptr->x) && (x > mon_fx)) || ((x > p_ptr->x) && (x < mon_fx)))
+ {
+ dpf = p_ptr->x - mon_fx;
+ d = x - mon_fx;
+ midpoint = mon_fy + ((p_ptr->y - mon_fy) * ABS(d)) / ABS(dpf);
+
+ /* Only first wall viewed from mid-y is lit */
+ if (y < midpoint)
+ {
+ if (!cave_los_bold(y + 1, x) && !cave_have_flag_bold(y + 1, x, FF_PROJECT)) return;
+ }
+ else if (y > midpoint)
+ {
+ if (!cave_los_bold(y - 1, x) && !cave_have_flag_bold(y - 1, x, FF_PROJECT)) return;
+ }
- /* Darken it */
- c_ptr->info |= CAVE_MNDK;
+ /* Hack XXX XXX - Is it a wall and monster not in LOS? */
+ else if (mon_invis) return;
+ }
}
+
+ /* We trust temp_n does not exceed TEMP_MAX */
+
+ /* Save this square */
+ temp_x[temp_n] = x;
+ temp_y[temp_n] = y;
+ temp_n++;
+
+ /* Darken it */
+ c_ptr->info |= CAVE_MNDK;
}
int i, rad;
cave_type *c_ptr;
- s16b fx, fy;
+ POSITION fx, fy;
+ void (*add_mon_lite)(POSITION, POSITION);
+ int f_flag;
s16b end_temp;
/* Empty temp list of new squares to lite up */
temp_n = 0;
- /* Loop through monsters, adding newly lit squares to changes list */
- for (i = 1; i < m_max; i++)
+ /* If a monster stops time, don't process */
+ if (!world_monster)
{
- monster_type *m_ptr = &m_list[i];
- monster_race *r_ptr = &r_info[m_ptr->r_idx];
+ monster_type *m_ptr;
+ monster_race *r_ptr;
- /* Skip dead monsters */
- if (!m_ptr->r_idx) continue;
+ /* Loop through monsters, adding newly lit squares to changes list */
+ for (i = 1; i < m_max; i++)
+ {
+ m_ptr = &m_list[i];
+ r_ptr = &r_info[m_ptr->r_idx];
- /* Is it too far away? */
- if (m_ptr->cdis > dis_lim) continue;
+ /* Skip dead monsters */
+ if (!m_ptr->r_idx) continue;
- /* Get lite radius */
- rad = 0;
+ /* Is it too far away? */
+ if (m_ptr->cdis > dis_lim) continue;
- /* Note the radii are cumulative */
- if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_SELF_LITE_1)) rad++;
- if (r_ptr->flags7 & (RF7_HAS_LITE_2 | RF7_SELF_LITE_2)) rad += 2;
- if (r_ptr->flags7 & (RF7_HAS_DARK_1 | RF7_SELF_DARK_1)) rad--;
- if (r_ptr->flags7 & (RF7_HAS_DARK_2 | RF7_SELF_DARK_2)) rad -= 2;
+ /* Get lite radius */
+ rad = 0;
- /* Exit if has no light */
- if (!rad) continue;
- else if (rad > 0)
- {
- if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (m_ptr->csleep || (!dun_level && is_daytime()) || p_ptr->inside_battle)) continue;
- if (d_info[dungeon_type].flags1 & DF1_DARKNESS) rad = 1;
- }
- else
- {
- if (!(r_ptr->flags7 & (RF7_SELF_DARK_1 | RF7_SELF_DARK_2)) && (m_ptr->csleep || (!dun_level && !is_daytime()))) continue;
- }
+ /* Note the radii are cumulative */
+ if (r_ptr->flags7 & (RF7_HAS_LITE_1 | RF7_SELF_LITE_1)) rad++;
+ if (r_ptr->flags7 & (RF7_HAS_LITE_2 | RF7_SELF_LITE_2)) rad += 2;
+ if (r_ptr->flags7 & (RF7_HAS_DARK_1 | RF7_SELF_DARK_1)) rad--;
+ if (r_ptr->flags7 & (RF7_HAS_DARK_2 | RF7_SELF_DARK_2)) rad -= 2;
- if (world_monster) continue;
+ /* Exit if has no light */
+ if (!rad) continue;
+ else if (rad > 0)
+ {
+ if (!(r_ptr->flags7 & (RF7_SELF_LITE_1 | RF7_SELF_LITE_2)) && (MON_CSLEEP(m_ptr) || (!dun_level && is_daytime()) || p_ptr->inside_battle)) continue;
+ if (d_info[dungeon_type].flags1 & DF1_DARKNESS) rad = 1;
+ add_mon_lite = mon_lite_hack;
+ f_flag = FF_LOS;
+ }
+ else
+ {
+ if (!(r_ptr->flags7 & (RF7_SELF_DARK_1 | RF7_SELF_DARK_2)) && (MON_CSLEEP(m_ptr) || (!dun_level && !is_daytime()))) continue;
+ add_mon_lite = mon_dark_hack;
+ f_flag = FF_PROJECT;
+ rad = -rad; /* Use absolute value */
+ }
- /* Access the location */
- fx = m_ptr->fx;
- fy = m_ptr->fy;
+ /* Access the location */
+ mon_fx = m_ptr->fx;
+ mon_fy = m_ptr->fy;
- /* Is the monster visible? */
- mon_invis = !(cave[fy][fx].info & CAVE_VIEW);
+ /* Is the monster visible? */
+ mon_invis = !(cave[mon_fy][mon_fx].info & CAVE_VIEW);
- if (rad > 0) /* Lite */
- {
/* The square it is on */
- mon_lite_hack(fy, fx);
+ add_mon_lite(mon_fy, mon_fx);
/* Adjacent squares */
- mon_lite_hack(fy + 1, fx);
- mon_lite_hack(fy - 1, fx);
- mon_lite_hack(fy, fx + 1);
- mon_lite_hack(fy, fx - 1);
- mon_lite_hack(fy + 1, fx + 1);
- mon_lite_hack(fy + 1, fx - 1);
- mon_lite_hack(fy - 1, fx + 1);
- mon_lite_hack(fy - 1, fx - 1);
+ add_mon_lite(mon_fy + 1, mon_fx);
+ add_mon_lite(mon_fy - 1, mon_fx);
+ add_mon_lite(mon_fy, mon_fx + 1);
+ add_mon_lite(mon_fy, mon_fx - 1);
+ add_mon_lite(mon_fy + 1, mon_fx + 1);
+ add_mon_lite(mon_fy + 1, mon_fx - 1);
+ add_mon_lite(mon_fy - 1, mon_fx + 1);
+ add_mon_lite(mon_fy - 1, mon_fx - 1);
/* Radius 2 */
if (rad >= 2)
{
/* South of the monster */
- if (cave_floor_bold(fy + 1, fx))
+ if (cave_have_flag_bold(mon_fy + 1, mon_fx, f_flag))
{
- mon_lite_hack(fy + 2, fx + 1);
- mon_lite_hack(fy + 2, fx);
- mon_lite_hack(fy + 2, fx - 1);
+ add_mon_lite(mon_fy + 2, mon_fx + 1);
+ add_mon_lite(mon_fy + 2, mon_fx);
+ add_mon_lite(mon_fy + 2, mon_fx - 1);
- c_ptr = &cave[fy + 2][fx];
+ c_ptr = &cave[mon_fy + 2][mon_fx];
/* Radius 3 */
- if ((rad == 3) && cave_floor_grid(c_ptr))
+ if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
{
- mon_lite_hack(fy + 3, fx + 1);
- mon_lite_hack(fy + 3, fx);
- mon_lite_hack(fy + 3, fx - 1);
+ add_mon_lite(mon_fy + 3, mon_fx + 1);
+ add_mon_lite(mon_fy + 3, mon_fx);
+ add_mon_lite(mon_fy + 3, mon_fx - 1);
}
}
/* North of the monster */
- if (cave_floor_bold(fy - 1, fx))
+ if (cave_have_flag_bold(mon_fy - 1, mon_fx, f_flag))
{
- mon_lite_hack(fy - 2, fx + 1);
- mon_lite_hack(fy - 2, fx);
- mon_lite_hack(fy - 2, fx - 1);
+ add_mon_lite(mon_fy - 2, mon_fx + 1);
+ add_mon_lite(mon_fy - 2, mon_fx);
+ add_mon_lite(mon_fy - 2, mon_fx - 1);
- c_ptr = &cave[fy - 2][fx];
+ c_ptr = &cave[mon_fy - 2][mon_fx];
/* Radius 3 */
- if ((rad == 3) && cave_floor_grid(c_ptr))
+ if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
{
- mon_lite_hack(fy - 3, fx + 1);
- mon_lite_hack(fy - 3, fx);
- mon_lite_hack(fy - 3, fx - 1);
+ add_mon_lite(mon_fy - 3, mon_fx + 1);
+ add_mon_lite(mon_fy - 3, mon_fx);
+ add_mon_lite(mon_fy - 3, mon_fx - 1);
}
}
/* East of the monster */
- if (cave_floor_bold(fy, fx + 1))
+ if (cave_have_flag_bold(mon_fy, mon_fx + 1, f_flag))
{
- mon_lite_hack(fy + 1, fx + 2);
- mon_lite_hack(fy, fx + 2);
- mon_lite_hack(fy - 1, fx + 2);
+ add_mon_lite(mon_fy + 1, mon_fx + 2);
+ add_mon_lite(mon_fy, mon_fx + 2);
+ add_mon_lite(mon_fy - 1, mon_fx + 2);
- c_ptr = &cave[fy][fx + 2];
+ c_ptr = &cave[mon_fy][mon_fx + 2];
/* Radius 3 */
- if ((rad == 3) && cave_floor_grid(c_ptr))
+ if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
{
- mon_lite_hack(fy + 1, fx + 3);
- mon_lite_hack(fy, fx + 3);
- mon_lite_hack(fy - 1, fx + 3);
+ add_mon_lite(mon_fy + 1, mon_fx + 3);
+ add_mon_lite(mon_fy, mon_fx + 3);
+ add_mon_lite(mon_fy - 1, mon_fx + 3);
}
}
/* West of the monster */
- if (cave_floor_bold(fy, fx - 1))
+ if (cave_have_flag_bold(mon_fy, mon_fx - 1, f_flag))
{
- mon_lite_hack(fy + 1, fx - 2);
- mon_lite_hack(fy, fx - 2);
- mon_lite_hack(fy - 1, fx - 2);
+ add_mon_lite(mon_fy + 1, mon_fx - 2);
+ add_mon_lite(mon_fy, mon_fx - 2);
+ add_mon_lite(mon_fy - 1, mon_fx - 2);
- c_ptr = &cave[fy][fx - 2];
+ c_ptr = &cave[mon_fy][mon_fx - 2];
/* Radius 3 */
- if ((rad == 3) && cave_floor_grid(c_ptr))
+ if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
{
- mon_lite_hack(fy + 1, fx - 3);
- mon_lite_hack(fy, fx - 3);
- mon_lite_hack(fy - 1, fx - 3);
+ add_mon_lite(mon_fy + 1, mon_fx - 3);
+ add_mon_lite(mon_fy, mon_fx - 3);
+ add_mon_lite(mon_fy - 1, mon_fx - 3);
}
}
}
if (rad == 3)
{
/* South-East of the monster */
- if (cave_floor_bold(fy + 1, fx + 1))
- {
- mon_lite_hack(fy + 2, fx + 2);
- }
-
- /* South-West of the monster */
- if (cave_floor_bold(fy + 1, fx - 1))
- {
- mon_lite_hack(fy + 2, fx - 2);
- }
-
- /* North-East of the monster */
- if (cave_floor_bold(fy - 1, fx + 1))
- {
- mon_lite_hack(fy - 2, fx + 2);
- }
-
- /* North-West of the monster */
- if (cave_floor_bold(fy - 1, fx - 1))
- {
- mon_lite_hack(fy - 2, fx - 2);
- }
- }
- }
- else /* Dark (rad < 0) */
- {
- /* The square it is on */
- mon_dark_hack(fy, fx);
-
- /* Adjacent squares */
- mon_dark_hack(fy + 1, fx);
- mon_dark_hack(fy - 1, fx);
- mon_dark_hack(fy, fx + 1);
- mon_dark_hack(fy, fx - 1);
- mon_dark_hack(fy + 1, fx + 1);
- mon_dark_hack(fy + 1, fx - 1);
- mon_dark_hack(fy - 1, fx + 1);
- mon_dark_hack(fy - 1, fx - 1);
-
- /* Radius -2 */
- if (rad <= -2)
- {
- /* South of the monster */
- if (cave_floor_bold(fy + 1, fx))
- {
- mon_dark_hack(fy + 2, fx + 1);
- mon_dark_hack(fy + 2, fx);
- mon_dark_hack(fy + 2, fx - 1);
-
- c_ptr = &cave[fy + 2][fx];
-
- /* Radius -3 */
- if ((rad == -3) && cave_floor_grid(c_ptr))
- {
- mon_dark_hack(fy + 3, fx + 1);
- mon_dark_hack(fy + 3, fx);
- mon_dark_hack(fy + 3, fx - 1);
- }
- }
-
- /* North of the monster */
- if (cave_floor_bold(fy - 1, fx))
- {
- mon_dark_hack(fy - 2, fx + 1);
- mon_dark_hack(fy - 2, fx);
- mon_dark_hack(fy - 2, fx - 1);
-
- c_ptr = &cave[fy - 2][fx];
-
- /* Radius -3 */
- if ((rad == -3) && cave_floor_grid(c_ptr))
- {
- mon_dark_hack(fy - 3, fx + 1);
- mon_dark_hack(fy - 3, fx);
- mon_dark_hack(fy - 3, fx - 1);
- }
- }
-
- /* East of the monster */
- if (cave_floor_bold(fy, fx + 1))
- {
- mon_dark_hack(fy + 1, fx + 2);
- mon_dark_hack(fy, fx + 2);
- mon_dark_hack(fy - 1, fx + 2);
-
- c_ptr = &cave[fy][fx + 2];
-
- /* Radius -3 */
- if ((rad == -3) && cave_floor_grid(c_ptr))
- {
- mon_dark_hack(fy + 1, fx + 3);
- mon_dark_hack(fy, fx + 3);
- mon_dark_hack(fy - 1, fx + 3);
- }
- }
-
- /* West of the monster */
- if (cave_floor_bold(fy, fx - 1))
- {
- mon_dark_hack(fy + 1, fx - 2);
- mon_dark_hack(fy, fx - 2);
- mon_dark_hack(fy - 1, fx - 2);
-
- c_ptr = &cave[fy][fx - 2];
-
- /* Radius -3 */
- if ((rad == -3) && cave_floor_grid(c_ptr))
- {
- mon_dark_hack(fy + 1, fx - 3);
- mon_dark_hack(fy, fx - 3);
- mon_dark_hack(fy - 1, fx - 3);
- }
- }
- }
-
- /* Radius -3 */
- if (rad == -3)
- {
- /* South-East of the monster */
- if (cave_floor_bold(fy + 1, fx + 1))
+ if (cave_have_flag_bold(mon_fy + 1, mon_fx + 1, f_flag))
{
- mon_dark_hack(fy + 2, fx + 2);
+ add_mon_lite(mon_fy + 2, mon_fx + 2);
}
/* South-West of the monster */
- if (cave_floor_bold(fy + 1, fx - 1))
+ if (cave_have_flag_bold(mon_fy + 1, mon_fx - 1, f_flag))
{
- mon_dark_hack(fy + 2, fx - 2);
+ add_mon_lite(mon_fy + 2, mon_fx - 2);
}
/* North-East of the monster */
- if (cave_floor_bold(fy - 1, fx + 1))
+ if (cave_have_flag_bold(mon_fy - 1, mon_fx + 1, f_flag))
{
- mon_dark_hack(fy - 2, fx + 2);
+ add_mon_lite(mon_fy - 2, mon_fx + 2);
}
/* North-West of the monster */
- if (cave_floor_bold(fy - 1, fx - 1))
+ if (cave_have_flag_bold(mon_fy - 1, mon_fx - 1, f_flag))
{
- mon_dark_hack(fy - 2, fx - 2);
+ add_mon_lite(mon_fy - 2, mon_fx - 2);
}
}
}
}
/* Add to end of temp array */
- temp_x[temp_n] = (byte)fx;
- temp_y[temp_n] = (byte)fy;
+ temp_x[temp_n] = fx;
+ temp_y[temp_n] = fy;
temp_n++;
}
/* Mega-Hack -- Visual update later */
p_ptr->update |= (PU_DELAY_VIS);
- p_ptr->monlite = (cave[py][px].info & CAVE_MNLT) ? TRUE : FALSE;
+ p_ptr->monlite = (cave[p_ptr->y][p_ptr->x].info & CAVE_MNLT) ? TRUE : FALSE;
if (p_ptr->special_defense & NINJA_S_STEALTH)
{
{
if (p_ptr->monlite)
{
-#ifdef JP
- msg_print("±Æ¤Îʤ¤¤¤¬Çö¤ì¤¿µ¤¤¬¤¹¤ë¡£");
-#else
- msg_print("Your mantle of shadow become thin.");
-#endif
+ msg_print(_("影の覆いが薄れた気がする。", "Your mantle of shadow become thin."));
}
else
{
-#ifdef JP
- msg_print("±Æ¤Îʤ¤¤¤¬Ç»¤¯¤Ê¤Ã¤¿¡ª");
-#else
- msg_print("Your mantle of shadow restored its original darkness.");
-#endif
+ msg_print(_("影の覆いが濃くなった!", "Your mantle of shadow restored its original darkness."));
}
}
}
/* Forget that the grid is viewable */
c_ptr->info &= ~(CAVE_VIEW);
- if (!panel_contains(y, x)) continue;
+ /* if (!panel_contains(y, x)) continue; */
/* Update the screen */
/* lite_spot(y, x); Perhaps don't need? */
*
* This function assumes that (y,x) is legal (i.e. on the map).
*
- * Grid (y1,x1) is on the "diagonal" between (py,px) and (y,x)
- * Grid (y2,x2) is "adjacent", also between (py,px) and (y,x).
+ * Grid (y1,x1) is on the "diagonal" between (p_ptr->y,p_ptr->x) and (y,x)
+ * Grid (y2,x2) is "adjacent", also between (p_ptr->y,p_ptr->x) and (y,x).
*
* Note that we are using the "CAVE_XTRA" field for marking grids as
* "easily viewable". This bit is cleared at the end of "update_view()".
/* Check for walls */
- f1 = (cave_floor_grid(g1_c_ptr));
- f2 = (cave_floor_grid(g2_c_ptr));
+ f1 = (cave_los_grid(g1_c_ptr));
+ f2 = (cave_los_grid(g2_c_ptr));
/* Totally blocked by physical walls */
if (!f1 && !f2) return (TRUE);
/* Check for walls */
- wall = (!cave_floor_grid(c_ptr));
+ wall = (!cave_los_grid(c_ptr));
/* Check the "ease" of visibility */
/* Hack -- check line of sight */
- if (los(py, px, y, x))
+ if (los(p_ptr->y, p_ptr->x, y, x))
{
cave_view_hack(c_ptr, y, x);
* Note also the care taken to prevent "running off the map". The use of
* explicit checks on the "validity" of the "diagonal", and the fact that
* the loops are never allowed to "leave" the map, lets "update_view_aux()"
- * use the optimized "cave_floor_bold()" macro, and to avoid the overhead
+ * use the optimized "cave_los_bold()" macro, and to avoid the overhead
* of multiple checks on the validity of grids.
*
* Note the "optimizations" involving the "se","sw","ne","nw","es","en",
* told not to go farther than the current strip's farthest viewable grid,
* unless open space is still available. This uses the "k" variable.
*
- * Note the use of "inline" macros for efficiency. The "cave_floor_grid()"
- * macro is a replacement for "cave_floor_bold()" which takes a pointer to
+ * Note the use of "inline" macros for efficiency. The "cave_los_grid()"
+ * macro is a replacement for "cave_los_bold()" which takes a pointer to
* a cave grid instead of its location. The "cave_view_hack()" macro is a
* chunk of code which adds the given location to the "view" array if it
* is not already there, using both the actual location and a pointer to
*/
void update_view(void)
{
- int n, m, d, k, y, x, z;
+ int n, m, d, k, z;
+ POSITION y, x;
int se, sw, ne, nw, es, en, ws, wn;
int full, over;
- int y_max = cur_hgt - 1;
- int x_max = cur_wid - 1;
+ POSITION y_max = cur_hgt - 1;
+ POSITION x_max = cur_wid - 1;
cave_type *c_ptr;
/*** Step 1 -- adjacent grids ***/
/* Now start on the player */
- y = py;
- x = px;
+ y = p_ptr->y;
+ x = p_ptr->x;
/* Access the grid */
c_ptr = &cave[y][x];
c_ptr = &cave[y+d][x+d];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y+d, x+d);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Scan south-west */
c_ptr = &cave[y+d][x-d];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y+d, x-d);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Scan north-east */
c_ptr = &cave[y-d][x+d];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y-d, x+d);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Scan north-west */
c_ptr = &cave[y-d][x-d];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y-d, x-d);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
c_ptr = &cave[y+d][x];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y+d, x);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Initialize the "south strips" */
c_ptr = &cave[y-d][x];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y-d, x);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Initialize the "north strips" */
c_ptr = &cave[y][x+d];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y, x+d);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Initialize the "east strips" */
c_ptr = &cave[y][x-d];
c_ptr->info |= (CAVE_XTRA);
cave_view_hack(c_ptr, y, x-d);
- if (!cave_floor_grid(c_ptr)) break;
+ if (!cave_los_grid(c_ptr)) break;
}
/* Initialize the "west strips" */
* it everytime the player moves out of LOS of the last
* "way-point".
*/
-static u16b flow_x = 0;
-static u16b flow_y = 0;
+static POSITION flow_x = 0;
+static POSITION flow_y = 0;
*/
void update_flow(void)
{
- int x, y, d;
+ POSITION x, y, d;
int flow_head = 1;
int flow_tail = 0;
}
/* Save player position */
- flow_y = py;
- flow_x = px;
+ flow_y = p_ptr->y;
+ flow_x = p_ptr->x;
/* Add the player's grid to the queue */
- temp_y[0] = py;
- temp_x[0] = px;
+ temp_y[0] = p_ptr->y;
+ temp_x[0] = p_ptr->x;
/* Now process the queue */
while (flow_head != flow_tail)
for (d = 0; d < 8; d++)
{
int old_head = flow_head;
- int m = cave[ty][tx].cost + 1;
- int n = cave[ty][tx].dist + 1;
+ byte_hack m = cave[ty][tx].cost + 1;
+ byte_hack n = cave[ty][tx].dist + 1;
cave_type *c_ptr;
/* Child location */
if (c_ptr->dist != 0 && c_ptr->dist <= n && c_ptr->cost <= m) continue;
/* Ignore "walls" and "rubble" */
- if ((c_ptr->feat >= FEAT_RUBBLE) && (c_ptr->feat != FEAT_TREES) && !cave_floor_grid(c_ptr)) continue;
+ if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !is_closed_door(c_ptr->feat)) continue;
/* Save the flow cost */
if (c_ptr->cost == 0 || c_ptr->cost > m) c_ptr->cost = m;
cave_type *c_ptr;
/* Translate table to map grids */
- y = i + py - 2;
- x = j + px - 2;
+ y = i + p_ptr->y - 2;
+ x = j + p_ptr->x - 2;
/* Check Bounds */
if (!in_bounds(y, x)) continue;
c_ptr = &cave[y][x];
/* Walls, water, and lava cannot hold scent. */
- if ((c_ptr->feat >= FEAT_RUBBLE) && (c_ptr->feat != FEAT_TREES) && !cave_floor_grid(c_ptr)) continue;
+ if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !is_closed_door(c_ptr->feat)) continue;
/* Grid must not be blocked by walls from the character */
if (!player_has_los_bold(y, x)) continue;
/*
* Hack -- map the current panel (plus some) ala "magic mapping"
*/
-void map_area(int range)
+void map_area(POSITION range)
{
int i, x, y;
-
cave_type *c_ptr;
-
- byte feat;
+ s16b feat;
+ feature_type *f_ptr;
if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
{
for (x = 1; x < cur_wid - 1; x++)
{
- if (distance(py, px, y, x) > range) continue;
+ if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
c_ptr = &cave[y][x];
+ /* Memorize terrain of the grid */
+ c_ptr->info |= (CAVE_KNOWN);
+
/* Feature code (applying "mimic" field) */
- feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+ feat = get_feat_mimic(c_ptr);
+ f_ptr = &f_info[feat];
/* All non-walls are "checked" */
- if ((feat <= FEAT_DOOR_TAIL) ||
- (feat == FEAT_RUBBLE) ||
- ((feat >= FEAT_MINOR_GLYPH) &&
- (feat <= FEAT_TREES)) ||
- (feat >= FEAT_TOWN))
+ if (!have_flag(f_ptr->flags, FF_WALL))
{
/* Memorize normal features */
- if ((feat > FEAT_INVIS) && (feat != FEAT_DIRT) && (feat != FEAT_GRASS))
+ if (have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Memorize the object */
c_ptr->info |= (CAVE_MARK);
c_ptr = &cave[y + ddy_ddd[i]][x + ddx_ddd[i]];
/* Feature code (applying "mimic" field) */
- feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+ feat = get_feat_mimic(c_ptr);
+ f_ptr = &f_info[feat];
/* Memorize walls (etc) */
- if ((feat >= FEAT_RUBBLE) && (feat != FEAT_DIRT) && (feat != FEAT_GRASS))
+ if (have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Memorize the walls */
c_ptr->info |= (CAVE_MARK);
void wiz_lite(bool ninja)
{
int i, y, x;
- byte feat;
+ s16b feat;
+ feature_type *f_ptr;
/* Memorize objects */
for (i = 1; i < o_max; i++)
{
cave_type *c_ptr = &cave[y][x];
+ /* Memorize terrain of the grid */
+ c_ptr->info |= (CAVE_KNOWN);
+
/* Feature code (applying "mimic" field) */
- feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+ feat = get_feat_mimic(c_ptr);
+ f_ptr = &f_info[feat];
/* Process all non-walls */
- if (cave_floor_bold(y, x) || (feat == FEAT_RUBBLE) || (feat == FEAT_TREES) || (feat == FEAT_MOUNTAIN))
+ if (!have_flag(f_ptr->flags, FF_WALL))
{
/* Scan all neighbors */
for (i = 0; i < 9; i++)
c_ptr = &cave[yy][xx];
/* Feature code (applying "mimic" field) */
- feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
+ f_ptr = &f_info[get_feat_mimic(c_ptr)];
+
+ /* Perma-lite the grid */
+ if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) && !ninja)
+ {
+ c_ptr->info |= (CAVE_GLOW);
+ }
/* Memorize normal features */
- if (ninja)
+ if (have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Memorize the grid */
c_ptr->info |= (CAVE_MARK);
}
- else
+
+ /* Perma-lit grids (newly and previously) */
+ else if (c_ptr->info & CAVE_GLOW)
{
- if ((feat > FEAT_INVIS))
+ /* Normally, memorize floors (see above) */
+ if (view_perma_grids && !view_torch_grids)
{
/* Memorize the grid */
c_ptr->info |= (CAVE_MARK);
}
-
- /* Perma-lite the grid */
- if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
- {
- c_ptr->info |= (CAVE_GLOW);
-
- /* Normally, memorize floors (see above) */
- if (view_perma_grids && !view_torch_grids)
- {
- /* Memorize the grid */
- c_ptr->info |= (CAVE_MARK);
- }
- }
}
}
}
/* Window stuff */
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+
+ if (p_ptr->special_defense & NINJA_S_STEALTH)
+ {
+ if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
+ }
}
/* Forget every grid */
- for (y = 0; y < cur_hgt; y++)
+ for (y = 1; y < cur_hgt - 1; y++)
{
- for (x = 0; x < cur_wid; x++)
+ for (x = 1; x < cur_wid - 1; x++)
{
cave_type *c_ptr = &cave[y][x];
/* Process the grid */
- c_ptr->info &= ~(CAVE_MARK);
+ c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
+ c_ptr->info |= (CAVE_UNSAFE);
}
}
+ /* Forget every grid on horizontal edge */
+ for (x = 0; x < cur_wid; x++)
+ {
+ cave[0][x].info &= ~(CAVE_MARK);
+ cave[cur_hgt - 1][x].info &= ~(CAVE_MARK);
+ }
+
+ /* Forget every grid on vertical edge */
+ for (y = 1; y < (cur_hgt - 1); y++)
+ {
+ cave[y][0].info &= ~(CAVE_MARK);
+ cave[y][cur_wid - 1].info &= ~(CAVE_MARK);
+ }
+
/* Forget all objects */
for (i = 1; i < o_max; i++)
{
if (o_ptr->held_m_idx) continue;
/* Forget the object */
- o_ptr->marked = 0;
+ o_ptr->marked &= OM_TOUCHED;
}
+ /* Forget travel route when we have forgotten map */
+ forget_travel_flow();
+
/* Mega-Hack -- Forget the view and lite */
p_ptr->update |= (PU_UN_VIEW | PU_UN_LITE);
/*
* Change the "feat" flag for a grid, and notice/redraw the grid
*/
-void cave_set_feat(int y, int x, int feat)
+void cave_set_feat(POSITION y, POSITION x, IDX feat)
{
cave_type *c_ptr = &cave[y][x];
+ feature_type *f_ptr = &f_info[feat];
+ bool old_los, old_mirror;
+
+ if (!character_dungeon)
+ {
+ /* Clear mimic type */
+ c_ptr->mimic = 0;
+
+ /* Change the feature */
+ c_ptr->feat = feat;
+
+ /* Hack -- glow the GLOW terrain */
+ if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
+ {
+ int i, yy, xx;
+
+ for (i = 0; i < 9; i++)
+ {
+ yy = y + ddy_ddd[i];
+ xx = x + ddx_ddd[i];
+ if (!in_bounds2(yy, xx)) continue;
+ cave[yy][xx].info |= CAVE_GLOW;
+ }
+ }
+
+ return;
+ }
+
+ old_los = cave_have_flag_bold(y, x, FF_LOS);
+ old_mirror = is_mirror_grid(c_ptr);
/* Clear mimic type */
c_ptr->mimic = 0;
+ /* Change the feature */
+ c_ptr->feat = feat;
+
/* Remove flag for mirror/glyph */
c_ptr->info &= ~(CAVE_OBJECT);
- /* Change the feature */
- c_ptr->feat = feat;
+ if (old_mirror && (d_info[dungeon_type].flags1 & DF1_DARKNESS))
+ {
+ c_ptr->info &= ~(CAVE_GLOW);
+ if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
+
+ update_local_illumination(y, x);
+ }
+
+ /* Check for change to boring grid */
+ if (!have_flag(f_ptr->flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
+
+ /* Update the monster */
+ if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+
+ /* Notice */
+ note_spot(y, x);
+
+ /* Redraw */
+ lite_spot(y, x);
+
+ /* Check if los has changed */
+ if (old_los ^ have_flag(f_ptr->flags, FF_LOS))
+ {
+
+#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
+
+ update_local_illumination(y, x);
- /* Hack -- glow the deep lava */
- if ((feat == FEAT_DEEP_LAVA) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
+#endif /* COMPLEX_WALL_ILLUMINATION */
+
+ /* Update the visuals */
+ p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_MONSTERS);
+ }
+
+ /* Hack -- glow the GLOW terrain */
+ if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
{
int i, yy, xx;
+ cave_type *cc_ptr;
for (i = 0; i < 9; i++)
{
yy = y + ddy_ddd[i];
xx = x + ddx_ddd[i];
if (!in_bounds2(yy, xx)) continue;
- cave[yy][xx].info |= CAVE_GLOW;
- if (player_has_los_bold(yy, xx))
+ cc_ptr = &cave[yy][xx];
+ cc_ptr->info |= CAVE_GLOW;
+
+ if (player_has_los_grid(cc_ptr))
{
+ /* Update the monster */
+ if (cc_ptr->m_idx) update_mon(cc_ptr->m_idx, FALSE);
+
/* Notice */
note_spot(yy, xx);
/* Redraw */
lite_spot(yy, xx);
}
+
+ update_local_illumination(yy, xx);
+ }
+
+ if (p_ptr->special_defense & NINJA_S_STEALTH)
+ {
+ if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
}
}
+}
- /* Notice */
- note_spot(y, x);
- /* Redraw */
- lite_spot(y, x);
+IDX conv_dungeon_feat(IDX newfeat)
+{
+ feature_type *f_ptr = &f_info[newfeat];
+
+ if (have_flag(f_ptr->flags, FF_CONVERT))
+ {
+ switch (f_ptr->subtype)
+ {
+ case CONVERT_TYPE_FLOOR:
+ return floor_type[randint0(100)];
+ case CONVERT_TYPE_WALL:
+ return fill_type[randint0(100)];
+ case CONVERT_TYPE_INNER:
+ return feat_wall_inner;
+ case CONVERT_TYPE_OUTER:
+ return feat_wall_outer;
+ case CONVERT_TYPE_SOLID:
+ return feat_wall_solid;
+ case CONVERT_TYPE_STREAM1:
+ return d_info[dungeon_type].stream1;
+ case CONVERT_TYPE_STREAM2:
+ return d_info[dungeon_type].stream2;
+ default:
+ return newfeat;
+ }
+ }
+ else return newfeat;
+}
+
+
+/*
+ * Take a feature, determine what that feature becomes
+ * through applying the given action.
+ */
+IDX feat_state(IDX feat, int action)
+{
+ feature_type *f_ptr = &f_info[feat];
+ int i;
+
+ /* Get the new feature */
+ for (i = 0; i < MAX_FEAT_STATES; i++)
+ {
+ if (f_ptr->state[i].action == action) return conv_dungeon_feat(f_ptr->state[i].result);
+ }
+
+ if (have_flag(f_ptr->flags, FF_PERMANENT)) return feat;
+
+ return (feature_action_flags[action] & FAF_DESTROY) ? conv_dungeon_feat(f_ptr->destroyed) : feat;
+}
+
+/*
+ * Takes a location and action and changes the feature at that
+ * location through applying the given action.
+ */
+void cave_alter_feat(int y, int x, int action)
+{
+ /* Set old feature */
+ IDX oldfeat = cave[y][x].feat;
+
+ /* Get the new feat */
+ IDX newfeat = feat_state(oldfeat, action);
+
+ /* No change */
+ if (newfeat == oldfeat) return;
+
+ /* Set the new feature */
+ cave_set_feat(y, x, newfeat);
+
+ if (!(feature_action_flags[action] & FAF_NO_DROP))
+ {
+ feature_type *old_f_ptr = &f_info[oldfeat];
+ feature_type *f_ptr = &f_info[newfeat];
+ bool found = FALSE;
+
+ /* Handle gold */
+ if (have_flag(old_f_ptr->flags, FF_HAS_GOLD) && !have_flag(f_ptr->flags, FF_HAS_GOLD))
+ {
+ /* Place some gold */
+ place_gold(y, x);
+ found = TRUE;
+ }
+
+ /* Handle item */
+ if (have_flag(old_f_ptr->flags, FF_HAS_ITEM) && !have_flag(f_ptr->flags, FF_HAS_ITEM) && (randint0(100) < (15 - dun_level / 2)))
+ {
+ /* Place object */
+ place_object(y, x, 0L);
+ found = TRUE;
+ }
+
+ if (found && character_dungeon && player_can_see_bold(y, x))
+ {
+ msg_print(_("何かを発見した!", "You have found something!"));
+ }
+ }
+
+ if (feature_action_flags[action] & FAF_CRASH_GLASS)
+ {
+ feature_type *old_f_ptr = &f_info[oldfeat];
+
+ if (have_flag(old_f_ptr->flags, FF_GLASS) && character_dungeon)
+ {
+ project(PROJECT_WHO_GLASS_SHARDS, 1, y, x, MIN(dun_level, 100) / 4, GF_SHARDS,
+ (PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL | PROJECT_HIDE | PROJECT_JUMP | PROJECT_NO_HANGEKI), -1);
+ }
+ }
}
+
/* Remove a mirror */
void remove_mirror(int y, int x)
{
+ cave_type *c_ptr = &cave[y][x];
+
/* Remove the mirror */
- cave[y][x].info &= ~(CAVE_OBJECT);
- cave[y][x].mimic = 0;
+ c_ptr->info &= ~(CAVE_OBJECT);
+ c_ptr->mimic = 0;
if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
{
- cave[y][x].info &= ~(CAVE_GLOW);
- if( !view_torch_grids )cave[y][x].info &= ~(CAVE_MARK);
+ c_ptr->info &= ~(CAVE_GLOW);
+ if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
+
+ /* Update the monster */
+ if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+
+ update_local_illumination(y, x);
}
+
/* Notice */
note_spot(y, x);
*/
bool is_mirror_grid(cave_type *c_ptr)
{
- if ((c_ptr->info & CAVE_OBJECT) && c_ptr->mimic == FEAT_MIRROR)
+ if ((c_ptr->info & CAVE_OBJECT) && have_flag(f_info[c_ptr->mimic].flags, FF_MIRROR))
return TRUE;
else
return FALSE;
*/
bool is_glyph_grid(cave_type *c_ptr)
{
- if ((c_ptr->info & CAVE_OBJECT) && c_ptr->mimic == FEAT_GLYPH)
+ if ((c_ptr->info & CAVE_OBJECT) && have_flag(f_info[c_ptr->mimic].flags, FF_GLYPH))
return TRUE;
else
return FALSE;
*/
bool is_explosive_rune_grid(cave_type *c_ptr)
{
- if ((c_ptr->info & CAVE_OBJECT) && c_ptr->mimic == FEAT_MINOR_GLYPH)
+ if ((c_ptr->info & CAVE_OBJECT) && have_flag(f_info[c_ptr->mimic].flags, FF_MINOR_GLYPH))
return TRUE;
else
return FALSE;
*
* This is slightly (but significantly) different from "los(y1,x1,y2,x2)".
*/
-bool projectable(int y1, int x1, int y2, int x2)
+bool projectable(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
{
- int y, x;
+ POSITION y, x;
int grid_n = 0;
u16b grid_g[512];
/* Check the projection path */
grid_n = project_path(grid_g, (project_length ? project_length : MAX_RANGE), y1, x1, y2, x2, 0);
- /* No grid is ever projectable from itself */
- if (!grid_n) return (FALSE);
+ /* Identical grid */
+ if (!grid_n) return TRUE;
/* Final grid */
y = GRID_Y(grid_g[grid_n - 1]);
*
* Currently the "m" parameter is unused.
*/
-void scatter(int *yp, int *xp, int y, int x, int d, int m)
+void scatter(POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, int m)
{
- int nx, ny;
+ POSITION nx, ny;
/* Unused */
m = m;
/* Ignore "excessively distant" locations */
if ((d > 1) && (distance(y, x, ny, nx) > d)) continue;
- /* Require "line of sight" */
- if (los(y, x, ny, nx)) break;
+ /* Require "line of projection" */
+ if (projectable(y, x, ny, nx)) break;
}
/* Save the location */
/*
* Track a new monster
*/
-void health_track(int m_idx)
+void health_track(MONSTER_IDX m_idx)
{
/* Mount monster is already tracked */
if (m_idx && m_idx == p_ptr->riding) return;
/*
* Hack -- track the given monster race
*/
-void monster_race_track(int r_idx)
+void monster_race_track(MONRACE_IDX r_idx)
{
/* Save this monster ID */
p_ptr->monster_race_idx = r_idx;
/*
* Hack -- track the given object kind
*/
-void object_kind_track(int k_idx)
+void object_kind_track(IDX k_idx)
{
/* Save this monster ID */
p_ptr->object_kind_idx = k_idx;
*
* All disturbance cancels repeated commands, resting, and running.
*/
-void disturb(int stop_search, int unused_flag)
+void disturb(int stop_search, int stop_travel)
{
+#ifndef TRAVEL
/* Unused */
- unused_flag = unused_flag;
+ stop_travel = stop_travel;
+#endif
/* Cancel auto-commands */
/* command_new = 0; */
p_ptr->update |= (PU_FLOW);
}
+#ifdef TRAVEL
+ if (stop_travel)
+ {
+ /* Cancel */
+ travel.run = 0;
+
+ /* Check for new panel if appropriate */
+ if (center_player && !center_running) verify_panel();
+
+ /* Calculate torch radius */
+ p_ptr->update |= (PU_TORCH);
+ }
+#endif
+
/* Flush the input if requested */
if (flush_disturb) flush();
}
{
int y, x, i, yy, xx;
cave_type *c_ptr;
- byte feat;
/* Not in the darkness dungeon */
if (d_info[dungeon_type].flags1 & DF1_DARKNESS) return;
c_ptr = &cave[y][x];
/* Feature code (applying "mimic" field) */
- feat = c_ptr->mimic ? c_ptr->mimic : f_info[c_ptr->feat].mimic;
-
- if ((feat == FEAT_DEEP_LAVA) ||
- ((feat >= FEAT_SHOP_HEAD) &&
- (feat <= FEAT_SHOP_TAIL)) ||
- (feat == FEAT_MUSEUM) ||
- ((feat >= FEAT_BLDG_HEAD) &&
- (feat <= FEAT_BLDG_TAIL)))
+
+ if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_GLOW))
{
for (i = 0; i < 9; i++)
{
xx = x + ddx_ddd[i];
if (!in_bounds2(yy, xx)) continue;
cave[yy][xx].info |= CAVE_GLOW;
- if (player_has_los_bold(yy, xx)) note_spot(yy, xx);
}
}
}
}
+
+ /* Update the view and lite */
+ p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
+
+ /* Redraw map */
+ p_ptr->redraw |= (PR_MAP);
}