diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-10-16 17:03:06 +0200 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-10-16 20:17:48 +0200 |
commit | 564dac43f50543729d004dc1dfe905e81321837d (patch) | |
tree | 2615c2205a951f823f9d2dd4dd5a56763fe70517 /crawl-ref/source/los.cc | |
parent | 6c3f2bb24979f61b40a3a666d17059e0e874e92f (diff) | |
download | crawl-ref-564dac43f50543729d004dc1dfe905e81321837d.tar.gz crawl-ref-564dac43f50543729d004dc1dfe905e81321837d.zip |
On the way to a simplified losight interface.
Added a function
void losight(env_show_grid& sh, const coord_def& center,
opacity_func opc, bounds_func bounds)
with sensible defaults for opc and bounds.
It's not necessary to abstract away the geometry as I initially
did with los_param.
Diffstat (limited to 'crawl-ref/source/los.cc')
-rw-r--r-- | crawl-ref/source/los.cc | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc index a1723cd72b..896ad452c9 100644 --- a/crawl-ref/source/los.cc +++ b/crawl-ref/source/los.cc @@ -859,6 +859,40 @@ void losight(env_show_grid& sh, const los_param& dat) sh(o+sh_o) = dat.appearance(o); } +struct los_param_funcs : public los_param +{ + coord_def center; + opacity_func opc; + bounds_func bounds; + + los_param_funcs(const coord_def& c, + opacity_func o, bounds_func b) + : center(c), opc(o), bounds(b) + { + } + + bool los_bounds(const coord_def& p) const + { + return (map_bounds(p + center) && bounds(p)); + } + + unsigned appearance(const coord_def& p) const + { + return (grid_appearance(p + center)); + } + + opacity_type opacity(const coord_def& p) const + { + return (opc(p + center)); + } +}; + +void losight(env_show_grid& sh, const coord_def& center, + opacity_func opc, bounds_func bounds) +{ + losight(sh, los_param_funcs(center, opc, bounds)); +} + void losight_permissive(env_show_grid &sh, const coord_def& center) { for (int x = -ENV_SHOW_OFFSET; x <= ENV_SHOW_OFFSET; ++x) @@ -875,7 +909,7 @@ void calc_show_los() if (!crawl_state.arena && !crawl_state.arena_suspended) { // Must be done first. - losight(env.show, los_param_base(you.pos())); + losight(env.show, you.pos()); // What would be visible, if all of the translucent walls were // made opaque. |