• Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

[Error] Auto Balance Bug

EDIT: THE CAUSE OF THIS BUG HAS BEEN FOUND:

The issue is gone by putting the autobalance to 2, instead of 1. So the bug happens only when it's set to 1, probably why it hasn't happened on other servers. I guess most admins let it at 2.

FIX FOR SERVER ADMINS:
Maximum Team Difference must be set to 2 or more, if it is set to 1 it will cause this bug.



--------------original post below----------------

So you get autobalanced to the other team, but when you respawn...

-you spawn with your former team in their spawn zone
-you're in your former team's uniform
-with your former team's weapons
-with your new team's voice
-you are listed with your new team on the scoreboard
-killing your old team counts as a TK
-killing your new team counts as a good kill
-you still capture/defend with your old team

This happens EVERY time somebody gets auto balanced ever since the GOTY patch. (on our servers at least, I don't know about anybody else's servers)

I'm not sure if this is a related issue or not, but many times I'll join a server, and when I see the screen to pick my team, I have to pick the one with the higher number because the game will not allow me to select the team with fewer players. I suspect the autobalance glitch is causing this to happen too.
 
Last edited:
It's happening on all our servers. The autobalance is set like this:

Balance Teams: Yes
Balance Teams On Death: Yes
Maximum Team Difference: 1

I think the default "Maximum Team Difference" was 2. I'll try to put it back there to see if it patches the problem.
 
Last edited:
Upvote 0
Happened to me plenty of times. Every time I get auto-balanced while playing Countdown I press escape and it keeps me in my team, same class and weapon.
Also the enemies names appear over their heads.
Will there be another patch or have they dropped this game?

I've had the same thing as well on Territory on U.S servers. I also repick my original team and just continue on......
 
Upvote 0
I tried it for the first time the other day. Quite a weird experience, and I can see how it can be exploited. Snipers and other concealed enemies are very visible on account of the name tag displaying on top of them.

Hopefully this is one of the bugs that will be fixed come next patch.
 
Upvote 0
I just made some testing and looked at the code, and found the cause of the bug.

In CheckBalanceTeamsOnDeath, the condition to bypass the autobalance is:
Code:
	if ( ROTeamInfo(GameReplicationInfo.Teams[CurrentTeamIdx]).[COLOR="Yellow"]NumPlayers [/COLOR]-
		 ROTeamInfo(GameReplicationInfo.Teams[1 - CurrentTeamIdx]).[COLOR="yellow"]NumPlayers [/COLOR]<= MaxDiff )
	{
		return;
	}

It is based on NumPlayers, which is the number of human players (not bots). So lets say you have 2 humans on 1 side, and 2 bots on the other team. When one of the human players die, the autobalance function (CheckBalanceTeamsOnDeath) is trigerred to balance the humans only (later on, a bot should switch teams).

At the end of this function, those calls are issued:
Code:
	JoinTeam(KilledPlayer, 1 - CurrentTeamIdx);
	KilledPlayer.ChangedTeams(1 - CurrentTeamIdx, true,, true);

First observation, JoinTeam has a return value of true/false, that means whether the team change has been done or not. The return value is NOT monitored. JoinTeam executes the server-side teams swap, and the second instruction executes the client-side teams swap. In the bug we are experiencing, it is clear that JoinTeam does not work, because only the client sees that he changed teams, although he didn't really changed teams.

To fix the "false" team change, it would be necessary to monitor the return value of JoinTeam. But that's not the end of the story. If the conditions that trigger the autobalance have been detected, why isn't JoinTeam issuing the team change? A small inspection of JoinTeam is required.

In JoinTeam, before making the team change, this condition is verified:
Code:
if ( TeamID == PickTeam(TeamID, Other) )

PickTeam is a function used to know which team you should go onto. So for example, when the game begins, and you click to select one team, this function is called, if you click the german teams, it calls PickTeam with German team as parameter. If the german team is full, it returns allies. Since autobalance has been triggered, PickTeam should return the team with the lowest human player count. There lies the core of the problem, look at the condition evaluated by PickTeam:

Code:
GameReplicationInfo.Teams[Current].[COLOR="yellow"]Size[/COLOR] - GameReplicationInfo.Teams[1 - Current].[COLOR="yellow"]Size[/COLOR] < MaxDiff - TeamAdjustment

Size! It's looking at the total number of players (humans + bots), opposedly to the autobalance function. So, while the autobalance sees an unbalance in human players, pickTeams sees no difference in the total number of players/team. PickTeam will return the current team of the player, not the team with less human players. The condition of the JoinTeam function won't be verified, and JoinTeam will not proceed. Since the return value is not monitored, the client function will be called from CheckBalanceTeamsOnDeath, triggering the bug.

How to fix that mess?

1. Monitor the return value of JoinTeam in CheckBalanceTeamsOnDeath:
Code:
	[COLOR="Red"]if([/COLOR]JoinTeam(KilledPlayer, 1 - CurrentTeamIdx)[COLOR="red"])
	{[/COLOR]
		KilledPlayer.ChangedTeams(1 - CurrentTeamIdx, true,, true);
	[COLOR="red"]}[/COLOR]

2. Fix the PickTeam function (FOR THE PLAYERS SECTION OF THE CODE ONLY, NOT FOR THE BOT CODE):

Code:
		if ( !bBalanceTeams || GameReplicationInfo.Teams[Current].[COLOR="red"]NumPlayers [/COLOR]- GameReplicationInfo.Teams[1 - Current].[COLOR="red"]NumPlayers[/COLOR]< MaxDiff - TeamAdjustment )
		{
			// Allow them to join their desired Team
			return Current;
		}
		else
		{
			// Otherwise, force them onto the other Team
			return (1 - Current);
		}

Fixing that function should also fix the problem where you can't join the other team because bots take the place of human players (within autobalance threshold)...

The issue is gone by putting the autobalance to 2, instead of 1. So the bug happens only when it's set to 1, probably why it hasn't happened on other servers. I guess most admins let it at 2.

Actually, setting a value of 2 doesn't fix the issue. You can reproduce it with 3 humans on 1 side, and 3 bots on the other side. But the bug just has less probability of happening with a value of 2... so it gave the illusion of being fixed.
 
Last edited:
Upvote 0