From 390762eebcd0673be4fb5ebdc34e656a9a175fa8 Mon Sep 17 00:00:00 2001 From: deskull Date: Thu, 9 Jan 2020 00:41:37 +0900 Subject: [PATCH 1/1] =?utf8?q?[Refactor]=20#38997=20delayed=5Fvisual=5Fupd?= =?utf8?q?ate()=20=E3=81=ABplayer=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=20/=20Added=20player=5Ftype=20*=20argument=20?= =?utf8?q?to=20delayed=5Fvisual=5Fupdate()?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/grid.c | 39 --------------------------------------- src/grid.h | 1 - src/player-status.c | 2 +- src/view-mainwindow.c | 36 ++++++++++++++++++++++++++++++++++++ src/view-mainwindow.h | 1 + 5 files changed, 38 insertions(+), 41 deletions(-) diff --git a/src/grid.c b/src/grid.c index f455e24cf..02426c8c4 100644 --- a/src/grid.c +++ b/src/grid.c @@ -842,43 +842,6 @@ void lite_spot(POSITION y, POSITION x) */ /* - * 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; - POSITION y, x; - grid_type *g_ptr; - - /* Update needed grids */ - for (i = 0; i < p_ptr->current_floor_ptr->redraw_n; i++) - { - y = p_ptr->current_floor_ptr->redraw_y[i]; - x = p_ptr->current_floor_ptr->redraw_x[i]; - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; - - /* Update only needed grids (prevent multiple updating) */ - if (!(g_ptr->info & CAVE_REDRAW)) continue; - - /* If required, note */ - if (g_ptr->info & CAVE_NOTE) note_spot(y, x); - - lite_spot(y, x); - - /* Hack -- Visual update of monster on this grid */ - if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE); - - /* No longer in the array */ - g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW); - } - - /* None left */ - p_ptr->current_floor_ptr->redraw_n = 0; -} - - -/* * Hack - speed up the update_flow algorithm by only doing * it everytime the player moves out of LOS of the last * "way-point". @@ -886,8 +849,6 @@ void delayed_visual_update(void) static POSITION flow_x = 0; static POSITION flow_y = 0; - - /* * Hack -- fill in the "cost" field of every grid that the player * can "reach" with the number of steps needed to reach that grid. diff --git a/src/grid.h b/src/grid.h index c70b888ff..e98244e3b 100644 --- a/src/grid.h +++ b/src/grid.h @@ -390,7 +390,6 @@ extern void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TE extern void print_rel(player_type *subject_ptr, SYMBOL_CODE c, TERM_COLOR a, TERM_LEN y, TERM_LEN x); extern void note_spot(POSITION y, POSITION x); extern void lite_spot(POSITION y, POSITION x); -extern void delayed_visual_update(void); extern void update_flow(player_type *subject_ptr); extern FEAT_IDX feat_state(FEAT_IDX feat, int action); extern void cave_alter_feat(POSITION y, POSITION x, int action); diff --git a/src/player-status.c b/src/player-status.c index 03efec44a..a073e5584 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -5096,7 +5096,7 @@ void update_creature(player_type *creature_ptr) if (creature_ptr->update & (PU_DELAY_VIS)) { creature_ptr->update &= ~(PU_DELAY_VIS); - delayed_visual_update(); + delayed_visual_update(creature_ptr->current_floor_ptr); } if (creature_ptr->update & (PU_MONSTERS)) diff --git a/src/view-mainwindow.c b/src/view-mainwindow.c index c04584110..20a69dc0c 100644 --- a/src/view-mainwindow.c +++ b/src/view-mainwindow.c @@ -3879,3 +3879,39 @@ void update_playtime(void) } } +/* + * Mega-Hack -- Delayed visual update + * Only used if update_view(), update_lite() or update_mon_lite() was called + */ +void delayed_visual_update(floor_type *floor_ptr) +{ + int i; + POSITION y, x; + grid_type *g_ptr; + + /* Update needed grids */ + for (i = 0; i < floor_ptr->redraw_n; i++) + { + y = floor_ptr->redraw_y[i]; + x = floor_ptr->redraw_x[i]; + g_ptr = &floor_ptr->grid_array[y][x]; + + /* Update only needed grids (prevent multiple updating) */ + if (!(g_ptr->info & CAVE_REDRAW)) continue; + + /* If required, note */ + if (g_ptr->info & CAVE_NOTE) note_spot(y, x); + + lite_spot(y, x); + + /* Hack -- Visual update of monster on this grid */ + if (g_ptr->m_idx) update_monster(p_ptr, g_ptr->m_idx, FALSE); + + /* No longer in the array */ + g_ptr->info &= ~(CAVE_NOTE | CAVE_REDRAW); + } + + /* None left */ + floor_ptr->redraw_n = 0; +} + diff --git a/src/view-mainwindow.h b/src/view-mainwindow.h index a0b92b764..1acacbed3 100644 --- a/src/view-mainwindow.h +++ b/src/view-mainwindow.h @@ -45,3 +45,4 @@ extern POSITION panel_col_prt, panel_row_prt; (((Y) >= panel_row_min) && ((Y) <= panel_row_max) && \ ((X) >= panel_col_min) && ((X) <= panel_col_max)) +extern void delayed_visual_update(floor_type *floor_ptr); -- 2.11.0