From 2fb004a5ae4d47af8151a821f296c25426fbe1e4 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 8 Oct 2009 19:57:59 +0200 Subject: Convert remaining uses of losight to los_param-style. --- crawl-ref/source/effects.cc | 4 ++-- crawl-ref/source/los.cc | 4 ++-- crawl-ref/source/losparam.cc | 19 +++++++++++++++++++ crawl-ref/source/losparam.h | 9 +++++++++ crawl-ref/source/spells3.cc | 2 +- crawl-ref/source/stuff.cc | 2 +- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 7385a352a9..acfd160e10 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -4344,9 +4344,9 @@ static int _mushroom_ring(item_def &corpse, int & seen_count) std::vector > radius_points; env_show_grid losgrid; - losight(losgrid, grd, corpse.pos, true); + losight(losgrid, los_param_solid(corpse.pos)); - collect_radius_points(radius_points,corpse.pos, losgrid); + collect_radius_points(radius_points, corpse.pos, losgrid); // So what we have done so far is collect the set of points at each radius // reachable from the origin with (somewhat constrained) 8 connectivity, diff --git a/crawl-ref/source/los.cc b/crawl-ref/source/los.cc index 400ea200a2..85ea3002af 100644 --- a/crawl-ref/source/los.cc +++ b/crawl-ref/source/los.cc @@ -852,11 +852,11 @@ void calc_show_los() if (!crawl_state.arena && !crawl_state.arena_suspended) { // Must be done first. - losight(env.show, grd, you.pos()); + losight(env.show, los_param_base(you.pos())); // What would be visible, if all of the translucent walls were // made opaque. - losight(env.no_trans_show, grd, you.pos(), true); + losight(env.no_trans_show, los_param_solid(you.pos())); } else { diff --git a/crawl-ref/source/losparam.cc b/crawl-ref/source/losparam.cc index cb4171c622..7c01d088c9 100644 --- a/crawl-ref/source/losparam.cc +++ b/crawl-ref/source/losparam.cc @@ -84,6 +84,25 @@ opacity_type los_param_base::opacity(const coord_def& p) const } +/* los_param_solid */ + +los_param_solid::los_param_solid(const coord_def& c) + : los_param_base(c) +{ +} + +opacity_type los_param_solid::opacity(const coord_def& p) const +{ + dungeon_feature_type f = feature(p); + if (grid_is_solid(f)) + return OPC_OPAQUE; + else if (is_opaque_cloud(cloud_idx(p))) + return OPC_HALF; + else + return OPC_CLEAR; +} + + /* los_param_compat */ los_param_compat::los_param_compat(const feature_grid& gr, const coord_def& c, diff --git a/crawl-ref/source/losparam.h b/crawl-ref/source/losparam.h index 15f1cc860a..db88db38d3 100644 --- a/crawl-ref/source/losparam.h +++ b/crawl-ref/source/losparam.h @@ -66,6 +66,15 @@ struct los_param_base : los_param_trans opacity_type opacity(const coord_def& p) const; }; +// Like los_param_base, but any solid object blocks. +// This includes clear walls and statues. +struct los_param_solid : los_param_base +{ + los_param_solid(const coord_def& c); + + opacity_type opacity(const coord_def& p) const; +}; + // Provides a compatible set of parameters for use with the // legacy losight() function. struct los_param_compat : los_param_base diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 71c4cbfa5f..23b49dd8f5 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1058,7 +1058,7 @@ int animate_dead(actor *caster, int pow, beh_type beha, unsigned short hitting, // Use an alternate LOS grid, based on the caster's LOS. env_show_grid losgrid; if (caster->atype() != ACT_PLAYER) - losight(losgrid, grd, caster->pos(), true); + losight(losgrid, los_param_solid(caster->pos())); int number_raised = 0; int number_seen = 0; diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 94a44ec5e2..fecb00a578 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -1695,7 +1695,7 @@ bool is_trap_square(dungeon_feature_type grid) // applied to new games. void zap_los_monsters() { - losight(env.show, grd, you.pos()); + losight(env.show, los_param_base(you.pos())); for (rectangle_iterator ri(crawl_view.vlos1, crawl_view.vlos2); ri; ++ri ) { -- cgit v1.2.3-54-g00ecf