Counter Strike : Global Offensive Source Code
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.

69 lines
2.5 KiB

  1. //====== Copyright � 1996-2005, Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: Uploads KeyValue stats to the new SteamWorks gamestats system.
  4. //
  5. //=============================================================================
  6. #include "cbase.h"
  7. #include "cdll_int.h"
  8. #include "tier2/tier2.h"
  9. #include <time.h>
  10. #include "gameinterface.h"
  11. #include "steam/isteamutils.h"
  12. #include "steamworks_gamestats_server.h"
  13. #include "icommandline.h"
  14. // NOTE: This has to be the last file included!
  15. #include "tier0/memdbgon.h"
  16. static CSteamWorksGameStatsServer g_SteamWorksGameStatsServer;
  17. extern ConVar developer;
  18. //-----------------------------------------------------------------------------
  19. // Purpose: Returns a reference to the global object
  20. //-----------------------------------------------------------------------------
  21. CSteamWorksGameStatsServer& GetSteamWorksGameStatsServer()
  22. {
  23. return g_SteamWorksGameStatsServer;
  24. }
  25. //-----------------------------------------------------------------------------
  26. // Purpose: Constructor. Sets up the steam callbacks accordingly depending on client/server dll
  27. //-----------------------------------------------------------------------------
  28. CSteamWorksGameStatsServer::CSteamWorksGameStatsServer() : BaseClass( "CSteamWorksGameStatsServer", "steamworks_sessionid_server" )
  29. {
  30. Reset();
  31. }
  32. void CSteamWorksGameStatsServer::AddSessionIDsToTable( int iTableID )
  33. {
  34. // The session of this server.
  35. WriteInt64ToTable( m_SessionID, iTableID, "ServerSessionID" );
  36. }
  37. //-----------------------------------------------------------------------------
  38. // Purpose: Uploads any end of session rows.
  39. //-----------------------------------------------------------------------------
  40. void CSteamWorksGameStatsServer::WriteSessionRow()
  41. {
  42. m_SteamWorksInterface = GetInterface();
  43. if ( !m_SteamWorksInterface )
  44. return;
  45. m_SteamWorksInterface->AddSessionAttributeInt64( m_SessionID, "ServerSessionID", m_SessionID );
  46. m_SteamWorksInterface->AddSessionAttributeString( m_SessionID, "ServerIP", m_pzServerIP );
  47. m_SteamWorksInterface->AddSessionAttributeString( m_SessionID, "ServerName", m_pzHostName );
  48. m_SteamWorksInterface->AddSessionAttributeString( m_SessionID, "StartMap", m_pzMapStart );
  49. BaseClass::WriteSessionRow();
  50. }
  51. //-----------------------------------------------------------
  52. EGameStatsAccountType CSteamWorksGameStatsServer::GetGameStatsAccountType()
  53. {
  54. return engine->IsDedicatedServer() ? k_EGameStatsAccountType_SteamGameServer : k_EGameStatsAccountType_Steam;
  55. }