Conversation
There was a problem hiding this comment.
🟡 Changes recommended
One newly added comment misstates the behavior of the alive-team-change guard and should be corrected to avoid misleading future maintenance.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Refactors OnJoinTeamCommand() in TeamManager.sp to make team-selection intent clearer (explicit operator precedence in a ZR-specific condition) and remove a dead/always-true sub-condition, aligning with the stated readability audit findings.
Changes:
- Added explicit parentheses (and explanatory comment) to avoid operator-precedence ambiguity in the ZombieReloaded team-selection branch.
- Removed the redundant
NewTeam >= 0check afterNewTeamis already range-validated earlier in the function. - Updated nearby comments to describe the logic (one comment needs a small wording correction to match behavior).
File summaries
| File | Description |
|---|---|
| addons/sourcemod/scripting/TeamManager.sp | Clarifies ZR team-selection condition precedence and removes a dead team-range check in OnJoinTeamCommand(). |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+326
to
+327
| // 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. |
- 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 <noreply@anthropic.com>
Rushaway
force-pushed
the
refactor/jointeam-team-selection
branch
from
September 11, 2026 20:47
0db270f to
66743a5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audit finding —
OnJoinTeamCommand()readability / dead code1. Operator-precedence footgun
&&binds tighter than||, so this already meant(!g_bZombieSpawned && NewTeam == CS_TEAM_T) || NewTeam == CS_TEAM_NONE.Added the explicit parentheses + a comment. No behaviour change — this
just makes the intent obvious and silences the compiler warning.
2. Always-true condition
NewTeamis validated to be within[CS_TEAM_NONE, CS_TEAM_CT](i.e.>= 0) earlier in the function, soNewTeam >= 0is dead. Removed.Noted, not changed here
The
strcmp(command, "joingame")branch (lines ~274-281) is unreachable:only
"jointeam"is registered withAddCommandListener. Activating it(registering
"joingame"so the forced team-selection panel works) is abehaviour change that deserves its own tested PR.
🤖 Generated with Claude Code