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