OSDN Git Service

grid.c 1.17 の変更に従い、隠しドア等を表示するとき、
[hengbandforosx/hengbandosx.git] / src / cave.c
index 0db6e8f..8992417 100644 (file)
@@ -3194,10 +3194,10 @@ static s16b mon_fy, mon_fx;
 static void mon_lite_hack(int y, int x)
 {
        cave_type *c_ptr;
-       int       midpoint;
+       int       midpoint, dpf, d;
 
-       /* Out of bounds */
-       if (!in_bounds2(y, x)) return;
+       /* We trust this grid is in bounds */
+       /* if (!in_bounds2(y, x)) return; */
 
        c_ptr = &cave[y][x];
 
@@ -3214,7 +3214,9 @@ static void mon_lite_hack(int y, int x)
                /* Horizontal walls between player and a monster */
                if (((y < py) && (y > mon_fy)) || ((y > py) && (y < mon_fy)))
                {
-                       midpoint = (px + mon_fx) >> 1;
+                       dpf = py - mon_fy;
+                       d = y - mon_fy;
+                       midpoint = mon_fx + ((px - mon_fx) * ABS(d)) / ABS(dpf);
 
                        /* Only first wall viewed from mid-x is lit */
                        if (x < midpoint)
@@ -3230,7 +3232,9 @@ static void mon_lite_hack(int y, int x)
                /* Vertical walls between player and a monster */
                if (((x < px) && (x > mon_fx)) || ((x > px) && (x < mon_fx)))
                {
-                       midpoint = (py + mon_fy) >> 1;
+                       dpf = px - mon_fx;
+                       d = x - mon_fx;
+                       midpoint = mon_fy + ((py - mon_fy) * ABS(d)) / ABS(dpf);
 
                        /* Only first wall viewed from mid-y is lit */
                        if (y < midpoint)
@@ -3273,15 +3277,15 @@ static void mon_lite_hack(int y, int x)
 static void mon_dark_hack(int y, int x)
 {
        cave_type *c_ptr;
-       int       midpoint;
+       int       midpoint, dpf, d;
 
-       /* Out of bounds */
-       if (!in_bounds2(y, x)) return;
+       /* We trust this grid is in bounds */
+       /* if (!in_bounds2(y, x)) return; */
 
        c_ptr = &cave[y][x];
 
        /* Want a unlit and undarkened square in view of the player */
-       if ((c_ptr->info & (CAVE_LITE | CAVE_MNLT)) || ((c_ptr->info & (CAVE_MNDK | CAVE_VIEW)) != CAVE_VIEW)) return;
+       if ((c_ptr->info & (CAVE_LITE | CAVE_MNLT | CAVE_MNDK | CAVE_VIEW)) != CAVE_VIEW) return;
 
        if (!cave_floor_grid(c_ptr))
        {
@@ -3293,9 +3297,11 @@ static void mon_dark_hack(int y, int x)
                /* Horizontal walls between player and a monster */
                if (((y < py) && (y > mon_fy)) || ((y > py) && (y < mon_fy)))
                {
-                       midpoint = (px + mon_fx) >> 1;
+                       dpf = py - mon_fy;
+                       d = y - mon_fy;
+                       midpoint = mon_fx + ((px - mon_fx) * ABS(d)) / ABS(dpf);
 
-                       /* Only first wall viewed from mid-x is darkened */
+                       /* Only first wall viewed from mid-x is lit */
                        if (x < midpoint)
                        {
                                if (!cave_floor_bold(y, x + 1)) return;
@@ -3309,9 +3315,11 @@ static void mon_dark_hack(int y, int x)
                /* Vertical walls between player and a monster */
                if (((x < px) && (x > mon_fx)) || ((x > px) && (x < mon_fx)))
                {
-                       midpoint = (py + mon_fy) >> 1;
+                       dpf = px - mon_fx;
+                       d = x - mon_fx;
+                       midpoint = mon_fy + ((py - mon_fy) * ABS(d)) / ABS(dpf);
 
-                       /* Only first wall viewed from mid-y is darkened */
+                       /* Only first wall viewed from mid-y is lit */
                        if (y < midpoint)
                        {
                                if (!cave_floor_bold(y + 1, x)) return;
@@ -4837,17 +4845,32 @@ void wiz_dark(void)
 
 
        /* Forget every grid */
-       for (y = 0; y < cur_hgt; y++)
+       for (y = 1; y < cur_hgt - 1; y++)
        {
-               for (x = 0; x < cur_wid; x++)
+               for (x = 1; x < cur_wid - 1; x++)
                {
                        cave_type *c_ptr = &cave[y][x];
 
                        /* Process the grid */
-                       c_ptr->info &= ~(CAVE_MARK);
+                       c_ptr->info &= ~(CAVE_MARK | CAVE_IN_DETECT);
+                       c_ptr->info |= (CAVE_UNSAFE);
                }
        }
 
+       /* Forget every grid on horizontal edge */
+       for (x = 0; x < cur_wid; x++)
+       {
+               cave[0][x].info &= ~(CAVE_MARK);
+               cave[cur_hgt - 1][x].info &= ~(CAVE_MARK);
+       }
+
+       /* Forget every grid on vertical edge */
+       for (y = 1; y < (cur_hgt - 1); y++)
+       {
+               cave[y][0].info &= ~(CAVE_MARK);
+               cave[y][cur_wid - 1].info &= ~(CAVE_MARK);
+       }
+
        /* Forget all objects */
        for (i = 1; i < o_max; i++)
        {