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.

274 lines
8.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Generic in-game abuse reporting
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef ABUSE_REPORT_H
  8. #define ABUSE_REPORT_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. #include <igamesystem.h>
  13. #include <GameEventListener.h>
  14. #include <bitmap/bitmap.h>
  15. #include <netadr.h>
  16. /// Different content types that can be reported as abusive.
  17. ///
  18. /// WARNING: These enum values MUST MATCH the values in Steam's
  19. /// ECommunityContentType!
  20. enum EAbuseReportContentType
  21. {
  22. k_EAbuseReportContentNoSelection = -1, // dummy ilegal value: the user has not made a selection
  23. k_EAbuseReportContentUnspecified = 0, // we use this to mean "other"
  24. //k_EAbuseReportContentAll = 1, // reset all community content
  25. k_EAbuseReportContentAvatarImage = 2, // clear avatar image
  26. //k_EAbuseReportContentProfileText = 3, // reset profile text
  27. //k_EAbuseReportContentWebLinks = 4, // delete web links
  28. //k_EAbuseReportContentAnnouncement = 5,
  29. //k_EAbuseReportContentEventText = 6,
  30. //k_EAbuseReportContentCustomCSS = 7,
  31. //k_EAbuseReportContentProfileURL = 8, // delete community URL ID
  32. k_EAbuseReportContentComments = 9, // just comments this guy has written
  33. k_EAbuseReportContentPersonaName = 10, // persona name
  34. //k_EAbuseReportContentScreenshot = 11, // screenshot
  35. //k_EAbuseReportContentVideo = 12, // videos
  36. k_EAbuseReportContentCheating = 13, // cheating
  37. k_EAbuseReportContentUGCImage = 14, // Image stored in UGC --- the report is accusing the image of being offensive
  38. k_EAbuseReportContentActorUGCImage = 15, // Abuse report actor has uploaded a UGC image to server as supporting documentation of their claim
  39. };
  40. /// Types of reasons why a violation report was issued
  41. ///
  42. /// WARNING: These enum values MUST MATCH the values in Steam's
  43. /// EAbuseReportType!
  44. enum EAbuseReportType
  45. {
  46. k_EAbuseReportTypeNoSelection = -1, // dummy ilegal value: the user has not made a selection
  47. k_EAbuseReportTypeUnspecified = 0,
  48. k_EAbuseReportTypeInappropriate = 1, // just not ok to post
  49. k_EAbuseReportTypeProhibited = 2, // prohibited by EULA or general law
  50. k_EAbuseReportTypeSpamming = 3, // excessive spamming
  51. k_EAbuseReportTypeAdvertisement = 4, // unwanted advertisement
  52. //k_EAbuseReportTypeExploit = 5, // content data attempts to exploit code issue
  53. k_EAbuseReportTypeSpoofing = 6, // user/group is impersonating an official contact
  54. k_EAbuseReportTypeLanguage = 7, // bad language
  55. k_EAbuseReportTypeAdultContent = 8, // any kind of adult material, references etc
  56. k_EAbuseReportTypeHarassment = 9, // harassment, discrimination, racism etc
  57. k_EAbuseReportTypeCheating = 10, // cheating
  58. };
  59. /// Container class that has everything we need to know in order to file
  60. /// an abuse report, which is significantly more than the data we actually
  61. /// include in a particular abuse report. It's everything we save off at the
  62. /// time the user initiates the abuse reporting mechanism. Games can derive
  63. /// their own report types and put game-specific data in here.
  64. struct AbuseIncidentData_t
  65. {
  66. AbuseIncidentData_t();
  67. virtual ~AbuseIncidentData_t();
  68. enum EPlayerImageType
  69. {
  70. k_PlayerImageType_UGC,
  71. k_PlayerImageType_Spray,
  72. };
  73. /// A custom image of the player's that could be considered offensive
  74. struct PlayerImage_t
  75. {
  76. /// What kind of image is it?
  77. EPlayerImageType m_eType;
  78. /// For UGC images, what's the handle?
  79. uint64 m_hUGCHandle;
  80. };
  81. /// Info we remember for one player.
  82. struct PlayerData_t
  83. {
  84. PlayerData_t()
  85. {
  86. m_iClientIndex = -1;
  87. m_iSteamAvatarIndex = -1;
  88. }
  89. /// The client index. (See UTIL_PlayerByIndex). Note that this
  90. /// index is really only valid at the time the incident is captured.
  91. /// Because players can leave after the incident is captured.
  92. int m_iClientIndex;
  93. /// The name they were going by at the time
  94. CUtlString m_sPersona;
  95. /// Their steam ID. This is essential so we can file
  96. /// an abuse report!
  97. CSteamID m_steamID;
  98. /// Index of steam friends icon for their avatar.
  99. /// 0 if they don't have one!
  100. int m_iSteamAvatarIndex;
  101. /// Do we have an entity for this player? They might not have spawned,
  102. /// or might be outside our PVS, etc.
  103. bool m_bHasEntity;
  104. /// Model transform for the player's render stuff
  105. VMatrix m_matModelToWorld;
  106. /// Model->clip matrix for the player's render stuff
  107. VMatrix m_matModelToClip;
  108. /// True if the render bounds are approximately correct, false if not
  109. bool m_bRenderBoundsValid;
  110. /// Bounds (in model space) of the player's renderable stuff
  111. Vector m_vecRenderBoundsMin, m_vecRenderBoundsMax;
  112. /// Bounds (in normalized screen space coords 0...1) of the player's
  113. /// renderable stuff
  114. Vector2D m_screenBoundsMin, m_screenBoundsMax;
  115. /// List of his images
  116. CUtlVector<PlayerImage_t> m_vecImages;
  117. };
  118. /// List of base player data. You got more data per player in your derived
  119. /// incident type? Store it in a parallel array.
  120. CUtlVector<PlayerData_t> m_vecPlayers;
  121. /// Camera world -> clip matrix.
  122. VMatrix m_matWorldToClip;
  123. /// Screenshot
  124. Bitmap_t m_bitmapScreenshot;
  125. // Screenshot file data
  126. CUtlBuffer m_bufScreenshotFileData;
  127. /// Number of frames we're willing to wait for the engine to write out a screenshot.
  128. /// Zero if we already failed
  129. int m_nScreenShotWaitFrames;
  130. /// Is it possible to report the game server itself for abuse?
  131. bool m_bCanReportGameServer;
  132. /// What Game Server/IP are we on? Will be an invalid address if we don't know
  133. netadr_t m_adrGameServer;
  134. /// Steam ID of the game server / IP we are on
  135. CSteamID m_steamIDGameServer;
  136. /// Poll report (some data may have to be fetched asynchronously),
  137. /// return true if everything is ready
  138. virtual bool Poll();
  139. };
  140. /// Generic abuse reporting panel. Your
  141. class CAbuseReportManager : public CBaseGameSystemPerFrame, public CGameEventListener
  142. {
  143. public:
  144. CAbuseReportManager();
  145. virtual ~CAbuseReportManager();
  146. //
  147. // CAutoGameSystemPerFrame overrides
  148. //
  149. virtual char const *Name();
  150. virtual bool Init();
  151. virtual void Shutdown();
  152. virtual void LevelShutdownPreEntity();
  153. //
  154. // CGameEventListener overrides
  155. //
  156. virtual void FireGameEvent( IGameEvent *event );
  157. // CAutoGameSystemPerFrame defines different stuff depending on which DLL we're building
  158. #ifdef CLIENT_DLL
  159. // Do our frame-time processing
  160. virtual void Update( float frametime );
  161. #else
  162. #error "Why is this being included?"
  163. #endif
  164. /// Called when the console command is executed to capture data for a report
  165. virtual void QueueReport();
  166. /// Called when the console command is executed to submit data for a report
  167. virtual void SubmitReportUIRequested();
  168. /// Called to actually trigger the report UI, after all data is ready
  169. virtual void ActivateSubmitReportUI() = 0;
  170. /// Fetch the incident that's queued to be reported
  171. AbuseIncidentData_t *GetIncidentData() const { return m_pIncidentData; }
  172. /// Delete any current report incident. Also should clean
  173. /// out any temporary files used by the incident system.
  174. virtual void DestroyIncidentData();
  175. /// Show a message box complaining about lack of steam
  176. /// connection
  177. virtual void ShowNoSteamErrorMessage();
  178. /// Insert a a notification into the queue indicating that an unfiled report is ready
  179. virtual void CreateReportReadyNotification( bool bInGame, float flLifetime );
  180. /// Test harness. Set this to true, to generate fake data
  181. bool m_bTestReport;
  182. static const char k_rchScreenShotFilenameBase[];
  183. static const char k_rchScreenShotFilename[];
  184. protected:
  185. /// Your app will probably define its own abuse report types.
  186. /// if so, you will need to override this function.
  187. /// The base class just calls new to create an object, then calls
  188. /// PopulateIncident()
  189. virtual bool CreateAndPopulateIncident();
  190. /// Fill in the details about the current incident. This just fills in the
  191. /// base class data, and it should be called from CreateAndPopulateIncident
  192. bool PopulateIncident();
  193. /// Current incident that is pending to be reported or is being generated.
  194. /// Might be NULL.
  195. AbuseIncidentData_t *m_pIncidentData;
  196. /// Status of incident data.
  197. enum EIncidentDataStatus
  198. {
  199. k_EIncidentDataStatus_None,
  200. k_EIncidentDataStatus_Preparing, // we shuld call Poll() until it's ready
  201. k_EIncidentDataStatus_Ready, // it's ready
  202. };
  203. EIncidentDataStatus m_eIncidentDataStatus;
  204. /// Do we want to show the report UI as soon as the report is ready?
  205. bool m_bReportUIPending;
  206. void CheckCreateReportReadyNotification( float flMinSecondsSinceLastNotification, bool bInGame, float flLifetime );
  207. /// Time when we last pestered them about filing their report
  208. double m_timeLastReportReadyNotification;
  209. /// Address of the lasts server we connected to
  210. netadr_t m_adrCurrentServer;
  211. CSteamID m_steamIDCurrentServer;
  212. };
  213. /// Pointer to the app-specific instance. This pointer mght be NULL! Your
  214. /// app should define set this pointer if it uses the system
  215. extern CAbuseReportManager *g_AbuseReportMgr;
  216. #endif // ABUSE_REPORT_H