Don't animate if there is nothing to animate #1494
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
SUMMARY: Performance "Do not go into animation loop if there is nothing to animate"
Purpose of change
When using animations the game will check for user input more quickly so that any active animations can progress. With terminal builds animations are fairly rare. This burns CPU time to do little of importance. A user reported high CPU usage with animations enabled on curses build that disappeared when disabled, even when there was no weather, SCT, nor after-life to animate.
Describe the solution
Check early to see if there is anything in need of animation. If there is something that requires we go into the faster animate loop do so. Otherwise treat it like animation is turned off to save some CPU time since new animations won't begin until at least after user input has been obtained.
In the case of TILES builds we will go ahead and enter animation loop anyway because there may be minimap or terrain animations to do and according to the comment these are not cached.
Describe alternatives you've considered
Leave it alone. For any recent CPUs the load from getting input isn't going to break anything. It's a minor problem.
Testing
Started character with animations off, stood still, observed CPU load for baseline.
Turned animations on with nothing around to animate, observed CPU load was similar.
Changed weather to rain, observed CPU load increase now that it has something to animate
Changed weather to clear, then got into a fight to see SCT animations, observed above baseline CPU load in small spikes
Died and watched the world move on.
Previous functionality remained.
Sent patch to reporting user to see if it helped them, it did.