From e21515fc1a8bdb90bfb73a1d7a1e629d8a279900 Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 2 Mar 2019 00:44:28 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38993=20mon=5Flite=5Fn/x/y=20?= =?utf8?q?=E3=82=92=20floor=5Ftype=20=E3=81=AB=E5=8F=96=E3=82=8A=E8=BE=BC?= =?utf8?q?=E3=82=80=E3=80=82=20/=20Move=20mon=5Flite=5Fn/x/y=20to=20floor?= =?utf8?q?=5Ftype=20structure.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/externs.h | 3 --- src/grid.c | 24 ++++++++++++------------ src/types.h | 3 +++ src/variable.c | 4 ---- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/externs.h b/src/externs.h index 4449e0c44..65b5f2f81 100644 --- a/src/externs.h +++ b/src/externs.h @@ -216,9 +216,6 @@ extern int player_egid; extern char player_base[32]; extern char savefile[1024]; extern char savefile_base[40]; -extern POSITION_IDX mon_lite_n; -extern POSITION mon_lite_y[MON_LITE_MAX]; -extern POSITION mon_lite_x[MON_LITE_MAX]; extern POSITION_IDX view_n; extern POSITION view_y[VIEW_MAX]; extern POSITION view_x[VIEW_MAX]; diff --git a/src/grid.c b/src/grid.c index 730dad38f..3e4a49022 100644 --- a/src/grid.c +++ b/src/grid.c @@ -3713,10 +3713,10 @@ void update_mon_lite(void) (MAX_SIGHT / 2 + 1) : (MAX_SIGHT + 3); /* Clear all monster lit squares */ - for (i = 0; i < mon_lite_n; i++) + for (i = 0; i < current_floor_ptr->mon_lite_n; i++) { /* Point to grid */ - g_ptr = ¤t_floor_ptr->grid_array[mon_lite_y[i]][mon_lite_x[i]]; + g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->mon_lite_y[i]][current_floor_ptr->mon_lite_x[i]]; /* Set temp or xtra flag */ g_ptr->info |= (g_ptr->info & CAVE_MNLT) ? CAVE_TEMP : CAVE_XTRA; @@ -3904,10 +3904,10 @@ void update_mon_lite(void) /* * Look at old set flags to see if there are any changes. */ - for (i = 0; i < mon_lite_n; i++) + for (i = 0; i < current_floor_ptr->mon_lite_n; i++) { - fx = mon_lite_x[i]; - fy = mon_lite_y[i]; + fx = current_floor_ptr->mon_lite_x[i]; + fy = current_floor_ptr->mon_lite_y[i]; /* We trust this grid is in bounds */ @@ -3942,7 +3942,7 @@ void update_mon_lite(void) } /* Clear the lite array */ - mon_lite_n = 0; + current_floor_ptr->mon_lite_n = 0; /* Copy the temp array into the lit array lighting the new squares. */ for (i = 0; i < end_temp; i++) @@ -3977,9 +3977,9 @@ void update_mon_lite(void) } /* Save in the monster lit or darkened array */ - mon_lite_x[mon_lite_n] = fx; - mon_lite_y[mon_lite_n] = fy; - mon_lite_n++; + current_floor_ptr->mon_lite_x[current_floor_ptr->mon_lite_n] = fx; + current_floor_ptr->mon_lite_y[current_floor_ptr->mon_lite_n] = fy; + current_floor_ptr->mon_lite_n++; } /* Clear the temp flag for the old lit or darken grids */ @@ -4021,17 +4021,17 @@ void clear_mon_lite(void) grid_type *g_ptr; /* Clear all monster lit squares */ - for (i = 0; i < mon_lite_n; i++) + for (i = 0; i < current_floor_ptr->mon_lite_n; i++) { /* Point to grid */ - g_ptr = ¤t_floor_ptr->grid_array[mon_lite_y[i]][mon_lite_x[i]]; + g_ptr = ¤t_floor_ptr->grid_array[current_floor_ptr->mon_lite_y[i]][current_floor_ptr->mon_lite_x[i]]; /* Clear monster illumination flag */ g_ptr->info &= ~(CAVE_MNLT | CAVE_MNDK); } /* Empty the array */ - mon_lite_n = 0; + current_floor_ptr->mon_lite_n = 0; } diff --git a/src/types.h b/src/types.h index 00474777b..8bb4ae2b3 100644 --- a/src/types.h +++ b/src/types.h @@ -1898,6 +1898,9 @@ typedef struct { POSITION lite_y[LITE_MAX]; POSITION lite_x[LITE_MAX]; + POSITION_IDX mon_lite_n; //!< Array of grids lit by player lite (see "current_floor_ptr->grid_array.c") + POSITION mon_lite_y[MON_LITE_MAX]; + POSITION mon_lite_x[MON_LITE_MAX]; } floor_type; typedef struct { diff --git a/src/variable.c b/src/variable.c index 7f7771b31..6ead5b809 100644 --- a/src/variable.c +++ b/src/variable.c @@ -209,10 +209,6 @@ char player_base[32]; char savefile[1024]; char savefile_base[40]; -POSITION_IDX mon_lite_n; //!< Array of grids lit by player lite (see "current_floor_ptr->grid_array.c") -POSITION mon_lite_y[MON_LITE_MAX]; -POSITION mon_lite_x[MON_LITE_MAX]; - POSITION_IDX view_n; //!< Array of grids viewable to the player (see "current_floor_ptr->grid_array.c") POSITION view_y[VIEW_MAX]; POSITION view_x[VIEW_MAX]; -- 2.11.0