1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Fix diagonal paths if we need to use them

This commit is contained in:
Tomasz Zieliński 2024-05-10 15:53:54 +02:00
parent a6fa6855dc
commit 7cb17afe7a

View File

@ -121,17 +121,13 @@ bool RoadPlacer::createRoad(const int3 & dst)
}
}
auto ret = dst.dist2d(src);
float weight = dst.dist2dSQ(src);
auto ret = weight * weight; // Still prefer straight paths
if (visitableTiles.contains(src) || visitableTiles.contains(dst))
{
ret *= VISITABLE_PENALTY;
}
float dist = border.distance(dst);
if(dist > 1)
{
ret /= dist;
}
return ret;
};
res = path.search(dst, false, desperateRoutig);