Core/Movement: fixed edge cases in which hovering units were considered far from poly during path generation, resulting in incomplete paths getting returned

This commit is contained in:
Ovahlord committed 2023-08-24 21:35:05 +02:00
1 parent ff3beb0e92
commit 5a62d6c570
2 files changed
+9 -8

No files matched your search

+7 -2
View File
@@ -222,8 +222,13 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
}
// we may need a better number here
bool startFarFromPoly = distToStartPoly > 7.0f;
bool endFarFromPoly = distToEndPoly > 7.0f;
float allowedPolyDist = 7.0f;
if (Unit const* unit = _source->ToUnit())
if (unit->IsHovering()) // some hovering units hover above the original 7.0f threshold so we have to take their hover offset into consideration
allowedPolyDist = std::max(allowedPolyDist, unit->GetHoverOffset());
bool startFarFromPoly = distToStartPoly > allowedPolyDist;
bool endFarFromPoly = distToEndPoly > allowedPolyDist;
if (startFarFromPoly || endFarFromPoly)
{
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f", distToStartPoly, distToEndPoly);