HomeWildfire Games

Fix some cases of units getting stuck.

Description

Fix some cases of units getting stuck.

This fixes an off-by-one error that led to entities sometimes getting stuck against obstructions.
It also increases the max-range of the short pathfinder to help entities find their way around corridors and house blocks.

Fixes rP22609 (off-by-one error) and reverts the range changes from rP22526

Reported By: Freagarach

Fixes #5586 . Refs #5624

Differential Revision: https://code.wildfiregames.com/D2754

Event Timeline

Commit message is incorrect, though this was still a necessary change (but perhaps not optimally clear)
The problem isn't really an off-by-one error, but the different systems interacting in unexpected ways.

HandleObstructedMove needs a long waypoint to short-path towards, which is why the original code (from D2095/rP22507 and not rP22609, but that merely imitated PathResult from rP16751) kept the last long-waypoint. However, as noted on the diff, there was a possibility of never actually taking the alternate code-path that recomputed a proper long path, thus the unit was stuck. If we pop all waypoints, a path is recomputed, so this cleared that issue.

Fact is the 'workaround' feature in HandleObstructedMove needs to make sure that it recomputes a long path at least once at some point, or the behaviour of the system can fail.
It's probably better to handle this explicitly particularly since removing too many waypoints is broken, thus D3203 does it.

vladislavbelov added inline comments.
/ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
1030

That's called !m_LongPath.m_Waypoints.empty().