OSDN Git Service

壁が裏から照らされないようにするコードcheck_local_illumination()の範
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 6 Dec 2003 03:03:45 +0000 (03:03 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 6 Dec 2003 03:03:45 +0000 (03:03 +0000)
囲に対応して, CAVE_GLOWが変化するタイミングでそのグリッドの周囲も併せ
て更新するように変更. なお, 以下の変更を含む.
* 暗闇の洞窟で閃光属性を使っても明るくならず, 暗くて見えなかったモン
  スターは見えないままであるので, その場合はupdate_mon()を呼ばないよ
  うにした. 暗黒属性に対してもほぼ同様に変更.
* CAVE_GLOWの変化時にupdate_mon()が足りない部分の修正.
* cave_set_feat()にupdate_mon()追加.

src/cave.c
src/externs.h
src/spells1.c
src/spells2.c
src/spells3.c

index c859092..519459f 100644 (file)
@@ -383,6 +383,83 @@ static bool check_local_illumination(int y, int x)
 
 
 /*
+ * Update "local" illumination
+ */
+void update_local_illumination(int y, int x)
+{
+       int i, yy, xx;
+
+       if (!in_bounds(y, x)) return;
+
+       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);
+               }
+       }
+       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);
+               }
+       }
+       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);
+               }
+       }
+       else /* Player's grid */
+       {
+               for (i = 0; i < 9; i++)
+               {
+                       yy = y + ddy_ddd[i];
+                       xx = x + ddx_ddd[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);
+               }
+       }
+}
+
+
+/*
  * Can the player "see" the given grid in detail?
  *
  * He must have vision, illumination, and line of sight.
@@ -4425,6 +4502,8 @@ void cave_set_feat(int y, int x, int feat)
 
                /* Remove flag for mirror/glyph */
                c_ptr->info &= ~(CAVE_OBJECT);
+
+               update_local_illumination(y, x);
        }
 
        /* Clear mimic type */
@@ -4441,6 +4520,9 @@ void cave_set_feat(int y, int x, int feat)
                /* Check for change to out of sight grid */
                else if (!player_can_see_bold(y, x)) c_ptr->info &= ~(CAVE_MARK);
 
+               /* Update the monster */
+               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+
                /* Notice */
                note_spot(y, x);
 
@@ -4452,20 +4534,30 @@ void cave_set_feat(int y, int x, int feat)
        if (have_flag(f_ptr->flags, FF_GLOW) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS))
        {
                int i, yy, xx;
+               cave_type *cc_ptr;
 
                for (i = 0; i < 9; i++)
                {
                        yy = y + ddy_ddd[i];
                        xx = x + ddx_ddd[i];
                        if (!in_bounds2(yy, xx)) continue;
-                       cave[yy][xx].info |= CAVE_GLOW;
-                       if (character_dungeon && player_has_los_bold(yy, xx))
+                       cc_ptr = &cave[yy][xx];
+                       cc_ptr->info |= CAVE_GLOW;
+                       if (character_dungeon)
                        {
-                               /* 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);
+
+                                       /* Notice */
+                                       note_spot(yy, xx);
+
+                                       /* Redraw */
+                                       lite_spot(yy, xx);
+                               }
 
-                               /* Redraw */
-                               lite_spot(yy, xx);
+                               update_local_illumination(yy, xx);
                        }
                }
        }
@@ -4577,15 +4669,23 @@ void cave_alter_feat(int y, int x, int action)
 /* Remove a mirror */
 void remove_mirror(int y, int x)
 {
+       cave_type *c_ptr = &cave[y][x];
+
        /* Remove the mirror */
-       cave[y][x].info &= ~(CAVE_OBJECT);
-       cave[y][x].mimic = 0;
+       c_ptr->info &= ~(CAVE_OBJECT);
+       c_ptr->mimic = 0;
 
        if (d_info[dungeon_type].flags1 & DF1_DARKNESS)
        {
-               cave[y][x].info &= ~(CAVE_GLOW);
-               if( !view_torch_grids )cave[y][x].info &= ~(CAVE_MARK);
+               c_ptr->info &= ~(CAVE_GLOW);
+               if (!view_torch_grids) c_ptr->info &= ~(CAVE_MARK);
+
+               /* Update the monster */
+               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+
+               update_local_illumination(y, x);
        }
+
        /* Notice */
        note_spot(y, x);
 
index d22462f..6af2485 100644 (file)
@@ -601,6 +601,7 @@ extern bool is_known_trap(cave_type *c_ptr);
 extern bool is_closed_door(int feat);
 extern bool is_hidden_door(cave_type *c_ptr);
 extern bool los(int y1, int x1, int y2, int x2);
+extern void update_local_illumination(int y, int x);
 extern bool player_can_see_bold(int y, int x);
 extern bool cave_valid_bold(int y, int x);
 extern bool cave_valid_grid(cave_type *c_ptr);
index ea8f86d..7d33025 100644 (file)
@@ -1037,20 +1037,25 @@ static bool project_f(int who, int r, int y, int x, int dam, int typ)
                case GF_LITE:
                {
                        /* Turn on the light */
-                       if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) c_ptr->info |= (CAVE_GLOW);
+                       if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS))
+                       {
+                               c_ptr->info |= (CAVE_GLOW);
 
-                       /* Notice */
-                       note_spot(y, x);
+                               /* Notice */
+                               note_spot(y, x);
 
-                       /* Redraw */
-                       lite_spot(y, x);
+                               /* Redraw */
+                               lite_spot(y, x);
 
-                       /* Observe */
-                       if (player_can_see_bold(y, x)) obvious = TRUE;
+                               update_local_illumination(y, x);
+
+                               /* Observe */
+                               if (player_can_see_bold(y, x)) obvious = TRUE;
 
-                       /* Mega-Hack -- Update the monster in the affected grid */
-                       /* This allows "spear of light" (etc) to work "correctly" */
-                       if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+                               /* Mega-Hack -- Update the monster in the affected grid */
+                               /* This allows "spear of light" (etc) to work "correctly" */
+                               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+                       }
 
                        break;
                }
@@ -1061,9 +1066,6 @@ static bool project_f(int who, int r, int y, int x, int dam, int typ)
                {
                        if (!p_ptr->inside_battle)
                        {
-                               /* Notice */
-                               if (player_can_see_bold(y, x)) obvious = TRUE;
-
                                /* Turn off the light. */
                                if (!is_mirror_grid(c_ptr))
                                {
@@ -1078,14 +1080,19 @@ static bool project_f(int who, int r, int y, int x, int dam, int typ)
                                                /* Notice */
                                                note_spot(y, x);
                                        }
-                               }
 
-                               /* Redraw */
-                               lite_spot(y, x);
+                                       /* Redraw */
+                                       lite_spot(y, x);
 
-                               /* Mega-Hack -- Update the monster in the affected grid */
-                               /* This allows "spear of light" (etc) to work "correctly" */
-                               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+                                       update_local_illumination(y, x);
+
+                                       /* Notice */
+                                       if (player_can_see_bold(y, x)) obvious = TRUE;
+
+                                       /* Mega-Hack -- Update the monster in the affected grid */
+                                       /* This allows "spear of light" (etc) to work "correctly" */
+                                       if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+                               }
                        }
 
                        /* All done */
index 9aed65e..380d2dc 100644 (file)
@@ -6061,6 +6061,8 @@ msg_format("%^s
 
                /* Redraw */
                lite_spot(y, x);
+
+               update_local_illumination(y, x);
        }
 
        /* None left */
@@ -6119,6 +6121,8 @@ static void cave_temp_room_unlite(void)
 
                        /* Redraw */
                        lite_spot(y, x);
+
+                       update_local_illumination(y, x);
                }
        }
 
index 5d1431f..8761b9b 100644 (file)
@@ -1941,10 +1941,12 @@ msg_print("
 
        /* Notice */
        note_spot(py, px);
-       
+
        /* Redraw */
        lite_spot(py, px);
 
+       update_local_illumination(py, px);
+
        return TRUE;
 }