Page MenuHomeWildfire Games

Fix UnitMotion calculation of time left to avoid units going ever so slightly too fast.
ClosedPublic

Authored by wraitii on Wed, May 1, 12:03 PM.

Details

Reviewers
None
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP22249: Fix UnitMotion calculation of time left to avoid units going back and forth…
Summary

As reported by @wowgetoffyourcellphone on the forums: units sometimes go ever so slightly too fast over an individual turn, making them quickly alternate between walking and running animation to disastrous effect.

The attached replay show this behaviour for blue cav at 3:15-30.

The source of this issue is that unitMotion is too optimistic about how much it can travel sometimes. This appears to be because the timeLeft computation rounds incorrectly. Changing the division arithmetic fixes it (though admittedly this is a tad slower).

Test Plan

Review the math change / suggest better.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wraitii created this revision.Wed, May 1, 12:03 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/1315/display/redirect

Imarok added a subscriber: Imarok.Wed, May 1, 2:52 PM

No idea, but does it make sense to test against that behaviour?

gameboy added a subscriber: gameboy.Wed, May 1, 2:53 PM

Can this patch be officially released?

Imarok added inline comments.Wed, May 1, 2:56 PM
source/simulation2/components/CCmpUnitMotion.cpp
912 ↗(On Diff #7893)

Why not reuse maxdist?

Can't be easily tested as it's the middle part of a big function in UnitMotion I think.

source/simulation2/components/CCmpUnitMotion.cpp
912 ↗(On Diff #7893)

Didn't notice we did that calculation already.

Stan added a subscriber: Stan.Wed, May 1, 4:33 PM

Good this way it won't be any slower :)

wraitii updated this revision to Diff 7904.Sat, May 4, 4:54 PM

Optimised.

Vulcan added a comment.Sat, May 4, 5:28 PM

Successful build - Chance fights ever on the side of the prudent.

Link to build: https://jenkins.wildfiregames.com/job/differential/1324/display/redirect

This revision was not accepted when it landed; it landed in state Needs Review.Sat, May 4, 5:53 PM
This revision was automatically updated to reflect the committed changes.

I'm not sure, but I don't think this was fixed. Units still randomly enter run mode even after the autobuild.