From #4420.
(outdated, read comments)
UnitMotion? has always been quite annoying to change, and full of a variety of complicated bugs. Its ties with unitAI are also quite annoying.
I have rewritten it.Test it out here: https://github.com/wraitii/0ad/tree/D13_UM_rewrite_core
"Big" changes:
-Dumped the m_State/m_PathState variablesThis includes the absolutely-needed diffs D981, D53 and D438, and generally streamlined the uas well as 2 others.
This is a mostly complete rewrite of UnitMotion logic,n (and associated parts). implemented an easier way to wait some turns when paths fail and react accordingly (should reduce units getting stuck and the number of potential bugs in general).The goals are:
-Let UnitMotion? handle the move animations instead of hacking it with unitAI. This means that ultimately we could have "walk-attack", "run-gather" animations. But for now we don't really support that. vastly increased code clarity and quality
-Changed speed to just walk speed, and use a ratio to change it instead of an absolute value. Ultimately, I plan te delete run speeds, but haven't gotten around to it yet. reducing chances to shoot oneself in the foot when updating unitMotion
In some finer points- bug fixing
The main change is a philosophy change: UnitMotion now always tries to reach the goal, I dump the "longPath"/"shortPath" split to just be a simple "Path",and never assumes more than that. so that if we remove the short pathfinder someday that will be easierUnitAI is now in charge of stopping when it wants to (this logic has only be partially applied to UnitAI in this diff to keep things… small-ish).
---
Gameplay-wise, and it just makes the whole ththis does:
- Fix all instances of gliding units (current and hopefully future by structuring nicer.the code better)
I also have a test map, available on my github branches: - Drastically reduce the number of stuck units by improving short-range/long-range pathfinder compatibility (without changes to the pathfinders themselves!)
-Working branch: https://github.com/wraitii/0ad/tree/UnitMotionRewrite - Allow unitAI to do things while walking (such as fighting or gathering - unimplemented for now, as this will also need animation engine changes)
-"Cleaned up" branch: https://github.com/wraitii/0ad/tree/UMRewrite_Clean - Keep formations and current functionality
Cleaned up branch might be slightly easier to review. - Set us up for pushing by using a manager.
---
Performance-wise, ought to be similar (the use of the manager reduces the number of messages sent, Attached unified diff (sans map) below.but this is offset by probably a little slowness passing around more things)