From e0f2964dd803fca8fc546118ec57f251495d7a7b Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 21 Sep 2019 18:08:02 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20in=5Fbounds2()=20=E3=81=AB?= =?utf8?q?=20floor=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92=E8=BF=BD?= =?utf8?q?=E5=8A=A0=EF=BC=8E=20/=20Add=20floor=5Ftype=20*=20argument=20to?= =?utf8?q?=20in=5Fbounds2().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/combat/shoot.c | 2 +- src/floor-events.c | 2 +- src/floor-streams.c | 4 ++-- src/floor.h | 4 ++-- src/grid.c | 6 +++--- src/monster-process.c | 14 +++++++------- src/player-move.c | 4 ++-- src/spells-floor.c | 4 ++-- src/spells1.c | 4 ++-- src/spells2.c | 4 ++-- src/view-mainwindow.c | 2 +- 11 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/combat/shoot.c b/src/combat/shoot.c index 9d1944725..cad6397eb 100644 --- a/src/combat/shoot.c +++ b/src/combat/shoot.c @@ -793,7 +793,7 @@ void exe_fire(player_type *shooter_ptr, INVENTORY_IDX item, object_type *j_ptr, mmove2(&ny, &nx, shooter_ptr->y, shooter_ptr->x, ty, tx); /* Stopped by wilderness boundary */ - if (!in_bounds2(ny, nx)) break; + if (!in_bounds2(shooter_ptr->current_floor_ptr, ny, nx)) break; /* Stopped by walls/doors */ if (!player_can_enter(p_ptr->current_floor_ptr->grid_array[ny][nx].feat, 0)) break; diff --git a/src/floor-events.c b/src/floor-events.c index e9aac78f1..5c5029250 100644 --- a/src/floor-events.c +++ b/src/floor-events.c @@ -351,7 +351,7 @@ void glow_deep_lava_and_bldg(floor_type *floor_ptr) { yy = y + ddy_ddd[i]; xx = x + ddx_ddd[i]; - if (!in_bounds2(yy, xx)) continue; + if (!in_bounds2(floor_ptr, yy, xx)) continue; floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW; } } diff --git a/src/floor-streams.c b/src/floor-streams.c index 6f5b2dad3..0eaec0bcc 100644 --- a/src/floor-streams.c +++ b/src/floor-streams.c @@ -117,7 +117,7 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2, { for (tx = x - width - 1; tx <= x + width + 1; tx++) { - if (!in_bounds2(ty, tx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, ty, tx)) continue; g_ptr = &p_ptr->current_floor_ptr->grid_array[ty][tx]; @@ -273,7 +273,7 @@ void build_streamer(FEAT_IDX feat, int chance) { ty = rand_spread(y, d); tx = rand_spread(x, d); - if (!in_bounds2(ty, tx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, ty, tx)) continue; break; } g_ptr = &p_ptr->current_floor_ptr->grid_array[ty][tx]; diff --git a/src/floor.h b/src/floor.h index 0e1da2f9c..d633bb9f4 100644 --- a/src/floor.h +++ b/src/floor.h @@ -177,8 +177,8 @@ extern floor_type floor_info; /* * Determines if a map location is on or inside the outer walls */ -#define in_bounds2(Y,X) \ - (((Y) >= 0) && ((X) >= 0) && ((Y) < p_ptr->current_floor_ptr->height) && ((X) < p_ptr->current_floor_ptr->width)) +#define in_bounds2(F,Y,X) \ + (((Y) >= 0) && ((X) >= 0) && ((Y) < (F)->height) && ((X) < (F)->width)) /* * Determines if a map location is on or inside the outer walls diff --git a/src/grid.c b/src/grid.c index 6849c4cec..42ad23c3c 100644 --- a/src/grid.c +++ b/src/grid.c @@ -1311,7 +1311,7 @@ void note_spot(POSITION y, POSITION x) void lite_spot(POSITION y, POSITION x) { /* Redraw if on screen */ - if (panel_contains(y, x) && in_bounds2(y, x)) + if (panel_contains(y, x) && in_bounds2(p_ptr->current_floor_ptr, y, x)) { TERM_COLOR a; SYMBOL_CODE c; @@ -1827,7 +1827,7 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat) { yy = y + ddy_ddd[i]; xx = x + ddx_ddd[i]; - if (!in_bounds2(yy, xx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue; p_ptr->current_floor_ptr->grid_array[yy][xx].info |= CAVE_GLOW; } } @@ -1887,7 +1887,7 @@ void cave_set_feat(POSITION y, POSITION x, FEAT_IDX feat) { yy = y + ddy_ddd[i]; xx = x + ddx_ddd[i]; - if (!in_bounds2(yy, xx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue; cc_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx]; cc_ptr->info |= CAVE_GLOW; diff --git a/src/monster-process.c b/src/monster-process.c index 56fe9630f..95cf5ec87 100644 --- a/src/monster-process.c +++ b/src/monster-process.c @@ -331,7 +331,7 @@ static bool get_moves_aux2(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) x = x1 + ddx_ddd[i]; /* Ignore locations off of edge */ - if (!in_bounds2(y, x)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue; /* Simply move to player */ if (player_bold(y, x)) return (FALSE); @@ -464,7 +464,7 @@ static bool get_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp, bool no x = x1 + ddx_ddd[i]; /* Ignore locations off of edge */ - if (!in_bounds2(y, x)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue; g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; @@ -542,7 +542,7 @@ static bool get_fear_moves_aux(MONSTER_IDX m_idx, POSITION *yp, POSITION *xp) x = fx + ddx_ddd[i]; /* Ignore locations off of edge */ - if (!in_bounds2(y, x)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue; /* Don't move toward player */ /* if (p_ptr->current_floor_ptr->grid_array[y][x].dist < 3) continue; */ /* Hmm.. Need it? */ @@ -928,7 +928,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm) int xx = p_ptr->x + ddx_ddd[i]; int yy = p_ptr->y + ddy_ddd[i]; - if (!in_bounds2(yy, xx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue; g_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx]; @@ -973,7 +973,7 @@ static bool get_moves(MONSTER_IDX m_idx, DIRECTION *mm) break; } - if (!in_bounds2(y2, x2)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, y2, x2)) continue; /* Ignore filled grids */ if (!monster_can_enter(y2, x2, r_ptr, 0)) continue; @@ -1501,7 +1501,7 @@ void process_monster(MONSTER_IDX m_idx) for (x = ox - 1; x <= ox + 1; x++) { /* Ignore locations off of edge */ - if (!in_bounds2(y, x)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue; if (p_ptr->current_floor_ptr->grid_array[y][x].m_idx) k++; } } @@ -1777,7 +1777,7 @@ void process_monster(MONSTER_IDX m_idx) nx = ox + ddx[d]; /* Ignore locations off of edge */ - if (!in_bounds2(ny, nx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, ny, nx)) continue; /* Access that grid */ g_ptr = &p_ptr->current_floor_ptr->grid_array[ny][nx]; diff --git a/src/player-move.c b/src/player-move.c index fd4ea2b82..52e830af3 100644 --- a/src/player-move.c +++ b/src/player-move.c @@ -1302,7 +1302,7 @@ static bool see_wall(DIRECTION dir, POSITION y, POSITION x) x += ddx[dir]; /* Illegal grids are not known walls */ - if (!in_bounds2(y, x)) return (FALSE); + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) return (FALSE); /* Access grid */ g_ptr = &p_ptr->current_floor_ptr->grid_array[y][x]; @@ -1345,7 +1345,7 @@ static bool see_nothing(DIRECTION dir, POSITION y, POSITION x) x += ddx[dir]; /* Illegal grids are unknown */ - if (!in_bounds2(y, x)) return (TRUE); + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) return (TRUE); /* Memorized grids are always known */ if (p_ptr->current_floor_ptr->grid_array[y][x].info & (CAVE_MARK)) return (FALSE); diff --git a/src/spells-floor.c b/src/spells-floor.c index 1c9d5c1ff..e1ec8d4cd 100644 --- a/src/spells-floor.c +++ b/src/spells-floor.c @@ -672,7 +672,7 @@ bool destroy_area(POSITION y1, POSITION x1, POSITION r, bool in_generate) { yy = y + ddy_ddd[i]; xx = x + ddx_ddd[i]; - if (!in_bounds2(yy, xx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, yy, xx)) continue; cc_ptr = &p_ptr->current_floor_ptr->grid_array[yy][xx]; if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW)) { @@ -1132,7 +1132,7 @@ bool earthquake(POSITION cy, POSITION cx, POSITION r, MONSTER_IDX m_idx) { yyy = yy + ddy_ddd[ii]; xxx = xx + ddx_ddd[ii]; - if (!in_bounds2(yyy, xxx)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, yyy, xxx)) continue; cc_ptr = &p_ptr->current_floor_ptr->grid_array[yyy][xxx]; if (have_flag(f_info[get_feat_mimic(cc_ptr)].flags, FF_GLOW)) { diff --git a/src/spells1.c b/src/spells1.c index 572c1106a..032cc425b 100644 --- a/src/spells1.c +++ b/src/spells1.c @@ -610,7 +610,7 @@ static bool project_f(MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_P int by = y + ddy_ddd[j]; int bx = x + ddx_ddd[j]; - if (in_bounds2(by, bx)) + if (in_bounds2(p_ptr->current_floor_ptr, by, bx)) { grid_type *cc_ptr = &p_ptr->current_floor_ptr->grid_array[by][bx]; @@ -6128,7 +6128,7 @@ bool project(MONSTER_IDX who, POSITION rad, POSITION y, POSITION x, HIT_POINT da for (x = bx - dist; x <= bx + dist; x++) { /* Ignore "illegal" locations */ - if (!in_bounds2(y, x)) continue; + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) continue; /* Enforce a "circular" explosion */ if (distance(by, bx, y, x) != dist) continue; diff --git a/src/spells2.c b/src/spells2.c index 73f7978dc..7721ae3b5 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -1537,7 +1537,7 @@ static void cave_temp_room_unlite(void) POSITION by = y + ddy_ddd[j]; POSITION bx = x + ddx_ddd[j]; - if (in_bounds2(by, bx)) + if (in_bounds2(p_ptr->current_floor_ptr, by, bx)) { grid_type *cc_ptr = &p_ptr->current_floor_ptr->grid_array[by][bx]; @@ -1664,7 +1664,7 @@ static void cave_temp_room_aux(POSITION y, POSITION x, bool only_room, bool (*pa if (only_room) return; /* Verify */ - if (!in_bounds2(y, x)) return; + if (!in_bounds2(p_ptr->current_floor_ptr, y, x)) return; /* Do not exceed the maximum spell range */ if (distance(p_ptr->y, p_ptr->x, y, x) > MAX_RANGE) return; diff --git a/src/view-mainwindow.c b/src/view-mainwindow.c index b1239d19b..afe2f2761 100644 --- a/src/view-mainwindow.c +++ b/src/view-mainwindow.c @@ -1930,7 +1930,7 @@ static void display_dungeon(void) { for (y = p_ptr->y - Term->hgt / 2 + 1; y <= p_ptr->y + Term->hgt / 2; y++) { - if (in_bounds2(y, x)) + if (in_bounds2(p_ptr->current_floor_ptr, y, x)) { map_info(y, x, &a, &c, &ta, &tc); -- 2.11.0