Only calculate input points once in IsBlockedByPreviousBridgeOrTunnel
This commit is contained in:
14
src/road.cpp
14
src/road.cpp
@@ -638,6 +638,13 @@ static bool IsBlockedByPreviousBridgeOrTunnel(OpenListNode *current, TileIndex s
|
|||||||
PathNode* start = ¤t->path;
|
PathNode* start = ¤t->path;
|
||||||
PathNode* end = current->path.parent;
|
PathNode* end = current->path.parent;
|
||||||
|
|
||||||
|
Point start_b {};
|
||||||
|
start_b.x = TileX(start_tile);
|
||||||
|
start_b.y = TileY(start_tile);
|
||||||
|
Point end_b {};
|
||||||
|
end_b.x = TileX(end_tile);
|
||||||
|
end_b.y = TileY(end_tile);
|
||||||
|
|
||||||
while (end != nullptr) {
|
while (end != nullptr) {
|
||||||
Point start_a {};
|
Point start_a {};
|
||||||
start_a.x = TileX(start->node.tile);
|
start_a.x = TileX(start->node.tile);
|
||||||
@@ -646,13 +653,6 @@ static bool IsBlockedByPreviousBridgeOrTunnel(OpenListNode *current, TileIndex s
|
|||||||
end_a.x = TileX(end->node.tile);
|
end_a.x = TileX(end->node.tile);
|
||||||
end_a.y = TileY(end->node.tile);
|
end_a.y = TileY(end->node.tile);
|
||||||
|
|
||||||
Point start_b {};
|
|
||||||
start_b.x = TileX(start_tile);
|
|
||||||
start_b.y = TileY(start_tile);
|
|
||||||
Point end_b {};
|
|
||||||
end_b.x = TileX(end_tile);
|
|
||||||
end_b.y = TileY(end_tile);
|
|
||||||
|
|
||||||
if (!AreTilesAdjacent(start->node.tile, end->node.tile) &&
|
if (!AreTilesAdjacent(start->node.tile, end->node.tile) &&
|
||||||
(AreIntersecting(start_a, end_a, start_b, end_b) || AreParallelOverlapping(start_a, end_a, start_b, end_b))) {
|
(AreIntersecting(start_a, end_a, start_b, end_b) || AreParallelOverlapping(start_a, end_a, start_b, end_b))) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user