OSDN Git Service

Dark grid that isn't lit by lite is unknown grid
[hengband/hengband.git] / src / cave.c
index 7c42482..4e31970 100644 (file)
@@ -368,6 +368,8 @@ bool los(int y1, int x1, int y2, int x2)
 
 
 
+#define COMPLEX_WALL_ILLUMINATION
+
 /*
  * Check for "local" illumination
  */
@@ -378,7 +380,41 @@ static bool check_local_illumination(int y, int x)
        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)); \
+       } \
 }
 
 
@@ -391,54 +427,41 @@ void update_local_illumination(int y, int 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 */
        {
@@ -446,16 +469,47 @@ void update_local_illumination(int y, int x)
                {
                        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 */
 }
 
 
@@ -572,41 +626,6 @@ bool cave_valid_bold(int y, int x)
 
 
 /*
- * 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[] = \
@@ -949,7 +968,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                        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];
@@ -1000,10 +1019,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                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];
@@ -1042,7 +1058,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                                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];
@@ -1116,10 +1132,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                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];
@@ -1162,7 +1175,7 @@ void map_info(int y, int x, byte *ap, char *cp, byte *tap, char *tcp)
                next_o_idx = o_ptr->next_o_idx;
 
                /* Memorized objects */
-               if (o_ptr->marked)
+               if (o_ptr->marked & OM_FOUND)
                {
                        if (display_autopick)
                        {
@@ -1553,7 +1566,7 @@ void display_dungeon(void)
                                /* 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];
@@ -2527,7 +2540,7 @@ void forget_lite(void)
 {\
        if (!(cave[Y][X].info & (CAVE_LITE))) \
        { \
-               cave[Y][X].info |= (CAVE_LITE); \
+               cave[Y][X].info |= (CAVE_LITE | CAVE_KNOWN); \
                lite_y[lite_n] = (Y); \
                lite_x[lite_n++] = (X); \
        } \
@@ -2725,7 +2738,7 @@ void update_lite(void)
                                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);
@@ -2799,9 +2812,6 @@ static void mon_lite_hack(int y, int x)
 
        if (!cave_los_grid(c_ptr))
        {
-               /* Hack XXX XXX - Is it a wall and monster not in LOS? */
-               if (mon_invis) return;
-
                /* Hack -- Prevent monster lite leakage in walls */
 
                /* Horizontal walls between player and a monster */
@@ -2820,6 +2830,9 @@ static void mon_lite_hack(int y, int x)
                        {
                                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;
                }
 
                /* Vertical walls between player and a monster */
@@ -2838,6 +2851,9 @@ static void mon_lite_hack(int y, int x)
                        {
                                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;
                }
        }
 
@@ -2880,11 +2896,8 @@ static void mon_dark_hack(int y, int 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 (!cave_los_grid(c_ptr))
+       if (!cave_los_grid(c_ptr) && !cave_have_flag_grid(c_ptr, FF_PROJECT))
        {
-               /* Hack XXX XXX - Is it a wall and monster not in LOS? */
-               if (mon_invis) return;
-
                /* Hack -- Prevent monster dark lite leakage in walls */
 
                /* Horizontal walls between player and a monster */
@@ -2897,12 +2910,15 @@ static void mon_dark_hack(int y, int x)
                        /* Only first wall viewed from mid-x is lit */
                        if (x < midpoint)
                        {
-                               if (!cave_los_bold(y, x + 1)) return;
+                               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)) return;
+                               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 */
@@ -2915,12 +2931,15 @@ static void mon_dark_hack(int y, int x)
                        /* Only first wall viewed from mid-y is lit */
                        if (y < midpoint)
                        {
-                               if (!cave_los_bold(y + 1, x)) return;
+                               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)) return;
+                               if (!cave_los_bold(y - 1, x) && !cave_have_flag_bold(y - 1, x, FF_PROJECT)) return;
                        }
+
+                       /* Hack XXX XXX - Is it a wall and monster not in LOS? */
+                       else if (mon_invis) return;
                }
        }
 
@@ -2953,6 +2972,7 @@ void update_mon_lite(void)
 
        s16b fx, fy;
        void (*add_mon_lite)(int, int);
+       int f_flag;
 
        s16b end_temp;
 
@@ -2976,166 +2996,172 @@ void update_mon_lite(void)
        /* 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;
 
-               /* If a monster stops time, break */
-               if (world_monster) break;
+                       /* Is it too far away? */
+                       if (m_ptr->cdis > dis_lim) continue;
 
-               /* Get lite radius */
-               rad = 0;
+                       /* Get lite radius */
+                       rad = 0;
 
-               /* 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;
+                       /* 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;
 
-               /* 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;
-                       add_mon_lite = mon_lite_hack;
-               }
-               else
-               {
-                       if (!(r_ptr->flags7 & (RF7_SELF_DARK_1 | RF7_SELF_DARK_2)) && (m_ptr->csleep || (!dun_level && !is_daytime()))) continue;
-                       add_mon_lite = mon_dark_hack;
-                       rad = -rad; /* Use absolute value */
-               }
+                       /* 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 */
-               mon_fx = m_ptr->fx;
-               mon_fy = m_ptr->fy;
+                       /* Access the location */
+                       mon_fx = m_ptr->fx;
+                       mon_fy = m_ptr->fy;
 
-               /* Is the monster visible? */
-               mon_invis = !(cave[mon_fy][mon_fx].info & CAVE_VIEW);
+                       /* Is the monster visible? */
+                       mon_invis = !(cave[mon_fy][mon_fx].info & CAVE_VIEW);
 
-               /* The square it is on */
-               add_mon_lite(mon_fy, mon_fx);
+                       /* The square it is on */
+                       add_mon_lite(mon_fy, mon_fx);
 
-               /* Adjacent squares */
-               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);
+                       /* Adjacent squares */
+                       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_los_bold(mon_fy + 1, mon_fx))
+                       /* Radius 2 */
+                       if (rad >= 2)
                        {
-                               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);
+                               /* South of the monster */
+                               if (cave_have_flag_bold(mon_fy + 1, mon_fx, f_flag))
+                               {
+                                       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[mon_fy + 2][mon_fx];
+                                       c_ptr = &cave[mon_fy + 2][mon_fx];
 
-                               /* Radius 3 */
-                               if ((rad == 3) && cave_los_grid(c_ptr))
-                               {
-                                       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);
+                                       /* Radius 3 */
+                                       if ((rad == 3) && cave_have_flag_grid(c_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 + 3, mon_fx - 1);
+                                       }
                                }
-                       }
 
-                       /* North of the monster */
-                       if (cave_los_bold(mon_fy - 1, mon_fx))
-                       {
-                               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);
+                               /* North of the monster */
+                               if (cave_have_flag_bold(mon_fy - 1, mon_fx, f_flag))
+                               {
+                                       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[mon_fy - 2][mon_fx];
+                                       c_ptr = &cave[mon_fy - 2][mon_fx];
 
-                               /* Radius 3 */
-                               if ((rad == 3) && cave_los_grid(c_ptr))
-                               {
-                                       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);
+                                       /* Radius 3 */
+                                       if ((rad == 3) && cave_have_flag_grid(c_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 - 3, mon_fx - 1);
+                                       }
                                }
-                       }
 
-                       /* East of the monster */
-                       if (cave_los_bold(mon_fy, mon_fx + 1))
-                       {
-                               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);
+                               /* East of the monster */
+                               if (cave_have_flag_bold(mon_fy, mon_fx + 1, f_flag))
+                               {
+                                       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[mon_fy][mon_fx + 2];
+                                       c_ptr = &cave[mon_fy][mon_fx + 2];
 
-                               /* Radius 3 */
-                               if ((rad == 3) && cave_los_grid(c_ptr))
-                               {
-                                       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);
+                                       /* Radius 3 */
+                                       if ((rad == 3) && cave_have_flag_grid(c_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 - 1, mon_fx + 3);
+                                       }
                                }
-                       }
 
-                       /* West of the monster */
-                       if (cave_los_bold(mon_fy, mon_fx - 1))
-                       {
-                               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);
+                               /* West of the monster */
+                               if (cave_have_flag_bold(mon_fy, mon_fx - 1, f_flag))
+                               {
+                                       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[mon_fy][mon_fx - 2];
+                                       c_ptr = &cave[mon_fy][mon_fx - 2];
 
-                               /* Radius 3 */
-                               if ((rad == 3) && cave_los_grid(c_ptr))
-                               {
-                                       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);
+                                       /* Radius 3 */
+                                       if ((rad == 3) && cave_have_flag_grid(c_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 - 1, mon_fx - 3);
+                                       }
                                }
                        }
-               }
 
-               /* Radius 3 */
-               if (rad == 3)
-               {
-                       /* South-East of the monster */
-                       if (cave_los_bold(mon_fy + 1, mon_fx + 1))
+                       /* Radius 3 */
+                       if (rad == 3)
                        {
-                               add_mon_lite(mon_fy + 2, mon_fx + 2);
-                       }
+                               /* South-East of the monster */
+                               if (cave_have_flag_bold(mon_fy + 1, mon_fx + 1, f_flag))
+                               {
+                                       add_mon_lite(mon_fy + 2, mon_fx + 2);
+                               }
 
-                       /* South-West of the monster */
-                       if (cave_los_bold(mon_fy + 1, mon_fx - 1))
-                       {
-                               add_mon_lite(mon_fy + 2, mon_fx - 2);
-                       }
+                               /* South-West of the monster */
+                               if (cave_have_flag_bold(mon_fy + 1, mon_fx - 1, f_flag))
+                               {
+                                       add_mon_lite(mon_fy + 2, mon_fx - 2);
+                               }
 
-                       /* North-East of the monster */
-                       if (cave_los_bold(mon_fy - 1, mon_fx + 1))
-                       {
-                               add_mon_lite(mon_fy - 2, mon_fx + 2);
-                       }
+                               /* North-East of the monster */
+                               if (cave_have_flag_bold(mon_fy - 1, mon_fx + 1, f_flag))
+                               {
+                                       add_mon_lite(mon_fy - 2, mon_fx + 2);
+                               }
 
-                       /* North-West of the monster */
-                       if (cave_los_bold(mon_fy - 1, mon_fx - 1))
-                       {
-                               add_mon_lite(mon_fy - 2, mon_fx - 2);
+                               /* North-West of the monster */
+                               if (cave_have_flag_bold(mon_fy - 1, mon_fx - 1, f_flag))
+                               {
+                                       add_mon_lite(mon_fy - 2, mon_fx - 2);
+                               }
                        }
                }
        }
@@ -3310,7 +3336,7 @@ void forget_view(void)
                /* 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? */
@@ -3332,6 +3358,7 @@ void forget_view(void)
 {\
     if (!((C)->info & (CAVE_VIEW))){\
     (C)->info |= (CAVE_VIEW); \
+    if ((C)->info & (CAVE_GLOW)) (C)->info |= (CAVE_KNOWN); \
     view_y[view_n] = (Y); \
     view_x[view_n] = (X); \
     view_n++;}\
@@ -4278,6 +4305,9 @@ void map_area(int range)
 
                        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];
@@ -4366,6 +4396,9 @@ void wiz_lite(bool ninja)
                {
                        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];
@@ -4421,6 +4454,11 @@ void wiz_lite(bool ninja)
 
        /* Window stuff */
        p_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+
+       if (p_ptr->special_defense & NINJA_S_STEALTH)
+       {
+               if (cave[py][px].info & CAVE_GLOW) set_superstealth(FALSE);
+       }
 }
 
 
@@ -4440,7 +4478,7 @@ void wiz_dark(void)
                        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);
                }
        }
@@ -4471,9 +4509,12 @@ void wiz_dark(void)
                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);
 
@@ -4501,43 +4542,80 @@ void cave_set_feat(int y, int x, int feat)
 {
        cave_type *c_ptr = &cave[y][x];
        feature_type *f_ptr = &f_info[feat];
+       bool old_los, old_mirror;
 
-       if (character_dungeon && is_mirror_grid(c_ptr) && (d_info[dungeon_type].flags1 & DF1_DARKNESS))
+       if (!character_dungeon)
        {
-               c_ptr->info &= ~(CAVE_GLOW);
-               if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
+               /* Clear mimic type */
+               c_ptr->mimic = 0;
 
-               /* Remove flag for mirror/glyph */
-               c_ptr->info &= ~(CAVE_OBJECT);
+               /* Change the feature */
+               c_ptr->feat = feat;
 
-               update_local_illumination(y, x);
+               /* 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))
        {
-               /* Check for change to boring grid */
-               if (!have_flag(f_ptr->flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
+               c_ptr->info &= ~(CAVE_GLOW);
+               if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
 
-               /* Check for change to out of sight grid */
-               else if (!player_can_see_bold(y, x)) c_ptr->info &= ~(CAVE_MARK);
+               update_local_illumination(y, x);
+       }
 
-               /* Update the monster */
-               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+       /* Check for change to boring grid */
+       if (!have_flag(f_ptr->flags, FF_REMEMBER)) c_ptr->info &= ~(CAVE_MARK);
 
-               /* Notice */
-               note_spot(y, x);
+       /* Update the monster */
+       if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
 
-               /* Redraw */
-               lite_spot(y, x);
+       /* 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);
+
+#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;
@@ -4550,22 +4628,25 @@ void cave_set_feat(int y, int x, int feat)
                        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 (cave[py][px].info & CAVE_GLOW) set_superstealth(FALSE);
                }
        }
 }
@@ -4577,7 +4658,7 @@ int conv_dungeon_feat(int newfeat)
 
        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)];
@@ -4670,6 +4751,17 @@ void cave_alter_feat(int y, int x, int action)
 #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);
+               }
+       }
 }
 
 
@@ -4921,10 +5013,12 @@ void object_kind_track(int 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; */
@@ -4962,6 +5056,20 @@ void disturb(int stop_search, int unused_flag)
                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();
 }