@@ -54,13 +54,118 @@ enum
5454extern const char *g_aTeamNames[TF_TEAM_COUNT ];
5555extern color32 g_aTeamColors[TF_TEAM_COUNT ];
5656
57+ extern const char *g_aTeamNames_Localized[TF_TEAM_COUNT ];
58+ extern const char *g_aTeamNamesShort[TF_TEAM_COUNT ];
59+ extern const char *g_aTeamUpperNamesShort[TF_TEAM_COUNT ];
60+ extern const char *g_aTeamLowerNames[TF_TEAM_COUNT ];
61+ extern const char *g_aTeamUpperNames[TF_TEAM_COUNT ];
62+
63+ extern const wchar_t *g_aTeamUpperNamesShort_W[TF_TEAM_COUNT ];
64+
65+ template <typename Functor>
66+ void ForEachTeamName ( Functor &&func, const char **pNames = g_aTeamLowerNames )
67+ {
68+ for ( int i = FIRST_GAME_TEAM ; i < TF_TEAM_COUNT ; i++ )
69+ {
70+ func ( pNames[i] );
71+ }
72+ }
73+
74+ inline int GetTeamSkin ( int iTeam )
75+ {
76+ switch ( iTeam )
77+ {
78+ default :
79+ case TF_TEAM_RED :
80+ return 0 ;
81+ case TF_TEAM_BLUE :
82+ return 1 ;
83+ }
84+ }
85+
86+ inline int GetPlayerTeamSkin ( int iTeam )
87+ {
88+ switch ( iTeam )
89+ {
90+ default :
91+ case TF_TEAM_RED :
92+ return 0 ;
93+ case TF_TEAM_BLUE :
94+ return 1 ;
95+ }
96+ }
97+
98+ #define TEAM_STRING ( teamNum, prefix ) teamNum == TF_TEAM_BLUE ? prefix " red" : prefix " blue"
99+ #define TEAM_STRING_POST ( teamNum, prefix, postfix ) teamNum == TF_TEAM_RED ? prefix " red" postfix : prefix " blue" postfix
100+ #define TEAM_STRING_SHORT ( teamNum, prefix ) teamNum == TF_TEAM_RED ? prefix " red" : prefix " blu"
101+ #define TEAM_STRING_SHORT_POST ( teamNum, prefix, postfix ) teamNum == TF_TEAM_RED ? prefix " red" postfix : prefix " blu" postfix
102+
103+ #define DECLARE_TEAM_INPUTFUNCS ( prefix, postfix ) \
104+ void Input##prefix##Red##postfix( inputdata_t &inputdata ); \
105+ void Input##prefix##Blue##postfix( inputdata_t &inputdata )
106+
107+ #define DEFINE_TEAM_INPUTFUNCS ( fieldType, prefix, postfix ) \
108+ DEFINE_INPUTFUNC ( fieldType, #prefix " Red" #postfix, Input##prefix##Red##postfix ), \
109+ DEFINE_INPUTFUNC( fieldType, #prefix " Blue" #postfix, Input##prefix##Blue##postfix )
110+
111+ #define DEFINE_TEAM_OUTPUTS ( outputName, prefix, postfix ) \
112+ DEFINE_OUTPUT ( outputName[0 ], prefix " Red" postfix ), \
113+ DEFINE_OUTPUT( outputName[1 ], prefix " Blue" postfix )
114+
115+ #define DEFINE_TEAM_OUTPUTS_NUMBERED ( outputName, prefix, postfix ) \
116+ DEFINE_OUTPUT ( outputName[0 ], prefix " 1" postfix ), \
117+ DEFINE_OUTPUT( outputName[1 ], prefix " 2" postfix )
118+
119+ #define DEFINE_TEAM_KEYFIELDS ( keyfieldName, fieldType, prefix, postfix ) \
120+ DEFINE_KEYFIELD ( keyfieldName[0 ], fieldType, prefix " red" postfix ), \
121+ DEFINE_KEYFIELD( keyfieldName[1 ], fieldType, prefix " blue" postfix )
122+
123+ #ifdef GAME_DLL
124+
125+ #define SendTeamProps ( netvartype, prefix, postfix ) \
126+ SendProp##netvartype( SENDINFO ( prefix##Red##postfix ) ), \
127+ SendProp##netvartype( SENDINFO ( prefix##Blue##postfix ) )
128+
129+ #define SendTeamPropsFlags ( netvartype, prefix, postfix, ... ) \
130+ SendProp##netvartype( SENDINFO ( prefix##Red##postfix ), ##__VA_ARGS__ ), \
131+ SendProp##netvartype( SENDINFO ( prefix##Blue##postfix ), ##__VA_ARGS__ )
132+
133+ #else
134+
135+ #define RecvTeamProps ( netvartype, prefix, postfix ) \
136+ RecvProp##netvartype( RECVINFO ( prefix##Red##postfix ) ), \
137+ RecvProp##netvartype( RECVINFO ( prefix##Blue##postfix ) )
138+
139+ #define RecvTeamPropsFlags ( netvartype, prefix, postfix, ... ) \
140+ RecvProp##netvartype( RECVINFO ( prefix##Red##postfix ), ##__VA_ARGS__ ), \
141+ RecvProp##netvartype( RECVINFO ( prefix##Blue##postfix ), ##__VA_ARGS__ )
142+
143+ #endif
144+
145+ // Flag corresponding to the specified TF team. Must be at or above FIRST_GAME_TEAM (TF_TEAM_RED). Use with CTFGameRules team activation functions
146+ #define TF_TEAM_F (team ) (1 << (team - FIRST_GAME_TEAM ))
147+ #define TF_TEAM_F_DEFAULT ( TF_TEAM_F ( TF_TEAM_RED ) | TF_TEAM_F ( TF_TEAM_BLUE ) )
148+
149+ inline void PrecacheTeamParticles ( const char *pszFormat, const char **pNames = g_aTeamLowerNames )
150+ {
151+ ForEachTeamName ( [=]( const char *pszTeam )
152+ {
153+ char szParticle[128 ];
154+ V_snprintf ( szParticle, sizeof ( szParticle ), pszFormat, pszTeam );
155+ PrecacheParticleSystem ( szParticle );
156+ }, pNames );
157+ }
158+
57159#define COLOR_TF_SPECTATOR Color ( 245 , 229 , 196 , 255 )
58160#define COLOR_TF_RED Color ( 175 , 73 , 73 , 255 )
59161#define COLOR_TF_BLUE Color ( 79 , 117 , 143 , 255 )
60162
61163#define CONTENTS_REDTEAM CONTENTS_TEAM1
62164#define CONTENTS_BLUETEAM CONTENTS_TEAM2
63165
166+ #define CONTENTS_TFTEAMS ( CONTENTS_REDTEAM | CONTENTS_BLUETEAM )
167+ static const int TeamContents[] = { CONTENTS_REDTEAM , CONTENTS_BLUETEAM };
168+
64169enum
65170{
66171 TF_ARENA_NOTIFICATION_CAREFUL = 0 ,
@@ -222,7 +327,12 @@ enum ETFClass
222327};
223328
224329inline bool IsValidTFPlayerClass ( int iClass ) { return iClass >= TF_FIRST_NORMAL_CLASS && iClass < TF_LAST_NORMAL_CLASS ; }
225- inline bool IsValidTFTeam ( int iTeam ) { return iTeam == TF_TEAM_RED || iTeam == TF_TEAM_BLUE ; }
330+ inline bool IsValidTFTeam ( int iTeam ) { return iTeam > LAST_SHARED_TEAM && iTeam < TF_TEAM_COUNT ; }
331+
332+ inline int GetContentsForTeam ( int iTeam )
333+ {
334+ return IsValidTFTeam ( iTeam ) ? TeamContents[iTeam - FIRST_GAME_TEAM ] : 0 ;
335+ }
226336
227337#define FOR_EACH_NORMAL_PLAYER_CLASS ( _i ) for ( int _i = TF_FIRST_NORMAL_CLASS ; _i < TF_LAST_NORMAL_CLASS ; _i++ )
228338
0 commit comments