From 6c14b48b8dd2ce7558bca53f0387b3080f7e19ab Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Thu, 3 Dec 2009 16:42:17 +0100 Subject: Fix off-by-one error in passwall depth calculation. Also reorganize cast_passwall() a bit. --- crawl-ref/source/spells4.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'crawl-ref/source/spells4.cc') diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index cfee0b35f8..3a87718b9e 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -920,8 +920,13 @@ bool cast_passwall(const coord_def& delta, int pow) int range = shallow + random2(pow) / 25; int maxrange = shallow + pow / 25; - coord_def n = you.pos() + delta; - if (!_feat_is_passwallable(grid_appearance(n))) + coord_def dest; + for (dest = you.pos() + delta; + in_bounds(dest) && _feat_is_passwallable(grd(dest)); + dest += delta) ; + + int walls = (dest - you.pos()).rdist() - 1; + if (walls == 0) { mpr("That's not a passable wall."); return (false); @@ -929,23 +934,18 @@ bool cast_passwall(const coord_def& delta, int pow) // Below here, failing to cast yields information to the // player, so we don't make the spell abort (return true). - - int howdeep; - for (howdeep = 1; in_bounds(n) && _feat_is_passwallable(grd(n)); - n += delta, howdeep++); - - if (!in_bounds(n)) + if (!in_bounds(dest)) mpr("You sense an overwhelming volume of rock."); - else if (feat_is_solid(grd(n))) + else if (feat_is_solid(grd(dest))) mpr("Something is blocking your path through the rock."); - else if (howdeep > maxrange) + else if (walls > maxrange) mpr("This rock feels extremely deep."); - else if (howdeep > range) + else if (walls > range) mpr("You fail to penetrate the rock."); else { // Passwall delay is reduced, and the delay cannot be interrupted. - start_delay(DELAY_PASSWALL, 1 + howdeep, n.x, n.y); + start_delay(DELAY_PASSWALL, 1 + walls, dest.x, dest.y); } return (true); } -- cgit v1.2.3-54-g00ecf