[GEN][ZH] Fixed garrison points not initialized before first use #783
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.
Fixes garrison points not initialized before first use throwing an debug asset
Background
GarrisonContain::loadGarrisonPoints()
method is not initially run when the object is created becausedraw
is false inGarrisonContain::onObjectCreated()
.The first time
loadGarrisonPoints()
is called is when the first unit garissons the object andGarrisonContain::onContaining()
is called. At that point the debug assert has already fired.The issue lies in its parent class method
OpenContain::addToContain
.It first calls
redeployOccupants()
, which contains the assert, then callsonContaining
.Solution in this PR is to call
redeployOccupants()
afteronContaining
.I've tested it by building, occupying exiting and destroying garrisonable objects to ensure there were no unexpected side effect.
This did however caused a mismatch in the Golden replay (about 10 minutes in).
I have looked at less elegant solutions - e.g. calling
loadGarrisonPoints()
inredeployOccupants
, but that still causes a mismatch.