Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sr2echa/TF2-Source-Code/llms.txt
Use this file to discover all available pages before exploring further.
CTFGameRules is TF2’s top-level game rules class. It inherits from CTeamplayRoundBasedRules (teamplayroundbased_gamerules.h), which provides the shared round state machine, respawn wave timing, stalemate logic, and team win tracking. CTFGameRules extends this base with TF-specific game type dispatch, holiday logic, MvM population management, and competitive extensions.
Inheritance chain
Round state machine
CTeamplayRoundBasedRules drives all round transitions via the gamerules_roundstate_t enum. Each state maps to a distinct phase in the match lifecycle.
Game types
CTFGameRules stores an ETFGameType network variable (m_nGameType) that controls which objective logic is active. The enum is defined in tf_shareddefs.h.
| Value | Enum | Mode |
|---|---|---|
| 0 | TF_GAMETYPE_UNDEFINED | Unknown / unset |
| 1 | TF_GAMETYPE_CTF | Capture the Flag |
| 2 | TF_GAMETYPE_CP | Control Points (5CP, A/D, KOTH) |
| 3 | TF_GAMETYPE_ESCORT | Payload / Payload Race |
| 4 | TF_GAMETYPE_ARENA | Arena |
| 5 | TF_GAMETYPE_MVM | Mann vs. Machine |
| 6 | TF_GAMETYPE_RD | Robot Destruction |
| 7 | TF_GAMETYPE_PASSTIME | PASS Time |
| 8 | TF_GAMETYPE_PD | Player Destruction |
Win conditions
Win reasons are encoded in theWINREASON_* enum and broadcast to clients when a round ends.
WINREASON_DEFEND_UNTIL_TIME_LIMIT is used by Attack/Defense CP maps where the defending team wins by running down the round timer.Round timer and stalemate
CTeamplayRoundBasedRules tracks a networked round timer via teamplay_round_timer.h. Relevant convars exposed server-side:
GR_STATE_STALEMATE state is entered when the round timer expires and no team has fulfilled its win condition. In CTF maps, m_bOvertimeAllowedForCTF (proxy field) gates whether sudden-death overtime applies before calling stalemate.