summaryrefslogtreecommitdiff
path: root/game/client/abuse_report.cpp
blob: 285a633b4aa9ca282e311d58927572a81e2ab095 (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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Generic in-game abuse reporting
//
// $NoKeywords: $
//=============================================================================//

#include "cbase.h"
#include "abuse_report.h"
#include "abuse_report_ui.h"
#include "filesystem.h"
#include "imageutils.h"
#include "econ/confirm_dialog.h"
#include "econ/econ_notifications.h"

inline bool IsLoggedOnToSteam()
{
	return steamapicontext != NULL && steamapicontext->SteamUser() != NULL && steamapicontext->SteamUser()->BLoggedOn();
}

const char CAbuseReportManager::k_rchScreenShotFilenameBase[] = "abuse_report";
const char CAbuseReportManager::k_rchScreenShotFilename[] = "screenshots\\abuse_report.jpg";

//-----------------------------------------------------------------------------
class CEconNotification_AbuseReportReady : public CEconNotification
{
public:
	CEconNotification_AbuseReportReady() : CEconNotification()
	{
		m_bHasTriggered = false;
		m_bShowInGame = false;
	}

	~CEconNotification_AbuseReportReady()
	{
		//if ( !m_bHasTriggered )
		//{
		//	ReallyTrigger();
		//}
	}

	virtual void MarkForDeletion()
	{
		m_bHasTriggered = true;

		CEconNotification::MarkForDeletion();
	}

	virtual bool BShowInGameElements() const { return m_bShowInGame; }
	virtual EType NotificationType() { return eType_Trigger; }
	virtual void Trigger()
	{
		ReallyTrigger();
		MarkForDeletion();
	}

	virtual const char *GetUnlocalizedHelpText()
	{
		return "#AbuseReport_Notification_Help";
	}

	static bool IsNotificationType( CEconNotification *pNotification ) { return dynamic_cast< CEconNotification_AbuseReportReady *>( pNotification ) != NULL; }
	static bool IsInGameNotificationType( CEconNotification *pNotification )
	{
		CEconNotification_AbuseReportReady *n = dynamic_cast< CEconNotification_AbuseReportReady *>( pNotification );
		return n != NULL && n->BShowInGameElements();
	}

	bool m_bShowInGame;

private:

	void ReallyTrigger()
	{
		Assert( !m_bHasTriggered );
		m_bHasTriggered = true;
		engine->ClientCmd_Unrestricted( "abuse_report_submit" );
	}

	bool m_bHasTriggered;
};

AbuseIncidentData_t::AbuseIncidentData_t()
{
	m_nScreenShotWaitFrames = 5;
}

AbuseIncidentData_t::~AbuseIncidentData_t()
{
}

bool AbuseIncidentData_t::Poll()
{
	bool bReady = true;

	// Poll player data
	for ( int i = 0 ; i < m_vecPlayers.Count() ; ++i )
	{

		// Make sure sure Steam knows we want the Avatar
		PlayerData_t *p = &m_vecPlayers[i];
		if ( p->m_iSteamAvatarIndex < 0 )
		{
			if ( steamapicontext && steamapicontext->SteamUser() )
			{

				p->m_iSteamAvatarIndex = steamapicontext->SteamFriends()->GetLargeFriendAvatar( p->m_steamID );
				if ( p->m_iSteamAvatarIndex < 0 )
				{
					bReady = false;
				}
			}
			else
			{
				p->m_iSteamAvatarIndex = 0;
			}
		}
	}

	// Screenshot ready?
	if ( !m_bitmapScreenshot.IsValid() && m_nScreenShotWaitFrames > 0 )
	{
		--m_nScreenShotWaitFrames;

		// Just load the whole file into a memory buffer
		char szFullPath[ MAX_PATH ] = "";
		if ( !g_pFullFileSystem->RelativePathToFullPath( CAbuseReportManager::k_rchScreenShotFilename, NULL, szFullPath, ARRAYSIZE(szFullPath) ) )
		{
			Assert( false ); // ???
		}

		// Load it

		if ( g_pFullFileSystem->FileExists( szFullPath ) )
		{

			// Load the screenshot into a local buffer
			if ( !g_pFullFileSystem->ReadFile( CAbuseReportManager::k_rchScreenShotFilename, NULL, m_bufScreenshotFileData ) )
			{
				Warning( "Failed to read back %s\n", CAbuseReportManager::k_rchScreenShotFilename );
				m_nScreenShotWaitFrames = 0;
			}
			else
			{
				ConversionErrorType nErrorCode = ImgUtl_LoadBitmap( szFullPath, m_bitmapScreenshot );
				if ( nErrorCode != CE_SUCCESS )
				{
					Warning( "Abuse report screenshot %s failed to load with error code %d\n", CAbuseReportManager::k_rchScreenShotFilename, nErrorCode );
					Assert( nErrorCode == CE_SUCCESS );
					m_nScreenShotWaitFrames = 0;
				}
				else
				{
					// !KLUDGE! Resize to power of two dimensions, since VGUI doesn't like odd sizes
					ImgUtl_ResizeBitmap( m_bitmapScreenshot, 1024, 1024, &m_bitmapScreenshot );
				}
			}
			g_pFullFileSystem->RemoveFile( CAbuseReportManager::k_rchScreenShotFilename );
		}
	}

	return bReady;
}

CAbuseReportManager *g_AbuseReportMgr;

CAbuseReportManager::CAbuseReportManager()
{
	m_pIncidentData = NULL;
	m_bTestReport = false;
	m_eIncidentDataStatus = k_EIncidentDataStatus_None;
	m_bReportUIPending = false;

	// We're the singleton --- set global pointer
	Assert( g_AbuseReportMgr == NULL );
	g_AbuseReportMgr = this;
	m_timeLastReportReadyNotification = 0.0;
	m_adrCurrentServer.Clear();
}

CAbuseReportManager::~CAbuseReportManager()
{
	Assert( m_pIncidentData == NULL );
}

char const *CAbuseReportManager::Name()
{
	return "AbuseRepotManager";
}

bool CAbuseReportManager::Init()
{
	// Clean out any temporary files
	Assert( m_pIncidentData == NULL );
	DestroyIncidentData();

	ListenForGameEvent( "teamplay_round_win" );
	ListenForGameEvent( "tf_game_over" );
	ListenForGameEvent( "player_death" );
	ListenForGameEvent( "server_spawn" );

	return true;
}

void CAbuseReportManager::LevelShutdownPreEntity()
{

	// Don't keep the dialog open across a level transition.  Don't discard their
	// report data, but let's kill the dialog
	if ( g_AbuseReportDlg.Get() != NULL )
	{
		Warning( "Abuse report dialog open during level shutdown.  Closing it.\n" );
		g_AbuseReportDlg.Get()->Close();
	}

	// And clear the 'pending' flag
	m_bReportUIPending = false;
}

void CAbuseReportManager::FireGameEvent( IGameEvent *event )
{
	//C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();

	const char *eventname = event->GetName();

	if ( !eventname || !eventname[0] )
		return;

	if (
		!Q_strcmp( "teamplay_round_win", eventname )
		|| !Q_strcmp( "tf_game_over", eventname )
	) {
		// Periodically remind them that they have a report ready to file
		CheckCreateReportReadyNotification( 60.0 * 5.0, true, 10.0f );
	}
	else if ( !Q_strcmp( "player_death", eventname ) )
	{
		// In some maps, the round just never ends.
		// So make sure we do remind them every now and then about this.
		// Just not too often
		CheckCreateReportReadyNotification( 60.0 * 20.0, true, 5.0f );
	}
	else if ( !Q_strcmp( "server_spawn", eventname ) )
	{
		m_adrCurrentServer.Clear();
		m_adrCurrentServer.SetFromString( event->GetString( "address", "" ), false );
		m_adrCurrentServer.SetPort( event->GetInt( "port", 0 ) );

		m_steamIDCurrentServer = CSteamID();
		if ( steamapicontext && steamapicontext->SteamUser() && GetUniverse() != k_EUniverseInvalid )
		{
			m_steamIDCurrentServer.SetFromString( event->GetString( "steamid", "" ), GetUniverse() );
		}
	}
}

void CAbuseReportManager::Shutdown()
{
	// Close the dialog, if any
	LevelShutdownPreEntity();

	DestroyIncidentData();

	// Clear global pointer
	Assert( g_AbuseReportMgr == this );
	if ( g_AbuseReportMgr == this )
	{
		g_AbuseReportMgr = NULL;
	}
}

void CAbuseReportManager::Update( float frametime )
{

	// if a dialog is already displayed, make sure we don't try to activate another
	if ( g_AbuseReportDlg.Get() != NULL )
	{
		m_bReportUIPending = false;
	}

	// Poll report data, if any
	if ( m_pIncidentData != NULL )
	{
		if ( m_eIncidentDataStatus == k_EIncidentDataStatus_Preparing )
		{
			if ( m_pIncidentData->Poll() )
			{
				m_eIncidentDataStatus = k_EIncidentDataStatus_Ready;
				CheckCreateReportReadyNotification( 1.0f, true, 7.0f );
			}
		}
		else
		{
			Assert( m_eIncidentDataStatus == k_EIncidentDataStatus_Ready );
		}

		if ( m_eIncidentDataStatus == k_EIncidentDataStatus_Ready && m_bReportUIPending )
		{
			m_bReportUIPending = false;
			ActivateSubmitReportUI();
		}
	}
	else
	{
		m_bReportUIPending = false;
	}

	// Re-create notification constantly in the menu.
	// While in game, we will only popup notifications
	// periodically at round end or player death
	CheckCreateReportReadyNotification( 10.0, false, 999.0f );
}

void CAbuseReportManager::SubmitReportUIRequested()
{
	if ( g_AbuseReportDlg.Get() != NULL )
	{
		Assert( g_AbuseReportDlg.Get() == NULL );
		return;
	}

	// If no report data already, then create some
	if ( m_pIncidentData == NULL )
	{
		QueueReport();
		if ( m_pIncidentData == NULL )
		{
			// Failed
			return;
		}
	}

	// Set flag to bring up the reporting UI at earliest opportunity,
	// once all data has been fetched asynchronously
	m_bReportUIPending = true;
}

bool CAbuseReportManager::CreateAndPopulateIncident()
{
	Assert( m_pIncidentData == NULL );

	// by default, just create the base class version
	m_pIncidentData = new AbuseIncidentData_t;

	// And populate it
	return PopulateIncident();
}

bool CAbuseReportManager::PopulateIncident()
{
	if ( m_pIncidentData == NULL )
	{
		Assert( m_pIncidentData );
		return false;
	}

	// Queue a screenshot
	CUtlString cmd;
	cmd.Format( "__screenshot_internal \"%s\"", k_rchScreenShotFilenameBase );
	engine->ClientCmd_Unrestricted( cmd );

	// Set status as preparing
	m_eIncidentDataStatus = k_EIncidentDataStatus_Preparing;

	m_pIncidentData->m_bCanReportGameServer = false;

	m_pIncidentData->m_adrGameServer.Clear();
	if (
		m_adrCurrentServer.IsValid()
		&& !m_adrCurrentServer.IsLocalhost()
		&& m_steamIDCurrentServer.IsValid()
		&& ( !m_adrCurrentServer.IsReservedAdr() || m_steamIDCurrentServer.GetEUniverse() != k_EUniversePublic )
	)
	{
		m_pIncidentData->m_adrGameServer = m_adrCurrentServer;
		m_pIncidentData->m_steamIDGameServer = m_steamIDCurrentServer;
		m_pIncidentData->m_bCanReportGameServer = true;
	}

	m_pIncidentData->m_matWorldToClip = engine->WorldToScreenMatrix();

	// Add in players
	for (int i = 1 ; i <= gpGlobals->maxClients ; ++i )
	{
		CBasePlayer *player = UTIL_PlayerByIndex( i );

		#ifndef _DEBUG
			// Skip local players
			if ( player != NULL && player->IsLocalPlayer() )
			{
				continue;
			}
		#endif

		// Get player info from the engine.  This works even if they haven't spawned yet.
		player_info_t pi;
		if ( !engine->GetPlayerInfo( i, &pi ) )
		{
			continue;
		}

		if ( pi.fakeplayer )
		{
			continue;
		}
		if ( pi.friendsID == 0 )
		{
			continue;
		}
		CSteamID steamID( pi.friendsID, 1, GetUniverse(), k_EAccountTypeIndividual );
		if ( !steamID.IsValid() )
		{
			Assert( steamID.IsValid() );
			continue;
		}

		int arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail();
		AbuseIncidentData_t::PlayerData_t *p = &m_pIncidentData->m_vecPlayers[ arrayIndex ];

		p->m_iClientIndex = i;
		p->m_steamID = steamID;
		p->m_sPersona = pi.name;
		p->m_bHasEntity = false;
		p->m_bRenderBoundsValid = false;
		p->m_screenBoundsMin.x = p->m_screenBoundsMin.y = 1.0f;
		p->m_screenBoundsMax.x = p->m_screenBoundsMax.y = 0.0f;

		if ( player==NULL )
		{
			continue;
		}

		p->m_bHasEntity = true;
		player->GetRenderBounds( p->m_vecRenderBoundsMin, p->m_vecRenderBoundsMax );
		p->m_matModelToWorld.CopyFrom3x4( player->RenderableToWorldTransform() );
		MatrixMultiply( m_pIncidentData->m_matWorldToClip, p->m_matModelToWorld, p->m_matModelToClip );

		// Gather up screen extents
		p->m_bRenderBoundsValid = false;
		for ( int j = 0 ; j < 8 ; ++j )
		{

			// Get corner point in model space
			Vector4D modelCorner(
				( j & 1 ) ? p->m_vecRenderBoundsMax.x : p->m_vecRenderBoundsMin.x,
				( j & 2 ) ? p->m_vecRenderBoundsMax.y : p->m_vecRenderBoundsMin.y,
				( j & 4 ) ? p->m_vecRenderBoundsMax.z : p->m_vecRenderBoundsMin.z,
				1.0f
			);

			// Transform to clip space
			Vector4D clipCorner;
			Vector4DMultiply( p->m_matModelToClip, modelCorner, clipCorner );

			//Msg( "%6.3f, %6.3f, %6.3f, %6.3f\n", clipCorner[0], clipCorner[1], clipCorner[2], clipCorner[3] );

			// If all points behind near clip plane, don't try to
			// figure out screen space bounds
			if ( clipCorner[3] > .1f )
			{
				p->m_bRenderBoundsValid = true;
			}

			// Push w forward to "near clip plane"
			float w = MAX( clipCorner[3], .1f );

			// Divide by w to project, and convert normalized device coordinates
			// where the view volume is (-1...1), to normalized screen coords, where
			// they are from 0...1
			float x = ( clipCorner[0] / w + 1.0f ) / 2.0f;
			float y = ( -clipCorner[1] / w + 1.0f ) / 2.0f;
			p->m_screenBoundsMin.x = MIN( p->m_screenBoundsMin.x, x );
			p->m_screenBoundsMax.x = MAX( p->m_screenBoundsMax.x, x );
			p->m_screenBoundsMin.y = MIN( p->m_screenBoundsMin.y, y );
			p->m_screenBoundsMax.y = MAX( p->m_screenBoundsMax.y, y );
		}

		// Clip projected rect to the screen
		if ( p->m_bRenderBoundsValid )
		{
			p->m_screenBoundsMin.x = MAX( p->m_screenBoundsMin.x, 0.0f );
			p->m_screenBoundsMax.x = MIN( p->m_screenBoundsMax.x, 1.0f );
			p->m_screenBoundsMin.y = MAX( p->m_screenBoundsMin.y, 0.0f );
			p->m_screenBoundsMax.y = MIN( p->m_screenBoundsMax.y, 1.0f );

			p->m_bRenderBoundsValid =
				p->m_screenBoundsMin.x + .01f < p->m_screenBoundsMax.x
				&& p->m_screenBoundsMin.y + .01f < p->m_screenBoundsMax.y;
		}

		// Sanity check that we agree on what their steam ID is!
		if ( player->GetSteamID( &steamID ) )
		{
			Assert( p->m_steamID == steamID );
		}
	}

	// Test harness: add in a handful of fake players
	#ifdef _DEBUG
		if ( m_bTestReport )
		{
			int arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail();
			AbuseIncidentData_t::PlayerData_t *p = &m_pIncidentData->m_vecPlayers[ arrayIndex ];

			p->m_iClientIndex = -1;
			p->m_sPersona = "Lippencott";
			p->m_steamID.SetFromUint64( 148618791998333672 );

			arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail();
			p = &m_pIncidentData->m_vecPlayers[ arrayIndex ];

			p->m_iClientIndex = -1;
			p->m_sPersona = "EricS";
			p->m_steamID.SetFromUint64( 148618791998195668 );

			arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail();
			p = &m_pIncidentData->m_vecPlayers[ arrayIndex ];

			p->m_iClientIndex = -1;
			p->m_sPersona = "Sarenya";
			p->m_steamID.SetFromUint64( 148618791998429832 );

			arrayIndex = m_pIncidentData->m_vecPlayers.AddToTail();
			p = &m_pIncidentData->m_vecPlayers[ arrayIndex ];
			

			p->m_iClientIndex = -1;
			p->m_sPersona = "fletch";
			p->m_steamID.SetFromUint64( 148618791998436114 );
			{
				AbuseIncidentData_t::PlayerImage_t img;
				img.m_eType = AbuseIncidentData_t::k_PlayerImageType_UGC;
				img.m_hUGCHandle = 6978249415967519;
				p->m_vecImages.AddToTail( img );
			}

			if ( !m_pIncidentData->m_bCanReportGameServer)
			{
				m_pIncidentData->m_adrGameServer.SetFromString( "123.45.67.89:27015", false );
				m_pIncidentData->m_steamIDGameServer = CSteamID( 12345, 0, GetUniverse(), k_EAccountTypeAnonGameServer );
				m_pIncidentData->m_bCanReportGameServer = true;
			}
		}
	#endif

	// Make sure there is at least one other person we could file a report against!
	if ( m_pIncidentData->m_vecPlayers.Count() < 1 )
	{
		Warning( "No players to accuse of abuse, cannot file report\n" );
		return false;
	}

	return true;
}

void CAbuseReportManager::DestroyIncidentData()
{
	if ( m_pIncidentData != NULL )
	{
		delete m_pIncidentData;
		m_pIncidentData = NULL;
	}
	m_eIncidentDataStatus = k_EIncidentDataStatus_None;

	// Get rid of any existing screenshot file, both locally
	// and in the cloud.  We don't want this to count against
	// our quota
	if ( steamapicontext && steamapicontext->SteamRemoteStorage() && steamapicontext->SteamRemoteStorage()->FileExists( k_rchScreenShotFilename ) )
	{
		steamapicontext->SteamRemoteStorage()->FileDelete( k_rchScreenShotFilename );
	}

	if ( g_pFullFileSystem->FileExists( k_rchScreenShotFilename ) ) // !KLUDGE! To prevent warning if the file doesn't exist!
	{
		g_pFullFileSystem->RemoveFile( k_rchScreenShotFilename );
	}

	m_timeLastReportReadyNotification = 0.0;

	// Make sure we don't have any notifications queued
	NotificationQueue_Remove( &CEconNotification_AbuseReportReady::IsNotificationType );
}

void CAbuseReportManager::QueueReport()
{
	// Dialog is already active?
	if ( g_AbuseReportDlg.Get() != NULL )
	{
		Warning( "Cannot capture another incident report.  Submission dialog is active.\n" );
		return;
	}

	// Destroy any existing data
	DestroyIncidentData();

	// Make sure we're logged on to Steam
	if ( !IsLoggedOnToSteam() )
	{
		g_AbuseReportMgr->ShowNoSteamErrorMessage();
		return;
	}

	if ( CreateAndPopulateIncident() )
	{
		Msg( "Captured data for abuse report.\n");
	}
	else
	{
		Warning( "Failed to captured data for abuse report.\n");
		DestroyIncidentData();
	}
}

void CAbuseReportManager::ShowNoSteamErrorMessage()
{
	ShowMessageBox( "#AbuseReport_NoSteamTitle", "#AbuseReport_NoSteamMessage", "#GameUI_OK" );
}

void CAbuseReportManager::CheckCreateReportReadyNotification( float flMinSecondsSinceLastNotification, bool bInGame, float flLifetime )
{
	// We have to have some data ready
	if ( m_pIncidentData == NULL || m_eIncidentDataStatus != k_EIncidentDataStatus_Ready )
	{
		return;
	}

	// Don't pester them if they are already trying to do something about it
	if ( g_AbuseReportDlg.Get() != NULL || m_bReportUIPending )
	{
		return;
	}

	// Already notified them too recently?
	if ( m_timeLastReportReadyNotification != 0.0 && Plat_FloatTime() < m_timeLastReportReadyNotification + flMinSecondsSinceLastNotification )
	{
		return;
	}

	// Already a notification in the queue?
	if ( bInGame )
	{
		if ( NotificationQueue_Count( &CEconNotification_AbuseReportReady::IsInGameNotificationType ) > 0 )
		{
			return;
		}
	}
	else
	{
		if ( NotificationQueue_Count( &CEconNotification_AbuseReportReady::IsNotificationType ) > 0 )
		{
			return;
		}
	}

	CreateReportReadyNotification( bInGame, flLifetime );
}

void CAbuseReportManager::CreateReportReadyNotification( bool bInGame, float flLifetime )
{
	NotificationQueue_Remove( &CEconNotification_AbuseReportReady::IsNotificationType );
	CEconNotification_AbuseReportReady *pNotification = new CEconNotification_AbuseReportReady();
	pNotification->SetText( "AbuseReport_Notification" );
	pNotification->SetLifetime( flLifetime );
	pNotification->m_bShowInGame = bInGame;
	NotificationQueue_Add( pNotification );

	m_timeLastReportReadyNotification = Plat_FloatTime();
}

CON_COMMAND_F( abuse_report_queue, "Capture data for abuse report and queue for submission.  Use abose_report_submit to activate UI to submit the report", FCVAR_DONTRECORD )
{
	if ( !g_AbuseReportMgr )
	{
		Warning( "abuse_report_queue: No abuse report manager, cannot create report.\n" );
		return;
	}

	g_AbuseReportMgr->QueueReport();
}

CON_COMMAND_F( abuse_report_submit, "Activate UI to submit queued report.  Use abuse_report_queue to capture data for the report the report", FCVAR_DONTRECORD )
{
	if ( !g_AbuseReportMgr )
	{
		Warning( "abuse_report_submit: No abuse report manager, cannot submit report.\n" );
		return;
	}

	// Make sure we're logged on to Steam
	if ( !IsLoggedOnToSteam() )
	{
		g_AbuseReportMgr->ShowNoSteamErrorMessage();
		return;
	}

	if ( g_AbuseReportDlg.Get() != NULL )
	{
		// Dialog is already active
		return;
	}
	g_AbuseReportMgr->SubmitReportUIRequested();
}

// Test harness
#ifdef _DEBUG

CON_COMMAND_F( abuse_report_test, "Make a test abuse incident and activate UI", FCVAR_DONTRECORD )
{
	if ( !g_AbuseReportMgr )
	{
		Assert( g_AbuseReportMgr );
		return;
	}
	g_AbuseReportMgr->m_bTestReport = true;
	g_AbuseReportMgr->QueueReport();
	g_AbuseReportMgr->m_bTestReport = false;
	engine->ClientCmd_Unrestricted( "abuse_report_submit" );
}

#endif