1
0
forked from 0ad/0ad

Fix degenerate case in UnitMotion resulting in lag.

9d82ae15af introduced logic to extend the search range of the short
pathfinder in some situations. This extension was unbounded, resulting
occasionally in search domains several hundred meters wide, and path
computation that can take several seconds.

Reported by: Vico (on the forums).
Differential Revision: https://code.wildfiregames.com/D3760
This was SVN commit r25150.
This commit is contained in:
wraitii 2021-03-28 13:12:51 +00:00
parent 4146428825
commit f6a2d6da63

View File

@ -1632,7 +1632,11 @@ void CCmpUnitMotion::RequestShortPath(const CFixedVector2D &from, const PathGoal
{
CFixedVector2D dist(from.X - goal.x, from.Y - goal.z);
if (dist.CompareLength(searchRange - entity_pos_t::FromInt(1)) >= 0)
{
searchRange = dist.Length() + fixed::FromInt(1);
if (searchRange > SHORT_PATH_MAX_SEARCH_RANGE)
searchRange = SHORT_PATH_MAX_SEARCH_RANGE;
}
}
m_ExpectedPathTicket.m_Type = Ticket::SHORT_PATH;