Skip to content

[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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

helmutbuhler
Copy link

@helmutbuhler helmutbuhler commented Mar 29, 2025

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:

  • Teamplayer leaving by: surrendering, exiting, disconnecting.
  • Playing with 1.04 players. Make sure they don't mismatch.
  • Make sure the surrendering player observes everything correctly after surrendering.

Change list

  • fix: Fixed mismatch that can happen in teamgames when a player surrenders with an empty palace.

Fixes Issue(s)

@xezon xezon changed the title [ZH] Fix: Game mismatches in team game when player surrenders and owns a base structure that has been cleared of infantry before [ZH] Fix game mismatch in team game when player surrenders and owns a base structure that has been cleared of infantry before Mar 30, 2025
@real2nabeel
Copy link

We tested this fix with bunkers and it worked properly. The bunker didn't become neutral and there was no mismatch.

@xezon xezon added this to the Stability fixes milestone Apr 28, 2025
@xezon xezon added the ZH Relates to Zero Hour label May 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ZH Relates to Zero Hour
Projects
None yet
3 participants