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.

116 lines
3.1 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Generic in-game abuse reporting
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "cbase.h"
  8. #include "tf_abuse_report.h"
  9. #include "abuse_report_ui.h"
  10. #include "game/client/iviewport.h"
  11. #include "tf_shareddefs.h"
  12. #include "tf_hud_mainmenuoverride.h"
  13. #include "tf_gcmessages.h"
  14. #include "c_tf_player.h"
  15. #include "tf_quickplay_shared.h"
  16. #include "tf_gc_client.h"
  17. // memdbgon must be the last include file in a .cpp file!!!
  18. #include "tier0/memdbgon.h"
  19. /// Declare singleton object
  20. CTFAbuseReportManager theAbuseReportManager;
  21. CTFAbuseReportManager::CTFAbuseReportManager() {}
  22. CTFAbuseReportManager::~CTFAbuseReportManager() {}
  23. bool CTFAbuseReportManager::CreateAndPopulateIncident()
  24. {
  25. if ( !CAbuseReportManager::CreateAndPopulateIncident() )
  26. {
  27. return false;
  28. }
  29. if ( m_bTestReport )
  30. {
  31. return true;
  32. }
  33. for ( int iPlayer = 0 ; iPlayer < m_pIncidentData->m_vecPlayers.Count() ; ++iPlayer )
  34. {
  35. AbuseIncidentData_t::PlayerData_t *p = &m_pIncidentData->m_vecPlayers[iPlayer];
  36. CPlayerInventory *pInv = InventoryManager()->GetInventoryForAccount( p->m_steamID.GetAccountID() );
  37. //C_TFPlayer *pTFPlayer = dynamic_cast<C_TFPlayer *> ( UTIL_PlayerByIndex( p->m_iClientIndex ) );
  38. //if ( pTFPlayer == NULL )
  39. //{
  40. // Assert( !p->m_bHasEntity );
  41. // continue;
  42. //}
  43. //CTFPlayerInventory *pInv = pTFPlayer->Inventory();
  44. if ( pInv == NULL )
  45. {
  46. Warning( "No inventory data for player '%s'; we won't be able to report this person for inappropriate custom images\n", p->m_sPersona.String() );
  47. continue;
  48. }
  49. for ( int i = 0 ; i < pInv->GetItemCount() ; ++i)
  50. {
  51. CEconItemView *pItem = pInv->GetItem( i );
  52. // Get custom texture ID, if any
  53. uint64 hCustomtextureID = pItem->GetCustomUserTextureID();
  54. // Most items won't have a custom texture
  55. if ( hCustomtextureID == 0 )
  56. {
  57. continue;
  58. }
  59. // Discard duplicates, as it makes the UI confusing
  60. bool bDup = false;
  61. for ( int j = 0 ; j < p->m_vecImages.Count() ; ++j )
  62. {
  63. if ( p->m_vecImages[ j ].m_hUGCHandle == hCustomtextureID )
  64. {
  65. bDup = true;
  66. break;
  67. }
  68. }
  69. if ( bDup )
  70. {
  71. continue;
  72. }
  73. AbuseIncidentData_t::PlayerImage_t img;
  74. img.m_eType = AbuseIncidentData_t::k_PlayerImageType_UGC;
  75. img.m_hUGCHandle = hCustomtextureID;
  76. p->m_vecImages.AddToTail( img );
  77. }
  78. }
  79. // Check if we can report abuse against the game server.
  80. if (m_pIncidentData->m_adrGameServer.IsValid() &&
  81. !GTFGCClientSystem()->BIsIPRecentMatchServer( m_pIncidentData->m_adrGameServer ) )
  82. {
  83. m_pIncidentData->m_bCanReportGameServer = true;
  84. }
  85. return true;
  86. }
  87. void CTFAbuseReportManager::ActivateSubmitReportUI()
  88. {
  89. Assert( g_AbuseReportDlg.Get() == NULL );
  90. Assert( m_pIncidentData != NULL );
  91. IViewPortPanel *pMMOverride = ( gViewPortInterface->FindPanelByName( PANEL_MAINMENUOVERRIDE ) );
  92. engine->ExecuteClientCmd("gameui_activate");
  93. vgui::SETUP_PANEL( new CAbuseReportDlg( (CHudMainMenuOverride*)pMMOverride, m_pIncidentData ) );
  94. Assert( g_AbuseReportDlg.Get() != NULL );
  95. g_AbuseReportDlg->MakeModal();
  96. }