+#define COMPLEX_WALL_ILLUMINATION
+
/*
* Check for "local" illumination
*/
int xx = (x < px) ? (x + 1) : (x > px) ? (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)))
+ {
+ 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)); \
+ } \
}
if (!in_bounds(y, x)) return;
+#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
+
if ((y != py) && (x != px))
{
yy = (y < py) ? (y - 1) : (y + 1);
xx = (x < px) ? (x - 1) : (x + 1);
-
- if (player_has_los_bold(yy, xx))
- {
- /* Update the monster */
- if (cave[yy][xx].m_idx) update_mon(cave[yy][xx].m_idx, FALSE);
-
- /* Notice and redraw */
- note_spot(yy, xx);
- lite_spot(yy, xx);
- }
+ update_local_illumination_aux(yy, xx);
+ update_local_illumination_aux(y, xx);
+ update_local_illumination_aux(yy, x);
}
else if (x != px) /* y == py */
{
xx = (x < px) ? (x - 1) : (x + 1);
-
for (i = -1; i <= 1; i++)
{
yy = y + i;
- if (!player_has_los_bold(yy, xx)) continue;
-
- /* Update the monster */
- if (cave[yy][xx].m_idx) update_mon(cave[yy][xx].m_idx, FALSE);
-
- /* Notice and redraw */
- note_spot(yy, xx);
- lite_spot(yy, xx);
+ 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 != py) /* x == px */
{
yy = (y < py) ? (y - 1) : (y + 1);
-
for (i = -1; i <= 1; i++)
{
xx = x + i;
- if (!player_has_los_bold(yy, xx)) continue;
-
- /* Update the monster */
- if (cave[yy][xx].m_idx) update_mon(cave[yy][xx].m_idx, FALSE);
-
- /* Notice and redraw */
- note_spot(yy, xx);
- lite_spot(yy, xx);
+ 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 */
{
{
yy = y + ddy_cdd[i];
xx = x + ddx_cdd[i];
- if (!player_has_los_bold(yy, xx)) continue;
+ update_local_illumination_aux(yy, xx);
+ }
+ }
- /* Update the monster */
- if (cave[yy][xx].m_idx) update_mon(cave[yy][xx].m_idx, FALSE);
+#else /* COMPLEX_WALL_ILLUMINATION */
- /* Notice and redraw */
- note_spot(yy, xx);
- lite_spot(yy, xx);
+ if ((y != py) && (x != px))
+ {
+ yy = (y < py) ? (y - 1) : (y + 1);
+ xx = (x < px) ? (x - 1) : (x + 1);
+ update_local_illumination_aux(yy, xx);
+ }
+ else if (x != px) /* y == py */
+ {
+ xx = (x < px) ? (x - 1) : (x + 1);
+ for (i = -1; i <= 1; i++)
+ {
+ yy = y + i;
+ update_local_illumination_aux(yy, xx);
}
}
+ else if (y != py) /* x == px */
+ {
+ yy = (y < py) ? (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 */
}
/*
- * 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 (object_is_artifact(o_ptr)) return (FALSE);
- }
-
- /* Accept */
- return (TRUE);
-}
-
-
-
-
-/*
* Hack -- Legal monster codes
*/
static char image_monster_hack[] = \
else if (darkened_grid(c_ptr))
{
/* Unsafe cave grid -- idea borrowed from Unangband */
- feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? FEAT_UNDETECTED : FEAT_NONE;
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
else
{
/* Unsafe cave grid -- idea borrowed from Unangband */
- if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
- feat = FEAT_UNDETECTED;
- else
- feat = FEAT_NONE;
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
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;
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access darkness */
f_ptr = &f_info[feat];
else
{
/* Unsafe cave grid -- idea borrowed from Unangband */
- if (view_unsafe_grids && (c_ptr->info & (CAVE_UNSAFE)))
- feat = FEAT_UNDETECTED;
- else
- feat = FEAT_NONE;
+ feat = (view_unsafe_grids && (c_ptr->info & CAVE_UNSAFE)) ? feat_undetected : feat_none;
/* Access feature */
f_ptr = &f_info[feat];
next_o_idx = o_ptr->next_o_idx;
/* Memorized objects */
- if (o_ptr->marked)
+ if (o_ptr->marked & OM_FOUND)
{
if (display_autopick)
{
c_ptr->info |= (CAVE_MARK);
}
}
+
+ /* Memorize terrain of the grid */
+ c_ptr->info |= (CAVE_KNOWN);
}
/* 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[F_LIT_STANDARD];
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);
}
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);
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 (!(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)) && (m_ptr->csleep || (!dun_level && !is_daytime()))) continue;
+ 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 */
/* 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? */
c_ptr = &cave[y][x];
+ /* Memorize terrain of the grid */
+ c_ptr->info |= (CAVE_KNOWN);
+
/* Feature code (applying "mimic" field) */
feat = get_feat_mimic(c_ptr);
f_ptr = &f_info[feat];
{
cave_type *c_ptr = &cave[y][x];
+ /* Memorize terrain of the grid */
+ c_ptr->info |= (CAVE_KNOWN);
+
/* Feature code (applying "mimic" field) */
feat = get_feat_mimic(c_ptr);
f_ptr = &f_info[feat];
cave_type *c_ptr = &cave[y][x];
/* Process the grid */
- c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT);
+ c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT | CAVE_KNOWN);
c_ptr->info |= (CAVE_UNSAFE);
}
}
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);
{
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;
- if (character_dungeon)
+ /* Remove flag for mirror/glyph */
+ c_ptr->info &= ~(CAVE_OBJECT);
+
+ if (old_mirror && (d_info[dungeon_type].flags1 & DF1_DARKNESS))
{
- if (is_mirror_grid(c_ptr) && (d_info[dungeon_type].flags1 & DF1_DARKNESS))
- {
- c_ptr->info &= ~(CAVE_GLOW);
- if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
+ c_ptr->info &= ~(CAVE_GLOW);
+ if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
- update_local_illumination(y, x);
- }
+ update_local_illumination(y, x);
+ }
- /* Remove flag for mirror/glyph */
- c_ptr->info &= ~(CAVE_OBJECT);
+ /* Check for change to boring grid */
+ if (!have_flag(f_ptr->flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
- /* 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);
- /* 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);
- /* Notice */
- note_spot(y, x);
+ /* Check if los has changed */
+ if (old_los ^ have_flag(f_ptr->flags, FF_LOS))
+ {
- /* Redraw */
- lite_spot(y, x);
+#ifdef COMPLEX_WALL_ILLUMINATION /* COMPLEX_WALL_ILLUMINATION */
+
+ update_local_illumination(y, x);
+
+#endif /* COMPLEX_WALL_ILLUMINATION */
+
+ /* Update the visuals */
+ p_ptr->update |= (PU_VIEW | PU_LITE | PU_MON_LITE | PU_MONSTERS);
}
- /* Hack -- glow the deep lava */
+ /* Hack -- glow the GLOW terrain */
if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
{
int i, yy, xx;
if (!in_bounds2(yy, xx)) continue;
cc_ptr = &cave[yy][xx];
cc_ptr->info |= CAVE_GLOW;
- if (character_dungeon)
- {
- 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);
+ if (player_has_los_grid(cc_ptr))
+ {
+ /* Update the monster */
+ if (cc_ptr->m_idx) update_mon(cc_ptr->m_idx, FALSE);
- /* Redraw */
- lite_spot(yy, xx);
- }
+ /* Notice */
+ note_spot(yy, xx);
- update_local_illumination(yy, xx);
+ /* Redraw */
+ lite_spot(yy, xx);
}
+
+ update_local_illumination(yy, xx);
}
if (p_ptr->special_defense & NINJA_S_STEALTH)
{
- if (character_dungeon && (cave[py][px].info & CAVE_GLOW)) set_superstealth(FALSE);
+ if (cave[py][px].info & CAVE_GLOW) set_superstealth(FALSE);
}
}
}
if (have_flag(f_ptr->flags, FF_CONVERT))
{
- switch (f_ptr->power)
+ switch (f_ptr->subtype)
{
case CONVERT_TYPE_FLOOR:
return floor_type[randint0(100)];
#endif
}
}
+
+ 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);
+ }
+ }
}
*
* 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();
}