OSDN Git Service

update_view(), update_lite(), update_mon_lite()で各グリッドに対し最大
authornothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 19 Jun 2003 03:42:01 +0000 (03:42 +0000)
committernothere <nothere@0568b783-4c39-0410-ac80-bf13821ea2a2>
Thu, 19 Jun 2003 03:42:01 +0000 (03:42 +0000)
3回までnote_spot()とlite_spot()が呼ばれるので, それらを少しでも高速化
すべく, update_stuff()内で前述のupdate_*()が全て呼ばれてから最後に必
要な回数分だけのnote_spot()とlite_spot()を呼ぶ仕様に変更.

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

index 5138839..0354c21 100644 (file)
@@ -2816,6 +2816,30 @@ void forget_lite(void)
 
 
 /*
+ * For delayed visual update
+ */
+#define cave_note_and_redraw_later(C,Y,X) \
+{\
+       (C)->info |= CAVE_NOTE; \
+       cave_redraw_later((C), (Y), (X)); \
+}
+
+
+/*
+ * For delayed visual update
+ */
+#define cave_redraw_later(C,Y,X) \
+{\
+       if (!((C)->info & CAVE_REDRAW)) \
+       { \
+               (C)->info |= CAVE_REDRAW; \
+               redraw_y[redraw_n] = (Y); \
+               redraw_x[redraw_n++] = (X); \
+       } \
+}
+
+
+/*
  * XXX XXX XXX
  *
  * This macro allows us to efficiently add a grid to the "lite" array,
@@ -2861,6 +2885,7 @@ void update_lite(void)
 {
        int i, x, y, min_x, max_x, min_y, max_y;
        int p = p_ptr->cur_lite;
+       cave_type *c_ptr;
 
        /*** Special case ***/
 
@@ -2871,8 +2896,8 @@ void update_lite(void)
                /* Forget the old lite */
                /* forget_lite(); Perhaps don't need? */
 
-               /* Draw the player */
-               lite_spot(py, px);
+               /* Add it to later visual update */
+               cave_redraw_later(&cave[py][px], py, px);
        }
 #endif
 
@@ -3041,14 +3066,13 @@ void update_lite(void)
                y = lite_y[i];
                x = lite_x[i];
 
-               /* Update fresh grids */
-               if (cave[y][x].info & (CAVE_TEMP)) continue;
+               c_ptr = &cave[y][x];
 
-               /* Note */
-               note_spot(y, x);
+               /* Update fresh grids */
+               if (c_ptr->info & (CAVE_TEMP)) continue;
 
-               /* Redraw */
-               lite_spot(y, x);
+               /* Add it to later visual update */
+               cave_note_and_redraw_later(c_ptr, y, x);
        }
 
        /* Clear them all */
@@ -3057,18 +3081,23 @@ void update_lite(void)
                y = temp_y[i];
                x = temp_x[i];
 
+               c_ptr = &cave[y][x];
+
                /* No longer in the array */
-               cave[y][x].info &= ~(CAVE_TEMP);
+               c_ptr->info &= ~(CAVE_TEMP);
 
                /* Update stale grids */
-               if (cave[y][x].info & (CAVE_LITE)) continue;
+               if (c_ptr->info & (CAVE_LITE)) continue;
 
-               /* Redraw */
-               lite_spot(y, x);
+               /* Add it to later visual update */
+               cave_redraw_later(c_ptr, y, x);
        }
 
        /* None left */
        temp_n = 0;
+
+       /* Mega-Hack -- Visual update later */
+       p_ptr->update |= (PU_DELAY_VIS);
 }
 
 
@@ -3313,9 +3342,8 @@ void update_mon_lite(void)
                /* It it no longer lit? */
                if (!(c_ptr->info & CAVE_MNLT) && player_has_los_grid(c_ptr))
                {
-                       /* It is now unlit */
-                       note_spot(fy, fx);
-                       lite_spot(fy, fx);
+                       /* Add it to later visual update */
+                       cave_note_and_redraw_later(c_ptr, fy, fx);
                }
 
                /* Add to end of temp array */
@@ -3349,12 +3377,8 @@ void update_mon_lite(void)
                        if ((c_ptr->info & (CAVE_VIEW | CAVE_TEMP)) == CAVE_VIEW)
                        {
                                /* It is now lit */
-
-                               /* Note */
-                               note_spot(fy, fx);
-
-                               /* Redraw */
-                               lite_spot(fy, fx);
+                               /* Add it to later visual update */
+                               cave_note_and_redraw_later(c_ptr, fy, fx);
                        }
 
                        /* Save in the monster lit array */
@@ -3367,6 +3391,9 @@ void update_mon_lite(void)
        /* Finished with temp_n */
        temp_n = 0;
 
+       /* Mega-Hack -- Visual update later */
+       p_ptr->update |= (PU_DELAY_VIS);
+
        p_ptr->monlite = (cave[py][px].info & CAVE_MNLT) ? TRUE : FALSE;
 
        if (p_ptr->special_defense & NINJA_S_STEALTH)
@@ -4097,11 +4124,8 @@ void update_view(void)
                /* Update only newly viewed grids */
                if (c_ptr->info & (CAVE_TEMP)) continue;
 
-               /* Note */
-               note_spot(y, x);
-
-               /* Redraw */
-               lite_spot(y, x);
+               /* Add it to later visual update */
+               cave_note_and_redraw_later(c_ptr, y, x);
        }
 
        /* Wipe the old grids, update as needed */
@@ -4119,15 +4143,56 @@ void update_view(void)
                /* Update only non-viewable grids */
                if (c_ptr->info & (CAVE_VIEW)) continue;
 
-               /* Redraw */
-               lite_spot(y, x);
+               /* Add it to later visual update */
+               cave_redraw_later(c_ptr, y, x);
        }
 
        /* None left */
        temp_n = 0;
+
+       /* Mega-Hack -- Visual update later */
+       p_ptr->update |= (PU_DELAY_VIS);
 }
 
 
+/*
+ * Mega-Hack -- Delayed visual update
+ * Only used if update_view(), update_lite() or update_mon_lite() was called
+ */
+void delayed_visual_update(void)
+{
+       int       i, y, x;
+       cave_type *c_ptr;
+
+       /* Update needed grids */
+       for (i = 0; i < redraw_n; i++)
+       {
+               y = redraw_y[i];
+               x = redraw_x[i];
+
+               /* Access the grid */
+               c_ptr = &cave[y][x];
+
+               /* Update only needed grids (prevent multiple updating) */
+               if (!(c_ptr->info & CAVE_REDRAW)) continue;
+
+               /* If required, note */
+               if (c_ptr->info & CAVE_NOTE) note_spot(y, x);
+
+               /* Redraw */
+               lite_spot(y, x);
+
+               /* Hack -- Visual update of monster on this grid */
+               if (c_ptr->m_idx) update_mon(c_ptr->m_idx, FALSE);
+
+               /* No longer in the array */
+               c_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW);
+       }
+
+       /* None left */
+       redraw_n = 0;
+}
+
 
 /*
  * Hack -- forget the "flow" information
index 344115a..f995d6d 100644 (file)
 
 /* Used only after cave generation */
 #define CAVE_XXXX1      0x0200
-#define CAVE_XXXX2      0x0400
-#define CAVE_XXXX3      0x0800
-#define CAVE_OBJECT  0x1000    /* mirror */
+#define CAVE_NOTE       0x0400    /* Flag for delayed visual update (needs note_spot()) */
+#define CAVE_REDRAW     0x0800    /* Flag for delayed visual update (needs lite_spot()) */
+#define CAVE_OBJECT     0x1000    /* mirror */
 #define CAVE_UNSAFE     0x2000    /* Might have trap */
 #define CAVE_IN_DETECT  0x4000    /* trap detected area (inner circle only) */
 
 #define PU_VIEW         0x00100000L     /* Update view */
 #define PU_LITE         0x00200000L     /* Update lite */
 #define PU_MON_LITE     0x00400000L     /* Monster illumination */
-/* xxx */
+#define PU_DELAY_VIS    0x00800000L     /* Mega-Hack -- Delayed visual update */
 #define PU_MONSTERS     0x01000000L     /* Update monsters */
 #define PU_DISTANCE     0x02000000L     /* Update distances */
 /* xxx */
index e4c72c4..17e0268 100644 (file)
@@ -357,6 +357,9 @@ extern byte view_x[VIEW_MAX];
 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 s16b macro__num;
 extern cptr *macro__pat;
 extern cptr *macro__act;
@@ -579,6 +582,7 @@ extern void forget_view(void);
 extern void update_view(void);
 extern void update_mon_lite(void);
 extern void clear_mon_lite(void);
+extern void delayed_visual_update(void);
 extern void forget_flow(void);
 extern void update_flow(void);
 extern void update_smell(void);
index 2be8d11..b1019ec 100644 (file)
@@ -402,6 +402,13 @@ s16b temp_n;
 byte temp_y[TEMP_MAX];
 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];
+
 
 /*
  * Number of active macros.
index 829207b..a8a8314 100644 (file)
@@ -5703,6 +5703,16 @@ void update_stuff(void)
                update_mon_lite();
        }
 
+       /*
+        * Mega-Hack -- Delayed visual update
+        * Only used if update_view(), update_lite() or update_mon_lite() was called
+        */
+       if (p_ptr->update & (PU_DELAY_VIS))
+       {
+               p_ptr->update &= ~(PU_DELAY_VIS);
+               delayed_visual_update();
+       }
+
        if (p_ptr->update & (PU_MONSTERS))
        {
                p_ptr->update &= ~(PU_MONSTERS);