diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java index 212c9e18a..6fda87361 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/mechanics/ShadowCaster.java @@ -80,9 +80,6 @@ public final class ShadowCaster { int x, int y, double lSlope, double rSlope, int mX, int mY, boolean mXY){ - //if we have negative space to traverse, just quit. - if (rSlope < lSlope) return; - boolean inBlocking = false; int start, end; int col; @@ -91,6 +88,9 @@ public final class ShadowCaster { //for each row, starting with the current one for (; row <= distance; row++){ + + //if we have negative space to traverse, just quit. + if (rSlope < lSlope) return; //we offset by slightly less than 0.5 to account for slopes just touching a cell if (lSlope == 0) start = 0; @@ -109,6 +109,13 @@ public final class ShadowCaster { //for each column in this row, which for (col = start; col <= end; col++){ + + + //handles the error case of the slope value at the end of a cell being 1 farther + // along then at the beginning of the cell, and that earlier cell is vision blocking + if (col == end && inBlocking && (int)Math.ceil((row - 0.5) * rSlope - 0.499) != end){ + break; + } fov[cell] = true;