From 68d87e76cd00daee758f5e45e235629f03de0b9e Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Sun, 8 Nov 2009 17:23:31 +0100 Subject: env_show_grid is now only used inside the LOS code. It's also called los_grid, and is a SquareArray of boolean since it doesn't need to store "objects" any more. --- crawl-ref/source/externs.h | 2 -- crawl-ref/source/los.cc | 46 ++++++++++----------------------------------- crawl-ref/source/los.h | 9 ++++----- crawl-ref/source/los_def.cc | 3 ++- crawl-ref/source/los_def.h | 2 +- 5 files changed, 17 insertions(+), 45 deletions(-) diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index c160970da4..c53d9b8559 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -76,8 +76,6 @@ const int kPathLen = 256; #define NO_BERSERK_PENALTY -1 typedef FixedArray feature_grid; -typedef FixedArray - env_show_grid; struct item_def; class melee_attack; diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc index 909ed97922..88fc7d8d01 100644 --- a/crawl-ref/source/los.cc +++ b/crawl-ref/source/los.cc @@ -74,15 +74,6 @@ const circle_def bds_precalc = circle_def(LOS_MAX_RANGE, C_ROUND); #define LOS_MAX_ANGLE (2*LOS_MAX_RANGE-2) #define LOS_INTERCEPT_MULT (2) -// the following two constants represent the 'middle' of the sh array. -// since the current shown area is 19x19, centering the view at (9,9) -// means it will be exactly centered. -// This is done to accomodate possible future changes in viewable screen -// area - simply change sh_xo and sh_yo to the new view center. -const int sh_xo = ENV_SHOW_OFFSET; // X and Y origins for the sh array -const int sh_yo = ENV_SHOW_OFFSET; -const coord_def sh_o = coord_def(sh_xo, sh_yo); - // These store all unique (in terms of footprint) full rays. // The footprint of ray=fullray[i] consists of ray.length cells, // stored in ray_coords[ray.start..ray.length-1]. @@ -817,7 +808,7 @@ bool cell_see_cell(const coord_def& p1, const coord_def& p2) // Smoke will now only block LOS after two cells of smoke. This is // done by updating with a second array. -void _losight_quadrant(env_show_grid& sh, const los_param& dat, int sx, int sy) +void _losight_quadrant(los_grid& sh, const los_param& dat, int sx, int sy) { const unsigned int num_cellrays = cellray_ends.size(); @@ -857,14 +848,14 @@ void _losight_quadrant(env_show_grid& sh, const los_param& dat, int sx, int sy) const coord_def p = coord_def(sx * cellray_ends[rayidx].x, sy * cellray_ends[rayidx].y); if (dat.los_bounds(p)) - sh(p+sh_o) = dat.appearance(p); + sh(p) = true; } } } -void losight(env_show_grid& sh, const los_param& dat) +void losight(los_grid& sh, const los_param& dat) { - sh.init(0); + sh.init(false); // Do precomputations if necessary. raycast(); @@ -876,7 +867,7 @@ void losight(env_show_grid& sh, const los_param& dat) // Center is always visible. const coord_def o = coord_def(0,0); - sh(o+sh_o) = dat.appearance(o); + sh(o) = dat.appearance(o); } struct los_param_funcs : public los_param @@ -907,48 +898,31 @@ struct los_param_funcs : public los_param } }; -void losight(env_show_grid& sh, const coord_def& center, +void losight(los_grid& sh, const coord_def& center, const opacity_func& opc, const circle_def& bounds) { losight(sh, los_param_funcs(center, opc, bounds)); } -void losight_permissive(env_show_grid &sh, const coord_def& center) +void losight_permissive(los_grid &sh, const coord_def& center) { for (int x = -ENV_SHOW_OFFSET; x <= ENV_SHOW_OFFSET; ++x) for (int y = -ENV_SHOW_OFFSET; y <= ENV_SHOW_OFFSET; ++y) { - const coord_def pos = center + coord_def(x, y); + const coord_def sp = coord_def(x, y); + const coord_def pos = center + sp; if (map_bounds(pos)) - sh[x + sh_xo][y + sh_yo] = env.grid(pos); + sh(sp) = env.grid(pos); } } - void calc_show_los() { if (!crawl_state.arena && !crawl_state.arena_suspended) you.update_los(); } -bool see_cell(const env_show_grid &show, - const coord_def &c, - const coord_def &pos) -{ - if (c == pos) - return (true); - - const coord_def ip = pos - c; - if (ip.rdist() <= ENV_SHOW_OFFSET) - { - const coord_def sp(ip + coord_def(ENV_SHOW_OFFSET, ENV_SHOW_OFFSET)); - if (show(sp)) - return (true); - } - return (false); -} - // Answers the question: Is the cell visible to the observer? // Usually the same as player LOS. bool observe_cell(const coord_def &p) diff --git a/crawl-ref/source/los.h b/crawl-ref/source/los.h index 642f90deab..11d727fea0 100644 --- a/crawl-ref/source/los.h +++ b/crawl-ref/source/los.h @@ -39,16 +39,15 @@ int num_feats_between(const coord_def& source, const coord_def& target, bool just_check = false); bool cell_see_cell(const coord_def& p1, const coord_def& p2); +typedef SquareArray los_grid; + void clear_rays_on_exit(); -void losight(env_show_grid& sh, const coord_def& center, +void losight(los_grid& sh, const coord_def& center, const opacity_func &opc = opc_default, const circle_def &bds = BDS_DEFAULT); -void losight(env_show_grid& sh, const los_param& param); +void losight(los_grid& sh, const los_param& param); void calc_show_los(); -bool see_cell(const env_show_grid &show, - const coord_def &c, - const coord_def &pos ); bool observe_cell(const coord_def &p); bool trans_wall_blocking( const coord_def &p ); diff --git a/crawl-ref/source/los_def.cc b/crawl-ref/source/los_def.cc index b01938cf6f..4106a2c02a 100644 --- a/crawl-ref/source/los_def.cc +++ b/crawl-ref/source/los_def.cc @@ -75,5 +75,6 @@ bool los_def::in_bounds(const coord_def& p) const bool los_def::see_cell(const coord_def& p) const { - return (::see_cell(show, center, p)); + const coord_def sp = p - center; + return (sp.rdist() <= ENV_SHOW_OFFSET && show(sp)); } diff --git a/crawl-ref/source/los_def.h b/crawl-ref/source/los_def.h index 42ac3b58ee..9b9b4a421c 100644 --- a/crawl-ref/source/los_def.h +++ b/crawl-ref/source/los_def.h @@ -7,7 +7,7 @@ class los_def { - env_show_grid show; + los_grid show; coord_def center; opacity_func const * opc; circle_def bds; -- cgit v1.2.3-54-g00ecf