From 66743a5462b6bc5ac80646047a2a7e970060439b Mon Sep 17 00:00:00 2001 From: Rushaway Date: Wed, 9 Sep 2026 17:58:56 +0200 Subject: [PATCH] refactor: clarify team-selection logic in OnJoinTeamCommand - Add explicit parentheses to the ZombieReloaded team remap. `&&` binds tighter than `||`, so the condition already meant `(!g_bZombieSpawned && NewTeam == CS_TEAM_T) || NewTeam == CS_TEAM_NONE`; this only makes the intent readable and silences the compiler warning. - Drop the always-true `NewTeam >= 0` check from the alive-team-change guard. NewTeam is validated to be within [CS_TEAM_NONE, CS_TEAM_CT] earlier in the function. Note for reviewers: the `strcmp(command, "joingame")` branch is currently dead code because only "jointeam" is registered with AddCommandListener. Left as-is here; activating it (registering "joingame") should be a separate, tested change. Co-Authored-By: Claude Sonnet 5 --- addons/sourcemod/scripting/TeamManager.sp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/addons/sourcemod/scripting/TeamManager.sp b/addons/sourcemod/scripting/TeamManager.sp index 09249e8..51b2d21 100644 --- a/addons/sourcemod/scripting/TeamManager.sp +++ b/addons/sourcemod/scripting/TeamManager.sp @@ -306,7 +306,9 @@ public Action OnJoinTeamCommand(int client, const char[] command, int argc) if(g_bZombieReloaded) { - if(!g_bZombieSpawned && NewTeam == CS_TEAM_T || NewTeam == CS_TEAM_NONE) + // Auto-assign (NONE) always goes to CT; joining T before the mother + // zombie has spawned is redirected to CT as well. + if((!g_bZombieSpawned && NewTeam == CS_TEAM_T) || NewTeam == CS_TEAM_NONE) NewTeam = CS_TEAM_CT; else if(g_bZombieSpawned && NewTeam == CS_TEAM_SPECTATOR) @@ -318,8 +320,9 @@ public Action OnJoinTeamCommand(int client, const char[] command, int argc) if(NewTeam == CurrentTeam) return Plugin_Handled; - // Prevent players from changing team if they are already in a team (CT or T) - if(!g_cvAliveTeamChange.BoolValue && IsPlayerAlive(client) && NewTeam >= 0 && (CurrentTeam == CS_TEAM_T || CurrentTeam == CS_TEAM_CT)) + // Prevent alive players from switching between CT and T when disallowed. + // NewTeam is already validated to be within [CS_TEAM_NONE, CS_TEAM_CT] above. + if(!g_cvAliveTeamChange.BoolValue && IsPlayerAlive(client) && (CurrentTeam == CS_TEAM_T || CurrentTeam == CS_TEAM_CT)) return Plugin_Handled; ChangeClientTeam(client, NewTeam);