Force the pathfinder to build serpentine roads
This commit is contained in:

committed by
Jonathan G Rennison

parent
bd41cb618a
commit
198ef11a2b
17
src/road.cpp
17
src/road.cpp
@@ -885,6 +885,23 @@ static int32 PublicRoad_CalculateG(AyStar *, AyStarNode *current, OpenListNode *
|
|||||||
|
|
||||||
if (GetTileZ(parent->path.node.tile) != GetTileZ(current->tile)) {
|
if (GetTileZ(parent->path.node.tile) != GetTileZ(current->tile)) {
|
||||||
cost += COST_FOR_SLOPE;
|
cost += COST_FOR_SLOPE;
|
||||||
|
|
||||||
|
auto current_node = &parent->path;
|
||||||
|
auto parent_node = parent->path.parent;
|
||||||
|
|
||||||
|
// Force the pathfinder to build serpentine roads by punishing every slope in the last couple of tiles.
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
if (current_node == nullptr || parent_node == nullptr) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (GetTileZ(current_node->node.tile) != GetTileZ(parent_node->node.tile)) {
|
||||||
|
cost += COST_FOR_SLOPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
current_node = parent_node;
|
||||||
|
parent_node = current_node->parent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user