[ZH] Fix game mismatch in team game when player surrenders and owns a base structure that has been cleared of infantry before #546
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 fixes one possible source of mismatches.
The underlying problem is in the
GarrisonContain
class. It exists for every structure that can contain other units (palace, bunker, etc.). The first time a unit is contained in that structure, this class saves the Player Team info of the associated building object. It uses that information to set the team when the last unit leaves the structure. This way, when a neutral building is emptied, it becomes neutral again.One bug is that when a player surrenders, the player info in
GarrisonContain
isn't updated to the player that takes ownership of the surrendered player's units. However, this bug alone doesn't cause a mismatch.The actual mismatch occurs because after surrendering, the surrendered player becomes an observer and executes code to update some variables (
m_hideGarrisonedStateFromNonallies
) so that they can see hidden garrisoned buildings (e.g., buildings with a Jarmen inside). At least, that's the intention of that code—it doesn’t actually work. Unfortunately, the same code also resets the team info when the structure is empty. Since this code runs only for the surrendered player, it results in a mismatch.We cannot actually fix the underlying issue without breaking compatibility, so this PR simply disables the code that runs for the new observer. It wasn't working anyway.
With this change, if the surrendering player is running this patch, no mismatch should occur, even if other 1.04 players are in the game. However, this PR introduces a minor side effect: when the surviving teammate fills the affected structure and then empties it again, the building will become neutral because the member variable in
GarrisonContain
is still set to the wrong value. But that's definitely better than a mismatch.Some things should still be tested:
Change list
Fixes Issue(s)