summaryrefslogtreecommitdiff
path: root/game/client/tf/tf_abuse_report.cpp
blob: b843d6baff591556aad9992dade85c93dd646434 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Generic in-game abuse reporting
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "tf_abuse_report.h"
#include "abuse_report_ui.h"
#include "game/client/iviewport.h"
#include "tf_shareddefs.h"
#include "tf_hud_mainmenuoverride.h"
#include "tf_gcmessages.h"
#include "c_tf_player.h"
#include "tf_quickplay_shared.h"
#include "tf_gc_client.h"

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"


/// Declare singleton object
CTFAbuseReportManager theAbuseReportManager;

CTFAbuseReportManager::CTFAbuseReportManager() {}
CTFAbuseReportManager::~CTFAbuseReportManager() {}

bool CTFAbuseReportManager::CreateAndPopulateIncident()
{
	if ( !CAbuseReportManager::CreateAndPopulateIncident() )
	{
		return false;
	}

	if ( m_bTestReport )
	{
		return true;
	}

	for ( int iPlayer = 0 ; iPlayer < m_pIncidentData->m_vecPlayers.Count() ; ++iPlayer )
	{

		AbuseIncidentData_t::PlayerData_t *p = &m_pIncidentData->m_vecPlayers[iPlayer];

		CPlayerInventory *pInv = InventoryManager()->GetInventoryForAccount( p->m_steamID.GetAccountID() );
		//C_TFPlayer *pTFPlayer = dynamic_cast<C_TFPlayer *> ( UTIL_PlayerByIndex( p->m_iClientIndex ) );
		//if ( pTFPlayer == NULL )
		//{
		//	Assert( !p->m_bHasEntity );
		//	continue;
		//}
		//CTFPlayerInventory *pInv = pTFPlayer->Inventory();
		if ( pInv == NULL )
		{
			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() );
			continue;
		}

		for ( int i = 0 ; i < pInv->GetItemCount() ; ++i)
		{
			CEconItemView *pItem = pInv->GetItem( i );

			// Get custom texture ID, if any
			uint64 hCustomtextureID = pItem->GetCustomUserTextureID();

			// Most items won't have a custom texture
			if ( hCustomtextureID == 0 )
			{
				continue;
			}

			// Discard duplicates, as it makes the UI confusing
			bool bDup = false;
			for ( int j = 0 ; j < p->m_vecImages.Count() ; ++j )
			{
				if ( p->m_vecImages[ j ].m_hUGCHandle == hCustomtextureID )
				{
					bDup = true;
					break;
				}
			}
			if ( bDup )
			{
				continue;
			}

			AbuseIncidentData_t::PlayerImage_t img;
			img.m_eType = AbuseIncidentData_t::k_PlayerImageType_UGC;
			img.m_hUGCHandle = hCustomtextureID;
			p->m_vecImages.AddToTail( img );
		}
	}

	// Check if we can report abuse against the game server.
	if (m_pIncidentData->m_adrGameServer.IsValid() &&
	    !GTFGCClientSystem()->BIsIPRecentMatchServer( m_pIncidentData->m_adrGameServer ) )
	{
		m_pIncidentData->m_bCanReportGameServer = true;
	}

	return true;
}

void CTFAbuseReportManager::ActivateSubmitReportUI()
{
	Assert( g_AbuseReportDlg.Get() == NULL );
	Assert( m_pIncidentData != NULL );

	IViewPortPanel *pMMOverride = ( gViewPortInterface->FindPanelByName( PANEL_MAINMENUOVERRIDE ) );
	engine->ExecuteClientCmd("gameui_activate");
	vgui::SETUP_PANEL( new CAbuseReportDlg( (CHudMainMenuOverride*)pMMOverride, m_pIncidentData ) );
	Assert( g_AbuseReportDlg.Get() != NULL );
	g_AbuseReportDlg->MakeModal();
}