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.

101 lines
4.3 KiB

  1. //====== Copyright � Valve Corporation, All rights reserved. =======
  2. //
  3. // Purpose: interface for game servers to steam stats and achievements
  4. //
  5. //=============================================================================
  6. #ifndef ISTEAMGAMESERVERSTATS_H
  7. #define ISTEAMGAMESERVERSTATS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "isteamclient.h"
  12. //-----------------------------------------------------------------------------
  13. // Purpose: Functions for authenticating users via Steam to play on a game server
  14. //-----------------------------------------------------------------------------
  15. class ISteamGameServerStats
  16. {
  17. public:
  18. // downloads stats for the user
  19. // returns a GSStatsReceived_t callback when completed
  20. // if the user has no stats, GSStatsReceived_t.m_eResult will be set to k_EResultFail
  21. // these stats will only be auto-updated for clients playing on the server. For other
  22. // users you'll need to call RequestUserStats() again to refresh any data
  23. CALL_RESULT( GSStatsReceived_t )
  24. virtual SteamAPICall_t RequestUserStats( CSteamID steamIDUser ) = 0;
  25. // requests stat information for a user, usable after a successful call to RequestUserStats()
  26. virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, int32 *pData ) = 0;
  27. virtual bool GetUserStat( CSteamID steamIDUser, const char *pchName, float *pData ) = 0;
  28. virtual bool GetUserAchievement( CSteamID steamIDUser, const char *pchName, bool *pbAchieved ) = 0;
  29. // Set / update stats and achievements.
  30. // Note: These updates will work only on stats game servers are allowed to edit and only for
  31. // game servers that have been declared as officially controlled by the game creators.
  32. // Set the IP range of your official servers on the Steamworks page
  33. virtual bool SetUserStat( CSteamID steamIDUser, const char *pchName, int32 nData ) = 0;
  34. virtual bool SetUserStat( CSteamID steamIDUser, const char *pchName, float fData ) = 0;
  35. virtual bool UpdateUserAvgRateStat( CSteamID steamIDUser, const char *pchName, float flCountThisSession, double dSessionLength ) = 0;
  36. virtual bool SetUserAchievement( CSteamID steamIDUser, const char *pchName ) = 0;
  37. virtual bool ClearUserAchievement( CSteamID steamIDUser, const char *pchName ) = 0;
  38. // Store the current data on the server, will get a GSStatsStored_t callback when set.
  39. //
  40. // If the callback has a result of k_EResultInvalidParam, one or more stats
  41. // uploaded has been rejected, either because they broke constraints
  42. // or were out of date. In this case the server sends back updated values.
  43. // The stats should be re-iterated to keep in sync.
  44. CALL_RESULT( GSStatsStored_t )
  45. virtual SteamAPICall_t StoreUserStats( CSteamID steamIDUser ) = 0;
  46. };
  47. #define STEAMGAMESERVERSTATS_INTERFACE_VERSION "SteamGameServerStats001"
  48. // callbacks
  49. #if defined( VALVE_CALLBACK_PACK_SMALL )
  50. #pragma pack( push, 4 )
  51. #elif defined( VALVE_CALLBACK_PACK_LARGE )
  52. #pragma pack( push, 8 )
  53. #else
  54. #error isteamclient.h must be included
  55. #endif
  56. //-----------------------------------------------------------------------------
  57. // Purpose: called when the latests stats and achievements have been received
  58. // from the server
  59. //-----------------------------------------------------------------------------
  60. struct GSStatsReceived_t
  61. {
  62. enum { k_iCallback = k_iSteamGameServerStatsCallbacks };
  63. EResult m_eResult; // Success / error fetching the stats
  64. CSteamID m_steamIDUser; // The user for whom the stats are retrieved for
  65. };
  66. //-----------------------------------------------------------------------------
  67. // Purpose: result of a request to store the user stats for a game
  68. //-----------------------------------------------------------------------------
  69. struct GSStatsStored_t
  70. {
  71. enum { k_iCallback = k_iSteamGameServerStatsCallbacks + 1 };
  72. EResult m_eResult; // success / error
  73. CSteamID m_steamIDUser; // The user for whom the stats were stored
  74. };
  75. //-----------------------------------------------------------------------------
  76. // Purpose: Callback indicating that a user's stats have been unloaded.
  77. // Call RequestUserStats again to access stats for this user
  78. //-----------------------------------------------------------------------------
  79. struct GSStatsUnloaded_t
  80. {
  81. enum { k_iCallback = k_iSteamUserStatsCallbacks + 8 };
  82. CSteamID m_steamIDUser; // User whose stats have been unloaded
  83. };
  84. #pragma pack( pop )
  85. #endif // ISTEAMGAMESERVERSTATS_H