diff options
author | Robert Vollmert <rvollmert@gmx.net> | 2009-12-03 16:42:17 +0100 |
---|---|---|
committer | Robert Vollmert <rvollmert@gmx.net> | 2009-12-03 16:42:17 +0100 |
commit | 6c14b48b8dd2ce7558bca53f0387b3080f7e19ab (patch) | |
tree | d422d371d1187e057b65d34264759af52048f982 /crawl-ref/source/spells4.cc | |
parent | 9dc6a97ec5369d54c9c46c6bdced240ee56b1763 (diff) | |
download | crawl-ref-6c14b48b8dd2ce7558bca53f0387b3080f7e19ab.tar.gz crawl-ref-6c14b48b8dd2ce7558bca53f0387b3080f7e19ab.zip |
Fix off-by-one error in passwall depth calculation.
Also reorganize cast_passwall() a bit.
Diffstat (limited to 'crawl-ref/source/spells4.cc')
-rw-r--r-- | crawl-ref/source/spells4.cc | 24 |
1 files changed, 12 insertions, 12 deletions
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); } |