-
-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fixes cannot see that issue with Map LOS Refactor. #2103
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -973,25 +973,21 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
return false; | ||
} | ||
|
||
if (origin.X > destination.X || origin.X == destination.X && origin.Y > destination.Y || origin.X == destination.X && origin.Y == destination.Y && origin.Z > destination.Z) | ||
{ | ||
(origin, destination) = (destination, origin); | ||
} | ||
|
||
Point3D p; | ||
var path = new Point3DList(); | ||
TileFlag flags; | ||
|
||
if (origin == destination) | ||
{ | ||
return true; | ||
} | ||
|
||
if (path.Count > 0) | ||
var end = destination; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Crux of the change. put back |
||
|
||
if (origin.X > destination.X || origin.X == destination.X && origin.Y > destination.Y || origin.X == destination.X | ||
&& origin.Y == destination.Y && origin.Z > destination.Z) | ||
{ | ||
path.Clear(); | ||
(origin, destination) = (destination, origin); | ||
} | ||
|
||
var path = new Point3DList(); | ||
|
||
var xd = destination.X - origin.X; | ||
var yd = destination.Y - origin.Y; | ||
var zd = destination.Z - origin.Z; | ||
|
@@ -1005,15 +1001,17 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
double y = origin.Y; | ||
double z = origin.Z; | ||
double x = origin.X; | ||
while (Utility.NumberBetween(x, destination.X, origin.X, 0.5) && Utility.NumberBetween(y, destination.Y, origin.Y, 0.5) && | ||
while (Utility.NumberBetween(x, destination.X, origin.X, 0.5) && | ||
Utility.NumberBetween(y, destination.Y, origin.Y, 0.5) && | ||
Utility.NumberBetween(z, destination.Z, origin.Z, 0.5)) | ||
{ | ||
var ix = (int)Math.Round(x); | ||
var iy = (int)Math.Round(y); | ||
var iz = (int)Math.Round(z); | ||
|
||
if (path.Count > 0) | ||
{ | ||
p = path.Last; | ||
var p = path.Last; | ||
|
||
if (p.X != ix || p.Y != iy || p.Z != iz) | ||
{ | ||
|
@@ -1035,18 +1033,13 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
return true; // <--should never happen, but to be safe. | ||
} | ||
|
||
p = path.Last; | ||
|
||
if (p != destination) | ||
if (path.Last != destination) | ||
{ | ||
path.Add(destination); | ||
} | ||
|
||
Point3D pTop = origin, pBottom = destination; | ||
Utility.FixPoints(ref pTop, ref pBottom); | ||
|
||
var pathCount = path.Count; | ||
var endTop = destination.Z + 1; | ||
var endTop = end.Z + 1; | ||
|
||
for (var i = 0; i < pathCount; ++i) | ||
{ | ||
|
@@ -1057,7 +1050,7 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
GetAverageZ(point.X, point.Y, out var landZ, out _, out var landTop); | ||
|
||
if (landZ <= pointTop && landTop >= point.m_Z && | ||
(point.X != destination.X || point.Y != destination.Y || landZ > endTop || landTop < destination.Z) && | ||
(point.X != end.X || point.Y != end.Y || landZ > endTop || landTop < end.Z) && | ||
!landTile.Ignored) | ||
{ | ||
return false; | ||
|
@@ -1085,14 +1078,14 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
|
||
var id = TileData.ItemTable[t.ID & TileData.MaxItemValue]; | ||
|
||
flags = id.Flags; | ||
var flags = id.Flags; | ||
|
||
if ( | ||
t.Z <= pointTop && t.Z + id.CalcHeight >= point.Z && | ||
(flags & (TileFlag.Window | TileFlag.NoShoot)) != 0 && | ||
(point.X != destination.X || | ||
point.Y != destination.Y || | ||
t.Z > endTop || t.Z + id.CalcHeight < destination.Z) | ||
(point.X != end.X || | ||
point.Y != end.Y || | ||
t.Z > endTop || t.Z + id.CalcHeight < end.Z) | ||
) | ||
{ | ||
return false; | ||
|
@@ -1117,6 +1110,10 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
} | ||
} | ||
|
||
var pTop = origin; | ||
var pBottom = destination; | ||
Utility.FixPoints(ref pTop, ref pBottom); | ||
|
||
var rect = new Rectangle2D(pTop.X, pTop.Y, pBottom.X - pTop.X + 1, pBottom.Y - pTop.Y + 1); | ||
|
||
foreach (var item in GetItemsInBounds(rect)) | ||
|
@@ -1132,7 +1129,7 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
} | ||
|
||
var id = item.ItemData; | ||
flags = id.Flags; | ||
var flags = id.Flags; | ||
|
||
if ((flags & (TileFlag.Window | TileFlag.NoShoot)) == 0) | ||
{ | ||
|
@@ -1160,14 +1157,14 @@ public bool LineOfSight(Point3D origin, Point3D destination) | |
itemLocation.X == destination.X && itemLocation.Y == destination.Y) && | ||
|
||
// Item is at some point along the path BEFORE the target | ||
(itemLocation.X != destination.X || | ||
itemLocation.Y != destination.Y || | ||
(itemLocation.X != end.X || | ||
itemLocation.Y != end.Y || | ||
|
||
// Item is diagonally looking DOWN at the target | ||
itemLocation.Z > endTop || | ||
|
||
// Item is diagonally looking UP at the target | ||
itemLocation.Z + id.CalcHeight < destination.Z) | ||
itemLocation.Z + id.CalcHeight < end.Z) | ||
) | ||
{ | ||
return false; | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bumped this to 16 because
eye
level is 14, and those checks use 15 point locations, so it is pretty common.