OSDN Git Service

壁が全くなく真の最大視界範囲(半径20, 総グリッド数1149)を取る場合に,
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sun, 29 Jun 2003 08:42:25 +0000 (08:42 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sun, 29 Jun 2003 08:42:25 +0000 (08:42 +0000)
視界範囲やモンスター光源範囲の再計算でtemp_*[]やredraw_*[]がオーバー
フローして変愚蛮怒が落ちていたので, 関連するバッファをさらに拡張. ま
た, mon_lite_hack()やmon_dark_hack()ではバッファがあふれないと仮定す
ることで, 比較を減らした.

src/cave.c
src/defines.h
src/externs.h
src/variable.c

index 8878fbf..2617819 100644 (file)
@@ -3205,27 +3205,26 @@ static void mon_lite_hack(int y, int x)
        /* Hack XXX XXX - Is it a wall and monster not in LOS? */
        if (!cave_floor_grid(c_ptr) && mon_invis) return;
 
-       if (temp_n < TEMP_MAX)
-       {
-               /* New grid */
-               if (!(c_ptr->info & CAVE_MNDK))
-               {
-                       /* Save this square */
-                       temp_x[temp_n] = x;
-                       temp_y[temp_n] = y;
-                       temp_n++;
-               }
+       /* We trust temp_n does not exceed TEMP_MAX */
 
-               /* Darkened grid */
-               else
-               {
-                       /* No longer dark */
-                       c_ptr->info &= ~(CAVE_MNDK);
-               }
+       /* New grid */
+       if (!(c_ptr->info & CAVE_MNDK))
+       {
+               /* Save this square */
+               temp_x[temp_n] = x;
+               temp_y[temp_n] = y;
+               temp_n++;
+       }
 
-               /* Light it */
-               c_ptr->info |= CAVE_MNLT;
+       /* Darkened grid */
+       else
+       {
+               /* No longer dark */
+               c_ptr->info &= ~(CAVE_MNDK);
        }
+
+       /* Light it */
+       c_ptr->info |= CAVE_MNLT;
 }
 
 
@@ -3247,16 +3246,15 @@ static void mon_dark_hack(int y, int x)
        /* Hack XXX XXX - Is it a wall and monster not in LOS? */
        if (!cave_floor_grid(c_ptr) && mon_invis) return;
 
-       if (temp_n < TEMP_MAX)
-       {
-               /* Save this square */
-               temp_x[temp_n] = x;
-               temp_y[temp_n] = y;
-               temp_n++;
+       /* We trust temp_n does not exceed TEMP_MAX */
 
-               /* Darken it */
-               c_ptr->info |= CAVE_MNDK;
-       }
+       /* Save this square */
+       temp_x[temp_n] = x;
+       temp_y[temp_n] = y;
+       temp_n++;
+
+       /* Darken it */
+       c_ptr->info |= CAVE_MNDK;
 }
 
 
index 10db0ca..c8eabea 100644 (file)
 #define LITE_MAX 600
 
 /*
+ * Maximum size of the "mon_lite" array (see "cave.c")
+ * Note that the "view radius" will NEVER exceed 20, monster illumination
+ * flags are dependent on CAVE_VIEW, and even if the "view" was octagonal,
+ * we would never require more than 1520 entries in the array.
+ */
+#define MON_LITE_MAX 1536
+
+/*
  * Maximum size of the "view" array (see "cave.c")
  * Note that the "view radius" will NEVER exceed 20, and even if the "view"
  * was octagonal, we would never require more than 1520 entries in the array.
  * must also be large enough to allow "good enough" use as a circular queue,
  * to calculate monster flow, but note that the flow code is "paranoid".
  */
-#define TEMP_MAX 1536
+#define TEMP_MAX 2298
+
+/*
+ * Maximum size of the "redraw" array (see "cave.c")
+ * We must be large for proper functioning of delayed redrawing.
+ * We must also be as large as two times of the largest view area.
+ * Note that maximum view grids are 1149 entries.
+ */
+#define REDRAW_MAX 2298
 
 
 /*
index e290783..2199980 100644 (file)
@@ -349,8 +349,8 @@ extern s16b lite_n;
 extern s16b lite_y[LITE_MAX];
 extern s16b lite_x[LITE_MAX];
 extern s16b mon_lite_n;
-extern s16b mon_lite_y[LITE_MAX];
-extern s16b mon_lite_x[LITE_MAX];
+extern s16b mon_lite_y[MON_LITE_MAX];
+extern s16b mon_lite_x[MON_LITE_MAX];
 extern s16b view_n;
 extern byte view_y[VIEW_MAX];
 extern byte view_x[VIEW_MAX];
@@ -358,8 +358,8 @@ extern s16b temp_n;
 extern byte temp_y[TEMP_MAX];
 extern byte temp_x[TEMP_MAX];
 extern s16b redraw_n;
-extern byte redraw_y[TEMP_MAX];
-extern byte redraw_x[TEMP_MAX];
+extern byte redraw_y[REDRAW_MAX];
+extern byte redraw_x[REDRAW_MAX];
 extern s16b macro__num;
 extern cptr *macro__pat;
 extern cptr *macro__act;
index b1019ec..3c7a861 100644 (file)
@@ -385,8 +385,8 @@ s16b lite_x[LITE_MAX];
  * Array of grids lit by player lite (see "cave.c")
  */
 s16b mon_lite_n;
-s16b mon_lite_y[LITE_MAX];
-s16b mon_lite_x[LITE_MAX];
+s16b mon_lite_y[MON_LITE_MAX];
+s16b mon_lite_x[MON_LITE_MAX];
 
 /*
  * Array of grids viewable to the player (see "cave.c")
@@ -405,9 +405,9 @@ byte temp_x[TEMP_MAX];
 /*
  * Array of grids for delayed visual updating (see "cave.c")
  */
-s16b redraw_n;
-byte redraw_y[TEMP_MAX];
-byte redraw_x[TEMP_MAX];
+s16b redraw_n = 0;
+byte redraw_y[REDRAW_MAX];
+byte redraw_x[REDRAW_MAX];
 
 
 /*