Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

619 lines
21 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Teamplay game rules that manage a round based structure for you
  4. //
  5. //=============================================================================
  6. #ifndef TEAMPLAYROUNDBASED_GAMERULES_H
  7. #define TEAMPLAYROUNDBASED_GAMERULES_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "teamplay_gamerules.h"
  12. #include "teamplay_round_timer.h"
  13. #include "GameEventListener.h"
  14. #ifdef GAME_DLL
  15. #include "team_control_point.h"
  16. #include "viewport_panel_names.h"
  17. extern ConVar mp_respawnwavetime;
  18. extern ConVar mp_showroundtransitions;
  19. extern ConVar mp_enableroundwaittime;
  20. extern ConVar mp_showcleanedupents;
  21. extern ConVar mp_bonusroundtime;
  22. extern ConVar mp_restartround;
  23. extern ConVar mp_winlimit;
  24. extern ConVar mp_maxrounds;
  25. extern ConVar mp_stalemate_timelimit;
  26. extern ConVar mp_stalemate_enable;
  27. #else
  28. #define CTeamplayRoundBasedRules C_TeamplayRoundBasedRules
  29. #define CTeamplayRoundBasedRulesProxy C_TeamplayRoundBasedRulesProxy
  30. #endif
  31. extern ConVar tf_arena_use_queue;
  32. extern ConVar mp_stalemate_meleeonly;
  33. extern ConVar mp_forceautoteam;
  34. class CTeamplayRoundBasedRules;
  35. //-----------------------------------------------------------------------------
  36. // Round states
  37. //-----------------------------------------------------------------------------
  38. enum gamerules_roundstate_t
  39. {
  40. // initialize the game, create teams
  41. GR_STATE_INIT = 0,
  42. //Before players have joined the game. Periodically checks to see if enough players are ready
  43. //to start a game. Also reverts to this when there are no active players
  44. GR_STATE_PREGAME,
  45. //The game is about to start, wait a bit and spawn everyone
  46. GR_STATE_STARTGAME,
  47. //All players are respawned, frozen in place
  48. GR_STATE_PREROUND,
  49. //Round is on, playing normally
  50. GR_STATE_RND_RUNNING,
  51. //Someone has won the round
  52. GR_STATE_TEAM_WIN,
  53. //Noone has won, manually restart the game, reset scores
  54. GR_STATE_RESTART,
  55. //Noone has won, restart the game
  56. GR_STATE_STALEMATE,
  57. //Game is over, showing the scoreboard etc
  58. GR_STATE_GAME_OVER,
  59. //Game is in a bonus state, transitioned to after a round ends
  60. GR_STATE_BONUS,
  61. //Game is awaiting the next wave/round of a multi round experience
  62. GR_STATE_BETWEEN_RNDS,
  63. GR_NUM_ROUND_STATES
  64. };
  65. enum {
  66. WINREASON_NONE =0,
  67. WINREASON_ALL_POINTS_CAPTURED,
  68. WINREASON_OPPONENTS_DEAD,
  69. WINREASON_FLAG_CAPTURE_LIMIT,
  70. WINREASON_DEFEND_UNTIL_TIME_LIMIT,
  71. WINREASON_STALEMATE,
  72. WINREASON_TIMELIMIT,
  73. WINREASON_WINLIMIT,
  74. WINREASON_WINDIFFLIMIT,
  75. #if defined(TF_CLIENT_DLL) || defined(TF_DLL)
  76. WINREASON_RD_REACTOR_CAPTURED,
  77. WINREASON_RD_CORES_COLLECTED,
  78. WINREASON_RD_REACTOR_RETURNED,
  79. WINREASON_PD_POINTS,
  80. WINREASON_SCORED,
  81. WINREASON_STOPWATCH_WATCHING_ROUNDS,
  82. WINREASON_STOPWATCH_WATCHING_FINAL_ROUND,
  83. WINREASON_STOPWATCH_PLAYING_ROUNDS,
  84. #endif
  85. };
  86. enum stalemate_reasons_t
  87. {
  88. STALEMATE_JOIN_MID,
  89. STALEMATE_TIMER,
  90. STALEMATE_SERVER_TIMELIMIT,
  91. NUM_STALEMATE_REASONS,
  92. };
  93. #if defined(TF_CLIENT_DLL) || defined(TF_DLL)
  94. #ifdef STAGING_ONLY
  95. extern ConVar tf_test_match_summary;
  96. #endif
  97. #endif
  98. //-----------------------------------------------------------------------------
  99. // Purpose: Per-state data
  100. //-----------------------------------------------------------------------------
  101. class CGameRulesRoundStateInfo
  102. {
  103. public:
  104. gamerules_roundstate_t m_iRoundState;
  105. const char *m_pStateName;
  106. void (CTeamplayRoundBasedRules::*pfnEnterState)(); // Init and deinit the state.
  107. void (CTeamplayRoundBasedRules::*pfnLeaveState)();
  108. void (CTeamplayRoundBasedRules::*pfnThink)(); // Do a PreThink() in this state.
  109. };
  110. //-----------------------------------------------------------------------------
  111. // Purpose:
  112. //-----------------------------------------------------------------------------
  113. class CTeamplayRoundBasedRulesProxy : public CGameRulesProxy
  114. {
  115. public:
  116. DECLARE_CLASS( CTeamplayRoundBasedRulesProxy, CGameRulesProxy );
  117. DECLARE_NETWORKCLASS();
  118. #ifdef GAME_DLL
  119. DECLARE_DATADESC();
  120. void InputSetStalemateOnTimelimit( inputdata_t &inputdata );
  121. #endif
  122. //----------------------------------------------------------------------------------
  123. // Client specific
  124. #ifdef CLIENT_DLL
  125. void OnPreDataChanged( DataUpdateType_t updateType );
  126. void OnDataChanged( DataUpdateType_t updateType );
  127. #endif // CLIENT_DLL
  128. };
  129. //-----------------------------------------------------------------------------
  130. // Purpose: Teamplay game rules that manage a round based structure for you
  131. //-----------------------------------------------------------------------------
  132. class CTeamplayRoundBasedRules : public CTeamplayRules, public CGameEventListener
  133. {
  134. DECLARE_CLASS( CTeamplayRoundBasedRules, CTeamplayRules );
  135. public:
  136. CTeamplayRoundBasedRules();
  137. #ifdef CLIENT_DLL
  138. DECLARE_CLIENTCLASS_NOBASE(); // This makes datatables able to access our private vars.
  139. void SetRoundState( int iRoundState );
  140. #else
  141. DECLARE_SERVERCLASS_NOBASE(); // This makes datatables able to access our private vars.
  142. #endif
  143. float GetLastRoundStateChangeTime( void ) const { return m_flLastRoundStateChangeTime; }
  144. float m_flLastRoundStateChangeTime;
  145. // Data accessors
  146. inline gamerules_roundstate_t State_Get( void ) { return m_iRoundState; }
  147. bool IsInWaitingForPlayers( void ) { return m_bInWaitingForPlayers; }
  148. virtual bool InRoundRestart( void ) { return State_Get() == GR_STATE_PREROUND; }
  149. bool InStalemate( void ) { return State_Get() == GR_STATE_STALEMATE; }
  150. bool RoundHasBeenWon( void ) { return State_Get() == GR_STATE_TEAM_WIN; }
  151. virtual float GetNextRespawnWave( int iTeam, CBasePlayer *pPlayer );
  152. virtual bool HasPassedMinRespawnTime( CBasePlayer *pPlayer );
  153. virtual void LevelInitPostEntity( void );
  154. virtual float GetRespawnTimeScalar( int iTeam );
  155. virtual float GetRespawnWaveMaxLength( int iTeam, bool bScaleWithNumPlayers = true );
  156. virtual bool ShouldRespawnQuickly( CBasePlayer *pPlayer ) { return false; }
  157. float GetMinTimeWhenPlayerMaySpawn( CBasePlayer *pPlayer );
  158. // Return false if players aren't allowed to cap points at this time (i.e. in WaitingForPlayers)
  159. virtual bool PointsMayBeCaptured( void ) { return ((State_Get() == GR_STATE_RND_RUNNING || State_Get() == GR_STATE_STALEMATE) && !IsInWaitingForPlayers()); }
  160. virtual void SetLastCapPointChanged( int iIndex ) { m_iLastCapPointChanged = iIndex; }
  161. int GetLastCapPointChanged( void ) { return m_iLastCapPointChanged; }
  162. virtual int GetWinningTeam( void )
  163. {
  164. //tagES
  165. #if defined( STAGING_ONLY ) && ( defined(TF_CLIENT_DLL) || defined(TF_DLL) )
  166. return ( tf_test_match_summary.GetBool() ? TF_TEAM_BLUE : m_iWinningTeam.Get() );
  167. #endif
  168. return m_iWinningTeam;
  169. }
  170. int GetWinReason() { return m_iWinReason; }
  171. bool InOvertime( void ){ return m_bInOvertime; }
  172. void SetOvertime( bool bOvertime );
  173. bool InSetup( void ){ return m_bInSetup; }
  174. #ifdef GAME_DLL
  175. virtual void BalanceTeams( bool bRequireSwitcheesToBeDead );
  176. #endif // GAME_DLL
  177. bool SwitchedTeamsThisRound( void ) { return m_bSwitchedTeamsThisRound; }
  178. virtual bool ShouldBalanceTeams( void );
  179. bool IsInTournamentMode( void );
  180. bool IsInHighlanderMode( void );
  181. bool IsInPreMatch( void ) { return (IsInTournamentMode() && IsInWaitingForPlayers()); }
  182. bool IsWaitingForTeams( void ) { return m_bAwaitingReadyRestart; }
  183. bool IsInStopWatch( void ) { return m_bStopWatch; }
  184. void SetInStopWatch( bool bState ) { m_bStopWatch = bState; }
  185. virtual void StopWatchModeThink( void ) { };
  186. bool IsTeamReady( int iTeamNumber )
  187. {
  188. return m_bTeamReady[iTeamNumber];
  189. }
  190. bool IsPlayerReady( int iIndex )
  191. {
  192. return m_bPlayerReady[iIndex];
  193. }
  194. virtual void HandleTeamScoreModify( int iTeam, int iScore) { };
  195. float GetRoundRestartTime( void ) const { return m_flRestartRoundTime; }
  196. //Arena Mode
  197. virtual bool IsInArenaMode( void ) const { return false; }
  198. //Koth Mode
  199. virtual bool IsInKothMode( void ) const { return false; }
  200. //Training Mode
  201. virtual bool IsInTraining( void ) { return false; }
  202. virtual bool IsInItemTestingMode( void ) { return false; }
  203. void SetMultipleTrains( bool bMultipleTrains ){ m_bMultipleTrains = bMultipleTrains; }
  204. bool HasMultipleTrains( void ){ return m_bMultipleTrains; }
  205. virtual int GetBonusRoundTime( bool bGameOver = false );
  206. virtual int GetPostMatchPeriod( void );
  207. int GetRoundsPlayed( void ) { return m_nRoundsPlayed; }
  208. float GetStateTransitionTime( void ){ return m_flStateTransitionTime; }
  209. #ifdef CLIENT_DLL
  210. virtual void Update( float frametime ) OVERRIDE;
  211. #endif
  212. void SetAllowBetweenRounds( bool bValue ) { m_bAllowBetweenRounds = bValue; }
  213. public: // IGameEventListener Interface
  214. virtual void FireGameEvent( IGameEvent * event );
  215. //----------------------------------------------------------------------------------
  216. // Server specific
  217. #ifdef GAME_DLL
  218. // Derived game rules class should override these
  219. public:
  220. // Override this to prevent removal of game specific entities that need to persist
  221. virtual bool RoundCleanupShouldIgnore( CBaseEntity *pEnt );
  222. virtual bool ShouldCreateEntity( const char *pszClassName );
  223. // Called when a new round is being initialized
  224. virtual void SetupOnRoundStart( void ) { return; }
  225. // Called when a new round is off and running
  226. virtual void SetupOnRoundRunning( void ) { return; }
  227. // Called before a new round is started (so the previous round can end)
  228. virtual void PreviousRoundEnd( void ) { return; }
  229. // Send the team scores down to the client
  230. virtual void SendTeamScoresEvent( void ) { return; }
  231. // Send the end of round info displayed in the win panel
  232. virtual void SendWinPanelInfo( bool bGameOver ) { return; }
  233. // Setup spawn points for the current round before it starts
  234. virtual void SetupSpawnPointsForRound( void ) { return; }
  235. // Called when a round has entered stalemate mode (timer has run out)
  236. virtual void SetupOnStalemateStart( void ) { return; }
  237. virtual void SetupOnStalemateEnd( void ) { return; }
  238. virtual void SetSetup( bool bSetup );
  239. virtual bool ShouldGoToBonusRound( void ) { return false; }
  240. virtual void SetupOnBonusStart( void ) { return; }
  241. virtual void SetupOnBonusEnd( void ) { return; }
  242. virtual void BonusStateThink( void ) { return; }
  243. virtual void BetweenRounds_Start( void ) { return; }
  244. virtual void BetweenRounds_End( void ) { return; }
  245. virtual void BetweenRounds_Think( void ) { return; }
  246. virtual void PreRound_Start( void ) { return; }
  247. virtual void PreRound_End( void ) { return; }
  248. bool PrevRoundWasWaitingForPlayers() { return m_bPrevRoundWasWaitingForPlayers; }
  249. virtual bool ShouldScorePerRound( void ){ return true; }
  250. bool CheckNextLevelCvar( bool bAllowEnd = true );
  251. virtual bool TimerMayExpire( void );
  252. virtual bool IsValveMap( void ){ return false; }
  253. virtual void RestartTournament( void );
  254. virtual bool TournamentModeCanEndWithTimelimit( void ){ return true; }
  255. public:
  256. void State_Transition( gamerules_roundstate_t newState );
  257. virtual void RespawnPlayers( bool bForceRespawn, bool bTeam = false, int iTeam = TEAM_UNASSIGNED );
  258. void SetForceMapReset( bool reset );
  259. void SetRoundToPlayNext( string_t strName ){ m_iszRoundToPlayNext = strName; }
  260. string_t GetRoundToPlayNext( void ){ return m_iszRoundToPlayNext; }
  261. void AddPlayedRound( string_t strName );
  262. bool IsPreviouslyPlayedRound ( string_t strName );
  263. string_t GetLastPlayedRound( void );
  264. virtual void SetWinningTeam( int team, int iWinReason, bool bForceMapReset = true, bool bSwitchTeams = false, bool bDontAddScore = false, bool bFinal = false ) OVERRIDE;
  265. virtual void SetStalemate( int iReason, bool bForceMapReset = true, bool bSwitchTeams = false );
  266. virtual void SetRoundOverlayDetails( void ){ return; }
  267. void ShouldResetScores( bool bResetTeam, bool bResetPlayer ){ m_bResetTeamScores = bResetTeam; m_bResetPlayerScores = bResetPlayer; }
  268. void ShouldResetRoundsPlayed( bool bResetRoundsPlayed ){ m_bResetRoundsPlayed = bResetRoundsPlayed; }
  269. void SetFirstRoundPlayed( string_t strName ){ m_iszFirstRoundPlayed = strName ; }
  270. string_t GetFirstRoundPlayed(){ return m_iszFirstRoundPlayed; }
  271. void SetTeamRespawnWaveTime( int iTeam, float flValue );
  272. void AddTeamRespawnWaveTime( int iTeam, float flValue );
  273. virtual void FillOutTeamplayRoundWinEvent( IGameEvent *event ) {} // derived classes may implement to add fields to this event
  274. void SetStalemateOnTimelimit( bool bStalemate ) { m_bAllowStalemateAtTimelimit = bStalemate; }
  275. bool IsGameUnderTimeLimit( void );
  276. CTeamRoundTimer *GetActiveRoundTimer( void );
  277. void HandleTimeLimitChange( void );
  278. void SetTeamReadyState( bool bState, int iTeam )
  279. {
  280. m_bTeamReady.Set( iTeam, bState );
  281. }
  282. void SetPlayerReadyState( int iIndex, bool bState )
  283. {
  284. m_bPlayerReady.Set( iIndex, bState );
  285. }
  286. void ResetPlayerAndTeamReadyState( void );
  287. virtual void PlayTrainCaptureAlert( CTeamControlPoint *pPoint, bool bFinalPointInMap ){ return; }
  288. virtual void PlaySpecialCapSounds( int iCappingTeam, CTeamControlPoint *pPoint ){ return; }
  289. bool PlayThrottledAlert( int iTeam, const char *sound, float fDelayBeforeNext );
  290. void BroadcastSound( int iTeam, const char *sound, int iAdditionalSoundFlags = 0 );
  291. virtual void RecalculateControlPointState( void ){ return; }
  292. virtual bool ShouldSkipAutoScramble( void ){ return false; }
  293. virtual bool ShouldWaitToStartRecording( void ){ return IsInWaitingForPlayers(); }
  294. bool IsGameOver( void ){ return ( CheckTimeLimit( false ) || CheckWinLimit( false ) || CheckMaxRounds( false ) || CheckNextLevelCvar( false ) ); }
  295. virtual bool StopWatchShouldBeTimedWin( void ) { return m_bStopWatchShouldBeTimedWin; }
  296. protected:
  297. virtual void Think( void );
  298. virtual void CheckChatText( CBasePlayer *pPlayer, char *pText );
  299. void CheckChatForReadySignal( CBasePlayer *pPlayer, const char *chatmsg );
  300. // Game beginning / end handling
  301. virtual void GoToIntermission( void );
  302. void SetInWaitingForPlayers( bool bWaitingForPlayers );
  303. void CheckWaitingForPlayers( void );
  304. virtual bool AllowWaitingForPlayers( void ) { return true; }
  305. void CheckRestartRound( void );
  306. bool CheckTimeLimit( bool bAllowEnd = true );
  307. int GetTimeLeft( void );
  308. virtual bool CheckWinLimit( bool bAllowEnd = true, int nAddValueWhenChecking = 0 );
  309. bool CheckMaxRounds( bool bAllowEnd = true, int nAddValueWhenChecking = 0 );
  310. void CheckReadyRestart( void );
  311. virtual bool CanChangelevelBecauseOfTimeLimit( void ) { return true; }
  312. virtual bool CanGoToStalemate( void ) { return true; }
  313. // State machine handling
  314. void State_Enter( gamerules_roundstate_t newState ); // Initialize the new state.
  315. void State_Leave(); // Cleanup the previous state.
  316. void State_Think(); // Update the current state.
  317. static CGameRulesRoundStateInfo* State_LookupInfo( gamerules_roundstate_t state ); // Find the state info for the specified state.
  318. // State Functions
  319. void State_Enter_INIT( void );
  320. void State_Think_INIT( void );
  321. void State_Enter_PREGAME( void );
  322. void State_Think_PREGAME( void );
  323. void State_Enter_STARTGAME( void );
  324. void State_Think_STARTGAME( void );
  325. void State_Enter_PREROUND( void );
  326. void State_Leave_PREROUND( void );
  327. void State_Think_PREROUND( void );
  328. void State_Enter_RND_RUNNING( void );
  329. void State_Think_RND_RUNNING( void );
  330. void State_Enter_TEAM_WIN( void );
  331. void State_Think_TEAM_WIN( void );
  332. void State_Enter_RESTART( void );
  333. void State_Think_RESTART( void );
  334. void State_Enter_STALEMATE( void );
  335. void State_Think_STALEMATE( void );
  336. void State_Leave_STALEMATE( void );
  337. void State_Enter_BONUS( void );
  338. void State_Think_BONUS( void );
  339. void State_Leave_BONUS( void );
  340. void State_Enter_BETWEEN_RNDS( void );
  341. void State_Leave_BETWEEN_RNDS( void );
  342. void State_Think_BETWEEN_RNDS( void );
  343. // mp_scrambleteams_auto
  344. void ResetTeamsRoundWinTracking( void );
  345. protected:
  346. virtual void InitTeams( void );
  347. virtual bool BHavePlayers( void );
  348. virtual void RoundRespawn( void );
  349. virtual void CleanUpMap( void );
  350. virtual void CheckRespawnWaves( void );
  351. void ResetScores( void );
  352. void ResetMapTime( void );
  353. void PlayStartRoundVoice( void );
  354. virtual void PlayWinSong( int team );
  355. void PlayStalemateSong( void );
  356. void PlaySuddenDeathSong( void );
  357. virtual const char* GetStalemateSong( int nTeam ) { return "Game.Stalemate"; }
  358. virtual const char* WinSongName( int nTeam ) { return "Game.YourTeamWon"; }
  359. virtual const char* LoseSongName( int nTeam ) { return "Game.YourTeamLost"; }
  360. virtual void RespawnTeam( int iTeam ) { RespawnPlayers( false, true, iTeam ); }
  361. void HideActiveTimer( void );
  362. virtual void RestoreActiveTimer( void );
  363. virtual void InternalHandleTeamWin( int iWinningTeam ){ return; }
  364. bool MapHasActiveTimer( void );
  365. void CreateTimeLimitTimer( void );
  366. virtual float GetLastMajorEventTime( void ) OVERRIDE { return m_flLastTeamWin; }
  367. protected:
  368. CGameRulesRoundStateInfo *m_pCurStateInfo; // Per-state data
  369. float m_flWaitingForPlayersTimeEnds;
  370. CHandle<CTeamRoundTimer> m_hWaitingForPlayersTimer;
  371. float m_flNextPeriodicThink;
  372. bool m_bChangeLevelOnRoundEnd;
  373. bool m_bResetTeamScores;
  374. bool m_bResetPlayerScores;
  375. bool m_bResetRoundsPlayed;
  376. // Stalemate
  377. EHANDLE m_hPreviousActiveTimer;
  378. CHandle<CTeamRoundTimer> m_hStalemateTimer;
  379. float m_flStalemateStartTime;
  380. CHandle<CTeamRoundTimer> m_hTimeLimitTimer;
  381. bool m_bForceMapReset; // should the map be reset when a team wins and the round is restarted?
  382. bool m_bPrevRoundWasWaitingForPlayers; // was the previous map reset after a waiting for players period
  383. bool m_bInitialSpawn;
  384. string_t m_iszRoundToPlayNext;
  385. CUtlVector<string_t> m_iszPreviousRounds; // we'll store the two previous rounds so we won't play them again right away if there are other rounds that can be played first
  386. string_t m_iszFirstRoundPlayed; // store the first round played after a full restart so we can pick a different one next time if we have other options
  387. float m_flOriginalTeamRespawnWaveTime[ MAX_TEAMS ];
  388. bool m_bAllowStalemateAtTimelimit;
  389. bool m_bChangelevelAfterStalemate;
  390. float m_flRoundStartTime; // time the current round started
  391. float m_flNewThrottledAlertTime; // time that we can play another throttled alert
  392. bool m_bUseAddScoreAnim;
  393. gamerules_roundstate_t m_prevState;
  394. bool m_bPlayerReadyBefore[MAX_PLAYERS+1]; // Test to see if a player has hit ready before
  395. float m_flLastTeamWin;
  396. bool m_bStopWatchShouldBeTimedWin;
  397. private:
  398. CUtlMap < int, int > m_GameTeams; // Team index, Score
  399. #endif
  400. // End server specific
  401. //----------------------------------------------------------------------------------
  402. //----------------------------------------------------------------------------------
  403. // Client specific
  404. #ifdef CLIENT_DLL
  405. public:
  406. virtual void OnPreDataChanged( DataUpdateType_t updateType );
  407. virtual void OnDataChanged( DataUpdateType_t updateType );
  408. virtual void HandleOvertimeBegin(){}
  409. virtual void GetTeamGlowColor( int nTeam, float &r, float &g, float &b ){ r = 0.76f; g = 0.76f; b = 0.76f; }
  410. private:
  411. bool m_bOldInWaitingForPlayers;
  412. bool m_bOldInOvertime;
  413. bool m_bOldInSetup;
  414. #endif // CLIENT_DLL
  415. public:
  416. bool WouldChangeUnbalanceTeams( int iNewTeam, int iCurrentTeam );
  417. bool AreTeamsUnbalanced( int &iHeaviestTeam, int &iLightestTeam );
  418. virtual bool HaveCheatsBeenEnabledDuringLevel( void ) { return m_bCheatsEnabledDuringLevel; }
  419. float GetPreroundCountdownTime( void ){ return m_flCountdownTime; }
  420. protected:
  421. CNetworkVar( gamerules_roundstate_t, m_iRoundState );
  422. CNetworkVar( bool, m_bInOvertime ); // Are we currently in overtime?
  423. CNetworkVar( bool, m_bInSetup ); // Are we currently in setup?
  424. CNetworkVar( bool, m_bSwitchedTeamsThisRound );
  425. protected:
  426. CNetworkVar( int, m_iWinningTeam ); // Set before entering GR_STATE_TEAM_WIN
  427. CNetworkVar( int, m_iWinReason );
  428. CNetworkVar( bool, m_bInWaitingForPlayers );
  429. CNetworkVar( bool, m_bAwaitingReadyRestart );
  430. CNetworkVar( float, m_flRestartRoundTime );
  431. CNetworkVar( float, m_flMapResetTime ); // Time that the map was reset
  432. CNetworkArray( float, m_flNextRespawnWave, MAX_TEAMS ); // Minor waste, but cleaner code
  433. CNetworkArray( bool, m_bTeamReady, MAX_TEAMS );
  434. CNetworkVar( bool, m_bStopWatch );
  435. CNetworkVar( bool, m_bMultipleTrains ); // two trains in this map?
  436. CNetworkArray( bool, m_bPlayerReady, MAX_PLAYERS );
  437. CNetworkVar( bool, m_bCheatsEnabledDuringLevel );
  438. CNetworkVar( int, m_nRoundsPlayed );
  439. CNetworkVar( float, m_flCountdownTime );
  440. CNetworkVar( float, m_flStateTransitionTime ); // Timer for round states
  441. public:
  442. CNetworkArray( float, m_TeamRespawnWaveTimes, MAX_TEAMS ); // Time between each team's respawn wave
  443. private:
  444. float m_flStartBalancingTeamsAt;
  445. float m_flNextBalanceTeamsTime;
  446. bool m_bPrintedUnbalanceWarning;
  447. float m_flFoundUnbalancedTeamsTime;
  448. float m_flAutoBalanceQueueTimeEnd;
  449. int m_nAutoBalanceQueuePlayerIndex;
  450. int m_nAutoBalanceQueuePlayerScore;
  451. int m_nLastEventFiredTime;
  452. protected:
  453. bool m_bAllowBetweenRounds;
  454. public:
  455. float m_flStopWatchTotalTime;
  456. int m_iLastCapPointChanged;
  457. };
  458. // Utility function
  459. bool FindInList( const char **pStrings, const char *pToFind );
  460. inline CTeamplayRoundBasedRules* TeamplayRoundBasedRules()
  461. {
  462. return static_cast<CTeamplayRoundBasedRules*>(g_pGameRules);
  463. }
  464. #endif // TEAMPLAYROUNDBASED_GAMERULES_H