Counter Strike : Global Offensive Source Code
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.

423 lines
19 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============
  2. //
  3. // Purpose: CS-specific things to vote on
  4. //
  5. //=============================================================================
  6. #ifndef CS_VOTEISSUES_H
  7. #define CS_VOTEISSUES_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "vote_controller.h"
  12. class CCSPlayer;
  13. //=============================================================================
  14. // do not re-order, stored in DB
  15. enum
  16. {
  17. kVoteKickBanPlayerReason_Other,
  18. kVoteKickBanPlayerReason_Cheating,
  19. kVoteKickBanPlayerReason_Idle,
  20. kVoteKickBanPlayerReason_Scamming,
  21. };
  22. uint32 GetKickBanPlayerReason( const char *pReasonString );
  23. //=============
  24. //-----------------------------------------------------------------------------
  25. // Purpose:
  26. //-----------------------------------------------------------------------------
  27. class CBaseCSIssue : public CBaseIssue
  28. {
  29. // Overrides to BaseIssue standard to this mod.
  30. public:
  31. CBaseCSIssue( const char *typeString, CVoteController *pVoteController ) : CBaseIssue( typeString, pVoteController )
  32. {
  33. }
  34. virtual int GetVoteIssue( void ) { return VOTEISSUE_UNDEFINED; }
  35. virtual const char *GetOtherTeamDisplayString() { return "#SFUI_otherteam_vote_unimplemented"; }
  36. };
  37. //-----------------------------------------------------------------------------
  38. // Purpose:
  39. //-----------------------------------------------------------------------------
  40. class CRestartGameIssue : public CBaseCSIssue
  41. {
  42. public:
  43. CRestartGameIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_RESTARTGAME, pVoteController )
  44. {
  45. }
  46. virtual void ExecuteCommand( void );
  47. virtual bool IsEnabled( void );
  48. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  49. virtual const char *GetDisplayString();
  50. virtual void ListIssueDetails( CBasePlayer *forWhom );
  51. virtual bool IsAllyRestrictedVote( void ){ return false; }
  52. virtual const char *GetVotePassedString();
  53. virtual int GetVoteIssue( void ) { return VOTEISSUE_RESTARTGAME; }
  54. };
  55. //-----------------------------------------------------------------------------
  56. // Purpose:
  57. //-----------------------------------------------------------------------------
  58. class CKickIssue : public CBaseCSIssue
  59. {
  60. public:
  61. CKickIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_KICK, pVoteController ), m_bPlayerCrashed( false )
  62. {
  63. }
  64. virtual void ExecuteCommand( void );
  65. virtual bool IsEnabled( void );
  66. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  67. virtual const char *GetDisplayString( void );
  68. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  69. virtual const char *GetVotePassedString( void );
  70. virtual bool IsAllyRestrictedVote( void ) { return true; }
  71. virtual void OnVoteFailed( void );
  72. virtual void OnVoteStarted( void );
  73. virtual const char *GetDetailsString( void );
  74. virtual const char *GetOtherTeamDisplayString();
  75. virtual int GetVoteIssue( void ) { return VOTEISSUE_KICK; }
  76. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  77. private:
  78. void ExtractDataFromDetails( const char *pszDetails, CCSPlayer **pSubject, uint32 *pReason = NULL );
  79. void NotifyGC( CCSPlayer *pSubject, bool bKickedSuccessfully, uint32 unReason );
  80. CSteamID m_steamIDVoteCaller;
  81. CSteamID m_steamIDtoBan;
  82. bool m_bPlayerCrashed;
  83. };
  84. //-----------------------------------------------------------------------------
  85. // Purpose:
  86. //-----------------------------------------------------------------------------
  87. class CLoadBackupIssue : public CBaseCSIssue
  88. {
  89. public:
  90. CLoadBackupIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_LOADBACKUP, pVoteController )
  91. {
  92. m_szPrevDetailsString[ 0 ] = 0;
  93. m_szNiceName[ 0 ] = 0;
  94. }
  95. virtual void ExecuteCommand( void );
  96. virtual bool IsEnabled( void );
  97. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  98. virtual const char *GetDisplayString( void );
  99. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  100. virtual const char *GetVotePassedString( void );
  101. virtual bool IsAllyRestrictedVote( void ) { return false; }
  102. virtual void OnVoteFailed( void );
  103. virtual const char *GetDetailsString( void );
  104. virtual float GetFailedVoteLockOutTime( void ) { return 1.0; }
  105. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  106. virtual int GetVoteIssue( void ) { return VOTEISSUE_LOADBACKUP; }
  107. private:
  108. CUtlVector< char const * > m_arrStrings;
  109. char m_szPrevDetailsString[MAX_PATH];
  110. char m_szNiceName[MAX_PATH];
  111. };
  112. //-----------------------------------------------------------------------------
  113. // Purpose:
  114. //-----------------------------------------------------------------------------
  115. class CChangeLevelIssue : public CBaseCSIssue
  116. {
  117. public:
  118. CChangeLevelIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_CHANGELEVEL, pVoteController )
  119. {
  120. }
  121. virtual void ExecuteCommand( void );
  122. virtual bool IsAllyRestrictedVote( void ){ return false; }
  123. virtual bool IsEnabled( void );
  124. virtual bool CanTeamCallVote( int iTeam ) const; // Can someone on the given team call this vote?
  125. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  126. virtual const char *GetDisplayString( void );
  127. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  128. virtual const char *GetVotePassedString( void );
  129. virtual const char *GetDetailsString( void );
  130. virtual bool IsYesNoVote( void );
  131. virtual int GetVoteIssue( void ) { return VOTEISSUE_CHANGELEVEL; }
  132. };
  133. //-----------------------------------------------------------------------------
  134. // Purpose:
  135. //-----------------------------------------------------------------------------
  136. class CNextLevelIssue : public CBaseCSIssue
  137. {
  138. public:
  139. CNextLevelIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_NEXTLEVEL, pVoteController )
  140. {
  141. }
  142. virtual void ExecuteCommand( void );
  143. virtual bool IsAllyRestrictedVote( void ){ return false; }
  144. virtual bool IsEnabled( void );
  145. virtual bool CanTeamCallVote( int iTeam ) const; // Can someone on the given team call this vote?
  146. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  147. virtual const char *GetDisplayString( void );
  148. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  149. virtual const char *GetVotePassedString( void );
  150. virtual const char *GetDetailsString( void );
  151. virtual bool IsYesNoVote( void );
  152. virtual int GetNumberVoteOptions( void );
  153. virtual int GetVoteIssue( void ) { return VOTEISSUE_NEXTLEVEL; }
  154. private:
  155. CUtlVector <const char *> m_IssueOptions;
  156. };
  157. //-----------------------------------------------------------------------------
  158. // Purpose:
  159. //-----------------------------------------------------------------------------
  160. class CScrambleTeams : public CBaseCSIssue
  161. {
  162. public:
  163. CScrambleTeams( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_SCRAMBLE, pVoteController )
  164. {
  165. }
  166. virtual void ExecuteCommand( void );
  167. virtual bool IsEnabled( void );
  168. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  169. virtual const char *GetDisplayString( void );
  170. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  171. virtual bool IsAllyRestrictedVote( void ){ return false; }
  172. virtual const char *GetVotePassedString( void );
  173. virtual int GetVoteIssue( void ) { return VOTEISSUE_SCRAMBLE; }
  174. };
  175. //-----------------------------------------------------------------------------
  176. // Purpose:
  177. //-----------------------------------------------------------------------------
  178. class CSwapTeams : public CBaseCSIssue
  179. {
  180. public:
  181. CSwapTeams( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_SWAPTEAMS, pVoteController )
  182. {
  183. }
  184. virtual void ExecuteCommand( void );
  185. virtual bool IsEnabled( void );
  186. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  187. virtual const char *GetDisplayString( void );
  188. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  189. virtual bool IsAllyRestrictedVote( void ){ return false; }
  190. virtual const char *GetVotePassedString( void );
  191. virtual int GetVoteIssue( void ) { return VOTEISSUE_SWAPTEAMS; }
  192. };
  193. //-----------------------------------------------------------------------------
  194. // Purpose:
  195. //-----------------------------------------------------------------------------
  196. class CPauseMatchIssue : public CBaseCSIssue
  197. {
  198. public:
  199. CPauseMatchIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_PAUSEMATCH, pVoteController )
  200. {
  201. }
  202. virtual void ExecuteCommand( void );
  203. virtual bool IsEnabled( void );
  204. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  205. virtual const char *GetDisplayString( void );
  206. virtual bool ShouldIgnoreCreationTimer( void ) { return true; }
  207. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  208. virtual int GetVotesRequiredToPass( void ){ return 1; }
  209. virtual const char *GetVotePassedString( void );
  210. virtual float GetCommandDelay( void ) { return 0.0; }
  211. virtual bool IsEnabledDuringWarmup( void ) { return true; } // Can this vote be called during warmup?
  212. virtual float GetFailedVoteLockOutTime( void ) { return 1.0; }
  213. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  214. virtual int GetVoteIssue( void ) { return VOTEISSUE_PAUSEMATCH; }
  215. };
  216. //-----------------------------------------------------------------------------
  217. // Purpose:
  218. //-----------------------------------------------------------------------------
  219. class CUnpauseMatchIssue : public CBaseCSIssue
  220. {
  221. public:
  222. CUnpauseMatchIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_UNPAUSEMATCH, pVoteController )
  223. {
  224. }
  225. virtual void ExecuteCommand( void );
  226. virtual bool IsEnabled( void );
  227. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  228. virtual const char *GetDisplayString( void );
  229. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  230. virtual bool ShouldIgnoreCreationTimer( void ) { return true; }
  231. virtual bool IsUnanimousVoteToPass( void ) { return true; } // Requires all potential voters to pass
  232. virtual bool IsEnabledDuringWarmup( void ) { return true; } // Can this vote be called during warmup?
  233. virtual bool IsVoteCallExclusiveToSpectators( void ) { return true; } // Whether only spectators can call the vote
  234. virtual const char *GetVotePassedString( void );
  235. virtual float GetFailedVoteLockOutTime( void ) { return 1.0; }
  236. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  237. virtual int GetVoteIssue( void ) { return VOTEISSUE_UNPAUSEMATCH; }
  238. };
  239. //-----------------------------------------------------------------------------
  240. // Purpose:
  241. //-----------------------------------------------------------------------------
  242. class CReadyForMatchIssue : public CBaseCSIssue
  243. {
  244. public:
  245. CReadyForMatchIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_READYFORMATCH, pVoteController )
  246. {
  247. }
  248. virtual void ExecuteCommand( void );
  249. virtual bool IsEnabled( void );
  250. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  251. virtual const char *GetDisplayString( void );
  252. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  253. virtual bool ShouldIgnoreCreationTimer( void ) { return true; }
  254. virtual bool IsUnanimousVoteToPass( void ) { return true; } // Requires all potential voters to pass
  255. virtual bool IsEnabledDuringWarmup( void ) { return true; } // Can this vote be called during warmup?
  256. virtual bool IsVoteCallExclusiveToSpectators( void ) { return true; } // Whether only spectators can call the vote
  257. virtual const char *GetVotePassedString( void );
  258. virtual float GetFailedVoteLockOutTime( void ) { return 1.0; }
  259. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  260. virtual int GetVoteIssue( void ) { return VOTEISSUE_READYFORMATCH; }
  261. };
  262. //-----------------------------------------------------------------------------
  263. // Purpose:
  264. //-----------------------------------------------------------------------------
  265. class CNotReadyForMatchIssue : public CBaseCSIssue
  266. {
  267. public:
  268. CNotReadyForMatchIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_NOTREADYFORMATCH, pVoteController )
  269. {
  270. }
  271. virtual void ExecuteCommand( void );
  272. virtual bool IsEnabled( void );
  273. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  274. virtual const char *GetDisplayString( void );
  275. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  276. virtual int GetVotesRequiredToPass( void ){ return 1; }
  277. virtual float GetCommandDelay( void ) { return 0.0; }
  278. virtual bool ShouldIgnoreCreationTimer( void ) { return true; }
  279. virtual bool IsEnabledDuringWarmup( void ) { return true; } // Can this vote be called during warmup?
  280. virtual const char *GetVotePassedString( void );
  281. virtual float GetFailedVoteLockOutTime( void ) { return 1.0; }
  282. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  283. virtual int GetVoteIssue( void ) { return VOTEISSUE_NOTREADYFORMATCH; }
  284. };
  285. class CStartTimeOutIssue : public CBaseCSIssue
  286. {
  287. public:
  288. CStartTimeOutIssue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_STARTTIMEOUT, pVoteController )
  289. {
  290. }
  291. virtual void ExecuteCommand( void );
  292. virtual bool IsEnabled( void );
  293. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  294. virtual bool CanTeamCallVote( int iTeam ) const; // Can someone on the given team call this vote?
  295. virtual const char *GetDisplayString( void );
  296. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  297. virtual bool IsAllyRestrictedVote( void ) { return true; }
  298. virtual const char *GetVotePassedString( void );
  299. virtual const char *GetOtherTeamDisplayString( ) { return "#SFUI_otherteam_vote_timeout"; }
  300. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  301. virtual int GetVoteIssue( void ) { return VOTEISSUE_STARTTIMEOUT; }
  302. virtual vote_create_failed_t MakeVoteFailErrorCodeForClients( vote_create_failed_t eDefaultFailCode );
  303. };
  304. //-----------------------------------------------------------------------------
  305. // Purpose:
  306. //-----------------------------------------------------------------------------
  307. class CSurrender : public CBaseCSIssue
  308. {
  309. public:
  310. CSurrender( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_SURRENDER, pVoteController )
  311. {
  312. }
  313. virtual void ExecuteCommand( void );
  314. virtual bool IsEnabled( void );
  315. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  316. virtual bool CanTeamCallVote( int iTeam ) const;
  317. virtual const char *GetDisplayString( void );
  318. virtual const char *GetOtherTeamDisplayString();
  319. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  320. virtual bool IsAllyRestrictedVote( void ){ return true; }
  321. virtual const char *GetVotePassedString( void );
  322. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  323. virtual int GetVoteIssue( void ) { return VOTEISSUE_SURRENDER; }
  324. virtual bool IsUnanimousVoteToPass( void ) {return true; } // Requires all potential voters to pass
  325. virtual vote_create_failed_t MakeVoteFailErrorCodeForClients( vote_create_failed_t eDefaultFailCode )
  326. {
  327. switch ( eDefaultFailCode )
  328. {
  329. case VOTE_FAILED_WAITINGFORPLAYERS:
  330. case VOTE_FAILED_TEAM_CANT_CALL:
  331. return VOTE_FAILED_TOO_EARLY_SURRENDER;
  332. default:
  333. return eDefaultFailCode;
  334. }
  335. }
  336. };
  337. //-----------------------------------------------------------------------------
  338. // Purpose:
  339. //-----------------------------------------------------------------------------
  340. class CQueuedMatchmakingRematch : public CBaseCSIssue
  341. {
  342. public:
  343. CQueuedMatchmakingRematch( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_REMATCH, pVoteController )
  344. {
  345. }
  346. virtual void ExecuteCommand( void );
  347. virtual void OnVoteFailed( void ); // The moment the vote fails, also has some time for feedback before the window goes away
  348. virtual bool IsEnabled( void );
  349. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  350. virtual const char *GetDisplayString( void );
  351. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  352. virtual bool IsAllyRestrictedVote( void ){ return false; }
  353. virtual const char *GetVotePassedString( void );
  354. virtual int GetVoteIssue( void ) { return VOTEISSUE_REMATCH; }
  355. virtual void OnVoteStarted( void );
  356. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  357. virtual vote_create_failed_t MakeVoteFailErrorCodeForClients( vote_create_failed_t eDefaultFailCode ) { return VOTE_FAILED_REMATCH; }
  358. public:
  359. static bool IsTimeForRematchVote();
  360. };
  361. //-----------------------------------------------------------------------------
  362. // Purpose:
  363. //-----------------------------------------------------------------------------
  364. class CQueuedMatchmakingContinue : public CBaseCSIssue
  365. {
  366. public:
  367. CQueuedMatchmakingContinue( CVoteController *pVoteController ) : CBaseCSIssue( VOTEISSUE_NAME_CONTINUE, pVoteController )
  368. {
  369. }
  370. virtual void ExecuteCommand( void );
  371. virtual void OnVoteFailed( void ); // The moment the vote fails, also has some time for feedback before the window goes away
  372. virtual bool IsEnabled( void );
  373. virtual bool CanCallVote( int iEntIndex, const char *pszTypeString, const char *pszDetails, vote_create_failed_t &nFailCode, int &nTime );
  374. virtual const char *GetDisplayString( void );
  375. virtual void ListIssueDetails( CBasePlayer *pForWhom );
  376. virtual bool IsAllyRestrictedVote( void ){ return false; }
  377. virtual const char *GetVotePassedString( void );
  378. virtual int GetVoteIssue( void ) { return VOTEISSUE_CONTINUE; }
  379. virtual void OnVoteStarted( void );
  380. virtual bool IsEnabledInQueuedMatchmaking( void ) { return true; } // Query if the issue is supported in queued matchmaking mode
  381. virtual bool IsUnanimousVoteToPass() { return true; } // Require all attending humans to vote
  382. virtual vote_create_failed_t MakeVoteFailErrorCodeForClients( vote_create_failed_t eDefaultFailCode ) { return VOTE_FAILED_CONTINUE; }
  383. };
  384. #endif // CS_VOTEISSUES_H