-
Notifications
You must be signed in to change notification settings - Fork 78
[ZH] Fix game mismatch in team game when player surrenders and owns a base structure that has been cleared of infantry before #546
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
We tested this fix with bunkers and it worked properly. The bunker didn't become neutral and there was no mismatch. |
Can we already add the proper fix in a !RETAIL_COMPATIBLE_CRC along with this change? |
I haven't investigated how to fix that in detail yet. It's probably a bigger change, so I'd prefer to do that later in another PR |
// the local player a mismatch results. | ||
// So for now we just comment it out. When we try to show disguises correctly for an observer | ||
// or we fix the team bug in the Contain classes, we can include this again. | ||
//becomingLocalPlayer(TRUE); // recalc disguises, etc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest write this as
#if 0
becomingLocalPlayer(TRUE); // recalc disguises, etc
#endif
This way it is easier to distinguish the disabled code from all this commenting.
// and the units transfer to another team. | ||
// In the end that means resetting the team sets it to neutral, and when this is done only for | ||
// the local player a mismatch results. | ||
// So for now we just comment it out. When we try to show disguises correctly for an observer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this text be simplified a bit? There are some filler words that can be removed. Also add the TheSuperHackers comment above.
Ok. |
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)