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.
This PR aims to fix 2 bugs that affect the UI and parts of the gameplay. They were introduced int this PR #833
Fix unit buttons
(Mostly) Because of the asynchronicity of the units, the unit action buttons would update while a selected unit was idle. So if a warrior just spawned in the capital, and was waiting to do something, an automated worker, or another warrior auto-moving in the background would cause the buttons to switch to that unit, and then, because "technically" we already have a unit selected, they wouldn't switch back to that unit's actions.
Also the button would flicker for the busy/automated units if there was nothing to move and just pressed the end turn button.
Fix NPE when a terraform doesn't have an improvement
The second bug, I again introduced with the relevant previous commit, where if there was no improvement on a tile, actions like Clear Forest had broken. A null pointer exception was thrown in the background but gameplay would continue normally.
This is because I was trying to access the current improvement to open the advisor pop up and ask if the player wants to override the previous improvement, which in this case it was null and not properly checked for.