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.

66 lines
1.9 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. // data_collector.cpp
  9. // Data collection system
  10. // Author: Michael S. Booth, June 2004
  11. #include "cbase.h"
  12. #include "data_collector.h"
  13. static CDataCollector *collector = NULL;
  14. //----------------------------------------------------------------------------------------------------------------------
  15. void StartDataCollection( void )
  16. {
  17. if (collector)
  18. {
  19. // already collecting
  20. return;
  21. }
  22. collector = new CDataCollector;
  23. Msg( "Data colletion started.\n" );
  24. }
  25. ConCommand data_collection_start( "data_collection_start", StartDataCollection, "Start collecting game event data." );
  26. //----------------------------------------------------------------------------------------------------------------------
  27. void StopDataCollection( void )
  28. {
  29. if (collector)
  30. {
  31. delete collector;
  32. collector = NULL;
  33. Msg( "Data collection stopped.\n" );
  34. }
  35. }
  36. ConCommand data_collection_stop( "data_collection_stop", StopDataCollection, "Stop collecting game event data." );
  37. //----------------------------------------------------------------------------------------------------------------------
  38. CDataCollector::CDataCollector( void )
  39. {
  40. // register for all events
  41. gameeventmanager->AddListener( this, true );
  42. }
  43. //----------------------------------------------------------------------------------------------------------------------
  44. CDataCollector::~CDataCollector()
  45. {
  46. gameeventmanager->RemoveListener( this );
  47. }
  48. //----------------------------------------------------------------------------------------------------------------------
  49. /**
  50. * This is invoked for each event that occurs in the game
  51. */
  52. void CDataCollector::FireGameEvent( KeyValues *event )
  53. {
  54. DevMsg( "Collected event '%s'\n", event->GetName() );
  55. }