/*!
- * @file cave.c
+ * @file grid_array.c
* @brief ダンジョンの基礎部分実装(主にマスの実装) / low level dungeon routines -BEN-
* @date 2013/12/30
* @author
#include "angband.h"
+#include "world.h"
+#include "projection.h"
+#include "object-hook.h"
static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
static int match_autopick;
* @param feat 地形情報のID
* @return 罠持ちの地形ならばTRUEを返す。
*/
-bool is_trap(IDX feat)
+bool is_trap(FEAT_IDX feat)
{
return have_flag(f_info[feat].flags, FF_TRAP);
}
/*!
* @brief マスに看破済みの罠があるかの判定を行う。 / Return TRUE if the given grid is a known trap
- * @param c_ptr マス構造体の参照ポインタ
+ * @param g_ptr マス構造体の参照ポインタ
* @return 看破済みの罠があるならTRUEを返す。
*/
-bool is_known_trap(cave_type *c_ptr)
+bool is_known_trap(grid_type *g_ptr)
{
- if (!c_ptr->mimic && !cave_have_flag_grid(c_ptr, FF_SECRET) &&
- is_trap(c_ptr->feat)) return TRUE;
+ if (!g_ptr->mimic && !cave_have_flag_grid(g_ptr, FF_SECRET) &&
+ is_trap(g_ptr->feat)) return TRUE;
else
return FALSE;
}
* @param feat 地形情報のID
* @return 閉じたドアのある地形ならばTRUEを返す。
*/
-bool is_closed_door(IDX feat)
+bool is_closed_door(FEAT_IDX feat)
{
feature_type *f_ptr = &f_info[feat];
/*!
* @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door
- * @param c_ptr マス構造体の参照ポインタ
+ * @param g_ptr マス構造体の参照ポインタ
* @return 隠されたドアがあるならTRUEを返す。
*/
-bool is_hidden_door(cave_type *c_ptr)
+bool is_hidden_door(grid_type *g_ptr)
{
- if ((c_ptr->mimic || cave_have_flag_grid(c_ptr, FF_SECRET)) &&
- is_closed_door(c_ptr->feat))
+ if ((g_ptr->mimic || cave_have_flag_grid(g_ptr, FF_SECRET)) &&
+ is_closed_door(g_ptr->feat))
return TRUE;
else
return FALSE;
POSITION dx, dy;
/* Absolute */
- int ax, ay;
+ POSITION ax, ay;
/* Signs */
- int sx, sy;
+ POSITION sx, sy;
/* Fractions */
- int qx, qy;
+ POSITION qx, qy;
/* Scanners */
- int tx, ty;
+ POSITION tx, ty;
/* Scale factors */
- int f1, f2;
+ POSITION f1, f2;
/* Slope, or 1/Slope, of LOS */
- int m;
+ POSITION m;
/* Extract the offset */
* @param x x座標
* @return 指定された座標に照明がかかっているならTRUEを返す。。
*/
-static bool check_local_illumination(int y, int x)
+static bool check_local_illumination(POSITION y, POSITION 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;
+ POSITION yy = (y < p_ptr->y) ? (y + 1) : (y > p_ptr->y) ? (y - 1) : y;
+ POSITION 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 */
/* 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)))
+ if ((feat_supports_los(get_feat_mimic(&grid_array[yy][xx])) &&
+ (grid_array[yy][xx].info & CAVE_GLOW)) ||
+ (feat_supports_los(get_feat_mimic(&grid_array[y][xx])) &&
+ (grid_array[y][xx].info & CAVE_GLOW)) ||
+ (feat_supports_los(get_feat_mimic(&grid_array[yy][x])) &&
+ (grid_array[yy][x].info & CAVE_GLOW)))
{
return TRUE;
}
#else /* COMPLEX_WALL_ILLUMINATION */
/* Check for "simple" illumination */
- return (cave[yy][xx].info & CAVE_GLOW) ? TRUE : FALSE;
+ return (grid_array[yy][xx].info & CAVE_GLOW) ? TRUE : FALSE;
#endif /* COMPLEX_WALL_ILLUMINATION */
}
if (player_has_los_bold((Y), (X))) \
{ \
/* Update the monster */ \
- if (cave[(Y)][(X)].m_idx) update_mon(cave[(Y)][(X)].m_idx, FALSE); \
+ if (grid_array[(Y)][(X)].m_idx) update_monster(grid_array[(Y)][(X)].m_idx, FALSE); \
\
/* Notice and redraw */ \
note_spot((Y), (X)); \
*/
bool player_can_see_bold(POSITION y, POSITION x)
{
- cave_type *c_ptr;
+ grid_type *g_ptr;
/* Blind players see nothing */
if (p_ptr->blind) return FALSE;
- /* Access the cave grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Note that "torch-lite" yields "illumination" */
- if (c_ptr->info & (CAVE_LITE | CAVE_MNLT)) return TRUE;
+ if (g_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 (p_ptr->see_nocto) return TRUE;
/* Require "perma-lite" of the grid */
- if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) return FALSE;
+ if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW) return FALSE;
/* Feature code (applying "mimic" field) */
/* Floors are simple */
- if (feat_supports_los(get_feat_mimic(c_ptr))) return TRUE;
+ if (feat_supports_los(get_feat_mimic(g_ptr))) return TRUE;
/* Check for "local" illumination */
return check_local_illumination(y, x);
*/
bool cave_valid_bold(POSITION y, POSITION x)
{
- cave_type *c_ptr = &cave[y][x];
+ grid_type *g_ptr = &grid_array[y][x];
OBJECT_IDX this_o_idx, next_o_idx = 0;
/* Forbid perma-grids */
- if (cave_perma_grid(c_ptr)) return (FALSE);
+ if (cave_perma_grid(g_ptr)) return (FALSE);
/* Check objects */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+ for (this_o_idx = g_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 */
* @param cp 本来のシンボル
* @return なし
*/
-static void image_monster(byte *ap, char *cp)
+static void image_monster(TERM_COLOR *ap, SYMBOL_CODE *cp)
{
/* Random symbol from set above */
if (use_graphics)
* @param cp 本来のシンボル
* @return なし
*/
-static void image_object(byte *ap, char *cp)
+static void image_object(TERM_COLOR *ap, SYMBOL_CODE *cp)
{
if (use_graphics)
{
* @param cp 本来のシンボル
* @return なし
*/
-static void image_random(byte *ap, char *cp)
+static void image_random(TERM_COLOR *ap, SYMBOL_CODE *cp)
{
/* Normally, assume monsters */
if (randint0(100) < 75)
*\n
* The layout of the array is [x][0] = light and [x][1] = dark.\n
*/
-static byte lighting_colours[16][2] =
+static TERM_COLOR lighting_colours[16][2] =
{
/* TERM_DARK */
{TERM_L_DARK, TERM_DARK},
* @brief 調査中
* @todo コメントを付加すること
*/
-void apply_default_feat_lighting(byte f_attr[F_LIT_MAX], byte f_char[F_LIT_MAX])
+void apply_default_feat_lighting(TERM_COLOR f_attr[F_LIT_MAX], SYMBOL_CODE f_char[F_LIT_MAX])
{
- byte s_attr = f_attr[F_LIT_STANDARD];
- byte s_char = f_char[F_LIT_STANDARD];
+ TERM_COLOR s_attr = f_attr[F_LIT_STANDARD];
+ SYMBOL_CODE s_char = f_char[F_LIT_STANDARD];
int i;
if (is_ascii_graphics(s_attr)) /* For ASCII */
* 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
+ * in "grid_array.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
* "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
*/
-void map_info(POSITION y, POSITION x, byte *ap, char *cp, byte *tap, char *tcp)
+void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLOR *tap, SYMBOL_CODE *tcp)
{
- /* Get the cave */
- cave_type *c_ptr = &cave[y][x];
+ /* Get the grid_array */
+ grid_type *g_ptr = &grid_array[y][x];
- s16b this_o_idx, next_o_idx = 0;
+ OBJECT_IDX this_o_idx, next_o_idx = 0;
/* Feature code (applying "mimic" field) */
- s16b feat = get_feat_mimic(c_ptr);
+ FEAT_IDX feat = get_feat_mimic(g_ptr);
/* Access floor */
feature_type *f_ptr = &f_info[feat];
- byte a;
- byte c;
+ TERM_COLOR a;
+ SYMBOL_CODE c;
/* Boring grids (floors, etc) */
if (!have_flag(f_ptr->flags, FF_REMEMBER))
* - 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))))
+ ((g_ptr->info & (CAVE_MARK | CAVE_LITE | CAVE_MNLT)) ||
+ ((g_ptr->info & CAVE_VIEW) && (((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) || p_ptr->see_nocto))))
{
/* Normal attr/char */
a = f_ptr->x_attr[F_LIT_STANDARD];
}
/* Mega-Hack -- Handle "in-sight" and "darkened" grids */
- else if (darkened_grid(c_ptr))
+ else if (darkened_grid(g_ptr))
{
- /* Unsafe cave grid -- idea borrowed from Unangband */
- feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+ /* Unsafe grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
else if (view_special_lite)
{
/* Handle "torch-lit" grids */
- if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
+ if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
{
/* Torch lite */
if (view_yellow_lite)
}
/* Handle "dark" grids */
- else if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
+ else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
{
/* Use a darkened colour/tile */
a = f_ptr->x_attr[F_LIT_DARK];
}
/* Handle "out-of-sight" grids */
- else if (!(c_ptr->info & CAVE_VIEW))
+ else if (!(g_ptr->info & CAVE_VIEW))
{
/* Special flag */
if (view_bright_lite)
/* Unknown */
else
{
- /* Unsafe cave grid -- idea borrowed from Unangband */
- feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+ /* Unsafe grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
else
{
/* Memorized grids */
- if (c_ptr->info & CAVE_MARK)
+ if (g_ptr->info & CAVE_MARK)
{
/* Normal attr/char */
a = f_ptr->x_attr[F_LIT_STANDARD];
}
/* Mega-Hack -- Handle "in-sight" and "darkened" grids */
- else if (darkened_grid(c_ptr) && !p_ptr->blind)
+ else if (darkened_grid(g_ptr) && !p_ptr->blind)
{
if (have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT))
{
- /* Unsafe cave grid -- idea borrowed from Unangband */
- feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+ /* Unsafe grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
}
/* Handle "torch-lit" grids */
- else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
+ else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
{
/* Torch lite */
if (view_yellow_lite)
else if (view_bright_lite)
{
/* Not viewable */
- if (!(c_ptr->info & CAVE_VIEW))
+ if (!(g_ptr->info & CAVE_VIEW))
{
/* Use a darkened colour/tile */
a = f_ptr->x_attr[F_LIT_DARK];
}
/* Not glowing */
- else if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
+ else if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
{
/* Use a darkened colour/tile */
a = f_ptr->x_attr[F_LIT_DARK];
/* Unknown */
else
{
- /* Unsafe cave grid -- idea borrowed from Unangband */
- feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
+ /* Unsafe grid -- idea borrowed from Unangband */
+ feat = (view_unsafe_grids && (g_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access feature */
f_ptr = &f_info[feat];
}
/* Objects */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+ for (this_o_idx = g_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 */
/* Hack -- hallucination */
if (p_ptr->image) image_object(ap, cp);
- /* Done */
break;
}
}
/* Handle monsters */
- if (c_ptr->m_idx && display_autopick == 0 )
+ if (g_ptr->m_idx && display_autopick == 0 )
{
- monster_type *m_ptr = &m_list[c_ptr->m_idx];
+ monster_type *m_ptr = &m_list[g_ptr->m_idx];
/* Visible monster */
if (m_ptr->ml)
else if ((r_ptr->flags1 & RF1_ATTR_SEMIRAND) && !use_graphics)
{
/* Use semi-random attr (usually mimics' colors vary) */
- *ap = c_ptr->m_idx % 15 + 1;
+ *ap = g_ptr->m_idx % 15 + 1;
}
else
{
if (player_bold(y, x))
{
monster_race *r_ptr = &r_info[0];
-
- /* Get the "player" attr */
*ap = r_ptr->x_attr;
-
- /* Get the "player" char */
*cp = r_ptr->x_char;
-
feat_priority = 31;
}
}
/*
* Place an attr/char pair at the given map coordinate, if legal.
*/
-void print_rel(char c, byte a, int y, int x)
+void print_rel(SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x)
{
/* Only do "legal" locations */
if (panel_contains(y, x))
if (!use_graphics)
{
if (world_monster) a = TERM_DARK;
- else if (IS_INVULN() || world_player) a = TERM_WHITE;
+ else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
* optimized primarily for the most common cases, that is, for the
* non-marked floor grids.
*/
-void note_spot(int y, int x)
+void note_spot(POSITION y, POSITION x)
{
- cave_type *c_ptr = &cave[y][x];
-
- s16b this_o_idx, next_o_idx = 0;
-
+ grid_type *g_ptr = &grid_array[y][x];
+ OBJECT_IDX this_o_idx, next_o_idx = 0;
/* Blind players see nothing */
if (p_ptr->blind) return;
/* Analyze non-torch-lit grids */
- if (!(c_ptr->info & (CAVE_LITE | CAVE_MNLT)))
+ if (!(g_ptr->info & (CAVE_LITE | CAVE_MNLT)))
{
/* Require line of sight to the grid */
- if (!(c_ptr->info & (CAVE_VIEW))) return;
+ if (!(g_ptr->info & (CAVE_VIEW))) return;
/* Require "perma-lite" of the grid */
- if ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
+ if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
{
/* Not Ninja */
if (!p_ptr->see_nocto) return;
/* Hack -- memorize objects */
- for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+ for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
{
object_type *o_ptr = &o_list[this_o_idx];
/* Hack -- memorize grids */
- if (!(c_ptr->info & (CAVE_MARK)))
+ if (!(g_ptr->info & (CAVE_MARK)))
{
/* Feature code (applying "mimic" field) */
- feature_type *f_ptr = &f_info[get_feat_mimic(c_ptr)];
+ feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
/* Memorize some "boring" grids */
if (!have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Option -- memorize all torch-lit floors */
if (view_torch_grids &&
- ((c_ptr->info & (CAVE_LITE | CAVE_MNLT)) || p_ptr->see_nocto))
+ ((g_ptr->info & (CAVE_LITE | CAVE_MNLT)) || p_ptr->see_nocto))
{
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
/* Option -- memorize all perma-lit floors */
- else if (view_perma_grids && ((c_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW))
+ else if (view_perma_grids && ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW))
{
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
}
/* Memorize normal grids */
else if (have_flag(f_ptr->flags, FF_LOS))
{
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
/* Memorize torch-lit walls */
- else if (c_ptr->info & (CAVE_LITE | CAVE_MNLT))
+ else if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
{
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
/* Memorize walls seen by noctovision of Ninja */
else if (p_ptr->see_nocto)
{
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
/* Memorize certain non-torch-lit wall grids */
else if (check_local_illumination(y, x))
{
- /* Memorize */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
}
/* Memorize terrain of the grid */
- c_ptr->info |= (CAVE_KNOWN);
+ g_ptr->info |= (CAVE_KNOWN);
}
void display_dungeon(void)
{
- int x, y;
- byte a;
- char c;
+ TERM_LEN x, y;
+ TERM_COLOR a;
+ SYMBOL_CODE c;
- byte ta = 0;
- char tc = '\0';
+ TERM_COLOR ta = 0;
+ SYMBOL_CODE tc = '\0';
for (x = p_ptr->x - Term->wid / 2 + 1; x <= p_ptr->x + Term->wid / 2; x++)
{
if (!use_graphics)
{
if (world_monster) a = TERM_DARK;
- else if (IS_INVULN() || world_player) a = TERM_WHITE;
+ else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
*
* This function should only be called on "legal" grids
*/
-void lite_spot(int y, int x)
+void lite_spot(POSITION y, POSITION x)
{
/* Redraw if on screen */
if (panel_contains(y, x) && in_bounds2(y, x))
{
- byte a;
- char c;
+ TERM_COLOR a;
+ SYMBOL_CODE c;
- byte ta;
- char tc;
+ TERM_COLOR ta;
+ SYMBOL_CODE tc;
/* Examine the grid */
map_info(y, x, &a, &c, &ta, &tc);
if (!use_graphics)
{
if (world_monster) a = TERM_DARK;
- else if (IS_INVULN() || world_player) a = TERM_WHITE;
+ else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
*/
void prt_map(void)
{
- int x, y;
- int v;
+ POSITION x, y;
+ int v;
/* map bounds */
- s16b xmin, xmax, ymin, ymax;
+ POSITION xmin, xmax, ymin, ymax;
- int wid, hgt;
+ TERM_LEN wid, hgt;
- /* Get size */
Term_get_size(&wid, &hgt);
/* Remove map offset */
/* Scan the columns of row "y" */
for (x = xmin; x <= xmax; x++)
{
- byte a;
- char c;
+ TERM_COLOR a;
+ SYMBOL_CODE c;
- byte ta;
- char tc;
+ TERM_COLOR ta;
+ SYMBOL_CODE tc;
/* Determine what is there */
map_info(y, x, &a, &c, &ta, &tc);
if (!use_graphics)
{
if (world_monster) a = TERM_DARK;
- else if (IS_INVULN() || world_player) a = TERM_WHITE;
+ else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
/*
* print project path
*/
-void prt_path(int y, int x)
+void prt_path(POSITION y, POSITION x)
{
int i;
int path_n;
/* Get projection path */
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);
-
- /* Redraw stuff */
- redraw_stuff();
+ handle_stuff();
/* Draw path */
for (i = 0; i < path_n; i++)
{
- int ny = GRID_Y(path_g[i]);
- int nx = GRID_X(path_g[i]);
- cave_type *c_ptr = &cave[ny][nx];
+ POSITION ny = GRID_Y(path_g[i]);
+ POSITION nx = GRID_X(path_g[i]);
+ grid_type *g_ptr = &grid_array[ny][nx];
if (panel_contains(ny, nx))
{
- byte a = default_color;
+ TERM_COLOR a = default_color;
char c;
- byte ta;
- char tc;
+ TERM_COLOR ta = default_color;
+ char tc = '*';
- if (c_ptr->m_idx && m_list[c_ptr->m_idx].ml)
+ if (g_ptr->m_idx && m_list[g_ptr->m_idx].ml)
{
/* Determine what is there */
map_info(ny, nx, &a, &c, &ta, &tc);
if (!use_graphics)
{
if (world_monster) a = TERM_DARK;
- else if (IS_INVULN() || world_player) a = TERM_WHITE;
+ else if (IS_INVULN() || p_ptr->timewalk) a = TERM_WHITE;
else if (p_ptr->wraith_form) a = TERM_L_DARK;
}
}
/* Known Wall */
- if ((c_ptr->info & CAVE_MARK) && !cave_have_flag_grid(c_ptr, FF_PROJECT)) break;
+ if ((g_ptr->info & CAVE_MARK) && !cave_have_flag_grid(g_ptr, FF_PROJECT)) break;
/* Change color */
if (nx == x && ny == y) default_color = TERM_L_DARK;
}
-static cptr simplify_list[][2] =
+static concptr simplify_list[][2] =
{
#ifdef JP
{"の魔法書", ""},
char buf[MAX_NLEN];
char *c = buf;
int len = 0;
- byte attr;
+ TERM_COLOR attr;
object_desc(buf, o_ptr, (OD_NO_FLAVOR | OD_OMIT_PREFIX | OD_NAME_ONLY));
attr = tval_to_attr[o_ptr->tval % 128];
int i;
for (i = 0; simplify_list[i][1]; i++)
{
- cptr org_w = simplify_list[i][0];
+ concptr org_w = simplify_list[i][0];
if (*org_w == '^')
{
if (!strncmp(c, org_w, strlen(org_w)))
{
char *s = c;
- cptr tmp = simplify_list[i][1];
+ concptr tmp = simplify_list[i][1];
while (*tmp)
*s++ = *tmp++;
tmp = c + strlen(org_w);
{
int i, j, x, y;
- byte ta;
- char tc;
+ TERM_COLOR ta;
+ SYMBOL_CODE tc;
byte tp;
- byte **bigma;
- char **bigmc;
+ TERM_COLOR **bigma;
+ SYMBOL_CODE **bigmc;
byte **bigmp;
- byte **ma;
- char **mc;
+ TERM_COLOR **ma;
+ SYMBOL_CODE **mc;
byte **mp;
/* Save lighting effects */
bool old_view_special_lite = view_special_lite;
bool old_view_granite_lite = view_granite_lite;
- int hgt, wid, yrat, xrat;
+ TERM_LEN hgt, wid, yrat, xrat;
int **match_autopick_yx;
object_type ***object_autopick_yx;
- /* Get size */
Term_get_size(&wid, &hgt);
hgt -= 2;
wid -= 14;
view_granite_lite = FALSE;
/* Allocate the maps */
- C_MAKE(ma, (hgt + 2), byte_ptr);
+ C_MAKE(ma, (hgt + 2), TERM_COLOR *);
C_MAKE(mc, (hgt + 2), char_ptr);
C_MAKE(mp, (hgt + 2), byte_ptr);
C_MAKE(match_autopick_yx, (hgt + 2), sint_ptr);
for (y = 0; y < (hgt + 2); y++)
{
/* Allocate one row each array */
- C_MAKE(ma[y], (wid + 2), byte);
+ C_MAKE(ma[y], (wid + 2), TERM_COLOR);
C_MAKE(mc[y], (wid + 2), char);
C_MAKE(mp[y], (wid + 2), byte);
C_MAKE(match_autopick_yx[y], (wid + 2), int);
}
/* Allocate the maps */
- C_MAKE(bigma, (cur_hgt + 2), byte_ptr);
+ C_MAKE(bigma, (cur_hgt + 2), TERM_COLOR *);
C_MAKE(bigmc, (cur_hgt + 2), char_ptr);
C_MAKE(bigmp, (cur_hgt + 2), byte_ptr);
for (y = 0; y < (cur_hgt + 2); y++)
{
/* Allocate one row each array */
- C_MAKE(bigma[y], (cur_wid + 2), byte);
+ C_MAKE(bigma[y], (cur_wid + 2), TERM_COLOR);
C_MAKE(bigmc[y], (cur_wid + 2), char);
C_MAKE(bigmp[y], (cur_wid + 2), byte);
{
for (j = 0; j < cur_hgt; ++j)
{
- /* Location */
x = i / xrat + 1;
y = j / yrat + 1;
{
for (i = 0; i < cur_wid; ++i)
{
- /* Location */
x = i / xrat + 1;
y = j / yrat + 1;
if (!use_graphics)
{
if (world_monster) ta = TERM_DARK;
- else if (IS_INVULN() || world_player) ta = TERM_WHITE;
+ else if (IS_INVULN() || p_ptr->timewalk) ta = TERM_WHITE;
else if (p_ptr->wraith_form) ta = TERM_L_DARK;
}
for (y = 0; y < (hgt + 2); y++)
{
/* Free one row each array */
- C_KILL(ma[y], (wid + 2), byte);
- C_KILL(mc[y], (wid + 2), char);
+ C_KILL(ma[y], (wid + 2), TERM_COLOR);
+ C_KILL(mc[y], (wid + 2), SYMBOL_CODE);
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_KILL(ma, (hgt + 2), byte_ptr);
+ C_KILL(ma, (hgt + 2), TERM_COLOR *);
C_KILL(mc, (hgt + 2), char_ptr);
C_KILL(mp, (hgt + 2), byte_ptr);
C_KILL(match_autopick_yx, (hgt + 2), sint_ptr);
for (y = 0; y < (cur_hgt + 2); y++)
{
/* Free one row each array */
- C_KILL(bigma[y], (cur_wid + 2), byte);
- C_KILL(bigmc[y], (cur_wid + 2), char);
+ C_KILL(bigma[y], (cur_wid + 2), TERM_COLOR);
+ C_KILL(bigmc[y], (cur_wid + 2), SYMBOL_CODE);
C_KILL(bigmp[y], (cur_wid + 2), byte);
}
/* Free each line map */
- C_KILL(bigma, (cur_hgt + 2), byte_ptr);
+ C_KILL(bigma, (cur_hgt + 2), TERM_COLOR *);
C_KILL(bigmc, (cur_hgt + 2), char_ptr);
C_KILL(bigmp, (cur_hgt + 2), byte_ptr);
}
/*
* Display a "small-scale" map of the dungeon for the player
*
- * Currently, the "player" is displayed on the map. XXX XXX XXX
+ * Currently, the "player" is displayed on the map.
*/
void do_cmd_view_map(void)
{
int cy, cx;
-
- /* Save the screen */
screen_save();
- /* Note */
prt(_("お待ち下さい...", "Please wait..."), 0, 0);
- /* Flush */
Term_fresh();
-
- /* Clear the screen */
Term_clear();
display_autopick = 0;
/* Get any key */
inkey();
}
-
- /* Restore the screen */
screen_load();
}
/*
- * Some comments on the cave grid flags. -BEN-
+ * Some comments on the grid flags. -BEN-
*
*
* One of the major bottlenecks in previous versions of Angband was in
x = lite_x[i];
/* Forget "LITE" flag */
- cave[y][x].info &= ~(CAVE_LITE);
+ grid_array[y][x].info &= ~(CAVE_LITE);
- /* Redraw */
/* lite_spot(y, x); Perhaps don't need? */
}
/*
- * XXX XXX XXX
- *
* This macro allows us to efficiently add a grid to the "lite" array,
* note that we are never called for illegal grids, or for grids which
* have already been placed into the "lite" array, and we are never
*/
#define cave_lite_hack(Y,X) \
{\
- if (!(cave[Y][X].info & (CAVE_LITE))) \
+ if (!(grid_array[Y][X].info & (CAVE_LITE))) \
{ \
- cave[Y][X].info |= (CAVE_LITE); \
+ grid_array[Y][X].info |= (CAVE_LITE); \
lite_y[lite_n] = (Y); \
lite_x[lite_n++] = (X); \
} \
*/
void update_lite(void)
{
- int i, x, y, min_x, max_x, min_y, max_y;
+ int i;
+ POSITION x, y, min_x, max_x, min_y, max_y;
int p = p_ptr->cur_lite;
- cave_type *c_ptr;
+ grid_type *g_ptr;
/*** Special case ***/
/* forget_lite(); Perhaps don't need? */
/* Add it to later visual update */
- cave_redraw_later(&cave[p_ptr->y][p_ptr->x], p_ptr->y, p_ptr->x);
+ cave_redraw_later(&grid_array[p_ptr->y][p_ptr->x], p_ptr->y, p_ptr->x);
}
#endif
x = lite_x[i];
/* Mark the grid as not "lite" */
- cave[y][x].info &= ~(CAVE_LITE);
+ grid_array[y][x].info &= ~(CAVE_LITE);
/* Mark the grid as "seen" */
- cave[y][x].info |= (CAVE_TEMP);
+ grid_array[y][x].info |= (CAVE_TEMP);
/* Add it to the "seen" set */
temp_y[temp_n] = y;
if (d > p) continue;
/* Viewable, nearby, grids get "torch lit" */
- if (cave[y][x].info & CAVE_VIEW)
+ if (grid_array[y][x].info & CAVE_VIEW)
{
/* This grid is "torch lit" */
cave_lite_hack(y, x);
y = lite_y[i];
x = lite_x[i];
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Update fresh grids */
- if (c_ptr->info & (CAVE_TEMP)) continue;
+ if (g_ptr->info & (CAVE_TEMP)) continue;
/* Add it to later visual update */
- cave_note_and_redraw_later(c_ptr, y, x);
+ cave_note_and_redraw_later(g_ptr, y, x);
}
/* Clear them all */
y = temp_y[i];
x = temp_x[i];
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* No longer in the array */
- c_ptr->info &= ~(CAVE_TEMP);
+ g_ptr->info &= ~(CAVE_TEMP);
/* Update stale grids */
- if (c_ptr->info & (CAVE_LITE)) continue;
+ if (g_ptr->info & (CAVE_LITE)) continue;
/* Add it to later visual update */
- cave_redraw_later(c_ptr, y, x);
+ cave_redraw_later(g_ptr, y, x);
}
/* None left */
*/
static void mon_lite_hack(POSITION y, POSITION x)
{
- cave_type *c_ptr;
+ grid_type *g_ptr;
int dpf, d;
POSITION midpoint;
/* We trust this grid is in bounds */
/* if (!in_bounds2(y, x)) return; */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Want a unlit square in view of the player */
- if ((c_ptr->info & (CAVE_MNLT | CAVE_VIEW)) != CAVE_VIEW) return;
+ if ((g_ptr->info & (CAVE_MNLT | CAVE_VIEW)) != CAVE_VIEW) return;
- if (!cave_los_grid(c_ptr))
+ if (!cave_los_grid(g_ptr))
{
/* Hack -- Prevent monster lite leakage in walls */
/* We trust temp_n does not exceed TEMP_MAX */
/* New grid */
- if (!(c_ptr->info & CAVE_MNDK))
+ if (!(g_ptr->info & CAVE_MNDK))
{
/* Save this square */
temp_x[temp_n] = x;
else
{
/* No longer dark */
- c_ptr->info &= ~(CAVE_MNDK);
+ g_ptr->info &= ~(CAVE_MNDK);
}
/* Light it */
- c_ptr->info |= CAVE_MNLT;
+ g_ptr->info |= CAVE_MNLT;
}
*/
static void mon_dark_hack(POSITION y, POSITION x)
{
- cave_type *c_ptr;
+ grid_type *g_ptr;
int midpoint, dpf, d;
/* We trust this grid is in bounds */
/* if (!in_bounds2(y, x)) return; */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Want a unlit and undarkened square in view of the player */
- if ((c_ptr->info & (CAVE_LITE | CAVE_MNLT | CAVE_MNDK | CAVE_VIEW)) != CAVE_VIEW) return;
+ if ((g_ptr->info & (CAVE_LITE | CAVE_MNLT | CAVE_MNDK | CAVE_VIEW)) != CAVE_VIEW) return;
- if (!cave_los_grid(c_ptr) && !cave_have_flag_grid(c_ptr, FF_PROJECT))
+ if (!cave_los_grid(g_ptr) && !cave_have_flag_grid(g_ptr, FF_PROJECT))
{
/* Hack -- Prevent monster dark lite leakage in walls */
temp_n++;
/* Darken it */
- c_ptr->info |= CAVE_MNDK;
+ g_ptr->info |= CAVE_MNDK;
}
void update_mon_lite(void)
{
int i, rad;
- cave_type *c_ptr;
+ grid_type *g_ptr;
POSITION fx, fy;
void (*add_mon_lite)(POSITION, POSITION);
s16b end_temp;
/* Non-Ninja player in the darkness */
- int dis_lim = ((d_info[dungeon_type].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto) ?
+ int dis_lim = ((d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !p_ptr->see_nocto) ?
(MAX_SIGHT / 2 + 1) : (MAX_SIGHT + 3);
/* Clear all monster lit squares */
for (i = 0; i < mon_lite_n; i++)
{
/* Point to grid */
- c_ptr = &cave[mon_lite_y[i]][mon_lite_x[i]];
+ g_ptr = &grid_array[mon_lite_y[i]][mon_lite_x[i]];
/* Set temp or xtra flag */
- c_ptr->info |= (c_ptr->info & CAVE_MNLT) ? CAVE_TEMP : CAVE_XTRA;
+ g_ptr->info |= (g_ptr->info & CAVE_MNLT) ? CAVE_TEMP : CAVE_XTRA;
/* Clear monster illumination flag */
- c_ptr->info &= ~(CAVE_MNLT | CAVE_MNDK);
+ g_ptr->info &= ~(CAVE_MNLT | CAVE_MNDK);
}
/* Empty temp list of new squares to lite up */
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;
+ if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) rad = 1;
add_mon_lite = mon_lite_hack;
f_flag = FF_LOS;
}
mon_fy = m_ptr->fy;
/* Is the monster visible? */
- mon_invis = !(cave[mon_fy][mon_fx].info & CAVE_VIEW);
+ mon_invis = !(grid_array[mon_fy][mon_fx].info & CAVE_VIEW);
/* The square it is on */
add_mon_lite(mon_fy, mon_fx);
add_mon_lite(mon_fy + 2, mon_fx);
add_mon_lite(mon_fy + 2, mon_fx - 1);
- c_ptr = &cave[mon_fy + 2][mon_fx];
+ g_ptr = &grid_array[mon_fy + 2][mon_fx];
/* Radius 3 */
- if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
+ if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
{
add_mon_lite(mon_fy + 3, mon_fx + 1);
add_mon_lite(mon_fy + 3, mon_fx);
add_mon_lite(mon_fy - 2, mon_fx);
add_mon_lite(mon_fy - 2, mon_fx - 1);
- c_ptr = &cave[mon_fy - 2][mon_fx];
+ g_ptr = &grid_array[mon_fy - 2][mon_fx];
/* Radius 3 */
- if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
+ if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
{
add_mon_lite(mon_fy - 3, mon_fx + 1);
add_mon_lite(mon_fy - 3, mon_fx);
add_mon_lite(mon_fy, mon_fx + 2);
add_mon_lite(mon_fy - 1, mon_fx + 2);
- c_ptr = &cave[mon_fy][mon_fx + 2];
+ g_ptr = &grid_array[mon_fy][mon_fx + 2];
/* Radius 3 */
- if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
+ if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
{
add_mon_lite(mon_fy + 1, mon_fx + 3);
add_mon_lite(mon_fy, mon_fx + 3);
add_mon_lite(mon_fy, mon_fx - 2);
add_mon_lite(mon_fy - 1, mon_fx - 2);
- c_ptr = &cave[mon_fy][mon_fx - 2];
+ g_ptr = &grid_array[mon_fy][mon_fx - 2];
/* Radius 3 */
- if ((rad == 3) && cave_have_flag_grid(c_ptr, f_flag))
+ if ((rad == 3) && cave_have_flag_grid(g_ptr, f_flag))
{
add_mon_lite(mon_fy + 1, mon_fx - 3);
add_mon_lite(mon_fy, mon_fx - 3);
/* We trust this grid is in bounds */
/* Point to grid */
- c_ptr = &cave[fy][fx];
+ g_ptr = &grid_array[fy][fx];
- if (c_ptr->info & CAVE_TEMP) /* Pervious lit */
+ if (g_ptr->info & CAVE_TEMP) /* Pervious lit */
{
/* It it no longer lit? */
- if ((c_ptr->info & (CAVE_VIEW | CAVE_MNLT)) == CAVE_VIEW)
+ if ((g_ptr->info & (CAVE_VIEW | CAVE_MNLT)) == CAVE_VIEW)
{
/* It is now unlit */
/* Add it to later visual update */
- cave_note_and_redraw_later(c_ptr, fy, fx);
+ cave_note_and_redraw_later(g_ptr, fy, fx);
}
}
else /* Pervious darkened */
{
/* It it no longer darken? */
- if ((c_ptr->info & (CAVE_VIEW | CAVE_MNDK)) == CAVE_VIEW)
+ if ((g_ptr->info & (CAVE_VIEW | CAVE_MNDK)) == CAVE_VIEW)
{
/* It is now undarken */
/* Add it to later visual update */
- cave_note_and_redraw_later(c_ptr, fy, fx);
+ cave_note_and_redraw_later(g_ptr, fy, fx);
}
}
/* We trust this grid is in bounds */
/* Point to grid */
- c_ptr = &cave[fy][fx];
+ g_ptr = &grid_array[fy][fx];
- if (c_ptr->info & CAVE_MNLT) /* Lit */
+ if (g_ptr->info & CAVE_MNLT) /* Lit */
{
/* The is the square newly lit and visible? */
- if ((c_ptr->info & (CAVE_VIEW | CAVE_TEMP)) == CAVE_VIEW)
+ if ((g_ptr->info & (CAVE_VIEW | CAVE_TEMP)) == CAVE_VIEW)
{
/* It is now lit */
/* Add it to later visual update */
- cave_note_and_redraw_later(c_ptr, fy, fx);
+ cave_note_and_redraw_later(g_ptr, fy, fx);
}
}
else /* Darkened */
{
/* The is the square newly darkened and visible? */
- if ((c_ptr->info & (CAVE_VIEW | CAVE_XTRA)) == CAVE_VIEW)
+ if ((g_ptr->info & (CAVE_VIEW | CAVE_XTRA)) == CAVE_VIEW)
{
/* It is now darkened */
/* Add it to later visual update */
- cave_note_and_redraw_later(c_ptr, fy, fx);
+ cave_note_and_redraw_later(g_ptr, fy, fx);
}
}
{
/* We trust this grid is in bounds */
- cave[temp_y[i]][temp_x[i]].info &= ~(CAVE_TEMP | CAVE_XTRA);
+ grid_array[temp_y[i]][temp_x[i]].info &= ~(CAVE_TEMP | CAVE_XTRA);
}
/* Finished with temp_n */
/* Mega-Hack -- Visual update later */
p_ptr->update |= (PU_DELAY_VIS);
- p_ptr->monlite = (cave[p_ptr->y][p_ptr->x].info & CAVE_MNLT) ? TRUE : FALSE;
+ p_ptr->monlite = (grid_array[p_ptr->y][p_ptr->x].info & CAVE_MNLT) ? TRUE : FALSE;
if (p_ptr->special_defense & NINJA_S_STEALTH)
{
void clear_mon_lite(void)
{
int i;
- cave_type *c_ptr;
+ grid_type *g_ptr;
/* Clear all monster lit squares */
for (i = 0; i < mon_lite_n; i++)
{
/* Point to grid */
- c_ptr = &cave[mon_lite_y[i]][mon_lite_x[i]];
+ g_ptr = &grid_array[mon_lite_y[i]][mon_lite_x[i]];
/* Clear monster illumination flag */
- c_ptr->info &= ~(CAVE_MNLT | CAVE_MNDK);
+ g_ptr->info &= ~(CAVE_MNLT | CAVE_MNDK);
}
/* Empty the array */
{
int i;
- cave_type *c_ptr;
+ grid_type *g_ptr;
/* None to forget */
if (!view_n) return;
/* Clear them all */
for (i = 0; i < view_n; i++)
{
- int y = view_y[i];
- int x = view_x[i];
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ POSITION y = view_y[i];
+ POSITION x = view_x[i];
+ g_ptr = &grid_array[y][x];
/* Forget that the grid is viewable */
- c_ptr->info &= ~(CAVE_VIEW);
+ g_ptr->info &= ~(CAVE_VIEW);
/* if (!panel_contains(y, x)) continue; */
*
* This function now returns "TRUE" if vision is "blocked" by grid (y,x).
*/
-static bool update_view_aux(int y, int x, int y1, int x1, int y2, int x2)
+static bool update_view_aux(POSITION y, POSITION x, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
{
bool f1, f2, v1, v2, z1, z2, wall;
- cave_type *c_ptr;
+ grid_type *g_ptr;
- cave_type *g1_c_ptr;
- cave_type *g2_c_ptr;
+ grid_type *g1_c_ptr;
+ grid_type *g2_c_ptr;
/* Access the grids */
- g1_c_ptr = &cave[y1][x1];
- g2_c_ptr = &cave[y2][x2];
+ g1_c_ptr = &grid_array[y1][x1];
+ g2_c_ptr = &grid_array[y2][x2];
/* Check for walls */
/* Totally blocked by "unviewable neighbors" */
if (!v1 && !v2) return (TRUE);
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Check for walls */
- wall = (!cave_los_grid(c_ptr));
+ wall = (!cave_los_grid(g_ptr));
/* Check the "ease" of visibility */
/* Hack -- "easy" plus "easy" yields "easy" */
if (z1 && z2)
{
- c_ptr->info |= (CAVE_XTRA);
+ g_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y, x);
+ cave_view_hack(g_ptr, y, x);
return (wall);
}
/* Hack -- primary "easy" yields "viewed" */
if (z1)
{
- cave_view_hack(c_ptr, y, x);
+ cave_view_hack(g_ptr, y, x);
return (wall);
}
/* Hack -- "view" plus "view" yields "view" */
if (v1 && v2)
{
- /* c_ptr->info |= (CAVE_XTRA); */
+ /* g_ptr->info |= (CAVE_XTRA); */
- cave_view_hack(c_ptr, y, x);
+ cave_view_hack(g_ptr, y, x);
return (wall);
}
/* Mega-Hack -- the "los()" function works poorly on walls */
if (wall)
{
- cave_view_hack(c_ptr, y, x);
+ cave_view_hack(g_ptr, y, x);
return (wall);
}
/* Hack -- check line of sight */
if (los(p_ptr->y, p_ptr->x, y, x))
{
- cave_view_hack(c_ptr, y, x);
+ cave_view_hack(g_ptr, y, x);
return (wall);
}
*
* 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
+ * a 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
- * the cave grid. See above.
+ * the grid. See above.
*
* By the way, the purpose of this code is to reduce the dependancy on the
* "los()" function which is slow, and, in some cases, not very accurate.
POSITION y_max = cur_hgt - 1;
POSITION x_max = cur_wid - 1;
- cave_type *c_ptr;
+ grid_type *g_ptr;
/*** Initialize ***/
{
y = view_y[n];
x = view_x[n];
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Mark the grid as not in "view" */
- c_ptr->info &= ~(CAVE_VIEW);
+ g_ptr->info &= ~(CAVE_VIEW);
/* Mark the grid as "seen" */
- c_ptr->info |= (CAVE_TEMP);
+ g_ptr->info |= (CAVE_TEMP);
/* Add it to the "seen" set */
temp_y[temp_n] = y;
/* Now start on the player */
y = p_ptr->y;
x = p_ptr->x;
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Assume the player grid is easily viewable */
- c_ptr->info |= (CAVE_XTRA);
+ g_ptr->info |= (CAVE_XTRA);
/* Assume the player grid is viewable */
- cave_view_hack(c_ptr, y, x);
+ cave_view_hack(g_ptr, y, x);
/*** Step 2 -- Major Diagonals ***/
/* Scan south-east */
for (d = 1; d <= z; d++)
{
- c_ptr = &cave[y+d][x+d];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y+d, x+d);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y+d][x+d];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y+d, x+d);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Scan south-west */
for (d = 1; d <= z; d++)
{
- c_ptr = &cave[y+d][x-d];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y+d, x-d);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y+d][x-d];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y+d, x-d);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Scan north-east */
for (d = 1; d <= z; d++)
{
- c_ptr = &cave[y-d][x+d];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y-d, x+d);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y-d][x+d];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y-d, x+d);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Scan north-west */
for (d = 1; d <= z; d++)
{
- c_ptr = &cave[y-d][x-d];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y-d, x-d);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y-d][x-d];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y-d, x-d);
+ if (!cave_los_grid(g_ptr)) break;
}
-
/*** Step 3 -- major axes ***/
/* Scan south */
for (d = 1; d <= full; d++)
{
- c_ptr = &cave[y+d][x];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y+d, x);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y+d][x];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y+d, x);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Initialize the "south strips" */
/* Scan north */
for (d = 1; d <= full; d++)
{
- c_ptr = &cave[y-d][x];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y-d, x);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y-d][x];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y-d, x);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Initialize the "north strips" */
/* Scan east */
for (d = 1; d <= full; d++)
{
- c_ptr = &cave[y][x+d];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y, x+d);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y][x+d];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y, x+d);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Initialize the "east strips" */
/* Scan west */
for (d = 1; d <= full; d++)
{
- c_ptr = &cave[y][x-d];
- c_ptr->info |= (CAVE_XTRA);
- cave_view_hack(c_ptr, y, x-d);
- if (!cave_los_grid(c_ptr)) break;
+ g_ptr = &grid_array[y][x-d];
+ g_ptr->info |= (CAVE_XTRA);
+ cave_view_hack(g_ptr, y, x-d);
+ if (!cave_los_grid(g_ptr)) break;
}
/* Initialize the "west strips" */
/* Now check each "diagonal" (in parallel) */
for (n = 1; n <= over / 2; n++)
{
- int ypn, ymn, xpn, xmn;
-
+ POSITION ypn, ymn, xpn, xmn;
/* Acquire the "bounds" of the maximal circle */
z = over - n - n;
{
y = view_y[n];
x = view_x[n];
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Clear the "CAVE_XTRA" flag */
- c_ptr->info &= ~(CAVE_XTRA);
+ g_ptr->info &= ~(CAVE_XTRA);
/* Update only newly viewed grids */
- if (c_ptr->info & (CAVE_TEMP)) continue;
+ if (g_ptr->info & (CAVE_TEMP)) continue;
/* Add it to later visual update */
- cave_note_and_redraw_later(c_ptr, y, x);
+ cave_note_and_redraw_later(g_ptr, y, x);
}
/* Wipe the old grids, update as needed */
{
y = temp_y[n];
x = temp_x[n];
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* No longer in the array */
- c_ptr->info &= ~(CAVE_TEMP);
+ g_ptr->info &= ~(CAVE_TEMP);
/* Update only non-viewable grids */
- if (c_ptr->info & (CAVE_VIEW)) continue;
+ if (g_ptr->info & (CAVE_VIEW)) continue;
/* Add it to later visual update */
- cave_redraw_later(c_ptr, y, x);
+ cave_redraw_later(g_ptr, y, x);
}
/* None left */
*/
void delayed_visual_update(void)
{
- int i, y, x;
- cave_type *c_ptr;
+ int i;
+ POSITION y, x;
+ grid_type *g_ptr;
/* Update needed grids */
for (i = 0; i < redraw_n; i++)
{
y = redraw_y[i];
x = redraw_x[i];
-
- /* Access the grid */
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Update only needed grids (prevent multiple updating) */
- if (!(c_ptr->info & CAVE_REDRAW)) continue;
+ if (!(g_ptr->info & CAVE_REDRAW)) continue;
/* If required, note */
- if (c_ptr->info & CAVE_NOTE) note_spot(y, x);
+ if (g_ptr->info & CAVE_NOTE) note_spot(y, x);
- /* Redraw */
lite_spot(y, x);
/* Hack -- Visual update of monster on this grid */
- if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+ if (g_ptr->m_idx) update_monster(g_ptr->m_idx, FALSE);
/* No longer in the array */
- c_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
+ g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
}
/* None left */
*/
void forget_flow(void)
{
- int x, y;
+ POSITION x, y;
/* Check the entire dungeon */
for (y = 0; y < cur_hgt; y++)
for (x = 0; x < cur_wid; x++)
{
/* Forget the old data */
- cave[y][x].dist = 0;
- cave[y][x].cost = 0;
- cave[y][x].when = 0;
+ grid_array[y][x].dist = 0;
+ grid_array[y][x].cost = 0;
+ grid_array[y][x].when = 0;
}
}
}
*/
void update_flow(void)
{
- POSITION x, y, d;
+ POSITION x, y;
+ DIRECTION d;
int flow_head = 1;
int flow_tail = 0;
if (running && in_bounds(flow_y, flow_x))
{
/* The way point is in sight - do not update. (Speedup) */
- if (cave[flow_y][flow_x].info & CAVE_VIEW) return;
+ if (grid_array[flow_y][flow_x].info & CAVE_VIEW) return;
}
/* Erase all of the current flow information */
{
for (x = 0; x < cur_wid; x++)
{
- cave[y][x].cost = 0;
- cave[y][x].dist = 0;
+ grid_array[y][x].cost = 0;
+ grid_array[y][x].dist = 0;
}
}
for (d = 0; d < 8; d++)
{
int old_head = flow_head;
- byte_hack m = cave[ty][tx].cost + 1;
- byte_hack n = cave[ty][tx].dist + 1;
- cave_type *c_ptr;
+ byte_hack m = grid_array[ty][tx].cost + 1;
+ byte_hack n = grid_array[ty][tx].dist + 1;
+ grid_type *g_ptr;
/* Child location */
y = ty + ddy_ddd[d];
/* Ignore player's grid */
if (player_bold(y, x)) continue;
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
- if (is_closed_door(c_ptr->feat)) m += 3;
+ if (is_closed_door(g_ptr->feat)) m += 3;
/* Ignore "pre-stamped" entries */
- if (c_ptr->dist != 0 && c_ptr->dist <= n && c_ptr->cost <= m) continue;
+ if (g_ptr->dist != 0 && g_ptr->dist <= n && g_ptr->cost <= m) continue;
/* Ignore "walls" and "rubble" */
- if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !is_closed_door(c_ptr->feat)) continue;
+ if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !is_closed_door(g_ptr->feat)) continue;
/* Save the flow cost */
- if (c_ptr->cost == 0 || c_ptr->cost > m) c_ptr->cost = m;
- if (c_ptr->dist == 0 || c_ptr->dist > n) c_ptr->dist = n;
+ if (g_ptr->cost == 0 || g_ptr->cost > m) g_ptr->cost = m;
+ if (g_ptr->dist == 0 || g_ptr->dist > n) g_ptr->dist = n;
/* Hack -- limit flow depth */
if (n == MONSTER_FLOW_DEPTH) continue;
*/
void update_smell(void)
{
- int i, j;
- int y, x;
+ POSITION i, j;
+ POSITION y, x;
/* Create a table that controls the spread of scent */
const int scent_adjust[5][5] =
{
for (x = 0; x < cur_wid; x++)
{
- int w = cave[y][x].when;
- cave[y][x].when = (w > 128) ? (w - 128) : 0;
+ int w = grid_array[y][x].when;
+ grid_array[y][x].when = (w > 128) ? (w - 128) : 0;
}
}
{
for (j = 0; j < 5; j++)
{
- cave_type *c_ptr;
+ grid_type *g_ptr;
/* Translate table to map grids */
y = i + p_ptr->y - 2;
/* Check Bounds */
if (!in_bounds(y, x)) continue;
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Walls, water, and lava cannot hold scent. */
- if (!cave_have_flag_grid(c_ptr, FF_MOVE) && !is_closed_door(c_ptr->feat)) continue;
+ if (!cave_have_flag_grid(g_ptr, FF_MOVE) && !is_closed_door(g_ptr->feat)) continue;
/* Grid must not be blocked by walls from the character */
if (!player_has_los_bold(y, x)) continue;
if (scent_adjust[i][j] == -1) continue;
/* Mark the grid with new scent */
- c_ptr->when = scent_when + scent_adjust[i][j];
+ g_ptr->when = scent_when + scent_adjust[i][j];
}
}
}
*/
void map_area(POSITION range)
{
- int i, x, y;
- cave_type *c_ptr;
- s16b feat;
- feature_type *f_ptr;
+ int i;
+ POSITION x, y;
+ grid_type *g_ptr;
+ FEAT_IDX feat;
+ feature_type *f_ptr;
- if (d_info[dungeon_type].flags1 & DF1_DARKNESS) range /= 3;
+ if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) range /= 3;
/* Scan that area */
for (y = 1; y < cur_hgt - 1; y++)
{
if (distance(p_ptr->y, p_ptr->x, y, x) > range) continue;
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Memorize terrain of the grid */
- c_ptr->info |= (CAVE_KNOWN);
+ g_ptr->info |= (CAVE_KNOWN);
/* Feature code (applying "mimic" field) */
- feat = get_feat_mimic(c_ptr);
+ feat = get_feat_mimic(g_ptr);
f_ptr = &f_info[feat];
/* All non-walls are "checked" */
if (have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Memorize the object */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
/* Memorize known walls */
for (i = 0; i < 8; i++)
{
- c_ptr = &cave[y + ddy_ddd[i]][x + ddx_ddd[i]];
+ g_ptr = &grid_array[y + ddy_ddd[i]][x + ddx_ddd[i]];
/* Feature code (applying "mimic" field) */
- feat = get_feat_mimic(c_ptr);
+ feat = get_feat_mimic(g_ptr);
f_ptr = &f_info[feat];
/* Memorize walls (etc) */
if (have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Memorize the walls */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
}
}
}
}
- /* Redraw map */
p_ptr->redraw |= (PR_MAP);
- /* Window stuff */
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
}
*/
void wiz_lite(bool ninja)
{
- int i, y, x;
- s16b feat;
+ OBJECT_IDX i;
+ POSITION y, x;
+ FEAT_IDX feat;
feature_type *f_ptr;
/* Memorize objects */
/* Scan all normal grids */
for (x = 1; x < cur_wid - 1; x++)
{
- cave_type *c_ptr = &cave[y][x];
+ grid_type *g_ptr = &grid_array[y][x];
/* Memorize terrain of the grid */
- c_ptr->info |= (CAVE_KNOWN);
+ g_ptr->info |= (CAVE_KNOWN);
/* Feature code (applying "mimic" field) */
- feat = get_feat_mimic(c_ptr);
+ feat = get_feat_mimic(g_ptr);
f_ptr = &f_info[feat];
/* Process all non-walls */
/* Scan all neighbors */
for (i = 0; i < 9; i++)
{
- int yy = y + ddy_ddd[i];
- int xx = x + ddx_ddd[i];
-
- /* Get the grid */
- c_ptr = &cave[yy][xx];
+ POSITION yy = y + ddy_ddd[i];
+ POSITION xx = x + ddx_ddd[i];
+ g_ptr = &grid_array[yy][xx];
/* Feature code (applying "mimic" field) */
- f_ptr = &f_info[get_feat_mimic(c_ptr)];
+ f_ptr = &f_info[get_feat_mimic(g_ptr)];
/* Perma-lite the grid */
- if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS) && !ninja)
+ if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) && !ninja)
{
- c_ptr->info |= (CAVE_GLOW);
+ g_ptr->info |= (CAVE_GLOW);
}
/* Memorize normal features */
if (have_flag(f_ptr->flags, FF_REMEMBER))
{
/* Memorize the grid */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
/* Perma-lit grids (newly and previously) */
- else if (c_ptr->info & CAVE_GLOW)
+ else if (g_ptr->info & CAVE_GLOW)
{
/* Normally, memorize floors (see above) */
if (view_perma_grids && !view_torch_grids)
{
/* Memorize the grid */
- c_ptr->info |= (CAVE_MARK);
+ g_ptr->info |= (CAVE_MARK);
}
}
}
}
}
- /* Update the monsters */
p_ptr->update |= (PU_MONSTERS);
-
- /* Redraw map */
p_ptr->redraw |= (PR_MAP);
-
- /* 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);
+ if (grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
}
}
*/
void wiz_dark(void)
{
- int i, y, x;
-
+ OBJECT_IDX i;
+ POSITION y, x;
/* Forget every grid */
for (y = 1; y < cur_hgt - 1; y++)
{
for (x = 1; x < cur_wid - 1; x++)
{
- cave_type *c_ptr = &cave[y][x];
+ grid_type *g_ptr = &grid_array[y][x];
/* Process the grid */
- c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
- c_ptr->info |= (CAVE_UNSAFE);
+ g_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
+ g_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);
+ grid_array[0][x].info &= ~(CAVE_MARK);
+ grid_array[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);
+ grid_array[y][0].info &= ~(CAVE_MARK);
+ grid_array[y][cur_wid - 1].info &= ~(CAVE_MARK);
}
/* Forget all objects */
/* 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);
-
- /* Update the view and lite */
p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
-
- /* Update the monsters */
p_ptr->update |= (PU_MONSTERS);
-
- /* Redraw map */
p_ptr->redraw |= (PR_MAP);
-
- /* Window stuff */
p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
}
-
-
-
-
/*
* Change the "feat" flag for a grid, and notice/redraw the grid
*/
-void cave_set_feat(POSITION y, POSITION x, IDX feat)
+void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat)
{
- cave_type *c_ptr = &cave[y][x];
+ grid_type *g_ptr = &grid_array[y][x];
feature_type *f_ptr = &f_info[feat];
bool old_los, old_mirror;
if (!character_dungeon)
{
/* Clear mimic type */
- c_ptr->mimic = 0;
+ g_ptr->mimic = 0;
/* Change the feature */
- c_ptr->feat = feat;
+ g_ptr->feat = feat;
/* Hack -- glow the GLOW terrain */
- if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
+ if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
{
- int i, yy, xx;
+ DIRECTION i;
+ POSITION 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;
+ grid_array[yy][xx].info |= CAVE_GLOW;
}
}
}
old_los = cave_have_flag_bold(y, x, FF_LOS);
- old_mirror = is_mirror_grid(c_ptr);
+ old_mirror = is_mirror_grid(g_ptr);
/* Clear mimic type */
- c_ptr->mimic = 0;
+ g_ptr->mimic = 0;
/* Change the feature */
- c_ptr->feat = feat;
+ g_ptr->feat = feat;
/* Remove flag for mirror/glyph */
- c_ptr->info &= ~(CAVE_OBJECT);
+ g_ptr->info &= ~(CAVE_OBJECT);
- if (old_mirror && (d_info[dungeon_type].flags1 & DF1_DARKNESS))
+ if (old_mirror && (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
{
- c_ptr->info &= ~(CAVE_GLOW);
- if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
+ g_ptr->info &= ~(CAVE_GLOW);
+ if (!view_torch_grids) g_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);
+ if (!have_flag(f_ptr->flags, FF_REMEMBER)) g_ptr->info &= ~(CAVE_MARK);
+ if (g_ptr->m_idx) update_monster(g_ptr->m_idx, FALSE);
- /* Notice */
note_spot(y, x);
- /* Redraw */
lite_spot(y, x);
/* Check if los has changed */
}
/* Hack -- glow the GLOW terrain */
- if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
+ if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
{
- int i, yy, xx;
- cave_type *cc_ptr;
+ DIRECTION i;
+ POSITION yy, xx;
+ grid_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;
- cc_ptr = &cave[yy][xx];
+ cc_ptr = &grid_array[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);
+ if (cc_ptr->m_idx) update_monster(cc_ptr->m_idx, FALSE);
- /* Notice */
note_spot(yy, xx);
- /* Redraw */
lite_spot(yy, xx);
}
if (p_ptr->special_defense & NINJA_S_STEALTH)
{
- if (cave[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
+ if (grid_array[p_ptr->y][p_ptr->x].info & CAVE_GLOW) set_superstealth(FALSE);
}
}
}
-IDX conv_dungeon_feat(IDX newfeat)
+FEAT_IDX conv_dungeon_feat(FEAT_IDX newfeat)
{
feature_type *f_ptr = &f_info[newfeat];
switch (f_ptr->subtype)
{
case CONVERT_TYPE_FLOOR:
- return floor_type[randint0(100)];
+ return feat_ground_type[randint0(100)];
case CONVERT_TYPE_WALL:
- return fill_type[randint0(100)];
+ return feat_wall_type[randint0(100)];
case CONVERT_TYPE_INNER:
return feat_wall_inner;
case CONVERT_TYPE_OUTER:
case CONVERT_TYPE_SOLID:
return feat_wall_solid;
case CONVERT_TYPE_STREAM1:
- return d_info[dungeon_type].stream1;
+ return d_info[p_ptr->dungeon_idx].stream1;
case CONVERT_TYPE_STREAM2:
- return d_info[dungeon_type].stream2;
+ return d_info[p_ptr->dungeon_idx].stream2;
default:
return newfeat;
}
* Take a feature, determine what that feature becomes
* through applying the given action.
*/
-IDX feat_state(IDX feat, int action)
+FEAT_IDX feat_state(FEAT_IDX feat, int action)
{
feature_type *f_ptr = &f_info[feat];
int i;
* 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)
+void cave_alter_feat(POSITION y, POSITION x, int action)
{
/* Set old feature */
- IDX oldfeat = cave[y][x].feat;
+ FEAT_IDX oldfeat = grid_array[y][x].feat;
/* Get the new feat */
- IDX newfeat = feat_state(oldfeat, action);
+ FEAT_IDX newfeat = feat_state(oldfeat, action);
/* No change */
if (newfeat == oldfeat) return;
/* Remove a mirror */
-void remove_mirror(int y, int x)
+void remove_mirror(POSITION y, POSITION x)
{
- cave_type *c_ptr = &cave[y][x];
+ grid_type *g_ptr = &grid_array[y][x];
/* Remove the mirror */
- c_ptr->info &= ~(CAVE_OBJECT);
- c_ptr->mimic = 0;
+ g_ptr->info &= ~(CAVE_OBJECT);
+ g_ptr->mimic = 0;
- if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
+ if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)
{
- 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);
+ g_ptr->info &= ~(CAVE_GLOW);
+ if (!view_torch_grids) g_ptr->info &= ~(CAVE_MARK);
+ if (g_ptr->m_idx) update_monster(g_ptr->m_idx, FALSE);
update_local_illumination(y, x);
}
- /* Notice */
note_spot(y, x);
- /* Redraw */
lite_spot(y, x);
}
/*
* Return TRUE if there is a mirror on the grid.
*/
-bool is_mirror_grid(cave_type *c_ptr)
+bool is_mirror_grid(grid_type *g_ptr)
{
- if ((c_ptr->info & CAVE_OBJECT) && have_flag(f_info[c_ptr->mimic].flags, FF_MIRROR))
+ if ((g_ptr->info & CAVE_OBJECT) && have_flag(f_info[g_ptr->mimic].flags, FF_MIRROR))
return TRUE;
else
return FALSE;
/*
* Return TRUE if there is a mirror on the grid.
*/
-bool is_glyph_grid(cave_type *c_ptr)
+bool is_glyph_grid(grid_type *g_ptr)
{
- if ((c_ptr->info & CAVE_OBJECT) && have_flag(f_info[c_ptr->mimic].flags, FF_GLYPH))
+ if ((g_ptr->info & CAVE_OBJECT) && have_flag(f_info[g_ptr->mimic].flags, FF_GLYPH))
return TRUE;
else
return FALSE;
/*
* Return TRUE if there is a mirror on the grid.
*/
-bool is_explosive_rune_grid(cave_type *c_ptr)
+bool is_explosive_rune_grid(grid_type *g_ptr)
{
- if ((c_ptr->info & CAVE_OBJECT) && have_flag(f_info[c_ptr->mimic].flags, FF_MINOR_GLYPH))
+ if ((g_ptr->info & CAVE_OBJECT) && have_flag(f_info[g_ptr->mimic].flags, FF_MINOR_GLYPH))
return TRUE;
else
return FALSE;
/* Save this monster ID */
p_ptr->monster_race_idx = r_idx;
- /* Window stuff */
p_ptr->window |= (PW_MONSTER);
}
/*
* Hack -- track the given object kind
*/
-void object_kind_track(IDX k_idx)
+void object_kind_track(KIND_OBJECT_IDX k_idx)
{
/* Save this monster ID */
p_ptr->object_kind_idx = k_idx;
- /* Window stuff */
p_ptr->window |= (PW_OBJECT);
}
*
* All disturbance cancels repeated commands, resting, and running.
*/
-void disturb(int stop_search, int stop_travel)
+void disturb(bool stop_search, bool stop_travel)
{
#ifndef TRAVEL
/* Unused */
*/
void glow_deep_lava_and_bldg(void)
{
- int y, x, i, yy, xx;
- cave_type *c_ptr;
+ POSITION y, x, yy, xx;
+ DIRECTION i;
+ grid_type *g_ptr;
/* Not in the darkness dungeon */
- if (d_info[dungeon_type].flags1 & DF1_DARKNESS) return;
+ if (d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS) return;
for (y = 0; y < cur_hgt; y++)
{
for (x = 0; x < cur_wid; x++)
{
- c_ptr = &cave[y][x];
+ g_ptr = &grid_array[y][x];
/* Feature code (applying "mimic" field) */
- if (have_flag(f_info[get_feat_mimic(c_ptr)].flags, FF_GLOW))
+ if (have_flag(f_info[get_feat_mimic(g_ptr)].flags, FF_GLOW))
{
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;
+ grid_array[yy][xx].info |= CAVE_GLOW;
}
}
}
/* Update the view and lite */
p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE);
- /* Redraw map */
p_ptr->redraw |= (PR_MAP);
}
+
+/*!
+* @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
+* @param m_idx モンスターID
+* @param y 移動先Y座標
+* @param x 移動先X座標
+* @param mode オプション
+* @return テレポート先として妥当ならばtrue
+*/
+bool cave_monster_teleportable_bold(MONSTER_IDX m_idx, POSITION y, POSITION x, BIT_FLAGS mode)
+{
+ monster_type *m_ptr = &m_list[m_idx];
+ grid_type *g_ptr = &grid_array[y][x];
+ feature_type *f_ptr = &f_info[g_ptr->feat];
+
+ /* Require "teleportable" space */
+ if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
+
+ if (g_ptr->m_idx && (g_ptr->m_idx != m_idx)) return FALSE;
+ if (player_bold(y, x)) return FALSE;
+
+ /* Hack -- no teleport onto glyph of warding */
+ if (is_glyph_grid(g_ptr)) return FALSE;
+ if (is_explosive_rune_grid(g_ptr)) return FALSE;
+
+ if (!(mode & TELEPORT_PASSIVE))
+ {
+ if (!monster_can_cross_terrain(g_ptr->feat, &r_info[m_ptr->r_idx], 0)) return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*!
+* @brief 指定されたマスにプレイヤーがテレポート可能かどうかを判定する。
+* @param y 移動先Y座標
+* @param x 移動先X座標
+* @param mode オプション
+* @return テレポート先として妥当ならばtrue
+*/
+bool cave_player_teleportable_bold(POSITION y, POSITION x, BIT_FLAGS mode)
+{
+ grid_type *g_ptr = &grid_array[y][x];
+ feature_type *f_ptr = &f_info[g_ptr->feat];
+
+ /* Require "teleportable" space */
+ if (!have_flag(f_ptr->flags, FF_TELEPORTABLE)) return FALSE;
+
+ /* No magical teleporting into vaults and such */
+ if (!(mode & TELEPORT_NONMAGICAL) && (g_ptr->info & CAVE_ICKY)) return FALSE;
+
+ if (g_ptr->m_idx && (g_ptr->m_idx != p_ptr->riding)) return FALSE;
+
+ /* don't teleport on a trap. */
+ if (have_flag(f_ptr->flags, FF_HIT_TRAP)) return FALSE;
+
+ if (!(mode & TELEPORT_PASSIVE))
+ {
+ if (!player_can_enter(g_ptr->feat, 0)) return FALSE;
+
+ if (have_flag(f_ptr->flags, FF_WATER) && have_flag(f_ptr->flags, FF_DEEP))
+ {
+ if (!p_ptr->levitation && !p_ptr->can_swim) return FALSE;
+ }
+
+ if (have_flag(f_ptr->flags, FF_LAVA) && !p_ptr->immune_fire && !IS_INVULN())
+ {
+ /* Always forbid deep lava */
+ if (have_flag(f_ptr->flags, FF_DEEP)) return FALSE;
+
+ /* Forbid shallow lava when the player don't have levitation */
+ if (!p_ptr->levitation) return FALSE;
+ }
+
+ }
+
+ return TRUE;
+}
+
+/*!
+ * @brief 地形は開くものであって、かつ開かれているかを返す /
+ * Attempt to open the given chest at the given location
+ * @param feat 地形ID
+ * @return 開いた地形である場合TRUEを返す / Return TRUE if the given feature is an open door
+ */
+bool is_open(FEAT_IDX feat)
+{
+ return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
+}