summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/view.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-29 16:33:19 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-29 16:33:19 +0000
commitcb8422f12037b42d9384c05418c6fc19092d0c3e (patch)
tree4eef976361b607d65d385e5138569e38aebc990c /crawl-ref/source/view.cc
parent0cd39802e4c5e298442adb83922592c6ac800b1d (diff)
downloadcrawl-ref-cb8422f12037b42d9384c05418c6fc19092d0c3e.tar.gz
crawl-ref-cb8422f12037b42d9384c05418c6fc19092d0c3e.zip
Correct a mistake in the los check -- it's not quite so fast now, but at
least it works correctly. Reduce chances for friendly orcs some more, though by now the main speech stems from cantrip spells of friendly priests and wizards. (At least I couldn't find special messages for them in monspeak.txt.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5332 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/view.cc')
-rw-r--r--crawl-ref/source/view.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 7f62bf9057..1ad9934809 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -5461,12 +5461,12 @@ static bool _set_beam_target(int cx, int cy, int dx, int dy,
* / SW | SE \
*
* target1_x and target1_y mark the base line target, so the base beam ends
- * on the diagonal line closest to the target (or one of the straight line
- * if cx == dx or dx == dy).
+ * on the diagonal line closest to the target (or on one of the straight
+ * lines if cx == dx or dx == dy).
*
* target2_x and target2_y then mark the second target our beam finder should
* cycle through. It'll always be target2_x = dx or target2_y = dy, the other
- * being 0 or 2*LOS_RADIUS depending on the quadrant.
+ * being on the edge of LOS, which one depending on the quadrant.
*
* The beam finder can then cycle from the nearest corner (target1) to the
* second edge target closest to (dx,dy).
@@ -5607,6 +5607,18 @@ void monster_los::check_los_beam(int dx, int dy)
return;
}
+ if (target1_x > target2_x || target1_y > target2_y)
+ {
+ // Swap the two targets so our loop will work correctly.
+ int help = target1_x;
+ target1_x = target2_x;
+ target2_x = help;
+
+ help = target1_y;
+ target1_y = target2_y;
+ target2_y = help;
+ }
+
const int max_dist = LOS_RADIUS;
int dist;
bool blocked = false;