Skip to content

fix: exclude SourceTV from warmup player counts - #44

Open
busheezy wants to merge 4 commits into
srcdslab:masterfrom
BadServersNet:fix/42-ignore-sourcetv-player-count
Open

busheezy wants to merge 4 commits into
srcdslab:masterfrom
BadServersNet:fix/42-ignore-sourcetv-player-count

Conversation

@busheezy

Copy link
Copy Markdown
Contributor

Excludes SourceTV clients from the connected and in-game player counts used by the warmup ratio.

Fixes #42

Copilot AI lite review requested due to automatic review settings September 12, 2026 09:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused change has no unresolved issues.

Pull request overview

Fixes warmup player-ratio calculations by excluding SourceTV clients.

Changes:

  • Adds SourceTV-aware player counting.
  • Uses filtered counts for connected and in-game ratios.
File summaries
File Description
addons/sourcemod/scripting/TeamManager.sp Excludes SourceTV clients from warmup ratio calculations.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@Rushaway

Copy link
Copy Markdown
Member

Suggestion: default sm_teammanager_warmup_exclude_spectators to 0 instead of 1, so this doesn'''t silently change behavior for existing servers (legacy warmup counted spectators). Also a small simplification to avoid iterating MaxClients twice per timer tick — merge the two GetWarmupPlayerCount(bool) calls into one pass:

	g_cvExcludeSpectators = CreateConVar("sm_teammanager_warmup_exclude_spectators", "0", "Exclude spectators from warmup player counts. [0 = Disabled | 1 = Enabled]", 0, true, 0.0, true, 1.0);
-		int ClientsConnected = GetWarmupPlayerCount(false);
-		int ClientsInGame = GetWarmupPlayerCount(true);
+		int ClientsConnected, ClientsInGame;
+		GetWarmupPlayerCounts(ClientsConnected, ClientsInGame);
 		int ClientsNeeded = RoundToCeil(float(ClientsConnected) * g_cvPlayersRatio.FloatValue);
-stock int GetWarmupPlayerCount(bool InGameOnly)
+stock void GetWarmupPlayerCounts(int &ClientsConnected, int &ClientsInGame)
 {
-	int Clients = 0;
+	ClientsConnected = 0;
+	ClientsInGame = 0;
 
 	for (int client = 1; client <= MaxClients; client++)
 	{
-		if (!IsClientConnected(client) || IsClientSourceTV(client))
+		if (!IsClientConnected(client) || IsClientSourceTV(client) || IsWarmupSpectator(client))
 		{
 			continue;
 		}
 
-		if (InGameOnly && !IsClientInGame(client))
-		{
-			continue;
-		}
-
-		if (IsWarmupSpectator(client))
-		{
-			continue;
-		}
-
-		Clients++;
+		ClientsConnected++;
+
+		if (IsClientInGame(client))
+		{
+			ClientsInGame++;
+		}
 	}
-
-	return Clients;
 }

I couldn't push directly to this branch — BadServersNet/sm-plugin-team-manager is an org-owned fork, and GitHub doesn't support "allow edits from maintainers" on org forks (only personal-account forks). Feel free to apply these as-is.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: SourceTV counts as a player

3 participants