From 61555b9cbf402012d5283a702538a20c0ac2e592 Mon Sep 17 00:00:00 2001 From: deskull Date: Tue, 24 Dec 2019 17:43:53 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20update=5Fflow()=20?= =?utf8?q?=E3=81=AB=20player=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E=20/=20Add=20player=5Ftype=20*=20argu?= =?utf8?q?ment=20to=20update=5Fflow().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/grid.c | 30 +++++++++++++++--------------- src/grid.h | 2 +- src/player-status.c | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/grid.c b/src/grid.c index d6cca0fed..fed98872b 100644 --- a/src/grid.c +++ b/src/grid.c @@ -1005,7 +1005,7 @@ static POSITION flow_y = 0; * We do not need a priority queue because the cost from grid * to grid is always "one" and we process them in order. */ -void update_flow(void) +void update_flow(player_type *subject_ptr) { POSITION x, y; DIRECTION d; @@ -1016,29 +1016,29 @@ void update_flow(void) if (tmp_pos.n) return; /* The last way-point is on the map */ - if (p_ptr->running && in_bounds(p_ptr->current_floor_ptr, flow_y, flow_x)) + if (subject_ptr->running && in_bounds(subject_ptr->current_floor_ptr, flow_y, flow_x)) { /* The way point is in sight - do not update. (Speedup) */ - if (p_ptr->current_floor_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW) return; + if (subject_ptr->current_floor_ptr->grid_array[flow_y][flow_x].info & CAVE_VIEW) return; } /* Erase all of the current flow information */ - for (y = 0; y < p_ptr->current_floor_ptr->height; y++) + for (y = 0; y < subject_ptr->current_floor_ptr->height; y++) { - for (x = 0; x < p_ptr->current_floor_ptr->width; x++) + for (x = 0; x < subject_ptr->current_floor_ptr->width; x++) { - p_ptr->current_floor_ptr->grid_array[y][x].cost = 0; - p_ptr->current_floor_ptr->grid_array[y][x].dist = 0; + subject_ptr->current_floor_ptr->grid_array[y][x].cost = 0; + subject_ptr->current_floor_ptr->grid_array[y][x].dist = 0; } } /* Save player position */ - flow_y = p_ptr->y; - flow_x = p_ptr->x; + flow_y = subject_ptr->y; + flow_x = subject_ptr->x; /* Add the player's grid to the queue */ - tmp_pos.y[0] = p_ptr->y; - tmp_pos.x[0] = p_ptr->x; + tmp_pos.y[0] = subject_ptr->y; + tmp_pos.x[0] = subject_ptr->x; /* Now process the queue */ while (flow_head != flow_tail) @@ -1056,8 +1056,8 @@ void update_flow(void) for (d = 0; d < 8; d++) { int old_head = flow_head; - byte_hack m = p_ptr->current_floor_ptr->grid_array[ty][tx].cost + 1; - byte_hack n = p_ptr->current_floor_ptr->grid_array[ty][tx].dist + 1; + byte_hack m = subject_ptr->current_floor_ptr->grid_array[ty][tx].cost + 1; + byte_hack n = subject_ptr->current_floor_ptr->grid_array[ty][tx].dist + 1; grid_type *g_ptr; /* Child location */ @@ -1065,9 +1065,9 @@ void update_flow(void) x = tx + ddx_ddd[d]; /* Ignore player's grid */ - if (player_bold(p_ptr, y, x)) continue; + if (player_bold(subject_ptr, y, x)) continue; - g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; + g_ptr = &subject_ptr->current_floor_ptr->grid_array[y][x]; if (is_closed_door(g_ptr->feat)) m += 3; diff --git a/src/grid.h b/src/grid.h index f5ddb2276..84fc0e2ff 100644 --- a/src/grid.h +++ b/src/grid.h @@ -396,7 +396,7 @@ extern void print_rel(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(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); extern void remove_mirror(POSITION y, POSITION x); diff --git a/src/player-status.c b/src/player-status.c index c3c61d4db..727d4697c 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -5070,7 +5070,7 @@ void update_creature(player_type *creature_ptr) if (creature_ptr->update & (PU_FLOW)) { creature_ptr->update &= ~(PU_FLOW); - update_flow(); + update_flow(creature_ptr); } if (creature_ptr->update & (PU_DISTANCE)) -- 2.11.0