rwe
rwe copied to clipboard
When player orders a unit to move to an invalid location, really path to a valid one
Running the pathfinder exhaustively is really slow, we want to avoid that. The pathfinder will run exhaustively when the location it is trying to path to is unwalkable by the unit. This results in lag when the player clicks to move a unit somewhere invalid, e.g. on top of a tree.
We should solve this by selecting an alternative location when the chosen location is invalid. Something like the closest valid location to that point. This will reduce the likelihood that the location will be unreachable.
It's tempting to just avoid this for a while since the pathfinder is working okay as-is without this change. This change wouldn't change apparent behaviour and is just an optimisation.