router: Limit the amount of move attempts in ROUTER::Finish

Otherwise auto-finish hangs in some cases.
This commit is contained in:
Alex 2022-12-07 19:24:00 +03:00
parent b15913bd53
commit 82874daf08
1 changed files with 6 additions and 3 deletions

View File

@ -540,13 +540,16 @@ bool ROUTER::Finish()
if( !getNearestRatnestAnchor( otherEnd, otherEndLayers ) ) if( !getNearestRatnestAnchor( otherEnd, otherEndLayers ) )
return false; return false;
// Keep moving until we don't change position // Keep moving until we don't change position or hit the limit
int triesLeft = 5;
VECTOR2I moveResultPoint; VECTOR2I moveResultPoint;
do do
{ {
moveResultPoint = Placer()->CurrentEnd(); moveResultPoint = Placer()->CurrentEnd();
Move( otherEnd, &current ); Move( otherEnd, &current );
} while( Placer()->CurrentEnd() != moveResultPoint ); triesLeft--;
} while( Placer()->CurrentEnd() != moveResultPoint && triesLeft );
// If we've made it, fix the route and we're done // If we've made it, fix the route and we're done
if( moveResultPoint == otherEnd && otherEndLayers.Overlaps( GetCurrentLayer() ) ) if( moveResultPoint == otherEnd && otherEndLayers.Overlaps( GetCurrentLayer() ) )